@krizaka/ui 4.6.0 → 4.7.1
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/README.md +1 -0
- package/dist/{RotatingWord-D3tpDLE4.d.ts → RotatingWord-CkDcPH9x.d.ts} +2 -2
- package/dist/account-menu.js +2 -2
- package/dist/account-menu.js.map +1 -1
- package/dist/account-settings.d.ts +9 -9
- package/dist/account-settings.js +4 -4
- package/dist/account-settings.js.map +1 -1
- package/dist/achievement.d.ts +3 -3
- package/dist/achievement.js +1 -1
- package/dist/achievement.js.map +1 -1
- package/dist/action-bar.d.ts +1 -1
- package/dist/action-bar.js +5 -5
- package/dist/action-bar.js.map +1 -1
- package/dist/activity-feed.d.ts +2 -2
- package/dist/activity-feed.js +1 -1
- package/dist/activity-feed.js.map +1 -1
- package/dist/alert.d.ts +1 -1
- package/dist/alert.js.map +1 -1
- package/dist/analysis-report.d.ts +1 -1
- package/dist/analysis-report.js +4 -4
- package/dist/analysis-report.js.map +1 -1
- package/dist/anatomy-plate.d.ts +1 -1
- package/dist/anatomy-plate.js +1 -1
- package/dist/anatomy-plate.js.map +1 -1
- package/dist/app-header/search.d.ts +1 -1
- package/dist/app-header/search.js +2 -2
- package/dist/app-header/search.js.map +1 -1
- package/dist/app-header.d.ts +2 -2
- package/dist/app-header.js.map +1 -1
- package/dist/app-shell.d.ts +8 -8
- package/dist/app-shell.js +4 -4
- package/dist/app-shell.js.map +1 -1
- package/dist/architecture-diagram.d.ts +46 -0
- package/dist/architecture-diagram.js +324 -0
- package/dist/architecture-diagram.js.map +1 -0
- package/dist/argument-card.d.ts +2 -2
- package/dist/argument-card.js +8 -8
- package/dist/argument-card.js.map +1 -1
- package/dist/auth-layout.d.ts +1 -1
- package/dist/auth-layout.js.map +1 -1
- package/dist/avatar.d.ts +2 -2
- package/dist/avatar.js.map +1 -1
- package/dist/badge.d.ts +1 -1
- package/dist/badge.js +1 -1
- package/dist/bird-plate.d.ts +1 -1
- package/dist/bird-plate.js +2 -2
- package/dist/bird-plate.js.map +1 -1
- package/dist/blocks.css +33 -0
- package/dist/button.d.ts +2 -2
- package/dist/button.js +3 -3
- package/dist/captcha.d.ts +2 -2
- package/dist/captcha.js +3 -3
- package/dist/captcha.js.map +1 -1
- package/dist/card-grid.d.ts +1 -1
- package/dist/card-grid.js +1 -1
- package/dist/card-grid.js.map +1 -1
- package/dist/card.d.ts +9 -9
- package/dist/card.js +1 -1
- package/dist/card.js.map +1 -1
- package/dist/catalogue-page.d.ts +2 -2
- package/dist/catalogue-page.js.map +1 -1
- package/dist/changelog-page.d.ts +1 -1
- package/dist/changelog-page.js +2 -2
- package/dist/changelog-page.js.map +1 -1
- package/dist/chapter.d.ts +3 -3
- package/dist/chapter.js +2 -2
- package/dist/chapter.js.map +1 -1
- package/dist/chat.d.ts +3 -3
- package/dist/chat.js +1 -1
- package/dist/chat.js.map +1 -1
- package/dist/checkbox.d.ts +1 -1
- package/dist/checkbox.js.map +1 -1
- package/dist/chip-link.d.ts +1 -1
- package/dist/chip-link.js +1 -1
- package/dist/chip-row.d.ts +2 -2
- package/dist/chip-row.js +1 -1
- package/dist/chip-row.js.map +1 -1
- package/dist/chip.d.ts +4 -5
- package/dist/chip.js +2 -2
- package/dist/choice-grid.d.ts +1 -1
- package/dist/choice-grid.js +2 -2
- package/dist/choice-grid.js.map +1 -1
- package/dist/{chunk-S6NYGOJT.js → chunk-22IORLB5.js} +1 -1
- package/dist/chunk-22IORLB5.js.map +1 -0
- package/dist/{chunk-QA3WETWT.js → chunk-2P7Y3LNN.js} +1 -1
- package/dist/chunk-2P7Y3LNN.js.map +1 -0
- package/dist/{chunk-OGWB76BR.js → chunk-3CEMOJBL.js} +2 -2
- package/dist/chunk-3CEMOJBL.js.map +1 -0
- package/dist/{chunk-WC3SO4CE.js → chunk-3SWWUJJL.js} +2 -2
- package/dist/chunk-3SWWUJJL.js.map +1 -0
- package/dist/{chunk-S2O4NSN5.js → chunk-3TCHVNNB.js} +1 -1
- package/dist/chunk-3TCHVNNB.js.map +1 -0
- package/dist/{chunk-7P7I5OQV.js → chunk-5KBYZLU4.js} +2 -2
- package/dist/chunk-5KBYZLU4.js.map +1 -0
- package/dist/{chunk-WKQ5CB3I.js → chunk-6ARAO3TR.js} +1 -1
- package/dist/{chunk-WKQ5CB3I.js.map → chunk-6ARAO3TR.js.map} +1 -1
- package/dist/{chunk-QHVV2JGF.js → chunk-6LF6IZZM.js} +2 -2
- package/dist/chunk-6LF6IZZM.js.map +1 -0
- package/dist/{chunk-HP7BDMVK.js → chunk-7B5Q76JR.js} +2 -2
- package/dist/chunk-7B5Q76JR.js.map +1 -0
- package/dist/{chunk-F2UZ2WWL.js → chunk-7KIIAOQH.js} +1 -1
- package/dist/{chunk-F2UZ2WWL.js.map → chunk-7KIIAOQH.js.map} +1 -1
- package/dist/{chunk-ADRUEPYC.js → chunk-7MA3UODW.js} +2 -2
- package/dist/{chunk-ADRUEPYC.js.map → chunk-7MA3UODW.js.map} +1 -1
- package/dist/{chunk-KH3JOEPY.js → chunk-7PVLEALV.js} +1 -1
- package/dist/chunk-7PVLEALV.js.map +1 -0
- package/dist/{chunk-QVHSV6RA.js → chunk-7UBLUGNW.js} +1 -1
- package/dist/chunk-7UBLUGNW.js.map +1 -0
- package/dist/{chunk-YTYNKMNS.js → chunk-BKMHN4UA.js} +5 -5
- package/dist/chunk-BKMHN4UA.js.map +1 -0
- package/dist/{chunk-4QH6CP2Y.js → chunk-BRYRZWLV.js} +1 -1
- package/dist/{chunk-4QH6CP2Y.js.map → chunk-BRYRZWLV.js.map} +1 -1
- package/dist/{chunk-43PTCDTL.js → chunk-BVN7JFOP.js} +1 -1
- package/dist/chunk-BVN7JFOP.js.map +1 -0
- package/dist/{chunk-5RWHDX5J.js → chunk-BYKA3FHX.js} +2 -2
- package/dist/chunk-BYKA3FHX.js.map +1 -0
- package/dist/{chunk-5PFCELGW.js → chunk-DIOAQOR5.js} +1 -1
- package/dist/chunk-DIOAQOR5.js.map +1 -0
- package/dist/{chunk-HJFRHYCI.js → chunk-DTGRZXYO.js} +2 -2
- package/dist/{chunk-P7AFIKWG.js → chunk-DVC4YQI2.js} +2 -2
- package/dist/chunk-DVC4YQI2.js.map +1 -0
- package/dist/{chunk-V5RO6JYI.js → chunk-E3LFHTUV.js} +2 -2
- package/dist/chunk-E3LFHTUV.js.map +1 -0
- package/dist/{chunk-WEVYKZIF.js → chunk-EAXIDRMB.js} +1 -1
- package/dist/chunk-EAXIDRMB.js.map +1 -0
- package/dist/{chunk-WU4VLSEA.js → chunk-EYMS6VRF.js} +1 -1
- package/dist/chunk-EYMS6VRF.js.map +1 -0
- package/dist/{chunk-LH5J3VLZ.js → chunk-F7EJZV53.js} +1 -1
- package/dist/chunk-F7EJZV53.js.map +1 -0
- package/dist/{chunk-VPO27AFS.js → chunk-G3L7AKZJ.js} +1 -1
- package/dist/chunk-G3L7AKZJ.js.map +1 -0
- package/dist/{chunk-EB45EVPJ.js → chunk-G5NROYGK.js} +3 -3
- package/dist/chunk-G5NROYGK.js.map +1 -0
- package/dist/{chunk-HKEAYSFS.js → chunk-GQMINKT3.js} +1 -1
- package/dist/{chunk-ENOS6ETI.js.map → chunk-GQMINKT3.js.map} +1 -1
- package/dist/{chunk-3X3OF4TI.js → chunk-H4NXYAL7.js} +1 -1
- package/dist/{chunk-3X3OF4TI.js.map → chunk-H4NXYAL7.js.map} +1 -1
- package/dist/{chunk-KR2W4ONJ.js → chunk-H7I6YLI6.js} +1 -1
- package/dist/chunk-H7I6YLI6.js.map +1 -0
- package/dist/{chunk-PJNR4NTS.js → chunk-HC2TY45B.js} +4 -4
- package/dist/{chunk-NSLXEDIS.js → chunk-HHBTM4AU.js} +1 -1
- package/dist/chunk-HHBTM4AU.js.map +1 -0
- package/dist/{chunk-XVRKKYWU.js → chunk-HVUR3UNK.js} +2 -2
- package/dist/{chunk-XVRKKYWU.js.map → chunk-HVUR3UNK.js.map} +1 -1
- package/dist/{chunk-V7W4RLRW.js → chunk-HWIDTLLO.js} +3 -3
- package/dist/chunk-HWIDTLLO.js.map +1 -0
- package/dist/{chunk-W675RFOA.js → chunk-ISC2QBXJ.js} +1 -1
- package/dist/chunk-ISC2QBXJ.js.map +1 -0
- package/dist/{chunk-7DYZTEE3.js → chunk-IWPB6SSW.js} +1 -1
- package/dist/chunk-IWPB6SSW.js.map +1 -0
- package/dist/{chunk-TVLRE7S3.js → chunk-JDVWUF5W.js} +2 -2
- package/dist/{chunk-TVLRE7S3.js.map → chunk-JDVWUF5W.js.map} +1 -1
- package/dist/{chunk-757ZTGU5.js → chunk-JE2NY4XE.js} +4 -4
- package/dist/chunk-JE2NY4XE.js.map +1 -0
- package/dist/{chunk-HLEBSAGC.js → chunk-KBSZ6JRF.js} +2 -2
- package/dist/chunk-KBSZ6JRF.js.map +1 -0
- package/dist/{chunk-Y3P5B4XS.js → chunk-KCU45KQ3.js} +3 -3
- package/dist/chunk-KCU45KQ3.js.map +1 -0
- package/dist/{chunk-ST5P5HNI.js → chunk-L4YBG5US.js} +4 -4
- package/dist/{chunk-ST5P5HNI.js.map → chunk-L4YBG5US.js.map} +1 -1
- package/dist/{chunk-NG6G6V5E.js → chunk-LFH3LEWR.js} +1 -1
- package/dist/chunk-LFH3LEWR.js.map +1 -0
- package/dist/{chunk-YATTFMDV.js → chunk-LSQQSJ6J.js} +2 -2
- package/dist/{chunk-YATTFMDV.js.map → chunk-LSQQSJ6J.js.map} +1 -1
- package/dist/{chunk-LNAAWT4Y.js → chunk-MJWOZ3JI.js} +1 -1
- package/dist/chunk-MJWOZ3JI.js.map +1 -0
- package/dist/{chunk-KID32IRJ.js → chunk-MXHJMTZ5.js} +1 -1
- package/dist/{chunk-KID32IRJ.js.map → chunk-MXHJMTZ5.js.map} +1 -1
- package/dist/{chunk-GHAN7OOE.js → chunk-N6LAWI4F.js} +2 -2
- package/dist/chunk-N6LAWI4F.js.map +1 -0
- package/dist/{chunk-5VZ37TY3.js → chunk-NFJWD5BT.js} +2 -2
- package/dist/chunk-NFJWD5BT.js.map +1 -0
- package/dist/{chunk-ZPOVOEO3.js → chunk-NJLIHGU4.js} +2 -2
- package/dist/chunk-NJLIHGU4.js.map +1 -0
- package/dist/{chunk-PRD7JRQX.js → chunk-ONCQWOTH.js} +4 -4
- package/dist/{chunk-PRD7JRQX.js.map → chunk-ONCQWOTH.js.map} +1 -1
- package/dist/{chunk-ENOS6ETI.js → chunk-OZC6CDZF.js} +1 -1
- package/dist/{chunk-HKEAYSFS.js.map → chunk-OZC6CDZF.js.map} +1 -1
- package/dist/{chunk-TXFX4PMN.js → chunk-OZY4C4W5.js} +1 -1
- package/dist/{chunk-TXFX4PMN.js.map → chunk-OZY4C4W5.js.map} +1 -1
- package/dist/{chunk-NPMGYLJV.js → chunk-PIRYDEX2.js} +3 -3
- package/dist/chunk-PIRYDEX2.js.map +1 -0
- package/dist/{chunk-C57KK5VB.js → chunk-PM23USOC.js} +1 -1
- package/dist/chunk-PM23USOC.js.map +1 -0
- package/dist/{chunk-PGBF3UBX.js → chunk-QKL5TECH.js} +1 -1
- package/dist/chunk-QKL5TECH.js.map +1 -0
- package/dist/{chunk-Z47KIPCT.js → chunk-QY5JEUJT.js} +1 -1
- package/dist/chunk-QY5JEUJT.js.map +1 -0
- package/dist/{chunk-FVGFPB73.js → chunk-RPVKF4RR.js} +1 -1
- package/dist/{chunk-FVGFPB73.js.map → chunk-RPVKF4RR.js.map} +1 -1
- package/dist/{chunk-NM2DEHFZ.js → chunk-RXYKJIC4.js} +1 -1
- package/dist/chunk-RXYKJIC4.js.map +1 -0
- package/dist/{chunk-W64RAX4N.js → chunk-TKYNYIJS.js} +5 -5
- package/dist/chunk-TKYNYIJS.js.map +1 -0
- package/dist/{chunk-S4TLZRGZ.js → chunk-UMXWOA3I.js} +1 -1
- package/dist/chunk-UMXWOA3I.js.map +1 -0
- package/dist/{chunk-VA4NPCUQ.js → chunk-VD7QFUAP.js} +3 -3
- package/dist/chunk-VD7QFUAP.js.map +1 -0
- package/dist/{chunk-MDSP7DJR.js → chunk-VQELCPQJ.js} +5 -5
- package/dist/chunk-VQELCPQJ.js.map +1 -0
- package/dist/{chunk-2FCQCWIK.js → chunk-VXNBXW3P.js} +5 -5
- package/dist/chunk-VXNBXW3P.js.map +1 -0
- package/dist/{chunk-B47WSPMP.js → chunk-WPUDPH2Q.js} +1 -1
- package/dist/chunk-WPUDPH2Q.js.map +1 -0
- package/dist/{chunk-SG2RKUVJ.js → chunk-WTZUMVJI.js} +5 -5
- package/dist/chunk-WTZUMVJI.js.map +1 -0
- package/dist/{chunk-EDQLPCM4.js → chunk-WVZF6WK3.js} +2 -2
- package/dist/chunk-WVZF6WK3.js.map +1 -0
- package/dist/{chunk-5D7NMUF6.js → chunk-XDAETKWM.js} +2 -2
- package/dist/chunk-XDAETKWM.js.map +1 -0
- package/dist/{chunk-QD6SNXF5.js → chunk-XDWSGNL4.js} +3 -3
- package/dist/chunk-XDWSGNL4.js.map +1 -0
- package/dist/{chunk-SB5WSVPI.js → chunk-ZFH2BYXW.js} +2 -2
- package/dist/chunk-ZFH2BYXW.js.map +1 -0
- package/dist/{chunk-XVLWVTQA.js → chunk-ZI7K742O.js} +1 -1
- package/dist/{chunk-XVLWVTQA.js.map → chunk-ZI7K742O.js.map} +1 -1
- package/dist/{chunk-NQENOT6L.js → chunk-ZRRWSKV3.js} +8 -8
- package/dist/chunk-ZRRWSKV3.js.map +1 -0
- package/dist/cn.js +1 -1
- package/dist/code-block.d.ts +2 -2
- package/dist/code-block.js +2 -2
- package/dist/code-block.js.map +1 -1
- package/dist/collection-switcher.d.ts +1 -1
- package/dist/collection-switcher.js +1 -1
- package/dist/collection-switcher.js.map +1 -1
- package/dist/columns.d.ts +2 -2
- package/dist/columns.js.map +1 -1
- package/dist/combobox.js +4 -4
- package/dist/command.d.ts +10 -10
- package/dist/command.js +4 -4
- package/dist/command.js.map +1 -1
- package/dist/comparison-table.d.ts +1 -1
- package/dist/comparison-table.js +1 -1
- package/dist/comparison-table.js.map +1 -1
- package/dist/component-page.d.ts +1 -1
- package/dist/component-page.js.map +1 -1
- package/dist/confirm-button.d.ts +1 -1
- package/dist/confirm-button.js +4 -4
- package/dist/contact-page.d.ts +1 -1
- package/dist/contact-page.js.map +1 -1
- package/dist/continue-prompt.d.ts +1 -1
- package/dist/continue-prompt.js +1 -1
- package/dist/continue-prompt.js.map +1 -1
- package/dist/copy-button.d.ts +1 -1
- package/dist/copy-button.js +4 -4
- package/dist/copy-button.js.map +1 -1
- package/dist/countdown.d.ts +1 -1
- package/dist/countdown.js.map +1 -1
- package/dist/cover-hero.d.ts +1 -1
- package/dist/cover-hero.js +5 -5
- package/dist/cover-hero.js.map +1 -1
- package/dist/cta-panel.d.ts +1 -1
- package/dist/cta-panel.js +1 -1
- package/dist/cta-panel.js.map +1 -1
- package/dist/dashboard-layout.d.ts +2 -2
- package/dist/dashboard-layout.js.map +1 -1
- package/dist/data-table.d.ts +5 -5
- package/dist/data-table.js +9 -9
- package/dist/date-picker.d.ts +11 -11
- package/dist/date-picker.js +5 -5
- package/dist/date-picker.js.map +1 -1
- package/dist/decision-list.d.ts +1 -1
- package/dist/decision-list.js +2 -2
- package/dist/decision-list.js.map +1 -1
- package/dist/description-list.d.ts +2 -2
- package/dist/description-list.js.map +1 -1
- package/dist/detail-layout.d.ts +5 -5
- package/dist/detail-layout.js +1 -1
- package/dist/detail-layout.js.map +1 -1
- package/dist/{dialog-DpUwec2g.d.ts → dialog-CFnxFGyn.d.ts} +7 -7
- package/dist/dialog.d.ts +2 -2
- package/dist/dialog.js +4 -4
- package/dist/dialog.js.map +1 -1
- package/dist/docs-article-page.d.ts +1 -1
- package/dist/docs-article-page.js.map +1 -1
- package/dist/docs-hub-page.d.ts +1 -1
- package/dist/docs-hub-page.js.map +1 -1
- package/dist/docs-layout.d.ts +1 -1
- package/dist/docs-layout.js +1 -1
- package/dist/docs-layout.js.map +1 -1
- package/dist/docs-nav.d.ts +1 -1
- package/dist/docs-nav.js +1 -1
- package/dist/docs-nav.js.map +1 -1
- package/dist/document-viewer.d.ts +2 -2
- package/dist/document-viewer.js +3 -3
- package/dist/document-viewer.js.map +1 -1
- package/dist/doodle.d.ts +1 -1
- package/dist/doodle.js +1 -1
- package/dist/doodle.js.map +1 -1
- package/dist/drop-overlay.d.ts +1 -1
- package/dist/drop-overlay.js +1 -1
- package/dist/drop-overlay.js.map +1 -1
- package/dist/dropdown-menu.d.ts +8 -8
- package/dist/dropdown-menu.js +2 -2
- package/dist/embed-facade.js +1 -1
- package/dist/empty-state.d.ts +1 -1
- package/dist/empty-state.js.map +1 -1
- package/dist/engine-flow.d.ts +1 -1
- package/dist/engine-flow.js +1 -1
- package/dist/engine-flow.js.map +1 -1
- package/dist/entity-header.d.ts +1 -1
- package/dist/entity-header.js +1 -1
- package/dist/entity-header.js.map +1 -1
- package/dist/environment-notice.d.ts +1 -1
- package/dist/environment-notice.js.map +1 -1
- package/dist/error-page.d.ts +1 -1
- package/dist/error-page.js +1 -1
- package/dist/error-page.js.map +1 -1
- package/dist/field.d.ts +3 -3
- package/dist/field.js +1 -1
- package/dist/field.js.map +1 -1
- package/dist/file-upload.d.ts +1 -1
- package/dist/file-upload.js +1 -1
- package/dist/file-upload.js.map +1 -1
- package/dist/filter-bar.d.ts +2 -2
- package/dist/filter-bar.js +4 -4
- package/dist/flock.d.ts +1 -1
- package/dist/flock.js +2 -2
- package/dist/flock.js.map +1 -1
- package/dist/footnote.d.ts +3 -3
- package/dist/footnote.js +1 -1
- package/dist/footnote.js.map +1 -1
- package/dist/force-update-screen.d.ts +1 -1
- package/dist/force-update-screen.js +3 -3
- package/dist/force-update-screen.js.map +1 -1
- package/dist/form/server.js.map +1 -1
- package/dist/form.d.ts +12 -12
- package/dist/form.js +4 -4
- package/dist/form.js.map +1 -1
- package/dist/{frame-CmDztC_y.d.ts → frame-D5HU_cG8.d.ts} +2 -2
- package/dist/gallery-page.d.ts +1 -1
- package/dist/gallery-page.js +1 -1
- package/dist/gallery-page.js.map +1 -1
- package/dist/genui.d.ts +2 -2
- package/dist/genui.js +9 -9
- package/dist/genui.js.map +1 -1
- package/dist/glossary-term.js +2 -2
- package/dist/glow-card.d.ts +1 -1
- package/dist/glow-card.js +1 -1
- package/dist/glow-card.js.map +1 -1
- package/dist/goal-gauge.d.ts +1 -1
- package/dist/goal-gauge.js +1 -1
- package/dist/goal-gauge.js.map +1 -1
- package/dist/grade-stamp.d.ts +1 -1
- package/dist/grade-stamp.js +2 -2
- package/dist/grade-stamp.js.map +1 -1
- package/dist/identity-card.d.ts +1 -1
- package/dist/identity-card.js +5 -5
- package/dist/identity-card.js.map +1 -1
- package/dist/image-cropper.d.ts +1 -1
- package/dist/image-cropper.js +3 -3
- package/dist/image-cropper.js.map +1 -1
- package/dist/index.d.ts +5 -5
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/kanban.d.ts +1 -1
- package/dist/kanban.js.map +1 -1
- package/dist/kbd.d.ts +1 -1
- package/dist/kbd.js.map +1 -1
- package/dist/kind-config-editor.js +8 -8
- package/dist/kind-config-editor.js.map +1 -1
- package/dist/kpi-explained.js +1 -1
- package/dist/kpi-explained.js.map +1 -1
- package/dist/landing-page.d.ts +1 -1
- package/dist/landing-page.js.map +1 -1
- package/dist/landscape.d.ts +1 -1
- package/dist/landscape.js +2 -2
- package/dist/landscape.js.map +1 -1
- package/dist/language-switch.d.ts +1 -1
- package/dist/language-switch.js +1 -1
- package/dist/legal-page.d.ts +1 -1
- package/dist/legal-page.js.map +1 -1
- package/dist/{lightbox-MRB2YZEP.js → lightbox-JLWASIJC.js} +4 -4
- package/dist/link-card.d.ts +1 -1
- package/dist/link-card.js +4 -4
- package/dist/list.d.ts +1 -1
- package/dist/list.js +2 -2
- package/dist/list.js.map +1 -1
- package/dist/loader.d.ts +2 -2
- package/dist/loader.js +1 -1
- package/dist/loader.js.map +1 -1
- package/dist/longform-page.d.ts +1 -1
- package/dist/longform-page.js +1 -1
- package/dist/longform-page.js.map +1 -1
- package/dist/maintenance-screen.d.ts +1 -1
- package/dist/maintenance-screen.js +3 -3
- package/dist/maintenance-screen.js.map +1 -1
- package/dist/map/cards.d.ts +2 -2
- package/dist/map/cards.js +1 -1
- package/dist/map/cards.js.map +1 -1
- package/dist/map/pin.js +1 -1
- package/dist/map/sheet.d.ts +1 -1
- package/dist/map/sheet.js +1 -1
- package/dist/map/sheet.js.map +1 -1
- package/dist/map.d.ts +5 -5
- package/dist/map.js +4 -4
- package/dist/map.js.map +1 -1
- package/dist/margin-layout.d.ts +2 -2
- package/dist/margin-layout.js.map +1 -1
- package/dist/markdown.d.ts +1 -1
- package/dist/markdown.js.map +1 -1
- package/dist/marketing-layout.d.ts +1 -1
- package/dist/marketing-layout.js.map +1 -1
- package/dist/mascot-quote.d.ts +1 -1
- package/dist/mascot-quote.js +2 -2
- package/dist/mascot-quote.js.map +1 -1
- package/dist/mascot-state.d.ts +5 -5
- package/dist/mascot-state.js +1 -1
- package/dist/mascot-state.js.map +1 -1
- package/dist/mascots.d.ts +2 -2
- package/dist/mascots.js +2 -2
- package/dist/mascots.js.map +1 -1
- package/dist/match-dialog.d.ts +1 -1
- package/dist/match-dialog.js +4 -4
- package/dist/match-dialog.js.map +1 -1
- package/dist/media-capture.d.ts +1 -1
- package/dist/media-capture.js +1 -1
- package/dist/media-capture.js.map +1 -1
- package/dist/media-carousel.js +5 -5
- package/dist/media-carousel.js.map +1 -1
- package/dist/media-gallery.d.ts +1 -1
- package/dist/media-gallery.js +1 -1
- package/dist/media-gallery.js.map +1 -1
- package/dist/media-player.d.ts +1 -1
- package/dist/media-player.js +4 -4
- package/dist/meter.d.ts +2 -2
- package/dist/meter.js +1 -1
- package/dist/money-input.d.ts +1 -1
- package/dist/money-input.js +3 -3
- package/dist/motion.d.ts +1 -1
- package/dist/motion.js +1 -1
- package/dist/native/form.d.ts +12 -12
- package/dist/native/form.js +4 -4
- package/dist/native/form.js.map +1 -1
- package/dist/native/list.d.ts +1 -1
- package/dist/native/list.js.map +1 -1
- package/dist/native/map.d.ts +4 -4
- package/dist/native/map.js +2 -2
- package/dist/native/map.js.map +1 -1
- package/dist/native/markdown.js.map +1 -1
- package/dist/native/media-capture.d.ts +1 -1
- package/dist/native/media-capture.js.map +1 -1
- package/dist/native/media-picker.d.ts +1 -1
- package/dist/native/media-picker.js.map +1 -1
- package/dist/native/vertical-video.d.ts +2 -2
- package/dist/native/vertical-video.js.map +1 -1
- package/dist/native/video-player.d.ts +1 -1
- package/dist/native/video-player.js.map +1 -1
- package/dist/native.d.ts +95 -95
- package/dist/native.js +13 -13
- package/dist/native.js.map +1 -1
- package/dist/nav-bar.d.ts +13 -13
- package/dist/nav-bar.js +5 -5
- package/dist/nav-bar.js.map +1 -1
- package/dist/notification-preferences.js +3 -3
- package/dist/number-ticker.d.ts +1 -1
- package/dist/number-ticker.js +1 -1
- package/dist/number-ticker.js.map +1 -1
- package/dist/opening-hours.d.ts +1 -1
- package/dist/opening-hours.js +1 -1
- package/dist/opening-hours.js.map +1 -1
- package/dist/{page-DPHDmDAQ.d.ts → page-Ufnb5TrQ.d.ts} +5 -5
- package/dist/page-header.d.ts +1 -1
- package/dist/page-header.js.map +1 -1
- package/dist/page-hero.d.ts +1 -1
- package/dist/page-hero.js +5 -5
- package/dist/page-hero.js.map +1 -1
- package/dist/page-index.d.ts +1 -1
- package/dist/page-index.js +2 -2
- package/dist/page-index.js.map +1 -1
- package/dist/page.d.ts +1 -1
- package/dist/page.js +3 -3
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +1 -1
- package/dist/pagination.js.map +1 -1
- package/dist/pausable-loop.js +2 -2
- package/dist/{player-lightbox-BYQ57OXT.js → player-lightbox-SJR3GB7U.js} +5 -5
- package/dist/player-lightbox-SJR3GB7U.js.map +1 -0
- package/dist/pointer-light.d.ts +1 -1
- package/dist/pointer-light.js.map +1 -1
- package/dist/popover.d.ts +1 -1
- package/dist/popover.js +1 -1
- package/dist/popover.js.map +1 -1
- package/dist/price-catalogue-editor.js +8 -8
- package/dist/price-catalogue-editor.js.map +1 -1
- package/dist/pricing-page.d.ts +1 -1
- package/dist/pricing-page.js +1 -1
- package/dist/pricing-page.js.map +1 -1
- package/dist/product-page.d.ts +1 -1
- package/dist/product-page.js +1 -1
- package/dist/product-page.js.map +1 -1
- package/dist/profile-card.d.ts +3 -3
- package/dist/profile-card.js +1 -1
- package/dist/profile-card.js.map +1 -1
- package/dist/progress.d.ts +1 -1
- package/dist/progress.js.map +1 -1
- package/dist/promise-card.d.ts +1 -1
- package/dist/promise-card.js +1 -1
- package/dist/promise-card.js.map +1 -1
- package/dist/promo-code-field.js +4 -4
- package/dist/proposal.js +5 -5
- package/dist/qr-code.js +6 -6
- package/dist/qr-code.js.map +1 -1
- package/dist/quota-meter.d.ts +1 -1
- package/dist/quota-meter.js +1 -1
- package/dist/quota-meter.js.map +1 -1
- package/dist/radio-group.d.ts +5 -5
- package/dist/radio-group.js +3 -3
- package/dist/radio-group.js.map +1 -1
- package/dist/rail-nav.d.ts +4 -4
- package/dist/rail-nav.js +3 -3
- package/dist/rail-nav.js.map +1 -1
- package/dist/recipes.js +1 -1
- package/dist/recipes.js.map +1 -1
- package/dist/retro-tv-playlist.d.ts +1 -1
- package/dist/retro-tv-playlist.js.map +1 -1
- package/dist/retro-tv.js +6 -6
- package/dist/retro-tv.js.map +1 -1
- package/dist/reviews.js +3 -3
- package/dist/schema-form.js +7 -7
- package/dist/schema-form.js.map +1 -1
- package/dist/scroll-stage.d.ts +2 -2
- package/dist/scroll-stage.js +2 -2
- package/dist/scroll-stage.js.map +1 -1
- package/dist/search-field.d.ts +1 -1
- package/dist/search-field.js +2 -2
- package/dist/section-backdrop.d.ts +1 -1
- package/dist/section-backdrop.js +1 -1
- package/dist/separator.d.ts +1 -1
- package/dist/separator.js.map +1 -1
- package/dist/service-card.d.ts +1 -1
- package/dist/service-card.js +6 -6
- package/dist/service-card.js.map +1 -1
- package/dist/settings-layout.d.ts +3 -3
- package/dist/settings-layout.js +2 -2
- package/dist/shop/booking.d.ts +1 -1
- package/dist/shop/booking.js +4 -4
- package/dist/shop/booking.js.map +1 -1
- package/dist/shop/bulletin.d.ts +1 -1
- package/dist/shop/bulletin.js +2 -2
- package/dist/shop/bulletin.js.map +1 -1
- package/dist/shop/faq.d.ts +1 -1
- package/dist/shop/faq.js +3 -3
- package/dist/shop/faq.js.map +1 -1
- package/dist/shop/gallery.d.ts +1 -1
- package/dist/shop/gallery.js +3 -3
- package/dist/shop/gallery.js.map +1 -1
- package/dist/shop/hero.d.ts +1 -1
- package/dist/shop/hero.js +2 -2
- package/dist/shop/hero.js.map +1 -1
- package/dist/shop/policies.d.ts +1 -1
- package/dist/shop/policies.js +2 -2
- package/dist/shop/policies.js.map +1 -1
- package/dist/shop/reviews.d.ts +1 -1
- package/dist/shop/reviews.js +2 -2
- package/dist/shop/reviews.js.map +1 -1
- package/dist/shop/services.d.ts +1 -1
- package/dist/shop/services.js +4 -4
- package/dist/shop/services.js.map +1 -1
- package/dist/shop/social.d.ts +1 -1
- package/dist/shop/social.js +2 -2
- package/dist/shop/social.js.map +1 -1
- package/dist/shop/story.d.ts +1 -1
- package/dist/shop/story.js +2 -2
- package/dist/shop/story.js.map +1 -1
- package/dist/shop/team.d.ts +1 -1
- package/dist/shop/team.js +2 -2
- package/dist/shop/team.js.map +1 -1
- package/dist/shop/video.d.ts +1 -1
- package/dist/shop/video.js +2 -2
- package/dist/shop/video.js.map +1 -1
- package/dist/shop/visit.d.ts +1 -1
- package/dist/shop/visit.js +2 -2
- package/dist/shop/visit.js.map +1 -1
- package/dist/shop-composer.js +2 -2
- package/dist/shop-composer.js.map +1 -1
- package/dist/shop-gallery.d.ts +1 -1
- package/dist/shop-gallery.js +2 -2
- package/dist/shop-gallery.js.map +1 -1
- package/dist/shop.d.ts +1 -1
- package/dist/shop.js +2 -2
- package/dist/showcase.d.ts +1 -1
- package/dist/showcase.js +6 -6
- package/dist/showcase.js.map +1 -1
- package/dist/signature.d.ts +1 -1
- package/dist/signature.js +2 -2
- package/dist/signature.js.map +1 -1
- package/dist/site-cahier.d.ts +3 -3
- package/dist/site-cahier.js +10 -10
- package/dist/site-cahier.js.map +1 -1
- package/dist/site-footer.d.ts +4 -4
- package/dist/site-footer.js +1 -1
- package/dist/site-footer.js.map +1 -1
- package/dist/skeleton.d.ts +3 -3
- package/dist/skeleton.js.map +1 -1
- package/dist/skip-link.d.ts +1 -1
- package/dist/skip-link.js +1 -1
- package/dist/slider.d.ts +1 -1
- package/dist/slider.js +2 -2
- package/dist/slider.js.map +1 -1
- package/dist/slot-picker.d.ts +1 -1
- package/dist/slot-picker.js +1 -1
- package/dist/slot-picker.js.map +1 -1
- package/dist/specimen-tag.d.ts +2 -2
- package/dist/specimen-tag.js +2 -2
- package/dist/speed-lines.d.ts +1 -1
- package/dist/speed-lines.js +1 -1
- package/dist/speed-lines.js.map +1 -1
- package/dist/spinner.d.ts +2 -2
- package/dist/spinner.js +1 -1
- package/dist/spinner.js.map +1 -1
- package/dist/split-view.d.ts +1 -1
- package/dist/split-view.js.map +1 -1
- package/dist/stage-banner.d.ts +1 -1
- package/dist/stage-banner.js +1 -1
- package/dist/stage-banner.js.map +1 -1
- package/dist/stat.d.ts +2 -2
- package/dist/stat.js +1 -1
- package/dist/status-chip.js +4 -4
- package/dist/status-chip.js.map +1 -1
- package/dist/status-page.d.ts +1 -1
- package/dist/status-page.js.map +1 -1
- package/dist/step-progress.d.ts +1 -1
- package/dist/step-progress.js.map +1 -1
- package/dist/step-showcase.d.ts +2 -2
- package/dist/step-showcase.js +3 -3
- package/dist/step-showcase.js.map +1 -1
- package/dist/stepper.d.ts +1 -1
- package/dist/stepper.js +1 -1
- package/dist/stepper.js.map +1 -1
- package/dist/sticky-action.d.ts +1 -1
- package/dist/sticky-action.js.map +1 -1
- package/dist/stuck.d.ts +1 -1
- package/dist/stuck.js +1 -1
- package/dist/stuck.js.map +1 -1
- package/dist/swipe-deck.d.ts +2 -2
- package/dist/swipe-deck.js.map +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +1 -1
- package/dist/tabs.d.ts +6 -6
- package/dist/tabs.js +1 -1
- package/dist/tabs.js.map +1 -1
- package/dist/tag-input.d.ts +1 -1
- package/dist/tag-input.js +4 -4
- package/dist/tag-input.js.map +1 -1
- package/dist/tag-selector.d.ts +1 -1
- package/dist/tag-selector.js +3 -3
- package/dist/tag-selector.js.map +1 -1
- package/dist/taped-photo.d.ts +1 -1
- package/dist/taped-photo.js +2 -2
- package/dist/terminal-replay.d.ts +1 -1
- package/dist/terminal-replay.js +3 -3
- package/dist/terminal-replay.js.map +1 -1
- package/dist/text-style/server.d.ts +1 -1
- package/dist/text-style/server.js.map +1 -1
- package/dist/text-style.d.ts +2 -2
- package/dist/text-style.js.map +1 -1
- package/dist/theme.d.ts +3 -3
- package/dist/theme.js +3 -3
- package/dist/theme.js.map +1 -1
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +2 -2
- package/dist/toast.js.map +1 -1
- package/dist/toc.d.ts +2 -2
- package/dist/toc.js +1 -1
- package/dist/toc.js.map +1 -1
- package/dist/tooltip.d.ts +1 -1
- package/dist/tooltip.js +2 -2
- package/dist/tree-view.d.ts +1 -1
- package/dist/tree-view.js +2 -2
- package/dist/tree-view.js.map +1 -1
- package/dist/update-prompt.d.ts +1 -1
- package/dist/update-prompt.js +3 -3
- package/dist/update-prompt.js.map +1 -1
- package/dist/upload-queue.d.ts +2 -2
- package/dist/upload-queue.js +1 -1
- package/dist/upload-queue.js.map +1 -1
- package/dist/usage.d.ts +4 -4
- package/dist/usage.js +3 -3
- package/dist/usage.js.map +1 -1
- package/dist/verified-badge.d.ts +1 -1
- package/dist/verified-badge.js.map +1 -1
- package/dist/versus-card.d.ts +1 -1
- package/dist/versus-card.js +2 -2
- package/dist/versus-card.js.map +1 -1
- package/dist/vertical-video.d.ts +2 -2
- package/dist/vertical-video.js +6 -6
- package/dist/vertical-video.js.map +1 -1
- package/dist/video-player.d.ts +1 -1
- package/dist/video-player.js +5 -5
- package/dist/video-trimmer.d.ts +1 -1
- package/dist/video-trimmer.js.map +1 -1
- package/dist/virtual.d.ts +2 -2
- package/dist/virtual.js +1 -1
- package/dist/wall.js +2 -2
- package/dist/wall.js.map +1 -1
- package/dist/waveform.d.ts +1 -1
- package/dist/waveform.js.map +1 -1
- package/package.json +26 -7
- package/registry/account-menu.json +1 -1
- package/registry/account-settings.json +18 -18
- package/registry/achievement.json +2 -2
- package/registry/action-bar.json +4 -4
- package/registry/activity-feed.json +3 -3
- package/registry/agenda.json +1 -1
- package/registry/alert.json +2 -2
- package/registry/analysis-report.json +2 -2
- package/registry/anatomy-plate.json +2 -2
- package/registry/app-frame.json +7 -7
- package/registry/app-header.json +5 -5
- package/registry/app-shell.json +3 -3
- package/registry/architecture-diagram.json +239 -0
- package/registry/argument-card.json +4 -4
- package/registry/auth-layout.json +2 -2
- package/registry/avatar.json +4 -4
- package/registry/badge.json +2 -2
- package/registry/bird-plate.json +2 -2
- package/registry/button.json +2 -2
- package/registry/captcha.json +2 -2
- package/registry/card-grid.json +2 -2
- package/registry/card.json +2 -2
- package/registry/catalogue-page.json +2 -2
- package/registry/changelog-page.json +3 -3
- package/registry/chapter.json +3 -3
- package/registry/chat.json +2 -2
- package/registry/checkbox.json +2 -2
- package/registry/chip-link.json +2 -2
- package/registry/chip-row.json +2 -2
- package/registry/chip.json +3 -3
- package/registry/choice-grid.json +3 -3
- package/registry/cn.json +1 -1
- package/registry/code-block.json +3 -3
- package/registry/collection-switcher.json +3 -3
- package/registry/columns.json +2 -2
- package/registry/combobox.json +3 -3
- package/registry/command.json +2 -2
- package/registry/comparison-table.json +2 -2
- package/registry/component-page.json +2 -2
- package/registry/confirm-button.json +2 -2
- package/registry/contact-page.json +2 -2
- package/registry/continue-prompt.json +2 -2
- package/registry/copy-button.json +3 -3
- package/registry/countdown.json +2 -2
- package/registry/cover-hero.json +4 -4
- package/registry/cta-panel.json +2 -2
- package/registry/dashboard-layout.json +3 -3
- package/registry/data-table.json +5 -5
- package/registry/date-picker.json +9 -9
- package/registry/decision-list.json +3 -3
- package/registry/description-list.json +2 -2
- package/registry/desktop-window.json +1 -1
- package/registry/detail-layout.json +2 -2
- package/registry/dialog.json +3 -3
- package/registry/docs-article-page.json +2 -2
- package/registry/docs-hub-page.json +2 -2
- package/registry/docs-layout.json +3 -3
- package/registry/docs-nav.json +2 -2
- package/registry/document-viewer.json +3 -3
- package/registry/doodle.json +2 -2
- package/registry/drop-overlay.json +2 -2
- package/registry/dropdown-menu.json +2 -2
- package/registry/elephant.json +1 -1
- package/registry/embed-facade.json +1 -1
- package/registry/empty-state.json +2 -2
- package/registry/engine-flow.json +2 -2
- package/registry/entity-header.json +3 -3
- package/registry/environment-notice.json +2 -2
- package/registry/error-page.json +2 -2
- package/registry/examples/architecture-diagram/containers.d.ts +4 -0
- package/registry/examples/architecture-diagram/containers.js +28 -0
- package/registry/examples/architecture-diagram/containers.tsx +24 -0
- package/registry/examples/architecture-diagram/context.d.ts +4 -0
- package/registry/examples/architecture-diagram/context.js +26 -0
- package/registry/examples/architecture-diagram/context.tsx +22 -0
- package/registry/examples/architecture-diagram/dynamic.d.ts +4 -0
- package/registry/examples/architecture-diagram/dynamic.js +27 -0
- package/registry/examples/architecture-diagram/dynamic.tsx +23 -0
- package/registry/field.json +2 -2
- package/registry/file-upload.json +3 -3
- package/registry/filter-bar.json +5 -5
- package/registry/flock.json +2 -2
- package/registry/footnote.json +2 -2
- package/registry/force-update-screen.json +2 -2
- package/registry/form.json +65 -65
- package/registry/gallery-page.json +2 -2
- package/registry/genui.json +3 -3
- package/registry/glossary-term.json +1 -1
- package/registry/glossary.json +1 -1
- package/registry/glow-card.json +2 -2
- package/registry/goal-gauge.json +2 -2
- package/registry/grade-stamp.json +2 -2
- package/registry/identity-card.json +2 -2
- package/registry/image-cropper.json +2 -2
- package/registry/index.json +37 -8
- package/registry/kanban.json +2 -2
- package/registry/kbd.json +2 -2
- package/registry/kind-config-editor.json +3 -3
- package/registry/kpi-explained.json +2 -2
- package/registry/landing-page.json +2 -2
- package/registry/landscape.json +2 -2
- package/registry/language-switch.json +2 -2
- package/registry/legal-page.json +2 -2
- package/registry/link-card.json +4 -4
- package/registry/list.json +3 -3
- package/registry/loader.json +2 -2
- package/registry/longform-page.json +2 -2
- package/registry/maintenance-screen.json +2 -2
- package/registry/map.json +8 -8
- package/registry/margin-layout.json +2 -2
- package/registry/markdown.json +2 -2
- package/registry/marketing-layout.json +2 -2
- package/registry/mascot-quote.json +2 -2
- package/registry/mascot-state.json +3 -3
- package/registry/mascots.json +4 -4
- package/registry/match-dialog.json +2 -2
- package/registry/media-capture.json +3 -3
- package/registry/media-gallery.json +5 -5
- package/registry/meter.json +2 -2
- package/registry/money-input.json +2 -2
- package/registry/nav-bar.json +9 -9
- package/registry/next-actions.json +1 -1
- package/registry/notification-preferences.json +1 -1
- package/registry/number-ticker.json +2 -2
- package/registry/opening-hours.json +3 -3
- package/registry/page-header.json +2 -2
- package/registry/page-hero.json +4 -4
- package/registry/page-index.json +3 -3
- package/registry/page.json +2 -2
- package/registry/pagination.json +3 -3
- package/registry/pointer-light.json +2 -2
- package/registry/popover.json +2 -2
- package/registry/price-catalogue-editor.json +2 -2
- package/registry/pricing-page.json +3 -3
- package/registry/product-page.json +2 -2
- package/registry/profile-card.json +4 -4
- package/registry/progress.json +2 -2
- package/registry/promise-card.json +2 -2
- package/registry/promo-code-field.json +1 -1
- package/registry/proposal.json +1 -1
- package/registry/qr-code.json +3 -3
- package/registry/quota-meter.json +2 -2
- package/registry/radio-group.json +15 -15
- package/registry/rail-nav.json +9 -9
- package/registry/recipes.json +2 -2
- package/registry/retro-tv.json +4 -4
- package/registry/reviews.json +1 -1
- package/registry/router.json +1 -1
- package/registry/schema-form.json +2 -2
- package/registry/scroll-stage.json +2 -2
- package/registry/search-field.json +3 -3
- package/registry/section-backdrop.json +2 -2
- package/registry/separator.json +2 -2
- package/registry/service-card.json +4 -4
- package/registry/settings-layout.json +2 -2
- package/registry/shop-composer.json +4 -4
- package/registry/shop-gallery.json +2 -2
- package/registry/shop.json +18 -18
- package/registry/showcase.json +2 -2
- package/registry/signature.json +2 -2
- package/registry/site-cahier.json +3 -3
- package/registry/site-footer.json +11 -11
- package/registry/sites.json +1 -1
- package/registry/skeleton.json +2 -2
- package/registry/skip-link.json +2 -2
- package/registry/slider.json +2 -2
- package/registry/slot-picker.json +3 -3
- package/registry/slot.json +1 -1
- package/registry/specimen-tag.json +2 -2
- package/registry/speed-lines.json +2 -2
- package/registry/spinner.json +3 -3
- package/registry/split-view.json +2 -2
- package/registry/stage-banner.json +2 -2
- package/registry/stat.json +2 -2
- package/registry/status-chip.json +3 -3
- package/registry/status-page.json +2 -2
- package/registry/step-progress.json +2 -2
- package/registry/step-showcase.json +3 -3
- package/registry/stepper.json +2 -2
- package/registry/sticky-action.json +2 -2
- package/registry/stuck.json +2 -2
- package/registry/swipe-deck.json +2 -2
- package/registry/switch.json +2 -2
- package/registry/tabs.json +2 -2
- package/registry/tag-input.json +2 -2
- package/registry/tag-selector.json +2 -2
- package/registry/taped-photo.json +2 -2
- package/registry/terminal-replay.json +3 -3
- package/registry/text-style.json +9 -9
- package/registry/theme.json +2 -2
- package/registry/toast.json +2 -2
- package/registry/toc.json +2 -2
- package/registry/tooltip.json +2 -2
- package/registry/tree-view.json +3 -3
- package/registry/update-prompt.json +2 -2
- package/registry/upload-queue.json +2 -2
- package/registry/usage.json +3 -3
- package/registry/verified-badge.json +2 -2
- package/registry/versus-card.json +2 -2
- package/registry/vertical-video.json +3 -3
- package/registry/video-player.json +3 -3
- package/registry/video-trimmer.json +2 -2
- package/registry/virtual.json +4 -4
- package/registry/wall.json +2 -2
- package/registry/waveform.json +2 -2
- package/dist/chunk-2FCQCWIK.js.map +0 -1
- package/dist/chunk-43PTCDTL.js.map +0 -1
- package/dist/chunk-5D7NMUF6.js.map +0 -1
- package/dist/chunk-5PFCELGW.js.map +0 -1
- package/dist/chunk-5RWHDX5J.js.map +0 -1
- package/dist/chunk-5VZ37TY3.js.map +0 -1
- package/dist/chunk-757ZTGU5.js.map +0 -1
- package/dist/chunk-7DYZTEE3.js.map +0 -1
- package/dist/chunk-7P7I5OQV.js.map +0 -1
- package/dist/chunk-B47WSPMP.js.map +0 -1
- package/dist/chunk-C57KK5VB.js.map +0 -1
- package/dist/chunk-EB45EVPJ.js.map +0 -1
- package/dist/chunk-EDQLPCM4.js.map +0 -1
- package/dist/chunk-GHAN7OOE.js.map +0 -1
- package/dist/chunk-HLEBSAGC.js.map +0 -1
- package/dist/chunk-HP7BDMVK.js.map +0 -1
- package/dist/chunk-KH3JOEPY.js.map +0 -1
- package/dist/chunk-KR2W4ONJ.js.map +0 -1
- package/dist/chunk-LH5J3VLZ.js.map +0 -1
- package/dist/chunk-LNAAWT4Y.js.map +0 -1
- package/dist/chunk-MDSP7DJR.js.map +0 -1
- package/dist/chunk-NG6G6V5E.js.map +0 -1
- package/dist/chunk-NM2DEHFZ.js.map +0 -1
- package/dist/chunk-NPMGYLJV.js.map +0 -1
- package/dist/chunk-NQENOT6L.js.map +0 -1
- package/dist/chunk-NSLXEDIS.js.map +0 -1
- package/dist/chunk-OGWB76BR.js.map +0 -1
- package/dist/chunk-P7AFIKWG.js.map +0 -1
- package/dist/chunk-PGBF3UBX.js.map +0 -1
- package/dist/chunk-QA3WETWT.js.map +0 -1
- package/dist/chunk-QD6SNXF5.js.map +0 -1
- package/dist/chunk-QHVV2JGF.js.map +0 -1
- package/dist/chunk-QVHSV6RA.js.map +0 -1
- package/dist/chunk-S2O4NSN5.js.map +0 -1
- package/dist/chunk-S4TLZRGZ.js.map +0 -1
- package/dist/chunk-S6NYGOJT.js.map +0 -1
- package/dist/chunk-SB5WSVPI.js.map +0 -1
- package/dist/chunk-SG2RKUVJ.js.map +0 -1
- package/dist/chunk-V5RO6JYI.js.map +0 -1
- package/dist/chunk-V7W4RLRW.js.map +0 -1
- package/dist/chunk-VA4NPCUQ.js.map +0 -1
- package/dist/chunk-VPO27AFS.js.map +0 -1
- package/dist/chunk-W64RAX4N.js.map +0 -1
- package/dist/chunk-W675RFOA.js.map +0 -1
- package/dist/chunk-WC3SO4CE.js.map +0 -1
- package/dist/chunk-WEVYKZIF.js.map +0 -1
- package/dist/chunk-WU4VLSEA.js.map +0 -1
- package/dist/chunk-Y3P5B4XS.js.map +0 -1
- package/dist/chunk-YTYNKMNS.js.map +0 -1
- package/dist/chunk-Z47KIPCT.js.map +0 -1
- package/dist/chunk-ZPOVOEO3.js.map +0 -1
- package/dist/player-lightbox-BYQ57OXT.js.map +0 -1
- /package/dist/{chunk-HJFRHYCI.js.map → chunk-DTGRZXYO.js.map} +0 -0
- /package/dist/{chunk-PJNR4NTS.js.map → chunk-HC2TY45B.js.map} +0 -0
- /package/dist/{lightbox-MRB2YZEP.js.map → lightbox-JLWASIJC.js.map} +0 -0
package/registry/data-table.json
CHANGED
|
@@ -791,7 +791,7 @@
|
|
|
791
791
|
},
|
|
792
792
|
{
|
|
793
793
|
"path": "data-table/data-table.tsx",
|
|
794
|
-
"content": "// Client (the table's state, the windowing of long lists). A real `<table>` with a caption and column headers\n// (`scope=\"col\"`, `aria-sort` on the sorted one) that turns into a stack of cards in a narrow container — one DOM, the\n// roles written out so that the change of `display` never loses the table's semantics. The engine is TanStack Table v9\n// (engine.ts): sorting, filters and facets, grouping, expanding, pagination, selection, visibility, pinning, resizing —\n// in the browser, or on the server (`manual` + `onStateChange`). Long lists render by what is in view (`virtualized`).\nimport { useTable } from \"@tanstack/react-table\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { Checkbox } from \"../checkbox\";\nimport { cn } from \"../cn\";\nimport { ChevronGlyph, SortGlyph } from \"../glyphs\";\nimport { useControllable } from \"../media\";\nimport { Pagination, type PaginationLabels } from \"../pagination\";\nimport { useLayoutFallbacks, useVirtualizer } from \"../virtual/virtual\";\nimport {\n type CellValue,\n type ColumnDef,\n type ColumnResizingState,\n type DataTableFilterState,\n type DataTableInstance,\n features,\n FILTERS,\n type FilterValue,\n type RowData,\n sortByValue,\n type TableCell,\n type TableColumn,\n type TableRow,\n} from \"./engine\";\nimport { SelectionBar, type SelectionBarLabels } from \"./selection-bar\";\nimport { useRouteTable } from \"./use-route-table\";\n\nexport const dataTable = tv({\n slots: {\n root: \"@container w-full overflow-clip rounded-xl border border-border-default bg-surface-1\",\n toolbar: \"border-b border-border-default p-3\",\n scroller: \"w-full overflow-x-auto\",\n table: \"w-full border-collapse text-left text-sm text-fg\",\n caption: \"px-4 pt-4 pb-2 text-left text-sm font-semibold text-fg\",\n thead: \"bg-surface-2/60\",\n headRow: \"border-b border-border-default\",\n th: \"relative whitespace-nowrap px-4 py-3 text-xs font-semibold text-fg-secondary\",\n sortButton:\n \"-mx-1.5 inline-flex items-center gap-1 rounded-md px-1.5 py-1 hover:bg-surface-3 hover:text-fg \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring aria-[pressed=true]:text-fg\",\n resizer:\n \"absolute top-0 right-0 h-full w-1.5 cursor-col-resize touch-none select-none bg-transparent hover:bg-border-strong \" +\n \"focus-visible:bg-accent focus-visible:outline-hidden data-[resizing]:bg-accent\",\n tbody: \"\",\n tr: \"border-b border-border-subtle transition-colors last:border-b-0 hover:bg-surface-2/50 data-[state=selected]:bg-accent-soft\",\n groupRow: \"bg-surface-2/40 font-semibold\",\n td: \"px-4 py-3 align-middle\",\n select: \"w-10\",\n expander: \"w-10\",\n toggle:\n \"inline-flex h-7 min-w-7 items-center justify-center gap-1.5 rounded-md text-fg-secondary hover:bg-surface-3 hover:text-fg \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&[aria-expanded=true]>svg]:rotate-90 [&>svg]:transition-transform motion-reduce:[&>svg]:transition-none\",\n detail: \"bg-surface-0 px-4 py-4\",\n message: \"px-4 py-10 text-center text-sm text-fg-secondary\",\n skeleton: \"h-4 w-full max-w-40 animate-pulse rounded bg-surface-3 motion-reduce:animate-none\",\n footer: \"border-t border-border-default px-4 py-3\",\n },\n variants: {\n layout: {\n table: {\n th: \"data-[pin]:sticky data-[pin]:z-[2] data-[pin]:bg-surface-2 data-[pin=start]:left-(--dt-pin) data-[pin=end]:right-(--dt-pin)\",\n td: \"data-[pin]:sticky data-[pin]:z-[1] data-[pin]:bg-surface-1 data-[pin=start]:left-(--dt-pin) data-[pin=end]:right-(--dt-pin)\",\n },\n // Below 36rem of container: cards. The sortable headers stay, as a row of sort buttons above the cards.\n auto: {\n table: \"@max-xl:block\",\n caption: \"@max-xl:block\",\n thead: \"@max-xl:sr-only @max-xl:bg-transparent @max-xl:has-[[data-keep]]:not-sr-only @max-xl:has-[[data-keep]]:block\",\n headRow: \"@max-xl:flex @max-xl:flex-wrap @max-xl:items-center @max-xl:gap-2 @max-xl:px-3 @max-xl:py-2\",\n th:\n \"@max-xl:sr-only @max-xl:data-[keep]:not-sr-only @max-xl:data-[keep]:block @max-xl:p-0 \" +\n \"@xl:data-[pin]:sticky @xl:data-[pin]:z-[2] @xl:data-[pin]:bg-surface-2 @xl:data-[pin=start]:left-(--dt-pin) @xl:data-[pin=end]:right-(--dt-pin)\",\n tbody: \"@max-xl:grid @max-xl:gap-3 @max-xl:p-3\",\n tr: \"@max-xl:relative @max-xl:grid @max-xl:gap-1.5 @max-xl:rounded-xl @max-xl:border @max-xl:border-border-default @max-xl:bg-surface-0 @max-xl:p-4 @max-xl:last:border-b\",\n td:\n \"@max-xl:flex @max-xl:min-w-0 @max-xl:items-baseline @max-xl:justify-between @max-xl:gap-4 @max-xl:p-0 @max-xl:text-right @max-xl:[overflow-wrap:anywhere] \" +\n \"@max-xl:[&>*]:min-w-0 @max-xl:[&>*]:shrink @max-xl:[&>*]:whitespace-normal \" +\n \"@max-xl:before:shrink-0 @max-xl:before:text-xs @max-xl:before:font-semibold @max-xl:before:text-fg-secondary @max-xl:before:content-[attr(data-label)] \" +\n \"@max-xl:data-[card=title]:order-first @max-xl:data-[card=title]:pr-8 @max-xl:data-[card=title]:text-left @max-xl:data-[card=title]:text-base @max-xl:data-[card=title]:font-semibold @max-xl:data-[card=title]:before:content-none \" +\n \"@max-xl:data-[card=hidden]:hidden @max-xl:data-[card=message]:block @max-xl:data-[card=message]:text-center @max-xl:data-[card=message]:before:content-none \" +\n \"@xl:data-[pin]:sticky @xl:data-[pin]:z-[1] @xl:data-[pin]:bg-surface-1 @xl:data-[pin=start]:left-(--dt-pin) @xl:data-[pin=end]:right-(--dt-pin)\",\n select: \"@max-xl:absolute @max-xl:right-3 @max-xl:top-3 @max-xl:w-auto @max-xl:before:content-none\",\n expander: \"@max-xl:before:content-none\",\n },\n cards: {\n table: \"block\",\n caption: \"block\",\n thead: \"sr-only bg-transparent has-[[data-keep]]:not-sr-only has-[[data-keep]]:block\",\n headRow: \"flex flex-wrap items-center gap-2 px-3 py-2\",\n th: \"sr-only p-0 data-[keep]:not-sr-only data-[keep]:block\",\n tbody: \"grid gap-3 p-3\",\n tr: \"relative grid gap-1.5 rounded-xl border border-border-default bg-surface-0 p-4 last:border-b\",\n td:\n \"flex min-w-0 items-baseline justify-between gap-4 p-0 text-right [overflow-wrap:anywhere] before:shrink-0 before:text-xs before:font-semibold before:text-fg-secondary before:content-[attr(data-label)] \" +\n \"[&>*]:min-w-0 [&>*]:shrink [&>*]:whitespace-normal \" +\n \"data-[card=title]:order-first data-[card=title]:pr-8 data-[card=title]:text-left data-[card=title]:text-base data-[card=title]:font-semibold data-[card=title]:before:content-none \" +\n \"data-[card=hidden]:hidden data-[card=message]:block data-[card=message]:text-center data-[card=message]:before:content-none\",\n select: \"absolute right-3 top-3 w-auto before:content-none\",\n expander: \"before:content-none\",\n },\n },\n density: {\n comfortable: {},\n compact: { th: \"py-2\", td: \"py-1.5\" },\n },\n // The header stays in view while the page scrolls (table layouts only; `--dt-top` clears a fixed bar).\n sticky: { true: {}, false: {} },\n // Zebra rows (the table layouts); the cards keep their frame.\n striped: { true: {}, false: {} },\n // Typed columns: one height per row (`typed`); untyped tables keep the height of their content.\n typed: { true: {}, false: {} },\n // What a row becomes on a phone (under 36 rem, or with `layout=\"cards\"`): a card, or a list row (#636).\n phone: { cards: {}, list: {} },\n },\n compoundVariants: [\n { layout: \"table\", sticky: true, class: { th: \"sticky top-(--dt-top,0px) z-[3] bg-surface-2\" } },\n { layout: \"auto\", sticky: true, class: { th: \"@xl:sticky @xl:top-(--dt-top,0px) @xl:z-[3] @xl:bg-surface-2\" } },\n { layout: \"table\", striped: true, class: { tr: \"even:bg-surface-2/40\" } },\n { layout: \"auto\", striped: true, class: { tr: \"@xl:even:bg-surface-2/40\" } },\n // One row height per density (a two-line row — a name and its id — is the tallest).\n { layout: \"table\", density: \"comfortable\", typed: true, class: { td: \"h-15\" } },\n { layout: \"auto\", density: \"comfortable\", typed: true, class: { td: \"@xl:h-15\" } },\n { layout: \"table\", density: \"compact\", typed: true, class: { td: \"h-12\" } },\n { layout: \"auto\", density: \"compact\", typed: true, class: { td: \"@xl:h-12\" } },\n // The list rows (#636): no box in the box, no label/value lines — the checkbox, the title and its line of facts, the\n // status at the end, a hairline between rows. Each cell says its place in `data-list` (title · status · away).\n {\n layout: \"auto\",\n phone: \"list\",\n class: {\n tbody: \"@max-xl:gap-0 @max-xl:p-0\",\n tr:\n \"@max-xl:flex @max-xl:items-center @max-xl:gap-3 @max-xl:rounded-none @max-xl:border-0 @max-xl:border-b @max-xl:border-border-subtle @max-xl:bg-transparent \" +\n \"@max-xl:px-4 @max-xl:py-3 @max-xl:last:border-b-0\",\n td:\n \"@max-xl:block @max-xl:text-left @max-xl:before:content-none @max-xl:data-[list=title]:min-w-0 @max-xl:data-[list=title]:flex-1 \" +\n \"@max-xl:data-[list=status]:shrink-0 @max-xl:data-[list=away]:hidden @max-xl:data-[card=message]:w-full\",\n select: \"@max-xl:relative @max-xl:right-auto @max-xl:top-auto @max-xl:z-[1] @max-xl:shrink-0 @max-xl:self-center\",\n expander: \"@max-xl:relative @max-xl:z-[1] @max-xl:shrink-0\",\n },\n },\n {\n layout: \"cards\",\n phone: \"list\",\n class: {\n tbody: \"gap-0 p-0\",\n tr: \"flex items-center gap-3 rounded-none border-0 border-b border-border-subtle bg-transparent px-4 py-3 last:border-b-0\",\n td: \"block text-left before:content-none data-[list=title]:min-w-0 data-[list=title]:flex-1 data-[list=status]:shrink-0 data-[list=away]:hidden data-[card=message]:w-full\",\n select: \"relative right-auto top-auto z-[1] shrink-0 self-center\",\n expander: \"relative z-[1] shrink-0\",\n },\n },\n ],\n defaultVariants: { layout: \"auto\", density: \"comfortable\", sticky: false, striped: false, typed: false, phone: \"cards\" },\n});\n\n// Column priorities. `priority: 1` (default) is always in the row; a higher number leaves the row when the table's own\n// width (a container query, not the window's) falls under its tier and goes to the row's detail — the same\n// `@container` that turns the table into cards. Written out in full: Tailwind finds a class only as a whole string.\n// priority 2 → 42rem · 3 → 48rem · 4 → 56rem · 5 → 64rem · 6 → 72rem · 7 → 80rem\n// On the cards (under 36rem), priority 2 stays on the card's face and 3+ go to its detail.\ntype Priority = 2 | 3 | 4 | 5 | 6 | 7;\ntype ByLayout = { auto: Record<Priority, string>; table: Record<Priority, string>; cards: Record<Priority, string> };\nconst NO_CLASS: Record<Priority, string> = { 2: \"\", 3: \"\", 4: \"\", 5: \"\", 6: \"\", 7: \"\" };\n/** The cell of a column that leaves the row. */\nconst LEAVES: ByLayout = {\n auto: { 2: \"@xl:@max-2xl:hidden!\", 3: \"@max-3xl:hidden!\", 4: \"@max-4xl:hidden!\", 5: \"@max-5xl:hidden!\", 6: \"@max-6xl:hidden!\", 7: \"@max-7xl:hidden!\" },\n table: { 2: \"@max-2xl:hidden!\", 3: \"@max-3xl:hidden!\", 4: \"@max-4xl:hidden!\", 5: \"@max-5xl:hidden!\", 6: \"@max-6xl:hidden!\", 7: \"@max-7xl:hidden!\" },\n cards: { 2: \"\", 3: \"hidden!\", 4: \"hidden!\", 5: \"hidden!\", 6: \"hidden!\", 7: \"hidden!\" },\n};\n/** Its header (the cards keep the sort buttons). */\nconst LEAVES_HEAD: ByLayout = {\n auto: { 2: \"@xl:@max-2xl:hidden!\", 3: \"@xl:@max-3xl:hidden!\", 4: \"@xl:@max-4xl:hidden!\", 5: \"@xl:@max-5xl:hidden!\", 6: \"@xl:@max-6xl:hidden!\", 7: \"@xl:@max-7xl:hidden!\" },\n table: LEAVES.table,\n cards: NO_CLASS,\n};\n/** Its line in the row's detail: shown exactly when the cell is not. */\nconst IN_DETAIL: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:grid\", 3: \"hidden @max-3xl:grid\", 4: \"hidden @max-4xl:grid\", 5: \"hidden @max-5xl:grid\", 6: \"hidden @max-6xl:grid\", 7: \"hidden @max-7xl:grid\" },\n table: { 2: \"hidden @max-2xl:grid\", 3: \"hidden @max-3xl:grid\", 4: \"hidden @max-4xl:grid\", 5: \"hidden @max-5xl:grid\", 6: \"hidden @max-6xl:grid\", 7: \"hidden @max-7xl:grid\" },\n cards: { 2: \"hidden\", 3: \"grid\", 4: \"grid\", 5: \"grid\", 6: \"grid\", 7: \"grid\" },\n};\n/** The button that opens the detail, and its panel, keyed by the highest priority of the table: seen only when something left the row. */\nconst TOGGLE: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:inline-flex\", 3: \"hidden @max-3xl:inline-flex\", 4: \"hidden @max-4xl:inline-flex\", 5: \"hidden @max-5xl:inline-flex\", 6: \"hidden @max-6xl:inline-flex\", 7: \"hidden @max-7xl:inline-flex\" },\n table: { 2: \"hidden @max-2xl:inline-flex\", 3: \"hidden @max-3xl:inline-flex\", 4: \"hidden @max-4xl:inline-flex\", 5: \"hidden @max-5xl:inline-flex\", 6: \"hidden @max-6xl:inline-flex\", 7: \"hidden @max-7xl:inline-flex\" },\n cards: { 2: \"hidden\", 3: \"inline-flex\", 4: \"inline-flex\", 5: \"inline-flex\", 6: \"inline-flex\", 7: \"inline-flex\" },\n};\nconst PANEL: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:block\", 3: \"hidden @max-3xl:block\", 4: \"hidden @max-4xl:block\", 5: \"hidden @max-5xl:block\", 6: \"hidden @max-6xl:block\", 7: \"hidden @max-7xl:block\" },\n table: { 2: \"hidden @max-2xl:block\", 3: \"hidden @max-3xl:block\", 4: \"hidden @max-4xl:block\", 5: \"hidden @max-5xl:block\", 6: \"hidden @max-6xl:block\", 7: \"hidden @max-7xl:block\" },\n cards: { 2: \"hidden\", 3: \"block\", 4: \"block\", 5: \"block\", 6: \"block\", 7: \"block\" },\n};\n\n// The list rows (`phone=\"list\"`): the facts line under the title, the columns that go to the row's detail (every\n// priority-1 column that is neither the title nor a status), the button and the panel that show them, the title's link\n// stretched over the row.\nconst LIST_FACTS = { auto: \"hidden @max-xl:mt-0.5 @max-xl:block @max-xl:truncate text-xs font-normal text-fg-secondary\", table: \"hidden\", cards: \"mt-0.5 block truncate text-xs font-normal text-fg-secondary\" } as const;\nconst LIST_IN_DETAIL = { auto: \"hidden @max-xl:grid\", table: \"hidden\", cards: \"grid\" } as const;\nconst LIST_TOGGLE = { auto: \"@max-xl:inline-flex\", table: \"\", cards: \"inline-flex\" } as const;\nconst LIST_PANEL = { auto: \"@max-xl:block\", table: \"\", cards: \"block\" } as const;\nconst LIST_LINK = { auto: \"@max-xl:after:absolute @max-xl:after:inset-0 @max-xl:after:content-['']\", table: \"\", cards: \"after:absolute after:inset-0 after:content-['']\" } as const;\n\nexport type DataTableColumnType = \"title\" | \"badge\" | \"number\" | \"link\" | \"date\" | \"status\" | \"text\";\n\n// What each type does to its cell. Sizes apply to the table layouts only (a card is not a column).\n// title: the column that takes the slack, truncated, full value on hover · badge, status, number, date: as wide as\n// their content, never stretched · link: truncated · text: wraps, two lines.\nconst TYPE_CELL: Record<DataTableColumnType, ByLayoutString> = {\n title: { auto: \"@xl:w-full @xl:max-w-0 @xl:min-w-44\", table: \"w-full max-w-0 min-w-44\", cards: \"\" },\n badge: { auto: \"@xl:w-px\", table: \"w-px\", cards: \"\" },\n status: { auto: \"@xl:w-px @xl:whitespace-nowrap\", table: \"w-px whitespace-nowrap\", cards: \"\" },\n number: { auto: \"@xl:w-px @xl:whitespace-nowrap tabular-nums\", table: \"w-px whitespace-nowrap tabular-nums\", cards: \"tabular-nums\" },\n date: { auto: \"@xl:w-px @xl:whitespace-nowrap tabular-nums\", table: \"w-px whitespace-nowrap tabular-nums\", cards: \"tabular-nums\" },\n link: { auto: \"@xl:min-w-28 @xl:max-w-56\", table: \"min-w-28 max-w-56\", cards: \"\" },\n text: { auto: \"@xl:min-w-36\", table: \"min-w-36\", cards: \"\" },\n};\ntype ByLayoutString = { auto: string; table: string; cards: string };\nconst CLAMP = { 1: \"line-clamp-1\", 2: \"line-clamp-2\", 3: \"line-clamp-3\" } as const;\n\nexport type SortDirection = \"ascending\" | \"descending\";\nexport type DataTableSort = { column: string; direction: SortDirection } | null;\n\n/** What the server needs to fetch a page (`manual` mode): given to `onStateChange` at each change. */\nexport type DataTableQuery = {\n /** The sorted column, or `null`. */\n sort: DataTableSort;\n /** The filters in force, by column id. */\n filters: DataTableFilterState;\n /** The page, from 1 (1 without pagination). */\n page: number;\n /** Rows per page (`Infinity` without pagination). */\n pageSize: number;\n};\n\nexport type DataTableColumn<T> = {\n /** A key of the column (and of the row, for the default value). */\n id: string;\n /** The column's name, passed translated: the header, the label of the value in a card, the filter's name. */\n header: string;\n /** What a cell shows. Default: the value as text. */\n cell?: (row: T) => React.ReactNode;\n /** The value sorted, filtered, grouped and exported. Default `row[id]`. */\n value?: (row: T) => CellValue;\n /** The header becomes a sort button (ascending → descending → none). */\n sortable?: boolean;\n /** How `DataTableFilters` filters it: `text` (a search), `facet` (values to choose), `range` (numbers between bounds). */\n filter?: \"text\" | \"facet\" | \"range\";\n /** The choices of a `facet` filter, with their words (and counts from the server). Default: the values found in the rows. */\n options?: readonly { value: string; label: string; count?: number }[];\n /** The rows can be grouped by this column (`groupBy`). */\n groupable?: boolean;\n /** What a group's row shows in this column, from the group's rows (a sum, a count). */\n aggregate?: (rows: readonly T[]) => React.ReactNode;\n /** Text alignment: `end` for amounts and counts. */\n align?: \"start\" | \"center\" | \"end\";\n /** The width, in px (the starting width when `resizing`). */\n width?: number;\n /** The narrowest the column may be, in px (also what a resized one may shrink to). Default 64. */\n minWidth?: number;\n /** In a card: `title` (the heading of the card), `label` (default: \"Header value\"), `hidden`. */\n card?: \"title\" | \"label\" | \"hidden\";\n /** Hides the header visually (an actions column), keeping it for screen readers. */\n headerHidden?: boolean;\n /** Listed in `DataTableColumnsMenu`, so a person can hide it. Default `true`. */\n hideable?: boolean;\n /**\n * What the column holds, which sizes and aligns it: `title` (the name, takes the slack, truncated, `subtitle` under it in\n * mono — and the card's heading), `badge` · `status` (as wide as the badge, never stretched), `number` (end-aligned,\n * tabular), `date`, `link` (truncated, `href`), `text` (wraps, two lines). Untyped: as before.\n */\n type?: DataTableColumnType;\n /**\n * 1 (default) always in the row; 2 to 7 leave it when the table is narrower than 42 · 48 · 56 · 64 · 72 · 80 rem and\n * go to the row's detail (a chevron opens it); under 36 rem (cards) 2 stays on the card, 3+ go to its detail. In the phone's\n * list rows (`phone=\"list\"`), the 2s are joined as the line of facts under the title.\n */\n priority?: 1 | 2 | 3 | 4 | 5 | 6 | 7;\n /** `title`: the line under the name (an id), in mono. */\n subtitle?: (row: T) => React.ReactNode;\n /** `link`: where the value leads. `title`: the row's page — the name becomes its link (the whole row, in the phone's list rows). */\n href?: (row: T) => string | undefined;\n /** `number`: the unit after the value (muted). */\n unit?: string;\n /** The widest the column may be in the table layouts, in px; longer text is clamped, the full value on hover. */\n maxWidth?: number;\n /** One line only, truncated (the full value on hover). */\n nowrap?: boolean;\n /** Lines of text kept before the ellipsis (default 2 for `text`). */\n clamp?: 1 | 2 | 3;\n};\n\nexport type DataTableLabels = {\n /** The checkbox of the header (\"Select all rows\"). */\n selectAll: string;\n /** The checkbox of a row: `(name) => \"Select \" + name`, the name from `rowLabel`. */\n selectRow: (name: string) => string;\n /** Read while the rows load (\"Loading\"). */\n loading: string;\n /** The default empty state (\"Nothing to show\"). */\n empty: string;\n /** The header of the column of the expand buttons, for screen readers (\"Details\"). */\n details: string;\n /** The button that opens a row: `(name) => \"Show details of \" + name`. */\n expandRow: (name: string) => string;\n /** The button of a group's row: `(value, count) => value + \", \" + count + \" rows\"`. */\n group: (value: string, count: number) => string;\n /** The handle that resizes a column: `(header) => \"Resize \" + header`. */\n resize: (header: string) => string;\n /** The count of results under the filters: `(count) => count + \" rows\"`. */\n results: (count: number) => string;\n /** The accessible name of the filters' bar (\"Filter the table\"). */\n filters: string;\n /** \"Clear filters\". */\n clearFilters: string;\n /** A filter's chip remove button: `(label) => \"Remove \" + label`. */\n removeFilter: (label: string) => string;\n /** The words of a filter in force: `(header, value) => header + \": \" + value`. */\n activeFilter: (header: string, value: string) => string;\n /** A `text` filter's field: `(header) => \"Search \" + header`. */\n search: (header: string) => string;\n /** The lower bound of a `range` filter: `(header) => header + \" from\"`. */\n rangeFrom: (header: string) => string;\n /** The upper bound of a `range` filter: `(header) => header + \" to\"`. */\n rangeTo: (header: string) => string;\n /** The button of the columns menu (\"Columns\"). */\n columns: string;\n /** The button that opens what left the row: `(name) => \"Show more about \" + name`. */\n showMore: (name: string) => string;\n /** The export button (\"Export CSV\"). */\n export: string;\n /** The words of the pagination under the table. */\n pagination?: Partial<PaginationLabels>;\n /** The words of the bar of a selection (`bulkActions`). */\n selection?: Partial<SelectionBarLabels>;\n};\n\nexport const dataTableLabels: DataTableLabels = {\n selectAll: \"Select all rows\",\n selectRow: (name) => `Select ${name}`,\n loading: \"Loading\",\n empty: \"Nothing to show\",\n details: \"Details\",\n expandRow: (name) => `Show details of ${name}`,\n group: (value, count) => `${value}, ${count} ${count === 1 ? \"row\" : \"rows\"}`,\n resize: (header) => `Resize ${header}`,\n results: (count) => `${count.toLocaleString(\"en\")} ${count === 1 ? \"row\" : \"rows\"}`,\n filters: \"Filter the table\",\n clearFilters: \"Clear filters\",\n removeFilter: (label) => `Remove ${label}`,\n activeFilter: (header, value) => `${header}: ${value}`,\n search: (header) => `Search ${header.toLocaleLowerCase()}`,\n rangeFrom: (header) => `${header} from`,\n rangeTo: (header) => `${header} to`,\n columns: \"Columns\",\n showMore: (name) => `Show more about ${name}`,\n export: \"Export CSV\",\n};\n\nexport type DataTableProps<T> = {\n /** The rows (stable: module scope, state or a query's data). Sorted, filtered and paginated here unless `manual`. */\n rows: readonly T[];\n /** The columns, in order (stable: module scope or `useMemo`). */\n columns: readonly DataTableColumn<T>[];\n /** A stable id per row: the React key, the selection's value, the expansion's key. */\n getRowId: (row: T) => string;\n /** What the table lists (\"Jobs\", \"Your videos\"): its `<caption>`, hidden unless `showCaption`. */\n caption: string;\n /** Shows the caption above the table. */\n showCaption?: boolean;\n\n /** The sorted column (controlled), `null` for none. */\n sort?: DataTableSort;\n /** The sort at first, uncontrolled. */\n defaultSort?: DataTableSort;\n /** Called when a header asks for a new sort. */\n onSortChange?: (sort: DataTableSort) => void;\n\n /** The filters in force (controlled), by column id — what `DataTableFilters` edits. */\n filters?: DataTableFilterState;\n /** The filters at first, uncontrolled. */\n defaultFilters?: DataTableFilterState;\n /** Called with the new filters. */\n onFiltersChange?: (filters: DataTableFilterState) => void;\n\n /**\n * Keeps the sort, the filters and the page in the address (`?clients.sort=…&clients.page=2`): back and forward, a reload\n * and a shared link all land on the same table. Replaces `sort`, `filters` and `page`; needs the router's adapter\n * (`RouteStateProvider`) in a framework.\n */\n routeKey?: string;\n\n /** Adds a checkbox per row and one in the header. */\n selectable?: boolean;\n /** The ids selected (controlled). */\n selected?: readonly string[];\n /** The ids selected at first, uncontrolled. */\n defaultSelected?: readonly string[];\n /** Called with the new selection. */\n onSelectedChange?: (selected: string[]) => void;\n /** The name of a row in its labels (checkbox, expand button). Default: its id. */\n rowLabel?: (row: T) => string;\n /**\n * The actions on the selection, given by the product: the bar (`SelectionBar`) appears under the table while rows are\n * chosen — the count, these actions, « Clear selection » — sticky, docked above the tab bar on a phone. Needs `selectable`.\n */\n bulkActions?: (selection: { selected: string[]; clear: () => void }) => React.ReactNode;\n /** The most rows a bulk call takes (200 for `@krizaka/organize`): the bar says so past it and its actions rest. */\n bulkMax?: number;\n /** What the last bulk change did (\"3 moved, 1 skipped\"), announced politely by the bar. */\n bulkResult?: string;\n\n /** The columns the rows are grouped by, in order (controlled) — each `groupable`. */\n groupBy?: readonly string[];\n /** The grouping at first, uncontrolled. */\n defaultGroupBy?: readonly string[];\n /** Called with the new grouping. */\n onGroupByChange?: (groupBy: string[]) => void;\n\n /** Visible (`true`) or hidden (`false`) columns, by id (controlled); a column not listed is visible. */\n columnVisibility?: Readonly<Record<string, boolean>>;\n /** The visibility at first, uncontrolled. */\n defaultColumnVisibility?: Readonly<Record<string, boolean>>;\n /** Called with the new visibility (`DataTableColumnsMenu`). */\n onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;\n\n /** Columns that stay in view while the table scrolls sideways: at the start (a name) or the end (actions). */\n pinning?: { start?: readonly string[]; end?: readonly string[] };\n /** Columns can be resized (pointer drag, or the arrow keys on the focused handle). */\n resizing?: boolean;\n\n /** The children of a row (a tree): each row with children gets a button that shows them. */\n getSubRows?: (row: T) => readonly T[] | undefined;\n /** A panel under an opened row (the details of a job): each row gets a button that opens it. */\n renderDetail?: (row: T) => React.ReactNode;\n /** The opened rows and groups (controlled), by id. */\n expanded?: Readonly<Record<string, boolean>>;\n /** The opened rows at first, uncontrolled. */\n defaultExpanded?: Readonly<Record<string, boolean>>;\n /** Called with the opened rows. */\n onExpandedChange?: (expanded: Record<string, boolean>) => void;\n\n /** Rows per page (controlled): turns on the pagination under the table. */\n pageSize?: number;\n /** Rows per page at first, uncontrolled: turns on the pagination under the table. */\n defaultPageSize?: number;\n /** Called with the size chosen in the pagination's select (`pageSizeOptions`). */\n onPageSizeChange?: (pageSize: number) => void;\n /** The sizes the pagination offers (`[10, 25, 50]`). */\n pageSizeOptions?: readonly number[];\n /** The page, from 1 (controlled). */\n page?: number;\n /** The page at first, uncontrolled. Default 1. */\n defaultPage?: number;\n /** Called with the page asked for. */\n onPageChange?: (page: number) => void;\n\n /** The server does the work: the rows are shown as given (sorted, filtered, a single page) — fetch in `onStateChange`. */\n manual?: { sorting?: boolean; filtering?: boolean; pagination?: boolean };\n /** The number of rows on the server (`manual.pagination`): the page count and the results' count. */\n rowCount?: number;\n /** Called with the sort, the filters and the page after each change: the query key of a server table. */\n onStateChange?: (query: DataTableQuery) => void;\n\n /** Rows are loading: skeleton rows (`loadingRows` of them) and `aria-busy`. */\n loading?: boolean;\n /** How many skeleton rows while loading. Default 5. */\n loadingRows?: number;\n /** A failure, shown in place of the rows (an `Alert`, a retry button); announced. */\n error?: React.ReactNode;\n /** Shown when there is no row (an `EmptyState`). Default: `labels.empty`. */\n empty?: React.ReactNode;\n\n /** `auto` (default): a table, cards below 36rem of container width. `table` or `cards` to force one. */\n layout?: \"auto\" | \"table\" | \"cards\";\n /**\n * What a row becomes on a phone (under 36 rem, or always with `layout=\"cards\"`): `cards` (a card per row, its values\n * labelled) or `list` — a list row: the selection's checkbox, the `title` column with its `priority: 2` columns joined as\n * one line of facts, the `status` / `badge` column at the end; the other columns in the row's detail.\n * @default \"cards\"\n */\n phone?: \"cards\" | \"list\";\n /** comfortable (default) · compact — one row height per density. */\n density?: \"comfortable\" | \"compact\";\n /** The header stays at the top of the window while the page scrolls (`--dt-top` on the table, or a number of px, clears a fixed bar). */\n stickyHeader?: boolean | number;\n /** Zebra rows. */\n striped?: boolean;\n /**\n * The table never scrolls sideways by default once its columns have a `type` or a `priority`: what does not fit goes to\n * the row's detail, then to cards. `true` opts in to a sideways scroll instead, with fades at the edges.\n */\n scroll?: boolean;\n /** Keeps the first column in view while the table scrolls sideways (with `scroll`). */\n stickyFirstColumn?: boolean;\n /** Renders only the rows in view, in a scrolling body of `height` px; rows are measured (`estimateRowHeight` is a guess). Forces the table layout. */\n virtualized?: { height: number; estimateRowHeight?: number; overscan?: number };\n\n /** Above the table, inside its frame: `DataTableFilters`, `DataTableColumnsMenu`, `DataTableExport`, actions. */\n toolbar?: React.ReactNode;\n /** Under the table (after the pagination): a total, a note. */\n footer?: React.ReactNode;\n /** The words, passed translated; English by default. */\n labels?: Partial<DataTableLabels>;\n /** Classes merged on the root. */\n className?: string;\n};\n\ntype Context = {\n table: DataTableInstance<object>;\n columns: readonly DataTableColumn<object>[];\n labels: DataTableLabels;\n filters: DataTableFilterState;\n setFilters: (filters: DataTableFilterState) => void;\n /** The rows after the filters (all pages), or the server's count. */\n resultCount: number;\n /** The rows to export: filtered and sorted, every page, without the group rows. */\n exportRows: () => readonly unknown[];\n manualFiltering: boolean;\n};\n\nconst DataTableContext = React.createContext<Context | null>(null);\n\n/**\n * The table a component sits in (`toolbar`, or anything under it): the TanStack Table instance (`table` — the escape\n * hatch for what the props do not cover), the columns, the words, the filters and their setter.\n */\nexport function useDataTable<T extends RowData = object>() {\n const context = React.useContext(DataTableContext);\n if (!context) throw new Error(\"useDataTable: call it inside a DataTable (its `toolbar`, `footer` or a cell)\");\n return context as unknown as Omit<Context, \"table\" | \"columns\" | \"exportRows\"> & {\n table: DataTableInstance<T>;\n columns: readonly DataTableColumn<T>[];\n exportRows: () => readonly T[];\n };\n}\n\n// A card never scrolls sideways, even when untyped columns keep the table's scroller.\nconst CARD_CLIP = { auto: \"@max-xl:overflow-x-clip!\", table: undefined, cards: \"overflow-x-clip!\" } as const;\nconst TRUNCATE = { auto: \"@xl:truncate\", table: \"truncate\", cards: \"\" } as const;\nconst MIN = { auto: \"@xl:min-w-(--dt-min)!\", table: \"min-w-(--dt-min)!\", cards: \"\" } as const;\nconst MAX = { auto: \"@xl:max-w-(--dt-max)!\", table: \"max-w-(--dt-max)!\", cards: \"\" } as const;\n// A sideways scroll asked for (`scroll`): the edges fade where there is more to see.\nconst SHADOWS =\n \"[background:linear-gradient(to_right,var(--kz-surface-1),transparent)_left/24px_100%_no-repeat_local,linear-gradient(to_left,var(--kz-surface-1),transparent)_right/24px_100%_no-repeat_local,linear-gradient(to_right,rgb(0_0_0/0.18),transparent)_left/10px_100%_no-repeat_scroll,linear-gradient(to_left,rgb(0_0_0/0.18),transparent)_right/10px_100%_no-repeat_scroll]\";\nconst ALIGN = { start: \"text-left\", center: \"text-center\", end: \"text-right\" } as const;\nconst NONE: readonly never[] = [];\nconst NO_RECORD: Readonly<Record<string, never>> = {};\ntype Up<S> = S | ((old: S) => S);\nconst apply = <S,>(updater: S | ((old: S) => S), old: S): S => (typeof updater === \"function\" ? (updater as (old: S) => S)(old) : updater);\n\nconst valueOf = <T,>(column: DataTableColumn<T>, row: T): CellValue =>\n column.value ? column.value(row) : ((row as Record<string, unknown>)[column.id] as CellValue);\n\nconst display = (value: CellValue) => (value instanceof Date ? value.toISOString() : String(value ?? \"\"));\n\ntype Layout = \"auto\" | \"table\" | \"cards\";\ntype Styles = ReturnType<typeof dataTable>;\ntype Place = \"title\" | \"status\" | \"facts\" | \"away\" | \"hidden\";\ntype TableHeader<T extends RowData> = ReturnType<DataTableInstance<T>[\"getHeaderGroups\"]>[number][\"headers\"][number];\ntype Pin = { \"data-pin\"?: \"start\" | \"end\"; style?: React.CSSProperties };\n\nconst sortingOf = (sort: DataTableSort) => (sort ? [{ id: sort.column, desc: sort.direction === \"descending\" }] : []);\nconst filterListOf = (filters: DataTableFilterState) => Object.entries(filters).map(([id, value]) => ({ id, value }));\nconst selectionOf = (selected: readonly string[]) => Object.fromEntries(selected.map((id) => [id, true as const]));\n\n// Columns that can leave the row: their lines go to the row's detail, opened by a chevron in the first cell.\nconst priorityOf = <T extends RowData>(column: DataTableColumn<T>): 1 | Priority => (column.priority && column.priority > 1 ? (column.priority as Priority) : 1);\n\n// The list rows' places: the title (the `title` column, else the first), the status at the end, the facts (the 2s) under\n// the title, and the rest away, in the row's detail.\nconst placeOf = <T extends RowData>(titleColumn: DataTableColumn<T> | undefined, column: DataTableColumn<T>): Place => {\n if (column.card === \"hidden\") return \"hidden\";\n if (column === titleColumn) return \"title\";\n if (column.type === \"status\" || column.type === \"badge\") return \"status\";\n return priorityOf(column) === 2 ? \"facts\" : \"away\";\n};\n\nconst cardOf = <T extends RowData>(column: DataTableColumn<T> | undefined) =>\n column?.card === \"title\" || (column && !column.card && column.type === \"title\") ? \"title\" : column?.card === \"hidden\" ? \"hidden\" : undefined;\n\n/** What the cells and the rows need to know about the table they are in. */\ntype View<T extends RowData> = {\n s: Styles;\n L: Layout;\n list: boolean;\n labels: DataTableLabels;\n byId: Map<string, DataTableColumn<T>>;\n titleColumn: DataTableColumn<T> | undefined;\n facts: DataTableColumn<T>[];\n listAway: DataTableColumn<T>[];\n maxPriority: 1 | Priority;\n inlineToggle: boolean;\n hasExpander: boolean;\n detailed: boolean;\n selectable: boolean;\n span: number;\n chosen: Set<string>;\n virtualized: boolean;\n fixedLayout: boolean;\n renderDetail: ((row: T) => React.ReactNode) | undefined;\n rowLabel: ((row: T) => string) | undefined;\n visibleColumns: TableColumn<T>[];\n measureElement: ((node: Element | null) => void) | undefined;\n loading: boolean | undefined;\n loadingCount: number;\n error: React.ReactNode;\n empty: React.ReactNode;\n pageRows: TableRow<T>[];\n windowItems: { index: number }[] | null;\n resizing: boolean | undefined;\n stickyHeader: boolean | number | undefined;\n setSizing: React.Dispatch<React.SetStateAction<Record<string, number>>>;\n allChosen: boolean;\n someChosen: boolean;\n selectableCount: number;\n toggleAll: () => void;\n};\n\nconst nameOf = <T extends RowData>(v: View<T>, row: TableRow<T>) => (v.rowLabel ? v.rowLabel(row.original) : row.id);\n\nconst pin = <T extends RowData>(column: TableColumn<T>): Pin => {\n const position = column.getIsPinned();\n if (!position) return {};\n const offset = position === \"start\" ? column.getStart(\"start\") : column.getAfter(\"end\");\n return { \"data-pin\": position, style: { [\"--dt-pin\" as string]: `${offset}px` } };\n};\n\nconst widthOf = <T extends RowData>(v: View<T>, column: TableColumn<T>): React.CSSProperties | undefined =>\n v.fixedLayout || v.byId.get(column.id)?.width ? { width: column.getSize() } : undefined;\n\n/** A title: a link when the column has addresses, with its subtitle under it. */\nfunction titleContent<T extends RowData>(v: View<T>, column: DataTableColumn<T>, original: T, text: string, cut: string) {\n const sub = column.subtitle?.(original);\n const href = column.href?.(original);\n const link = cn(\"block font-semibold text-fg no-underline hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\", cut, v.list && LIST_LINK[v.L]);\n return (\n <span className=\"block min-w-0\">\n {href ? (\n <a href={href} className={link} title={text}>\n {text}\n </a>\n ) : (\n <span className={cn(\"block font-semibold text-fg\", cut)} title={text}>\n {text}\n </span>\n )}\n {sub ? <span className={cn(\"block font-mono text-xs text-fg-tertiary\", cut)}>{sub}</span> : null}\n </span>\n );\n}\n\nfunction numberContent<T extends RowData>(column: DataTableColumn<T>, value: CellValue, text: string) {\n return (\n <span>\n {typeof value === \"number\" ? value.toLocaleString(\"en\") : text}\n {column.unit ? <span className=\"ms-1 text-fg-secondary\">{column.unit}</span> : null}\n </span>\n );\n}\n\nfunction linkContent<T extends RowData>(column: DataTableColumn<T>, original: T, text: string, cut: string) {\n const href = column.href?.(original);\n if (!href) {\n return (\n <span className={cn(\"block\", cut)} title={text}>\n {text}\n </span>\n );\n }\n return (\n <a href={href} title={text} className={cn(\"block text-fg-accent underline-offset-2 hover:underline\", cut)}>\n {text}\n </a>\n );\n}\n\nfunction plainContent<T extends RowData>(column: DataTableColumn<T>, text: string, cut: string) {\n const lines = column.clamp ?? (column.type === \"text\" ? 2 : undefined);\n if (!column.nowrap && !lines) return text;\n return (\n <span className={column.nowrap ? cn(\"block\", cut || \"truncate\") : CLAMP[lines as 1 | 2 | 3]} title={text}>\n {text}\n </span>\n );\n}\n\n// What a cell shows: the column's `cell`, or its value by type.\nfunction contentOf<T extends RowData>(v: View<T>, column: DataTableColumn<T>, original: T): React.ReactNode {\n if (column.cell) return column.cell(original);\n const value = valueOf(column, original);\n const text = column.type === \"date\" && value instanceof Date ? value.toISOString().slice(0, 10) : display(value);\n const cut = TRUNCATE[v.L];\n switch (column.type) {\n case \"title\":\n return titleContent(v, column, original, text, cut);\n case \"number\":\n return numberContent(column, value, text);\n case \"link\":\n return linkContent(column, original, text, cut);\n default:\n return plainContent(column, text, cut);\n }\n}\n\n// A group's row keeps its value as the title and its aggregates; a facts column is away (its value is in the title's line).\nfunction listPlace<T extends RowData>(v: View<T>, row: TableRow<T> | null, column: DataTableColumn<T>) {\n if (row?.getIsGrouped()) return row.groupingColumnId === column.id ? \"title\" : column.aggregate ? \"status\" : \"away\";\n const place = placeOf(v.titleColumn, column);\n return place === \"facts\" || place === \"hidden\" ? \"away\" : place;\n}\n\n/** The cell of a group row: the group's value as a button that opens it, or the column's aggregate. */\nfunction groupContent<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, columnId: string) {\n const leaves = row\n .getLeafRows()\n .filter((r) => !r.getIsGrouped())\n .map((r) => r.original);\n if (columnId !== row.groupingColumnId) return column.aggregate ? column.aggregate(leaves) : null;\n const value = display(row.groupingValue as CellValue);\n return (\n <button type=\"button\" className={v.s.toggle({ className: \"px-1.5 font-semibold text-fg\" })} aria-expanded={row.getIsExpanded()} onClick={row.getToggleExpandedHandler()}>\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n {v.labels.group(value, leaves.length)}\n </button>\n );\n}\n\n/** The list row's title cell: the title, and under it the facts joined by a dot. */\nfunction withFacts<T extends RowData>(v: View<T>, content: React.ReactNode, original: T) {\n return (\n <span className=\"block min-w-0\">\n {content}\n <span data-facts=\"\" className={LIST_FACTS[v.L]}>\n {v.facts.map((c, i) => (\n <React.Fragment key={c.id}>\n {i > 0 ? <span aria-hidden>{\" · \"}</span> : null}\n {contentOf(v, c, original)}\n </React.Fragment>\n ))}\n </span>\n </span>\n );\n}\n\n/** The first cell with its chevron, when the columns that left the row are shown in its detail. */\nfunction withToggle<T extends RowData>(v: View<T>, content: React.ReactNode, row: TableRow<T>) {\n const shown = v.maxPriority > 1 ? TOGGLE[v.L][v.maxPriority as Priority] : \"hidden\";\n return (\n <span className=\"flex min-w-0 items-center gap-1\">\n <button\n type=\"button\"\n className={v.s.toggle({ className: cn(shown, v.listAway.length > 0 && LIST_TOGGLE[v.L], v.list && \"relative z-[1]\") })}\n aria-expanded={row.getIsExpanded()}\n aria-label={v.labels.showMore(nameOf(v, row))}\n onClick={row.getToggleExpandedHandler()}\n >\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n </button>\n <span className=\"min-w-0 flex-1\">{content}</span>\n </span>\n );\n}\n\nfunction bodyContent<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, first: boolean) {\n let content = contentOf(v, column, row.original);\n if (v.list && column === v.titleColumn && v.facts.length > 0) content = withFacts(v, content, row.original);\n if (first && v.inlineToggle) content = withToggle(v, content, row);\n return content;\n}\n\nfunction cellClass<T extends RowData>(v: View<T>, column: DataTableColumn<T>) {\n const level = priorityOf(column);\n const type = column.type;\n return [\n ALIGN[column.align ?? (type === \"number\" ? \"end\" : \"start\")],\n type ? TYPE_CELL[type][v.L] : \"\",\n level > 1 ? LEAVES[v.L][level as Priority] : \"\",\n (type || column.priority) && column.minWidth !== undefined ? MIN[v.L] : \"\",\n column.maxWidth !== undefined ? MAX[v.L] : \"\",\n ].join(\" \");\n}\n\nfunction cardRole<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, columnId: string) {\n if (v.list) return column.card === \"hidden\" ? \"hidden\" : undefined;\n if (!row.getIsGrouped()) return cardOf(column);\n if (columnId === row.groupingColumnId) return \"title\";\n return column.aggregate ? undefined : \"hidden\";\n}\n\nfunction cellStyle<T extends RowData>(row: TableRow<T>, column: DataTableColumn<T>, first: boolean, base: React.CSSProperties | undefined): React.CSSProperties {\n const indent = first && row.depth > 0 && !row.getIsGrouped();\n return {\n ...base,\n ...(column.minWidth !== undefined ? { [\"--dt-min\" as string]: `${column.minWidth}px` } : {}),\n ...(column.maxWidth !== undefined ? { [\"--dt-max\" as string]: `${column.maxWidth}px` } : {}),\n ...(indent ? { paddingInlineStart: `${1 + row.depth * 1.25}rem` } : {}),\n };\n}\n\nfunction dataCell<T extends RowData>(v: View<T>, row: TableRow<T>, cell: TableCell<T>, first: boolean) {\n const column = v.byId.get(cell.column.id);\n if (!column) return null;\n const { style, ...pinnedProps } = pin(cell.column);\n const content = row.getIsGrouped() ? groupContent(v, row, column, cell.column.id) : bodyContent(v, row, column, first);\n return (\n <td\n role=\"cell\"\n key={cell.id}\n data-label={column.header}\n data-card={cardRole(v, row, column, cell.column.id)}\n data-list={v.list ? listPlace(v, row, column) : undefined}\n {...pinnedProps}\n className={v.s.td({ className: cellClass(v, column) })}\n style={cellStyle(row, column, first, style)}\n >\n {content}\n </td>\n );\n}\n\n/** The panel under an opened row: the columns that left the row, then the host's own detail. */\nfunction detailRow<T extends RowData>(v: View<T>, row: TableRow<T>) {\n const left = v.visibleColumns.filter((c) => {\n const column = v.byId.get(c.id) as DataTableColumn<T>;\n return priorityOf(column) > 1 || v.listAway.includes(column);\n });\n const { L, s, renderDetail } = v;\n const panel = cn(\"px-4 py-4\", v.maxPriority > 1 ? PANEL[L][v.maxPriority as Priority] : \"hidden\", v.listAway.length > 0 && LIST_PANEL[L]);\n return wideRow(\n v,\n renderDetail ? s.detail() : \"bg-surface-0 p-0 text-left\",\n <>\n {left.length > 0 ? (\n <dl className={cn(\"m-0 grid gap-3 text-left\", renderDetail ? \"mb-4\" : panel)}>\n {left.map((c) => {\n const column = v.byId.get(c.id) as DataTableColumn<T>;\n const place = v.listAway.includes(column) ? LIST_IN_DETAIL[L] : IN_DETAIL[L][priorityOf(column) as Priority];\n return (\n <div key={c.id} className={cn(place, \"grid-cols-[minmax(5rem,8rem)_minmax(0,1fr)] items-baseline gap-3\")}>\n <dt className=\"text-xs font-semibold text-fg-secondary\">{column.header}</dt>\n <dd className=\"m-0 min-w-0 text-sm text-fg\">{contentOf(v, column, row.original)}</dd>\n </div>\n );\n })}\n </dl>\n ) : null}\n {renderDetail ? renderDetail(row.original) : null}\n </>,\n );\n}\n\n/** The leading cells of a row: its checkbox, then the button that opens it. */\nfunction rowLeadCells<T extends RowData>(v: View<T>, row: TableRow<T>, isChosen: boolean) {\n const { s, labels } = v;\n const grouped = row.getIsGrouped();\n const canExpand = !grouped && (v.renderDetail ? true : row.getCanExpand());\n return (\n <>\n {v.selectable && (\n <td role=\"cell\" className={s.td({ className: s.select() })}>\n {grouped ? null : <Checkbox checked={isChosen} onCheckedChange={() => row.toggleSelected()} aria-label={labels.selectRow(nameOf(v, row))} />}\n </td>\n )}\n {v.hasExpander && (\n <td role=\"cell\" className={s.td({ className: s.expander() })}>\n {canExpand ? (\n <button type=\"button\" className={s.toggle()} aria-expanded={row.getIsExpanded()} aria-label={labels.expandRow(nameOf(v, row))} onClick={row.getToggleExpandedHandler()}>\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n </button>\n ) : null}\n </td>\n )}\n </>\n );\n}\n\nfunction renderRow<T extends RowData>(v: View<T>, row: TableRow<T>, index: number) {\n const isChosen = v.chosen.has(row.id);\n const grouped = row.getIsGrouped();\n const showDetail = v.detailed && !grouped && row.getIsExpanded() && !v.virtualized;\n const main = (\n <tr\n role=\"row\"\n data-index={v.measureElement ? index : undefined}\n ref={v.measureElement}\n aria-rowindex={v.virtualized ? index + 2 : undefined}\n data-state={isChosen ? \"selected\" : undefined}\n data-group={grouped ? \"\" : undefined}\n className={v.s.tr({ className: grouped ? v.s.groupRow() : undefined })}\n >\n {rowLeadCells(v, row, isChosen)}\n {row.getVisibleCells().map((cell, i) => dataCell(v, row, cell, i === 0))}\n </tr>\n );\n // One Fragment keyed by the row either way: opening a row keeps its button (and the focus on it).\n return (\n <React.Fragment key={row.id}>\n {main}\n {showDetail ? detailRow(v, row) : null}\n </React.Fragment>\n );\n}\n\n/** A full-width row: a message, or the opened row's detail. */\nfunction wideRow<T extends RowData>(v: View<T>, tdClass: string, children: React.ReactNode) {\n return (\n <tr role=\"row\" className={v.s.tr({ className: \"hover:bg-transparent\" })}>\n <td role=\"cell\" colSpan={v.span} data-card=\"message\" className={v.s.td({ className: tdClass })}>\n {children}\n </td>\n </tr>\n );\n}\n\nfunction messageRow<T extends RowData>(v: View<T>, content: React.ReactNode, alert?: boolean) {\n return wideRow(v, v.s.message(), alert ? <div role=\"alert\">{content}</div> : content);\n}\n\nfunction skeletonRows<T extends RowData>(v: View<T>, count: number) {\n const { s, list } = v;\n return Array.from({ length: count }, (_, i) => (\n <tr role=\"row\" key={`loading-${i}`} aria-hidden className={s.tr()}>\n {v.selectable && <td role=\"cell\" className={s.td({ className: s.select() })} />}\n {v.hasExpander && <td role=\"cell\" className={s.td({ className: s.expander() })} />}\n {v.visibleColumns.map((column) => (\n <td role=\"cell\" key={column.id} data-card={list ? undefined : cardOf(v.byId.get(column.id))} data-list={list ? listPlace(v, null, v.byId.get(column.id) as DataTableColumn<T>) : undefined} className={s.td()}>\n <div className={s.skeleton()} />\n </td>\n ))}\n </tr>\n ));\n}\n\nfunction bodyRows<T extends RowData>(v: View<T>) {\n const { pageRows: rows, windowItems } = v;\n if (v.loading) return skeletonRows(v, v.loadingCount);\n if (v.error) return messageRow(v, v.error, true);\n if (rows.length === 0) return messageRow(v, v.empty ?? v.labels.empty);\n if (windowItems) return windowItems.map((item) => renderRow(v, rows[item.index] as TableRow<T>, item.index));\n return rows.map((row, i) => renderRow(v, row, i));\n}\n\nfunction headerLabel<T extends RowData>(v: View<T>, header: TableHeader<T>, column: DataTableColumn<T>, direction: SortDirection | undefined) {\n if (column.sortable) {\n return (\n <button type=\"button\" aria-pressed={Boolean(direction)} className={v.s.sortButton()} onClick={() => header.column.toggleSorting(undefined, false)}>\n {column.header}\n <SortGlyph direction={direction} className=\"h-3.5 w-3.5\" />\n </button>\n );\n }\n return column.headerHidden ? <span className=\"sr-only\">{column.header}</span> : column.header;\n}\n\nfunction headerCell<T extends RowData>(v: View<T>, header: TableHeader<T>) {\n const column = v.byId.get(header.column.id);\n if (!column) return null;\n const sorted = header.column.getIsSorted();\n const direction: SortDirection | undefined = sorted === \"asc\" ? \"ascending\" : sorted === \"desc\" ? \"descending\" : undefined;\n const { style, ...pinnedProps } = pin(header.column);\n const level = priorityOf(column);\n const top = typeof v.stickyHeader === \"number\" ? { [\"--dt-top\" as string]: `${v.stickyHeader}px` } : {};\n return (\n <th\n role=\"columnheader\"\n scope=\"col\"\n key={header.id}\n aria-sort={column.sortable ? (direction ?? \"none\") : undefined}\n data-keep={column.sortable ? \"\" : undefined}\n {...pinnedProps}\n className={v.s.th({ className: cn(ALIGN[column.align ?? (column.type === \"number\" ? \"end\" : \"start\")], level > 1 && LEAVES_HEAD[v.L][level as Priority]) })}\n style={{ ...style, ...top, ...widthOf(v, header.column) }}\n >\n {headerLabel(v, header, column, direction)}\n {v.resizing && header.column.getCanResize() ? (\n <ResizeHandle\n label={v.labels.resize(column.header)}\n size={header.column.getSize()}\n min={column.minWidth ?? 64}\n resizing={header.column.getIsResizing()}\n className={v.s.resizer()}\n onPointerStart={header.getResizeHandler()}\n onSize={(size) => v.setSizing((old) => ({ ...old, [header.column.id]: size }))}\n />\n ) : null}\n </th>\n );\n}\n\nfunction headerRow<T extends RowData>(v: View<T>, headers: TableHeader<T>[]) {\n const { s, labels } = v;\n return (\n <tr role=\"row\" aria-rowindex={v.virtualized ? 1 : undefined} className={s.headRow()}>\n {v.selectable && (\n <th role=\"columnheader\" scope=\"col\" data-keep=\"\" className={s.th({ className: s.select() })}>\n <Checkbox\n checked={v.allChosen ? true : v.someChosen ? \"indeterminate\" : false}\n onCheckedChange={v.toggleAll}\n disabled={v.loading || v.selectableCount === 0}\n aria-label={labels.selectAll}\n />\n </th>\n )}\n {v.hasExpander && (\n <th role=\"columnheader\" scope=\"col\" className={s.th({ className: s.expander() })}>\n <span className=\"sr-only\">{labels.details}</span>\n </th>\n )}\n {headers.map((header) => headerCell(v, header))}\n </tr>\n );\n}\n\n/** The sort, filters, selection, grouping, visibility, opened rows, page and page size — controlled or not — and the address's query. */\nfunction useControlled<T extends RowData>(p: DataTableProps<T>, route: ReturnType<typeof useRouteTable>) {\n const { defaultSort = null, defaultFilters = NO_RECORD, defaultSelected = NONE, defaultGroupBy = NONE, defaultColumnVisibility = NO_RECORD, defaultExpanded = NO_RECORD, defaultPage = 1 } = p;\n const paginated = p.pageSize !== undefined || p.defaultPageSize !== undefined;\n const [sort, setSort] = useControllable<DataTableSort>(route ? route.sort : p.sort, defaultSort, route?.onSortChange ?? p.onSortChange);\n const [filters, setFiltersState] = useControllable<DataTableFilterState>(route ? route.filters : p.filters, defaultFilters, route?.onFiltersChange ?? p.onFiltersChange);\n const [selected, setSelected] = useControllable<readonly string[]>(p.selected, defaultSelected, p.onSelectedChange as (next: readonly string[]) => void);\n const [groupBy, setGroupBy] = useControllable<readonly string[]>(p.groupBy, defaultGroupBy, p.onGroupByChange as (next: readonly string[]) => void);\n const [visibility, setVisibility] = useControllable<Readonly<Record<string, boolean>>>(p.columnVisibility, defaultColumnVisibility, p.onColumnVisibilityChange as (next: Readonly<Record<string, boolean>>) => void);\n const [expanded, setExpanded] = useControllable<Readonly<Record<string, boolean>>>(p.expanded, defaultExpanded, p.onExpandedChange as (next: Readonly<Record<string, boolean>>) => void);\n const [pageSize, setPageSize] = useControllable<number>(p.pageSize, p.defaultPageSize ?? Number.POSITIVE_INFINITY, p.onPageSizeChange);\n const [page, setPage] = useControllable<number>(route ? route.page : p.page, defaultPage, route?.onPageChange ?? p.onPageChange);\n return { paginated, sort, setSort, filters, setFiltersState, selected, setSelected, groupBy, setGroupBy, visibility, setVisibility, expanded, setExpanded, pageSize, setPageSize, page, setPage };\n}\n\ntype Controlled = ReturnType<typeof useControlled>;\n\n/** One place announces the server's query: after any change of sort, filters, page or page size. */\nfunction useAnnounce<T extends RowData>(p: DataTableProps<T>, c: Controlled, route: ReturnType<typeof useRouteTable>) {\n const { paginated, sort, filters, page, pageSize } = c;\n const { defaultSort = null, defaultFilters = NO_RECORD, defaultPage = 1 } = p;\n const announced = React.useRef(JSON.stringify([defaultSort, defaultFilters, paginated ? defaultPage : 1, paginated ? pageSize : null]));\n const announce = (next: Partial<DataTableQuery>) => {\n const query = { sort, filters, page: paginated ? page : 1, pageSize: paginated ? pageSize : Number.POSITIVE_INFINITY, ...next };\n if (route) announced.current = JSON.stringify([query.sort, query.filters, query.page, paginated ? query.pageSize : null]);\n p.onStateChange?.(query);\n };\n // The address can change under the table (back, forward, a shared link): the server is told the query it now shows,\n // once — a change the table made itself was announced already. A first visit on the defaults says nothing.\n const routeQuery = route ? JSON.stringify([route.sort, route.filters, paginated ? route.page : 1, paginated ? pageSize : null]) : null;\n React.useEffect(() => {\n if (routeQuery === null || routeQuery === announced.current) return;\n announced.current = routeQuery;\n announce({});\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only a change of the address's query announces\n }, [routeQuery]);\n return announce;\n}\n\n/** The changes of the query, each announced; in the address, the sort or the filters reset the page in the same navigation. */\nfunction useQueryChanges<T extends RowData>(p: DataTableProps<T>, c: Controlled, route: ReturnType<typeof useRouteTable>) {\n const announce = useAnnounce(p, c, route);\n const resetPage = () => {\n if (c.paginated && c.page !== 1 && !route) c.setPage(1);\n };\n return {\n changeSort: (next: DataTableSort) => {\n c.setSort(next);\n resetPage();\n announce({ sort: next, page: 1 });\n },\n changeFilters: (next: DataTableFilterState) => {\n c.setFiltersState(next);\n resetPage();\n announce({ filters: next, page: 1 });\n },\n changePage: (next: number) => {\n c.setPage(next);\n announce({ page: next });\n },\n changePageSize: (next: number) => {\n c.setPageSize(next);\n c.setPage(1);\n announce({ pageSize: next, page: 1 });\n },\n };\n}\n\ntype Changes = ReturnType<typeof useQueryChanges>;\n\nconst columnDefs = <T extends RowData>(columns: readonly DataTableColumn<T>[], resizing: boolean | undefined): ColumnDef<typeof features, T>[] =>\n columns.map((column) => ({\n id: column.id,\n accessorFn: (row: T) => valueOf(column, row),\n header: column.header,\n enableSorting: Boolean(column.sortable),\n sortFn: sortByValue as never,\n sortUndefined: \"last\",\n enableColumnFilter: Boolean(column.filter),\n filterFn: (column.filter ? FILTERS[column.filter] : FILTERS.text) as never,\n enableGrouping: Boolean(column.groupable),\n enableHiding: column.hideable !== false,\n enableResizing: Boolean(resizing),\n ...(column.width ? { size: column.width } : {}),\n minSize: column.minWidth ?? 64,\n }));\n\ntype Pinning = { start?: readonly string[]; end?: readonly string[] } | undefined;\n\n/** The table's state handed to the engine, from what the props and the hooks hold. */\nfunction engineState(c: Controlled, rowCount: number, pinned: Pinning, sizing: Record<string, number>, resizeState: ColumnResizingState | undefined) {\n return {\n sorting: sortingOf(c.sort),\n columnFilters: filterListOf(c.filters),\n rowSelection: selectionOf(c.selected),\n grouping: [...c.groupBy],\n columnVisibility: { ...c.visibility },\n expanded: { ...c.expanded },\n pagination: { pageIndex: Math.max(0, c.page - 1), pageSize: c.paginated ? c.pageSize : Math.max(1, rowCount) },\n columnPinning: { start: [...(pinned?.start ?? [])], end: [...(pinned?.end ?? [])] },\n columnSizing: sizing,\n ...(resizeState ? { columnResizing: resizeState } : {}),\n };\n}\n\n/** What the engine tells us changed: each becomes our own state, announced when it is the query. */\nfunction engineHandlers<T extends RowData>(\n c: Controlled,\n changes: Changes,\n setSizing: React.Dispatch<React.SetStateAction<Record<string, number>>>,\n setResizeState: React.Dispatch<React.SetStateAction<ColumnResizingState | undefined>>,\n currentRows: () => TableRow<T>[],\n) {\n return {\n onSortingChange: (updater: Up<ReturnType<typeof sortingOf>>) => {\n const [first] = apply(updater, sortingOf(c.sort));\n changes.changeSort(first ? { column: first.id, direction: first.desc ? \"descending\" : \"ascending\" } : null);\n },\n onColumnFiltersChange: (updater: Up<{ id: string; value: unknown }[]>) => {\n const next = apply(updater, filterListOf(c.filters));\n changes.changeFilters(Object.fromEntries(next.map((f) => [f.id, f.value as FilterValue])));\n },\n onRowSelectionChange: (updater: Up<Record<string, true>>) => {\n const next = apply(updater, selectionOf(c.selected));\n c.setSelected(Object.keys(next).filter((id) => next[id]));\n },\n onGroupingChange: (updater: Up<string[]>) => c.setGroupBy(apply(updater, [...c.groupBy])),\n onColumnVisibilityChange: (updater: Up<Record<string, boolean>>) => c.setVisibility(apply(updater, { ...c.visibility })),\n onExpandedChange: (updater: Up<Record<string, boolean> | true>) => {\n const next = apply<Record<string, boolean> | true>(updater, { ...c.expanded });\n c.setExpanded(next === true ? Object.fromEntries(currentRows().map((r) => [r.id, true])) : next);\n },\n onColumnSizingChange: (updater: Up<Record<string, number>>) => setSizing((old: Record<string, number>) => apply(updater, old)),\n onColumnResizingChange: (updater: Up<ColumnResizingState>) => setResizeState((old) => apply(updater, old as ColumnResizingState)),\n };\n}\n\n/** What the props and the columns say about the table's layout. */\nfunction shapeOf<T extends RowData>(props: DataTableProps<T>) {\n const { columns, phone = \"cards\", virtualized, renderDetail, getSubRows } = props;\n const L: Layout = virtualized ? \"table\" : (props.layout ?? \"auto\");\n const typed = columns.some((c) => c.type || c.priority);\n const list = phone === \"list\" && L !== \"table\";\n const hasExpander = Boolean(renderDetail || getSubRows);\n const maxPriority = columns.reduce<1 | Priority>((max, column) => (priorityOf(column) > max ? priorityOf(column) : max), 1);\n const titleColumn = columns.find((col) => col.card === \"title\" || (!col.card && col.type === \"title\")) ?? columns[0];\n const listAway = list ? columns.filter((col) => placeOf(titleColumn, col) === \"away\" && priorityOf(col) === 1) : [];\n const facts = list ? columns.filter((col) => placeOf(titleColumn, col) === \"facts\") : [];\n const inlineToggle = (maxPriority > 1 || listAway.length > 0) && !hasExpander;\n return { L, typed, list, hasExpander, maxPriority, inlineToggle, detailed: Boolean(renderDetail) || inlineToggle, titleColumn, listAway, facts };\n}\n\n/** The engine, fed by our own state: sizing and resizing live here, everything else in `c`. */\nfunction useEngine<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, detailed: boolean) {\n const { rows, columns, getRowId, getSubRows, pinning, resizing, manual, rowCount, stickyFirstColumn } = props;\n const [sizing, setSizing] = React.useState<Record<string, number>>({});\n const [resizeState, setResizeState] = React.useState<ColumnResizingState | undefined>(undefined);\n const defs = React.useMemo(() => columnDefs(columns, resizing), [columns, resizing]);\n const firstId = columns[0]?.id;\n const pinned = stickyFirstColumn && firstId && !pinning?.start?.length ? { ...pinning, start: [firstId] } : pinning;\n const table: DataTableInstance<T> = useTable<typeof features, T>({\n features,\n columns: defs,\n data: rows as T[],\n getRowId: (row) => getRowId(row),\n getSubRows: getSubRows ? (row) => getSubRows(row) as T[] | undefined : undefined,\n getRowCanExpand: detailed ? () => true : undefined,\n state: engineState(c, rows.length, pinned, sizing, resizeState),\n ...engineHandlers<T>(c, changes, setSizing, setResizeState, () => table.getRowModel().rows),\n enableSortingRemoval: true,\n sortDescFirst: false,\n manualSorting: manual?.sorting,\n manualFiltering: manual?.filtering,\n manualPagination: manual?.pagination || !c.paginated,\n rowCount: manual?.pagination ? rowCount : undefined,\n autoResetPageIndex: false,\n autoResetExpanded: false,\n groupedColumnMode: false,\n columnResizeMode: \"onChange\",\n enableRowSelection: (row) => !row.getIsGrouped(),\n }) as unknown as DataTableInstance<T>;\n return { table, pinned, setSizing };\n}\n\n/** The count of results and of pages; a page beyond the last (the filters shrank the list) shows the last one. */\nfunction usePaging<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, table: DataTableInstance<T>) {\n const { manual, rowCount, rows, loading } = props;\n const { paginated, page, pageSize } = c;\n const leafCount = (manual?.pagination || manual?.filtering) && rowCount !== undefined ? rowCount : table.getFilteredRowModel().rows.length;\n const pageCount = paginated ? Math.max(1, manual?.pagination ? Math.ceil((rowCount ?? rows.length) / pageSize) : table.getPageCount()) : 1;\n React.useEffect(() => {\n if (paginated && !loading && page > pageCount) changes.changePage(pageCount);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only when the count of pages drops under the page\n }, [pageCount]);\n return { leafCount, pageCount };\n}\n\n/** What is chosen on this page: the ids that can be, whether all or some are, and the toggle. */\nfunction useChoice<T extends RowData>(pageRows: TableRow<T>[], selected: readonly string[], setSelected: (ids: string[]) => void) {\n const selectableIds = pageRows.filter((r) => !r.getIsGrouped()).map((r) => r.id);\n const chosen = new Set(selected);\n const allChosen = selectableIds.length > 0 && selectableIds.every((id) => chosen.has(id));\n const someChosen = selectableIds.some((id) => chosen.has(id));\n const toggleAll = () => setSelected(allChosen ? selected.filter((id) => !selectableIds.includes(id)) : [...new Set([...selected, ...selectableIds])]);\n return { chosen, allChosen, someChosen, toggleAll, selectableCount: selectableIds.length };\n}\n\n/** The query in the address (or in memory): the sort, the page, the filters. */\nfunction useRoute<T extends RowData>(props: DataTableProps<T>) {\n const { defaultSort, defaultPage, defaultFilters, columns } = props;\n return useRouteTable(props.routeKey, { sort: defaultSort ?? null, page: defaultPage ?? 1, filters: defaultFilters ?? NO_RECORD }, columns.map((c) => c.id));\n}\n\n/** The table element: caption, header and the body between two spacer rows when windowed. */\nfunction tableOf<T extends RowData>(v: View<T>, table: DataTableInstance<T>, caption: string, showCaption: boolean | undefined, before: number, after: number) {\n const { s, labels, virtualized, span, fixedLayout, loading } = v;\n const headers = table.getHeaderGroups().at(-1)?.headers ?? [];\n const spacer = (height: number) => (\n <tr aria-hidden style={{ height }}>\n <td colSpan={span} />\n </tr>\n );\n return (\n <table\n role=\"table\"\n aria-busy={loading || undefined}\n aria-rowcount={virtualized ? v.pageRows.length + 1 : undefined}\n className={s.table({ className: fixedLayout ? \"table-fixed\" : undefined })}\n style={fixedLayout ? { minWidth: table.getTotalSize() + (v.selectable ? 40 : 0) + (v.hasExpander ? 40 : 0) } : undefined}\n >\n <caption className={showCaption ? s.caption() : \"sr-only\"}>\n {caption}\n {loading ? <span className=\"sr-only\">{` — ${labels.loading}`}</span> : null}\n </caption>\n <thead role=\"rowgroup\" className={s.thead({ className: virtualized ? \"sticky top-0 z-10 bg-surface-2\" : undefined })}>\n {headerRow(v, headers as unknown as TableHeader<T>[])}\n </thead>\n <tbody role=\"rowgroup\" className={s.tbody()}>\n {before > 0 && spacer(before)}\n {bodyRows(v)}\n {after > 0 && spacer(after)}\n </tbody>\n </table>\n );\n}\n\n/** The page controls under the table. */\nfunction pager<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, pageCount: number, labels: DataTableLabels) {\n const { pageSizeOptions, loading } = props;\n return (\n <Pagination\n page={Math.min(c.page, pageCount)}\n pageCount={pageCount}\n onPageChange={changes.changePage}\n pageSize={pageSizeOptions ? c.pageSize : undefined}\n pageSizeOptions={pageSizeOptions}\n onPageSizeChange={pageSizeOptions ? changes.changePageSize : undefined}\n disabled={loading}\n labels={labels.pagination}\n />\n );\n}\n\n/** A table of records — sort, filters and facets, groups, details, pages, selection, visibility, pinning, resizing — on the client or the server, cards on a phone, windowing for long lists. */\nexport function DataTable<T extends RowData>(props: DataTableProps<T>) {\n const { columns, caption, showCaption, selectable, bulkActions, bulkMax, bulkResult, resizing, renderDetail, rowLabel, toolbar, footer, className, virtualized, loading, stickyHeader, scroll, manual } = props;\n const labels = { ...dataTableLabels, ...props.labels };\n const shape = shapeOf(props);\n const s = dataTable({ layout: shape.L, density: props.density, sticky: Boolean(stickyHeader), striped: Boolean(props.striped), typed: shape.typed, phone: shape.list ? \"list\" : \"cards\" });\n\n const route = useRoute(props);\n const c = useControlled(props, route);\n const changes = useQueryChanges(props, c, route);\n const { table, pinned, setSizing } = useEngine(props, c, changes, shape.detailed);\n const { leafCount, pageCount } = usePaging(props, c, changes, table);\n const pageRows = table.getRowModel().rows;\n const pick = useChoice(pageRows, c.selected, c.setSelected);\n const scroller = React.useRef<HTMLDivElement>(null);\n const win = useWindow(virtualized, loading, pageRows, scroller);\n\n const span = table.getVisibleLeafColumns().length + (selectable ? 1 : 0) + (shape.hasExpander ? 1 : 0);\n const fixedLayout = Boolean(resizing || pinned?.start?.length || pinned?.end?.length);\n const v: View<T> = {\n ...shape, ...pick,\n s, labels, byId: new Map(columns.map((col) => [col.id, col])),\n selectable: Boolean(selectable), span, virtualized: Boolean(virtualized), fixedLayout, renderDetail,\n rowLabel, visibleColumns: table.getVisibleLeafColumns(), measureElement: win.measureElement, loading, loadingCount: props.loadingRows ?? 5, error: props.error, empty: props.empty, pageRows, windowItems: win.items, resizing, stickyHeader, setSizing,\n };\n\n const context: Context = {\n table: table as unknown as DataTableInstance<object>,\n columns: columns as readonly DataTableColumn<object>[],\n labels,\n filters: c.filters,\n setFilters: changes.changeFilters,\n resultCount: leafCount,\n exportRows: () => table.getSortedRowModel().flatRows.filter((r) => !r.getIsGrouped()).map((r) => r.original),\n manualFiltering: Boolean(manual?.filtering),\n };\n\n const tableElement = tableOf(v, table, caption, showCaption, win.before, win.after);\n const sideways = scroll ?? (!shape.typed && !stickyHeader);\n const pagination = c.paginated ? pager(props, c, changes, pageCount, labels) : null;\n\n return (\n <DataTableContext.Provider value={context}>\n <div className={s.root({ className })}>\n {toolbar ? <div className={s.toolbar()}>{toolbar}</div> : null}\n {virtualized ? (\n // A scrolling region the keyboard can reach: Tab lands on it, the arrows scroll it.\n <div\n ref={scroller}\n tabIndex={0}\n role=\"region\"\n aria-label={caption}\n className={s.scroller({ className: \"overflow-y-auto focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\" })}\n style={{ height: virtualized.height }}\n >\n {tableElement}\n </div>\n ) : (\n <div className={s.scroller({ className: sideways ? (scroll ? SHADOWS : CARD_CLIP[shape.L]) : \"overflow-x-clip\" })}>{tableElement}</div>\n )}\n {selectable && bulkActions ? (\n <SelectionBar count={c.selected.length} max={bulkMax} result={bulkResult} labels={labels.selection} onClear={() => c.setSelected([])}>\n {bulkActions({ selected: [...c.selected], clear: () => c.setSelected([]) })}\n </SelectionBar>\n ) : null}\n {pagination || footer ? (\n <div className={s.footer({ className: \"flex flex-col gap-3\" })}>\n {pagination}\n {footer}\n </div>\n ) : null}\n </div>\n </DataTableContext.Provider>\n );\n}\n\n/** Windowing: the rows in view, between two spacer rows that keep the scroll height. */\nfunction useWindow<T extends RowData>(virtualized: DataTableProps<T>[\"virtualized\"], loading: boolean | undefined, pageRows: TableRow<T>[], scroller: React.RefObject<HTMLDivElement | null>) {\n const fallbacks = useLayoutFallbacks(virtualized?.height ?? 0, virtualized?.estimateRowHeight ?? 44);\n const virtualizer = useVirtualizer({\n ...fallbacks,\n count: pageRows.length,\n getScrollElement: () => scroller.current,\n estimateSize: () => virtualized?.estimateRowHeight ?? 44,\n overscan: virtualized?.overscan ?? 6,\n initialRect: { width: 0, height: virtualized?.height ?? 0 },\n getItemKey: (index) => pageRows[index]?.id ?? index,\n enabled: Boolean(virtualized) && !loading,\n });\n const items = virtualized && !loading ? virtualizer.getVirtualItems() : null;\n const before = items?.[0]?.start ?? 0;\n const after = items && items.length > 0 ? virtualizer.getTotalSize() - (items.at(-1)?.end ?? 0) : 0;\n return { items, before, after, measureElement: items ? virtualizer.measureElement : undefined };\n}\n\n/** The handle on a header's edge: drag it, or focus it and use ← → (Shift for larger steps). */\nfunction ResizeHandle({\n label,\n size,\n min,\n resizing,\n className,\n onPointerStart,\n onSize,\n}: {\n label: string;\n size: number;\n min: number;\n resizing: boolean;\n className: string;\n onPointerStart: (event: unknown) => void;\n onSize: (size: number) => void;\n}) {\n return (\n // A focusable separator is interactive (WAI-ARIA \"window splitter\"): its value is the width, the arrows change it.\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-valuenow={Math.round(size)}\n aria-valuemin={min}\n tabIndex={0}\n data-resizing={resizing ? \"\" : undefined}\n className={className}\n onMouseDown={onPointerStart}\n onTouchStart={onPointerStart}\n onClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => {\n const step = event.shiftKey ? 48 : 16;\n if (event.key === \"ArrowLeft\") onSize(Math.max(min, size - step));\n else if (event.key === \"ArrowRight\") onSize(size + step);\n else return;\n event.preventDefault();\n }}\n />\n );\n}\n"
|
|
794
|
+
"content": "// Client (the table's state, the windowing of long lists). A real `<table>` with a caption and column headers\n// (`scope=\"col\"`, `aria-sort` on the sorted one) that turns into a stack of cards in a narrow container — one DOM, the\n// roles written out so that the change of `display` never loses the table's semantics. The engine is TanStack Table v9\n// (engine.ts): sorting, filters and facets, grouping, expanding, pagination, selection, visibility, pinning, resizing —\n// in the browser, or on the server (`manual` + `onStateChange`). Long lists render by what is in view (`virtualized`).\nimport { useTable } from \"@tanstack/react-table\";\nimport * as React from \"react\";\nimport { tv } from \"tailwind-variants\";\n\nimport { Checkbox } from \"../checkbox\";\nimport { cn } from \"../cn\";\nimport { ChevronGlyph, SortGlyph } from \"../glyphs\";\nimport { useControllable } from \"../media\";\nimport { Pagination, type PaginationLabels } from \"../pagination\";\nimport { useLayoutFallbacks, useVirtualizer } from \"../virtual/virtual\";\nimport {\n type CellValue,\n type ColumnDef,\n type ColumnResizingState,\n type DataTableFilterState,\n type DataTableInstance,\n features,\n FILTERS,\n type FilterValue,\n type RowData,\n sortByValue,\n type TableCell,\n type TableColumn,\n type TableRow,\n} from \"./engine\";\nimport { SelectionBar, type SelectionBarLabels } from \"./selection-bar\";\nimport { useRouteTable } from \"./use-route-table\";\n\nexport const dataTable = tv({\n slots: {\n root: \"@container w-full overflow-clip rounded-xl border border-border-default bg-surface-1\",\n toolbar: \"border-b border-border-default p-3\",\n scroller: \"w-full overflow-x-auto\",\n table: \"w-full border-collapse text-left text-sm text-fg\",\n caption: \"px-4 pt-4 pb-2 text-left text-sm font-semibold text-fg\",\n thead: \"bg-surface-2/60\",\n headRow: \"border-b border-border-default\",\n th: \"relative whitespace-nowrap px-4 py-3 text-xs font-semibold text-fg-secondary\",\n sortButton:\n \"-mx-1.5 inline-flex items-center gap-1 rounded-md px-1.5 py-1 hover:bg-surface-3 hover:text-fg \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring aria-[pressed=true]:text-fg\",\n resizer:\n \"absolute top-0 right-0 h-full w-1.5 cursor-col-resize touch-none select-none bg-transparent hover:bg-border-strong \" +\n \"focus-visible:bg-accent focus-visible:outline-hidden data-[resizing]:bg-accent\",\n tbody: \"\",\n tr: \"border-b border-border-subtle transition-colors last:border-b-0 hover:bg-surface-2/50 data-[state=selected]:bg-accent-soft\",\n groupRow: \"bg-surface-2/40 font-semibold\",\n td: \"px-4 py-3 align-middle\",\n select: \"w-10\",\n expander: \"w-10\",\n toggle:\n \"inline-flex h-7 min-w-7 items-center justify-center gap-1.5 rounded-md text-fg-secondary hover:bg-surface-3 hover:text-fg \" +\n \"focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring [&[aria-expanded=true]>svg]:rotate-90 [&>svg]:transition-transform motion-reduce:[&>svg]:transition-none\",\n detail: \"bg-surface-0 px-4 py-4\",\n message: \"px-4 py-10 text-center text-sm text-fg-secondary\",\n skeleton: \"h-4 w-full max-w-40 animate-pulse rounded bg-surface-3 motion-reduce:animate-none\",\n footer: \"border-t border-border-default px-4 py-3\",\n },\n variants: {\n layout: {\n table: {\n th: \"data-[pin]:sticky data-[pin]:z-[2] data-[pin]:bg-surface-2 data-[pin=start]:left-(--dt-pin) data-[pin=end]:right-(--dt-pin)\",\n td: \"data-[pin]:sticky data-[pin]:z-[1] data-[pin]:bg-surface-1 data-[pin=start]:left-(--dt-pin) data-[pin=end]:right-(--dt-pin)\",\n },\n // Below 36rem of container: cards. The sortable headers stay, as a row of sort buttons above the cards.\n auto: {\n table: \"@max-xl:block\",\n caption: \"@max-xl:block\",\n thead: \"@max-xl:sr-only @max-xl:bg-transparent @max-xl:has-[[data-keep]]:not-sr-only @max-xl:has-[[data-keep]]:block\",\n headRow: \"@max-xl:flex @max-xl:flex-wrap @max-xl:items-center @max-xl:gap-2 @max-xl:px-3 @max-xl:py-2\",\n th:\n \"@max-xl:sr-only @max-xl:data-[keep]:not-sr-only @max-xl:data-[keep]:block @max-xl:p-0 \" +\n \"@xl:data-[pin]:sticky @xl:data-[pin]:z-[2] @xl:data-[pin]:bg-surface-2 @xl:data-[pin=start]:left-(--dt-pin) @xl:data-[pin=end]:right-(--dt-pin)\",\n tbody: \"@max-xl:grid @max-xl:gap-3 @max-xl:p-3\",\n tr: \"@max-xl:relative @max-xl:grid @max-xl:gap-1.5 @max-xl:rounded-xl @max-xl:border @max-xl:border-border-default @max-xl:bg-surface-0 @max-xl:p-4 @max-xl:last:border-b\",\n td:\n \"@max-xl:flex @max-xl:min-w-0 @max-xl:items-baseline @max-xl:justify-between @max-xl:gap-4 @max-xl:p-0 @max-xl:text-right @max-xl:[overflow-wrap:anywhere] \" +\n \"@max-xl:[&>*]:min-w-0 @max-xl:[&>*]:shrink @max-xl:[&>*]:whitespace-normal \" +\n \"@max-xl:before:shrink-0 @max-xl:before:text-xs @max-xl:before:font-semibold @max-xl:before:text-fg-secondary @max-xl:before:content-[attr(data-label)] \" +\n \"@max-xl:data-[card=title]:order-first @max-xl:data-[card=title]:pr-8 @max-xl:data-[card=title]:text-left @max-xl:data-[card=title]:text-base @max-xl:data-[card=title]:font-semibold @max-xl:data-[card=title]:before:content-none \" +\n \"@max-xl:data-[card=hidden]:hidden @max-xl:data-[card=message]:block @max-xl:data-[card=message]:text-center @max-xl:data-[card=message]:before:content-none \" +\n \"@xl:data-[pin]:sticky @xl:data-[pin]:z-[1] @xl:data-[pin]:bg-surface-1 @xl:data-[pin=start]:left-(--dt-pin) @xl:data-[pin=end]:right-(--dt-pin)\",\n select: \"@max-xl:absolute @max-xl:right-3 @max-xl:top-3 @max-xl:w-auto @max-xl:before:content-none\",\n expander: \"@max-xl:before:content-none\",\n },\n cards: {\n table: \"block\",\n caption: \"block\",\n thead: \"sr-only bg-transparent has-[[data-keep]]:not-sr-only has-[[data-keep]]:block\",\n headRow: \"flex flex-wrap items-center gap-2 px-3 py-2\",\n th: \"sr-only p-0 data-[keep]:not-sr-only data-[keep]:block\",\n tbody: \"grid gap-3 p-3\",\n tr: \"relative grid gap-1.5 rounded-xl border border-border-default bg-surface-0 p-4 last:border-b\",\n td:\n \"flex min-w-0 items-baseline justify-between gap-4 p-0 text-right [overflow-wrap:anywhere] before:shrink-0 before:text-xs before:font-semibold before:text-fg-secondary before:content-[attr(data-label)] \" +\n \"[&>*]:min-w-0 [&>*]:shrink [&>*]:whitespace-normal \" +\n \"data-[card=title]:order-first data-[card=title]:pr-8 data-[card=title]:text-left data-[card=title]:text-base data-[card=title]:font-semibold data-[card=title]:before:content-none \" +\n \"data-[card=hidden]:hidden data-[card=message]:block data-[card=message]:text-center data-[card=message]:before:content-none\",\n select: \"absolute right-3 top-3 w-auto before:content-none\",\n expander: \"before:content-none\",\n },\n },\n density: {\n comfortable: {},\n compact: { th: \"py-2\", td: \"py-1.5\" },\n },\n // The header stays in view while the page scrolls (table layouts only; `--dt-top` clears a fixed bar).\n sticky: { true: {}, false: {} },\n // Zebra rows (the table layouts); the cards keep their frame.\n striped: { true: {}, false: {} },\n // Typed columns: one height per row (`typed`); untyped tables keep the height of their content.\n typed: { true: {}, false: {} },\n // What a row becomes on a phone (under 36 rem, or with `layout=\"cards\"`): a card, or a list row (#636).\n phone: { cards: {}, list: {} },\n },\n compoundVariants: [\n { layout: \"table\", sticky: true, class: { th: \"sticky top-(--dt-top,0px) z-[3] bg-surface-2\" } },\n { layout: \"auto\", sticky: true, class: { th: \"@xl:sticky @xl:top-(--dt-top,0px) @xl:z-[3] @xl:bg-surface-2\" } },\n { layout: \"table\", striped: true, class: { tr: \"even:bg-surface-2/40\" } },\n { layout: \"auto\", striped: true, class: { tr: \"@xl:even:bg-surface-2/40\" } },\n // One row height per density (a two-line row — a name and its id — is the tallest).\n { layout: \"table\", density: \"comfortable\", typed: true, class: { td: \"h-15\" } },\n { layout: \"auto\", density: \"comfortable\", typed: true, class: { td: \"@xl:h-15\" } },\n { layout: \"table\", density: \"compact\", typed: true, class: { td: \"h-12\" } },\n { layout: \"auto\", density: \"compact\", typed: true, class: { td: \"@xl:h-12\" } },\n // The list rows (#636): no box in the box, no label/value lines — the checkbox, the title and its line of facts, the\n // status at the end, a hairline between rows. Each cell says its place in `data-list` (title · status · away).\n {\n layout: \"auto\",\n phone: \"list\",\n class: {\n tbody: \"@max-xl:gap-0 @max-xl:p-0\",\n tr:\n \"@max-xl:flex @max-xl:items-center @max-xl:gap-3 @max-xl:rounded-none @max-xl:border-0 @max-xl:border-b @max-xl:border-border-subtle @max-xl:bg-transparent \" +\n \"@max-xl:px-4 @max-xl:py-3 @max-xl:last:border-b-0\",\n td:\n \"@max-xl:block @max-xl:text-left @max-xl:before:content-none @max-xl:data-[list=title]:min-w-0 @max-xl:data-[list=title]:flex-1 \" +\n \"@max-xl:data-[list=status]:shrink-0 @max-xl:data-[list=away]:hidden @max-xl:data-[card=message]:w-full\",\n select: \"@max-xl:relative @max-xl:right-auto @max-xl:top-auto @max-xl:z-[1] @max-xl:shrink-0 @max-xl:self-center\",\n expander: \"@max-xl:relative @max-xl:z-[1] @max-xl:shrink-0\",\n },\n },\n {\n layout: \"cards\",\n phone: \"list\",\n class: {\n tbody: \"gap-0 p-0\",\n tr: \"flex items-center gap-3 rounded-none border-0 border-b border-border-subtle bg-transparent px-4 py-3 last:border-b-0\",\n td: \"block text-left before:content-none data-[list=title]:min-w-0 data-[list=title]:flex-1 data-[list=status]:shrink-0 data-[list=away]:hidden data-[card=message]:w-full\",\n select: \"relative right-auto top-auto z-[1] shrink-0 self-center\",\n expander: \"relative z-[1] shrink-0\",\n },\n },\n ],\n defaultVariants: { layout: \"auto\", density: \"comfortable\", sticky: false, striped: false, typed: false, phone: \"cards\" },\n});\n\n// Column priorities. `priority: 1` (default) is always in the row; a higher number leaves the row when the table's own\n// width (a container query, not the window's) falls under its tier and goes to the row's detail — the same\n// `@container` that turns the table into cards. Written out in full: Tailwind finds a class only as a whole string.\n// priority 2 → 42rem · 3 → 48rem · 4 → 56rem · 5 → 64rem · 6 → 72rem · 7 → 80rem\n// On the cards (under 36rem), priority 2 stays on the card's face and 3+ go to its detail.\ntype Priority = 2 | 3 | 4 | 5 | 6 | 7;\ntype ByLayout = { auto: Record<Priority, string>; table: Record<Priority, string>; cards: Record<Priority, string> };\nconst NO_CLASS: Record<Priority, string> = { 2: \"\", 3: \"\", 4: \"\", 5: \"\", 6: \"\", 7: \"\" };\n/** The cell of a column that leaves the row. */\nconst LEAVES: ByLayout = {\n auto: { 2: \"@xl:@max-2xl:hidden!\", 3: \"@max-3xl:hidden!\", 4: \"@max-4xl:hidden!\", 5: \"@max-5xl:hidden!\", 6: \"@max-6xl:hidden!\", 7: \"@max-7xl:hidden!\" },\n table: { 2: \"@max-2xl:hidden!\", 3: \"@max-3xl:hidden!\", 4: \"@max-4xl:hidden!\", 5: \"@max-5xl:hidden!\", 6: \"@max-6xl:hidden!\", 7: \"@max-7xl:hidden!\" },\n cards: { 2: \"\", 3: \"hidden!\", 4: \"hidden!\", 5: \"hidden!\", 6: \"hidden!\", 7: \"hidden!\" },\n};\n/** Its header (the cards keep the sort buttons). */\nconst LEAVES_HEAD: ByLayout = {\n auto: { 2: \"@xl:@max-2xl:hidden!\", 3: \"@xl:@max-3xl:hidden!\", 4: \"@xl:@max-4xl:hidden!\", 5: \"@xl:@max-5xl:hidden!\", 6: \"@xl:@max-6xl:hidden!\", 7: \"@xl:@max-7xl:hidden!\" },\n table: LEAVES.table,\n cards: NO_CLASS,\n};\n/** Its line in the row's detail: shown exactly when the cell is not. */\nconst IN_DETAIL: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:grid\", 3: \"hidden @max-3xl:grid\", 4: \"hidden @max-4xl:grid\", 5: \"hidden @max-5xl:grid\", 6: \"hidden @max-6xl:grid\", 7: \"hidden @max-7xl:grid\" },\n table: { 2: \"hidden @max-2xl:grid\", 3: \"hidden @max-3xl:grid\", 4: \"hidden @max-4xl:grid\", 5: \"hidden @max-5xl:grid\", 6: \"hidden @max-6xl:grid\", 7: \"hidden @max-7xl:grid\" },\n cards: { 2: \"hidden\", 3: \"grid\", 4: \"grid\", 5: \"grid\", 6: \"grid\", 7: \"grid\" },\n};\n/** The button that opens the detail, and its panel, keyed by the highest priority of the table: seen only when something left the row. */\nconst TOGGLE: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:inline-flex\", 3: \"hidden @max-3xl:inline-flex\", 4: \"hidden @max-4xl:inline-flex\", 5: \"hidden @max-5xl:inline-flex\", 6: \"hidden @max-6xl:inline-flex\", 7: \"hidden @max-7xl:inline-flex\" },\n table: { 2: \"hidden @max-2xl:inline-flex\", 3: \"hidden @max-3xl:inline-flex\", 4: \"hidden @max-4xl:inline-flex\", 5: \"hidden @max-5xl:inline-flex\", 6: \"hidden @max-6xl:inline-flex\", 7: \"hidden @max-7xl:inline-flex\" },\n cards: { 2: \"hidden\", 3: \"inline-flex\", 4: \"inline-flex\", 5: \"inline-flex\", 6: \"inline-flex\", 7: \"inline-flex\" },\n};\nconst PANEL: ByLayout = {\n auto: { 2: \"hidden @xl:@max-2xl:block\", 3: \"hidden @max-3xl:block\", 4: \"hidden @max-4xl:block\", 5: \"hidden @max-5xl:block\", 6: \"hidden @max-6xl:block\", 7: \"hidden @max-7xl:block\" },\n table: { 2: \"hidden @max-2xl:block\", 3: \"hidden @max-3xl:block\", 4: \"hidden @max-4xl:block\", 5: \"hidden @max-5xl:block\", 6: \"hidden @max-6xl:block\", 7: \"hidden @max-7xl:block\" },\n cards: { 2: \"hidden\", 3: \"block\", 4: \"block\", 5: \"block\", 6: \"block\", 7: \"block\" },\n};\n\n// The list rows (`phone=\"list\"`): the facts line under the title, the columns that go to the row's detail (every\n// priority-1 column that is neither the title nor a status), the button and the panel that show them, the title's link\n// stretched over the row.\nconst LIST_FACTS = { auto: \"hidden @max-xl:mt-0.5 @max-xl:block @max-xl:truncate text-xs font-normal text-fg-secondary\", table: \"hidden\", cards: \"mt-0.5 block truncate text-xs font-normal text-fg-secondary\" } as const;\nconst LIST_IN_DETAIL = { auto: \"hidden @max-xl:grid\", table: \"hidden\", cards: \"grid\" } as const;\nconst LIST_TOGGLE = { auto: \"@max-xl:inline-flex\", table: \"\", cards: \"inline-flex\" } as const;\nconst LIST_PANEL = { auto: \"@max-xl:block\", table: \"\", cards: \"block\" } as const;\nconst LIST_LINK = { auto: \"@max-xl:after:absolute @max-xl:after:inset-0 @max-xl:after:content-['']\", table: \"\", cards: \"after:absolute after:inset-0 after:content-['']\" } as const;\n\nexport type DataTableColumnType = \"title\" | \"badge\" | \"number\" | \"link\" | \"date\" | \"status\" | \"text\";\n\n// What each type does to its cell. Sizes apply to the table layouts only (a card is not a column).\n// title: the column that takes the slack, truncated, full value on hover · badge, status, number, date: as wide as\n// their content, never stretched · link: truncated · text: wraps, two lines.\nconst TYPE_CELL: Record<DataTableColumnType, ByLayoutString> = {\n title: { auto: \"@xl:w-full @xl:max-w-0 @xl:min-w-44\", table: \"w-full max-w-0 min-w-44\", cards: \"\" },\n badge: { auto: \"@xl:w-px\", table: \"w-px\", cards: \"\" },\n status: { auto: \"@xl:w-px @xl:whitespace-nowrap\", table: \"w-px whitespace-nowrap\", cards: \"\" },\n number: { auto: \"@xl:w-px @xl:whitespace-nowrap tabular-nums\", table: \"w-px whitespace-nowrap tabular-nums\", cards: \"tabular-nums\" },\n date: { auto: \"@xl:w-px @xl:whitespace-nowrap tabular-nums\", table: \"w-px whitespace-nowrap tabular-nums\", cards: \"tabular-nums\" },\n link: { auto: \"@xl:min-w-28 @xl:max-w-56\", table: \"min-w-28 max-w-56\", cards: \"\" },\n text: { auto: \"@xl:min-w-36\", table: \"min-w-36\", cards: \"\" },\n};\ntype ByLayoutString = { auto: string; table: string; cards: string };\nconst CLAMP = { 1: \"line-clamp-1\", 2: \"line-clamp-2\", 3: \"line-clamp-3\" } as const;\n\nexport type SortDirection = \"ascending\" | \"descending\";\nexport type DataTableSort = { column: string; direction: SortDirection } | null;\n\n/** What the server needs to fetch a page (`manual` mode): given to `onStateChange` at each change. */\nexport type DataTableQuery = {\n /** The sorted column, or `null`. */\n sort: DataTableSort;\n /** The filters in force, by column id. */\n filters: DataTableFilterState;\n /** The page, from 1 (1 without pagination). */\n page: number;\n /** Rows per page (`Infinity` without pagination). */\n pageSize: number;\n};\n\nexport type DataTableColumn<T> = {\n /** A key of the column (and of the row, for the default value). */\n id: string;\n /** The column's name, passed translated: the header, the label of the value in a card, the filter's name. */\n header: string;\n /** What a cell shows. Default: the value as text. */\n cell?: (row: T) => React.ReactNode;\n /** The value sorted, filtered, grouped and exported. Default `row[id]`. */\n value?: (row: T) => CellValue;\n /** The header becomes a sort button (ascending → descending → none). */\n sortable?: boolean;\n /** How `DataTableFilters` filters it: `text` (a search), `facet` (values to choose), `range` (numbers between bounds). */\n filter?: \"text\" | \"facet\" | \"range\";\n /** The choices of a `facet` filter, with their words (and counts from the server). Default: the values found in the rows. */\n options?: readonly { value: string; label: string; count?: number }[];\n /** The rows can be grouped by this column (`groupBy`). */\n groupable?: boolean;\n /** What a group's row shows in this column, from the group's rows (a sum, a count). */\n aggregate?: (rows: readonly T[]) => React.ReactNode;\n /** Text alignment: `end` for amounts and counts. */\n align?: \"start\" | \"center\" | \"end\";\n /** The width, in px (the starting width when `resizing`). */\n width?: number;\n /** The narrowest the column may be, in px (also what a resized one may shrink to). Default 64. */\n minWidth?: number;\n /** In a card: `title` (the heading of the card), `label` (default: \"Header value\"), `hidden`. */\n card?: \"title\" | \"label\" | \"hidden\";\n /** Hides the header visually (an actions column), keeping it for screen readers. */\n headerHidden?: boolean;\n /** Listed in `DataTableColumnsMenu`, so a person can hide it. Default `true`. */\n hideable?: boolean;\n /**\n * What the column holds, which sizes and aligns it: `title` (the name, takes the slack, truncated, `subtitle` under it in\n * mono — and the card's heading), `badge` · `status` (as wide as the badge, never stretched), `number` (end-aligned,\n * tabular), `date`, `link` (truncated, `href`), `text` (wraps, two lines). Untyped: as before.\n */\n type?: DataTableColumnType;\n /**\n * 1 (default) always in the row; 2 to 7 leave it when the table is narrower than 42 · 48 · 56 · 64 · 72 · 80 rem and\n * go to the row's detail (a chevron opens it); under 36 rem (cards) 2 stays on the card, 3+ go to its detail. In the phone's\n * list rows (`phone=\"list\"`), the 2s are joined as the line of facts under the title.\n */\n priority?: 1 | 2 | 3 | 4 | 5 | 6 | 7;\n /** `title`: the line under the name (an id), in mono. */\n subtitle?: (row: T) => React.ReactNode;\n /** `link`: where the value leads. `title`: the row's page — the name becomes its link (the whole row, in the phone's list rows). */\n href?: (row: T) => string | undefined;\n /** `number`: the unit after the value (muted). */\n unit?: string;\n /** The widest the column may be in the table layouts, in px; longer text is clamped, the full value on hover. */\n maxWidth?: number;\n /** One line only, truncated (the full value on hover). */\n nowrap?: boolean;\n /** Lines of text kept before the ellipsis (default 2 for `text`). */\n clamp?: 1 | 2 | 3;\n};\n\nexport type DataTableLabels = {\n /** The checkbox of the header (\"Select all rows\"). */\n selectAll: string;\n /** The checkbox of a row: `(name) => \"Select \" + name`, the name from `rowLabel`. */\n selectRow: (name: string) => string;\n /** Read while the rows load (\"Loading\"). */\n loading: string;\n /** The default empty state (\"Nothing to show\"). */\n empty: string;\n /** The header of the column of the expand buttons, for screen readers (\"Details\"). */\n details: string;\n /** The button that opens a row: `(name) => \"Show details of \" + name`. */\n expandRow: (name: string) => string;\n /** The button of a group's row: `(value, count) => value + \", \" + count + \" rows\"`. */\n group: (value: string, count: number) => string;\n /** The handle that resizes a column: `(header) => \"Resize \" + header`. */\n resize: (header: string) => string;\n /** The count of results under the filters: `(count) => count + \" rows\"`. */\n results: (count: number) => string;\n /** The accessible name of the filters' bar (\"Filter the table\"). */\n filters: string;\n /** \"Clear filters\". */\n clearFilters: string;\n /** A filter's chip remove button: `(label) => \"Remove \" + label`. */\n removeFilter: (label: string) => string;\n /** The words of a filter in force: `(header, value) => header + \": \" + value`. */\n activeFilter: (header: string, value: string) => string;\n /** A `text` filter's field: `(header) => \"Search \" + header`. */\n search: (header: string) => string;\n /** The lower bound of a `range` filter: `(header) => header + \" from\"`. */\n rangeFrom: (header: string) => string;\n /** The upper bound of a `range` filter: `(header) => header + \" to\"`. */\n rangeTo: (header: string) => string;\n /** The button of the columns menu (\"Columns\"). */\n columns: string;\n /** The button that opens what left the row: `(name) => \"Show more about \" + name`. */\n showMore: (name: string) => string;\n /** The export button (\"Export CSV\"). */\n export: string;\n /** The words of the pagination under the table. */\n pagination?: Partial<PaginationLabels>;\n /** The words of the bar of a selection (`bulkActions`). */\n selection?: Partial<SelectionBarLabels>;\n};\n\nexport const dataTableLabels: DataTableLabels = {\n selectAll: \"Select all rows\",\n selectRow: (name) => `Select ${name}`,\n loading: \"Loading\",\n empty: \"Nothing to show\",\n details: \"Details\",\n expandRow: (name) => `Show details of ${name}`,\n group: (value, count) => `${value}, ${count} ${count === 1 ? \"row\" : \"rows\"}`,\n resize: (header) => `Resize ${header}`,\n results: (count) => `${count.toLocaleString(\"en\")} ${count === 1 ? \"row\" : \"rows\"}`,\n filters: \"Filter the table\",\n clearFilters: \"Clear filters\",\n removeFilter: (label) => `Remove ${label}`,\n activeFilter: (header, value) => `${header}: ${value}`,\n search: (header) => `Search ${header.toLocaleLowerCase()}`,\n rangeFrom: (header) => `${header} from`,\n rangeTo: (header) => `${header} to`,\n columns: \"Columns\",\n showMore: (name) => `Show more about ${name}`,\n export: \"Export CSV\",\n};\n\nexport type DataTableProps<T> = {\n /** The rows (stable: module scope, state or a query's data). Sorted, filtered and paginated here unless `manual`. */\n rows: readonly T[];\n /** The columns, in order (stable: module scope or `useMemo`). */\n columns: readonly DataTableColumn<T>[];\n /** A stable id per row: the React key, the selection's value, the expansion's key. */\n getRowId: (row: T) => string;\n /** What the table lists (\"Jobs\", \"Your videos\"): its `<caption>`, hidden unless `showCaption`. */\n caption: string;\n /** Shows the caption above the table. */\n showCaption?: boolean;\n\n /** The sorted column (controlled), `null` for none. */\n sort?: DataTableSort;\n /** The sort at first, uncontrolled. */\n defaultSort?: DataTableSort;\n /** Called when a header asks for a new sort. */\n onSortChange?: (sort: DataTableSort) => void;\n\n /** The filters in force (controlled), by column id — what `DataTableFilters` edits. */\n filters?: DataTableFilterState;\n /** The filters at first, uncontrolled. */\n defaultFilters?: DataTableFilterState;\n /** Called with the new filters. */\n onFiltersChange?: (filters: DataTableFilterState) => void;\n\n /**\n * Keeps the sort, the filters and the page in the address (`?clients.sort=…&clients.page=2`): back and forward, a reload\n * and a shared link all land on the same table. Replaces `sort`, `filters` and `page`; needs the router's adapter\n * (`RouteStateProvider`) in a framework.\n */\n routeKey?: string;\n\n /** Adds a checkbox per row and one in the header. */\n selectable?: boolean;\n /** The ids selected (controlled). */\n selected?: readonly string[];\n /** The ids selected at first, uncontrolled. */\n defaultSelected?: readonly string[];\n /** Called with the new selection. */\n onSelectedChange?: (selected: string[]) => void;\n /** The name of a row in its labels (checkbox, expand button). Default: its id. */\n rowLabel?: (row: T) => string;\n /**\n * The actions on the selection, given by the product: the bar (`SelectionBar`) appears under the table while rows are\n * chosen — the count, these actions, « Clear selection » — sticky, docked above the tab bar on a phone. Needs `selectable`.\n */\n bulkActions?: (selection: { selected: string[]; clear: () => void }) => React.ReactNode;\n /** The most rows a bulk call takes (200 for `@krizaka/organize`): the bar says so past it and its actions rest. */\n bulkMax?: number;\n /** What the last bulk change did (\"3 moved, 1 skipped\"), announced politely by the bar. */\n bulkResult?: string;\n\n /** The columns the rows are grouped by, in order (controlled) — each `groupable`. */\n groupBy?: readonly string[];\n /** The grouping at first, uncontrolled. */\n defaultGroupBy?: readonly string[];\n /** Called with the new grouping. */\n onGroupByChange?: (groupBy: string[]) => void;\n\n /** Visible (`true`) or hidden (`false`) columns, by id (controlled); a column not listed is visible. */\n columnVisibility?: Readonly<Record<string, boolean>>;\n /** The visibility at first, uncontrolled. */\n defaultColumnVisibility?: Readonly<Record<string, boolean>>;\n /** Called with the new visibility (`DataTableColumnsMenu`). */\n onColumnVisibilityChange?: (visibility: Record<string, boolean>) => void;\n\n /** Columns that stay in view while the table scrolls sideways: at the start (a name) or the end (actions). */\n pinning?: { start?: readonly string[]; end?: readonly string[] };\n /** Columns can be resized (pointer drag, or the arrow keys on the focused handle). */\n resizing?: boolean;\n\n /** The children of a row (a tree): each row with children gets a button that shows them. */\n getSubRows?: (row: T) => readonly T[] | undefined;\n /** A panel under an opened row (the details of a job): each row gets a button that opens it. */\n renderDetail?: (row: T) => React.ReactNode;\n /** The opened rows and groups (controlled), by id. */\n expanded?: Readonly<Record<string, boolean>>;\n /** The opened rows at first, uncontrolled. */\n defaultExpanded?: Readonly<Record<string, boolean>>;\n /** Called with the opened rows. */\n onExpandedChange?: (expanded: Record<string, boolean>) => void;\n\n /** Rows per page (controlled): turns on the pagination under the table. */\n pageSize?: number;\n /** Rows per page at first, uncontrolled: turns on the pagination under the table. */\n defaultPageSize?: number;\n /** Called with the size chosen in the pagination's select (`pageSizeOptions`). */\n onPageSizeChange?: (pageSize: number) => void;\n /** The sizes the pagination offers (`[10, 25, 50]`). */\n pageSizeOptions?: readonly number[];\n /** The page, from 1 (controlled). */\n page?: number;\n /** The page at first, uncontrolled. Default 1. */\n defaultPage?: number;\n /** Called with the page asked for. */\n onPageChange?: (page: number) => void;\n\n /** The server does the work: the rows are shown as given (sorted, filtered, a single page) — fetch in `onStateChange`. */\n manual?: { sorting?: boolean; filtering?: boolean; pagination?: boolean };\n /** The number of rows on the server (`manual.pagination`): the page count and the results' count. */\n rowCount?: number;\n /** Called with the sort, the filters and the page after each change: the query key of a server table. */\n onStateChange?: (query: DataTableQuery) => void;\n\n /** Rows are loading: skeleton rows (`loadingRows` of them) and `aria-busy`. */\n loading?: boolean;\n /** How many skeleton rows while loading. Default 5. */\n loadingRows?: number;\n /** A failure, shown in place of the rows (an `Alert`, a retry button); announced. */\n error?: React.ReactNode;\n /** Shown when there is no row (an `EmptyState`). Default: `labels.empty`. */\n empty?: React.ReactNode;\n\n /** `auto` (default): a table, cards below 36rem of container width. `table` or `cards` to force one. */\n layout?: \"auto\" | \"table\" | \"cards\";\n /**\n * What a row becomes on a phone (under 36 rem, or always with `layout=\"cards\"`): `cards` (a card per row, its values\n * labelled) or `list` — a list row: the selection's checkbox, the `title` column with its `priority: 2` columns joined as\n * one line of facts, the `status` / `badge` column at the end; the other columns in the row's detail.\n * @default \"cards\"\n */\n phone?: \"cards\" | \"list\";\n /** comfortable (default) · compact — one row height per density. */\n density?: \"comfortable\" | \"compact\";\n /** The header stays at the top of the window while the page scrolls (`--dt-top` on the table, or a number of px, clears a fixed bar). */\n stickyHeader?: boolean | number;\n /** Zebra rows. */\n striped?: boolean;\n /**\n * The table never scrolls sideways by default once its columns have a `type` or a `priority`: what does not fit goes to\n * the row's detail, then to cards. `true` opts in to a sideways scroll instead, with fades at the edges.\n */\n scroll?: boolean;\n /** Keeps the first column in view while the table scrolls sideways (with `scroll`). */\n stickyFirstColumn?: boolean;\n /** Renders only the rows in view, in a scrolling body of `height` px; rows are measured (`estimateRowHeight` is a guess). Forces the table layout. */\n virtualized?: { height: number; estimateRowHeight?: number; overscan?: number };\n\n /** Above the table, inside its frame: `DataTableFilters`, `DataTableColumnsMenu`, `DataTableExport`, actions. */\n toolbar?: React.ReactNode;\n /** Under the table (after the pagination): a total, a note. */\n footer?: React.ReactNode;\n /** The words, passed translated; English by default. */\n labels?: Partial<DataTableLabels>;\n /** Classes merged on the root. */\n className?: string;\n};\n\ntype Context = {\n table: DataTableInstance<object>;\n columns: readonly DataTableColumn<object>[];\n labels: DataTableLabels;\n filters: DataTableFilterState;\n setFilters: (filters: DataTableFilterState) => void;\n /** The rows after the filters (all pages), or the server's count. */\n resultCount: number;\n /** The rows to export: filtered and sorted, every page, without the group rows. */\n exportRows: () => readonly unknown[];\n manualFiltering: boolean;\n};\n\nconst DataTableContext = React.createContext<Context | null>(null);\n\n/**\n * The table a component sits in (`toolbar`, or anything under it): the TanStack Table instance (`table` — the escape\n * hatch for what the props do not cover), the columns, the words, the filters and their setter.\n */\nexport function useDataTable<T extends RowData = object>() {\n const context = React.useContext(DataTableContext);\n if (!context) throw new Error(\"useDataTable: call it inside a DataTable (its `toolbar`, `footer` or a cell)\");\n return context as unknown as Omit<Context, \"table\" | \"columns\" | \"exportRows\"> & {\n table: DataTableInstance<T>;\n columns: readonly DataTableColumn<T>[];\n exportRows: () => readonly T[];\n };\n}\n\n// A card never scrolls sideways, even when untyped columns keep the table's scroller.\nconst CARD_CLIP = { auto: \"@max-xl:overflow-x-clip!\", table: undefined, cards: \"overflow-x-clip!\" } as const;\nconst TRUNCATE = { auto: \"@xl:truncate\", table: \"truncate\", cards: \"\" } as const;\nconst MIN = { auto: \"@xl:min-w-(--dt-min)!\", table: \"min-w-(--dt-min)!\", cards: \"\" } as const;\nconst MAX = { auto: \"@xl:max-w-(--dt-max)!\", table: \"max-w-(--dt-max)!\", cards: \"\" } as const;\n// A sideways scroll asked for (`scroll`): the edges fade where there is more to see.\nconst SHADOWS =\n \"[background:linear-gradient(to_right,var(--kz-surface-1),transparent)_left/24px_100%_no-repeat_local,linear-gradient(to_left,var(--kz-surface-1),transparent)_right/24px_100%_no-repeat_local,linear-gradient(to_right,rgb(0_0_0/0.18),transparent)_left/10px_100%_no-repeat_scroll,linear-gradient(to_left,rgb(0_0_0/0.18),transparent)_right/10px_100%_no-repeat_scroll]\";\nconst ALIGN = { start: \"text-left\", center: \"text-center\", end: \"text-right\" } as const;\nconst NONE: readonly never[] = [];\nconst NO_RECORD: Readonly<Record<string, never>> = {};\ntype Up<S> = S | ((old: S) => S);\nconst apply = <S,>(updater: S | ((old: S) => S), old: S): S => (typeof updater === \"function\" ? (updater as (old: S) => S)(old) : updater);\n\nconst valueOf = <T,>(column: DataTableColumn<T>, row: T): CellValue =>\n column.value ? column.value(row) : ((row as Record<string, unknown>)[column.id] as CellValue);\n\nconst display = (value: CellValue) => (value instanceof Date ? value.toISOString() : String(value ?? \"\"));\n\ntype Layout = \"auto\" | \"table\" | \"cards\";\ntype Styles = ReturnType<typeof dataTable>;\ntype Place = \"title\" | \"status\" | \"facts\" | \"away\" | \"hidden\";\ntype TableHeader<T extends RowData> = ReturnType<DataTableInstance<T>[\"getHeaderGroups\"]>[number][\"headers\"][number];\ntype Pin = { \"data-pin\"?: \"start\" | \"end\"; style?: React.CSSProperties };\n\nconst sortingOf = (sort: DataTableSort) => (sort ? [{ id: sort.column, desc: sort.direction === \"descending\" }] : []);\nconst filterListOf = (filters: DataTableFilterState) => Object.entries(filters).map(([id, value]) => ({ id, value }));\nconst selectionOf = (selected: readonly string[]) => Object.fromEntries(selected.map((id) => [id, true as const]));\n\n// Columns that can leave the row: their lines go to the row's detail, opened by a chevron in the first cell.\nconst priorityOf = <T extends RowData>(column: DataTableColumn<T>): 1 | Priority => (column.priority && column.priority > 1 ? (column.priority as Priority) : 1);\n\n// The list rows' places: the title (the `title` column, else the first), the status at the end, the facts (the 2s) under\n// the title, and the rest away, in the row's detail.\nconst placeOf = <T extends RowData>(titleColumn: DataTableColumn<T> | undefined, column: DataTableColumn<T>): Place => {\n if (column.card === \"hidden\") return \"hidden\";\n if (column === titleColumn) return \"title\";\n if (column.type === \"status\" || column.type === \"badge\") return \"status\";\n return priorityOf(column) === 2 ? \"facts\" : \"away\";\n};\n\nconst cardOf = <T extends RowData>(column: DataTableColumn<T> | undefined) =>\n column?.card === \"title\" || (column && !column.card && column.type === \"title\") ? \"title\" : column?.card === \"hidden\" ? \"hidden\" : undefined;\n\n/** What the cells and the rows need to know about the table they are in. */\ntype View<T extends RowData> = {\n s: Styles;\n L: Layout;\n list: boolean;\n labels: DataTableLabels;\n byId: Map<string, DataTableColumn<T>>;\n titleColumn: DataTableColumn<T> | undefined;\n facts: DataTableColumn<T>[];\n listAway: DataTableColumn<T>[];\n maxPriority: 1 | Priority;\n inlineToggle: boolean;\n hasExpander: boolean;\n detailed: boolean;\n selectable: boolean;\n span: number;\n chosen: Set<string>;\n virtualized: boolean;\n fixedLayout: boolean;\n renderDetail: ((row: T) => React.ReactNode) | undefined;\n rowLabel: ((row: T) => string) | undefined;\n visibleColumns: TableColumn<T>[];\n measureElement: ((node: Element | null) => void) | undefined;\n loading: boolean | undefined;\n loadingCount: number;\n error: React.ReactNode;\n empty: React.ReactNode;\n pageRows: TableRow<T>[];\n windowItems: { index: number }[] | null;\n resizing: boolean | undefined;\n stickyHeader: boolean | number | undefined;\n setSizing: React.Dispatch<React.SetStateAction<Record<string, number>>>;\n allChosen: boolean;\n someChosen: boolean;\n selectableCount: number;\n toggleAll: () => void;\n};\n\nconst nameOf = <T extends RowData>(v: View<T>, row: TableRow<T>) => (v.rowLabel ? v.rowLabel(row.original) : row.id);\n\nconst pin = <T extends RowData>(column: TableColumn<T>): Pin => {\n const position = column.getIsPinned();\n if (!position) return {};\n const offset = position === \"start\" ? column.getStart(\"start\") : column.getAfter(\"end\");\n return { \"data-pin\": position, style: { [\"--dt-pin\" as string]: `${offset}px` } };\n};\n\nconst widthOf = <T extends RowData>(v: View<T>, column: TableColumn<T>): React.CSSProperties | undefined =>\n v.fixedLayout || v.byId.get(column.id)?.width ? { width: column.getSize() } : undefined;\n\n/** A title: a link when the column has addresses, with its subtitle under it. */\nfunction titleContent<T extends RowData>(v: View<T>, column: DataTableColumn<T>, original: T, text: string, cut: string) {\n const sub = column.subtitle?.(original);\n const href = column.href?.(original);\n const link = cn(\"block font-semibold text-fg no-underline hover:underline focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\", cut, v.list && LIST_LINK[v.L]);\n return (\n <span className=\"block min-w-0\">\n {href ? (\n <a href={href} className={link} title={text}>\n {text}\n </a>\n ) : (\n <span className={cn(\"block font-semibold text-fg\", cut)} title={text}>\n {text}\n </span>\n )}\n {sub ? <span className={cn(\"block font-mono text-xs text-fg-tertiary\", cut)}>{sub}</span> : null}\n </span>\n );\n}\n\nfunction numberContent<T extends RowData>(column: DataTableColumn<T>, value: CellValue, text: string) {\n return (\n <span>\n {typeof value === \"number\" ? value.toLocaleString(\"en\") : text}\n {column.unit ? <span className=\"ms-1 text-fg-secondary\">{column.unit}</span> : null}\n </span>\n );\n}\n\nfunction linkContent<T extends RowData>(column: DataTableColumn<T>, original: T, text: string, cut: string) {\n const href = column.href?.(original);\n if (!href) {\n return (\n <span className={cn(\"block\", cut)} title={text}>\n {text}\n </span>\n );\n }\n return (\n <a href={href} title={text} className={cn(\"block text-fg-accent underline-offset-2 hover:underline\", cut)}>\n {text}\n </a>\n );\n}\n\nfunction plainContent<T extends RowData>(column: DataTableColumn<T>, text: string, cut: string) {\n const lines = column.clamp ?? (column.type === \"text\" ? 2 : undefined);\n if (!column.nowrap && !lines) return text;\n return (\n <span className={column.nowrap ? cn(\"block\", cut || \"truncate\") : CLAMP[lines as 1 | 2 | 3]} title={text}>\n {text}\n </span>\n );\n}\n\n// What a cell shows: the column's `cell`, or its value by type.\nfunction contentOf<T extends RowData>(v: View<T>, column: DataTableColumn<T>, original: T): React.ReactNode {\n if (column.cell) return column.cell(original);\n const value = valueOf(column, original);\n const text = column.type === \"date\" && value instanceof Date ? value.toISOString().slice(0, 10) : display(value);\n const cut = TRUNCATE[v.L];\n switch (column.type) {\n case \"title\":\n return titleContent(v, column, original, text, cut);\n case \"number\":\n return numberContent(column, value, text);\n case \"link\":\n return linkContent(column, original, text, cut);\n default:\n return plainContent(column, text, cut);\n }\n}\n\n// A group's row keeps its value as the title and its aggregates; a facts column is away (its value is in the title's line).\nfunction listPlace<T extends RowData>(v: View<T>, row: TableRow<T> | null, column: DataTableColumn<T>) {\n if (row?.getIsGrouped()) return row.groupingColumnId === column.id ? \"title\" : column.aggregate ? \"status\" : \"away\";\n const place = placeOf(v.titleColumn, column);\n return place === \"facts\" || place === \"hidden\" ? \"away\" : place;\n}\n\n/** The cell of a group row: the group's value as a button that opens it, or the column's aggregate. */\nfunction groupContent<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, columnId: string) {\n const leaves = row\n .getLeafRows()\n .filter((r) => !r.getIsGrouped())\n .map((r) => r.original);\n if (columnId !== row.groupingColumnId) return column.aggregate ? column.aggregate(leaves) : null;\n const value = display(row.groupingValue as CellValue);\n return (\n <button type=\"button\" className={v.s.toggle({ className: \"px-1.5 font-semibold text-fg\" })} aria-expanded={row.getIsExpanded()} onClick={row.getToggleExpandedHandler()}>\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n {v.labels.group(value, leaves.length)}\n </button>\n );\n}\n\n/** The list row's title cell: the title, and under it the facts joined by a dot. */\nfunction withFacts<T extends RowData>(v: View<T>, content: React.ReactNode, original: T) {\n return (\n <span className=\"block min-w-0\">\n {content}\n <span data-facts=\"\" className={LIST_FACTS[v.L]}>\n {v.facts.map((c, i) => (\n <React.Fragment key={c.id}>\n {i > 0 ? <span aria-hidden>{\" · \"}</span> : null}\n {contentOf(v, c, original)}\n </React.Fragment>\n ))}\n </span>\n </span>\n );\n}\n\n/** The first cell with its chevron, when the columns that left the row are shown in its detail. */\nfunction withToggle<T extends RowData>(v: View<T>, content: React.ReactNode, row: TableRow<T>) {\n const shown = v.maxPriority > 1 ? TOGGLE[v.L][v.maxPriority as Priority] : \"hidden\";\n return (\n <span className=\"flex min-w-0 items-center gap-1\">\n <button\n type=\"button\"\n className={v.s.toggle({ className: cn(shown, v.listAway.length > 0 && LIST_TOGGLE[v.L], v.list && \"relative z-[1]\") })}\n aria-expanded={row.getIsExpanded()}\n aria-label={v.labels.showMore(nameOf(v, row))}\n onClick={row.getToggleExpandedHandler()}\n >\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n </button>\n <span className=\"min-w-0 flex-1\">{content}</span>\n </span>\n );\n}\n\nfunction bodyContent<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, first: boolean) {\n let content = contentOf(v, column, row.original);\n if (v.list && column === v.titleColumn && v.facts.length > 0) content = withFacts(v, content, row.original);\n if (first && v.inlineToggle) content = withToggle(v, content, row);\n return content;\n}\n\nfunction cellClass<T extends RowData>(v: View<T>, column: DataTableColumn<T>) {\n const level = priorityOf(column);\n const type = column.type;\n return [\n ALIGN[column.align ?? (type === \"number\" ? \"end\" : \"start\")],\n type ? TYPE_CELL[type][v.L] : \"\",\n level > 1 ? LEAVES[v.L][level as Priority] : \"\",\n (type || column.priority) && column.minWidth !== undefined ? MIN[v.L] : \"\",\n column.maxWidth !== undefined ? MAX[v.L] : \"\",\n ].join(\" \");\n}\n\nfunction cardRole<T extends RowData>(v: View<T>, row: TableRow<T>, column: DataTableColumn<T>, columnId: string) {\n if (v.list) return column.card === \"hidden\" ? \"hidden\" : undefined;\n if (!row.getIsGrouped()) return cardOf(column);\n if (columnId === row.groupingColumnId) return \"title\";\n return column.aggregate ? undefined : \"hidden\";\n}\n\nfunction cellStyle<T extends RowData>(row: TableRow<T>, column: DataTableColumn<T>, first: boolean, base: React.CSSProperties | undefined): React.CSSProperties {\n const indent = first && row.depth > 0 && !row.getIsGrouped();\n return {\n ...base,\n ...(column.minWidth !== undefined ? { [\"--dt-min\" as string]: `${column.minWidth}px` } : {}),\n ...(column.maxWidth !== undefined ? { [\"--dt-max\" as string]: `${column.maxWidth}px` } : {}),\n ...(indent ? { paddingInlineStart: `${1 + row.depth * 1.25}rem` } : {}),\n };\n}\n\nfunction dataCell<T extends RowData>(v: View<T>, row: TableRow<T>, cell: TableCell<T>, first: boolean) {\n const column = v.byId.get(cell.column.id);\n if (!column) return null;\n const { style, ...pinnedProps } = pin(cell.column);\n const content = row.getIsGrouped() ? groupContent(v, row, column, cell.column.id) : bodyContent(v, row, column, first);\n return (\n <td\n role=\"cell\"\n key={cell.id}\n data-label={column.header}\n data-card={cardRole(v, row, column, cell.column.id)}\n data-list={v.list ? listPlace(v, row, column) : undefined}\n {...pinnedProps}\n className={v.s.td({ className: cellClass(v, column) })}\n style={cellStyle(row, column, first, style)}\n >\n {content}\n </td>\n );\n}\n\n/** The panel under an opened row: the columns that left the row, then the host's own detail. */\nfunction detailRow<T extends RowData>(v: View<T>, row: TableRow<T>) {\n const left = v.visibleColumns.filter((c) => {\n const column = v.byId.get(c.id) as DataTableColumn<T>;\n return priorityOf(column) > 1 || v.listAway.includes(column);\n });\n const { L, s, renderDetail } = v;\n const panel = cn(\"px-4 py-4\", v.maxPriority > 1 ? PANEL[L][v.maxPriority as Priority] : \"hidden\", v.listAway.length > 0 && LIST_PANEL[L]);\n return wideRow(\n v,\n renderDetail ? s.detail() : \"bg-surface-0 p-0 text-left\",\n <>\n {left.length > 0 ? (\n <dl className={cn(\"m-0 grid gap-3 text-left\", renderDetail ? \"mb-4\" : panel)}>\n {left.map((c) => {\n const column = v.byId.get(c.id) as DataTableColumn<T>;\n const place = v.listAway.includes(column) ? LIST_IN_DETAIL[L] : IN_DETAIL[L][priorityOf(column) as Priority];\n return (\n <div key={c.id} className={cn(place, \"grid-cols-[minmax(5rem,8rem)_minmax(0,1fr)] items-baseline gap-3\")}>\n <dt className=\"text-xs font-semibold text-fg-secondary\">{column.header}</dt>\n <dd className=\"m-0 min-w-0 text-sm text-fg\">{contentOf(v, column, row.original)}</dd>\n </div>\n );\n })}\n </dl>\n ) : null}\n {renderDetail ? renderDetail(row.original) : null}\n </>,\n );\n}\n\n/** The leading cells of a row: its checkbox, then the button that opens it. */\nfunction rowLeadCells<T extends RowData>(v: View<T>, row: TableRow<T>, isChosen: boolean) {\n const { s, labels } = v;\n const grouped = row.getIsGrouped();\n const canExpand = !grouped && (v.renderDetail ? true : row.getCanExpand());\n return (\n <>\n {v.selectable && (\n <td role=\"cell\" className={s.td({ className: s.select() })}>\n {grouped ? null : <Checkbox checked={isChosen} onCheckedChange={() => row.toggleSelected()} aria-label={labels.selectRow(nameOf(v, row))} />}\n </td>\n )}\n {v.hasExpander && (\n <td role=\"cell\" className={s.td({ className: s.expander() })}>\n {canExpand ? (\n <button type=\"button\" className={s.toggle()} aria-expanded={row.getIsExpanded()} aria-label={labels.expandRow(nameOf(v, row))} onClick={row.getToggleExpandedHandler()}>\n <ChevronGlyph direction=\"right\" className=\"h-4 w-4\" />\n </button>\n ) : null}\n </td>\n )}\n </>\n );\n}\n\nfunction renderRow<T extends RowData>(v: View<T>, row: TableRow<T>, index: number) {\n const isChosen = v.chosen.has(row.id);\n const grouped = row.getIsGrouped();\n const showDetail = v.detailed && !grouped && row.getIsExpanded() && !v.virtualized;\n const main = (\n <tr\n role=\"row\"\n data-index={v.measureElement ? index : undefined}\n ref={v.measureElement}\n aria-rowindex={v.virtualized ? index + 2 : undefined}\n data-state={isChosen ? \"selected\" : undefined}\n data-group={grouped ? \"\" : undefined}\n className={v.s.tr({ className: grouped ? v.s.groupRow() : undefined })}\n >\n {rowLeadCells(v, row, isChosen)}\n {row.getVisibleCells().map((cell, i) => dataCell(v, row, cell, i === 0))}\n </tr>\n );\n // One Fragment keyed by the row either way: opening a row keeps its button (and the focus on it).\n return (\n <React.Fragment key={row.id}>\n {main}\n {showDetail ? detailRow(v, row) : null}\n </React.Fragment>\n );\n}\n\n/** A full-width row: a message, or the opened row's detail. */\nfunction wideRow<T extends RowData>(v: View<T>, tdClass: string, children: React.ReactNode) {\n return (\n <tr role=\"row\" className={v.s.tr({ className: \"hover:bg-transparent\" })}>\n <td role=\"cell\" colSpan={v.span} data-card=\"message\" className={v.s.td({ className: tdClass })}>\n {children}\n </td>\n </tr>\n );\n}\n\nfunction messageRow<T extends RowData>(v: View<T>, content: React.ReactNode, alert?: boolean) {\n return wideRow(v, v.s.message(), alert ? <div role=\"alert\">{content}</div> : content);\n}\n\nfunction skeletonRows<T extends RowData>(v: View<T>, count: number) {\n const { s, list } = v;\n return Array.from({ length: count }, (_, i) => (\n <tr role=\"row\" key={`loading-${i}`} aria-hidden className={s.tr()}>\n {v.selectable && <td role=\"cell\" className={s.td({ className: s.select() })} />}\n {v.hasExpander && <td role=\"cell\" className={s.td({ className: s.expander() })} />}\n {v.visibleColumns.map((column) => (\n <td role=\"cell\" key={column.id} data-card={list ? undefined : cardOf(v.byId.get(column.id))} data-list={list ? listPlace(v, null, v.byId.get(column.id) as DataTableColumn<T>) : undefined} className={s.td()}>\n <div className={s.skeleton()} />\n </td>\n ))}\n </tr>\n ));\n}\n\nfunction bodyRows<T extends RowData>(v: View<T>) {\n const { pageRows: rows, windowItems } = v;\n if (v.loading) return skeletonRows(v, v.loadingCount);\n if (v.error) return messageRow(v, v.error, true);\n if (rows.length === 0) return messageRow(v, v.empty ?? v.labels.empty);\n if (windowItems) return windowItems.map((item) => renderRow(v, rows[item.index] as TableRow<T>, item.index));\n return rows.map((row, i) => renderRow(v, row, i));\n}\n\nfunction headerLabel<T extends RowData>(v: View<T>, header: TableHeader<T>, column: DataTableColumn<T>, direction: SortDirection | undefined) {\n if (column.sortable) {\n return (\n <button type=\"button\" aria-pressed={Boolean(direction)} className={v.s.sortButton()} onClick={() => header.column.toggleSorting(undefined, false)}>\n {column.header}\n <SortGlyph direction={direction} className=\"h-3.5 w-3.5\" />\n </button>\n );\n }\n return column.headerHidden ? <span className=\"sr-only\">{column.header}</span> : column.header;\n}\n\nfunction headerCell<T extends RowData>(v: View<T>, header: TableHeader<T>) {\n const column = v.byId.get(header.column.id);\n if (!column) return null;\n const sorted = header.column.getIsSorted();\n const direction: SortDirection | undefined = sorted === \"asc\" ? \"ascending\" : sorted === \"desc\" ? \"descending\" : undefined;\n const { style, ...pinnedProps } = pin(header.column);\n const level = priorityOf(column);\n const top = typeof v.stickyHeader === \"number\" ? { [\"--dt-top\" as string]: `${v.stickyHeader}px` } : {};\n return (\n <th\n role=\"columnheader\"\n scope=\"col\"\n key={header.id}\n aria-sort={column.sortable ? (direction ?? \"none\") : undefined}\n data-keep={column.sortable ? \"\" : undefined}\n {...pinnedProps}\n className={v.s.th({ className: cn(ALIGN[column.align ?? (column.type === \"number\" ? \"end\" : \"start\")], level > 1 && LEAVES_HEAD[v.L][level as Priority]) })}\n style={{ ...style, ...top, ...widthOf(v, header.column) }}\n >\n {headerLabel(v, header, column, direction)}\n {v.resizing && header.column.getCanResize() ? (\n <ResizeHandle\n label={v.labels.resize(column.header)}\n size={header.column.getSize()}\n min={column.minWidth ?? 64}\n resizing={header.column.getIsResizing()}\n className={v.s.resizer()}\n onPointerStart={header.getResizeHandler()}\n onSize={(size) => v.setSizing((old) => ({ ...old, [header.column.id]: size }))}\n />\n ) : null}\n </th>\n );\n}\n\nfunction headerRow<T extends RowData>(v: View<T>, headers: TableHeader<T>[]) {\n const { s, labels } = v;\n return (\n <tr role=\"row\" aria-rowindex={v.virtualized ? 1 : undefined} className={s.headRow()}>\n {v.selectable && (\n <th role=\"columnheader\" scope=\"col\" data-keep=\"\" className={s.th({ className: s.select() })}>\n <Checkbox\n checked={v.allChosen ? true : v.someChosen ? \"indeterminate\" : false}\n onCheckedChange={v.toggleAll}\n disabled={v.loading || v.selectableCount === 0}\n aria-label={labels.selectAll}\n />\n </th>\n )}\n {v.hasExpander && (\n <th role=\"columnheader\" scope=\"col\" className={s.th({ className: s.expander() })}>\n <span className=\"sr-only\">{labels.details}</span>\n </th>\n )}\n {headers.map((header) => headerCell(v, header))}\n </tr>\n );\n}\n\n/** The sort, filters, selection, grouping, visibility, opened rows, page and page size — controlled or not — and the address's query. */\nfunction useControlled<T extends RowData>(p: DataTableProps<T>, route: ReturnType<typeof useRouteTable>) {\n const { defaultSort = null, defaultFilters = NO_RECORD, defaultSelected = NONE, defaultGroupBy = NONE, defaultColumnVisibility = NO_RECORD, defaultExpanded = NO_RECORD, defaultPage = 1 } = p;\n const paginated = p.pageSize !== undefined || p.defaultPageSize !== undefined;\n const [sort, setSort] = useControllable<DataTableSort>(route ? route.sort : p.sort, defaultSort, route?.onSortChange ?? p.onSortChange);\n const [filters, setFiltersState] = useControllable<DataTableFilterState>(route ? route.filters : p.filters, defaultFilters, route?.onFiltersChange ?? p.onFiltersChange);\n const [selected, setSelected] = useControllable<readonly string[]>(p.selected, defaultSelected, p.onSelectedChange as (next: readonly string[]) => void);\n const [groupBy, setGroupBy] = useControllable<readonly string[]>(p.groupBy, defaultGroupBy, p.onGroupByChange as (next: readonly string[]) => void);\n const [visibility, setVisibility] = useControllable<Readonly<Record<string, boolean>>>(p.columnVisibility, defaultColumnVisibility, p.onColumnVisibilityChange as (next: Readonly<Record<string, boolean>>) => void);\n const [expanded, setExpanded] = useControllable<Readonly<Record<string, boolean>>>(p.expanded, defaultExpanded, p.onExpandedChange as (next: Readonly<Record<string, boolean>>) => void);\n const [pageSize, setPageSize] = useControllable<number>(p.pageSize, p.defaultPageSize ?? Number.POSITIVE_INFINITY, p.onPageSizeChange);\n const [page, setPage] = useControllable<number>(route ? route.page : p.page, defaultPage, route?.onPageChange ?? p.onPageChange);\n return { paginated, sort, setSort, filters, setFiltersState, selected, setSelected, groupBy, setGroupBy, visibility, setVisibility, expanded, setExpanded, pageSize, setPageSize, page, setPage };\n}\n\ntype Controlled = ReturnType<typeof useControlled>;\n\n/** One place announces the server's query: after any change of sort, filters, page or page size. */\nfunction useAnnounce<T extends RowData>(p: DataTableProps<T>, c: Controlled, route: ReturnType<typeof useRouteTable>) {\n const { paginated, sort, filters, page, pageSize } = c;\n const { defaultSort = null, defaultFilters = NO_RECORD, defaultPage = 1 } = p;\n const announced = React.useRef(JSON.stringify([defaultSort, defaultFilters, paginated ? defaultPage : 1, paginated ? pageSize : null]));\n const announce = (next: Partial<DataTableQuery>) => {\n const query = { sort, filters, page: paginated ? page : 1, pageSize: paginated ? pageSize : Number.POSITIVE_INFINITY, ...next };\n if (route) announced.current = JSON.stringify([query.sort, query.filters, query.page, paginated ? query.pageSize : null]);\n p.onStateChange?.(query);\n };\n // The address can change under the table (back, forward, a shared link): the server is told the query it now shows,\n // once — a change the table made itself was announced already. A first visit on the defaults says nothing.\n const routeQuery = route ? JSON.stringify([route.sort, route.filters, paginated ? route.page : 1, paginated ? pageSize : null]) : null;\n React.useEffect(() => {\n if (routeQuery === null || routeQuery === announced.current) return;\n announced.current = routeQuery;\n announce({});\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only a change of the address's query announces\n }, [routeQuery]);\n return announce;\n}\n\n/** The changes of the query, each announced; in the address, the sort or the filters reset the page in the same navigation. */\nfunction useQueryChanges<T extends RowData>(p: DataTableProps<T>, c: Controlled, route: ReturnType<typeof useRouteTable>) {\n const announce = useAnnounce(p, c, route);\n const resetPage = () => {\n if (c.paginated && c.page !== 1 && !route) c.setPage(1);\n };\n return {\n changeSort: (next: DataTableSort) => {\n c.setSort(next);\n resetPage();\n announce({ sort: next, page: 1 });\n },\n changeFilters: (next: DataTableFilterState) => {\n c.setFiltersState(next);\n resetPage();\n announce({ filters: next, page: 1 });\n },\n changePage: (next: number) => {\n c.setPage(next);\n announce({ page: next });\n },\n changePageSize: (next: number) => {\n c.setPageSize(next);\n c.setPage(1);\n announce({ pageSize: next, page: 1 });\n },\n };\n}\n\ntype Changes = ReturnType<typeof useQueryChanges>;\n\nconst columnDefs = <T extends RowData>(columns: readonly DataTableColumn<T>[], resizing: boolean | undefined): ColumnDef<typeof features, T>[] =>\n columns.map((column) => ({\n id: column.id,\n accessorFn: (row: T) => valueOf(column, row),\n header: column.header,\n enableSorting: Boolean(column.sortable),\n sortFn: sortByValue as never,\n sortUndefined: \"last\",\n enableColumnFilter: Boolean(column.filter),\n filterFn: (column.filter ? FILTERS[column.filter] : FILTERS.text) as never,\n enableGrouping: Boolean(column.groupable),\n enableHiding: column.hideable !== false,\n enableResizing: Boolean(resizing),\n ...(column.width ? { size: column.width } : {}),\n minSize: column.minWidth ?? 64,\n }));\n\ntype Pinning = { start?: readonly string[]; end?: readonly string[] } | undefined;\n\n/** The table's state handed to the engine, from what the props and the hooks hold. */\nfunction engineState(c: Controlled, rowCount: number, pinned: Pinning, sizing: Record<string, number>, resizeState: ColumnResizingState | undefined) {\n return {\n sorting: sortingOf(c.sort),\n columnFilters: filterListOf(c.filters),\n rowSelection: selectionOf(c.selected),\n grouping: [...c.groupBy],\n columnVisibility: { ...c.visibility },\n expanded: { ...c.expanded },\n pagination: { pageIndex: Math.max(0, c.page - 1), pageSize: c.paginated ? c.pageSize : Math.max(1, rowCount) },\n columnPinning: { start: [...(pinned?.start ?? [])], end: [...(pinned?.end ?? [])] },\n columnSizing: sizing,\n ...(resizeState ? { columnResizing: resizeState } : {}),\n };\n}\n\n/** What the engine tells us changed: each becomes our own state, announced when it is the query. */\nfunction engineHandlers<T extends RowData>(\n c: Controlled,\n changes: Changes,\n setSizing: React.Dispatch<React.SetStateAction<Record<string, number>>>,\n setResizeState: React.Dispatch<React.SetStateAction<ColumnResizingState | undefined>>,\n currentRows: () => TableRow<T>[],\n) {\n return {\n onSortingChange: (updater: Up<ReturnType<typeof sortingOf>>) => {\n const [first] = apply(updater, sortingOf(c.sort));\n changes.changeSort(first ? { column: first.id, direction: first.desc ? \"descending\" : \"ascending\" } : null);\n },\n onColumnFiltersChange: (updater: Up<{ id: string; value: unknown }[]>) => {\n const next = apply(updater, filterListOf(c.filters));\n changes.changeFilters(Object.fromEntries(next.map((f) => [f.id, f.value as FilterValue])));\n },\n onRowSelectionChange: (updater: Up<Record<string, true>>) => {\n const next = apply(updater, selectionOf(c.selected));\n c.setSelected(Object.keys(next).filter((id) => next[id]));\n },\n onGroupingChange: (updater: Up<string[]>) => c.setGroupBy(apply(updater, [...c.groupBy])),\n onColumnVisibilityChange: (updater: Up<Record<string, boolean>>) => c.setVisibility(apply(updater, { ...c.visibility })),\n onExpandedChange: (updater: Up<Record<string, boolean> | true>) => {\n const next = apply<Record<string, boolean> | true>(updater, { ...c.expanded });\n c.setExpanded(next === true ? Object.fromEntries(currentRows().map((r) => [r.id, true])) : next);\n },\n onColumnSizingChange: (updater: Up<Record<string, number>>) => setSizing((old: Record<string, number>) => apply(updater, old)),\n onColumnResizingChange: (updater: Up<ColumnResizingState>) => setResizeState((old) => apply(updater, old as ColumnResizingState)),\n };\n}\n\n/** What the props and the columns say about the table's layout. */\nfunction shapeOf<T extends RowData>(props: DataTableProps<T>) {\n const { columns, phone = \"cards\", virtualized, renderDetail, getSubRows } = props;\n const L: Layout = virtualized ? \"table\" : (props.layout ?? \"auto\");\n const typed = columns.some((c) => c.type || c.priority);\n const list = phone === \"list\" && L !== \"table\";\n const hasExpander = Boolean(renderDetail || getSubRows);\n const maxPriority = columns.reduce<1 | Priority>((max, column) => (priorityOf(column) > max ? priorityOf(column) : max), 1);\n const titleColumn = columns.find((col) => col.card === \"title\" || (!col.card && col.type === \"title\")) ?? columns[0];\n const listAway = list ? columns.filter((col) => placeOf(titleColumn, col) === \"away\" && priorityOf(col) === 1) : [];\n const facts = list ? columns.filter((col) => placeOf(titleColumn, col) === \"facts\") : [];\n const inlineToggle = (maxPriority > 1 || listAway.length > 0) && !hasExpander;\n return { L, typed, list, hasExpander, maxPriority, inlineToggle, detailed: Boolean(renderDetail) || inlineToggle, titleColumn, listAway, facts };\n}\n\n/** The engine, fed by our own state: sizing and resizing live here, everything else in `c`. */\nfunction useEngine<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, detailed: boolean) {\n const { rows, columns, getRowId, getSubRows, pinning, resizing, manual, rowCount, stickyFirstColumn } = props;\n const [sizing, setSizing] = React.useState<Record<string, number>>({});\n const [resizeState, setResizeState] = React.useState<ColumnResizingState | undefined>(undefined);\n const defs = React.useMemo(() => columnDefs(columns, resizing), [columns, resizing]);\n const firstId = columns[0]?.id;\n const pinned = stickyFirstColumn && firstId && !pinning?.start?.length ? { ...pinning, start: [firstId] } : pinning;\n const table: DataTableInstance<T> = useTable<typeof features, T>({\n features,\n columns: defs,\n data: rows as T[],\n getRowId: (row) => getRowId(row),\n getSubRows: getSubRows ? (row) => getSubRows(row) as T[] | undefined : undefined,\n getRowCanExpand: detailed ? () => true : undefined,\n state: engineState(c, rows.length, pinned, sizing, resizeState),\n ...engineHandlers<T>(c, changes, setSizing, setResizeState, () => table.getRowModel().rows),\n enableSortingRemoval: true,\n sortDescFirst: false,\n manualSorting: manual?.sorting,\n manualFiltering: manual?.filtering,\n manualPagination: manual?.pagination || !c.paginated,\n rowCount: manual?.pagination ? rowCount : undefined,\n autoResetPageIndex: false,\n autoResetExpanded: false,\n groupedColumnMode: false,\n columnResizeMode: \"onChange\",\n enableRowSelection: (row) => !row.getIsGrouped(),\n }) as unknown as DataTableInstance<T>;\n return { table, pinned, setSizing };\n}\n\n/** The count of results and of pages; a page beyond the last (the filters shrank the list) shows the last one. */\nfunction usePaging<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, table: DataTableInstance<T>) {\n const { manual, rowCount, rows, loading } = props;\n const { paginated, page, pageSize } = c;\n const leafCount = (manual?.pagination || manual?.filtering) && rowCount !== undefined ? rowCount : table.getFilteredRowModel().rows.length;\n const pageCount = paginated ? Math.max(1, manual?.pagination ? Math.ceil((rowCount ?? rows.length) / pageSize) : table.getPageCount()) : 1;\n React.useEffect(() => {\n if (paginated && !loading && page > pageCount) changes.changePage(pageCount);\n // eslint-disable-next-line react-hooks/exhaustive-deps -- only when the count of pages drops under the page\n }, [pageCount]);\n return { leafCount, pageCount };\n}\n\n/** What is chosen on this page: the ids that can be, whether all or some are, and the toggle. */\nfunction useChoice<T extends RowData>(pageRows: TableRow<T>[], selected: readonly string[], setSelected: (ids: string[]) => void) {\n const selectableIds = pageRows.filter((r) => !r.getIsGrouped()).map((r) => r.id);\n const chosen = new Set(selected);\n const allChosen = selectableIds.length > 0 && selectableIds.every((id) => chosen.has(id));\n const someChosen = selectableIds.some((id) => chosen.has(id));\n const toggleAll = () => setSelected(allChosen ? selected.filter((id) => !selectableIds.includes(id)) : [...new Set([...selected, ...selectableIds])]);\n return { chosen, allChosen, someChosen, toggleAll, selectableCount: selectableIds.length };\n}\n\n/** The query in the address (or in memory): the sort, the page, the filters. */\nfunction useRoute<T extends RowData>(props: DataTableProps<T>) {\n const { defaultSort, defaultPage, defaultFilters, columns } = props;\n return useRouteTable(props.routeKey, { sort: defaultSort ?? null, page: defaultPage ?? 1, filters: defaultFilters ?? NO_RECORD }, columns.map((c) => c.id));\n}\n\n/** The table element: caption, header and the body between two spacer rows when windowed. */\nfunction tableOf<T extends RowData>(v: View<T>, table: DataTableInstance<T>, caption: string, showCaption: boolean | undefined, before: number, after: number) {\n const { s, labels, virtualized, span, fixedLayout, loading } = v;\n const headers = table.getHeaderGroups().at(-1)?.headers ?? [];\n const spacer = (height: number) => (\n <tr aria-hidden style={{ height }}>\n <td colSpan={span} />\n </tr>\n );\n return (\n <table\n role=\"table\"\n aria-busy={loading || undefined}\n aria-rowcount={virtualized ? v.pageRows.length + 1 : undefined}\n className={s.table({ className: fixedLayout ? \"table-fixed\" : undefined })}\n style={fixedLayout ? { minWidth: table.getTotalSize() + (v.selectable ? 40 : 0) + (v.hasExpander ? 40 : 0) } : undefined}\n >\n <caption className={showCaption ? s.caption() : \"sr-only\"}>\n {caption}\n {loading ? <span className=\"sr-only\">{` — ${labels.loading}`}</span> : null}\n </caption>\n <thead role=\"rowgroup\" className={s.thead({ className: virtualized ? \"sticky top-0 z-10 bg-surface-2\" : undefined })}>\n {headerRow(v, headers as unknown as TableHeader<T>[])}\n </thead>\n <tbody role=\"rowgroup\" className={s.tbody()}>\n {before > 0 && spacer(before)}\n {bodyRows(v)}\n {after > 0 && spacer(after)}\n </tbody>\n </table>\n );\n}\n\n/** The page controls under the table. */\nfunction pager<T extends RowData>(props: DataTableProps<T>, c: Controlled, changes: Changes, pageCount: number, labels: DataTableLabels) {\n const { pageSizeOptions, loading } = props;\n return (\n <Pagination\n page={Math.min(c.page, pageCount)}\n pageCount={pageCount}\n onPageChange={changes.changePage}\n pageSize={pageSizeOptions ? c.pageSize : undefined}\n pageSizeOptions={pageSizeOptions}\n onPageSizeChange={pageSizeOptions ? changes.changePageSize : undefined}\n disabled={loading}\n labels={labels.pagination}\n />\n );\n}\n\n/** A table of records — sort, filters and facets, groups, details, pages, selection, visibility, pinning, resizing — on the client or the server, cards on a phone, windowing for long lists. */\nexport function DataTable<T extends RowData>(props: Readonly<DataTableProps<T>>) {\n const { columns, caption, showCaption, selectable, bulkActions, bulkMax, bulkResult, resizing, renderDetail, rowLabel, toolbar, footer, className, virtualized, loading, stickyHeader, scroll, manual } = props;\n const labels = { ...dataTableLabels, ...props.labels };\n const shape = shapeOf(props);\n const s = dataTable({ layout: shape.L, density: props.density, sticky: Boolean(stickyHeader), striped: Boolean(props.striped), typed: shape.typed, phone: shape.list ? \"list\" : \"cards\" });\n\n const route = useRoute(props);\n const c = useControlled(props, route);\n const changes = useQueryChanges(props, c, route);\n const { table, pinned, setSizing } = useEngine(props, c, changes, shape.detailed);\n const { leafCount, pageCount } = usePaging(props, c, changes, table);\n const pageRows = table.getRowModel().rows;\n const pick = useChoice(pageRows, c.selected, c.setSelected);\n const scroller = React.useRef<HTMLDivElement>(null);\n const win = useWindow(virtualized, loading, pageRows, scroller);\n\n const span = table.getVisibleLeafColumns().length + (selectable ? 1 : 0) + (shape.hasExpander ? 1 : 0);\n const fixedLayout = Boolean(resizing || pinned?.start?.length || pinned?.end?.length);\n const v: View<T> = {\n ...shape, ...pick,\n s, labels, byId: new Map(columns.map((col) => [col.id, col])),\n selectable: Boolean(selectable), span, virtualized: Boolean(virtualized), fixedLayout, renderDetail,\n rowLabel, visibleColumns: table.getVisibleLeafColumns(), measureElement: win.measureElement, loading, loadingCount: props.loadingRows ?? 5, error: props.error, empty: props.empty, pageRows, windowItems: win.items, resizing, stickyHeader, setSizing,\n };\n\n const context: Context = {\n table: table as unknown as DataTableInstance<object>,\n columns: columns as readonly DataTableColumn<object>[],\n labels,\n filters: c.filters,\n setFilters: changes.changeFilters,\n resultCount: leafCount,\n exportRows: () => table.getSortedRowModel().flatRows.filter((r) => !r.getIsGrouped()).map((r) => r.original),\n manualFiltering: Boolean(manual?.filtering),\n };\n\n const tableElement = tableOf(v, table, caption, showCaption, win.before, win.after);\n const sideways = scroll ?? (!shape.typed && !stickyHeader);\n const pagination = c.paginated ? pager(props, c, changes, pageCount, labels) : null;\n\n return (\n <DataTableContext.Provider value={context}>\n <div className={s.root({ className })}>\n {toolbar ? <div className={s.toolbar()}>{toolbar}</div> : null}\n {virtualized ? (\n // A scrolling region the keyboard can reach: Tab lands on it, the arrows scroll it.\n <div\n ref={scroller}\n tabIndex={0}\n role=\"region\"\n aria-label={caption}\n className={s.scroller({ className: \"overflow-y-auto focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\" })}\n style={{ height: virtualized.height }}\n >\n {tableElement}\n </div>\n ) : (\n <div className={s.scroller({ className: sideways ? (scroll ? SHADOWS : CARD_CLIP[shape.L]) : \"overflow-x-clip\" })}>{tableElement}</div>\n )}\n {selectable && bulkActions ? (\n <SelectionBar count={c.selected.length} max={bulkMax} result={bulkResult} labels={labels.selection} onClear={() => c.setSelected([])}>\n {bulkActions({ selected: [...c.selected], clear: () => c.setSelected([]) })}\n </SelectionBar>\n ) : null}\n {pagination || footer ? (\n <div className={s.footer({ className: \"flex flex-col gap-3\" })}>\n {pagination}\n {footer}\n </div>\n ) : null}\n </div>\n </DataTableContext.Provider>\n );\n}\n\n/** Windowing: the rows in view, between two spacer rows that keep the scroll height. */\nfunction useWindow<T extends RowData>(virtualized: DataTableProps<T>[\"virtualized\"], loading: boolean | undefined, pageRows: TableRow<T>[], scroller: React.RefObject<HTMLDivElement | null>) {\n const fallbacks = useLayoutFallbacks(virtualized?.height ?? 0, virtualized?.estimateRowHeight ?? 44);\n const virtualizer = useVirtualizer({\n ...fallbacks,\n count: pageRows.length,\n getScrollElement: () => scroller.current,\n estimateSize: () => virtualized?.estimateRowHeight ?? 44,\n overscan: virtualized?.overscan ?? 6,\n initialRect: { width: 0, height: virtualized?.height ?? 0 },\n getItemKey: (index) => pageRows[index]?.id ?? index,\n enabled: Boolean(virtualized) && !loading,\n });\n const items = virtualized && !loading ? virtualizer.getVirtualItems() : null;\n const before = items?.[0]?.start ?? 0;\n const after = items && items.length > 0 ? virtualizer.getTotalSize() - (items.at(-1)?.end ?? 0) : 0;\n return { items, before, after, measureElement: items ? virtualizer.measureElement : undefined };\n}\n\n/** The handle on a header's edge: drag it, or focus it and use ← → (Shift for larger steps). */\nfunction ResizeHandle({\n label,\n size,\n min,\n resizing,\n className,\n onPointerStart,\n onSize,\n}: Readonly<{\n label: string;\n size: number;\n min: number;\n resizing: boolean;\n className: string;\n onPointerStart: (event: unknown) => void;\n onSize: (size: number) => void;\n}>) {\n return (\n // A focusable separator is interactive (WAI-ARIA \"window splitter\"): its value is the width, the arrows change it.\n <div\n role=\"separator\"\n aria-orientation=\"vertical\"\n aria-label={label}\n aria-valuenow={Math.round(size)}\n aria-valuemin={min}\n tabIndex={0}\n data-resizing={resizing ? \"\" : undefined}\n className={className}\n onMouseDown={onPointerStart}\n onTouchStart={onPointerStart}\n onClick={(event) => event.stopPropagation()}\n onKeyDown={(event) => {\n const step = event.shiftKey ? 48 : 16;\n if (event.key === \"ArrowLeft\") onSize(Math.max(min, size - step));\n else if (event.key === \"ArrowRight\") onSize(size + step);\n else return;\n event.preventDefault();\n }}\n />\n );\n}\n"
|
|
795
795
|
},
|
|
796
796
|
{
|
|
797
797
|
"path": "data-table/engine.ts",
|
|
@@ -811,11 +811,11 @@
|
|
|
811
811
|
},
|
|
812
812
|
{
|
|
813
813
|
"path": "data-table/selection-bar.tsx",
|
|
814
|
-
"content": "// Client (a polite live region). The bar of a selection (krizaka-ts#89, bulk actions): how many rows are chosen, the actions\n// the PRODUCT gives for them (tag, untag, move status, move to a collection, export…), « Clear selection », and what the last\n// bulk change did (« 3 moved, 1 skipped »), announced politely. It is sticky at the bottom of its list; on a phone it docks\n// above the tab bar (`--kz-dock-offset`, the bar's height, set by the shell that has one). The service takes at most `max`\n// ids per call: past it the bar says so and the actions rest. `DataTable` draws it itself with `bulkActions`.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\n\nexport type SelectionBarLabels = {\n /** The bar's accessible name (\"Actions on the selection\"). */\n bar: string;\n /** The count: `(n) => n + \" selected\"`. */\n selected: (count: number) => string;\n /** \"Clear selection\". */\n clear: string;\n /** Said when the selection is bigger than the service takes: `(max) => \"At most \" + max + \" at a time\"`. */\n tooMany: (max: number) => string;\n};\n\nexport const selectionBarLabels: SelectionBarLabels = {\n bar: \"Actions on the selection\",\n selected: (count) => `${count.toLocaleString(\"en\")} selected`,\n clear: \"Clear selection\",\n tooMany: (max) => `At most ${max.toLocaleString(\"en\")} at a time`,\n};\n\nexport type SelectionBarProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** How many rows are chosen. The bar is not drawn at 0. */\n count: number;\n /** The actions the product gives (`Button`s). They rest when the selection is over `max`. */\n children?: React.ReactNode;\n /** Clears the selection. */\n onClear: () => void;\n /** The most the service takes at a time (200 for `@krizaka/organize`): the bar says so past it. */\n max?: number;\n /** What the last bulk change did (\"3 moved, 1 skipped — 1 has no right to this move\"), announced politely. */\n result?: string;\n /** The words, passed translated (English by default). */\n labels?: Partial<SelectionBarLabels>;\n};\n\n/** The count, the product's bulk actions, « Clear selection » and the result of the last change — sticky, docked on a phone. */\nexport function SelectionBar({ count, children, onClear, max, result, labels: given, className, ...props }: SelectionBarProps) {\n const labels = { ...selectionBarLabels, ...given };\n const over = max !== undefined && count > max;\n // The live region exists before its text changes, so a screen reader hears the count and the result.\n return (\n <div\n role=\"toolbar\"\n aria-label={labels.bar}\n data-over={over ? \"\" : undefined}\n hidden={count === 0}\n className={cn(\n \"sticky bottom-(--kz-dock-offset,0px) z-20 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border-default bg-surface-1 px-3 py-2.5 shadow-md\",\n \"max-md:rounded-b-none max-md:pb-[max(0.625rem,env(safe-area-inset-bottom))]\",\n \"[&_[role=toolbar]]:contents\",\n className,\n )}\n {...props}\n >\n <p className=\"m-0 text-sm font-semibold text-fg tabular-nums\" aria-live=\"polite\" aria-atomic>\n {count > 0 ? labels.selected(count) : \"\"}\n {over && max !== undefined ? <span className=\"ml-2 font-normal text-fg-danger\">{labels.tooMany(max)}</span> : null}\n </p>\n <div className={cn(\"flex flex-wrap items-center gap-2\", over && \"pointer-events-none opacity-40\")} inert={over || undefined}>\n {children}\n </div>\n <button\n type=\"button\"\n onClick={onClear}\n className=\"ml-auto inline-flex h-9 items-center rounded-md px-2.5 text-xs font-semibold text-fg-accent hover:bg-surface-2 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {labels.clear}\n </button>\n <p className=\"m-0 basis-full text-xs text-fg-secondary empty:hidden\" aria-live=\"polite\" aria-atomic>\n {result}\n </p>\n </div>\n );\n}\n"
|
|
814
|
+
"content": "// Client (a polite live region). The bar of a selection (krizaka-ts#89, bulk actions): how many rows are chosen, the actions\n// the PRODUCT gives for them (tag, untag, move status, move to a collection, export…), « Clear selection », and what the last\n// bulk change did (« 3 moved, 1 skipped »), announced politely. It is sticky at the bottom of its list; on a phone it docks\n// above the tab bar (`--kz-dock-offset`, the bar's height, set by the shell that has one). The service takes at most `max`\n// ids per call: past it the bar says so and the actions rest. `DataTable` draws it itself with `bulkActions`.\nimport * as React from \"react\";\n\nimport { cn } from \"../cn\";\n\nexport type SelectionBarLabels = {\n /** The bar's accessible name (\"Actions on the selection\"). */\n bar: string;\n /** The count: `(n) => n + \" selected\"`. */\n selected: (count: number) => string;\n /** \"Clear selection\". */\n clear: string;\n /** Said when the selection is bigger than the service takes: `(max) => \"At most \" + max + \" at a time\"`. */\n tooMany: (max: number) => string;\n};\n\nexport const selectionBarLabels: SelectionBarLabels = {\n bar: \"Actions on the selection\",\n selected: (count) => `${count.toLocaleString(\"en\")} selected`,\n clear: \"Clear selection\",\n tooMany: (max) => `At most ${max.toLocaleString(\"en\")} at a time`,\n};\n\nexport type SelectionBarProps = Omit<React.ComponentProps<\"div\">, \"children\"> & {\n /** How many rows are chosen. The bar is not drawn at 0. */\n count: number;\n /** The actions the product gives (`Button`s). They rest when the selection is over `max`. */\n children?: React.ReactNode;\n /** Clears the selection. */\n onClear: () => void;\n /** The most the service takes at a time (200 for `@krizaka/organize`): the bar says so past it. */\n max?: number;\n /** What the last bulk change did (\"3 moved, 1 skipped — 1 has no right to this move\"), announced politely. */\n result?: string;\n /** The words, passed translated (English by default). */\n labels?: Partial<SelectionBarLabels>;\n};\n\n/** The count, the product's bulk actions, « Clear selection » and the result of the last change — sticky, docked on a phone. */\nexport function SelectionBar({ count, children, onClear, max, result, labels: given, className, ...props }: Readonly<SelectionBarProps>) {\n const labels = { ...selectionBarLabels, ...given };\n const over = max !== undefined && count > max;\n // The live region exists before its text changes, so a screen reader hears the count and the result.\n return (\n <div\n role=\"toolbar\"\n aria-label={labels.bar}\n data-over={over ? \"\" : undefined}\n hidden={count === 0}\n className={cn(\n \"sticky bottom-(--kz-dock-offset,0px) z-20 flex flex-wrap items-center gap-x-3 gap-y-2 rounded-lg border border-border-default bg-surface-1 px-3 py-2.5 shadow-md\",\n \"max-md:rounded-b-none max-md:pb-[max(0.625rem,env(safe-area-inset-bottom))]\",\n \"[&_[role=toolbar]]:contents\",\n className,\n )}\n {...props}\n >\n <p className=\"m-0 text-sm font-semibold text-fg tabular-nums\" aria-live=\"polite\" aria-atomic>\n {count > 0 ? labels.selected(count) : \"\"}\n {over && max !== undefined ? <span className=\"ml-2 font-normal text-fg-danger\">{labels.tooMany(max)}</span> : null}\n </p>\n <div className={cn(\"flex flex-wrap items-center gap-2\", over && \"pointer-events-none opacity-40\")} inert={over || undefined}>\n {children}\n </div>\n <button\n type=\"button\"\n onClick={onClear}\n className=\"ml-auto inline-flex h-9 items-center rounded-md px-2.5 text-xs font-semibold text-fg-accent hover:bg-surface-2 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring\"\n >\n {labels.clear}\n </button>\n <p className=\"m-0 basis-full text-xs text-fg-secondary empty:hidden\" aria-live=\"polite\" aria-atomic>\n {result}\n </p>\n </div>\n );\n}\n"
|
|
815
815
|
},
|
|
816
816
|
{
|
|
817
817
|
"path": "data-table/toolbar.tsx",
|
|
818
|
-
"content": "// The toolbar of a DataTable — its filters (a FilterBar built from the columns), the columns menu and the CSV export —\n// connected to the table they sit in through `useDataTable()`. Words come from the table's `labels`.\nimport * as React from \"react\";\n\nimport { Button } from \"../button\";\nimport { DropdownMenu } from \"../dropdown-menu\";\nimport { Input } from \"../field\";\nimport { type ActiveFilter, FilterBar, FilterMenu } from \"../filter-bar\";\nimport { ChevronGlyph } from \"../glyphs\";\nimport { SearchField } from \"../search-field\";\nimport { dataTableCsv } from \"./csv\";\nimport { type DataTableColumn, useDataTable } from \"./data-table\";\nimport type { FilterValue } from \"./engine\";\n\nexport type DataTableFiltersProps = {\n /** The search's wait after the last key, in ms, before the filter applies (a request, in server mode). Default 250. */\n debounce?: number;\n /** More controls in the bar (a date range picker, a toggle). */\n children?: React.ReactNode;\n /** Classes merged on the bar. */\n className?: string;\n};\n\nconst asRange = (value: FilterValue | undefined): [number | null, number | null] =>\n Array.isArray(value) && value.length === 2 && (typeof value[0] !== \"string\" || typeof value[1] !== \"string\") ? [value[0] as number | null, value[1] as number | null] : [null, null];\nconst asList = (value: FilterValue | undefined): readonly string[] => (Array.isArray(value) ? (value as readonly string[]) : []);\nconst number = (text: string) => (text.trim() === \"\" || Number.isNaN(Number(text)) ? null : Number(text));\n\n/**\n * The filters of the table, from its columns: a search per `text` column, a menu of values (with their counts) per\n * `facet` column, two bounds per `range` column; the filters in force as removable chips, \"clear all\", and the count\n * of results, announced.\n */\nexport function DataTableFilters({ debounce = 250, children, className }: DataTableFiltersProps) {\n const { table, columns, labels, filters, setFilters, resultCount, manualFiltering } = useDataTable();\n const set = (id: string, value: FilterValue | null) => {\n const next = { ...filters };\n if (value === null || value === \"\" || (Array.isArray(value) && (value.length === 0 || (value.length === 2 && value[0] == null && value[1] == null)))) delete next[id];\n else next[id] = value;\n setFilters(next);\n };\n const filterable = columns.filter((column) => column.filter);\n const optionsOf = (column: DataTableColumn<object>) => {\n if (column.options) return column.options;\n // The values found in the rows, with their counts — the other filters applied (TanStack's facets).\n const facets = manualFiltering ? new Map<unknown, number>() : (table.getColumn(column.id)?.getFacetedUniqueValues() ?? new Map<unknown, number>());\n return [...facets.entries()]\n .filter(([value]) => value != null && value !== \"\")\n .map(([value, count]) => ({ value: String(value), label: String(value), count }))\n .sort((a, b) => a.label.localeCompare(b.label, undefined, { numeric: true }));\n };\n const active: ActiveFilter[] = filterable.flatMap((column) => {\n const value = filters[column.id];\n if (value === undefined) return [];\n let text: string;\n if (column.filter === \"facet\") {\n const options = optionsOf(column);\n text = asList(value).map((v) => options.find((o) => o.value === v)?.label ?? v).join(\", \");\n } else if (column.filter === \"range\") {\n const [min, max] = asRange(value);\n text = `${min ?? \"…\"}–${max ?? \"…\"}`;\n } else text = String(value);\n const label = labels.activeFilter(column.header, text);\n return [{ id: column.id, label, onRemove: () => set(column.id, null) }];\n });\n return (\n <FilterBar\n label={labels.filters}\n active={active}\n onClearAll={() => setFilters({})}\n clearLabel={labels.clearFilters}\n removeLabel={labels.removeFilter}\n results={labels.results(resultCount)}\n className={className}\n >\n {filterable.map((column) => {\n if (column.filter === \"text\")\n return (\n <TextFilter\n key={column.id}\n label={labels.search(column.header)}\n value={typeof filters[column.id] === \"string\" ? (filters[column.id] as string) : \"\"}\n debounce={debounce}\n onCommit={(query) => set(column.id, query)}\n />\n );\n if (column.filter === \"facet\")\n return (\n <FilterMenu key={column.id} label={column.header} options={optionsOf(column)} value={asList(filters[column.id])} onValueChange={(value) => set(column.id, value)} />\n );\n const [min, max] = asRange(filters[column.id]);\n const bounds = manualFiltering ? undefined : table.getColumn(column.id)?.getFacetedMinMaxValues();\n return (\n <span key={column.id} className=\"inline-flex items-center gap-1.5\">\n <Input\n type=\"number\"\n inputMode=\"decimal\"\n aria-label={labels.rangeFrom(column.header)}\n placeholder={bounds ? String(bounds[0]) : labels.rangeFrom(column.header)}\n value={min ?? \"\"}\n onChange={(event) => set(column.id, [number(event.currentTarget.value), max])}\n className=\"h-11 w-28\"\n />\n <span aria-hidden className=\"text-fg-secondary\">\n –\n </span>\n <Input\n type=\"number\"\n inputMode=\"decimal\"\n aria-label={labels.rangeTo(column.header)}\n placeholder={bounds ? String(bounds[1]) : labels.rangeTo(column.header)}\n value={max ?? \"\"}\n onChange={(event) => set(column.id, [min, number(event.currentTarget.value)])}\n className=\"h-11 w-28\"\n />\n </span>\n );\n })}\n {children}\n </FilterBar>\n );\n}\n\nexport type DataTableColumnsMenuProps = {\n /** Opens the menu at first (a story, a test). */\n defaultOpen?: boolean;\n /** Classes merged on the button. */\n className?: string;\n};\n\n/** A menu of the `hideable` columns, each a checkbox: the person chooses what the table shows. */\nexport function DataTableColumnsMenu({ defaultOpen, className }: DataTableColumnsMenuProps) {\n const { table, columns, labels } = useDataTable();\n return (\n <DropdownMenu.Root defaultOpen={defaultOpen} modal={false}>\n <DropdownMenu.Trigger asChild>\n <Button variant=\"outline\" size=\"sm\" className={className}>\n {labels.columns}\n <ChevronGlyph className=\"h-4 w-4\" />\n </Button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\" aria-label={labels.columns}>\n {columns\n .filter((column) => column.hideable !== false)\n .map((column) => {\n const instance = table.getColumn(column.id);\n return (\n <DropdownMenu.CheckboxItem\n key={column.id}\n checked={instance?.getIsVisible() ?? true}\n onSelect={(event) => event.preventDefault()}\n onCheckedChange={(checked) => instance?.toggleVisibility(Boolean(checked))}\n >\n {column.header}\n </DropdownMenu.CheckboxItem>\n );\n })}\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}\n\nexport type DataTableExportProps = {\n /** The file's name. Default `\"export.csv\"`. */\n filename?: string;\n /** Receives the CSV instead of downloading it (send it to the server, a test). */\n onExport?: (csv: string) => void;\n /** Classes merged on the button. */\n className?: string;\n};\n\n/** Downloads what the table shows — the filtered and sorted rows of every page, the visible columns — as CSV. */\nexport function DataTableExport({ filename = \"export.csv\", onExport, className }: DataTableExportProps) {\n const { table, columns, labels, exportRows } = useDataTable();\n const run = () => {\n const visible = columns.filter((column) => table.getColumn(column.id)?.getIsVisible() !== false);\n const csv = dataTableCsv(exportRows(), visible);\n if (onExport) return onExport(csv);\n const url = URL.createObjectURL(new Blob([\"\", csv], { type: \"text/csv;charset=utf-8\" }));\n const link = Object.assign(document.createElement(\"a\"), { href: url, download: filename });\n link.click();\n setTimeout(() => URL.revokeObjectURL(url), 0);\n };\n return (\n <Button variant=\"outline\" size=\"sm\" className={className} onClick={run}>\n {labels.export}\n </Button>\n );\n}\n\n/**\n * A text filter: what is typed stays a draft until the debounce commits it, and a value that changes from outside\n * (back or forward on a `routeKey` table, « Clear all ») replaces the draft — the box always says what filters the rows.\n */\nfunction TextFilter({ label, value, debounce, onCommit }: Readonly<{ label: string; value: string; debounce?: number; onCommit: (query: string) => void }>) {\n const [draft, setDraft] = React.useState(value);\n const [seen, setSeen] = React.useState(value);\n const [committed, setCommitted] = React.useState(value);\n if (value !== seen) {\n setSeen(value);\n if (value !== committed) {\n setCommitted(value);\n setDraft(value);\n }\n }\n return (\n <SearchField\n label={label}\n placeholder={label}\n value={draft}\n onValueChange={setDraft}\n debounce={debounce}\n onSearch={(query) => {\n setCommitted(query);\n onCommit(query);\n }}\n landmark={false}\n size=\"sm\"\n className=\"min-w-48 flex-1\"\n />\n );\n}\n"
|
|
818
|
+
"content": "// The toolbar of a DataTable — its filters (a FilterBar built from the columns), the columns menu and the CSV export —\n// connected to the table they sit in through `useDataTable()`. Words come from the table's `labels`.\nimport * as React from \"react\";\n\nimport { Button } from \"../button\";\nimport { DropdownMenu } from \"../dropdown-menu\";\nimport { Input } from \"../field\";\nimport { type ActiveFilter, FilterBar, FilterMenu } from \"../filter-bar\";\nimport { ChevronGlyph } from \"../glyphs\";\nimport { SearchField } from \"../search-field\";\nimport { dataTableCsv } from \"./csv\";\nimport { type DataTableColumn, useDataTable } from \"./data-table\";\nimport type { FilterValue } from \"./engine\";\n\nexport type DataTableFiltersProps = {\n /** The search's wait after the last key, in ms, before the filter applies (a request, in server mode). Default 250. */\n debounce?: number;\n /** More controls in the bar (a date range picker, a toggle). */\n children?: React.ReactNode;\n /** Classes merged on the bar. */\n className?: string;\n};\n\nconst asRange = (value: FilterValue | undefined): [number | null, number | null] =>\n Array.isArray(value) && value.length === 2 && (typeof value[0] !== \"string\" || typeof value[1] !== \"string\") ? [value[0] as number | null, value[1] as number | null] : [null, null];\nconst asList = (value: FilterValue | undefined): readonly string[] => (Array.isArray(value) ? (value as readonly string[]) : []);\nconst number = (text: string) => (text.trim() === \"\" || Number.isNaN(Number(text)) ? null : Number(text));\n\n/**\n * The filters of the table, from its columns: a search per `text` column, a menu of values (with their counts) per\n * `facet` column, two bounds per `range` column; the filters in force as removable chips, \"clear all\", and the count\n * of results, announced.\n */\nexport function DataTableFilters({ debounce = 250, children, className }: Readonly<DataTableFiltersProps>) {\n const { table, columns, labels, filters, setFilters, resultCount, manualFiltering } = useDataTable();\n const set = (id: string, value: FilterValue | null) => {\n const next = { ...filters };\n if (value === null || value === \"\" || (Array.isArray(value) && (value.length === 0 || (value.length === 2 && value[0] == null && value[1] == null)))) delete next[id];\n else next[id] = value;\n setFilters(next);\n };\n const filterable = columns.filter((column) => column.filter);\n const optionsOf = (column: DataTableColumn<object>) => {\n if (column.options) return column.options;\n // The values found in the rows, with their counts — the other filters applied (TanStack's facets).\n const facets = manualFiltering ? new Map<unknown, number>() : (table.getColumn(column.id)?.getFacetedUniqueValues() ?? new Map<unknown, number>());\n return [...facets.entries()]\n .filter(([value]) => value != null && value !== \"\")\n .map(([value, count]) => ({ value: String(value), label: String(value), count }))\n .sort((a, b) => a.label.localeCompare(b.label, undefined, { numeric: true }));\n };\n const active: ActiveFilter[] = filterable.flatMap((column) => {\n const value = filters[column.id];\n if (value === undefined) return [];\n let text: string;\n if (column.filter === \"facet\") {\n const options = optionsOf(column);\n text = asList(value).map((v) => options.find((o) => o.value === v)?.label ?? v).join(\", \");\n } else if (column.filter === \"range\") {\n const [min, max] = asRange(value);\n text = `${min ?? \"…\"}–${max ?? \"…\"}`;\n } else text = String(value);\n const label = labels.activeFilter(column.header, text);\n return [{ id: column.id, label, onRemove: () => set(column.id, null) }];\n });\n return (\n <FilterBar\n label={labels.filters}\n active={active}\n onClearAll={() => setFilters({})}\n clearLabel={labels.clearFilters}\n removeLabel={labels.removeFilter}\n results={labels.results(resultCount)}\n className={className}\n >\n {filterable.map((column) => {\n if (column.filter === \"text\")\n return (\n <TextFilter\n key={column.id}\n label={labels.search(column.header)}\n value={typeof filters[column.id] === \"string\" ? (filters[column.id] as string) : \"\"}\n debounce={debounce}\n onCommit={(query) => set(column.id, query)}\n />\n );\n if (column.filter === \"facet\")\n return (\n <FilterMenu key={column.id} label={column.header} options={optionsOf(column)} value={asList(filters[column.id])} onValueChange={(value) => set(column.id, value)} />\n );\n const [min, max] = asRange(filters[column.id]);\n const bounds = manualFiltering ? undefined : table.getColumn(column.id)?.getFacetedMinMaxValues();\n return (\n <span key={column.id} className=\"inline-flex items-center gap-1.5\">\n <Input\n type=\"number\"\n inputMode=\"decimal\"\n aria-label={labels.rangeFrom(column.header)}\n placeholder={bounds ? String(bounds[0]) : labels.rangeFrom(column.header)}\n value={min ?? \"\"}\n onChange={(event) => set(column.id, [number(event.currentTarget.value), max])}\n className=\"h-11 w-28\"\n />\n <span aria-hidden className=\"text-fg-secondary\">\n –\n </span>\n <Input\n type=\"number\"\n inputMode=\"decimal\"\n aria-label={labels.rangeTo(column.header)}\n placeholder={bounds ? String(bounds[1]) : labels.rangeTo(column.header)}\n value={max ?? \"\"}\n onChange={(event) => set(column.id, [min, number(event.currentTarget.value)])}\n className=\"h-11 w-28\"\n />\n </span>\n );\n })}\n {children}\n </FilterBar>\n );\n}\n\nexport type DataTableColumnsMenuProps = {\n /** Opens the menu at first (a story, a test). */\n defaultOpen?: boolean;\n /** Classes merged on the button. */\n className?: string;\n};\n\n/** A menu of the `hideable` columns, each a checkbox: the person chooses what the table shows. */\nexport function DataTableColumnsMenu({ defaultOpen, className }: Readonly<DataTableColumnsMenuProps>) {\n const { table, columns, labels } = useDataTable();\n return (\n <DropdownMenu.Root defaultOpen={defaultOpen} modal={false}>\n <DropdownMenu.Trigger asChild>\n <Button variant=\"outline\" size=\"sm\" className={className}>\n {labels.columns}\n <ChevronGlyph className=\"h-4 w-4\" />\n </Button>\n </DropdownMenu.Trigger>\n <DropdownMenu.Content align=\"end\" aria-label={labels.columns}>\n {columns\n .filter((column) => column.hideable !== false)\n .map((column) => {\n const instance = table.getColumn(column.id);\n return (\n <DropdownMenu.CheckboxItem\n key={column.id}\n checked={instance?.getIsVisible() ?? true}\n onSelect={(event) => event.preventDefault()}\n onCheckedChange={(checked) => instance?.toggleVisibility(Boolean(checked))}\n >\n {column.header}\n </DropdownMenu.CheckboxItem>\n );\n })}\n </DropdownMenu.Content>\n </DropdownMenu.Root>\n );\n}\n\nexport type DataTableExportProps = {\n /** The file's name. Default `\"export.csv\"`. */\n filename?: string;\n /** Receives the CSV instead of downloading it (send it to the server, a test). */\n onExport?: (csv: string) => void;\n /** Classes merged on the button. */\n className?: string;\n};\n\n/** Downloads what the table shows — the filtered and sorted rows of every page, the visible columns — as CSV. */\nexport function DataTableExport({ filename = \"export.csv\", onExport, className }: Readonly<DataTableExportProps>) {\n const { table, columns, labels, exportRows } = useDataTable();\n const run = () => {\n const visible = columns.filter((column) => table.getColumn(column.id)?.getIsVisible() !== false);\n const csv = dataTableCsv(exportRows(), visible);\n if (onExport) return onExport(csv);\n const url = URL.createObjectURL(new Blob([\"\", csv], { type: \"text/csv;charset=utf-8\" }));\n const link = Object.assign(document.createElement(\"a\"), { href: url, download: filename });\n link.click();\n setTimeout(() => URL.revokeObjectURL(url), 0);\n };\n return (\n <Button variant=\"outline\" size=\"sm\" className={className} onClick={run}>\n {labels.export}\n </Button>\n );\n}\n\n/**\n * A text filter: what is typed stays a draft until the debounce commits it, and a value that changes from outside\n * (back or forward on a `routeKey` table, « Clear all ») replaces the draft — the box always says what filters the rows.\n */\nfunction TextFilter({ label, value, debounce, onCommit }: Readonly<{ label: string; value: string; debounce?: number; onCommit: (query: string) => void }>) {\n const [draft, setDraft] = React.useState(value);\n const [seen, setSeen] = React.useState(value);\n const [committed, setCommitted] = React.useState(value);\n if (value !== seen) {\n setSeen(value);\n if (value !== committed) {\n setCommitted(value);\n setDraft(value);\n }\n }\n return (\n <SearchField\n label={label}\n placeholder={label}\n value={draft}\n onValueChange={setDraft}\n debounce={debounce}\n onSearch={(query) => {\n setCommitted(query);\n onCommit(query);\n }}\n landmark={false}\n size=\"sm\"\n className=\"min-w-48 flex-1\"\n />\n );\n}\n"
|
|
819
819
|
},
|
|
820
820
|
{
|
|
821
821
|
"path": "data-table/use-route-table.ts",
|
|
@@ -823,7 +823,7 @@
|
|
|
823
823
|
},
|
|
824
824
|
{
|
|
825
825
|
"path": "glyphs.tsx",
|
|
826
|
-
"content": "// The small line glyphs the data and media primitives draw (play, volume, search, chevrons…): decorative, 24-unit\n// box, `currentColor`, sized by the caller's class. Shared by the entries that need them; never exported on its own —\n// a product draws its own icons with @krizaka/icons.\nimport type * as React from \"react\";\n\ntype GlyphProps = { className?: string };\n\nfunction Glyph({ className = \"h-4 w-4\", fill, children }: GlyphProps & { fill?: boolean; children: React.ReactNode }) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n className={className}\n fill={fill ? \"currentColor\" : \"none\"}\n stroke={fill ? \"none\" : \"currentColor\"}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden\n focusable=\"false\"\n >\n {children}\n </svg>\n );\n}\n\nexport const PlayGlyph = (p: GlyphProps) => (\n <Glyph {...p} fill>\n <path d=\"M8 5.5v13a1 1 0 0 0 1.5.86l10.4-6.5a1 1 0 0 0 0-1.72L9.5 4.64A1 1 0 0 0 8 5.5Z\" />\n </Glyph>\n);\nexport const PauseGlyph = (p: GlyphProps) => (\n <Glyph {...p} fill>\n <rect x=\"6\" y=\"5\" width=\"4\" height=\"14\" rx=\"1\" />\n <rect x=\"14\" y=\"5\" width=\"4\" height=\"14\" rx=\"1\" />\n </Glyph>\n);\nexport const VolumeGlyph = ({ muted, ...p }: GlyphProps & { muted?: boolean }) => (\n <Glyph {...p}>\n <path d=\"M11 5 6 9H3v6h3l5 4V5Z\" />\n {muted ? <path d=\"m22 9-6 6m0-6 6 6\" /> : <path d=\"M15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13\" />}\n </Glyph>\n);\nexport const FullscreenGlyph = ({ exit, ...p }: GlyphProps & { exit?: boolean }) => (\n <Glyph {...p}>\n {exit ? <path d=\"M9 4v5H4m11-5v5h5M9 20v-5H4m11 5v-5h5\" /> : <path d=\"M4 9V4h5m6 0h5v5M4 15v5h5m11-5v5h-5\" />}\n </Glyph>\n);\nexport const CaptionsGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\" />\n <path d=\"M10 10.5a2 2 0 1 0 0 3M17 10.5a2 2 0 1 0 0 3\" />\n </Glyph>\n);\nexport const PipGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\" />\n <rect x=\"12\" y=\"12\" width=\"6\" height=\"4\" rx=\"1\" />\n </Glyph>\n);\nexport const SearchGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <circle cx=\"11\" cy=\"11\" r=\"7\" />\n <path d=\"m20 20-3.5-3.5\" />\n </Glyph>\n);\nexport const CloseGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M18 6 6 18M6 6l12 12\" />\n </Glyph>\n);\nexport const ChevronGlyph = ({ direction = \"down\", ...p }: GlyphProps & { direction?: \"left\" | \"right\" | \"up\" | \"down\" }) => (\n <Glyph {...p}>\n <path d={{ left: \"m15 6-6 6 6 6\", right: \"m9 6 6 6-6 6\", up: \"m6 15 6-6 6 6\", down: \"m6 9 6 6 6-6\" }[direction]} />\n </Glyph>\n);\nexport const CheckGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M20 6 9 17l-5-5\" />\n </Glyph>\n);\nexport const PlusGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M12 5v14M5 12h14\" />\n </Glyph>\n);\nexport const CalendarGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <rect x=\"3\" y=\"5\" width=\"18\" height=\"16\" rx=\"2\" />\n <path d=\"M3 10h18M8 3v4M16 3v4\" />\n </Glyph>\n);\nexport const UploadGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M12 16V4m0 0L7 9m5-5 5 5\" />\n <path d=\"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\" />\n </Glyph>\n);\nexport const FileGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5Z\" />\n <path d=\"M14 3v5h5\" />\n </Glyph>\n);\nexport const CameraGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M4 8h3l2-3h6l2 3h3a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1Z\" />\n <circle cx=\"12\" cy=\"13.5\" r=\"3.5\" />\n </Glyph>\n);\nexport const FlipGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M4 12a8 8 0 0 1 14-5.3M20 12a8 8 0 0 1-14 5.3\" />\n <path d=\"M18 3v4h-4M6 21v-4h4\" />\n </Glyph>\n);\nexport const RetryGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M4 12a8 8 0 1 0 2.3-5.7L4 8.5\" />\n <path d=\"M4 4v4.5h4.5\" />\n </Glyph>\n);\nexport const SortGlyph = ({ direction, ...p }: GlyphProps & { direction?: \"ascending\" | \"descending\" }) => (\n <Glyph {...p}>\n {direction === \"ascending\" ? <path d=\"m7 14 5-5 5 5\" /> : direction === \"descending\" ? <path d=\"m7 10 5 5 5-5\" /> : <path d=\"m8 9 4-4 4 4M8 15l4 4 4-4\" />}\n </Glyph>\n);\nexport const ArrowGlyph = ({ direction = \"right\", ...p }: GlyphProps & { direction?: \"left\" | \"right\" }) => (\n <Glyph {...p}>\n <path d={direction === \"left\" ? \"M19 12H5m0 0 6-6m-6 6 6 6\" : \"M5 12h14m0 0-6-6m6 6-6 6\"} />\n </Glyph>\n);\nexport const ExternalGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M14 4h6v6M20 4l-9 9\" />\n <path d=\"M18 14v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4\" />\n </Glyph>\n);\nexport const WarningGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M12 4 2.5 20h19L12 4Z\" />\n <path d=\"M12 10v4M12 17.2v.1\" />\n </Glyph>\n);\nexport const CopyGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <rect x=\"9\" y=\"9\" width=\"11\" height=\"11\" rx=\"2\" />\n <path d=\"M15 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h3\" />\n </Glyph>\n);\nexport const PencilGlyph = (p: GlyphProps) => (\n <Glyph {...p}>\n <path d=\"M4 20h4L19 9a2.8 2.8 0 0 0-4-4L4 16v4zM13.5 6.5l4 4\" />\n </Glyph>\n);\n"
|
|
826
|
+
"content": "// The small line glyphs the data and media primitives draw (play, volume, search, chevrons…): decorative, 24-unit\n// box, `currentColor`, sized by the caller's class. Shared by the entries that need them; never exported on its own —\n// a product draws its own icons with @krizaka/icons.\nimport type * as React from \"react\";\n\ntype GlyphProps = { className?: string };\n\nfunction Glyph({ className = \"h-4 w-4\", fill, children }: Readonly<GlyphProps & { fill?: boolean; children: React.ReactNode }>) {\n return (\n <svg\n viewBox=\"0 0 24 24\"\n className={className}\n fill={fill ? \"currentColor\" : \"none\"}\n stroke={fill ? \"none\" : \"currentColor\"}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n aria-hidden\n focusable=\"false\"\n >\n {children}\n </svg>\n );\n}\n\nexport const PlayGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p} fill>\n <path d=\"M8 5.5v13a1 1 0 0 0 1.5.86l10.4-6.5a1 1 0 0 0 0-1.72L9.5 4.64A1 1 0 0 0 8 5.5Z\" />\n </Glyph>\n);\nexport const PauseGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p} fill>\n <rect x=\"6\" y=\"5\" width=\"4\" height=\"14\" rx=\"1\" />\n <rect x=\"14\" y=\"5\" width=\"4\" height=\"14\" rx=\"1\" />\n </Glyph>\n);\nexport const VolumeGlyph = ({ muted, ...p }: Readonly<GlyphProps & { muted?: boolean }>) => (\n <Glyph {...p}>\n <path d=\"M11 5 6 9H3v6h3l5 4V5Z\" />\n {muted ? <path d=\"m22 9-6 6m0-6 6 6\" /> : <path d=\"M15.5 8.5a5 5 0 0 1 0 7M18.5 5.5a9 9 0 0 1 0 13\" />}\n </Glyph>\n);\nexport const FullscreenGlyph = ({ exit, ...p }: Readonly<GlyphProps & { exit?: boolean }>) => (\n <Glyph {...p}>\n {exit ? <path d=\"M9 4v5H4m11-5v5h5M9 20v-5H4m11 5v-5h5\" /> : <path d=\"M4 9V4h5m6 0h5v5M4 15v5h5m11-5v5h-5\" />}\n </Glyph>\n);\nexport const CaptionsGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\" />\n <path d=\"M10 10.5a2 2 0 1 0 0 3M17 10.5a2 2 0 1 0 0 3\" />\n </Glyph>\n);\nexport const PipGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\" />\n <rect x=\"12\" y=\"12\" width=\"6\" height=\"4\" rx=\"1\" />\n </Glyph>\n);\nexport const SearchGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <circle cx=\"11\" cy=\"11\" r=\"7\" />\n <path d=\"m20 20-3.5-3.5\" />\n </Glyph>\n);\nexport const CloseGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M18 6 6 18M6 6l12 12\" />\n </Glyph>\n);\nexport const ChevronGlyph = ({ direction = \"down\", ...p }: Readonly<GlyphProps & { direction?: \"left\" | \"right\" | \"up\" | \"down\" }>) => (\n <Glyph {...p}>\n <path d={{ left: \"m15 6-6 6 6 6\", right: \"m9 6 6 6-6 6\", up: \"m6 15 6-6 6 6\", down: \"m6 9 6 6 6-6\" }[direction]} />\n </Glyph>\n);\nexport const CheckGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M20 6 9 17l-5-5\" />\n </Glyph>\n);\nexport const PlusGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M12 5v14M5 12h14\" />\n </Glyph>\n);\nexport const CalendarGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <rect x=\"3\" y=\"5\" width=\"18\" height=\"16\" rx=\"2\" />\n <path d=\"M3 10h18M8 3v4M16 3v4\" />\n </Glyph>\n);\nexport const UploadGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M12 16V4m0 0L7 9m5-5 5 5\" />\n <path d=\"M4 16v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2\" />\n </Glyph>\n);\nexport const FileGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8l-5-5Z\" />\n <path d=\"M14 3v5h5\" />\n </Glyph>\n);\nexport const CameraGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M4 8h3l2-3h6l2 3h3a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V9a1 1 0 0 1 1-1Z\" />\n <circle cx=\"12\" cy=\"13.5\" r=\"3.5\" />\n </Glyph>\n);\nexport const FlipGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M4 12a8 8 0 0 1 14-5.3M20 12a8 8 0 0 1-14 5.3\" />\n <path d=\"M18 3v4h-4M6 21v-4h4\" />\n </Glyph>\n);\nexport const RetryGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M4 12a8 8 0 1 0 2.3-5.7L4 8.5\" />\n <path d=\"M4 4v4.5h4.5\" />\n </Glyph>\n);\nexport const SortGlyph = ({ direction, ...p }: Readonly<GlyphProps & { direction?: \"ascending\" | \"descending\" }>) => (\n <Glyph {...p}>\n {direction === \"ascending\" ? <path d=\"m7 14 5-5 5 5\" /> : direction === \"descending\" ? <path d=\"m7 10 5 5 5-5\" /> : <path d=\"m8 9 4-4 4 4M8 15l4 4 4-4\" />}\n </Glyph>\n);\nexport const ArrowGlyph = ({ direction = \"right\", ...p }: Readonly<GlyphProps & { direction?: \"left\" | \"right\" }>) => (\n <Glyph {...p}>\n <path d={direction === \"left\" ? \"M19 12H5m0 0 6-6m-6 6 6 6\" : \"M5 12h14m0 0-6-6m6 6-6 6\"} />\n </Glyph>\n);\nexport const ExternalGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M14 4h6v6M20 4l-9 9\" />\n <path d=\"M18 14v4a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4\" />\n </Glyph>\n);\nexport const WarningGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M12 4 2.5 20h19L12 4Z\" />\n <path d=\"M12 10v4M12 17.2v.1\" />\n </Glyph>\n);\nexport const CopyGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <rect x=\"9\" y=\"9\" width=\"11\" height=\"11\" rx=\"2\" />\n <path d=\"M15 9V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h3\" />\n </Glyph>\n);\nexport const PencilGlyph = (p: Readonly<GlyphProps>) => (\n <Glyph {...p}>\n <path d=\"M4 20h4L19 9a2.8 2.8 0 0 0-4-4L4 16v4zM13.5 6.5l4 4\" />\n </Glyph>\n);\n"
|
|
827
827
|
},
|
|
828
828
|
{
|
|
829
829
|
"path": "media.ts",
|
|
@@ -831,7 +831,7 @@
|
|
|
831
831
|
},
|
|
832
832
|
{
|
|
833
833
|
"path": "meta.ts",
|
|
834
|
-
"content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"columns\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"waveform\"\n | \"proposal\"\n | \"qr-code\"\n | \"identity-card\"\n | \"entity-header\"\n | \"collection-switcher\"\n | \"marketing-layout\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"shop-gallery\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"schema-form\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Sovkora Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the thirteen domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"abuse\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
|
|
834
|
+
"content": "// The documentation of a component, carried by its code: each primitive has a `meta.ts` beside its source\n// (`src/<name>/meta.ts`; a component that exists only in React Native: `src/native/meta/<name>.ts`). Never built into\n// the package: `scripts/build-registry.mjs` reads them into `registry/<name>.json`, which ui.krizaka.com (apps/site) renders as\n// ui.krizaka.com/components/<name>, and `scripts/registry.test.mjs` fails when one is missing or incomplete.\n//\n// Why a typed module and not JSDoc tags: the fields are lists and links (`related`, `whenNotToUse[].use`, examples),\n// which a type checks and a comment does not; the file is plain data (erasable TypeScript), so Node reads it without a\n// compiler, and an editor completes it.\n\n/** Every documented component: the web primitives (one entry of the package each) and the native-only ones. */\nexport type ComponentName =\n | \"notification-preferences\"\n | \"quota-meter\"\n | \"environment-notice\"\n | \"embed-facade\"\n | \"reviews\"\n | \"margin-layout\"\n | \"analysis-report\"\n | \"status-chip\"\n | \"kind-config-editor\"\n | \"agenda\"\n | \"account-settings\"\n | \"drop-overlay\"\n | \"upload-queue\"\n | \"achievement\"\n | \"anatomy-plate\"\n | \"architecture-diagram\"\n | \"bird-plate\"\n | \"taped-photo\"\n | \"stuck\"\n | \"doodle\"\n | \"signature\"\n | \"grade-stamp\"\n | \"versus-card\"\n | \"speed-lines\"\n | \"site-cahier\"\n | \"text-style\"\n | \"flock\"\n | \"elephant\"\n | \"footnote\"\n | \"page-index\"\n | \"chapter\"\n | \"specimen-tag\"\n | \"action-bar\"\n | \"action-sheet\"\n | \"activity-feed\"\n | \"alert\"\n | \"app-frame\"\n | \"desktop-window\"\n | \"form-flow\"\n | \"grid\"\n | \"list-detail\"\n | \"state-screen\"\n | \"app-header\"\n | \"app-shell\"\n | \"argument-card\"\n | \"auth-layout\"\n | \"avatar\"\n | \"badge\"\n | \"button\"\n | \"captcha\"\n | \"card\"\n | \"card-grid\"\n | \"catalogue-page\"\n | \"changelog-page\"\n | \"chat\"\n | \"checkbox\"\n | \"chip\"\n | \"chip-link\"\n | \"chip-row\"\n | \"columns\"\n | \"choice-grid\"\n | \"cn\"\n | \"code-block\"\n | \"combobox\"\n | \"comparison-table\"\n | \"command\"\n | \"component-page\"\n | \"confirm-button\"\n | \"copy-button\"\n | \"money-input\"\n | \"price-catalogue-editor\"\n | \"promo-code-field\"\n | \"contact-page\"\n | \"continue-prompt\"\n | \"countdown\"\n | \"cover-hero\"\n | \"cta-panel\"\n | \"dashboard-layout\"\n | \"data-table\"\n | \"date-picker\"\n | \"decision-list\"\n | \"description-list\"\n | \"detail-layout\"\n | \"dialog\"\n | \"docs-article-page\"\n | \"docs-hub-page\"\n | \"docs-layout\"\n | \"docs-nav\"\n | \"document-viewer\"\n | \"dropdown-menu\"\n | \"empty-state\"\n | \"engine-flow\"\n | \"error-page\"\n | \"fab\"\n | \"field\"\n | \"file-upload\"\n | \"filter-bar\"\n | \"force-update-screen\"\n | \"form\"\n | \"gallery-page\"\n | \"genui\"\n | \"glossary\"\n | \"glossary-term\"\n | \"glow-card\"\n | \"goal-gauge\"\n | \"header\"\n | \"image-cropper\"\n | \"image-viewer\"\n | \"kanban\"\n | \"kbd\"\n | \"kpi-explained\"\n | \"landing-page\"\n | \"landscape\"\n | \"legal-page\"\n | \"link-card\"\n | \"list\"\n | \"loader\"\n | \"longform-page\"\n | \"maintenance-screen\"\n | \"map\"\n | \"markdown\"\n | \"waveform\"\n | \"proposal\"\n | \"qr-code\"\n | \"identity-card\"\n | \"entity-header\"\n | \"collection-switcher\"\n | \"marketing-layout\"\n | \"mascot-quote\"\n | \"mascot-state\"\n | \"mascots\"\n | \"match-dialog\"\n | \"media-capture\"\n | \"language-switch\"\n | \"media-gallery\"\n | \"media-picker\"\n | \"meter\"\n | \"nav-bar\"\n | \"number-ticker\"\n | \"onboarding\"\n | \"opening-hours\"\n | \"otp-input\"\n | \"page\"\n | \"page-header\"\n | \"page-hero\"\n | \"pagination\"\n | \"permission-prompt\"\n | \"pointer-light\"\n | \"popover\"\n | \"pricing-page\"\n | \"product-page\"\n | \"profile-card\"\n | \"progress\"\n | \"promise-card\"\n | \"pull-to-refresh\"\n | \"retro-tv\"\n | \"shop-gallery\"\n | \"radio-group\"\n | \"router\"\n | \"rail-nav\"\n | \"recipes\"\n | \"screen\"\n | \"scroll-stage\"\n | \"search-field\"\n | \"section-backdrop\"\n | \"segmented\"\n | \"separator\"\n | \"service-card\"\n | \"shop\"\n | \"shop-composer\"\n | \"schema-form\"\n | \"settings-layout\"\n | \"account-menu\"\n | \"showcase\"\n | \"step-showcase\"\n | \"site-footer\"\n | \"sites\"\n | \"skeleton\"\n | \"skip-link\"\n | \"slider\"\n | \"slot-picker\"\n | \"slot\"\n | \"spinner\"\n | \"sticky-action\"\n | \"splash-handoff\"\n | \"split-view\"\n | \"stage-banner\"\n | \"stat\"\n | \"usage\"\n | \"status-page\"\n | \"step-progress\"\n | \"stepper\"\n | \"swipe-deck\"\n | \"swipeable-row\"\n | \"switch\"\n | \"tab-bar\"\n | \"tabs\"\n | \"tag-input\"\n | \"tag-selector\"\n | \"terminal-replay\"\n | \"theme\"\n | \"toast\"\n | \"toc\"\n | \"tooltip\"\n | \"tree-view\"\n | \"txt\"\n | \"update-prompt\"\n | \"verified-badge\"\n | \"vertical-video\"\n | \"video-player\"\n | \"video-trimmer\"\n | \"virtual\"\n | \"wall\";\n\n/** Where a component exists: `@krizaka/ui/<name>` (web), `@krizaka/ui/native` (React Native), or both. */\nexport type Platform = \"web\" | \"native\" | \"both\";\n\n/**\n * Why a component is not on a platform — a decision, never a silence (the parity matrix of ui.krizaka.com/platforms):\n * - `gap` (✗): it belongs there and is not built yet; `issue` is the issue that tracks it (`krizaka/krizaka-ui#275`);\n * - `n/a`: it is not meant for that platform (a site's page block on a phone, a swipe on a desktop); `use` names the\n * component that answers there, when one does.\n */\nexport type Absence =\n | { readonly status: \"gap\"; readonly issue: string; readonly reason: string; readonly use?: undefined }\n | { readonly status: \"n/a\"; readonly reason: string; readonly use?: ComponentName; readonly issue?: undefined };\n\n/**\n * Desktop is the Sovkora Mac app (Tauri 2: the system WebView renders the web components — ADR-002). `web`: the web\n * component runs there as it is; `desktop`: it also has a desktop form (a window's title bar, a denser layout…), said in\n * its documentation; otherwise the absence and why.\n */\nexport type DesktopSupport = \"web\" | \"desktop\" | Absence;\n\n/**\n * The three platforms of Krizaka UI — web · native (React Native, Expo) · desktop — for one component. The side a\n * component has is `platforms`; the side it lacks says why here: `native` is required for (and only for) a web-only\n * component, `web` for a native-only one; `desktop` always. `scripts/registry.test.mjs` fails on a missing decision.\n */\nexport interface Parity {\n readonly web?: Absence;\n readonly native?: Absence;\n readonly desktop: DesktopSupport;\n}\n\n/**\n * `experimental`: created for a filed need (ADR-008 §4), it may change or go in any minor until its first consumer imports it; `adoption`\n * names that consumer's issue. `stable`: its API only changes in a major. `beta`: it may still change in a minor. `deprecated`: no product uses it and\n * no work plans to — it still works, says what replaces it, and goes in the major named by `deprecated.removedIn`.\n */\nexport type Status = \"experimental\" | \"stable\" | \"beta\" | \"deprecated\";\n\n/**\n * What a component is for (ADR-008 §3): the thirteen domains the documentation, the size budgets and the guards are\n * organised by. The domain is metadata: the entries stay flat (`@krizaka/ui/<name>`). `cahier` is the sites' register\n * (ADR-004): a product never imports it.\n */\nexport type Domain =\n | \"foundations\"\n | \"forms\"\n | \"data-display\"\n | \"navigation-shell\"\n | \"feedback\"\n | \"maps\"\n | \"media\"\n | \"commerce\"\n | \"identity\"\n | \"abuse\"\n | \"conversation\"\n | \"page-blocks\"\n | \"cahier\";\n\n/** What a deprecated component says (required when `status` is `deprecated`, absent otherwise). */\nexport interface Deprecation {\n /** The version that deprecated it (`3.6.0`). */\n readonly since: string;\n /** The major that removes it (`4.0.0`). */\n readonly removedIn: string;\n /** What replaces it, when a component does. */\n readonly use?: ComponentName;\n /** Why it goes: no product uses it, no planned work needs it. */\n readonly reason: string;\n}\n\n/**\n * The group of the catalogue. `media`: video, sound, camera, files, cropping. `blocks`: the page blocks — the frame,\n * the hero, sections, cards that lead or argue, decisions, code, calls to act — that every page of a site is made of.\n * `layouts`: the shells of whole screens — an application, a dashboard, settings, sign-in, an object, a list and its\n * item, a site's page, a documentation page — each with its screens. `templates`: the page templates — whole pages of a\n * site (a landing, a product, a docs hub, a long read, a changelog, pricing, status, an error…), each a distinct\n * composition of the blocks, words and content as props.\n */\nexport type Category = \"actions\" | \"forms\" | \"navigation\" | \"overlays\" | \"feedback\" | \"data-display\" | \"media\" | \"blocks\" | \"layouts\" | \"templates\" | \"layout\" | \"foundations\";\n\n/** Why a reader needs a template: the seven intents the templates are grouped by (sidebar sub-headings, catalogue filter). */\nexport type TemplatePurpose = \"convince\" | \"explain\" | \"show\" | \"act\" | \"operate\" | \"converse\" | \"recover\";\n\n/** The groups of templates, in reading order: the title, and the one line that says when to come to that group. */\nexport const templatePurposes = {\n convince: { title: \"Convince\", useWhen: \"You come here when a visitor must decide: a landing, a product, a price, a comparison, a proof.\" },\n explain: { title: \"Explain\", useWhen: \"You come here when a reader must understand: how it works, a documentation hub or article, a changelog, a FAQ, a policy.\" },\n show: { title: \"Show\", useWhen: \"You come here when the work itself is the argument: a gallery, a story, a case study, an object and its details.\" },\n act: { title: \"Act\", useWhen: \"You come here when a person must do something once: reach the team, sign in or up, set up, pay.\" },\n operate: { title: \"Operate\", useWhen: \"You come here when a person works every day: a dashboard, a console with a table, settings, an app shell.\" },\n converse: { title: \"Converse\", useWhen: \"You come here when people talk: an inbox, a chat, comments, a notifications centre.\" },\n recover: { title: \"Recover\", useWhen: \"You come here when the way is blocked: an empty list, an error, a missing page, maintenance, a product still being built.\" },\n} as const satisfies Record<TemplatePurpose, { readonly title: string; readonly useWhen: string }>;\n\n/**\n * A named example: the file `registry/examples/<component>/<name>.tsx` (web) or\n * `registry/examples/<component>/native/<name>.tsx` (React Native) — at most 40 lines, imported by the stories and\n * shown (live, with its code) by the documentation.\n */\ninterface ExampleBase {\n /** The file name, kebab-case (`primary`, `icon-button`). */\n readonly name: string;\n /** A short title (`Primary`, `Icon button`). */\n readonly title: string;\n /** One or two sentences: when this variant is the right one. */\n readonly description: string;\n}\n\n/** A plain example, or a template: a whole screen with its intent (`purpose`) and the user goal its layout serves (`why`). */\nexport type Example =\n | (ExampleBase & { readonly template?: false; readonly purpose?: undefined; readonly why?: undefined })\n | (ExampleBase & {\n /**\n * A template: a whole screen of a product composed from the platform (a layout and its blocks, real words, its\n * phone version thought out), copied as a starting point — at most 160 lines, listed on ui.krizaka.com/templates.\n */\n readonly template: true;\n /** The intent that groups it: why you need this block. */\n readonly purpose: TemplatePurpose;\n /** Why this layout: the user goal it serves, in one sentence. */\n readonly why: string;\n });\n\n/** One platform's side of a component. */\nexport interface PlatformDocs {\n /** The names to import (`[\"Button\", \"IconButton\"]`): from `@krizaka/ui/<name>` on the web, `@krizaka/ui/native` in React Native. */\n readonly imports: readonly string[];\n /** The examples, in reading order; the first one is the component's preview. */\n readonly examples: readonly Example[];\n}\n\n/** The React Native side: the same concept, and what differs from the web API. */\nexport interface NativeDocs extends PlatformDocs {\n /**\n * The entry to import from when it is not `@krizaka/ui/native`: a component that needs an Expo module (an optional\n * peer) has its own, `@krizaka/ui/native/<name>`, so an app that does not use it never installs the module.\n */\n readonly entry?: string;\n /** What differs from the web API (`label` instead of children…); empty for a native-only component. */\n readonly differences: readonly string[];\n /** The React Native entry alone is deprecated while the web one stays (ADR-006 §7); a deprecated component says it once, above. */\n readonly deprecated?: Deprecation;\n}\n\nexport interface KeyboardInteraction {\n /** The keys, as written on a keyboard: `Space`, `Enter`, `Arrow keys`, `Esc`, `Tab`. */\n readonly keys: string;\n /** What they do. */\n readonly action: string;\n}\n\nexport interface ComponentMeta {\n /** The display name: `Button`, `Dropdown menu`. */\n readonly title: string;\n /** One sentence: what it is. */\n readonly summary: string;\n readonly status: Status;\n /** Required for, and only for, a `deprecated` component. */\n readonly deprecated?: Deprecation;\n readonly category: Category;\n /** What it is for: one of the twelve domains (ADR-008 §3). */\n readonly domain: Domain;\n /** The `<repo>#<n>` issue of its first consumer: required for, and only for, an `experimental` component. */\n readonly adoption?: string;\n /** Must match the sides below: `both` ⇔ `web` and `native`. */\n readonly platforms: Platform;\n /** The platforms it is not on, and why; and its desktop form (see `Parity`). */\n readonly parity: Parity;\n /** When to reach for it: concrete situations, one per item. */\n readonly whenToUse: readonly string[];\n /** When not to — and what to use instead (`use`), when another component is the answer. */\n readonly whenNotToUse: readonly { readonly when: string; readonly use?: ComponentName }[];\n /** How to use it well: wording, placement, composition. */\n readonly bestPractices: readonly string[];\n readonly accessibility: {\n /** The keyboard, when it does more than Tab and Enter. */\n readonly keyboard: readonly KeyboardInteraction[];\n /** Roles, names and announcements: what the component does, what the app must provide. */\n readonly notes: readonly string[];\n };\n /** The components a reader of this page should know about. */\n readonly related: readonly ComponentName[];\n readonly web?: PlatformDocs;\n readonly native?: NativeDocs;\n}\n"
|
|
835
835
|
}
|
|
836
836
|
],
|
|
837
837
|
"dependencies": [
|