@chassis-ui/react 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -3
- package/dist/accordion.js +1 -1
- package/dist/alert.js +1 -1
- package/dist/autocomplete.d.ts +1 -1
- package/dist/autocomplete.js +1 -1
- package/dist/avatar.js +1 -1
- package/dist/badge.js +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button-group.js +1 -1
- package/dist/button.js +1 -1
- package/dist/calendar.js +1 -1
- package/dist/card.js +1 -1
- package/dist/carousel.js +1 -1
- package/dist/checkbox.d.ts +1 -1
- package/dist/checkbox.js +1 -1
- package/dist/chip-input.js +1 -1
- package/dist/chip.js +1 -1
- package/dist/chunks/Button-Cjenm3ku.js +2 -0
- package/dist/chunks/Button-Cjenm3ku.js.map +1 -0
- package/dist/chunks/{Chip-C7QlFCvx.js → Chip-CXuYhjc3.js} +2 -2
- package/dist/chunks/{Chip-C7QlFCvx.js.map → Chip-CXuYhjc3.js.map} +1 -1
- package/dist/chunks/CloseButton-CAQ--0sB.js +2 -0
- package/dist/chunks/CloseButton-CAQ--0sB.js.map +1 -0
- package/dist/chunks/{DateField-4cdcwt0v.js → DateField-G1TP9ayt.js} +2 -2
- package/dist/chunks/{DateField-4cdcwt0v.js.map → DateField-G1TP9ayt.js.map} +1 -1
- package/dist/chunks/{FormHelp-B1eSoack.js → FormHelp-2U3P8C6b.js} +2 -2
- package/dist/chunks/{FormHelp-B1eSoack.js.map → FormHelp-2U3P8C6b.js.map} +1 -1
- package/dist/chunks/Link-B3SX50Od.js +2 -0
- package/dist/chunks/Link-B3SX50Od.js.map +1 -0
- package/dist/chunks/Menu-DBN4Mxak.js +2 -0
- package/dist/chunks/Menu-DBN4Mxak.js.map +1 -0
- package/dist/chunks/MenuToggle-DHzKm1Ed.js +2 -0
- package/dist/chunks/MenuToggle-DHzKm1Ed.js.map +1 -0
- package/dist/chunks/{RangeCalendar-mM3OeTlU.js → RangeCalendar-DRcg1Hp3.js} +2 -2
- package/dist/chunks/{RangeCalendar-mM3OeTlU.js.map → RangeCalendar-DRcg1Hp3.js.map} +1 -1
- package/dist/chunks/{VisuallyHidden-CGv-mBuQ.js → VisuallyHidden-24WfUCsJ.js} +2 -2
- package/dist/chunks/{VisuallyHidden-CGv-mBuQ.js.map → VisuallyHidden-24WfUCsJ.js.map} +1 -1
- package/dist/chunks/{accordion-BZlX2uk8.js → accordion-DiYPbV_r.js} +2 -2
- package/dist/chunks/{accordion-BZlX2uk8.js.map → accordion-DiYPbV_r.js.map} +1 -1
- package/dist/chunks/alert-oSKrhxkI.js +2 -0
- package/dist/chunks/{alert-DSLg5MBb.js.map → alert-oSKrhxkI.js.map} +1 -1
- package/dist/chunks/autocomplete-wjDWeWDh.js +2 -0
- package/dist/chunks/autocomplete-wjDWeWDh.js.map +1 -0
- package/dist/chunks/{avatar-BQBbcnk6.js → avatar-CvcvC9KA.js} +2 -2
- package/dist/chunks/{avatar-BQBbcnk6.js.map → avatar-CvcvC9KA.js.map} +1 -1
- package/dist/chunks/{badge-Ths1Qn1a.js → badge-D7XgWBXc.js} +2 -2
- package/dist/chunks/{badge-Ths1Qn1a.js.map → badge-D7XgWBXc.js.map} +1 -1
- package/dist/chunks/{breadcrumb-BTiQikk-.js → breadcrumb-DxCHVppV.js} +2 -2
- package/dist/chunks/{breadcrumb-BTiQikk-.js.map → breadcrumb-DxCHVppV.js.map} +1 -1
- package/dist/chunks/{button-group-CefkGeYL.js → button-group-CXMj0D4r.js} +2 -2
- package/dist/chunks/{button-group-CefkGeYL.js.map → button-group-CXMj0D4r.js.map} +1 -1
- package/dist/chunks/{card-CEQgHIaL.js → card-C6lPZs5J.js} +2 -2
- package/dist/chunks/{card-CEQgHIaL.js.map → card-C6lPZs5J.js.map} +1 -1
- package/dist/chunks/carousel-Ka9OA-HJ.js +2 -0
- package/dist/chunks/carousel-Ka9OA-HJ.js.map +1 -0
- package/dist/chunks/checkbox-5jv0YWoi.js +2 -0
- package/dist/chunks/checkbox-5jv0YWoi.js.map +1 -0
- package/dist/chunks/chip-input-D8EaNujM.js +2 -0
- package/dist/chunks/chip-input-D8EaNujM.js.map +1 -0
- package/dist/chunks/{collapse-CBi3RWTf.js → collapse-Bc7fnmyU.js} +2 -2
- package/dist/chunks/{collapse-CBi3RWTf.js.map → collapse-Bc7fnmyU.js.map} +1 -1
- package/dist/chunks/color-input-DBOd4Jba.js +2 -0
- package/dist/chunks/color-input-DBOd4Jba.js.map +1 -0
- package/dist/chunks/combobox-DByuUtwh.js +2 -0
- package/dist/chunks/{combobox-DNqR4d3V.js.map → combobox-DByuUtwh.js.map} +1 -1
- package/dist/chunks/context-HDVxTNPi.js.map +1 -1
- package/dist/chunks/context-menu-CGOGliw6.js +2 -0
- package/dist/chunks/context-menu-CGOGliw6.js.map +1 -0
- package/dist/chunks/datagrid-Dv_9uFef.js +2 -0
- package/dist/chunks/datagrid-Dv_9uFef.js.map +1 -0
- package/dist/chunks/datepicker-DuYmXiSe.js +2 -0
- package/dist/chunks/datepicker-DuYmXiSe.js.map +1 -0
- package/dist/chunks/dialogTitle-DMBvXZLT.js +2 -0
- package/dist/chunks/dialogTitle-DMBvXZLT.js.map +1 -0
- package/dist/chunks/{divider-C1-NoKMV.js → divider-DbWmMSrn.js} +2 -2
- package/dist/chunks/{divider-C1-NoKMV.js.map → divider-DbWmMSrn.js.map} +1 -1
- package/dist/chunks/drawer-DPxF30qn.js +2 -0
- package/dist/chunks/drawer-DPxF30qn.js.map +1 -0
- package/dist/chunks/file-input-B5YaBXjI.js +2 -0
- package/dist/chunks/file-input-B5YaBXjI.js.map +1 -0
- package/dist/chunks/{flex-C2jV5LyV.js → flex-C6CbAkVJ.js} +2 -2
- package/dist/chunks/{flex-C2jV5LyV.js.map → flex-C6CbAkVJ.js.map} +1 -1
- package/dist/chunks/floating-input-B9YAJ9d4.js +2 -0
- package/dist/chunks/floating-input-B9YAJ9d4.js.map +1 -0
- package/dist/chunks/{form-field-Bcx96ezd.js → form-field-D74QY_wP.js} +2 -2
- package/dist/chunks/{form-field-Bcx96ezd.js.map → form-field-D74QY_wP.js.map} +1 -1
- package/dist/chunks/grid-BCVkow3u.js +2 -0
- package/dist/chunks/grid-BCVkow3u.js.map +1 -0
- package/dist/chunks/{index-5qsV1-cc.d.ts → index--DV9l24Q.d.ts} +18 -14
- package/dist/chunks/{index-BAvt_oPe.d.ts → index-B2d_pjjy.d.ts} +6 -5
- package/dist/chunks/{index-CbcFEGCh.d.ts → index-BIWaMOr6.d.ts} +9 -2
- package/dist/chunks/{index-3JVLrDHv.d.ts → index-BMAdUGiM.d.ts} +7 -1
- package/dist/chunks/{index-Cpifcw5a.d.ts → index-BzYAMLX1.d.ts} +44 -4
- package/dist/chunks/{index-BbZzaApz.d.ts → index-C9RqZNjk.d.ts} +7 -1
- package/dist/chunks/{index-D0Dhs7YI.d.ts → index-CHtvpvUh.d.ts} +6 -1
- package/dist/chunks/{index-Bl-_sC4y.d.ts → index-CSmHNy8M.d.ts} +8 -2
- package/dist/chunks/{index-Davd7Cue.d.ts → index-CXzKYWtS.d.ts} +3 -2
- package/dist/chunks/{index-OnB4_h6x.d.ts → index-DV_JBDoF.d.ts} +2 -2
- package/dist/chunks/{index-Es9I0fIS.d.ts → index-DjmN2hBX.d.ts} +2 -2
- package/dist/chunks/{index-UjmJQRaG.d.ts → index-DyB9XXLJ.d.ts} +3 -3
- package/dist/chunks/{index-CSRGr7pU.d.ts → index-JCnEw-55.d.ts} +2 -6
- package/dist/chunks/{index-Ctf5hLue.d.ts → index-Me921MYl.d.ts} +15 -13
- package/dist/chunks/{index-C-IrFdKe.d.ts → index-OgWCTy2Y.d.ts} +2 -2
- package/dist/chunks/{index-BZpHSGlk.d.ts → index-bZRQGwY7.d.ts} +7 -2
- package/dist/chunks/{index-Cm3rPbI1.d.ts → index-qJGkO-ni.d.ts} +3 -3
- package/dist/chunks/{input-adorn-DV9tuWXh.js → input-adorn-D0E3Afdf.js} +2 -2
- package/dist/chunks/{input-adorn-DV9tuWXh.js.map → input-adorn-D0E3Afdf.js.map} +1 -1
- package/dist/chunks/{input-group-YB_zoKud.js → input-group-paIBtI1R.js} +2 -2
- package/dist/chunks/{input-group-YB_zoKud.js.map → input-group-paIBtI1R.js.map} +1 -1
- package/dist/chunks/{list-BPBZR66Y.js → list-Ch6vxaUs.js} +2 -2
- package/dist/chunks/{list-BPBZR66Y.js.map → list-Ch6vxaUs.js.map} +1 -1
- package/dist/chunks/menu-DTe27h5q.js +2 -0
- package/dist/chunks/{menu-Bqlhottl.js.map → menu-DTe27h5q.js.map} +1 -1
- package/dist/chunks/modal-BDQe7xyy.js +2 -0
- package/dist/chunks/modal-BDQe7xyy.js.map +1 -0
- package/dist/chunks/nativeFormReset-DgsRU9SA.js +2 -0
- package/dist/chunks/nativeFormReset-DgsRU9SA.js.map +1 -0
- package/dist/chunks/nav-DDI8Dv28.js +2 -0
- package/dist/chunks/nav-DDI8Dv28.js.map +1 -0
- package/dist/chunks/{nav-overflow-GWARvoQZ.js → nav-overflow-BxAhoMh3.js} +2 -2
- package/dist/chunks/{nav-overflow-GWARvoQZ.js.map → nav-overflow-BxAhoMh3.js.map} +1 -1
- package/dist/chunks/{navOverflow-C_QJmkPM.js → navOverflow-eSROB_mV.js} +2 -2
- package/dist/chunks/{navOverflow-C_QJmkPM.js.map → navOverflow-eSROB_mV.js.map} +1 -1
- package/dist/chunks/{navVariant-D4wiKS8I.js → navVariant-Bm5k8CY3.js} +2 -2
- package/dist/chunks/{navVariant-D4wiKS8I.js.map → navVariant-Bm5k8CY3.js.map} +1 -1
- package/dist/chunks/{navbar-C7dO0YRs.js → navbar-BYMKe2yW.js} +2 -2
- package/dist/chunks/{navbar-C7dO0YRs.js.map → navbar-BYMKe2yW.js.map} +1 -1
- package/dist/chunks/{notification-oIrUtDhl.js → notification-C1Sd4X7M.js} +2 -2
- package/dist/chunks/{notification-oIrUtDhl.js.map → notification-C1Sd4X7M.js.map} +1 -1
- package/dist/chunks/{number-field-ChPTSBwI.js → number-field-BIApgIlR.js} +2 -2
- package/dist/chunks/{number-field-ChPTSBwI.js.map → number-field-BIApgIlR.js.map} +1 -1
- package/dist/chunks/otp-input-CCkfFZID.js +2 -0
- package/dist/chunks/otp-input-CCkfFZID.js.map +1 -0
- package/dist/chunks/overlayPlacement-D2vfhhg3.js +2 -0
- package/dist/chunks/overlayPlacement-D2vfhhg3.js.map +1 -0
- package/dist/chunks/{pagination-Dvz8lccd.js → pagination-WINUPT_P.js} +2 -2
- package/dist/chunks/pagination-WINUPT_P.js.map +1 -0
- package/dist/chunks/placeholder-9rTlnMso.js +2 -0
- package/dist/chunks/{placeholder-SPoVRkKE.js.map → placeholder-9rTlnMso.js.map} +1 -1
- package/dist/chunks/polymorphic-mAKwlLiW.js +2 -0
- package/dist/chunks/{polymorphic-CZIFszAy.js.map → polymorphic-mAKwlLiW.js.map} +1 -1
- package/dist/chunks/popover-CrAJTevL.js +2 -0
- package/dist/chunks/popover-CrAJTevL.js.map +1 -0
- package/dist/chunks/{progress-CiSJDNwx.js → progress-CAqSu3jc.js} +2 -2
- package/dist/chunks/{progress-CiSJDNwx.js.map → progress-CAqSu3jc.js.map} +1 -1
- package/dist/chunks/{radio-C42F_5OD.js → radio-XlINMnQm.js} +2 -2
- package/dist/chunks/{radio-C42F_5OD.js.map → radio-XlINMnQm.js.map} +1 -1
- package/dist/chunks/range-input-tyImJHKI.js +2 -0
- package/dist/chunks/range-input-tyImJHKI.js.map +1 -0
- package/dist/chunks/{renderFormField-_6WswnEX.js → renderFormField-CaZ8-xrn.js} +2 -2
- package/dist/chunks/{renderFormField-_6WswnEX.js.map → renderFormField-CaZ8-xrn.js.map} +1 -1
- package/dist/chunks/{search-field-OFsb3t4L.js → search-field-CIYtMraB.js} +2 -2
- package/dist/chunks/{search-field-OFsb3t4L.js.map → search-field-CIYtMraB.js.map} +1 -1
- package/dist/chunks/select-CkucgA6H.js +2 -0
- package/dist/chunks/select-CkucgA6H.js.map +1 -0
- package/dist/chunks/{skeleton-B2blJGWj.js → skeleton-CXFwCjB9.js} +2 -2
- package/dist/chunks/{skeleton-B2blJGWj.js.map → skeleton-CXFwCjB9.js.map} +1 -1
- package/dist/chunks/slot-DagH0Gxq.js +2 -0
- package/dist/chunks/slot-DagH0Gxq.js.map +1 -0
- package/dist/chunks/{spinner-D8lQCW4u.js → spinner-BLQiCoQd.js} +2 -2
- package/dist/chunks/{spinner-D8lQCW4u.js.map → spinner-BLQiCoQd.js.map} +1 -1
- package/dist/chunks/{stack-DtzW54UK.js → stack-OItr30SC.js} +2 -2
- package/dist/chunks/{stack-DtzW54UK.js.map → stack-OItr30SC.js.map} +1 -1
- package/dist/chunks/{stepper-tSA84huJ.js → stepper-BLjW7UnC.js} +2 -2
- package/dist/chunks/{stepper-tSA84huJ.js.map → stepper-BLjW7UnC.js.map} +1 -1
- package/dist/chunks/switch-nt7aXQDX.js +2 -0
- package/dist/chunks/switch-nt7aXQDX.js.map +1 -0
- package/dist/chunks/table-KtPHx4FG.js +2 -0
- package/dist/chunks/table-KtPHx4FG.js.map +1 -0
- package/dist/chunks/{tabs-DMFSLjnV.js → tabs-Dh5kH5Ik.js} +2 -2
- package/dist/chunks/{tabs-DMFSLjnV.js.map → tabs-Dh5kH5Ik.js.map} +1 -1
- package/dist/chunks/{text-input-CR73x-8D.js → text-input-D3jBYiLn.js} +2 -2
- package/dist/chunks/{text-input-CR73x-8D.js.map → text-input-D3jBYiLn.js.map} +1 -1
- package/dist/chunks/{textarea-C-1cMyH4.js → textarea-2BJCzT97.js} +2 -2
- package/dist/chunks/{textarea-C-1cMyH4.js.map → textarea-2BJCzT97.js.map} +1 -1
- package/dist/chunks/{time-field-CbCfOQZz.js → time-field-ClPbatW3.js} +2 -2
- package/dist/chunks/{time-field-CbCfOQZz.js.map → time-field-ClPbatW3.js.map} +1 -1
- package/dist/chunks/toast-D5-58Ch1.js +2 -0
- package/dist/chunks/toast-D5-58Ch1.js.map +1 -0
- package/dist/chunks/tooltip-TGFFlOJL.js +2 -0
- package/dist/chunks/tooltip-TGFFlOJL.js.map +1 -0
- package/dist/chunks/tree-BO0WSxQa.js +2 -0
- package/dist/chunks/tree-BO0WSxQa.js.map +1 -0
- package/dist/chunks/useButtonSemantics-DN3OIXtG.js +2 -0
- package/dist/chunks/useButtonSemantics-DN3OIXtG.js.map +1 -0
- package/dist/chunks/{useDialogElement-BfygWBPZ.js → useDialogElement-yEgUSejP.js} +2 -2
- package/dist/chunks/useDialogElement-yEgUSejP.js.map +1 -0
- package/dist/chunks/{useFormField-DH2tlc3e.js → useFormField-q21MOgh8.js} +2 -2
- package/dist/chunks/{useFormField-DH2tlc3e.js.map → useFormField-q21MOgh8.js.map} +1 -1
- package/dist/chunks/useFormReset-BK5Yb24_.js +2 -0
- package/dist/chunks/useFormReset-BK5Yb24_.js.map +1 -0
- package/dist/chunks/useHeldBack-o-CsPcSe.js +2 -0
- package/dist/chunks/useHeldBack-o-CsPcSe.js.map +1 -0
- package/dist/chunks/{useOpenStateProps-BhjSQ3f6.js → useOpenStateProps-CdSO1nmI.js} +2 -2
- package/dist/chunks/{useOpenStateProps-BhjSQ3f6.js.map → useOpenStateProps-CdSO1nmI.js.map} +1 -1
- package/dist/chunks/useOverlayMaxHeight-5UnurH0W.js +2 -0
- package/dist/chunks/useOverlayMaxHeight-5UnurH0W.js.map +1 -0
- package/dist/chunks/{useRequiredValueInput-gYN8I-LY.js → useRequiredValueInput-CL7AIgqz.js} +2 -2
- package/dist/chunks/{useRequiredValueInput-gYN8I-LY.js.map → useRequiredValueInput-CL7AIgqz.js.map} +1 -1
- package/dist/chunks/useSelectionForMode-B_oTWvEy.js +2 -0
- package/dist/chunks/useSelectionForMode-B_oTWvEy.js.map +1 -0
- package/dist/chunks/useToastRegionQueue-QHa4v7k6.js +2 -0
- package/dist/chunks/useToastRegionQueue-QHa4v7k6.js.map +1 -0
- package/dist/chunks/useTransitionState-WEw9C0yn.js +2 -0
- package/dist/chunks/useTransitionState-WEw9C0yn.js.map +1 -0
- package/dist/chunks/{visibleState-CWyQak65.js → visibleState-DVyxSMUT.js} +2 -2
- package/dist/chunks/{visibleState-CWyQak65.js.map → visibleState-DVyxSMUT.js.map} +1 -1
- package/dist/close-button.js +1 -1
- package/dist/collapse.js +1 -1
- package/dist/color-input.d.ts +1 -1
- package/dist/color-input.js +1 -1
- package/dist/combobox.js +1 -1
- package/dist/context-menu.js +1 -1
- package/dist/datagrid.d.ts +1 -1
- package/dist/datagrid.js +1 -1
- package/dist/datepicker.js +1 -1
- package/dist/divider.js +1 -1
- package/dist/drawer.d.ts +1 -1
- package/dist/drawer.js +1 -1
- package/dist/file-input.d.ts +1 -1
- package/dist/file-input.js +1 -1
- package/dist/flex.js +1 -1
- package/dist/floating-input.d.ts +1 -1
- package/dist/floating-input.js +1 -1
- package/dist/form-field.js +1 -1
- package/dist/form.js +1 -1
- package/dist/grid.js +1 -1
- package/dist/index.d.ts +19 -19
- package/dist/index.js +1 -1
- package/dist/input-adorn.js +1 -1
- package/dist/input-group.js +1 -1
- package/dist/link.js +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.js +1 -1
- package/dist/modal.d.ts +1 -1
- package/dist/modal.js +1 -1
- package/dist/nav-overflow.js +1 -1
- package/dist/nav.d.ts +1 -1
- package/dist/nav.js +1 -1
- package/dist/navbar.js +1 -1
- package/dist/notification.js +1 -1
- package/dist/number-field.js +1 -1
- package/dist/otp-input.d.ts +1 -1
- package/dist/otp-input.js +1 -1
- package/dist/pagination.d.ts +1 -1
- package/dist/pagination.js +1 -1
- package/dist/placeholder.js +1 -1
- package/dist/popover.js +1 -1
- package/dist/progress.js +1 -1
- package/dist/radio.d.ts +1 -1
- package/dist/radio.js +1 -1
- package/dist/range-input.d.ts +1 -1
- package/dist/range-input.js +1 -1
- package/dist/search-field.js +1 -1
- package/dist/select.d.ts +1 -1
- package/dist/select.js +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/spinner.js +1 -1
- package/dist/stack.js +1 -1
- package/dist/stepper.js +1 -1
- package/dist/style.css +1 -1
- package/dist/switch.d.ts +1 -1
- package/dist/switch.js +1 -1
- package/dist/table.d.ts +1 -1
- package/dist/table.js +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-input.js +1 -1
- package/dist/textarea.js +1 -1
- package/dist/time-field.js +1 -1
- package/dist/toast.d.ts +1 -1
- package/dist/toast.js +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/tree.js +1 -1
- package/dist/visually-hidden.js +1 -1
- package/package.json +11 -11
- package/dist/chunks/Button-ZU-x1uN_.js +0 -2
- package/dist/chunks/Button-ZU-x1uN_.js.map +0 -1
- package/dist/chunks/CloseButton-BPUI5iGX.js +0 -2
- package/dist/chunks/CloseButton-BPUI5iGX.js.map +0 -1
- package/dist/chunks/Link-DE8NSAXJ.js +0 -2
- package/dist/chunks/Link-DE8NSAXJ.js.map +0 -1
- package/dist/chunks/Menu-BiE9CzNk.js +0 -2
- package/dist/chunks/Menu-BiE9CzNk.js.map +0 -1
- package/dist/chunks/MenuToggle-W-ZSHFwF.js +0 -2
- package/dist/chunks/MenuToggle-W-ZSHFwF.js.map +0 -1
- package/dist/chunks/alert-DSLg5MBb.js +0 -2
- package/dist/chunks/autocomplete-Btcsjrh3.js +0 -2
- package/dist/chunks/autocomplete-Btcsjrh3.js.map +0 -1
- package/dist/chunks/carousel-DC-UGc6W.js +0 -2
- package/dist/chunks/carousel-DC-UGc6W.js.map +0 -1
- package/dist/chunks/checkbox-ko6CdtoT.js +0 -2
- package/dist/chunks/checkbox-ko6CdtoT.js.map +0 -1
- package/dist/chunks/chip-input-CugY8EOc.js +0 -2
- package/dist/chunks/chip-input-CugY8EOc.js.map +0 -1
- package/dist/chunks/color-input-C4zMWlvm.js +0 -2
- package/dist/chunks/color-input-C4zMWlvm.js.map +0 -1
- package/dist/chunks/combobox-DNqR4d3V.js +0 -2
- package/dist/chunks/context-menu-D3DNFN-P.js +0 -2
- package/dist/chunks/context-menu-D3DNFN-P.js.map +0 -1
- package/dist/chunks/datagrid-n9vFeXN1.js +0 -2
- package/dist/chunks/datagrid-n9vFeXN1.js.map +0 -1
- package/dist/chunks/datepicker-DqztYJD6.js +0 -2
- package/dist/chunks/datepicker-DqztYJD6.js.map +0 -1
- package/dist/chunks/drawer-CRv9jmbp.js +0 -2
- package/dist/chunks/drawer-CRv9jmbp.js.map +0 -1
- package/dist/chunks/file-input-D_Gl1h-T.js +0 -2
- package/dist/chunks/file-input-D_Gl1h-T.js.map +0 -1
- package/dist/chunks/floating-input-D4gWFfOU.js +0 -2
- package/dist/chunks/floating-input-D4gWFfOU.js.map +0 -1
- package/dist/chunks/grid-CkdPftit.js +0 -2
- package/dist/chunks/grid-CkdPftit.js.map +0 -1
- package/dist/chunks/menu-Bqlhottl.js +0 -2
- package/dist/chunks/modal-CHvsDTyl.js +0 -2
- package/dist/chunks/modal-CHvsDTyl.js.map +0 -1
- package/dist/chunks/nav-B4U_Hqs7.js +0 -2
- package/dist/chunks/nav-B4U_Hqs7.js.map +0 -1
- package/dist/chunks/otp-input-DUtCMg8P.js +0 -2
- package/dist/chunks/otp-input-DUtCMg8P.js.map +0 -1
- package/dist/chunks/overlayPlacement-Q6bcbXA5.js +0 -2
- package/dist/chunks/overlayPlacement-Q6bcbXA5.js.map +0 -1
- package/dist/chunks/pagination-Dvz8lccd.js.map +0 -1
- package/dist/chunks/placeholder-SPoVRkKE.js +0 -2
- package/dist/chunks/polymorphic-CZIFszAy.js +0 -2
- package/dist/chunks/popover-C_32yD9W.js +0 -2
- package/dist/chunks/popover-C_32yD9W.js.map +0 -1
- package/dist/chunks/range-input-DeZq_9S7.js +0 -2
- package/dist/chunks/range-input-DeZq_9S7.js.map +0 -1
- package/dist/chunks/select-DwyL6aqY.js +0 -2
- package/dist/chunks/select-DwyL6aqY.js.map +0 -1
- package/dist/chunks/slot-BQVx1Eew.js +0 -2
- package/dist/chunks/slot-BQVx1Eew.js.map +0 -1
- package/dist/chunks/switch-cp3IZg3L.js +0 -2
- package/dist/chunks/switch-cp3IZg3L.js.map +0 -1
- package/dist/chunks/table-CBTg5Yuq.js +0 -2
- package/dist/chunks/table-CBTg5Yuq.js.map +0 -1
- package/dist/chunks/toast-Dd0J2e1z.js +0 -2
- package/dist/chunks/toast-Dd0J2e1z.js.map +0 -1
- package/dist/chunks/tooltip-CmKeQwYw.js +0 -2
- package/dist/chunks/tooltip-CmKeQwYw.js.map +0 -1
- package/dist/chunks/tree-DNj_EfUl.js +0 -2
- package/dist/chunks/tree-DNj_EfUl.js.map +0 -1
- package/dist/chunks/useButtonSemantics-B1SbGaDO.js +0 -2
- package/dist/chunks/useButtonSemantics-B1SbGaDO.js.map +0 -1
- package/dist/chunks/useDialogElement-BfygWBPZ.js.map +0 -1
- package/dist/chunks/useDialogTitle-DiB4YDGI.js +0 -2
- package/dist/chunks/useDialogTitle-DiB4YDGI.js.map +0 -1
- package/dist/chunks/useFloatingOverlay-BuiI_CCn.js +0 -2
- package/dist/chunks/useFloatingOverlay-BuiI_CCn.js.map +0 -1
- package/dist/chunks/useHeldBack-eeTfpa_t.js +0 -2
- package/dist/chunks/useHeldBack-eeTfpa_t.js.map +0 -1
- package/dist/chunks/useOverlayMaxHeight-DTgbr4UQ.js +0 -2
- package/dist/chunks/useOverlayMaxHeight-DTgbr4UQ.js.map +0 -1
- package/dist/chunks/useToastRegionQueue-CuAMxAIA.js +0 -2
- package/dist/chunks/useToastRegionQueue-CuAMxAIA.js.map +0 -1
- package/dist/chunks/useTransitionState-sQUQey74.js +0 -2
- package/dist/chunks/useTransitionState-sQUQey74.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./polymorphic-mAKwlLiW.js";import{i as t,r as n}from"./overlayPlacement-D2vfhhg3.js";import{t as r}from"./useOverlayMaxHeight-5UnurH0W.js";import{t as i}from"./Portal-BTDylxAi.js";import{i as a,n as o}from"./Menu-DBN4Mxak.js";import{a as s,c,i as l,l as ee,o as te,r as u,s as ne}from"./MenuToggle-DHzKm1Ed.js";import d,{forwardRef as f,useCallback as p,useContext as m,useEffect as h,useId as re,useRef as g,useState as ie}from"react";import _ from"classnames";import{useLocale as v,useOverlayPosition as ae}from"react-aria";function y({children:e,className:t,component:n,...r},i){let a=n??`span`,o=_(`menu-text`,t);return/* @__PURE__ */ d.createElement(a,{className:o,...r,ref:i},e)}const b=e(y,`MenuText`),x=f(({children:e,activation:f=`both`,className:y,disabled:b,offset:x=[-4,0],placement:S,stacked:C,submenuDelay:w=100,trigger:T,...E},oe)=>{let D=re(),O=`${D}-trigger`,k=`${D}-menu`,[A,j]=ie(!1),M=g(void 0),N=g(void 0),P=g(!1),F=g(null),I=g(null),L=m(l),se=te(),{portalContainer:ce,registerOverlay:le,visible:R}=m(o),z=m(s),{direction:B}=v(),V=B===`rtl`,H=S??(V?`left-start`:`right-start`),{overlayProps:U,placement:ue}=ae({targetRef:F,overlayRef:I,placement:t(H),offset:x[1],crossOffset:x[0],containerPadding:8,isOpen:A,onClose:null});r(I,A);let{menuStyle:de,placementAttr:fe}=n(U.style,H,ue),W=p(()=>{M.current!==void 0&&(window.clearTimeout(M.current),M.current=void 0)},[]),G=p(()=>{N.current!==void 0&&(cancelAnimationFrame(N.current),N.current=void 0)},[]),K=p(()=>{W(),G(),j(!1)},[W,G]),q=()=>{b||A||(W(),L?.notifyOpen(D),j(!0))},J=()=>{W(),M.current=window.setTimeout(K,w)};h(()=>L?.register(D,K),[L,D,K]),h(()=>W,[W]),h(()=>G,[G]),h(()=>{(!R||!z)&&K()},[R,z,K]);let Y=typeof window<`u`&&!!window.matchMedia&&window.matchMedia(`(hover: hover)`).matches,X=Y&&(f===`hover`||f===`both`),Z=f!==`hover`||!Y,Q=()=>{q(),G(),N.current=requestAnimationFrame(()=>{N.current=void 0,ne(c(I.current),`first`)})},$=()=>{P.current=!0,K()};h(()=>{!A&&P.current&&F.current?.focus(),P.current=!1},[A]);let pe=e=>{e.preventDefault(),a.add(e.nativeEvent),Z&&!b&&(A?K():Q())},me=V?`ArrowLeft`:`ArrowRight`,he=e=>{b||(e.key===`Enter`||e.key===` `||e.key===me)&&(e.preventDefault(),e.stopPropagation(),Q())},ge={close:$};return/* @__PURE__ */ d.createElement(`div`,{className:_(`submenu`,{show:A},y),...E,ref:oe},/* @__PURE__ */ d.createElement(`button`,{type:`button`,id:O,role:`menuitem`,className:`menu-item`,"aria-expanded":A,"aria-haspopup":`true`,"aria-controls":A?k:void 0,disabled:b,onClick:pe,onKeyDown:he,onMouseEnter:X?q:void 0,onMouseLeave:X?J:void 0,ref:e=>{F.current=e}},T),(()=>{let t=/* @__PURE__ */ d.createElement(`div`,{role:`menu`,id:k,"aria-labelledby":O,className:_(`menu`,{show:A,"submenu-stacked":C}),style:de,"data-cx-placement":fe,onKeyDown:e=>ee(e,{onEscape:$,...V?{onArrowRight:$}:{onArrowLeft:$}}),onMouseEnter:X?W:void 0,onMouseLeave:X?J:void 0,ref:e=>{I.current=e,le(k,e)}},/* @__PURE__ */ d.createElement(u.Provider,{value:ge},/* @__PURE__ */ d.createElement(l.Provider,{value:se},/* @__PURE__ */ d.createElement(s.Provider,{value:A},e))));return C?t:/* @__PURE__ */ d.createElement(i,{container:ce,fallback:t},t)})())});x.displayName=`MenuSubmenu`;const S=f(({children:e,className:t,onClick:n,type:r=`button`,...i},o)=>{let s=m(u),c=e=>{n?.(e),s&&(a.add(e.nativeEvent),s.close())};return/* @__PURE__ */ d.createElement(`button`,{type:r,role:`menuitem`,className:_(`submenu-back`,`menu-item`,t),...i,onClick:c,ref:o},e)});S.displayName=`MenuSubmenuBack`;export{x as n,b as r,S as t};
|
|
2
|
+
//# sourceMappingURL=menu-DTe27h5q.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"menu-Bqlhottl.js","names":["createPolymorphicComponent","toAriaPlacement","Portal","MenuContext","menuToggleClicks","SubmenuVisibleContext","getMenuItems","SubmenuGroupContext","handleMenuKeyDown","useSubmenuGroupProvider","SubmenuActionsContext","focusMenuItem","React","classNames","MenuTextRender","rest","Component","component","_className","className","children","MenuText","MenuSubmenu","forwardRef","offsetProp","id","useId","triggerId","menuId","visible","setVisible","useState","closeTimeoutRef","useRef","focusFirstRafRef","refocusTriggerRef","triggerRef","overlayRef","parentGroup","useContext","ownGroup","parentMenuVisible","parentSubmenuVisible","useLocale","isRtl","direction","effectivePlacement","placement","resolvedPlacement","useOverlayPosition","useOverlayMaxHeight","resolveMenuOverlayPositioning","overlayProps","clearCloseTimeout","useCallback","cancelFocusFirstRaf","close","open","disabled","scheduleClose","submenuDelay","useEffect","supportsHover","hoverEnabled","activation","clickEnabled","openAndFocusFirst","closeAndRefocusTrigger","handleTriggerClick","event","openKey","handleTriggerKeyDown","actionsValue","node","trigger","panel","stacked","menuStyle","placementAttr","registerOverlay","portalContainer","MenuSubmenuBack","actions","handleClick","onClick"],"sources":["../../src/components/menu/MenuText.tsx","../../src/components/menu/MenuSubmenu.tsx","../../src/components/menu/MenuSubmenuBack.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype MenuTextOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type MenuTextProps<C extends ElementType = 'span'> = PolymorphicComponentProps<\n C,\n MenuTextOwnProps<C>\n>\n\ntype MenuTextComponent = (<C extends ElementType = 'span'>(\n props: MenuTextProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction MenuTextRender<C extends ElementType = 'span'>(\n { children, className, component, ...rest }: MenuTextProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'span'\n const _className = classNames('menu-text', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const MenuText = createPolymorphicComponent<MenuTextComponent>(\n MenuTextRender as ForwardRefRenderFunction<Element, MenuTextProps<ElementType>>,\n 'MenuText'\n)\n","import React, {\n forwardRef,\n HTMLAttributes,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useRef,\n useState\n} from 'react'\nimport classNames from 'classnames'\nimport { useLocale, useOverlayPosition } from 'react-aria'\n\nimport { useOverlayMaxHeight } from '../../hooks/useOverlayMaxHeight'\nimport { MenuContext, menuToggleClicks } from './Menu'\nimport {\n Placement,\n resolveMenuOverlayPositioning,\n toAriaPlacement\n} from '../../utils/overlayPlacement'\nimport { Portal } from '../portal/Portal'\nimport { focusMenuItem, getMenuItems, handleMenuKeyDown } from './menuNavigation'\nimport {\n SubmenuActionsContext,\n SubmenuGroupContext,\n SubmenuVisibleContext,\n useSubmenuGroupProvider\n} from './submenuGroup'\n\nexport interface MenuSubmenuProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n /**\n * MenuSubmenu activation mode on hover-capable devices. `'click'` activates on click only.\n * `'hover'` activates on hover only. `'both'` (the default) activates on both. Touch\n * devices always use tap regardless of this setting.\n */\n activation?: 'click' | 'hover' | 'both'\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Prevents the submenu from opening.\n */\n disabled?: boolean\n /**\n * Distance between the nested menu and the trigger, as `[skidding, distance]` in pixels.\n */\n offset?: [number, number]\n /**\n * Placement of the nested menu relative to the trigger. Defaults to cascading in the reading\n * direction — `'right-start'` under LTR locales, `'left-start'` under RTL ones (see\n * `useLocale`) — matching native OS/browser submenu behavior. An explicit value always wins\n * over that locale-based default.\n */\n placement?: Placement\n /**\n * Switches to a view-replacement pattern below the `sm` breakpoint. Pair with a\n * `MenuSubmenuBack` as the first item of the nested menu.\n */\n stacked?: boolean\n /**\n * Milliseconds before closing the submenu when the pointer leaves it.\n */\n submenuDelay?: number\n /**\n * Content of the `.menu-item` trigger that opens the submenu.\n */\n trigger: ReactNode\n}\n\nexport const MenuSubmenu = forwardRef<HTMLDivElement, MenuSubmenuProps>(\n (\n {\n children,\n activation = 'both',\n className,\n disabled,\n offset: offsetProp = [-4, 0],\n placement,\n stacked,\n submenuDelay = 100,\n trigger,\n ...rest\n },\n ref\n ) => {\n const id = useId()\n const triggerId = `${id}-trigger`\n const menuId = `${id}-menu`\n const [visible, setVisible] = useState(false)\n const closeTimeoutRef = useRef<number | undefined>(undefined)\n const focusFirstRafRef = useRef<number | undefined>(undefined)\n const refocusTriggerRef = useRef(false)\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n const overlayRef = useRef<HTMLElement | null>(null)\n const parentGroup = useContext(SubmenuGroupContext)\n const ownGroup = useSubmenuGroupProvider()\n const { portalContainer, registerOverlay, visible: parentMenuVisible } = useContext(MenuContext)\n const parentSubmenuVisible = useContext(SubmenuVisibleContext)\n const { direction } = useLocale()\n const isRtl = direction === 'rtl'\n const effectivePlacement = placement ?? (isRtl ? 'left-start' : 'right-start')\n\n const { overlayProps, placement: resolvedPlacement } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef,\n // Viewport-relative (matching the portal below): the trigger lives inside the parent\n // menu's own floated panel, and `useOverlayPosition` measures against the overlay's real\n // containing block — since the panel portals straight to `document.body`, that resolves\n // the same way a `fixed`-strategy engine would.\n placement: toAriaPlacement(effectivePlacement),\n offset: offsetProp[1],\n crossOffset: offsetProp[0],\n containerPadding: 8,\n isOpen: visible,\n // See `useOverlayPlacement`'s comment for why this needs to be explicit `null`, not left\n // unset — matches the same fix already applied to `Autocomplete`/`Combobox`/`Menu`/`Popover`.\n onClose: null\n })\n useOverlayMaxHeight(overlayRef, visible)\n\n const { menuStyle, placementAttr } = resolveMenuOverlayPositioning(\n overlayProps.style,\n effectivePlacement,\n resolvedPlacement\n )\n\n const clearCloseTimeout = useCallback(() => {\n if (closeTimeoutRef.current !== undefined) {\n window.clearTimeout(closeTimeoutRef.current)\n closeTimeoutRef.current = undefined\n }\n }, [])\n\n const cancelFocusFirstRaf = useCallback(() => {\n if (focusFirstRafRef.current !== undefined) {\n cancelAnimationFrame(focusFirstRafRef.current)\n focusFirstRafRef.current = undefined\n }\n }, [])\n\n const close = useCallback(() => {\n clearCloseTimeout()\n cancelFocusFirstRaf()\n setVisible(false)\n }, [clearCloseTimeout, cancelFocusFirstRaf])\n\n const open = () => {\n if (disabled || visible) return\n clearCloseTimeout()\n parentGroup?.notifyOpen(id)\n setVisible(true)\n }\n\n const scheduleClose = () => {\n clearCloseTimeout()\n closeTimeoutRef.current = window.setTimeout(close, submenuDelay)\n }\n\n useEffect(() => parentGroup?.register(id, close), [parentGroup, id, close])\n useEffect(() => clearCloseTimeout, [clearCloseTimeout])\n useEffect(() => cancelFocusFirstRaf, [cancelFocusFirstRaf])\n\n // The submenu's own open state is local and doesn't otherwise hear about its ancestor\n // `Menu` closing (via Escape, outside click, etc.), or about the submenu it is nested in\n // closing (the pointer leaving it, a sibling opening, ArrowLeft) — without this it's left\n // open and fully visible (it's portaled to `document.body`, so nothing hides it for free)\n // even after the menu or the submenu it belongs to has disappeared.\n useEffect(() => {\n if (!parentMenuVisible || !parentSubmenuVisible) close()\n }, [parentMenuVisible, parentSubmenuVisible, close])\n\n const supportsHover =\n typeof window !== 'undefined' &&\n !!window.matchMedia &&\n window.matchMedia('(hover: hover)').matches\n const hoverEnabled = supportsHover && (activation === 'hover' || activation === 'both')\n // A device without hover takes a tap whatever `activation` says, as the prop promises:\n // `'hover'` left nothing to open the submenu with there.\n const clickEnabled = activation !== 'hover' || !supportsHover\n\n const openAndFocusFirst = () => {\n open()\n cancelFocusFirstRaf()\n focusFirstRafRef.current = requestAnimationFrame(() => {\n focusFirstRafRef.current = undefined\n focusMenuItem(getMenuItems(overlayRef.current), 'first')\n })\n }\n\n // Focus returns to the trigger once the close has rendered, in the effect below, not here:\n // below the `sm` breakpoint a shown `stacked` panel hides its trigger (chassis-css's\n // `.submenu:has(.submenu-stacked.show)` rule), and focusing a hidden element leaves focus on\n // `document.body`.\n const closeAndRefocusTrigger = () => {\n refocusTriggerRef.current = true\n close()\n }\n\n useEffect(() => {\n if (!visible && refocusTriggerRef.current) triggerRef.current?.focus()\n refocusTriggerRef.current = false\n }, [visible])\n\n // Marked as a toggle's click even when it doesn't toggle the submenu (`activation=\"hover\"`):\n // the trigger is in the menu's list, and the menu's listener on `window` took the click for\n // an item's and closed the whole menu.\n const handleTriggerClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault()\n menuToggleClicks.add(event.nativeEvent)\n if (!clickEnabled || disabled) return\n visible ? close() : openAndFocusFirst()\n }\n\n // A submenu cascades toward the reading direction, so the arrow key that opens it (and the\n // one its own item list closes on, below) mirror too: ArrowRight/ArrowLeft under LTR,\n // ArrowLeft/ArrowRight under RTL.\n const openKey = isRtl ? 'ArrowLeft' : 'ArrowRight'\n\n const handleTriggerKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) return\n if (event.key === 'Enter' || event.key === ' ' || event.key === openKey) {\n event.preventDefault()\n event.stopPropagation()\n openAndFocusFirst()\n }\n }\n\n const actionsValue = { close: closeAndRefocusTrigger }\n\n return (\n <div className={classNames('submenu', { show: visible }, className)} {...rest} ref={ref}>\n <button\n type=\"button\"\n id={triggerId}\n role=\"menuitem\"\n className=\"menu-item\"\n aria-expanded={visible}\n aria-haspopup=\"true\"\n aria-controls={visible ? menuId : undefined}\n disabled={disabled}\n onClick={handleTriggerClick}\n onKeyDown={handleTriggerKeyDown}\n onMouseEnter={hoverEnabled ? open : undefined}\n onMouseLeave={hoverEnabled ? scheduleClose : undefined}\n ref={(node) => {\n triggerRef.current = node\n }}\n >\n {trigger}\n </button>\n {(() => {\n const panel = (\n <div\n role=\"menu\"\n id={menuId}\n aria-labelledby={triggerId}\n className={classNames('menu', { show: visible, 'submenu-stacked': stacked })}\n style={menuStyle}\n data-cx-placement={placementAttr}\n onKeyDown={(event) =>\n handleMenuKeyDown(event, {\n onEscape: closeAndRefocusTrigger,\n ...(isRtl\n ? { onArrowRight: closeAndRefocusTrigger }\n : { onArrowLeft: closeAndRefocusTrigger })\n })\n }\n onMouseEnter={hoverEnabled ? clearCloseTimeout : undefined}\n onMouseLeave={hoverEnabled ? scheduleClose : undefined}\n // Registers this panel with the ancestor `Menu` (see `MenuContext.registerOverlay`)\n // so its own click-dismiss logic recognizes clicks here as \"inside\" the menu — the\n // panel portals straight to `document.body` when not `stacked`, so plain DOM\n // containment against the top-level menu's own element wouldn't otherwise see it.\n ref={(node) => {\n overlayRef.current = node\n registerOverlay(menuId, node)\n }}\n >\n <SubmenuActionsContext.Provider value={actionsValue}>\n <SubmenuGroupContext.Provider value={ownGroup}>\n <SubmenuVisibleContext.Provider value={visible}>\n {children}\n </SubmenuVisibleContext.Provider>\n </SubmenuGroupContext.Provider>\n </SubmenuActionsContext.Provider>\n </div>\n )\n\n // `stacked`'s sm-breakpoint CSS (`.menu:has(.submenu-stacked.show) ...`) needs the\n // panel to be a real DOM descendant of `.menu`/`.submenu` to match — portaling would\n // break that ancestor relationship, so it renders inline instead. Trade-off: above the\n // `sm` breakpoint a `stacked` submenu no longer escapes ancestor overflow/stacking-\n // context clipping the way a portaled one does; accepted since `stacked` targets mobile\n // nav/drawer usage, not floating dropdowns.\n // On the server and during hydration the panel renders inline next to its trigger, which\n // is what the server's HTML holds; `Portal` moves it to `document.body` afterwards, or\n // to the open dialog the menu is in: under a modal dialog's top layer the panel would be\n // behind the backdrop, and inert.\n return stacked ? (\n panel\n ) : (\n <Portal container={portalContainer} fallback={panel}>\n {panel}\n </Portal>\n )\n })()}\n </div>\n )\n }\n)\n\nMenuSubmenu.displayName = 'MenuSubmenu'\n","import React, { ButtonHTMLAttributes, forwardRef, useContext } from 'react'\nimport classNames from 'classnames'\n\nimport { SubmenuActionsContext } from './submenuGroup'\n\nexport interface MenuSubmenuBackProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n}\n\n// First item of a stacked submenu's nested menu (see `MenuSubmenu`'s `stacked` prop). Closes\n// the submenu and returns focus to its trigger — visible only below the `sm` breakpoint.\nexport const MenuSubmenuBack = forwardRef<HTMLButtonElement, MenuSubmenuBackProps>(\n ({ children, className, onClick, type = 'button', ...rest }, ref) => {\n const actions = useContext(SubmenuActionsContext)\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (!actions) return\n // Going back is the submenu's own action, as opening it from its trigger is: the click\n // stops here. On `window`, the `autoClose` listener of `Menu` and `ContextMenu` would read\n // it as a click on an item and close the whole menu.\n event.stopPropagation()\n actions.close()\n }\n\n return (\n <button\n type={type}\n role=\"menuitem\"\n className={classNames('submenu-back', 'menu-item', className)}\n {...rest}\n onClick={handleClick}\n ref={ref}\n >\n {children}\n </button>\n )\n }\n)\n\nMenuSubmenuBack.displayName = 'MenuSubmenuBack'\n"],"mappings":"A,6jBA6BA,SAASc,EACP,CAAE,WAAU,YAAW,YAAW,GAAGC,GACrC,EACA,CACA,IAAMC,EAAYC,GAAa,OACzBC,EAAaL,EAAW,YAAaM,CAAS,EAEpD,MACE,kBAAA,cAACH,EAAD,CAAW,UAAWE,EAAY,GAAIH,EAAW,KAEtC,EADRK,CACQ,CAEf,CAEA,MAAaC,EAAWrB,EACtBc,EACA,UACF,ECyBaQ,EAAcC,GAEvB,CACE,WACA,aAAa,OACb,YACA,WACA,OAAQC,EAAa,CAAC,GAAI,CAAC,EAC3B,YACA,UACA,eAAe,IACf,UACA,GAAGT,GAEL,KACG,CACH,IAAMU,EAAKC,GAAM,EACXC,EAAY,GAAGF,EAAG,UAClBG,EAAS,GAAGH,EAAG,OACf,CAACI,EAASC,GAAcC,GAAS,EAAK,EACtCC,EAAkBC,EAA2B,IAAA,EAAS,EACtDC,EAAmBD,EAA2B,IAAA,EAAS,EACvDE,EAAoBF,EAAO,EAAK,EAChCG,EAAaH,EAAiC,IAAI,EAClDI,EAAaJ,EAA2B,IAAI,EAC5CK,E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UAAWrE,EAAW,eAAgB,YAAaM,CAAS,EAC5D,GAAIJ,EACJ,QAASoE,EACJ,KAGC,EADL/D,CACK,CAEZ,CACF,EAEA,EAAgB,YAAc,kB"}
|
|
1
|
+
{"version":3,"file":"menu-DTe27h5q.js","names":["createPolymorphicComponent","toAriaPlacement","resolveMenuOverlayPositioning","useOverlayMaxHeight","Portal","menuToggleClicks","MenuContext","SubmenuVisibleContext","SubmenuGroupContext","handleMenuKeyDown","useSubmenuGroupProvider","SubmenuActionsContext","focusMenuItem","React","classNames","MenuTextRender","rest","Component","component","_className","className","children","MenuText","MenuSubmenu","forwardRef","offsetProp","id","useId","triggerId","menuId","visible","setVisible","useState","closeTimeoutRef","useRef","focusFirstRafRef","refocusTriggerRef","triggerRef","overlayRef","parentGroup","useContext","ownGroup","parentMenuVisible","parentSubmenuVisible","useLocale","isRtl","direction","effectivePlacement","placement","resolvedPlacement","useOverlayPosition","overlayProps","clearCloseTimeout","useCallback","cancelFocusFirstRaf","close","open","disabled","scheduleClose","submenuDelay","useEffect","supportsHover","hoverEnabled","activation","clickEnabled","openAndFocusFirst","getMenuItems","closeAndRefocusTrigger","handleTriggerClick","event","openKey","handleTriggerKeyDown","actionsValue","node","trigger","panel","stacked","menuStyle","placementAttr","registerOverlay","portalContainer","MenuSubmenuBack","actions","handleClick","onClick"],"sources":["../../src/components/menu/MenuText.tsx","../../src/components/menu/MenuSubmenu.tsx","../../src/components/menu/MenuSubmenuBack.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype MenuTextOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type MenuTextProps<C extends ElementType = 'span'> = PolymorphicComponentProps<\n C,\n MenuTextOwnProps<C>\n>\n\ntype MenuTextComponent = (<C extends ElementType = 'span'>(\n props: MenuTextProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction MenuTextRender<C extends ElementType = 'span'>(\n { children, className, component, ...rest }: MenuTextProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'span'\n const _className = classNames('menu-text', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const MenuText = createPolymorphicComponent<MenuTextComponent>(\n MenuTextRender as ForwardRefRenderFunction<Element, MenuTextProps<ElementType>>,\n 'MenuText'\n)\n","import React, {\n forwardRef,\n HTMLAttributes,\n ReactNode,\n useCallback,\n useContext,\n useEffect,\n useId,\n useRef,\n useState\n} from 'react'\nimport classNames from 'classnames'\nimport { useLocale, useOverlayPosition } from 'react-aria'\n\nimport { useOverlayMaxHeight } from '../../hooks/useOverlayMaxHeight'\nimport { MenuContext, menuToggleClicks } from './Menu'\nimport {\n Placement,\n resolveMenuOverlayPositioning,\n toAriaPlacement\n} from '../../utils/overlayPlacement'\nimport { Portal } from '../portal/Portal'\nimport { focusMenuItem, getMenuItems, handleMenuKeyDown } from './menuNavigation'\nimport {\n SubmenuActionsContext,\n SubmenuGroupContext,\n SubmenuVisibleContext,\n useSubmenuGroupProvider\n} from './submenuGroup'\n\nexport interface MenuSubmenuProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onSelect'> {\n /**\n * MenuSubmenu activation mode on hover-capable devices. `'click'` activates on click only.\n * `'hover'` activates on hover only. `'both'` (the default) activates on both. Touch\n * devices always use tap regardless of this setting.\n */\n activation?: 'click' | 'hover' | 'both'\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Prevents the submenu from opening.\n */\n disabled?: boolean\n /**\n * Distance between the nested menu and the trigger, as `[skidding, distance]` in pixels.\n */\n offset?: [number, number]\n /**\n * Placement of the nested menu relative to the trigger. Defaults to cascading in the reading\n * direction — `'right-start'` under LTR locales, `'left-start'` under RTL ones (see\n * `useLocale`) — matching native OS/browser submenu behavior. An explicit value always wins\n * over that locale-based default.\n */\n placement?: Placement\n /**\n * Switches to a view-replacement pattern below the `sm` breakpoint. Pair with a\n * `MenuSubmenuBack` as the first item of the nested menu.\n */\n stacked?: boolean\n /**\n * Milliseconds before closing the submenu when the pointer leaves it.\n */\n submenuDelay?: number\n /**\n * Content of the `.menu-item` trigger that opens the submenu.\n */\n trigger: ReactNode\n}\n\nexport const MenuSubmenu = forwardRef<HTMLDivElement, MenuSubmenuProps>(\n (\n {\n children,\n activation = 'both',\n className,\n disabled,\n offset: offsetProp = [-4, 0],\n placement,\n stacked,\n submenuDelay = 100,\n trigger,\n ...rest\n },\n ref\n ) => {\n const id = useId()\n const triggerId = `${id}-trigger`\n const menuId = `${id}-menu`\n const [visible, setVisible] = useState(false)\n const closeTimeoutRef = useRef<number | undefined>(undefined)\n const focusFirstRafRef = useRef<number | undefined>(undefined)\n const refocusTriggerRef = useRef(false)\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n const overlayRef = useRef<HTMLElement | null>(null)\n const parentGroup = useContext(SubmenuGroupContext)\n const ownGroup = useSubmenuGroupProvider()\n const { portalContainer, registerOverlay, visible: parentMenuVisible } = useContext(MenuContext)\n const parentSubmenuVisible = useContext(SubmenuVisibleContext)\n const { direction } = useLocale()\n const isRtl = direction === 'rtl'\n const effectivePlacement = placement ?? (isRtl ? 'left-start' : 'right-start')\n\n const { overlayProps, placement: resolvedPlacement } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef,\n // Viewport-relative (matching the portal below): the trigger lives inside the parent\n // menu's own floated panel, and `useOverlayPosition` measures against the overlay's real\n // containing block — since the panel portals straight to `document.body`, that resolves\n // the same way a `fixed`-strategy engine would.\n placement: toAriaPlacement(effectivePlacement),\n offset: offsetProp[1],\n crossOffset: offsetProp[0],\n containerPadding: 8,\n isOpen: visible,\n // See `useOverlayPlacement`'s comment for why this needs to be explicit `null`, not left\n // unset — matches the same fix already applied to `Autocomplete`/`Combobox`/`Menu`/`Popover`.\n onClose: null\n })\n useOverlayMaxHeight(overlayRef, visible)\n\n const { menuStyle, placementAttr } = resolveMenuOverlayPositioning(\n overlayProps.style,\n effectivePlacement,\n resolvedPlacement\n )\n\n const clearCloseTimeout = useCallback(() => {\n if (closeTimeoutRef.current !== undefined) {\n window.clearTimeout(closeTimeoutRef.current)\n closeTimeoutRef.current = undefined\n }\n }, [])\n\n const cancelFocusFirstRaf = useCallback(() => {\n if (focusFirstRafRef.current !== undefined) {\n cancelAnimationFrame(focusFirstRafRef.current)\n focusFirstRafRef.current = undefined\n }\n }, [])\n\n const close = useCallback(() => {\n clearCloseTimeout()\n cancelFocusFirstRaf()\n setVisible(false)\n }, [clearCloseTimeout, cancelFocusFirstRaf])\n\n const open = () => {\n if (disabled || visible) return\n clearCloseTimeout()\n parentGroup?.notifyOpen(id)\n setVisible(true)\n }\n\n const scheduleClose = () => {\n clearCloseTimeout()\n closeTimeoutRef.current = window.setTimeout(close, submenuDelay)\n }\n\n useEffect(() => parentGroup?.register(id, close), [parentGroup, id, close])\n useEffect(() => clearCloseTimeout, [clearCloseTimeout])\n useEffect(() => cancelFocusFirstRaf, [cancelFocusFirstRaf])\n\n // The submenu's own open state is local and doesn't otherwise hear about its ancestor\n // `Menu` closing (via Escape, outside click, etc.), or about the submenu it is nested in\n // closing (the pointer leaving it, a sibling opening, ArrowLeft) — without this it's left\n // open and fully visible (it's portaled to `document.body`, so nothing hides it for free)\n // even after the menu or the submenu it belongs to has disappeared.\n useEffect(() => {\n if (!parentMenuVisible || !parentSubmenuVisible) close()\n }, [parentMenuVisible, parentSubmenuVisible, close])\n\n const supportsHover =\n typeof window !== 'undefined' &&\n !!window.matchMedia &&\n window.matchMedia('(hover: hover)').matches\n const hoverEnabled = supportsHover && (activation === 'hover' || activation === 'both')\n // A device without hover takes a tap whatever `activation` says, as the prop promises:\n // `'hover'` left nothing to open the submenu with there.\n const clickEnabled = activation !== 'hover' || !supportsHover\n\n const openAndFocusFirst = () => {\n open()\n cancelFocusFirstRaf()\n focusFirstRafRef.current = requestAnimationFrame(() => {\n focusFirstRafRef.current = undefined\n focusMenuItem(getMenuItems(overlayRef.current), 'first')\n })\n }\n\n // Focus returns to the trigger once the close has rendered, in the effect below, not here:\n // below the `sm` breakpoint a shown `stacked` panel hides its trigger (chassis-css's\n // `.submenu:has(.submenu-stacked.show)` rule), and focusing a hidden element leaves focus on\n // `document.body`.\n const closeAndRefocusTrigger = () => {\n refocusTriggerRef.current = true\n close()\n }\n\n useEffect(() => {\n if (!visible && refocusTriggerRef.current) triggerRef.current?.focus()\n refocusTriggerRef.current = false\n }, [visible])\n\n // Marked as a toggle's click even when it doesn't toggle the submenu (`activation=\"hover\"`):\n // the trigger is in the menu's list, and the menu's listener on `window` took the click for\n // an item's and closed the whole menu.\n const handleTriggerClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n event.preventDefault()\n menuToggleClicks.add(event.nativeEvent)\n if (!clickEnabled || disabled) return\n visible ? close() : openAndFocusFirst()\n }\n\n // A submenu cascades toward the reading direction, so the arrow key that opens it (and the\n // one its own item list closes on, below) mirror too: ArrowRight/ArrowLeft under LTR,\n // ArrowLeft/ArrowRight under RTL.\n const openKey = isRtl ? 'ArrowLeft' : 'ArrowRight'\n\n const handleTriggerKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n if (disabled) return\n if (event.key === 'Enter' || event.key === ' ' || event.key === openKey) {\n event.preventDefault()\n event.stopPropagation()\n openAndFocusFirst()\n }\n }\n\n const actionsValue = { close: closeAndRefocusTrigger }\n\n return (\n <div className={classNames('submenu', { show: visible }, className)} {...rest} ref={ref}>\n <button\n type=\"button\"\n id={triggerId}\n role=\"menuitem\"\n className=\"menu-item\"\n aria-expanded={visible}\n aria-haspopup=\"true\"\n aria-controls={visible ? menuId : undefined}\n disabled={disabled}\n onClick={handleTriggerClick}\n onKeyDown={handleTriggerKeyDown}\n onMouseEnter={hoverEnabled ? open : undefined}\n onMouseLeave={hoverEnabled ? scheduleClose : undefined}\n ref={(node) => {\n triggerRef.current = node\n }}\n >\n {trigger}\n </button>\n {(() => {\n const panel = (\n <div\n role=\"menu\"\n id={menuId}\n aria-labelledby={triggerId}\n className={classNames('menu', { show: visible, 'submenu-stacked': stacked })}\n style={menuStyle}\n data-cx-placement={placementAttr}\n onKeyDown={(event) =>\n handleMenuKeyDown(event, {\n onEscape: closeAndRefocusTrigger,\n ...(isRtl\n ? { onArrowRight: closeAndRefocusTrigger }\n : { onArrowLeft: closeAndRefocusTrigger })\n })\n }\n onMouseEnter={hoverEnabled ? clearCloseTimeout : undefined}\n onMouseLeave={hoverEnabled ? scheduleClose : undefined}\n // Registers this panel with the ancestor `Menu` (see `MenuContext.registerOverlay`)\n // so its own click-dismiss logic recognizes clicks here as \"inside\" the menu — the\n // panel portals straight to `document.body` when not `stacked`, so plain DOM\n // containment against the top-level menu's own element wouldn't otherwise see it.\n ref={(node) => {\n overlayRef.current = node\n registerOverlay(menuId, node)\n }}\n >\n <SubmenuActionsContext.Provider value={actionsValue}>\n <SubmenuGroupContext.Provider value={ownGroup}>\n <SubmenuVisibleContext.Provider value={visible}>\n {children}\n </SubmenuVisibleContext.Provider>\n </SubmenuGroupContext.Provider>\n </SubmenuActionsContext.Provider>\n </div>\n )\n\n // `stacked`'s sm-breakpoint CSS (`.menu:has(.submenu-stacked.show) ...`) needs the\n // panel to be a real DOM descendant of `.menu`/`.submenu` to match — portaling would\n // break that ancestor relationship, so it renders inline instead. Trade-off: above the\n // `sm` breakpoint a `stacked` submenu no longer escapes ancestor overflow/stacking-\n // context clipping the way a portaled one does; accepted since `stacked` targets mobile\n // nav/drawer usage, not floating dropdowns.\n // On the server and during hydration the panel renders inline next to its trigger, which\n // is what the server's HTML holds; `Portal` moves it to `document.body` afterwards, or\n // to the open dialog the menu is in: under a modal dialog's top layer the panel would be\n // behind the backdrop, and inert.\n return stacked ? (\n panel\n ) : (\n <Portal container={portalContainer} fallback={panel}>\n {panel}\n </Portal>\n )\n })()}\n </div>\n )\n }\n)\n\nMenuSubmenu.displayName = 'MenuSubmenu'\n","import React, { ButtonHTMLAttributes, forwardRef, useContext } from 'react'\nimport classNames from 'classnames'\n\nimport { menuToggleClicks } from './Menu'\nimport { SubmenuActionsContext } from './submenuGroup'\n\nexport interface MenuSubmenuBackProps extends ButtonHTMLAttributes<HTMLButtonElement> {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n}\n\n// First item of a stacked submenu's nested menu (see `MenuSubmenu`'s `stacked` prop). Closes\n// the submenu and returns focus to its trigger — visible only below the `sm` breakpoint.\nexport const MenuSubmenuBack = forwardRef<HTMLButtonElement, MenuSubmenuBackProps>(\n ({ children, className, onClick, type = 'button', ...rest }, ref) => {\n const actions = useContext(SubmenuActionsContext)\n\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event)\n if (!actions) return\n // Going back is the submenu's own action, as opening it from its trigger is: the click is\n // marked as the trigger's is (`menuToggleClicks`). On `window`, the `autoClose` listener of\n // `Menu` and `ContextMenu` would read it as a click on an item and close the whole menu.\n // Stopping it didn't keep it from them: they hear a stopped click too (`listenOnWindow`).\n menuToggleClicks.add(event.nativeEvent)\n actions.close()\n }\n\n return (\n <button\n type={type}\n role=\"menuitem\"\n className={classNames('submenu-back', 'menu-item', className)}\n {...rest}\n onClick={handleClick}\n ref={ref}\n >\n {children}\n </button>\n )\n }\n)\n\nMenuSubmenuBack.displayName = 'MenuSubmenuBack'\n"],"mappings":"A,kkBA6BA,SAASe,EACP,CAAE,WAAU,YAAW,YAAW,GAAGC,GACrC,EACA,CACA,IAAMC,EAAYC,GAAa,OACzBC,EAAaL,EAAW,YAAaM,CAAS,EAEpD,MACE,kBAAA,cAACH,EAAD,CAAW,UAAWE,EAAY,GAAIH,EAAW,KAEtC,EADRK,CACQ,CAEf,CAEA,MAAaC,EAAWtB,EACtBe,EACA,UACF,ECyBaQ,EAAcC,GAEvB,CACE,WACA,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EAAD,CAAQ,UAAW4E,GAAiB,SAAUL,CAEtC,EADLA,CACK,CAEZ,EAAA,CAAG,CACA,CAET,CACF,EAEA,EAAY,YAAc,cC1S1B,MAAaM,EAAkBzD,GAC5B,CAAE,WAAU,YAAW,UAAS,OAAO,SAAU,GAAGR,GAAQ,IAAQ,CACnE,IAAMkE,EAAU1C,EAAW7B,CAAqB,EAE1CwE,EAAe,GAA+C,CAClEC,IAAUf,CAAK,EACVa,IAKL7E,EAAiB,IAAIgE,EAAM,WAAW,EACtCa,EAAQ,MAAM,EAChB,EAEA,MACE,kBAAA,cAAC,SAAD,CACQ,OACN,KAAK,WACL,UAAWpE,EAAW,eAAgB,YAAaM,CAAS,EAC5D,GAAIJ,EACJ,QAASmE,EACJ,KAGC,EADL9D,CACK,CAEZ,CACF,EAEA,EAAgB,YAAc,kB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{y as e}from"./slot-DagH0Gxq.js";import{t}from"./polymorphic-mAKwlLiW.js";import{t as n}from"./useIsomorphicLayoutEffect-BbqRwuqn.js";import{t as r}from"./useDialogElement-yEgUSejP.js";import{t as i}from"./CloseButton-CAQ--0sB.js";import{n as a,t as o}from"./dialogTitle-DMBvXZLT.js";import s,{createContext as c,forwardRef as l,useContext as u,useId as d}from"react";import f from"classnames";const p=c({close:()=>{}}),m=c(()=>()=>{}),h=()=>u(p);function g({children:t,component:r,className:i,id:a,...o},c){let{titleId:l}=h(),d=u(m),p=r??`h2`,g=f(`modal-title`,i),_=e(p)??a??l;return n(()=>_?d(_):void 0,[d,_]),/* @__PURE__ */ s.createElement(p,{className:g,id:_,...o,ref:c},t)}const _=t(g,`ModalTitle`),v=l(({"aria-labelledby":e,children:t,backdrop:n=!0,className:i,defaultVisible:c,fullscreen:l,instant:u,keyboard:h=!0,modal:g=!0,onClick:y,onClose:b,onClosePrevented:x,onHidden:S,onKeyDown:C,onShow:w,onShown:T,onVisibleChange:E,scrollable:D,size:O,open:k,visible:A,...j},M)=>{let{close:N,forkedRef:P,handleBackdropClick:F,handleCancel:I,handleKeyDown:L,handleNativeClose:R,hiding:z,staticBounce:B}=r({backdrop:n,defaultVisible:c,instant:u,isModal:g,keyboard:h,onClick:y,onClose:b,onClosePrevented:x,onHidden:S,onKeyDown:C,onShow:w,onShown:T,onVisibleChange:E,open:k,ref:M,visible:A}),V=d(),[H,U]=a(()=>k?o(t,{dialog:v,generatedId:V,title:_}):void 0),W=f(`modal`,`dialog`,{[typeof l==`boolean`?`fullscreen`:`max-${l}:fullscreen`]:l,[`${O}`]:O,instant:u,nonmodal:!g,scrollable:D,hiding:z,"dialog-static":B},i);return/* @__PURE__ */ s.createElement(p.Provider,{value:{close:N,titleId:V}},/* @__PURE__ */ s.createElement(m.Provider,{value:U},/* @__PURE__ */ s.createElement(`dialog`,{"aria-labelledby":e??(j[`aria-label`]?void 0:H),tabIndex:-1,...j,open:k,className:W,onCancel:I,onClick:F,onClose:R,onKeyDown:L,ref:P},t)))});v.displayName=`Modal`;function y({children:e,className:t,component:n,...r},i){let a=n??`div`,o=f(`modal-body`,t);return/* @__PURE__ */ s.createElement(a,{className:o,...r,ref:i},e)}const b=t(y,`ModalBody`);function x({children:e,className:t,component:n,stacked:r,...i},a){let o=n??`div`,c=f(`modal-footer`,{stacked:r},t);return/* @__PURE__ */ s.createElement(o,{className:c,...i,ref:a},e)}const S=t(x,`ModalFooter`);function C({children:e,className:t,closeButton:n=!0,closeLabel:r,component:a,...o},c){let l=a??`div`,{close:u}=h(),d=f(`modal-header`,t);return/* @__PURE__ */ s.createElement(l,{className:d,...o,ref:c},e,n&&/* @__PURE__ */ s.createElement(i,{label:r,onClick:u}))}const w=t(C,`ModalHeader`);export{_ as a,v as i,S as n,h as o,b as r,w as t};
|
|
2
|
+
//# sourceMappingURL=modal-BDQe7xyy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal-BDQe7xyy.js","names":["resolveSlottedId","useIsomorphicLayoutEffect","useDialogElement","CloseButton","useDialogTitle","findDialogTitleId","React","classNames","ModalContext","createContext","ModalTitleContext","useModal","useContext","ModalTitleRender","rest","registerTitle","Component","component","_className","className","resolvedId","id","titleId","children","ModalTitle","createPolymorphicComponent","Modal","forwardRef","ariaLabelledBy","modal","useId","labelledBy","open","fullscreen","size","staticBounce","handleCancel","handleBackdropClick","handleNativeClose","handleKeyDown","forkedRef","ModalBodyRender","ModalBody","ModalFooterRender","ModalFooter","ModalHeaderRender","closeButton","closeLabel","close","ModalHeader"],"sources":["../../src/components/modal/context.ts","../../src/components/modal/useModal.ts","../../src/components/modal/ModalTitle.tsx","../../src/components/modal/Modal.tsx","../../src/components/modal/ModalBody.tsx","../../src/components/modal/ModalFooter.tsx","../../src/components/modal/ModalHeader.tsx"],"sourcesContent":["import { createContext } from 'react'\n\nimport { RegisterDialogTitle } from '../../hooks/useDialogTitle'\n\nexport interface ModalContextProps {\n /**\n * Requests the modal be closed — fires `onClose`. Wire this to any element's `onClick`; see\n * `useModal`.\n */\n close: () => void\n /**\n * Id generated by `Modal` and applied automatically by `ModalTitle` to itself, so the\n * dialog's `aria-labelledby` resolves to it without any manual wiring.\n */\n titleId?: string\n}\n\nexport const ModalContext = createContext<ModalContextProps>({ close: () => {} })\n\n// How a rendered `ModalTitle` tells its `Modal` the id it has (`useDialogTitle`). Apart from\n// `ModalContext`, whose value `useModal` returns to callers.\nexport const ModalTitleContext = createContext<RegisterDialogTitle>(() => () => {})\n","import { useContext } from 'react'\nimport { ModalContext, ModalContextProps } from './context'\n\nexport type UseModalResult = ModalContextProps\n\n// Reach the enclosing `Modal`'s close handler from anywhere in its composed markup — e.g. to\n// close it from a plain `Button` placed in a `ModalFooter`. Only meaningful inside a `Modal`;\n// outside one it returns a no-op `close`.\nexport const useModal = (): UseModalResult => useContext(ModalContext)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement, useContext } from 'react'\nimport classNames from 'classnames'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks'\nimport { ModalTitleContext } from './context'\nimport { useModal } from './useModal'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { resolveSlottedId } from '../../utils/elementKind'\n\ntype ModalTitleOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type ModalTitleProps<C extends ElementType = 'h2'> = PolymorphicComponentProps<\n C,\n ModalTitleOwnProps<C>\n>\n\ntype ModalTitleComponent = (<C extends ElementType = 'h2'>(\n props: ModalTitleProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ModalTitleRender<C extends ElementType = 'h2'>(\n { children, component, className, id, ...rest }: ModalTitleProps<C>,\n ref: PolymorphicRef<C>\n) {\n const { titleId } = useModal()\n const registerTitle = useContext(ModalTitleContext)\n const Component = component ?? 'h2'\n const _className = classNames('modal-title', className)\n // Under `asChild` the child's own `id` is the one rendered (`Slot`), so it is the one registered.\n const resolvedId = resolveSlottedId(Component) ?? id ?? titleId\n\n // The modal is labelled by this title, under the id it has here.\n useIsomorphicLayoutEffect(\n () => (resolvedId ? registerTitle(resolvedId) : undefined),\n [registerTitle, resolvedId]\n )\n\n return (\n <Component className={_className} id={resolvedId} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const ModalTitle = createPolymorphicComponent<ModalTitleComponent>(\n ModalTitleRender as ForwardRefRenderFunction<Element, ModalTitleProps<ElementType>>,\n 'ModalTitle'\n)\n","import React, { DialogHTMLAttributes, forwardRef, useId } from 'react'\nimport classNames from 'classnames'\n\nimport { useDialogElement } from '../../hooks'\nimport { useDialogTitle } from '../../hooks/useDialogTitle'\nimport { findDialogTitleId } from '../../utils/dialogTitle'\nimport { ModalContext, ModalTitleContext } from './context'\nimport { ModalTitle } from './ModalTitle'\n\nexport interface ModalProps extends Omit<\n DialogHTMLAttributes<HTMLDialogElement>,\n 'onCancel' | 'onClose'\n> {\n /**\n * Show a backdrop while the modal is open. `'static'` blocks closing on backdrop click\n * (the modal bounces instead). `false` is intentionally not equivalent to `modal={false}` —\n * unlike `Drawer`, whose vanilla chassis-css counterpart derives modality from `backdrop`,\n * chassis-css's vanilla `Dialog` only ever reads `backdrop` to distinguish `'static'` from\n * everything else; `modal` alone decides `showModal()`/`show()`. This mirrors that faithfully\n * rather than reintroducing an inconsistency with the vendored behavior.\n */\n backdrop?: boolean | 'static'\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Whether the modal is open when it first renders. Such a modal is uncontrolled: it closes\n * itself on a close request. Use `visible` to open and close it from outside.\n */\n defaultVisible?: boolean\n /**\n * Set modal to cover the entire user viewport. A breakpoint value goes fullscreen only\n * below that breakpoint.\n */\n fullscreen?: boolean | 'sm' | 'md' | 'lg' | 'xl' | '2xl'\n /**\n * Disable the open/close transition entirely.\n */\n instant?: boolean\n /**\n * Closes the modal when the escape key is pressed.\n */\n keyboard?: boolean\n /**\n * Open with `showModal()` (top-layer, native backdrop). Set `false` to open with `show()`\n * instead — no backdrop, and the page behind the modal stays interactive.\n */\n modal?: boolean\n /**\n * Renders the modal open from its first paint, server HTML included, as a non-modal dialog: a\n * static preview. It stays open until a close request. Use `visible` or `defaultVisible` to\n * open it as a modal dialog.\n */\n open?: boolean\n /**\n * Callback fired when the modal requests to be closed (escape, backdrop click, or close button).\n */\n onClose?: () => void\n /**\n * Callback fired when a close attempt is blocked (static backdrop click, or escape with `keyboard=false`).\n */\n onClosePrevented?: () => void\n /**\n * Callback fired after the exit transition completes and the modal is fully hidden.\n */\n onHidden?: () => void\n /**\n * Callback fired when the modal starts to open.\n */\n onShow?: () => void\n /**\n * Callback fired after the entry transition completes and the modal is fully visible.\n */\n onShown?: () => void\n /**\n * Callback fired with `false` when the modal requests to be closed, at the same moments as\n * `onClose`. It makes `visible` and `onVisibleChange` a pair that takes a state setter.\n */\n onVisibleChange?: (visible: boolean) => void\n /**\n * Create a scrollable modal — the header and footer stay fixed while the body scrolls.\n */\n scrollable?: boolean\n /**\n * Size the component sm, lg, or extra lg.\n */\n size?: 'sm' | 'lg' | 'xl'\n /**\n * Whether the modal is open. The modal is then controlled: a close request only fires\n * `onClose` and `onVisibleChange`, and the modal closes when this becomes `false`.\n */\n visible?: boolean\n}\n\nexport const Modal = forwardRef<HTMLDialogElement, ModalProps>(\n (\n {\n 'aria-labelledby': ariaLabelledBy,\n children,\n backdrop = true,\n className,\n defaultVisible,\n fullscreen,\n instant,\n keyboard = true,\n modal = true,\n onClick,\n onClose,\n onClosePrevented,\n onHidden,\n onKeyDown,\n onShow,\n onShown,\n onVisibleChange,\n scrollable,\n size,\n open,\n visible,\n ...rest\n },\n ref\n ) => {\n const {\n close,\n forkedRef,\n handleBackdropClick,\n handleCancel,\n handleKeyDown,\n handleNativeClose,\n hiding,\n staticBounce\n } = useDialogElement({\n backdrop,\n defaultVisible,\n instant,\n isModal: modal,\n keyboard,\n onClick,\n onClose,\n onClosePrevented,\n onHidden,\n onKeyDown,\n onShow,\n onShown,\n onVisibleChange,\n open,\n ref,\n visible\n })\n\n const titleId = useId()\n // Labelled by the title that is rendered, under the id it has, unless the caller names the\n // dialog itself: `aria-labelledby` would outrank that `aria-label`.\n const [labelledBy, registerTitle] = useDialogTitle(() =>\n open\n ? findDialogTitleId(children, { dialog: Modal, generatedId: titleId, title: ModalTitle })\n : undefined\n )\n\n const _className = classNames(\n 'modal',\n 'dialog',\n {\n [typeof fullscreen === 'boolean' ? 'fullscreen' : `max-${fullscreen}:fullscreen`]:\n fullscreen,\n [`${size}`]: size,\n instant,\n nonmodal: !modal,\n scrollable,\n hiding,\n 'dialog-static': staticBounce\n },\n className\n )\n\n return (\n <ModalContext.Provider value={{ close, titleId }}>\n <ModalTitleContext.Provider value={registerTitle}>\n <dialog\n // Out of `rest`, so a caller's `aria-labelledby={undefined}` (a wrapper forwarding a prop\n // it wasn't given) leaves the title's label in place instead of writing over it.\n aria-labelledby={ariaLabelledBy ?? (rest['aria-label'] ? undefined : labelledBy)}\n // Firefox and Safari put a `<dialog>` without a tabindex in the Tab order, where it takes\n // focus with no ring; -1 keeps it focusable for the open-focus fallback only.\n tabIndex={-1}\n {...rest}\n open={open}\n className={_className}\n onCancel={handleCancel}\n onClick={handleBackdropClick}\n onClose={handleNativeClose}\n onKeyDown={handleKeyDown}\n ref={forkedRef}\n >\n {children}\n </dialog>\n </ModalTitleContext.Provider>\n </ModalContext.Provider>\n )\n }\n)\n\nModal.displayName = 'Modal'\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype ModalBodyOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type ModalBodyProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ModalBodyOwnProps<C>\n>\n\ntype ModalBodyComponent = (<C extends ElementType = 'div'>(\n props: ModalBodyProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ModalBodyRender<C extends ElementType = 'div'>(\n { children, className, component, ...rest }: ModalBodyProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('modal-body', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const ModalBody = createPolymorphicComponent<ModalBodyComponent>(\n ModalBodyRender as ForwardRefRenderFunction<Element, ModalBodyProps<ElementType>>,\n 'ModalBody'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype ModalFooterOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * Stack the footer actions as full-width columns instead of a right-aligned row.\n */\n stacked?: boolean\n}\n\nexport type ModalFooterProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ModalFooterOwnProps<C>\n>\n\ntype ModalFooterComponent = (<C extends ElementType = 'div'>(\n props: ModalFooterProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ModalFooterRender<C extends ElementType = 'div'>(\n { children, className, component, stacked, ...rest }: ModalFooterProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('modal-footer', { stacked }, className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const ModalFooter = createPolymorphicComponent<ModalFooterComponent>(\n ModalFooterRender as ForwardRefRenderFunction<Element, ModalFooterProps<ElementType>>,\n 'ModalFooter'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { useModal } from './useModal'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { CloseButton } from '../close-button/CloseButton'\n\ntype ModalHeaderOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Add a close button component to the header.\n */\n closeButton?: boolean\n /**\n * Overrides the close button's accessible name (defaults to `'Close'`). Set this for\n * non-English UIs.\n */\n closeLabel?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n}\n\nexport type ModalHeaderProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ModalHeaderOwnProps<C>\n>\n\ntype ModalHeaderComponent = (<C extends ElementType = 'div'>(\n props: ModalHeaderProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ModalHeaderRender<C extends ElementType = 'div'>(\n { children, className, closeButton = true, closeLabel, component, ...rest }: ModalHeaderProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const { close } = useModal()\n const _className = classNames('modal-header', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n {closeButton && <CloseButton label={closeLabel} onClick={close} />}\n </Component>\n )\n}\n\nexport const ModalHeader = createPolymorphicComponent<ModalHeaderComponent>(\n ModalHeaderRender as ForwardRefRenderFunction<Element, ModalHeaderProps<ElementType>>,\n 'ModalHeader'\n)\n"],"mappings":"A,ibAiBA,MAAaQ,EAAeC,EAAiC,CAAE,UAAa,CAAC,CAAE,CAAC,EAInEC,EAAoBD,UAA+C,CAAC,CAAC,ECbrEE,MAAiCC,EAAWJ,CAAY,ECyBrE,SAASK,EACP,CAAE,WAAU,YAAW,YAAW,KAAI,GAAGC,GACzC,EACA,CACA,GAAM,CAAE,WAAYH,EAAS,EACvBI,EAAgBH,EAAWF,CAAiB,EAC5CM,EAAYC,GAAa,KACzBC,EAAaX,EAAW,cAAeY,CAAS,EAEhDC,EAAapB,EAAiBgB,CAAS,GAAKK,GAAMC,EAQxD,OALArB,MACSmB,EAAaL,EAAcK,CAAU,EAAI,IAAA,GAChD,CAACL,EAAeK,CAAU,CAC5B,EAGE,kBAAA,cAACJ,EAAD,CAAW,UAAWE,EAAY,GAAIE,EAAY,GAAIN,EAAW,KAEtD,EADRS,CACQ,CAEf,CAEA,MAAaC,EAAaC,EACxBZ,EACA,YACF,ECmCaa,EAAQC,GAEjB,CACE,kBAAmBC,EACnB,WACA,WAAW,GACX,YACA,iBACA,aACA,UACA,WAAW,GACX,QAAQ,GACR,UACA,UACA,mBACA,WACA,YACA,SACA,UACA,kBACA,aACA,OACA,OACA,UACA,GAAGd,GAEL,IACG,CACH,GAAM,CACJ,QACA,YACA,sBACA,eACA,gBACA,oBACA,SACA,gBACEZ,EAAiB,CACnB,WACA,iBACA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AAW,KAEtC,EADRS,CACQ,CAEf,CAEA,MAAaqB,EAAcnB,EACzBkB,EACA,aACF,ECVA,SAASE,EACP,CAAE,WAAU,YAAW,cAAc,GAAM,aAAY,YAAW,GAAG/B,GACrE,EACA,CACA,IAAME,EAAYC,GAAa,MACzB,CAAE,SAAUN,EAAS,EACrBO,EAAaX,EAAW,eAAgBY,CAAS,EAEvD,MACE,kBAAA,cAACH,EAAD,CAAW,UAAWE,EAAY,GAAIJ,EAAW,KAGtC,EAFRS,EACAuB,GAAe,kBAAA,cAAC3C,EAAD,CAAa,MAAO4C,EAAY,QAASC,CAAQ,CAAA,CACxD,CAEf,CAEA,MAAaC,EAAcxB,EACzBoB,EACA,aACF,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=(e,t)=>{let n=(Array.isArray(t)?t:[t]).map(String);if(e instanceof HTMLSelectElement){let t=!1;for(let r of e.options){let e=n.includes(r.value);r.defaultSelected=e,r.selected!==e&&(r.selected=e,t=!0)}t&&e.dispatchEvent(new Event(`change`,{bubbles:!0}));return}let r=n[0]??``;e.defaultValue=r,e.value!==r&&(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set?.call(e,r),e.dispatchEvent(new Event(`input`,{bubbles:!0})))};export{e as t};
|
|
2
|
+
//# sourceMappingURL=nativeFormReset-DgsRU9SA.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nativeFormReset-DgsRU9SA.js","names":["resetNativeControl","values","initial","node","changed","option","selected","value"],"sources":["../../src/utils/nativeFormReset.ts"],"sourcesContent":["// The reset of a native control React renders. A browser puts a control back to its default,\n// `defaultValue` or the options with `defaultSelected`, which React keeps in step with the\n// controlled value of an input and never sets for a controlled select: a controlled\n// `<select value>` went to its first option with its state left as it was, and the next render\n// put the edited value back, and a controlled color or range input stayed as edited. Before the\n// browser's own reset, in the form's `reset` event, the first value is made the default and the\n// control set to it, and the change is dispatched as a browser dispatches it, so React reports\n// it through `onChange` and the state follows. The value is set through the prototype's setter:\n// React tracks one set through the element's own, and reports no change for it.\nexport const resetNativeControl = (\n node: HTMLInputElement | HTMLSelectElement,\n initial: string | number | readonly string[]\n): void => {\n const values = (Array.isArray(initial) ? initial : [initial]).map(String)\n if (node instanceof HTMLSelectElement) {\n let changed = false\n for (const option of node.options) {\n const selected = values.includes(option.value)\n option.defaultSelected = selected\n if (option.selected !== selected) {\n option.selected = selected\n changed = true\n }\n }\n if (changed) node.dispatchEvent(new Event('change', { bubbles: true }))\n return\n }\n const value = values[0] ?? ''\n node.defaultValue = value\n if (node.value === value) return\n Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set?.call(node, value)\n node.dispatchEvent(new Event('input', { bubbles: true }))\n}\n"],"mappings":"AASA,MAAaA,GACX,EACA,IACS,CACT,IAAMC,GAAU,MAAM,QAAQC,CAAO,EAAIA,EAAU,CAACA,CAAO,EAAA,CAAG,IAAI,MAAM,EACxE,GAAIC,aAAgB,kBAAmB,CACrC,IAAIC,EAAU,GACd,IAAK,IAAMC,KAAUF,EAAK,QAAS,CACjC,IAAMG,EAAWL,EAAO,SAASI,EAAO,KAAK,EAC7C,EAAO,gBAAkBC,EACrBD,EAAO,WAAaC,IACtB,EAAO,SAAWA,EAClB,EAAU,GAEd,CACIF,GAASD,EAAK,cAAc,IAAI,MAAM,SAAU,CAAE,QAAS,EAAK,CAAC,CAAC,EACtE,MACF,CACA,IAAMI,EAAQN,EAAO,IAAM,GAC3B,EAAK,aAAeM,EAChBJ,EAAK,QAAUI,IACnB,OAAO,yBAAyB,iBAAiB,UAAW,OAAO,CAAC,EAAE,KAAK,KAAKJ,EAAMI,CAAK,EAC3FJ,EAAK,cAAc,IAAI,MAAM,QAAS,CAAE,QAAS,EAAK,CAAC,CAAC,EAC1D,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{C as e,d as t,g as n}from"./slot-DagH0Gxq.js";import{t as r}from"./useForkedRef-WoqMqsWE.js";import{t as i}from"./polymorphic-mAKwlLiW.js";import{t as a}from"./Link-B3SX50Od.js";import{a as o,i as s,o as c,r as l,s as u}from"./navOverflow-eSROB_mV.js";import{t as d}from"./navVariant-Bm5k8CY3.js";import f,{forwardRef as p}from"react";import m from"classnames";function h({children:e,className:t,...n},r){let i=m(`nav-link`,t),s=c();return/* @__PURE__ */ f.createElement(f.Fragment,null,/* @__PURE__ */ f.createElement(a,{className:i,...n,ref:r},e),s&&/* @__PURE__ */ f.createElement(o,{props:{...n,children:e}}))}const g=i(h,`NavLink`);function _({active:n,asChild:i,children:a,className:o,component:s,disabled:c,href:d,keepVisible:p,linkProps:h,onClick:_,...v},y){let b=m(`nav-item`,{"nav-overflow-keep":p},o),x=u(),S=r(y,x.ref),C=x.hidden?{"data-cx-nav-overflow":`true`}:void 0;if(t(d)||s!==void 0||i){let e=Object.fromEntries(Object.entries({active:n,asChild:i,component:s,disabled:c,href:d,onClick:_}).filter(([,e])=>e!==void 0));return/* @__PURE__ */ f.createElement(`li`,{className:b,...v,...C,ref:S},/* @__PURE__ */ f.createElement(l,{value:x.scope},/* @__PURE__ */ f.createElement(g,{...h,...e},a)))}return e(!!n||!!c||h!==void 0,"NavItem: `active`, `disabled` and `linkProps` are for its link, and without `href`, `component` or `asChild` it renders none. Put them on the link inside it."),/* @__PURE__ */ f.createElement(`li`,{className:b,...v,onClick:_,...C,ref:S},/* @__PURE__ */ f.createElement(l,{value:x.scope},a))}const v=p(_);v.displayName=`NavItem`;function y({children:e,className:r,component:i,items:a,layout:o,size:c,variant:l,...u},p){let h=i??`ul`,g=m(`nav`,c,{[`nav-${o}`]:o},d(l,`Nav`),r),_=a?a.map((e,n)=>/* @__PURE__ */ f.createElement(v,{key:n,active:e.active,component:t(e.href)?void 0:`button`,disabled:e.disabled,href:e.href,onClick:e.onClick},e.label)):null;return/* @__PURE__ */ f.createElement(h,{className:g,...u,ref:p},/* @__PURE__ */ f.createElement(s,{tag:n(h)},_??e))}const b=i(y,`Nav`),x=p(({children:e,className:t,...n},r)=>/* @__PURE__ */ f.createElement(`li`,{className:t,...n,ref:r},e));x.displayName=`NavTitle`;export{g as i,b as n,v as r,x as t};
|
|
2
|
+
//# sourceMappingURL=nav-DDI8Dv28.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nav-DDI8Dv28.js","names":["devWarning","hasHref","resolveElementTag","useForkedRef","createPolymorphicComponent","Link","NavOverflowLink","NavOverflowItems","useIsNavOverflowLink","NavOverflowItemScope","useNavOverflowItem","navVariantClassName","React","classNames","NavLinkRender","rest","_className","className","isOverflowLink","children","NavLink","NavItemRender","keepVisible","overflow","forkedRef","ref","overflowProps","href","component","asChild","ownLinkProps","value","linkProps","active","disabled","NavItem","forwardRef","NavRender","Component","size","layout","variant","autoContent","items","idx","item","Nav","NavTitle"],"sources":["../../src/components/nav/NavLink.tsx","../../src/components/nav/NavItem.tsx","../../src/components/nav/Nav.tsx","../../src/components/nav/NavTitle.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { NavOverflowLink, useIsNavOverflowLink } from '../../utils/navOverflow'\nimport { createPolymorphicComponent, PolymorphicRef } from '../../utils/polymorphic'\nimport { LinkProps, Link } from '../link/Link'\n\ntype NavLinkOwnProps = {\n /**\n * Toggle the active state for the component.\n */\n active?: boolean\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Toggle the disabled state for the component.\n */\n disabled?: boolean\n}\n\nexport type NavLinkProps<C extends ElementType = 'a'> = LinkProps<C> & NavLinkOwnProps\n\ntype NavLinkComponent = (<C extends ElementType = 'a'>(\n props: NavLinkProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction NavLinkRender<C extends ElementType = 'a'>(\n { children, className, ...rest }: NavLinkProps<C>,\n ref: PolymorphicRef<C>\n) {\n const _className = classNames('nav-link', className)\n // Inside a `NavOverflow`, the link of an item that doesn't fit is shown in the menu instead, as\n // a `MenuItem` with these props.\n const isOverflowLink = useIsNavOverflowLink()\n\n return (\n <>\n <Link\n className={_className}\n {...(rest as Record<string, unknown>)}\n ref={ref as PolymorphicRef<ElementType>}\n >\n {children}\n </Link>\n {isOverflowLink && <NavOverflowLink props={{ ...rest, children }} />}\n </>\n )\n}\n\nexport const NavLink = createPolymorphicComponent<NavLinkComponent>(\n NavLinkRender as ForwardRefRenderFunction<Element, NavLinkProps<ElementType>>,\n 'NavLink'\n)\n","import React, {\n ElementType,\n ForwardRefRenderFunction,\n forwardRef,\n LiHTMLAttributes,\n MouseEventHandler,\n ReactElement,\n Ref\n} from 'react'\nimport classNames from 'classnames'\n\nimport { useForkedRef } from '../../hooks'\nimport { devWarning } from '../../utils/devWarning'\nimport { hasHref } from '../../utils/elementKind'\nimport { NavOverflowItemScope, useNavOverflowItem } from '../../utils/navOverflow'\nimport { NavLink, NavLinkProps } from './NavLink'\n\ntype NavItemOwnProps<C extends ElementType> = {\n /**\n * Toggle the active state of the item's link.\n */\n active?: boolean\n /**\n * Render the item's link as its child element, as `NavLink`'s `asChild` does.\n */\n asChild?: boolean\n /**\n * A string of all className you want applied to the `<li>`, which takes the ref and the other\n * attributes too.\n */\n className?: string\n /**\n * Component used for the item's link. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * Toggle the disabled state of the item's link.\n */\n disabled?: boolean\n /**\n * URL for the item's link.\n */\n href?: string\n /**\n * Keeps the item in the list inside a `NavOverflow`, whatever the width.\n */\n keepVisible?: boolean\n /**\n * Any other props of the item's link, such as a router link's `to`, `target` or `aria-label`,\n * and its own `className`.\n */\n linkProps?: Omit<\n NavLinkProps<C>,\n 'active' | 'asChild' | 'children' | 'component' | 'disabled' | 'href' | 'onClick'\n >\n /**\n * Callback fired on a click of the item's link, or of the `<li>` when it has none.\n */\n onClick?: MouseEventHandler<HTMLElement>\n}\n\nexport type NavItemProps<C extends ElementType = 'a'> = Omit<\n LiHTMLAttributes<HTMLLIElement>,\n keyof NavItemOwnProps<C>\n> &\n NavItemOwnProps<C>\n\ntype NavItemComponent = (<C extends ElementType = 'a'>(\n props: NavItemProps<C> & { ref?: Ref<HTMLLIElement> }\n) => ReactElement | null) & { displayName?: string }\n\n// A `.nav-item` wrapping a `.nav-link` when there is a link to render: an `href`, or a `component`\n// or `asChild` element, which `NavLink` renders. Otherwise a bare `<li>` around `children`, such as\n// a `MenuToggle`. Either way the `<li>` takes `className`, the ref and the other attributes, as\n// `BreadcrumbItem`'s does; the link takes the props that make it one, and `linkProps`. The `<li>`\n// took `className` and the ref while the link took the rest.\nfunction NavItemRender<C extends ElementType = 'a'>(\n {\n active,\n asChild,\n children,\n className,\n component,\n disabled,\n href,\n keepVisible,\n linkProps,\n onClick,\n ...rest\n }: NavItemProps<C>,\n ref: Ref<HTMLLIElement>\n) {\n const _className = classNames('nav-item', { 'nav-overflow-keep': keepVisible }, className)\n // Inside a `NavOverflow`: the `<li>` is what it measures, and hides when the item is in the\n // menu. chassis-css hides it by this attribute.\n const overflow = useNavOverflowItem()\n const forkedRef = useForkedRef(ref, overflow.ref)\n const overflowProps = overflow.hidden ? { 'data-cx-nav-overflow': 'true' } : undefined\n\n if (hasHref(href) || component !== undefined || asChild) {\n // Only the props given, so the link (and the menu item a `NavOverflow` copies from it) gets\n // no key set to `undefined`.\n const ownLinkProps = Object.fromEntries(\n Object.entries({ active, asChild, component, disabled, href, onClick }).filter(\n ([, value]) => value !== undefined\n )\n )\n return (\n <li className={_className} {...rest} {...overflowProps} ref={forkedRef}>\n <NavOverflowItemScope value={overflow.scope}>\n <NavLink {...(linkProps as Record<string, unknown>)} {...ownLinkProps}>\n {children}\n </NavLink>\n </NavOverflowItemScope>\n </li>\n )\n }\n\n devWarning(\n !!active || !!disabled || linkProps !== undefined,\n 'NavItem: `active`, `disabled` and `linkProps` are for its link, and without `href`, ' +\n '`component` or `asChild` it renders none. Put them on the link inside it.'\n )\n return (\n <li className={_className} {...rest} onClick={onClick} {...overflowProps} ref={forkedRef}>\n <NavOverflowItemScope value={overflow.scope}>{children}</NavOverflowItemScope>\n </li>\n )\n}\n\nexport const NavItem = forwardRef(\n NavItemRender as ForwardRefRenderFunction<HTMLLIElement, NavItemProps<ElementType>>\n) as NavItemComponent\n\nNavItem.displayName = 'NavItem'\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { hasHref, resolveElementTag } from '../../utils/elementKind'\nimport { NavOverflowItems } from '../../utils/navOverflow'\nimport { NavVariant, navVariantClassName } from '../../utils/navVariant'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { NavItem } from './NavItem'\n\nexport interface NavItemDef {\n /**\n * Label content for the nav item.\n */\n label: React.ReactNode\n /**\n * URL for the nav link. Without one the link is a `<button>`.\n */\n href?: string\n /**\n * Marks the item as active.\n */\n active?: boolean\n /**\n * Marks the item as disabled.\n */\n disabled?: boolean\n /**\n * Called when the item is clicked. An item without `href` renders its link as a `<button>`,\n * which this gives something to do, such as switching a tab's panel.\n */\n onClick?: (event: React.MouseEvent<HTMLElement>) => void\n}\n\ntype NavOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Component used for the root node. Either a string to use a HTML element or a component.\n */\n component?: C\n /**\n * Array of nav item definitions for data-driven rendering. When provided, children are ignored.\n */\n items?: NavItemDef[]\n /**\n * Specify a layout type for component.\n */\n layout?: 'fill' | 'justified'\n /**\n * Size the component sm or lg.\n */\n size?: 'sm' | 'lg'\n /**\n * Set the nav variant to tabs, to segments (a segmented control) or to underline, which\n * underlines the active link. `'pills'` is the former name of `'segments'`: deprecated, it\n * renders the same.\n *\n * @type { 'tabs' | 'segments' | 'underline' | 'pills' }\n */\n variant?: NavVariant\n}\n\nexport type NavProps<C extends ElementType = 'ul'> = PolymorphicComponentProps<C, NavOwnProps<C>>\n\ntype NavComponent = (<C extends ElementType = 'ul'>(\n props: NavProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction NavRender<C extends ElementType = 'ul'>(\n { children, className, component, items, layout, size, variant, ...rest }: NavProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'ul'\n const _className = classNames(\n 'nav',\n size,\n { [`nav-${layout}`]: layout },\n navVariantClassName(variant, 'Nav'),\n className\n )\n\n // An item without `href` is a button, so `active`, `disabled` and `onClick` still have a link to\n // act on; `NavItem` alone would render a bare `<li>` for it.\n const autoContent = items\n ? items.map((item, idx) => (\n <NavItem\n // eslint-disable-next-line react/no-array-index-key\n key={idx}\n active={item.active}\n component={hasHref(item.href) ? undefined : 'button'}\n disabled={item.disabled}\n href={item.href}\n onClick={item.onClick}\n >\n {item.label}\n </NavItem>\n ))\n : null\n\n // No `role`: `navigation` on the `<ul>` took away its list semantics, and `ul` doesn't allow\n // that role. A landmark is the caller's `<nav>` around it, or `component=\"nav\"` holding\n // `NavLink`s without items.\n return (\n <Component className={_className} {...rest} ref={ref}>\n {/* Inside a `NavOverflow`, the items it collapses and its toggle item. */}\n <NavOverflowItems tag={resolveElementTag(Component)}>\n {autoContent ?? children}\n </NavOverflowItems>\n </Component>\n )\n}\n\nexport const Nav = createPolymorphicComponent<NavComponent>(\n NavRender as ForwardRefRenderFunction<Element, NavProps<ElementType>>,\n 'Nav'\n)\n","import React, { forwardRef, HTMLAttributes } from 'react'\n\nexport interface NavTitleProps extends HTMLAttributes<HTMLLIElement> {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n}\n\nexport const NavTitle = forwardRef<HTMLLIElement, NavTitleProps>(\n ({ children, className, ...rest }, ref) => {\n // chassis-css has no rule for a nav title, so it takes no class of its own: the caller's\n // `className` styles it.\n return (\n <li className={className} {...rest} ref={ref}>\n {children}\n </li>\n )\n }\n)\n\nNavTitle.displayName = 'NavTitle'\n"],"mappings":"A,iZA4BA,SAASc,EACP,CAAE,WAAU,YAAW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kBAAA,cAACf,EAAD,CAAsB,MAAOc,EAAS,KAAuC,EAA/BJ,CAA+B,CAC3E,CAER,CAEA,MAAagB,EAAUC,EACrBf,CACF,EAEA,EAAQ,YAAc,UC5DtB,SAASgB,EACP,CAAE,WAAU,YAAW,YAAW,QAAO,SAAQ,OAAM,UAAS,GAAGtB,GACnE,EACA,CACA,IAAMuB,EAAYV,GAAa,KACzBZ,EAAaH,EACjB,MACA0B,EACA,EAAG,OAAOC,KAAWA,CAAO,EAC5B7B,EAAoB8B,EAAS,KAAK,EAClCxB,CACF,EAIMyB,EAAcC,EAChBA,EAAM,KAAK,EAAM,IACf,kBAAA,cAACR,EAAD,CAEE,IAAKS,EACL,OAAQC,EAAK,OACb,UAAW5C,EAAQ4C,EAAK,IAAI,EAAI,IAAA,GAAY,SAC5C,SAAUA,EAAK,SACf,KAAMA,EAAK,KACX,QAASA,EAAK,OAGP,EADNA,EAAK,KACC,CACV,EACD,KAKJ,MACE,kBAAA,cAACP,EAAD,CAAW,UAAWtB,EAAY,GAAID,EAAW,KAKtC,EAHT,kBAAA,cAACR,EAAD,CAAkB,IAAKL,EAAkBoC,CAAS,CAEhC,EADfI,GAAevB,CACA,CACT,CAEf,CAEA,MAAa2B,EAAM1C,EACjBiC,EACA,KACF,EChHaU,EAAWX,GACrB,CAAE,WAAU,YAAW,GAAGrB,GAAQ,IAI/B,kBAAA,cAAC,KAAD,CAAe,YAAW,GAAIA,EAAW,KAErC,EADDI,CACC,CAGV,EAEA,EAAS,YAAc,W"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./focus-ring-Bs80iIBN.js";import{
|
|
2
|
-
//# sourceMappingURL=nav-overflow-
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{C as e}from"./slot-DagH0Gxq.js";import{t}from"./useForkedRef-WoqMqsWE.js";import{t as n}from"./polymorphic-mAKwlLiW.js";import{t as r}from"./useIsomorphicLayoutEffect-BbqRwuqn.js";import{t as i}from"./useHydrated-Dud4JEwp.js";import{t as a}from"./iconSlot-DU_WcSL_.js";import{n as o}from"./navOverflow-eSROB_mV.js";import{t as s}from"./Menu-DBN4Mxak.js";import{n as c,t as l,u}from"./MenuToggle-DHzKm1Ed.js";import d,{createContext as f,useCallback as p,useContext as m,useEffect as h,useMemo as g,useRef as _,useState as v,useSyncExternalStore as y}from"react";import b from"classnames";import{flushSync as x}from"react-dom";const S=f(null);function C(e){for(let t=e.previousElementSibling;t;t=t.previousElementSibling){if(t.hasAttribute(`data-cx-nav-overflow`))continue;let e=t.querySelector(`a[href], button:not(:disabled), [tabindex]`);if(e)return e}return null}function w({tabs:e}){let t=m(S),[n,i]=v(!1),o=_(null),f=_(!1),p=t?.hidden,h=!p?.length;r(()=>{let e=o.current;if(!e||!f.current)return;let t=e.ownerDocument.activeElement;(!t||t===e.ownerDocument.body||h&&e.contains(t))&&(f.current=!h,(h?C(e):e.querySelector(`.nav-overflow-toggle`))?.focus())},[p,h]);let g=t=>{f.current=!0,e&&t.stopPropagation()},x=()=>{f.current=!1};if(y(t?.subscribe??D,t?.getVersion??O,t?.getVersion??O),!t||!p)return null;let{getLink:w,iconPlacement:k,menuContainer:A,menuPlacement:j,moreIcon:M,moreLabel:N,moreText:P}=t;h&&n&&i(!1);let F=/* @__PURE__ */ d.createElement(`span`,{key:`icon`,className:`nav-overflow-icon`,style:E},/* @__PURE__ */ d.createElement(a,{icon:`more`,override:M})),I=P===!1?null:/* @__PURE__ */ d.createElement(`span`,{key:`text`,className:`nav-overflow-text`},P);return/* @__PURE__ */ d.createElement(s,{component:`li`,className:b(`nav-item nav-overflow-item`,{[T]:h}),container:e&&typeof A!=`object`||A,onBlur:x,onFocus:g,onVisibleChange:i,placement:j,visible:n&&!h,...e&&{role:`presentation`},ref:o},/* @__PURE__ */ d.createElement(l,{"aria-label":P===!1?N:void 0,caret:!1,className:`nav-link nav-overflow-toggle`,component:`button`,...e&&{"aria-selected":!1,role:`tab`,tabIndex:-1}},k===`end`?[I,F]:[F,I]),/* @__PURE__ */ d.createElement(c,{className:`nav-overflow-menu`},p.map(e=>{let t=w(e);return t&&/* @__PURE__ */ d.createElement(u,{key:e,...t})})))}const T=`d-none`,E={"--cx-icon-color":`currentcolor`,"--cx-icon-size":`1rem`},D=()=>()=>{},O=()=>0;function k({available:e,collapseAll:t,gap:n,items:r,more:i,threshold:a}){let o=r.filter(e=>!e.keep),s=e=>e.map(e=>e.id);if(t)return s(o);if(r.reduce((e,t)=>e+t.width,0)+n*(r.length-1)<=e+1)return[];let c=i+r.reduce((e,t)=>t.keep?e+t.width+n:e,0),l=o.filter(t=>(c+=t.width+n,c>e+1));return r.length-l.length<a&&(l=r.slice(a).filter(e=>!e.keep)),s(l)}function A(){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Set,n=0,r=t=>{let n=e.get(t);return n||(n={element:null,link:null},e.set(t,n)),n};return{entries:e,getVersion:()=>n,notify:()=>{n+=1,t.forEach(e=>e())},set:(t,n)=>{let i=Object.assign(r(t),n);!i.element&&!i.link&&e.delete(t)},subscribe:e=>(t.add(e),()=>{t.delete(e)})}}const j=`data-cx-nav-overflow`,M=`d-none`,N=[],P=e=>Number.parseFloat(e)||0,F=e=>`offsetWidth`in e,I=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]);function ee(e,t){if(typeof e==`number`)return e;if(!e)return 0;let n=getComputedStyle(t.ownerDocument.documentElement),r=n.getPropertyValue(`--cx-breakpoint-${e}`).trim();return/r?em$/.test(r)?P(r)*(P(n.fontSize)||16):P(r)}const te={overflowX:`auto`,scrollbarWidth:`none`};function L({children:n,className:a,collapseBelow:s,component:c,iconPlacement:l=`start`,menuContainer:u,menuPlacement:f=`bottom-end`,moreIcon:m,moreLabel:y=`More`,moreText:C=`More`,onOverflow:T,style:E,threshold:D=0,...O},L){let R=c??`div`,z=_(null),ne=p(e=>{e&&(z.current=e)},[]),re=t(L,ne),ie=i(),[B]=v(A),[V,H]=v(N),U=_(V),W=_(0),G=_({collapseBelow:s,threshold:D});G.current={collapseBelow:s,threshold:D};let K=_(null),q=p(()=>{let t=z.current?.isConnected?z.current:null,n=t&&Array.from(t.children).find(e=>e.matches(`.nav`));if(e(!!t&&!n,"NavOverflow: expects a `Nav`, a `NavbarNav` or a `TabList` as its child; found no `.nav` to collapse."),!t||!n)return null;let r=Array.from(n.children).filter(F),i=r.find(e=>e.classList.contains(`nav-overflow-item`)),a=r.filter(e=>e!==i);if(Y(t,n,r),W.current=a.length,!i)return[];let o=/* @__PURE__ */ new Map;B.entries.forEach((e,t)=>{e.element&&o.set(e.element,t)});let s=a.filter(e=>e.hasAttribute(j)),c=i.classList.contains(M);s.forEach(e=>e.removeAttribute(j)),i.classList.remove(M);try{let e=getComputedStyle(t),r=getComputedStyle(n),s=t.clientWidth-P(e.paddingInlineStart)-P(e.paddingInlineEnd),c=t.ownerDocument.activeElement,l=a.map(e=>{let t=o.get(e);return{id:t,keep:!t||!B.entries.get(t)?.link||e.classList.contains(`nav-overflow-keep`)||e.querySelector(`.nav-link.active, .nav-link[aria-current]:not([aria-current="false"]), [role="tab"][tabindex="0"]`)!==null||e.contains(c),width:e.offsetWidth}}),{collapseBelow:u,threshold:d}=G.current;return k({available:s-P(r.paddingInlineStart)-P(r.paddingInlineEnd)-P(r.borderInlineStartWidth)-P(r.borderInlineEndWidth),collapseAll:s<ee(u,t),gap:P(r.columnGap),items:l,more:i.offsetWidth,threshold:d})}finally{s.forEach(e=>e.setAttribute(j,`true`)),c&&i.classList.add(M),t.offsetWidth,K.current?.mutation?.takeRecords()}},[B]),J=p(()=>{let e=q();e&&!I(e,U.current)&&(U.current=e,H(e))},[q]);function Y(e,t,n){let r=K.current;if(r&&r.wrapper!==e&&(X(),r=null),!r){let t=()=>x(J),n={frame:0,mutation:typeof MutationObserver>`u`?null:new MutationObserver(t),nav:null,observed:/* @__PURE__ */ new Set,resize:typeof ResizeObserver>`u`?null:new ResizeObserver(r=>{if(!r.some(t=>t.target===e)){cancelAnimationFrame(n.frame),n.frame=requestAnimationFrame(t);return}let i=U.current;t(),U.current!==i&&K.current===n&&(n.resize?.unobserve(e),cancelAnimationFrame(n.wrapperFrame),n.wrapperFrame=requestAnimationFrame(()=>n.resize?.observe(e)))}),wrapperFrame:0,wrapper:e};r=K.current=n,r.resize?.observe(e)}let{mutation:i,observed:a,resize:o}=r;r.nav!==t&&(r.nav=t,i?.disconnect(),i?.observe(t,{attributeFilter:[`class`,`aria-current`],attributes:!0,childList:!0,subtree:!0}));let s=new Set(n);a.forEach(e=>{s.has(e)||(o?.unobserve(e),a.delete(e))}),s.forEach(e=>{a.has(e)||(o?.observe(e),a.add(e))})}function X(){let e=K.current;e&&(cancelAnimationFrame(e.frame),cancelAnimationFrame(e.wrapperFrame),e.mutation?.disconnect(),e.resize?.disconnect(),K.current=null)}h(()=>X,[]),r(J,[J,R,s,D]);let Z=_(V);h(()=>{Z.current!==V&&(Z.current=V,T?.({overflowCount:V.length,visibleCount:W.current-V.length}))},[V]);let Q=p((e,t)=>B.set(e,{element:t}),[B]),$=p((e,t)=>{B.set(e,{link:t}),U.current.includes(e)&&B.notify()},[B]),ae=g(()=>({hidden:V,More:w,registerItem:Q,registerLink:$,update:J}),[V,Q,$,J]),oe=g(()=>({getLink:e=>B.entries.get(e)?.link??null,getVersion:B.getVersion,hidden:V,iconPlacement:l,menuContainer:u,menuPlacement:f,moreIcon:m,moreLabel:y,moreText:C,subscribe:B.subscribe}),[V,l,u,f,m,y,C,B]);return/* @__PURE__ */ d.createElement(o.Provider,{value:ae},/* @__PURE__ */ d.createElement(S.Provider,{value:oe},/* @__PURE__ */ d.createElement(R,{className:b(`nav-overflow`,a),style:ie?E:{...te,...E},...O,ref:re},n)))}const R=n(L,`NavOverflow`);export{R as t};
|
|
2
|
+
//# sourceMappingURL=nav-overflow-BxAhoMh3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav-overflow-GWARvoQZ.js","names":["HIDDEN_CLASS","devWarning","createPolymorphicComponent","useIsomorphicLayoutEffect","useHydrated","IconSlot","NavOverflowContext","Menu","MenuList","MenuToggle","React","classNames","NavOverflowMoreContext","createContext","lastShownStop","shown","item","stop","NavOverflowMore","state","useContext","visible","setVisible","useState","itemRef","useRef","focusWithinRef","hidden","empty","active","handleFocus","tabs","event","handleBlur","useSyncExternalStore","subscribeToNothing","zero","icon","ICON_STYLE","moreIcon","text","moreText","HIDDEN_CLASS$1","menuContainer","menuPlacement","moreLabel","iconPlacement","link","getLink","id","MenuItem","overflowingIds","movable","items","ids","overflowing","collapseAll","sum","gap","available","used","more","threshold","createRegistry","entries","listeners","version","entry","found","listener","next","value","HIDDEN_ATTRIBUTE","HIDDEN_CLASS","EMPTY","pixels","isHTMLElement","element","sameIds","a","b","index","resolveCollapseBelow","root","wrapper","width","UNMEASURED_STYLE","NavOverflowRender","rest","Component","component","wrapperRef","setWrapper","useCallback","forkedRef","useForkedRef","ref","hydrated","registry","setHidden","hiddenRef","itemCountRef","optionsRef","observersRef","measure","nav","child","children","elements","observe","wereHidden","moreWasHidden","wrapperStyle","navStyle","focused","collapseBelow","update","observers","disconnect","flush","flushSync","created","before","mutation","current","observed","resize","useEffect","reportedRef","onOverflow","registerItem","registerLink","controller","useMemo","className","style","NavOverflow"],"sources":["../../src/components/nav-overflow/more.tsx","../../src/components/nav-overflow/overflow.ts","../../src/components/nav-overflow/NavOverflow.tsx"],"sourcesContent":["import React, {\n createContext,\n CSSProperties,\n FocusEvent,\n ReactNode,\n useContext,\n useRef,\n useState,\n useSyncExternalStore\n} from 'react'\nimport classNames from 'classnames'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks'\nimport { IconValue } from '../../utils/iconConfig'\nimport { IconSlot } from '../icon/iconSlot'\nimport { NavOverflowLinkProps, NavOverflowMoreProps } from '../../utils/navOverflow'\nimport { Placement } from '../../utils/overlayPlacement'\nimport { Menu } from '../menu/Menu'\nimport { MenuItem } from '../menu/MenuItem'\nimport { MenuList } from '../menu/MenuList'\nimport { MenuToggle } from '../menu/MenuToggle'\n\n// From `NavOverflow` to the toggle item, which a list renders for it: the items in the menu, the\n// props their links registered, and how the toggle looks.\nexport interface NavOverflowMoreState {\n getLink: (id: string) => NavOverflowLinkProps | null\n getVersion: () => number\n hidden: readonly string[]\n iconPlacement: 'start' | 'end'\n menuContainer: boolean | Element | undefined\n menuPlacement: Placement\n moreIcon: IconValue | undefined\n moreLabel: string\n moreText: ReactNode | false\n subscribe: (listener: () => void) => () => void\n}\n\nexport const NavOverflowMoreContext = createContext<NavOverflowMoreState | null>(null)\n\n// The nearest item before `item` that is shown and can take focus: its link, or its tab.\nfunction lastShownStop(item: HTMLElement): HTMLElement | null {\n for (let shown = item.previousElementSibling; shown; shown = shown.previousElementSibling) {\n if (shown.hasAttribute('data-cx-nav-overflow')) continue\n const stop = shown.querySelector<HTMLElement>('a[href], button:not(:disabled), [tabindex]')\n if (stop) return stop\n }\n return null\n}\n\n// chassis-css's markup (`nav-overflow.js`): a `.nav-item.nav-overflow-item` holding the\n// `.nav-link.nav-overflow-toggle` button and the `.menu.nav-overflow-menu`. It is in the list at\n// all times, hidden while every item fits, so its width can be measured before it is needed.\nexport function NavOverflowMore({ tabs }: NavOverflowMoreProps) {\n const state = useContext(NavOverflowMoreContext)\n const [visible, setVisible] = useState(false)\n const itemRef = useRef<HTMLLIElement>(null)\n const focusWithinRef = useRef(false)\n const hidden = state?.hidden\n const empty = !hidden?.length\n\n // A resize can take away what has focus here: the toggle, when the last item leaves the menu,\n // or a menu item, when its item is back in the list. Neither blurs first, and focus would fall\n // to the page. It goes to the toggle while there is one, and to the last item otherwise.\n useIsomorphicLayoutEffect(() => {\n const item = itemRef.current\n if (!item || !focusWithinRef.current) return\n const active = item.ownerDocument.activeElement\n const lost = !active || active === item.ownerDocument.body || (empty && item.contains(active))\n if (!lost) return\n focusWithinRef.current = !empty\n const stop = empty\n ? lastShownStop(item)\n : item.querySelector<HTMLElement>('.nav-overflow-toggle')\n stop?.focus()\n }, [hidden, empty])\n\n const handleFocus = (event: FocusEvent) => {\n focusWithinRef.current = true\n // react-aria's tab list takes focus back to the selected tab when focus enters the list from\n // outside, which a click on the toggle does. The toggle is reached with the arrow keys, from\n // a tab (`TabList`), so the list doesn't need to hear of its focus.\n if (tabs) event.stopPropagation()\n }\n const handleBlur = () => {\n focusWithinRef.current = false\n }\n // A hidden item's link re-registers its props on each of its renders.\n useSyncExternalStore(\n state?.subscribe ?? subscribeToNothing,\n state?.getVersion ?? zero,\n state?.getVersion ?? zero\n )\n\n if (!state || !hidden) return null\n\n const { getLink, iconPlacement, menuContainer, menuPlacement, moreIcon, moreLabel, moreText } =\n state\n // The toggle goes when the last item leaves the menu, and an open menu with it.\n if (empty && visible) setVisible(false)\n\n // Keyed, so `iconPlacement` moves the two spans instead of turning one into the other.\n const icon = (\n <span key=\"icon\" className=\"nav-overflow-icon\" style={ICON_STYLE}>\n <IconSlot icon=\"more\" override={moreIcon} />\n </span>\n )\n const text =\n moreText === false ? null : (\n <span key=\"text\" className=\"nav-overflow-text\">\n {moreText}\n </span>\n )\n\n return (\n <Menu\n component=\"li\"\n className={classNames('nav-item nav-overflow-item', { [HIDDEN_CLASS]: empty })}\n // A `tablist` owns tabs only. The toggle is one of them, and the menu is rendered outside.\n // (No `instanceof Element`: a server has no `Element`.)\n container={tabs ? (typeof menuContainer === 'object' ? menuContainer : true) : menuContainer}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onVisibleChange={setVisible}\n placement={menuPlacement}\n visible={visible && !empty}\n {...(tabs && { role: 'presentation' })}\n ref={itemRef}\n >\n <MenuToggle\n aria-label={moreText === false ? moreLabel : undefined}\n caret={false}\n className=\"nav-link nav-overflow-toggle\"\n component=\"button\"\n {...(tabs && { 'aria-selected': false, role: 'tab', tabIndex: -1 })}\n >\n {iconPlacement === 'end' ? [text, icon] : [icon, text]}\n </MenuToggle>\n <MenuList className=\"nav-overflow-menu\">\n {hidden.map((id) => {\n const link = getLink(id)\n return link && <MenuItem key={id} {...link} />\n })}\n </MenuList>\n </Menu>\n )\n}\n\nconst HIDDEN_CLASS = 'd-none'\n// The icon as chassis-css's plugin draws its own: in the color of the toggle's text, and 1rem\n// wide. The default icon size is taller than a link's text, and would make the list a little\n// taller each time the toggle appeared.\nconst ICON_STYLE = { '--cx-icon-color': 'currentcolor', '--cx-icon-size': '1rem' } as CSSProperties\nconst subscribeToNothing = () => () => {}\nconst zero = () => 0\n","// Which items go into the menu, from widths `NavOverflow` has read with every item shown.\n\nexport interface MeasuredItem {\n /**\n * Unset for an item that registered nothing, which can't be moved.\n */\n id?: string\n /**\n * Stays in the list whatever the width: marked to keep, active, focused, or with no link for\n * the menu to show.\n */\n keep: boolean\n width: number\n}\n\nexport interface Measurement {\n /**\n * The width the items have to fit in.\n */\n available: number\n /**\n * The wrapper is narrower than `collapseBelow`.\n */\n collapseAll: boolean\n gap: number\n /**\n * In document order, without the toggle item.\n */\n items: MeasuredItem[]\n /**\n * The width of the toggle item.\n */\n more: number\n /**\n * The fewest items to leave in the list.\n */\n threshold: number\n}\n\n// A pixel of slack for sub-pixel layout: `offsetWidth` is rounded.\nconst SLACK = 1\n\nexport function overflowingIds({\n available,\n collapseAll,\n gap,\n items,\n more,\n threshold\n}: Measurement): string[] {\n const movable = items.filter((item) => !item.keep)\n const ids = (overflowing: MeasuredItem[]) => overflowing.map((item) => item.id as string)\n\n if (collapseAll) return ids(movable)\n\n // Everything fits without the toggle, which then isn't shown. chassis-css's plugin always\n // reserves the toggle's width, and so moves the last item of a list that fits exactly.\n const total = items.reduce((sum, item) => sum + item.width, 0) + gap * (items.length - 1)\n if (total <= available + SLACK) return []\n\n // The toggle and the kept items are shown whatever happens, each with the gap to the next.\n let used = more + items.reduce((sum, item) => (item.keep ? sum + item.width + gap : sum), 0)\n let overflowing = movable.filter((item) => {\n used += item.width + gap\n return used > available + SLACK\n })\n\n // Fewer than `threshold` would be left: the first `threshold` stay whatever the width. A list\n // that has no more than that keeps every item, as `slice` leaves none to move.\n if (items.length - overflowing.length < threshold) {\n overflowing = items.slice(threshold).filter((item) => !item.keep)\n }\n\n return ids(overflowing)\n}\n","import React, {\n CSSProperties,\n ElementType,\n ForwardRefRenderFunction,\n ReactElement,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react'\nimport { flushSync } from 'react-dom'\nimport classNames from 'classnames'\n\nimport { useForkedRef, useIsomorphicLayoutEffect } from '../../hooks'\nimport { Breakpoint } from '../../types'\nimport { devWarning } from '../../utils/devWarning'\nimport { IconValue } from '../../utils/iconConfig'\nimport {\n NavOverflowContext,\n NavOverflowController,\n NavOverflowLinkProps\n} from '../../utils/navOverflow'\nimport { Placement } from '../../utils/overlayPlacement'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { useHydrated } from '../../hooks/useHydrated'\nimport { NavOverflowMore, NavOverflowMoreContext, NavOverflowMoreState } from './more'\nimport { MeasuredItem, overflowingIds } from './overflow'\n\nexport interface NavOverflowDetail {\n /**\n * How many items are in the menu.\n */\n overflowCount: number\n /**\n * How many items are left in the list.\n */\n visibleCount: number\n}\n\ntype NavOverflowOwnProps<C extends ElementType> = {\n /**\n * The list to collapse: a `Nav`, a `NavbarNav` or a `TabList`.\n */\n children?: ReactNode\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Moves every item into the menu while the component is narrower than this: a width in pixels,\n * or the name of a breakpoint, read from `--cx-breakpoint-{name}`.\n */\n collapseBelow?: number | Breakpoint\n /**\n * Component used for the root node. Either a string to use an HTML element or a component.\n *\n * @default 'div'\n */\n component?: C\n /**\n * Which side of the toggle's text its icon is on.\n *\n * @default 'start'\n */\n iconPlacement?: 'start' | 'end'\n /**\n * Renders the menu in a container element instead of inside the toggle's item, where an\n * ancestor with `overflow` set would clip it: an element, or `true` for `document.body`. The\n * menu of a `TabList` is always rendered outside it.\n */\n menuContainer?: boolean | Element\n /**\n * Where the menu opens, relative to the toggle. It flips to stay in view.\n *\n * @default 'bottom-end'\n * @type 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'\n */\n menuPlacement?: Placement\n /**\n * The toggle's icon: an icon name, or an element of your own icon set. Defaults to\n * `IconProvider`'s `more` icon.\n */\n moreIcon?: IconValue\n /**\n * The accessible name of a toggle without text (`moreText={false}`).\n *\n * @default 'More'\n */\n moreLabel?: string\n /**\n * The toggle's text. `false` leaves the icon alone, named by `moreLabel`.\n *\n * @default 'More'\n */\n moreText?: ReactNode | false\n /**\n * Callback fired when items move into the menu or back out of it, with the number of items in\n * the menu and in the list.\n */\n onOverflow?: (detail: NavOverflowDetail) => void\n /**\n * The fewest items to leave in the list. They stay even when they don't fit.\n *\n * @default 0\n */\n threshold?: number\n}\n\nexport type NavOverflowProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n NavOverflowOwnProps<C>\n>\n\ntype NavOverflowComponent = (<C extends ElementType = 'div'>(\n props: NavOverflowProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\ninterface Entry {\n element: HTMLElement | null\n link: NavOverflowLinkProps | null\n}\n\ninterface Observers {\n frame: number\n mutation: MutationObserver | null\n nav: Element | null\n observed: Set<Element>\n resize: ResizeObserver | null\n wrapper: HTMLElement\n wrapperFrame: number\n}\n\n// What the items and links registered, and the listeners of the menu that renders from it. Kept\n// outside React state: a link registers new props on every one of its renders.\nfunction createRegistry() {\n const entries = new Map<string, Entry>()\n const listeners = new Set<() => void>()\n let version = 0\n\n const entry = (id: string) => {\n let found = entries.get(id)\n if (!found) {\n found = { element: null, link: null }\n entries.set(id, found)\n }\n return found\n }\n\n return {\n entries,\n getVersion: () => version,\n notify: () => {\n version += 1\n listeners.forEach((listener) => listener())\n },\n set: (id: string, value: Partial<Entry>) => {\n const next = Object.assign(entry(id), value)\n if (!next.element && !next.link) entries.delete(id)\n },\n subscribe: (listener: () => void) => {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n }\n }\n}\n\n// chassis-css hides an item with this attribute (`_nav-overflow.scss`) and the toggle item with\n// the display utility, as its plugin does.\nconst HIDDEN_ATTRIBUTE = 'data-cx-nav-overflow'\nconst HIDDEN_CLASS = 'd-none'\n\n// What keeps an item in the list by being inside it: the current link, and the tab that is the\n// list's Tab stop. react-aria gives that to the tab focused last, which needn't be the selected\n// one: hidden, it would leave the keyboard no way into the list.\nconst KEPT_CONTENT =\n '.nav-link.active, .nav-link[aria-current]:not([aria-current=\"false\"]), [role=\"tab\"][tabindex=\"0\"]'\n\nconst EMPTY: readonly string[] = []\n\nconst pixels = (value: string) => Number.parseFloat(value) || 0\n\n// Not `instanceof HTMLElement`: a list rendered into another window has that window's classes.\nconst isHTMLElement = (element: Element): element is HTMLElement => 'offsetWidth' in element\n\nconst sameIds = (a: readonly string[], b: readonly string[]) =>\n a.length === b.length && a.every((id, index) => id === b[index])\n\n// `collapseBelow` in pixels. A breakpoint is a custom property of chassis-css, in `rem`.\nfunction resolveCollapseBelow(value: number | Breakpoint | undefined, wrapper: HTMLElement) {\n if (typeof value === 'number') return value\n if (!value) return 0\n const root = getComputedStyle(wrapper.ownerDocument.documentElement)\n const width = root.getPropertyValue(`--cx-breakpoint-${value}`).trim()\n return /r?em$/.test(width) ? pixels(width) * (pixels(root.fontSize) || 16) : pixels(width)\n}\n\n// Until the page has hydrated nothing has been measured, and the server's HTML holds every item\n// on one line (`.nav-overflow > .nav` doesn't wrap). The items that don't fit are clipped at the\n// wrapper's edge and can be scrolled to, instead of running over what is next to the list.\nconst UNMEASURED_STYLE: CSSProperties = { overflowX: 'auto', scrollbarWidth: 'none' }\n\nfunction NavOverflowRender<C extends ElementType = 'div'>(\n {\n children,\n className,\n collapseBelow,\n component,\n iconPlacement = 'start',\n menuContainer,\n menuPlacement = 'bottom-end',\n moreIcon,\n moreLabel = 'More',\n moreText = 'More',\n onOverflow,\n style,\n threshold = 0,\n ...rest\n }: NavOverflowProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n // The wrapper, kept while React re-attaches a ref: a caller's ref that is a new function on\n // each render makes it detach and attach this one too, and in between, where the list's\n // effects run, there would be nothing to measure.\n const wrapperRef = useRef<HTMLElement | null>(null)\n const setWrapper = useCallback((element: HTMLElement | null) => {\n if (element) wrapperRef.current = element\n }, [])\n const forkedRef = useForkedRef(ref, setWrapper)\n const hydrated = useHydrated()\n\n const [registry] = useState(createRegistry)\n const [hidden, setHidden] = useState(EMPTY)\n const hiddenRef = useRef(hidden)\n const itemCountRef = useRef(0)\n const optionsRef = useRef({ collapseBelow, threshold })\n optionsRef.current = { collapseBelow, threshold }\n\n const observersRef = useRef<Observers | null>(null)\n\n // Which items don't fit, or `null` when there is nothing to measure.\n //\n // Widths are read with every item and the toggle shown, so they never depend on what the last\n // pass hid. Showing and hiding again happens in one synchronous block, outside React: the browser\n // paints neither, and the elements are back as React rendered them before it looks again.\n const measure = useCallback((): string[] | null => {\n const wrapper = wrapperRef.current?.isConnected ? wrapperRef.current : null\n const nav = wrapper && Array.from(wrapper.children).find((child) => child.matches('.nav'))\n devWarning(\n !!wrapper && !nav,\n 'NavOverflow: expects a `Nav`, a `NavbarNav` or a `TabList` as its child; found no `.nav` ' +\n 'to collapse.'\n )\n if (!wrapper || !nav) return null\n\n // Every child of the list takes room in the row, a title or a divider too; only registered\n // items can leave it.\n const children = Array.from(nav.children).filter(isHTMLElement)\n const more = children.find((child) => child.classList.contains('nav-overflow-item'))\n const elements = children.filter((child) => child !== more)\n observe(wrapper, nav, children)\n itemCountRef.current = elements.length\n // No toggle: the list is not one that takes part, so nothing can move.\n if (!more) return []\n\n const ids = new Map<Element, string>()\n registry.entries.forEach((entry, id) => {\n if (entry.element) ids.set(entry.element, id)\n })\n\n const wereHidden = elements.filter((element) => element.hasAttribute(HIDDEN_ATTRIBUTE))\n const moreWasHidden = more.classList.contains(HIDDEN_CLASS)\n wereHidden.forEach((element) => element.removeAttribute(HIDDEN_ATTRIBUTE))\n more.classList.remove(HIDDEN_CLASS)\n\n try {\n const wrapperStyle = getComputedStyle(wrapper)\n const navStyle = getComputedStyle(nav)\n // The wrapper's content box, as chassis-css's plugin takes it.\n const width =\n wrapper.clientWidth -\n pixels(wrapperStyle.paddingInlineStart) -\n pixels(wrapperStyle.paddingInlineEnd)\n const focused = wrapper.ownerDocument.activeElement\n\n const items = elements.map((element): MeasuredItem => {\n const id = ids.get(element)\n return {\n id,\n // An item stays in the list when the menu has nothing to show for it, when it is\n // marked to stay, when it is the current one or the list's Tab stop, and while it has\n // focus, which hiding it would drop.\n keep:\n !id ||\n !registry.entries.get(id)?.link ||\n element.classList.contains('nav-overflow-keep') ||\n element.querySelector(KEPT_CONTENT) !== null ||\n element.contains(focused),\n width: element.offsetWidth\n }\n })\n\n const { collapseBelow, threshold } = optionsRef.current\n return overflowingIds({\n available:\n width -\n pixels(navStyle.paddingInlineStart) -\n pixels(navStyle.paddingInlineEnd) -\n pixels(navStyle.borderInlineStartWidth) -\n pixels(navStyle.borderInlineEndWidth),\n collapseAll: width < resolveCollapseBelow(collapseBelow, wrapper),\n gap: pixels(navStyle.columnGap),\n items,\n more: more.offsetWidth,\n threshold\n })\n } finally {\n wereHidden.forEach((element) => element.setAttribute(HIDDEN_ATTRIBUTE, 'true'))\n if (moreWasHidden) more.classList.add(HIDDEN_CLASS)\n // Lay the list out as it was. Without this the layout stays as measured, with everything\n // shown, until the browser next needs it, and a ResizeObserver delivering in the meantime\n // (react-aria's, on the toggle) is told of sizes that were never painted.\n void wrapper.offsetWidth\n // The mutations above are this function's own.\n observersRef.current?.mutation?.takeRecords()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [registry])\n\n const update = useCallback(() => {\n const next = measure()\n if (!next || sameIds(next, hiddenRef.current)) return\n hiddenRef.current = next\n setHidden(next)\n }, [measure])\n\n // What changes the result without a render of the list:\n //\n // - The wrapper's width. The wrapper and not the list, whose width the result itself changes.\n // - An item's width: a font that loads, a label that changes.\n // - A link that becomes the current one by itself, as a router's link does on navigation.\n //\n // An observer's callback runs before the browser paints, and `flushSync` commits the result\n // there, so no frame shows the items of the old width.\n //\n // A ResizeObserver delivers sizes top down, and reports a loop error when a callback changes\n // a size it has already passed. Two things here would: hiding an item's siblings from the\n // callback for that item, so an item's own resize waits a frame; and a toggle taller than the\n // links, which changes the wrapper's height from the wrapper's own callback, so the wrapper is\n // observed again from the next frame once a pass has moved anything.\n function observe(wrapper: HTMLElement, nav: Element, children: HTMLElement[]) {\n let observers = observersRef.current\n if (observers && observers.wrapper !== wrapper) {\n disconnect()\n observers = null\n }\n if (!observers) {\n const flush = () => flushSync(update)\n const created: Observers = {\n frame: 0,\n mutation: typeof MutationObserver === 'undefined' ? null : new MutationObserver(flush),\n nav: null,\n observed: new Set(),\n resize:\n typeof ResizeObserver === 'undefined'\n ? null\n : new ResizeObserver((entries) => {\n if (!entries.some((entry) => entry.target === wrapper)) {\n cancelAnimationFrame(created.frame)\n created.frame = requestAnimationFrame(flush)\n return\n }\n const before = hiddenRef.current\n flush()\n // The pass can have replaced these observers, for a wrapper that is a new element.\n if (hiddenRef.current === before || observersRef.current !== created) return\n created.resize?.unobserve(wrapper)\n cancelAnimationFrame(created.wrapperFrame)\n created.wrapperFrame = requestAnimationFrame(() => created.resize?.observe(wrapper))\n }),\n wrapperFrame: 0,\n wrapper\n }\n observers = observersRef.current = created\n observers.resize?.observe(wrapper)\n }\n const { mutation, observed, resize } = observers\n\n if (observers.nav !== nav) {\n observers.nav = nav\n mutation?.disconnect()\n mutation?.observe(nav, {\n attributeFilter: ['class', 'aria-current'],\n attributes: true,\n childList: true,\n subtree: true\n })\n }\n\n const current = new Set<Element>(children)\n observed.forEach((element) => {\n if (current.has(element)) return\n resize?.unobserve(element)\n observed.delete(element)\n })\n current.forEach((element) => {\n if (observed.has(element)) return\n resize?.observe(element)\n observed.add(element)\n })\n }\n\n function disconnect() {\n const observers = observersRef.current\n if (!observers) return\n cancelAnimationFrame(observers.frame)\n cancelAnimationFrame(observers.wrapperFrame)\n observers.mutation?.disconnect()\n observers.resize?.disconnect()\n observersRef.current = null\n }\n\n useEffect(() => disconnect, [])\n\n // The list measures after each of its commits (`NavOverflowItems`). This covers what it can't:\n // the first commit and a wrapper that becomes another element, where React attaches the\n // wrapper's ref after the list's effects have run, and the options, which can change without\n // the list rendering.\n useIsomorphicLayoutEffect(update, [update, Component, collapseBelow, threshold])\n\n const reportedRef = useRef(hidden)\n useEffect(() => {\n if (reportedRef.current === hidden) return\n reportedRef.current = hidden\n onOverflow?.({\n overflowCount: hidden.length,\n visibleCount: itemCountRef.current - hidden.length\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hidden])\n\n const registerItem = useCallback(\n (id: string, element: HTMLElement | null) => registry.set(id, { element }),\n [registry]\n )\n const registerLink = useCallback(\n (id: string, link: NavOverflowLinkProps | null) => {\n registry.set(id, { link })\n // The menu renders from these props, and only it needs to hear of new ones.\n if (hiddenRef.current.includes(id)) registry.notify()\n },\n [registry]\n )\n\n const controller: NavOverflowController = useMemo(\n () => ({ hidden, More: NavOverflowMore, registerItem, registerLink, update }),\n [hidden, registerItem, registerLink, update]\n )\n\n const more: NavOverflowMoreState = useMemo(\n () => ({\n getLink: (id) => registry.entries.get(id)?.link ?? null,\n getVersion: registry.getVersion,\n hidden,\n iconPlacement,\n menuContainer,\n menuPlacement,\n moreIcon,\n moreLabel,\n moreText,\n subscribe: registry.subscribe\n }),\n [hidden, iconPlacement, menuContainer, menuPlacement, moreIcon, moreLabel, moreText, registry]\n )\n\n return (\n <NavOverflowContext.Provider value={controller}>\n <NavOverflowMoreContext.Provider value={more}>\n <Component\n className={classNames('nav-overflow', className)}\n style={hydrated ? style : { ...UNMEASURED_STYLE, ...style }}\n {...rest}\n ref={forkedRef}\n >\n {children}\n </Component>\n </NavOverflowMoreContext.Provider>\n </NavOverflowContext.Provider>\n )\n}\n\nexport const NavOverflow = createPolymorphicComponent<NavOverflowComponent>(\n NavOverfl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etG,EAAO,OACtB,aAAc0E,EAAa,QAAU1E,EAAO,MAC9C,CAAC,EAEH,EAAG,CAACA,CAAM,CAAC,EAEX,IAAMuG,EAAerC,GAClB,EAAY,IAAgCK,EAAS,IAAIjD,EAAI,CAAE,SAAQ,CAAC,EACzE,CAACiD,CAAQ,CACX,EACMiC,EAAetC,GAClB,EAAY,IAAsC,CACjDK,EAAS,IAAIjD,EAAI,CAAE,MAAK,CAAC,EAErBmD,EAAU,QAAQ,SAASnD,CAAE,GAAGiD,EAAS,OAAO,CACtD,EACA,CAACA,CAAQ,CACX,EAEMkC,GAAoCC,OACjC,CAAE,SAAQ,KAAMnH,EAAiB,eAAc,eAAc,QAAO,GAC3E,CAACS,EAAQuG,EAAcC,EAAcf,CAAM,CAC7C,EAEMvD,GAA6BwE,OAC1B,CACL,QAAU,GAAOnC,EAAS,QAAQ,IAAIjD,CAAE,CAAC,EAAE,MAAQ,KACnD,WAAYiD,EAAS,WACrB,SACA,gBACA,gBACA,gBACA,WACA,YACA,WACA,UAAWA,EAAS,SACtB,GACA,CAACvE,EAAQmB,EAAeH,EAAeC,EAAeL,EAAUM,EAAWJ,EAAUyD,CAAQ,CAC/F,EAEA,MACE,kBAAA,cAAC5F,EAAmB,SAApB,CAA6B,MAAO8H,EAWP,EAV3B,kBAAA,cAACxH,EAAuB,SAAxB,CAAiC,MAAOiD,EASP,EAR/B,kBAAA,cAAC4B,EAAD,CACE,UAAW9E,EAAW,eAAgB2H,CAAS,EAC/C,MAAOrC,GAAWsC,EAAQ,CAAE,GAAGjD,GAAkB,GAAGiD,CAAM,EAC1D,GAAI/C,EACJ,IAAKM,EAGI,EADRa,CACQ,CACoB,CACN,CAEjC,CAEA,MAAa6B,EAActI,EACzBqF,EACA,aACF,E"}
|
|
1
|
+
{"version":3,"file":"nav-overflow-BxAhoMh3.js","names":["HIDDEN_CLASS","devWarning","createPolymorphicComponent","useIsomorphicLayoutEffect","useHydrated","IconSlot","NavOverflowContext","Menu","MenuList","MenuToggle","React","classNames","NavOverflowMoreContext","createContext","lastShownStop","shown","item","stop","NavOverflowMore","state","useContext","visible","setVisible","useState","itemRef","useRef","focusWithinRef","hidden","empty","active","handleFocus","tabs","event","handleBlur","useSyncExternalStore","subscribeToNothing","zero","icon","ICON_STYLE","moreIcon","text","moreText","HIDDEN_CLASS$1","menuContainer","menuPlacement","moreLabel","iconPlacement","link","getLink","id","MenuItem","overflowingIds","movable","items","ids","overflowing","collapseAll","sum","gap","available","used","more","threshold","createRegistry","entries","listeners","version","entry","found","listener","next","value","HIDDEN_ATTRIBUTE","HIDDEN_CLASS","EMPTY","pixels","isHTMLElement","element","sameIds","a","b","index","resolveCollapseBelow","root","wrapper","width","UNMEASURED_STYLE","NavOverflowRender","rest","Component","component","wrapperRef","setWrapper","useCallback","forkedRef","useForkedRef","ref","hydrated","registry","setHidden","hiddenRef","itemCountRef","optionsRef","observersRef","measure","nav","child","children","elements","observe","wereHidden","moreWasHidden","wrapperStyle","navStyle","focused","collapseBelow","update","observers","disconnect","flush","flushSync","created","before","mutation","current","observed","resize","useEffect","reportedRef","onOverflow","registerItem","registerLink","controller","useMemo","className","style","NavOverflow"],"sources":["../../src/components/nav-overflow/more.tsx","../../src/components/nav-overflow/overflow.ts","../../src/components/nav-overflow/NavOverflow.tsx"],"sourcesContent":["import React, {\n createContext,\n CSSProperties,\n FocusEvent,\n ReactNode,\n useContext,\n useRef,\n useState,\n useSyncExternalStore\n} from 'react'\nimport classNames from 'classnames'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks'\nimport { IconValue } from '../../utils/iconConfig'\nimport { IconSlot } from '../icon/iconSlot'\nimport { NavOverflowLinkProps, NavOverflowMoreProps } from '../../utils/navOverflow'\nimport { Placement } from '../../utils/overlayPlacement'\nimport { Menu } from '../menu/Menu'\nimport { MenuItem } from '../menu/MenuItem'\nimport { MenuList } from '../menu/MenuList'\nimport { MenuToggle } from '../menu/MenuToggle'\n\n// From `NavOverflow` to the toggle item, which a list renders for it: the items in the menu, the\n// props their links registered, and how the toggle looks.\nexport interface NavOverflowMoreState {\n getLink: (id: string) => NavOverflowLinkProps | null\n getVersion: () => number\n hidden: readonly string[]\n iconPlacement: 'start' | 'end'\n menuContainer: boolean | Element | undefined\n menuPlacement: Placement\n moreIcon: IconValue | undefined\n moreLabel: string\n moreText: ReactNode | false\n subscribe: (listener: () => void) => () => void\n}\n\nexport const NavOverflowMoreContext = createContext<NavOverflowMoreState | null>(null)\n\n// The nearest item before `item` that is shown and can take focus: its link, or its tab.\nfunction lastShownStop(item: HTMLElement): HTMLElement | null {\n for (let shown = item.previousElementSibling; shown; shown = shown.previousElementSibling) {\n if (shown.hasAttribute('data-cx-nav-overflow')) continue\n const stop = shown.querySelector<HTMLElement>('a[href], button:not(:disabled), [tabindex]')\n if (stop) return stop\n }\n return null\n}\n\n// chassis-css's markup (`nav-overflow.js`): a `.nav-item.nav-overflow-item` holding the\n// `.nav-link.nav-overflow-toggle` button and the `.menu.nav-overflow-menu`. It is in the list at\n// all times, hidden while every item fits, so its width can be measured before it is needed.\nexport function NavOverflowMore({ tabs }: NavOverflowMoreProps) {\n const state = useContext(NavOverflowMoreContext)\n const [visible, setVisible] = useState(false)\n const itemRef = useRef<HTMLLIElement>(null)\n const focusWithinRef = useRef(false)\n const hidden = state?.hidden\n const empty = !hidden?.length\n\n // A resize can take away what has focus here: the toggle, when the last item leaves the menu,\n // or a menu item, when its item is back in the list. Neither blurs first, and focus would fall\n // to the page. It goes to the toggle while there is one, and to the last item otherwise.\n useIsomorphicLayoutEffect(() => {\n const item = itemRef.current\n if (!item || !focusWithinRef.current) return\n const active = item.ownerDocument.activeElement\n const lost = !active || active === item.ownerDocument.body || (empty && item.contains(active))\n if (!lost) return\n focusWithinRef.current = !empty\n const stop = empty\n ? lastShownStop(item)\n : item.querySelector<HTMLElement>('.nav-overflow-toggle')\n stop?.focus()\n }, [hidden, empty])\n\n const handleFocus = (event: FocusEvent) => {\n focusWithinRef.current = true\n // react-aria's tab list takes focus back to the selected tab when focus enters the list from\n // outside, which a click on the toggle does. The toggle is reached with the arrow keys, from\n // a tab (`TabList`), so the list doesn't need to hear of its focus.\n if (tabs) event.stopPropagation()\n }\n const handleBlur = () => {\n focusWithinRef.current = false\n }\n // A hidden item's link re-registers its props on each of its renders.\n useSyncExternalStore(\n state?.subscribe ?? subscribeToNothing,\n state?.getVersion ?? zero,\n state?.getVersion ?? zero\n )\n\n if (!state || !hidden) return null\n\n const { getLink, iconPlacement, menuContainer, menuPlacement, moreIcon, moreLabel, moreText } =\n state\n // The toggle goes when the last item leaves the menu, and an open menu with it.\n if (empty && visible) setVisible(false)\n\n // Keyed, so `iconPlacement` moves the two spans instead of turning one into the other.\n const icon = (\n <span key=\"icon\" className=\"nav-overflow-icon\" style={ICON_STYLE}>\n <IconSlot icon=\"more\" override={moreIcon} />\n </span>\n )\n const text =\n moreText === false ? null : (\n <span key=\"text\" className=\"nav-overflow-text\">\n {moreText}\n </span>\n )\n\n return (\n <Menu\n component=\"li\"\n className={classNames('nav-item nav-overflow-item', { [HIDDEN_CLASS]: empty })}\n // A `tablist` owns tabs only. The toggle is one of them, and the menu is rendered outside.\n // (No `instanceof Element`: a server has no `Element`.)\n container={tabs ? (typeof menuContainer === 'object' ? menuContainer : true) : menuContainer}\n onBlur={handleBlur}\n onFocus={handleFocus}\n onVisibleChange={setVisible}\n placement={menuPlacement}\n visible={visible && !empty}\n {...(tabs && { role: 'presentation' })}\n ref={itemRef}\n >\n <MenuToggle\n aria-label={moreText === false ? moreLabel : undefined}\n caret={false}\n className=\"nav-link nav-overflow-toggle\"\n component=\"button\"\n {...(tabs && { 'aria-selected': false, role: 'tab', tabIndex: -1 })}\n >\n {iconPlacement === 'end' ? [text, icon] : [icon, text]}\n </MenuToggle>\n <MenuList className=\"nav-overflow-menu\">\n {hidden.map((id) => {\n const link = getLink(id)\n return link && <MenuItem key={id} {...link} />\n })}\n </MenuList>\n </Menu>\n )\n}\n\nconst HIDDEN_CLASS = 'd-none'\n// The icon as chassis-css's plugin draws its own: in the color of the toggle's text, and 1rem\n// wide. The default icon size is taller than a link's text, and would make the list a little\n// taller each time the toggle appeared.\nconst ICON_STYLE = { '--cx-icon-color': 'currentcolor', '--cx-icon-size': '1rem' } as CSSProperties\nconst subscribeToNothing = () => () => {}\nconst zero = () => 0\n","// Which items go into the menu, from widths `NavOverflow` has read with every item shown.\n\nexport interface MeasuredItem {\n /**\n * Unset for an item that registered nothing, which can't be moved.\n */\n id?: string\n /**\n * Stays in the list whatever the width: marked to keep, active, focused, or with no link for\n * the menu to show.\n */\n keep: boolean\n width: number\n}\n\nexport interface Measurement {\n /**\n * The width the items have to fit in.\n */\n available: number\n /**\n * The wrapper is narrower than `collapseBelow`.\n */\n collapseAll: boolean\n gap: number\n /**\n * In document order, without the toggle item.\n */\n items: MeasuredItem[]\n /**\n * The width of the toggle item.\n */\n more: number\n /**\n * The fewest items to leave in the list.\n */\n threshold: number\n}\n\n// A pixel of slack for sub-pixel layout: `offsetWidth` is rounded.\nconst SLACK = 1\n\nexport function overflowingIds({\n available,\n collapseAll,\n gap,\n items,\n more,\n threshold\n}: Measurement): string[] {\n const movable = items.filter((item) => !item.keep)\n const ids = (overflowing: MeasuredItem[]) => overflowing.map((item) => item.id as string)\n\n if (collapseAll) return ids(movable)\n\n // Everything fits without the toggle, which then isn't shown. chassis-css's plugin always\n // reserves the toggle's width, and so moves the last item of a list that fits exactly.\n const total = items.reduce((sum, item) => sum + item.width, 0) + gap * (items.length - 1)\n if (total <= available + SLACK) return []\n\n // The toggle and the kept items are shown whatever happens, each with the gap to the next.\n let used = more + items.reduce((sum, item) => (item.keep ? sum + item.width + gap : sum), 0)\n let overflowing = movable.filter((item) => {\n used += item.width + gap\n return used > available + SLACK\n })\n\n // Fewer than `threshold` would be left: the first `threshold` stay whatever the width. A list\n // that has no more than that keeps every item, as `slice` leaves none to move.\n if (items.length - overflowing.length < threshold) {\n overflowing = items.slice(threshold).filter((item) => !item.keep)\n }\n\n return ids(overflowing)\n}\n","import React, {\n CSSProperties,\n ElementType,\n ForwardRefRenderFunction,\n ReactElement,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react'\nimport { flushSync } from 'react-dom'\nimport classNames from 'classnames'\n\nimport { useForkedRef, useIsomorphicLayoutEffect } from '../../hooks'\nimport { Breakpoint } from '../../types'\nimport { devWarning } from '../../utils/devWarning'\nimport { IconValue } from '../../utils/iconConfig'\nimport {\n NavOverflowContext,\n NavOverflowController,\n NavOverflowLinkProps\n} from '../../utils/navOverflow'\nimport { Placement } from '../../utils/overlayPlacement'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { useHydrated } from '../../hooks/useHydrated'\nimport { NavOverflowMore, NavOverflowMoreContext, NavOverflowMoreState } from './more'\nimport { MeasuredItem, overflowingIds } from './overflow'\n\nexport interface NavOverflowDetail {\n /**\n * How many items are in the menu.\n */\n overflowCount: number\n /**\n * How many items are left in the list.\n */\n visibleCount: number\n}\n\ntype NavOverflowOwnProps<C extends ElementType> = {\n /**\n * The list to collapse: a `Nav`, a `NavbarNav` or a `TabList`.\n */\n children?: ReactNode\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Moves every item into the menu while the component is narrower than this: a width in pixels,\n * or the name of a breakpoint, read from `--cx-breakpoint-{name}`.\n */\n collapseBelow?: number | Breakpoint\n /**\n * Component used for the root node. Either a string to use an HTML element or a component.\n *\n * @default 'div'\n */\n component?: C\n /**\n * Which side of the toggle's text its icon is on.\n *\n * @default 'start'\n */\n iconPlacement?: 'start' | 'end'\n /**\n * Renders the menu in a container element instead of inside the toggle's item, where an\n * ancestor with `overflow` set would clip it: an element, or `true` for `document.body`. The\n * menu of a `TabList` is always rendered outside it.\n */\n menuContainer?: boolean | Element\n /**\n * Where the menu opens, relative to the toggle. It flips to stay in view.\n *\n * @default 'bottom-end'\n * @type 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end'\n */\n menuPlacement?: Placement\n /**\n * The toggle's icon: an icon name, or an element of your own icon set. Defaults to\n * `IconProvider`'s `more` icon.\n */\n moreIcon?: IconValue\n /**\n * The accessible name of a toggle without text (`moreText={false}`).\n *\n * @default 'More'\n */\n moreLabel?: string\n /**\n * The toggle's text. `false` leaves the icon alone, named by `moreLabel`.\n *\n * @default 'More'\n */\n moreText?: ReactNode | false\n /**\n * Callback fired when items move into the menu or back out of it, with the number of items in\n * the menu and in the list.\n */\n onOverflow?: (detail: NavOverflowDetail) => void\n /**\n * The fewest items to leave in the list. They stay even when they don't fit.\n *\n * @default 0\n */\n threshold?: number\n}\n\nexport type NavOverflowProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n NavOverflowOwnProps<C>\n>\n\ntype NavOverflowComponent = (<C extends ElementType = 'div'>(\n props: NavOverflowProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\ninterface Entry {\n element: HTMLElement | null\n link: NavOverflowLinkProps | null\n}\n\ninterface Observers {\n frame: number\n mutation: MutationObserver | null\n nav: Element | null\n observed: Set<Element>\n resize: ResizeObserver | null\n wrapper: HTMLElement\n wrapperFrame: number\n}\n\n// What the items and links registered, and the listeners of the menu that renders from it. Kept\n// outside React state: a link registers new props on every one of its renders.\nfunction createRegistry() {\n const entries = new Map<string, Entry>()\n const listeners = new Set<() => void>()\n let version = 0\n\n const entry = (id: string) => {\n let found = entries.get(id)\n if (!found) {\n found = { element: null, link: null }\n entries.set(id, found)\n }\n return found\n }\n\n return {\n entries,\n getVersion: () => version,\n notify: () => {\n version += 1\n listeners.forEach((listener) => listener())\n },\n set: (id: string, value: Partial<Entry>) => {\n const next = Object.assign(entry(id), value)\n if (!next.element && !next.link) entries.delete(id)\n },\n subscribe: (listener: () => void) => {\n listeners.add(listener)\n return () => {\n listeners.delete(listener)\n }\n }\n }\n}\n\n// chassis-css hides an item with this attribute (`_nav-overflow.scss`) and the toggle item with\n// the display utility, as its plugin does.\nconst HIDDEN_ATTRIBUTE = 'data-cx-nav-overflow'\nconst HIDDEN_CLASS = 'd-none'\n\n// What keeps an item in the list by being inside it: the current link, and the tab that is the\n// list's Tab stop. react-aria gives that to the tab focused last, which needn't be the selected\n// one: hidden, it would leave the keyboard no way into the list.\nconst KEPT_CONTENT =\n '.nav-link.active, .nav-link[aria-current]:not([aria-current=\"false\"]), [role=\"tab\"][tabindex=\"0\"]'\n\nconst EMPTY: readonly string[] = []\n\nconst pixels = (value: string) => Number.parseFloat(value) || 0\n\n// Not `instanceof HTMLElement`: a list rendered into another window has that window's classes.\nconst isHTMLElement = (element: Element): element is HTMLElement => 'offsetWidth' in element\n\nconst sameIds = (a: readonly string[], b: readonly string[]) =>\n a.length === b.length && a.every((id, index) => id === b[index])\n\n// `collapseBelow` in pixels. A breakpoint is a custom property of chassis-css, in `rem`.\nfunction resolveCollapseBelow(value: number | Breakpoint | undefined, wrapper: HTMLElement) {\n if (typeof value === 'number') return value\n if (!value) return 0\n const root = getComputedStyle(wrapper.ownerDocument.documentElement)\n const width = root.getPropertyValue(`--cx-breakpoint-${value}`).trim()\n return /r?em$/.test(width) ? pixels(width) * (pixels(root.fontSize) || 16) : pixels(width)\n}\n\n// Until the page has hydrated nothing has been measured, and the server's HTML holds every item\n// on one line (`.nav-overflow > .nav` doesn't wrap). The items that don't fit are clipped at the\n// wrapper's edge and can be scrolled to, instead of running over what is next to the list.\nconst UNMEASURED_STYLE: CSSProperties = { overflowX: 'auto', scrollbarWidth: 'none' }\n\nfunction NavOverflowRender<C extends ElementType = 'div'>(\n {\n children,\n className,\n collapseBelow,\n component,\n iconPlacement = 'start',\n menuContainer,\n menuPlacement = 'bottom-end',\n moreIcon,\n moreLabel = 'More',\n moreText = 'More',\n onOverflow,\n style,\n threshold = 0,\n ...rest\n }: NavOverflowProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n // The wrapper, kept while React re-attaches a ref: a caller's ref that is a new function on\n // each render makes it detach and attach this one too, and in between, where the list's\n // effects run, there would be nothing to measure.\n const wrapperRef = useRef<HTMLElement | null>(null)\n const setWrapper = useCallback((element: HTMLElement | null) => {\n if (element) wrapperRef.current = element\n }, [])\n const forkedRef = useForkedRef(ref, setWrapper)\n const hydrated = useHydrated()\n\n const [registry] = useState(createRegistry)\n const [hidden, setHidden] = useState(EMPTY)\n const hiddenRef = useRef(hidden)\n const itemCountRef = useRef(0)\n const optionsRef = useRef({ collapseBelow, threshold })\n optionsRef.current = { collapseBelow, threshold }\n\n const observersRef = useRef<Observers | null>(null)\n\n // Which items don't fit, or `null` when there is nothing to measure.\n //\n // Widths are read with every item and the toggle shown, so they never depend on what the last\n // pass hid. Showing and hiding again happens in one synchronous block, outside React: the browser\n // paints neither, and the elements are back as React rendered them before it looks again.\n const measure = useCallback((): string[] | null => {\n const wrapper = wrapperRef.current?.isConnected ? wrapperRef.current : null\n const nav = wrapper && Array.from(wrapper.children).find((child) => child.matches('.nav'))\n devWarning(\n !!wrapper && !nav,\n 'NavOverflow: expects a `Nav`, a `NavbarNav` or a `TabList` as its child; found no `.nav` ' +\n 'to collapse.'\n )\n if (!wrapper || !nav) return null\n\n // Every child of the list takes room in the row, a title or a divider too; only registered\n // items can leave it.\n const children = Array.from(nav.children).filter(isHTMLElement)\n const more = children.find((child) => child.classList.contains('nav-overflow-item'))\n const elements = children.filter((child) => child !== more)\n observe(wrapper, nav, children)\n itemCountRef.current = elements.length\n // No toggle: the list is not one that takes part, so nothing can move.\n if (!more) return []\n\n const ids = new Map<Element, string>()\n registry.entries.forEach((entry, id) => {\n if (entry.element) ids.set(entry.element, id)\n })\n\n const wereHidden = elements.filter((element) => element.hasAttribute(HIDDEN_ATTRIBUTE))\n const moreWasHidden = more.classList.contains(HIDDEN_CLASS)\n wereHidden.forEach((element) => element.removeAttribute(HIDDEN_ATTRIBUTE))\n more.classList.remove(HIDDEN_CLASS)\n\n try {\n const wrapperStyle = getComputedStyle(wrapper)\n const navStyle = getComputedStyle(nav)\n // The wrapper's content box, as chassis-css's plugin takes it.\n const width =\n wrapper.clientWidth -\n pixels(wrapperStyle.paddingInlineStart) -\n pixels(wrapperStyle.paddingInlineEnd)\n const focused = wrapper.ownerDocument.activeElement\n\n const items = elements.map((element): MeasuredItem => {\n const id = ids.get(element)\n return {\n id,\n // An item stays in the list when the menu has nothing to show for it, when it is\n // marked to stay, when it is the current one or the list's Tab stop, and while it has\n // focus, which hiding it would drop.\n keep:\n !id ||\n !registry.entries.get(id)?.link ||\n element.classList.contains('nav-overflow-keep') ||\n element.querySelector(KEPT_CONTENT) !== null ||\n element.contains(focused),\n width: element.offsetWidth\n }\n })\n\n const { collapseBelow, threshold } = optionsRef.current\n return overflowingIds({\n available:\n width -\n pixels(navStyle.paddingInlineStart) -\n pixels(navStyle.paddingInlineEnd) -\n pixels(navStyle.borderInlineStartWidth) -\n pixels(navStyle.borderInlineEndWidth),\n collapseAll: width < resolveCollapseBelow(collapseBelow, wrapper),\n gap: pixels(navStyle.columnGap),\n items,\n more: more.offsetWidth,\n threshold\n })\n } finally {\n wereHidden.forEach((element) => element.setAttribute(HIDDEN_ATTRIBUTE, 'true'))\n if (moreWasHidden) more.classList.add(HIDDEN_CLASS)\n // Lay the list out as it was. Without this the layout stays as measured, with everything\n // shown, until the browser next needs it, and a ResizeObserver delivering in the meantime\n // (react-aria's, on the toggle) is told of sizes that were never painted.\n void wrapper.offsetWidth\n // The mutations above are this function's own.\n observersRef.current?.mutation?.takeRecords()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [registry])\n\n const update = useCallback(() => {\n const next = measure()\n if (!next || sameIds(next, hiddenRef.current)) return\n hiddenRef.current = next\n setHidden(next)\n }, [measure])\n\n // What changes the result without a render of the list:\n //\n // - The wrapper's width. The wrapper and not the list, whose width the result itself changes.\n // - An item's width: a font that loads, a label that changes.\n // - A link that becomes the current one by itself, as a router's link does on navigation.\n //\n // An observer's callback runs before the browser paints, and `flushSync` commits the result\n // there, so no frame shows the items of the old width.\n //\n // A ResizeObserver delivers sizes top down, and reports a loop error when a callback changes\n // a size it has already passed. Two things here would: hiding an item's siblings from the\n // callback for that item, so an item's own resize waits a frame; and a toggle taller than the\n // links, which changes the wrapper's height from the wrapper's own callback, so the wrapper is\n // observed again from the next frame once a pass has moved anything.\n function observe(wrapper: HTMLElement, nav: Element, children: HTMLElement[]) {\n let observers = observersRef.current\n if (observers && observers.wrapper !== wrapper) {\n disconnect()\n observers = null\n }\n if (!observers) {\n const flush = () => flushSync(update)\n const created: Observers = {\n frame: 0,\n mutation: typeof MutationObserver === 'undefined' ? null : new MutationObserver(flush),\n nav: null,\n observed: new Set(),\n resize:\n typeof ResizeObserver === 'undefined'\n ? null\n : new ResizeObserver((entries) => {\n if (!entries.some((entry) => entry.target === wrapper)) {\n cancelAnimationFrame(created.frame)\n created.frame = requestAnimationFrame(flush)\n return\n }\n const before = hiddenRef.current\n flush()\n // The pass can have replaced these observers, for a wrapper that is a new element.\n if (hiddenRef.current === before || observersRef.current !== created) return\n created.resize?.unobserve(wrapper)\n cancelAnimationFrame(created.wrapperFrame)\n created.wrapperFrame = requestAnimationFrame(() => created.resize?.observe(wrapper))\n }),\n wrapperFrame: 0,\n wrapper\n }\n observers = observersRef.current = created\n observers.resize?.observe(wrapper)\n }\n const { mutation, observed, resize } = observers\n\n if (observers.nav !== nav) {\n observers.nav = nav\n mutation?.disconnect()\n mutation?.observe(nav, {\n attributeFilter: ['class', 'aria-current'],\n attributes: true,\n childList: true,\n subtree: true\n })\n }\n\n const current = new Set<Element>(children)\n observed.forEach((element) => {\n if (current.has(element)) return\n resize?.unobserve(element)\n observed.delete(element)\n })\n current.forEach((element) => {\n if (observed.has(element)) return\n resize?.observe(element)\n observed.add(element)\n })\n }\n\n function disconnect() {\n const observers = observersRef.current\n if (!observers) return\n cancelAnimationFrame(observers.frame)\n cancelAnimationFrame(observers.wrapperFrame)\n observers.mutation?.disconnect()\n observers.resize?.disconnect()\n observersRef.current = null\n }\n\n useEffect(() => disconnect, [])\n\n // The list measures after each of its commits (`NavOverflowItems`). This covers what it can't:\n // the first commit and a wrapper that becomes another element, where React attaches the\n // wrapper's ref after the list's effects have run, and the options, which can change without\n // the list rendering.\n useIsomorphicLayoutEffect(update, [update, Component, collapseBelow, threshold])\n\n const reportedRef = useRef(hidden)\n useEffect(() => {\n if (reportedRef.current === hidden) return\n reportedRef.current = hidden\n onOverflow?.({\n overflowCount: hidden.length,\n visibleCount: itemCountRef.current - hidden.length\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [hidden])\n\n const registerItem = useCallback(\n (id: string, element: HTMLElement | null) => registry.set(id, { element }),\n [registry]\n )\n const registerLink = useCallback(\n (id: string, link: NavOverflowLinkProps | null) => {\n registry.set(id, { link })\n // The menu renders from these props, and only it needs to hear of new ones.\n if (hiddenRef.current.includes(id)) registry.notify()\n },\n [registry]\n )\n\n const controller: NavOverflowController = useMemo(\n () => ({ hidden, More: NavOverflowMore, registerItem, registerLink, update }),\n [hidden, registerItem, registerLink, update]\n )\n\n const more: NavOverflowMoreState = useMemo(\n () => ({\n getLink: (id) => registry.entries.get(id)?.link ?? null,\n getVersion: registry.getVersion,\n hidden,\n iconPlacement,\n menuContainer,\n menuPlacement,\n moreIcon,\n moreLabel,\n moreText,\n subscribe: registry.subscribe\n }),\n [hidden, iconPlacement, menuContainer, menuPlacement, moreIcon, moreLabel, moreText, registry]\n )\n\n return (\n <NavOverflowContext.Provider value={controller}>\n <NavOverflowMoreContext.Provider value={more}>\n <Component\n className={classNames('nav-overflow', className)}\n style={hydrated ? style : { ...UNMEASURED_STYLE, ...style }}\n {...rest}\n ref={forkedRef}\n >\n {children}\n </Component>\n </NavOverflowMoreContext.Provider>\n </NavOverflowContext.Provider>\n )\n}\n\nexport const NavOverflow = createPolymorphicComponent<NavOverflowComponent>(\n NavOverflowRender as ForwardRefRenderFunction<Element, NavOverflowProps<ElementType>>,\n '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9C,CAAC,EAEH,EAAG,CAACA,CAAM,CAAC,EAEX,IAAMuG,EAAerC,GAClB,EAAY,IAAgCK,EAAS,IAAIjD,EAAI,CAAE,SAAQ,CAAC,EACzE,CAACiD,CAAQ,CACX,EACMiC,EAAetC,GAClB,EAAY,IAAsC,CACjDK,EAAS,IAAIjD,EAAI,CAAE,MAAK,CAAC,EAErBmD,EAAU,QAAQ,SAASnD,CAAE,GAAGiD,EAAS,OAAO,CACtD,EACA,CAACA,CAAQ,CACX,EAEMkC,GAAoCC,OACjC,CAAE,SAAQ,KAAMnH,EAAiB,eAAc,eAAc,QAAO,GAC3E,CAACS,EAAQuG,EAAcC,EAAcf,CAAM,CAC7C,EAEMvD,GAA6BwE,OAC1B,CACL,QAAU,GAAOnC,EAAS,QAAQ,IAAIjD,CAAE,CAAC,EAAE,MAAQ,KACnD,WAAYiD,EAAS,WACrB,SACA,gBACA,gBACA,gBACA,WACA,YACA,WACA,UAAWA,EAAS,SACtB,GACA,CAACvE,EAAQmB,EAAeH,EAAeC,EAAeL,EAAUM,EAAWJ,EAAUyD,CAAQ,CAC/F,EAEA,MACE,kBAAA,cAAC5F,EAAmB,SAApB,CAA6B,MAAO8H,EAWP,EAV3B,kBAAA,cAACxH,EAAuB,SAAxB,CAAiC,MAAOiD,EASP,EAR/B,kBAAA,cAAC4B,EAAD,CACE,UAAW9E,EAAW,eAAgB2H,CAAS,EAC/C,MAAOrC,GAAWsC,EAAQ,CAAE,GAAGjD,GAAkB,GAAGiD,CAAM,EAC1D,GAAI/C,EACJ,IAAKM,EAGI,EADRa,CACQ,CACoB,CACN,CAEjC,CAEA,MAAa6B,EAActI,EACzBqF,EACA,aACF,E"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=navOverflow-
|
|
1
|
+
import{C as e,a as t,s as n}from"./slot-DagH0Gxq.js";import{t as r}from"./useIsomorphicLayoutEffect-BbqRwuqn.js";import i,{cloneElement as a,createContext as o,useCallback as s,useContext as c,useId as l,useMemo as u}from"react";const d=o(null),f=o(null);function p({children:e}){return/* @__PURE__ */ i.createElement(f.Provider,{value:null},e)}function m({children:t,tabs:n,tag:a}){let o=a===void 0||a===`ul`||a===`ol`,s=c(d);e(!!s&&!o,`NavOverflow: collapses the \`NavItem\`s of a list, and a <${a}> has none. Leave out \`component\` to render a <ul>.`);let l=o?s:null,p=u(()=>l?{controller:l}:null,[l]),m=l?.update;r(()=>{m?.()});let h=l?.More;return/* @__PURE__ */ i.createElement(i.Fragment,null,/* @__PURE__ */ i.createElement(d.Provider,{value:null},/* @__PURE__ */ i.createElement(f.Provider,{value:p},t)),h&&/* @__PURE__ */ i.createElement(h,{tabs:n}))}const h=f.Provider;function g(e){let t=c(f),n=l(),r=t&&t.itemId===void 0?t.controller:null,i=u(()=>r?{controller:r,itemId:n}:null,[r,n]),a=r?.registerItem,o=s(e=>a?.(n,e),[a,n]);return b(e?r?.registerLink:void 0,n,e),{hidden:!!r&&r.hidden.includes(n),ref:r?o:void 0,scope:i}}const _=()=>c(f)?.itemId!==void 0;function v({props:e}){let r=c(f),i=n(),{component:o,...s}=y(e);return b(r?.itemId===void 0?void 0:r.controller.registerLink,r?.itemId,t(o)&&i?{...s,asChild:!0,children:a(i,{id:void 0,ref:null})}:{...s,component:o}),null}function y(e){return Object.fromEntries(Object.entries(e).filter(([e])=>e!==`id`&&e!==`aria-describedby`&&(e===`onClick`||!/^on[A-Z]/.test(e))))}function b(e,t,n){r(()=>{e&&t!==void 0&&n&&e(t,n)}),r(()=>{if(e&&t!==void 0)return()=>e(t,null)},[e,t])}export{v as a,m as i,d as n,_ as o,h as r,g as s,p as t};
|
|
2
|
+
//# sourceMappingURL=navOverflow-eSROB_mV.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navOverflow-C_QJmkPM.js","names":["devWarning","isSlot","useSlotElement","useIsomorphicLayoutEffect","React","NavOverflowContext","createContext","NavOverflowScopeContext","NavOverflowBoundary","children","NavOverflowItems","collapses","tag","inherited","useContext","controller","scope","useMemo","update","More","NavOverflowItemScope","useNavOverflowItem","id","useId","registerItem","ref","useCallback","element","useRegisteredLink","link","useIsNavOverflowLink","NavOverflowLink","slotted","menuProps","props","component","cloneElement","name","register"],"sources":["../../src/utils/navOverflow.tsx"],"sourcesContent":["import React, {\n cloneElement,\n ComponentType,\n createContext,\n ReactElement,\n ReactNode,\n RefCallback,\n useCallback,\n useContext,\n useId,\n useMemo\n} from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../hooks/useIsomorphicLayoutEffect'\nimport { devWarning } from './devWarning'\nimport { isSlot, useSlotElement } from './slot'\n\n// How `NavOverflow` (`components/nav-overflow`) and the lists it collapses work together.\n//\n// chassis-css's plugin clones the links that don't fit into its menu. A clone has no React\n// behind it: no `onClick`, no router link. Here nothing is cloned. Three parts take a role each:\n//\n// - The list (`Nav`, `NavbarNav`, `TabList`) renders `NavOverflowItems` around its items, which\n// adds the toggle item after them.\n// - An item (`NavItem`, a tab) registers its `<li>`, which is what `NavOverflow` measures and\n// hides.\n// - The item's link (`NavLink`) registers the props it was rendered with, and the menu renders a\n// `MenuItem` from them. An item with no link registered, such as one holding a dropdown, has\n// nothing to show in the menu, so it is never moved.\n//\n// An item is known by an id of its own rather than by its position among the list's children, so\n// a component that renders several items, or a fragment of them, works like items written in\n// place. `NavOverflow` takes their order from the document.\n//\n// These live here, not in `components/nav-overflow`, so that `Nav` and `Tabs` import a context and\n// nothing else: the toggle and its `Menu` reach a list through the controller (`More`), and stay\n// out of the bundle of a page that only renders a `Nav`.\n\n/** The props a link hands to the `MenuItem` that stands in for it. */\nexport type NavOverflowLinkProps = Record<string, unknown>\n\nexport interface NavOverflowMoreProps {\n /**\n * The list is a `tablist`: the toggle is one of its tabs, and its menu is rendered outside it.\n */\n tabs?: boolean\n}\n\nexport interface NavOverflowController {\n /**\n * The ids of the items that are in the menu, in document order.\n */\n hidden: readonly string[]\n /**\n * The toggle item and its menu, rendered by the list after its items.\n */\n More: ComponentType<NavOverflowMoreProps>\n registerItem: (id: string, element: HTMLElement | null) => void\n registerLink: (id: string, props: NavOverflowLinkProps | null) => void\n /**\n * Measures again. A list calls it after each of its commits.\n */\n update: () => void\n}\n\n/**\n * From `NavOverflow` to the list directly inside it.\n */\nexport const NavOverflowContext = createContext<NavOverflowController | null>(null)\n\n// From the list to its items (`itemId` unset), and from an item to its link (`itemId` set). One\n// context, so an item nested in another item finds `itemId` set and knows it isn't the list's own.\ninterface NavOverflowScope {\n controller: NavOverflowController\n itemId?: string\n}\n\nconst NavOverflowScopeContext = createContext<NavOverflowScope | null>(null)\n\n/**\n * Closes the scope for everything inside: a `Menu` in an item isn't that item's link, and neither\n * is anything in its list.\n */\nexport function NavOverflowBoundary({ children }: { children?: ReactNode }): ReactElement {\n return (\n <NavOverflowScopeContext.Provider value={null}>{children}</NavOverflowScopeContext.Provider>\n )\n}\n\n/**\n * A list's items. Inside a `NavOverflow` they are the items it collapses, followed by the toggle\n * item. Anywhere else they render as they are, and a list nested in a collapsing item takes no\n * part in it.\n */\nexport function NavOverflowItems({\n children,\n tabs,\n tag\n}: NavOverflowMoreProps & {\n children?: ReactNode\n /**\n * The tag the list renders, when it is known. The toggle item is an `<li>`, so only a `<ul>`\n * or an `<ol>` takes part.\n */\n tag?: string\n}): ReactElement {\n const collapses = tag === undefined || tag === 'ul' || tag === 'ol'\n const inherited = useContext(NavOverflowContext)\n devWarning(\n !!inherited && !collapses,\n `NavOverflow: collapses the \\`NavItem\\`s of a list, and a <${tag}> has none. Leave out ` +\n `\\`component\\` to render a <ul>.`\n )\n const controller = collapses ? inherited : null\n const scope = useMemo(() => (controller ? { controller } : null), [controller])\n const update = controller?.update\n\n // After every commit of the list: an item added, removed, renamed or made active changes what\n // fits, and none of those resizes the wrapper.\n useIsomorphicLayoutEffect(() => {\n update?.()\n })\n\n const More = controller?.More\n\n return (\n <>\n <NavOverflowContext.Provider value={null}>\n <NavOverflowScopeContext.Provider value={scope}>\n {children}\n </NavOverflowScopeContext.Provider>\n </NavOverflowContext.Provider>\n {More && <More tabs={tabs} />}\n </>\n )\n}\n\nexport interface NavOverflowItem {\n /**\n * Whether the item is in the menu, and so hidden in the list.\n */\n hidden: boolean\n /**\n * For the item's `<li>`. `undefined` outside a collapsing list.\n */\n ref: RefCallback<HTMLElement> | undefined\n /**\n * For `NavOverflowItemScope`, around the item's children.\n */\n scope: NavOverflowScope | null\n}\n\nexport const NavOverflowItemScope = NavOverflowScopeContext.Provider\n\n/**\n * An item of a list. `link` is for an item that is its own link, as a tab is; an item that holds\n * a `NavLink` leaves it out, and the link registers itself.\n */\nexport function useNavOverflowItem(link?: NavOverflowLinkProps): NavOverflowItem {\n const inherited = useContext(NavOverflowScopeContext)\n const id = useId()\n // The list's own items only: inside another item, `itemId` is that item's.\n const controller = inherited && inherited.itemId === undefined ? inherited.controller : null\n const scope = useMemo(() => (controller ? { controller, itemId: id } : null), [controller, id])\n const registerItem = controller?.registerItem\n const ref = useCallback(\n (element: HTMLElement | null) => registerItem?.(id, element),\n [registerItem, id]\n )\n\n useRegisteredLink(link ? controller?.registerLink : undefined, id, link)\n\n return {\n hidden: !!controller && controller.hidden.includes(id),\n ref: controller ? ref : undefined,\n scope\n }\n}\n\n/**\n * Whether the caller is the link of an item that can move into the menu, and so should render a\n * `NavOverflowLink`.\n */\nexport const useIsNavOverflowLink = (): boolean =>\n useContext(NavOverflowScopeContext)?.itemId !== undefined\n\n/**\n * Registers the props of an item's link, which the menu renders its `MenuItem` from. It renders\n * nothing. A component, not a hook, because a link rendered with `asChild` has to hand over the\n * element it was given, and only something rendered beside the `Slot` can read that.\n */\nexport function NavOverflowLink({ props }: { props: NavOverflowLinkProps }): null {\n const scope = useContext(NavOverflowScopeContext)\n const slotted = useSlotElement()\n const { component, ...link } = menuProps(props)\n useRegisteredLink(\n scope?.itemId === undefined ? undefined : scope.controller.registerLink,\n scope?.itemId,\n isSlot(component) && slotted\n ? // The caller's element, without what is its own in the list: its `ref` would be taken\n // over by the copy in the menu, and dropped when that copy went.\n { ...link, asChild: true, children: cloneElement(slotted, { id: undefined, ref: null }) }\n : { ...link, component }\n )\n return null\n}\n\n// What a link hands to its menu item. Not its `id`: the two are in the document together. And of\n// its handlers, `onClick` only: the rest are for the link where it is, such as the hover and\n// focus handlers a `Tooltip` around it adds, which would open a tooltip anchored to a hidden\n// link. Its description goes with them.\nfunction menuProps(props: NavOverflowLinkProps): NavOverflowLinkProps {\n return Object.fromEntries(\n Object.entries(props).filter(\n ([name]) =>\n name !== 'id' &&\n name !== 'aria-describedby' &&\n (name === 'onClick' || !/^on[A-Z]/.test(name))\n )\n )\n}\n\nfunction useRegisteredLink(\n register: NavOverflowController['registerLink'] | undefined,\n id: string | undefined,\n props: NavOverflowLinkProps | undefined\n) {\n // On every commit: the props are new objects on each render, and the menu shows the latest.\n useIsomorphicLayoutEffect(() => {\n if (register && id !== undefined && props) register(id, props)\n })\n\n useIsomorphicLayoutEffect(() => {\n if (!register || id === undefined) return undefined\n return () => register(id, null)\n }, [register, id])\n}\n"],"mappings":"A,qOAoEA,MAAaK,EAAqBC,EAA4C,IAAI,EAS5EC,EAA0BD,EAAuC,IAAI,EAM3E,SAAgBE,EAAoB,CAAE,YAAoD,CACxF,MACE,kBAAA,cAACD,EAAwB,SAAzB,CAAkC,MAAO,IAAkD,EAA3CE,CAA2C,CAE/F,CAOA,SAAgBC,EAAiB,CAC/B,WACA,OACA,OAQe,CACf,IAAMC,EAAYC,IAAQ,IAAA,IAAaA,IAAQ,MAAQA,IAAQ,KACzDC,EAAYC,EAAWT,CAAkB,EAC/CL,EACE,CAAC,CAACa,GAAa,CAACF,EAChB,6DAA6DC,EAAI,sDAEnE,EACA,IAAMG,EAAaJ,EAAYE,EAAY,KACrCG,EAAQC,MAAeF,EAAa,CAAE,YAAW,EAAI,KAAO,CAACA,CAAU,CAAC,EACxEG,EAASH,GAAY,OAI3BZ,MAAgC,CAC9Be,IAAS,CACX,CAAC,EAED,IAAMC,EAAO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AM,WAAU,CAC3B,EACO,IACT,CAMA,SAASI,EAAU,EAAmD,CACpE,OAAO,OAAO,YACZ,OAAO,QAAQC,CAAK,CAAC,CAAC,QACnB,CAACG,KACAA,IAAS,MACTA,IAAS,qBACRA,IAAS,WAAa,CAAC,WAAW,KAAKA,CAAI,EAChD,CACF,CACF,CAEA,SAAST,EACP,EACA,EACA,EACA,CAEAzB,MAAgC,CAC1BmC,GAAYhB,IAAO,IAAA,IAAaY,GAAOI,EAAShB,EAAIY,CAAK,CAC/D,CAAC,EAED/B,MAAgC,CAC9B,GAAKmC,GAAYhB,IAAO,IAAA,GACxB,UAAagB,EAAShB,EAAI,IAAI,CAChC,EAAG,CAACgB,EAAUhB,CAAE,CAAC,CACnB,C"}
|
|
1
|
+
{"version":3,"file":"navOverflow-eSROB_mV.js","names":["devWarning","isSlot","useSlotElement","useIsomorphicLayoutEffect","React","NavOverflowContext","createContext","NavOverflowScopeContext","NavOverflowBoundary","children","NavOverflowItems","collapses","tag","inherited","useContext","controller","scope","useMemo","update","More","NavOverflowItemScope","useNavOverflowItem","id","useId","registerItem","ref","useCallback","element","useRegisteredLink","link","useIsNavOverflowLink","NavOverflowLink","slotted","menuProps","props","component","cloneElement","name","register"],"sources":["../../src/utils/navOverflow.tsx"],"sourcesContent":["import React, {\n cloneElement,\n ComponentType,\n createContext,\n ReactElement,\n ReactNode,\n RefCallback,\n useCallback,\n useContext,\n useId,\n useMemo\n} from 'react'\n\nimport { useIsomorphicLayoutEffect } from '../hooks/useIsomorphicLayoutEffect'\nimport { devWarning } from './devWarning'\nimport { isSlot, useSlotElement } from './slot'\n\n// How `NavOverflow` (`components/nav-overflow`) and the lists it collapses work together.\n//\n// chassis-css's plugin clones the links that don't fit into its menu. A clone has no React\n// behind it: no `onClick`, no router link. Here nothing is cloned. Three parts take a role each:\n//\n// - The list (`Nav`, `NavbarNav`, `TabList`) renders `NavOverflowItems` around its items, which\n// adds the toggle item after them.\n// - An item (`NavItem`, a tab) registers its `<li>`, which is what `NavOverflow` measures and\n// hides.\n// - The item's link (`NavLink`) registers the props it was rendered with, and the menu renders a\n// `MenuItem` from them. An item with no link registered, such as one holding a dropdown, has\n// nothing to show in the menu, so it is never moved.\n//\n// An item is known by an id of its own rather than by its position among the list's children, so\n// a component that renders several items, or a fragment of them, works like items written in\n// place. `NavOverflow` takes their order from the document.\n//\n// These live here, not in `components/nav-overflow`, so that `Nav` and `Tabs` import a context and\n// nothing else: the toggle and its `Menu` reach a list through the controller (`More`), and stay\n// out of the bundle of a page that only renders a `Nav`.\n\n/** The props a link hands to the `MenuItem` that stands in for it. */\nexport type NavOverflowLinkProps = Record<string, unknown>\n\nexport interface NavOverflowMoreProps {\n /**\n * The list is a `tablist`: the toggle is one of its tabs, and its menu is rendered outside it.\n */\n tabs?: boolean\n}\n\nexport interface NavOverflowController {\n /**\n * The ids of the items that are in the menu, in document order.\n */\n hidden: readonly string[]\n /**\n * The toggle item and its menu, rendered by the list after its items.\n */\n More: ComponentType<NavOverflowMoreProps>\n registerItem: (id: string, element: HTMLElement | null) => void\n registerLink: (id: string, props: NavOverflowLinkProps | null) => void\n /**\n * Measures again. A list calls it after each of its commits.\n */\n update: () => void\n}\n\n/**\n * From `NavOverflow` to the list directly inside it.\n */\nexport const NavOverflowContext = createContext<NavOverflowController | null>(null)\n\n// From the list to its items (`itemId` unset), and from an item to its link (`itemId` set). One\n// context, so an item nested in another item finds `itemId` set and knows it isn't the list's own.\ninterface NavOverflowScope {\n controller: NavOverflowController\n itemId?: string\n}\n\nconst NavOverflowScopeContext = createContext<NavOverflowScope | null>(null)\n\n/**\n * Closes the scope for everything inside: a `Menu` in an item isn't that item's link, and neither\n * is anything in its list.\n */\nexport function NavOverflowBoundary({ children }: { children?: ReactNode }): ReactElement {\n return (\n <NavOverflowScopeContext.Provider value={null}>{children}</NavOverflowScopeContext.Provider>\n )\n}\n\n/**\n * A list's items. Inside a `NavOverflow` they are the items it collapses, followed by the toggle\n * item. Anywhere else they render as they are, and a list nested in a collapsing item takes no\n * part in it.\n */\nexport function NavOverflowItems({\n children,\n tabs,\n tag\n}: NavOverflowMoreProps & {\n children?: ReactNode\n /**\n * The tag the list renders, when it is known. The toggle item is an `<li>`, so only a `<ul>`\n * or an `<ol>` takes part.\n */\n tag?: string\n}): ReactElement {\n const collapses = tag === undefined || tag === 'ul' || tag === 'ol'\n const inherited = useContext(NavOverflowContext)\n devWarning(\n !!inherited && !collapses,\n `NavOverflow: collapses the \\`NavItem\\`s of a list, and a <${tag}> has none. Leave out ` +\n `\\`component\\` to render a <ul>.`\n )\n const controller = collapses ? inherited : null\n const scope = useMemo(() => (controller ? { controller } : null), [controller])\n const update = controller?.update\n\n // After every commit of the list: an item added, removed, renamed or made active changes what\n // fits, and none of those resizes the wrapper.\n useIsomorphicLayoutEffect(() => {\n update?.()\n })\n\n const More = controller?.More\n\n return (\n <>\n <NavOverflowContext.Provider value={null}>\n <NavOverflowScopeContext.Provider value={scope}>\n {children}\n </NavOverflowScopeContext.Provider>\n </NavOverflowContext.Provider>\n {More && <More tabs={tabs} />}\n </>\n )\n}\n\nexport interface NavOverflowItem {\n /**\n * Whether the item is in the menu, and so hidden in the list.\n */\n hidden: boolean\n /**\n * For the item's `<li>`. `undefined` outside a collapsing list.\n */\n ref: RefCallback<HTMLElement> | undefined\n /**\n * For `NavOverflowItemScope`, around the item's children.\n */\n scope: NavOverflowScope | null\n}\n\nexport const NavOverflowItemScope = NavOverflowScopeContext.Provider\n\n/**\n * An item of a list. `link` is for an item that is its own link, as a tab is; an item that holds\n * a `NavLink` leaves it out, and the link registers itself.\n */\nexport function useNavOverflowItem(link?: NavOverflowLinkProps): NavOverflowItem {\n const inherited = useContext(NavOverflowScopeContext)\n const id = useId()\n // The list's own items only: inside another item, `itemId` is that item's.\n const controller = inherited && inherited.itemId === undefined ? inherited.controller : null\n const scope = useMemo(() => (controller ? { controller, itemId: id } : null), [controller, id])\n const registerItem = controller?.registerItem\n const ref = useCallback(\n (element: HTMLElement | null) => registerItem?.(id, element),\n [registerItem, id]\n )\n\n useRegisteredLink(link ? controller?.registerLink : undefined, id, link)\n\n return {\n hidden: !!controller && controller.hidden.includes(id),\n ref: controller ? ref : undefined,\n scope\n }\n}\n\n/**\n * Whether the caller is the link of an item that can move into the menu, and so should render a\n * `NavOverflowLink`.\n */\nexport const useIsNavOverflowLink = (): boolean =>\n useContext(NavOverflowScopeContext)?.itemId !== undefined\n\n/**\n * Registers the props of an item's link, which the menu renders its `MenuItem` from. It renders\n * nothing. A component, not a hook, because a link rendered with `asChild` has to hand over the\n * element it was given, and only something rendered beside the `Slot` can read that.\n */\nexport function NavOverflowLink({ props }: { props: NavOverflowLinkProps }): null {\n const scope = useContext(NavOverflowScopeContext)\n const slotted = useSlotElement()\n const { component, ...link } = menuProps(props)\n useRegisteredLink(\n scope?.itemId === undefined ? undefined : scope.controller.registerLink,\n scope?.itemId,\n isSlot(component) && slotted\n ? // The caller's element, without what is its own in the list: its `ref` would be taken\n // over by the copy in the menu, and dropped when that copy went.\n { ...link, asChild: true, children: cloneElement(slotted, { id: undefined, ref: null }) }\n : { ...link, component }\n )\n return null\n}\n\n// What a link hands to its menu item. Not its `id`: the two are in the document together. And of\n// its handlers, `onClick` only: the rest are for the link where it is, such as the hover and\n// focus handlers a `Tooltip` around it adds, which would open a tooltip anchored to a hidden\n// link. Its description goes with them.\nfunction menuProps(props: NavOverflowLinkProps): NavOverflowLinkProps {\n return Object.fromEntries(\n Object.entries(props).filter(\n ([name]) =>\n name !== 'id' &&\n name !== 'aria-describedby' &&\n (name === 'onClick' || !/^on[A-Z]/.test(name))\n )\n )\n}\n\nfunction useRegisteredLink(\n register: NavOverflowController['registerLink'] | undefined,\n id: string | undefined,\n props: NavOverflowLinkProps | undefined\n) {\n // On every commit: the props are new objects on each render, and the menu shows the latest.\n useIsomorphicLayoutEffect(() => {\n if (register && id !== undefined && props) register(id, props)\n })\n\n useIsomorphicLayoutEffect(() => {\n if (!register || id === undefined) return undefined\n return () => register(id, null)\n },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,GAAY,aAAe,IAAA,GAAWO,EAAIO,CAAI,EAEhE,CACL,OAAQ,CAAC,CAACd,GAAcA,EAAW,OAAO,SAASO,CAAE,EACrD,IAAKP,EAAaU,EAAM,IAAA,GACxB,OACF,CACF,CAMA,MAAaK,MACXhB,EAAWP,CAAuB,CAAC,EAAE,SAAW,IAAA,GAOlD,SAAgBwB,EAAgB,CAAE,SAAgD,CAChF,IAAMf,EAAQF,EAAWP,CAAuB,EAC1CyB,EAAU9B,EAAe,EACzB,CAAE,YAAW,GAAG2B,GAASI,EAAUC,CAAK,EAU9C,OATAN,EACEZ,GAAO,SAAW,IAAA,GAAY,IAAA,GAAYA,EAAM,WAAW,aAC3DA,GAAO,OACPf,EAAOkC,CAAS,GAAKH,EAGjB,CAAE,GAAGH,EAAM,QAAS,GAAM,SAAUO,EAAaJ,EAAS,CAAE,GAAI,IAAA,GAAW,IAAK,IAAK,CAAC,CAAE,EACxF,CAAE,GAAGH,EAAM,WAAU,CAC3B,EACO,IACT,CAMA,SAASI,EAAU,EAAmD,CACpE,OAAO,OAAO,YACZ,OAAO,QAAQC,CAAK,CAAC,CAAC,QACnB,CAACG,KACAA,IAAS,MACTA,IAAS,qBACRA,IAAS,WAAa,CAAC,WAAW,KAAKA,CAAI,EAChD,CACF,CACF,CAEA,SAAST,EACP,EACA,EACA,EACA,CAEAzB,MAAgC,CAC1BmC,GAAYhB,IAAO,IAAA,IAAaY,GAAOI,EAAShB,EAAIY,CAAK,CAC/D,CAAC,EAED/B,MAAgC,CAC9B,GAAKmC,GAAYhB,IAAO,IAAA,GACxB,UAAagB,EAAShB,EAAI,IAAI,CAChC,EAAG,CAACgB,EAAUhB,CAAE,CAAC,CACnB,C"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
2
|
-
//# sourceMappingURL=navVariant-
|
|
1
|
+
import{C as e}from"./slot-DagH0Gxq.js";function t(t,n){return e(t===`pills`,`${n}: variant="pills" is deprecated, use variant="segments" instead. It will be removed in a future major version.`),t&&`nav-${t===`pills`?`segments`:t}`}export{t};
|
|
2
|
+
//# sourceMappingURL=navVariant-Bm5k8CY3.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navVariant-
|
|
1
|
+
{"version":3,"file":"navVariant-Bm5k8CY3.js","names":["devWarning","navVariantClassName","variant","displayName"],"sources":["../../src/utils/navVariant.ts"],"sourcesContent":["import { devWarning } from './devWarning'\n\n// The looks of a `.nav` that `Nav` and `TabList` share. `'pills'` is what `'segments'` was called\n// until chassis-css 0.6 renamed `.nav-pills` to `.nav-segments`: still accepted, deprecated.\nexport type NavVariant = 'tabs' | 'segments' | 'underline' | 'pills'\n\nexport function navVariantClassName(\n variant: NavVariant | undefined,\n displayName: string\n): string | undefined {\n devWarning(\n variant === 'pills',\n `${displayName}: variant=\"pills\" is deprecated, use variant=\"segments\" instead. It will be ` +\n 'removed in a future major version.'\n )\n\n return variant && `nav-${variant === 'pills' ? 'segments' : variant}`\n}\n"],"mappings":"A,uCAMA,SAAgBC,EACd,EACA,EACoB,CAOpB,OANAD,EACEE,IAAY,QACZ,GAAGC,EAAY,+GAEjB,EAEOD,GAAW,OAAOA,IAAY,QAAU,WAAaA,GAC9D,C"}
|