@42-central/ui-react 0.19.2 → 0.20.0
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/biome/no-gray-scale-class.grit +27 -0
- package/dist/{chunk-HCYULRWT.js → chunk-2KN3MI7I.js} +38 -34
- package/dist/chunk-2KN3MI7I.js.map +1 -0
- package/dist/chunk-2LI3VPDP.js +39 -0
- package/dist/chunk-2LI3VPDP.js.map +1 -0
- package/dist/{chunk-2NNZHVKD.js → chunk-2OQP7UY4.js} +22 -18
- package/dist/chunk-2OQP7UY4.js.map +1 -0
- package/dist/{chunk-RKYXG6X7.js → chunk-2TM7UVM2.js} +16 -13
- package/dist/chunk-2TM7UVM2.js.map +1 -0
- package/dist/chunk-3REFDGOM.js +89 -0
- package/dist/chunk-3REFDGOM.js.map +1 -0
- package/dist/{chunk-TBTSEPGP.js → chunk-45DFYIK5.js} +9 -7
- package/dist/chunk-45DFYIK5.js.map +1 -0
- package/dist/{chunk-CYWMES5P.js → chunk-4BGU2UQB.js} +23 -11
- package/dist/chunk-4BGU2UQB.js.map +1 -0
- package/dist/chunk-4EU6FGGB.js +104 -0
- package/dist/chunk-4EU6FGGB.js.map +1 -0
- package/dist/{chunk-P3XMBETI.js → chunk-4G3N7UMJ.js} +4 -7
- package/dist/chunk-4G3N7UMJ.js.map +1 -0
- package/dist/chunk-4TCTMRR5.js +293 -0
- package/dist/chunk-4TCTMRR5.js.map +1 -0
- package/dist/chunk-5337N3FE.js +176 -0
- package/dist/chunk-5337N3FE.js.map +1 -0
- package/dist/{chunk-GCGX4FEF.js → chunk-6KER77RS.js} +27 -41
- package/dist/chunk-6KER77RS.js.map +1 -0
- package/dist/chunk-6N6J2DOE.js +27 -0
- package/dist/chunk-6N6J2DOE.js.map +1 -0
- package/dist/{chunk-A6MYJTJI.js → chunk-6OV6EJQ2.js} +6 -7
- package/dist/chunk-6OV6EJQ2.js.map +1 -0
- package/dist/chunk-7AWOMWCQ.js +345 -0
- package/dist/chunk-7AWOMWCQ.js.map +1 -0
- package/dist/{chunk-Z6RPMRFH.js → chunk-7R4CDHBK.js} +9 -8
- package/dist/chunk-7R4CDHBK.js.map +1 -0
- package/dist/chunk-7TDHT3QD.js +62 -0
- package/dist/chunk-7TDHT3QD.js.map +1 -0
- package/dist/chunk-AHM6SGEU.js +15 -0
- package/dist/chunk-AHM6SGEU.js.map +1 -0
- package/dist/chunk-AZ2VUAGX.js +3 -0
- package/dist/chunk-AZ2VUAGX.js.map +1 -0
- package/dist/chunk-BUFALAEK.js +337 -0
- package/dist/chunk-BUFALAEK.js.map +1 -0
- package/dist/chunk-CDHIF2NV.js +340 -0
- package/dist/chunk-CDHIF2NV.js.map +1 -0
- package/dist/chunk-CQ4M4BSF.js +12 -0
- package/dist/chunk-CQ4M4BSF.js.map +1 -0
- package/dist/chunk-DHM4IG2O.js +13 -0
- package/dist/chunk-DHM4IG2O.js.map +1 -0
- package/dist/chunk-DHTSVJ4G.js +948 -0
- package/dist/chunk-DHTSVJ4G.js.map +1 -0
- package/dist/{chunk-WSIVRDRB.js → chunk-DUPE2CRU.js} +3 -3
- package/dist/{chunk-WSIVRDRB.js.map → chunk-DUPE2CRU.js.map} +1 -1
- package/dist/chunk-EIBDLRAR.js +30 -0
- package/dist/chunk-EIBDLRAR.js.map +1 -0
- package/dist/chunk-FUNTJZX7.js +217 -0
- package/dist/chunk-FUNTJZX7.js.map +1 -0
- package/dist/{chunk-YWRBG23W.js → chunk-FXDLS23K.js} +6 -3
- package/dist/chunk-FXDLS23K.js.map +1 -0
- package/dist/chunk-FZNPJAGJ.js +62 -0
- package/dist/chunk-FZNPJAGJ.js.map +1 -0
- package/dist/{chunk-CHTN5AHI.js → chunk-GGT4GJD6.js} +3 -3
- package/dist/chunk-GGT4GJD6.js.map +1 -0
- package/dist/chunk-GIPQUKCN.js +44 -0
- package/dist/chunk-GIPQUKCN.js.map +1 -0
- package/dist/chunk-H26K66EU.js +316 -0
- package/dist/chunk-H26K66EU.js.map +1 -0
- package/dist/chunk-H7INUXZD.js +104 -0
- package/dist/chunk-H7INUXZD.js.map +1 -0
- package/dist/{chunk-AIQG7IIT.js → chunk-H7WOMZXO.js} +10 -5
- package/dist/chunk-H7WOMZXO.js.map +1 -0
- package/dist/{chunk-WJOHNCYY.js → chunk-HBFN5W7Q.js} +37 -90
- package/dist/chunk-HBFN5W7Q.js.map +1 -0
- package/dist/chunk-HBWV5EPU.js +31 -0
- package/dist/chunk-HBWV5EPU.js.map +1 -0
- package/dist/chunk-HC4XVBP2.js +118 -0
- package/dist/chunk-HC4XVBP2.js.map +1 -0
- package/dist/chunk-HDRC6ITF.js +93 -0
- package/dist/chunk-HDRC6ITF.js.map +1 -0
- package/dist/chunk-HDYORQZN.js +23 -0
- package/dist/chunk-HDYORQZN.js.map +1 -0
- package/dist/chunk-HEQ2H6VO.js +148 -0
- package/dist/chunk-HEQ2H6VO.js.map +1 -0
- package/dist/chunk-HVOEVB4E.js +80 -0
- package/dist/chunk-HVOEVB4E.js.map +1 -0
- package/dist/chunk-HX3LNK26.js +193 -0
- package/dist/chunk-HX3LNK26.js.map +1 -0
- package/dist/{chunk-CSCVTESP.js → chunk-IMP5VHEN.js} +4 -11
- package/dist/chunk-IMP5VHEN.js.map +1 -0
- package/dist/{chunk-57BTVRRB.js → chunk-IPYHTCFL.js} +3 -3
- package/dist/{chunk-57BTVRRB.js.map → chunk-IPYHTCFL.js.map} +1 -1
- package/dist/chunk-J2WSKRJW.js +3 -0
- package/dist/chunk-J2WSKRJW.js.map +1 -0
- package/dist/chunk-J43LSYQO.js +14 -0
- package/dist/chunk-J43LSYQO.js.map +1 -0
- package/dist/{chunk-Z43YWH4R.js → chunk-JL4QMM46.js} +47 -25
- package/dist/chunk-JL4QMM46.js.map +1 -0
- package/dist/chunk-JQJ23YQX.js +38 -0
- package/dist/chunk-JQJ23YQX.js.map +1 -0
- package/dist/{chunk-SVKU3GUN.js → chunk-JYK6JVR3.js} +13 -13
- package/dist/chunk-JYK6JVR3.js.map +1 -0
- package/dist/chunk-JYKP4RSG.js +304 -0
- package/dist/chunk-JYKP4RSG.js.map +1 -0
- package/dist/chunk-K6BHDFX3.js +120 -0
- package/dist/chunk-K6BHDFX3.js.map +1 -0
- package/dist/chunk-K6YASO4L.js +25 -0
- package/dist/chunk-K6YASO4L.js.map +1 -0
- package/dist/{chunk-64T6Z7BA.js → chunk-KOT4PWGE.js} +107 -95
- package/dist/chunk-KOT4PWGE.js.map +1 -0
- package/dist/{chunk-RIP5G47F.js → chunk-LJ3GHC4V.js} +13 -11
- package/dist/chunk-LJ3GHC4V.js.map +1 -0
- package/dist/{chunk-YW6Q6ERX.js → chunk-LSIX2PVU.js} +49 -56
- package/dist/chunk-LSIX2PVU.js.map +1 -0
- package/dist/chunk-LZWA7V62.js +140 -0
- package/dist/chunk-LZWA7V62.js.map +1 -0
- package/dist/chunk-MKJKCBRE.js +437 -0
- package/dist/chunk-MKJKCBRE.js.map +1 -0
- package/dist/{chunk-QIDAXFKK.js → chunk-NJ4RO3CT.js} +52 -18
- package/dist/chunk-NJ4RO3CT.js.map +1 -0
- package/dist/{chunk-PINENGML.js → chunk-P276SCCV.js} +15 -8
- package/dist/chunk-P276SCCV.js.map +1 -0
- package/dist/chunk-PAFS7TED.js +85 -0
- package/dist/chunk-PAFS7TED.js.map +1 -0
- package/dist/chunk-PD4FX34E.js +309 -0
- package/dist/chunk-PD4FX34E.js.map +1 -0
- package/dist/{chunk-BEL75C7N.js → chunk-PMUCGFY5.js} +6 -4
- package/dist/chunk-PMUCGFY5.js.map +1 -0
- package/dist/{chunk-4NNGTNPV.js → chunk-Q5ZO2O25.js} +48 -34
- package/dist/chunk-Q5ZO2O25.js.map +1 -0
- package/dist/{chunk-YKUCSV34.js → chunk-R52P43LZ.js} +7 -13
- package/dist/chunk-R52P43LZ.js.map +1 -0
- package/dist/{chunk-CZEKZ5HR.js → chunk-R57QP43T.js} +32 -11
- package/dist/chunk-R57QP43T.js.map +1 -0
- package/dist/{chunk-I4SQQIP5.js → chunk-R5LYFTHA.js} +2 -2
- package/dist/chunk-R5LYFTHA.js.map +1 -0
- package/dist/{chunk-FOMR74VE.js → chunk-RGLNH7A5.js} +6 -6
- package/dist/chunk-RGLNH7A5.js.map +1 -0
- package/dist/chunk-RNRD6ER5.js +32 -0
- package/dist/chunk-RNRD6ER5.js.map +1 -0
- package/dist/{chunk-VZBUQNLX.js → chunk-S4TRYMCU.js} +51 -40
- package/dist/chunk-S4TRYMCU.js.map +1 -0
- package/dist/chunk-SDVZFXQ2.js +21 -0
- package/dist/chunk-SDVZFXQ2.js.map +1 -0
- package/dist/{chunk-CTSO6V72.js → chunk-SE3CGQRO.js} +11 -5
- package/dist/chunk-SE3CGQRO.js.map +1 -0
- package/dist/chunk-TCFB23JT.js +354 -0
- package/dist/chunk-TCFB23JT.js.map +1 -0
- package/dist/{chunk-BTFBBNRW.js → chunk-THLMW5IU.js} +5 -5
- package/dist/{chunk-BTFBBNRW.js.map → chunk-THLMW5IU.js.map} +1 -1
- package/dist/{chunk-YQHOKMSV.js → chunk-U2PNMMDB.js} +60 -53
- package/dist/chunk-U2PNMMDB.js.map +1 -0
- package/dist/{chunk-IRXZHLUL.js → chunk-VALQ2XVA.js} +4 -4
- package/dist/chunk-VALQ2XVA.js.map +1 -0
- package/dist/{chunk-UJZIF2BA.js → chunk-VVM7JMZS.js} +40 -54
- package/dist/chunk-VVM7JMZS.js.map +1 -0
- package/dist/{chunk-OGJFDNIS.js → chunk-WFHY6NRQ.js} +85 -54
- package/dist/chunk-WFHY6NRQ.js.map +1 -0
- package/dist/chunk-WG3BCIU4.js +20 -0
- package/dist/chunk-WG3BCIU4.js.map +1 -0
- package/dist/{chunk-K5UWVH6P.js → chunk-WR444JRU.js} +35 -26
- package/dist/chunk-WR444JRU.js.map +1 -0
- package/dist/chunk-XFEPUGUZ.js +15 -0
- package/dist/chunk-XFEPUGUZ.js.map +1 -0
- package/dist/chunk-XXOR34T4.js +10 -0
- package/dist/chunk-XXOR34T4.js.map +1 -0
- package/dist/{chunk-VZH6TS7M.js → chunk-Z5WYYDG2.js} +7 -4
- package/dist/chunk-Z5WYYDG2.js.map +1 -0
- package/dist/{chunk-IG7FBZVM.js → chunk-ZFUTGBJC.js} +13 -12
- package/dist/chunk-ZFUTGBJC.js.map +1 -0
- package/dist/{chunk-LM6F6DLR.js → chunk-ZN3WYGIQ.js} +18 -9
- package/dist/chunk-ZN3WYGIQ.js.map +1 -0
- package/dist/{chunk-FAOBC4IS.js → chunk-ZWOZL4XX.js} +38 -28
- package/dist/chunk-ZWOZL4XX.js.map +1 -0
- package/dist/chunk-ZYX564HO.js +27 -0
- package/dist/chunk-ZYX564HO.js.map +1 -0
- package/dist/colors.css +16 -8
- package/dist/components/accordion/accordion.d.ts +13 -4
- package/dist/components/accordion/accordion.d.ts.map +1 -1
- package/dist/components/accordion/index.d.ts +1 -1
- package/dist/components/accordion/index.d.ts.map +1 -1
- package/dist/components/accordion/index.js +27 -15
- package/dist/components/accordion/index.js.map +1 -1
- package/dist/components/action-icon/action-icon.d.ts.map +1 -1
- package/dist/components/action-icon/index.js +5 -4
- package/dist/components/alert/alert.d.ts +20 -8
- package/dist/components/alert/alert.d.ts.map +1 -1
- package/dist/components/alert/index.d.ts +1 -1
- package/dist/components/alert/index.d.ts.map +1 -1
- package/dist/components/alert/index.js +22 -10
- package/dist/components/alert/index.js.map +1 -1
- package/dist/components/ambient-background/ambient-background.d.ts +13 -3
- package/dist/components/ambient-background/ambient-background.d.ts.map +1 -1
- package/dist/components/ambient-background/index.js +38 -27
- package/dist/components/ambient-background/index.js.map +1 -1
- package/dist/components/app-shell/app-shell.d.ts +68 -6
- package/dist/components/app-shell/app-shell.d.ts.map +1 -1
- package/dist/components/app-shell/index.d.ts +1 -1
- package/dist/components/app-shell/index.d.ts.map +1 -1
- package/dist/components/app-shell/index.js +46 -18
- package/dist/components/app-shell/index.js.map +1 -1
- package/dist/components/aspect-ratio/aspect-ratio.d.ts +39 -0
- package/dist/components/aspect-ratio/aspect-ratio.d.ts.map +1 -0
- package/dist/components/aspect-ratio/index.d.ts +2 -0
- package/dist/components/aspect-ratio/index.d.ts.map +1 -0
- package/dist/components/aspect-ratio/index.js +33 -0
- package/dist/components/aspect-ratio/index.js.map +1 -0
- package/dist/components/autocomplete/autocomplete.d.ts.map +1 -1
- package/dist/components/autocomplete/index.js +16 -19
- package/dist/components/autocomplete/index.js.map +1 -1
- package/dist/components/avatar/avatar.d.ts +14 -2
- package/dist/components/avatar/avatar.d.ts.map +1 -1
- package/dist/components/avatar/index.d.ts +1 -1
- package/dist/components/avatar/index.d.ts.map +1 -1
- package/dist/components/avatar/index.js +26 -13
- package/dist/components/avatar/index.js.map +1 -1
- package/dist/components/badge/badge.d.ts.map +1 -1
- package/dist/components/badge/index.js +6 -100
- package/dist/components/badge/index.js.map +1 -1
- package/dist/components/breadcrumb/breadcrumb.d.ts +21 -5
- package/dist/components/breadcrumb/breadcrumb.d.ts.map +1 -1
- package/dist/components/breadcrumb/index.d.ts +1 -1
- package/dist/components/breadcrumb/index.d.ts.map +1 -1
- package/dist/components/breadcrumb/index.js +30 -6
- package/dist/components/breadcrumb/index.js.map +1 -1
- package/dist/components/button/button.d.ts +37 -16
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/index.js +5 -4
- package/dist/components/button-multi-select/index.js +9 -7
- package/dist/components/button-multi-select/index.js.map +1 -1
- package/dist/components/button-select/button-select.d.ts.map +1 -1
- package/dist/components/button-select/index.js +9 -7
- package/dist/components/button-select/index.js.map +1 -1
- package/dist/components/calendar/calendar-body.d.ts +10 -1
- package/dist/components/calendar/calendar-body.d.ts.map +1 -1
- package/dist/components/calendar/calendar.d.ts +24 -7
- package/dist/components/calendar/calendar.d.ts.map +1 -1
- package/dist/components/calendar/index.d.ts +2 -1
- package/dist/components/calendar/index.d.ts.map +1 -1
- package/dist/components/calendar/index.js +10 -8
- package/dist/components/camera/camera-machine.d.ts +131 -0
- package/dist/components/camera/camera-machine.d.ts.map +1 -0
- package/dist/components/camera/camera.d.ts +230 -0
- package/dist/components/camera/camera.d.ts.map +1 -0
- package/dist/components/camera/fake-camera.d.ts +77 -0
- package/dist/components/camera/fake-camera.d.ts.map +1 -0
- package/dist/components/camera/index.d.ts +5 -0
- package/dist/components/camera/index.d.ts.map +1 -0
- package/dist/components/camera/index.js +38 -0
- package/dist/components/camera/index.js.map +1 -0
- package/dist/components/camera/platform.d.ts +21 -0
- package/dist/components/camera/platform.d.ts.map +1 -0
- package/dist/components/camera/use-camera.d.ts +98 -0
- package/dist/components/camera/use-camera.d.ts.map +1 -0
- package/dist/components/card/card.d.ts.map +1 -1
- package/dist/components/card/index.js +2 -1
- package/dist/components/carousel/carousel.d.ts +270 -0
- package/dist/components/carousel/carousel.d.ts.map +1 -0
- package/dist/components/carousel/index.d.ts +2 -0
- package/dist/components/carousel/index.d.ts.map +1 -0
- package/dist/components/carousel/index.js +666 -0
- package/dist/components/carousel/index.js.map +1 -0
- package/dist/components/chart/chart.d.ts +20 -2
- package/dist/components/chart/chart.d.ts.map +1 -1
- package/dist/components/chart/index.js +11 -1
- package/dist/components/chart/index.js.map +1 -1
- package/dist/components/chart/styles.css +12 -10
- package/dist/components/checkbox/checkbox.d.ts +8 -1
- package/dist/components/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/checkbox/index.d.ts +1 -1
- package/dist/components/checkbox/index.d.ts.map +1 -1
- package/dist/components/checkbox/index.js +7 -5
- package/dist/components/choice-card-group/choice-card-group.d.ts +1 -1
- package/dist/components/choice-card-group/choice-card-group.d.ts.map +1 -1
- package/dist/components/choice-card-group/index.js +50 -48
- package/dist/components/choice-card-group/index.js.map +1 -1
- package/dist/components/circular-progress/circular-progress.d.ts +9 -1
- package/dist/components/circular-progress/circular-progress.d.ts.map +1 -1
- package/dist/components/circular-progress/index.js +12 -1
- package/dist/components/circular-progress/index.js.map +1 -1
- package/dist/components/clipboard/clipboard.d.ts +17 -8
- package/dist/components/clipboard/clipboard.d.ts.map +1 -1
- package/dist/components/clipboard/copy.d.ts +19 -5
- package/dist/components/clipboard/copy.d.ts.map +1 -1
- package/dist/components/clipboard/index.d.ts +1 -1
- package/dist/components/clipboard/index.d.ts.map +1 -1
- package/dist/components/clipboard/index.js +60 -23
- package/dist/components/clipboard/index.js.map +1 -1
- package/dist/components/code/code.d.ts.map +1 -1
- package/dist/components/code/index.js +3 -2
- package/dist/components/code/index.js.map +1 -1
- package/dist/components/code-block/chrome.d.ts +10 -9
- package/dist/components/code-block/chrome.d.ts.map +1 -1
- package/dist/components/code-block/chrome.js +10 -8
- package/dist/components/code-block/code-block.d.ts +6 -11
- package/dist/components/code-block/code-block.d.ts.map +1 -1
- package/dist/components/code-block/index.d.ts +2 -2
- package/dist/components/code-block/index.d.ts.map +1 -1
- package/dist/components/code-block/index.js +11 -9
- package/dist/components/code-block/index.js.map +1 -1
- package/dist/components/code-block/static.d.ts +3 -5
- package/dist/components/code-block/static.d.ts.map +1 -1
- package/dist/components/code-block/static.js.map +1 -1
- package/dist/components/collapse/index.js +2 -2
- package/dist/components/combobox/combobox.d.ts +2 -2
- package/dist/components/combobox/combobox.d.ts.map +1 -1
- package/dist/components/combobox/index.js +10 -8
- package/dist/components/combobox-list/combobox-list.d.ts +10 -2
- package/dist/components/combobox-list/combobox-list.d.ts.map +1 -1
- package/dist/components/combobox-list/combobox-search-row.d.ts +31 -0
- package/dist/components/combobox-list/combobox-search-row.d.ts.map +1 -0
- package/dist/components/combobox-list/index.d.ts +1 -1
- package/dist/components/combobox-list/index.d.ts.map +1 -1
- package/dist/components/combobox-list/index.js +13 -10
- package/dist/components/compare/compare.d.ts +45 -0
- package/dist/components/compare/compare.d.ts.map +1 -0
- package/dist/components/compare/index.d.ts +2 -0
- package/dist/components/compare/index.d.ts.map +1 -0
- package/dist/components/compare/index.js +206 -0
- package/dist/components/compare/index.js.map +1 -0
- package/dist/components/container/container.d.ts +7 -1
- package/dist/components/container/container.d.ts.map +1 -1
- package/dist/components/container/index.js.map +1 -1
- package/dist/components/data-table/data-table-filter/data-table-date-filter.d.ts +13 -12
- package/dist/components/data-table/data-table-filter/data-table-date-filter.d.ts.map +1 -1
- package/dist/components/data-table/data-table-filter/data-table-number-filter.d.ts +4 -1
- package/dist/components/data-table/data-table-filter/data-table-number-filter.d.ts.map +1 -1
- package/dist/components/data-table/data-table-filter/index.d.ts +8 -4
- package/dist/components/data-table/data-table-filter/index.d.ts.map +1 -1
- package/dist/components/data-table/data-table-header-cell.d.ts +6 -9
- package/dist/components/data-table/data-table-header-cell.d.ts.map +1 -1
- package/dist/components/data-table/data-table-icons.d.ts +27 -0
- package/dist/components/data-table/data-table-icons.d.ts.map +1 -0
- package/dist/components/data-table/data-table-pagination.d.ts +18 -3
- package/dist/components/data-table/data-table-pagination.d.ts.map +1 -1
- package/dist/components/data-table/data-table-stack.d.ts +5 -2
- package/dist/components/data-table/data-table-stack.d.ts.map +1 -1
- package/dist/components/data-table/data-table-state.d.ts.map +1 -1
- package/dist/components/data-table/data-table-toolbar.d.ts +7 -2
- package/dist/components/data-table/data-table-toolbar.d.ts.map +1 -1
- package/dist/components/data-table/data-table-translations.d.ts +11 -2
- package/dist/components/data-table/data-table-translations.d.ts.map +1 -1
- package/dist/components/data-table/data-table.d.ts +12 -1
- package/dist/components/data-table/data-table.d.ts.map +1 -1
- package/dist/components/data-table/index.d.ts +1 -0
- package/dist/components/data-table/index.d.ts.map +1 -1
- package/dist/components/data-table/index.js +281 -198
- package/dist/components/data-table/index.js.map +1 -1
- package/dist/components/date-picker/aliases.d.ts +7 -0
- package/dist/components/date-picker/aliases.d.ts.map +1 -1
- package/dist/components/date-picker/date-picker.d.ts +15 -6
- package/dist/components/date-picker/date-picker.d.ts.map +1 -1
- package/dist/components/date-picker/date-time-text.d.ts +2 -2
- package/dist/components/date-picker/date-time-text.d.ts.map +1 -1
- package/dist/components/date-picker/index.d.ts +1 -1
- package/dist/components/date-picker/index.d.ts.map +1 -1
- package/dist/components/date-picker/index.js +23 -20
- package/dist/components/date-picker/index.js.map +1 -1
- package/dist/components/divider/divider.d.ts +12 -3
- package/dist/components/divider/divider.d.ts.map +1 -1
- package/dist/components/divider/index.js +2 -1
- package/dist/components/download-button/download-button.d.ts +69 -0
- package/dist/components/download-button/download-button.d.ts.map +1 -0
- package/dist/components/download-button/index.d.ts +2 -0
- package/dist/components/download-button/index.d.ts.map +1 -0
- package/dist/components/download-button/index.js +13 -0
- package/dist/components/download-button/index.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +79 -44
- package/dist/components/drawer/drawer.d.ts.map +1 -1
- package/dist/components/drawer/index.d.ts +1 -1
- package/dist/components/drawer/index.d.ts.map +1 -1
- package/dist/components/drawer/index.js +10 -6
- package/dist/components/field/field.d.ts +8 -0
- package/dist/components/field/field.d.ts.map +1 -1
- package/dist/components/field/index.js +2 -1
- package/dist/components/figure/figure.d.ts +27 -0
- package/dist/components/figure/figure.d.ts.map +1 -0
- package/dist/components/figure/index.d.ts +2 -0
- package/dist/components/figure/index.d.ts.map +1 -0
- package/dist/components/figure/index.js +7 -0
- package/dist/components/figure/index.js.map +1 -0
- package/dist/components/file-item/file-item.d.ts +178 -0
- package/dist/components/file-item/file-item.d.ts.map +1 -0
- package/dist/components/file-item/index.d.ts +2 -0
- package/dist/components/file-item/index.d.ts.map +1 -0
- package/dist/components/file-item/index.js +25 -0
- package/dist/components/file-item/index.js.map +1 -0
- package/dist/components/file-preview/file-preview.d.ts +189 -0
- package/dist/components/file-preview/file-preview.d.ts.map +1 -0
- package/dist/components/file-preview/index.d.ts +2 -0
- package/dist/components/file-preview/index.d.ts.map +1 -0
- package/dist/components/file-preview/index.js +572 -0
- package/dist/components/file-preview/index.js.map +1 -0
- package/dist/components/file-queue-summary/file-queue-summary.d.ts +35 -0
- package/dist/components/file-queue-summary/file-queue-summary.d.ts.map +1 -0
- package/dist/components/file-queue-summary/index.d.ts +3 -0
- package/dist/components/file-queue-summary/index.d.ts.map +1 -0
- package/dist/components/file-queue-summary/index.js +7 -0
- package/dist/components/file-queue-summary/index.js.map +1 -0
- package/dist/components/file-trigger/file-trigger.d.ts +40 -0
- package/dist/components/file-trigger/file-trigger.d.ts.map +1 -0
- package/dist/components/file-trigger/index.d.ts +2 -0
- package/dist/components/file-trigger/index.d.ts.map +1 -0
- package/dist/components/file-trigger/index.js +11 -0
- package/dist/components/file-trigger/index.js.map +1 -0
- package/dist/components/file-upload/file-upload.d.ts +102 -14
- package/dist/components/file-upload/file-upload.d.ts.map +1 -1
- package/dist/components/file-upload/index.d.ts +1 -1
- package/dist/components/file-upload/index.d.ts.map +1 -1
- package/dist/components/file-upload/index.js +205 -101
- package/dist/components/file-upload/index.js.map +1 -1
- package/dist/components/flex/flex.d.ts +14 -2
- package/dist/components/flex/flex.d.ts.map +1 -1
- package/dist/components/flex/index.js +2 -1
- package/dist/components/gallery/gallery.d.ts +77 -0
- package/dist/components/gallery/gallery.d.ts.map +1 -0
- package/dist/components/gallery/index.d.ts +3 -0
- package/dist/components/gallery/index.d.ts.map +1 -0
- package/dist/components/gallery/index.js +272 -0
- package/dist/components/gallery/index.js.map +1 -0
- package/dist/components/gallery/layout.d.ts +96 -0
- package/dist/components/gallery/layout.d.ts.map +1 -0
- package/dist/components/grid/grid.d.ts +7 -1
- package/dist/components/grid/grid.d.ts.map +1 -1
- package/dist/components/grid/index.js +2 -10
- package/dist/components/grid/index.js.map +1 -1
- package/dist/components/hover-card/index.js +4 -3
- package/dist/components/hover-card/index.js.map +1 -1
- package/dist/components/image/blur-svg.d.ts +11 -0
- package/dist/components/image/blur-svg.d.ts.map +1 -0
- package/dist/components/image/image.d.ts +126 -0
- package/dist/components/image/image.d.ts.map +1 -0
- package/dist/components/image/index.d.ts +3 -0
- package/dist/components/image/index.d.ts.map +1 -0
- package/dist/components/image/index.js +12 -0
- package/dist/components/image/index.js.map +1 -0
- package/dist/components/image/srcset.d.ts +47 -0
- package/dist/components/image/srcset.d.ts.map +1 -0
- package/dist/components/image-cropper/image-cropper.d.ts +208 -0
- package/dist/components/image-cropper/image-cropper.d.ts.map +1 -0
- package/dist/components/image-cropper/index.d.ts +2 -0
- package/dist/components/image-cropper/index.d.ts.map +1 -0
- package/dist/components/image-cropper/index.js +22 -0
- package/dist/components/image-cropper/index.js.map +1 -0
- package/dist/components/indicator/index.js +10 -3
- package/dist/components/indicator/index.js.map +1 -1
- package/dist/components/indicator/indicator.d.ts +21 -8
- package/dist/components/indicator/indicator.d.ts.map +1 -1
- package/dist/components/input/index.js +3 -2
- package/dist/components/input/input.d.ts +1 -1
- package/dist/components/input/input.d.ts.map +1 -1
- package/dist/components/kbd/index.d.ts +1 -0
- package/dist/components/kbd/index.d.ts.map +1 -1
- package/dist/components/kbd/index.js +10 -78
- package/dist/components/kbd/index.js.map +1 -1
- package/dist/components/kbd/kbd.d.ts +45 -3
- package/dist/components/kbd/kbd.d.ts.map +1 -1
- package/dist/components/lightbox/index.d.ts +2 -0
- package/dist/components/lightbox/index.d.ts.map +1 -0
- package/dist/components/lightbox/index.js +1922 -0
- package/dist/components/lightbox/index.js.map +1 -0
- package/dist/components/lightbox/lightbox-controller.d.ts +97 -0
- package/dist/components/lightbox/lightbox-controller.d.ts.map +1 -0
- package/dist/components/lightbox/lightbox-machine.d.ts +165 -0
- package/dist/components/lightbox/lightbox-machine.d.ts.map +1 -0
- package/dist/components/lightbox/lightbox-zoom.d.ts +72 -0
- package/dist/components/lightbox/lightbox-zoom.d.ts.map +1 -0
- package/dist/components/lightbox/lightbox.d.ts +297 -0
- package/dist/components/lightbox/lightbox.d.ts.map +1 -0
- package/dist/components/mark/index.js +1 -1
- package/dist/components/mark/mark.d.ts.map +1 -1
- package/dist/components/menu/index.d.ts +1 -1
- package/dist/components/menu/index.d.ts.map +1 -1
- package/dist/components/menu/index.js +12 -6
- package/dist/components/menu/index.js.map +1 -1
- package/dist/components/menu/menu-data.d.ts +5 -8
- package/dist/components/menu/menu-data.d.ts.map +1 -1
- package/dist/components/menu/menu.d.ts +40 -18
- package/dist/components/menu/menu.d.ts.map +1 -1
- package/dist/components/modal/index.d.ts +1 -1
- package/dist/components/modal/index.d.ts.map +1 -1
- package/dist/components/modal/index.js +10 -6
- package/dist/components/modal/modal.d.ts +25 -19
- package/dist/components/modal/modal.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.d.ts +1 -1
- package/dist/components/multi-combobox-list/index.d.ts.map +1 -1
- package/dist/components/multi-combobox-list/index.js +15 -12
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts +10 -2
- package/dist/components/multi-combobox-list/multi-combobox-list.d.ts.map +1 -1
- package/dist/components/multi-select/index.js +25 -19
- package/dist/components/multi-select/index.js.map +1 -1
- package/dist/components/multi-select/multi-select.d.ts +5 -2
- package/dist/components/multi-select/multi-select.d.ts.map +1 -1
- package/dist/components/nav-link/index.js +9 -6
- package/dist/components/nav-link/nav-link.d.ts +5 -2
- package/dist/components/nav-link/nav-link.d.ts.map +1 -1
- package/dist/components/nav-link/navigation.d.ts +8 -1
- package/dist/components/nav-link/navigation.d.ts.map +1 -1
- package/dist/components/nav-link/tanstack.js +9 -6
- package/dist/components/nav-link/tanstack.js.map +1 -1
- package/dist/components/notification/create-notifier.d.ts +4 -1
- package/dist/components/notification/create-notifier.d.ts.map +1 -1
- package/dist/components/notification/index.d.ts +1 -1
- package/dist/components/notification/index.d.ts.map +1 -1
- package/dist/components/notification/index.js +59 -21
- package/dist/components/notification/index.js.map +1 -1
- package/dist/components/notification/notification.d.ts +41 -11
- package/dist/components/notification/notification.d.ts.map +1 -1
- package/dist/components/number-input/index.d.ts +1 -1
- package/dist/components/number-input/index.d.ts.map +1 -1
- package/dist/components/number-input/index.js +10 -8
- package/dist/components/number-input/number-input.d.ts +9 -1
- package/dist/components/number-input/number-input.d.ts.map +1 -1
- package/dist/components/overlays/create-overlays.d.ts.map +1 -1
- package/dist/components/overlays/dialog-parts.d.ts +59 -0
- package/dist/components/overlays/dialog-parts.d.ts.map +1 -0
- package/dist/components/overlays/index.js +28 -31
- package/dist/components/overlays/index.js.map +1 -1
- package/dist/components/overlays/renderer.d.ts.map +1 -1
- package/dist/components/overlays/store.d.ts.map +1 -1
- package/dist/components/password-input/index.d.ts +1 -1
- package/dist/components/password-input/index.d.ts.map +1 -1
- package/dist/components/password-input/index.js +13 -5
- package/dist/components/password-input/index.js.map +1 -1
- package/dist/components/password-input/password-input.d.ts +10 -1
- package/dist/components/password-input/password-input.d.ts.map +1 -1
- package/dist/components/photo-capture/index.d.ts +4 -0
- package/dist/components/photo-capture/index.d.ts.map +1 -0
- package/dist/components/photo-capture/index.js +519 -0
- package/dist/components/photo-capture/index.js.map +1 -0
- package/dist/components/photo-capture/photo-capture-machine.d.ts +74 -0
- package/dist/components/photo-capture/photo-capture-machine.d.ts.map +1 -0
- package/dist/components/photo-capture/photo-capture.d.ts +192 -0
- package/dist/components/photo-capture/photo-capture.d.ts.map +1 -0
- package/dist/components/photo-capture/use-photo-capture.d.ts +92 -0
- package/dist/components/photo-capture/use-photo-capture.d.ts.map +1 -0
- package/dist/components/pill/index.js +5 -3
- package/dist/components/pill/pill.d.ts +4 -3
- package/dist/components/pill/pill.d.ts.map +1 -1
- package/dist/components/pills-input/index.d.ts +1 -1
- package/dist/components/pills-input/index.d.ts.map +1 -1
- package/dist/components/pills-input/index.js +12 -6
- package/dist/components/pills-input/pills-input.d.ts +29 -10
- package/dist/components/pills-input/pills-input.d.ts.map +1 -1
- package/dist/components/pin-input/index.d.ts +1 -1
- package/dist/components/pin-input/index.d.ts.map +1 -1
- package/dist/components/pin-input/index.js +39 -12
- package/dist/components/pin-input/index.js.map +1 -1
- package/dist/components/pin-input/pin-input.d.ts +14 -2
- package/dist/components/pin-input/pin-input.d.ts.map +1 -1
- package/dist/components/popover/icons.d.ts +9 -4
- package/dist/components/popover/icons.d.ts.map +1 -1
- package/dist/components/popover/index.js +4 -3
- package/dist/components/popover/popover.d.ts +12 -8
- package/dist/components/popover/popover.d.ts.map +1 -1
- package/dist/components/progress/index.js +4 -109
- package/dist/components/progress/index.js.map +1 -1
- package/dist/components/progress/progress.d.ts +9 -1
- package/dist/components/progress/progress.d.ts.map +1 -1
- package/dist/components/radio-group/index.js +11 -5
- package/dist/components/radio-group/index.js.map +1 -1
- package/dist/components/radio-group/radio-group.d.ts +3 -3
- package/dist/components/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/rating/icons.d.ts +0 -10
- package/dist/components/rating/icons.d.ts.map +1 -1
- package/dist/components/rating/index.d.ts +1 -1
- package/dist/components/rating/index.d.ts.map +1 -1
- package/dist/components/rating/index.js +16 -6
- package/dist/components/rating/index.js.map +1 -1
- package/dist/components/rating/rating.d.ts +18 -8
- package/dist/components/rating/rating.d.ts.map +1 -1
- package/dist/components/schedule/index.d.ts +6 -23
- package/dist/components/schedule/index.d.ts.map +1 -1
- package/dist/components/schedule/index.js +3314 -2729
- package/dist/components/schedule/index.js.map +1 -1
- package/dist/components/schedule/now-cursor-line.d.ts +11 -3
- package/dist/components/schedule/now-cursor-line.d.ts.map +1 -1
- package/dist/components/schedule/schedule-agenda-list.d.ts +1 -1
- package/dist/components/schedule/schedule-agenda-list.d.ts.map +1 -1
- package/dist/components/schedule/schedule-agenda-view.d.ts +3 -4
- package/dist/components/schedule/schedule-agenda-view.d.ts.map +1 -1
- package/dist/components/schedule/schedule-all-day-row.d.ts +3 -1
- package/dist/components/schedule/schedule-all-day-row.d.ts.map +1 -1
- package/dist/components/schedule/schedule-create-draft.d.ts.map +1 -1
- package/dist/components/schedule/schedule-dates.d.ts +42 -19
- package/dist/components/schedule/schedule-dates.d.ts.map +1 -1
- package/dist/components/schedule/schedule-day-column.d.ts +111 -0
- package/dist/components/schedule/schedule-day-column.d.ts.map +1 -0
- package/dist/components/schedule/schedule-days-view.d.ts +2 -2
- package/dist/components/schedule/schedule-days-view.d.ts.map +1 -1
- package/dist/components/schedule/schedule-drag-ghost.d.ts.map +1 -1
- package/dist/components/schedule/schedule-event-chip.d.ts +31 -2
- package/dist/components/schedule/schedule-event-chip.d.ts.map +1 -1
- package/dist/components/schedule/schedule-event-details-popover.d.ts +57 -0
- package/dist/components/schedule/schedule-event-details-popover.d.ts.map +1 -0
- package/dist/components/schedule/schedule-event-details.d.ts.map +1 -1
- package/dist/components/schedule/schedule-event-list-popover-content.d.ts +4 -1
- package/dist/components/schedule/schedule-event-list-popover-content.d.ts.map +1 -1
- package/dist/components/schedule/schedule-event-pill.d.ts +68 -0
- package/dist/components/schedule/schedule-event-pill.d.ts.map +1 -0
- package/dist/components/schedule/schedule-event-styles.d.ts +54 -0
- package/dist/components/schedule/schedule-event-styles.d.ts.map +1 -1
- package/dist/components/schedule/schedule-geometry.d.ts +10 -8
- package/dist/components/schedule/schedule-geometry.d.ts.map +1 -1
- package/dist/components/schedule/schedule-grid-gesture.d.ts +24 -2
- package/dist/components/schedule/schedule-grid-gesture.d.ts.map +1 -1
- package/dist/components/schedule/schedule-icons.d.ts +20 -0
- package/dist/components/schedule/schedule-icons.d.ts.map +1 -0
- package/dist/components/schedule/schedule-month-view.d.ts +1 -1
- package/dist/components/schedule/schedule-month-view.d.ts.map +1 -1
- package/dist/components/schedule/schedule-overflow-chip.d.ts +4 -2
- package/dist/components/schedule/schedule-overflow-chip.d.ts.map +1 -1
- package/dist/components/schedule/schedule-overflow-popover.d.ts +4 -1
- package/dist/components/schedule/schedule-overflow-popover.d.ts.map +1 -1
- package/dist/components/schedule/schedule-slot-cursor.d.ts +36 -0
- package/dist/components/schedule/schedule-slot-cursor.d.ts.map +1 -0
- package/dist/components/schedule/schedule-timed-grid-chrome.d.ts +86 -0
- package/dist/components/schedule/schedule-timed-grid-chrome.d.ts.map +1 -0
- package/dist/components/schedule/schedule-timed-grid.d.ts +3 -1
- package/dist/components/schedule/schedule-timed-grid.d.ts.map +1 -1
- package/dist/components/schedule/schedule-toolbar.d.ts +33 -10
- package/dist/components/schedule/schedule-toolbar.d.ts.map +1 -1
- package/dist/components/schedule/schedule-types.d.ts +103 -15
- package/dist/components/schedule/schedule-types.d.ts.map +1 -1
- package/dist/components/schedule/schedule-view-pagination-chrome.d.ts +36 -0
- package/dist/components/schedule/schedule-view-pagination-chrome.d.ts.map +1 -0
- package/dist/components/schedule/schedule-year-view.d.ts +1 -1
- package/dist/components/schedule/schedule-year-view.d.ts.map +1 -1
- package/dist/components/schedule/schedule.d.ts +0 -18
- package/dist/components/schedule/schedule.d.ts.map +1 -1
- package/dist/components/schedule/use-chip-keyboard-move.d.ts +45 -0
- package/dist/components/schedule/use-chip-keyboard-move.d.ts.map +1 -0
- package/dist/components/schedule/use-chip-motion.d.ts +28 -0
- package/dist/components/schedule/use-chip-motion.d.ts.map +1 -0
- package/dist/components/schedule/use-date-grid-navigation.d.ts +59 -0
- package/dist/components/schedule/use-date-grid-navigation.d.ts.map +1 -0
- package/dist/components/schedule/use-event-drag.d.ts.map +1 -1
- package/dist/components/schedule/use-event-resize.d.ts +10 -2
- package/dist/components/schedule/use-event-resize.d.ts.map +1 -1
- package/dist/components/schedule/use-schedule-reveal.d.ts +29 -0
- package/dist/components/schedule/use-schedule-reveal.d.ts.map +1 -0
- package/dist/components/schedule/use-schedule-selection.d.ts +3 -1
- package/dist/components/schedule/use-schedule-selection.d.ts.map +1 -1
- package/dist/components/schedule/use-timed-grid-announcer.d.ts +21 -0
- package/dist/components/schedule/use-timed-grid-announcer.d.ts.map +1 -0
- package/dist/components/schedule/use-timed-grid-paging.d.ts +36 -0
- package/dist/components/schedule/use-timed-grid-paging.d.ts.map +1 -0
- package/dist/components/segment-group/index.js +8 -6
- package/dist/components/segment-group/segment-group.d.ts +1 -1
- package/dist/components/segment-group/segment-group.d.ts.map +1 -1
- package/dist/components/select/index.js +13 -11
- package/dist/components/select/select.d.ts.map +1 -1
- package/dist/components/skeleton/index.js +2 -1
- package/dist/components/slider/index.js +6 -256
- package/dist/components/slider/index.js.map +1 -1
- package/dist/components/slider/slider.d.ts +18 -10
- package/dist/components/slider/slider.d.ts.map +1 -1
- package/dist/components/spinner/index.js +2 -1
- package/dist/components/spinner/spinner.d.ts +7 -36
- package/dist/components/spinner/spinner.d.ts.map +1 -1
- package/dist/components/spotlight/context.d.ts +50 -0
- package/dist/components/spotlight/context.d.ts.map +1 -0
- package/dist/components/spotlight/create-spotlight.d.ts +193 -0
- package/dist/components/spotlight/create-spotlight.d.ts.map +1 -0
- package/dist/components/spotlight/highlight.d.ts +23 -0
- package/dist/components/spotlight/highlight.d.ts.map +1 -0
- package/dist/components/spotlight/icons.d.ts +14 -0
- package/dist/components/spotlight/icons.d.ts.map +1 -0
- package/dist/components/spotlight/index.d.ts +12 -0
- package/dist/components/spotlight/index.d.ts.map +1 -0
- package/dist/components/spotlight/index.js +1695 -0
- package/dist/components/spotlight/index.js.map +1 -0
- package/dist/components/spotlight/label.d.ts +9 -0
- package/dist/components/spotlight/label.d.ts.map +1 -0
- package/dist/components/spotlight/recents.d.ts +29 -0
- package/dist/components/spotlight/recents.d.ts.map +1 -0
- package/dist/components/spotlight/spotlight-engine.d.ts +86 -0
- package/dist/components/spotlight/spotlight-engine.d.ts.map +1 -0
- package/dist/components/spotlight/spotlight.d.ts +233 -0
- package/dist/components/spotlight/spotlight.d.ts.map +1 -0
- package/dist/components/spotlight/static-source.d.ts +32 -0
- package/dist/components/spotlight/static-source.d.ts.map +1 -0
- package/dist/components/spotlight/store.d.ts +39 -0
- package/dist/components/spotlight/store.d.ts.map +1 -0
- package/dist/components/spotlight/translations.d.ts +90 -0
- package/dist/components/spotlight/translations.d.ts.map +1 -0
- package/dist/components/spotlight/types.d.ts +297 -0
- package/dist/components/spotlight/types.d.ts.map +1 -0
- package/dist/components/spotlight/view.d.ts +139 -0
- package/dist/components/spotlight/view.d.ts.map +1 -0
- package/dist/components/switch/index.js +7 -6
- package/dist/components/switch/index.js.map +1 -1
- package/dist/components/switch/switch.d.ts +3 -2
- package/dist/components/switch/switch.d.ts.map +1 -1
- package/dist/components/table/index.js +3 -1
- package/dist/components/table/table.d.ts.map +1 -1
- package/dist/components/tabs/index.js +5 -4
- package/dist/components/tabs/tabs-data.d.ts +6 -2
- package/dist/components/tabs/tabs-data.d.ts.map +1 -1
- package/dist/components/tabs/tabs.d.ts +55 -34
- package/dist/components/tabs/tabs.d.ts.map +1 -1
- package/dist/components/tags-input/index.js +41 -24
- package/dist/components/tags-input/index.js.map +1 -1
- package/dist/components/tags-input/tags-input.d.ts +12 -5
- package/dist/components/tags-input/tags-input.d.ts.map +1 -1
- package/dist/components/text/index.js +2 -2
- package/dist/components/text/text.d.ts.map +1 -1
- package/dist/components/text-input/index.js +3 -2
- package/dist/components/text-input/index.js.map +1 -1
- package/dist/components/textarea/index.js +3 -2
- package/dist/components/textarea/index.js.map +1 -1
- package/dist/components/theme-icon/index.js +2 -2
- package/dist/components/theme-script/index.js.map +1 -1
- package/dist/components/theme-script/theme-script.d.ts +2 -2
- package/dist/components/theme-script/theme-script.d.ts.map +1 -1
- package/dist/components/time-input/hour-cycle.d.ts +17 -7
- package/dist/components/time-input/hour-cycle.d.ts.map +1 -1
- package/dist/components/time-input/index.js +21 -20
- package/dist/components/time-input/index.js.map +1 -1
- package/dist/components/time-input/time-input.d.ts +2 -1
- package/dist/components/time-input/time-input.d.ts.map +1 -1
- package/dist/components/time-input/time-row.d.ts +20 -1
- package/dist/components/time-input/time-row.d.ts.map +1 -1
- package/dist/components/timeline/index.d.ts +1 -1
- package/dist/components/timeline/index.d.ts.map +1 -1
- package/dist/components/timeline/index.js +43 -30
- package/dist/components/timeline/index.js.map +1 -1
- package/dist/components/timeline/timeline.d.ts +16 -2
- package/dist/components/timeline/timeline.d.ts.map +1 -1
- package/dist/components/title/index.js +2 -2
- package/dist/components/title/title.d.ts.map +1 -1
- package/dist/components/tooltip/index.js +3 -2
- package/dist/components/tooltip/tooltip.d.ts +6 -4
- package/dist/components/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/tree-multi-select/index.d.ts +1 -1
- package/dist/components/tree-multi-select/index.d.ts.map +1 -1
- package/dist/components/tree-multi-select/index.js +111 -247
- package/dist/components/tree-multi-select/index.js.map +1 -1
- package/dist/components/tree-multi-select/tree-multi-select.d.ts +12 -5
- package/dist/components/tree-multi-select/tree-multi-select.d.ts.map +1 -1
- package/dist/components/tree-select/index.d.ts +1 -1
- package/dist/components/tree-select/index.d.ts.map +1 -1
- package/dist/components/tree-select/index.js +104 -320
- package/dist/components/tree-select/index.js.map +1 -1
- package/dist/components/tree-select/tree-popover.d.ts +126 -0
- package/dist/components/tree-select/tree-popover.d.ts.map +1 -0
- package/dist/components/tree-select/tree-select.d.ts +24 -2
- package/dist/components/tree-select/tree-select.d.ts.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +59 -112
- package/dist/index.js.map +1 -1
- package/dist/lib/as-child.d.ts +1 -1
- package/dist/lib/cutout.d.ts +34 -0
- package/dist/lib/cutout.d.ts.map +1 -0
- package/dist/lib/dev-warn.d.ts +11 -0
- package/dist/lib/dev-warn.d.ts.map +1 -1
- package/dist/lib/file-kind-icons.d.ts +5 -0
- package/dist/lib/file-kind-icons.d.ts.map +1 -0
- package/dist/lib/file-queue-summary.d.ts +89 -0
- package/dist/lib/file-queue-summary.d.ts.map +1 -0
- package/dist/lib/file-queue.d.ts +147 -0
- package/dist/lib/file-queue.d.ts.map +1 -0
- package/dist/lib/files.d.ts +29 -0
- package/dist/lib/files.d.ts.map +1 -0
- package/dist/lib/focus-styles.d.ts +46 -7
- package/dist/lib/focus-styles.d.ts.map +1 -1
- package/dist/lib/gap.d.ts +17 -0
- package/dist/lib/gap.d.ts.map +1 -0
- package/dist/lib/graphemes.d.ts +10 -0
- package/dist/lib/graphemes.d.ts.map +1 -0
- package/dist/lib/icons.d.ts +34 -0
- package/dist/lib/icons.d.ts.map +1 -0
- package/dist/lib/image-file.d.ts +9 -0
- package/dist/lib/image-file.d.ts.map +1 -0
- package/dist/lib/merge-refs.d.ts +34 -7
- package/dist/lib/merge-refs.d.ts.map +1 -1
- package/dist/lib/motion/animate.d.ts +42 -0
- package/dist/lib/motion/animate.d.ts.map +1 -0
- package/dist/lib/motion/easing.d.ts +33 -0
- package/dist/lib/motion/easing.d.ts.map +1 -0
- package/dist/lib/motion/gesture.d.ts +127 -0
- package/dist/lib/motion/gesture.d.ts.map +1 -0
- package/dist/lib/motion/morph.d.ts +61 -0
- package/dist/lib/motion/morph.d.ts.map +1 -0
- package/dist/lib/motion/physics.d.ts +44 -0
- package/dist/lib/motion/physics.d.ts.map +1 -0
- package/dist/lib/motion/rect.d.ts +39 -0
- package/dist/lib/motion/rect.d.ts.map +1 -0
- package/dist/lib/motion/reduced-motion.d.ts +23 -0
- package/dist/lib/motion/reduced-motion.d.ts.map +1 -0
- package/dist/lib/motion/spring.d.ts +80 -0
- package/dist/lib/motion/spring.d.ts.map +1 -0
- package/dist/lib/motion/tokens.d.ts +43 -0
- package/dist/lib/motion/tokens.d.ts.map +1 -0
- package/dist/lib/motion/use-gesture.d.ts +36 -0
- package/dist/lib/motion/use-gesture.d.ts.map +1 -0
- package/dist/lib/open-file.d.ts +82 -0
- package/dist/lib/open-file.d.ts.map +1 -0
- package/dist/lib/open-index.d.ts +59 -0
- package/dist/lib/open-index.d.ts.map +1 -0
- package/dist/lib/overlay-layer.d.ts +15 -1
- package/dist/lib/overlay-layer.d.ts.map +1 -1
- package/dist/lib/radius.d.ts +17 -0
- package/dist/lib/radius.d.ts.map +1 -0
- package/dist/lib/ratio.d.ts +16 -0
- package/dist/lib/ratio.d.ts.map +1 -0
- package/dist/lib/save-file.d.ts +52 -0
- package/dist/lib/save-file.d.ts.map +1 -0
- package/dist/lib/select-data.d.ts +57 -24
- package/dist/lib/select-data.d.ts.map +1 -1
- package/dist/lib/tree-data.d.ts +7 -2
- package/dist/lib/tree-data.d.ts.map +1 -1
- package/dist/lib/typography-size.d.ts +27 -8
- package/dist/lib/typography-size.d.ts.map +1 -1
- package/dist/lib/use-debounced.d.ts +17 -0
- package/dist/lib/use-debounced.d.ts.map +1 -0
- package/dist/lib/use-disclosure.d.ts.map +1 -1
- package/dist/lib/use-document-visibility.d.ts +16 -0
- package/dist/lib/use-document-visibility.d.ts.map +1 -0
- package/dist/lib/use-element-size.d.ts +42 -0
- package/dist/lib/use-element-size.d.ts.map +1 -0
- package/dist/lib/use-file-queue.d.ts +62 -0
- package/dist/lib/use-file-queue.d.ts.map +1 -0
- package/dist/lib/use-hotkey.d.ts +240 -0
- package/dist/lib/use-hotkey.d.ts.map +1 -0
- package/dist/lib/use-hydrated.d.ts +16 -0
- package/dist/lib/use-hydrated.d.ts.map +1 -0
- package/dist/lib/use-in-view.d.ts +37 -0
- package/dist/lib/use-in-view.d.ts.map +1 -0
- package/dist/lib/use-now.d.ts +34 -3
- package/dist/lib/use-now.d.ts.map +1 -1
- package/dist/lib/use-object-url.d.ts +61 -0
- package/dist/lib/use-object-url.d.ts.map +1 -0
- package/dist/lib/use-uncontrolled.d.ts.map +1 -1
- package/dist/theme.css +184 -16
- package/package.json +4 -2
- package/src/as-child.contract.test.tsx +221 -6
- package/src/biome-plugins.test.ts +34 -4
- package/src/colors.css +16 -8
- package/src/components/accordion/accordion.test.tsx +45 -2
- package/src/components/accordion/accordion.tsx +38 -17
- package/src/components/accordion/index.ts +2 -0
- package/src/components/action-icon/action-icon.tsx +8 -6
- package/src/components/alert/alert.test.tsx +49 -2
- package/src/components/alert/alert.tsx +47 -14
- package/src/components/alert/index.ts +8 -1
- package/src/components/ambient-background/ambient-background.test.tsx +21 -7
- package/src/components/ambient-background/ambient-background.tsx +49 -28
- package/src/components/app-shell/app-shell.test.tsx +58 -8
- package/src/components/app-shell/app-shell.tsx +69 -17
- package/src/components/app-shell/index.ts +2 -0
- package/src/components/aspect-ratio/aspect-ratio.test.tsx +82 -0
- package/src/components/aspect-ratio/aspect-ratio.tsx +63 -0
- package/src/components/aspect-ratio/index.ts +1 -0
- package/src/components/autocomplete/autocomplete.tsx +9 -14
- package/src/components/avatar/avatar.test.tsx +101 -2
- package/src/components/avatar/avatar.tsx +65 -15
- package/src/components/avatar/index.ts +2 -0
- package/src/components/badge/badge.tsx +3 -1
- package/src/components/breadcrumb/breadcrumb.test.tsx +46 -0
- package/src/components/breadcrumb/breadcrumb.tsx +51 -10
- package/src/components/breadcrumb/index.ts +2 -0
- package/src/components/button/button.test.tsx +65 -12
- package/src/components/button/button.tsx +119 -29
- package/src/components/button-select/button-select.tsx +1 -2
- package/src/components/calendar/calendar-body.tsx +42 -28
- package/src/components/calendar/calendar.test.tsx +89 -0
- package/src/components/calendar/calendar.tsx +42 -4
- package/src/components/calendar/index.ts +2 -0
- package/src/components/camera/camera-machine.test.ts +188 -0
- package/src/components/camera/camera-machine.ts +274 -0
- package/src/components/camera/camera.test.tsx +580 -0
- package/src/components/camera/camera.tsx +938 -0
- package/src/components/camera/fake-camera.ts +153 -0
- package/src/components/camera/index.ts +36 -0
- package/src/components/camera/platform.test.ts +40 -0
- package/src/components/camera/platform.ts +53 -0
- package/src/components/camera/use-camera.ts +428 -0
- package/src/components/card/card.test.tsx +70 -0
- package/src/components/card/card.tsx +5 -2
- package/src/components/carousel/carousel.test.tsx +757 -0
- package/src/components/carousel/carousel.tsx +1115 -0
- package/src/components/carousel/index.ts +24 -0
- package/src/components/chart/chart.test.tsx +26 -0
- package/src/components/chart/chart.tsx +33 -3
- package/src/components/chart/styles.css +12 -10
- package/src/components/checkbox/checkbox.test.tsx +38 -1
- package/src/components/checkbox/checkbox.tsx +34 -10
- package/src/components/checkbox/control.ts +3 -3
- package/src/components/checkbox/index.ts +6 -1
- package/src/components/choice-card-group/choice-card-group.test.tsx +18 -0
- package/src/components/choice-card-group/choice-card-group.tsx +78 -58
- package/src/components/circular-progress/circular-progress.test.tsx +24 -5
- package/src/components/circular-progress/circular-progress.tsx +26 -3
- package/src/components/clipboard/clipboard.test.tsx +64 -5
- package/src/components/clipboard/clipboard.tsx +62 -16
- package/src/components/clipboard/copy.tsx +35 -20
- package/src/components/clipboard/index.ts +7 -1
- package/src/components/code/code.test.tsx +1 -1
- package/src/components/code/code.tsx +2 -1
- package/src/components/code-block/chrome.tsx +49 -53
- package/src/components/code-block/code-block.test.tsx +34 -13
- package/src/components/code-block/code-block.tsx +8 -9
- package/src/components/code-block/index.ts +4 -0
- package/src/components/code-block/static.tsx +8 -5
- package/src/components/combobox/combobox.tsx +14 -6
- package/src/components/combobox-list/combobox-list.test.tsx +54 -0
- package/src/components/combobox-list/combobox-list.tsx +57 -61
- package/src/components/combobox-list/combobox-search-row.tsx +92 -0
- package/src/components/combobox-list/index.ts +2 -0
- package/src/components/compare/compare.test.tsx +291 -0
- package/src/components/compare/compare.tsx +300 -0
- package/src/components/compare/index.ts +3 -0
- package/src/components/container/container.test.tsx +47 -0
- package/src/components/container/container.tsx +8 -2
- package/src/components/data-table/data-table-filter/data-table-date-filter.tsx +24 -18
- package/src/components/data-table/data-table-filter/data-table-number-filter.tsx +6 -3
- package/src/components/data-table/data-table-filter/index.tsx +34 -9
- package/src/components/data-table/data-table-filter.test.tsx +72 -0
- package/src/components/data-table/data-table-header-cell.tsx +75 -68
- package/src/components/data-table/data-table-icons.tsx +79 -0
- package/src/components/data-table/data-table-pagination.tsx +55 -19
- package/src/components/data-table/data-table-placeholder.tsx +2 -2
- package/src/components/data-table/data-table-stack.tsx +19 -25
- package/src/components/data-table/data-table-state.ts +4 -5
- package/src/components/data-table/data-table-toolbar.tsx +10 -3
- package/src/components/data-table/data-table-translations.ts +15 -3
- package/src/components/data-table/data-table.test.tsx +300 -13
- package/src/components/data-table/data-table.tsx +54 -21
- package/src/components/data-table/index.ts +5 -0
- package/src/components/date-picker/aliases.tsx +8 -0
- package/src/components/date-picker/date-picker.test.tsx +75 -0
- package/src/components/date-picker/date-picker.tsx +102 -51
- package/src/components/date-picker/date-time-text.test.ts +9 -0
- package/src/components/date-picker/date-time-text.ts +12 -4
- package/src/components/date-picker/index.ts +1 -0
- package/src/components/divider/divider.test.tsx +34 -5
- package/src/components/divider/divider.tsx +23 -6
- package/src/components/download-button/download-button.test.tsx +253 -0
- package/src/components/download-button/download-button.tsx +236 -0
- package/src/components/download-button/index.ts +11 -0
- package/src/components/drawer/drawer.test.tsx +287 -0
- package/src/components/drawer/drawer.tsx +238 -172
- package/src/components/drawer/index.ts +4 -11
- package/src/components/field/field.test.tsx +115 -0
- package/src/components/field/field.tsx +13 -4
- package/src/components/figure/figure.test.tsx +133 -0
- package/src/components/figure/figure.tsx +137 -0
- package/src/components/figure/index.ts +6 -0
- package/src/components/file-item/file-item.test.tsx +395 -0
- package/src/components/file-item/file-item.tsx +625 -0
- package/src/components/file-item/index.ts +22 -0
- package/src/components/file-preview/file-preview.test.tsx +479 -0
- package/src/components/file-preview/file-preview.tsx +953 -0
- package/src/components/file-preview/index.ts +22 -0
- package/src/components/file-queue-summary/file-queue-summary.test.tsx +285 -0
- package/src/components/file-queue-summary/file-queue-summary.tsx +121 -0
- package/src/components/file-queue-summary/index.ts +12 -0
- package/src/components/file-trigger/file-trigger.test.tsx +138 -0
- package/src/components/file-trigger/file-trigger.tsx +135 -0
- package/src/components/file-trigger/index.ts +3 -0
- package/src/components/file-upload/file-upload.test.tsx +416 -2
- package/src/components/file-upload/file-upload.tsx +391 -136
- package/src/components/file-upload/index.ts +11 -1
- package/src/components/flex/flex.test.tsx +15 -0
- package/src/components/flex/flex.tsx +20 -12
- package/src/components/gallery/gallery.test.tsx +436 -0
- package/src/components/gallery/gallery.tsx +367 -0
- package/src/components/gallery/index.ts +16 -0
- package/src/components/gallery/layout.test.ts +158 -0
- package/src/components/gallery/layout.ts +168 -0
- package/src/components/grid/grid.test.tsx +46 -0
- package/src/components/grid/grid.tsx +11 -11
- package/src/components/image/blur-svg.ts +54 -0
- package/src/components/image/image.test.tsx +481 -0
- package/src/components/image/image.tsx +424 -0
- package/src/components/image/index.ts +14 -0
- package/src/components/image/srcset.test.ts +73 -0
- package/src/components/image/srcset.ts +70 -0
- package/src/components/image-cropper/image-cropper.test.tsx +446 -0
- package/src/components/image-cropper/image-cropper.tsx +745 -0
- package/src/components/image-cropper/index.ts +24 -0
- package/src/components/indicator/indicator.test.tsx +73 -6
- package/src/components/indicator/indicator.tsx +38 -10
- package/src/components/input/input.tsx +6 -5
- package/src/components/kbd/index.ts +6 -0
- package/src/components/kbd/kbd.test.tsx +239 -2
- package/src/components/kbd/kbd.tsx +130 -6
- package/src/components/lightbox/index.ts +25 -0
- package/src/components/lightbox/lightbox-controller.ts +796 -0
- package/src/components/lightbox/lightbox-machine.test.ts +460 -0
- package/src/components/lightbox/lightbox-machine.ts +285 -0
- package/src/components/lightbox/lightbox-zoom.test.ts +130 -0
- package/src/components/lightbox/lightbox-zoom.ts +142 -0
- package/src/components/lightbox/lightbox.test.tsx +821 -0
- package/src/components/lightbox/lightbox.tsx +1301 -0
- package/src/components/mark/mark.test.tsx +21 -2
- package/src/components/mark/mark.tsx +15 -1
- package/src/components/menu/index.ts +4 -0
- package/src/components/menu/menu-data.tsx +20 -17
- package/src/components/menu/menu.test.tsx +123 -19
- package/src/components/menu/menu.tsx +150 -102
- package/src/components/modal/close-trigger.test.tsx +49 -0
- package/src/components/modal/index.ts +2 -0
- package/src/components/modal/modal.test.tsx +101 -0
- package/src/components/modal/modal.tsx +64 -103
- package/src/components/multi-combobox-list/index.ts +2 -0
- package/src/components/multi-combobox-list/multi-combobox-list.test.tsx +45 -0
- package/src/components/multi-combobox-list/multi-combobox-list.tsx +45 -62
- package/src/components/multi-select/multi-select.test.tsx +10 -2
- package/src/components/multi-select/multi-select.tsx +20 -18
- package/src/components/nav-link/nav-link.test.tsx +43 -0
- package/src/components/nav-link/nav-link.tsx +34 -15
- package/src/components/nav-link/navigation.test.tsx +29 -1
- package/src/components/nav-link/navigation.tsx +45 -22
- package/src/components/notification/create-notifier.tsx +79 -13
- package/src/components/notification/index.ts +2 -0
- package/src/components/notification/notification.test.tsx +252 -1
- package/src/components/notification/notification.tsx +102 -58
- package/src/components/number-input/index.ts +7 -1
- package/src/components/number-input/number-input.test.tsx +45 -0
- package/src/components/number-input/number-input.tsx +34 -27
- package/src/components/overlays/create-overlays.tsx +18 -21
- package/src/components/overlays/dialog-parts.tsx +201 -0
- package/src/components/overlays/overlays.test.tsx +170 -0
- package/src/components/overlays/renderer.tsx +2 -9
- package/src/components/overlays/store.ts +4 -1
- package/src/components/password-input/index.ts +2 -0
- package/src/components/password-input/password-input.test.tsx +30 -0
- package/src/components/password-input/password-input.tsx +17 -3
- package/src/components/photo-capture/index.ts +35 -0
- package/src/components/photo-capture/photo-capture-machine.test.ts +147 -0
- package/src/components/photo-capture/photo-capture-machine.ts +112 -0
- package/src/components/photo-capture/photo-capture.test.tsx +375 -0
- package/src/components/photo-capture/photo-capture.tsx +665 -0
- package/src/components/photo-capture/use-photo-capture.ts +199 -0
- package/src/components/pill/pill.test.tsx +58 -1
- package/src/components/pill/pill.tsx +34 -16
- package/src/components/pills-input/index.ts +1 -0
- package/src/components/pills-input/pills-input.test.ts +14 -14
- package/src/components/pills-input/pills-input.test.tsx +39 -0
- package/src/components/pills-input/pills-input.tsx +70 -32
- package/src/components/pin-input/index.ts +1 -1
- package/src/components/pin-input/pin-input.test.tsx +28 -0
- package/src/components/pin-input/pin-input.tsx +64 -16
- package/src/components/popover/icons.tsx +16 -12
- package/src/components/popover/popover.test.tsx +11 -0
- package/src/components/popover/popover.tsx +21 -11
- package/src/components/progress/progress.test.tsx +17 -5
- package/src/components/progress/progress.tsx +23 -7
- package/src/components/radio-group/radio-group.test.tsx +21 -1
- package/src/components/radio-group/radio-group.tsx +66 -48
- package/src/components/rating/icons.tsx +4 -2
- package/src/components/rating/index.ts +2 -0
- package/src/components/rating/rating.test.tsx +43 -4
- package/src/components/rating/rating.tsx +29 -13
- package/src/components/schedule/index.ts +4 -1
- package/src/components/schedule/now-cursor-line.test.tsx +6 -6
- package/src/components/schedule/now-cursor-line.tsx +29 -15
- package/src/components/schedule/schedule-a11y.test.tsx +847 -0
- package/src/components/schedule/schedule-agenda-list.tsx +25 -44
- package/src/components/schedule/schedule-agenda-view.test.tsx +2 -2
- package/src/components/schedule/schedule-agenda-view.tsx +22 -37
- package/src/components/schedule/schedule-all-day-row.tsx +35 -96
- package/src/components/schedule/schedule-create-draft.tsx +23 -90
- package/src/components/schedule/schedule-dates.test.ts +64 -20
- package/src/components/schedule/schedule-dates.ts +65 -27
- package/src/components/schedule/schedule-day-column.tsx +607 -0
- package/src/components/schedule/schedule-days-view.tsx +40 -49
- package/src/components/schedule/schedule-details-popover.test.tsx +97 -0
- package/src/components/schedule/schedule-drag-ghost.tsx +30 -98
- package/src/components/schedule/schedule-event-chip.tsx +120 -262
- package/src/components/schedule/schedule-event-details-popover.tsx +132 -0
- package/src/components/schedule/schedule-event-details.tsx +6 -7
- package/src/components/schedule/schedule-event-list-popover-content.tsx +9 -5
- package/src/components/schedule/schedule-event-pill.tsx +159 -0
- package/src/components/schedule/schedule-event-styles.ts +71 -0
- package/src/components/schedule/schedule-geometry.test.ts +5 -5
- package/src/components/schedule/schedule-geometry.ts +16 -13
- package/src/components/schedule/schedule-grid-gesture.test.ts +99 -0
- package/src/components/schedule/schedule-grid-gesture.ts +50 -12
- package/src/components/schedule/schedule-icons.test.tsx +105 -0
- package/src/components/schedule/schedule-icons.tsx +40 -0
- package/src/components/schedule/schedule-month-view.test.tsx +118 -2
- package/src/components/schedule/schedule-month-view.tsx +258 -200
- package/src/components/schedule/schedule-overflow-chip.tsx +9 -4
- package/src/components/schedule/schedule-overflow-popover.tsx +5 -0
- package/src/components/schedule/schedule-slot-cursor.tsx +422 -0
- package/src/components/schedule/schedule-timed-grid-chrome.tsx +330 -0
- package/src/components/schedule/schedule-timed-grid.tsx +222 -893
- package/src/components/schedule/schedule-toolbar.tsx +108 -60
- package/src/components/schedule/schedule-types.test.ts +43 -2
- package/src/components/schedule/schedule-types.ts +164 -17
- package/src/components/schedule/schedule-view-pagination-chrome.tsx +101 -0
- package/src/components/schedule/schedule-year-view.test.tsx +86 -1
- package/src/components/schedule/schedule-year-view.tsx +163 -136
- package/src/components/schedule/schedule.test.tsx +275 -7
- package/src/components/schedule/schedule.tsx +36 -242
- package/src/components/schedule/use-chip-keyboard-move.ts +109 -0
- package/src/components/schedule/use-chip-motion.ts +71 -0
- package/src/components/schedule/use-date-grid-navigation.ts +120 -0
- package/src/components/schedule/use-event-drag.ts +1 -23
- package/src/components/schedule/use-event-resize.ts +27 -22
- package/src/components/schedule/use-schedule-reveal.ts +259 -0
- package/src/components/schedule/use-schedule-selection.ts +14 -2
- package/src/components/schedule/use-timed-grid-announcer.test.ts +72 -0
- package/src/components/schedule/use-timed-grid-announcer.ts +42 -0
- package/src/components/schedule/use-timed-grid-paging.ts +118 -0
- package/src/components/segment-group/segment-group.test.tsx +27 -5
- package/src/components/segment-group/segment-group.tsx +35 -28
- package/src/components/select/select.tsx +8 -8
- package/src/components/skeleton/skeleton.tsx +1 -1
- package/src/components/slider/slider.test.tsx +56 -5
- package/src/components/slider/slider.tsx +93 -31
- package/src/components/spinner/spinner.test.tsx +34 -10
- package/src/components/spinner/spinner.tsx +52 -49
- package/src/components/spotlight/context.ts +62 -0
- package/src/components/spotlight/create-spotlight.test.tsx +252 -0
- package/src/components/spotlight/create-spotlight.tsx +515 -0
- package/src/components/spotlight/highlight.test.ts +57 -0
- package/src/components/spotlight/highlight.ts +86 -0
- package/src/components/spotlight/icons.tsx +27 -0
- package/src/components/spotlight/index.ts +68 -0
- package/src/components/spotlight/label.ts +10 -0
- package/src/components/spotlight/recents.test.ts +46 -0
- package/src/components/spotlight/recents.ts +54 -0
- package/src/components/spotlight/spotlight-engine.test.ts +836 -0
- package/src/components/spotlight/spotlight-engine.ts +525 -0
- package/src/components/spotlight/spotlight.test.tsx +2532 -0
- package/src/components/spotlight/spotlight.tsx +1429 -0
- package/src/components/spotlight/static-source.test.ts +71 -0
- package/src/components/spotlight/static-source.ts +62 -0
- package/src/components/spotlight/store.test.ts +122 -0
- package/src/components/spotlight/store.ts +130 -0
- package/src/components/spotlight/translations.ts +124 -0
- package/src/components/spotlight/types.ts +308 -0
- package/src/components/spotlight/view.test.ts +216 -0
- package/src/components/spotlight/view.ts +350 -0
- package/src/components/switch/switch.test.tsx +8 -0
- package/src/components/switch/switch.tsx +12 -8
- package/src/components/table/table.test.tsx +35 -0
- package/src/components/table/table.tsx +28 -4
- package/src/components/tabs/tabs-data.tsx +7 -2
- package/src/components/tabs/tabs.test.tsx +211 -50
- package/src/components/tabs/tabs.tsx +309 -120
- package/src/components/tags-input/tags-input.test.tsx +116 -2
- package/src/components/tags-input/tags-input.tsx +51 -31
- package/src/components/text/text.test.tsx +1 -1
- package/src/components/text/text.tsx +1 -4
- package/src/components/theme-icon/theme-icon.tsx +2 -2
- package/src/components/theme-script/theme-script.test.tsx +52 -0
- package/src/components/theme-script/theme-script.tsx +1 -1
- package/src/components/time-input/hour-cycle.test.ts +37 -0
- package/src/components/time-input/hour-cycle.ts +37 -10
- package/src/components/time-input/time-input.test.tsx +34 -0
- package/src/components/time-input/time-input.tsx +12 -14
- package/src/components/time-input/time-row.test.ts +10 -0
- package/src/components/time-input/time-row.tsx +39 -19
- package/src/components/timeline/index.ts +1 -0
- package/src/components/timeline/timeline.test.tsx +39 -4
- package/src/components/timeline/timeline.tsx +43 -7
- package/src/components/title/title.test.tsx +3 -3
- package/src/components/title/title.tsx +2 -1
- package/src/components/tooltip/tooltip.test.tsx +38 -5
- package/src/components/tooltip/tooltip.tsx +17 -17
- package/src/components/tree-multi-select/index.ts +2 -0
- package/src/components/tree-multi-select/tree-multi-select.test.tsx +137 -3
- package/src/components/tree-multi-select/tree-multi-select.tsx +130 -332
- package/src/components/tree-select/index.ts +7 -1
- package/src/components/tree-select/tree-popover.tsx +484 -0
- package/src/components/tree-select/tree-select.test.tsx +93 -1
- package/src/components/tree-select/tree-select.tsx +117 -415
- package/src/icon-stroke.test.tsx +114 -0
- package/src/index.ts +71 -0
- package/src/lib/as-child.ts +1 -1
- package/src/lib/cn.test.ts +14 -2
- package/src/lib/cutout.test.ts +37 -0
- package/src/lib/cutout.ts +56 -0
- package/src/lib/dev-warn.test.ts +89 -0
- package/src/lib/dev-warn.ts +61 -12
- package/src/lib/file-kind-icons.tsx +29 -0
- package/src/lib/file-queue-summary.test.ts +323 -0
- package/src/lib/file-queue-summary.ts +239 -0
- package/src/lib/file-queue.ts +493 -0
- package/src/lib/files.test.ts +72 -0
- package/src/lib/files.ts +211 -0
- package/src/lib/focus-styles.test.ts +97 -1
- package/src/lib/focus-styles.ts +153 -9
- package/src/lib/gap.ts +17 -0
- package/src/lib/graphemes.test.ts +26 -0
- package/src/lib/graphemes.ts +19 -0
- package/src/lib/icons.test.ts +22 -0
- package/src/lib/icons.ts +40 -0
- package/src/lib/image-file.test.ts +18 -0
- package/src/lib/image-file.ts +21 -0
- package/src/lib/merge-refs.test.tsx +79 -0
- package/src/lib/merge-refs.ts +58 -11
- package/src/lib/motion/animate.test.ts +114 -0
- package/src/lib/motion/animate.ts +88 -0
- package/src/lib/motion/easing.test.ts +57 -0
- package/src/lib/motion/easing.ts +107 -0
- package/src/lib/motion/gesture.test.ts +183 -0
- package/src/lib/motion/gesture.ts +300 -0
- package/src/lib/motion/morph.test.ts +93 -0
- package/src/lib/motion/morph.ts +88 -0
- package/src/lib/motion/physics.test.ts +75 -0
- package/src/lib/motion/physics.ts +61 -0
- package/src/lib/motion/rect.test.ts +52 -0
- package/src/lib/motion/rect.ts +67 -0
- package/src/lib/motion/reduced-motion.test.ts +57 -0
- package/src/lib/motion/reduced-motion.ts +34 -0
- package/src/lib/motion/spring.test.ts +93 -0
- package/src/lib/motion/spring.ts +143 -0
- package/src/lib/motion/tokens.ts +48 -0
- package/src/lib/motion/use-gesture.test.tsx +111 -0
- package/src/lib/motion/use-gesture.ts +133 -0
- package/src/lib/open-file.test.ts +275 -0
- package/src/lib/open-file.ts +351 -0
- package/src/lib/open-index.test.tsx +95 -0
- package/src/lib/open-index.tsx +90 -0
- package/src/lib/overlay-layer.test.tsx +32 -13
- package/src/lib/overlay-layer.tsx +25 -3
- package/src/lib/radius.ts +17 -0
- package/src/lib/ratio.test.ts +31 -0
- package/src/lib/ratio.ts +26 -0
- package/src/lib/save-file.test.ts +91 -0
- package/src/lib/save-file.ts +91 -0
- package/src/lib/select-data.test.tsx +123 -0
- package/src/lib/select-data.ts +130 -44
- package/src/lib/tree-data.ts +9 -4
- package/src/lib/typography-size.ts +28 -8
- package/src/lib/use-container-query.ts +4 -4
- package/src/lib/use-debounced.test.ts +105 -0
- package/src/lib/use-debounced.ts +44 -0
- package/src/lib/use-disclosure.ts +6 -1
- package/src/lib/use-document-visibility.test.tsx +46 -0
- package/src/lib/use-document-visibility.ts +37 -0
- package/src/lib/use-element-size.test.ts +142 -0
- package/src/lib/use-element-size.ts +87 -0
- package/src/lib/use-file-queue.test.tsx +774 -0
- package/src/lib/use-file-queue.ts +114 -0
- package/src/lib/use-hotkey.test.tsx +667 -0
- package/src/lib/use-hotkey.ts +562 -0
- package/src/lib/use-hydrated.test.tsx +43 -0
- package/src/lib/use-hydrated.ts +27 -0
- package/src/lib/use-in-view.test.ts +113 -0
- package/src/lib/use-in-view.ts +69 -0
- package/src/lib/use-now.test.tsx +65 -0
- package/src/lib/use-now.ts +37 -14
- package/src/lib/use-object-url.test.ts +195 -0
- package/src/lib/use-object-url.ts +108 -0
- package/src/lib/use-uncontrolled.test.ts +34 -2
- package/src/lib/use-uncontrolled.ts +7 -2
- package/src/test-setup.ts +65 -1
- package/src/theme.css +184 -16
- package/src/theme.forced-colors.test.tsx +152 -0
- package/src/theme.test.ts +34 -0
- package/src/visually-hidden-containment.test.tsx +32 -0
- package/dist/chunk-2GILNBZW.js +0 -31
- package/dist/chunk-2GILNBZW.js.map +0 -1
- package/dist/chunk-2NNZHVKD.js.map +0 -1
- package/dist/chunk-4NNGTNPV.js.map +0 -1
- package/dist/chunk-64T6Z7BA.js.map +0 -1
- package/dist/chunk-A6MYJTJI.js.map +0 -1
- package/dist/chunk-AIQG7IIT.js.map +0 -1
- package/dist/chunk-BEL75C7N.js.map +0 -1
- package/dist/chunk-CHTN5AHI.js.map +0 -1
- package/dist/chunk-CSCVTESP.js.map +0 -1
- package/dist/chunk-CTSO6V72.js.map +0 -1
- package/dist/chunk-CYWMES5P.js.map +0 -1
- package/dist/chunk-CZEKZ5HR.js.map +0 -1
- package/dist/chunk-DBTJEBMO.js +0 -291
- package/dist/chunk-DBTJEBMO.js.map +0 -1
- package/dist/chunk-FAOBC4IS.js.map +0 -1
- package/dist/chunk-FOMR74VE.js.map +0 -1
- package/dist/chunk-GCGX4FEF.js.map +0 -1
- package/dist/chunk-HCYULRWT.js.map +0 -1
- package/dist/chunk-I4SQQIP5.js.map +0 -1
- package/dist/chunk-IG7FBZVM.js.map +0 -1
- package/dist/chunk-INJUILCN.js +0 -31
- package/dist/chunk-INJUILCN.js.map +0 -1
- package/dist/chunk-IRXZHLUL.js.map +0 -1
- package/dist/chunk-K5UWVH6P.js.map +0 -1
- package/dist/chunk-LM6F6DLR.js.map +0 -1
- package/dist/chunk-MQO42HZL.js +0 -223
- package/dist/chunk-MQO42HZL.js.map +0 -1
- package/dist/chunk-OC7I2CTA.js +0 -8
- package/dist/chunk-OC7I2CTA.js.map +0 -1
- package/dist/chunk-OGJFDNIS.js.map +0 -1
- package/dist/chunk-P3XMBETI.js.map +0 -1
- package/dist/chunk-PINENGML.js.map +0 -1
- package/dist/chunk-PS2PZFXH.js +0 -84
- package/dist/chunk-PS2PZFXH.js.map +0 -1
- package/dist/chunk-QIDAXFKK.js.map +0 -1
- package/dist/chunk-RIP5G47F.js.map +0 -1
- package/dist/chunk-RKYXG6X7.js.map +0 -1
- package/dist/chunk-SVKU3GUN.js.map +0 -1
- package/dist/chunk-TBTSEPGP.js.map +0 -1
- package/dist/chunk-TWGCWKRV.js +0 -44
- package/dist/chunk-TWGCWKRV.js.map +0 -1
- package/dist/chunk-UJZIF2BA.js.map +0 -1
- package/dist/chunk-UVYTJQTJ.js +0 -14
- package/dist/chunk-UVYTJQTJ.js.map +0 -1
- package/dist/chunk-VZBUQNLX.js.map +0 -1
- package/dist/chunk-VZH6TS7M.js.map +0 -1
- package/dist/chunk-WJOHNCYY.js.map +0 -1
- package/dist/chunk-WZB6LPQI.js +0 -47
- package/dist/chunk-WZB6LPQI.js.map +0 -1
- package/dist/chunk-YKUCSV34.js.map +0 -1
- package/dist/chunk-YQHOKMSV.js.map +0 -1
- package/dist/chunk-YW6Q6ERX.js.map +0 -1
- package/dist/chunk-YWRBG23W.js.map +0 -1
- package/dist/chunk-Z43YWH4R.js.map +0 -1
- package/dist/chunk-Z6RPMRFH.js.map +0 -1
- package/dist/components/slider/sliderThumb.d.ts +0 -1
- package/dist/components/slider/sliderThumb.d.ts.map +0 -1
- package/src/components/slider/sliderThumb.tsx +0 -0
|
@@ -0,0 +1,2532 @@
|
|
|
1
|
+
import { act, fireEvent, render, screen, waitFor, within } from "@testing-library/react"
|
|
2
|
+
import type { ComponentProps, ReactNode } from "react"
|
|
3
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"
|
|
4
|
+
import { IntlProvider } from "../../lib/intl"
|
|
5
|
+
import { LinkComponentProvider } from "../../lib/link-component"
|
|
6
|
+
import { createSpotlight } from "./create-spotlight"
|
|
7
|
+
import { Spotlight } from "./spotlight"
|
|
8
|
+
import { staticSource } from "./static-source"
|
|
9
|
+
import type { SpotlightItem, SpotlightSource } from "./types"
|
|
10
|
+
|
|
11
|
+
const sleep = (ms: number) => new Promise<void>((resolve) => setTimeout(resolve, ms))
|
|
12
|
+
|
|
13
|
+
const user = (id: string, title = id): SpotlightItem => ({
|
|
14
|
+
id,
|
|
15
|
+
title,
|
|
16
|
+
link: { href: `/users/${id}` },
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
/** A one-shot source answering after `latency` ms, with no debounce. */
|
|
20
|
+
const delayed = (
|
|
21
|
+
id: string,
|
|
22
|
+
items: SpotlightItem[],
|
|
23
|
+
latency = 0,
|
|
24
|
+
extra: Partial<SpotlightSource<string>> = {},
|
|
25
|
+
): SpotlightSource<string> => ({
|
|
26
|
+
id,
|
|
27
|
+
label: id[0]?.toUpperCase() + id.slice(1),
|
|
28
|
+
debounce: 0,
|
|
29
|
+
search: async (query) => {
|
|
30
|
+
await sleep(latency)
|
|
31
|
+
return items.filter((item) => item.title.toLowerCase().includes(query.toLowerCase()))
|
|
32
|
+
},
|
|
33
|
+
...extra,
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
/** A row matching "a" from the first render: something on screen, which skeletons wait before covering. */
|
|
37
|
+
const onScreen = staticSource({
|
|
38
|
+
id: "shown",
|
|
39
|
+
label: "Shown",
|
|
40
|
+
items: [{ id: "always", title: "Always here" }],
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
const input = () => screen.getByRole("combobox")
|
|
44
|
+
const type = (query: string) => fireEvent.change(input(), { target: { value: query } })
|
|
45
|
+
const press = (key: string, init: Partial<KeyboardEventInit> = {}) =>
|
|
46
|
+
fireEvent.keyDown(input(), { key, ...init })
|
|
47
|
+
const highlightedRow = () => document.querySelector("[role=option][data-highlighted]")
|
|
48
|
+
/** The groups' skeleton rows, one 32px circle each, not the list's filler under them. */
|
|
49
|
+
const skeletonRows = (root: Element) =>
|
|
50
|
+
[...root.querySelectorAll(".animate-pulse.rounded-full")].filter(
|
|
51
|
+
(circle) => !circle.closest("[data-spotlight-filler]"),
|
|
52
|
+
)
|
|
53
|
+
/** zag reports a highlight change after the event, so wait for it to land. */
|
|
54
|
+
const highlighted = (text: string) =>
|
|
55
|
+
waitFor(() => expect(highlightedRow()?.textContent).toBe(text))
|
|
56
|
+
|
|
57
|
+
beforeEach(() => {
|
|
58
|
+
localStorage.clear()
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
afterEach(() => {
|
|
62
|
+
vi.useRealTimers()
|
|
63
|
+
vi.unstubAllGlobals()
|
|
64
|
+
vi.restoreAllMocks()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
describe("SpotlightProvider", () => {
|
|
68
|
+
it("opens and closes on the hotkey", async () => {
|
|
69
|
+
const { SpotlightProvider } = createSpotlight({ sources: [], hotkey: "mod+k" })
|
|
70
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
71
|
+
expect(screen.queryByRole("dialog")).toBeNull()
|
|
72
|
+
|
|
73
|
+
fireEvent.keyDown(window, { key: "k", ctrlKey: true })
|
|
74
|
+
expect(await screen.findByRole("dialog")).toBeTruthy()
|
|
75
|
+
expect(screen.getByTestId("spotlight-input")).toBe(input())
|
|
76
|
+
|
|
77
|
+
fireEvent.keyDown(window, { key: "k", ctrlKey: true })
|
|
78
|
+
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull())
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
it("binds no hotkey with hotkey: false", () => {
|
|
82
|
+
const { SpotlightProvider } = createSpotlight({ sources: [], hotkey: false })
|
|
83
|
+
render(<SpotlightProvider />)
|
|
84
|
+
fireEvent.keyDown(window, { key: "k", ctrlKey: true })
|
|
85
|
+
expect(screen.queryByRole("dialog")).toBeNull()
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
it("closes on Esc", async () => {
|
|
89
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [] })
|
|
90
|
+
render(<SpotlightProvider />)
|
|
91
|
+
act(() => spotlight.open())
|
|
92
|
+
await screen.findByRole("combobox")
|
|
93
|
+
// The dialog's dismissable layer arms over a frame and a timeout.
|
|
94
|
+
await act(() => sleep(150))
|
|
95
|
+
fireEvent.keyDown(input(), { key: "Escape" })
|
|
96
|
+
await waitFor(() => expect(spotlight.getState().open).toBe(false))
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it("streams groups in as their sources answer", async () => {
|
|
100
|
+
const people = delayed("people", [user("marvin", "Marvin")], 10)
|
|
101
|
+
async function* search(query: string) {
|
|
102
|
+
yield { id: "e1", title: `${query} event 1` }
|
|
103
|
+
await sleep(30)
|
|
104
|
+
yield [{ id: "e2", title: `${query} event 2` }]
|
|
105
|
+
}
|
|
106
|
+
const events: SpotlightSource<"events"> = { id: "events", label: "Events", debounce: 0, search }
|
|
107
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people, events] })
|
|
108
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
109
|
+
act(() => spotlight.open())
|
|
110
|
+
await screen.findByRole("combobox")
|
|
111
|
+
type("mar")
|
|
112
|
+
|
|
113
|
+
expect(await screen.findByTestId("spotlight-item-events-e1")).toBeTruthy()
|
|
114
|
+
expect(screen.queryByTestId("spotlight-item-events-e2")).toBeNull()
|
|
115
|
+
expect(await screen.findByTestId("spotlight-item-people-marvin")).toBeTruthy()
|
|
116
|
+
expect(await screen.findByTestId("spotlight-item-events-e2")).toBeTruthy()
|
|
117
|
+
|
|
118
|
+
// Groups keep the sources' order, whichever answered first.
|
|
119
|
+
const labels = within(screen.getByTestId("spotlight-list"))
|
|
120
|
+
.getAllByRole("presentation")
|
|
121
|
+
.map((label) => label.textContent)
|
|
122
|
+
expect(labels).toEqual(["People", "Events"])
|
|
123
|
+
})
|
|
124
|
+
|
|
125
|
+
it("ends a streaming group with three skeleton rows, and no spinner", async () => {
|
|
126
|
+
let finish = () => {}
|
|
127
|
+
async function* search() {
|
|
128
|
+
yield { id: "a", title: "A" }
|
|
129
|
+
await new Promise<void>((resolve) => {
|
|
130
|
+
finish = resolve
|
|
131
|
+
})
|
|
132
|
+
}
|
|
133
|
+
const stream: SpotlightSource<"stream"> = { id: "stream", label: "Stream", debounce: 0, search }
|
|
134
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [stream] })
|
|
135
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
136
|
+
act(() => spotlight.open({ query: "a" }))
|
|
137
|
+
await screen.findByTestId("spotlight-item-stream-a")
|
|
138
|
+
const list = screen.getByTestId("spotlight-list")
|
|
139
|
+
const group = () => list.querySelector("[data-status]") as Element
|
|
140
|
+
await waitFor(() => expect(group().getAttribute("data-status")).toBe("streaming"))
|
|
141
|
+
await waitFor(() => expect(skeletonRows(group())).toHaveLength(3))
|
|
142
|
+
// After the row it follows, hidden from assistive tech.
|
|
143
|
+
const tail = skeletonRows(group())[0]?.closest(".min-h-11")
|
|
144
|
+
expect(tail?.getAttribute("aria-hidden")).toBe("true")
|
|
145
|
+
expect(tail?.previousElementSibling).toBe(screen.getByTestId("spotlight-item-stream-a"))
|
|
146
|
+
expect(list.querySelector(".animate-spin")).toBeNull()
|
|
147
|
+
act(() => finish())
|
|
148
|
+
await waitFor(() => expect(group().getAttribute("data-status")).toBe("success"))
|
|
149
|
+
expect(skeletonRows(list)).toHaveLength(0)
|
|
150
|
+
})
|
|
151
|
+
|
|
152
|
+
it("waits out skeletonDelay before a streaming group's tail", async () => {
|
|
153
|
+
vi.useFakeTimers({
|
|
154
|
+
toFake: [
|
|
155
|
+
"setTimeout",
|
|
156
|
+
"clearTimeout",
|
|
157
|
+
"requestAnimationFrame",
|
|
158
|
+
"cancelAnimationFrame",
|
|
159
|
+
"performance",
|
|
160
|
+
],
|
|
161
|
+
})
|
|
162
|
+
async function* search() {
|
|
163
|
+
yield { id: "a", title: "A" }
|
|
164
|
+
await sleep(1000)
|
|
165
|
+
yield { id: "b", title: "B" }
|
|
166
|
+
}
|
|
167
|
+
const stream: SpotlightSource<"stream"> = { id: "stream", label: "Stream", debounce: 0, search }
|
|
168
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
169
|
+
sources: [stream],
|
|
170
|
+
skeletonDelay: 120,
|
|
171
|
+
})
|
|
172
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
173
|
+
act(() => spotlight.open())
|
|
174
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
175
|
+
type("a")
|
|
176
|
+
// The store publishes on the next frame.
|
|
177
|
+
await act(() => vi.advanceTimersByTimeAsync(20))
|
|
178
|
+
expect(screen.getByTestId("spotlight-item-stream-a")).toBeTruthy()
|
|
179
|
+
const list = screen.getByTestId("spotlight-list")
|
|
180
|
+
await act(() => vi.advanceTimersByTimeAsync(100))
|
|
181
|
+
expect(skeletonRows(list)).toHaveLength(0)
|
|
182
|
+
await act(() => vi.advanceTimersByTimeAsync(30))
|
|
183
|
+
expect(skeletonRows(list)).toHaveLength(3)
|
|
184
|
+
await act(() => vi.advanceTimersByTimeAsync(1000))
|
|
185
|
+
expect(screen.getByTestId("spotlight-item-stream-b")).toBeTruthy()
|
|
186
|
+
expect(skeletonRows(list)).toHaveLength(0)
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
it("never flashes the tail of a stream that ends within skeletonDelay", async () => {
|
|
190
|
+
vi.useFakeTimers({
|
|
191
|
+
toFake: [
|
|
192
|
+
"setTimeout",
|
|
193
|
+
"clearTimeout",
|
|
194
|
+
"requestAnimationFrame",
|
|
195
|
+
"cancelAnimationFrame",
|
|
196
|
+
"performance",
|
|
197
|
+
],
|
|
198
|
+
})
|
|
199
|
+
async function* search() {
|
|
200
|
+
yield { id: "a", title: "A" }
|
|
201
|
+
await sleep(60)
|
|
202
|
+
yield { id: "b", title: "B" }
|
|
203
|
+
}
|
|
204
|
+
const stream: SpotlightSource<"stream"> = { id: "stream", label: "Stream", debounce: 0, search }
|
|
205
|
+
// With a row already on screen: alone, the skeletons show at once (see "list height").
|
|
206
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [onScreen, stream] })
|
|
207
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
208
|
+
act(() => spotlight.open())
|
|
209
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
210
|
+
type("a")
|
|
211
|
+
const list = screen.getByTestId("spotlight-list")
|
|
212
|
+
const seen = new Set<boolean>()
|
|
213
|
+
for (const _ of Array.from({ length: 20 })) {
|
|
214
|
+
await act(() => vi.advanceTimersByTimeAsync(10))
|
|
215
|
+
seen.add(skeletonRows(list).length > 0)
|
|
216
|
+
}
|
|
217
|
+
expect(seen.has(true)).toBe(false)
|
|
218
|
+
expect(screen.getByTestId("spotlight-item-stream-b")).toBeTruthy()
|
|
219
|
+
})
|
|
220
|
+
|
|
221
|
+
it("dims the previous query's rows while the source re-runs, with no skeleton tail", async () => {
|
|
222
|
+
const answers: ((items: SpotlightItem[]) => void)[] = []
|
|
223
|
+
const people: SpotlightSource<"people"> = {
|
|
224
|
+
id: "people",
|
|
225
|
+
label: "People",
|
|
226
|
+
debounce: 0,
|
|
227
|
+
search: () => new Promise<SpotlightItem[]>((resolve) => answers.push(resolve)),
|
|
228
|
+
}
|
|
229
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
230
|
+
sources: [people],
|
|
231
|
+
skeletonDelay: 0,
|
|
232
|
+
})
|
|
233
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
234
|
+
act(() => spotlight.open({ query: "m" }))
|
|
235
|
+
act(() => answers.shift()?.([user("marvin", "Marvin"), user("mary", "Mary")]))
|
|
236
|
+
await screen.findByTestId("spotlight-item-people-marvin")
|
|
237
|
+
const list = screen.getByTestId("spotlight-list")
|
|
238
|
+
const group = () => list.querySelector("[data-status]") as Element
|
|
239
|
+
expect(group().hasAttribute("data-stale")).toBe(false)
|
|
240
|
+
|
|
241
|
+
type("ma")
|
|
242
|
+
await waitFor(() => expect(group().getAttribute("data-status")).toBe("loading"))
|
|
243
|
+
// Even with no delay to wait out: the rows stay, dimmed, and nothing trails them.
|
|
244
|
+
await act(() => sleep(20))
|
|
245
|
+
expect(group().hasAttribute("data-stale")).toBe(true)
|
|
246
|
+
expect(group().className).toContain("data-stale:[&>[data-part=item]]:opacity-60")
|
|
247
|
+
expect(screen.getByTestId("spotlight-item-people-marvin")).toBeTruthy()
|
|
248
|
+
expect(screen.getByTestId("spotlight-item-people-mary")).toBeTruthy()
|
|
249
|
+
expect(skeletonRows(list)).toHaveLength(0)
|
|
250
|
+
|
|
251
|
+
act(() => answers.shift()?.([user("marvin", "Marvin")]))
|
|
252
|
+
await waitFor(() => expect(group().getAttribute("data-status")).toBe("success"))
|
|
253
|
+
expect(group().hasAttribute("data-stale")).toBe(false)
|
|
254
|
+
expect(screen.queryByTestId("spotlight-item-people-mary")).toBeNull()
|
|
255
|
+
})
|
|
256
|
+
|
|
257
|
+
it("lays a skeleton row out with an item row's classes", async () => {
|
|
258
|
+
async function* search() {
|
|
259
|
+
yield { id: "a", title: "A" }
|
|
260
|
+
await new Promise<void>(() => {})
|
|
261
|
+
}
|
|
262
|
+
const stream: SpotlightSource<"stream"> = { id: "stream", label: "Stream", debounce: 0, search }
|
|
263
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [stream] })
|
|
264
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
265
|
+
act(() => spotlight.open({ query: "a" }))
|
|
266
|
+
const item = await screen.findByTestId("spotlight-item-stream-a")
|
|
267
|
+
await waitFor(() => expect(skeletonRows(screen.getByTestId("spotlight-list"))).toHaveLength(3))
|
|
268
|
+
const skeleton = skeletonRows(screen.getByTestId("spotlight-list"))[0]?.closest(
|
|
269
|
+
".min-h-11",
|
|
270
|
+
) as Element
|
|
271
|
+
// jsdom does no layout: the shared row classes are what keep the heights equal.
|
|
272
|
+
const rowClasses = ["min-h-11", "gap-3", "px-2.5", "py-1.5"]
|
|
273
|
+
for (const name of rowClasses) {
|
|
274
|
+
expect(item.classList.contains(name)).toBe(true)
|
|
275
|
+
expect(skeleton.classList.contains(name)).toBe(true)
|
|
276
|
+
}
|
|
277
|
+
// The circle sits in a slot as wide as an item's icon.
|
|
278
|
+
expect(skeleton.firstElementChild?.classList.contains("size-8")).toBe(true)
|
|
279
|
+
})
|
|
280
|
+
|
|
281
|
+
it("shows skeleton rows only once a source has loaded longer than skeletonDelay", async () => {
|
|
282
|
+
vi.useFakeTimers({
|
|
283
|
+
toFake: [
|
|
284
|
+
"setTimeout",
|
|
285
|
+
"clearTimeout",
|
|
286
|
+
"requestAnimationFrame",
|
|
287
|
+
"cancelAnimationFrame",
|
|
288
|
+
"performance",
|
|
289
|
+
],
|
|
290
|
+
})
|
|
291
|
+
const slow = delayed("slow", [user("a", "Alpha")], 500, { debounce: 150 })
|
|
292
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
293
|
+
sources: [onScreen, slow],
|
|
294
|
+
skeletonDelay: 120,
|
|
295
|
+
})
|
|
296
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
297
|
+
act(() => spotlight.open())
|
|
298
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
299
|
+
type("a")
|
|
300
|
+
const list = screen.getByTestId("spotlight-list")
|
|
301
|
+
const skeletons = () => list.querySelectorAll(".animate-pulse")
|
|
302
|
+
|
|
303
|
+
// The debounce doesn't count: 150ms, then 100ms of search, still nothing.
|
|
304
|
+
await act(() => vi.advanceTimersByTimeAsync(250))
|
|
305
|
+
expect(within(list).queryByText("Slow")).toBeNull()
|
|
306
|
+
|
|
307
|
+
await act(() => vi.advanceTimersByTimeAsync(30))
|
|
308
|
+
expect(within(list).getByText("Slow")).toBeTruthy()
|
|
309
|
+
expect(skeletons().length).toBeGreaterThan(0)
|
|
310
|
+
|
|
311
|
+
await act(() => vi.advanceTimersByTimeAsync(400))
|
|
312
|
+
expect(screen.getByTestId("spotlight-item-slow-a")).toBeTruthy()
|
|
313
|
+
expect(within(list).queryAllByText("Slow")).toHaveLength(1)
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
it("never shows skeleton rows for a source answering within skeletonDelay", async () => {
|
|
317
|
+
vi.useFakeTimers({
|
|
318
|
+
toFake: [
|
|
319
|
+
"setTimeout",
|
|
320
|
+
"clearTimeout",
|
|
321
|
+
"requestAnimationFrame",
|
|
322
|
+
"cancelAnimationFrame",
|
|
323
|
+
"performance",
|
|
324
|
+
],
|
|
325
|
+
})
|
|
326
|
+
const fast = delayed("fast", [user("a", "Alpha")], 80, { debounce: 150 })
|
|
327
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [onScreen, fast] })
|
|
328
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
329
|
+
act(() => spotlight.open())
|
|
330
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
331
|
+
type("a")
|
|
332
|
+
const list = screen.getByTestId("spotlight-list")
|
|
333
|
+
const seen = new Set<boolean>()
|
|
334
|
+
for (const _ of Array.from({ length: 30 })) {
|
|
335
|
+
await act(() => vi.advanceTimersByTimeAsync(10))
|
|
336
|
+
// The groups' skeletons: the list's filler fills only a height held
|
|
337
|
+
// over shorter rows, which a first keystroke never holds.
|
|
338
|
+
seen.add(skeletonRows(list).length > 0)
|
|
339
|
+
}
|
|
340
|
+
expect(seen.has(true)).toBe(false)
|
|
341
|
+
expect(screen.getByTestId("spotlight-item-fast-a")).toBeTruthy()
|
|
342
|
+
})
|
|
343
|
+
|
|
344
|
+
it("keeps the items received before an error, and retries the source", async () => {
|
|
345
|
+
let calls = 0
|
|
346
|
+
async function* search() {
|
|
347
|
+
calls += 1
|
|
348
|
+
yield { id: "a", title: "Alpha" }
|
|
349
|
+
if (calls === 1) throw new Error("boom")
|
|
350
|
+
yield { id: "b", title: "Beta" }
|
|
351
|
+
}
|
|
352
|
+
const flaky: SpotlightSource<"flaky"> = { id: "flaky", label: "Flaky", debounce: 0, search }
|
|
353
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [flaky] })
|
|
354
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
355
|
+
act(() => spotlight.open({ query: "a" }))
|
|
356
|
+
|
|
357
|
+
const retry = await screen.findByRole("option", { name: /Couldn't load Flaky/ })
|
|
358
|
+
expect(screen.getByTestId("spotlight-item-flaky-a")).toBeTruthy()
|
|
359
|
+
|
|
360
|
+
fireEvent.click(retry)
|
|
361
|
+
expect(await screen.findByTestId("spotlight-item-flaky-b")).toBeTruthy()
|
|
362
|
+
expect(screen.queryByRole("option", { name: /Couldn't load/ })).toBeNull()
|
|
363
|
+
expect(calls).toBe(2)
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
it("retries from the keyboard too", async () => {
|
|
367
|
+
let calls = 0
|
|
368
|
+
const failing: SpotlightSource<"failing"> = {
|
|
369
|
+
id: "failing",
|
|
370
|
+
label: "Failing",
|
|
371
|
+
debounce: 0,
|
|
372
|
+
search: () => {
|
|
373
|
+
calls += 1
|
|
374
|
+
throw new Error("down")
|
|
375
|
+
},
|
|
376
|
+
}
|
|
377
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [failing] })
|
|
378
|
+
render(<SpotlightProvider />)
|
|
379
|
+
act(() => spotlight.open({ query: "x" }))
|
|
380
|
+
await screen.findByRole("option", { name: /Couldn't load Failing/ })
|
|
381
|
+
press("Enter")
|
|
382
|
+
await waitFor(() => expect(calls).toBe(2))
|
|
383
|
+
})
|
|
384
|
+
|
|
385
|
+
it("shows the empty state once every source has settled", async () => {
|
|
386
|
+
const people = delayed("people", [user("marvin", "Marvin")], 20)
|
|
387
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people] })
|
|
388
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
389
|
+
act(() => spotlight.open())
|
|
390
|
+
await screen.findByRole("combobox")
|
|
391
|
+
type("zz")
|
|
392
|
+
const list = screen.getByTestId("spotlight-list")
|
|
393
|
+
expect(within(list).queryByText("No results for “zz”")).toBeNull()
|
|
394
|
+
expect(await within(list).findByText("No results for “zz”")).toBeTruthy()
|
|
395
|
+
})
|
|
396
|
+
|
|
397
|
+
it("draws the empty state's icon, message and hint", async () => {
|
|
398
|
+
const people = delayed("people", [user("marvin", "Marvin")])
|
|
399
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people] })
|
|
400
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
401
|
+
act(() => spotlight.open({ query: "zz" }))
|
|
402
|
+
// The live region says it too: look in the list.
|
|
403
|
+
const message = await within(await screen.findByTestId("spotlight-list")).findByText(
|
|
404
|
+
"No results for “zz”",
|
|
405
|
+
)
|
|
406
|
+
const empty = message.parentElement as HTMLElement
|
|
407
|
+
expect(empty.querySelector("svg")).toBeTruthy()
|
|
408
|
+
expect(within(empty).getByText("Try fewer or different words")).toBeTruthy()
|
|
409
|
+
expect(within(empty).queryByText("to widen the search")).toBeNull()
|
|
410
|
+
})
|
|
411
|
+
|
|
412
|
+
it("says ⌫ widens the search while scoped", async () => {
|
|
413
|
+
const people = delayed("people", [user("marvin", "Marvin")])
|
|
414
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
415
|
+
sources: [people],
|
|
416
|
+
translations: { noResultsScopedHint: "pour élargir" },
|
|
417
|
+
})
|
|
418
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
419
|
+
act(() => spotlight.open({ path: [{ source: "people" }], query: "zz" }))
|
|
420
|
+
// The live region says it too: look in the list.
|
|
421
|
+
const message = await within(await screen.findByTestId("spotlight-list")).findByText(
|
|
422
|
+
"No results for “zz”",
|
|
423
|
+
)
|
|
424
|
+
const empty = message.parentElement as HTMLElement
|
|
425
|
+
const hint = within(empty).getByText("pour élargir")
|
|
426
|
+
// After the ⌫ key, drawn by Kbd.
|
|
427
|
+
expect(hint.querySelector("kbd")).toBeTruthy()
|
|
428
|
+
expect(within(empty).queryByText("Try fewer or different words")).toBeNull()
|
|
429
|
+
})
|
|
430
|
+
|
|
431
|
+
it("drops the empty state's icon for `icons.empty: null`", async () => {
|
|
432
|
+
const people = delayed("people", [user("marvin", "Marvin")])
|
|
433
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
434
|
+
sources: [people],
|
|
435
|
+
icons: { empty: null },
|
|
436
|
+
})
|
|
437
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
438
|
+
act(() => spotlight.open({ query: "zz" }))
|
|
439
|
+
const list = await screen.findByTestId("spotlight-list")
|
|
440
|
+
const empty = (await within(list).findByText("No results for “zz”")).parentElement
|
|
441
|
+
expect(empty?.querySelector("svg")).toBeNull()
|
|
442
|
+
expect(within(empty as HTMLElement).getByText("Try fewer or different words")).toBeTruthy()
|
|
443
|
+
})
|
|
444
|
+
|
|
445
|
+
it("lets the empty state's children replace its icon, message and hint", async () => {
|
|
446
|
+
const people = delayed("people", [user("marvin", "Marvin")])
|
|
447
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people] })
|
|
448
|
+
render(
|
|
449
|
+
<SpotlightProvider>
|
|
450
|
+
<Spotlight.Root>
|
|
451
|
+
<Spotlight.Input />
|
|
452
|
+
<Spotlight.List>
|
|
453
|
+
{(groups) => groups.map((group) => <Spotlight.Group key={group.key} group={group} />)}
|
|
454
|
+
</Spotlight.List>
|
|
455
|
+
<Spotlight.Empty testId="empty">Nothing here</Spotlight.Empty>
|
|
456
|
+
</Spotlight.Root>
|
|
457
|
+
</SpotlightProvider>,
|
|
458
|
+
)
|
|
459
|
+
act(() => spotlight.open({ query: "zz" }))
|
|
460
|
+
const empty = await screen.findByTestId("empty")
|
|
461
|
+
expect(empty.textContent).toBe("Nothing here")
|
|
462
|
+
expect(empty.querySelector("svg")).toBeNull()
|
|
463
|
+
})
|
|
464
|
+
|
|
465
|
+
it("walks the rows with ↑↓ and runs the highlighted one with ↵", async () => {
|
|
466
|
+
const onSelect = vi.fn()
|
|
467
|
+
const commands = staticSource({
|
|
468
|
+
id: "commands",
|
|
469
|
+
label: "Commands",
|
|
470
|
+
items: [
|
|
471
|
+
{ id: "one", title: "Run one", onSelect },
|
|
472
|
+
{ id: "two", title: "Run two", onSelect: ({ close }) => close() },
|
|
473
|
+
{ id: "three", title: "Run three", onSelect, closeOnSelect: false },
|
|
474
|
+
],
|
|
475
|
+
})
|
|
476
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [commands] })
|
|
477
|
+
render(<SpotlightProvider />)
|
|
478
|
+
act(() => spotlight.open({ query: "run" }))
|
|
479
|
+
await screen.findByTestId("spotlight-item-commands-one")
|
|
480
|
+
|
|
481
|
+
await highlighted("Run one")
|
|
482
|
+
press("ArrowDown")
|
|
483
|
+
await highlighted("Run two")
|
|
484
|
+
press("ArrowDown")
|
|
485
|
+
await highlighted("Run three")
|
|
486
|
+
press("Enter")
|
|
487
|
+
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ query: "run" }))
|
|
488
|
+
expect(spotlight.getState().open).toBe(true)
|
|
489
|
+
|
|
490
|
+
press("ArrowUp")
|
|
491
|
+
await highlighted("Run two")
|
|
492
|
+
press("Enter")
|
|
493
|
+
expect(spotlight.getState().open).toBe(false)
|
|
494
|
+
})
|
|
495
|
+
|
|
496
|
+
it("keeps the highlighted row when a group arrives above it", async () => {
|
|
497
|
+
let release = () => {}
|
|
498
|
+
const first: SpotlightSource<"first"> = {
|
|
499
|
+
id: "first",
|
|
500
|
+
label: "First",
|
|
501
|
+
debounce: 0,
|
|
502
|
+
order: 0,
|
|
503
|
+
search: () =>
|
|
504
|
+
new Promise((resolve) => {
|
|
505
|
+
release = () => resolve([{ id: "late", title: "Late" }])
|
|
506
|
+
}),
|
|
507
|
+
}
|
|
508
|
+
const second = delayed("second", [user("x", "Xavier"), user("y", "Yvonne")], 0, { order: 1 })
|
|
509
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [first, second] })
|
|
510
|
+
render(<SpotlightProvider />)
|
|
511
|
+
act(() => spotlight.open({ query: "v" }))
|
|
512
|
+
await screen.findByTestId("spotlight-item-second-y")
|
|
513
|
+
press("ArrowDown")
|
|
514
|
+
await highlighted("Yvonne")
|
|
515
|
+
|
|
516
|
+
act(() => release())
|
|
517
|
+
await screen.findByTestId("spotlight-item-first-late")
|
|
518
|
+
expect(highlightedRow()?.textContent).toBe("Yvonne")
|
|
519
|
+
})
|
|
520
|
+
|
|
521
|
+
it("keeps the first row highlighted when a group arrives above it", async () => {
|
|
522
|
+
let release = () => {}
|
|
523
|
+
const first: SpotlightSource<"first"> = {
|
|
524
|
+
id: "first",
|
|
525
|
+
label: "First",
|
|
526
|
+
debounce: 0,
|
|
527
|
+
search: () =>
|
|
528
|
+
new Promise((resolve) => {
|
|
529
|
+
release = () => resolve([{ id: "late", title: "Late" }])
|
|
530
|
+
}),
|
|
531
|
+
}
|
|
532
|
+
const second = delayed("second", [user("x", "Xavier")], 0)
|
|
533
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [first, second] })
|
|
534
|
+
render(<SpotlightProvider />)
|
|
535
|
+
act(() => spotlight.open({ query: "a" }))
|
|
536
|
+
await screen.findByTestId("spotlight-item-second-x")
|
|
537
|
+
await highlighted("Xavier")
|
|
538
|
+
act(() => release())
|
|
539
|
+
await screen.findByTestId("spotlight-item-first-late")
|
|
540
|
+
expect(highlightedRow()?.textContent).toBe("Xavier")
|
|
541
|
+
})
|
|
542
|
+
})
|
|
543
|
+
|
|
544
|
+
describe("links", () => {
|
|
545
|
+
const RouterLink = ({ to, children, ...rest }: { to: string } & ComponentProps<"a">) => (
|
|
546
|
+
<a href={`/app${to}`} data-router-link {...rest}>
|
|
547
|
+
{children}
|
|
548
|
+
</a>
|
|
549
|
+
)
|
|
550
|
+
type Route = { to: string }
|
|
551
|
+
const routes = staticSource({
|
|
552
|
+
id: "pages",
|
|
553
|
+
label: "Pages",
|
|
554
|
+
items: [
|
|
555
|
+
{ id: "home", title: "Home", link: { to: "/home" } },
|
|
556
|
+
{ id: "about", title: "About", link: { to: "/about" } },
|
|
557
|
+
],
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
const withRouter = (children: ReactNode) => (
|
|
561
|
+
<LinkComponentProvider component={RouterLink}>{children}</LinkComponentProvider>
|
|
562
|
+
)
|
|
563
|
+
|
|
564
|
+
it("renders link rows as the provider's Link, spread with the link object", async () => {
|
|
565
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
566
|
+
sources: [routes],
|
|
567
|
+
navigate: (_: Route) => {},
|
|
568
|
+
})
|
|
569
|
+
render(withRouter(<SpotlightProvider />))
|
|
570
|
+
act(() => spotlight.open({ query: "home" }))
|
|
571
|
+
const row = await screen.findByTestId("spotlight-item-pages-home")
|
|
572
|
+
expect(row.tagName).toBe("A")
|
|
573
|
+
expect(row.getAttribute("href")).toBe("/app/home")
|
|
574
|
+
expect(row.getAttribute("role")).toBe("option")
|
|
575
|
+
expect(row.hasAttribute("data-router-link")).toBe(true)
|
|
576
|
+
})
|
|
577
|
+
|
|
578
|
+
it("falls back to a plain <a> without a LinkComponentProvider", async () => {
|
|
579
|
+
const people = staticSource({
|
|
580
|
+
id: "people",
|
|
581
|
+
label: "People",
|
|
582
|
+
items: [user("marvin", "Marvin")],
|
|
583
|
+
})
|
|
584
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people] })
|
|
585
|
+
render(<SpotlightProvider />)
|
|
586
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
587
|
+
const row = await screen.findByTestId("spotlight-item-people-marvin")
|
|
588
|
+
expect(row.tagName).toBe("A")
|
|
589
|
+
expect(row.getAttribute("href")).toBe("/users/marvin")
|
|
590
|
+
})
|
|
591
|
+
|
|
592
|
+
it("navigates through the factory's navigate on ↵ and on click", async () => {
|
|
593
|
+
const navigate = vi.fn((_: Route) => {})
|
|
594
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [routes], navigate })
|
|
595
|
+
render(withRouter(<SpotlightProvider />))
|
|
596
|
+
act(() => spotlight.open({ query: "home" }))
|
|
597
|
+
await screen.findByTestId("spotlight-item-pages-home")
|
|
598
|
+
press("Enter")
|
|
599
|
+
expect(navigate).toHaveBeenCalledWith({ to: "/home" })
|
|
600
|
+
expect(spotlight.getState().open).toBe(false)
|
|
601
|
+
|
|
602
|
+
act(() => spotlight.open({ query: "about" }))
|
|
603
|
+
const row = await screen.findByTestId("spotlight-item-pages-about")
|
|
604
|
+
const click = new MouseEvent("click", { bubbles: true, cancelable: true, button: 0 })
|
|
605
|
+
fireEvent(row, click)
|
|
606
|
+
expect(click.defaultPrevented).toBe(true)
|
|
607
|
+
expect(navigate).toHaveBeenLastCalledWith({ to: "/about" })
|
|
608
|
+
})
|
|
609
|
+
|
|
610
|
+
it("leaves a modified click to the browser", async () => {
|
|
611
|
+
const navigate = vi.fn((_: Route) => {})
|
|
612
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [routes], navigate })
|
|
613
|
+
render(withRouter(<SpotlightProvider />))
|
|
614
|
+
act(() => spotlight.open({ query: "home" }))
|
|
615
|
+
const row = await screen.findByTestId("spotlight-item-pages-home")
|
|
616
|
+
const click = new MouseEvent("click", { bubbles: true, cancelable: true, metaKey: true })
|
|
617
|
+
fireEvent(row, click)
|
|
618
|
+
expect(click.defaultPrevented).toBe(false)
|
|
619
|
+
expect(navigate).not.toHaveBeenCalled()
|
|
620
|
+
expect(spotlight.getState().open).toBe(true)
|
|
621
|
+
})
|
|
622
|
+
|
|
623
|
+
it("lets the provider's navigate override the factory's", async () => {
|
|
624
|
+
const factory = vi.fn((_: Route) => {})
|
|
625
|
+
const provider = vi.fn((_: Route) => {})
|
|
626
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
627
|
+
sources: [routes],
|
|
628
|
+
navigate: factory,
|
|
629
|
+
})
|
|
630
|
+
render(withRouter(<SpotlightProvider navigate={provider} />))
|
|
631
|
+
act(() => spotlight.open({ query: "home" }))
|
|
632
|
+
await screen.findByTestId("spotlight-item-pages-home")
|
|
633
|
+
press("Enter")
|
|
634
|
+
expect(provider).toHaveBeenCalledWith({ to: "/home" })
|
|
635
|
+
expect(factory).not.toHaveBeenCalled()
|
|
636
|
+
})
|
|
637
|
+
|
|
638
|
+
it("opens the row's rendered href in a new tab on ⌘↵ / Ctrl+↵, and stays open", async () => {
|
|
639
|
+
const open = vi.fn()
|
|
640
|
+
vi.stubGlobal("open", open)
|
|
641
|
+
const navigate = vi.fn((_: Route) => {})
|
|
642
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [routes], navigate })
|
|
643
|
+
render(withRouter(<SpotlightProvider />))
|
|
644
|
+
act(() => spotlight.open({ query: "o" }))
|
|
645
|
+
await screen.findByTestId("spotlight-item-pages-about")
|
|
646
|
+
await highlighted("Home")
|
|
647
|
+
press("ArrowDown")
|
|
648
|
+
await highlighted("About")
|
|
649
|
+
press("Enter", { metaKey: true })
|
|
650
|
+
expect(open).toHaveBeenCalledWith(
|
|
651
|
+
expect.stringMatching(/\/app\/about$/),
|
|
652
|
+
"_blank",
|
|
653
|
+
"noopener,noreferrer",
|
|
654
|
+
)
|
|
655
|
+
press("Enter", { ctrlKey: true })
|
|
656
|
+
expect(open).toHaveBeenCalledTimes(2)
|
|
657
|
+
expect(navigate).not.toHaveBeenCalled()
|
|
658
|
+
expect(spotlight.getState().open).toBe(true)
|
|
659
|
+
})
|
|
660
|
+
|
|
661
|
+
it("does not restore focus to the trigger after a navigation", async () => {
|
|
662
|
+
const navigate = vi.fn((_: Route) => {})
|
|
663
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [routes], navigate })
|
|
664
|
+
render(
|
|
665
|
+
withRouter(
|
|
666
|
+
<>
|
|
667
|
+
<button type="button" onClick={() => spotlight.open({ query: "home" })}>
|
|
668
|
+
Search
|
|
669
|
+
</button>
|
|
670
|
+
<SpotlightProvider />
|
|
671
|
+
</>,
|
|
672
|
+
),
|
|
673
|
+
)
|
|
674
|
+
const trigger = screen.getByRole("button", { name: "Search" })
|
|
675
|
+
trigger.focus()
|
|
676
|
+
fireEvent.click(trigger)
|
|
677
|
+
await screen.findByTestId("spotlight-item-pages-home")
|
|
678
|
+
await waitFor(() => expect(document.activeElement).toBe(input()))
|
|
679
|
+
press("Enter")
|
|
680
|
+
expect(navigate).toHaveBeenCalled()
|
|
681
|
+
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull())
|
|
682
|
+
await sleep(50)
|
|
683
|
+
expect(document.activeElement).not.toBe(trigger)
|
|
684
|
+
})
|
|
685
|
+
|
|
686
|
+
it("restores focus to the trigger after a close without navigation", async () => {
|
|
687
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [] })
|
|
688
|
+
render(
|
|
689
|
+
<>
|
|
690
|
+
<button type="button" onClick={() => spotlight.open()}>
|
|
691
|
+
Search
|
|
692
|
+
</button>
|
|
693
|
+
<SpotlightProvider />
|
|
694
|
+
</>,
|
|
695
|
+
)
|
|
696
|
+
const trigger = screen.getByRole("button", { name: "Search" })
|
|
697
|
+
trigger.focus()
|
|
698
|
+
fireEvent.click(trigger)
|
|
699
|
+
await waitFor(() => expect(document.activeElement).toBe(input()))
|
|
700
|
+
await act(() => sleep(150))
|
|
701
|
+
fireEvent.keyDown(input(), { key: "Escape" })
|
|
702
|
+
await waitFor(() => expect(screen.queryByRole("dialog")).toBeNull())
|
|
703
|
+
await waitFor(() => expect(document.activeElement).toBe(trigger))
|
|
704
|
+
})
|
|
705
|
+
})
|
|
706
|
+
|
|
707
|
+
describe("items", () => {
|
|
708
|
+
it("renders the icon, description, badge and shortcut", async () => {
|
|
709
|
+
const commands = staticSource({
|
|
710
|
+
id: "commands",
|
|
711
|
+
label: "Commands",
|
|
712
|
+
items: [
|
|
713
|
+
{
|
|
714
|
+
id: "new",
|
|
715
|
+
title: "New project",
|
|
716
|
+
description: "Start from a template",
|
|
717
|
+
icon: <svg data-icon />,
|
|
718
|
+
badge: <span>Beta</span>,
|
|
719
|
+
shortcut: ["⌘", "N"],
|
|
720
|
+
},
|
|
721
|
+
],
|
|
722
|
+
})
|
|
723
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [commands] })
|
|
724
|
+
render(<SpotlightProvider />)
|
|
725
|
+
act(() => spotlight.open({ query: "new" }))
|
|
726
|
+
const row = await screen.findByTestId("spotlight-item-commands-new")
|
|
727
|
+
expect(row.querySelector("[data-icon]")).not.toBeNull()
|
|
728
|
+
expect(within(row).getByText("Start from a template")).toBeTruthy()
|
|
729
|
+
expect(within(row).getByText("Beta")).toBeTruthy()
|
|
730
|
+
expect([...row.querySelectorAll("kbd")].map((kbd) => kbd.textContent)).toEqual(["⌘", "N"])
|
|
731
|
+
})
|
|
732
|
+
|
|
733
|
+
it("marks the query in the title, ignoring case and diacritics", async () => {
|
|
734
|
+
const people = staticSource({
|
|
735
|
+
id: "people",
|
|
736
|
+
label: "People",
|
|
737
|
+
items: [{ id: "h", title: "Hotblack Désiato" }],
|
|
738
|
+
})
|
|
739
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people] })
|
|
740
|
+
render(<SpotlightProvider />)
|
|
741
|
+
act(() => spotlight.open({ query: "desi hot" }))
|
|
742
|
+
const row = await screen.findByTestId("spotlight-item-people-h")
|
|
743
|
+
expect([...row.querySelectorAll("mark")].map((mark) => mark.textContent)).toEqual([
|
|
744
|
+
"Hot",
|
|
745
|
+
"Dési",
|
|
746
|
+
])
|
|
747
|
+
})
|
|
748
|
+
|
|
749
|
+
it("marks the item's own highlights instead of the query", async () => {
|
|
750
|
+
const search: SpotlightSource<"search"> = {
|
|
751
|
+
id: "search",
|
|
752
|
+
label: "Search",
|
|
753
|
+
debounce: 0,
|
|
754
|
+
search: () => [{ id: "a", title: "Running shoes", highlights: [[0, 3]] }],
|
|
755
|
+
}
|
|
756
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [search] })
|
|
757
|
+
render(<SpotlightProvider />)
|
|
758
|
+
act(() => spotlight.open({ query: "runs" }))
|
|
759
|
+
const row = await screen.findByTestId("spotlight-item-search-a")
|
|
760
|
+
expect([...row.querySelectorAll("mark")].map((mark) => mark.textContent)).toEqual(["Run"])
|
|
761
|
+
})
|
|
762
|
+
|
|
763
|
+
it("lets a source's render replace the row's content", async () => {
|
|
764
|
+
const custom = staticSource({
|
|
765
|
+
id: "custom",
|
|
766
|
+
label: "Custom",
|
|
767
|
+
items: [{ id: "a", title: "Alpha" }],
|
|
768
|
+
render: (item, { highlighted, query }) => (
|
|
769
|
+
<span data-custom>{`${item.title}:${String(highlighted)}:${query}`}</span>
|
|
770
|
+
),
|
|
771
|
+
})
|
|
772
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [custom] })
|
|
773
|
+
render(<SpotlightProvider />)
|
|
774
|
+
act(() => spotlight.open({ query: "al" }))
|
|
775
|
+
const row = await screen.findByTestId("spotlight-item-custom-a")
|
|
776
|
+
expect(row.getAttribute("role")).toBe("option")
|
|
777
|
+
expect(row.textContent).toBe("Alpha:true:al")
|
|
778
|
+
})
|
|
779
|
+
|
|
780
|
+
it("keys a Group's render-prop rows itself, so an unkeyed row doesn't warn", async () => {
|
|
781
|
+
const error = vi.spyOn(console, "error").mockImplementation(() => {})
|
|
782
|
+
const letters = staticSource({
|
|
783
|
+
id: "letters",
|
|
784
|
+
label: "Letters",
|
|
785
|
+
items: [
|
|
786
|
+
{ id: "a", title: "Alpha" },
|
|
787
|
+
{ id: "b", title: "Albert" },
|
|
788
|
+
],
|
|
789
|
+
})
|
|
790
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [letters] })
|
|
791
|
+
render(
|
|
792
|
+
<SpotlightProvider>
|
|
793
|
+
<Spotlight.Root>
|
|
794
|
+
<Spotlight.Input />
|
|
795
|
+
<Spotlight.List>
|
|
796
|
+
{(groups) =>
|
|
797
|
+
groups.map((group) => (
|
|
798
|
+
<Spotlight.Group key={group.key} group={group}>
|
|
799
|
+
{(item) => <Spotlight.Item item={item} testId="row" />}
|
|
800
|
+
</Spotlight.Group>
|
|
801
|
+
))
|
|
802
|
+
}
|
|
803
|
+
</Spotlight.List>
|
|
804
|
+
</Spotlight.Root>
|
|
805
|
+
</SpotlightProvider>,
|
|
806
|
+
)
|
|
807
|
+
act(() => spotlight.open({ query: "al" }))
|
|
808
|
+
await waitFor(() => expect(screen.getAllByTestId("row")).toHaveLength(2))
|
|
809
|
+
|
|
810
|
+
const keyWarnings = error.mock.calls.filter((args) => String(args[0]).includes('unique "key"'))
|
|
811
|
+
expect(keyWarnings).toEqual([])
|
|
812
|
+
})
|
|
813
|
+
})
|
|
814
|
+
|
|
815
|
+
describe("recents", () => {
|
|
816
|
+
const people = staticSource({
|
|
817
|
+
id: "people",
|
|
818
|
+
label: "People",
|
|
819
|
+
items: [user("marvin", "Marvin"), user("trillian", "Trillian")],
|
|
820
|
+
})
|
|
821
|
+
|
|
822
|
+
it("records selected items and shows them on an empty query, most recent first", async () => {
|
|
823
|
+
const navigate = vi.fn()
|
|
824
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
825
|
+
sources: [people],
|
|
826
|
+
navigate,
|
|
827
|
+
recents: { storageKey: "test-recents" },
|
|
828
|
+
})
|
|
829
|
+
const { unmount } = render(<SpotlightProvider />)
|
|
830
|
+
act(() => spotlight.open({ query: "marvin" }))
|
|
831
|
+
await screen.findByTestId("spotlight-item-people-marvin")
|
|
832
|
+
press("Enter")
|
|
833
|
+
act(() => spotlight.open({ query: "trillian" }))
|
|
834
|
+
await screen.findByTestId("spotlight-item-people-trillian")
|
|
835
|
+
press("Enter")
|
|
836
|
+
|
|
837
|
+
expect(JSON.parse(localStorage.getItem("test-recents") ?? "[]")).toEqual([
|
|
838
|
+
{ source: "people", id: "trillian", title: "Trillian", link: { href: "/users/trillian" } },
|
|
839
|
+
{ source: "people", id: "marvin", title: "Marvin", link: { href: "/users/marvin" } },
|
|
840
|
+
])
|
|
841
|
+
|
|
842
|
+
// Restored after a remount (a reload), from storage.
|
|
843
|
+
unmount()
|
|
844
|
+
render(<SpotlightProvider />)
|
|
845
|
+
act(() => spotlight.open())
|
|
846
|
+
const list = await screen.findByRole("listbox")
|
|
847
|
+
expect(within(list).getByText("Recent")).toBeTruthy()
|
|
848
|
+
expect(
|
|
849
|
+
within(list)
|
|
850
|
+
.getAllByRole("option")
|
|
851
|
+
.map((row) => row.getAttribute("data-testid")),
|
|
852
|
+
).toEqual(["spotlight-recent-people-trillian", "spotlight-recent-people-marvin"])
|
|
853
|
+
|
|
854
|
+
// Selecting a recent moves it to the top and navigates to it.
|
|
855
|
+
press("ArrowDown")
|
|
856
|
+
await highlighted("Marvin")
|
|
857
|
+
press("Enter")
|
|
858
|
+
expect(navigate).toHaveBeenLastCalledWith({ href: "/users/marvin" })
|
|
859
|
+
expect(
|
|
860
|
+
JSON.parse(localStorage.getItem("test-recents") ?? "[]").map((r: { id: string }) => r.id),
|
|
861
|
+
).toEqual(["marvin", "trillian"])
|
|
862
|
+
})
|
|
863
|
+
|
|
864
|
+
it("keeps at most `limit` recents and hides them once a query is typed", async () => {
|
|
865
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
866
|
+
sources: [people],
|
|
867
|
+
navigate: () => {},
|
|
868
|
+
recents: { limit: 1 },
|
|
869
|
+
})
|
|
870
|
+
render(<SpotlightProvider />)
|
|
871
|
+
act(() => spotlight.open({ query: "marvin" }))
|
|
872
|
+
await screen.findByTestId("spotlight-item-people-marvin")
|
|
873
|
+
press("Enter")
|
|
874
|
+
act(() => spotlight.open({ query: "trillian" }))
|
|
875
|
+
await screen.findByTestId("spotlight-item-people-trillian")
|
|
876
|
+
press("Enter")
|
|
877
|
+
act(() => spotlight.open())
|
|
878
|
+
expect(await screen.findByTestId("spotlight-recent-people-trillian")).toBeTruthy()
|
|
879
|
+
expect(screen.queryByTestId("spotlight-recent-people-marvin")).toBeNull()
|
|
880
|
+
|
|
881
|
+
type("trillian")
|
|
882
|
+
await screen.findByTestId("spotlight-item-people-trillian")
|
|
883
|
+
expect(screen.queryByTestId("spotlight-recent-people-trillian")).toBeNull()
|
|
884
|
+
})
|
|
885
|
+
|
|
886
|
+
it("records nothing with recents: false", async () => {
|
|
887
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
888
|
+
sources: [people],
|
|
889
|
+
navigate: () => {},
|
|
890
|
+
recents: false,
|
|
891
|
+
})
|
|
892
|
+
render(<SpotlightProvider />)
|
|
893
|
+
act(() => spotlight.open({ query: "marvin" }))
|
|
894
|
+
await screen.findByTestId("spotlight-item-people-marvin")
|
|
895
|
+
press("Enter")
|
|
896
|
+
expect(localStorage.length).toBe(0)
|
|
897
|
+
})
|
|
898
|
+
|
|
899
|
+
it("shows suggestion sources next to the recents on an empty query", async () => {
|
|
900
|
+
const suggestions = staticSource({
|
|
901
|
+
id: "suggested",
|
|
902
|
+
label: "Suggested",
|
|
903
|
+
minQueryLength: 0,
|
|
904
|
+
items: [{ id: "s", title: "Upcoming exam" }],
|
|
905
|
+
})
|
|
906
|
+
localStorage.setItem(
|
|
907
|
+
"42-spotlight-recents",
|
|
908
|
+
JSON.stringify([{ source: "people", id: "marvin", title: "Marvin", link: { href: "/m" } }]),
|
|
909
|
+
)
|
|
910
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people, suggestions] })
|
|
911
|
+
render(<SpotlightProvider />)
|
|
912
|
+
act(() => spotlight.open())
|
|
913
|
+
const list = await screen.findByRole("listbox")
|
|
914
|
+
await waitFor(() =>
|
|
915
|
+
expect(
|
|
916
|
+
within(list)
|
|
917
|
+
.getAllByRole("presentation")
|
|
918
|
+
.map((label) => label.textContent),
|
|
919
|
+
).toEqual(["Recent", "Search in", "Suggested"]),
|
|
920
|
+
)
|
|
921
|
+
})
|
|
922
|
+
})
|
|
923
|
+
|
|
924
|
+
describe("prompt", () => {
|
|
925
|
+
const people = (extra: Partial<SpotlightSource<string>> = {}) =>
|
|
926
|
+
delayed("people", [user("marvin", "Marvin")], 0, {
|
|
927
|
+
icon: <svg data-testid="people-icon" />,
|
|
928
|
+
...extra,
|
|
929
|
+
})
|
|
930
|
+
/** The prompt's box, found by its heading in the list. */
|
|
931
|
+
const prompt = async (title: string) =>
|
|
932
|
+
(await within(await screen.findByTestId("spotlight-list")).findByText(title)).closest(
|
|
933
|
+
"div",
|
|
934
|
+
) as HTMLElement
|
|
935
|
+
|
|
936
|
+
it("shows the scope's icon, title, hint and ⌫ on an empty query with nothing to show", async () => {
|
|
937
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people()] })
|
|
938
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
939
|
+
act(() => spotlight.open({ path: [{ source: "people" }], query: "" }))
|
|
940
|
+
const box = await prompt("Search People")
|
|
941
|
+
expect(within(box).getByTestId("people-icon")).toBeTruthy()
|
|
942
|
+
expect(within(box).getByText("Type to search")).toBeTruthy()
|
|
943
|
+
// After the ⌫ key, drawn by Kbd.
|
|
944
|
+
expect(within(box).getByText("to go back").querySelector("kbd")).toBeTruthy()
|
|
945
|
+
// In the measured rows, so the list's height eases to it.
|
|
946
|
+
expect(box.parentElement?.classList.contains("peer")).toBe(true)
|
|
947
|
+
|
|
948
|
+
// Gone once something is typed, and at the root.
|
|
949
|
+
type("zz")
|
|
950
|
+
await within(screen.getByTestId("spotlight-list")).findByText("No results for “zz”")
|
|
951
|
+
expect(screen.queryByText("Search People")).toBeNull()
|
|
952
|
+
act(() => spotlight.setPath([]))
|
|
953
|
+
await waitFor(() => expect(screen.queryByText("Type to search")).toBeNull())
|
|
954
|
+
})
|
|
955
|
+
|
|
956
|
+
it("reads the scoped source's `hint`, a function one at render", async () => {
|
|
957
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
958
|
+
sources: [people({ hint: () => "Type a login" })],
|
|
959
|
+
})
|
|
960
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
961
|
+
act(() => spotlight.open({ path: [{ source: "people" }], query: "" }))
|
|
962
|
+
const box = await prompt("Search People")
|
|
963
|
+
expect(within(box).getByText("Type a login")).toBeTruthy()
|
|
964
|
+
expect(within(box).queryByText("Type to search")).toBeNull()
|
|
965
|
+
})
|
|
966
|
+
|
|
967
|
+
it("names a group's label, with its source's hint", async () => {
|
|
968
|
+
const catalog = delayed("catalog", [], 0, {
|
|
969
|
+
groups: { rooms: { label: "Rooms" } },
|
|
970
|
+
hint: "Type a room",
|
|
971
|
+
})
|
|
972
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [catalog] })
|
|
973
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
974
|
+
act(() => spotlight.open({ path: [{ source: "catalog", group: "rooms" }], query: "" }))
|
|
975
|
+
const box = await prompt("Search Rooms")
|
|
976
|
+
expect(within(box).getByText("Type a room")).toBeTruthy()
|
|
977
|
+
})
|
|
978
|
+
|
|
979
|
+
it("says “Search in” an item, without its source's hint", async () => {
|
|
980
|
+
const inner = delayed("projects", [{ id: "libft", title: "libft" }])
|
|
981
|
+
const source = people({ hint: "Type a login", within: () => [inner] })
|
|
982
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [source], scopes: false })
|
|
983
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
984
|
+
act(() =>
|
|
985
|
+
spotlight.open({ path: [{ source: "people", item: user("marvin", "Marvin") }], query: "" }),
|
|
986
|
+
)
|
|
987
|
+
const box = await prompt("Search in Marvin")
|
|
988
|
+
expect(within(box).getByText("Type to search")).toBeTruthy()
|
|
989
|
+
expect(within(box).queryByText("Type a login")).toBeNull()
|
|
990
|
+
})
|
|
991
|
+
|
|
992
|
+
it("never shows while a suggestion source loads, from the push on, nor once it answered", async () => {
|
|
993
|
+
let answer = (_items: SpotlightItem[]) => {}
|
|
994
|
+
const suggested: SpotlightSource<"suggested"> = {
|
|
995
|
+
id: "suggested",
|
|
996
|
+
label: "Suggested",
|
|
997
|
+
minQueryLength: 0,
|
|
998
|
+
debounce: 0,
|
|
999
|
+
search: () =>
|
|
1000
|
+
new Promise<SpotlightItem[]>((resolve) => {
|
|
1001
|
+
answer = resolve
|
|
1002
|
+
}),
|
|
1003
|
+
}
|
|
1004
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [suggested] })
|
|
1005
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1006
|
+
act(() => spotlight.open())
|
|
1007
|
+
await screen.findByRole("combobox")
|
|
1008
|
+
// The push and its first render: the source is already `loading`.
|
|
1009
|
+
act(() => spotlight.push({ source: "suggested" }))
|
|
1010
|
+
expect(screen.queryByText("Search Suggested")).toBeNull()
|
|
1011
|
+
await act(() => sleep(50))
|
|
1012
|
+
expect(screen.queryByText("Search Suggested")).toBeNull()
|
|
1013
|
+
await act(async () => answer([{ id: "s", title: "Upcoming exam" }]))
|
|
1014
|
+
expect(await screen.findByTestId("spotlight-item-suggested-s")).toBeTruthy()
|
|
1015
|
+
expect(screen.queryByText("Search Suggested")).toBeNull()
|
|
1016
|
+
|
|
1017
|
+
// One that answers nothing leaves the prompt, once settled.
|
|
1018
|
+
act(() => spotlight.setPath([]))
|
|
1019
|
+
act(() => spotlight.push({ source: "suggested" }))
|
|
1020
|
+
expect(screen.queryByText("Search Suggested")).toBeNull()
|
|
1021
|
+
await act(async () => answer([]))
|
|
1022
|
+
expect(await screen.findByText("Search Suggested")).toBeTruthy()
|
|
1023
|
+
})
|
|
1024
|
+
|
|
1025
|
+
it("lets its children replace its content", async () => {
|
|
1026
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people()] })
|
|
1027
|
+
render(
|
|
1028
|
+
<SpotlightProvider>
|
|
1029
|
+
<Spotlight.Root>
|
|
1030
|
+
<Spotlight.Input />
|
|
1031
|
+
<Spotlight.List>
|
|
1032
|
+
{(groups) => groups.map((group) => <Spotlight.Group key={group.key} group={group} />)}
|
|
1033
|
+
</Spotlight.List>
|
|
1034
|
+
<Spotlight.Prompt testId="prompt">Pick a person</Spotlight.Prompt>
|
|
1035
|
+
</Spotlight.Root>
|
|
1036
|
+
</SpotlightProvider>,
|
|
1037
|
+
)
|
|
1038
|
+
act(() => spotlight.open({ path: [{ source: "people" }], query: "" }))
|
|
1039
|
+
const box = await screen.findByTestId("prompt")
|
|
1040
|
+
expect(box.textContent).toBe("Pick a person")
|
|
1041
|
+
expect(box.querySelector("svg")).toBeNull()
|
|
1042
|
+
})
|
|
1043
|
+
})
|
|
1044
|
+
|
|
1045
|
+
describe("placeholder", () => {
|
|
1046
|
+
it("follows the path's last chip, and keeps the factory's at the root", async () => {
|
|
1047
|
+
const inner = delayed("projects", [])
|
|
1048
|
+
const people = delayed("people", [], 0, {
|
|
1049
|
+
groups: { staff: { label: "Staff" } },
|
|
1050
|
+
within: () => [inner],
|
|
1051
|
+
})
|
|
1052
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1053
|
+
sources: [people],
|
|
1054
|
+
placeholder: "Search 42…",
|
|
1055
|
+
})
|
|
1056
|
+
render(<SpotlightProvider />)
|
|
1057
|
+
act(() => spotlight.open())
|
|
1058
|
+
const placeholder = async () =>
|
|
1059
|
+
(await screen.findByRole("combobox")).getAttribute("placeholder")
|
|
1060
|
+
expect(await placeholder()).toBe("Search 42…")
|
|
1061
|
+
act(() => spotlight.setPath([{ source: "people" }]))
|
|
1062
|
+
expect(await placeholder()).toBe("Search People…")
|
|
1063
|
+
act(() => spotlight.setPath([{ source: "people", group: "staff" }]))
|
|
1064
|
+
expect(await placeholder()).toBe("Search Staff…")
|
|
1065
|
+
act(() => spotlight.setPath([{ source: "people", item: user("marvin", "Marvin") }]))
|
|
1066
|
+
expect(await placeholder()).toBe("Search in Marvin…")
|
|
1067
|
+
act(() => spotlight.setPath([]))
|
|
1068
|
+
expect(await placeholder()).toBe("Search 42…")
|
|
1069
|
+
})
|
|
1070
|
+
|
|
1071
|
+
it("reads the scoped source's `placeholder`, and the translation", async () => {
|
|
1072
|
+
const people = delayed("people", [], 0, { placeholder: () => "Login or name…" })
|
|
1073
|
+
const events = delayed("events", [])
|
|
1074
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1075
|
+
sources: [people, events],
|
|
1076
|
+
translations: { searchPlaceholder: (label) => `Chercher dans ${label}…` },
|
|
1077
|
+
})
|
|
1078
|
+
render(<SpotlightProvider />)
|
|
1079
|
+
act(() => spotlight.open({ path: [{ source: "people" }] }))
|
|
1080
|
+
expect((await screen.findByRole("combobox")).getAttribute("placeholder")).toBe("Login or name…")
|
|
1081
|
+
act(() => spotlight.setPath([{ source: "events" }]))
|
|
1082
|
+
expect(input().getAttribute("placeholder")).toBe("Chercher dans Events…")
|
|
1083
|
+
})
|
|
1084
|
+
})
|
|
1085
|
+
|
|
1086
|
+
describe("scoped recents", () => {
|
|
1087
|
+
const people = staticSource({
|
|
1088
|
+
id: "people",
|
|
1089
|
+
label: "People",
|
|
1090
|
+
items: [user("marvin", "Marvin"), user("trillian", "Trillian")],
|
|
1091
|
+
within: () => [delayed("projects", [])],
|
|
1092
|
+
})
|
|
1093
|
+
const catalog = delayed("catalog", [], 0, {
|
|
1094
|
+
groups: { rooms: { label: "Rooms" }, modules: { label: "Modules" } },
|
|
1095
|
+
})
|
|
1096
|
+
const stored = [
|
|
1097
|
+
{ source: "catalog", group: "rooms", id: "turing", title: "Turing", link: { href: "/t" } },
|
|
1098
|
+
{ source: "people", id: "marvin", title: "Marvin", link: { href: "/m" } },
|
|
1099
|
+
{ source: "catalog", group: "modules", id: "algo", title: "Algo", link: { href: "/a" } },
|
|
1100
|
+
{ source: "people", id: "trillian", title: "Trillian", link: { href: "/tr" } },
|
|
1101
|
+
]
|
|
1102
|
+
const rows = (list: HTMLElement) =>
|
|
1103
|
+
within(list)
|
|
1104
|
+
.queryAllByRole("option")
|
|
1105
|
+
.map((row) => row.getAttribute("data-testid"))
|
|
1106
|
+
|
|
1107
|
+
it("shows only the category's own, headed with its label, and no prompt", async () => {
|
|
1108
|
+
localStorage.setItem("42-spotlight-recents", JSON.stringify(stored))
|
|
1109
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1110
|
+
sources: [people, catalog],
|
|
1111
|
+
recents: { limit: 1 },
|
|
1112
|
+
})
|
|
1113
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1114
|
+
act(() => spotlight.open({ path: [{ source: "people" }] }))
|
|
1115
|
+
const list = await screen.findByTestId("spotlight-list")
|
|
1116
|
+
expect(await within(list).findByText("Recent in People")).toBeTruthy()
|
|
1117
|
+
// Up to `limit`, counted among the category's own.
|
|
1118
|
+
expect(rows(list)).toEqual(["spotlight-recent-people-marvin"])
|
|
1119
|
+
expect(within(list).queryByText("Search People")).toBeNull()
|
|
1120
|
+
|
|
1121
|
+
// A group's chip keeps the recents of that group.
|
|
1122
|
+
act(() => spotlight.setPath([{ source: "catalog", group: "modules" }]))
|
|
1123
|
+
expect(await within(list).findByText("Recent in Modules")).toBeTruthy()
|
|
1124
|
+
expect(rows(list)).toEqual(["spotlight-recent-catalog-algo"])
|
|
1125
|
+
})
|
|
1126
|
+
|
|
1127
|
+
it("shows none on an item's chip, nor once a query is typed", async () => {
|
|
1128
|
+
localStorage.setItem("42-spotlight-recents", JSON.stringify(stored))
|
|
1129
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1130
|
+
sources: [people, catalog],
|
|
1131
|
+
scopes: false,
|
|
1132
|
+
})
|
|
1133
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1134
|
+
act(() => spotlight.open({ path: [{ source: "people", item: user("marvin", "Marvin") }] }))
|
|
1135
|
+
const list = await screen.findByTestId("spotlight-list")
|
|
1136
|
+
// Nothing to show there, so the prompt.
|
|
1137
|
+
expect(await within(list).findByText("Search in Marvin")).toBeTruthy()
|
|
1138
|
+
expect(rows(list)).toEqual([])
|
|
1139
|
+
|
|
1140
|
+
act(() => spotlight.open({ path: [{ source: "people" }], query: "tri" }))
|
|
1141
|
+
expect(await screen.findByTestId("spotlight-item-people-trillian")).toBeTruthy()
|
|
1142
|
+
expect(within(list).queryByText("Recent in People")).toBeNull()
|
|
1143
|
+
})
|
|
1144
|
+
|
|
1145
|
+
it("records an item's group with it", async () => {
|
|
1146
|
+
const rooms = staticSource({
|
|
1147
|
+
id: "rooms",
|
|
1148
|
+
label: "Rooms",
|
|
1149
|
+
groups: { floor: { label: "Floor 1" } },
|
|
1150
|
+
items: [{ id: "turing", title: "Turing", group: "floor", link: { href: "/t" } }],
|
|
1151
|
+
})
|
|
1152
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1153
|
+
sources: [rooms],
|
|
1154
|
+
navigate: () => {},
|
|
1155
|
+
})
|
|
1156
|
+
render(<SpotlightProvider />)
|
|
1157
|
+
act(() => spotlight.open({ query: "turing" }))
|
|
1158
|
+
await screen.findByTestId("spotlight-item-rooms-turing")
|
|
1159
|
+
press("Enter")
|
|
1160
|
+
expect(JSON.parse(localStorage.getItem("42-spotlight-recents") ?? "[]")).toEqual([
|
|
1161
|
+
{ source: "rooms", group: "floor", id: "turing", title: "Turing", link: { href: "/t" } },
|
|
1162
|
+
])
|
|
1163
|
+
})
|
|
1164
|
+
})
|
|
1165
|
+
|
|
1166
|
+
describe("contextual sources", () => {
|
|
1167
|
+
const route = staticSource({
|
|
1168
|
+
id: "route",
|
|
1169
|
+
label: "This project",
|
|
1170
|
+
minQueryLength: 0,
|
|
1171
|
+
items: [{ id: "file", title: "README" }],
|
|
1172
|
+
})
|
|
1173
|
+
|
|
1174
|
+
it("registers SpotlightSources while mounted", async () => {
|
|
1175
|
+
const { spotlight, SpotlightProvider, SpotlightSources } = createSpotlight({
|
|
1176
|
+
sources: [],
|
|
1177
|
+
recents: false,
|
|
1178
|
+
})
|
|
1179
|
+
const { rerender } = render(
|
|
1180
|
+
<>
|
|
1181
|
+
<SpotlightProvider />
|
|
1182
|
+
<SpotlightSources sources={[route]} />
|
|
1183
|
+
</>,
|
|
1184
|
+
)
|
|
1185
|
+
act(() => spotlight.open())
|
|
1186
|
+
expect(await screen.findByTestId("spotlight-item-route-file")).toBeTruthy()
|
|
1187
|
+
|
|
1188
|
+
rerender(<SpotlightProvider />)
|
|
1189
|
+
await waitFor(() => expect(screen.queryByTestId("spotlight-item-route-file")).toBeNull())
|
|
1190
|
+
})
|
|
1191
|
+
|
|
1192
|
+
it("registers useSpotlightSource while mounted", async () => {
|
|
1193
|
+
const { spotlight, SpotlightProvider, useSpotlightSource } = createSpotlight({
|
|
1194
|
+
sources: [],
|
|
1195
|
+
recents: false,
|
|
1196
|
+
})
|
|
1197
|
+
const Route = () => {
|
|
1198
|
+
useSpotlightSource(route)
|
|
1199
|
+
return null
|
|
1200
|
+
}
|
|
1201
|
+
const { rerender } = render(
|
|
1202
|
+
<>
|
|
1203
|
+
<SpotlightProvider />
|
|
1204
|
+
<Route />
|
|
1205
|
+
</>,
|
|
1206
|
+
)
|
|
1207
|
+
act(() => spotlight.open())
|
|
1208
|
+
expect(await screen.findByTestId("spotlight-item-route-file")).toBeTruthy()
|
|
1209
|
+
rerender(<SpotlightProvider />)
|
|
1210
|
+
await waitFor(() => expect(screen.queryByTestId("spotlight-item-route-file")).toBeNull())
|
|
1211
|
+
})
|
|
1212
|
+
})
|
|
1213
|
+
|
|
1214
|
+
describe("custom layout", () => {
|
|
1215
|
+
it("renders the parts, with testIds and translations", async () => {
|
|
1216
|
+
const commands = staticSource({
|
|
1217
|
+
id: "commands",
|
|
1218
|
+
label: "Commands",
|
|
1219
|
+
items: [{ id: "a", title: "Alpha" }],
|
|
1220
|
+
})
|
|
1221
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1222
|
+
sources: [commands],
|
|
1223
|
+
translations: { hintClose: "pour fermer", keyEsc: "Échap" },
|
|
1224
|
+
})
|
|
1225
|
+
render(
|
|
1226
|
+
<SpotlightProvider translations={{ inputLabel: "Rechercher" }} placeholder="Cherchez…">
|
|
1227
|
+
<Spotlight.Root testId="root">
|
|
1228
|
+
<Spotlight.Input testId="input" />
|
|
1229
|
+
<Spotlight.List testId="list">
|
|
1230
|
+
{(groups) =>
|
|
1231
|
+
groups.map((group) => (
|
|
1232
|
+
<Spotlight.Group key={group.key} group={group} testId={`group-${group.key}`}>
|
|
1233
|
+
{(item) => <Spotlight.Item key={item.value} item={item} testId="row" />}
|
|
1234
|
+
</Spotlight.Group>
|
|
1235
|
+
))
|
|
1236
|
+
}
|
|
1237
|
+
</Spotlight.List>
|
|
1238
|
+
<Spotlight.Empty testId="empty" />
|
|
1239
|
+
<Spotlight.Footer testId="footer" />
|
|
1240
|
+
</Spotlight.Root>
|
|
1241
|
+
</SpotlightProvider>,
|
|
1242
|
+
)
|
|
1243
|
+
act(() => spotlight.open({ query: "al" }))
|
|
1244
|
+
expect(await screen.findByTestId("row")).toBeTruthy()
|
|
1245
|
+
expect(screen.getByTestId("root").getAttribute("role")).toBe("dialog")
|
|
1246
|
+
expect(screen.getByTestId("input")).toBe(screen.getByRole("combobox", { name: "Rechercher" }))
|
|
1247
|
+
expect(screen.getByTestId("input").getAttribute("placeholder")).toBe("Cherchez…")
|
|
1248
|
+
expect(screen.getByTestId("list")).toBeTruthy()
|
|
1249
|
+
expect(screen.getByTestId("group-commands")).toBeTruthy()
|
|
1250
|
+
expect(within(screen.getByTestId("footer")).getByText("pour fermer")).toBeTruthy()
|
|
1251
|
+
expect(within(screen.getByTestId("footer")).getByText("Échap")).toBeTruthy()
|
|
1252
|
+
expect(within(screen.getByTestId("footer")).queryByText("Esc")).toBeNull()
|
|
1253
|
+
expect(screen.queryByTestId("empty")).toBeNull()
|
|
1254
|
+
|
|
1255
|
+
type("zz")
|
|
1256
|
+
expect(await screen.findByTestId("empty")).toBeTruthy()
|
|
1257
|
+
})
|
|
1258
|
+
|
|
1259
|
+
it("mirrors with an RTL locale", async () => {
|
|
1260
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [] })
|
|
1261
|
+
render(
|
|
1262
|
+
<IntlProvider locale="ar">
|
|
1263
|
+
<SpotlightProvider />
|
|
1264
|
+
</IntlProvider>,
|
|
1265
|
+
)
|
|
1266
|
+
act(() => spotlight.open())
|
|
1267
|
+
expect(
|
|
1268
|
+
(await screen.findByRole("combobox")).closest("[data-scope=combobox]")?.getAttribute("dir"),
|
|
1269
|
+
).toBe("rtl")
|
|
1270
|
+
expect(screen.getByRole("dialog").getAttribute("dir")).toBe("rtl")
|
|
1271
|
+
})
|
|
1272
|
+
|
|
1273
|
+
it("throws a helpful error outside the provider", () => {
|
|
1274
|
+
vi.spyOn(console, "error").mockImplementation(() => {})
|
|
1275
|
+
expect(() => render(<Spotlight.Footer />)).toThrow(/SpotlightProvider/)
|
|
1276
|
+
})
|
|
1277
|
+
})
|
|
1278
|
+
|
|
1279
|
+
describe("paths", () => {
|
|
1280
|
+
const people = staticSource({
|
|
1281
|
+
id: "people",
|
|
1282
|
+
label: "People",
|
|
1283
|
+
prefix: "@",
|
|
1284
|
+
items: [user("marvin", "Marvin"), user("trillian", "Trillian"), user("arthur", "Arthur")],
|
|
1285
|
+
})
|
|
1286
|
+
const catalog: SpotlightSource<"catalog"> = {
|
|
1287
|
+
id: "catalog",
|
|
1288
|
+
label: "Catalog",
|
|
1289
|
+
prefix: "#",
|
|
1290
|
+
debounce: 0,
|
|
1291
|
+
groups: { rooms: { label: "Rooms" }, modules: { label: "Modules" } },
|
|
1292
|
+
search: (query) =>
|
|
1293
|
+
[
|
|
1294
|
+
{ id: "turing", title: "Turing room", group: "rooms" },
|
|
1295
|
+
{ id: "algo", title: "Algo module", group: "modules" },
|
|
1296
|
+
].filter((item) => item.title.toLowerCase().includes(query.toLowerCase())),
|
|
1297
|
+
}
|
|
1298
|
+
/** A user source whose rows can be entered: within a user, their projects and events. */
|
|
1299
|
+
const enterable = () => {
|
|
1300
|
+
const within = vi.fn((person: SpotlightItem) => [
|
|
1301
|
+
staticSource({
|
|
1302
|
+
id: "projects",
|
|
1303
|
+
label: "Project",
|
|
1304
|
+
prefix: "#",
|
|
1305
|
+
minQueryLength: 0,
|
|
1306
|
+
items: [
|
|
1307
|
+
{ id: "libft", title: `libft by ${person.title}` },
|
|
1308
|
+
{ id: "minishell", title: `minishell by ${person.title}` },
|
|
1309
|
+
],
|
|
1310
|
+
}),
|
|
1311
|
+
staticSource({
|
|
1312
|
+
id: "events",
|
|
1313
|
+
label: "Events",
|
|
1314
|
+
minQueryLength: 0,
|
|
1315
|
+
items: [{ id: "exam", title: `Exam for ${person.title}` }],
|
|
1316
|
+
}),
|
|
1317
|
+
])
|
|
1318
|
+
const users = staticSource({
|
|
1319
|
+
id: "users",
|
|
1320
|
+
label: "User",
|
|
1321
|
+
prefix: "@",
|
|
1322
|
+
items: [user("marvin", "Marvin"), user("trillian", "Trillian")],
|
|
1323
|
+
within,
|
|
1324
|
+
})
|
|
1325
|
+
return { users, within }
|
|
1326
|
+
}
|
|
1327
|
+
const chip = (index: number) => screen.queryByTestId(`spotlight-path-${index}`)
|
|
1328
|
+
const path = (spotlight: { getState: () => { path: readonly unknown[] } }) =>
|
|
1329
|
+
spotlight.getState().path
|
|
1330
|
+
const live = (text: string) =>
|
|
1331
|
+
waitFor(() =>
|
|
1332
|
+
expect(
|
|
1333
|
+
[...document.querySelectorAll("[aria-live=polite]")].map((node) => node.textContent),
|
|
1334
|
+
).toContain(text),
|
|
1335
|
+
)
|
|
1336
|
+
/** Records keydowns that reach the document: a key Spotlight takes stops before it. */
|
|
1337
|
+
const reachDocument = () => {
|
|
1338
|
+
const reached = vi.fn()
|
|
1339
|
+
document.addEventListener("keydown", reached)
|
|
1340
|
+
return { reached, stop: () => document.removeEventListener("keydown", reached) }
|
|
1341
|
+
}
|
|
1342
|
+
|
|
1343
|
+
it("pushes a plain row's group on Tab, keeping the query, then lets Tab move focus", async () => {
|
|
1344
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people, catalog] })
|
|
1345
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1346
|
+
act(() => spotlight.open({ query: "o" }))
|
|
1347
|
+
await screen.findByTestId("spotlight-item-catalog-algo")
|
|
1348
|
+
await highlighted("Turing room")
|
|
1349
|
+
|
|
1350
|
+
const { reached, stop } = reachDocument()
|
|
1351
|
+
press("Tab")
|
|
1352
|
+
expect(reached).not.toHaveBeenCalled()
|
|
1353
|
+
await waitFor(() => expect(path(spotlight)).toEqual([{ source: "catalog", group: "rooms" }]))
|
|
1354
|
+
expect(chip(0)?.textContent).toContain("Rooms")
|
|
1355
|
+
await waitFor(() => expect(screen.queryByTestId("spotlight-item-catalog-algo")).toBeNull())
|
|
1356
|
+
expect(spotlight.getState().query).toBe("o")
|
|
1357
|
+
|
|
1358
|
+
// Its group is the path's last frame now: Tab is the browser's again.
|
|
1359
|
+
await highlighted("Turing room")
|
|
1360
|
+
press("Tab")
|
|
1361
|
+
expect(reached).toHaveBeenCalledTimes(1)
|
|
1362
|
+
// Shift+Tab is never taken.
|
|
1363
|
+
press("Tab", { shiftKey: true })
|
|
1364
|
+
expect(reached).toHaveBeenCalledTimes(2)
|
|
1365
|
+
expect(path(spotlight)).toHaveLength(1)
|
|
1366
|
+
stop()
|
|
1367
|
+
})
|
|
1368
|
+
|
|
1369
|
+
it("pushes an ungrouped plain row's source on Tab", async () => {
|
|
1370
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people, catalog] })
|
|
1371
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1372
|
+
act(() => spotlight.open({ query: "ar" }))
|
|
1373
|
+
await screen.findByTestId("spotlight-item-people-marvin")
|
|
1374
|
+
await highlighted("Marvin")
|
|
1375
|
+
press("Tab")
|
|
1376
|
+
await waitFor(() => expect(path(spotlight)).toEqual([{ source: "people" }]))
|
|
1377
|
+
expect(chip(0)?.textContent).toContain("People")
|
|
1378
|
+
})
|
|
1379
|
+
|
|
1380
|
+
it("pushes an enterable row's item on Tab, clears the query and searches within it", async () => {
|
|
1381
|
+
const { users, within } = enterable()
|
|
1382
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [users] })
|
|
1383
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1384
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
1385
|
+
await screen.findByTestId("spotlight-item-users-marvin")
|
|
1386
|
+
await highlighted("Marvin")
|
|
1387
|
+
press("Tab")
|
|
1388
|
+
|
|
1389
|
+
await waitFor(() => expect(spotlight.getState().query).toBe(""))
|
|
1390
|
+
expect(within).toHaveBeenCalledWith(expect.objectContaining({ id: "marvin" }))
|
|
1391
|
+
expect(path(spotlight)).toEqual([
|
|
1392
|
+
{ source: "users", item: expect.objectContaining({ id: "marvin" }) },
|
|
1393
|
+
])
|
|
1394
|
+
expect(chip(0)?.textContent).toContain("User: Marvin")
|
|
1395
|
+
expect(await screen.findByTestId("spotlight-item-projects-libft")).toBeTruthy()
|
|
1396
|
+
expect(screen.getByTestId("spotlight-item-events-exam").textContent).toContain(
|
|
1397
|
+
"Exam for Marvin",
|
|
1398
|
+
)
|
|
1399
|
+
|
|
1400
|
+
// One level deeper, Tab on a plain row pushes its source, as at the root.
|
|
1401
|
+
// (A query, so the "Search in" rows of the empty one aren't first.)
|
|
1402
|
+
type("marvin")
|
|
1403
|
+
await highlighted("libft by Marvin")
|
|
1404
|
+
press("Tab")
|
|
1405
|
+
await waitFor(() => expect(path(spotlight)).toHaveLength(2))
|
|
1406
|
+
expect(chip(1)?.textContent).toContain("Project")
|
|
1407
|
+
await waitFor(() => expect(screen.queryByTestId("spotlight-item-events-exam")).toBeNull())
|
|
1408
|
+
})
|
|
1409
|
+
|
|
1410
|
+
it("keeps focus in the input on Tab with chips before it, ahead of the dialog's focus trap", async () => {
|
|
1411
|
+
const { users } = enterable()
|
|
1412
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [users] })
|
|
1413
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1414
|
+
act(() =>
|
|
1415
|
+
spotlight.open({
|
|
1416
|
+
path: [{ source: "users", item: user("marvin", "Marvin") }],
|
|
1417
|
+
query: "marvin",
|
|
1418
|
+
}),
|
|
1419
|
+
)
|
|
1420
|
+
await screen.findByTestId("spotlight-item-projects-libft")
|
|
1421
|
+
await waitFor(() => expect(document.activeElement).toBe(input()))
|
|
1422
|
+
// The dialog's focus trap arms over a frame and a timeout.
|
|
1423
|
+
await act(() => sleep(150))
|
|
1424
|
+
await highlighted("libft by Marvin")
|
|
1425
|
+
// A real Tab: the default action is what moves focus.
|
|
1426
|
+
const tab = new KeyboardEvent("keydown", { key: "Tab", bubbles: true, cancelable: true })
|
|
1427
|
+
input().dispatchEvent(tab)
|
|
1428
|
+
expect(tab.defaultPrevented).toBe(true)
|
|
1429
|
+
await waitFor(() => expect(path(spotlight)).toHaveLength(2))
|
|
1430
|
+
expect(document.activeElement).toBe(input())
|
|
1431
|
+
})
|
|
1432
|
+
|
|
1433
|
+
it("replaces the category an item was found in, through Tab and ›, and pops back to the root", async () => {
|
|
1434
|
+
const { users } = enterable()
|
|
1435
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [users] })
|
|
1436
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1437
|
+
act(() => spotlight.open())
|
|
1438
|
+
await screen.findByRole("combobox")
|
|
1439
|
+
|
|
1440
|
+
// `@ mar`, then Tab on Marvin: one chip, not [User] [User: Marvin].
|
|
1441
|
+
type("@ mar")
|
|
1442
|
+
await waitFor(() => expect(path(spotlight)).toEqual([{ source: "users" }]))
|
|
1443
|
+
await screen.findByTestId("spotlight-item-users-marvin")
|
|
1444
|
+
await highlighted("Marvin")
|
|
1445
|
+
press("Tab")
|
|
1446
|
+
await waitFor(() =>
|
|
1447
|
+
expect(path(spotlight)).toEqual([
|
|
1448
|
+
{ source: "users", item: expect.objectContaining({ id: "marvin" }) },
|
|
1449
|
+
]),
|
|
1450
|
+
)
|
|
1451
|
+
expect(chip(1)).toBeNull()
|
|
1452
|
+
expect(chip(0)?.textContent).toContain("User: Marvin")
|
|
1453
|
+
|
|
1454
|
+
// ⌫ goes back to the root, not to [User].
|
|
1455
|
+
await waitFor(() => expect(spotlight.getState().query).toBe(""))
|
|
1456
|
+
press("Backspace")
|
|
1457
|
+
expect(path(spotlight)).toEqual([])
|
|
1458
|
+
|
|
1459
|
+
// The same through the › button.
|
|
1460
|
+
act(() => spotlight.setPath([{ source: "users" }]))
|
|
1461
|
+
type("tri")
|
|
1462
|
+
fireEvent.click(await screen.findByTestId("spotlight-item-users-trillian-enter"))
|
|
1463
|
+
await waitFor(() =>
|
|
1464
|
+
expect(path(spotlight)).toEqual([
|
|
1465
|
+
{ source: "users", item: expect.objectContaining({ id: "trillian" }) },
|
|
1466
|
+
]),
|
|
1467
|
+
)
|
|
1468
|
+
})
|
|
1469
|
+
|
|
1470
|
+
it("enters a row from its › button, while a click on the row still selects it", async () => {
|
|
1471
|
+
const onSelect = vi.fn()
|
|
1472
|
+
const { users } = enterable()
|
|
1473
|
+
const commands = staticSource({
|
|
1474
|
+
id: "commands",
|
|
1475
|
+
label: "Commands",
|
|
1476
|
+
items: [{ id: "run", title: "Run marvin", onSelect }],
|
|
1477
|
+
})
|
|
1478
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1479
|
+
sources: [users, commands],
|
|
1480
|
+
navigate: () => {},
|
|
1481
|
+
})
|
|
1482
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1483
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
1484
|
+
const row = await screen.findByTestId("spotlight-item-users-marvin")
|
|
1485
|
+
// Only rows whose source has `within` get one.
|
|
1486
|
+
expect(screen.queryByTestId("spotlight-item-commands-run-enter")).toBeNull()
|
|
1487
|
+
const button = within(row).getByRole("button", { name: "Search in Marvin" })
|
|
1488
|
+
expect(button).toBe(screen.getByTestId("spotlight-item-users-marvin-enter"))
|
|
1489
|
+
expect(button.tabIndex).toBe(-1)
|
|
1490
|
+
|
|
1491
|
+
fireEvent.click(button)
|
|
1492
|
+
expect(spotlight.getState()).toMatchObject({ open: true, query: "" })
|
|
1493
|
+
expect(path(spotlight)).toHaveLength(1)
|
|
1494
|
+
|
|
1495
|
+
act(() => spotlight.open({ path: [], query: "run" }))
|
|
1496
|
+
fireEvent.click(await screen.findByTestId("spotlight-item-commands-run"))
|
|
1497
|
+
expect(onSelect).toHaveBeenCalled()
|
|
1498
|
+
})
|
|
1499
|
+
|
|
1500
|
+
it("leaves Tab alone with nothing highlighted", async () => {
|
|
1501
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people] })
|
|
1502
|
+
render(<SpotlightProvider />)
|
|
1503
|
+
act(() => spotlight.open())
|
|
1504
|
+
await screen.findByRole("combobox")
|
|
1505
|
+
const { reached, stop } = reachDocument()
|
|
1506
|
+
press("Tab")
|
|
1507
|
+
expect(reached).toHaveBeenCalledTimes(1)
|
|
1508
|
+
expect(path(spotlight)).toEqual([])
|
|
1509
|
+
stop()
|
|
1510
|
+
})
|
|
1511
|
+
|
|
1512
|
+
it("pushes a source on its prefix and a space, and strips it", async () => {
|
|
1513
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people, catalog] })
|
|
1514
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1515
|
+
act(() => spotlight.open())
|
|
1516
|
+
await screen.findByRole("combobox")
|
|
1517
|
+
|
|
1518
|
+
type("@ mar")
|
|
1519
|
+
await waitFor(() => expect(path(spotlight)).toEqual([{ source: "people" }]))
|
|
1520
|
+
expect(spotlight.getState().query).toBe("mar")
|
|
1521
|
+
await waitFor(() => expect(input()).toHaveProperty("value", "mar"))
|
|
1522
|
+
expect(chip(0)?.textContent).toContain("People")
|
|
1523
|
+
expect(await screen.findByTestId("spotlight-item-people-marvin")).toBeTruthy()
|
|
1524
|
+
})
|
|
1525
|
+
|
|
1526
|
+
it("keeps a bare prefix literal, and ignores prefixes after a category", async () => {
|
|
1527
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people, catalog] })
|
|
1528
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1529
|
+
act(() => spotlight.open())
|
|
1530
|
+
await screen.findByRole("combobox")
|
|
1531
|
+
type("#42")
|
|
1532
|
+
await waitFor(() => expect(spotlight.getState().query).toBe("#42"))
|
|
1533
|
+
expect(path(spotlight)).toEqual([])
|
|
1534
|
+
|
|
1535
|
+
act(() => spotlight.setPath([{ source: "people" }]))
|
|
1536
|
+
type("# x")
|
|
1537
|
+
await waitFor(() => expect(spotlight.getState().query).toBe("# x"))
|
|
1538
|
+
expect(path(spotlight)).toEqual([{ source: "people" }])
|
|
1539
|
+
})
|
|
1540
|
+
|
|
1541
|
+
it("resolves prefixes against the current level's sources only", async () => {
|
|
1542
|
+
const { users } = enterable()
|
|
1543
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [users, catalog] })
|
|
1544
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1545
|
+
act(() => spotlight.open({ path: [{ source: "users", item: user("marvin", "Marvin") }] }))
|
|
1546
|
+
await screen.findByTestId("spotlight-item-projects-libft")
|
|
1547
|
+
|
|
1548
|
+
// The root's "@" means nothing here.
|
|
1549
|
+
type("@ x")
|
|
1550
|
+
await waitFor(() => expect(spotlight.getState().query).toBe("@ x"))
|
|
1551
|
+
expect(path(spotlight)).toHaveLength(1)
|
|
1552
|
+
|
|
1553
|
+
// This level's "#" is the projects within Marvin, not the root's catalog.
|
|
1554
|
+
type("# lib")
|
|
1555
|
+
await waitFor(() => expect(path(spotlight)).toHaveLength(2))
|
|
1556
|
+
expect(path(spotlight).at(-1)).toEqual({ source: "projects" })
|
|
1557
|
+
expect(spotlight.getState().query).toBe("lib")
|
|
1558
|
+
})
|
|
1559
|
+
|
|
1560
|
+
it("pops one frame on ⌫ in an empty input, and keeps the query otherwise", async () => {
|
|
1561
|
+
const { users } = enterable()
|
|
1562
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [users] })
|
|
1563
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1564
|
+
act(() =>
|
|
1565
|
+
spotlight.open({
|
|
1566
|
+
path: [{ source: "users", item: user("marvin", "Marvin") }, { source: "projects" }],
|
|
1567
|
+
query: "l",
|
|
1568
|
+
}),
|
|
1569
|
+
)
|
|
1570
|
+
await screen.findByTestId("spotlight-path-1")
|
|
1571
|
+
expect(fireEvent.keyDown(input(), { key: "Backspace" })).toBe(true)
|
|
1572
|
+
expect(path(spotlight)).toHaveLength(2)
|
|
1573
|
+
|
|
1574
|
+
type("")
|
|
1575
|
+
await waitFor(() => expect(spotlight.getState().query).toBe(""))
|
|
1576
|
+
expect(fireEvent.keyDown(input(), { key: "Backspace" })).toBe(false)
|
|
1577
|
+
expect(path(spotlight)).toHaveLength(1)
|
|
1578
|
+
await waitFor(() => expect(chip(1)).toBeNull())
|
|
1579
|
+
expect(chip(0)?.textContent).toContain("User: Marvin")
|
|
1580
|
+
|
|
1581
|
+
press("Backspace")
|
|
1582
|
+
expect(path(spotlight)).toEqual([])
|
|
1583
|
+
})
|
|
1584
|
+
|
|
1585
|
+
it("pops one frame per Esc, and closes only on an empty path", async () => {
|
|
1586
|
+
const { users } = enterable()
|
|
1587
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [users] })
|
|
1588
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1589
|
+
act(() =>
|
|
1590
|
+
spotlight.open({
|
|
1591
|
+
path: [{ source: "users", item: user("marvin", "Marvin") }, { source: "projects" }],
|
|
1592
|
+
query: "lib",
|
|
1593
|
+
}),
|
|
1594
|
+
)
|
|
1595
|
+
await screen.findByTestId("spotlight-path-1")
|
|
1596
|
+
// The dialog's dismissable layer arms over a frame and a timeout.
|
|
1597
|
+
await act(() => sleep(150))
|
|
1598
|
+
|
|
1599
|
+
fireEvent.keyDown(input(), { key: "Escape" })
|
|
1600
|
+
await waitFor(() => expect(path(spotlight)).toHaveLength(1))
|
|
1601
|
+
fireEvent.keyDown(input(), { key: "Escape" })
|
|
1602
|
+
await waitFor(() => expect(path(spotlight)).toEqual([]))
|
|
1603
|
+
expect(spotlight.getState()).toMatchObject({ open: true, query: "lib" })
|
|
1604
|
+
|
|
1605
|
+
fireEvent.keyDown(input(), { key: "Escape" })
|
|
1606
|
+
await waitFor(() => expect(spotlight.getState().open).toBe(false))
|
|
1607
|
+
})
|
|
1608
|
+
|
|
1609
|
+
it("removes a chip and every chip after it from its ×, keeping focus in the input", async () => {
|
|
1610
|
+
const { users } = enterable()
|
|
1611
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [users] })
|
|
1612
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1613
|
+
act(() =>
|
|
1614
|
+
spotlight.open({
|
|
1615
|
+
path: [{ source: "users", item: user("marvin", "Marvin") }, { source: "projects" }],
|
|
1616
|
+
}),
|
|
1617
|
+
)
|
|
1618
|
+
const remove = await screen.findByRole("button", { name: "Leave User: Marvin" })
|
|
1619
|
+
expect(remove).toBe(screen.getByTestId("spotlight-path-0-remove"))
|
|
1620
|
+
remove.focus()
|
|
1621
|
+
fireEvent.click(remove)
|
|
1622
|
+
expect(path(spotlight)).toEqual([])
|
|
1623
|
+
await waitFor(() => expect(chip(0)).toBeNull())
|
|
1624
|
+
await waitFor(() => expect(document.activeElement).toBe(input()))
|
|
1625
|
+
})
|
|
1626
|
+
|
|
1627
|
+
it("shows the chips when opened at a path, from code or from a contextual source", async () => {
|
|
1628
|
+
const { spotlight, SpotlightProvider, useSpotlightSource } = createSpotlight({
|
|
1629
|
+
sources: [people],
|
|
1630
|
+
})
|
|
1631
|
+
const route = staticSource({
|
|
1632
|
+
id: "route",
|
|
1633
|
+
label: "This project",
|
|
1634
|
+
icon: <svg data-route-icon />,
|
|
1635
|
+
items: [],
|
|
1636
|
+
})
|
|
1637
|
+
const Route = () => {
|
|
1638
|
+
const files = useSpotlightSource(route)
|
|
1639
|
+
return (
|
|
1640
|
+
<button type="button" onClick={() => files.open()}>
|
|
1641
|
+
Search this project
|
|
1642
|
+
</button>
|
|
1643
|
+
)
|
|
1644
|
+
}
|
|
1645
|
+
render(
|
|
1646
|
+
<>
|
|
1647
|
+
<SpotlightProvider testId="spotlight" />
|
|
1648
|
+
<Route />
|
|
1649
|
+
</>,
|
|
1650
|
+
)
|
|
1651
|
+
act(() => spotlight.open({ path: [{ source: "people" }] }))
|
|
1652
|
+
expect((await screen.findByTestId("spotlight-path-0")).textContent).toContain("People")
|
|
1653
|
+
act(() => spotlight.close())
|
|
1654
|
+
await waitFor(() => expect(chip(0)).toBeNull())
|
|
1655
|
+
|
|
1656
|
+
fireEvent.click(screen.getByRole("button", { name: "Search this project" }))
|
|
1657
|
+
const scoped = await screen.findByTestId("spotlight-path-0")
|
|
1658
|
+
expect(scoped.textContent).toContain("This project")
|
|
1659
|
+
expect(scoped.querySelector("[data-route-icon]")).not.toBeNull()
|
|
1660
|
+
})
|
|
1661
|
+
|
|
1662
|
+
it("opens at a page's useSpotlightPath while it is mounted, unless open names a path", async () => {
|
|
1663
|
+
const { users } = enterable()
|
|
1664
|
+
const { spotlight, SpotlightProvider, useSpotlightPath, SpotlightPath } = createSpotlight({
|
|
1665
|
+
sources: [users],
|
|
1666
|
+
hotkey: "mod+k",
|
|
1667
|
+
})
|
|
1668
|
+
const profile = [{ source: "users", item: user("marvin", "Marvin") }] as const
|
|
1669
|
+
const Profile = () => {
|
|
1670
|
+
useSpotlightPath(profile)
|
|
1671
|
+
return null
|
|
1672
|
+
}
|
|
1673
|
+
const { rerender } = render(
|
|
1674
|
+
<>
|
|
1675
|
+
<SpotlightProvider testId="spotlight" />
|
|
1676
|
+
<Profile />
|
|
1677
|
+
</>,
|
|
1678
|
+
)
|
|
1679
|
+
fireEvent.keyDown(window, { key: "k", ctrlKey: true })
|
|
1680
|
+
expect((await screen.findByTestId("spotlight-path-0")).textContent).toContain("User: Marvin")
|
|
1681
|
+
expect(await screen.findByTestId("spotlight-item-projects-libft")).toBeTruthy()
|
|
1682
|
+
act(() => spotlight.close())
|
|
1683
|
+
|
|
1684
|
+
// An explicit path wins.
|
|
1685
|
+
act(() => spotlight.open({ path: [] }))
|
|
1686
|
+
await screen.findByRole("combobox")
|
|
1687
|
+
expect(chip(0)).toBeNull()
|
|
1688
|
+
act(() => spotlight.close())
|
|
1689
|
+
|
|
1690
|
+
// Unmounting clears it; the component form does the same.
|
|
1691
|
+
rerender(<SpotlightProvider testId="spotlight" />)
|
|
1692
|
+
act(() => spotlight.open())
|
|
1693
|
+
await screen.findByRole("combobox")
|
|
1694
|
+
expect(chip(0)).toBeNull()
|
|
1695
|
+
act(() => spotlight.close())
|
|
1696
|
+
|
|
1697
|
+
rerender(
|
|
1698
|
+
<>
|
|
1699
|
+
<SpotlightProvider testId="spotlight" />
|
|
1700
|
+
<SpotlightPath path={[{ source: "users" }]} />
|
|
1701
|
+
</>,
|
|
1702
|
+
)
|
|
1703
|
+
act(() => spotlight.open())
|
|
1704
|
+
expect((await screen.findByTestId("spotlight-path-0")).textContent).toContain("User")
|
|
1705
|
+
})
|
|
1706
|
+
|
|
1707
|
+
it("announces the whole path, and emptying it", async () => {
|
|
1708
|
+
const { users } = enterable()
|
|
1709
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [users, catalog] })
|
|
1710
|
+
render(<SpotlightProvider />)
|
|
1711
|
+
act(() => spotlight.open())
|
|
1712
|
+
await screen.findByRole("combobox")
|
|
1713
|
+
expect(document.body.textContent).not.toContain("Searching everywhere")
|
|
1714
|
+
act(() => spotlight.setPath([{ source: "catalog", group: "modules" }]))
|
|
1715
|
+
await live("Searching in Modules")
|
|
1716
|
+
act(() =>
|
|
1717
|
+
spotlight.setPath([
|
|
1718
|
+
{ source: "users", item: user("marvin", "Marvin") },
|
|
1719
|
+
{ source: "projects", item: { id: "libft", title: "libft" } },
|
|
1720
|
+
]),
|
|
1721
|
+
)
|
|
1722
|
+
// "projects" has no `within`, so the path ends after Marvin.
|
|
1723
|
+
await live("Searching in User: Marvin")
|
|
1724
|
+
act(() => spotlight.push({ source: "projects" }))
|
|
1725
|
+
await live("Searching in User: Marvin, Project")
|
|
1726
|
+
act(() => spotlight.setPath([]))
|
|
1727
|
+
await live("Searching everywhere")
|
|
1728
|
+
})
|
|
1729
|
+
|
|
1730
|
+
it("shows the ⌘↵ hint only while the highlighted row has a link", async () => {
|
|
1731
|
+
const commands = staticSource({
|
|
1732
|
+
id: "commands",
|
|
1733
|
+
label: "Commands",
|
|
1734
|
+
items: [{ id: "run", title: "Run marvin", onSelect: () => {} }],
|
|
1735
|
+
})
|
|
1736
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [commands, people] })
|
|
1737
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1738
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
1739
|
+
await screen.findByTestId("spotlight-item-people-marvin")
|
|
1740
|
+
const footer = screen.getByTestId("spotlight-footer")
|
|
1741
|
+
await highlighted("Run marvin")
|
|
1742
|
+
expect(within(footer).queryByText("new tab")).toBeNull()
|
|
1743
|
+
press("ArrowDown")
|
|
1744
|
+
await highlighted("Marvin")
|
|
1745
|
+
expect(within(footer).getByText("new tab")).toBeTruthy()
|
|
1746
|
+
})
|
|
1747
|
+
|
|
1748
|
+
it.each([
|
|
1749
|
+
["MacIntel", ["Up Arrow", "Down Arrow", "Return", "Command", "Return", "Tab", "Échap"]],
|
|
1750
|
+
["Win32", ["Up Arrow", "Down Arrow", "Enter", "Strg", "Enter", "Tab", "Échap"]],
|
|
1751
|
+
])(
|
|
1752
|
+
"draws the footer's keys as per-key caps on %s, keeping the translated words",
|
|
1753
|
+
async (platform, read) => {
|
|
1754
|
+
vi.stubGlobal("navigator", { ...navigator, platform })
|
|
1755
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1756
|
+
sources: [people],
|
|
1757
|
+
translations: { keyCtrl: "Strg", keyEsc: "Échap" },
|
|
1758
|
+
})
|
|
1759
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1760
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
1761
|
+
await highlighted("Marvin")
|
|
1762
|
+
const footer = screen.getByTestId("spotlight-footer")
|
|
1763
|
+
await waitFor(() => expect(within(footer).getByText("new tab")).toBeTruthy())
|
|
1764
|
+
// Every cap, in order: a `<Kbd hotkey>` group's inner caps, or a word cap.
|
|
1765
|
+
const caps = [...footer.querySelectorAll("kbd")].filter((kbd) => !kbd.querySelector("kbd"))
|
|
1766
|
+
expect(caps.map((cap) => cap.textContent)).toEqual(read)
|
|
1767
|
+
const drawn = caps.filter((cap) => cap.querySelector("svg"))
|
|
1768
|
+
expect(drawn.every((cap) => cap.querySelector(".sr-only"))).toBe(true)
|
|
1769
|
+
expect(caps.find((cap) => cap.textContent === "Échap")?.querySelector("svg")).toBeNull()
|
|
1770
|
+
},
|
|
1771
|
+
)
|
|
1772
|
+
|
|
1773
|
+
it.each([
|
|
1774
|
+
[
|
|
1775
|
+
"MacIntel",
|
|
1776
|
+
["Flèche haut", "Flèche bas", "Retour", "Commande", "Retour", "Tabulation", "Échap"],
|
|
1777
|
+
],
|
|
1778
|
+
["Win32", ["Flèche haut", "Flèche bas", "Entrée", "Ctrl", "Entrée", "Tabulation", "Échap"]],
|
|
1779
|
+
])("forwards translations.kbd to every footer cap on %s", async (platform, read) => {
|
|
1780
|
+
vi.stubGlobal("navigator", { ...navigator, platform })
|
|
1781
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1782
|
+
sources: [people],
|
|
1783
|
+
translations: { kbd: { up: "Flèche haut", down: "Flèche bas", escape: "Échap" } },
|
|
1784
|
+
})
|
|
1785
|
+
// The provider's words add to the factory's, key by key.
|
|
1786
|
+
const french = { command: "Commande", return: "Retour", enter: "Entrée", tab: "Tabulation" }
|
|
1787
|
+
render(<SpotlightProvider testId="spotlight" translations={{ kbd: french }} />)
|
|
1788
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
1789
|
+
await highlighted("Marvin")
|
|
1790
|
+
const footer = screen.getByTestId("spotlight-footer")
|
|
1791
|
+
await waitFor(() => expect(within(footer).getByText("new tab")).toBeTruthy())
|
|
1792
|
+
const caps = [...footer.querySelectorAll("kbd")].filter((kbd) => !kbd.querySelector("kbd"))
|
|
1793
|
+
expect(caps.map((cap) => cap.textContent)).toEqual(read)
|
|
1794
|
+
// A drawn cap speaks its translated name through its visually hidden text.
|
|
1795
|
+
const spoken = caps.flatMap((cap) => [...cap.querySelectorAll(".sr-only")])
|
|
1796
|
+
expect(spoken.map((name) => name.textContent)).toContain(
|
|
1797
|
+
platform === "Win32" ? "Entrée" : "Retour",
|
|
1798
|
+
)
|
|
1799
|
+
})
|
|
1800
|
+
|
|
1801
|
+
it("keeps each hint whole, so a narrow footer wraps between hints only", async () => {
|
|
1802
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people] })
|
|
1803
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1804
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
1805
|
+
await screen.findByTestId("spotlight-item-people-marvin")
|
|
1806
|
+
const footer = screen.getByTestId("spotlight-footer")
|
|
1807
|
+
expect(footer.className).toContain("flex-wrap")
|
|
1808
|
+
const hints = [...footer.children]
|
|
1809
|
+
expect(hints.length).toBeGreaterThan(0)
|
|
1810
|
+
expect(hints.every((hint) => hint.className.includes("whitespace-nowrap"))).toBe(true)
|
|
1811
|
+
})
|
|
1812
|
+
|
|
1813
|
+
it("prefers kbd.ctrl and kbd.escape over the deprecated keyCtrl and keyEsc", async () => {
|
|
1814
|
+
vi.stubGlobal("navigator", { ...navigator, platform: "Win32" })
|
|
1815
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
1816
|
+
sources: [people],
|
|
1817
|
+
translations: { keyCtrl: "Strg", keyEsc: "Esc!", kbd: { escape: "Échap" } },
|
|
1818
|
+
})
|
|
1819
|
+
render(<SpotlightProvider testId="spotlight" translations={{ kbd: { ctrl: "Ctl" } }} />)
|
|
1820
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
1821
|
+
await highlighted("Marvin")
|
|
1822
|
+
const footer = screen.getByTestId("spotlight-footer")
|
|
1823
|
+
await waitFor(() => expect(within(footer).getByText("new tab")).toBeTruthy())
|
|
1824
|
+
expect(within(footer).getByText("Ctl")).toBeTruthy()
|
|
1825
|
+
expect(within(footer).getByText("Échap")).toBeTruthy()
|
|
1826
|
+
expect(within(footer).queryByText("Strg")).toBeNull()
|
|
1827
|
+
})
|
|
1828
|
+
|
|
1829
|
+
it("shows the Tab hint while a row can be entered, and ⌫ / Esc on a path", async () => {
|
|
1830
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [people] })
|
|
1831
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1832
|
+
act(() => spotlight.open({ query: "mar" }))
|
|
1833
|
+
await screen.findByTestId("spotlight-item-people-marvin")
|
|
1834
|
+
const footer = screen.getByTestId("spotlight-footer")
|
|
1835
|
+
await waitFor(() => expect(within(footer).getByText("search within")).toBeTruthy())
|
|
1836
|
+
expect(within(footer).getByText("close")).toBeTruthy()
|
|
1837
|
+
|
|
1838
|
+
press("Tab")
|
|
1839
|
+
await waitFor(() => expect(within(footer).getByText("back")).toBeTruthy())
|
|
1840
|
+
expect(within(footer).queryByText("search within")).toBeNull()
|
|
1841
|
+
expect(within(footer).queryByText("close")).toBeNull()
|
|
1842
|
+
})
|
|
1843
|
+
})
|
|
1844
|
+
|
|
1845
|
+
describe("Search in", () => {
|
|
1846
|
+
const people = staticSource({
|
|
1847
|
+
id: "people",
|
|
1848
|
+
label: "People",
|
|
1849
|
+
prefix: "@",
|
|
1850
|
+
items: [user("marvin", "Marvin"), user("arthur", "Arthur Dent")],
|
|
1851
|
+
within: () => [
|
|
1852
|
+
staticSource({ id: "projects", label: "Projects", prefix: "#", items: [] }),
|
|
1853
|
+
staticSource({ id: "events", label: "Événements", items: [] }),
|
|
1854
|
+
],
|
|
1855
|
+
})
|
|
1856
|
+
const catalog = staticSource({
|
|
1857
|
+
id: "catalog",
|
|
1858
|
+
label: "Catalog",
|
|
1859
|
+
prefix: "#",
|
|
1860
|
+
items: [{ id: "turing", title: "Turing room" }],
|
|
1861
|
+
})
|
|
1862
|
+
const commands = staticSource({
|
|
1863
|
+
id: "commands",
|
|
1864
|
+
label: "Commands",
|
|
1865
|
+
prefix: ">",
|
|
1866
|
+
items: [{ id: "theme", title: "Toggle theme" }],
|
|
1867
|
+
})
|
|
1868
|
+
const sources = [people, catalog, commands]
|
|
1869
|
+
const scopeRows = () =>
|
|
1870
|
+
[...document.querySelectorAll("[data-testid^=spotlight-scope-]")].map((row) => ({
|
|
1871
|
+
testId: row.getAttribute("data-testid"),
|
|
1872
|
+
name: row.getAttribute("aria-label"),
|
|
1873
|
+
key: row.querySelector("kbd")?.textContent,
|
|
1874
|
+
}))
|
|
1875
|
+
const headings = () =>
|
|
1876
|
+
within(screen.getByTestId("spotlight-list"))
|
|
1877
|
+
.getAllByRole("presentation")
|
|
1878
|
+
.map((label) => label.textContent)
|
|
1879
|
+
|
|
1880
|
+
it("lists the level's sources with their prefixes on an empty query, after the recents", async () => {
|
|
1881
|
+
localStorage.setItem(
|
|
1882
|
+
"42-spotlight-recents",
|
|
1883
|
+
JSON.stringify([{ source: "people", id: "marvin", title: "Marvin", link: { href: "/m" } }]),
|
|
1884
|
+
)
|
|
1885
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources })
|
|
1886
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1887
|
+
act(() => spotlight.open())
|
|
1888
|
+
await screen.findByTestId("spotlight-scope-people")
|
|
1889
|
+
expect(headings()).toEqual(["Recent", "Search in"])
|
|
1890
|
+
expect(scopeRows()).toEqual([
|
|
1891
|
+
{ testId: "spotlight-scope-people", name: "Search in People", key: "@" },
|
|
1892
|
+
{ testId: "spotlight-scope-catalog", name: "Search in Catalog", key: "#" },
|
|
1893
|
+
{ testId: "spotlight-scope-commands", name: "Search in Commands", key: ">" },
|
|
1894
|
+
])
|
|
1895
|
+
expect(screen.getByRole("option", { name: "Search in Catalog" })).toBe(
|
|
1896
|
+
screen.getByTestId("spotlight-scope-catalog"),
|
|
1897
|
+
)
|
|
1898
|
+
})
|
|
1899
|
+
|
|
1900
|
+
it("puts the scope a query names first, by prefix or by a word of its label", async () => {
|
|
1901
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources })
|
|
1902
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1903
|
+
act(() => spotlight.open())
|
|
1904
|
+
await screen.findByTestId("spotlight-scope-people")
|
|
1905
|
+
|
|
1906
|
+
type("@")
|
|
1907
|
+
await waitFor(() =>
|
|
1908
|
+
expect(scopeRows().map(({ testId }) => testId)).toEqual(["spotlight-scope-people"]),
|
|
1909
|
+
)
|
|
1910
|
+
await highlighted("People@")
|
|
1911
|
+
|
|
1912
|
+
type("COM")
|
|
1913
|
+
await waitFor(() =>
|
|
1914
|
+
expect(scopeRows().map(({ testId }) => testId)).toEqual(["spotlight-scope-commands"]),
|
|
1915
|
+
)
|
|
1916
|
+
await highlighted("Commands>")
|
|
1917
|
+
// The normal search still runs underneath.
|
|
1918
|
+
type("o")
|
|
1919
|
+
expect(await screen.findByTestId("spotlight-item-catalog-turing")).toBeTruthy()
|
|
1920
|
+
expect(scopeRows()).toEqual([])
|
|
1921
|
+
// Each heading ends with its source's prefix.
|
|
1922
|
+
expect(headings()).toEqual(["Catalog#", "Commands>"])
|
|
1923
|
+
|
|
1924
|
+
// `@` then a space still enters the scope by itself.
|
|
1925
|
+
type("@ ")
|
|
1926
|
+
await waitFor(() => expect(spotlight.getState().path).toEqual([{ source: "people" }]))
|
|
1927
|
+
expect(spotlight.getState().query).toBe("")
|
|
1928
|
+
})
|
|
1929
|
+
|
|
1930
|
+
it.each([
|
|
1931
|
+
["↵", () => press("Enter")],
|
|
1932
|
+
["Tab", () => press("Tab")],
|
|
1933
|
+
["a click", () => fireEvent.click(screen.getByTestId("spotlight-scope-catalog"))],
|
|
1934
|
+
])("scopes to the source on %s and clears the query", async (_, run) => {
|
|
1935
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources })
|
|
1936
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1937
|
+
act(() => spotlight.open({ query: "cat" }))
|
|
1938
|
+
await highlighted("Catalog#")
|
|
1939
|
+
run()
|
|
1940
|
+
await waitFor(() => expect(spotlight.getState().path).toEqual([{ source: "catalog" }]))
|
|
1941
|
+
expect(spotlight.getState().query).toBe("")
|
|
1942
|
+
expect(screen.getByTestId("spotlight-path-0").textContent).toContain("Catalog")
|
|
1943
|
+
expect(scopeRows()).toEqual([])
|
|
1944
|
+
})
|
|
1945
|
+
|
|
1946
|
+
it("lists the sources within an item frame", async () => {
|
|
1947
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources })
|
|
1948
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1949
|
+
act(() => spotlight.open({ path: [{ source: "people", item: user("marvin", "Marvin") }] }))
|
|
1950
|
+
await screen.findByTestId("spotlight-scope-projects")
|
|
1951
|
+
expect(scopeRows()).toEqual([
|
|
1952
|
+
{ testId: "spotlight-scope-projects", name: "Search in Projects", key: "#" },
|
|
1953
|
+
{ testId: "spotlight-scope-events", name: "Search in Événements", key: undefined },
|
|
1954
|
+
])
|
|
1955
|
+
// Diacritics and case don't matter.
|
|
1956
|
+
type("eve")
|
|
1957
|
+
await waitFor(() =>
|
|
1958
|
+
expect(scopeRows().map(({ testId }) => testId)).toEqual(["spotlight-scope-events"]),
|
|
1959
|
+
)
|
|
1960
|
+
})
|
|
1961
|
+
|
|
1962
|
+
it("is hidden when scoped, on a level of one source, and with scopes: false", async () => {
|
|
1963
|
+
const scoped = createSpotlight({ sources })
|
|
1964
|
+
const { unmount } = render(<scoped.SpotlightProvider testId="spotlight" />)
|
|
1965
|
+
act(() => scoped.spotlight.open({ path: [{ source: "people" }] }))
|
|
1966
|
+
await screen.findByTestId("spotlight-path-0")
|
|
1967
|
+
expect(scopeRows()).toEqual([])
|
|
1968
|
+
act(() => scoped.spotlight.close())
|
|
1969
|
+
unmount()
|
|
1970
|
+
|
|
1971
|
+
const single = createSpotlight({ sources: [people] })
|
|
1972
|
+
const second = render(<single.SpotlightProvider testId="spotlight" />)
|
|
1973
|
+
act(() => single.spotlight.open({ query: "peo" }))
|
|
1974
|
+
await screen.findByRole("combobox")
|
|
1975
|
+
await act(() => sleep(20))
|
|
1976
|
+
expect(scopeRows()).toEqual([])
|
|
1977
|
+
act(() => single.spotlight.close())
|
|
1978
|
+
second.unmount()
|
|
1979
|
+
|
|
1980
|
+
const off = createSpotlight({ sources, scopes: false })
|
|
1981
|
+
const third = render(<off.SpotlightProvider testId="spotlight" />)
|
|
1982
|
+
act(() => off.spotlight.open())
|
|
1983
|
+
await screen.findByRole("combobox")
|
|
1984
|
+
expect(scopeRows()).toEqual([])
|
|
1985
|
+
act(() => off.spotlight.close())
|
|
1986
|
+
third.unmount()
|
|
1987
|
+
|
|
1988
|
+
// The provider's prop wins over the factory's.
|
|
1989
|
+
render(<off.SpotlightProvider testId="spotlight" scopes />)
|
|
1990
|
+
act(() => off.spotlight.open())
|
|
1991
|
+
expect(await screen.findByTestId("spotlight-scope-people")).toBeTruthy()
|
|
1992
|
+
})
|
|
1993
|
+
|
|
1994
|
+
it("shows a group's prefix after its heading only while the prefix works", async () => {
|
|
1995
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources })
|
|
1996
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
1997
|
+
act(() => spotlight.open({ query: "ar" }))
|
|
1998
|
+
await screen.findByTestId("spotlight-item-people-arthur")
|
|
1999
|
+
const heading = () =>
|
|
2000
|
+
within(screen.getByTestId("spotlight-list")).getByText("People", {
|
|
2001
|
+
selector: "[role=presentation]",
|
|
2002
|
+
})
|
|
2003
|
+
const kbd = heading().querySelector("kbd")
|
|
2004
|
+
expect(kbd?.textContent).toBe("@")
|
|
2005
|
+
expect(kbd?.getAttribute("aria-hidden")).toBe("true")
|
|
2006
|
+
|
|
2007
|
+
act(() => spotlight.setPath([{ source: "people" }]))
|
|
2008
|
+
await waitFor(() => expect(heading().querySelector("kbd")).toBeNull())
|
|
2009
|
+
})
|
|
2010
|
+
})
|
|
2011
|
+
|
|
2012
|
+
describe("See all", () => {
|
|
2013
|
+
const many = (prefix: string, count: number) =>
|
|
2014
|
+
Array.from({ length: count }, (_, index) => user(`${prefix}${index}`, `${prefix} ${index}`))
|
|
2015
|
+
|
|
2016
|
+
it("ends an unscoped group only when it has more to show, and scopes to it", async () => {
|
|
2017
|
+
const full = staticSource({ id: "full", label: "Full", items: many("full", 4) })
|
|
2018
|
+
const short = staticSource({ id: "short", label: "Short", items: many("short", 1) })
|
|
2019
|
+
const paged: SpotlightSource<"paged"> = {
|
|
2020
|
+
id: "paged",
|
|
2021
|
+
label: "Paged",
|
|
2022
|
+
debounce: 0,
|
|
2023
|
+
search: () => ({ items: [user("p", "paged 0")], nextCursor: "1" }),
|
|
2024
|
+
}
|
|
2025
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
2026
|
+
sources: [full, short, paged],
|
|
2027
|
+
limit: { unscoped: 3 },
|
|
2028
|
+
})
|
|
2029
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2030
|
+
act(() => spotlight.open({ query: "0" }))
|
|
2031
|
+
// "0" matches one item of each: only the paged source has more.
|
|
2032
|
+
await screen.findByTestId("spotlight-item-paged-p")
|
|
2033
|
+
expect(screen.queryByTestId("spotlight-see-all-full")).toBeNull()
|
|
2034
|
+
expect(screen.queryByTestId("spotlight-see-all-short")).toBeNull()
|
|
2035
|
+
expect(screen.getByTestId("spotlight-see-all-paged").textContent).toBe("See all in Paged")
|
|
2036
|
+
|
|
2037
|
+
// "u" matches every full item: the group reaches the limit.
|
|
2038
|
+
type("u")
|
|
2039
|
+
expect(await screen.findByTestId("spotlight-see-all-full")).toBeTruthy()
|
|
2040
|
+
fireEvent.click(screen.getByTestId("spotlight-see-all-full"))
|
|
2041
|
+
await waitFor(() => expect(spotlight.getState().path).toEqual([{ source: "full" }]))
|
|
2042
|
+
// Scoped, the row goes away.
|
|
2043
|
+
await screen.findByTestId("spotlight-item-full-full3")
|
|
2044
|
+
expect(screen.queryByTestId("spotlight-see-all-full")).toBeNull()
|
|
2045
|
+
})
|
|
2046
|
+
})
|
|
2047
|
+
|
|
2048
|
+
describe("pagination", () => {
|
|
2049
|
+
/** A stand-in IntersectionObserver whose live instances `reachEnd` reports as visible. */
|
|
2050
|
+
class Observer {
|
|
2051
|
+
static live = new Set<Observer>()
|
|
2052
|
+
constructor(readonly callback: (entries: { isIntersecting: boolean }[]) => void) {}
|
|
2053
|
+
observe() {
|
|
2054
|
+
Observer.live.add(this)
|
|
2055
|
+
}
|
|
2056
|
+
unobserve() {}
|
|
2057
|
+
disconnect() {
|
|
2058
|
+
Observer.live.delete(this)
|
|
2059
|
+
}
|
|
2060
|
+
takeRecords() {
|
|
2061
|
+
return []
|
|
2062
|
+
}
|
|
2063
|
+
}
|
|
2064
|
+
const reachEnd = () =>
|
|
2065
|
+
act(() => {
|
|
2066
|
+
Observer.live.forEach((observer) => {
|
|
2067
|
+
observer.callback([{ isIntersecting: true }])
|
|
2068
|
+
})
|
|
2069
|
+
})
|
|
2070
|
+
|
|
2071
|
+
beforeEach(() => {
|
|
2072
|
+
Observer.live.clear()
|
|
2073
|
+
vi.stubGlobal("IntersectionObserver", Observer)
|
|
2074
|
+
})
|
|
2075
|
+
|
|
2076
|
+
const logs = () => {
|
|
2077
|
+
const cursors: (string | undefined)[] = []
|
|
2078
|
+
let release = () => {}
|
|
2079
|
+
const source: SpotlightSource<"logs"> = {
|
|
2080
|
+
id: "logs",
|
|
2081
|
+
label: "Logs",
|
|
2082
|
+
debounce: 0,
|
|
2083
|
+
minQueryLength: 0,
|
|
2084
|
+
limit: { scoped: 3 },
|
|
2085
|
+
search: async (_query, { cursor, limit }) => {
|
|
2086
|
+
cursors.push(cursor)
|
|
2087
|
+
// Later pages wait for `release`, so a test can look at one in flight.
|
|
2088
|
+
if (cursor !== undefined) await new Promise<void>((resolve) => (release = resolve))
|
|
2089
|
+
const start = Number(cursor ?? 0)
|
|
2090
|
+
return {
|
|
2091
|
+
items: Array.from({ length: limit }, (_, index) => ({
|
|
2092
|
+
id: `l${start + index}`,
|
|
2093
|
+
title: `Log ${start + index}`,
|
|
2094
|
+
})),
|
|
2095
|
+
nextCursor: start + limit < 9 ? String(start + limit) : undefined,
|
|
2096
|
+
}
|
|
2097
|
+
},
|
|
2098
|
+
}
|
|
2099
|
+
return { source, cursors, release: () => act(() => release()) }
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
it("loads the next page near the end, once, with skeleton rows, keeping the highlight", async () => {
|
|
2103
|
+
const { source, cursors, release } = logs()
|
|
2104
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [source] })
|
|
2105
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2106
|
+
act(() => spotlight.open({ path: [{ source: "logs" }] }))
|
|
2107
|
+
await screen.findByTestId("spotlight-item-logs-l2")
|
|
2108
|
+
expect(cursors).toEqual([undefined])
|
|
2109
|
+
// A next page is coming before the list asks for it, so the rows are already there.
|
|
2110
|
+
expect(skeletonRows(screen.getByTestId("spotlight-list"))).toHaveLength(3)
|
|
2111
|
+
press("ArrowDown")
|
|
2112
|
+
press("ArrowDown")
|
|
2113
|
+
await highlighted("Log 2")
|
|
2114
|
+
|
|
2115
|
+
reachEnd()
|
|
2116
|
+
reachEnd()
|
|
2117
|
+
await waitFor(() => expect(cursors).toEqual([undefined, "3"]))
|
|
2118
|
+
const list = screen.getByTestId("spotlight-list")
|
|
2119
|
+
// Three rows end the list, after its last item.
|
|
2120
|
+
await waitFor(() => expect(skeletonRows(list)).toHaveLength(3))
|
|
2121
|
+
const tail = skeletonRows(list)[0]?.closest(".min-h-11")
|
|
2122
|
+
expect(tail?.previousElementSibling).toBe(screen.getByTestId("spotlight-item-logs-l2"))
|
|
2123
|
+
expect(list.querySelector(".animate-spin")).toBeNull()
|
|
2124
|
+
// While the page is in flight, reaching the end again asks for nothing.
|
|
2125
|
+
reachEnd()
|
|
2126
|
+
expect(cursors).toEqual([undefined, "3"])
|
|
2127
|
+
|
|
2128
|
+
// A landing page doesn't pull the list back to the highlighted row (the
|
|
2129
|
+
// reader may have scrolled away from it); a moving highlight still does.
|
|
2130
|
+
const scroll = vi.spyOn(Element.prototype, "scrollIntoView")
|
|
2131
|
+
await release()
|
|
2132
|
+
await screen.findByTestId("spotlight-item-logs-l5")
|
|
2133
|
+
// The page landed with a cursor: the rows stay, since there's more to come.
|
|
2134
|
+
expect(skeletonRows(list)).toHaveLength(3)
|
|
2135
|
+
expect(highlightedRow()?.textContent).toBe("Log 2")
|
|
2136
|
+
await act(() => sleep(50))
|
|
2137
|
+
expect(scroll).not.toHaveBeenCalled()
|
|
2138
|
+
press("ArrowDown")
|
|
2139
|
+
await highlighted("Log 3")
|
|
2140
|
+
await waitFor(() => expect(scroll).toHaveBeenCalled())
|
|
2141
|
+
|
|
2142
|
+
reachEnd()
|
|
2143
|
+
await waitFor(() => expect(cursors).toEqual([undefined, "3", "6"]))
|
|
2144
|
+
await release()
|
|
2145
|
+
await screen.findByTestId("spotlight-item-logs-l8")
|
|
2146
|
+
// The last page has no cursor: no more rows, and nothing more to observe.
|
|
2147
|
+
await waitFor(() => expect(skeletonRows(list)).toHaveLength(0))
|
|
2148
|
+
reachEnd()
|
|
2149
|
+
expect(cursors).toEqual([undefined, "3", "6"])
|
|
2150
|
+
expect(Observer.live.size).toBe(0)
|
|
2151
|
+
})
|
|
2152
|
+
|
|
2153
|
+
it("loads nothing unscoped", async () => {
|
|
2154
|
+
const { source, cursors } = logs()
|
|
2155
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [source] })
|
|
2156
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2157
|
+
act(() => spotlight.open())
|
|
2158
|
+
await screen.findByTestId("spotlight-item-logs-l0")
|
|
2159
|
+
expect(skeletonRows(screen.getByTestId("spotlight-list"))).toHaveLength(0)
|
|
2160
|
+
reachEnd()
|
|
2161
|
+
expect(cursors).toEqual([undefined])
|
|
2162
|
+
expect(Observer.live.size).toBe(0)
|
|
2163
|
+
})
|
|
2164
|
+
})
|
|
2165
|
+
|
|
2166
|
+
describe("list height", () => {
|
|
2167
|
+
/** A `ResizeObserver` the test drives: `resize` reports a border box to every live one. */
|
|
2168
|
+
class Observer {
|
|
2169
|
+
static live = new Map<Element, Observer>()
|
|
2170
|
+
constructor(readonly callback: (entries: Partial<ResizeObserverEntry>[]) => void) {}
|
|
2171
|
+
observe(target: Element) {
|
|
2172
|
+
Observer.live.set(target, this)
|
|
2173
|
+
}
|
|
2174
|
+
unobserve() {}
|
|
2175
|
+
disconnect() {
|
|
2176
|
+
Observer.live.forEach((observer, target) => {
|
|
2177
|
+
if (observer === this) Observer.live.delete(target)
|
|
2178
|
+
})
|
|
2179
|
+
}
|
|
2180
|
+
}
|
|
2181
|
+
const resize = (target: Element, blockSize: number) =>
|
|
2182
|
+
act(() => {
|
|
2183
|
+
Observer.live
|
|
2184
|
+
.get(target)
|
|
2185
|
+
?.callback([{ target, borderBoxSize: [{ blockSize, inlineSize: 600 }] }])
|
|
2186
|
+
})
|
|
2187
|
+
|
|
2188
|
+
beforeEach(() => {
|
|
2189
|
+
Observer.live.clear()
|
|
2190
|
+
vi.stubGlobal("ResizeObserver", Observer)
|
|
2191
|
+
})
|
|
2192
|
+
|
|
2193
|
+
it("writes the rows' height onto the scroller, which CSS eases to", async () => {
|
|
2194
|
+
const commands = staticSource({
|
|
2195
|
+
id: "commands",
|
|
2196
|
+
label: "Commands",
|
|
2197
|
+
items: [{ id: "a", title: "Alpha" }],
|
|
2198
|
+
})
|
|
2199
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [commands] })
|
|
2200
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2201
|
+
act(() => spotlight.open({ query: "al" }))
|
|
2202
|
+
await screen.findByTestId("spotlight-item-commands-a")
|
|
2203
|
+
const list = screen.getByTestId("spotlight-list")
|
|
2204
|
+
// The scroller is Ark's list part; inside it, a frame holds the rows'
|
|
2205
|
+
// wrapper, which alone is measured, and the filler under it.
|
|
2206
|
+
const scroller = list.querySelector("[data-part=list]") as HTMLElement
|
|
2207
|
+
const frame = scroller.firstElementChild as HTMLElement
|
|
2208
|
+
const wrapper = frame.firstElementChild as HTMLElement
|
|
2209
|
+
expect([...Observer.live.keys()]).toEqual([wrapper])
|
|
2210
|
+
expect(scroller.style.getPropertyValue("--spotlight-list-height")).toBe("")
|
|
2211
|
+
|
|
2212
|
+
resize(wrapper, 120)
|
|
2213
|
+
expect(scroller.style.getPropertyValue("--spotlight-list-height")).toBe("120px")
|
|
2214
|
+
resize(wrapper, 48)
|
|
2215
|
+
expect(scroller.style.getPropertyValue("--spotlight-list-height")).toBe("48px")
|
|
2216
|
+
expect(scroller.className).toContain("h-[min(var(--spotlight-list-height),28rem,60dvh)]")
|
|
2217
|
+
expect(scroller.className).toContain("motion-reduce:transition-none")
|
|
2218
|
+
})
|
|
2219
|
+
|
|
2220
|
+
/** A source whose every search waits for `answer`, so a test can hold it busy. */
|
|
2221
|
+
const held = () => {
|
|
2222
|
+
const pending: ((items: SpotlightItem[]) => void)[] = []
|
|
2223
|
+
const source: SpotlightSource<"held"> = {
|
|
2224
|
+
id: "held",
|
|
2225
|
+
label: "Held",
|
|
2226
|
+
debounce: 0,
|
|
2227
|
+
search: () => new Promise<SpotlightItem[]>((resolve) => pending.push(resolve)),
|
|
2228
|
+
}
|
|
2229
|
+
const answer = (items: SpotlightItem[]) => act(() => pending.shift()?.(items))
|
|
2230
|
+
return { source, answer }
|
|
2231
|
+
}
|
|
2232
|
+
|
|
2233
|
+
it("only grows while a source is busy, then eases once to the rows' height", async () => {
|
|
2234
|
+
const { source, answer } = held()
|
|
2235
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [source] })
|
|
2236
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2237
|
+
act(() => spotlight.open({ query: "a" }))
|
|
2238
|
+
await answer([user("a", "Alpha"), user("b", "Beta")])
|
|
2239
|
+
await screen.findByTestId("spotlight-item-held-a")
|
|
2240
|
+
const scroller = screen
|
|
2241
|
+
.getByTestId("spotlight-list")
|
|
2242
|
+
.querySelector("[data-part=list]") as HTMLElement
|
|
2243
|
+
const wrapper = scroller.firstElementChild?.firstElementChild as HTMLElement
|
|
2244
|
+
const target = () => scroller.style.getPropertyValue("--spotlight-list-height")
|
|
2245
|
+
resize(wrapper, 200)
|
|
2246
|
+
expect(target()).toBe("200px")
|
|
2247
|
+
|
|
2248
|
+
// A re-query: the source is busy, so a shorter measurement holds the floor
|
|
2249
|
+
// and a taller one still grows the list.
|
|
2250
|
+
type("al")
|
|
2251
|
+
await waitFor(() => expect(spotlight.getState().sources[0]?.status).toBe("loading"))
|
|
2252
|
+
resize(wrapper, 90)
|
|
2253
|
+
expect(target()).toBe("200px")
|
|
2254
|
+
resize(wrapper, 260)
|
|
2255
|
+
expect(target()).toBe("260px")
|
|
2256
|
+
resize(wrapper, 120)
|
|
2257
|
+
expect(target()).toBe("260px")
|
|
2258
|
+
|
|
2259
|
+
// Settled: one step down to the last measurement.
|
|
2260
|
+
await answer([user("a", "Alpha")])
|
|
2261
|
+
await waitFor(() => expect(target()).toBe("120px"))
|
|
2262
|
+
resize(wrapper, 64)
|
|
2263
|
+
expect(target()).toBe("64px")
|
|
2264
|
+
})
|
|
2265
|
+
|
|
2266
|
+
it("fills the held height with skeleton rows while busy, outside the rows and the options", async () => {
|
|
2267
|
+
const { source, answer } = held()
|
|
2268
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
2269
|
+
sources: [source],
|
|
2270
|
+
skeletonDelay: 0,
|
|
2271
|
+
})
|
|
2272
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2273
|
+
act(() => spotlight.open({ query: "a" }))
|
|
2274
|
+
await answer([user("a", "Alpha"), user("b", "Beta")])
|
|
2275
|
+
await screen.findByTestId("spotlight-item-held-a")
|
|
2276
|
+
const scroller = screen
|
|
2277
|
+
.getByTestId("spotlight-list")
|
|
2278
|
+
.querySelector("[data-part=list]") as HTMLElement
|
|
2279
|
+
const frame = scroller.firstElementChild as HTMLElement
|
|
2280
|
+
const wrapper = frame.firstElementChild as HTMLElement
|
|
2281
|
+
const filler = () => scroller.querySelector("[data-spotlight-filler]")
|
|
2282
|
+
expect(filler()).toBeNull()
|
|
2283
|
+
resize(wrapper, 200)
|
|
2284
|
+
|
|
2285
|
+
// Busy, with the floor held over shorter rows: the filler takes the rest.
|
|
2286
|
+
type("al")
|
|
2287
|
+
await waitFor(() => expect(filler()).not.toBeNull())
|
|
2288
|
+
resize(wrapper, 90)
|
|
2289
|
+
expect(scroller.style.getPropertyValue("--spotlight-list-height")).toBe("200px")
|
|
2290
|
+
const shown = filler() as HTMLElement
|
|
2291
|
+
// A sibling after the rows' wrapper, so it's never measured or an option.
|
|
2292
|
+
expect(shown.parentElement).toBe(frame)
|
|
2293
|
+
expect(shown.previousElementSibling).toBe(wrapper)
|
|
2294
|
+
expect([...Observer.live.keys()]).toEqual([wrapper])
|
|
2295
|
+
expect(shown.getAttribute("aria-hidden")).toBe("true")
|
|
2296
|
+
expect(shown.querySelector("[role=option], [data-part=item]")).toBeNull()
|
|
2297
|
+
expect(shown.querySelectorAll(".animate-pulse.rounded-full").length).toBeGreaterThan(0)
|
|
2298
|
+
// CSS gives it only what the rows leave, and clips the rest.
|
|
2299
|
+
expect(frame.className).toContain("min-h-full")
|
|
2300
|
+
expect(shown.className).toContain("grow")
|
|
2301
|
+
expect(shown.className).toContain("basis-0")
|
|
2302
|
+
expect(shown.className).toContain("overflow-hidden")
|
|
2303
|
+
// ↓ walks the options and never lands on it.
|
|
2304
|
+
press("ArrowDown")
|
|
2305
|
+
press("ArrowDown")
|
|
2306
|
+
press("ArrowDown")
|
|
2307
|
+
expect(highlightedRow()?.closest("[data-spotlight-filler]")).toBeNull()
|
|
2308
|
+
|
|
2309
|
+
// Settled: it goes, and the list eases to the rows.
|
|
2310
|
+
await answer([user("a", "Alpha")])
|
|
2311
|
+
await waitFor(() => expect(filler()).toBeNull())
|
|
2312
|
+
})
|
|
2313
|
+
|
|
2314
|
+
it("lets the first height after a path change shrink, busy or not", async () => {
|
|
2315
|
+
const { source, answer } = held()
|
|
2316
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [source] })
|
|
2317
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2318
|
+
act(() => spotlight.open({ query: "a" }))
|
|
2319
|
+
await answer([user("a", "Alpha")])
|
|
2320
|
+
await screen.findByTestId("spotlight-item-held-a")
|
|
2321
|
+
const scroller = screen
|
|
2322
|
+
.getByTestId("spotlight-list")
|
|
2323
|
+
.querySelector("[data-part=list]") as HTMLElement
|
|
2324
|
+
const wrapper = scroller.firstElementChild?.firstElementChild as HTMLElement
|
|
2325
|
+
const target = () => scroller.style.getPropertyValue("--spotlight-list-height")
|
|
2326
|
+
resize(wrapper, 300)
|
|
2327
|
+
|
|
2328
|
+
// Entering the source is a new search: its first height is no floor's.
|
|
2329
|
+
act(() => spotlight.push({ source: "held" }))
|
|
2330
|
+
act(() => spotlight.setQuery("b"))
|
|
2331
|
+
await waitFor(() => expect(spotlight.getState().sources[0]?.status).toBe("loading"))
|
|
2332
|
+
resize(wrapper, 80)
|
|
2333
|
+
expect(target()).toBe("80px")
|
|
2334
|
+
resize(wrapper, 40)
|
|
2335
|
+
expect(target()).toBe("80px")
|
|
2336
|
+
})
|
|
2337
|
+
|
|
2338
|
+
describe("with nothing else on screen", () => {
|
|
2339
|
+
beforeEach(() => {
|
|
2340
|
+
vi.useFakeTimers({
|
|
2341
|
+
toFake: [
|
|
2342
|
+
"setTimeout",
|
|
2343
|
+
"clearTimeout",
|
|
2344
|
+
"requestAnimationFrame",
|
|
2345
|
+
"cancelAnimationFrame",
|
|
2346
|
+
"performance",
|
|
2347
|
+
],
|
|
2348
|
+
})
|
|
2349
|
+
})
|
|
2350
|
+
const slow = (id: string, debounce = 150, latency = 500) =>
|
|
2351
|
+
delayed(id, [user(`${id}-a`, "Alpha")], latency, { debounce })
|
|
2352
|
+
|
|
2353
|
+
it("shows the pending groups' skeletons at once, the debounce included", async () => {
|
|
2354
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
2355
|
+
sources: [slow("one"), slow("two", 150, 1500)],
|
|
2356
|
+
})
|
|
2357
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2358
|
+
act(() => spotlight.open())
|
|
2359
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
2360
|
+
// The first key: both sources still wait out their debounce, and no timer runs.
|
|
2361
|
+
type("a")
|
|
2362
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
2363
|
+
const list = screen.getByTestId("spotlight-list")
|
|
2364
|
+
expect(spotlight.getState().sources.every(({ debounced }) => debounced)).toBe(true)
|
|
2365
|
+
expect(skeletonRows(list)).toHaveLength(6)
|
|
2366
|
+
const wrapper = list.querySelector("[data-part=list]")?.firstElementChild?.firstElementChild
|
|
2367
|
+
expect(wrapper?.childElementCount).toBeGreaterThan(0)
|
|
2368
|
+
|
|
2369
|
+
// Shown, they stay while the other source is still pending.
|
|
2370
|
+
await act(() => vi.advanceTimersByTimeAsync(700))
|
|
2371
|
+
expect(screen.getByTestId("spotlight-item-one-one-a")).toBeTruthy()
|
|
2372
|
+
expect(screen.queryByTestId("spotlight-item-two-two-a")).toBeNull()
|
|
2373
|
+
expect(skeletonRows(list)).toHaveLength(3)
|
|
2374
|
+
})
|
|
2375
|
+
|
|
2376
|
+
it("after the empty state, and on a path push whose sources all load", async () => {
|
|
2377
|
+
const inner = slow("projects", 0)
|
|
2378
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
2379
|
+
sources: [slow("one", 0), { ...slow("people", 0), within: () => [inner] }],
|
|
2380
|
+
scopes: false,
|
|
2381
|
+
})
|
|
2382
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2383
|
+
act(() => spotlight.open({ query: "zz" }))
|
|
2384
|
+
await act(() => vi.advanceTimersByTimeAsync(600))
|
|
2385
|
+
const list = screen.getByTestId("spotlight-list")
|
|
2386
|
+
expect(within(list).getByText("No results for “zz”")).toBeTruthy()
|
|
2387
|
+
|
|
2388
|
+
type("zzz")
|
|
2389
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
2390
|
+
expect(within(list).queryByText(/No results/)).toBeNull()
|
|
2391
|
+
expect(skeletonRows(list)).toHaveLength(6)
|
|
2392
|
+
await act(() => vi.advanceTimersByTimeAsync(600))
|
|
2393
|
+
|
|
2394
|
+
act(() =>
|
|
2395
|
+
spotlight.open({ path: [{ source: "people", item: user("marvin", "Marvin") }], query: "" }),
|
|
2396
|
+
)
|
|
2397
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
2398
|
+
expect(within(list).getByText("Search in Marvin")).toBeTruthy()
|
|
2399
|
+
// `minQueryLength` 1: nothing runs, so the prompt; with a query, the source loads.
|
|
2400
|
+
type("a")
|
|
2401
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
2402
|
+
expect(skeletonRows(list)).toHaveLength(3)
|
|
2403
|
+
})
|
|
2404
|
+
|
|
2405
|
+
it("keeps the delay once a row is on screen", async () => {
|
|
2406
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
2407
|
+
sources: [onScreen, slow("one", 0)],
|
|
2408
|
+
})
|
|
2409
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2410
|
+
act(() => spotlight.open({ query: "a" }))
|
|
2411
|
+
await act(() => vi.advanceTimersByTimeAsync(0))
|
|
2412
|
+
const list = screen.getByTestId("spotlight-list")
|
|
2413
|
+
expect(screen.getByTestId("spotlight-item-shown-always")).toBeTruthy()
|
|
2414
|
+
expect(skeletonRows(list)).toHaveLength(0)
|
|
2415
|
+
await act(() => vi.advanceTimersByTimeAsync(130))
|
|
2416
|
+
expect(skeletonRows(list)).toHaveLength(3)
|
|
2417
|
+
})
|
|
2418
|
+
})
|
|
2419
|
+
|
|
2420
|
+
it("holds the prompt's height as the floor of the first key typed over it", async () => {
|
|
2421
|
+
const { source, answer } = held()
|
|
2422
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [source] })
|
|
2423
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2424
|
+
act(() => spotlight.open({ path: [{ source: "held" }], query: "" }))
|
|
2425
|
+
await within(await screen.findByTestId("spotlight-list")).findByText("Search Held")
|
|
2426
|
+
const scroller = screen
|
|
2427
|
+
.getByTestId("spotlight-list")
|
|
2428
|
+
.querySelector("[data-part=list]") as HTMLElement
|
|
2429
|
+
const wrapper = scroller.firstElementChild?.firstElementChild as HTMLElement
|
|
2430
|
+
const target = () => scroller.style.getPropertyValue("--spotlight-list-height")
|
|
2431
|
+
resize(wrapper, 168)
|
|
2432
|
+
|
|
2433
|
+
// Nothing to show yet: the list doesn't collapse under the busy source.
|
|
2434
|
+
type("t")
|
|
2435
|
+
await waitFor(() => expect(spotlight.getState().sources[0]?.status).toBe("loading"))
|
|
2436
|
+
resize(wrapper, 0)
|
|
2437
|
+
expect(target()).toBe("168px")
|
|
2438
|
+
await answer([user("t", "Turing")])
|
|
2439
|
+
await screen.findByTestId("spotlight-item-held-t")
|
|
2440
|
+
resize(wrapper, 90)
|
|
2441
|
+
expect(target()).toBe("90px")
|
|
2442
|
+
|
|
2443
|
+
// Leaving the chip is a new search, free of the prompt's floor.
|
|
2444
|
+
act(() => spotlight.setPath([]))
|
|
2445
|
+
resize(wrapper, 0)
|
|
2446
|
+
expect(target()).toBe("0px")
|
|
2447
|
+
})
|
|
2448
|
+
|
|
2449
|
+
it("lets the first height of a query shrink from the empty query's menu", async () => {
|
|
2450
|
+
const { source, answer } = held()
|
|
2451
|
+
const commands = staticSource({
|
|
2452
|
+
id: "commands",
|
|
2453
|
+
label: "Commands",
|
|
2454
|
+
minQueryLength: 0,
|
|
2455
|
+
items: [{ id: "a", title: "Alpha" }],
|
|
2456
|
+
})
|
|
2457
|
+
const { spotlight, SpotlightProvider } = createSpotlight({ sources: [commands, source] })
|
|
2458
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2459
|
+
act(() => spotlight.open())
|
|
2460
|
+
await screen.findByTestId("spotlight-item-commands-a")
|
|
2461
|
+
const scroller = screen
|
|
2462
|
+
.getByTestId("spotlight-list")
|
|
2463
|
+
.querySelector("[data-part=list]") as HTMLElement
|
|
2464
|
+
const wrapper = scroller.firstElementChild?.firstElementChild as HTMLElement
|
|
2465
|
+
const target = () => scroller.style.getPropertyValue("--spotlight-list-height")
|
|
2466
|
+
resize(wrapper, 400)
|
|
2467
|
+
|
|
2468
|
+
// The suggestions aren't results: the first keystroke's height is free.
|
|
2469
|
+
type("x")
|
|
2470
|
+
await waitFor(() => expect(spotlight.getState().sources[1]?.status).toBe("loading"))
|
|
2471
|
+
resize(wrapper, 90)
|
|
2472
|
+
expect(target()).toBe("90px")
|
|
2473
|
+
resize(wrapper, 60)
|
|
2474
|
+
expect(target()).toBe("90px")
|
|
2475
|
+
await answer([])
|
|
2476
|
+
})
|
|
2477
|
+
})
|
|
2478
|
+
|
|
2479
|
+
describe("icons", () => {
|
|
2480
|
+
const sources = () => [
|
|
2481
|
+
staticSource({
|
|
2482
|
+
id: "users",
|
|
2483
|
+
label: "User",
|
|
2484
|
+
items: [user("marvin", "Marvin"), user("ford", "Ford")],
|
|
2485
|
+
within: () => [],
|
|
2486
|
+
}),
|
|
2487
|
+
]
|
|
2488
|
+
const searchSlot = () => input().parentElement?.firstElementChild
|
|
2489
|
+
const enter = () => screen.getByTestId("spotlight-item-users-marvin-enter")
|
|
2490
|
+
const seeAll = () => screen.getByTestId("spotlight-see-all-users")
|
|
2491
|
+
|
|
2492
|
+
it("draws the default magnifier and chevrons", async () => {
|
|
2493
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
2494
|
+
sources: sources(),
|
|
2495
|
+
limit: { unscoped: 1 },
|
|
2496
|
+
})
|
|
2497
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2498
|
+
act(() => spotlight.open({ query: "r" }))
|
|
2499
|
+
await screen.findByTestId("spotlight-item-users-marvin")
|
|
2500
|
+
expect(searchSlot()?.querySelector("svg")).toBeTruthy()
|
|
2501
|
+
expect(enter().querySelector("svg")).toBeTruthy()
|
|
2502
|
+
expect(seeAll().querySelector("svg")).toBeTruthy()
|
|
2503
|
+
})
|
|
2504
|
+
|
|
2505
|
+
it("lays the provider's icons over the factory's, key by key", async () => {
|
|
2506
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
2507
|
+
sources: sources(),
|
|
2508
|
+
limit: { unscoped: 1 },
|
|
2509
|
+
icons: { search: <i>find</i>, enter: <i>in</i> },
|
|
2510
|
+
})
|
|
2511
|
+
render(<SpotlightProvider testId="spotlight" icons={{ enter: <i>dive</i> }} />)
|
|
2512
|
+
act(() => spotlight.open({ query: "r" }))
|
|
2513
|
+
await screen.findByTestId("spotlight-item-users-marvin")
|
|
2514
|
+
expect(searchSlot()?.textContent).toBe("find")
|
|
2515
|
+
expect(enter().textContent).toBe("dive")
|
|
2516
|
+
expect(seeAll().querySelector("svg")).toBeTruthy()
|
|
2517
|
+
})
|
|
2518
|
+
|
|
2519
|
+
it("drops the magnifier and the See all mark for `null`", async () => {
|
|
2520
|
+
const { spotlight, SpotlightProvider } = createSpotlight({
|
|
2521
|
+
sources: sources(),
|
|
2522
|
+
limit: { unscoped: 1 },
|
|
2523
|
+
icons: { search: null, seeAll: null },
|
|
2524
|
+
})
|
|
2525
|
+
render(<SpotlightProvider testId="spotlight" />)
|
|
2526
|
+
act(() => spotlight.open({ query: "r" }))
|
|
2527
|
+
await screen.findByTestId("spotlight-item-users-marvin")
|
|
2528
|
+
expect(searchSlot()).toBe(input())
|
|
2529
|
+
expect(seeAll().querySelector("svg")).toBeNull()
|
|
2530
|
+
expect(seeAll().textContent).toBe("See all in User")
|
|
2531
|
+
})
|
|
2532
|
+
})
|