@economic/taco 2.48.3 → 2.48.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/packages/taco/src/components/Menu/components/Content.js +6 -1
- package/dist/esm/packages/taco/src/components/Menu/components/Content.js.map +1 -1
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js +6 -6
- package/dist/esm/packages/taco/src/components/Table3/components/Columns/Cell/EditingControlCell.js.map +1 -1
- package/dist/esm/packages/taco/src/hooks/useGlobalKeyDown.js +2 -2
- package/dist/esm/packages/taco/src/hooks/useGlobalKeyDown.js.map +1 -1
- package/dist/esm/packages/taco/src/index.js +1 -1
- package/dist/esm/packages/taco/src/primitives/Button.js +6 -1
- package/dist/esm/packages/taco/src/primitives/Button.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/Core/components/Columns/Internal/Selection.js +1 -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/Toolbar/components/Search/Search.js +1 -2
- 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/types.js +1 -7
- package/dist/esm/packages/taco/src/primitives/Table/types.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js +13 -8
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/features/useTableServerLoading.js.map +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/listeners/useTableSearchListener.js +1 -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 +1 -1
- package/dist/esm/packages/taco/src/primitives/Table/useTableManager/useTableManager.js.map +1 -1
- package/dist/esm/packages/taco/src/utils/keyboard.js +2 -5
- package/dist/esm/packages/taco/src/utils/keyboard.js.map +1 -1
- package/dist/hooks/useGlobalKeyDown.d.ts +1 -1
- package/dist/primitives/Table/types.d.ts +0 -5
- package/dist/primitives/Table/useTableManager/features/useTableServerLoading.d.ts +3 -3
- package/dist/taco.cjs.development.js +39 -31
- 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/dist/utils/keyboard.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableServerLoading.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableServerLoading.ts"],"sourcesContent":["import React from 'react';\nimport { TableServerLoadAllHandler,
|
|
1
|
+
{"version":3,"file":"useTableServerLoading.js","sources":["../../../../../../../../../src/primitives/Table/useTableManager/features/useTableServerLoading.ts"],"sourcesContent":["import React from 'react';\nimport { TableServerLoadAllHandler, TableServerLoadPageHandler } from '../../types';\nimport { DEFAULT_PAGE_SIZE } from '../../useTableDataLoader';\n\nexport function useTableServerLoading<TType = unknown>(\n length: number,\n data: TType[],\n loadPage?: TableServerLoadPageHandler,\n loadAll?: TableServerLoadAllHandler,\n pageSize = DEFAULT_PAGE_SIZE\n) {\n const isEnabled = !!loadPage && !!loadAll;\n const [isReady, setReady] = React.useState(false);\n const [loading, setLoading] = React.useState<boolean>(false);\n\n const hasLoadedAll = React.useMemo(() => {\n if (data.length !== length || !!data.some?.(x => x === undefined)) {\n return false;\n }\n\n return true;\n }, [data, length]);\n\n let _loadPage: TableServerLoadPageHandler | undefined;\n let _loadAll: TableServerLoadAllHandler | undefined;\n let _loadAllIfNeeded: TableServerLoadAllHandler | undefined;\n\n if (typeof loadPage === 'function') {\n _loadPage = async (...args) => {\n if (typeof loadPage === 'function') {\n await loadPage(...args);\n setReady(true);\n }\n };\n }\n\n if (typeof loadAll === 'function') {\n _loadAll = async (...args) => {\n if (typeof loadAll === 'function') {\n setLoading(true);\n await loadAll(...args);\n setLoading(false);\n setReady(true);\n }\n };\n\n _loadAllIfNeeded = async (...args) => {\n if (!hasLoadedAll) {\n await _loadAll?.(...args);\n }\n };\n }\n\n return {\n isEnabled,\n isReady,\n loadPage: _loadPage,\n loadAll: _loadAll,\n loadAllIfNeeded: _loadAllIfNeeded,\n loading,\n pageSize,\n };\n}\n"],"names":["useTableServerLoading","length","data","loadPage","loadAll","pageSize","DEFAULT_PAGE_SIZE","isEnabled","isReady","setReady","React","useState","loading","setLoading","hasLoadedAll","useMemo","_data$some","some","call","x","undefined","_loadPage","_loadAll","_loadAllIfNeeded","args","Promise","resolve","then","_temp","e","reject","_temp2","_loadAll2","_temp3","loadAllIfNeeded"],"mappings":";;;SAIgBA,qBAAqBA,CACjCC,MAAc,EACdC,IAAa,EACbC,QAAqC,EACrCC,OAAmC,EACnCC,QAAQ,GAAGC,iBAAiB;EAE5B,MAAMC,SAAS,GAAG,CAAC,CAACJ,QAAQ,IAAI,CAAC,CAACC,OAAO;EACzC,MAAM,CAACI,OAAO,EAAEC,QAAQ,CAAC,GAAGC,cAAK,CAACC,QAAQ,CAAC,KAAK,CAAC;EACjD,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGH,cAAK,CAACC,QAAQ,CAAU,KAAK,CAAC;EAE5D,MAAMG,YAAY,GAAGJ,cAAK,CAACK,OAAO,CAAC;;IAC/B,IAAIb,IAAI,CAACD,MAAM,KAAKA,MAAM,IAAI,CAAC,GAAAe,UAAA,GAACd,IAAI,CAACe,IAAI,cAAAD,UAAA,eAATA,UAAA,CAAAE,IAAA,CAAAhB,IAAI,EAAQiB,CAAC,IAAIA,CAAC,KAAKC,SAAS,CAAC,GAAE;MAC/D,OAAO,KAAK;;IAGhB,OAAO,IAAI;GACd,EAAE,CAAClB,IAAI,EAAED,MAAM,CAAC,CAAC;EAElB,IAAIoB,SAAiD;EACrD,IAAIC,QAA+C;EACnD,IAAIC,gBAAuD;EAE3D,IAAI,OAAOpB,QAAQ,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AD,CAAA;;;;EAGL,OAAO;IACHtB,SAAS;IACTC,OAAO;IACPL,QAAQ,EAAEkB,SAAS;IACnBjB,OAAO,EAAEkB,QAAQ;IACjBY,eAAe,EAAEX,gBAAgB;IACjCX,OAAO;IACPP;GACH;AACL;;;;"}
|
|
@@ -25,7 +25,7 @@ function useTableSearchListener(table, onChangeSearch) {
|
|
|
25
25
|
onChangeSearch(query);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
|
-
}, [meta.server.
|
|
28
|
+
}, [meta.server.loading, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), onChangeSearch]);
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
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';\nimport { TableSearchHandler } from '../../types';\nimport { useLocalization } from '../../../../components/Provider/Localization';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const localization = useLocalization();\n\n const visibleColumns = table.getVisibleFlatColumns();\n\n // Need to re-run search when columns are getting shown/hidden.\n React.useEffect(() => {\n if (meta.search.isEnabled && visibleColumns.length > 0) {\n const currentFilter = table.getState().globalFilter;\n requestAnimationFrame(() => {\n table.resetGlobalFilter();\n table.setGlobalFilter(currentFilter);\n });\n }\n }, [visibleColumns.length]);\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, localization);\n\n if (typeof onChangeSearch === 'function') {\n onChangeSearch(query);\n }\n }\n }, [\n meta.server.
|
|
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';\nimport { useLocalization } from '../../../../components/Provider/Localization';\n\nexport function useTableSearchListener<TType = unknown>(table: ReactTable<TType>, onChangeSearch?: TableSearchHandler) {\n const meta = table.options.meta as ReactTableMeta<TType>;\n const localization = useLocalization();\n\n const visibleColumns = table.getVisibleFlatColumns();\n\n // Need to re-run search when columns are getting shown/hidden.\n React.useEffect(() => {\n if (meta.search.isEnabled && visibleColumns.length > 0) {\n const currentFilter = table.getState().globalFilter;\n requestAnimationFrame(() => {\n table.resetGlobalFilter();\n table.setGlobalFilter(currentFilter);\n });\n }\n }, [visibleColumns.length]);\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, localization);\n\n if (typeof onChangeSearch === 'function') {\n onChangeSearch(query);\n }\n }\n }, [\n meta.server.loading,\n meta.search.isEnabled,\n meta.search.enableGlobalFilter,\n table.getRowModel().rows.length,\n table.getState().globalFilter,\n JSON.stringify(table.getState().sorting),\n onChangeSearch,\n ]);\n}\n"],"names":["useTableSearchListener","table","onChangeSearch","meta","options","localization","useLocalization","visibleColumns","getVisibleFlatColumns","React","useEffect","search","isEnabled","length","currentFilter","getState","globalFilter","requestAnimationFrame","resetGlobalFilter","setGlobalFilter","query","resetHighlightedColumnIndexes","server","loading","enableGlobalFilter","getRowModel","rows","JSON","stringify","sorting"],"mappings":";;;;SAMgBA,sBAAsBA,CAAkBC,KAAwB,EAAEC,cAAmC;EACjH,MAAMC,IAAI,GAAGF,KAAK,CAACG,OAAO,CAACD,IAA6B;EACxD,MAAME,YAAY,GAAGC,eAAe,EAAE;EAEtC,MAAMC,cAAc,GAAGN,KAAK,CAACO,qBAAqB,EAAE;;EAGpDC,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,IAAI,CAACQ,MAAM,CAACC,SAAS,IAAIL,cAAc,CAACM,MAAM,GAAG,CAAC,EAAE;MACpD,MAAMC,aAAa,GAAGb,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY;MACnDC,qBAAqB,CAAC;QAClBhB,KAAK,CAACiB,iBAAiB,EAAE;QACzBjB,KAAK,CAACkB,eAAe,CAACL,aAAa,CAAC;OACvC,CAAC;;GAET,EAAE,CAACP,cAAc,CAACM,MAAM,CAAC,CAAC;;EAG3BJ,cAAK,CAACC,SAAS,CAAC;IACZ,IAAIP,IAAI,CAACQ,MAAM,CAACC,SAAS,EAAE;MACvB,MAAMQ,KAAK,GAAGnB,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY;MAC3CK,6BAA6B,CAACD,KAAK,EAAEnB,KAAK,EAAEI,YAAY,CAAC;MAEzD,IAAI,OAAOH,cAAc,KAAK,UAAU,EAAE;QACtCA,cAAc,CAACkB,KAAK,CAAC;;;GAGhC,EAAE,CACCjB,IAAI,CAACmB,MAAM,CAACC,OAAO,EACnBpB,IAAI,CAACQ,MAAM,CAACC,SAAS,EACrBT,IAAI,CAACQ,MAAM,CAACa,kBAAkB,EAC9BvB,KAAK,CAACwB,WAAW,EAAE,CAACC,IAAI,CAACb,MAAM,EAC/BZ,KAAK,CAACc,QAAQ,EAAE,CAACC,YAAY,EAC7BW,IAAI,CAACC,SAAS,CAAC3B,KAAK,CAACc,QAAQ,EAAE,CAACc,OAAO,CAAC,EACxC3B,cAAc,CACjB,CAAC;AACN;;;;"}
|
|
@@ -62,7 +62,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
|
62
62
|
const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);
|
|
63
63
|
const rowSelection = useTableRowSelection(!!options.enableRowSelection);
|
|
64
64
|
const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
|
|
65
|
-
const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);
|
|
65
|
+
const server = useTableServerLoading(length, data, props.loadPage, props.loadAll, props.pageSize);
|
|
66
66
|
// TODO: memoise
|
|
67
67
|
// convert jsx column components into valid table columns
|
|
68
68
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableFilterComparator,\n TableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityAccessor: keyof TData;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSaveSettings,\n safeId,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(\n options.enableRowExpansion,\n options.enableRowExpansionAll,\n props.rowExpansionRenderer\n );\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityAccessor: props.rowIdentityAccessor,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance, props.onChangeSearch);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","enableRowExpansionAll","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","rowIdentityAccessor","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","onChangeSearch","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;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AAC;EAC/CgG,yBAAyB,CAACjB,QAAQ,EAAE1F,KAAK,CAAC4G,SAAS,CAAC;EACpDC,uBAAuB,CAACnB,QAAQ,EAAE1F,KAAK,CAAC8G,YAAY,CAAC;EAErD,OAAO;IACHxG,EAAE,EAAED,MAAM;IACVqF,QAAQ;IACRzF,IAAI,GAAA8G,qBAAA,GAAGrB,QAAQ,CAAClF,OAAO,CAACP,IAAI,cAAA8G,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEtB,QAAQ,CAACuB,QAAQ;GAC3B;AACL;;;;"}
|
|
1
|
+
{"version":3,"file":"useTableManager.js","sources":["../../../../../../../../src/primitives/Table/useTableManager/useTableManager.ts"],"sourcesContent":["import { useReactTable, TableMeta as ReactTableMeta, RowData, getCoreRowModel } from '@tanstack/react-table';\nimport {\n TableColumnAlignment,\n TableColumnClassNameHandler,\n TableColumnDataType,\n TableColumnMenu,\n TableColumnRenderer,\n TableColumnRendererControl,\n TableFilterComparator,\n TableProps,\n} from '../types';\nimport { useReactTableInitialState, configureReactTableOptions, mapTableChildrenToColumns } from './util/setup';\nimport { getTableFeaturePreset } from './util/presets';\nimport { useTableColumnFreezing } from './features/useTableColumnFreezing';\nimport { useTableColumnOrdering } from './features/useTableColumnOrdering';\nimport { useTableFooter } from './features/useTableFooter';\nimport { useTableFontSize } from './features/useTableFontSize';\nimport { useTablePrinting } from './features/useTablePrinting';\nimport { useTableRowActions } from './features/useTableRowActions';\nimport { useTableRowActive } from './features/useTableRowActive';\nimport { useTableRowClick } from './features/useTableRowClick';\nimport { useTableRowExpansion } from './features/useTableRowExpansion';\nimport { useTableRowGoto } from './features/useTableRowGoto';\nimport { useTableRowGroups } from './features/useTableRowGroups';\nimport { useTableRowHeight } from './features/useTableRowHeight';\nimport { useTableRowSelection } from './features/useTableRowSelection';\nimport { useTableSearch } from './features/useTableSearch';\nimport { useTableServerLoading } from './features/useTableServerLoading';\nimport { useTableSettings } from './features/useTableSettings';\nimport { useTableDataListener } from './listeners/useTableDataListener';\nimport { useTableFilterListener } from './listeners/useTableFilterListener';\nimport { useTableFontSizeListener } from './listeners/useTableFontSizeListener';\nimport { useTableRowHeightListener } from './listeners/useTableRowHeightListener';\nimport { useTableRowSelectionListener } from './listeners/useTableRowSelectionListener';\nimport { useTableSearchListener } from './listeners/useTableSearchListener';\nimport { useTableSettingsListener } from './listeners/useTableSettingsListener';\nimport { useTableShortcutsListener } from './listeners/useTableShortcutsListener';\nimport { useTableSortingListener } from './listeners/useTableSortingListener';\nimport { useTableServerLoadingListener } from './listeners/useTableServerLoadingListener';\nimport { useTableManagerInternalColumns } from './types';\nimport { useTableRowDrag } from './features/useTableRowDrag';\nimport { useTableRowDrop } from './features/useTableRowDrop';\nimport { useLocalization } from '../../../components/Provider/Localization';\n\n/*\n EDITING THIS FILE? READ ME FIRST!\n\n This is a shared, common hook for multiple tables. It's feature set is specifically chosen to support features\n common across those tables. If you are adding a new feature or changing an existing one, before writing any code\n in this file ask yourself the question - is this specific to a given table, or is it common to all of them.\n If you are unsure, ask your team first.\n*/\n\ndeclare module '@tanstack/table-core' {\n interface TableMeta<TData extends RowData> {\n columnFreezing: ReturnType<typeof useTableColumnFreezing>;\n columnOrdering: ReturnType<typeof useTableColumnOrdering>;\n fontSize: ReturnType<typeof useTableFontSize>;\n footer: ReturnType<typeof useTableFooter>;\n length: number;\n printing: ReturnType<typeof useTablePrinting>;\n rowActions: ReturnType<typeof useTableRowActions>;\n rowActive: ReturnType<typeof useTableRowActive>;\n rowClick: ReturnType<typeof useTableRowClick>;\n rowDrag: ReturnType<typeof useTableRowDrag>;\n rowDrop: ReturnType<typeof useTableRowDrop>;\n rowExpansion: ReturnType<typeof useTableRowExpansion>;\n rowGoto: ReturnType<typeof useTableRowGoto>;\n rowGroups: ReturnType<typeof useTableRowGroups>;\n rowHeight: ReturnType<typeof useTableRowHeight>;\n rowIdentityAccessor: keyof TData;\n rowSelection: ReturnType<typeof useTableRowSelection>;\n search: ReturnType<typeof useTableSearch>;\n server: ReturnType<typeof useTableServerLoading>;\n }\n\n interface ColumnMeta<TData extends RowData, TValue> {\n align?: TableColumnAlignment;\n className?: TableColumnClassNameHandler<TData>;\n control?: TableColumnRendererControl<TData>;\n dataType?: TableColumnDataType;\n defaultWidth?: number;\n enableEditing?: boolean;\n enableOrdering?: boolean;\n enablePrinting?: boolean;\n enableSearch?: boolean;\n enableTruncate?: boolean;\n filters?: TableFilterComparator[];\n header: string;\n headerClassName?: string;\n menu?: TableColumnMenu;\n renderer?: TableColumnRenderer<TValue, TData>;\n tooltip?: string;\n }\n}\n\n// Placed this array outside the hook to avoid creating a new array reference on each hook re-render\nconst DEFAULT_EMPTY_ARRAY = [];\n\nexport function useTableManager<TType = unknown, TMeta = {}>(\n props: TableProps<TType>,\n meta?: Partial<ReactTableMeta<TType>> & TMeta,\n internalColumns?: useTableManagerInternalColumns<TType>\n) {\n const localization = useLocalization();\n // CSS.escape would be best here, but it doesn't seem to work very well\n const safeId = props.id.replace('.', '_');\n // configure table options, merging props with presets\n const options = getTableFeaturePreset(props);\n\n // load any persisted table settings and merge them with any defaults\n const [settings, setSettings] = useTableSettings(\n options.enableSaveSettings,\n safeId,\n props.defaultSettings,\n props.onChangeSettings\n );\n\n // ensure data is always valid\n const data = props.data ?? DEFAULT_EMPTY_ARRAY;\n const length = props.length ?? data.length;\n\n // configure common custom features\n const columnFreezing = useTableColumnFreezing(options.enableColumnFreezing);\n const columnOrdering = useTableColumnOrdering(options.enableColumnOrdering);\n const fontSize = useTableFontSize(options.enableFontSize, settings.fontSize);\n const footer = useTableFooter(options.enableFooter);\n const printing = useTablePrinting(options.enablePrinting, safeId);\n const rowActive = useTableRowActive(options.enableRowActive, props.defaultRowActiveIndex);\n const rowActions = useTableRowActions<TType>(options.enableRowActions, props.rowActions, props.rowActionsLength);\n const rowClick = useTableRowClick<TType>(options.enableRowClick, props.onRowClick);\n const rowDrag = useTableRowDrag<TType>(options.enableRowDrag && !meta?.editing?.isEditing, props.onRowDrag);\n const rowDrop = useTableRowDrop<TType>(options.enableRowDrop, props.onRowDrop);\n const rowExpansion = useTableRowExpansion<TType>(\n options.enableRowExpansion,\n options.enableRowExpansionAll,\n props.rowExpansionRenderer\n );\n const rowGoto = useTableRowGoto(options.enableRowGoto, props.onRowGoto);\n const rowGroups = useTableRowGroups(props.rowActionsForGroup);\n const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);\n const rowSelection = useTableRowSelection(!!options.enableRowSelection);\n const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);\n const server = useTableServerLoading(length, data, props.loadPage, props.loadAll, props.pageSize);\n\n // TODO: memoise\n // convert jsx column components into valid table columns\n const { columns, ...defaultState } = mapTableChildrenToColumns<TType>(\n props,\n settings,\n options,\n internalColumns,\n localization\n );\n\n // configure initial table state\n const initialState = useReactTableInitialState<TType>(props, columns, settings, defaultState);\n\n // create a react-table instance\n const instance = useReactTable<TType>({\n data,\n columns,\n // configure initial table state\n initialState,\n getCoreRowModel: getCoreRowModel<TType>(),\n // configure react-table built-in features\n ...configureReactTableOptions<TType>(options, props, localization),\n // settings that can be toggled by the user, and therefore require our own state\n enableGlobalFilter: search.enableGlobalFilter,\n // custom context\n meta: {\n // spread features from specific implementations\n ...meta,\n columnFreezing,\n columnOrdering,\n fontSize,\n footer,\n length,\n printing,\n rowActions: rowActions as any, // no other way around ReturnType<typeof X> not supporting generics\n rowActive,\n rowClick: rowClick as any, // no other way around ReturnType<typeof X> not supporting generics\n rowDrag,\n rowDrop: rowDrop as any, // no other way around ReturnType<typeof X> not supporting generics\n rowExpansion: rowExpansion as any, // no other way around ReturnType<typeof X> not supporting generics\n rowIdentityAccessor: props.rowIdentityAccessor,\n rowGoto,\n rowGroups: rowGroups as any, // no other way around ReturnType<typeof X> not supporting generics\n rowHeight,\n rowSelection,\n search,\n server,\n } as ReactTableMeta<TType> & TMeta,\n });\n\n // state listeners - we have these so that we don't have to control state outside the table\n useTableDataListener(instance);\n useTableFilterListener(instance, props.onChangeFilter);\n useTableFontSizeListener(instance);\n useTableRowHeightListener(instance);\n useTableRowSelectionListener(instance, props.onRowSelect);\n useTableSearchListener(instance, props.onChangeSearch);\n useTableServerLoadingListener(instance, server.loadPage);\n useTableSettingsListener(instance, setSettings);\n useTableShortcutsListener(instance, props.shortcuts);\n useTableSortingListener(instance, props.onChangeSort);\n\n return {\n id: safeId,\n instance,\n meta: (instance.options.meta ?? {}) as ReactTableMeta<TType> & TMeta,\n state: instance.getState(),\n };\n}\n"],"names":["DEFAULT_EMPTY_ARRAY","useTableManager","props","meta","internalColumns","localization","useLocalization","safeId","id","replace","options","getTableFeaturePreset","settings","setSettings","useTableSettings","enableSaveSettings","defaultSettings","onChangeSettings","data","_props$data","length","_props$length","columnFreezing","useTableColumnFreezing","enableColumnFreezing","columnOrdering","useTableColumnOrdering","enableColumnOrdering","fontSize","useTableFontSize","enableFontSize","footer","useTableFooter","enableFooter","printing","useTablePrinting","enablePrinting","rowActive","useTableRowActive","enableRowActive","defaultRowActiveIndex","rowActions","useTableRowActions","enableRowActions","rowActionsLength","rowClick","useTableRowClick","enableRowClick","onRowClick","rowDrag","useTableRowDrag","enableRowDrag","_meta$editing","editing","isEditing","onRowDrag","rowDrop","useTableRowDrop","enableRowDrop","onRowDrop","rowExpansion","useTableRowExpansion","enableRowExpansion","enableRowExpansionAll","rowExpansionRenderer","rowGoto","useTableRowGoto","enableRowGoto","onRowGoto","rowGroups","useTableRowGroups","rowActionsForGroup","rowHeight","useTableRowHeight","enableRowHeight","rowSelection","useTableRowSelection","enableRowSelection","search","useTableSearch","enableSearch","excludeUnmatchedRecordsInSearch","server","useTableServerLoading","loadPage","loadAll","pageSize","columns","defaultState","mapTableChildrenToColumns","initialState","useReactTableInitialState","instance","useReactTable","getCoreRowModel","configureReactTableOptions","enableGlobalFilter","rowIdentityAccessor","useTableDataListener","useTableFilterListener","onChangeFilter","useTableFontSizeListener","useTableRowHeightListener","useTableRowSelectionListener","onRowSelect","useTableSearchListener","onChangeSearch","useTableServerLoadingListener","useTableSettingsListener","useTableShortcutsListener","shortcuts","useTableSortingListener","onChangeSort","_instance$options$met","state","getState"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA;AACA,MAAMA,mBAAmB,GAAG,EAAE;SAEdC,eAAeA,CAC3BC,KAAwB,EACxBC,IAA6C,EAC7CC,eAAuD;;EAEvD,MAAMC,YAAY,GAAGC,eAAe,EAAE;;EAEtC,MAAMC,MAAM,GAAGL,KAAK,CAACM,EAAE,CAACC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC;;EAEzC,MAAMC,OAAO,GAAGC,qBAAqB,CAACT,KAAK,CAAC;;EAG5C,MAAM,CAACU,QAAQ,EAAEC,WAAW,CAAC,GAAGC,gBAAgB,CAC5CJ,OAAO,CAACK,kBAAkB,EAC1BR,MAAM,EACNL,KAAK,CAACc,eAAe,EACrBd,KAAK,CAACe,gBAAgB,CACzB;;EAGD,MAAMC,IAAI,IAAAC,WAAA,GAAGjB,KAAK,CAACgB,IAAI,cAAAC,WAAA,cAAAA,WAAA,GAAInB,mBAAmB;EAC9C,MAAMoB,MAAM,IAAAC,aAAA,GAAGnB,KAAK,CAACkB,MAAM,cAAAC,aAAA,cAAAA,aAAA,GAAIH,IAAI,CAACE,MAAM;;EAG1C,MAAME,cAAc,GAAGC,sBAAsB,CAACb,OAAO,CAACc,oBAAoB,CAAC;EAC3E,MAAMC,cAAc,GAAGC,sBAAsB,CAAChB,OAAO,CAACiB,oBAAoB,CAAC;EAC3E,MAAMC,QAAQ,GAAGC,gBAAgB,CAACnB,OAAO,CAACoB,cAAc,EAAElB,QAAQ,CAACgB,QAAQ,CAAC;EAC5E,MAAMG,MAAM,GAAGC,cAAc,CAACtB,OAAO,CAACuB,YAAY,CAAC;EACnD,MAAMC,QAAQ,GAAGC,gBAAgB,CAACzB,OAAO,CAAC0B,cAAc,EAAE7B,MAAM,CAAC;EACjE,MAAM8B,SAAS,GAAG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b,QAAQ,EAAE1F,KAAK,CAACwG,cAAc,CAAC;EACtDC,6BAA6B,CAACf,QAAQ,EAAEV,MAAM,CAACE,QAAQ,CAAC;EACxDwB,wBAAwB,CAAChB,QAAQ,EAAE/E,WAAW,CAAC;EAC/CgG,yBAAyB,CAACjB,QAAQ,EAAE1F,KAAK,CAAC4G,SAAS,CAAC;EACpDC,uBAAuB,CAACnB,QAAQ,EAAE1F,KAAK,CAAC8G,YAAY,CAAC;EAErD,OAAO;IACHxG,EAAE,EAAED,MAAM;IACVqF,QAAQ;IACRzF,IAAI,GAAA8G,qBAAA,GAAGrB,QAAQ,CAAClF,OAAO,CAACP,IAAI,cAAA8G,qBAAA,cAAAA,qBAAA,GAAI,EAAoC;IACpEC,KAAK,EAAEtB,QAAQ,CAACuB,QAAQ;GAC3B;AACL;;;;"}
|
|
@@ -17,12 +17,9 @@ function shouldTriggerShortcut(event, key) {
|
|
|
17
17
|
}
|
|
18
18
|
return event.key.toLowerCase() === keyOptions.key.toLowerCase();
|
|
19
19
|
}
|
|
20
|
-
function createShortcutKeyDownHandler(key, handler, stopPropagation = true
|
|
20
|
+
function createShortcutKeyDownHandler(key, handler, stopPropagation = true) {
|
|
21
21
|
return function (event) {
|
|
22
|
-
|
|
23
|
-
const isOutsideDialog = element && dialog && !dialog.contains(element);
|
|
24
|
-
if (event.target !== event.currentTarget && isElementInteractive(event.target) && !isPressingMetaKey(event) || isOutsideDialog // Avoid triggering shortcut if dialog is open and element is outside the dialog
|
|
25
|
-
) {
|
|
22
|
+
if (event.target !== event.currentTarget && isElementInteractive(event.target) && !isPressingMetaKey(event)) {
|
|
26
23
|
return;
|
|
27
24
|
}
|
|
28
25
|
const condition = shouldTriggerShortcut(event, key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keyboard.js","sources":["../../../../../../src/utils/keyboard.ts"],"sourcesContent":["import React from 'react';\nimport { isElementInteractive } from './dom';\n\nexport type KeyDownHandlerOptions = { key: string; meta?: boolean; shift?: boolean };\n\nexport function isPressingMetaKey<T = Element>(event: KeyboardEvent | React.KeyboardEvent<T>) {\n return isMacOs() ? event.metaKey : event.ctrlKey;\n}\n\nexport function shouldTriggerShortcut<T = Element>(\n event: KeyboardEvent | React.KeyboardEvent<T>,\n key: string | KeyDownHandlerOptions\n) {\n const keyOptions: KeyDownHandlerOptions = typeof key === 'string' ? { key, meta: false, shift: false } : key;\n\n if (\n (keyOptions.meta && (isMacOs() ? !event.metaKey : !event.ctrlKey)) ||\n (!keyOptions.meta && (isMacOs() ? event.metaKey : event.ctrlKey))\n ) {\n return false;\n }\n\n if ((keyOptions.shift && !event.shiftKey) || (keyOptions.shift === false && event.shiftKey)) {\n return false;\n }\n\n return event.key.toLowerCase() === keyOptions.key.toLowerCase();\n}\n\nexport function createShortcutKeyDownHandler<T = Element>(\n key: string | KeyDownHandlerOptions,\n handler: (event: KeyboardEvent | React.KeyboardEvent<T>) => void,\n stopPropagation = true
|
|
1
|
+
{"version":3,"file":"keyboard.js","sources":["../../../../../../src/utils/keyboard.ts"],"sourcesContent":["import React from 'react';\nimport { isElementInteractive } from './dom';\n\nexport type KeyDownHandlerOptions = { key: string; meta?: boolean; shift?: boolean };\n\nexport function isPressingMetaKey<T = Element>(event: KeyboardEvent | React.KeyboardEvent<T>) {\n return isMacOs() ? event.metaKey : event.ctrlKey;\n}\n\nexport function shouldTriggerShortcut<T = Element>(\n event: KeyboardEvent | React.KeyboardEvent<T>,\n key: string | KeyDownHandlerOptions\n) {\n const keyOptions: KeyDownHandlerOptions = typeof key === 'string' ? { key, meta: false, shift: false } : key;\n\n if (\n (keyOptions.meta && (isMacOs() ? !event.metaKey : !event.ctrlKey)) ||\n (!keyOptions.meta && (isMacOs() ? event.metaKey : event.ctrlKey))\n ) {\n return false;\n }\n\n if ((keyOptions.shift && !event.shiftKey) || (keyOptions.shift === false && event.shiftKey)) {\n return false;\n }\n\n return event.key.toLowerCase() === keyOptions.key.toLowerCase();\n}\n\nexport function createShortcutKeyDownHandler<T = Element>(\n key: string | KeyDownHandlerOptions,\n handler: (event: KeyboardEvent | React.KeyboardEvent<T>) => void,\n stopPropagation = true\n) {\n return function (event: KeyboardEvent | React.KeyboardEvent<T>) {\n if (\n event.target !== event.currentTarget &&\n isElementInteractive(event.target as HTMLElement) &&\n !isPressingMetaKey(event)\n ) {\n return;\n }\n\n const condition = shouldTriggerShortcut(event, key);\n\n if (condition) {\n if (stopPropagation) {\n // stops react handlers bubbling up to global\n event.stopPropagation();\n // stops global handlers bubbling up to other global\n (event as KeyboardEvent).stopImmediatePropagation?.();\n }\n\n handler(event);\n }\n };\n}\n\nexport const isMacOs = () => window?.navigator.userAgent.includes('Mac');\n"],"names":["isPressingMetaKey","event","isMacOs","metaKey","ctrlKey","shouldTriggerShortcut","key","keyOptions","meta","shift","shiftKey","toLowerCase","createShortcutKeyDownHandler","handler","stopPropagation","target","currentTarget","isElementInteractive","condition","_event$stopImmediateP","stopImmediatePropagation","call","_window","window","navigator","userAgent","includes"],"mappings":";;SAKgBA,iBAAiBA,CAAcC,KAA6C;EACxF,OAAOC,OAAO,EAAE,GAAGD,KAAK,CAACE,OAAO,GAAGF,KAAK,CAACG,OAAO;AACpD;SAEgBC,qBAAqBA,CACjCJ,KAA6C,EAC7CK,GAAmC;EAEnC,MAAMC,UAAU,GAA0B,OAAOD,GAAG,KAAK,QAAQ,GAAG;IAAEA,GAAG;IAAEE,IAAI,EAAE,KAAK;IAAEC,KAAK,EAAE;GAAO,GAAGH,GAAG;EAE5G,IACKC,UAAU,CAACC,IAAI,KAAKN,OAAO,EAAE,GAAG,CAACD,KAAK,CAACE,OAAO,GAAG,CAACF,KAAK,CAACG,OAAO,CAAC,IAChE,CAACG,UAAU,CAACC,IAAI,KAAKN,OAAO,EAAE,GAAGD,KAAK,CAACE,OAAO,GAAGF,KAAK,CAACG,OAAO,CAAE,EACnE;IACE,OAAO,KAAK;;EAGhB,IAAKG,UAAU,CAACE,KAAK,IAAI,CAACR,KAAK,CAACS,QAAQ,IAAMH,UAAU,CAACE,KAAK,KAAK,KAAK,IAAIR,KAAK,CAACS,QAAS,EAAE;IACzF,OAAO,KAAK;;EAGhB,OAAOT,KAAK,CAACK,GAAG,CAACK,WAAW,EAAE,KAAKJ,UAAU,CAACD,GAAG,CAACK,WAAW,EAAE;AACnE;SAEgBC,4BAA4BA,CACxCN,GAAmC,EACnCO,OAAgE,EAChEC,eAAe,GAAG,IAAI;EAEtB,OAAO,UAAUb,KAA6C;IAC1D,IACIA,KAAK,CAACc,MAAM,KAAKd,KAAK,CAACe,aAAa,IACpCC,oBAAoB,CAAChB,KAAK,CAACc,MAAqB,CAAC,IACjD,CAACf,iBAAiB,CAACC,KAAK,CAAC,EAC3B;MACE;;IAGJ,MAAMiB,SAAS,GAAGb,qBAAqB,CAACJ,KAAK,EAAEK,GAAG,CAAC;IAEnD,IAAIY,SAAS,EAAE;MACX,IAAIJ,eAAe,EAAE;QAAA,IAAAK,qBAAA;;QAEjBlB,KAAK,CAACa,eAAe,EAAE;;QAEtB,CAAAK,qBAAA,GAAAlB,KAAuB,CAACmB,wBAAwB,cAAAD,qBAAA,uBAAhDA,qBAAA,CAAAE,IAAA,CAAApB,MAAoD;;MAGzDY,OAAO,CAACZ,KAAK,CAAC;;GAErB;AACL;MAEaC,OAAO,GAAGA;EAAA,IAAAoB,OAAA;EAAA,QAAAA,OAAA,GAAMC,MAAM,cAAAD,OAAA,uBAANA,OAAA,CAAQE,SAAS,CAACC,SAAS,CAACC,QAAQ,CAAC,KAAK,CAAC;AAAA;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { KeyDownHandlerOptions } from '../utils/keyboard';
|
|
2
|
-
export declare const useGlobalKeyDown: (shortcut: string | KeyDownHandlerOptions | undefined, handler: (event: KeyboardEvent) => void
|
|
2
|
+
export declare const useGlobalKeyDown: (shortcut: string | KeyDownHandlerOptions | undefined, handler: (event: KeyboardEvent) => void) => void;
|
|
@@ -89,11 +89,6 @@ export declare type TableScrollToIndexHandler = (index: number, options?: {
|
|
|
89
89
|
export declare type TableSearchHandler = (search: string | undefined) => void | Promise<void>;
|
|
90
90
|
export declare type TableServerLoadPageHandler = (pageIndex: number, sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;
|
|
91
91
|
export declare type TableServerLoadAllHandler = (sorting: TableColumnSort[], filters: TableColumnFilter[]) => Promise<void>;
|
|
92
|
-
export declare enum TableServerLoadAllState {
|
|
93
|
-
Incomplete = 0,
|
|
94
|
-
Loading = 1,
|
|
95
|
-
Completed = 2
|
|
96
|
-
}
|
|
97
92
|
export declare type TableSettingsHandler = (settings: TableSettings) => void | Promise<void>;
|
|
98
93
|
export declare type TableShortcuts<TType = unknown> = Record<string, TableShortcutHandlerFn<TType> | TableShortcutHandlerObject<TType>>;
|
|
99
94
|
export declare type TableSortHandler = (sorting: TableColumnSort[]) => void | Promise<void>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { TableServerLoadAllHandler,
|
|
2
|
-
export declare function useTableServerLoading(loadPage?: TableServerLoadPageHandler, loadAll?: TableServerLoadAllHandler, pageSize?: number): {
|
|
1
|
+
import { TableServerLoadAllHandler, TableServerLoadPageHandler } from '../../types';
|
|
2
|
+
export declare function useTableServerLoading<TType = unknown>(length: number, data: TType[], loadPage?: TableServerLoadPageHandler, loadAll?: TableServerLoadAllHandler, pageSize?: number): {
|
|
3
3
|
isEnabled: boolean;
|
|
4
4
|
isReady: boolean;
|
|
5
5
|
loadPage: TableServerLoadPageHandler | undefined;
|
|
6
6
|
loadAll: TableServerLoadAllHandler | undefined;
|
|
7
7
|
loadAllIfNeeded: TableServerLoadAllHandler | undefined;
|
|
8
|
-
|
|
8
|
+
loading: boolean;
|
|
9
9
|
pageSize: number;
|
|
10
10
|
};
|
|
@@ -4395,12 +4395,9 @@ function shouldTriggerShortcut(event, key) {
|
|
|
4395
4395
|
}
|
|
4396
4396
|
return event.key.toLowerCase() === keyOptions.key.toLowerCase();
|
|
4397
4397
|
}
|
|
4398
|
-
function createShortcutKeyDownHandler(key, handler, stopPropagation = true
|
|
4398
|
+
function createShortcutKeyDownHandler(key, handler, stopPropagation = true) {
|
|
4399
4399
|
return function (event) {
|
|
4400
|
-
|
|
4401
|
-
const isOutsideDialog = element && dialog && !dialog.contains(element);
|
|
4402
|
-
if (event.target !== event.currentTarget && isElementInteractive(event.target) && !isPressingMetaKey(event) || isOutsideDialog // Avoid triggering shortcut if dialog is open and element is outside the dialog
|
|
4403
|
-
) {
|
|
4400
|
+
if (event.target !== event.currentTarget && isElementInteractive(event.target) && !isPressingMetaKey(event)) {
|
|
4404
4401
|
return;
|
|
4405
4402
|
}
|
|
4406
4403
|
const condition = shouldTriggerShortcut(event, key);
|
|
@@ -4421,11 +4418,11 @@ const isMacOs = () => {
|
|
|
4421
4418
|
return (_window = window) === null || _window === void 0 ? void 0 : _window.navigator.userAgent.includes('Mac');
|
|
4422
4419
|
};
|
|
4423
4420
|
|
|
4424
|
-
const useGlobalKeyDown = (shortcut, handler
|
|
4421
|
+
const useGlobalKeyDown = (shortcut, handler) => {
|
|
4425
4422
|
React__default.useEffect(() => {
|
|
4426
4423
|
let handleKeyDown;
|
|
4427
4424
|
if (shortcut) {
|
|
4428
|
-
handleKeyDown = createShortcutKeyDownHandler(shortcut, handler, false
|
|
4425
|
+
handleKeyDown = createShortcutKeyDownHandler(shortcut, handler, false);
|
|
4429
4426
|
document.addEventListener('keydown', handleKeyDown);
|
|
4430
4427
|
}
|
|
4431
4428
|
return () => {
|
|
@@ -4448,8 +4445,13 @@ const Button = /*#__PURE__*/React.forwardRef(function Button(props, ref) {
|
|
|
4448
4445
|
useGlobalKeyDown(shortcut, event => {
|
|
4449
4446
|
var _internalRef$current;
|
|
4450
4447
|
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
4448
|
+
const dialog = document.querySelector('[role="dialog"]');
|
|
4449
|
+
// Don't trigger the click on the button if it is outside of the dialog
|
|
4450
|
+
if (dialog && !(dialog !== null && dialog !== void 0 && dialog.contains(internalRef.current))) {
|
|
4451
|
+
return;
|
|
4452
|
+
}
|
|
4451
4453
|
(_internalRef$current = internalRef.current) === null || _internalRef$current === void 0 ? void 0 : _internalRef$current.click();
|
|
4452
|
-
}
|
|
4454
|
+
});
|
|
4453
4455
|
const Tag = props.href ? 'a' : 'button';
|
|
4454
4456
|
return /*#__PURE__*/React.createElement(Tag, Object.assign({}, otherProps, {
|
|
4455
4457
|
href: disabled ? undefined : props.href,
|
|
@@ -8327,12 +8329,17 @@ const Content$8 = /*#__PURE__*/React.forwardRef(function MenuContent(props, ref)
|
|
|
8327
8329
|
if (child.props.shortcut) {
|
|
8328
8330
|
shortcuts.push(createShortcutKeyDownHandler(child.props.shortcut, event => {
|
|
8329
8331
|
event.preventDefault();
|
|
8332
|
+
const dialog = document.querySelector('[role="dialog"]');
|
|
8333
|
+
// Don't trigger the shortcut if it is outside of the dialog
|
|
8334
|
+
if (dialog && !(dialog !== null && dialog !== void 0 && dialog.contains(internalRef.current))) {
|
|
8335
|
+
return;
|
|
8336
|
+
}
|
|
8330
8337
|
menu === null || menu === void 0 ? void 0 : menu.open();
|
|
8331
8338
|
setTimeout(() => {
|
|
8332
8339
|
var _childrenRefs$current, _childrenRefs$current2;
|
|
8333
8340
|
return (_childrenRefs$current = childrenRefs.current[index]) === null || _childrenRefs$current === void 0 ? void 0 : (_childrenRefs$current2 = _childrenRefs$current.current) === null || _childrenRefs$current2 === void 0 ? void 0 : _childrenRefs$current2.click();
|
|
8334
8341
|
}, 1);
|
|
8335
|
-
}
|
|
8342
|
+
}));
|
|
8336
8343
|
}
|
|
8337
8344
|
});
|
|
8338
8345
|
shortcuts.forEach(handler => document.addEventListener('keydown', handler));
|
|
@@ -9941,11 +9948,6 @@ const fixedForwardRef = React__default.forwardRef;
|
|
|
9941
9948
|
TableFilterComparator[TableFilterComparator["HasAllOf"] = 12] = "HasAllOf";
|
|
9942
9949
|
TableFilterComparator[TableFilterComparator["HasNoneOf"] = 13] = "HasNoneOf";
|
|
9943
9950
|
})(exports.TableFilterComparator || (exports.TableFilterComparator = {}));
|
|
9944
|
-
(function (TableServerLoadAllState) {
|
|
9945
|
-
TableServerLoadAllState[TableServerLoadAllState["Incomplete"] = 0] = "Incomplete";
|
|
9946
|
-
TableServerLoadAllState[TableServerLoadAllState["Loading"] = 1] = "Loading";
|
|
9947
|
-
TableServerLoadAllState[TableServerLoadAllState["Completed"] = 2] = "Completed";
|
|
9948
|
-
})(exports.TableServerLoadAllState || (exports.TableServerLoadAllState = {}));
|
|
9949
9951
|
|
|
9950
9952
|
const dataTypes = {
|
|
9951
9953
|
auto: {
|
|
@@ -11488,10 +11490,17 @@ function useTableDataLoader(fetchPage, fetchAll, options = {
|
|
|
11488
11490
|
}, invalidate];
|
|
11489
11491
|
}
|
|
11490
11492
|
|
|
11491
|
-
function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
|
|
11493
|
+
function useTableServerLoading(length, data, loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE) {
|
|
11492
11494
|
const isEnabled = !!loadPage && !!loadAll;
|
|
11493
11495
|
const [isReady, setReady] = React__default.useState(false);
|
|
11494
|
-
const [
|
|
11496
|
+
const [loading, setLoading] = React__default.useState(false);
|
|
11497
|
+
const hasLoadedAll = React__default.useMemo(() => {
|
|
11498
|
+
var _data$some;
|
|
11499
|
+
if (data.length !== length || !!((_data$some = data.some) !== null && _data$some !== void 0 && _data$some.call(data, x => x === undefined))) {
|
|
11500
|
+
return false;
|
|
11501
|
+
}
|
|
11502
|
+
return true;
|
|
11503
|
+
}, [data, length]);
|
|
11495
11504
|
let _loadPage;
|
|
11496
11505
|
let _loadAll;
|
|
11497
11506
|
let _loadAllIfNeeded;
|
|
@@ -11501,7 +11510,6 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
|
11501
11510
|
const _temp = function () {
|
|
11502
11511
|
if (typeof loadPage === 'function') {
|
|
11503
11512
|
return Promise.resolve(loadPage(...args)).then(function () {
|
|
11504
|
-
setLoadedStatus(exports.TableServerLoadAllState.Incomplete);
|
|
11505
11513
|
setReady(true);
|
|
11506
11514
|
});
|
|
11507
11515
|
}
|
|
@@ -11517,9 +11525,9 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
|
11517
11525
|
try {
|
|
11518
11526
|
const _temp2 = function () {
|
|
11519
11527
|
if (typeof loadAll === 'function') {
|
|
11520
|
-
|
|
11528
|
+
setLoading(true);
|
|
11521
11529
|
return Promise.resolve(loadAll(...args)).then(function () {
|
|
11522
|
-
|
|
11530
|
+
setLoading(false);
|
|
11523
11531
|
setReady(true);
|
|
11524
11532
|
});
|
|
11525
11533
|
}
|
|
@@ -11532,7 +11540,7 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
|
11532
11540
|
_loadAllIfNeeded = function (...args) {
|
|
11533
11541
|
try {
|
|
11534
11542
|
const _temp3 = function () {
|
|
11535
|
-
if (
|
|
11543
|
+
if (!hasLoadedAll) {
|
|
11536
11544
|
var _loadAll2;
|
|
11537
11545
|
return Promise.resolve((_loadAll2 = _loadAll) === null || _loadAll2 === void 0 ? void 0 : _loadAll2(...args)).then(function () {});
|
|
11538
11546
|
}
|
|
@@ -11549,7 +11557,7 @@ function useTableServerLoading(loadPage, loadAll, pageSize = DEFAULT_PAGE_SIZE)
|
|
|
11549
11557
|
loadPage: _loadPage,
|
|
11550
11558
|
loadAll: _loadAll,
|
|
11551
11559
|
loadAllIfNeeded: _loadAllIfNeeded,
|
|
11552
|
-
|
|
11560
|
+
loading,
|
|
11553
11561
|
pageSize
|
|
11554
11562
|
};
|
|
11555
11563
|
}
|
|
@@ -11744,7 +11752,7 @@ function useTableSearchListener(table, onChangeSearch) {
|
|
|
11744
11752
|
onChangeSearch(query);
|
|
11745
11753
|
}
|
|
11746
11754
|
}
|
|
11747
|
-
}, [meta.server.
|
|
11755
|
+
}, [meta.server.loading, meta.search.isEnabled, meta.search.enableGlobalFilter, table.getRowModel().rows.length, table.getState().globalFilter, JSON.stringify(table.getState().sorting), onChangeSearch]);
|
|
11748
11756
|
}
|
|
11749
11757
|
|
|
11750
11758
|
function useTableSettingsListener(table, onChangeSettings) {
|
|
@@ -11886,7 +11894,7 @@ function useTableManager(props, meta, internalColumns) {
|
|
|
11886
11894
|
const rowHeight = useTableRowHeight(options.enableRowHeight, settings.rowHeight);
|
|
11887
11895
|
const rowSelection = useTableRowSelection(!!options.enableRowSelection);
|
|
11888
11896
|
const search = useTableSearch(options.enableSearch, settings.excludeUnmatchedRecordsInSearch);
|
|
11889
|
-
const server = useTableServerLoading(props.loadPage, props.loadAll, props.pageSize);
|
|
11897
|
+
const server = useTableServerLoading(length, data, props.loadPage, props.loadAll, props.pageSize);
|
|
11890
11898
|
// TODO: memoise
|
|
11891
11899
|
// convert jsx column components into valid table columns
|
|
11892
11900
|
const {
|
|
@@ -12724,7 +12732,7 @@ function Header$4(context) {
|
|
|
12724
12732
|
className: "hover:border-blue !-mt-px",
|
|
12725
12733
|
checked: isAllRowsSelected,
|
|
12726
12734
|
indeterminate: isSomeRowsSelected && !isAllRowsSelected,
|
|
12727
|
-
loading: tableMeta.server.
|
|
12735
|
+
loading: tableMeta.server.loading,
|
|
12728
12736
|
onChange: handleChange
|
|
12729
12737
|
}));
|
|
12730
12738
|
}
|
|
@@ -14283,7 +14291,7 @@ function Search$1(props) {
|
|
|
14283
14291
|
return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement(SearchInput2, {
|
|
14284
14292
|
findCurrent: tableMeta.search.currentHighlightColumnIndex !== undefined ? tableMeta.search.currentHighlightColumnIndex + 1 : null,
|
|
14285
14293
|
findTotal: (_tableMeta$search$hig = (_tableMeta$search$hig2 = tableMeta.search.highlightedColumnIndexes) === null || _tableMeta$search$hig2 === void 0 ? void 0 : _tableMeta$search$hig2.length) !== null && _tableMeta$search$hig !== void 0 ? _tableMeta$search$hig : null,
|
|
14286
|
-
loading: tableMeta.server.
|
|
14294
|
+
loading: tableMeta.server.loading,
|
|
14287
14295
|
name: "table-search",
|
|
14288
14296
|
onClickFindPrevious: handlePreviousResult,
|
|
14289
14297
|
onClickFindNext: handleNextResult,
|
|
@@ -19636,24 +19644,24 @@ function EditingControlCell(props) {
|
|
|
19636
19644
|
var _cellRef$current;
|
|
19637
19645
|
return typeof type === 'function' && !!((_cellRef$current = cellRef.current) !== null && _cellRef$current !== void 0 && _cellRef$current.querySelector('[data-taco="Select2"],[data-taco="switch"],[data-taco="checkbox"]'));
|
|
19638
19646
|
}, [cellRef.current]);
|
|
19639
|
-
const handleChange = nextValue => {
|
|
19647
|
+
const handleChange = React__default.useCallback(nextValue => {
|
|
19640
19648
|
if (nextValue !== value) {
|
|
19641
19649
|
tableMeta.editing.setCellValue(cell, nextValue);
|
|
19642
19650
|
if (hasNonTextControl) {
|
|
19643
19651
|
requestAnimationFrame(() => tableMeta.editing.onCellChanged(cell, rowIndex, nextValue));
|
|
19644
19652
|
}
|
|
19645
19653
|
}
|
|
19646
|
-
};
|
|
19647
|
-
function blur() {
|
|
19654
|
+
}, [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex, value]);
|
|
19655
|
+
const blur = React__default.useCallback(function blur() {
|
|
19648
19656
|
tableMeta.editing.toggleDetailedMode(false);
|
|
19649
19657
|
tableMeta.editing.onCellChanged(cell, rowIndex, undefined, !hasNonTextControl);
|
|
19650
|
-
}
|
|
19651
|
-
const handleBlur = event => {
|
|
19658
|
+
}, [hasNonTextControl, cell.row.id, cell.column.id, cell.row.original, rowIndex]);
|
|
19659
|
+
const handleBlur = React__default.useCallback(event => {
|
|
19652
19660
|
if (isElementInsideOrTriggeredFromContainer(event.relatedTarget, event.currentTarget)) {
|
|
19653
19661
|
return;
|
|
19654
19662
|
}
|
|
19655
19663
|
blur();
|
|
19656
|
-
};
|
|
19664
|
+
}, [blur]);
|
|
19657
19665
|
// ensure that blur runs when the cell gets unmounted (when vertically arrow key navigating)
|
|
19658
19666
|
React__default.useEffect(() => {
|
|
19659
19667
|
const ref = cellRef.current;
|