From b3b3b017556d61d26e0e868d87dc2d72a29a1f34 Mon Sep 17 00:00:00 2001 From: Micaela Goffe Date: Mon, 9 Dec 2024 11:37:40 +0100 Subject: [PATCH] fix(footer): set max-toolbar-items when mini table is used --- lib/render-footer.js | 109 ++++++++++++++++++++--------------------- lib/use-fast-layout.js | 8 ++- lib/use-footer.js | 17 +++---- lib/use-mini.js | 1 + lib/use-omnitable.js | 4 +- 5 files changed, 70 insertions(+), 69 deletions(-) diff --git a/lib/render-footer.js b/lib/render-footer.js index 8720beee..d84ecbb8 100644 --- a/lib/render-footer.js +++ b/lib/render-footer.js @@ -11,61 +11,56 @@ export const renderFooter = ({ csvFilename, xlsxFilename, xlsxSheetname, - topPlacement -}) => { - return html` - - - ${ngettext( - '{0} selected item', - '{0} selected items', - selectedItems.length - )} - - - - - - - - - - - - - - - - `; -}; + + + + + + + + + + + + + `; diff --git a/lib/use-fast-layout.js b/lib/use-fast-layout.js index 96e70b46..a316f496 100644 --- a/lib/use-fast-layout.js +++ b/lib/use-fast-layout.js @@ -16,7 +16,11 @@ export const useFastLayout = ({ sortAndGroupOptions, }) => { const canvasWidth = useCanvasWidth(host), - { miniColumn, miniColumns } = useMini({ host, canvasWidth, columns }), + { isMiniSize, miniColumn, miniColumns } = useMini({ + host, + canvasWidth, + columns, + }), { groupOnColumn } = sortAndGroupOptions, layout = useLayout({ canvasWidth, @@ -52,5 +56,5 @@ export const useFastLayout = ({ useStyleSheet(layoutCss); - return { collapsedColumns, miniColumns }; + return { isMiniSize, collapsedColumns, miniColumns }; }; diff --git a/lib/use-footer.js b/lib/use-footer.js index a4d53571..56dc19f1 100644 --- a/lib/use-footer.js +++ b/lib/use-footer.js @@ -1,22 +1,21 @@ import { defaultPlacement } from '@neovici/cosmoz-dropdown'; const _defaultPlacement = ['top-right', ...defaultPlacement]; -export const useFooter = ({ - host, - ...rest -}) => { +export const useFooter = ({ host, ...rest }) => { const { - csvFilename = 'omnitable.csv', - xlsxFilename = 'omnitable.xlsx', - xlsxSheetname = 'Omnitable', - topPlacement = _defaultPlacement, - } = host; + csvFilename = 'omnitable.csv', + xlsxFilename = 'omnitable.xlsx', + xlsxSheetname = 'Omnitable', + topPlacement = _defaultPlacement, + maxToolbarItems, + } = host; return { csvFilename, xlsxFilename, xlsxSheetname, topPlacement, + maxToolbarItems, ...rest, }; }; diff --git a/lib/use-mini.js b/lib/use-mini.js index cc2e64f4..9a41f216 100644 --- a/lib/use-mini.js +++ b/lib/use-mini.js @@ -23,6 +23,7 @@ export const useMini = ({ host, canvasWidth, columns: _columns }) => { }, [miniColumn]); return { + isMiniSize, miniColumn, miniColumns, }; diff --git a/lib/use-omnitable.js b/lib/use-omnitable.js index 64088bb9..5bf7c304 100644 --- a/lib/use-omnitable.js +++ b/lib/use-omnitable.js @@ -40,7 +40,7 @@ export const useOmnitable = (host) => { noLocalSort, noLocalFilter, }), - { collapsedColumns, miniColumns } = useFastLayout({ + { isMiniSize, collapsedColumns, miniColumns } = useFastLayout({ host, columns, settings, @@ -48,6 +48,7 @@ export const useOmnitable = (host) => { resizeSpeedFactor, sortAndGroupOptions, }), + maxToolbarItems = host.hasAttribute('mini') && isMiniSize ? '0' : '', dataIsValid = data && Array.isArray(data) && data.length > 0, [selectedItems, setSelectedItems] = useState([]); @@ -94,6 +95,7 @@ export const useOmnitable = (host) => { host, selectedItems, columns, + maxToolbarItems, }), }; };