@marimo-team/islands 0.24.1-dev99 → 0.24.2-dev1
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/{ConnectedDataExplorerComponent-D9EG584s.js → ConnectedDataExplorerComponent-qIKbwYin.js} +12 -12
- package/dist/{ErrorBoundary-D-EKz8oE.js → ErrorBoundary-CR-ZQN_c.js} +3 -3
- package/dist/any-language-editor-CpTnK43-.js +76 -0
- package/dist/{apl-DbeWBitN.js → apl-BYaaig9_.js} +1 -1
- package/dist/{asciiarmor-DVGcwGvr.js → asciiarmor-GKQFJXQG.js} +1 -1
- package/dist/{asn1-C7ZkyMi3.js → asn1-BsSb7HP5.js} +1 -1
- package/dist/assets/__vite-browser-external-BdKGjRZ4.js +1 -0
- package/dist/assets/{worker-C3TCEtlU.js → worker-DlIBfp9S.js} +2 -2
- package/dist/{asterisk-4f1CDJJt.js → asterisk-B3I8SNb5.js} +1 -1
- package/dist/{brainfuck-Cr9wPNgk.js → brainfuck-DXjk3bQe.js} +1 -1
- package/dist/{button-DlqUC8W-.js → button-CKBkqR9J.js} +6 -1
- package/dist/{capabilities-CGBDXz_E.js → capabilities-CMBBJTcc.js} +1 -1
- package/dist/{chat-ui-CHoI65Rg.js → chat-ui-DttQ-5Ut.js} +27 -27
- package/dist/{check-BcJDmQdF.js → check-CHig47QV.js} +1 -1
- package/dist/{clike-BqAajeY2.js → clike-E2lFbGVj.js} +1 -1
- package/dist/{clojure-Bug5Gc5H.js → clojure-Dn_K4RlK.js} +1 -1
- package/dist/{cmake-R8uEfQdt.js → cmake-DpN2Top5.js} +1 -1
- package/dist/{cobol-DCX3p7Cj.js → cobol-Chf22-GM.js} +1 -1
- package/dist/{coffeescript-CA08GUrM.js → coffeescript-BVe1OiD9.js} +1 -1
- package/dist/{common-BTbFryuV.js → common-DjEjXIEn.js} +6846 -6695
- package/dist/{commonlisp-CUlYkvkK.js → commonlisp-DxoBG7fU.js} +1 -1
- package/dist/{copy-D9h0DuU7.js → copy-CD7S58CY.js} +2 -2
- package/dist/{crystal-CHw9Y8bp.js → crystal-DCM3yc4r.js} +1 -1
- package/dist/{css-BR752P21.js → css-DkZ9mMyI.js} +1 -1
- package/dist/{cypher-CGXYVdtR.js → cypher-Drw_8U5I.js} +1 -1
- package/dist/{d-B3Jeg95D.js → d-CsVGcKMF.js} +1 -1
- package/dist/{diff-BskCEFEO.js → diff-CBikYCUF.js} +1 -1
- package/dist/{dist-wdOJ5T7-.js → dist-3_o3T78I.js} +15 -15
- package/dist/{dist-C2unEUWZ.js → dist-BEmkrGoQ.js} +1492 -1484
- package/dist/{dist-3YfamrHv.js → dist-BVRM2y1P.js} +2 -2
- package/dist/{dist-cnCt-QhO.js → dist-BbSMhhD2.js} +2 -2
- package/dist/{dist-C9fJPKPl.js → dist-BrQGcfQ9.js} +4 -4
- package/dist/{dist-Bsa-FD4p.js → dist-Byj2bV8o.js} +1 -1
- package/dist/{dist-t3GZQZfR.js → dist-BzN60Z2s.js} +1 -1
- package/dist/{dist-CDiyTpo-.js → dist-C5Bn52W4.js} +3 -3
- package/dist/{dist-C1_Y0fKn.js → dist-C7v-9nUK.js} +3 -3
- package/dist/{dist-B59W3SQC.js → dist-CGAxEiaM.js} +2 -2
- package/dist/{dist-wGdFe2i2.js → dist-CO5R6VMi.js} +2 -2
- package/dist/{dist-CkF6zgs_.js → dist-CRjAdnqF.js} +14 -12
- package/dist/{dist-BDP-ZzBX.js → dist-D4Z_qdP4.js} +1 -1
- package/dist/{dist-CdoyP1Fz.js → dist-DEeLqRlU.js} +1 -1
- package/dist/{dist-TouP85Vh.js → dist-DJFiGP2k.js} +2 -2
- package/dist/{dist-Ceegh7bg.js → dist-DVFbIwc5.js} +1 -1
- package/dist/{dist-xIlsWj6K.js → dist-DcgzXCfy.js} +2 -2
- package/dist/{dist-BywyHJ0k.js → dist-Re9sOPOx.js} +2 -2
- package/dist/{dist-CN2pQuxD.js → dist-VdvbxG72.js} +1 -1
- package/dist/{dist-Bwzl7sp6.js → dist-_XvgytiS.js} +1 -1
- package/dist/{dist-BdxSRiPP.js → dist-dAqZAPcF.js} +3 -3
- package/dist/{dist-Cri9-7UA.js → dist-hXd65f0_.js} +1 -1
- package/dist/{dist-BmR-cjzI.js → dist-jWUab2d1.js} +1 -1
- package/dist/{dist-CeTE0w_x.js → dist-qhLI-SHd.js} +2 -2
- package/dist/{dockerfile-HPpWCSsC.js → dockerfile-DJnSntVB.js} +2 -2
- package/dist/{dropdown-menu-Baf29jmS.js → dropdown-menu-DhCfcscX.js} +726 -716
- package/dist/{dtd-9Bm4j20r.js → dtd-BHa4v0Bn.js} +1 -1
- package/dist/{dylan-BOpu3dto.js → dylan-BypL2Zz8.js} +1 -1
- package/dist/{ebnf-BogGWV2V.js → ebnf-5guncNu-.js} +1 -1
- package/dist/{ecl-DAcPDOW1.js → ecl-iRcVIKYZ.js} +1 -1
- package/dist/{eiffel-C4NgXX-Y.js → eiffel-BEqF9aU4.js} +1 -1
- package/dist/{elm-BiY4zCKH.js → elm-DYcfNE9c.js} +1 -1
- package/dist/{erlang-Dg5zi-Qk.js → erlang-BtAuIoF0.js} +1 -1
- package/dist/{error-banner-xVkWHg51.js → error-banner-WDhUzJyg.js} +203 -203
- package/dist/{esm-ElfO9dV2.js → esm-CR1nhb1c.js} +108 -107
- package/dist/{esm-DkklGms7.js → esm-CesmlDrs.js} +5 -5
- package/dist/{extends-KH0CV__g.js → extends-BPB6_lTK.js} +8 -7
- package/dist/{factor-B0-OaK4k.js → factor-3nzOwLuN.js} +2 -2
- package/dist/{fcl-DwSn1rXM.js → fcl-C90TGnJJ.js} +1 -1
- package/dist/{formats-nPPeLOk2.js → formats-CJMVUfb3.js} +3 -3
- package/dist/{forth-BGTlwczu.js → forth-DEaRrLUi.js} +1 -1
- package/dist/{fortran-UUzzVROb.js → fortran-Bv6JRUjY.js} +1 -1
- package/dist/{gas-CjkVDeev.js → gas-JNerWj3-.js} +1 -1
- package/dist/{gherkin-CF2G_sqt.js → gherkin-CSrl-H70.js} +1 -1
- package/dist/{glide-data-editor-n5E9BAD8.js → glide-data-editor-sPZ8fUFn.js} +8 -8
- package/dist/{glide-utils-C0dRuWI_.js → glide-utils-NShAPPtn.js} +3 -3
- package/dist/{groovy-YcvlOKLA.js → groovy-X7euO_vE.js} +1 -1
- package/dist/{haskell-BdvVmmhX.js → haskell-C48Z70Az.js} +1 -1
- package/dist/{haxe-Dkk4Avys.js → haxe-CAUWMmwR.js} +1 -1
- package/dist/{html-to-image-B09MiZT1.js → html-to-image-BTYnN4ev.js} +3782 -3784
- package/dist/{http-Cncc-AcB.js → http-BrSBnhDH.js} +1 -1
- package/dist/{idl-D5eSUN-2.js → idl-BXuPleZv.js} +1 -1
- package/dist/{javascript-DV7jbCN7.js → javascript-B4EPWJf_.js} +1 -1
- package/dist/{julia-DRMVPyrg.js → julia-ke9Kh8b7.js} +1 -1
- package/dist/{label-CEgg1Ymb.js → label-lwzzBHUW.js} +2 -2
- package/dist/{livescript-3tVlEl0n.js → livescript-Ce4uqGAC.js} +1 -1
- package/dist/{loader-D8jS1unC.js → loader-VZ__bv4g.js} +1 -1
- package/dist/{lua-DvuDcwhK.js → lua-D6fti_Jk.js} +2 -2
- package/dist/main.js +6189 -6189
- package/dist/{mathematica-DeUYrmDQ.js → mathematica-DcEpZ3Vj.js} +1 -1
- package/dist/{mbox-CP8ncY6Y.js → mbox-DFBbOu0X.js} +1 -1
- package/dist/{mermaid-CKjZUiG7.js → mermaid-BsHdQeQf.js} +4 -4
- package/dist/{mirc-D0BFuM5A.js → mirc-CqeibO3N.js} +1 -1
- package/dist/{mllike-EW0YU24D.js → mllike-D54QZYTP.js} +1 -1
- package/dist/{modelica-0c53v3vH.js → modelica-DuML2-8V.js} +1 -1
- package/dist/{mscgen-DXtnmkk0.js → mscgen-CJmKwp3b.js} +1 -1
- package/dist/{mumps-DuZvAoq5.js → mumps-DaVgFtkd.js} +1 -1
- package/dist/{nginx-BgxmKoMB.js → nginx-BXN1rqI0.js} +1 -1
- package/dist/{nsis-CXKR4weY.js → nsis-CMfRqf0V.js} +2 -2
- package/dist/{ntriples-BvwIFlGB.js → ntriples-BiOGlMDR.js} +1 -1
- package/dist/{octave-Ddh8-k4Y.js → octave-CgVnzxKk.js} +1 -1
- package/dist/{oz-DASBLPdZ.js → oz-B2mky97X.js} +1 -1
- package/dist/{pascal-DKEHBGVg.js → pascal-BoZhBf6s.js} +1 -1
- package/dist/{perl-CG83_G1y.js → perl-DjzMqXtt.js} +1 -1
- package/dist/{pig-C1IvQ7dn.js → pig-B2mB-01d.js} +1 -1
- package/dist/{powershell-Mh2j_Y9A.js → powershell-D0zT88Aj.js} +1 -1
- package/dist/{process-output-kUlWbyzk.js → process-output-CsALk6tp.js} +3 -3
- package/dist/{properties-Cr3dDyK_.js → properties-3_5qCgOj.js} +1 -1
- package/dist/{protobuf-5RkBxiY2.js → protobuf-Dgoxfi1H.js} +1 -1
- package/dist/{pug-CZBnH0wJ.js → pug-CNRdd8oG.js} +2 -2
- package/dist/{puppet-CjiD4zLe.js → puppet-DzILxZfz.js} +1 -1
- package/dist/{python-n5psJoQh.js → python-AfVdMn_l.js} +1 -1
- package/dist/{q-tF-lfOc1.js → q-C6p-CGWh.js} +1 -1
- package/dist/{r-E-Ox73Cl.js → r-CzKF1D2X.js} +1 -1
- package/dist/{reveal-component-AkbqvWB3.js → reveal-component-g415wUxR.js} +446 -446
- package/dist/{rpm-6OeX6y2d.js → rpm-Bx7FkjTO.js} +1 -1
- package/dist/{ruby-BfKhtJ9W.js → ruby-BMzgq2bf.js} +1 -1
- package/dist/{sas-BXINOUe8.js → sas-ClGVnK3F.js} +1 -1
- package/dist/{schemas-JTyiKlcH.js → schemas-DzK6U94N.js} +1380 -1364
- package/dist/{scheme-Bl28UhhC.js → scheme-C0MXqXep.js} +1 -1
- package/dist/{select-DQ9jU_B_.js → select-3qHpFKF9.js} +295 -295
- package/dist/{shell-C6dbyRNm.js → shell-CiQZv6oG.js} +1 -1
- package/dist/{sieve-CtzpqaVa.js → sieve-BiIMePvV.js} +1 -1
- package/dist/{simple-mode-Fa0cHplh.js → simple-mode-8ETW2RS6.js} +1 -1
- package/dist/{smalltalk-SWUbrj2a.js → smalltalk-9-llftyG.js} +1 -1
- package/dist/{solr-DrqND0L5.js → solr-CxCKEuwq.js} +1 -1
- package/dist/{sparql-DNeyanaw.js → sparql-BRmy7pzx.js} +1 -1
- package/dist/{spec-DNZWpXiu.js → spec-CutWdqo3.js} +4 -4
- package/dist/{spreadsheet-DUXiDdBd.js → spreadsheet-UCNUIGsn.js} +1 -1
- package/dist/{sql-BKgWZE5S.js → sql-D0hSGZ-H.js} +1 -1
- package/dist/{stex-DylRJo9v.js → stex-UeT_Aofp.js} +1 -1
- package/dist/style.css +1 -1
- package/dist/{stylus-dWe8kzGp.js → stylus-Fi4waA2H.js} +1 -1
- package/dist/{swift-BmWs7LJc.js → swift-NqPyaBye.js} +1 -1
- package/dist/{swiper-component-deYugN58.js → swiper-component-C90YjhaV.js} +2 -2
- package/dist/{tcl-DxdPnAuD.js → tcl-B4f0xfmM.js} +1 -1
- package/dist/{textile-CJnP1piA.js → textile-CnNbnPTe.js} +1 -1
- package/dist/{tiddlywiki-DwhP379Y.js → tiddlywiki-CSGSOg38.js} +1 -1
- package/dist/{tiki-1YDPYy3B.js → tiki-9F02WBA6.js} +1 -1
- package/dist/{toDate-DfFzRDkN.js → toDate-D-Rx3ux5.js} +3 -3
- package/dist/{toml-Cm-dCBP-.js → toml-AesZ6RBt.js} +1 -1
- package/dist/{tooltip-7p_32zdw.js → tooltip-Dt77sBeT.js} +88 -88
- package/dist/{troff-DNWcQdLA.js → troff-DlfvveK1.js} +1 -1
- package/dist/{ttcn-CaUsDYVT.js → ttcn--YVSkGs_.js} +1 -1
- package/dist/{ttcn-cfg-BqNhpRrY.js → ttcn-cfg-Bb1Knl_J.js} +1 -1
- package/dist/{turtle-CK42qVcQ.js → turtle-DC24v1bz.js} +1 -1
- package/dist/{useAsyncData-Cyh2jLTR.js → useAsyncData-CH6-CgJF.js} +1 -1
- package/dist/{useDateFormatter-CcY1uXEk.js → useDateFormatter-Cp9Jdxls.js} +2 -2
- package/dist/{useDeepCompareMemoize-BqcHK9ZZ.js → useDeepCompareMemoize-JC87C_jO.js} +1 -1
- package/dist/{useIframeCapabilities-BmYPLMe1.js → useIframeCapabilities-De3C-9b4.js} +1 -1
- package/dist/{useLifecycle-foJH5Q8T.js → useLifecycle-B4RGlyf0.js} +10 -10
- package/dist/{useTheme-C2ZreN00.js → useTheme-CVJ0UOf2.js} +3 -2
- package/dist/{vb-DUEXFGmn.js → vb-Dpc8vhvF.js} +1 -1
- package/dist/{vbscript-O6Mq-1Bt.js → vbscript-B-Y1XnZe.js} +1 -1
- package/dist/{vega-component-LgU-A6O9.js → vega-component-D-IXRnlx.js} +9 -9
- package/dist/{velocity-DTlmtsPi.js → velocity-DHMu9kc-.js} +1 -1
- package/dist/{verilog-prDoxOJS.js → verilog-DhiEaoUl.js} +1 -1
- package/dist/{vhdl-BAJ9qF1C.js → vhdl-D4X23YKO.js} +1 -1
- package/dist/{webidl-ybLbdZxR.js → webidl-SyzNxWpJ.js} +1 -1
- package/dist/{xquery-81N7rqzd.js → xquery-BC2R4Hk6.js} +1 -1
- package/dist/{yacas-BwVftjEP.js → yacas-DLNXPMmH.js} +1 -1
- package/dist/{z80-CmT0MNUO.js → z80-CDXWHOO6.js} +1 -1
- package/package.json +26 -26
- package/src/components/ai/ai-provider-icon.tsx +2 -2
- package/src/components/ai/ai-utils.ts +1 -1
- package/src/components/app-config/ai-config.tsx +33 -37
- package/src/components/app-config/user-config-form.tsx +1 -1
- package/src/components/data-table/__tests__/column-explorer.test.tsx +64 -4
- package/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx +137 -4
- package/src/components/data-table/__tests__/url-detector.test.tsx +1 -1
- package/src/components/data-table/__tests__/useColumnVisibility.test.ts +153 -1
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +54 -25
- package/src/components/data-table/column-visibility-dropdown.tsx +62 -14
- package/src/components/data-table/date-popover.tsx +2 -1
- package/src/components/data-table/hooks/use-column-visibility.ts +76 -0
- package/src/components/data-table/renderers.tsx +4 -8
- package/src/components/data-table/show-only-column-button.tsx +58 -0
- package/src/components/dependency-graph/__tests__/elements.test.ts +151 -0
- package/src/components/dependency-graph/custom-edge.tsx +68 -0
- package/src/components/dependency-graph/custom-node.tsx +54 -26
- package/src/components/dependency-graph/dependency-graph-tree.tsx +110 -21
- package/src/components/dependency-graph/elements.ts +225 -31
- package/src/components/dependency-graph/panels.tsx +23 -2
- package/src/components/dependency-graph/utils/__tests__/layout.test.ts +78 -0
- package/src/components/dependency-graph/utils/layout.ts +108 -18
- package/src/components/editor/Output.tsx +40 -0
- package/src/components/editor/__tests__/Output.test.tsx +85 -2
- package/src/components/editor/connections/secret-combobox.tsx +3 -1
- package/src/components/editor/file-tree/__tests__/file-explorer-navigation.test.tsx +832 -0
- package/src/components/editor/file-tree/__tests__/file-viewer.test.tsx +27 -0
- package/src/components/editor/file-tree/__tests__/requesting-tree.test.ts +130 -0
- package/src/components/editor/file-tree/file-browser-row.tsx +82 -0
- package/src/components/editor/file-tree/file-explorer.tsx +377 -159
- package/src/components/editor/file-tree/file-operations.tsx +1 -1
- package/src/components/editor/file-tree/file-search-results.tsx +142 -0
- package/src/components/editor/file-tree/file-tree-row.tsx +40 -0
- package/src/components/editor/file-tree/file-viewer.tsx +2 -1
- package/src/components/editor/file-tree/renderers.tsx +4 -2
- package/src/components/editor/file-tree/requesting-tree.tsx +162 -32
- package/src/components/editor/file-tree/use-file-search.ts +142 -0
- package/src/components/editor/file-tree/use-hover-expand.ts +34 -0
- package/src/components/editor/navigation/__tests__/navigation.test.ts +30 -0
- package/src/components/editor/navigation/navigation.ts +20 -0
- package/src/components/forms/form.tsx +6 -4
- package/src/components/home/components.tsx +1 -0
- package/src/components/static-html/share-modal.tsx +3 -2
- package/src/components/ui/__tests__/badge.test.ts +63 -0
- package/src/components/ui/__tests__/button.test.ts +19 -0
- package/src/components/ui/__tests__/fullscreen.test.tsx +88 -0
- package/src/components/ui/__tests__/menu-items.test.ts +31 -0
- package/src/components/ui/badge.tsx +9 -7
- package/src/components/ui/button.tsx +1 -0
- package/src/components/ui/combobox.tsx +1 -1
- package/src/components/ui/date-input.tsx +1 -1
- package/src/components/ui/dialog.tsx +3 -1
- package/src/components/ui/fullscreen.tsx +43 -1
- package/src/components/ui/input.tsx +5 -1
- package/src/components/ui/links.tsx +2 -1
- package/src/components/ui/menu-items.tsx +9 -9
- package/src/components/ui/native-select.tsx +2 -2
- package/src/components/ui/navigation.tsx +1 -1
- package/src/components/ui/range-slider.tsx +5 -3
- package/src/components/ui/select.tsx +1 -1
- package/src/components/ui/sheet.tsx +1 -1
- package/src/components/ui/toast.tsx +8 -5
- package/src/components/ui/toaster.tsx +2 -2
- package/src/core/ai/ids/__tests__/ids.test.ts +0 -8
- package/src/core/ai/ids/ids.ts +1 -1
- package/src/core/cells/__tests__/add-missing-import.test.ts +20 -0
- package/src/core/codemirror/language/__tests__/utils.test.ts +1 -1
- package/src/core/config/config-schema.ts +1 -0
- package/src/core/hotkeys/hotkeys.ts +5 -0
- package/src/core/network/__tests__/requests-toasting.test.tsx +14 -0
- package/src/core/network/requests-toasting.tsx +1 -1
- package/src/css/globals.css +28 -0
- package/src/hooks/useEventListener.ts +1 -1
- package/src/plugins/core/RenderHTML.tsx +6 -4
- package/src/plugins/impl/MatrixPlugin.tsx +1 -1
- package/src/plugins/impl/code/any-language-editor.tsx +7 -4
- package/src/plugins/impl/data-frames/__tests__/schema.test.ts +34 -1
- package/src/plugins/impl/data-frames/forms/__tests__/__snapshots__/form.test.tsx.snap +25 -25
- package/src/plugins/impl/data-frames/schema.ts +5 -11
- package/src/plugins/impl/panel/__tests__/utils.test.ts +4 -4
- package/src/plugins/impl/vega/__tests__/vega.test.ts +1 -1
- package/src/stories/cell.stories.tsx +15 -11
- package/src/utils/__tests__/events.test.ts +1 -1
- package/dist/any-language-editor-D751ztAP.js +0 -76
- package/dist/assets/__vite-browser-external-Cf4O9gnt.js +0 -1
|
@@ -1,8 +1,62 @@
|
|
|
1
1
|
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
type ColumnDef,
|
|
5
|
+
getCoreRowModel,
|
|
6
|
+
useReactTable,
|
|
7
|
+
} from "@tanstack/react-table";
|
|
3
8
|
import { act, renderHook } from "@testing-library/react";
|
|
4
9
|
import { describe, expect, it } from "vitest";
|
|
5
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
applyShowOnlyColumns,
|
|
12
|
+
getShowOnlyColumnState,
|
|
13
|
+
getShowOnlyVisibility,
|
|
14
|
+
isShowingOnly,
|
|
15
|
+
isShowingOnlyColumns,
|
|
16
|
+
useColumnVisibility,
|
|
17
|
+
} from "../hooks/use-column-visibility";
|
|
18
|
+
import { INDEX_COLUMN_NAME, SELECT_COLUMN_ID } from "../types";
|
|
19
|
+
|
|
20
|
+
type Row = Record<string, unknown>;
|
|
21
|
+
|
|
22
|
+
const TEST_COLUMNS: ColumnDef<Row>[] = [
|
|
23
|
+
{ id: SELECT_COLUMN_ID, accessorKey: SELECT_COLUMN_ID, enableHiding: false },
|
|
24
|
+
{
|
|
25
|
+
id: INDEX_COLUMN_NAME,
|
|
26
|
+
accessorKey: INDEX_COLUMN_NAME,
|
|
27
|
+
enableHiding: false,
|
|
28
|
+
},
|
|
29
|
+
{ id: "customer_name", accessorKey: "customer_name" },
|
|
30
|
+
{ id: "cust_age", accessorKey: "cust_age" },
|
|
31
|
+
{ id: "order_total", accessorKey: "order_total" },
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
function createTestTable({
|
|
35
|
+
initiallyHidden = [],
|
|
36
|
+
nonHideable = [],
|
|
37
|
+
}: {
|
|
38
|
+
initiallyHidden?: string[];
|
|
39
|
+
nonHideable?: string[];
|
|
40
|
+
} = {}) {
|
|
41
|
+
const { result } = renderHook(() =>
|
|
42
|
+
useReactTable<Row>({
|
|
43
|
+
data: [],
|
|
44
|
+
columns: TEST_COLUMNS.map((column) =>
|
|
45
|
+
nonHideable.includes(column.id as string)
|
|
46
|
+
? { ...column, enableHiding: false }
|
|
47
|
+
: column,
|
|
48
|
+
),
|
|
49
|
+
getCoreRowModel: getCoreRowModel(),
|
|
50
|
+
locale: "en-US",
|
|
51
|
+
initialState: {
|
|
52
|
+
columnVisibility: Object.fromEntries(
|
|
53
|
+
initiallyHidden.map((id) => [id, false]),
|
|
54
|
+
),
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
);
|
|
58
|
+
return result.current;
|
|
59
|
+
}
|
|
6
60
|
|
|
7
61
|
describe("useColumnVisibility", () => {
|
|
8
62
|
it("should initialize with correct default values", () => {
|
|
@@ -40,3 +94,101 @@ describe("useColumnVisibility", () => {
|
|
|
40
94
|
expect(result.current.columnVisibility).toEqual({ a: false, c: false });
|
|
41
95
|
});
|
|
42
96
|
});
|
|
97
|
+
|
|
98
|
+
describe("getShowOnlyVisibility", () => {
|
|
99
|
+
it("shows matching hideable columns and hides the rest", () => {
|
|
100
|
+
const table = createTestTable({ initiallyHidden: ["cust_age"] });
|
|
101
|
+
|
|
102
|
+
expect(
|
|
103
|
+
getShowOnlyVisibility(table, ["customer_name", "order_total"]),
|
|
104
|
+
).toEqual({
|
|
105
|
+
customer_name: true,
|
|
106
|
+
cust_age: false,
|
|
107
|
+
order_total: true,
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("ignores non-hideable columns in the input", () => {
|
|
112
|
+
const table = createTestTable({ nonHideable: ["customer_name"] });
|
|
113
|
+
|
|
114
|
+
expect(
|
|
115
|
+
getShowOnlyVisibility(table, [
|
|
116
|
+
SELECT_COLUMN_ID,
|
|
117
|
+
"customer_name",
|
|
118
|
+
"cust_age",
|
|
119
|
+
]),
|
|
120
|
+
).toEqual({
|
|
121
|
+
cust_age: true,
|
|
122
|
+
order_total: false,
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
it("hides every hideable column when the input is empty", () => {
|
|
127
|
+
const table = createTestTable();
|
|
128
|
+
|
|
129
|
+
expect(getShowOnlyVisibility(table, [])).toEqual({
|
|
130
|
+
customer_name: false,
|
|
131
|
+
cust_age: false,
|
|
132
|
+
order_total: false,
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("isShowingOnly", () => {
|
|
138
|
+
it("returns true when visible hideable columns match the input", () => {
|
|
139
|
+
const table = createTestTable({
|
|
140
|
+
initiallyHidden: ["cust_age", "order_total"],
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
expect(isShowingOnly(table, ["customer_name"])).toBe(true);
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it("returns false when extra hideable columns remain visible", () => {
|
|
147
|
+
const table = createTestTable();
|
|
148
|
+
|
|
149
|
+
expect(isShowingOnly(table, ["customer_name"])).toBe(false);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it("ignores non-hideable columns in the input", () => {
|
|
153
|
+
const table = createTestTable({
|
|
154
|
+
initiallyHidden: ["cust_age", "order_total"],
|
|
155
|
+
nonHideable: ["customer_name"],
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
expect(isShowingOnly(table, [SELECT_COLUMN_ID, "customer_name"])).toBe(
|
|
159
|
+
true,
|
|
160
|
+
);
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
it("returns true when every hideable column is hidden and the input is empty", () => {
|
|
164
|
+
const table = createTestTable({
|
|
165
|
+
initiallyHidden: ["customer_name", "cust_age", "order_total"],
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
expect(isShowingOnly(table, [])).toBe(true);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe("isShowingOnlyColumns", () => {
|
|
173
|
+
it("reuses precomputed visible hideable columns", () => {
|
|
174
|
+
const table = createTestTable({
|
|
175
|
+
initiallyHidden: ["cust_age", "order_total"],
|
|
176
|
+
});
|
|
177
|
+
const state = getShowOnlyColumnState(table);
|
|
178
|
+
|
|
179
|
+
expect(isShowingOnlyColumns(state, ["customer_name"])).toBe(true);
|
|
180
|
+
expect(isShowingOnly(table, ["customer_name"])).toBe(true);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
describe("applyShowOnlyColumns", () => {
|
|
185
|
+
it("shows only the requested hideable columns", () => {
|
|
186
|
+
const table = createTestTable({ initiallyHidden: ["cust_age"] });
|
|
187
|
+
|
|
188
|
+
act(() => {
|
|
189
|
+
applyShowOnlyColumns(table, ["customer_name", "order_total"]);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
expect(isShowingOnly(table, ["customer_name", "order_total"])).toBe(true);
|
|
193
|
+
});
|
|
194
|
+
});
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
EyeIcon,
|
|
11
11
|
EyeOffIcon,
|
|
12
12
|
} from "lucide-react";
|
|
13
|
-
import { useState } from "react";
|
|
13
|
+
import { useMemo, useState } from "react";
|
|
14
14
|
import { useLocale } from "react-aria";
|
|
15
15
|
import {
|
|
16
16
|
AddDataframeChart,
|
|
@@ -52,8 +52,12 @@ import type { Column, Table } from "@tanstack/react-table";
|
|
|
52
52
|
import { cn } from "@/utils/cn";
|
|
53
53
|
import {
|
|
54
54
|
getColumnCountForDisplay,
|
|
55
|
+
getShowOnlyColumnState,
|
|
55
56
|
getUserColumnVisibilityCounts,
|
|
57
|
+
isShowingOnlyColumns,
|
|
58
|
+
type ShowOnlyColumnState,
|
|
56
59
|
} from "../hooks/use-column-visibility";
|
|
60
|
+
import { ShowOnlyColumnButton } from "../show-only-column-button";
|
|
57
61
|
|
|
58
62
|
interface ColumnExplorerPanelProps<TData> {
|
|
59
63
|
previewColumn: PreviewColumn;
|
|
@@ -94,6 +98,11 @@ export function ColumnExplorerPanel<TData>({
|
|
|
94
98
|
hiddenColumns: hiddenColumnCount,
|
|
95
99
|
} = getColumnCountForDisplay(table, totalColumns);
|
|
96
100
|
const { visible: visibleColumnCount } = getUserColumnVisibilityCounts(table);
|
|
101
|
+
const columnVisibility = table.getState().columnVisibility;
|
|
102
|
+
const showOnlyColumnState = useMemo(
|
|
103
|
+
() => getShowOnlyColumnState(table),
|
|
104
|
+
[table, columnVisibility],
|
|
105
|
+
);
|
|
97
106
|
|
|
98
107
|
const { rowsAndColumns, hiddenSuffix } = prettifyRowColumnCount({
|
|
99
108
|
numRows: totalRows,
|
|
@@ -162,6 +171,8 @@ export function ColumnExplorerPanel<TData>({
|
|
|
162
171
|
dataType={dataType}
|
|
163
172
|
externalType={externalType}
|
|
164
173
|
previewColumn={previewColumn}
|
|
174
|
+
table={table}
|
|
175
|
+
showOnlyColumnState={showOnlyColumnState}
|
|
165
176
|
defaultExpanded={index === 0}
|
|
166
177
|
/>
|
|
167
178
|
);
|
|
@@ -179,6 +190,8 @@ function ColumnItem<TData>({
|
|
|
179
190
|
dataType,
|
|
180
191
|
externalType,
|
|
181
192
|
previewColumn,
|
|
193
|
+
table,
|
|
194
|
+
showOnlyColumnState,
|
|
182
195
|
defaultExpanded = false,
|
|
183
196
|
}: {
|
|
184
197
|
columnName: string;
|
|
@@ -186,6 +199,8 @@ function ColumnItem<TData>({
|
|
|
186
199
|
dataType: DataType;
|
|
187
200
|
externalType: string;
|
|
188
201
|
previewColumn: PreviewColumn;
|
|
202
|
+
table: Table<TData>;
|
|
203
|
+
showOnlyColumnState: ShowOnlyColumnState;
|
|
189
204
|
defaultExpanded?: boolean;
|
|
190
205
|
}) {
|
|
191
206
|
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
|
|
@@ -218,36 +233,50 @@ function ColumnItem<TData>({
|
|
|
218
233
|
)}
|
|
219
234
|
/>
|
|
220
235
|
{column?.getCanHide() && (
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
size="icon"
|
|
229
|
-
aria-label={
|
|
230
|
-
column.getIsVisible() ? "Hide column" : "Show column"
|
|
231
|
-
}
|
|
236
|
+
<>
|
|
237
|
+
<ShowOnlyColumnButton
|
|
238
|
+
table={table}
|
|
239
|
+
columnIds={[columnName]}
|
|
240
|
+
disabled={isShowingOnlyColumns(showOnlyColumnState, [
|
|
241
|
+
columnName,
|
|
242
|
+
])}
|
|
232
243
|
className={cn(
|
|
233
|
-
"hover:bg-muted text-muted-foreground hover:text-primary",
|
|
234
244
|
column.getIsVisible()
|
|
235
245
|
? "group-hover:opacity-100 opacity-0"
|
|
236
246
|
: "opacity-100",
|
|
237
247
|
)}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}}
|
|
248
|
+
/>
|
|
249
|
+
<Tooltip
|
|
250
|
+
content={column.getIsVisible() ? "Hide column" : "Show column"}
|
|
251
|
+
delayDuration={400}
|
|
243
252
|
>
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
253
|
+
<Button
|
|
254
|
+
type="button"
|
|
255
|
+
variant="text"
|
|
256
|
+
size="icon"
|
|
257
|
+
aria-label={
|
|
258
|
+
column.getIsVisible() ? "Hide column" : "Show column"
|
|
259
|
+
}
|
|
260
|
+
className={cn(
|
|
261
|
+
"hover:bg-muted text-muted-foreground hover:text-primary",
|
|
262
|
+
column.getIsVisible()
|
|
263
|
+
? "group-hover:opacity-100 opacity-0"
|
|
264
|
+
: "opacity-100",
|
|
265
|
+
)}
|
|
266
|
+
onClick={(e) => {
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
e.stopPropagation();
|
|
269
|
+
column.toggleVisibility(!column.getIsVisible());
|
|
270
|
+
}}
|
|
271
|
+
>
|
|
272
|
+
{column.getIsVisible() ? (
|
|
273
|
+
<EyeIcon className="h-3 w-3" strokeWidth={2.5} />
|
|
274
|
+
) : (
|
|
275
|
+
<EyeOffIcon className="h-3 w-3" strokeWidth={2.5} />
|
|
276
|
+
)}
|
|
277
|
+
</Button>
|
|
278
|
+
</Tooltip>
|
|
279
|
+
</>
|
|
251
280
|
)}
|
|
252
281
|
<span className="text-xs text-muted-foreground">{externalType}</span>
|
|
253
282
|
</div>
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
// https://github.com/TanStack/table/issues/5567
|
|
6
6
|
|
|
7
7
|
import type { Table } from "@tanstack/react-table";
|
|
8
|
-
import { Columns3Icon, EyeIcon, EyeOffIcon } from "lucide-react";
|
|
9
|
-
import React from "react";
|
|
8
|
+
import { Columns3Icon, EyeIcon, EyeOffIcon, ScanEyeIcon } from "lucide-react";
|
|
9
|
+
import React, { useMemo } from "react";
|
|
10
10
|
import { ColumnName } from "@/components/datasources/components";
|
|
11
11
|
import { Button } from "@/components/ui/button";
|
|
12
12
|
import {
|
|
@@ -28,6 +28,11 @@ import { cn } from "@/utils/cn";
|
|
|
28
28
|
import { Events } from "@/utils/events";
|
|
29
29
|
import { smartMatchFilter } from "@/utils/smartMatch";
|
|
30
30
|
import { NAMELESS_COLUMN_PREFIX } from "./columns";
|
|
31
|
+
import {
|
|
32
|
+
applyShowOnlyColumns,
|
|
33
|
+
isShowingOnlyColumns,
|
|
34
|
+
} from "./hooks/use-column-visibility";
|
|
35
|
+
import { ShowOnlyColumnButton } from "./show-only-column-button";
|
|
31
36
|
import { INDEX_COLUMN_NAME, SELECT_COLUMN_ID } from "./types";
|
|
32
37
|
|
|
33
38
|
function getUserColumns<TData>(table: Table<TData>) {
|
|
@@ -95,6 +100,23 @@ export const ColumnVisibilityDropdown = <TData,>({
|
|
|
95
100
|
> =>
|
|
96
101
|
action.kind === "select-matching" || action.kind === "deselect-matching",
|
|
97
102
|
);
|
|
103
|
+
const showOnlyMatchIds =
|
|
104
|
+
list.searchQuery !== ""
|
|
105
|
+
? list.visibleOptions
|
|
106
|
+
.filter((option) => !option.disabled)
|
|
107
|
+
.map((option) => option.value)
|
|
108
|
+
: [];
|
|
109
|
+
const showOnlyColumnState = useMemo(
|
|
110
|
+
() => ({
|
|
111
|
+
visibleHideableColumnIds: hideableIds.filter(
|
|
112
|
+
(id) => !hiddenIds.includes(id),
|
|
113
|
+
),
|
|
114
|
+
hideableColumnIdSet: new Set(hideableIds),
|
|
115
|
+
}),
|
|
116
|
+
[hideableIds, hiddenIds],
|
|
117
|
+
);
|
|
118
|
+
const hasSearchBulkActions =
|
|
119
|
+
showOnlyMatchIds.length > 0 || matchingActions.length > 0;
|
|
98
120
|
|
|
99
121
|
return (
|
|
100
122
|
<Popover open={list.open} onOpenChange={list.setOpen}>
|
|
@@ -145,8 +167,25 @@ export const ColumnVisibilityDropdown = <TData,>({
|
|
|
145
167
|
<CommandSeparator />
|
|
146
168
|
</>
|
|
147
169
|
) : (
|
|
148
|
-
|
|
170
|
+
hasSearchBulkActions && (
|
|
149
171
|
<>
|
|
172
|
+
<CommandItem
|
|
173
|
+
value="__show_only_matching__"
|
|
174
|
+
disabled={
|
|
175
|
+
showOnlyMatchIds.length === 0 ||
|
|
176
|
+
isShowingOnlyColumns(
|
|
177
|
+
showOnlyColumnState,
|
|
178
|
+
showOnlyMatchIds,
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
onSelect={() => {
|
|
182
|
+
applyShowOnlyColumns(table, showOnlyMatchIds);
|
|
183
|
+
}}
|
|
184
|
+
className="cursor-pointer"
|
|
185
|
+
>
|
|
186
|
+
<ScanEyeIcon className="w-3 h-3 mr-1.5" />
|
|
187
|
+
Show only {showOnlyMatchIds.length} matching
|
|
188
|
+
</CommandItem>
|
|
150
189
|
{matchingActions.map((action) => (
|
|
151
190
|
<CommandItem
|
|
152
191
|
key={action.kind}
|
|
@@ -194,17 +233,26 @@ export const ColumnVisibilityDropdown = <TData,>({
|
|
|
194
233
|
/>
|
|
195
234
|
)}
|
|
196
235
|
{!option.disabled && (
|
|
197
|
-
<span
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
236
|
+
<span className="ml-auto flex items-center gap-0.5">
|
|
237
|
+
<ShowOnlyColumnButton
|
|
238
|
+
table={table}
|
|
239
|
+
columnIds={[option.value]}
|
|
240
|
+
disabled={isShowingOnlyColumns(showOnlyColumnState, [
|
|
241
|
+
option.value,
|
|
242
|
+
])}
|
|
243
|
+
iconClassName="w-3 h-3"
|
|
244
|
+
/>
|
|
245
|
+
<span
|
|
246
|
+
className={cn(
|
|
247
|
+
hidden ? "text-primary" : "text-muted-foreground",
|
|
248
|
+
)}
|
|
249
|
+
>
|
|
250
|
+
{hidden ? (
|
|
251
|
+
<EyeOffIcon className="w-3 h-3" />
|
|
252
|
+
) : (
|
|
253
|
+
<EyeIcon className="w-3 h-3" />
|
|
254
|
+
)}
|
|
255
|
+
</span>
|
|
208
256
|
</span>
|
|
209
257
|
)}
|
|
210
258
|
</CommandItem>
|
|
@@ -45,7 +45,8 @@ export const DatePopover: React.FC<DatePopoverProps> = ({
|
|
|
45
45
|
|
|
46
46
|
const TimezoneDisplay = ({ date }: { date: Date }) => {
|
|
47
47
|
const { locale } = useLocale();
|
|
48
|
-
const localTimezone = Intl.DateTimeFormat(locale).resolvedOptions()
|
|
48
|
+
const localTimezone = new Intl.DateTimeFormat(locale).resolvedOptions()
|
|
49
|
+
.timeZone;
|
|
49
50
|
const hasSubSeconds = date.getUTCMilliseconds() !== 0;
|
|
50
51
|
|
|
51
52
|
const utcFormatter = useDateFormatter(
|
|
@@ -54,3 +54,79 @@ export function getColumnCountForDisplay<TData>(
|
|
|
54
54
|
hiddenColumns: counts.hidden,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
export function getShowOnlyVisibility<TData>(
|
|
59
|
+
table: Table<TData>,
|
|
60
|
+
columnIds: string[],
|
|
61
|
+
): VisibilityState {
|
|
62
|
+
const showOnlySet = new Set(columnIds);
|
|
63
|
+
const visibility: VisibilityState = {};
|
|
64
|
+
|
|
65
|
+
for (const column of table.getAllLeafColumns()) {
|
|
66
|
+
if (!column.getCanHide()) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
visibility[column.id] = showOnlySet.has(column.id);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return visibility;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function applyShowOnlyColumns<TData>(
|
|
76
|
+
table: Table<TData>,
|
|
77
|
+
columnIds: string[],
|
|
78
|
+
): void {
|
|
79
|
+
table.setColumnVisibility((previous) => ({
|
|
80
|
+
...previous,
|
|
81
|
+
...getShowOnlyVisibility(table, columnIds),
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface ShowOnlyColumnState {
|
|
86
|
+
visibleHideableColumnIds: readonly string[];
|
|
87
|
+
hideableColumnIdSet: ReadonlySet<string>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function getShowOnlyColumnState<TData>(
|
|
91
|
+
table: Table<TData>,
|
|
92
|
+
): ShowOnlyColumnState {
|
|
93
|
+
const hideableIds: string[] = [];
|
|
94
|
+
const visibleHideableColumnIds: string[] = [];
|
|
95
|
+
|
|
96
|
+
for (const column of table.getAllLeafColumns()) {
|
|
97
|
+
if (!column.getCanHide()) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
hideableIds.push(column.id);
|
|
101
|
+
if (column.getIsVisible()) {
|
|
102
|
+
visibleHideableColumnIds.push(column.id);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
visibleHideableColumnIds,
|
|
108
|
+
hideableColumnIdSet: new Set(hideableIds),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function isShowingOnlyColumns(
|
|
113
|
+
state: ShowOnlyColumnState,
|
|
114
|
+
columnIds: readonly string[],
|
|
115
|
+
): boolean {
|
|
116
|
+
const targetIds = new Set(
|
|
117
|
+
columnIds.filter((id) => state.hideableColumnIdSet.has(id)),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
if (state.visibleHideableColumnIds.length !== targetIds.size) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return state.visibleHideableColumnIds.every((id) => targetIds.has(id));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function isShowingOnly<TData>(
|
|
128
|
+
table: Table<TData>,
|
|
129
|
+
columnIds: string[],
|
|
130
|
+
): boolean {
|
|
131
|
+
return isShowingOnlyColumns(getShowOnlyColumnState(table), columnIds);
|
|
132
|
+
}
|
|
@@ -71,11 +71,7 @@ export function renderTableHeader<TData>(
|
|
|
71
71
|
{renderHeaderGroup(table.getCenterHeaderGroups())}
|
|
72
72
|
{renderHeaderGroup(table.getRightHeaderGroups())}
|
|
73
73
|
{table.getAllColumns().length <= AUTO_WIDTH_MAX_COLUMNS && (
|
|
74
|
-
<th
|
|
75
|
-
className="w-full border-0"
|
|
76
|
-
aria-hidden="true"
|
|
77
|
-
role="presentation"
|
|
78
|
-
/>
|
|
74
|
+
<th className="w-full border-0" aria-hidden="true" />
|
|
79
75
|
)}
|
|
80
76
|
</TableRow>
|
|
81
77
|
</TableHeader>
|
|
@@ -217,7 +213,7 @@ export const DataTableBody = <TData,>({
|
|
|
217
213
|
{renderCells(row.getCenterVisibleCells())}
|
|
218
214
|
{renderCells(row.getRightVisibleCells())}
|
|
219
215
|
{columns.length <= AUTO_WIDTH_MAX_COLUMNS && (
|
|
220
|
-
<td className="border-0" aria-hidden="true"
|
|
216
|
+
<td className="border-0" aria-hidden="true" />
|
|
221
217
|
)}
|
|
222
218
|
</TableRow>
|
|
223
219
|
);
|
|
@@ -247,7 +243,7 @@ export const DataTableBody = <TData,>({
|
|
|
247
243
|
data-virtual-spacer=""
|
|
248
244
|
style={{ height: virtualItems[0].start }}
|
|
249
245
|
>
|
|
250
|
-
<td colSpan={totalColSpan} />
|
|
246
|
+
<td aria-hidden="true" colSpan={totalColSpan} />
|
|
251
247
|
</tr>
|
|
252
248
|
)}
|
|
253
249
|
{virtualItems.map((vItem) => renderRow(rows[vItem.index]))}
|
|
@@ -258,7 +254,7 @@ export const DataTableBody = <TData,>({
|
|
|
258
254
|
height: totalSize - (virtualItems.at(-1)?.end ?? totalSize),
|
|
259
255
|
}}
|
|
260
256
|
>
|
|
261
|
-
<td colSpan={totalColSpan} />
|
|
257
|
+
<td aria-hidden="true" colSpan={totalColSpan} />
|
|
262
258
|
</tr>
|
|
263
259
|
)}
|
|
264
260
|
</>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
"use no memo";
|
|
3
|
+
|
|
4
|
+
import type { Table } from "@tanstack/react-table";
|
|
5
|
+
import { ScanEyeIcon } from "lucide-react";
|
|
6
|
+
import { Button } from "@/components/ui/button";
|
|
7
|
+
import { Tooltip } from "@/components/ui/tooltip";
|
|
8
|
+
import { cn } from "@/utils/cn";
|
|
9
|
+
import { applyShowOnlyColumns } from "./hooks/use-column-visibility";
|
|
10
|
+
|
|
11
|
+
export const SHOW_ONLY_COLUMN_LABEL = "Show only this column";
|
|
12
|
+
|
|
13
|
+
interface ShowOnlyColumnButtonProps<TData> {
|
|
14
|
+
table: Table<TData>;
|
|
15
|
+
columnIds: string[];
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
iconClassName?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function ShowOnlyColumnButton<TData>({
|
|
22
|
+
table,
|
|
23
|
+
columnIds,
|
|
24
|
+
disabled,
|
|
25
|
+
className,
|
|
26
|
+
iconClassName = "h-3 w-3",
|
|
27
|
+
}: ShowOnlyColumnButtonProps<TData>) {
|
|
28
|
+
return (
|
|
29
|
+
<Tooltip content={SHOW_ONLY_COLUMN_LABEL} delayDuration={400}>
|
|
30
|
+
<Button
|
|
31
|
+
type="button"
|
|
32
|
+
variant="text"
|
|
33
|
+
size="icon"
|
|
34
|
+
aria-label={SHOW_ONLY_COLUMN_LABEL}
|
|
35
|
+
aria-disabled={disabled}
|
|
36
|
+
tabIndex={disabled ? -1 : 0}
|
|
37
|
+
className={cn(
|
|
38
|
+
"h-6 w-6 hover:bg-muted text-muted-foreground hover:text-primary",
|
|
39
|
+
disabled && "opacity-50",
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
onPointerDown={(event) => {
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
}}
|
|
45
|
+
onClick={(event) => {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
event.stopPropagation();
|
|
48
|
+
if (disabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
applyShowOnlyColumns(table, columnIds);
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<ScanEyeIcon className={iconClassName} strokeWidth={2.5} />
|
|
55
|
+
</Button>
|
|
56
|
+
</Tooltip>
|
|
57
|
+
);
|
|
58
|
+
}
|