@marimo-team/islands 0.23.9-dev2 → 0.23.9-dev4
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-2lBNiUv6.js → ConnectedDataExplorerComponent-OzrfMM5L.js} +20 -20
- package/dist/ErrorBoundary-rULOrC_p.js +175 -0
- package/dist/{ImageComparisonComponent-CNHIsPDj.js → ImageComparisonComponent-CHrI72em.js} +1 -1
- package/dist/{Plot-4wn-lMVn.js → Plot-CAYS29h9.js} +1 -1
- package/dist/{_baseUniq-CxZRxRRo.js → _baseUniq-B_2Hw7zG.js} +3 -3
- package/dist/{any-language-editor-VWs_7v27.js → any-language-editor-DfdpyDv_.js} +23 -23
- package/dist/architecture-7HQA4BMR-Kyc44TmC.js +6 -0
- package/dist/{architectureDiagram-VXUJARFQ-CXVJxFhH.js → architectureDiagram-VXUJARFQ-CT2SuxNw.js} +15 -15
- package/dist/{arrays-CldYf7p7.js → arrays-sEtDRoG4.js} +1 -1
- package/dist/{blockDiagram-VD42YOAC-DGDaxR8I.js → blockDiagram-VD42YOAC-Dy7hlFla.js} +7 -7
- package/dist/{button-Dj4BTre0.js → button-C5K9fIPF.js} +2 -2
- package/dist/{c4Diagram-YG6GDRKO-C2hc6ne8.js → c4Diagram-YG6GDRKO-BXlAmZ8Z.js} +4 -4
- package/dist/{capabilities-C9rrYCzf.js → capabilities-BceAxrAW.js} +2 -2
- package/dist/{channel-BBoIVUrJ.js → channel-D_PHgcig.js} +1 -1
- package/dist/{chat-ui-D3XBept8.js → chat-ui-BDI3FMI8.js} +29 -29
- package/dist/{check-BcUIXnUT.js → check-DTbrK0zt.js} +1 -1
- package/dist/{chunk-4F5CHEZ2-BZq7Kom7.js → chunk-4F5CHEZ2-D9nGEHV8.js} +1 -1
- package/dist/{chunk-5FQGJX7Z-BOg95xG5.js → chunk-5FQGJX7Z-BNjes6Yx.js} +5 -5
- package/dist/{chunk-ABZYJK2D-D0cLy8Bb.js → chunk-ABZYJK2D-Dz0-H2B5.js} +1 -1
- package/dist/{chunk-ATLVNIR6-BXsEjlHF.js → chunk-ATLVNIR6-o0Z5MZLd.js} +1 -1
- package/dist/{chunk-B2363JML-D9-XOau1.js → chunk-B2363JML-KEJpLGGP.js} +1 -1
- package/dist/{chunk-B4BG7PRW-Q1usn6T3.js → chunk-B4BG7PRW-BL98U9B4.js} +4 -4
- package/dist/{chunk-DI55MBZ5-D1qLYNrb.js → chunk-DI55MBZ5-Dwkn0LWm.js} +4 -4
- package/dist/{chunk-EXTU4WIE-BKNXdLmD.js → chunk-EXTU4WIE-9sNjmQrB.js} +1 -1
- package/dist/{chunk-FRFDVMJY-BSBUAX7r.js → chunk-FRFDVMJY-DzQqMWrl.js} +1 -1
- package/dist/{chunk-JA3XYJ7Z-D6c6cOBG.js → chunk-JA3XYJ7Z-C32Y7Epf.js} +2 -2
- package/dist/{chunk-JZLCHNYA-BvsPHJmL.js → chunk-JZLCHNYA-C6ftyVMN.js} +4 -4
- package/dist/{chunk-N4CR4FBY-8ycT-O9a.js → chunk-N4CR4FBY-DUhGZhZs.js} +5 -5
- package/dist/{chunk-PL6DKKU2-B0MTXvyc.js → chunk-PL6DKKU2-D7km-08O.js} +1 -1
- package/dist/{chunk-QN33PNHL-Bb-eUBW3.js → chunk-QN33PNHL-0K6SDYn3.js} +1 -1
- package/dist/{chunk-QXUST7PY-DV8yRwBd.js → chunk-QXUST7PY-DMhsRpYK.js} +5 -5
- package/dist/{chunk-S3R3BYOJ-mQeCz5CE.js → chunk-S3R3BYOJ-oAe3dEbO.js} +3 -3
- package/dist/{chunk-SJTYNZTY-CEG4F0pB.js → chunk-SJTYNZTY-BkJrPRFC.js} +1 -1
- package/dist/{chunk-TCCFYFTB-d3HOqL2I.js → chunk-TCCFYFTB-D58KeXnC.js} +6 -6
- package/dist/{chunk-TQ3KTPDO-DiCtqVSi.js → chunk-TQ3KTPDO-D_yA_wAb.js} +1 -1
- package/dist/{chunk-TZMSLE5B-BqW10dHe.js → chunk-TZMSLE5B-yBKS_DQU.js} +1 -1
- package/dist/{chunk-UMXZTB3W-97iS1iEl.js → chunk-UMXZTB3W-D7uwvNjd.js} +1 -1
- package/dist/{classDiagram-2ON5EDUG--Yh__LHb.js → classDiagram-2ON5EDUG-QjoAcuFE.js} +10 -10
- package/dist/{classDiagram-v2-WZHVMYZB-BC7X7Xtc.js → classDiagram-v2-WZHVMYZB-bUCv4gu2.js} +10 -10
- package/dist/{clone-BuIIsfA8.js → clone-Q4Fqwn6q.js} +1 -1
- package/dist/{code-block-37QAKDTI-BsGy1AOJ.js → code-block-37QAKDTI-m92Yc8pv.js} +2 -2
- package/dist/{code-visibility-Dt0Aq6-t.js → code-visibility-VZebNmSs.js} +7073 -7439
- package/dist/{constants-D0gkYoE2.js → constants-T20xxyNf.js} +2 -2
- package/dist/{copy-DLf4aN7I.js → copy-BuQpJEzp.js} +2 -2
- package/dist/{dagre-6UL2VRFP-DRBWoQUw.js → dagre-6UL2VRFP-J0JKgwOt.js} +11 -11
- package/dist/{dagre-VYEPqXIV.js → dagre-By_QsQgc.js} +11 -11
- package/dist/{data-grid-overlay-editor-efe5ZagF.js → data-grid-overlay-editor-mfEJ5475.js} +2 -2
- package/dist/{diagram-PSM6KHXK-H66ATWP2.js → diagram-PSM6KHXK-DYgJuNk9.js} +18 -18
- package/dist/{diagram-QEK2KX5R-DItl5Wns.js → diagram-QEK2KX5R-CKdBR2sb.js} +14 -14
- package/dist/{diagram-S2PKOQOG-CtuW_ZuL.js → diagram-S2PKOQOG-Dpi7mo5W.js} +14 -14
- package/dist/dist-0Fif7jnk.js +5 -0
- package/dist/{dist-Dh3wkoyH.js → dist-4j4c7bjm.js} +2 -2
- package/dist/{dist-CDFZi-QD.js → dist-B3P2fFpz.js} +1 -1
- package/dist/{dist-BNyrZfqT.js → dist-B3pZ0Ab6.js} +2 -2
- package/dist/dist-B5h_9sHB.js +6 -0
- package/dist/dist-B9M6R5ye.js +5 -0
- package/dist/dist-BCt3tnck.js +8 -0
- package/dist/{dist-BrBucRXs.js → dist-BTfv03uy.js} +2 -2
- package/dist/dist-BUIJwMwn.js +8 -0
- package/dist/{dist-CYEylvZA.js → dist-BbbIBDiQ.js} +1 -1
- package/dist/{dist-KnujRhFL.js → dist-BcuoonNH.js} +4 -4
- package/dist/{dist-DJ6zJQZ4.js → dist-Bde4a2kU.js} +2 -2
- package/dist/{dist-t_qL7eB8.js → dist-Bfwsv11D.js} +2 -2
- package/dist/{dist-CNtV21T_.js → dist-BhM8gdSO.js} +4 -4
- package/dist/{dist-nuW5EDYT.js → dist-BotSqB48.js} +2 -2
- package/dist/dist-BpquMd3k.js +5 -0
- package/dist/dist-BzJsqYfz.js +5 -0
- package/dist/{dist-D029TiHd.js → dist-Bz_sYWbr.js} +2 -2
- package/dist/{dist-D3ZI9nhS.js → dist-C1BYNeCR.js} +4 -4
- package/dist/{dist-Bc5pmZIw.js → dist-C5VC_yzu.js} +1 -1
- package/dist/dist-CA5ELXAf.js +6 -0
- package/dist/dist-CLBRs6Uv.js +5 -0
- package/dist/{dist-Dhk6FMb0.js → dist-CLJWPTX2.js} +3 -3
- package/dist/{dist-C34oIrQ9.js → dist-CLUtPrdy.js} +1 -1
- package/dist/dist-CStVCMbq.js +5 -0
- package/dist/{dist-B8RaFTRF.js → dist-CUCNs1ja.js} +2 -2
- package/dist/dist-CZRIEY3Y.js +8 -0
- package/dist/{dist-UcOPnRMa.js → dist-CcXxepx6.js} +3 -3
- package/dist/dist-CuUHbFD0.js +5 -0
- package/dist/{dist-B8BjrFUE.js → dist-Cy1WxgBD.js} +5 -5
- package/dist/{dist-WdPUFc56.js → dist-D4CewLk6.js} +1 -1
- package/dist/{dist-DMZNjfX4.js → dist-DRfcqpxJ.js} +2 -2
- package/dist/dist-DV7Iabxb.js +8 -0
- package/dist/{dist-usPCDYx8.js → dist-D_bzzWBm.js} +1 -1
- package/dist/{dist-BvCfQQQE.js → dist-DgnE8F-r.js} +1 -1
- package/dist/{dist-JEhxD_cn.js → dist-DhHh0jLg.js} +1 -1
- package/dist/{dist-DGAfI2rB.js → dist-DqAWR3CS.js} +2 -2
- package/dist/{dist--sWVZwjW.js → dist-Du8WkPuU.js} +1 -1
- package/dist/dist-DuEeHMvL.js +5 -0
- package/dist/{dist-BTyJtnNg.js → dist-DxvORzUR.js} +1 -1
- package/dist/{dist-B507mf_I.js → dist-RqXTaiir.js} +2 -2
- package/dist/{dist-Yrfc6L0I.js → dist-fQ0ViXGs.js} +3 -3
- package/dist/{dist-B4LJpMEg.js → dist-h2c8sZvT.js} +1 -1
- package/dist/{dist-C2ej4eOH.js → dist-luvabDEB.js} +2 -2
- package/dist/{dist-B52GXZbd.js → dist-p2qyWijU.js} +2 -2
- package/dist/{erDiagram-Q2GNP2WA--19X2kU5.js → erDiagram-Q2GNP2WA-BU-m41EQ.js} +10 -10
- package/dist/{error-banner-CVkfBUT3.js → error-banner-5bz0L9hS.js} +3 -3
- package/dist/{esm-CWp0KQeK.js → esm-BfhQmZjp.js} +4 -4
- package/dist/{esm-DjNnlmpf.js → esm-Duie8iU-.js} +23 -23
- package/dist/{extends-vAi97cpa.js → extends-BgdxCfYu.js} +6 -6
- package/dist/{flatten-CzBvFdvC.js → flatten-Bbw7g6-K.js} +1 -1
- package/dist/{flowDiagram-NV44I4VS-DQmWlo7f.js → flowDiagram-NV44I4VS-CRoXKjGq.js} +10 -10
- package/dist/{formats-Dsy9kkZu.js → formats-DQ5qjo_Q.js} +4 -4
- package/dist/{ganttDiagram-JELNMOA3-BOGXJ8Lk.js → ganttDiagram-JELNMOA3-7mq5f9cO.js} +7 -7
- package/dist/{gitGraph-G5XIXVHT-DGlbae5m.js → gitGraph-G5XIXVHT-DiniR35k.js} +3 -3
- package/dist/{gitGraphDiagram-V2S2FVAM-DjzxfF0P.js → gitGraphDiagram-V2S2FVAM-Dfuokq6w.js} +13 -13
- package/dist/{glide-data-editor-DucgdjRo.js → glide-data-editor-DqRY9naW.js} +557 -557
- package/dist/{graphlib-CVPKjKCS.js → graphlib-Ns7y5crs.js} +5 -5
- package/dist/{hasIn-COs6vImh.js → hasIn-Deg7jl_j.js} +3 -3
- package/dist/{html-to-image-CpggM7u1.js → html-to-image-CiSinpSR.js} +109 -109
- package/dist/{info-VBDWY6EO-D2lvLLw5.js → info-VBDWY6EO-DVZvGhkQ.js} +3 -3
- package/dist/{infoDiagram-HS3SLOUP-ChNufFsP.js → infoDiagram-HS3SLOUP-CEnzWruK.js} +13 -13
- package/dist/{input-D4kjoQUB.js → input-CZD2z6X2.js} +70 -67
- package/dist/{isEmpty-Dd8mx_WL.js → isEmpty-CJJMn-QP.js} +1 -1
- package/dist/{isSymbol-BvIfMnn6.js → isSymbol-CoUCgMCM.js} +1 -1
- package/dist/{journeyDiagram-XKPGCS4Q-BO_O4Ij1.js → journeyDiagram-XKPGCS4Q-8XYSU1GI.js} +3 -3
- package/dist/{kanban-definition-3W4ZIXB7-CPpiiiWk.js → kanban-definition-3W4ZIXB7--9pT9z1R.js} +7 -7
- package/dist/{label-BLqV33b1.js → label-LWtdw5i8.js} +3 -3
- package/dist/{linear-2NnK4cxi.js → linear-B5-AFRiR.js} +2 -2
- package/dist/{loader-Dr8Qem8p.js → loader-BWLPpjKK.js} +2 -2
- package/dist/main.js +1141 -987
- package/dist/{memoize-C9ltv0Cw.js → memoize-BOtf2yFf.js} +1 -1
- package/dist/{merge-CHn7Yx0N.js → merge-Be1CqGnU.js} +1 -1
- package/dist/mermaid-4DMBBIKO-DIdL224_.js +6 -0
- package/dist/{mermaid-DO-Daq7u.js → mermaid-IU93XzmY.js} +44 -44
- package/dist/{mermaid-parser.core-DreccfmS.js → mermaid-parser.core-C3XRsazI.js} +8 -8
- package/dist/{min-BNz2lZfk.js → min-Dtgc8txR.js} +4 -4
- package/dist/{mindmap-definition-VGOIOE7T-CC1_Vl0f.js → mindmap-definition-VGOIOE7T-B-4mnfFG.js} +9 -9
- package/dist/{now-Sgq5m3D-.js → now-Ch98bJO_.js} +2 -2
- package/dist/{number-overlay-editor-CpKi64Fy.js → number-overlay-editor-D-a0qCT8.js} +1 -1
- package/dist/{once-rJImu7SE.js → once-DPuqGUeo.js} +1 -1
- package/dist/{packet-DYOGHKS2-CmWtF3uO.js → packet-DYOGHKS2-34raHOiB.js} +3 -3
- package/dist/{pick-CRAXxDYn.js → pick-D1Qo8s2C.js} +4 -4
- package/dist/{pie-VRWISCQL-B6u8vus8.js → pie-VRWISCQL-BaLlzZa3.js} +3 -3
- package/dist/{pieDiagram-ADFJNKIX-Di34MOFQ.js → pieDiagram-ADFJNKIX-Cr3cNpZY.js} +15 -15
- package/dist/{precisionRound-CnHPY_5v.js → precisionRound-Tqb4mg-H.js} +1 -1
- package/dist/{process-output-X8TR20AK.js → process-output-5qJjMRKh.js} +4 -4
- package/dist/{quadrantDiagram-AYHSOK5B-B9kVk1ny.js → quadrantDiagram-AYHSOK5B-BuNL8Q93.js} +4 -4
- package/dist/{radar-ZZBFDIW7-XAmXSa8s.js → radar-ZZBFDIW7-Ci7bfoZa.js} +3 -3
- package/dist/{react-vega-Dh6-UKKe.js → react-vega-B0sAlDTL.js} +9 -9
- package/dist/react-vega-B6ncY2Tp.js +9 -0
- package/dist/{requirementDiagram-UZGBJVZJ-BxGfGYEx.js → requirementDiagram-UZGBJVZJ-BG2lLUN1.js} +9 -9
- package/dist/{reveal-component-Cj2fUG1Q.js → reveal-component-DZtPMEoM.js} +28 -28
- package/dist/{sankeyDiagram-TZEHDZUN-D09PBJ-n.js → sankeyDiagram-TZEHDZUN-DMal8sps.js} +3 -3
- package/dist/{sequenceDiagram-WL72ISMW-t_Dpemj0.js → sequenceDiagram-WL72ISMW-DT6Tk-Eo.js} +4 -4
- package/dist/{spec-hVaaZsY5.js → spec-a6DaqW__.js} +4 -4
- package/dist/{stateDiagram-FKZM4ZOC-B18gTP_j.js → stateDiagram-FKZM4ZOC-CB_lodq3.js} +12 -12
- package/dist/{stateDiagram-v2-4FDKWEC3-B6e_t14A.js → stateDiagram-v2-4FDKWEC3-E0RGjKsm.js} +10 -10
- package/dist/stex-KfRnSHzF.js +4 -0
- package/dist/{strings-BiIhGaI8.js → strings-Bu3vlb6W.js} +7 -7
- package/dist/style.css +1 -1
- package/dist/{swiper-component-DlD2GU2g.js → swiper-component-B2t5sN1q.js} +3 -3
- package/dist/{time-C1SGcFMH.js → time-CsmIF9YZ.js} +3 -3
- package/dist/{timeline-definition-IT6M3QCI-DJnh1ks5.js → timeline-definition-IT6M3QCI-NfSKRvH0.js} +2 -2
- package/dist/{toDate-CIpC_34u.js → toDate-ZVVIBmdk.js} +5 -5
- package/dist/{tooltip-DRaMBu06.js → tooltip-C5FYOpQc.js} +4 -4
- package/dist/{treemap-GDKQZRPO-Du95DV6u.js → treemap-GDKQZRPO-Cl6OQh8D.js} +3 -3
- package/dist/{types-Dzuoc3LN.js → types-CVvp1fKr.js} +2 -9
- package/dist/{useAsyncData-C56Khv_R.js → useAsyncData-C008zUPi.js} +2 -2
- package/dist/{useDateFormatter-B_9k85Ex.js → useDateFormatter-BA4FCquG.js} +2 -2
- package/dist/{useDeepCompareMemoize-Dt98v2ua.js → useDeepCompareMemoize-BrA3_n61.js} +1 -1
- package/dist/{useIframeCapabilities-BkYHTrss.js → useIframeCapabilities-C4JTXTIh.js} +1 -1
- package/dist/{useLifecycle-BF6-z62y.js → useLifecycle-BNaoJ5a4.js} +4 -4
- package/dist/{useTheme-DykuNHR2.js → useTheme-7O0YWlE5.js} +3 -3
- package/dist/{vega-component-cSdqoAxe.js → vega-component-DJNmOdUj.js} +18 -18
- package/dist/{vega-loader.browser-3_z8GoFC.js → vega-loader.browser-CZ-J8Py3.js} +3 -3
- package/dist/{xychartDiagram-PRI3JC2R-Dk2d_bX0.js → xychartDiagram-PRI3JC2R-BvwftqMA.js} +9 -9
- package/dist/{zod-BWkcDORu.js → zod-CoBiJ5v4.js} +3 -3
- package/package.json +1 -1
- package/src/components/data-table/__tests__/column-header.test.tsx +110 -277
- package/src/components/data-table/__tests__/date-filter-inputs.test.tsx +33 -0
- package/src/components/data-table/__tests__/filter-pill-editor.test.tsx +75 -38
- package/src/components/data-table/__tests__/filter-pills.test.tsx +287 -0
- package/src/components/data-table/__tests__/filter-test-utils.ts +47 -0
- package/src/components/data-table/__tests__/filters.test.ts +5 -5
- package/src/components/data-table/add-filter-button.tsx +85 -0
- package/src/components/data-table/column-header.tsx +92 -691
- package/src/components/data-table/context-menu.tsx +26 -12
- package/src/components/data-table/data-table.tsx +89 -57
- package/src/components/data-table/date-filter-inputs.tsx +13 -10
- package/src/components/data-table/filter-by-values-picker.tsx +13 -19
- package/src/components/data-table/filter-editor-context.tsx +34 -0
- package/src/components/data-table/filter-pill-editor.tsx +152 -175
- package/src/components/data-table/filter-pills.tsx +190 -153
- package/src/components/data-table/filters/builders.ts +102 -0
- package/src/components/data-table/filters/defaults.ts +31 -0
- package/src/components/data-table/filters/format.ts +131 -0
- package/src/components/data-table/filters/guards.ts +51 -0
- package/src/components/data-table/filters/index.ts +7 -0
- package/src/components/data-table/filters/operators.ts +76 -0
- package/src/components/data-table/filters/serialize.ts +186 -0
- package/src/components/data-table/filters/types.ts +33 -0
- package/src/components/data-table/header-items.tsx +6 -83
- package/src/components/data-table/value-chips.tsx +52 -0
- package/src/components/dependency-graph/minimap-content.tsx +2 -2
- package/src/components/ui/number-field.tsx +13 -1
- package/src/utils/dates.ts +39 -0
- package/dist/ErrorBoundary-D3wrPNma.js +0 -167
- package/dist/architecture-7HQA4BMR-CS9jOrqM.js +0 -6
- package/dist/dist-21ButRCu.js +0 -8
- package/dist/dist-B--tLnAP.js +0 -5
- package/dist/dist-BoHGySTM.js +0 -5
- package/dist/dist-ByAz19Qc.js +0 -5
- package/dist/dist-C1Ap5CYU.js +0 -5
- package/dist/dist-C93EysN4.js +0 -5
- package/dist/dist-CY-lVor6.js +0 -8
- package/dist/dist-CYDuv4bR.js +0 -8
- package/dist/dist-Cfo5EE2t.js +0 -6
- package/dist/dist-CjivSDvN.js +0 -5
- package/dist/dist-Cqwx-MH7.js +0 -5
- package/dist/dist-DbpcoFAV.js +0 -6
- package/dist/dist-FUNenbiQ.js +0 -5
- package/dist/dist-zhSud5X3.js +0 -8
- package/dist/mermaid-4DMBBIKO-B7VQMwJx.js +0 -6
- package/dist/react-vega-Cavbrg4l.js +0 -9
- package/dist/stex-ChDHQs3R.js +0 -4
- package/src/components/data-table/__tests__/column-header.test.ts +0 -65
- package/src/components/data-table/filters.ts +0 -386
- /package/dist/{_baseFor-BGiY-cm1.js → _baseFor-4jw-lnCC.js} +0 -0
- /package/dist/{clsx-CyyyQ8Ue.js → clsx-CIWA5tNO.js} +0 -0
- /package/dist/{defaultLocale-DoeErsX2.js → defaultLocale-BoHTsDG6.js} +0 -0
- /package/dist/{defaultLocale-BpsHxBd7.js → defaultLocale-u-3osm0P.js} +0 -0
- /package/dist/{dist-CCADb07R.js → dist-DNdhYsgW.js} +0 -0
- /package/dist/{emotion-is-prop-valid.esm-DtW2o230.js → emotion-is-prop-valid.esm-DzSb5hsH.js} +0 -0
- /package/dist/{invariant-UcGKQEhF.js → invariant-wRzNXIsJ.js} +0 -0
- /package/dist/{jsx-runtime-COBk7ree.js → jsx-runtime-DebpN0FN.js} +0 -0
- /package/dist/{main-CThhXnXU.js → main-Tj_-QTyF.js} +0 -0
- /package/dist/{micromark-factory-space-CwHmg6iz.js → micromark-factory-space-DF2w36zS.js} +0 -0
- /package/dist/{ordinal-B43ZeR68.js → ordinal-ArJavP1Q.js} +0 -0
- /package/dist/{purify.es-DT70lfR0.js → purify.es-H92eMd9-.js} +0 -0
- /package/dist/{range-BOiA8qqU.js → range-C-rmrM1O.js} +0 -0
- /package/dist/{react-dom-BWRJ_g_k.js → react-dom-BTJzcVJ9.js} +0 -0
- /package/dist/{stex-DrxP7bb3.js → stex-BIsgBmK4.js} +0 -0
|
@@ -2,62 +2,154 @@
|
|
|
2
2
|
"use no memo";
|
|
3
3
|
|
|
4
4
|
import type { ColumnFiltersState, Table } from "@tanstack/react-table";
|
|
5
|
-
import { XIcon } from "lucide-react";
|
|
6
|
-
import { useState } from "react";
|
|
7
|
-
import {
|
|
5
|
+
import { MoreHorizontalIcon, XIcon } from "lucide-react";
|
|
6
|
+
import { useLayoutEffect, useRef, useState } from "react";
|
|
7
|
+
import { useLocale } from "react-aria";
|
|
8
8
|
import type { CalculateTopKRows } from "@/plugins/impl/DataTablePlugin";
|
|
9
|
-
import { logNever } from "@/utils/assertNever";
|
|
10
9
|
import { cn } from "@/utils/cn";
|
|
11
10
|
import { Badge } from "../ui/badge";
|
|
12
11
|
import { Button } from "../ui/button";
|
|
13
|
-
import {
|
|
14
|
-
import { FilterPillEditor } from "./filter-pill-editor";
|
|
12
|
+
import { DraggablePopover } from "../ui/draggable-popover";
|
|
15
13
|
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
import {
|
|
14
|
+
Popover,
|
|
15
|
+
PopoverClose,
|
|
16
|
+
PopoverContent,
|
|
17
|
+
PopoverTrigger,
|
|
18
|
+
} from "../ui/popover";
|
|
19
|
+
import { Tooltip } from "../ui/tooltip";
|
|
20
|
+
import { AddFilterButton } from "./add-filter-button";
|
|
21
|
+
import { FilterPillEditor } from "./filter-pill-editor";
|
|
22
|
+
import { type ColumnFilterValue, formatValue, type Snapshot } from "./filters";
|
|
23
|
+
import { extractTimezone } from "./types";
|
|
24
|
+
import { ChipWithComma, CompactChipRow } from "./value-chips";
|
|
22
25
|
|
|
23
26
|
interface Props<TData> {
|
|
24
27
|
filters: ColumnFiltersState | undefined;
|
|
25
28
|
table: Table<TData>;
|
|
26
29
|
calculateTopKRows?: CalculateTopKRows;
|
|
30
|
+
addFilterSnapshot: Snapshot | null;
|
|
31
|
+
onAddFilterSnapshotChange: (snapshot: Snapshot | null) => void;
|
|
27
32
|
}
|
|
28
33
|
|
|
34
|
+
const useHasOverflow = (
|
|
35
|
+
ref: React.RefObject<HTMLElement | null>,
|
|
36
|
+
signature: string,
|
|
37
|
+
): boolean => {
|
|
38
|
+
const [hasOverflow, setHasOverflow] = useState(false);
|
|
39
|
+
useLayoutEffect(() => {
|
|
40
|
+
const el = ref.current;
|
|
41
|
+
if (!el) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const measure = () => setHasOverflow(el.scrollWidth > el.clientWidth);
|
|
45
|
+
measure();
|
|
46
|
+
const ro = new ResizeObserver(measure);
|
|
47
|
+
ro.observe(el);
|
|
48
|
+
return () => ro.disconnect();
|
|
49
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: signature triggers re-measure on filter content change
|
|
50
|
+
}, [ref, signature]);
|
|
51
|
+
return hasOverflow;
|
|
52
|
+
};
|
|
53
|
+
|
|
29
54
|
export const FilterPills = <TData,>({
|
|
30
55
|
filters,
|
|
31
56
|
table,
|
|
32
57
|
calculateTopKRows,
|
|
58
|
+
addFilterSnapshot,
|
|
59
|
+
onAddFilterSnapshotChange,
|
|
33
60
|
}: Props<TData>) => {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
61
|
+
const { locale } = useLocale();
|
|
62
|
+
|
|
63
|
+
const containerRef = useRef<HTMLDivElement | null>(null);
|
|
64
|
+
const [overflowOpen, setOverflowOpen] = useState(false);
|
|
65
|
+
const allFilters = filters ?? [];
|
|
66
|
+
const signature = allFilters
|
|
67
|
+
.map((f) => `${f.id}:${JSON.stringify(f.value)}`)
|
|
68
|
+
.join("|");
|
|
69
|
+
const hasOverflow = useHasOverflow(containerRef, signature);
|
|
39
70
|
|
|
40
|
-
if (
|
|
71
|
+
if (allFilters.length === 0 && addFilterSnapshot === null) {
|
|
41
72
|
return null;
|
|
42
73
|
}
|
|
43
74
|
|
|
75
|
+
const renderPill = (filter: ColumnFiltersState[number], index: number) => (
|
|
76
|
+
<FilterPill
|
|
77
|
+
key={`${filter.id}:${index}`}
|
|
78
|
+
columnId={filter.id}
|
|
79
|
+
value={filter.value as ColumnFilterValue}
|
|
80
|
+
index={index}
|
|
81
|
+
locale={locale}
|
|
82
|
+
table={table}
|
|
83
|
+
calculateTopKRows={calculateTopKRows}
|
|
84
|
+
onRemove={() =>
|
|
85
|
+
table.setColumnFilters((current) =>
|
|
86
|
+
current.filter((_, i) => i !== index),
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
|
|
44
92
|
return (
|
|
45
|
-
<div
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
93
|
+
<div
|
|
94
|
+
part="filter-pills"
|
|
95
|
+
className="relative flex items-center gap-2 px-1 py-2"
|
|
96
|
+
>
|
|
97
|
+
<AddFilterButton
|
|
98
|
+
table={table}
|
|
99
|
+
calculateTopKRows={calculateTopKRows}
|
|
100
|
+
snapshot={addFilterSnapshot}
|
|
101
|
+
onSnapshotChange={onAddFilterSnapshotChange}
|
|
102
|
+
/>
|
|
103
|
+
<div
|
|
104
|
+
ref={containerRef}
|
|
105
|
+
className={cn(
|
|
106
|
+
"flex flex-nowrap items-center gap-2 overflow-hidden min-w-0 flex-1",
|
|
107
|
+
hasOverflow &&
|
|
108
|
+
"mask-[linear-gradient(to_right,black_calc(100%-2rem),transparent)]",
|
|
109
|
+
)}
|
|
110
|
+
>
|
|
111
|
+
{allFilters.map((filter, index) => renderPill(filter, index))}
|
|
112
|
+
</div>
|
|
113
|
+
{hasOverflow && (
|
|
114
|
+
<button
|
|
115
|
+
type="button"
|
|
116
|
+
onClick={() => setOverflowOpen(true)}
|
|
117
|
+
className="shrink-0 inline-flex items-center gap-0.5 rounded-full border border-border bg-background px-2 py-0.5 text-xs text-foreground hover:bg-accent hover:text-accent-foreground"
|
|
118
|
+
aria-label="See all filters"
|
|
119
|
+
>
|
|
120
|
+
<MoreHorizontalIcon className="h-3.5 w-3.5" aria-hidden={true} />
|
|
121
|
+
<span>See all</span>
|
|
122
|
+
</button>
|
|
123
|
+
)}
|
|
124
|
+
{hasOverflow && (
|
|
125
|
+
<DraggablePopover
|
|
126
|
+
open={overflowOpen}
|
|
127
|
+
onOpenChange={setOverflowOpen}
|
|
128
|
+
className="w-fit max-w-[min(90vw,40rem)] p-0"
|
|
129
|
+
>
|
|
130
|
+
<PopoverClose className="absolute top-2 right-2" aria-label="Close">
|
|
131
|
+
<XIcon className="h-4 w-4" aria-hidden={true} />
|
|
132
|
+
</PopoverClose>
|
|
133
|
+
<div className="flex flex-col pt-7">
|
|
134
|
+
<div className="max-h-80 overflow-y-auto flex flex-col items-start gap-2 px-3 pb-2">
|
|
135
|
+
{allFilters.map((filter, index) => renderPill(filter, index))}
|
|
136
|
+
</div>
|
|
137
|
+
<div className="flex justify-end border-t border-border px-3 py-2">
|
|
138
|
+
<Button
|
|
139
|
+
type="button"
|
|
140
|
+
size="sm"
|
|
141
|
+
variant="ghost"
|
|
142
|
+
onClick={() => {
|
|
143
|
+
table.setColumnFilters([]);
|
|
144
|
+
setOverflowOpen(false);
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
Clear all
|
|
148
|
+
</Button>
|
|
149
|
+
</div>
|
|
150
|
+
</div>
|
|
151
|
+
</DraggablePopover>
|
|
152
|
+
)}
|
|
61
153
|
</div>
|
|
62
154
|
);
|
|
63
155
|
};
|
|
@@ -65,7 +157,8 @@ export const FilterPills = <TData,>({
|
|
|
65
157
|
interface FilterPillProps<TData> {
|
|
66
158
|
columnId: string;
|
|
67
159
|
value: ColumnFilterValue;
|
|
68
|
-
|
|
160
|
+
index: number;
|
|
161
|
+
locale: string;
|
|
69
162
|
table: Table<TData>;
|
|
70
163
|
calculateTopKRows?: CalculateTopKRows;
|
|
71
164
|
onRemove: () => void;
|
|
@@ -74,28 +167,63 @@ interface FilterPillProps<TData> {
|
|
|
74
167
|
const FilterPill = <TData,>({
|
|
75
168
|
columnId,
|
|
76
169
|
value,
|
|
77
|
-
|
|
170
|
+
index,
|
|
171
|
+
locale,
|
|
78
172
|
table,
|
|
79
173
|
calculateTopKRows,
|
|
80
174
|
onRemove,
|
|
81
175
|
}: FilterPillProps<TData>) => {
|
|
82
176
|
const [open, setOpen] = useState(false);
|
|
83
177
|
|
|
84
|
-
const
|
|
178
|
+
const timezone = extractTimezone(
|
|
179
|
+
table.getColumn(columnId)?.columnDef.meta?.dtype,
|
|
180
|
+
);
|
|
181
|
+
const formatted = formatValue(value, { locale, timezone });
|
|
85
182
|
if (!formatted) {
|
|
86
183
|
return null;
|
|
87
184
|
}
|
|
88
185
|
|
|
89
|
-
const twoSegment =
|
|
186
|
+
const twoSegment =
|
|
187
|
+
formatted.kind === "scalar" && formatted.value === undefined;
|
|
90
188
|
|
|
91
189
|
const handleRemove = (e: React.MouseEvent) => {
|
|
92
190
|
e.stopPropagation();
|
|
93
191
|
onRemove();
|
|
94
192
|
};
|
|
95
193
|
|
|
96
|
-
const
|
|
194
|
+
const renderValue = (truncateValue: boolean) => {
|
|
195
|
+
if (formatted.kind === "scalar") {
|
|
196
|
+
return (
|
|
197
|
+
<span
|
|
198
|
+
className={cn(
|
|
199
|
+
"font-semibold text-foreground",
|
|
200
|
+
truncateValue &&
|
|
201
|
+
"inline-block max-w-[24ch] overflow-hidden text-ellipsis whitespace-nowrap align-middle",
|
|
202
|
+
)}
|
|
203
|
+
>
|
|
204
|
+
{formatted.value}
|
|
205
|
+
</span>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
if (truncateValue) {
|
|
209
|
+
return <CompactChipRow items={formatted.items} max={3} />;
|
|
210
|
+
}
|
|
211
|
+
return (
|
|
212
|
+
<span className="grid grid-cols-[repeat(5,max-content)] gap-1">
|
|
213
|
+
{formatted.items.map((item, i) => (
|
|
214
|
+
<ChipWithComma
|
|
215
|
+
key={i}
|
|
216
|
+
value={item}
|
|
217
|
+
showComma={i < formatted.items.length - 1}
|
|
218
|
+
/>
|
|
219
|
+
))}
|
|
220
|
+
</span>
|
|
221
|
+
);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
const renderSegments = (truncateValue: boolean) => (
|
|
97
225
|
<>
|
|
98
|
-
<span className="text-foreground">{columnId}</span>
|
|
226
|
+
<span className="font-semibold text-foreground">{columnId}</span>
|
|
99
227
|
<Separator />
|
|
100
228
|
<span
|
|
101
229
|
className={cn(
|
|
@@ -108,12 +236,17 @@ const FilterPill = <TData,>({
|
|
|
108
236
|
{!twoSegment && (
|
|
109
237
|
<>
|
|
110
238
|
<Separator />
|
|
111
|
-
|
|
239
|
+
{renderValue(truncateValue)}
|
|
112
240
|
</>
|
|
113
241
|
)}
|
|
114
242
|
</>
|
|
115
243
|
);
|
|
116
244
|
|
|
245
|
+
const tooltip = (
|
|
246
|
+
<span className="inline-flex items-center">{renderSegments(false)}</span>
|
|
247
|
+
);
|
|
248
|
+
const segments = renderSegments(true);
|
|
249
|
+
|
|
117
250
|
const removeButton = (
|
|
118
251
|
<Button
|
|
119
252
|
type="button"
|
|
@@ -138,16 +271,20 @@ const FilterPill = <TData,>({
|
|
|
138
271
|
"transition-colors",
|
|
139
272
|
)}
|
|
140
273
|
>
|
|
141
|
-
<
|
|
142
|
-
<
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
274
|
+
<Tooltip content={tooltip} delayDuration={600}>
|
|
275
|
+
<span className="inline-flex items-center">
|
|
276
|
+
<PopoverTrigger asChild={true}>
|
|
277
|
+
<button
|
|
278
|
+
type="button"
|
|
279
|
+
className="inline-flex items-center whitespace-nowrap cursor-pointer bg-transparent border-0 p-0 [font:inherit] text-inherit"
|
|
280
|
+
aria-label={`Edit filter on ${columnId}`}
|
|
281
|
+
>
|
|
282
|
+
{segments}
|
|
283
|
+
</button>
|
|
284
|
+
</PopoverTrigger>
|
|
285
|
+
{removeButton}
|
|
286
|
+
</span>
|
|
287
|
+
</Tooltip>
|
|
151
288
|
</Badge>
|
|
152
289
|
<PopoverContent
|
|
153
290
|
className="w-auto p-0"
|
|
@@ -156,9 +293,11 @@ const FilterPill = <TData,>({
|
|
|
156
293
|
sideOffset={10}
|
|
157
294
|
avoidCollisions={true}
|
|
158
295
|
onOpenAutoFocus={(e) => e.preventDefault()}
|
|
296
|
+
onCloseAutoFocus={(e) => e.preventDefault()}
|
|
159
297
|
>
|
|
160
298
|
<FilterPillEditor
|
|
161
299
|
snapshot={{ columnId, value }}
|
|
300
|
+
editIndex={index}
|
|
162
301
|
table={table}
|
|
163
302
|
calculateTopKRows={calculateTopKRows}
|
|
164
303
|
onClose={() => setOpen(false)}
|
|
@@ -173,105 +312,3 @@ function Separator() {
|
|
|
173
312
|
<span aria-hidden={true} className="mx-1.5 w-px h-3 bg-foreground/30" />
|
|
174
313
|
);
|
|
175
314
|
}
|
|
176
|
-
|
|
177
|
-
interface FormattedFilter {
|
|
178
|
-
operator: string;
|
|
179
|
-
value?: string;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function formatValue(
|
|
183
|
-
value: ColumnFilterValue,
|
|
184
|
-
timeFormatter: DateFormatter,
|
|
185
|
-
): FormattedFilter | undefined {
|
|
186
|
-
if (!("type" in value)) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (value.operator === "is_null") {
|
|
191
|
-
return { operator: "is null" };
|
|
192
|
-
}
|
|
193
|
-
if (value.operator === "is_not_null") {
|
|
194
|
-
return { operator: "is not null" };
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
if (value.type === "number") {
|
|
198
|
-
switch (value.operator) {
|
|
199
|
-
case "between":
|
|
200
|
-
return {
|
|
201
|
-
operator: OPERATOR_LABELS.between.toLowerCase(),
|
|
202
|
-
value: `${value.min} - ${value.max}`,
|
|
203
|
-
};
|
|
204
|
-
case "==":
|
|
205
|
-
case "!=":
|
|
206
|
-
case ">":
|
|
207
|
-
case ">=":
|
|
208
|
-
case "<":
|
|
209
|
-
case "<=":
|
|
210
|
-
return { operator: value.operator, value: String(value.value) };
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
if (value.type === "text") {
|
|
214
|
-
switch (value.operator) {
|
|
215
|
-
case "in":
|
|
216
|
-
case "not_in": {
|
|
217
|
-
const items = value.values.map((v) => `"${v}"`);
|
|
218
|
-
return {
|
|
219
|
-
operator: value.operator === "in" ? "is in" : "not in",
|
|
220
|
-
value: `[${items.join(", ")}]`,
|
|
221
|
-
};
|
|
222
|
-
}
|
|
223
|
-
case "is_empty":
|
|
224
|
-
return { operator: "is empty" };
|
|
225
|
-
case "contains":
|
|
226
|
-
case "equals":
|
|
227
|
-
case "does_not_equal":
|
|
228
|
-
case "regex":
|
|
229
|
-
case "starts_with":
|
|
230
|
-
case "ends_with":
|
|
231
|
-
return {
|
|
232
|
-
operator: OPERATOR_LABELS[value.operator].toLowerCase(),
|
|
233
|
-
value: `"${value.text}"`,
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (
|
|
238
|
-
value.type === "date" ||
|
|
239
|
-
value.type === "datetime" ||
|
|
240
|
-
value.type === "time"
|
|
241
|
-
) {
|
|
242
|
-
const format =
|
|
243
|
-
value.type === "time"
|
|
244
|
-
? (d: Date) => timeFormatter.format(d)
|
|
245
|
-
: value.type === "date"
|
|
246
|
-
? dateToISODate
|
|
247
|
-
: dateToISODateTime;
|
|
248
|
-
switch (value.operator) {
|
|
249
|
-
case "between":
|
|
250
|
-
return {
|
|
251
|
-
operator: OPERATOR_LABELS.between.toLowerCase(),
|
|
252
|
-
value: `${format(value.min)} - ${format(value.max)}`,
|
|
253
|
-
};
|
|
254
|
-
case "==":
|
|
255
|
-
case "!=":
|
|
256
|
-
case ">":
|
|
257
|
-
case ">=":
|
|
258
|
-
case "<":
|
|
259
|
-
case "<=":
|
|
260
|
-
return { operator: value.operator, value: format(value.value) };
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
if (value.type === "boolean") {
|
|
264
|
-
return { operator: `is ${value.value ? "True" : "False"}` };
|
|
265
|
-
}
|
|
266
|
-
if (value.type === "select") {
|
|
267
|
-
const stringifiedOptions = value.options.map((o) =>
|
|
268
|
-
stringifyUnknownValue({ value: o }),
|
|
269
|
-
);
|
|
270
|
-
return {
|
|
271
|
-
operator: value.operator === "in" ? "is in" : "not in",
|
|
272
|
-
value: `[${stringifiedOptions.join(", ")}]`,
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
logNever(value);
|
|
276
|
-
return undefined;
|
|
277
|
-
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
BooleanOp,
|
|
5
|
+
ComparisonOp,
|
|
6
|
+
MembershipOp,
|
|
7
|
+
NullishOp,
|
|
8
|
+
TextScalarOp,
|
|
9
|
+
} from "./operators";
|
|
10
|
+
import type { FilterType } from "./types";
|
|
11
|
+
|
|
12
|
+
interface NullishOpts {
|
|
13
|
+
operator: NullishOp;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface MembershipOpts {
|
|
17
|
+
operator: MembershipOp;
|
|
18
|
+
values: unknown[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface BetweenRangeOpts<T> {
|
|
22
|
+
operator: "between";
|
|
23
|
+
min: T;
|
|
24
|
+
max: T;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
type NumberFilterOpts =
|
|
28
|
+
| { operator: ComparisonOp; value: number }
|
|
29
|
+
| BetweenRangeOpts<number>
|
|
30
|
+
| MembershipOpts
|
|
31
|
+
| NullishOpts;
|
|
32
|
+
|
|
33
|
+
type TextFilterOpts =
|
|
34
|
+
| { operator: TextScalarOp; text: string }
|
|
35
|
+
| { operator: "is_empty" }
|
|
36
|
+
| MembershipOpts
|
|
37
|
+
| NullishOpts;
|
|
38
|
+
|
|
39
|
+
type DateLikeFilterOpts =
|
|
40
|
+
| { operator: ComparisonOp; value: Date }
|
|
41
|
+
| BetweenRangeOpts<Date>
|
|
42
|
+
| NullishOpts;
|
|
43
|
+
|
|
44
|
+
interface BooleanFilterOpts {
|
|
45
|
+
operator: BooleanOp;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Filter is a factory function that creates a filter object
|
|
49
|
+
export const Filter = {
|
|
50
|
+
number(opts: NumberFilterOpts) {
|
|
51
|
+
return {
|
|
52
|
+
type: "number",
|
|
53
|
+
...opts,
|
|
54
|
+
} as const;
|
|
55
|
+
},
|
|
56
|
+
text(opts: TextFilterOpts) {
|
|
57
|
+
return {
|
|
58
|
+
type: "text",
|
|
59
|
+
...opts,
|
|
60
|
+
} as const;
|
|
61
|
+
},
|
|
62
|
+
date(opts: DateLikeFilterOpts) {
|
|
63
|
+
return {
|
|
64
|
+
type: "date",
|
|
65
|
+
...opts,
|
|
66
|
+
} as const;
|
|
67
|
+
},
|
|
68
|
+
datetime(opts: DateLikeFilterOpts) {
|
|
69
|
+
return {
|
|
70
|
+
type: "datetime",
|
|
71
|
+
...opts,
|
|
72
|
+
} as const;
|
|
73
|
+
},
|
|
74
|
+
time(opts: DateLikeFilterOpts) {
|
|
75
|
+
return {
|
|
76
|
+
type: "time",
|
|
77
|
+
...opts,
|
|
78
|
+
} as const;
|
|
79
|
+
},
|
|
80
|
+
boolean(opts: BooleanFilterOpts) {
|
|
81
|
+
return {
|
|
82
|
+
type: "boolean",
|
|
83
|
+
...opts,
|
|
84
|
+
} as const;
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export type ColumnFilterValue = ReturnType<
|
|
89
|
+
(typeof Filter)[keyof typeof Filter]
|
|
90
|
+
>;
|
|
91
|
+
export type ColumnFilterForType<T extends FilterType> = T extends FilterType
|
|
92
|
+
? Extract<ColumnFilterValue, { type: T }>
|
|
93
|
+
: never;
|
|
94
|
+
export type MembershipFilterType = Extract<
|
|
95
|
+
ColumnFilterValue,
|
|
96
|
+
{ operator: "in" | "not_in" }
|
|
97
|
+
>["type"];
|
|
98
|
+
|
|
99
|
+
export interface Snapshot {
|
|
100
|
+
columnId: string;
|
|
101
|
+
value: ColumnFilterValue;
|
|
102
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
"use no memo";
|
|
3
|
+
|
|
4
|
+
import type { Column } from "@tanstack/react-table";
|
|
5
|
+
import type { OperatorType } from "@/plugins/impl/data-frames/utils/operators";
|
|
6
|
+
import type { ColumnFilterValue } from "./builders";
|
|
7
|
+
import { isMembershipFilterType, isMembershipOp } from "./guards";
|
|
8
|
+
import { EDITABLE_FILTER_TYPES, type FilterType } from "./types";
|
|
9
|
+
|
|
10
|
+
export function columnEditableType<TData, TValue>(
|
|
11
|
+
column: Column<TData, TValue>,
|
|
12
|
+
): FilterType {
|
|
13
|
+
const ft = column.columnDef.meta?.filterType;
|
|
14
|
+
if (!ft || !EDITABLE_FILTER_TYPES.has(ft)) {
|
|
15
|
+
throw new Error(
|
|
16
|
+
`Invalid or missing filterType for column ${column.id}: ${ft}`,
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
return ft;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Minimal ColumnFilterValue for a (type, operator) pair, seeding extra fields for shapes that require them. */
|
|
23
|
+
export function defaultFilterValueFor(
|
|
24
|
+
type: FilterType,
|
|
25
|
+
operator: OperatorType,
|
|
26
|
+
): ColumnFilterValue {
|
|
27
|
+
if (isMembershipFilterType(type) && isMembershipOp(operator)) {
|
|
28
|
+
return { type, operator, values: [] };
|
|
29
|
+
}
|
|
30
|
+
return { type, operator } as ColumnFilterValue;
|
|
31
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
|
|
3
|
+
import { logNever } from "@/utils/assertNever";
|
|
4
|
+
import {
|
|
5
|
+
dateToLocalISODate,
|
|
6
|
+
dateToLocalISOTime,
|
|
7
|
+
exactDateTime,
|
|
8
|
+
} from "@/utils/dates";
|
|
9
|
+
import { OPERATOR_LABELS } from "../operator-labels";
|
|
10
|
+
import { stringifyUnknownValue } from "../utils";
|
|
11
|
+
import type { ColumnFilterValue } from "./builders";
|
|
12
|
+
import type { FormattedFilter } from "./types";
|
|
13
|
+
|
|
14
|
+
interface FormatContext {
|
|
15
|
+
locale: string;
|
|
16
|
+
timezone: string | undefined;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function formatValue(
|
|
20
|
+
value: ColumnFilterValue,
|
|
21
|
+
ctx: FormatContext,
|
|
22
|
+
): FormattedFilter | undefined {
|
|
23
|
+
if (!("type" in value)) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (value.operator === "is_null") {
|
|
28
|
+
return { kind: "scalar", operator: "is null" };
|
|
29
|
+
}
|
|
30
|
+
if (value.operator === "is_not_null") {
|
|
31
|
+
return { kind: "scalar", operator: "is not null" };
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (value.type === "number") {
|
|
35
|
+
switch (value.operator) {
|
|
36
|
+
case "between":
|
|
37
|
+
return {
|
|
38
|
+
kind: "scalar",
|
|
39
|
+
operator: OPERATOR_LABELS.between.toLowerCase(),
|
|
40
|
+
value: `${value.min} - ${value.max}`,
|
|
41
|
+
};
|
|
42
|
+
case "==":
|
|
43
|
+
case "!=":
|
|
44
|
+
case ">":
|
|
45
|
+
case ">=":
|
|
46
|
+
case "<":
|
|
47
|
+
case "<=":
|
|
48
|
+
return {
|
|
49
|
+
kind: "scalar",
|
|
50
|
+
operator: value.operator,
|
|
51
|
+
value: String(value.value),
|
|
52
|
+
};
|
|
53
|
+
case "in":
|
|
54
|
+
case "not_in":
|
|
55
|
+
return {
|
|
56
|
+
kind: "list",
|
|
57
|
+
operator: value.operator === "in" ? "is in" : "not in",
|
|
58
|
+
items: value.values
|
|
59
|
+
.map((v) => stringifyUnknownValue({ value: v }))
|
|
60
|
+
.toSorted((a, b) => a.localeCompare(b)),
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (value.type === "text") {
|
|
65
|
+
switch (value.operator) {
|
|
66
|
+
case "in":
|
|
67
|
+
case "not_in":
|
|
68
|
+
return {
|
|
69
|
+
kind: "list",
|
|
70
|
+
operator: value.operator === "in" ? "is in" : "not in",
|
|
71
|
+
items: value.values
|
|
72
|
+
.map((v) => stringifyUnknownValue({ value: v }))
|
|
73
|
+
.toSorted((a, b) => a.localeCompare(b)),
|
|
74
|
+
};
|
|
75
|
+
case "is_empty":
|
|
76
|
+
return { kind: "scalar", operator: "is empty" };
|
|
77
|
+
case "contains":
|
|
78
|
+
case "equals":
|
|
79
|
+
case "does_not_equal":
|
|
80
|
+
case "regex":
|
|
81
|
+
case "starts_with":
|
|
82
|
+
case "ends_with":
|
|
83
|
+
return {
|
|
84
|
+
kind: "scalar",
|
|
85
|
+
operator: OPERATOR_LABELS[value.operator].toLowerCase(),
|
|
86
|
+
value: `"${value.text}"`,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (
|
|
91
|
+
value.type === "date" ||
|
|
92
|
+
value.type === "datetime" ||
|
|
93
|
+
value.type === "time"
|
|
94
|
+
) {
|
|
95
|
+
const format =
|
|
96
|
+
value.type === "date"
|
|
97
|
+
? dateToLocalISODate
|
|
98
|
+
: value.type === "time"
|
|
99
|
+
? dateToLocalISOTime
|
|
100
|
+
: (d: Date) => exactDateTime(d, ctx.timezone, ctx.locale);
|
|
101
|
+
switch (value.operator) {
|
|
102
|
+
case "between":
|
|
103
|
+
return {
|
|
104
|
+
kind: "scalar",
|
|
105
|
+
operator: OPERATOR_LABELS.between.toLowerCase(),
|
|
106
|
+
value: `${format(value.min)} - ${format(value.max)}`,
|
|
107
|
+
};
|
|
108
|
+
case "==":
|
|
109
|
+
case "!=":
|
|
110
|
+
case ">":
|
|
111
|
+
case ">=":
|
|
112
|
+
case "<":
|
|
113
|
+
case "<=":
|
|
114
|
+
return {
|
|
115
|
+
kind: "scalar",
|
|
116
|
+
operator: value.operator,
|
|
117
|
+
value: format(value.value),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
if (value.type === "boolean") {
|
|
122
|
+
switch (value.operator) {
|
|
123
|
+
case "is_true":
|
|
124
|
+
return { kind: "scalar", operator: "is True" };
|
|
125
|
+
case "is_false":
|
|
126
|
+
return { kind: "scalar", operator: "is False" };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
logNever(value);
|
|
130
|
+
return undefined;
|
|
131
|
+
}
|