@economic/taco 2.27.0 → 2.27.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/Select2/Select2.d.ts +4 -4
- package/dist/components/Select2/components/Trigger.d.ts +0 -1
- package/dist/components/Select2/utilities.d.ts +1 -2
- package/dist/esm/index.css +9 -3
- package/dist/esm/packages/taco/src/components/Provider/Localization.js +3 -3
- package/dist/esm/packages/taco/src/components/Provider/Localization.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/Select2.js +5 -6
- package/dist/esm/packages/taco/src/components/Select2/Select2.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js +5 -6
- package/dist/esm/packages/taco/src/components/Select2/components/Option.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js +17 -17
- package/dist/esm/packages/taco/src/components/Select2/components/Trigger.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Select2/utilities.js +1 -2
- package/dist/esm/packages/taco/src/components/Select2/utilities.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/TextareaWithAutosizing.js +1 -0
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/Editing/TextareaWithAutosizing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js +7 -2
- package/dist/esm/packages/taco/src/components/Table3/components/Editing/Alert.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/util.js +3 -7
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/util.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +2 -2
- 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/BuiltIns/SkeletonRow.js +1 -1
- 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/Toolbar/components/Print/Print.js +1 -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 +1 -1
- 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/useTableStyleColumnFreezing.js +19 -6
- package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleColumnFreezing.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 +45 -12
- package/dist/esm/packages/taco/src/primitives/Table/useTableDataLoader.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js +9 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +7 -3
- 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 +1 -2
- 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 +1 -1
- 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 +6 -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/settings.js +15 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/settings.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +6 -2
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/index.css +9 -3
- package/dist/primitives/Table/Core/components/Columns/Cell/util.d.ts +0 -1
- package/dist/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterColumn.d.ts +1 -1
- package/dist/primitives/Table/types.d.ts +6 -7
- package/dist/primitives/Table/useTableDataLoader.d.ts +5 -4
- package/dist/primitives/Table/useTableManager/listeners/useTableSearchListener.d.ts +2 -1
- package/dist/primitives/Table/useTableManager/util/settings.d.ts +2 -1
- package/dist/taco.cjs.development.js +169 -94
- 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":"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, TableServerLoadAllState } 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, undefined);\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.loadAllStatus === TableServerLoadAllState.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","undefined","then","_temp","e","reject","handleChange","setGlobalFilter","String","handleToggleExcludeUnmatchedResults","enabled","setEnableGlobalFilter","requestAnimationFrame","_ref$current","current","focus","handleNextResult","nextIndex","currentHighlightColumnIndex","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","loadAllStatus","TableServerLoadAllState","Loading","name","onClickFindPrevious","onClickFindNext","onFocus","onKeyDown","placeholder","settingsContent","shortcut","shift","value"],"mappings":";;;;;;SAagBA,MAAMA,CAAkBC,KAAy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duB,SAAS,GAAAC,qBAAA,IAAAC,sBAAA,GAAE9D,SAAS,CAACU,MAAM,CAACC,wBAAwB,cAAAmD,sBAAA,uBAAzCA,sBAAA,CAA2ClD,MAAM,cAAAiD,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IACpEE,OAAO,EAAE/D,SAAS,CAACc,MAAM,CAACkD,aAAa,KAAKC,uBAAuB,CAACC,OAAO;IAC3EC,IAAI,EAAC,cAAc;IACnBC,mBAAmB,EAAE7B,oBAAoB;IACzC8B,eAAe,EAAElC,gBAAgB;IACjCW,QAAQ,EAAErB,YAAY;IACtB6C,OAAO,EAAEzD,WAAW;IACpB0D,SAAS,EAAExB,aAAa;IACxByB,WAAW,EAAE7E,KAAK,CAACF,KAAK,CAACiB,MAAM,CAAC8D,WAAW;IAC3CC,eAAe,EAAEjC,QAAQ;IACzB3C,GAAG,EAAEA,GAAG;IACR6E,QAAQ,EAAE;MAAEzB,GAAG,EAAE,GAAG;MAAE/C,IAAI,EAAE,IAAI;MAAEyE,KAAK,EAAE;KAAO;IAChDC,KAAK,EAAEzE;IACT,CACH;AAEX;;;;"}
|
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, TableServerLoadAllState } 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.loadAllStatus === TableServerLoadAllState.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","loadAllStatus","TableServerLoadAllState","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,CAACC,eAAe;;UAChC,OAAAC,OAAA,CAAAC,OAAA,CACMjB,SAAS,CAACc,MAAM,CAACC,eAAe,CAACtB,KAAK,CAACW,QAAQ,EAAE,CAACc,OAAO,EAAEzB,KAAK,CAACW,QAAQ,EAAE,CAACe,aAAa,CAAC,EAAAC,IAAA;;;;MAHpG,OAAAJ,OAAA,CAAAC,OAAA,CAAAI,KAAA,IAAAA,KAAA,CAAAD,IAAA,GAAAC,KAAA,CAAAD,IAA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8B;;SAEtC,CAAC;;;GAGb;EAED,oBACIvD,yEACIA,6BAAC4D,YAAY;IACTC,WAAW,EACP3D,SAAS,CAACU,MAAM,CAAC0B,2BAA2B,KAAKC,SAAS,GACpDrC,SAAS,CAACU,MAAM,CAAC0B,2BAA2B,GAAG,CAAC,GAChD,IAAI;IAEdwB,SAAS,GAAAC,qBAAA,IAAAC,sBAAA,GAAE9D,SAAS,CAACU,MAAM,CAACC,wBAAwB,cAAAmD,sBAAA,uBAAzCA,sBAAA,CAA2ClD,MAAM,cAAAiD,qBAAA,cAAAA,qBAAA,GAAI,IAAI;IACpEE,OAAO,EAAE/D,SAAS,CAACc,MAAM,CAACkD,aAAa,KAAKC,uBAAuB,CAACC,OAAO;IAC3EC,IAAI,EAAC,cAAc;IACnBC,mBAAmB,EAAE7B,oBAAoB;IACzC8B,eAAe,EAAEnC,gBAAgB;IACjCY,QAAQ,EAAEtB,YAAY;IACtB8C,OAAO,EAAEzD,WAAW;IACpB0D,SAAS,EAAExB,aAAa;IACxByB,WAAW,EAAE7E,KAAK,CAACF,KAAK,CAACiB,MAAM,CAAC8D,WAAW;IAC3CC,eAAe,EAAEjC,QAAQ;IACzB3C,GAAG,EAAEA,GAAG;IACR6E,QAAQ,EAAE;MAAEzB,GAAG,EAAE,GAAG;MAAE/C,IAAI,EAAE,IAAI;MAAEyE,KAAK,EAAE;KAAO;IAChDC,KAAK,EAAEzE;IACT,CACH;AAEX;;;;"}
|
package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleColumnFreezing.js
CHANGED
@@ -2,16 +2,23 @@ import React__default from 'react';
|
|
2
2
|
|
3
3
|
function useTableStyleColumnFreezing(tableId, table) {
|
4
4
|
const {
|
5
|
-
columnPinning
|
5
|
+
columnPinning,
|
6
|
+
columnSizing
|
6
7
|
} = table.getState();
|
7
8
|
const stylesheet = React__default.useMemo(() => {
|
8
9
|
const styles = [];
|
9
10
|
// might be a better way to get this information, but it wasn't obvious
|
10
11
|
const all = table.getFlatHeaders().filter(column => !column.subHeaders.length).map(x => x.id);
|
11
|
-
const left = table.getLeftFlatHeaders().filter(column => !column.subHeaders.length)
|
12
|
-
const right = table.getRightFlatHeaders().filter(column => !column.subHeaders.length)
|
12
|
+
const left = table.getLeftFlatHeaders().filter(column => !column.subHeaders.length);
|
13
|
+
const right = table.getRightFlatHeaders().filter(column => !column.subHeaders.length);
|
13
14
|
if (left.length) {
|
14
|
-
|
15
|
+
left.forEach(cell => {
|
16
|
+
styles.push(`table[data-taco^='table']#${tableId} [data-cell-id="${cell.column.id}"] {
|
17
|
+
left: ${cell.column.getStart(cell.column.getIsPinned())}px;
|
18
|
+
}`);
|
19
|
+
});
|
20
|
+
const leftIds = left.map(x => x.id);
|
21
|
+
const index = all.indexOf(leftIds[leftIds.length - 1]);
|
15
22
|
// add right border, hide the header seperator and add shadow when scrolled
|
16
23
|
// we have to be specific so that nested tables don't inherit the same css
|
17
24
|
styles.push(`table[data-taco^='table']#${tableId} > thead > tr > th:nth-child(${index + 1}),
|
@@ -29,14 +36,20 @@ function useTableStyleColumnFreezing(tableId, table) {
|
|
29
36
|
}`);
|
30
37
|
}
|
31
38
|
if (right.length) {
|
32
|
-
|
39
|
+
right.forEach(cell => {
|
40
|
+
styles.push(`table[data-taco^='table']#${tableId} [data-cell-id="${cell.column.id}"] {
|
41
|
+
right: ${cell.column.getStart(cell.column.getIsPinned())}px;
|
42
|
+
}`);
|
43
|
+
});
|
44
|
+
const rightIds = right.map(x => x.id);
|
45
|
+
const index = all.indexOf(rightIds[rightIds.length - 1]);
|
33
46
|
styles.push(`table[data-taco^='table']#${tableId} > thead > tr > th:nth-child(${index + 1}):not([data-cell-id^="__"]),
|
34
47
|
table[data-taco^='table']#${tableId} > tbody > tr > td:nth-child(${index + 1}):not([data-cell-id^="__"]) {
|
35
48
|
border-left-width: 1px;
|
36
49
|
}`);
|
37
50
|
}
|
38
51
|
return styles.join('\n');
|
39
|
-
}, [columnPinning]);
|
52
|
+
}, [columnPinning, columnSizing]);
|
40
53
|
return {
|
41
54
|
stylesheet
|
42
55
|
};
|
package/dist/esm/packages/taco/src/primitives/Table/Core/features/useTableStyleColumnFreezing.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableStyleColumnFreezing.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableStyleColumnFreezing.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\n\nexport function useTableStyleColumnFreezing<TType = unknown>(tableId: string, table: ReactTable<TType>) {\n const { columnPinning } = table.getState();\n\n const stylesheet = React.useMemo(() => {\n const styles: string[] = [];\n\n // might be a better way to get this information, but it wasn't obvious\n const all = table\n .getFlatHeaders()\n .filter(column => !column.subHeaders.length)\n .map(x => x.id);\n const left = table
|
1
|
+
{"version":3,"file":"useTableStyleColumnFreezing.js","sources":["../../../../../../../../../src/primitives/Table/Core/features/useTableStyleColumnFreezing.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\n\nexport function useTableStyleColumnFreezing<TType = unknown>(tableId: string, table: ReactTable<TType>) {\n const { columnPinning, columnSizing } = table.getState();\n\n const stylesheet = React.useMemo(() => {\n const styles: string[] = [];\n\n // might be a better way to get this information, but it wasn't obvious\n const all = table\n .getFlatHeaders()\n .filter(column => !column.subHeaders.length)\n .map(x => x.id);\n const left = table.getLeftFlatHeaders().filter(column => !column.subHeaders.length);\n const right = table.getRightFlatHeaders().filter(column => !column.subHeaders.length);\n\n if (left.length) {\n left.forEach(cell => {\n styles.push(`table[data-taco^='table']#${tableId} [data-cell-id=\"${cell.column.id}\"] {\n left: ${cell.column.getStart(cell.column.getIsPinned())}px;\n }`);\n });\n const leftIds = left.map(x => x.id);\n const index = all.indexOf(leftIds[leftIds.length - 1]);\n\n // add right border, hide the header seperator and add shadow when scrolled\n // we have to be specific so that nested tables don't inherit the same css\n styles.push(`table[data-taco^='table']#${tableId} > thead > tr > th:nth-child(${index + 1}),\n table[data-taco^='table']#${tableId} > tbody > tr > td:nth-child(${index + 1}) {\n border-right-width: 1px;\n }\\ntable[data-taco^='table']#${tableId} > thead > tr > th:nth-child(${index + 1})[data-cell-id^=\"__\"],\n table[data-taco^='table']#${tableId} > tbody > tr > td:nth-child(${index + 1})[data-cell-id^=\"__\"] {\n border-right-color: transparent;\n }\\ntable[data-taco^='table']#${tableId} > thead > tr > th:nth-child(${index + 1}):after {\n content: none;\n }\\ntable[data-taco^='table'][data-table-horizontally-scrolled=\"true\"]#${tableId} > thead > tr > th:nth-child(${\n index + 1\n }),\n table[data-taco^='table'][data-table-horizontally-scrolled=\"true\"]#${tableId} > tbody > tr > td:nth-child(${\n index + 1\n }) {\n border-right-color: rgb(221, 221, 221);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), 6px 0px 6px rgb(0 0 0/8%);\n }`);\n }\n\n if (right.length) {\n right.forEach(cell => {\n styles.push(`table[data-taco^='table']#${tableId} [data-cell-id=\"${cell.column.id}\"] {\n right: ${cell.column.getStart(cell.column.getIsPinned())}px;\n }`);\n });\n const rightIds = right.map(x => x.id);\n const index = all.indexOf(rightIds[rightIds.length - 1]);\n\n styles.push(`table[data-taco^='table']#${tableId} > thead > tr > th:nth-child(${index + 1}):not([data-cell-id^=\"__\"]),\n table[data-taco^='table']#${tableId} > tbody > tr > td:nth-child(${index + 1}):not([data-cell-id^=\"__\"]) {\n border-left-width: 1px;\n }`);\n }\n\n return styles.join('\\n');\n }, [columnPinning, columnSizing]);\n\n return { stylesheet };\n}\n"],"names":["useTableStyleColumnFreezing","tableId","table","columnPinning","columnSizing","getState","stylesheet","React","useMemo","styles","all","getFlatHeaders","filter","column","subHeaders","length","map","x","id","left","getLeftFlatHeaders","right","getRightFlatHeaders","forEach","cell","push","getStart","getIsPinned","leftIds","index","indexOf","rightIds","join"],"mappings":";;SAGgBA,2BAA2BA,CAAkBC,OAAe,EAAEC,KAAwB;EAClG,MAAM;IAAEC,a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B,KAAK,GAAG;qFAE6D5B,wCACrE4B,KAAK,GAAG;;;kBAIN,CAAC;;IAGX,IAAIR,KAAK,CAACN,MAAM,EAAE;MACdM,KAAK,CAACE,OAAO,CAACC,IAAI;QACdf,MAAM,CAACgB,IAAI,8BAA8BxB,0BAA0BuB,IAAI,CAACX,MAAM,CAACK;6BAClEM,IAAI,CAACX,MAAM,CAACa,QAAQ,CAACF,IAAI,CAACX,MAAM,CAACc,WAAW,EAAE;kBACzD,CAAC;OACN,CAAC;MACF,MAAMI,QAAQ,GAAGV,KAAK,CAACL,GAAG,CAACC,CAAC,IAAIA,CAAC,CAACC,EAAE,CAAC;MACrC,MAAMW,KAAK,GAAGnB,GAAG,CAACoB,OAAO,CAACC,QAAQ,CAACA,QAAQ,CAAChB,MAAM,GAAG,CAAC,CAAC,CAAC;MAExDN,MAAM,CAACgB,IAAI,8BAA8BxB,uCAAuC4B,KAAK,GAAG;4CACxD5B,uCAAuC4B,KAAK,GAAG;;kBAEzE,CAAC;;IAGX,OAAOpB,MAAM,CAACuB,IAAI,CAAC,IAAI,CAAC;GAC3B,EAAE,CAAC7B,aAAa,EAAEC,YAAY,CAAC,CAAC;EAEjC,OAAO;IAAEE;GAAY;AACzB;;;;"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, ValueOf } from '../../types';\nimport { MenuProps } from '../../components/Menu/Menu';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\ntype TODO = any;\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = (props: Partial<MenuProps>) => JSX.Element;\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TValue> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateRenderer = () => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableFeatureProps = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: boolean;\n enableRowSelectionSingle?: boolean;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: boolean;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps & {\n children: (JSX.Element | boolean | null | undefined)[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityColumnId?: string;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TODO; // not currently supported\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: string;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType[Key]>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AA2BA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IA+GrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../../../../../src/primitives/Table/types.ts"],"sourcesContent":["import {\n ColumnFilter as ReactTableColumnFilter,\n ColumnFiltersState as ReactTableColumnFilterState,\n ColumnOrderState as ReactTableColumnOrderState,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSort as ReactTableColumnSort,\n ColumnSizingState as ReactTableColumnSizingState,\n VisibilityState as ReactTableColumnVisibilityState,\n SortingState as ReactTableSortingState,\n BuiltInAggregationFn as ReactTableBuiltInAggregationFn,\n BuiltInSortingFn as ReactTableBuiltInSortingFn,\n} from '@tanstack/react-table';\nimport { FontSize, FontSizes, ValueOf } from '../../types';\nimport { MenuProps } from '../../components/Menu/Menu';\nimport { MenuItemProps } from '../../components/Menu/components/Item';\n\nexport type TableRef = HTMLTableElement & {\n instance: {\n resetFiltering: () => void;\n resetRowExpansion: () => void;\n resetRowSelection: () => void;\n resetSorting: () => void;\n };\n};\n\n// filtering\nexport enum TableFilterComparator {\n Contains,\n DoesNotContain,\n IsEqualTo,\n IsNotEqualTo,\n IsGreaterThan,\n IsLessThan,\n IsBetween,\n IsEmpty,\n IsNotEmpty,\n IsLessThanOrEqualTo,\n IsGreaterThanOrEqualTo,\n HasAnyOf,\n HasAllOf,\n HasNoneOf,\n}\nexport type TableFilterValue = {\n comparator: TableFilterComparator;\n value: any;\n};\nexport type TableFilter = {\n id: string;\n value: TableFilterValue;\n};\n\n// columns\nexport type TableColumnAlignment = 'left' | 'center' | 'right';\nexport type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);\nexport type TableColumnDataType = 'auto' | 'number' | 'alphanumeric' | 'alphanumericCaseSensitive' | 'datetime' | 'boolean';\nexport type TableColumnFilter = ReactTableColumnFilter;\nexport type TableColumnMenu = (props: Partial<MenuProps>) => JSX.Element;\nexport type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererAggregate<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;\nexport type TableColumnRendererControl<TType = unknown> =\n | ((props: TableColumnRendererControlProps, row?: TType) => JSX.Element)\n | 'datepicker'\n | 'input'\n | 'switch'\n | 'textarea';\nexport type TableColumnRendererControlProps = {\n className?: string;\n disabled?: boolean;\n fontSize?: FontSize;\n invalid?: boolean;\n onBlur?: (value: any) => void;\n onFocus?: React.FocusEventHandler;\n readOnly?: boolean;\n ref: React.RefObject<HTMLElement> | ((instance: HTMLElement | null | undefined) => void);\n setValue: (value: any) => void;\n value: any;\n};\nexport type TableColumnRendererHeader = string;\nexport type TableColumnRendererFooter<TValue> = (values: TValue[]) => JSX.Element | string | number | null;\nexport type TableColumnSort = ReactTableColumnSort;\nexport type TableColumnSortDirection = 'asc' | 'desc';\nexport type TableColumnSortFn<TType = unknown> =\n | ((rowA: TType, rowB: TType, columnId: string) => -1 | 0 | 1)\n | ReactTableBuiltInSortingFn\n | 'auto';\nexport type TableColumnWidth = number | 'grow';\n\n// rows\nexport type TableRowActionRenderer<TType = unknown> = (row: TType, internalRowId: string) => JSX.Element | null;\nexport type TableRowActionGroupRenderer<TType = unknown> = (rows: TType[]) => JSX.Element | null;\nexport type TableRowClickHandler<TType = unknown> = (row: TType) => void;\nexport type TableRowDragHandler<TType = unknown> = (\n rows: TType[],\n showPlaceholder: (string) => void,\n setDataTransfer: (data: string) => void\n) => void;\nexport type TableRowDropHandler<TType = unknown> = (event: React.DragEvent, row: TType) => void;\nexport type TableRowGotoHandler = (\n column: string,\n query: string,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<number>;\nexport type TableRowHeight = 'short' | 'medium' | 'tall' | 'extra-tall';\nexport type TableRowSelectHandler<TType = unknown> = (rows: TType[]) => void;\nexport type TableRowWithMetaData<TType = unknown> = TType & {\n _meta?: {\n layout?: 'heading' | 'summary' | 'item';\n };\n};\n\n// shortcuts\nexport type TableShortcutHandlerFn<TType = unknown> = (row: TType) => void;\nexport type TableShortcutHandlerObject<TType = unknown> = {\n handler: TableShortcutHandlerFn<TType>;\n meta?: boolean;\n shift?: boolean;\n};\n\n// table\nexport type TableFilterHandler = (filters: TableColumnFilter[]) => void | Promise<void>;\nexport type TableFontSize = keyof typeof FontSizes;\nexport type TablePreset = 'complex' | 'list' | 'simple';\nexport type TableRowExpansionRenderer<TType = unknown> = (row: TType) => (() => JSX.Element) | null;\nexport type TableScrollToIndexHandler = (index: number, options?: { align: 'start' | 'center' | 'end' | 'auto' }) => void;\nexport type TableSearchHandler = (search: string | undefined) => void | Promise<void>;\nexport type TableServerLoadPageHandler = (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<void>;\nexport type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;\nexport enum TableServerLoadAllState {\n Incomplete,\n Loading,\n Completed,\n}\nexport type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;\nexport type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;\nexport type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;\nexport type TableCustomSettingsRenderer = (props: TableSettings) => React.ReactElement<MenuItemProps>[];\nexport type TableEmptyStateRenderer = () => JSX.Element | null;\n\n// settings\nexport type TableSettings = {\n columnFilters?: ReactTableColumnFilterState;\n columnOrder?: ReactTableColumnOrderState;\n columnPinning?: ReactTableColumnPinningState;\n columnSizing?: ReactTableColumnSizingState;\n columnVisibility?: ReactTableColumnVisibilityState;\n excludeUnmatchedRecordsInSearch?: boolean;\n fontSize?: TableFontSize;\n rowHeight?: TableRowHeight;\n searchQuery?: string;\n sorting?: ReactTableSortingState;\n};\nexport type TableEnableSettingsOptions = {\n columnOrder: boolean;\n columnPinning: boolean;\n columnSizing: boolean;\n columnVisibility: boolean;\n excludeUnmatchedRecordsInSearch: boolean;\n fontSize: boolean;\n grouping: boolean;\n rowHeight: boolean;\n sorting: boolean;\n};\n\n// props\nexport type TableFeatureProps = {\n // react-table built-in\n enableFiltering?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableColumnFreezing?: boolean;\n enableColumnHiding?: boolean;\n enableColumnResizing?: boolean;\n enableRowExpansion?: boolean;\n enableRowSelection?: boolean;\n enableRowSelectionSingle?: boolean;\n\n // custom -- common between all table types\n enableColumnOrdering?: boolean;\n enableFontSize?: boolean;\n enableFooter?: boolean;\n enablePrinting?: boolean;\n enableRowActions?: boolean;\n enableRowActive?: boolean;\n enableRowClick?: boolean;\n enableRowDrag?: boolean;\n enableRowDrop?: boolean;\n enableRowGoto?: boolean;\n enableRowHeight?: boolean;\n enableSaveSettings?: boolean | Partial<TableEnableSettingsOptions>;\n};\n\nexport type TableCommonProps<TType = unknown> = TableFeatureProps & {\n children: (JSX.Element | boolean | null | undefined)[];\n data: TType[];\n id: string;\n\n // misc\n customSettings?: TableCustomSettingsRenderer;\n defaultColumnFreezingIndex?: number;\n defaultRowActiveIndex?: number;\n defaultRowGroupColumnId?: keyof TType;\n defaultSettings?: TableSettings;\n emptyState?: TableEmptyStateRenderer;\n preset?: TablePreset;\n rowActions?: TableRowActionRenderer<TType>[];\n rowActionsForGroup?: TableRowActionGroupRenderer<TType>[];\n rowActionsLength?: number;\n rowExpansionRenderer?: TableRowExpansionRenderer<TType>;\n rowIdentityColumnId?: string;\n shortcuts?: TableShortcuts<TType>;\n toolbarLeft?: JSX.Element;\n toolbarRight?: JSX.Element;\n toolbarPanel?: JSX.Element;\n\n // handlers\n onRowClick?: TableRowClickHandler<TType>;\n onRowDrag?: TableRowDragHandler<TType>;\n onRowDrop?: TableRowDropHandler<TType>;\n onRowGoto?: TableRowGotoHandler;\n onRowSelect?: TableRowSelectHandler<TType>;\n\n // state change handlers\n onChangeFilter?: TableFilterHandler;\n onChangeSearch?: TableSearchHandler;\n onChangeSettings?: TableSettingsHandler;\n onChangeSort?: TableSortHandler;\n};\n\nexport interface TableClientProps<TType = unknown> extends TableCommonProps<TType> {\n length?: never;\n loadAll?: never;\n loadPage?: never;\n pageSize?: never;\n}\n\nexport interface TableServerProps<TType = unknown> extends TableCommonProps<TType> {\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n pageSize?: number;\n}\n\nexport type TableProps<TType = unknown> = TableClientProps<TType> | TableServerProps<TType>;\n\nexport type TableColumnProps<TType = unknown> = ValueOf<{\n [Key in keyof TType]: {\n accessor?: Key;\n id: string;\n // renderers\n renderer?: TableColumnRenderer<TType, TType[Key]>;\n /** Renderer to use if the cell is an aggregate cell and part of a grouped row */\n aggregate?: TableColumnRendererAggregate<TType, TType[Key]>;\n control?: TableColumnRendererControl<TType>;\n footer?: TableColumnRendererFooter<TType[Key]>;\n header: TableColumnRendererHeader;\n // options\n /** Aggregation function to be used when the column is part of a grouped row */\n aggregationFn?: 'auto' | ReactTableBuiltInAggregationFn;\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TType>;\n dataType?: TableColumnDataType;\n defaultHidden?: boolean;\n defaultWidth?: TableColumnWidth;\n enableFiltering?: boolean;\n enableGrouping?: boolean;\n enableHiding?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableResizing?: boolean;\n enableSearch?: boolean;\n enableSorting?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n headerClassName?: string;\n menu?: TableColumnMenu;\n minWidth?: number;\n sort?: TableColumnSortDirection;\n sortFn?: TableColumnSortFn<TType>;\n tooltip?: string;\n };\n}>;\n\nexport type TableGroupProps = {\n children: (JSX.Element | boolean | null | undefined)[];\n header: string;\n id: string;\n};\n\nexport type TableTexts = {\n columns: {\n actions: {\n tooltip: string;\n };\n drag: {\n tooltip: string;\n };\n expansion: {\n collapse: string;\n collapseAll: string;\n expand: string;\n expandAll: string;\n };\n menu: {\n editFilter: string;\n filter: string;\n freezeFirstColumn: string;\n freezeUptoColumn: string;\n gotoRow: string;\n hideColumn: string;\n unfreezeColumns: string;\n sorting: string;\n sortingOrder: {\n ascending: string;\n descending: string;\n unsorted: string;\n };\n };\n resize: {\n tooltip: string;\n };\n select: {\n deselect: string;\n deselectAll: string;\n select: string;\n selectAll: string;\n };\n };\n columnSettings: {\n button: string;\n noResults: string;\n search: string;\n tooltip: string;\n };\n filters: {\n button: string;\n buttons: {\n addFilter: string;\n clearFilters: string;\n };\n comparators: {\n contains: string;\n doesNotContain: string;\n isEqualTo: string;\n isNotEqualTo: string;\n isGreaterThan: string;\n isLessThan: string;\n isBetween: string;\n isEmpty: string;\n isNotEmpty: string;\n isBefore: string;\n isAfter: string;\n isLessThanOrEqualTo: string;\n isGreaterThanOrEqualTo: string;\n isOnOrBefore: string;\n isOnOrAfter: string;\n hasAnyOf: string;\n hasAllOf: string;\n hasNoneOf: string;\n };\n conditions: {\n and: string;\n where: string;\n };\n emptyFilter: {\n condition: string;\n value: string;\n };\n hiddenColumn: string;\n hiddenGroupedColumn: string;\n tooltip: string;\n total: string;\n };\n fontSize: {\n tooltip: string;\n sizes: {\n small: string;\n medium: string;\n large: string;\n };\n };\n footer: {\n summary: {\n count: string;\n records: string;\n selected: string;\n };\n };\n print: {\n error: string;\n loading: string;\n tooltip: string;\n warningDialog: {\n title: string;\n description: string;\n checkboxVisibilityLabel: string;\n cancelButtonText: string;\n printButtonText: string;\n };\n settingsDialog: {\n title: string;\n size: string;\n sizeA5: string;\n sizeA4: string;\n sizeA3: string;\n sizeLetter: string;\n sizeLegal: string;\n orientation: string;\n orientationLandscape: string;\n orientationPortrait: string;\n rows: string;\n rowsAll: string;\n rowsSelected: string;\n layout: string;\n layoutSplitGroups: string;\n };\n };\n rowHeight: {\n tooltip: string;\n sizes: {\n short: string;\n medium: string;\n tall: string;\n extraTall: string;\n };\n };\n search: {\n excludeUnmatchedResults: string;\n placeholder: string;\n };\n otherOptions: {\n tooltip: string;\n };\n};\n"],"names":["TableFilterComparator","TableServerLoadAllState"],"mappings":"AAyBA;IACYA;AAAZ,WAAYA,qBAAqB;EAC7BA,yEAAQ;EACRA,qFAAc;EACdA,2EAAS;EACTA,iFAAY;EACZA,mFAAa;EACbA,6EAAU;EACVA,2EAAS;EACTA,uEAAO;EACPA,6EAAU;EACVA,+FAAmB;EACnBA,sGAAsB;EACtBA,0EAAQ;EACRA,0EAAQ;EACRA,4EAAS;AACb,CAAC,EAfWA,qBAAqB,KAArBA,qBAAqB;IA2GrBC;AAAZ,WAAYA,uBAAuB;EAC/BA,iFAAU;EACVA,2EAAO;EACPA,+EAAS;AACb,CAAC,EAJWA,uBAAuB,KAAvBA,uBAAuB;;;;"}
|
@@ -2,7 +2,7 @@ import React__default from 'react';
|
|
2
2
|
import { _finallyRethrows, _catch } from '../../../../../node_modules/babel-plugin-transform-async-to-promises/helpers.mjs.js';
|
3
3
|
|
4
4
|
const DEFAULT_PAGE_SIZE = 100;
|
5
|
-
function useTableDataLoader(
|
5
|
+
function useTableDataLoader(fetchPage, fetchAll, options = {
|
6
6
|
pageSize: DEFAULT_PAGE_SIZE
|
7
7
|
}) {
|
8
8
|
const {
|
@@ -18,11 +18,11 @@ function useTableDataLoader(fetch, fetchAll, options = {
|
|
18
18
|
const _lastUsedFilters = React__default.useRef([]);
|
19
19
|
const _lastUsedSearch = React__default.useRef();
|
20
20
|
const _forceReset = React__default.useRef(false);
|
21
|
-
const loadPage = function (pageIndex, sorting, filters
|
21
|
+
const loadPage = function (pageIndex, sorting, filters) {
|
22
22
|
try {
|
23
23
|
let reset = false;
|
24
24
|
// sorting or filters changed, reset everything
|
25
|
-
if (_forceReset.current ||
|
25
|
+
if (_forceReset.current || JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) || JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)) {
|
26
26
|
_pendingPageRequests.current = {};
|
27
27
|
// nuke the dataset so that we "start again" after sorting
|
28
28
|
reset = true;
|
@@ -38,11 +38,9 @@ function useTableDataLoader(fetch, fetchAll, options = {
|
|
38
38
|
_lastUsedSorting.current = sorting;
|
39
39
|
// set the filters so we can track if it changed between loads
|
40
40
|
_lastUsedFilters.current = filters;
|
41
|
-
// set the search so we can track if it changed between loads
|
42
|
-
_lastUsedSearch.current = search;
|
43
41
|
const _temp = _finallyRethrows(function () {
|
44
42
|
return _catch(function () {
|
45
|
-
return Promise.resolve(
|
43
|
+
return Promise.resolve(fetchPage(pageIndex, pageSize, sorting, filters)).then(function (response) {
|
46
44
|
// update state, here we do some "magic" to support "load in place"
|
47
45
|
setData(currentData => {
|
48
46
|
let nextData;
|
@@ -71,10 +69,14 @@ function useTableDataLoader(fetch, fetchAll, options = {
|
|
71
69
|
return Promise.reject(e);
|
72
70
|
}
|
73
71
|
};
|
74
|
-
const loadAll = function (sorting, filters
|
72
|
+
const loadAll = function (sorting, filters) {
|
75
73
|
try {
|
74
|
+
// set the sorting so we can track if it changed between loads
|
75
|
+
_lastUsedSorting.current = sorting;
|
76
|
+
// set the filters so we can track if it changed between loads
|
77
|
+
_lastUsedFilters.current = filters;
|
76
78
|
const _temp2 = _catch(function () {
|
77
|
-
return Promise.resolve(fetchAll(sorting, filters
|
79
|
+
return Promise.resolve(fetchAll(sorting, filters)).then(function (response) {
|
78
80
|
length.current = response.length;
|
79
81
|
setData(() => {
|
80
82
|
let nextData;
|
@@ -96,22 +98,52 @@ function useTableDataLoader(fetch, fetchAll, options = {
|
|
96
98
|
const invalidate = function () {
|
97
99
|
try {
|
98
100
|
_forceReset.current = true;
|
99
|
-
return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current
|
101
|
+
return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current);
|
100
102
|
} catch (e) {
|
101
103
|
return Promise.reject(e);
|
102
104
|
}
|
103
105
|
};
|
104
|
-
//
|
106
|
+
// search works client side - it fetches all then works client side - so these handlers are a little "weird"
|
107
|
+
// if a search is currently "active", we need to re load all because
|
105
108
|
const handleSort = function (sorting) {
|
106
109
|
try {
|
107
|
-
|
110
|
+
// set the sorting so we can track if it changed between loads
|
111
|
+
_lastUsedSorting.current = sorting;
|
112
|
+
if (_lastUsedSearch.current) {
|
113
|
+
// we're searching, which means we need to refetch all with the correct sorting applied
|
114
|
+
loadAll(sorting, _lastUsedFilters.current);
|
115
|
+
} else {
|
116
|
+
// reset the page to 0 whenever sorting
|
117
|
+
loadPage(0, sorting, _lastUsedFilters.current);
|
118
|
+
}
|
119
|
+
return Promise.resolve();
|
108
120
|
} catch (e) {
|
109
121
|
return Promise.reject(e);
|
110
122
|
}
|
111
123
|
};
|
112
124
|
const handleFilter = function (filters) {
|
113
125
|
try {
|
114
|
-
|
126
|
+
// set the filters so we can track if it changed between loads
|
127
|
+
_lastUsedFilters.current = filters;
|
128
|
+
if (_lastUsedSearch.current) {
|
129
|
+
// we're searching, which means we need to refetch all with the correct sorting applied
|
130
|
+
loadAll(_lastUsedSorting.current, filters);
|
131
|
+
} else {
|
132
|
+
// reset the page to 0 whenever sorting
|
133
|
+
loadPage(0, _lastUsedSorting.current, filters);
|
134
|
+
}
|
135
|
+
return Promise.resolve();
|
136
|
+
} catch (e) {
|
137
|
+
return Promise.reject(e);
|
138
|
+
}
|
139
|
+
};
|
140
|
+
const handleSearch = function (search) {
|
141
|
+
try {
|
142
|
+
// set the search so we can track if it changed between loads
|
143
|
+
_lastUsedSearch.current = search || undefined;
|
144
|
+
// search works client side, and focusing the search field triggers a load of all so we don't actually
|
145
|
+
// want to load anything when search gets changed, we just store the value for other handlers
|
146
|
+
return Promise.resolve();
|
115
147
|
} catch (e) {
|
116
148
|
return Promise.reject(e);
|
117
149
|
}
|
@@ -122,6 +154,7 @@ function useTableDataLoader(fetch, fetchAll, options = {
|
|
122
154
|
loadAll,
|
123
155
|
loadPage,
|
124
156
|
onChangeFilter: handleFilter,
|
157
|
+
onChangeSearch: handleSearch,
|
125
158
|
onChangeSort: handleSort,
|
126
159
|
pageSize
|
127
160
|
}, invalidate];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableDataLoader.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader.ts"],"sourcesContent":["import React from 'react';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n} from './types';\n\nexport const DEFAULT_PAGE_SIZE = 100;\n\nexport type useTableDataPageFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderOptions = { pageSize: number };\n\nexport type useTableDataLoaderValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n};\n\nexport function useTableDataLoader<TType = unknown>(\n fetch: useTableDataPageFetcher<TType>,\n fetchAll: useTableDataAllFetcher<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues<TType>, () => void] {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<any[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (\n pageIndex: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[],\n search: string | undefined\n ) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n _forceReset.current ||\n search !== _lastUsedSearch.current ||\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n _forceReset.current = false;\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n // set the search so we can track if it changed between loads\n _lastUsedSearch.current = search;\n\n try {\n const response = await fetch(pageIndex, pageSize, sorting, filters, search);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = [...currentData];\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: TableColumnSort[], filters: TableColumnFilter[], search: string | undefined) => {\n try {\n const response = await fetchAll(sorting, filters, search);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n const invalidate = async () => {\n _forceReset.current = true;\n return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current, _lastUsedSearch.current);\n };\n\n // we reset the page to 0 whenever sorting, filtering or search changes\n const handleSort = async (sorting: TableColumnSort[]) =>\n loadPage(0, sorting, _lastUsedFilters.current, _lastUsedSearch.current);\n const handleFilter = async (filters: TableColumnFilter[]) =>\n loadPage(0, _lastUsedSorting.current, filters, _lastUsedSearch.current);\n\n return [\n {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSort: handleSort,\n pageSize,\n },\n invalidate,\n ];\n}\n"],"names":["DEFAULT_PAGE_SIZE","useTableDataLoader","fetch","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","_forceReset","loadPage","pageIndex","sorting","filters","search","reset","current","JSON","stringify","Promise","resolve","_temp","_finallyRethrows","_catch","then","response","currentData","nextData","Array","fill","startIndex","splice","_wasThrown","_result","e","reject","loadAll","_temp2","invalidate","handleSort","handleFilter","onChangeFilter","onChangeSort"],"mappings":";;;MAUaA,iBAAiB,GAAG;SA4BjBC,kBAAkBA,CAC9BC,KAAqC,EACrCC,QAAuC,EACvCC,UAAqC;EAAEC,QAAQ,EAAEL;CAAmB;EAEpE,MAAM;IAAEK;GAAU,GAAGD,OAAO;;EAG5B,MAAME,MAAM,GAAGC,cAAK,CAACC,MAAM,CAAqBC,SAAS,CAAC;;EAE1D,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGJ,cAAK,CAACK,QAAQ,CAAQ,EAAE,CAAC;;EAEjD,MAAMC,oBAAoB,GAAGN,cAAK,CAACC,MAAM,CAAC,EAAE,CAAC;EAC7C,MAAMM,gBAAgB,GAAGP,cAAK,CAACC,MAAM,CAAoB,EAAE,CAAC;EAC5D,MAAMO,gBAAgB,GAAGR,cAAK,CAACC,MAAM,CAAsB,EAAE,CAAC;EAC9D,MAAMQ,eAAe,GAAGT,cAAK,CAACC,MAAM,EAAU;EAC9C,MAAMS,WAAW,GAAGV,cAAK,CAACC,MAAM,CAAC,KAAK,CAAC;EAEvC,MAAMU,QAAQ,aACVC,SAAiB,EACjBC,OAA0B,EAC1BC,OAA4B,EAC5BC,MAA0B;IAAA;MAE1B,IAAIC,KAAK,GAAG,KAAK;;MAGjB,IACIN,WAAW,CAACO,OAAO,IACnBF,MAAM,KAAKN,eAAe,CAACQ,OAAO,IAClCC,IAAI,CAACC,SAAS,CAACN,OAAO,CAAC,KAAKK,IAAI,CAACC,SAAS,CAACZ,gBAAgB,CA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AAMI,UAAU;IAAA;MACZ7B,WAAW,CAACO,OAAO,GAAG,IAAI;MAC1B,OAAON,QAAQ,CAAC,CAAC,EAAEJ,gBAAgB,CAACU,OAAO,EAAET,gBAAgB,CAACS,OAAO,EAAER,eAAe,CAACQ,OAAO,CAAC;KAClG,QAAAkB,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;;EAGD,MAAMK,UAAU,aAAU3B,OAA0B;IAAA;MAAA,OAChDF,QAAQ,CAAC,CAAC,EAAEE,OAAO,EAAEL,gBAAgB,CAACS,OAAO,EAAER,eAAe,CAACQ,OAAO,CAAC;aAAAkB,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAC3E,MAAMM,YAAY,aAAU3B,OAA4B;IAAA;MAAA,OACpDH,QAAQ,CAAC,CAAC,EAAEJ,gBAAgB,CAACU,OAAO,EAAEH,OAAO,EAAEL,eAAe,CAACQ,OAAO,CAAC;aAAAkB,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAE3E,OAAO,CACH;IACIhC,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACkB,OAAO;IACtBoB,OAAO;IACP1B,QAAQ;IACR+B,cAAc,EAAED,YAAY;IAC5BE,YAAY,EAAEH,UAAU;IACxB1C;GACH,EACDyC,UAAU,CACb;AACL;;;;"}
|
1
|
+
{"version":3,"file":"useTableDataLoader.js","sources":["../../../../../../../src/primitives/Table/useTableDataLoader.ts"],"sourcesContent":["import React from 'react';\nimport {\n TableColumnFilter,\n TableColumnSort,\n TableFilterHandler,\n TableServerLoadPageHandler,\n TableServerLoadAllHandler,\n TableSortHandler,\n TableSearchHandler,\n} from './types';\n\nexport const DEFAULT_PAGE_SIZE = 100;\n\nexport type useTableDataPageFetcher<TType = unknown> = (\n pageIndex: number,\n pageSize: number,\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataAllFetcher<TType = unknown> = (\n sorting: TableColumnSort[],\n filters: TableColumnFilter[]\n) => Promise<{ data: TType[]; length: number }>;\n\nexport type useTableDataLoaderOptions = { pageSize: number };\n\nexport type useTableDataLoaderValues<TType = unknown> = {\n data: TType[];\n length: number | undefined;\n loadAll: TableServerLoadAllHandler;\n loadPage: TableServerLoadPageHandler;\n onChangeFilter: TableFilterHandler;\n onChangeSearch: TableSearchHandler;\n onChangeSort: TableSortHandler;\n pageSize: number;\n};\n\nexport function useTableDataLoader<TType = unknown>(\n fetchPage: useTableDataPageFetcher<TType>,\n fetchAll: useTableDataAllFetcher<TType>,\n options: useTableDataLoaderOptions = { pageSize: DEFAULT_PAGE_SIZE }\n): [useTableDataLoaderValues<TType>, () => void] {\n const { pageSize } = options;\n\n // track the data length, we don't know it until the first request\n const length = React.useRef<number | undefined>(undefined);\n // data will be filled after the first request, then we'll update values in place\n const [data, setData] = React.useState<any[]>([]);\n // track which pages have been loaded to dedupe requests\n const _pendingPageRequests = React.useRef({});\n const _lastUsedSorting = React.useRef<TableColumnSort[]>([]);\n const _lastUsedFilters = React.useRef<TableColumnFilter[]>([]);\n const _lastUsedSearch = React.useRef<string>();\n const _forceReset = React.useRef(false);\n\n const loadPage = async (pageIndex: number, sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n let reset = false;\n\n // sorting or filters changed, reset everything\n if (\n _forceReset.current ||\n JSON.stringify(sorting) !== JSON.stringify(_lastUsedSorting.current) ||\n JSON.stringify(filters) !== JSON.stringify(_lastUsedFilters.current)\n ) {\n _pendingPageRequests.current = {};\n // nuke the dataset so that we \"start again\" after sorting\n reset = true;\n }\n\n if (_pendingPageRequests.current[pageIndex]) {\n // if page is already loaded/loading, abort, otherwise mark it as loading\n return;\n } else {\n _pendingPageRequests.current[pageIndex] = true;\n }\n\n _forceReset.current = false;\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchPage(pageIndex, pageSize, sorting, filters);\n\n // update state, here we do some \"magic\" to support \"load in place\"\n setData(currentData => {\n let nextData;\n\n // reset table state if:\n // - the length isn't set at all (first load)\n // - the client length and server length are different (the data changed)\n if (reset || length.current !== response.length) {\n length.current = response.length;\n nextData = Array(length.current).fill(undefined);\n } else {\n nextData = [...currentData];\n }\n\n const startIndex = pageIndex * pageSize;\n nextData.splice(startIndex, pageSize, ...response.data);\n return nextData;\n });\n } catch {\n //\n } finally {\n _pendingPageRequests.current[pageIndex] = false;\n }\n };\n\n const loadAll = async (sorting: TableColumnSort[], filters: TableColumnFilter[]) => {\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n try {\n const response = await fetchAll(sorting, filters);\n length.current = response.length;\n\n setData(() => {\n let nextData;\n\n if (response.data.length !== response.length) {\n nextData = Array(response.length).fill(undefined);\n nextData.splice(0, response.data.length, ...response.data);\n } else {\n nextData = [...response.data];\n }\n\n return nextData;\n });\n } catch {\n //\n }\n };\n\n const invalidate = async () => {\n _forceReset.current = true;\n return loadPage(0, _lastUsedSorting.current, _lastUsedFilters.current);\n };\n\n // search works client side - it fetches all then works client side - so these handlers are a little \"weird\"\n // if a search is currently \"active\", we need to re load all because\n const handleSort = async (sorting: TableColumnSort[]) => {\n // set the sorting so we can track if it changed between loads\n _lastUsedSorting.current = sorting;\n\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n loadAll(sorting, _lastUsedFilters.current);\n } else {\n // reset the page to 0 whenever sorting\n loadPage(0, sorting, _lastUsedFilters.current);\n }\n };\n const handleFilter = async (filters: TableColumnFilter[]) => {\n // set the filters so we can track if it changed between loads\n _lastUsedFilters.current = filters;\n\n if (_lastUsedSearch.current) {\n // we're searching, which means we need to refetch all with the correct sorting applied\n loadAll(_lastUsedSorting.current, filters);\n } else {\n // reset the page to 0 whenever sorting\n loadPage(0, _lastUsedSorting.current, filters);\n }\n };\n const handleSearch = async (search: string | undefined) => {\n // set the search so we can track if it changed between loads\n _lastUsedSearch.current = search || undefined;\n // search works client side, and focusing the search field triggers a load of all so we don't actually\n // want to load anything when search gets changed, we just store the value for other handlers\n };\n\n return [\n {\n data,\n length: length.current,\n loadAll,\n loadPage,\n onChangeFilter: handleFilter,\n onChangeSearch: handleSearch,\n onChangeSort: handleSort,\n pageSize,\n },\n invalidate,\n ];\n}\n"],"names":["DEFAULT_PAGE_SIZE","useTableDataLoader","fetchPage","fetchAll","options","pageSize","length","React","useRef","undefined","data","setData","useState","_pendingPageRequests","_lastUsedSorting","_lastUsedFilters","_lastUsedSearch","_forceReset","loadPage","pageIndex","sorting","filters","reset","current","JSON","stringify","Promise","resolve","_temp","_finallyRethrows","_catch","then","response","currentData","nextData","Array","fill","startIndex","splice","_wasThrown","_result","e","reject","loadAll","_temp2","invalidate","handleSort","handleFilter","handleSearch","search","onChangeFilter","onChangeSearch","onChangeSort"],"mappings":";;;MAWaA,iBAAiB,GAAG;SA2BjBC,kBAAkBA,CAC9BC,SAAyC,EACzCC,QAAuC,EACvCC,UAAqC;EAAEC,QAAQ,EAAEL;CAAmB;EAEpE,MAAM;IAAEK;GAAU,GAAGD,OAAO;;EAG5B,MAAME,MAAM,GAAGC,cAAK,CAACC,MAAM,CAAqBC,SAAS,CAAC;;EAE1D,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGJ,cAAK,CAACK,QAAQ,CAAQ,EAAE,CAAC;;EAEjD,MAAMC,oBAAoB,GAAGN,cAAK,CAACC,MAAM,CAAC,EAAE,CAAC;EAC7C,MAAMM,gBAAgB,GAAGP,cAAK,CAACC,MAAM,CAAoB,EAAE,CAAC;EAC5D,MAAMO,gBAAgB,GAAGR,cAAK,CAACC,MAAM,CAAsB,EAAE,CAAC;EAC9D,MAAMQ,eAAe,GAAGT,cAAK,CAACC,MAAM,EAAU;EAC9C,MAAMS,WAAW,GAAGV,cAAK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AA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EACD,MAAMO,YAAY,aAAUC,MAA0B;IAAA;;MAElDjC,eAAe,CAACO,OAAO,GAAG0B,MAAM,IAAIxC,SAAS;;;MAE7C,OAAAiB,OAAA,CAAAC,OAAA;KACH,QAAAc,CAAA;MAAA,OAAAf,OAAA,CAAAgB,MAAA,CAAAD,CAAA;;;EAED,OAAO,CACH;IACI/B,IAAI;IACJJ,MAAM,EAAEA,MAAM,CAACiB,OAAO;IACtBoB,OAAO;IACPzB,QAAQ;IACRgC,cAAc,EAAEH,YAAY;IAC5BI,cAAc,EAAEH,YAAY;IAC5BI,YAAY,EAAEN,UAAU;IACxBzC;GACH,EACDwC,UAAU,CACb;AACL;;;;"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { FontSizes } from '../../../../types.js';
|
3
|
-
import { getCellMinWidth } from '../util/columns.js';
|
3
|
+
import { isInternalColumn, getCellMinWidth } from '../util/columns.js';
|
4
4
|
import { useLazyEffect } from '../../../../hooks/useLazyEffect.js';
|
5
5
|
|
6
6
|
function useTableFontSizeListener(table) {
|
@@ -8,10 +8,17 @@ function useTableFontSizeListener(table) {
|
|
8
8
|
const previousFontSizeRef = React__default.useRef(meta.fontSize.size);
|
9
9
|
useLazyEffect(() => {
|
10
10
|
const cellWidthDifference = getCellWidthDifference(`${previousFontSizeRef.current}-${meta.fontSize.size}`);
|
11
|
+
const globalMinSize = getCellMinWidth(meta.fontSize.size);
|
11
12
|
table.setColumnSizing(sizes => {
|
12
|
-
const minColumnSize = getCellMinWidth(meta.fontSize.size);
|
13
13
|
return Object.fromEntries(Object.entries(sizes).map(([columnName, prevColumnSize]) => {
|
14
|
+
var _column$columnDef$min;
|
15
|
+
const column = table.getColumn(columnName);
|
16
|
+
if (isInternalColumn(columnName)) {
|
17
|
+
var _column$getSize;
|
18
|
+
return [columnName, (_column$getSize = column === null || column === void 0 ? void 0 : column.getSize()) !== null && _column$getSize !== void 0 ? _column$getSize : prevColumnSize];
|
19
|
+
}
|
14
20
|
// Prevents width value in the setting to go below the minColumnSize
|
21
|
+
const minColumnSize = (_column$columnDef$min = column === null || column === void 0 ? void 0 : column.columnDef.minSize) !== null && _column$columnDef$min !== void 0 ? _column$columnDef$min : globalMinSize;
|
15
22
|
const newSize = Math.max(minColumnSize, prevColumnSize + cellWidthDifference);
|
16
23
|
return [columnName, newSize];
|
17
24
|
}));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableFontSizeListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { FontSizes } from '../../../../types';\nimport { getCellMinWidth } from '../util/columns';\n\nexport function useTableFontSizeListener<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const previousFontSizeRef = React.useRef(meta.fontSize.size);\n\n useLazyEffect(() => {\n const cellWidthDifference = getCellWidthDifference(`${previousFontSizeRef.current}-${meta.fontSize.size}`);\n
|
1
|
+
{"version":3,"file":"useTableFontSizeListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableFontSizeListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { useLazyEffect } from '../../../../hooks/useLazyEffect';\nimport { FontSizes } from '../../../../types';\nimport { getCellMinWidth, isInternalColumn } from '../util/columns';\n\nexport function useTableFontSizeListener<TType = unknown>(table: ReactTable<TType>) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const previousFontSizeRef = React.useRef(meta.fontSize.size);\n\n useLazyEffect(() => {\n const cellWidthDifference = getCellWidthDifference(`${previousFontSizeRef.current}-${meta.fontSize.size}`);\n const globalMinSize = getCellMinWidth(meta.fontSize.size);\n\n table.setColumnSizing(sizes => {\n return Object.fromEntries(\n Object.entries(sizes).map(([columnName, prevColumnSize]) => {\n const column = table.getColumn(columnName);\n\n if (isInternalColumn(columnName)) {\n return [columnName, column?.getSize() ?? prevColumnSize];\n }\n\n // Prevents width value in the setting to go below the minColumnSize\n const minColumnSize = column?.columnDef.minSize ?? globalMinSize;\n const newSize = Math.max(minColumnSize, prevColumnSize + cellWidthDifference);\n return [columnName, newSize];\n })\n );\n });\n previousFontSizeRef.current = meta.fontSize.size;\n }, [meta.fontSize.size]);\n}\n\nfunction getCellWidthDifference(fontSizeKey: string) {\n switch (fontSizeKey) {\n case `${FontSizes.small}-${FontSizes.medium}`:\n case `${FontSizes.medium}-${FontSizes.large}`:\n return 8;\n\n case `${FontSizes.medium}-${FontSizes.small}`:\n case `${FontSizes.large}-${FontSizes.medium}`:\n return -8;\n\n case `${FontSizes.small}-${FontSizes.large}`:\n return 16;\n\n case `${FontSizes.large}-${FontSizes.small}`:\n return -16;\n\n default:\n return 0;\n }\n}\n"],"names":["useTableFontSizeListener","table","meta","options","previousFontSizeRef","React","useRef","fontSize","size","useLazyEffect","cellWidthDifference","getCellWidthDifference","current","globalMinSize","getCellMinWidth","setColumnSizing","sizes","Object","fromEntries","entries","map","columnName","prevColumnSize","column","getColumn","isInternalColumn","_column$getSize","getSize","minColumnSize","_column$columnDef$min","columnDef","minSize","newSize","Math","max","fontSizeKey","FontSizes","small","medium","large"],"mappings":";;;;;SAMgBA,wBAAwBA,CAAkBC,KAAwB;EAC9E,MAAMC,IAAI,GAAGD,KAAK,CAACE,OAAO,CAACD,IAA6B;EACxD,MAAME,mBAAmB,GAAGC,cAAK,CAACC,MAAM,CAACJ,IAAI,CAACK,QAAQ,CAACC,IAAI,CAAC;EAE5DC,aAAa,CAAC;IACV,MAAMC,mBAAmB,GAAGC,sBAAsB,IAAIP,mBAAmB,CAACQ,WAAWV,IAAI,CAACK,QAAQ,CAACC,MAAM,CAAC;IAC1G,MAAMK,aAAa,G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C,OAAO,CAAC,CAAC;IAEb,QAAQF,SAAS,CAACC,SAASD,SAAS,CAACG,OAAO;MACxC,OAAO,EAAE;IAEb,QAAQH,SAAS,CAACG,SAASH,SAAS,CAACC,OAAO;MACxC,OAAO,CAAC,EAAE;IAEd;MACI,OAAO,CAAC;;AAEpB;;;;"}
|
@@ -1,14 +1,18 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { resetHighlightedColumnIndexes } from '../util/search.js';
|
3
3
|
|
4
|
-
function useTableSearchListener(table) {
|
4
|
+
function useTableSearchListener(table, onChangeSearch) {
|
5
5
|
const meta = table.options.meta;
|
6
6
|
// recalculates highlighted indexes whenever something important changes
|
7
7
|
React__default.useEffect(() => {
|
8
8
|
if (meta.search.isEnabled) {
|
9
|
-
|
9
|
+
const query = table.getState().globalFilter;
|
10
|
+
resetHighlightedColumnIndexes(query, table);
|
11
|
+
if (typeof onChangeSearch === 'function') {
|
12
|
+
onChangeSearch(query);
|
13
|
+
}
|
10
14
|
}
|
11
|
-
}, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility)]);
|
15
|
+
}, [meta.server.loadAllStatus, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), JSON.stringify(table.getState().columnVisibility), onChangeSearch]);
|
12
16
|
}
|
13
17
|
|
14
18
|
export { useTableSearchListener };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSearchListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType
|
1
|
+
{"version":3,"file":"useTableSearchListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableSearchListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport { resetHighlightedColumnIndexes } from '../util/search';\nimport { TableSearchHandler } from '../../types';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n\n // recalculates highlighted indexes whenever something important changes\n React.useEffect(() => {\n if (meta.search.isEnabled) {\n const query = table.getState().globalFilter;\n resetHighlightedColumnIndexes(query, table);\n\n if (typeof onChangeSearch === 'function') {\n onChangeSearch(query);\n }\n }\n }, [\n meta.server.loadAllStatus,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows.length,\n table.getState().globalFilter,\n JSON.stringify(table.getState().sorting),\n JSON.stringify(table.getState().columnVisibility),\n onChangeSearch,\n ]);\n}\n"],"names":["useTableSearchListener","table","onChangeSearch","meta","options","React","useEffect","search","isEnabled","query","getState","globalFilter","resetHighlightedColumnIndexes","server","loadAllStatus","enableGlobalFilter","getRowModel","rows","length","JSON","stringify","sorting","columnVisibility"],"mappings":";;;SAKgBA,sBAAsBA,CAAkBC,KAAwB,EAAEC,cAAmC;EACjH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;;EAGxDE,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIH,IAAI,CAACI,MAAM,CAACC,SAAS,EAAE;MACvB,MAAMC,KAAK,GAAGR,KAAK,CAACS,QAAQ,EAAE,CAACC,YAAY;MAC3CC,6BAA6B,CAACH,KAAK,EAAER,KAAK,CAAC;MAE3C,IAAI,OAAOC,cAAc,KAAK,UAAU,EAAE;QACtCA,cAAc,CAACO,KAAK,CAAC;;;GAGhC,EAAE,CACCN,IAAI,CAACU,MAAM,CAACC,aAAa,EACzBX,IAAI,CAACI,MAAM,CAACC,SAAS,EACrBL,IAAI,CAACI,MAAM,CAACQ,kBAAkB,EAC9Bd,KAAK,CAACe,WAAW,EAAE,CAACC,IAAI,CAACC,MAAM,EAC/BjB,KAAK,CAACS,QAAQ,EAAE,CAACC,YAAY,EAC7BQ,IAAI,CAACC,SAAS,CAACnB,KAAK,CAACS,QAAQ,EAAE,CAACW,OAAO,CAAC,EACxCF,IAAI,CAACC,SAAS,CAACnB,KAAK,CAACS,QAAQ,EAAE,CAACY,gBAAgB,CAAC,EACjDpB,cAAc,CACjB,CAAC;AACN;;;;"}
|
@@ -3,11 +3,10 @@ import React__default from 'react';
|
|
3
3
|
function useTableServerLoadingListener(table, loadPage) {
|
4
4
|
const sorting = table.getState().sorting;
|
5
5
|
const columnFilters = table.getState().columnFilters;
|
6
|
-
const search = table.getState().globalFilter;
|
7
6
|
// trigger load of the first page on mount
|
8
7
|
React__default.useEffect(() => {
|
9
8
|
if (loadPage) {
|
10
|
-
loadPage(0, sorting, columnFilters
|
9
|
+
loadPage(0, sorting, columnFilters);
|
11
10
|
}
|
12
11
|
}, []);
|
13
12
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useTableServerLoadingListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { TableServerLoadPageHandler } from '../../types';\n\nexport function useTableServerLoadingListener<TType = unknown>(table: ReactTable<TType>, loadPage?: TableServerLoadPageHandler) {\n const sorting = table.getState().sorting;\n const columnFilters = table.getState().columnFilters;\n
|
1
|
+
{"version":3,"file":"useTableServerLoadingListener.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/listeners/useTableServerLoadingListener.ts"],"sourcesContent":["import React from 'react';\nimport { Table as ReactTable } from '@tanstack/react-table';\nimport { TableServerLoadPageHandler } from '../../types';\n\nexport function useTableServerLoadingListener<TType = unknown>(table: ReactTable<TType>, loadPage?: TableServerLoadPageHandler) {\n const sorting = table.getState().sorting;\n const columnFilters = table.getState().columnFilters;\n\n // trigger load of the first page on mount\n React.useEffect(() => {\n if (loadPage) {\n loadPage(0, sorting, columnFilters);\n }\n }, []);\n}\n"],"names":["useTableServerLoadingListener","table","loadPage","sorting","getState","columnFilters","React","useEffect"],"mappings":";;SAIgBA,6BAA6BA,CAAkBC,KAAwB,EAAEC,QAAqC;EAC1H,MAAMC,OAAO,GAAGF,KAAK,CAACG,QAAQ,EAAE,CAACD,OAAO;EACxC,MAAME,aAAa,GAAGJ,KAAK,CAACG,QAAQ,EAAE,CAACC,aAAa;;EAGpDC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIL,QAAQ,EAAE;MACVA,QAAQ,CAAC,CAAC,EAAEC,OAAO,EAAEE,aAAa,CAAC;;GAE1C,EAAE,EAAE,CAAC;AACV;;;;"}
|
@@ -109,7 +109,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
109
109
|
useTableFontSizeListener(instance);
|
110
110
|
useTableRowHeightListener(instance);
|
111
111
|
useTableRowSelectionListener(instance, props.onRowSelect);
|
112
|
-
useTableSearchListener(instance);
|
112
|
+
useTableSearchListener(instance, props.onChangeSearch);
|
113
113
|
useTableServerLoadingListener(instance, server.loadPage);
|
114
114
|
useTableSettingsListener(instance, setSettings);
|
115
115
|
useTableShortcutsListener(instance, props.shortcuts);
|