@economic/taco 2.41.4 → 2.42.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/components/AlertDialog/AlertDialog.d.ts +2 -0
- package/dist/components/AlertDialog/components/Content.d.ts +1 -1
- package/dist/components/Table3/util/editing.d.ts +2 -1
- package/dist/esm/packages/taco/src/components/AlertDialog/AlertDialog.js.map +1 -1
- package/dist/esm/packages/taco/src/components/AlertDialog/components/Content.js +31 -3
- package/dist/esm/packages/taco/src/components/AlertDialog/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Card/Card.js +7 -5
- package/dist/esm/packages/taco/src/components/Card/Card.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Popover/Primitives.js +2 -1
- package/dist/esm/packages/taco/src/components/Popover/Primitives.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js +7 -4
- package/dist/esm/packages/taco/src/components/Table3/features/useTableEditing.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js +6 -5
- package/dist/esm/packages/taco/src/components/Table3/util/editing.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Cell/util.js +3 -1
- 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/Header/Header.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/ManageFiltersPopover.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/components/FilterValue.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/util.js +5 -7
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Toolbar/components/Filters/util.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/useTableManager/listeners/useTableSearchListener.js +3 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js +4 -2
- 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 -17
- 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/dataTypes.js +62 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/dataTypes.js.map +1 -0
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/filtering.js +1 -15
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/filtering.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js +37 -7
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/search.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js +22 -8
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/setup.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js +4 -6
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/util/sorting.js.map +1 -1
- package/dist/primitives/Table/types.d.ts +1 -1
- package/dist/primitives/Table/useTableManager/util/columns.d.ts +2 -2
- package/dist/primitives/Table/useTableManager/util/dataTypes.d.ts +12 -0
- package/dist/primitives/Table/useTableManager/util/filtering.d.ts +0 -2
- package/dist/primitives/Table/useTableManager/util/search.d.ts +6 -2
- package/dist/primitives/Table/useTableManager/util/setup.d.ts +3 -2
- package/dist/primitives/Table/useTableManager/util/sorting.d.ts +2 -1
- package/dist/taco.cjs.development.js +319 -219
- 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
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"dataTypes.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/dataTypes.ts"],"sourcesContent":["import { SortingFnOption as ReactTableSortingFnOption } from '@tanstack/react-table';\nimport { isDate } from 'date-fns';\nimport { format, parseFromISOString } from '../../../../utils/date';\nimport { TableColumnAlignment, TableColumnDataType, TableFilterComparator } from '../../types';\nimport { Localization } from '../../../../components/Provider/Localization';\n\nexport type TableDataType<TType = unknown> = {\n align?: TableColumnAlignment;\n sortingFn: ReactTableSortingFnOption<TType>;\n filterComparators: TableFilterComparator[];\n getDisplayValue?: (value: any, options?: { localization: Localization }) => string;\n};\n\nconst dataTypes: Record<TableColumnDataType | 'auto', TableDataType> = {\n auto: {\n sortingFn: 'auto',\n filterComparators: [\n TableFilterComparator.Contains,\n TableFilterComparator.DoesNotContain,\n TableFilterComparator.IsEqualTo,\n TableFilterComparator.IsNotEqualTo,\n TableFilterComparator.IsEmpty,\n TableFilterComparator.IsNotEmpty,\n ],\n },\n // base\n text: {\n sortingFn: 'alphanumeric',\n filterComparators: [\n TableFilterComparator.Contains,\n TableFilterComparator.DoesNotContain,\n TableFilterComparator.IsEqualTo,\n TableFilterComparator.IsNotEqualTo,\n TableFilterComparator.IsEmpty,\n TableFilterComparator.IsNotEmpty,\n ],\n },\n number: {\n sortingFn: 'basic',\n filterComparators: [\n TableFilterComparator.IsEqualTo,\n TableFilterComparator.IsNotEqualTo,\n TableFilterComparator.IsGreaterThan,\n TableFilterComparator.IsLessThan,\n TableFilterComparator.IsGreaterThanOrEqualTo,\n TableFilterComparator.IsLessThanOrEqualTo,\n TableFilterComparator.IsBetween,\n TableFilterComparator.IsEmpty,\n TableFilterComparator.IsNotEmpty,\n ],\n },\n datetime: {\n sortingFn: 'datetime',\n filterComparators: [\n TableFilterComparator.IsEqualTo,\n TableFilterComparator.IsNotEqualTo,\n TableFilterComparator.IsGreaterThan,\n TableFilterComparator.IsLessThan,\n TableFilterComparator.IsGreaterThanOrEqualTo,\n TableFilterComparator.IsLessThanOrEqualTo,\n TableFilterComparator.IsBetween,\n TableFilterComparator.IsEmpty,\n TableFilterComparator.IsNotEmpty,\n ],\n getDisplayValue: (value: string | Date, options) => {\n if (value === undefined) {\n return '';\n }\n\n if (isDate(value)) {\n return format(value as Date, options?.localization?.formatting.date) ?? '';\n } else if (typeof value === 'string') {\n return format(parseFromISOString(value as string), options?.localization?.formatting.date) ?? '';\n }\n\n return String(value);\n },\n },\n boolean: {\n sortingFn: 'basic',\n filterComparators: [TableFilterComparator.IsEqualTo, TableFilterComparator.IsNotEqualTo],\n },\n // advanced\n amount: {\n align: 'right',\n sortingFn: 'basic',\n filterComparators: [\n TableFilterComparator.IsEqualTo,\n TableFilterComparator.IsNotEqualTo,\n TableFilterComparator.IsGreaterThan,\n TableFilterComparator.IsLessThan,\n TableFilterComparator.IsGreaterThanOrEqualTo,\n TableFilterComparator.IsLessThanOrEqualTo,\n TableFilterComparator.IsBetween,\n TableFilterComparator.IsEmpty,\n TableFilterComparator.IsNotEmpty,\n ],\n getDisplayValue: (value: number | bigint | string, options) => {\n if (value === undefined) {\n return '';\n }\n\n return new Intl.NumberFormat(options?.localization?.locale, { minimumFractionDigits: 2 }).format(Number(value));\n },\n },\n};\n\nexport function getDataTypeProperties<TType = unknown>(dataType: TableColumnDataType | undefined): TableDataType<TType> {\n return (dataTypes[dataType ?? 'text'] ?? dataTypes.text) as TableDataType<TType>;\n}\n"],"names":["dataTypes","auto","sortingFn","filterComparators","TableFilterComparator","Contains","DoesNotContain","IsEqualTo","IsNotEqualTo","IsEmpty","IsNotEmpty","text","number","IsGreaterThan","IsLessThan","IsGreaterThanOrEqualTo","IsLessThanOrEqualTo","IsBetween","datetime","getDisplayValue","value","options","undefined","isDate","_format","_options$localization","format","localization","formatting","date","_format2","_options$localization2","parseFromISOString","String","boolean","amount","align","Intl","NumberFormat","_options$localization3","locale","minimumFractionDigits","Number","getDataTypeProperties","dataType","_dataTypes"],"mappings":";;;;AAaA,MAAMA,SAAS,GAAwD;EACnEC,IAAI,EAAE;IACFC,SAAS,EAAE,M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AAE;;MAGb,OAAO,IAAIe,IAAI,CAACC,YAAY,CAACjB,OAAO,aAAPA,OAAO,wBAAAkB,sBAAA,GAAPlB,OAAO,CAAEM,YAAY,cAAAY,sBAAA,uBAArBA,sBAAA,CAAuBC,MAAM,EAAE;QAAEC,qBAAqB,EAAE;OAAG,CAAC,CAACf,MAAM,CAACgB,MAAM,CAACtB,KAAK,CAAC,CAAC;;;CAG1H;SAEeuB,qBAAqBA,CAAkBC,QAAyC;;EAC5F,QAAAC,UAAA,GAAQ7C,SAAS,CAAC4C,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI,MAAM,CAAC,cAAAC,UAAA,cAAAA,UAAA,GAAI7C,SAAS,CAACW,IAAI;AAC3D;;;;"}
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import { isDate, isBefore, isAfter, isEqual } from 'date-fns';
|
2
2
|
import { isWeakEqual as isWeakEqual$1 } from '../../../../utils/date.js';
|
3
|
-
import { getCellValueAsString } from './columns.js';
|
4
3
|
import { TableFilterComparator } from '../../types.js';
|
5
4
|
|
6
5
|
const toLowerCase = value => String(value !== null && value !== void 0 ? value : '').toLocaleLowerCase();
|
@@ -113,19 +112,6 @@ function columnFilterFn(value, filter) {
|
|
113
112
|
return true;
|
114
113
|
}
|
115
114
|
}
|
116
|
-
function globalFilterFn(row, columnId, searchQuery) {
|
117
|
-
try {
|
118
|
-
if (row.original) {
|
119
|
-
var _row$_getAllCellsByCo, _row$_getAllCellsByCo2;
|
120
|
-
const dataType = (_row$_getAllCellsByCo = row._getAllCellsByColumnId()[columnId]) === null || _row$_getAllCellsByCo === void 0 ? void 0 : (_row$_getAllCellsByCo2 = _row$_getAllCellsByCo.column.columnDef.meta) === null || _row$_getAllCellsByCo2 === void 0 ? void 0 : _row$_getAllCellsByCo2.dataType;
|
121
|
-
const cellValue = getCellValueAsString(row.original[columnId], dataType);
|
122
|
-
return isWeakContains(cellValue, searchQuery);
|
123
|
-
}
|
124
|
-
} catch {
|
125
|
-
// we don't care, just fail silently and return no results
|
126
|
-
}
|
127
|
-
return false;
|
128
|
-
}
|
129
115
|
|
130
|
-
export { columnFilterFn,
|
116
|
+
export { columnFilterFn, isWeakContains, isWeakEqual, toLowerCase };
|
131
117
|
//# sourceMappingURL=filtering.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"filtering.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/filtering.ts"],"sourcesContent":["import { Row as ReactTableRow } from '@tanstack/react-table';\nimport { isDate, isAfter as isAfterDate, isBefore as isBeforeDate, isEqual as isEqualDate } from 'date-fns';\nimport { isWeakEqual as isWeakEqualDate } from '../../../../utils/date';\nimport { TableFilterValue, TableFilterComparator } from '../../types';\nimport { getCellValueAsString } from './columns';\n\nexport const toLowerCase = (value: string | number) => String(value ?? '').toLocaleLowerCase();\nexport const isWeakContains = (left: string | number, right: string | number) => toLowerCase(left).includes(toLowerCase(right));\nexport const isWeakEqual = (left: string | number, right: string | number) => toLowerCase(left) === toLowerCase(right);\n\n// the filter type is only settable on the column definition, which would re-render all columns.\n// so instead we store it in the filter value, but that means we also have to destructure that\n// before we filter - that's why this custom filter function exists\nexport function columnFilterFn(value: any, filter: TableFilterValue) {\n try {\n if (filter.comparator === TableFilterComparator.IsEmpty || filter.comparator === TableFilterComparator.IsNotEmpty) {\n const isEmpty = value === undefined || value === null || value === '';\n return filter.comparator === TableFilterComparator.IsEmpty ? isEmpty : !isEmpty;\n }\n\n if (filter.value === undefined || filter.value === null || filter.value === '') {\n return true;\n }\n\n switch (filter.comparator) {\n case TableFilterComparator.Contains:\n return isWeakContains(value, filter.value);\n\n case TableFilterComparator.DoesNotContain:\n return !isWeakContains(value, filter.value);\n\n case TableFilterComparator.IsEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && isWeakEqualDate(value, filter.value);\n } else if (typeof filter.value === 'boolean') {\n return value === filter.value;\n }\n\n return isWeakEqual(value, filter.value);\n }\n\n case TableFilterComparator.IsNotEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && isWeakEqualDate(value, filter.value) === false;\n } else if (typeof filter.value === 'boolean') {\n return value !== filter.value;\n }\n\n return !isWeakEqual(value, filter.value);\n }\n\n case TableFilterComparator.IsGreaterThan: {\n if (isDate(value)) {\n return isDate(filter.value) && isAfterDate(value, filter.value);\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber > filter.value;\n }\n }\n\n case TableFilterComparator.IsLessThan: {\n if (isDate(value)) {\n return isDate(filter.value) && isBeforeDate(value, filter.value);\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber < filter.value;\n }\n }\n\n case TableFilterComparator.IsLessThanOrEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && (isBeforeDate(value, filter.value) || isEqualDate(value, filter.value));\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber <= filter.value;\n }\n }\n\n case TableFilterComparator.IsGreaterThanOrEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && (isAfterDate(value, filter.value) || isEqualDate(value, filter.value));\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber >= filter.value;\n }\n }\n\n case TableFilterComparator.IsBetween: {\n const [fromValue, toValue] = filter.value;\n\n if (isDate(value)) {\n if (isDate(fromValue) && isBeforeDate(value, fromValue)) {\n return false;\n } else if (isDate(toValue) && isAfterDate(value, toValue)) {\n return false;\n }\n\n return true;\n } else {\n const valueAsNumber = parseInt(value);\n\n if (isNaN(valueAsNumber)) {\n return false;\n }\n\n if (fromValue !== undefined && valueAsNumber < fromValue) {\n return false;\n } else if (toValue !== undefined && valueAsNumber > toValue) {\n return false;\n }\n\n return true;\n }\n }\n\n case TableFilterComparator.HasAnyOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.some(item => value.includes(item))\n : false;\n\n case TableFilterComparator.HasNoneOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.every(item => value.includes(item) === false)\n : false;\n\n case TableFilterComparator.HasAllOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.filter(v => value.includes(v)).length === filter.value.length\n : false;\n }\n\n return false;\n } catch (e) {\n console.error(e);\n return true;\n }\n}\n\nexport function globalFilterFn<TType = unknown>(row: ReactTableRow<TType>, columnId: string, searchQuery: string) {\n try {\n if (row.original) {\n const dataType = row._getAllCellsByColumnId()[columnId]?.column.columnDef.meta?.dataType;\n const cellValue = getCellValueAsString(row.original[columnId], dataType);\n return isWeakContains(cellValue, searchQuery);\n }\n } catch {\n // we don't care, just fail silently and return no results\n }\n\n return false;\n}\n"],"names":["toLowerCase","value","String","toLocaleLowerCase","isWeakContains","left","right","includes","isWeakEqual","columnFilterFn","filter","comparator","TableFilterComparator","IsEmpty","IsNotEmpty","isEmpty","undefined","Contains","DoesNotContain","IsEqualTo","isDate","isWeakEqualDate","IsNotEqualTo","IsGreaterThan","isAfterDate","valueAsNumber","parseInt","isNaN","IsLessThan","isBeforeDate","IsLessThanOrEqualTo","isEqualDate","IsGreaterThanOrEqualTo","IsBetween","fromValue","toValue","HasAnyOf","Array","isArray","some","item","HasNoneOf","every","HasAllOf","v","length","e","console","error","globalFilterFn","row","columnId","searchQuery","original","_row$_getAllCellsByCo","_row$_getAllCellsByCo2","dataType","_getAllCellsByColumnId","column","columnDef","meta","cellValue","getCellValueAsString"],"mappings":";;;;;MAMaA,WAAW,GAAIC,KAAsB,IAAKC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC,CAACE,iBAAiB;MAC/EC,cAAc,GAAGA,CAACC,IAAqB,EAAEC,KAAsB,KAAKN,WAAW,CAACK,IAAI,CAAC,CAACE,QAAQ,CAACP,WAAW,CAACM,KAAK,CAAC;MACjHE,WAAW,GAAGA,CAACH,IAAqB,EAAEC,KAAsB,KAAKN,W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CAAkBC,GAAyB,EAAEC,QAAgB,EAAEC,WAAmB;EAC5G,IAAI;IACA,IAAIF,GAAG,CAACG,QAAQ,EAAE;MAAA,IAAAC,qBAAA,EAAAC,sBAAA;MACd,MAAMC,QAAQ,IAAAF,qBAAA,GAAGJ,GAAG,CAACO,sBAAsB,EAAE,CAACN,QAAQ,CAAC,cAAAG,qBAAA,wBAAAC,sBAAA,GAAtCD,qBAAA,CAAwCI,MAAM,CAACC,SAAS,CAACC,IAAI,cAAAL,sBAAA,uBAA7DA,sBAAA,CAA+DC,QAAQ;MACxF,MAAMK,SAAS,GAAGC,oBAAoB,CAACZ,GAAG,CAACG,QAAQ,CAACF,QAAQ,CAAC,EAAEK,QAAQ,CAAC;MACxE,OAAOpD,cAAc,CAACyD,SAAS,EAAET,WAAW,CAAC;;GAEpD,CAAC,MAAM;;;EAIR,OAAO,KAAK;AAChB;;;;"}
|
1
|
+
{"version":3,"file":"filtering.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/filtering.ts"],"sourcesContent":["import { isDate, isAfter as isAfterDate, isBefore as isBeforeDate, isEqual as isEqualDate } from 'date-fns';\nimport { isWeakEqual as isWeakEqualDate } from '../../../../utils/date';\nimport { TableFilterValue, TableFilterComparator } from '../../types';\n\nexport const toLowerCase = (value: string | number) => String(value ?? '').toLocaleLowerCase();\nexport const isWeakContains = (left: string | number, right: string | number) => toLowerCase(left).includes(toLowerCase(right));\nexport const isWeakEqual = (left: string | number, right: string | number) => toLowerCase(left) === toLowerCase(right);\n\n// the filter type is only settable on the column definition, which would re-render all columns.\n// so instead we store it in the filter value, but that means we also have to destructure that\n// before we filter - that's why this custom filter function exists\nexport function columnFilterFn(value: any, filter: TableFilterValue) {\n try {\n if (filter.comparator === TableFilterComparator.IsEmpty || filter.comparator === TableFilterComparator.IsNotEmpty) {\n const isEmpty = value === undefined || value === null || value === '';\n return filter.comparator === TableFilterComparator.IsEmpty ? isEmpty : !isEmpty;\n }\n\n if (filter.value === undefined || filter.value === null || filter.value === '') {\n return true;\n }\n\n switch (filter.comparator) {\n case TableFilterComparator.Contains:\n return isWeakContains(value, filter.value);\n\n case TableFilterComparator.DoesNotContain:\n return !isWeakContains(value, filter.value);\n\n case TableFilterComparator.IsEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && isWeakEqualDate(value, filter.value);\n } else if (typeof filter.value === 'boolean') {\n return value === filter.value;\n }\n\n return isWeakEqual(value, filter.value);\n }\n\n case TableFilterComparator.IsNotEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && isWeakEqualDate(value, filter.value) === false;\n } else if (typeof filter.value === 'boolean') {\n return value !== filter.value;\n }\n\n return !isWeakEqual(value, filter.value);\n }\n\n case TableFilterComparator.IsGreaterThan: {\n if (isDate(value)) {\n return isDate(filter.value) && isAfterDate(value, filter.value);\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber > filter.value;\n }\n }\n\n case TableFilterComparator.IsLessThan: {\n if (isDate(value)) {\n return isDate(filter.value) && isBeforeDate(value, filter.value);\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber < filter.value;\n }\n }\n\n case TableFilterComparator.IsLessThanOrEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && (isBeforeDate(value, filter.value) || isEqualDate(value, filter.value));\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber <= filter.value;\n }\n }\n\n case TableFilterComparator.IsGreaterThanOrEqualTo: {\n if (isDate(value)) {\n return isDate(filter.value) && (isAfterDate(value, filter.value) || isEqualDate(value, filter.value));\n } else {\n const valueAsNumber = parseInt(value);\n return !isNaN(valueAsNumber) && filter.value !== undefined && valueAsNumber >= filter.value;\n }\n }\n\n case TableFilterComparator.IsBetween: {\n const [fromValue, toValue] = filter.value;\n\n if (isDate(value)) {\n if (isDate(fromValue) && isBeforeDate(value, fromValue)) {\n return false;\n } else if (isDate(toValue) && isAfterDate(value, toValue)) {\n return false;\n }\n\n return true;\n } else {\n const valueAsNumber = parseInt(value);\n\n if (isNaN(valueAsNumber)) {\n return false;\n }\n\n if (fromValue !== undefined && valueAsNumber < fromValue) {\n return false;\n } else if (toValue !== undefined && valueAsNumber > toValue) {\n return false;\n }\n\n return true;\n }\n }\n\n case TableFilterComparator.HasAnyOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.some(item => value.includes(item))\n : false;\n\n case TableFilterComparator.HasNoneOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.every(item => value.includes(item) === false)\n : false;\n\n case TableFilterComparator.HasAllOf:\n return Array.isArray(filter.value) && Array.isArray(value)\n ? filter.value.filter(v => value.includes(v)).length === filter.value.length\n : false;\n }\n\n return false;\n } catch (e) {\n console.error(e);\n return true;\n }\n}\n"],"names":["toLowerCase","value","String","toLocaleLowerCase","isWeakContains","left","right","includes","isWeakEqual","columnFilterFn","filter","comparator","TableFilterComparator","IsEmpty","IsNotEmpty","isEmpty","undefined","Contains","DoesNotContain","IsEqualTo","isDate","isWeakEqualDate","IsNotEqualTo","IsGreaterThan","isAfterDate","valueAsNumber","parseInt","isNaN","IsLessThan","isBeforeDate","IsLessThanOrEqualTo","isEqualDate","IsGreaterThanOrEqualTo","IsBetween","fromValue","toValue","HasAnyOf","Array","isArray","some","item","HasNoneOf","every","HasAllOf","v","length","e","console","error"],"mappings":";;;;MAIaA,WAAW,GAAIC,KAAsB,IAAKC,MAAM,CAACD,KAAK,aAALA,KAAK,cAALA,KAAK,GAAI,EAAE,CAAC,CAACE,iBAAiB;MAC/EC,cAAc,GAAGA,CAACC,IAAqB,EAAEC,KAAsB,KAAKN,WAAW,CAACK,IAAI,CAAC,CAACE,QAAQ,CAACP,WAAW,CAACM,KAAK,CAAC;MACjHE,WAAW,GAAGA,CAACH,IAAqB,EAAEC,KAAsB,KAAKN,WAAW,CAACK,IAAI,CAAC,KAAKL,WAAW,C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/get';
|
2
|
-
import {
|
2
|
+
import { getDataTypeProperties } from './dataTypes.js';
|
3
3
|
import { isWeakContains } from './filtering.js';
|
4
4
|
|
5
|
-
function
|
5
|
+
function isMatched(searchQuery, cellValue, dataType, localization) {
|
6
|
+
const cellValueAsString = String(cellValue !== null && cellValue !== void 0 ? cellValue : '');
|
7
|
+
if (cellValueAsString !== undefined && isWeakContains(cellValueAsString, searchQuery)) {
|
8
|
+
return true;
|
9
|
+
} else {
|
10
|
+
const dataTypeProperties = getDataTypeProperties(dataType);
|
11
|
+
if (dataTypeProperties.getDisplayValue) {
|
12
|
+
const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, {
|
13
|
+
localization
|
14
|
+
});
|
15
|
+
if (cellDisplayValue !== undefined && isWeakContains(cellDisplayValue, searchQuery)) {
|
16
|
+
return true;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
function globalFilterFn(row, columnId, searchQuery, localization) {
|
23
|
+
try {
|
24
|
+
if (row.original) {
|
25
|
+
var _row$_getAllCellsByCo, _row$_getAllCellsByCo2;
|
26
|
+
const cellValue = row.original[columnId];
|
27
|
+
const dataType = (_row$_getAllCellsByCo = row._getAllCellsByColumnId()[columnId]) === null || _row$_getAllCellsByCo === void 0 ? void 0 : (_row$_getAllCellsByCo2 = _row$_getAllCellsByCo.column.columnDef.meta) === null || _row$_getAllCellsByCo2 === void 0 ? void 0 : _row$_getAllCellsByCo2.dataType;
|
28
|
+
return isMatched(searchQuery, cellValue, dataType, localization);
|
29
|
+
}
|
30
|
+
} catch {
|
31
|
+
// we don't care, just fail silently and return no results
|
32
|
+
}
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
function resetHighlightedColumnIndexes(searchQuery, table, localization) {
|
6
36
|
const tableMeta = table.options.meta;
|
7
37
|
let firstRowIndex;
|
8
|
-
if (
|
38
|
+
if (searchQuery) {
|
9
39
|
const indexes = [];
|
10
40
|
const columns = table.getVisibleLeafColumns();
|
11
41
|
const rowGrouping = table.getState().grouping;
|
@@ -25,9 +55,9 @@ function resetHighlightedColumnIndexes(value, table) {
|
|
25
55
|
}
|
26
56
|
if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {
|
27
57
|
var _column$columnDef$met;
|
28
|
-
const cellValue =
|
29
|
-
|
30
|
-
if (
|
58
|
+
const cellValue = get(row.original, column.id);
|
59
|
+
const dataType = (_column$columnDef$met = column.columnDef.meta) === null || _column$columnDef$met === void 0 ? void 0 : _column$columnDef$met.dataType;
|
60
|
+
if (isMatched(searchQuery, cellValue, dataType, localization)) {
|
31
61
|
indexes.push([rowIndex, columnIndex]);
|
32
62
|
}
|
33
63
|
}
|
@@ -53,5 +83,5 @@ function resetHighlightedColumnIndexes(value, table) {
|
|
53
83
|
return firstRowIndex;
|
54
84
|
}
|
55
85
|
|
56
|
-
export { resetHighlightedColumnIndexes };
|
86
|
+
export { globalFilterFn, isMatched, resetHighlightedColumnIndexes };
|
57
87
|
//# sourceMappingURL=search.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"search.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/search.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta } from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport {
|
1
|
+
{"version":3,"file":"search.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/search.ts"],"sourcesContent":["import { Table as ReactTable, TableMeta as ReactTableMeta, Row as ReactTableRow } from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { isWeakContains } from './filtering';\nimport { getDataTypeProperties } from './dataTypes';\nimport { TableColumnDataType } from '../../types';\nimport { Localization } from '../../../../components/Provider/Localization';\n\nexport function isMatched<TType = unknown>(\n searchQuery: string,\n cellValue: any,\n dataType: TableColumnDataType | undefined,\n localization: Localization\n) {\n const cellValueAsString = String(cellValue ?? '');\n\n if (cellValueAsString !== undefined && isWeakContains(cellValueAsString, searchQuery)) {\n return true;\n } else {\n const dataTypeProperties = getDataTypeProperties<TType>(dataType);\n\n if (dataTypeProperties.getDisplayValue) {\n const cellDisplayValue = dataTypeProperties.getDisplayValue(cellValue, { localization });\n\n if (cellDisplayValue !== undefined && isWeakContains(cellDisplayValue, searchQuery)) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function globalFilterFn<TType = unknown>(\n row: ReactTableRow<TType>,\n columnId: string,\n searchQuery: string,\n localization: Localization\n) {\n try {\n if (row.original) {\n const cellValue = row.original[columnId];\n const dataType = row._getAllCellsByColumnId()[columnId]?.column.columnDef.meta?.dataType;\n return isMatched(searchQuery, cellValue, dataType, localization);\n }\n } catch {\n // we don't care, just fail silently and return no results\n }\n\n return false;\n}\n\nexport function resetHighlightedColumnIndexes<TType = unknown>(\n searchQuery: string | undefined,\n table: ReactTable<TType>,\n localization: Localization\n) {\n const tableMeta = table.options.meta as ReactTableMeta<TType>;\n let firstRowIndex: undefined | number;\n\n if (searchQuery) {\n const indexes: number[][] = [];\n const columns = table.getVisibleLeafColumns();\n const rowGrouping = table.getState().grouping;\n\n table.getRowModel().rows.forEach((row, rowIndex) => {\n columns.forEach((column, columnIndex) => {\n try {\n let allowSearch = true;\n\n if (rowGrouping?.length) {\n // if it's the grouped row, only allow search of the grouped column - because that's all that's visible\n if (row.getIsGrouped()) {\n allowSearch = column.getIsGrouped();\n }\n // otherwise for other rows, don't search the grouped column - because it isn't visible\n else if (rowGrouping.includes(column.id)) {\n allowSearch = false;\n }\n }\n\n if (column.getIsVisible() && column.columnDef.enableGlobalFilter && allowSearch) {\n const cellValue = get(row.original, column.id);\n const dataType = column.columnDef.meta?.dataType;\n\n if (isMatched(searchQuery, cellValue, dataType, localization)) {\n indexes.push([rowIndex, columnIndex]);\n }\n }\n } catch (e) {\n //\n }\n });\n });\n\n tableMeta.search.setHighlightedColumnIndexes(indexes);\n\n if (indexes.length) {\n firstRowIndex = indexes[0][0];\n tableMeta.search.setCurrentHighlightColumnIndex(0);\n } else {\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n } else {\n tableMeta.search.setHighlightedColumnIndexes([]);\n tableMeta.search.setCurrentHighlightColumnIndex(undefined);\n }\n\n if (firstRowIndex !== undefined) {\n tableMeta.rowActive.setRowActiveIndex(firstRowIndex);\n }\n\n return firstRowIndex;\n}\n"],"names":["isMatched","searchQuery","cellValue","dataType","localization","cellValueAsString","String","undefined","isWeakContains","dataTypeProperties","getDataTypeProperties","getDisplayValue","cellDisplayValue","globalFilterFn","row","columnId","original","_row$_getAllCellsByCo","_row$_getAllCellsByCo2","_getAllCellsByColumnId","column","columnDef","meta","resetHighlightedColumnIndexes","table","tableMeta","options","firstRowIndex","indexes","columns","getVisibleLeafColumns","rowGrouping","getState","grouping","getRowModel","rows","forEach","rowIndex","columnIndex","allowSearch","length","getIsGrouped","includes","id","getIsVisible","enableGlobalFilter","_column$columnDef$met","get","push","e","search","setHighlightedColumnIndexes","setCurrentHighlightColumnIndex","rowActive","setRowActiveIndex"],"mappings":";;;;SAOgBA,SAASA,CACrBC,WAAmB,EACnBC,SAAc,EACdC,QAAyC,EACzCC,YAA0B;EAE1B,MAAMC,iBAAiB,GAAGC,MAAM,CAACJ,SAAS,aAATA,SAAS,cAATA,SAAS,GAAI,EAAE,CAAC;EAEjD,IAAIG,iBAAiB,KAAKE,SAAS,IAAIC,cAAc,CAACH,iBAAiB,EAAEJ,WAAW,CAAC,EAAE;IACnF,OAAO,IAAI;GACd,MAAM;IACH,MAAMQ,kBAAkB,GAAGC,qBAAqB,CAAQP,QAAQ,CAAC;IAEjE,IAAIM,kBAAkB,CAACE,eAAe,EAAE;MACpC,MAAMC,gBAAgB,GAAGH,kBAAkB,CAACE,eAAe,CAACT,SAAS,EAAE;QAAEE;OAAc,CAAC;MAExF,IAAIQ,gBAAgB,KAAKL,SAAS,IAAIC,cAAc,CAACI,gBAAgB,EAAEX,WAAW,CAAC,EAAE;QACjF,OAAO,IAAI;;;;EAKvB,OAAO,KAAK;AA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;EAGxD,OAAOA,aAAa;AACxB;;;;"}
|
@@ -1,13 +1,15 @@
|
|
1
1
|
import React__default from 'react';
|
2
2
|
import { getExpandedRowModel, getGroupedRowModel, getFilteredRowModel, getSortedRowModel, createColumnHelper } from '@tanstack/react-table';
|
3
3
|
import get from 'lodash-es/get';
|
4
|
+
import { getDataTypeProperties } from './dataTypes.js';
|
4
5
|
import { getSortingFn } from './sorting.js';
|
6
|
+
import { columnFilterFn } from './filtering.js';
|
7
|
+
import { globalFilterFn } from './search.js';
|
5
8
|
import { ensureOrdering, freezeUptoExternalColumn, unfreezeAllExternalColumns, getCellMinWidth } from './columns.js';
|
6
|
-
import { columnFilterFn, globalFilterFn } from './filtering.js';
|
7
9
|
import { ignoreInternalColumns } from './settings.js';
|
8
10
|
|
9
11
|
// mapping children to react-table columns
|
10
|
-
function processChildren(child, columns, defaultSizing, defaultSorting, defaultVisibility, settings, defaultRowGroupColumnId) {
|
12
|
+
function processChildren(child, columns, defaultSizing, defaultSorting, defaultVisibility, settings, defaultRowGroupColumnId, localization) {
|
11
13
|
const columnHelper = createColumnHelper();
|
12
14
|
if (/*#__PURE__*/React__default.isValidElement(child) && child.props.children) {
|
13
15
|
const {
|
@@ -18,11 +20,12 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
|
|
18
20
|
columns.push(columnHelper.group({
|
19
21
|
id,
|
20
22
|
header,
|
21
|
-
columns: React__default.Children.toArray(children).reduce((columns, child) => processChildren(child, columns, defaultSizing, defaultSorting, defaultVisibility, settings, defaultRowGroupColumnId), []),
|
23
|
+
columns: React__default.Children.toArray(children).reduce((columns, child) => processChildren(child, columns, defaultSizing, defaultSorting, defaultVisibility, settings, defaultRowGroupColumnId, localization), []),
|
22
24
|
// we don't want to let column groups be grouped/aggregrated
|
23
25
|
enableGrouping: false
|
24
26
|
}));
|
25
27
|
} else if (/*#__PURE__*/React__default.isValidElement(child) && (child.props.accessor || child.props.id)) {
|
28
|
+
var _meta$align;
|
26
29
|
const {
|
27
30
|
id: untypedId,
|
28
31
|
accessor: accessorKey = untypedId,
|
@@ -51,6 +54,7 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
|
|
51
54
|
...meta
|
52
55
|
} = child.props;
|
53
56
|
const id = untypedId;
|
57
|
+
const dataTypeProperties = getDataTypeProperties(child.props.dataType);
|
54
58
|
if (defaultHidden && enableHiding) {
|
55
59
|
defaultVisibility[id] = false;
|
56
60
|
}
|
@@ -83,6 +87,7 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
|
|
83
87
|
// meta
|
84
88
|
meta: {
|
85
89
|
...meta,
|
90
|
+
align: (_meta$align = meta.align) !== null && _meta$align !== void 0 ? _meta$align : dataTypeProperties.align,
|
86
91
|
defaultWidth,
|
87
92
|
enableOrdering: isGrouped ? false : enableOrdering,
|
88
93
|
enablePrinting,
|
@@ -92,9 +97,18 @@ function processChildren(child, columns, defaultSizing, defaultSorting, defaultV
|
|
92
97
|
renderer
|
93
98
|
}
|
94
99
|
};
|
95
|
-
// renderers
|
100
|
+
// renderers - use defined renderers first, then fall back to data type renderers (if there is one)
|
96
101
|
if (typeof renderer === 'function') {
|
97
102
|
column.cell = info => renderer(info.getValue(), info.row.original);
|
103
|
+
} else if (dataTypeProperties.getDisplayValue) {
|
104
|
+
const dataTypeRenderer = value => {
|
105
|
+
var _dataTypeProperties$g, _dataTypeProperties$g2;
|
106
|
+
return (_dataTypeProperties$g = (_dataTypeProperties$g2 = dataTypeProperties.getDisplayValue) === null || _dataTypeProperties$g2 === void 0 ? void 0 : _dataTypeProperties$g2.call(dataTypeProperties, value, {
|
107
|
+
localization
|
108
|
+
})) !== null && _dataTypeProperties$g !== void 0 ? _dataTypeProperties$g : value;
|
109
|
+
};
|
110
|
+
column.cell = info => dataTypeRenderer(info.getValue());
|
111
|
+
column.meta.renderer = dataTypeRenderer;
|
98
112
|
}
|
99
113
|
if (typeof footer === 'function') {
|
100
114
|
column.footer = info => footer(info.table.getRowModel().rows.flatMap(row => row.original !== undefined ? row.original : []));
|
@@ -148,7 +162,7 @@ function createInternalColumn(id, column, defaultSizing) {
|
|
148
162
|
}
|
149
163
|
};
|
150
164
|
}
|
151
|
-
function mapTableChildrenToColumns(props, settings, options, internalColumns) {
|
165
|
+
function mapTableChildrenToColumns(props, settings, options, internalColumns, localization) {
|
152
166
|
const {
|
153
167
|
children,
|
154
168
|
defaultRowGroupColumnId
|
@@ -156,7 +170,7 @@ function mapTableChildrenToColumns(props, settings, options, internalColumns) {
|
|
156
170
|
const defaultSizing = {};
|
157
171
|
const defaultSorting = [];
|
158
172
|
const defaultVisibility = {};
|
159
|
-
const columns = React__default.Children.toArray(children).reduce((columns, child) => processChildren(child, columns, defaultSizing, defaultSorting, defaultVisibility, settings, defaultRowGroupColumnId), []);
|
173
|
+
const columns = React__default.Children.toArray(children).reduce((columns, child) => processChildren(child, columns, defaultSizing, defaultSorting, defaultVisibility, settings, defaultRowGroupColumnId, localization), []);
|
160
174
|
if (internalColumns) {
|
161
175
|
var _props$rowActions;
|
162
176
|
if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {
|
@@ -183,7 +197,7 @@ function mapTableChildrenToColumns(props, settings, options, internalColumns) {
|
|
183
197
|
defaultVisibility
|
184
198
|
};
|
185
199
|
}
|
186
|
-
function configureReactTableOptions(options, props) {
|
200
|
+
function configureReactTableOptions(options, props, localization) {
|
187
201
|
var _options$enableFilter, _options$enableColumn, _options$enableRowExp, _options$enableColumn2, _options$enableColumn3, _options$enableSortin;
|
188
202
|
const enableRowSelection = options.enableRowSelection || options.enableRowSelectionSingle;
|
189
203
|
// We don't want to expose internal Tanstack Table row, so we need to wrap enableRowSelection callback into additional function,
|
@@ -230,7 +244,7 @@ function configureReactTableOptions(options, props) {
|
|
230
244
|
if (options.enableSearch) {
|
231
245
|
// always set these because enableGlobalFilter can be toggled on and off by the user
|
232
246
|
tableOptions.getFilteredRowModel = getFilteredRowModel();
|
233
|
-
tableOptions.globalFilterFn = globalFilterFn;
|
247
|
+
tableOptions.globalFilterFn = (row, columnId, searchQuery) => globalFilterFn(row, columnId, searchQuery, localization);
|
234
248
|
tableOptions.getColumnCanGlobalFilter = column => {
|
235
249
|
var _column$columnDef$met, _column$columnDef$met2;
|
236
250
|
return (_column$columnDef$met = (_column$columnDef$met2 = column.columnDef.meta) === null || _column$columnDef$met2 === void 0 ? void 0 : _column$columnDef$met2.enableSearch) !== null && _column$columnDef$met !== void 0 ? _column$columnDef$met : true;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"setup.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/setup.ts"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n getExpandedRowModel,\n getFilteredRowModel,\n getGroupedRowModel,\n getSortedRowModel,\n TableOptions as ReactTableOptions,\n Row as ReactTableRow,\n Column as ReactTableColumn,\n ColumnDef as ReactTableColumnDef,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSizingState as ReactTableColumnSizingState,\n ColumnSort as ReactTableColumnSort,\n TableState as ReactTableState,\n VisibilityState as ReactTableVisibilityState,\n} from '@tanstack/react-table';\nimport get from 'lodash/get';\n\nimport { useTableManagerInternalColumns, useTableManagerInternalColumn } from '../types';\nimport { TableColumnProps, TableFeatureProps, TableGroupProps, TableProps, TableSettings } from '../../types';\nimport { getSortingFn } from './sorting';\nimport { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, unfreezeAllExternalColumns } from './columns';\nimport { columnFilterFn, globalFilterFn } from './filtering';\nimport { ignoreInternalColumns } from './settings';\n\n// mapping children to react-table columns\nfunction processChildren<TType>(\n child: React.ReactChild | React.ReactFragment | React.ReactPortal,\n columns: ReactTableColumnDef<TType>[],\n defaultSizing: ReactTableColumnSizingState,\n defaultSorting: ReactTableColumnSort[],\n defaultVisibility: ReactTableVisibilityState,\n settings: TableSettings,\n defaultRowGroupColumnId?: keyof TType\n): ReactTableColumnDef<TType>[] {\n const columnHelper = createColumnHelper<TType>();\n\n if (React.isValidElement<TableGroupProps>(child) && child.props.children) {\n const { children, id, header } = child.props;\n\n columns.push(\n columnHelper.group({\n id,\n header,\n columns: React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId\n ),\n []\n ),\n // we don't want to let column groups be grouped/aggregrated\n enableGrouping: false,\n })\n );\n } else if (React.isValidElement<TableColumnProps<TType>>(child) && (child.props.accessor || child.props.id)) {\n const {\n id: untypedId,\n accessor: accessorKey = untypedId,\n // renderers\n renderer,\n aggregate,\n footer,\n header,\n // options\n aggregationFn,\n defaultHidden,\n defaultWidth,\n enableEditing = !!child.props.control,\n enableFiltering: enableColumnFilter = true,\n enableGrouping = false,\n enableHiding = true,\n enableOrdering = true,\n enablePrinting = true,\n enableResizing = true,\n enableSearch: enableGlobalFilter = true,\n enableSorting = true,\n enableTruncate = false,\n minWidth: minSize = getCellMinWidth(settings.fontSize),\n sort,\n sortFn,\n ...meta\n } = child.props;\n const id = untypedId as string;\n\n if (defaultHidden && enableHiding) {\n defaultVisibility[id] = false;\n }\n\n if (defaultWidth) {\n defaultSizing[id] = defaultWidth as any;\n }\n\n const isGrouped = defaultRowGroupColumnId === id;\n\n if (child.props.sort !== undefined || isGrouped) {\n defaultSorting.push({\n id,\n desc: sort === 'desc',\n });\n }\n\n const column: ReactTableColumnDef<TType, any> = {\n id,\n accessorKey,\n // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure\n // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children\n accessorFn: row => get(row, accessorKey),\n header: header,\n // features\n enableColumnFilter,\n enableGlobalFilter,\n enableGrouping,\n enableHiding: isGrouped ? false : enableHiding,\n enableResizing,\n enableSorting,\n // config - sizing\n minSize,\n // meta\n meta: {\n ...(meta as any),\n defaultWidth,\n enableOrdering: isGrouped ? false : enableOrdering,\n enablePrinting,\n enableTruncate,\n enableEditing,\n header,\n renderer,\n },\n };\n\n // renderers\n if (typeof renderer === 'function') {\n column.cell = info => renderer(info.getValue(), info.row.original);\n }\n\n if (typeof footer === 'function') {\n column.footer = info =>\n footer(info.table.getRowModel().rows.flatMap(row => (row.original !== undefined ? row.original : [])));\n }\n\n // config - filtering\n if (enableColumnFilter) {\n column.filterFn = 'tacoFilter' as any;\n }\n\n // config - grouping/aggregation\n if (enableGrouping) {\n column.aggregationFn = aggregationFn;\n\n if (typeof aggregate === 'function') {\n column.aggregatedCell = info => aggregate(info.getValue(), info.row.original);\n }\n }\n\n // config - sorting\n if (enableSorting) {\n column.sortingFn = getSortingFn<TType>(child.props.dataType, sortFn);\n column.sortDescFirst = false;\n column.sortUndefined = 1;\n }\n\n columns.push(column);\n }\n\n return columns;\n}\n\nfunction createInternalColumn<TType = unknown>(\n id: string,\n column: useTableManagerInternalColumn<TType>,\n defaultSizing: ReactTableColumnSizingState\n) {\n if (column.size) {\n defaultSizing[id] = column.size;\n }\n\n return {\n id,\n accessorKey: id,\n header: column.header,\n cell: column.renderer,\n // features\n enableColumnFilter: false,\n enableGlobalFilter: false,\n enableGrouping: false,\n enableHiding: false,\n enableResizing: false,\n enableSorting: false,\n // config - sizing\n size: column.size,\n minSize: column.size,\n // meta\n meta: {\n ...(column.meta as any),\n enableOrdering: false,\n enablePrinting: false,\n enableTruncate: false,\n },\n } as ReactTableColumnDef<TType, any>;\n}\n\nexport function mapTableChildrenToColumns<TType = unknown>(\n props: TableProps<TType>,\n settings: TableSettings,\n options: TableFeatureProps<TType>,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const { children, defaultRowGroupColumnId } = props;\n const defaultSizing: ReactTableColumnSizingState = {};\n const defaultSorting: ReactTableColumnSort[] = [];\n const defaultVisibility: ReactTableVisibilityState = {};\n\n const columns = React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId\n ),\n\n []\n );\n\n if (internalColumns) {\n if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {\n const column = createInternalColumn<TType>('__expansion', internalColumns.rowExpansion, defaultSizing);\n columns.unshift(column);\n }\n\n if ((options.enableRowSelection || options.enableRowSelectionSingle) && internalColumns.rowSelection) {\n const column = createInternalColumn<TType>('__select', internalColumns.rowSelection, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowDrag && props.onRowDrag && internalColumns.rowDrag) {\n const column = createInternalColumn<TType>('__drag', internalColumns.rowDrag, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowActions && props.rowActions?.length && internalColumns.rowActions) {\n const column = createInternalColumn<TType>('__actions', internalColumns.rowActions, defaultSizing);\n columns.push(column);\n }\n }\n\n return { columns, defaultSizing, defaultSorting, defaultVisibility };\n}\n\nexport function configureReactTableOptions<TType = unknown>(options: TableFeatureProps<TType>, props: TableProps<TType>) {\n const enableRowSelection = options.enableRowSelection || options.enableRowSelectionSingle;\n // We don't want to expose internal Tanstack Table row, so we need to wrap enableRowSelection callback into additional function,\n // which receives the React Table Row object and passes row.original to a callback.\n const reactTableEnableRowSelection =\n typeof enableRowSelection === 'function'\n ? (row: ReactTableRow<TType>) => (enableRowSelection as (row: TType) => boolean)(row.original)\n : enableRowSelection;\n\n const tableOptions: Partial<ReactTableOptions<TType>> = {\n defaultColumn: {\n enableColumnFilter: options.enableFiltering || true,\n enableGrouping: false,\n enableHiding: options.enableColumnHiding || true,\n enableResizing: options.enableColumnResizing || true,\n enableGlobalFilter: options.enableSearch || true,\n enableSorting: options.enableSorting || true,\n minSize: 1,\n // the default is 150, which is a bit random\n size: 1,\n },\n enableColumnFilters: options.enableFiltering ?? false,\n enableColumnResizing: options.enableColumnResizing ?? false,\n enableExpanding: options.enableRowExpansion ?? false,\n enableGrouping: true, // users can't customise row grouping, so it can just be always enabled and left to the defaultRowGroupColumnId prop\n enableHiding: options.enableColumnHiding ?? false,\n enablePinning: options.enableColumnFreezing ?? false,\n enableRowSelection: reactTableEnableRowSelection ?? false,\n enableMultiRowSelection: !options.enableRowSelectionSingle && reactTableEnableRowSelection,\n enableSorting: options.enableSorting ?? false,\n // models for default features\n getExpandedRowModel: getExpandedRowModel<TType>(),\n getGroupedRowModel: getGroupedRowModel<TType>(),\n groupedColumnMode: false,\n };\n\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n if (tableOptions.enableColumnFilters) {\n // enter controlled filter mode (controlled could be local state, but usually the server)\n if (props.onChangeFilter) {\n // tableOptions.manualFiltering = true;\n // we don't set it because it breaks global filtering (used for search, which is fully client side)\n //\n // tableOptions.onColumnFiltersChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onFilter\n } else {\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.filterFns = {\n tacoFilter: (row: ReactTableRow<TType>, columnId: string, filter: any) =>\n columnFilterFn(row.getValue(columnId), filter),\n };\n }\n }\n\n if (options.enableSearch) {\n // always set these because enableGlobalFilter can be toggled on and off by the user\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.globalFilterFn = globalFilterFn;\n tableOptions.getColumnCanGlobalFilter = (column: ReactTableColumn<TType>) => column.columnDef.meta?.enableSearch ?? true;\n\n // enter controlled search mode (controlled could be local state, but usually the server)\n if (props.onChangeSearch) {\n // tableOptions.manualFiltering = true;\n // we don't set this because controlled search is not currently supported, search is always client side\n //\n // tableOptions.onGlobalFilterChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSearch.\n //\n // we also don't always filter when searching, we have the highlight functionality as the default\n // and filtering can be toggled by the user\n }\n }\n\n if (tableOptions.enableSorting) {\n // enter controlled sort mode (controlled could be local state, but usually the server)\n if (props.onChangeSort) {\n tableOptions.manualSorting = true;\n\n // tableOptions.onSortingChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSort\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n\nexport function useReactTableInitialState<TType = unknown>(\n props: TableProps<TType>,\n columns: ReactTableColumnDef<TType>[],\n persistedSettings: TableSettings,\n defaults: {\n defaultSizing: ReactTableColumnSizingState;\n defaultSorting: ReactTableColumnSort[];\n defaultVisibility: ReactTableVisibilityState;\n }\n): Partial<ReactTableState> {\n return React.useMemo(() => {\n const ignoreNotDefinedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const columnPinning: ReactTableColumnPinningState =\n persistedSettings.columnPinning ?? props.defaultSettings?.columnPinning ?? {};\n\n const columnOrder = ensureOrdering<TType>(\n columns,\n persistedSettings.columnOrder ?? props.defaultSettings?.columnOrder,\n columnPinning.left\n );\n\n // ensure internal columns are pinned, and are pinned in the correct order\n if (columnPinning?.left?.length) {\n columnPinning.left = freezeUptoExternalColumn(\n columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]),\n columnOrder\n );\n } else {\n if (props.defaultColumnFreezingIndex) {\n columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);\n } else {\n columnPinning.left = unfreezeAllExternalColumns(columnOrder);\n }\n }\n\n const state: Partial<ReactTableState> = {\n columnFilters: persistedSettings.columnFilters ?? props.defaultSettings?.columnFilters ?? [],\n columnOrder,\n columnPinning,\n columnSizing: ignoreInternalColumns(\n persistedSettings.columnSizing ?? props.defaultSettings?.columnSizing ?? defaults.defaultSizing ?? {}\n ),\n columnVisibility:\n persistedSettings.columnVisibility ?? props.defaultSettings?.columnVisibility ?? defaults.defaultVisibility ?? {},\n globalFilter: persistedSettings.searchQuery ?? props.defaultSettings?.searchQuery,\n sorting: persistedSettings.sorting\n ? persistedSettings.sorting.filter(ignoreNotDefinedColumns)\n : props.defaultSettings?.sorting ?? defaults.defaultSorting,\n };\n\n if (props.defaultRowGroupColumnId) {\n state.grouping = [props.defaultRowGroupColumnId as string];\n // row groups should (all) always be expanded by default\n state.expanded = true;\n }\n\n return state;\n }, []);\n}\n"],"names":["processChildren","child","columns","defaultSizing","defaultSorting","defaultVisibility","settings","defaultRowGroupColumnId","columnHelper","createColumnHelper","React","isValidElement","props","children","id","header","push","group","Children","toArray","reduce","enableGrouping","accessor","untypedId","accessorKey","renderer","aggregate","footer","aggregationFn","defaultHidden","defaultWidth","enableEditing","control","enableFiltering","enableColumnFilter","enableHiding","enableOrdering","enablePrinting","enableResizing","enableSearch","enableGlobalFilter","enableSorting","enableTruncate","minWidth","minSize","getCellMinWidth","fontSize","sort","sortFn","meta","isGrouped","undefined","desc","column","accessorFn","row","get","cell","info","getValue","original","table","getRowModel","rows","flatMap","filterFn","aggregatedCell","sortingFn","getSortingFn","dataType","sortDescFirst","sortUndefined","createInternalColumn","size","mapTableChildrenToColumns","options","internalColumns","_props$rowActions","enableRowExpansion","rowExpansionRenderer","rowExpansion","unshift","enableRowSelection","enableRowSelectionSingle","rowSelection","enableRowDrag","onRowDrag","rowDrag","enableRowActions","rowActions","length","configureReactTableOptions","reactTableEnableRowSelection","tableOptions","defaultColumn","enableColumnHiding","enableColumnResizing","enableColumnFilters","_options$enableFilter","_options$enableColumn","enableExpanding","_options$enableRowExp","_options$enableColumn2","enablePinning","_options$enableColumn3","enableColumnFreezing","enableMultiRowSelection","_options$enableSortin","getExpandedRowModel","getGroupedRowModel","groupedColumnMode","columnResizeMode","onChangeFilter","getFilteredRowModel","filterFns","tacoFilter","columnId","filter","columnFilterFn","globalFilterFn","getColumnCanGlobalFilter","_column$columnDef$met","_column$columnDef$met2","columnDef","onChangeSort","manualSorting","getSortedRowModel","useReactTableInitialState","persistedSettings","defaults","useMemo","ignoreNotDefinedColumns","find","definedColumn","columnPinning","_ref","_persistedSettings$co","_props$defaultSetting","defaultSettings","columnOrder","ensureOrdering","_persistedSettings$co2","_props$defaultSetting2","left","_columnPinning$left","freezeUptoExternalColumn","indexOf","defaultColumnFreezingIndex","unfreezeAllExternalColumns","state","columnFilters","_ref2","_persistedSettings$co3","_props$defaultSetting3","columnSizing","ignoreInternalColumns","_ref3","_ref4","_persistedSettings$co4","_props$defaultSetting4","columnVisibility","_ref5","_ref6","_persistedSettings$co5","_props$defaultSetting5","globalFilter","_persistedSettings$se","searchQuery","_props$defaultSetting6","sorting","_props$defaultSetting7","_props$defaultSetting8","grouping","expanded"],"mappings":";;;;;;;;AA0BA;AACA,SAASA,eAAeA,CACpBC,KAAiE,EACjEC,OAAqC,EACrCC,aAA0C,EAC1CC,cAAsC,EACtCC,iBAA4C,EAC5CC,QAAuB,EACvBC,uBAAqC;EAErC,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;EAEhD,iBAAIC,cAAK,CAACC,cAAc,CAAkBV,KAAK,CAAC,IAAIA,KAAK,CAACW,KAAK,CAACC,QAAQ,EAAE;IACtE,MAAM;MAAEA,QAAQ;MAAEC,EAAE;MAAEC;KAAQ,GAAGd,KAAK,CAACW,KAAK;IAE5CV,OAAO,CAACc,IAAI,CACRR,YAAY,CAACS,KAAK,CAAC;MACfH,EAAE;MACFC,MAAM;MACNb,OAAO,EAAEQ,cAAK,CAACQ,QAAQ,CAACC,OAAO,CAACN,QAAQ,CAAC,CAACO,MAAM,CAC5C,CAAClB,OAAqC,EAAED,KAAK,KACzCD,eAAe,CACXC,KAAK,EACLC,OAAO,EACPC,aAAa,EACbC,cAAc,EACdC,iBAAiB,EACjBC,QAAQ,EACRC,uBAAuB,CAC1B,EACL,EAAE,CACL;;MAEDc,cAAc,EAAE;KACnB,CAAC,CACL;GACJ,MAAM,iBAAIX,cAAK,CAACC,cAAc,CAA0BV,KAAK,CAAC,KAAKA,KAAK,CAACW,KAAK,CAACU,QAAQ,IAAIrB,KAAK,CAACW,KAAK,CAACE,EAAE,CAAC,EAAE;IACzG,MAAM;MACFA,EAAE,EAAES,SAAS;MACbD,QAAQ,EAAEE,WAAW,GAAGD,SAAS;;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AAC,sBAAA,GACzD/J,KAAK,CAAC8H,eAAe,cAAAiC,sBAAA,uBAArBA,sBAAA,CAAuBF,OAAO,cAAAC,sBAAA,cAAAA,sBAAA,GAAIzC,QAAQ,CAAC7H;KACpD;IAED,IAAIQ,KAAK,CAACL,uBAAuB,EAAE;MAC/B8I,KAAK,CAACuB,QAAQ,GAAG,CAAChK,KAAK,CAACL,uBAAiC,CAAC;;MAE1D8I,KAAK,CAACwB,QAAQ,GAAG,IAAI;;IAGzB,OAAOxB,KAAK;GACf,EAAE,EAAE,CAAC;AACV;;;;"}
|
1
|
+
{"version":3,"file":"setup.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/setup.ts"],"sourcesContent":["import React from 'react';\nimport {\n createColumnHelper,\n getExpandedRowModel,\n getFilteredRowModel,\n getGroupedRowModel,\n getSortedRowModel,\n TableOptions as ReactTableOptions,\n Row as ReactTableRow,\n Column as ReactTableColumn,\n ColumnDef as ReactTableColumnDef,\n ColumnPinningState as ReactTableColumnPinningState,\n ColumnSizingState as ReactTableColumnSizingState,\n ColumnSort as ReactTableColumnSort,\n TableState as ReactTableState,\n VisibilityState as ReactTableVisibilityState,\n} from '@tanstack/react-table';\nimport get from 'lodash/get';\nimport { useTableManagerInternalColumns, useTableManagerInternalColumn } from '../types';\nimport { TableColumnProps, TableFeatureProps, TableGroupProps, TableProps, TableSettings } from '../../types';\nimport { getSortingFn } from './sorting';\nimport { ensureOrdering, freezeUptoExternalColumn, getCellMinWidth, unfreezeAllExternalColumns } from './columns';\nimport { columnFilterFn } from './filtering';\nimport { globalFilterFn } from './search';\nimport { ignoreInternalColumns } from './settings';\nimport { getDataTypeProperties } from './dataTypes';\nimport { Localization } from '../../../../components/Provider/Localization';\n\n// mapping children to react-table columns\nfunction processChildren<TType>(\n child: React.ReactChild | React.ReactFragment | React.ReactPortal,\n columns: ReactTableColumnDef<TType>[],\n defaultSizing: ReactTableColumnSizingState,\n defaultSorting: ReactTableColumnSort[],\n defaultVisibility: ReactTableVisibilityState,\n settings: TableSettings,\n defaultRowGroupColumnId: keyof TType | undefined,\n localization: Localization\n): ReactTableColumnDef<TType>[] {\n const columnHelper = createColumnHelper<TType>();\n\n if (React.isValidElement<TableGroupProps>(child) && child.props.children) {\n const { children, id, header } = child.props;\n\n columns.push(\n columnHelper.group({\n id,\n header,\n columns: React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n []\n ),\n // we don't want to let column groups be grouped/aggregrated\n enableGrouping: false,\n })\n );\n } else if (React.isValidElement<TableColumnProps<TType>>(child) && (child.props.accessor || child.props.id)) {\n const {\n id: untypedId,\n accessor: accessorKey = untypedId,\n // renderers\n renderer,\n aggregate,\n footer,\n header,\n // options\n aggregationFn,\n defaultHidden,\n defaultWidth,\n enableEditing = !!child.props.control,\n enableFiltering: enableColumnFilter = true,\n enableGrouping = false,\n enableHiding = true,\n enableOrdering = true,\n enablePrinting = true,\n enableResizing = true,\n enableSearch: enableGlobalFilter = true,\n enableSorting = true,\n enableTruncate = false,\n minWidth: minSize = getCellMinWidth(settings.fontSize),\n sort,\n sortFn,\n ...meta\n } = child.props;\n const id = untypedId as string;\n const dataTypeProperties = getDataTypeProperties<TType>(child.props.dataType);\n\n if (defaultHidden && enableHiding) {\n defaultVisibility[id] = false;\n }\n\n if (defaultWidth) {\n defaultSizing[id] = defaultWidth as any;\n }\n\n const isGrouped = defaultRowGroupColumnId === id;\n\n if (child.props.sort !== undefined || isGrouped) {\n defaultSorting.push({\n id,\n desc: sort === 'desc',\n });\n }\n\n const column: ReactTableColumnDef<TType, any> = {\n id,\n accessorKey,\n // To avoid errors caused by undefined row data values, we pass accessorFn as a preventive measure\n // accessorKey can be dot notated strings, so we use lodash.get to access deeply nested children\n accessorFn: row => get(row, accessorKey),\n header: header,\n // features\n enableColumnFilter,\n enableGlobalFilter,\n enableGrouping,\n enableHiding: isGrouped ? false : enableHiding,\n enableResizing,\n enableSorting,\n // config - sizing\n minSize,\n // meta\n meta: {\n ...(meta as any),\n align: meta.align ?? dataTypeProperties.align,\n defaultWidth,\n enableOrdering: isGrouped ? false : enableOrdering,\n enablePrinting,\n enableTruncate,\n enableEditing,\n header,\n renderer,\n },\n };\n\n // renderers - use defined renderers first, then fall back to data type renderers (if there is one)\n if (typeof renderer === 'function') {\n column.cell = info => renderer(info.getValue(), info.row.original);\n } else if (dataTypeProperties.getDisplayValue) {\n const dataTypeRenderer = (value: any) => dataTypeProperties.getDisplayValue?.(value, { localization }) ?? value;\n column.cell = info => dataTypeRenderer(info.getValue());\n (column.meta as any).renderer = dataTypeRenderer;\n }\n\n if (typeof footer === 'function') {\n column.footer = info =>\n footer(info.table.getRowModel().rows.flatMap(row => (row.original !== undefined ? row.original : [])));\n }\n\n // config - filtering\n if (enableColumnFilter) {\n column.filterFn = 'tacoFilter' as any;\n }\n\n // config - grouping/aggregation\n if (enableGrouping) {\n column.aggregationFn = aggregationFn;\n\n if (typeof aggregate === 'function') {\n column.aggregatedCell = info => aggregate(info.getValue(), info.row.original);\n }\n }\n\n // config - sorting\n if (enableSorting) {\n column.sortingFn = getSortingFn<TType>(child.props.dataType, sortFn);\n column.sortDescFirst = false;\n column.sortUndefined = 1;\n }\n\n columns.push(column);\n }\n\n return columns;\n}\n\nfunction createInternalColumn<TType = unknown>(\n id: string,\n column: useTableManagerInternalColumn<TType>,\n defaultSizing: ReactTableColumnSizingState\n) {\n if (column.size) {\n defaultSizing[id] = column.size;\n }\n\n return {\n id,\n accessorKey: id,\n header: column.header,\n cell: column.renderer,\n // features\n enableColumnFilter: false,\n enableGlobalFilter: false,\n enableGrouping: false,\n enableHiding: false,\n enableResizing: false,\n enableSorting: false,\n // config - sizing\n size: column.size,\n minSize: column.size,\n // meta\n meta: {\n ...(column.meta as any),\n enableOrdering: false,\n enablePrinting: false,\n enableTruncate: false,\n },\n } as ReactTableColumnDef<TType, any>;\n}\n\nexport function mapTableChildrenToColumns<TType = unknown>(\n props: TableProps<TType>,\n settings: TableSettings,\n options: TableFeatureProps<TType>,\n internalColumns: useTableManagerInternalColumns<TType> | undefined,\n localization: Localization\n) {\n const { children, defaultRowGroupColumnId } = props;\n const defaultSizing: ReactTableColumnSizingState = {};\n const defaultSorting: ReactTableColumnSort[] = [];\n const defaultVisibility: ReactTableVisibilityState = {};\n\n const columns = React.Children.toArray(children).reduce(\n (columns: ReactTableColumnDef<TType>[], child) =>\n processChildren<TType>(\n child,\n columns,\n defaultSizing,\n defaultSorting,\n defaultVisibility,\n settings,\n defaultRowGroupColumnId,\n localization\n ),\n\n []\n );\n\n if (internalColumns) {\n if (options.enableRowExpansion && props.rowExpansionRenderer && internalColumns.rowExpansion) {\n const column = createInternalColumn<TType>('__expansion', internalColumns.rowExpansion, defaultSizing);\n columns.unshift(column);\n }\n\n if ((options.enableRowSelection || options.enableRowSelectionSingle) && internalColumns.rowSelection) {\n const column = createInternalColumn<TType>('__select', internalColumns.rowSelection, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowDrag && props.onRowDrag && internalColumns.rowDrag) {\n const column = createInternalColumn<TType>('__drag', internalColumns.rowDrag, defaultSizing);\n columns.unshift(column);\n }\n\n if (options.enableRowActions && props.rowActions?.length && internalColumns.rowActions) {\n const column = createInternalColumn<TType>('__actions', internalColumns.rowActions, defaultSizing);\n columns.push(column);\n }\n }\n\n return { columns, defaultSizing, defaultSorting, defaultVisibility };\n}\n\nexport function configureReactTableOptions<TType = unknown>(\n options: TableFeatureProps<TType>,\n props: TableProps<TType>,\n localization: Localization\n) {\n const enableRowSelection = options.enableRowSelection || options.enableRowSelectionSingle;\n // We don't want to expose internal Tanstack Table row, so we need to wrap enableRowSelection callback into additional function,\n // which receives the React Table Row object and passes row.original to a callback.\n const reactTableEnableRowSelection =\n typeof enableRowSelection === 'function'\n ? (row: ReactTableRow<TType>) => (enableRowSelection as (row: TType) => boolean)(row.original)\n : enableRowSelection;\n\n const tableOptions: Partial<ReactTableOptions<TType>> = {\n defaultColumn: {\n enableColumnFilter: options.enableFiltering || true,\n enableGrouping: false,\n enableHiding: options.enableColumnHiding || true,\n enableResizing: options.enableColumnResizing || true,\n enableGlobalFilter: options.enableSearch || true,\n enableSorting: options.enableSorting || true,\n minSize: 1,\n // the default is 150, which is a bit random\n size: 1,\n },\n enableColumnFilters: options.enableFiltering ?? false,\n enableColumnResizing: options.enableColumnResizing ?? false,\n enableExpanding: options.enableRowExpansion ?? false,\n enableGrouping: true, // users can't customise row grouping, so it can just be always enabled and left to the defaultRowGroupColumnId prop\n enableHiding: options.enableColumnHiding ?? false,\n enablePinning: options.enableColumnFreezing ?? false,\n enableRowSelection: reactTableEnableRowSelection ?? false,\n enableMultiRowSelection: !options.enableRowSelectionSingle && reactTableEnableRowSelection,\n enableSorting: options.enableSorting ?? false,\n // models for default features\n getExpandedRowModel: getExpandedRowModel<TType>(),\n getGroupedRowModel: getGroupedRowModel<TType>(),\n groupedColumnMode: false,\n };\n\n if (tableOptions.enableColumnResizing) {\n tableOptions.columnResizeMode = 'onChange';\n }\n\n if (tableOptions.enableColumnFilters) {\n // enter controlled filter mode (controlled could be local state, but usually the server)\n if (props.onChangeFilter) {\n // tableOptions.manualFiltering = true;\n // we don't set it because it breaks global filtering (used for search, which is fully client side)\n //\n // tableOptions.onColumnFiltersChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onFilter\n } else {\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.filterFns = {\n tacoFilter: (row: ReactTableRow<TType>, columnId: string, filter: any) =>\n columnFilterFn(row.getValue(columnId), filter),\n };\n }\n }\n\n if (options.enableSearch) {\n // always set these because enableGlobalFilter can be toggled on and off by the user\n tableOptions.getFilteredRowModel = getFilteredRowModel<TType>();\n tableOptions.globalFilterFn = (row: ReactTableRow<TType>, columnId: string, searchQuery: any) =>\n globalFilterFn(row, columnId, searchQuery, localization);\n tableOptions.getColumnCanGlobalFilter = (column: ReactTableColumn<TType>) => column.columnDef.meta?.enableSearch ?? true;\n\n // enter controlled search mode (controlled could be local state, but usually the server)\n if (props.onChangeSearch) {\n // tableOptions.manualFiltering = true;\n // we don't set this because controlled search is not currently supported, search is always client side\n //\n // tableOptions.onGlobalFilterChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSearch.\n //\n // we also don't always filter when searching, we have the highlight functionality as the default\n // and filtering can be toggled by the user\n }\n }\n\n if (tableOptions.enableSorting) {\n // enter controlled sort mode (controlled could be local state, but usually the server)\n if (props.onChangeSort) {\n tableOptions.manualSorting = true;\n\n // tableOptions.onSortingChange = ...\n // we don't set this because it expects state to be maintained externally, and we don't want\n // consumers to control state outside the table. instead we have a listener that calls onSort\n } else {\n tableOptions.getSortedRowModel = getSortedRowModel();\n }\n }\n\n return tableOptions;\n}\n\nexport function useReactTableInitialState<TType = unknown>(\n props: TableProps<TType>,\n columns: ReactTableColumnDef<TType>[],\n persistedSettings: TableSettings,\n defaults: {\n defaultSizing: ReactTableColumnSizingState;\n defaultSorting: ReactTableColumnSort[];\n defaultVisibility: ReactTableVisibilityState;\n }\n): Partial<ReactTableState> {\n return React.useMemo(() => {\n const ignoreNotDefinedColumns = column => columns.find(definedColumn => definedColumn.id === column.id);\n\n const columnPinning: ReactTableColumnPinningState =\n persistedSettings.columnPinning ?? props.defaultSettings?.columnPinning ?? {};\n\n const columnOrder = ensureOrdering<TType>(\n columns,\n persistedSettings.columnOrder ?? props.defaultSettings?.columnOrder,\n columnPinning.left\n );\n\n // ensure internal columns are pinned, and are pinned in the correct order\n if (columnPinning?.left?.length) {\n columnPinning.left = freezeUptoExternalColumn(\n columnOrder.indexOf(columnPinning.left[columnPinning.left.length - 1]),\n columnOrder\n );\n } else {\n if (props.defaultColumnFreezingIndex) {\n columnPinning.left = freezeUptoExternalColumn(props.defaultColumnFreezingIndex, columnOrder);\n } else {\n columnPinning.left = unfreezeAllExternalColumns(columnOrder);\n }\n }\n\n const state: Partial<ReactTableState> = {\n columnFilters: persistedSettings.columnFilters ?? props.defaultSettings?.columnFilters ?? [],\n columnOrder,\n columnPinning,\n columnSizing: ignoreInternalColumns(\n persistedSettings.columnSizing ?? props.defaultSettings?.columnSizing ?? defaults.defaultSizing ?? {}\n ),\n columnVisibility:\n persistedSettings.columnVisibility ?? props.defaultSettings?.columnVisibility ?? defaults.defaultVisibility ?? {},\n globalFilter: persistedSettings.searchQuery ?? props.defaultSettings?.searchQuery,\n sorting: persistedSettings.sorting\n ? persistedSettings.sorting.filter(ignoreNotDefinedColumns)\n : props.defaultSettings?.sorting ?? defaults.defaultSorting,\n };\n\n if (props.defaultRowGroupColumnId) {\n state.grouping = [props.defaultRowGroupColumnId as string];\n // row groups should (all) always be expanded by default\n state.expanded = true;\n }\n\n return state;\n }, []);\n}\n"],"names":["processChildren","child","columns","defaultSizing","defaultSorting","defaultVisibility","settings","defaultRowGroupColumnId","localization","columnHelper","createColumnHelper","React","isValidElement","props","children","id","header","push","group","Children","toArray","reduce","enableGrouping","accessor","_meta$align","untypedId","accessorKey","renderer","aggregate","footer","aggregationFn","defaultHidden","defaultWidth","enableEditing","control","enableFiltering","enableColumnFilter","enableHiding","enableOrdering","enablePrinting","enableResizing","enableSearch","enableGlobalFilter","enableSorting","enableTruncate","minWidth","minSize","getCellMinWidth","fontSize","sort","sortFn","meta","dataTypeProperties","getDataTypeProperties","dataType","isGrouped","undefined","desc","column","accessorFn","row","get","align","cell","info","getValue","original","getDisplayValue","dataTypeRenderer","value","_dataTypeProperties$g","_dataTypeProperties$g2","call","table","getRowModel","rows","flatMap","filterFn","aggregatedCell","sortingFn","getSortingFn","sortDescFirst","sortUndefined","createInternalColumn","size","mapTableChildrenToColumns","options","internalColumns","_props$rowActions","enableRowExpansion","rowExpansionRenderer","rowExpansion","unshift","enableRowSelection","enableRowSelectionSingle","rowSelection","enableRowDrag","onRowDrag","rowDrag","enableRowActions","rowActions","length","configureReactTableOptions","reactTableEnableRowSelection","tableOptions","defaultColumn","enableColumnHiding","enableColumnResizing","enableColumnFilters","_options$enableFilter","_options$enableColumn","enableExpanding","_options$enableRowExp","_options$enableColumn2","enablePinning","_options$enableColumn3","enableColumnFreezing","enableMultiRowSelection","_options$enableSortin","getExpandedRowModel","getGroupedRowModel","groupedColumnMode","columnResizeMode","onChangeFilter","getFilteredRowModel","filterFns","tacoFilter","columnId","filter","columnFilterFn","globalFilterFn","searchQuery","getColumnCanGlobalFilter","_column$columnDef$met","_column$columnDef$met2","columnDef","onChangeSort","manualSorting","getSortedRowModel","useReactTableInitialState","persistedSettings","defaults","useMemo","ignoreNotDefinedColumns","find","definedColumn","columnPinning","_ref","_persistedSettings$co","_props$defaultSetting","defaultSettings","columnOrder","ensureOrdering","_persistedSettings$co2","_props$defaultSetting2","left","_columnPinning$left","freezeUptoExternalColumn","indexOf","defaultColumnFreezingIndex","unfreezeAllExternalColumns","state","columnFilters","_ref2","_persistedSettings$co3","_props$defaultSetting3","columnSizing","ignoreInternalColumns","_ref3","_ref4","_persistedSettings$co4","_props$defaultSetting4","columnVisibility","_ref5","_ref6","_persistedSettings$co5","_props$defaultSetting5","globalFilter","_persistedSettings$se","_props$defaultSetting6","sorting","_props$defaultSetting7","_props$defaultSetting8","grouping","expanded"],"mappings":";;;;;;;;;;AA4BA;AACA,SAASA,eAAeA,CACpBC,KAAiE,EACjEC,OAAqC,EACrCC,aAA0C,EAC1CC,cAAsC,EACtCC,iBAA4C,EAC5CC,QAAuB,EACvBC,uBAAgD,EAChDC,YAA0B;EAE1B,MAAMC,YAAY,GAAGC,kBAAkB,EAAS;EAEhD,iBAAIC,cAAK,CAACC,cAAc,CAAkBX,KAAK,CAAC,IAAIA,KAAK,CAACY,KAAK,CAACC,QAAQ,EAAE;IACtE,MAAM;MAAEA,QAAQ;MAAEC,EAAE;MAAEC;KAAQ,GAAGf,KAAK,CAACY,KAAK;IAE5CX,O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C,sBAAA,GAAItK,KAAK,CAACyI,eAAe,cAAA6B,sBAAA,uBAArBA,sBAAA,CAAuBhD,WAAW;MACjFiD,OAAO,EAAExC,iBAAiB,CAACwC,OAAO,GAC5BxC,iBAAiB,CAACwC,OAAO,CAACpD,MAAM,CAACe,uBAAuB,CAAC,IAAAsC,sBAAA,IAAAC,sBAAA,GACzDzK,KAAK,CAACyI,eAAe,cAAAgC,sBAAA,uBAArBA,sBAAA,CAAuBF,OAAO,cAAAC,sBAAA,cAAAA,sBAAA,GAAIxC,QAAQ,CAACzI;KACpD;IAED,IAAIS,KAAK,CAACN,uBAAuB,EAAE;MAC/B0J,KAAK,CAACsB,QAAQ,GAAG,CAAC1K,KAAK,CAACN,uBAAiC,CAAC;;MAE1D0J,KAAK,CAACuB,QAAQ,GAAG,IAAI;;IAGzB,OAAOvB,KAAK;GACf,EAAE,EAAE,CAAC;AACV;;;;"}
|
@@ -1,4 +1,7 @@
|
|
1
|
+
import { getDataTypeProperties } from './dataTypes.js';
|
2
|
+
|
1
3
|
function getSortingFn(dataType, customFnOrBuiltIn) {
|
4
|
+
// custom functions should override any that come from dataType
|
2
5
|
if (typeof customFnOrBuiltIn === 'function') {
|
3
6
|
return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);
|
4
7
|
}
|
@@ -6,12 +9,7 @@ function getSortingFn(dataType, customFnOrBuiltIn) {
|
|
6
9
|
if (customFnOrBuiltIn) {
|
7
10
|
return customFnOrBuiltIn;
|
8
11
|
}
|
9
|
-
|
10
|
-
if (dataType && dataType !== 'boolean' && dataType !== 'number') {
|
11
|
-
return dataType;
|
12
|
-
}
|
13
|
-
// otherwise fall back to auto
|
14
|
-
return 'auto';
|
12
|
+
return getDataTypeProperties(dataType).sortingFn;
|
15
13
|
}
|
16
14
|
|
17
15
|
export { getSortingFn };
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"sorting.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/sorting.ts"],"sourcesContent":["import { TableColumnDataType, TableColumnSortFn } from '../../types';\n\nexport function getSortingFn<TType = unknown>(dataType?: TableColumnDataType
|
1
|
+
{"version":3,"file":"sorting.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/util/sorting.ts"],"sourcesContent":["import { SortingFnOption } from '@tanstack/react-table';\nimport { TableColumnDataType, TableColumnSortFn } from '../../types';\nimport { getDataTypeProperties } from './dataTypes';\n\nexport function getSortingFn<TType = unknown>(\n dataType?: TableColumnDataType,\n customFnOrBuiltIn?: TableColumnSortFn<TType>\n): SortingFnOption<TType> | undefined {\n // custom functions should override any that come from dataType\n if (typeof customFnOrBuiltIn === 'function') {\n return (rowA, rowB, columnId) => customFnOrBuiltIn(rowA.original, rowB.original, columnId);\n }\n\n // if a built in is being used, just return that\n if (customFnOrBuiltIn) {\n return customFnOrBuiltIn;\n }\n\n return getDataTypeProperties<TType>(dataType).sortingFn;\n}\n"],"names":["getSortingFn","dataType","customFnOrBuiltIn","rowA","rowB","columnId","original","getDataTypeProperties","sortingFn"],"mappings":";;SAIgBA,YAAYA,CACxBC,QAA8B,EAC9BC,iBAA4C;;EAG5C,IAAI,OAAOA,iBAAiB,KAAK,UAAU,EAAE;IACzC,OAAO,CAACC,IAAI,EAAEC,IAAI,EAAEC,QAAQ,KAAKH,iBAAiB,CAACC,IAAI,CAACG,QAAQ,EAAEF,IAAI,CAACE,QAAQ,EAAED,QAAQ,CAAC;;;EAI9F,IAAIH,iBAAiB,EAAE;IACnB,OAAOA,iBAAiB;;EAG5B,OAAOK,qBAAqB,CAAQN,QAAQ,CAAC,CAACO,SAAS;AAC3D;;;;"}
|
@@ -36,7 +36,7 @@ export declare type TableFilter = {
|
|
36
36
|
};
|
37
37
|
export declare type TableColumnAlignment = 'left' | 'center' | 'right';
|
38
38
|
export declare type TableColumnClassNameHandler<TType = unknown> = string | ((row: TType) => string | undefined);
|
39
|
-
export declare type TableColumnDataType = '
|
39
|
+
export declare type TableColumnDataType = 'text' | 'number' | 'datetime' | 'boolean' | 'amount';
|
40
40
|
export declare type TableColumnFilter = ReactTableColumnFilter;
|
41
41
|
export declare type TableColumnMenu = ((columnId: string) => React.ReactNode | null)[];
|
42
42
|
export declare type TableColumnRenderer<TType, TValue> = (value: TValue, row: TType) => JSX.Element | string | number | null;
|
@@ -1,10 +1,10 @@
|
|
1
1
|
import { ColumnDef as ReactTableColumnDef } from '@tanstack/react-table';
|
2
2
|
import { FontSize } from '../../../../types';
|
3
3
|
import { TableColumnDataType } from '../../types';
|
4
|
+
import { Localization } from '../../../../components/Provider/Localization';
|
4
5
|
export declare function isInternalColumn(id: string | undefined): boolean | undefined;
|
5
6
|
export declare const getCellMinWidth: (fontSize?: FontSize) => 57 | 83 | 72;
|
6
|
-
export declare function isCellHighlighted(query: string, value: unknown, dataType
|
7
|
-
export declare function getCellValueAsString(value: unknown, dataType?: TableColumnDataType): string;
|
7
|
+
export declare function isCellHighlighted(query: string, value: unknown, dataType: TableColumnDataType | undefined, localization: Localization): boolean;
|
8
8
|
export declare function ensureOrdering<TType = unknown>(columns: ReactTableColumnDef<TType>[], settingsOrder: string[] | undefined, pinnedOrder?: string[] | undefined, internalColumnsPinnedToTheRight?: string[]): string[];
|
9
9
|
export declare function unfreezeAllExternalColumns(leftPinnedState?: string[]): string[];
|
10
10
|
export declare function freezeUptoExternalColumn(index: number, columns: string[]): string[];
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { SortingFnOption as ReactTableSortingFnOption } from '@tanstack/react-table';
|
2
|
+
import { TableColumnAlignment, TableColumnDataType, TableFilterComparator } from '../../types';
|
3
|
+
import { Localization } from '../../../../components/Provider/Localization';
|
4
|
+
export declare type TableDataType<TType = unknown> = {
|
5
|
+
align?: TableColumnAlignment;
|
6
|
+
sortingFn: ReactTableSortingFnOption<TType>;
|
7
|
+
filterComparators: TableFilterComparator[];
|
8
|
+
getDisplayValue?: (value: any, options?: {
|
9
|
+
localization: Localization;
|
10
|
+
}) => string;
|
11
|
+
};
|
12
|
+
export declare function getDataTypeProperties<TType = unknown>(dataType: TableColumnDataType | undefined): TableDataType<TType>;
|
@@ -1,7 +1,5 @@
|
|
1
|
-
import { Row as ReactTableRow } from '@tanstack/react-table';
|
2
1
|
import { TableFilterValue } from '../../types';
|
3
2
|
export declare const toLowerCase: (value: string | number) => string;
|
4
3
|
export declare const isWeakContains: (left: string | number, right: string | number) => boolean;
|
5
4
|
export declare const isWeakEqual: (left: string | number, right: string | number) => boolean;
|
6
5
|
export declare function columnFilterFn(value: any, filter: TableFilterValue): boolean;
|
7
|
-
export declare function globalFilterFn<TType = unknown>(row: ReactTableRow<TType>, columnId: string, searchQuery: string): boolean;
|
@@ -1,2 +1,6 @@
|
|
1
|
-
import { Table as ReactTable } from '@tanstack/react-table';
|
2
|
-
|
1
|
+
import { Table as ReactTable, Row as ReactTableRow } from '@tanstack/react-table';
|
2
|
+
import { TableColumnDataType } from '../../types';
|
3
|
+
import { Localization } from '../../../../components/Provider/Localization';
|
4
|
+
export declare function isMatched<TType = unknown>(searchQuery: string, cellValue: any, dataType: TableColumnDataType | undefined, localization: Localization): boolean;
|
5
|
+
export declare function globalFilterFn<TType = unknown>(row: ReactTableRow<TType>, columnId: string, searchQuery: string, localization: Localization): boolean;
|
6
|
+
export declare function resetHighlightedColumnIndexes<TType = unknown>(searchQuery: string | undefined, table: ReactTable<TType>, localization: Localization): number | undefined;
|
@@ -1,13 +1,14 @@
|
|
1
1
|
import { TableOptions as ReactTableOptions, ColumnDef as ReactTableColumnDef, ColumnSizingState as ReactTableColumnSizingState, ColumnSort as ReactTableColumnSort, TableState as ReactTableState, VisibilityState as ReactTableVisibilityState } from '@tanstack/react-table';
|
2
2
|
import { useTableManagerInternalColumns } from '../types';
|
3
3
|
import { TableFeatureProps, TableProps, TableSettings } from '../../types';
|
4
|
-
|
4
|
+
import { Localization } from '../../../../components/Provider/Localization';
|
5
|
+
export declare function mapTableChildrenToColumns<TType = unknown>(props: TableProps<TType>, settings: TableSettings, options: TableFeatureProps<TType>, internalColumns: useTableManagerInternalColumns<TType> | undefined, localization: Localization): {
|
5
6
|
columns: ReactTableColumnDef<TType, unknown>[];
|
6
7
|
defaultSizing: Record<string, number>;
|
7
8
|
defaultSorting: ReactTableColumnSort[];
|
8
9
|
defaultVisibility: Record<string, boolean>;
|
9
10
|
};
|
10
|
-
export declare function configureReactTableOptions<TType = unknown>(options: TableFeatureProps<TType>, props: TableProps<TType
|
11
|
+
export declare function configureReactTableOptions<TType = unknown>(options: TableFeatureProps<TType>, props: TableProps<TType>, localization: Localization): Partial<ReactTableOptions<TType>>;
|
11
12
|
export declare function useReactTableInitialState<TType = unknown>(props: TableProps<TType>, columns: ReactTableColumnDef<TType>[], persistedSettings: TableSettings, defaults: {
|
12
13
|
defaultSizing: ReactTableColumnSizingState;
|
13
14
|
defaultSorting: ReactTableColumnSort[];
|
@@ -1,2 +1,3 @@
|
|
1
|
+
import { SortingFnOption } from '@tanstack/react-table';
|
1
2
|
import { TableColumnDataType, TableColumnSortFn } from '../../types';
|
2
|
-
export declare function getSortingFn<TType = unknown>(dataType?: TableColumnDataType, customFnOrBuiltIn?: TableColumnSortFn<TType>):
|
3
|
+
export declare function getSortingFn<TType = unknown>(dataType?: TableColumnDataType, customFnOrBuiltIn?: TableColumnSortFn<TType>): SortingFnOption<TType> | undefined;
|