@economic/taco 2.48.4 → 2.49.0-dataloader.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Report/Report.d.ts +1 -1
- package/dist/components/SearchInput2/SearchInput2.d.ts +2 -0
- package/dist/components/Table3/features/useEditingState.d.ts +13 -13
- package/dist/components/Table3/features/useTableEditing.d.ts +15 -15
- package/dist/components/Table3/types.d.ts +2 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js +1 -0
- package/dist/esm/packages/taco/src/charts/components/Donut/Legend.js.map +1 -1
- package/dist/esm/packages/taco/src/charts/components/Legend.js +1 -0
- package/dist/esm/packages/taco/src/charts/components/Legend.js.map +1 -1
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js +6 -3
- package/dist/esm/packages/taco/src/components/SearchInput2/SearchInput2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table/hooks/plugins/useRowActions.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +15 -9
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Row/Editing/CreateNewRow.js +4 -2
- 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 +3 -2
- 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 +61 -69
- 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 +13 -6
- 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 +15 -12
- package/dist/esm/packages/taco/src/components/Table3/listeners/useTableEditingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js +1 -1
- package/dist/esm/packages/taco/src/components/Table3/useTable3.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -0
- package/dist/esm/packages/taco/src/index.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +7 -4
- 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/Footer/Summary.js +7 -6
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Footer/Summary.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js +24 -22
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/Row.js +41 -4
- 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/Toolbar/components/Print/Print.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Print/Print.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js +26 -3
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Search/Search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js +2 -2
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js +40 -13
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableRenderer.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/useTable.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js +13 -12
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js +223 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader2.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableRowActive.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js +3 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableSearch.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js +8 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFilterListener.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFilterListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js +4 -4
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableRowSelectionListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +14 -13
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js +7 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +3 -3
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js +4 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/columns.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +8 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/hooks/useLazyDebouncedEffect.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.d.ts +2 -2
- package/dist/primitives/Table/Core/components/Row/Row.d.ts +2 -0
- package/dist/primitives/Table/Core/features/useTableRenderer.d.ts +1 -1
- package/dist/primitives/Table/types.d.ts +10 -6
- package/dist/primitives/Table/useTableDataLoader.d.ts +2 -2
- package/dist/primitives/Table/useTableDataLoader2.d.ts +23 -0
- package/dist/primitives/Table/useTableManager/features/useTableSearch.d.ts +4 -2
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.d.ts +4 -1
- package/dist/primitives/Table/useTableManager/listeners/useTableSearchListener.d.ts +1 -2
- package/dist/primitives/Table/useTableManager/util/columns.d.ts +2 -1
- package/dist/taco.cjs.development.js +577 -233
- 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":"Summary.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Footer/Summary.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../../components/Provider/Localization';\n\nexport type FooterSummaryProps<TType = unknown> = {\n table: ReactTable<TType>;\n};\n\nexport function Summary<TType = unknown>(props: FooterSummaryProps<TType>) {\n const { table } = props;\n const { locale, texts } = useLocalization();\n const
|
1
|
+
{"version":3,"file":"Summary.js","sources":["../../../../../../../../../../src/primitives/Table/Core/components/Footer/Summary.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../../components/Provider/Localization';\n\nexport type FooterSummaryProps<TType = unknown> = {\n table: ReactTable<TType>;\n};\n\nexport function Summary<TType = unknown>(props: FooterSummaryProps<TType>) {\n const { table } = props;\n const { locale, texts } = useLocalization();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const length = tableMeta.length;\n const currentLength = table.getRowModel().rows.length;\n\n let label;\n let count;\n\n // row selection\n // use table state and not the selected row model because of the way server loading works\n const rowsSelectedLength = Object.keys(table.getState().rowSelection).length;\n\n if (rowsSelectedLength > 0) {\n label = texts.table.footer.summary.selected;\n count = (\n <>\n <strong>{new Intl.NumberFormat(locale).format(rowsSelectedLength)}</strong> \n {texts.table.footer.summary.count} \n <strong>{new Intl.NumberFormat(locale).format(length)}</strong>\n </>\n );\n } else if (\n !tableMeta.server.isEnabled &&\n (table.getState().columnFilters?.length || // filtered data\n (!!table.getState().globalFilter && table.options.enableGlobalFilter))\n ) {\n label = texts.table.footer.summary.records;\n count = (\n <>\n <strong>{new Intl.NumberFormat(locale).format(currentLength)}</strong> \n {texts.table.footer.summary.count} \n <strong>{new Intl.NumberFormat(locale).format(length)}</strong>\n </>\n );\n } else {\n label = texts.table.footer.summary.records;\n count = <strong>{new Intl.NumberFormat(locale).format(length)}</strong>;\n }\n\n return (\n <div\n className=\"sticky left-0 z-20 flex h-full w-fit items-center whitespace-nowrap bg-white pr-1 shadow-[12px_0px_6px_white]\"\n data-taco=\"table-footer-summary\">\n {label} {count}\n </div>\n );\n}\n"],"names":["Summary","props","table","locale","texts","useLocalization","tableMeta","options","meta","length","currentLength","getRowModel","rows","label","count","rowsSelectedLength","Object","keys","getState","rowSelection","footer","summary","selected","React","Intl","NumberFormat","format","server","isEnabled","_table$getState$colum","columnFilters","globalFilter","enableGlobalFilter","records","className"],"mappings":";;;SAQgBA,OAAOA,CAAkBC,KAAgC;;EACrE,MAAM;IAAE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AAY,CAACtB,MAAM,CAAC,CAACuB,MAAM,CAAChB,aAAa,CAAC,CAAU,YACrEN,KAAK,CAACF,KAAK,CAACkB,MAAM,CAACC,OAAO,CAACP,KAAK,yBACjCS,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACtB,MAAM,CAAC,CAACuB,MAAM,CAACjB,MAAM,CAAC,CAAU,CAEtE;GACJ,MAAM;IACHI,KAAK,GAAGT,KAAK,CAACF,KAAK,CAACkB,MAAM,CAACC,OAAO,CAACY,OAAO;IAC1CnB,KAAK,gBAAGS,6CAAS,IAAIC,IAAI,CAACC,YAAY,CAACtB,MAAM,CAAC,CAACuB,MAAM,CAACjB,MAAM,CAAC,CAAU;;EAG3E,oBACIc;IACIW,SAAS,EAAC,+GAA+G;iBAC/G;KACTrB,KAAK,YAAQC,KAAK,CACjB;AAEd;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js
CHANGED
@@ -1,57 +1,59 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
-
import {
|
2
|
+
import { getHiddenColumns } from '../../../../useTableManager/util/columns.js';
|
3
3
|
|
4
|
+
const DELAY_BEFORE_LOAD_MS = 150;
|
4
5
|
function SkeletonRow(props) {
|
5
6
|
const {
|
6
7
|
index,
|
7
|
-
row,
|
8
8
|
table
|
9
9
|
} = props;
|
10
10
|
const tableMeta = table.options.meta;
|
11
11
|
if (tableMeta.server.isEnabled) {
|
12
|
-
return /*#__PURE__*/React__default.createElement(RowWithServerLoading, Object.assign({}, props
|
13
|
-
index: index
|
14
|
-
}));
|
12
|
+
return /*#__PURE__*/React__default.createElement(RowWithServerLoading, Object.assign({}, props));
|
15
13
|
}
|
16
14
|
return /*#__PURE__*/React__default.createElement(Skeleton, {
|
17
|
-
cellsCount:
|
15
|
+
cellsCount: table.getVisibleFlatColumns().length,
|
16
|
+
index: index
|
18
17
|
});
|
19
18
|
}
|
20
19
|
function RowWithServerLoading(props) {
|
21
20
|
var _table$getState$group, _table$getState;
|
22
21
|
const {
|
23
22
|
index,
|
24
|
-
row,
|
25
23
|
table
|
26
24
|
} = props;
|
27
25
|
const tableMeta = table.options.meta;
|
28
26
|
const pageIndex = Math.floor(index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
|
29
|
-
const {
|
30
|
-
ref,
|
31
|
-
inView
|
32
|
-
} = useInView({
|
33
|
-
threshold: 0,
|
34
|
-
triggerOnce: true,
|
35
|
-
initialInView: pageIndex === 0
|
36
|
-
});
|
37
27
|
React__default.useEffect(() => {
|
38
|
-
|
39
|
-
|
40
|
-
|
28
|
+
let timeout;
|
29
|
+
if (tableMeta.server.isEnabled) {
|
30
|
+
const sorting = props.table.getState().sorting;
|
31
|
+
const filters = props.table.getState().columnFilters;
|
32
|
+
const search = props.table.getState().globalFilter;
|
33
|
+
const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);
|
34
|
+
timeout = setTimeout(() => {
|
35
|
+
var _tableMeta$server$loa, _tableMeta$server;
|
36
|
+
(_tableMeta$server$loa = (_tableMeta$server = tableMeta.server).loadPage) === null || _tableMeta$server$loa === void 0 ? void 0 : _tableMeta$server$loa.call(_tableMeta$server, pageIndex, sorting, filters, hiddenColumns, tableMeta.search.enableGlobalFilter ? search : undefined);
|
37
|
+
}, DELAY_BEFORE_LOAD_MS);
|
41
38
|
}
|
42
|
-
|
39
|
+
return () => {
|
40
|
+
clearTimeout(timeout);
|
41
|
+
};
|
42
|
+
}, []);
|
43
43
|
const groupedCellCount = (_table$getState$group = (_table$getState = table.getState()) === null || _table$getState === void 0 ? void 0 : _table$getState.grouping.length) !== null && _table$getState$group !== void 0 ? _table$getState$group : 0;
|
44
|
-
const ungroupedCellCount =
|
44
|
+
const ungroupedCellCount = table.getVisibleFlatColumns().length - groupedCellCount;
|
45
45
|
return /*#__PURE__*/React__default.createElement(Skeleton, {
|
46
46
|
cellsCount: ungroupedCellCount,
|
47
|
-
|
47
|
+
index: index
|
48
48
|
});
|
49
49
|
}
|
50
50
|
const Skeleton = /*#__PURE__*/React__default.forwardRef(function Skeleton(props, ref) {
|
51
51
|
const {
|
52
|
-
cellsCount
|
52
|
+
cellsCount,
|
53
|
+
index
|
53
54
|
} = props;
|
54
55
|
return /*#__PURE__*/React__default.createElement("tr", {
|
56
|
+
"data-row-index": index,
|
55
57
|
ref: ref
|
56
58
|
}, Array(cellsCount).fill(null).map((_, index) => (/*#__PURE__*/React__default.createElement("td", {
|
57
59
|
key: index
|
package/dist/esm/packages/taco/src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"SkeletonRow.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta
|
1
|
+
{"version":3,"file":"SkeletonRow.js","sources":["../../../../../../../../../../../src/primitives/Table/Core/components/Row/BuiltIns/SkeletonRow.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { getHiddenColumns } from '../../../../useTableManager/util/columns';\n\nconst DELAY_BEFORE_LOAD_MS = 150;\n\nexport type RowProps<TType = unknown> = {\n index: number;\n scrollDirection: 'forward' | 'backward' | undefined;\n table: ReactTable<TType>;\n};\n\nexport function SkeletonRow<TType = unknown>(props: RowProps<TType>) {\n const { index, table } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n\n if (tableMeta.server.isEnabled) {\n return <RowWithServerLoading {...props} />;\n }\n\n return <Skeleton cellsCount={table.getVisibleFlatColumns().length} index={index} />;\n}\n\nfunction RowWithServerLoading<TType = unknown>(props: RowProps<TType>) {\n const { index, table } = props;\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const pageIndex = (Math.floor(index / tableMeta.server.pageSize) * tableMeta.server.pageSize) / tableMeta.server.pageSize;\n\n React.useEffect(() => {\n let timeout;\n\n if (tableMeta.server.isEnabled) {\n const sorting = props.table.getState().sorting;\n const filters = props.table.getState().columnFilters;\n const search = props.table.getState().globalFilter;\n const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);\n\n timeout = setTimeout(() => {\n tableMeta.server.loadPage?.(\n pageIndex,\n sorting,\n filters,\n hiddenColumns,\n tableMeta.search.enableGlobalFilter ? search : undefined\n );\n }, DELAY_BEFORE_LOAD_MS);\n }\n\n return () => {\n clearTimeout(timeout);\n };\n }, []);\n\n const groupedCellCount = table.getState()?.grouping.length ?? 0;\n const ungroupedCellCount = table.getVisibleFlatColumns().length - groupedCellCount;\n\n return <Skeleton cellsCount={ungroupedCellCount} index={index} />;\n}\n\nconst Skeleton = React.forwardRef(function Skeleton(\n props: { cellsCount: number; index: number },\n ref: React.Ref<HTMLTableRowElement>\n) {\n const { cellsCount, index } = props;\n\n return (\n <tr data-row-index={index} ref={ref}>\n {Array(cellsCount)\n .fill(null)\n .map((_, index) => (\n <td key={index}>\n <span className=\"bg-grey-100 text-grey-700 h-4 w-full text-center text-xs\" />\n </td>\n ))}\n </tr>\n );\n});\n"],"names":["DELAY_BEFORE_LOAD_MS","SkeletonRow","props","index","table","tableMeta","options","meta","server","isEnabled","React","RowWithServerLoading","Skeleton","cellsCount","getVisibleFlatColumns","length","pageIndex","Math","floor","pageSize","useEffect","timeout","sorting","getState","filters","columnFilters","search","globalFilter","hiddenColumns","getHiddenColumns","columnVisibility","setTimeout","_tableMeta$server$loa","_tableMeta$server","loadPage","call","enableGlobalFilter","undefined","clearTimeout","groupedCellCount","_table$getState$group","_table$getState","grouping","ungroupedCellCount","forwardRef","ref","Array","fill","map","_","key","className"],"mappings":";;;AAIA,MAAMA,oBAAoB,GAAG,GAAG;SAQhBC,WAAWA,CAAkBC,KAAsB;EAC/D,MAAM;IAAEC,KAAK;IAAEC;GAAO,GAAGF,KAAK;EAC9B,MAAMG,SAAS,GAAGD,KAAK,CAACE,OAAO,CAACC,IAA6B;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B,MAAM,CAACU,kBAAkB,GAAGV,MAAM,GAAGW,SAAS,CAC3D;OACJ,EAAErC,oBAAoB,CAAC;;IAG5B,OAAO;MACHsC,YAAY,CAACjB,OAAO,CAAC;KACxB;GACJ,EAAE,EAAE,CAAC;EAEN,MAAMkB,gBAAgB,IAAAC,qBAAA,IAAAC,eAAA,GAAGrC,KAAK,CAACmB,QAAQ,EAAE,cAAAkB,eAAA,uBAAhBA,eAAA,CAAkBC,QAAQ,CAAC3B,MAAM,cAAAyB,qBAAA,cAAAA,qBAAA,GAAI,CAAC;EAC/D,MAAMG,kBAAkB,GAAGvC,KAAK,CAACU,qBAAqB,EAAE,CAACC,MAAM,GAAGwB,gBAAgB;EAElF,oBAAO7B,6BAACE,QAAQ;IAACC,UAAU,EAAE8B,kBAAkB;IAAExC,KAAK,EAAEA;IAAS;AACrE;AAEA,MAAMS,QAAQ,gBAAGF,cAAK,CAACkC,UAAU,CAAC,SAAShC,QAAQA,CAC/CV,KAA4C,EAC5C2C,GAAmC;EAEnC,MAAM;IAAEhC,UAAU;IAAEV;GAAO,GAAGD,KAAK;EAEnC,oBACIQ;sBAAoBP,KAAK;IAAE0C,GAAG,EAAEA;KAC3BC,KAAK,CAACjC,UAAU,CAAC,CACbkC,IAAI,CAAC,IAAI,CAAC,CACVC,GAAG,CAAC,CAACC,CAAC,EAAE9C,KAAK,mBACVO;IAAIwC,GAAG,EAAE/C;kBACLO;IAAMyC,SAAS,EAAC;IAA6D,CAC5E,CACR,CAAC,CACL;AAEb,CAAC,CAAC;;;;"}
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import React__default from 'react';
|
2
|
-
import {
|
2
|
+
import { getHiddenColumns } from '../../../useTableManager/util/columns.js';
|
3
3
|
import { RowContext } from './RowContext.js';
|
4
4
|
|
5
|
+
const DELAY_BEFORE_LOAD_MS = 250;
|
5
6
|
/* anonymous functions will break the memoisation on each render, wrap handlers in callbacks */
|
6
7
|
function Row(props) {
|
7
8
|
const {
|
@@ -9,6 +10,8 @@ function Row(props) {
|
|
9
10
|
cellRenderer: CellRenderer,
|
10
11
|
hideInternalColumns = false,
|
11
12
|
hideRowActions = false,
|
13
|
+
scrollDirection,
|
14
|
+
skipPageLoading = false,
|
12
15
|
...displayRowProps
|
13
16
|
} = props;
|
14
17
|
const tableMeta = props.table.options.meta;
|
@@ -20,9 +23,43 @@ function Row(props) {
|
|
20
23
|
hideInternalColumns,
|
21
24
|
hideRowActions
|
22
25
|
}), [isHovered, props.index, hideInternalColumns, hideRowActions]);
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
React__default.useEffect(() => {
|
27
|
+
let timeout;
|
28
|
+
if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 && !skipPageLoading) {
|
29
|
+
const pageIndex = Math.floor(props.index / tableMeta.server.pageSize) * tableMeta.server.pageSize / tableMeta.server.pageSize;
|
30
|
+
const sorting = props.table.getState().sorting;
|
31
|
+
const filters = props.table.getState().columnFilters;
|
32
|
+
const search = props.table.getState().globalFilter;
|
33
|
+
const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);
|
34
|
+
const pageIndexesToFetch = [];
|
35
|
+
// if there's no direction, it means the scroll bar got dropped un unloaded pages,
|
36
|
+
// in that case, load forward and backward pages to prevent skeletons
|
37
|
+
if (scrollDirection === 'backward' || !scrollDirection) {
|
38
|
+
const backIndex = pageIndex - 1;
|
39
|
+
if (backIndex > -1) {
|
40
|
+
pageIndexesToFetch.push(backIndex);
|
41
|
+
}
|
42
|
+
}
|
43
|
+
// always load the next page
|
44
|
+
if ((scrollDirection === 'forward' || !scrollDirection) && pageIndex + 2 < tableMeta.server.pageCount) {
|
45
|
+
pageIndexesToFetch.push(pageIndex + 1);
|
46
|
+
}
|
47
|
+
if (pageIndexesToFetch.length) {
|
48
|
+
// the virtualiser fetches a page ahead, so this won't get called in most cases
|
49
|
+
// but it provides a fallback for some edge cases
|
50
|
+
timeout = setTimeout(() => {
|
51
|
+
pageIndexesToFetch.forEach(index => {
|
52
|
+
var _tableMeta$server$loa, _tableMeta$server;
|
53
|
+
// this can be called by every row within the current page, but loadPage returns early if a pending request exists
|
54
|
+
(_tableMeta$server$loa = (_tableMeta$server = tableMeta.server).loadPage) === null || _tableMeta$server$loa === void 0 ? void 0 : _tableMeta$server$loa.call(_tableMeta$server, index, sorting, filters, hiddenColumns, tableMeta.search.enableGlobalFilter ? search : undefined);
|
55
|
+
});
|
56
|
+
}, DELAY_BEFORE_LOAD_MS);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
return () => {
|
60
|
+
clearTimeout(timeout);
|
61
|
+
};
|
62
|
+
}, [tableMeta.server.pages]);
|
26
63
|
return /*#__PURE__*/React__default.createElement(RowContext.Provider, {
|
27
64
|
value: contextValue
|
28
65
|
}, /*#__PURE__*/React__default.createElement(RowRenderer, Object.assign({}, displayRowProps, {
|
@@ -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 {
|
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 { RowContext } from './RowContext';\nimport { TableRowRenderer, TableRowRendererProps } from '../../types';\nimport { getHiddenColumns } from '../../../useTableManager/util/columns';\n\nconst DELAY_BEFORE_LOAD_MS = 250;\n\nexport type RowProps<TType = unknown> = React.HTMLAttributes<HTMLTableRowElement> &\n TableRowRendererProps<TType> & {\n renderer: TableRowRenderer<TType>;\n scrollDirection?: 'forward' | 'backward';\n skipPageLoading?: boolean;\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 scrollDirection,\n skipPageLoading = 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 React.useEffect(() => {\n let timeout;\n\n if (tableMeta.server.isEnabled && tableMeta.server._experimentalDataLoader2 && !skipPageLoading) {\n const pageIndex =\n (Math.floor(props.index / tableMeta.server.pageSize) * tableMeta.server.pageSize) / tableMeta.server.pageSize;\n\n const sorting = props.table.getState().sorting;\n const filters = props.table.getState().columnFilters;\n const search = props.table.getState().globalFilter;\n const hiddenColumns = getHiddenColumns(props.table.getState().columnVisibility);\n\n const pageIndexesToFetch: number[] = [];\n\n // if there's no direction, it means the scroll bar got dropped un unloaded pages,\n // in that case, load forward and backward pages to prevent skeletons\n if (scrollDirection === 'backward' || !scrollDirection) {\n const backIndex = pageIndex - 1;\n\n if (backIndex > -1) {\n pageIndexesToFetch.push(backIndex);\n }\n }\n\n // always load the next page\n if ((scrollDirection === 'forward' || !scrollDirection) && pageIndex + 2 < tableMeta.server.pageCount) {\n pageIndexesToFetch.push(pageIndex + 1);\n }\n\n if (pageIndexesToFetch.length) {\n // the virtualiser fetches a page ahead, so this won't get called in most cases\n // but it provides a fallback for some edge cases\n timeout = setTimeout(() => {\n pageIndexesToFetch.forEach(index => {\n // this can be called by every row within the current page, but loadPage returns early if a pending request exists\n tableMeta.server.loadPage?.(\n index,\n sorting,\n filters,\n hiddenColumns,\n tableMeta.search.enableGlobalFilter ? search : undefined\n );\n });\n }, DELAY_BEFORE_LOAD_MS);\n }\n }\n\n return () => {\n clearTimeout(timeout);\n };\n }, [tableMeta.server.pages]);\n\n return (\n <RowContext.Provider value={contextValue}>\n <RowRenderer<TType> {...displayRowProps} cellRenderer={CellRenderer} />\n </RowContext.Provider>\n );\n}\n"],"names":["DELAY_BEFORE_LOAD_MS","Row","props","renderer","RowRenderer","cellRenderer","CellRenderer","hideInternalColumns","hideRowActions","scrollDirection","skipPageLoading","displayRowProps","tableMeta","table","options","meta","isHovered","rowActive","rowHoverIndex","index","contextValue","React","useMemo","rowIndex","useEffect","timeout","server","isEnabled","_experimentalDataLoader2","pageIndex","Math","floor","pageSize","sorting","getState","filters","columnFilters","search","globalFilter","hiddenColumns","getHiddenColumns","columnVisibility","pageIndexesToFetch","backIndex","push","pageCount","length","setTimeout","forEach","_tableMeta$server$loa","_tableMeta$server","loadPage","call","enableGlobalFilter","undefined","clearTimeout","pages","RowContext","Provider","value"],"mappings":";;;;AAMA,MAAMA,oBAAoB,GAAG,GAAG;AAShC;SACgBC,GAAGA,CAAkBC,KAAsB;EACvD,MAAM;IACFC,QAAQ,EAAEC,WAAW;IACrBC,YAAY,EAAEC,YAAY;IAC1BC,mBAAmB,GAAG,KAAK;IAC3BC,cAAc,GAAG,KAAK;IACtBC,eAAe;IACfC,eAAe,GAAG,KAAK;IACvB,GAAGC;GACN,GAAGT,KAAK;EAET,MAAMU,SAAS,GAAGV,KAAK,CAACW,KAAK,CAACC,OAAO,CAACC,IAA6B;EACnE,MAAMC,SAAS,GAAGJ,SAAS,CAACK,SAAS,CAACC,aAAa,KAAKhB,KAAK,CAACiB,KAAK;;EAEnE,MAAMC,YAAY,GAAGC,cAAK,CAACC,OAAO,CAC9B,OAAO;IAAEN,SAAS;IAAEO,QAAQ,EAAErB,KAAK,CAACiB,KAAK;IAAEZ,mBAAmB;IAAEC;GAAgB,CAAC,EACjF,CAACQ,SAAS,EAAEd,KAAK,CAACiB,KAAK,EAAEZ,mBAAmB,EAAEC,cAAc,CAAC,CAChE;EAEDa,cAAK,CAACG,SAAS,CAAC;IACZ,IAAIC,OAAO;IAEX,IAAIb,SAAS,CAACc,MAAM,CAACC,SAAS,IAAIf,SAAS,CAACc,MAAM,CAACE,wBAAwB,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AF,iBAAA,EACI/B,KAAK,EACLc,OAAO,EACPE,OAAO,EACPI,aAAa,EACb3B,SAAS,CAACyB,MAAM,CAACgB,kBAAkB,GAAGhB,MAAM,GAAGiB,SAAS,CAC3D;WACJ,CAAC;SACL,EAAEtD,oBAAoB,CAAC;;;IAIhC,OAAO;MACHuD,YAAY,CAAC9B,OAAO,CAAC;KACxB;GACJ,EAAE,CAACb,SAAS,CAACc,MAAM,CAAC8B,KAAK,CAAC,CAAC;EAE5B,oBACInC,6BAACoC,UAAU,CAACC,QAAQ;IAACC,KAAK,EAAEvC;kBACxBC,6BAACjB,WAAW,oBAAYO,eAAe;IAAEN,YAAY,EAAEC;KAAgB,CACrD;AAE9B;;;;"}
|
@@ -3,6 +3,7 @@ import { IconButton } from '../../../../../../../components/IconButton/IconButto
|
|
3
3
|
import { useLocalization } from '../../../../../../../components/Provider/Localization.js';
|
4
4
|
import { Shortcut } from '../../../../../../../components/Shortcut/Shortcut.js';
|
5
5
|
import { useToast } from '../../../../../../../components/Toast/Toaster.js';
|
6
|
+
import { getHiddenColumns } from '../../../../../useTableManager/util/columns.js';
|
6
7
|
import { _catch } from '../../../../../../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
|
7
8
|
import { PrintDialog } from './PrintDialog.js';
|
8
9
|
|
@@ -76,8 +77,9 @@ function Print(props) {
|
|
76
77
|
const toastRef = toast.loading(texts.table.print.loading);
|
77
78
|
const _temp2 = function () {
|
78
79
|
if (tableMeta.server.isEnabled && tableMeta.server.loadAllIfNeeded) {
|
80
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
79
81
|
const _temp = _catch(function () {
|
80
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters)).then(function () {});
|
82
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, hiddenColumns, tableMeta.search.enableGlobalFilter ? table.getState().globalFilter : undefined)).then(function () {});
|
81
83
|
}, function (error) {
|
82
84
|
const errorMessage = `${texts.table.print.error}: ${error}`;
|
83
85
|
console.error(errorMessage);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Print.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Print/Print.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../../components/IconButton/IconButton';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { useToast } from '../../../../../../../components/Toast/Toaster';\nimport { TableRef } from '../../../../../types';\nimport { PrintDialog } from './PrintDialog';\nimport { Shortcut } from '../../../../../../../components/Shortcut/Shortcut';\n\nexport type PrintProps<TType = unknown> = {\n table: ReactTable<TType>;\n tableId: string;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function Print<TType = unknown>(props: PrintProps<TType>) {\n const { table, tableId, tableRef } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const lastScrollTopRef = React.useRef<number>();\n const toast = useToast();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const { allRows, orientation, size, splitGroups } = tableMeta.printing.settings;\n\n const togglePrinting = React.useCallback(\n enabled => {\n tableMeta.printing.setIsPrinting(enabled);\n\n if (tableRef.current) {\n if (enabled) {\n lastScrollTopRef.current = tableRef.current.scrollTop;\n } else if (lastScrollTopRef.current !== undefined) {\n tableRef.current.scrollTop = lastScrollTopRef.current;\n lastScrollTopRef.current = undefined;\n }\n }\n },\n [tableRef.current]\n );\n\n React.useEffect(() => {\n const afterPrint = () => {\n togglePrinting(false);\n };\n\n window.addEventListener('afterprint', afterPrint);\n\n return () => {\n window.removeEventListener('afterprint', afterPrint);\n };\n }, []);\n\n const print = async () => {\n const toastRef = toast.loading(texts.table.print.loading);\n\n if (tableMeta.server.isEnabled && tableMeta.server.loadAllIfNeeded) {\n try {\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n } catch (error) {\n const errorMessage = `${texts.table.print.error}: ${error}`;\n console.error(errorMessage);\n toastRef.error(errorMessage);\n }\n }\n\n // this might close immediately if the dataset is small - this is okay\n toastRef.close();\n\n // use a timeout to let the toast close, otherwise it freezes mid animation when the print dialog opens\n setTimeout(() => {\n // do this here because Safari doesn't support the beforeprint event\n togglePrinting(true);\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n\n if (isSafari) {\n try {\n // Try using document.execCommand for printing in Safari\n document.execCommand('print', false, undefined);\n } catch (error) {\n // If document.execCommand fails or throws an error, fallback to window.print()\n window.print();\n }\n } else {\n // Execute window.print() for all other browsers\n window.print();\n }\n });\n });\n }, 150);\n };\n\n const printStyle = [`@page { size: ${size} ${orientation}; }`];\n\n if (!allRows) {\n printStyle.push(`table[data-taco^='table']#${tableId} tr:not([data-row-selected=\"true\"]) { display: none; }`);\n }\n\n if (splitGroups) {\n printStyle.push(`table[data-taco^='table']#${tableId} tr[data-row-group]:not(:first-child) { break-before: page; }`);\n }\n\n const shortcut = { key: 'p', meta: true, shift: false };\n const tooltip = (\n <>\n {texts.table.print.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n return (\n <>\n <style media=\"print\">{printStyle.join('\\n')}</style>\n <IconButton\n icon=\"print\"\n aria-label={texts.table.print.tooltip}\n dialog={dialogProps => (\n <PrintDialog\n {...dialogProps}\n table={table}\n onAccept={print}\n orientation={orientation}\n setOrientation={value => tableMeta.printing.setSetting('orientation', value)}\n size={size}\n setSize={value => tableMeta.printing.setSetting('size', value)}\n allRows={allRows}\n setAllRows={value => tableMeta.printing.setSetting('allRows', value)}\n splitGroups={splitGroups}\n setSplitGroups={value => tableMeta.printing.setSetting('splitGroups', value)}\n />\n )}\n ref={ref}\n shortcut={shortcut}\n tooltip={tooltip}\n />\n </>\n );\n}\n"],"names":["Print","props","table","tableId","tableRef","texts","useLocalization","ref","React","useRef","lastScrollTopRef","toast","useToast","tableMeta","options","meta","allRows","orientation","size","splitGroups","printing","settings","togglePrinting","useCallback","enabled","setIsPrinting","current","scrollTop","undefined","useEffect","afterPrint","window","addEventListener","removeEventListener","print","toastRef","close","setTimeout","requestAnimationFrame","isSafari","test","navigator","userAgent","document","execCommand","error","loading","_temp2","server","isEnabled","loadAllIfNeeded","_temp","_catch","Promise","resolve","getState","sorting","columnFilters","then","errorMessage","console","_temp3","e","reject","printStyle","push","shortcut","key","shift","tooltip","Shortcut","className","keys","media","join","IconButton","icon","dialog","dialogProps","PrintDialog","onAccept","setOrientation","value","setSetting","setSize","setAllRows","setSplitGroups"],"mappings":";;;;;;;;SAegBA,KAAKA,CAAkBC,KAAwB;EAC3D,MAAM;IAAEC,KAAK;IAAEC,OAAO;IAAEC;GAAU,GAAGH,KAAK;EAC1C,MAAM;IAAEI;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,gBAAgB,GAAGF,cAAK,CAACC,MAAM,EAAU;EAC/C,MAAME,KAAK,GAAGC,QAAQ,EAAE;EACxB,MAAMC,SAAS,GAAGX,KAAK,CAACY,OAAO,CAACC,IAA6B;EAC7D,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC,IAAI;IAAEC;GAAa,GAAGN,SAAS,CAACO,QAAQ,CAACC,QAAQ;EAE/E,MAAMC,cAAc,GAAGd,cAAK,CAACe,WAAW,CACpCC,OAAO;IACHX,SAAS,CAACO,QAAQ,CAACK,aAAa,CAACD,OAAO,CAAC;IAEzC,IAAIpB,QAAQ,CAACsB,OAAO,EAAE;MAClB,IAAIF,OAAO,EAAE;QACTd,gBAAgB,CAACgB,OAAO,GAAGtB,QAAQ,CAACsB,OAAO,CAACC,SAAS;OACxD,MAAM,IAAIjB,gBAAgB,CAACgB,OAAO,KAAKE,SAAS,EAAE;QAC/CxB,QAAQ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AC,CAAS,eACpDlE,6BAACmE,UAAU;IACPC,IAAI,EAAC,OAAO;kBACAvE,KAAK,CAACH,KAAK,CAACgC,KAAK,CAACmC,OAAO;IACrCQ,MAAM,EAAEC,WAAW,kBACftE,6BAACuE,WAAW,oBACJD,WAAW;MACf5E,KAAK,EAAEA,KAAK;MACZ8E,QAAQ,EAAE9C,KAAK;MACfjB,WAAW,EAAEA,WAAW;MACxBgE,cAAc,EAAEC,KAAK,IAAIrE,SAAS,CAACO,QAAQ,CAAC+D,UAAU,CAAC,aAAa,EAAED,KAAK,CAAC;MAC5EhE,IAAI,EAAEA,IAAI;MACVkE,OAAO,EAAEF,KAAK,IAAIrE,SAAS,CAACO,QAAQ,CAAC+D,UAAU,CAAC,MAAM,EAAED,KAAK,CAAC;MAC9DlE,OAAO,EAAEA,OAAO;MAChBqE,UAAU,EAAEH,KAAK,IAAIrE,SAAS,CAACO,QAAQ,CAAC+D,UAAU,CAAC,SAAS,EAAED,KAAK,CAAC;MACpE/D,WAAW,EAAEA,WAAW;MACxBmE,cAAc,EAAEJ,KAAK,IAAIrE,SAAS,CAACO,QAAQ,CAAC+D,UAAU,CAAC,aAAa,EAAED,KAAK;OAC7E,CACL;IACD3E,GAAG,EAAEA,GAAG;IACR2D,QAAQ,EAAEA,QAAQ;IAClBG,OAAO,EAAEA;IACX,CACH;AAEX;;;;"}
|
1
|
+
{"version":3,"file":"Print.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Print/Print.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { IconButton } from '../../../../../../../components/IconButton/IconButton';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { useToast } from '../../../../../../../components/Toast/Toaster';\nimport { TableRef } from '../../../../../types';\nimport { PrintDialog } from './PrintDialog';\nimport { Shortcut } from '../../../../../../../components/Shortcut/Shortcut';\nimport { getHiddenColumns } from '../../../../../useTableManager/util/columns';\n\nexport type PrintProps<TType = unknown> = {\n table: ReactTable<TType>;\n tableId: string;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function Print<TType = unknown>(props: PrintProps<TType>) {\n const { table, tableId, tableRef } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLButtonElement>(null);\n const lastScrollTopRef = React.useRef<number>();\n const toast = useToast();\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const { allRows, orientation, size, splitGroups } = tableMeta.printing.settings;\n\n const togglePrinting = React.useCallback(\n enabled => {\n tableMeta.printing.setIsPrinting(enabled);\n\n if (tableRef.current) {\n if (enabled) {\n lastScrollTopRef.current = tableRef.current.scrollTop;\n } else if (lastScrollTopRef.current !== undefined) {\n tableRef.current.scrollTop = lastScrollTopRef.current;\n lastScrollTopRef.current = undefined;\n }\n }\n },\n [tableRef.current]\n );\n\n React.useEffect(() => {\n const afterPrint = () => {\n togglePrinting(false);\n };\n\n window.addEventListener('afterprint', afterPrint);\n\n return () => {\n window.removeEventListener('afterprint', afterPrint);\n };\n }, []);\n\n const print = async () => {\n const toastRef = toast.loading(texts.table.print.loading);\n\n if (tableMeta.server.isEnabled && tableMeta.server.loadAllIfNeeded) {\n const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);\n\n try {\n await tableMeta.server.loadAllIfNeeded(\n table.getState().sorting,\n table.getState().columnFilters,\n hiddenColumns,\n tableMeta.search.enableGlobalFilter ? table.getState().globalFilter : undefined\n );\n } catch (error) {\n const errorMessage = `${texts.table.print.error}: ${error}`;\n console.error(errorMessage);\n toastRef.error(errorMessage);\n }\n }\n\n // this might close immediately if the dataset is small - this is okay\n toastRef.close();\n\n // use a timeout to let the toast close, otherwise it freezes mid animation when the print dialog opens\n setTimeout(() => {\n // do this here because Safari doesn't support the beforeprint event\n togglePrinting(true);\n\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n\n if (isSafari) {\n try {\n // Try using document.execCommand for printing in Safari\n document.execCommand('print', false, undefined);\n } catch (error) {\n // If document.execCommand fails or throws an error, fallback to window.print()\n window.print();\n }\n } else {\n // Execute window.print() for all other browsers\n window.print();\n }\n });\n });\n }, 150);\n };\n\n const printStyle = [`@page { size: ${size} ${orientation}; }`];\n\n if (!allRows) {\n printStyle.push(`table[data-taco^='table']#${tableId} tr:not([data-row-selected=\"true\"]) { display: none; }`);\n }\n\n if (splitGroups) {\n printStyle.push(`table[data-taco^='table']#${tableId} tr[data-row-group]:not(:first-child) { break-before: page; }`);\n }\n\n const shortcut = { key: 'p', meta: true, shift: false };\n const tooltip = (\n <>\n {texts.table.print.tooltip}\n <Shortcut className=\"ml-2\" keys={shortcut} />\n </>\n );\n\n return (\n <>\n <style media=\"print\">{printStyle.join('\\n')}</style>\n <IconButton\n icon=\"print\"\n aria-label={texts.table.print.tooltip}\n dialog={dialogProps => (\n <PrintDialog\n {...dialogProps}\n table={table}\n onAccept={print}\n orientation={orientation}\n setOrientation={value => tableMeta.printing.setSetting('orientation', value)}\n size={size}\n setSize={value => tableMeta.printing.setSetting('size', value)}\n allRows={allRows}\n setAllRows={value => tableMeta.printing.setSetting('allRows', value)}\n splitGroups={splitGroups}\n setSplitGroups={value => tableMeta.printing.setSetting('splitGroups', value)}\n />\n )}\n ref={ref}\n shortcut={shortcut}\n tooltip={tooltip}\n />\n </>\n );\n}\n"],"names":["Print","props","table","tableId","tableRef","texts","useLocalization","ref","React","useRef","lastScrollTopRef","toast","useToast","tableMeta","options","meta","allRows","orientation","size","splitGroups","printing","settings","togglePrinting","useCallback","enabled","setIsPrinting","current","scrollTop","undefined","useEffect","afterPrint","window","addEventListener","removeEventListener","print","toastRef","close","setTimeout","requestAnimationFrame","isSafari","test","navigator","userAgent","document","execCommand","error","loading","_temp2","server","isEnabled","loadAllIfNeeded","hiddenColumns","getHiddenColumns","getState","columnVisibility","_temp","_catch","Promise","resolve","sorting","columnFilters","search","enableGlobalFilter","globalFilter","then","errorMessage","console","_temp3","e","reject","printStyle","push","shortcut","key","shift","tooltip","Shortcut","className","keys","media","join","IconButton","icon","dialog","dialogProps","PrintDialog","onAccept","setOrientation","value","setSetting","setSize","setAllRows","setSplitGroups"],"mappings":";;;;;;;;;SAgBgBA,KAAKA,CAAkBC,KAAwB;EAC3D,MAAM;IAAEC,KAAK;IAAEC,OAAO;IAAEC;GAAU,GAAGH,KAAK;EAC1C,MAAM;IAAEI;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAoB,IAAI,CAAC;EACjD,MAAMC,gBAAgB,GAAGF,cAAK,CAACC,MAAM,EAAU;EAC/C,MAAME,KAAK,GAAGC,QAAQ,EAAE;EACxB,MAAMC,SAAS,GAAGX,KAAK,CAACY,OAAO,CAACC,IAA6B;EAC7D,MAAM;IAAEC,OAAO;IAAEC,WAAW;IAAEC,IAAI;IAAEC;GAAa,GAAGN,SAAS,CAACO,QAAQ,CAACC,QAAQ;EAE/E,MAAMC,cAAc,GAAGd,cAAK,CAACe,WAAW,CACpCC,OAAO;IACHX,SAAS,CAACO,QAAQ,CAACK,aAAa,CAACD,OAAO,CAAC;IAEzC,IAAIpB,QAAQ,CAACsB,OAAO,EAAE;MAClB,IAAIF,OAAO,EAAE;QACTd,gBAAgB,CAACgB,OAAO,GAAGtB,QAAQ,CAACsB,OAAO,CAACC,SAAS;OACxD,MAAM,IAAIjB,gBAAgB,CAACgB,OAAO,KAAKE,SAAS,EAAE;QAC/CxB,QAAQ,CAACsB,OAAO,CAACC,SAAS,GAAGjB,gBAAgB,CAACgB,OAAO;QACrDhB,gBAAgB,CAACgB,OAAO,GAAGE,SAAS;;;GAG/C,EACD,CAACxB,QAAQ,CAACsB,OAAO,CAAC,CACrB;EAEDlB,cAAK,CAACqB,SAAS,CAAC;IACZ,MAAMC,UAAU,GAAGA;MACfR,cAAc,CAAC,KAAK,CAAC;KACxB;IAEDS,MAAM,CAACC,gBAAgB,CAAC,YAAY,E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CAACH,KAAK,CAACgC,KAAK,CAACyC,OAAO;IACrCQ,MAAM,EAAEC,WAAW,kBACf5E,6BAAC6E,WAAW,oBACJD,WAAW;MACflF,KAAK,EAAEA,KAAK;MACZoF,QAAQ,EAAEpD,KAAK;MACfjB,WAAW,EAAEA,WAAW;MACxBsE,cAAc,EAAEC,KAAK,IAAI3E,SAAS,CAACO,QAAQ,CAACqE,UAAU,CAAC,aAAa,EAAED,KAAK,CAAC;MAC5EtE,IAAI,EAAEA,IAAI;MACVwE,OAAO,EAAEF,KAAK,IAAI3E,SAAS,CAACO,QAAQ,CAACqE,UAAU,CAAC,MAAM,EAAED,KAAK,CAAC;MAC9DxE,OAAO,EAAEA,OAAO;MAChB2E,UAAU,EAAEH,KAAK,IAAI3E,SAAS,CAACO,QAAQ,CAACqE,UAAU,CAAC,SAAS,EAAED,KAAK,CAAC;MACpErE,WAAW,EAAEA,WAAW;MACxByE,cAAc,EAAEJ,KAAK,IAAI3E,SAAS,CAACO,QAAQ,CAACqE,UAAU,CAAC,aAAa,EAAED,KAAK;OAC7E,CACL;IACDjF,GAAG,EAAEA,GAAG;IACRiE,QAAQ,EAAEA,QAAQ;IAClBG,OAAO,EAAEA;IACX,CACH;AAEX;;;;"}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { useLocalization } from '../../../../../../../components/Provider/Localization.js';
|
3
3
|
import { Switch } from '../../../../../../../components/Switch/Switch.js';
|
4
|
+
import { getHiddenColumns } from '../../../../../useTableManager/util/columns.js';
|
4
5
|
import { SearchInput2 } from '../../../../../../../components/SearchInput2/SearchInput2.js';
|
5
6
|
|
6
7
|
function Search(props) {
|
@@ -19,6 +20,7 @@ function Search(props) {
|
|
19
20
|
const scrollTo = rowIndex => scrollToIndex(rowIndex, {
|
20
21
|
align: 'center'
|
21
22
|
});
|
23
|
+
const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);
|
22
24
|
React__default.useEffect(() => {
|
23
25
|
if (tableMeta.search.highlightedColumnIndexes.length) {
|
24
26
|
scrollTo(tableMeta.search.highlightedColumnIndexes[0][0]);
|
@@ -27,9 +29,11 @@ function Search(props) {
|
|
27
29
|
const handleFocus = function () {
|
28
30
|
try {
|
29
31
|
const _temp = function () {
|
30
|
-
if (tableMeta.server.loadAllIfNeeded) {
|
32
|
+
if (tableMeta.server.loadAllIfNeeded && !tableMeta.server._experimentalDataLoader2) {
|
31
33
|
// don't pass the search query because we need all data - not filtered data
|
32
|
-
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters
|
34
|
+
return Promise.resolve(tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters, hiddenColumns,
|
35
|
+
// the old data loader doesn't have server side search
|
36
|
+
undefined)).then(function () {});
|
33
37
|
}
|
34
38
|
}();
|
35
39
|
// load all data if that is possible
|
@@ -38,8 +42,20 @@ function Search(props) {
|
|
38
42
|
return Promise.reject(e);
|
39
43
|
}
|
40
44
|
};
|
45
|
+
const [loading, setLoading] = React__default.useState(false);
|
46
|
+
const searchTimeoutRef = React__default.useRef();
|
41
47
|
const handleChange = query => {
|
42
48
|
table.setGlobalFilter(String(query !== null && query !== void 0 ? query : ''));
|
49
|
+
if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {
|
50
|
+
clearTimeout(searchTimeoutRef.current);
|
51
|
+
searchTimeoutRef.current = setTimeout(() => {
|
52
|
+
var _tableMeta$search$han, _tableMeta$search;
|
53
|
+
setLoading(true);
|
54
|
+
(_tableMeta$search$han = (_tableMeta$search = tableMeta.search).handleSearch) === null || _tableMeta$search$han === void 0 ? void 0 : _tableMeta$search$han.call(_tableMeta$search, query, hiddenColumns).then(() => {
|
55
|
+
setLoading(false);
|
56
|
+
});
|
57
|
+
}, 150);
|
58
|
+
}
|
43
59
|
};
|
44
60
|
const handleToggleExcludeUnmatchedResults = enabled => {
|
45
61
|
tableMeta.search.setEnableGlobalFilter(enabled, table);
|
@@ -47,6 +63,12 @@ function Search(props) {
|
|
47
63
|
var _ref$current;
|
48
64
|
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
|
49
65
|
});
|
66
|
+
if (tableMeta.search.handleSearch) {
|
67
|
+
setLoading(true);
|
68
|
+
tableMeta.search.handleSearch(enabled ? query : undefined, hiddenColumns).then(() => {
|
69
|
+
setLoading(false);
|
70
|
+
});
|
71
|
+
}
|
50
72
|
};
|
51
73
|
const handleNextResult = () => {
|
52
74
|
if (!tableMeta.search.highlightedColumnIndexes.length) {
|
@@ -90,7 +112,7 @@ function Search(props) {
|
|
90
112
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SearchInput2, {
|
91
113
|
findCurrent: tableMeta.search.currentHighlightColumnIndex !== undefined ? tableMeta.search.currentHighlightColumnIndex + 1 : null,
|
92
114
|
findTotal: (_tableMeta$search$hig = (_tableMeta$search$hig2 = tableMeta.search.highlightedColumnIndexes) === null || _tableMeta$search$hig2 === void 0 ? void 0 : _tableMeta$search$hig2.length) !== null && _tableMeta$search$hig !== void 0 ? _tableMeta$search$hig : null,
|
93
|
-
loading: tableMeta.server.loading,
|
115
|
+
loading: tableMeta.server._experimentalDataLoader2 ? loading : tableMeta.server.loading,
|
94
116
|
name: "table-search",
|
95
117
|
onClickFindPrevious: handlePreviousResult,
|
96
118
|
onClickFindNext: handleNextResult,
|
@@ -105,6 +127,7 @@ function Search(props) {
|
|
105
127
|
meta: true,
|
106
128
|
shift: false
|
107
129
|
},
|
130
|
+
showTotal: !tableMeta.server._experimentalDataLoader2,
|
108
131
|
value: query
|
109
132
|
}));
|
110
133
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"Search.js","sources":["../../../../../../../../../../../../src/primitives/Table/Core/components/Toolbar/components/Search/Search.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { SearchInput2 } from '../../../../../../../components/SearchInput2/SearchInput2';\nimport { Switch } from '../../../../../../../components/Switch/Switch';\nimport { TableRef } from '../../../../../types';\n\ntype SearchProps<TType = unknown> = {\n scrollToIndex: any;\n table: ReactTable<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function Search<TType = unknown>(props: SearchProps<TType>) {\n const { scrollToIndex, table, tableRef } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLInputElement>(null);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const query = table.getState().globalFilter;\n const scrollTo = (rowIndex: number) => scrollToIndex(rowIndex, { align: 'center' });\n\n React.useEffect(() => {\n if (tableMeta.search.highlightedColumnIndexes.length) {\n scrollTo(tableMeta.search.highlightedColumnIndexes[0][0]);\n }\n }, [tableMeta.search.highlightedColumnIndexes.length]);\n\n const handleFocus = async () => {\n // load all data if that is possible\n if (tableMeta.server.loadAllIfNeeded) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(table.getState().sorting, table.getState().columnFilters);\n }\n };\n\n const handleChange = (query: any) => {\n table.setGlobalFilter(String(query ?? ''));\n };\n\n const handleToggleExcludeUnmatchedResults = (enabled: boolean) => {\n tableMeta.search.setEnableGlobalFilter(enabled, table);\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.table.search.excludeUnmatchedResults}\n checked={!!table.options.enableGlobalFilter}\n onChange={handleToggleExcludeUnmatchedResults}\n />\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && tableMeta.search.currentHighlightColumnIndex !== undefined) {\n const [rowIndex, cellIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (rowIndex !== undefined && cellIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n\n requestAnimationFrame(() => {\n const cell = tableRef.current?.querySelector(\n `tbody > tr[data-row-index=\"${rowIndex}\"] > td[data-cell-index=\"${cellIndex}\"]`\n );\n\n if (cell) {\n (cell as HTMLElement).focus?.();\n }\n });\n }\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?.length ?? null}\n loading={tableMeta.server.loading}\n name=\"table-search\"\n onClickFindPrevious={handlePreviousResult}\n onClickFindNext={handleNextResult}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n placeholder={texts.table.search.placeholder}\n settingsContent={settings}\n ref={ref}\n shortcut={{ key: 'f', meta: true, shift: false }}\n value={query}\n />\n </>\n );\n}\n"],"names":["Search","props","scrollToIndex","table","tableRef","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","query","getState","globalFilter","scrollTo","rowIndex","align","useEffect","search","highlightedColumnIndexes","length","handleFocus","server","loadAllIfNeeded","Promise","resolve","sorting","columnFilters","then","_temp","e","reject","handleChange","setGlobalFilter","String","handleToggleExcludeUnmatchedResults","enabled","setEnableGlobalFilter","requestAnimationFrame","_ref$current","current","focus","handleNextResult","nextIndex","currentHighlightColumnIndex","undefined","setCurrentHighlightColumnIndex","handlePreviousResult","settings","Switch","label","excludeUnmatchedResults","checked","enableGlobalFilter","onChange","handleKeyDown","event","key","cellIndex","rowActive","setRowActiveIndex","cell","_tableRef$current","querySelector","_cell$focus","call","SearchInput2","findCurrent","findTotal","_tableMeta$search$hig","_tableMeta$search$hig2","loading","name","onClickFindPrevious","onClickFindNext","onFocus","onKeyDown","placeholder","settingsContent","shortcut","shift","value"],"mappings":";;;;;SAagBA,MAAMA,CAAkBC,KAAyB;;EAC7D,MAAM;IAAEC,aAAa;IAAEC,KAAK;IAAEC;GAAU,GAAGH,KAAK;EAChD,MAAM;IAAEI;GAAO,GAAGC,eAAe,EAAE;EACnC,MAAMC,GAAG,GAAGC,cAAK,CAACC,MAAM,CAAmB,IAAI,CAAC;EAChD,MAAMC,SAAS,GAAGP,KAAK,CAACQ,OAAO,CAACC,IAA6B;EAC7D,MAAMC,KAAK,GAAGV,KAAK,CAACW,QAAQ,EAAE,CAACC,YAAY;EAC3C,MAAMC,QAAQ,GAAIC,QAAgB,IAAKf,aAAa,CAACe,QAAQ,EAAE;IAAEC,KAAK,EAAE;GAAU,CAAC;EAEnFV,cAAK,CAACW,SAAS,CAAC;IACZ,IAAIT,SAAS,CAACU,MAAM,CAACC,wBAAwB,CAACC,MAAM,EAAE;MAClDN,QAAQ,CAACN,SAAS,CAACU,MAAM,CAACC,wBAAwB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;GAEhE,EAAE,CAACX,SAAS,CAACU,MAAM,CAACC,wBAAwB,CAACC,MAAM,CAAC,CAAC;EAEtD,MAAMC,WAAW;IAAA;;YAETb,SAAS,CAACc,MAAM,CA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/primitives/Table/Core/components/Toolbar/components/Search/Search.tsx"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLocalization } from '../../../../../../../components/Provider/Localization';\nimport { SearchInput2 } from '../../../../../../../components/SearchInput2/SearchInput2';\nimport { Switch } from '../../../../../../../components/Switch/Switch';\nimport { TableRef } from '../../../../../types';\nimport { getHiddenColumns } from '../../../../../useTableManager/util/columns';\n\ntype SearchProps<TType = unknown> = {\n scrollToIndex: any;\n table: ReactTable<TType>;\n tableRef: React.RefObject<TableRef>;\n};\n\nexport function Search<TType = unknown>(props: SearchProps<TType>) {\n const { scrollToIndex, table, tableRef } = props;\n const { texts } = useLocalization();\n const ref = React.useRef<HTMLInputElement>(null);\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const query = table.getState().globalFilter;\n const scrollTo = (rowIndex: number) => scrollToIndex(rowIndex, { align: 'center' });\n const hiddenColumns = getHiddenColumns(table.getState().columnVisibility);\n\n React.useEffect(() => {\n if (tableMeta.search.highlightedColumnIndexes.length) {\n scrollTo(tableMeta.search.highlightedColumnIndexes[0][0]);\n }\n }, [tableMeta.search.highlightedColumnIndexes.length]);\n\n const handleFocus = async () => {\n // load all data if that is possible\n if (tableMeta.server.loadAllIfNeeded && !tableMeta.server._experimentalDataLoader2) {\n // don't pass the search query because we need all data - not filtered data\n await tableMeta.server.loadAllIfNeeded(\n table.getState().sorting,\n table.getState().columnFilters,\n hiddenColumns,\n // the old data loader doesn't have server side search\n undefined\n );\n }\n };\n\n const [loading, setLoading] = React.useState(false);\n\n const searchTimeoutRef = React.useRef<NodeJS.Timeout>();\n\n const handleChange = (query: any) => {\n table.setGlobalFilter(String(query ?? ''));\n\n if (tableMeta.search.enableGlobalFilter && tableMeta.search.handleSearch) {\n clearTimeout(searchTimeoutRef.current);\n searchTimeoutRef.current = setTimeout(() => {\n setLoading(true);\n tableMeta.search.handleSearch?.(query, hiddenColumns).then(() => {\n setLoading(false);\n });\n }, 150);\n }\n };\n\n const handleToggleExcludeUnmatchedResults = (enabled: boolean) => {\n tableMeta.search.setEnableGlobalFilter(enabled, table);\n requestAnimationFrame(() => ref.current?.focus());\n\n if (tableMeta.search.handleSearch) {\n setLoading(true);\n tableMeta.search.handleSearch(enabled ? query : undefined, hiddenColumns).then(() => {\n setLoading(false);\n });\n }\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.table.search.excludeUnmatchedResults}\n checked={!!table.options.enableGlobalFilter}\n onChange={handleToggleExcludeUnmatchedResults}\n />\n );\n\n const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {\n if (event.key === 'Escape' && tableMeta.search.currentHighlightColumnIndex !== undefined) {\n const [rowIndex, cellIndex] = tableMeta.search.highlightedColumnIndexes[tableMeta.search.currentHighlightColumnIndex];\n\n if (rowIndex !== undefined && cellIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(rowIndex);\n\n requestAnimationFrame(() => {\n const cell = tableRef.current?.querySelector(\n `tbody > tr[data-row-index=\"${rowIndex}\"] > td[data-cell-index=\"${cellIndex}\"]`\n );\n\n if (cell) {\n (cell as HTMLElement).focus?.();\n }\n });\n }\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?.length ?? null}\n loading={tableMeta.server._experimentalDataLoader2 ? loading : tableMeta.server.loading}\n name=\"table-search\"\n onClickFindPrevious={handlePreviousResult}\n onClickFindNext={handleNextResult}\n onChange={handleChange}\n onFocus={handleFocus}\n onKeyDown={handleKeyDown}\n placeholder={texts.table.search.placeholder}\n settingsContent={settings}\n ref={ref}\n shortcut={{ key: 'f', meta: true, shift: false }}\n showTotal={!tableMeta.server._experimentalDataLoader2}\n value={query}\n />\n </>\n );\n}\n"],"names":["Search","props","scrollToIndex","table","tableRef","texts","useLocalization","ref","React","useRef","tableMeta","options","meta","query","getState","globalFilter","scrollTo","rowIndex","align","hiddenColumns","getHiddenColumns","columnVisibility","useEffect","search","highlightedColumnIndexes","length","handleFocus","server","loadAllIfNeeded","_experimentalDataLoader2","Promise","resolve","sorting","columnFilters","undefined","then","_temp","e","reject","loading","setLoading","useState","searchTimeoutRef","handleChange","setGlobalFilter","String","enableGlobalFilter","handleSearch","clearTimeout","current","setTimeout","_tableMeta$search$han","_tableMeta$search","call","handleToggleExcludeUnmatchedResults","enabled","setEnableGlobalFilter","requestAnimationFrame","_ref$current","focus","handleNextResult","nextIndex","currentHighlightColumnIndex","setCurrentHighlightColumnIndex","handlePreviousResult","settings","Switch","label","excludeUnmatchedResults","checked","onChange","handleKeyDown","event","key","cellIndex","rowActive","setRowActiveIndex","cell","_tableRef$current","querySelector","_cell$focus","SearchInput2","findCurrent","findTotal","_tableMeta$search$hig","_tableMeta$search$hig2","name","onClickFindPrevious","onClickFindNext","onFocus","on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,sBAAA,CAA2C5D,MAAM,cAAA2D,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IACpE7C,OAAO,EAAE7B,SAAS,CAACiB,MAAM,CAACE,wBAAwB,GAAGU,OAAO,GAAG7B,SAAS,CAACiB,MAAM,CAACY,OAAO;IACvF+C,IAAI,EAAC,cAAc;IACnBC,mBAAmB,EAAEvB,oBAAoB;IACzCwB,eAAe,EAAE5B,gBAAgB;IACjCU,QAAQ,EAAE3B,YAAY;IACtB8C,OAAO,EAAE/D,WAAW;IACpBgE,SAAS,EAAEnB,aAAa;IACxBoB,WAAW,EAAEtF,KAAK,CAACF,KAAK,CAACoB,MAAM,CAACoE,WAAW;IAC3CC,eAAe,EAAE3B,QAAQ;IACzB1D,GAAG,EAAEA,GAAG;IACRsF,QAAQ,EAAE;MAAEpB,GAAG,EAAE,GAAG;MAAE7D,IAAI,EAAE,IAAI;MAAEkF,KAAK,EAAE;KAAO;IAChDC,SAAS,EAAE,CAACrF,SAAS,CAACiB,MAAM,CAACE,wBAAwB;IACrDmE,KAAK,EAAEnF;IACT,CACH;AAEX;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js
CHANGED
@@ -10,7 +10,7 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
|
|
10
10
|
if (isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, tableRef.current) || isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, tableRef.current)) {
|
11
11
|
return;
|
12
12
|
}
|
13
|
-
tableMeta.rowActive.handleKeyDown(event,
|
13
|
+
tableMeta.rowActive.handleKeyDown(event, tableMeta.length, scrollToIndex);
|
14
14
|
tableMeta.rowSelection.handleKeyDown(event, table);
|
15
15
|
if (tableMeta.rowActive.rowActiveIndex !== undefined) {
|
16
16
|
var _rows$tableMeta$rowAc;
|
@@ -23,7 +23,7 @@ function useTableGlobalShortcuts(table, tableRef, scrollToIndex) {
|
|
23
23
|
};
|
24
24
|
},
|
25
25
|
// scrollToIndex function changes when row count changes, so it is important to update handlers
|
26
|
-
[tableRef.current, tableMeta.rowActive.rowActiveIndex, scrollToIndex]);
|
26
|
+
[tableRef.current, tableMeta.length, tableMeta.rowActive.rowActiveIndex, scrollToIndex]);
|
27
27
|
}
|
28
28
|
|
29
29
|
export { useTableGlobalShortcuts };
|
package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableGlobalShortcuts.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableGlobalShortcuts.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableGlobalShortcuts.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableRef } from '../../types';\nimport {\n isElementInsideOrTriggeredFromContainer,\n isElementInsideOverlay,\n isElementInteractive,\n isSiblingElementInsideSameParentOverlay,\n} from '../../../../utils/dom';\n\nexport function useTableGlobalShortcuts<TType = unknown>(\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n scrollToIndex: (index: number) => void\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const trigger = event.target as HTMLElement;\n\n if (\n (isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, tableRef.current)) ||\n (isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, tableRef.current))\n ) {\n return;\n }\n\n tableMeta.rowActive.handleKeyDown(event,
|
1
|
+
{"version":3,"file":"useTableGlobalShortcuts.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableGlobalShortcuts.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { TableRef } from '../../types';\nimport {\n isElementInsideOrTriggeredFromContainer,\n isElementInsideOverlay,\n isElementInteractive,\n isSiblingElementInsideSameParentOverlay,\n} from '../../../../utils/dom';\n\nexport function useTableGlobalShortcuts<TType = unknown>(\n table: ReactTable<TType>,\n tableRef: React.RefObject<TableRef>,\n scrollToIndex: (index: number) => void\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n const rows = table.getRowModel().rows;\n\n React.useEffect(\n () => {\n const handleKeyDown = (event: KeyboardEvent) => {\n const trigger = event.target as HTMLElement;\n\n if (\n (isElementInsideOverlay(trigger) && !isSiblingElementInsideSameParentOverlay(trigger, tableRef.current)) ||\n (isElementInteractive(trigger) && !isElementInsideOrTriggeredFromContainer(trigger, tableRef.current))\n ) {\n return;\n }\n\n tableMeta.rowActive.handleKeyDown(event, tableMeta.length, scrollToIndex);\n tableMeta.rowSelection.handleKeyDown(event, table);\n\n if (tableMeta.rowActive.rowActiveIndex !== undefined) {\n tableMeta.rowClick.handleKeyDown(event, rows[tableMeta.rowActive.rowActiveIndex]?.original);\n }\n };\n\n document.addEventListener('keydown', handleKeyDown);\n\n return () => {\n document.removeEventListener('keydown', handleKeyDown);\n };\n },\n\n // scrollToIndex function changes when row count changes, so it is important to update handlers\n [tableRef.current, tableMeta.length, tableMeta.rowActive.rowActiveIndex, scrollToIndex]\n );\n}\n"],"names":["useTableGlobalShortcuts","table","tableRef","scrollToIndex","tableMeta","options","meta","rows","getRowModel","React","useEffect","handleKeyDown","event","trigger","target","isElementInsideOverlay","isSiblingElementInsideSameParentOverlay","current","isElementInteractive","isElementInsideOrTriggeredFromContainer","rowActive","length","rowSelection","rowActiveIndex","undefined","_rows$tableMeta$rowAc","rowClick","original","document","addEventListener","removeEventListener"],"mappings":";;;SAUgBA,uBAAuBA,CACnCC,KAAwB,EACxBC,QAAmC,EACnCC,aAAsC;EAEtC,MAAMC,SAAS,GAAGH,KAAK,CAACI,OAAO,CAACC,IAA6B;EAC7D,MAAMC,IAAI,GAAGN,KAAK,CAACO,WAAW,EAAE,CAACD,IAAI;EAErCE,cAAK,CAACC,SAAS,CAC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