@chassis-ui/react 0.4.1 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -6
- package/dist/accordion.d.ts +1 -1
- package/dist/accordion.js +1 -1
- package/dist/alert.d.ts +1 -1
- package/dist/alert.js +1 -1
- package/dist/autocomplete.d.ts +1 -1
- package/dist/autocomplete.js +1 -1
- package/dist/avatar.d.ts +1 -1
- package/dist/avatar.js +1 -1
- package/dist/badge.d.ts +1 -1
- package/dist/badge.js +1 -1
- package/dist/breadcrumb.d.ts +1 -1
- package/dist/breadcrumb.js +1 -1
- package/dist/button-group.d.ts +1 -1
- package/dist/button-group.js +1 -1
- package/dist/button.d.ts +2 -2
- package/dist/button.js +1 -1
- package/dist/calendar.d.ts +1 -1
- package/dist/calendar.js +1 -1
- package/dist/card.d.ts +1 -1
- package/dist/card.js +1 -1
- package/dist/carousel.d.ts +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.d.ts +1 -1
- package/dist/chip-input.js +1 -1
- package/dist/chip.d.ts +1 -1
- package/dist/chip.js +1 -1
- package/dist/chunks/{Button-BuZ_GOHS.d.ts → Button-DblYVwl-.d.ts} +4 -2
- package/dist/chunks/Button-ZU-x1uN_.js +2 -0
- package/dist/chunks/Button-ZU-x1uN_.js.map +1 -0
- package/dist/chunks/Chip-C7QlFCvx.js +2 -0
- package/dist/chunks/Chip-C7QlFCvx.js.map +1 -0
- package/dist/chunks/CloseButton-BPUI5iGX.js +2 -0
- package/dist/chunks/CloseButton-BPUI5iGX.js.map +1 -0
- package/dist/chunks/ComboboxListBox-Db0rSM3w.js +2 -0
- package/dist/chunks/ComboboxListBox-Db0rSM3w.js.map +1 -0
- package/dist/chunks/DateField-4cdcwt0v.js +2 -0
- package/dist/chunks/DateField-4cdcwt0v.js.map +1 -0
- package/dist/chunks/FormHelp-B1eSoack.js +2 -0
- package/dist/chunks/FormHelp-B1eSoack.js.map +1 -0
- package/dist/chunks/FormLabel-CpzWYh6U.js +2 -0
- package/dist/chunks/FormLabel-CpzWYh6U.js.map +1 -0
- package/dist/chunks/{Icon-DLB1f88W.js → Icon-Dk5_q79o.js} +2 -2
- package/dist/chunks/Icon-Dk5_q79o.js.map +1 -0
- package/dist/chunks/Link-DE8NSAXJ.js +2 -0
- package/dist/chunks/Link-DE8NSAXJ.js.map +1 -0
- package/dist/chunks/Menu-BiE9CzNk.js +2 -0
- package/dist/chunks/Menu-BiE9CzNk.js.map +1 -0
- package/dist/chunks/{Menu-QeYOzrUL.d.ts → Menu-CCYshRuL.d.ts} +3 -2
- package/dist/chunks/MenuToggle-W-ZSHFwF.js +2 -0
- package/dist/chunks/MenuToggle-W-ZSHFwF.js.map +1 -0
- package/dist/chunks/Portal-BTDylxAi.js +2 -0
- package/dist/chunks/Portal-BTDylxAi.js.map +1 -0
- package/dist/chunks/RangeCalendar-mM3OeTlU.js +2 -0
- package/dist/chunks/RangeCalendar-mM3OeTlU.js.map +1 -0
- package/dist/chunks/VisuallyHidden-CGv-mBuQ.js +2 -0
- package/dist/chunks/VisuallyHidden-CGv-mBuQ.js.map +1 -0
- package/dist/chunks/accordion-BZlX2uk8.js +2 -0
- package/dist/chunks/accordion-BZlX2uk8.js.map +1 -0
- package/dist/chunks/alert-DSLg5MBb.js +2 -0
- package/dist/chunks/alert-DSLg5MBb.js.map +1 -0
- package/dist/chunks/autocomplete-Btcsjrh3.js +2 -0
- package/dist/chunks/autocomplete-Btcsjrh3.js.map +1 -0
- package/dist/chunks/avatar-BQBbcnk6.js +2 -0
- package/dist/chunks/avatar-BQBbcnk6.js.map +1 -0
- package/dist/chunks/{badge-D2oztCvs.js → badge-Ths1Qn1a.js} +2 -2
- package/dist/chunks/badge-Ths1Qn1a.js.map +1 -0
- package/dist/chunks/breadcrumb-BTiQikk-.js +2 -0
- package/dist/chunks/breadcrumb-BTiQikk-.js.map +1 -0
- package/dist/chunks/breakpoints-CGk8szzR.js.map +1 -1
- package/dist/chunks/button-group-CefkGeYL.js +2 -0
- package/dist/chunks/button-group-CefkGeYL.js.map +1 -0
- package/dist/chunks/card-CEQgHIaL.js +2 -0
- package/dist/chunks/card-CEQgHIaL.js.map +1 -0
- package/dist/chunks/carousel-DC-UGc6W.js +2 -0
- package/dist/chunks/carousel-DC-UGc6W.js.map +1 -0
- package/dist/chunks/checkbox-ko6CdtoT.js +2 -0
- package/dist/chunks/checkbox-ko6CdtoT.js.map +1 -0
- package/dist/chunks/chip-input-CugY8EOc.js +2 -0
- package/dist/chunks/chip-input-CugY8EOc.js.map +1 -0
- package/dist/chunks/{collapse--Go2Y73B.js → collapse-CBi3RWTf.js} +2 -2
- package/dist/chunks/collapse-CBi3RWTf.js.map +1 -0
- package/dist/chunks/color-input-C4zMWlvm.js +2 -0
- package/dist/chunks/color-input-C4zMWlvm.js.map +1 -0
- package/dist/chunks/colorClassNames-YzGWu6qm.js +2 -0
- package/dist/chunks/colorClassNames-YzGWu6qm.js.map +1 -0
- package/dist/chunks/combobox-DNqR4d3V.js +2 -0
- package/dist/chunks/combobox-DNqR4d3V.js.map +1 -0
- package/dist/chunks/context-DCg95BgR.js +2 -0
- package/dist/chunks/context-DCg95BgR.js.map +1 -0
- package/dist/chunks/context-HDVxTNPi.js +2 -0
- package/dist/chunks/context-HDVxTNPi.js.map +1 -0
- package/dist/chunks/context-menu-D3DNFN-P.js +2 -0
- package/dist/chunks/context-menu-D3DNFN-P.js.map +1 -0
- package/dist/chunks/datagrid-n9vFeXN1.js +2 -0
- package/dist/chunks/datagrid-n9vFeXN1.js.map +1 -0
- package/dist/chunks/datepicker-DqztYJD6.js +2 -0
- package/dist/chunks/datepicker-DqztYJD6.js.map +1 -0
- package/dist/chunks/{dialogTransition-i9vw0i2Z.js → dialogTransition-C8fYTsSa.js} +2 -2
- package/dist/chunks/dialogTransition-C8fYTsSa.js.map +1 -0
- package/dist/chunks/direction-LN6uwsK5.js.map +1 -1
- package/dist/chunks/divider-C1-NoKMV.js +2 -0
- package/dist/chunks/divider-C1-NoKMV.js.map +1 -0
- package/dist/chunks/drawer-CRv9jmbp.js +2 -0
- package/dist/chunks/drawer-CRv9jmbp.js.map +1 -0
- package/dist/chunks/file-input-D_Gl1h-T.js +2 -0
- package/dist/chunks/file-input-D_Gl1h-T.js.map +1 -0
- package/dist/chunks/{flex-B52oLCCC.js → flex-C2jV5LyV.js} +2 -2
- package/dist/chunks/flex-C2jV5LyV.js.map +1 -0
- package/dist/chunks/floating-input-D4gWFfOU.js +2 -0
- package/dist/chunks/floating-input-D4gWFfOU.js.map +1 -0
- package/dist/chunks/focus-ring-Bs80iIBN.js +2 -0
- package/dist/chunks/focus-ring-Bs80iIBN.js.map +1 -0
- package/dist/chunks/focusRedirect-CrBl4p_n.js +2 -0
- package/dist/chunks/focusRedirect-CrBl4p_n.js.map +1 -0
- package/dist/chunks/form-CPS2eNw1.js +2 -0
- package/dist/chunks/form-CPS2eNw1.js.map +1 -0
- package/dist/chunks/{form-field-CNPGTMiW.js → form-field-Bcx96ezd.js} +2 -2
- package/dist/chunks/form-field-Bcx96ezd.js.map +1 -0
- package/dist/chunks/grid-CkdPftit.js +2 -0
- package/dist/chunks/grid-CkdPftit.js.map +1 -0
- package/dist/chunks/icon-CVD3rTr-.js +2 -0
- package/dist/chunks/icon-CVD3rTr-.js.map +1 -0
- package/dist/chunks/iconSlot-DU_WcSL_.js +2 -0
- package/dist/chunks/iconSlot-DU_WcSL_.js.map +1 -0
- package/dist/chunks/{index-91YA-jkp.d.ts → index-3JVLrDHv.d.ts} +11 -3
- package/dist/chunks/{index-DMbdEm__.d.ts → index-5mW1Y9Lm.d.ts} +7 -4
- package/dist/chunks/{index-Cc4SSslb.d.ts → index-5qsV1-cc.d.ts} +3 -3
- package/dist/chunks/{index-CYvVmTPR.d.ts → index-6PnrAJmb.d.ts} +4 -4
- package/dist/chunks/{index-BA-raEMm.d.ts → index-B5f6haU-.d.ts} +2 -2
- package/dist/chunks/{index-4cKG9KWB.d.ts → index-B8OIYfGw.d.ts} +2 -2
- package/dist/chunks/{index-CjT_4IZx.d.ts → index-BAvt_oPe.d.ts} +14 -5
- package/dist/chunks/{index-DtbUXxjz.d.ts → index-BB8UNxnM.d.ts} +2 -2
- package/dist/chunks/{index-aRdgpeRb.d.ts → index-BEAZrhyV.d.ts} +2 -2
- package/dist/chunks/{index-BOx8v-oT.d.ts → index-BISMaKaC.d.ts} +14 -2
- package/dist/chunks/{index-DtvHH_Mb.d.ts → index-BOroLDDZ.d.ts} +2 -2
- package/dist/chunks/{index-C4Dks__B.d.ts → index-BZpHSGlk.d.ts} +2 -2
- package/dist/chunks/{index-C9gzVqwX.d.ts → index-BbZzaApz.d.ts} +2 -2
- package/dist/chunks/{index-DAoPg59I.d.ts → index-Bca_HQWF.d.ts} +7 -3
- package/dist/chunks/{index-B0-8n-Gs.d.ts → index-Bl-_sC4y.d.ts} +12 -4
- package/dist/chunks/{index-BSLneLYu.d.ts → index-BxJ6Vrhm.d.ts} +2 -2
- package/dist/chunks/{index-CTpwB1yR.d.ts → index-BxrIOrAc.d.ts} +11 -6
- package/dist/chunks/{index-DHcztR18.d.ts → index-ByBbC4Jh.d.ts} +3 -3
- package/dist/chunks/{index-DHGgezXU.d.ts → index-C-IrFdKe.d.ts} +2 -2
- package/dist/chunks/{index-B8uaSJA9.d.ts → index-C0g8NSXY.d.ts} +13 -4
- package/dist/chunks/{index-CFnQubsV.d.ts → index-C1RKm3hQ.d.ts} +5 -3
- package/dist/chunks/{index-BxROljJI.d.ts → index-C3qqMzs5.d.ts} +2 -2
- package/dist/chunks/{index-Dcc_W6Kv.d.ts → index-C6F3DQCd.d.ts} +2 -2
- package/dist/chunks/{index-x0vZRyoU.d.ts → index-CEPAXElM.d.ts} +4 -3
- package/dist/chunks/{index-DaHQdNul.d.ts → index-COVY45gK.d.ts} +2 -2
- package/dist/chunks/{index-DJfga0Ce.d.ts → index-COq1jJ6Y.d.ts} +2 -2
- package/dist/chunks/{index-HrKN6s8z.d.ts → index-CSRGr7pU.d.ts} +2 -2
- package/dist/chunks/{index-B1kw0jzM.d.ts → index-CTNqEMug.d.ts} +6 -3
- package/dist/chunks/{index-6uob77s9.d.ts → index-CW94lG-e.d.ts} +7 -4
- package/dist/chunks/{index-Ddd7iWfm.d.ts → index-CY-A60p6.d.ts} +2 -2
- package/dist/chunks/{index-lSPcxiii.d.ts → index-CbcFEGCh.d.ts} +5 -3
- package/dist/chunks/{index-9rQeMqVI.d.ts → index-Ce0f-bDM.d.ts} +2 -2
- package/dist/chunks/{index-Ci7AEgEc.d.ts → index-Cf3gHDjh.d.ts} +2 -2
- package/dist/chunks/{index-BVGGIaPX.d.ts → index-Cm3rPbI1.d.ts} +10 -5
- package/dist/chunks/{index-DPCwFiJL.d.ts → index-CmljNQ8F.d.ts} +2 -2
- package/dist/chunks/{index-DQImhbhy.d.ts → index-Cpifcw5a.d.ts} +2 -2
- package/dist/chunks/{index-B_UzbGOa.d.ts → index-Ctf5hLue.d.ts} +3 -3
- package/dist/chunks/{index-DM01FX3a.d.ts → index-D0Dhs7YI.d.ts} +18 -6
- package/dist/chunks/{index-BAsbRx5n.d.ts → index-D5KJRfMg.d.ts} +2 -2
- package/dist/chunks/{index-Bz8MDq0H.d.ts → index-DD6Z5NW-.d.ts} +7 -4
- package/dist/chunks/{index-Dfg4Ftb8.d.ts → index-DFKBJxqA.d.ts} +7 -4
- package/dist/chunks/{index-BMkbJVHg.d.ts → index-DGGyvlEQ.d.ts} +3 -3
- package/dist/chunks/{index-YJ9QdBuq.d.ts → index-DOxVxbb9.d.ts} +6 -5
- package/dist/chunks/{index-CxjNw4ss.d.ts → index-DVK16_FU.d.ts} +2 -2
- package/dist/chunks/{index-DHOG_rjE.d.ts → index-DVfH_2Ma.d.ts} +7 -4
- package/dist/chunks/{index-0jbACjYQ.d.ts → index-DXBkVdWc.d.ts} +2 -2
- package/dist/chunks/{index-CsARGAzD.d.ts → index-Davd7Cue.d.ts} +10 -5
- package/dist/chunks/{index-Bi8FFadV.d.ts → index-Dc50UjJy.d.ts} +13 -4
- package/dist/chunks/{index-BF3OWUVc.d.ts → index-Dci43Xhl.d.ts} +3 -3
- package/dist/chunks/{index-B2K-O9kl.d.ts → index-DdFipHYL.d.ts} +5 -4
- package/dist/chunks/{index-Du9fBqkT.d.ts → index-DmmLEHVo.d.ts} +2 -2
- package/dist/chunks/{index-Dzga1f4w.d.ts → index-DsU3M0oP.d.ts} +2 -2
- package/dist/chunks/{index-DP5xugE-.d.ts → index-Es9I0fIS.d.ts} +3 -3
- package/dist/chunks/{index-CqZ68Z8R.d.ts → index-HNUhTj5e.d.ts} +25 -6
- package/dist/chunks/{index-CCXJXToc.d.ts → index-OnB4_h6x.d.ts} +7 -4
- package/dist/chunks/{index-CftERHnE.d.ts → index-QeI-KSng.d.ts} +3 -2
- package/dist/chunks/{index-BLS1jhSJ.d.ts → index-RyE80_VH.d.ts} +2 -2
- package/dist/chunks/{index-CIwzgZJi.d.ts → index-UjmJQRaG.d.ts} +2 -2
- package/dist/chunks/{index-B19ZH3fm.d.ts → index-YzIZhXZ1.d.ts} +2 -2
- package/dist/chunks/{index-CHQR8x8_.d.ts → index-Z_5ArZpE.d.ts} +4 -2
- package/dist/chunks/{index-BNf0jIIL.d.ts → index-doVyX-4i.d.ts} +7 -4
- package/dist/chunks/{index-NGgDkhyn.d.ts → index-mLtlx-d9.d.ts} +6 -3
- package/dist/chunks/{index-g74gO0pc.d.ts → index-sT0Hnr_n.d.ts} +12 -10
- package/dist/chunks/{index-Bkj17NEQ.d.ts → index-t3k_T3Dv.d.ts} +2 -2
- package/dist/chunks/{index-BfEJYF4c.d.ts → index-yVsGuikp.d.ts} +2 -2
- package/dist/chunks/input-adorn-DV9tuWXh.js +2 -0
- package/dist/chunks/input-adorn-DV9tuWXh.js.map +1 -0
- package/dist/chunks/input-group-YB_zoKud.js +2 -0
- package/dist/chunks/input-group-YB_zoKud.js.map +1 -0
- package/dist/chunks/insideEvents-CWcNrMu7.js +2 -0
- package/dist/chunks/insideEvents-CWcNrMu7.js.map +1 -0
- package/dist/chunks/lazyElement-tfMG21pZ.js.map +1 -1
- package/dist/chunks/list-BPBZR66Y.js +2 -0
- package/dist/chunks/list-BPBZR66Y.js.map +1 -0
- package/dist/chunks/menu-Bqlhottl.js +2 -0
- package/dist/chunks/menu-Bqlhottl.js.map +1 -0
- package/dist/chunks/modal-CHvsDTyl.js +2 -0
- package/dist/chunks/modal-CHvsDTyl.js.map +1 -0
- package/dist/chunks/nav-B4U_Hqs7.js +2 -0
- package/dist/chunks/nav-B4U_Hqs7.js.map +1 -0
- package/dist/chunks/nav-overflow-GWARvoQZ.js +2 -0
- package/dist/chunks/nav-overflow-GWARvoQZ.js.map +1 -0
- package/dist/chunks/navOverflow-C_QJmkPM.js +2 -0
- package/dist/chunks/navOverflow-C_QJmkPM.js.map +1 -0
- package/dist/chunks/{navVariant-DeGTk9B7.js → navVariant-D4wiKS8I.js} +2 -2
- package/dist/chunks/navVariant-D4wiKS8I.js.map +1 -0
- package/dist/chunks/navbar-C7dO0YRs.js +2 -0
- package/dist/chunks/navbar-C7dO0YRs.js.map +1 -0
- package/dist/chunks/notification-oIrUtDhl.js +2 -0
- package/dist/chunks/notification-oIrUtDhl.js.map +1 -0
- package/dist/chunks/number-field-ChPTSBwI.js +2 -0
- package/dist/chunks/number-field-ChPTSBwI.js.map +1 -0
- package/dist/chunks/otp-input-DUtCMg8P.js +2 -0
- package/dist/chunks/otp-input-DUtCMg8P.js.map +1 -0
- package/dist/chunks/{overlayPlacement-BtS90IVf.js → overlayPlacement-Q6bcbXA5.js} +2 -2
- package/dist/chunks/overlayPlacement-Q6bcbXA5.js.map +1 -0
- package/dist/chunks/overlayStack-BXtTGCRm.js +2 -0
- package/dist/chunks/overlayStack-BXtTGCRm.js.map +1 -0
- package/dist/chunks/pagination-Dvz8lccd.js +2 -0
- package/dist/chunks/pagination-Dvz8lccd.js.map +1 -0
- package/dist/chunks/{password-strength-DDK8pHRq.js → password-strength-Qg5GHBmu.js} +2 -2
- package/dist/chunks/password-strength-Qg5GHBmu.js.map +1 -0
- package/dist/chunks/placeholder-SPoVRkKE.js +2 -0
- package/dist/chunks/placeholder-SPoVRkKE.js.map +1 -0
- package/dist/chunks/polymorphic-CZIFszAy.js +2 -0
- package/dist/chunks/polymorphic-CZIFszAy.js.map +1 -0
- package/dist/chunks/popover-C_32yD9W.js +2 -0
- package/dist/chunks/popover-C_32yD9W.js.map +1 -0
- package/dist/chunks/progress-CiSJDNwx.js +2 -0
- package/dist/chunks/progress-CiSJDNwx.js.map +1 -0
- package/dist/chunks/radio-C42F_5OD.js +2 -0
- package/dist/chunks/radio-C42F_5OD.js.map +1 -0
- package/dist/chunks/range-input-DeZq_9S7.js +2 -0
- package/dist/chunks/range-input-DeZq_9S7.js.map +1 -0
- package/dist/chunks/renderFormCheck-DvpfK_I4.js +2 -0
- package/dist/chunks/renderFormCheck-DvpfK_I4.js.map +1 -0
- package/dist/chunks/renderFormField-_6WswnEX.js +2 -0
- package/dist/chunks/renderFormField-_6WswnEX.js.map +1 -0
- package/dist/chunks/renderMenuItemContent-DNdj-Ukz.js +2 -0
- package/dist/chunks/renderMenuItemContent-DNdj-Ukz.js.map +1 -0
- package/dist/chunks/scrollspy-BEZEVyIw.js +2 -0
- package/dist/chunks/scrollspy-BEZEVyIw.js.map +1 -0
- package/dist/chunks/scrollspy-D_lPjb92.js.map +1 -1
- package/dist/chunks/search-field-OFsb3t4L.js +2 -0
- package/dist/chunks/search-field-OFsb3t4L.js.map +1 -0
- package/dist/chunks/select-DwyL6aqY.js +2 -0
- package/dist/chunks/select-DwyL6aqY.js.map +1 -0
- package/dist/chunks/skeleton-B2blJGWj.js +2 -0
- package/dist/chunks/skeleton-B2blJGWj.js.map +1 -0
- package/dist/chunks/slot-BQVx1Eew.js +2 -0
- package/dist/chunks/slot-BQVx1Eew.js.map +1 -0
- package/dist/chunks/spacingClassName-DVhk8m3P.js.map +1 -1
- package/dist/chunks/spinner-D8lQCW4u.js +2 -0
- package/dist/chunks/spinner-D8lQCW4u.js.map +1 -0
- package/dist/chunks/stack-DtzW54UK.js +2 -0
- package/dist/chunks/stack-DtzW54UK.js.map +1 -0
- package/dist/chunks/static-table-C7ZtFQ66.js +2 -0
- package/dist/chunks/static-table-C7ZtFQ66.js.map +1 -0
- package/dist/chunks/stepper-tSA84huJ.js +2 -0
- package/dist/chunks/stepper-tSA84huJ.js.map +1 -0
- package/dist/chunks/switch-cp3IZg3L.js +2 -0
- package/dist/chunks/switch-cp3IZg3L.js.map +1 -0
- package/dist/chunks/table-CBTg5Yuq.js +2 -0
- package/dist/chunks/table-CBTg5Yuq.js.map +1 -0
- package/dist/chunks/tableClassName-jRfRDXA3.js +2 -0
- package/dist/chunks/tableClassName-jRfRDXA3.js.map +1 -0
- package/dist/chunks/tabs-DMFSLjnV.js +2 -0
- package/dist/chunks/tabs-DMFSLjnV.js.map +1 -0
- package/dist/chunks/text-input-CR73x-8D.js +2 -0
- package/dist/chunks/text-input-CR73x-8D.js.map +1 -0
- package/dist/chunks/textarea-C-1cMyH4.js +2 -0
- package/dist/chunks/textarea-C-1cMyH4.js.map +1 -0
- package/dist/chunks/time-field-CbCfOQZz.js +2 -0
- package/dist/chunks/time-field-CbCfOQZz.js.map +1 -0
- package/dist/chunks/toast-Dd0J2e1z.js +2 -0
- package/dist/chunks/toast-Dd0J2e1z.js.map +1 -0
- package/dist/chunks/tooltip-CmKeQwYw.js +2 -0
- package/dist/chunks/tooltip-CmKeQwYw.js.map +1 -0
- package/dist/chunks/tree-DNj_EfUl.js +2 -0
- package/dist/chunks/tree-DNj_EfUl.js.map +1 -0
- package/dist/chunks/unhandledProps-9Kdj7WVf.js.map +1 -1
- package/dist/chunks/{useButtonSemantics-CILM_lhi.js → useButtonSemantics-B1SbGaDO.js} +2 -2
- package/dist/chunks/useButtonSemantics-B1SbGaDO.js.map +1 -0
- package/dist/chunks/useControllableState-CPUJxfKW.js.map +1 -1
- package/dist/chunks/useDialogElement-BfygWBPZ.js +2 -0
- package/dist/chunks/useDialogElement-BfygWBPZ.js.map +1 -0
- package/dist/chunks/useDialogTitle-DiB4YDGI.js +2 -0
- package/dist/chunks/useDialogTitle-DiB4YDGI.js.map +1 -0
- package/dist/chunks/useDisabledAnchorGuard-CH6df46a.js +2 -0
- package/dist/chunks/useDisabledAnchorGuard-CH6df46a.js.map +1 -0
- package/dist/chunks/useFloatingOverlay-BuiI_CCn.js +2 -0
- package/dist/chunks/useFloatingOverlay-BuiI_CCn.js.map +1 -0
- package/dist/chunks/useForkedRef-WoqMqsWE.js +2 -0
- package/dist/chunks/useForkedRef-WoqMqsWE.js.map +1 -0
- package/dist/chunks/useFormField-DH2tlc3e.js +2 -0
- package/dist/chunks/useFormField-DH2tlc3e.js.map +1 -0
- package/dist/chunks/useHeldBack-eeTfpa_t.js +2 -0
- package/dist/chunks/useHeldBack-eeTfpa_t.js.map +1 -0
- package/dist/chunks/useHydrated-Dud4JEwp.js +2 -0
- package/dist/chunks/useHydrated-Dud4JEwp.js.map +1 -0
- package/dist/chunks/useIsomorphicLayoutEffect-BbqRwuqn.js.map +1 -1
- package/dist/chunks/{useOpenStateProps-DykUbnPJ.js → useOpenStateProps-BhjSQ3f6.js} +2 -2
- package/dist/chunks/useOpenStateProps-BhjSQ3f6.js.map +1 -0
- package/dist/chunks/useOverlayMaxHeight-DTgbr4UQ.js +2 -0
- package/dist/chunks/useOverlayMaxHeight-DTgbr4UQ.js.map +1 -0
- package/dist/chunks/useRequiredValueInput-gYN8I-LY.js +2 -0
- package/dist/chunks/useRequiredValueInput-gYN8I-LY.js.map +1 -0
- package/dist/chunks/useToastRegionQueue-CuAMxAIA.js +2 -0
- package/dist/chunks/useToastRegionQueue-CuAMxAIA.js.map +1 -0
- package/dist/chunks/{useTransitionState-e5ToY7eX.js → useTransitionState-sQUQey74.js} +2 -2
- package/dist/chunks/useTransitionState-sQUQey74.js.map +1 -0
- package/dist/chunks/validationClassName-gRGs4KBm.js.map +1 -1
- package/dist/chunks/{visibleState-B_i1zHu2.js → visibleState-CWyQak65.js} +2 -2
- package/dist/chunks/visibleState-CWyQak65.js.map +1 -0
- package/dist/close-button.d.ts +1 -1
- package/dist/close-button.js +1 -1
- package/dist/collapse.d.ts +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.d.ts +1 -1
- package/dist/combobox.js +1 -1
- package/dist/context-menu.d.ts +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.d.ts +1 -1
- package/dist/datepicker.js +1 -1
- package/dist/divider.d.ts +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.d.ts +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.d.ts +1 -1
- package/dist/form-field.js +1 -1
- package/dist/form.d.ts +1 -1
- package/dist/form.js +1 -1
- package/dist/grid.d.ts +1 -1
- package/dist/grid.js +1 -1
- package/dist/icon.d.ts +1 -1
- package/dist/icon.js +1 -1
- package/dist/index.d.ts +68 -68
- package/dist/index.js +1 -1
- package/dist/input-adorn.d.ts +1 -1
- package/dist/input-adorn.js +1 -1
- package/dist/input-group.d.ts +1 -1
- package/dist/input-group.js +1 -1
- package/dist/link.d.ts +1 -1
- package/dist/link.js +1 -1
- package/dist/list.d.ts +1 -1
- package/dist/list.js +1 -1
- package/dist/menu.d.ts +2 -2
- package/dist/menu.js +1 -1
- package/dist/modal.d.ts +1 -1
- package/dist/modal.js +1 -1
- package/dist/nav-overflow.d.ts +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.d.ts +1 -1
- package/dist/navbar.js +1 -1
- package/dist/notification.d.ts +1 -1
- package/dist/notification.js +1 -1
- package/dist/number-field.d.ts +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/password-strength.d.ts +1 -1
- package/dist/password-strength.js +1 -1
- package/dist/placeholder.d.ts +1 -1
- package/dist/placeholder.js +1 -1
- package/dist/popover.d.ts +1 -1
- package/dist/popover.js +1 -1
- package/dist/portal.d.ts +1 -1
- package/dist/portal.js +1 -1
- package/dist/progress.d.ts +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/scrollspy.d.ts +1 -1
- package/dist/scrollspy.js +1 -1
- package/dist/search-field.d.ts +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.d.ts +1 -1
- package/dist/skeleton.js +1 -1
- package/dist/spinner.d.ts +1 -1
- package/dist/spinner.js +1 -1
- package/dist/stack.d.ts +1 -1
- package/dist/stack.js +1 -1
- package/dist/static-table.js +1 -1
- package/dist/stepper.d.ts +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.d.ts +1 -1
- package/dist/tabs.js +1 -1
- package/dist/text-input.d.ts +1 -1
- package/dist/text-input.js +1 -1
- package/dist/textarea.d.ts +1 -1
- package/dist/textarea.js +1 -1
- package/dist/time-field.d.ts +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.d.ts +1 -1
- package/dist/tooltip.js +1 -1
- package/dist/tree.d.ts +1 -1
- package/dist/tree.js +1 -1
- package/dist/visually-hidden.d.ts +1 -1
- package/dist/visually-hidden.js +1 -1
- package/package.json +29 -28
- package/dist/chunks/Button-BoymWE-L.js +0 -2
- package/dist/chunks/Button-BoymWE-L.js.map +0 -1
- package/dist/chunks/Chip-DCaWaBqo.js +0 -2
- package/dist/chunks/Chip-DCaWaBqo.js.map +0 -1
- package/dist/chunks/CloseButton-DPgQztE0.js +0 -2
- package/dist/chunks/CloseButton-DPgQztE0.js.map +0 -1
- package/dist/chunks/ComboboxListBox-Cm3L1ULl.js +0 -2
- package/dist/chunks/ComboboxListBox-Cm3L1ULl.js.map +0 -1
- package/dist/chunks/DateSegment-2agXAd0f.js +0 -2
- package/dist/chunks/DateSegment-2agXAd0f.js.map +0 -1
- package/dist/chunks/FormHelp-AE6_iSLJ.js +0 -2
- package/dist/chunks/FormHelp-AE6_iSLJ.js.map +0 -1
- package/dist/chunks/FormLabel-CYcQiFUI.js +0 -2
- package/dist/chunks/FormLabel-CYcQiFUI.js.map +0 -1
- package/dist/chunks/Icon-DLB1f88W.js.map +0 -1
- package/dist/chunks/Link-DyZyAQFj.js +0 -2
- package/dist/chunks/Link-DyZyAQFj.js.map +0 -1
- package/dist/chunks/Menu-CSBg2Zmc.js +0 -2
- package/dist/chunks/Menu-CSBg2Zmc.js.map +0 -1
- package/dist/chunks/MenuToggle-7RQ0dmtZ.js +0 -2
- package/dist/chunks/MenuToggle-7RQ0dmtZ.js.map +0 -1
- package/dist/chunks/Portal-CgeR1WXV.js +0 -2
- package/dist/chunks/Portal-CgeR1WXV.js.map +0 -1
- package/dist/chunks/RangeCalendar-BJl-j4W2.js +0 -2
- package/dist/chunks/RangeCalendar-BJl-j4W2.js.map +0 -1
- package/dist/chunks/VisuallyHidden-C2dM7HhC.js +0 -2
- package/dist/chunks/VisuallyHidden-C2dM7HhC.js.map +0 -1
- package/dist/chunks/accordion-B8UWyvQB.js +0 -2
- package/dist/chunks/accordion-B8UWyvQB.js.map +0 -1
- package/dist/chunks/alert-3kTBfWFw.js +0 -2
- package/dist/chunks/alert-3kTBfWFw.js.map +0 -1
- package/dist/chunks/autocomplete-Baf9VSHN.js +0 -2
- package/dist/chunks/autocomplete-Baf9VSHN.js.map +0 -1
- package/dist/chunks/avatar-MklqAKcz.js +0 -2
- package/dist/chunks/avatar-MklqAKcz.js.map +0 -1
- package/dist/chunks/badge-D2oztCvs.js.map +0 -1
- package/dist/chunks/breadcrumb-CHxTiZLt.js +0 -2
- package/dist/chunks/breadcrumb-CHxTiZLt.js.map +0 -1
- package/dist/chunks/button-group-BGppPrIv.js +0 -2
- package/dist/chunks/button-group-BGppPrIv.js.map +0 -1
- package/dist/chunks/card-CTP9K8xG.js +0 -2
- package/dist/chunks/card-CTP9K8xG.js.map +0 -1
- package/dist/chunks/carousel-fTVPqnSV.js +0 -2
- package/dist/chunks/carousel-fTVPqnSV.js.map +0 -1
- package/dist/chunks/checkbox-ZyQn5Ku5.js +0 -2
- package/dist/chunks/checkbox-ZyQn5Ku5.js.map +0 -1
- package/dist/chunks/chip-input-BpVDRERg.js +0 -2
- package/dist/chunks/chip-input-BpVDRERg.js.map +0 -1
- package/dist/chunks/collapse--Go2Y73B.js.map +0 -1
- package/dist/chunks/color-input-Bwl5ef5B.js +0 -2
- package/dist/chunks/color-input-Bwl5ef5B.js.map +0 -1
- package/dist/chunks/colorClassNames-CEh5Yzfp.js +0 -2
- package/dist/chunks/colorClassNames-CEh5Yzfp.js.map +0 -1
- package/dist/chunks/combobox-Bp1tIaiW.js +0 -2
- package/dist/chunks/combobox-Bp1tIaiW.js.map +0 -1
- package/dist/chunks/context-menu-B4a0tS-h.js +0 -2
- package/dist/chunks/context-menu-B4a0tS-h.js.map +0 -1
- package/dist/chunks/datagrid-DOYxx0sF.js +0 -3
- package/dist/chunks/datagrid-DOYxx0sF.js.map +0 -1
- package/dist/chunks/datepicker-bOiM_zhJ.js +0 -2
- package/dist/chunks/datepicker-bOiM_zhJ.js.map +0 -1
- package/dist/chunks/dialogTransition-i9vw0i2Z.js.map +0 -1
- package/dist/chunks/divider-CjbF4OfA.js +0 -2
- package/dist/chunks/divider-CjbF4OfA.js.map +0 -1
- package/dist/chunks/drawer-C7Tz4XU_.js +0 -2
- package/dist/chunks/drawer-C7Tz4XU_.js.map +0 -1
- package/dist/chunks/file-input-CDM6qrmV.js +0 -2
- package/dist/chunks/file-input-CDM6qrmV.js.map +0 -1
- package/dist/chunks/flex-B52oLCCC.js.map +0 -1
- package/dist/chunks/floating-input-DmSZZc27.js +0 -2
- package/dist/chunks/floating-input-DmSZZc27.js.map +0 -1
- package/dist/chunks/focus-ring-SR_LwaN7.js +0 -2
- package/dist/chunks/focus-ring-SR_LwaN7.js.map +0 -1
- package/dist/chunks/focusRedirect-BrvK3U_o.js +0 -2
- package/dist/chunks/focusRedirect-BrvK3U_o.js.map +0 -1
- package/dist/chunks/form-GpdAyWWi.js +0 -2
- package/dist/chunks/form-GpdAyWWi.js.map +0 -1
- package/dist/chunks/form-field-CNPGTMiW.js.map +0 -1
- package/dist/chunks/grid-C7tO-ppc.js +0 -2
- package/dist/chunks/grid-C7tO-ppc.js.map +0 -1
- package/dist/chunks/icon-BQsT6YtE.js +0 -2
- package/dist/chunks/icon-BQsT6YtE.js.map +0 -1
- package/dist/chunks/iconSlot-BNu2MrFI.js +0 -2
- package/dist/chunks/iconSlot-BNu2MrFI.js.map +0 -1
- package/dist/chunks/input-adorn-DwdX-jxA.js +0 -2
- package/dist/chunks/input-adorn-DwdX-jxA.js.map +0 -1
- package/dist/chunks/input-group-Cuiuf4Dl.js +0 -2
- package/dist/chunks/input-group-Cuiuf4Dl.js.map +0 -1
- package/dist/chunks/list-07e2a1Ym.js +0 -2
- package/dist/chunks/list-07e2a1Ym.js.map +0 -1
- package/dist/chunks/menu-Upf6P-2P.js +0 -2
- package/dist/chunks/menu-Upf6P-2P.js.map +0 -1
- package/dist/chunks/modal-bgDR29Jh.js +0 -2
- package/dist/chunks/modal-bgDR29Jh.js.map +0 -1
- package/dist/chunks/nav-DI6oEULI.js +0 -2
- package/dist/chunks/nav-DI6oEULI.js.map +0 -1
- package/dist/chunks/nav-overflow-DlLer6EK.js +0 -2
- package/dist/chunks/nav-overflow-DlLer6EK.js.map +0 -1
- package/dist/chunks/navOverflow-B5krZe6D.js +0 -2
- package/dist/chunks/navOverflow-B5krZe6D.js.map +0 -1
- package/dist/chunks/navVariant-DeGTk9B7.js.map +0 -1
- package/dist/chunks/navbar-DxIwt0sc.js +0 -2
- package/dist/chunks/navbar-DxIwt0sc.js.map +0 -1
- package/dist/chunks/notification-Dbci5Ka3.js +0 -2
- package/dist/chunks/notification-Dbci5Ka3.js.map +0 -1
- package/dist/chunks/number-field-IBIX2IWH.js +0 -2
- package/dist/chunks/number-field-IBIX2IWH.js.map +0 -1
- package/dist/chunks/otp-input-ws393uPB.js +0 -2
- package/dist/chunks/otp-input-ws393uPB.js.map +0 -1
- package/dist/chunks/overlayPlacement-BtS90IVf.js.map +0 -1
- package/dist/chunks/pagination-BREQp-ZC.js +0 -2
- package/dist/chunks/pagination-BREQp-ZC.js.map +0 -1
- package/dist/chunks/password-strength-DDK8pHRq.js.map +0 -1
- package/dist/chunks/placeholder-DhNpUJqv.js +0 -2
- package/dist/chunks/placeholder-DhNpUJqv.js.map +0 -1
- package/dist/chunks/polymorphic-BhGNZQja.js +0 -2
- package/dist/chunks/polymorphic-BhGNZQja.js.map +0 -1
- package/dist/chunks/popover-Bdg8D4sm.js +0 -2
- package/dist/chunks/popover-Bdg8D4sm.js.map +0 -1
- package/dist/chunks/progress-BqgWezdG.js +0 -2
- package/dist/chunks/progress-BqgWezdG.js.map +0 -1
- package/dist/chunks/radio-B6gJdtoN.js +0 -2
- package/dist/chunks/radio-B6gJdtoN.js.map +0 -1
- package/dist/chunks/range-input-CT_8TKL7.js +0 -2
- package/dist/chunks/range-input-CT_8TKL7.js.map +0 -1
- package/dist/chunks/renderFormCheck-DN_-V62U.js +0 -2
- package/dist/chunks/renderFormCheck-DN_-V62U.js.map +0 -1
- package/dist/chunks/renderFormField-Brkw1yA6.js +0 -2
- package/dist/chunks/renderFormField-Brkw1yA6.js.map +0 -1
- package/dist/chunks/renderMenuItemContent-DUezZrpj.js +0 -2
- package/dist/chunks/renderMenuItemContent-DUezZrpj.js.map +0 -1
- package/dist/chunks/scrollspy-C2HmrnZ4.js +0 -2
- package/dist/chunks/scrollspy-C2HmrnZ4.js.map +0 -1
- package/dist/chunks/search-field--nDoCI_E.js +0 -2
- package/dist/chunks/search-field--nDoCI_E.js.map +0 -1
- package/dist/chunks/select-BwJIfv9f.js +0 -2
- package/dist/chunks/select-BwJIfv9f.js.map +0 -1
- package/dist/chunks/skeleton-Bjv9gGd3.js +0 -2
- package/dist/chunks/skeleton-Bjv9gGd3.js.map +0 -1
- package/dist/chunks/slot-CNhFZdHF.js +0 -2
- package/dist/chunks/slot-CNhFZdHF.js.map +0 -1
- package/dist/chunks/spinner-DBuvQvMR.js +0 -2
- package/dist/chunks/spinner-DBuvQvMR.js.map +0 -1
- package/dist/chunks/stack-DK5F53VT.js +0 -2
- package/dist/chunks/stack-DK5F53VT.js.map +0 -1
- package/dist/chunks/static-table-uu297Liz.js +0 -2
- package/dist/chunks/static-table-uu297Liz.js.map +0 -1
- package/dist/chunks/stepper-CVXMJ2yg.js +0 -2
- package/dist/chunks/stepper-CVXMJ2yg.js.map +0 -1
- package/dist/chunks/switch-C6s3LxEv.js +0 -2
- package/dist/chunks/switch-C6s3LxEv.js.map +0 -1
- package/dist/chunks/table-DPLOygg0.js +0 -2
- package/dist/chunks/table-DPLOygg0.js.map +0 -1
- package/dist/chunks/tableClassName-DleBjOj2.js +0 -2
- package/dist/chunks/tableClassName-DleBjOj2.js.map +0 -1
- package/dist/chunks/tabs-91T7-8qq.js +0 -2
- package/dist/chunks/tabs-91T7-8qq.js.map +0 -1
- package/dist/chunks/text-input-B4pTv6SU.js +0 -2
- package/dist/chunks/text-input-B4pTv6SU.js.map +0 -1
- package/dist/chunks/textarea-1A1nABQE.js +0 -2
- package/dist/chunks/textarea-1A1nABQE.js.map +0 -1
- package/dist/chunks/time-field-B3MA7ED_.js +0 -2
- package/dist/chunks/time-field-B3MA7ED_.js.map +0 -1
- package/dist/chunks/toast-CGHl3-oU.js +0 -2
- package/dist/chunks/toast-CGHl3-oU.js.map +0 -1
- package/dist/chunks/tooltip-Bc-u6nIW.js +0 -2
- package/dist/chunks/tooltip-Bc-u6nIW.js.map +0 -1
- package/dist/chunks/tree-Cql1veeZ.js +0 -2
- package/dist/chunks/tree-Cql1veeZ.js.map +0 -1
- package/dist/chunks/useButtonSemantics-CILM_lhi.js.map +0 -1
- package/dist/chunks/useDialogElement-CgOnJAzu.js +0 -2
- package/dist/chunks/useDialogElement-CgOnJAzu.js.map +0 -1
- package/dist/chunks/useDisabledAnchorGuard-Cz58UCXy.js +0 -2
- package/dist/chunks/useDisabledAnchorGuard-Cz58UCXy.js.map +0 -1
- package/dist/chunks/useFloatingOverlay-DLIvwx-8.js +0 -2
- package/dist/chunks/useFloatingOverlay-DLIvwx-8.js.map +0 -1
- package/dist/chunks/useForkedRef-DVEfT-KI.js +0 -2
- package/dist/chunks/useForkedRef-DVEfT-KI.js.map +0 -1
- package/dist/chunks/useFormField-BOqmBTC4.js +0 -2
- package/dist/chunks/useFormField-BOqmBTC4.js.map +0 -1
- package/dist/chunks/useOpenStateProps-DykUbnPJ.js.map +0 -1
- package/dist/chunks/useToastRegionQueue-CIV5SdiE.js +0 -2
- package/dist/chunks/useToastRegionQueue-CIV5SdiE.js.map +0 -1
- package/dist/chunks/useTransitionState-e5ToY7eX.js.map +0 -1
- package/dist/chunks/visibleState-B_i1zHu2.js.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./polymorphic-CZIFszAy.js";import{t}from"./useOverlayMaxHeight-DTgbr4UQ.js";import{i as n,r}from"./overlayPlacement-Q6bcbXA5.js";import{t as i}from"./Portal-BTDylxAi.js";import{n as a,r as o}from"./Menu-BiE9CzNk.js";import{a as s,c as ee,i as c,l as te,o as ne,r as l,s as u}from"./MenuToggle-W-ZSHFwF.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(c),se=ne(),{portalContainer:ce,registerOverlay:le,visible:R}=m(a),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:n(H),offset:x[1],crossOffset:x[0],containerPadding:8,isOpen:A,onClose:null});t(I,A);let{menuStyle:de,placementAttr:fe}=r(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,u(ee(I.current),`first`)})},$=()=>{P.current=!0,K()};h(()=>{!A&&P.current&&F.current?.focus(),P.current=!1},[A]);let pe=e=>{e.preventDefault(),o.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=>te(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(l.Provider,{value:ge},/* @__PURE__ */ d.createElement(c.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},a)=>{let o=m(l),s=e=>{n?.(e),o&&(e.stopPropagation(),o.close())};return/* @__PURE__ */ d.createElement(`button`,{type:r,role:`menuitem`,className:_(`submenu-back`,`menu-item`,t),...i,onClick:s,ref:a},e)});S.displayName=`MenuSubmenuBack`;export{x as n,b as r,S as t};
|
|
2
|
+
//# sourceMappingURL=menu-Bqlhottl.js.map
|
|
@@ -0,0 +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,E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AEA,MACE,kBAAA,cAAC,SAAD,CACQ,OACN,KAAK,WACL,UAAWrE,EAAW,eAAgB,YAAaM,CAAS,EAC5D,GAAIJ,EACJ,QAASoE,EACJ,KAGC,EADL/D,CACK,CAEZ,CACF,EAEA,EAAgB,YAAc,kB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{y as e}from"./slot-BQVx1Eew.js";import{t}from"./polymorphic-CZIFszAy.js";import{t as n}from"./useIsomorphicLayoutEffect-BbqRwuqn.js";import{t as r}from"./useDialogElement-BfygWBPZ.js";import{t as i}from"./CloseButton-BPUI5iGX.js";import{t as a}from"./useDialogTitle-DiB4YDGI.js";import o,{createContext as s,forwardRef as c,useContext as l,useId as u}from"react";import d from"classnames";const f=s({close:()=>{}}),p=s(()=>()=>{}),m=c(({children:e,backdrop:t=!0,className:n,defaultVisible:i,fullscreen:s,instant:c,keyboard:l=!0,modal:m=!0,onClick:h,onClose:g,onClosePrevented:_,onHidden:v,onKeyDown:y,onShow:b,onShown:x,onVisibleChange:S,scrollable:C,size:w,open:T,visible:E,...D},O)=>{let{close:k,forkedRef:A,handleBackdropClick:j,handleCancel:M,handleKeyDown:N,handleNativeClose:P,hiding:F,staticBounce:I}=r({backdrop:t,defaultVisible:i,instant:c,isModal:m,keyboard:l,onClick:h,onClose:g,onClosePrevented:_,onHidden:v,onKeyDown:y,onShow:b,onShown:x,onVisibleChange:S,open:T,ref:O,visible:E}),L=u(),[R,z]=a(L),B=d(`modal`,`dialog`,{[typeof s==`boolean`?`fullscreen`:`max-${s}:fullscreen`]:s,[`${w}`]:w,instant:c,nonmodal:!m,scrollable:C,hiding:F,"dialog-static":I},n);return/* @__PURE__ */ o.createElement(f.Provider,{value:{close:k,titleId:L}},/* @__PURE__ */ o.createElement(p.Provider,{value:z},/* @__PURE__ */ o.createElement(`dialog`,{"aria-labelledby":D[`aria-label`]?void 0:R,...D,open:T,className:B,onCancel:M,onClick:j,onClose:P,onKeyDown:N,ref:A},e)))});m.displayName=`Modal`;function h({children:e,className:t,component:n,...r},i){let a=n??`div`,s=d(`modal-body`,t);return/* @__PURE__ */ o.createElement(a,{className:s,...r,ref:i},e)}const g=t(h,`ModalBody`);function _({children:e,className:t,component:n,stacked:r,...i},a){let s=n??`div`,c=d(`modal-footer`,{stacked:r},t);return/* @__PURE__ */ o.createElement(s,{className:c,...i,ref:a},e)}const v=t(_,`ModalFooter`),y=()=>l(f);function b({children:e,className:t,closeButton:n=!0,closeLabel:r,component:a,...s},c){let l=a??`div`,{close:u}=y(),f=d(`modal-header`,t);return/* @__PURE__ */ o.createElement(l,{className:f,...s,ref:c},e,n&&/* @__PURE__ */ o.createElement(i,{label:r,onClick:u}))}const x=t(b,`ModalHeader`);function S({children:t,component:r,className:i,id:a,...s},c){let{titleId:u}=y(),f=l(p),m=r??`h2`,h=d(`modal-title`,i),g=e(m)??a??u;return n(()=>g?f(g):void 0,[f,g]),/* @__PURE__ */ o.createElement(m,{className:h,id:g,...s,ref:c},t)}const C=t(S,`ModalTitle`);export{g as a,v as i,x as n,m as o,y as r,C as t};
|
|
2
|
+
//# sourceMappingURL=modal-CHvsDTyl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modal-CHvsDTyl.js","names":["resolveSlottedId","useIsomorphicLayoutEffect","useDialogElement","CloseButton","useDialogTitle","React","classNames","ModalContext","createContext","ModalTitleContext","Modal","forwardRef","rest","modal","titleId","useId","labelledBy","registerTitle","_className","fullscreen","size","staticBounce","className","handleCancel","handleBackdropClick","handleNativeClose","handleKeyDown","forkedRef","children","ModalBodyRender","Component","component","ModalBody","createPolymorphicComponent","ModalFooterRender","ModalFooter","useModal","useContext","ModalHeaderRender","closeButton","closeLabel","close","ModalHeader","ModalTitleRender","resolvedId","id","ModalTitle"],"sources":["../../src/components/modal/Modal.tsx","../../src/components/modal/ModalBody.tsx","../../src/components/modal/ModalFooter.tsx","../../src/components/modal/useModal.ts","../../src/components/modal/ModalHeader.tsx","../../src/components/modal/ModalTitle.tsx"],"sourcesContent":["import React, { createContext, DialogHTMLAttributes, forwardRef, useId } from 'react'\nimport classNames from 'classnames'\n\nimport { useDialogElement } from '../../hooks'\nimport { RegisterDialogTitle, useDialogTitle } from '../../hooks/useDialogTitle'\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 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\nexport const Modal = forwardRef<HTMLDialogElement, ModalProps>(\n (\n {\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(titleId)\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 aria-labelledby={rest['aria-label'] ? undefined : labelledBy}\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 { useContext } from 'react'\nimport { ModalContext, ModalContextProps } from './Modal'\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 } 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","import React, { ElementType, ForwardRefRenderFunction, ReactElement, useContext } from 'react'\nimport classNames from 'classnames'\n\nimport { useIsomorphicLayoutEffect } from '../../hooks'\nimport { ModalTitleContext } from './Modal'\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"],"mappings":"A,6aAyGA,MAAaO,EAAeC,EAAiC,CAAE,UAAa,CAAC,CAAE,CAAC,EAInEC,EAAoBD,UAA+C,CAAC,CAAC,EAErEE,EAAQC,GAEjB,CACE,WACA,WAAW,GACX,YACA,iBACA,aACA,UACA,WAAW,GACX,QAAQ,GACR,UACA,UACA,mBACA,WACA,YACA,SACA,UACA,kBACA,aACA,OACA,OACA,UACA,GAAGC,GAEL,IACG,CACH,GAAM,CACJ,QACA,YACA,sBACA,eACA,gBACA,oBACA,SACA,gBACEV,EAAiB,CACnB,WACA,iBACA,UACA,QAASW,EACT,WACA,UACA,UACA,mBACA,WACA,YACA,SACA,UACA,kBACA,OACA,MACA,SACF,CAAC,EAEKC,EAAUC,EAAM,EAGhB,CAACC,EAAYC,GAAiBb,EAA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EAAaZ,EAAW,eAAgBgB,CAAS,EAEvD,MACE,kBAAA,cAACQ,EAAD,CAAW,UAAWZ,EAAY,GAAIN,EAAW,KAGtC,EAFRgB,EACAW,GAAe,kBAAA,cAACpC,EAAD,CAAa,MAAOqC,EAAY,QAASC,CAAQ,CAAA,CACxD,CAEf,CAEA,MAAaC,EAAcT,EACzBK,EACA,aACF,EC1BA,SAASK,EACP,CAAE,WAAU,YAAW,YAAW,KAAI,GAAG/B,GACzC,EACA,CACA,GAAM,CAAE,WAAYwB,EAAS,EACvBnB,EAAgBoB,EAAW5B,CAAiB,EAC5CqB,EAAYC,GAAa,KACzBb,EAAaZ,EAAW,cAAegB,CAAS,EAEhDsB,EAAa5C,EAAiB8B,CAAS,GAAKe,GAAM/B,EAQxD,OALAb,MACS2C,EAAa3B,EAAc2B,CAAU,EAAI,IAAA,GAChD,CAAC3B,EAAe2B,CAAU,CAC5B,EAGE,kBAAA,cAACd,EAAD,CAAW,UAAWZ,EAAY,GAAI0B,EAAY,GAAIhC,EAAW,KAEtD,EADRgB,CACQ,CAEf,CAEA,MAAakB,EAAab,EACxBU,EACA,YACF,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{S as e,d as t,g as n}from"./slot-BQVx1Eew.js";import{t as r}from"./useForkedRef-WoqMqsWE.js";import{t as i}from"./polymorphic-CZIFszAy.js";import{t as a}from"./Link-DE8NSAXJ.js";import{a as o,i as s,o as c,r as l,s as u}from"./navOverflow-C_QJmkPM.js";import{t as d}from"./navVariant-D4wiKS8I.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`),_=/* @__PURE__ */ new Set([`active`,`color`,`disabled`,`iconLink`,`reset`,`stretched`,`type`]);function v({children:n,className:i,keepVisible:a,...o},s){let c=m(`nav-item`,{"nav-overflow-keep":a},i),{asChild:d,component:p,href:h}=o,v=u(),y=r(s,v.ref),b=v.hidden?{"data-cx-nav-overflow":`true`}:void 0;if(t(h)||p!==void 0||d)return/* @__PURE__ */ f.createElement(`li`,{className:c,...b,ref:y},/* @__PURE__ */ f.createElement(l,{value:v.scope},/* @__PURE__ */ f.createElement(g,o,n)));let{active:x,disabled:S}=o,C=Object.fromEntries(Object.entries(o).filter(([e])=>!_.has(e)));return e(!!x||!!S,"NavItem: `active` and `disabled` style its link, and without `href`, `component` or `asChild` it renders none. Put them on the link inside it."),/* @__PURE__ */ f.createElement(`li`,{className:c,...C,...b,ref:y},/* @__PURE__ */ f.createElement(l,{value:v.scope},n))}const y=p(v);y.displayName=`NavItem`;function b({children:e,className:t,component:r,items:i,layout:a,size:o,variant:c,...l},u){let p=r??`ul`,h=m(`nav`,o,{[`nav-${a}`]:a},d(c,`Nav`),t),g=i?i.map((e,t)=>/* @__PURE__ */ f.createElement(y,{key:t,active:e.active,disabled:e.disabled,href:e.href},e.label)):null;return/* @__PURE__ */ f.createElement(p,{className:h,...l,ref:u},/* @__PURE__ */ f.createElement(s,{tag:n(p)},g??e))}const x=i(b,`Nav`),S=p(({children:e,className:t,...n},r)=>{let i=m(`nav-title`,t);return/* @__PURE__ */ f.createElement(`li`,{className:i,...n,ref:r},e)});S.displayName=`NavTitle`;export{g as i,x as n,y as r,S as t};
|
|
2
|
+
//# sourceMappingURL=nav-B4U_Hqs7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nav-B4U_Hqs7.js","names":["devWarning","hasHref","resolveElementTag","useForkedRef","createPolymorphicComponent","Link","NavOverflowLink","NavOverflowItems","useIsNavOverflowLink","NavOverflowItemScope","useNavOverflowItem","navVariantClassName","React","classNames","NavLinkRender","rest","_className","className","isOverflowLink","children","NavLink","LINK_ONLY_PROPS","NavItemRender","keepVisible","overflow","forkedRef","ref","overflowProps","href","component","asChild","itemProps","key","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 ReactElement,\n ReactNode,\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\nexport type NavItemProps<C extends ElementType = 'a'> = NavLinkProps<C> & {\n /**\n * Keeps the item in the list inside a `NavOverflow`, whatever the width.\n */\n keepVisible?: boolean\n}\n\ntype NavItemComponent = (<C extends ElementType = 'a'>(\n props: NavItemProps<C> & { ref?: Ref<HTMLLIElement> }\n) => ReactElement | null) & { displayName?: string }\n\nconst LINK_ONLY_PROPS = new Set([\n 'active',\n 'color',\n 'disabled',\n 'iconLink',\n 'reset',\n 'stretched',\n 'type'\n])\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`. Only the `<li>` takes the caller's own attributes then: `active`, `disabled` and\n// the other `NavLink` props style a link, and on the `<li>` they were written out as invalid\n// attributes (`disabled=\"\"`, `component=\"button\"`).\nfunction NavItemRender<C extends ElementType = 'a'>(\n { children, className, keepVisible, ...rest }: NavItemProps<C>,\n ref: Ref<HTMLLIElement>\n) {\n const _className = classNames('nav-item', { 'nav-overflow-keep': keepVisible }, className)\n const { asChild, component, href } = rest as {\n asChild?: boolean\n component?: ElementType\n href?: string\n }\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 return (\n <li className={_className} {...overflowProps} ref={forkedRef}>\n <NavOverflowItemScope value={overflow.scope}>\n <NavLink {...(rest as Record<string, unknown>)}>{children as ReactNode}</NavLink>\n </NavOverflowItemScope>\n </li>\n )\n }\n\n const { active, disabled } = rest as NavLinkProps<'a'>\n const itemProps = Object.fromEntries(\n Object.entries(rest).filter(([key]) => !LINK_ONLY_PROPS.has(key))\n )\n devWarning(\n !!active || !!disabled,\n 'NavItem: `active` and `disabled` style its link, and without `href`, `component` or ' +\n '`asChild` it renders none. Put them on the link inside it.'\n )\n return (\n <li className={_className} {...itemProps} {...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 { 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.\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\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 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 disabled={item.disabled}\n href={item.href}\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'\nimport classNames from 'classnames'\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 const _className = classNames('nav-title', className)\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,GAAGC,GAC1B,EACA,CACA,IAAMC,EAAaH,EAAW,W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AAuC,EAA/BL,CAA+B,CAC3E,CAER,CAEA,MAAagB,EAAUC,EACrBd,CACF,EAEA,EAAQ,YAAc,UCnBtB,SAASe,EACP,CAAE,WAAU,YAAW,YAAW,QAAO,SAAQ,OAAM,UAAS,GAAGtB,GACnE,EACA,CACA,IAAMuB,EAAYT,GAAa,KACzBb,EAAaH,EACjB,MACA0B,EACA,EAAG,OAAOC,KAAWA,CAAO,EAC5B7B,EAAoB8B,EAAS,KAAK,EAClCxB,CACF,EAEMyB,EAAcC,EAChBA,EAAM,KAAK,EAAM,IACf,kBAAA,cAACR,EAAD,CAEE,IAAKS,EACL,OAAQC,EAAK,OACb,SAAUA,EAAK,SACf,KAAMA,EAAK,IAGJ,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,ECtGaU,EAAWX,GACrB,CAAE,WAAU,YAAW,GAAGrB,GAAQ,IAAQ,CACzC,IAAMC,EAAaH,EAAW,YAAaI,CAAS,EACpD,MACE,kBAAA,cAAC,KAAD,CAAI,UAAWD,EAAY,GAAID,EAAW,KAEtC,EADDI,CACC,CAER,CACF,EAEA,EAAS,YAAc,W"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{S as e}from"./slot-BQVx1Eew.js";import{t}from"./useForkedRef-WoqMqsWE.js";import{t as n}from"./polymorphic-CZIFszAy.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-C_QJmkPM.js";import{t as s}from"./Menu-BiE9CzNk.js";import{n as c,t as l,u}from"./MenuToggle-W-ZSHFwF.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-GWARvoQZ.js.map
|
|
@@ -0,0 +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 NavOverflowRender as ForwardRefRenderFunction<Element, NavOverflowProps<ElementType>>,\n 'NavOverflow'\n)\n"],"mappings":"A,0pBAqCA,MAAaY,EAAyBC,EAA2C,IAAI,EAGrF,SAASC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gCK,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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{S as e,a as t,s as n}from"./slot-BQVx1Eew.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-C_QJmkPM.js.map
|
|
@@ -0,0 +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,EAAOJ,GAAY,KAEzB,MACE,kBAAA,cAAAX,EAAA,SAAA,KACE,kBAAA,cAACC,EAAmB,SAApB,CAA6B,MAAO,IAIP,EAH3B,kBAAA,cAACE,EAA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A,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{S as e}from"./slot-BQVx1Eew.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-D4wiKS8I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navVariant-D4wiKS8I.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"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{f as e,g as t,m as n,v as r}from"./slot-BQVx1Eew.js";import{t as i}from"./polymorphic-CZIFszAy.js";import{t as a}from"./iconSlot-DU_WcSL_.js";import{t as o}from"./VisuallyHidden-CGv-mBuQ.js";import{i as s,n as c}from"./navOverflow-C_QJmkPM.js";import l,{forwardRef as u,useContext as d}from"react";import f from"classnames";function p({children:e,className:t,color:n,component:r,container:i,expand:a,placement:o,translucent:s,variant:c,...u},d){let p=r??`nav`,m=f(`navbar`,n,{context:!!n,solid:c===`solid`,smooth:c===`smooth`,outline:c===`outline`,translucent:s,[typeof a==`boolean`?`navbar-expand`:`${a}:navbar-expand`]:a},o,t),h;return h=i?/* @__PURE__ */ l.createElement(`div`,{className:f(`container`,i===`fluid`?`fluid`:i!==!0&&i)},e):e,/* @__PURE__ */ l.createElement(p,{className:m,...u,ref:d},h)}const m=i(p,`Navbar`);function h({children:t,component:i,className:a,href:o,...s},c){let u=n(i,o,`span`),d=f(`navbar-brand`,a);return/* @__PURE__ */ l.createElement(u,{className:d,...e(r(u,o,s),o,`NavbarBrand`),...s,ref:c},t)}const g=i(h,`NavbarBrand`);function _({children:e,component:n,className:r,...i},a){let o=n??`ul`,u=d(c)!==null,p=f({nav:u},`navbar-nav`,r);return/* @__PURE__ */ l.createElement(o,{className:p,...i,ref:a},/* @__PURE__ */ l.createElement(s,{tag:t(o)},e))}const v=i(_,`NavbarNav`);function y({children:e,className:t,component:n,...r},i){let a=n??`span`,o=f(`navbar-text`,t);return/* @__PURE__ */ l.createElement(a,{className:o,...r,ref:i},e)}const b=i(y,`NavbarText`),x=u(({children:e,className:t,icon:n,label:r=`Toggle navigation`,...i},s)=>{let c=f(`button icon-only navbar-toggler`,t);return/* @__PURE__ */ l.createElement(`button`,{type:`button`,className:c,...i,ref:s},e??/* @__PURE__ */ l.createElement(l.Fragment,null,/* @__PURE__ */ l.createElement(a,{icon:`menu`,override:n,className:`navbar-toggler-icon`}),/* @__PURE__ */ l.createElement(o,null,r)))});x.displayName=`NavbarToggler`;export{m as a,g as i,b as n,v as r,x as t};
|
|
2
|
+
//# sourceMappingURL=navbar-C7dO0YRs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navbar-C7dO0YRs.js","names":["hrefProps","resolveElementTag","linkElement","resolveLinkKind","createPolymorphicComponent","IconSlot","VisuallyHidden","NavOverflowItems","NavOverflowContext","React","classNames","NavbarRender","rest","Component","component","_className","color","variant","expand","placement","className","content","container","children","Navbar","NavbarBrandRender","href","NavbarBrand","NavbarNavRender","overflows","useContext","NavbarNav","NavbarTextRender","NavbarText","NavbarToggler","forwardRef","icon","label"],"sources":["../../src/components/navbar/Navbar.tsx","../../src/components/navbar/NavbarBrand.tsx","../../src/components/navbar/NavbarNav.tsx","../../src/components/navbar/NavbarText.tsx","../../src/components/navbar/NavbarToggler.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'\nimport { Breakpoint, ContextColor, ContextStyle } from '../../types'\n\ntype NavbarOwnProps<C extends ElementType> = {\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\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 * Wraps the children in a `.container`, as `Container` renders one: `true` for the default,\n * `'fluid'` for one as wide as the navbar, or a breakpoint for one that is fluid until it.\n */\n container?: boolean | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | 'fluid'\n /**\n * Opts this navbar into the framework's dark or light theming, independent of the page's own\n * theme.\n */\n 'data-cx-theme'?: 'dark' | 'light'\n /**\n * Renders inline at and above this breakpoint, as a drawer below it. `true` renders inline at\n * every width; omit to keep the drawer at every width.\n */\n expand?: boolean | Breakpoint\n /**\n * Place component in non-static positions.\n */\n placement?: 'fixed-top' | 'fixed-bottom' | 'sticky-top' | 'sticky-bottom'\n /**\n * Blurs and saturates whatever sits behind the navbar — useful when it's positioned over a\n * hero image, video, or scrollable content.\n */\n translucent?: boolean\n /**\n * Sets the context style of the component. `basic` (the default) renders with no extra class.\n */\n variant?: ContextStyle\n}\n\nexport type NavbarProps<C extends ElementType = 'nav'> = PolymorphicComponentProps<\n C,\n NavbarOwnProps<C>\n>\n\ntype NavbarComponent = (<C extends ElementType = 'nav'>(\n props: NavbarProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction NavbarRender<C extends ElementType = 'nav'>(\n {\n children,\n className,\n color,\n component,\n container,\n expand,\n placement,\n translucent,\n variant,\n ...rest\n }: NavbarProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'nav'\n const _className = classNames(\n 'navbar',\n color,\n {\n context: !!color,\n solid: variant === 'solid',\n smooth: variant === 'smooth',\n outline: variant === 'outline',\n translucent,\n [typeof expand === 'boolean' ? 'navbar-expand' : `${expand}:navbar-expand`]: expand\n },\n placement,\n className\n )\n\n let content\n if (container) {\n content = (\n <div\n className={classNames(\n 'container',\n container === 'fluid' ? 'fluid' : container !== true && container\n )}\n >\n {children}\n </div>\n )\n } else {\n content = children\n }\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {content}\n </Component>\n )\n}\n\nexport const Navbar = createPolymorphicComponent<NavbarComponent>(\n NavbarRender as ForwardRefRenderFunction<Element, NavbarProps<ElementType>>,\n 'Navbar'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { hrefProps, linkElement, resolveLinkKind } from '../../utils/elementKind'\n\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n PolymorphicRefWithFallback\n} from '../../utils/polymorphic'\n\ntype NavbarBrandOwnProps<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 * Defaults to `span`, or `a` when `href` is set.\n */\n component?: C\n /**\n * The href attribute specifies the URL of the page the link goes to. Defaults `component` to\n * `a`.\n */\n href?: string\n}\n\nexport type NavbarBrandProps<C extends ElementType = 'span'> = PolymorphicComponentProps<\n C,\n NavbarBrandOwnProps<C>\n>\n\ntype NavbarBrandComponent = (<C extends ElementType = 'span'>(\n props: NavbarBrandProps<C> & {\n ref?: PolymorphicRefWithFallback<C, HTMLSpanElement | HTMLAnchorElement>\n }\n) => ReactElement | null) & { displayName?: string }\n\nfunction NavbarBrandRender<C extends ElementType = 'span'>(\n { children, component, className, href, ...rest }: NavbarBrandProps<C>,\n ref: PolymorphicRef<C>\n) {\n // `href` makes it an `<a>`, unless `component` or `asChild` chose the element (see\n // `linkElement`).\n const Component = linkElement(component, href, 'span')\n const _className = classNames('navbar-brand', className)\n\n return (\n <Component\n className={_className}\n {...hrefProps(resolveLinkKind(Component, href, rest), href, 'NavbarBrand')}\n {...rest}\n ref={ref}\n >\n {children}\n </Component>\n )\n}\n\nexport const NavbarBrand = createPolymorphicComponent<NavbarBrandComponent>(\n NavbarBrandRender as ForwardRefRenderFunction<Element, NavbarBrandProps<ElementType>>,\n 'NavbarBrand'\n)\n","import React, { ElementType, ForwardRefRenderFunction, ReactElement, useContext } from 'react'\nimport classNames from 'classnames'\n\nimport { resolveElementTag } from '../../utils/elementKind'\nimport { NavOverflowContext, NavOverflowItems } from '../../utils/navOverflow'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\ntype NavbarNavOwnProps<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 NavbarNavProps<C extends ElementType = 'ul'> = PolymorphicComponentProps<\n C,\n NavbarNavOwnProps<C>\n>\n\ntype NavbarNavComponent = (<C extends ElementType = 'ul'>(\n props: NavbarNavProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction NavbarNavRender<C extends ElementType = 'ul'>(\n { children, component, className, ...rest }: NavbarNavProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'ul'\n // Inside a `NavOverflow` the list is also a `.nav`, which is what chassis-css keeps on one line\n // there (`.nav-overflow > .nav`).\n const overflows = useContext(NavOverflowContext) !== null\n const _className = classNames({ nav: overflows }, 'navbar-nav', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n <NavOverflowItems tag={resolveElementTag(Component)}>{children}</NavOverflowItems>\n </Component>\n )\n}\n\nexport const NavbarNav = createPolymorphicComponent<NavbarNavComponent>(\n NavbarNavRender as ForwardRefRenderFunction<Element, NavbarNavProps<ElementType>>,\n 'NavbarNav'\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 NavbarTextOwnProps<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 NavbarTextProps<C extends ElementType = 'span'> = PolymorphicComponentProps<\n C,\n NavbarTextOwnProps<C>\n>\n\ntype NavbarTextComponent = (<C extends ElementType = 'span'>(\n props: NavbarTextProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction NavbarTextRender<C extends ElementType = 'span'>(\n { children, className, component, ...rest }: NavbarTextProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'span'\n const _className = classNames('navbar-text', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const NavbarText = createPolymorphicComponent<NavbarTextComponent>(\n NavbarTextRender as ForwardRefRenderFunction<Element, NavbarTextProps<ElementType>>,\n 'NavbarText'\n)\n","import React, { forwardRef, HTMLAttributes } from 'react'\nimport classNames from 'classnames'\n\nimport { IconValue } from '../../utils/iconConfig'\nimport { IconSlot } from '../icon/iconSlot'\nimport { VisuallyHidden } from '../visually-hidden/VisuallyHidden'\n\nexport interface NavbarTogglerProps extends HTMLAttributes<HTMLButtonElement> {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * The toggler icon: an icon name, or an element of your own icon set. Defaults to\n * `IconProvider`'s `menu` icon.\n */\n icon?: IconValue\n /**\n * The accessible label announced by assistive technology when no children are provided.\n */\n label?: string\n}\n\nexport const NavbarToggler = forwardRef<HTMLButtonElement, NavbarTogglerProps>(\n ({ children, className, icon, label = 'Toggle navigation', ...rest }, ref) => {\n const _className = classNames('button icon-only navbar-toggler', className)\n\n return (\n <button type=\"button\" className={_className} {...rest} ref={ref}>\n {children ?? (\n <>\n <IconSlot icon=\"menu\" override={icon} className=\"navbar-toggler-icon\" />\n <VisuallyHidden>{label}</VisuallyHidden>\n </>\n )}\n </button>\n )\n }\n)\n\nNavbarToggler.displayName = 'NavbarToggler'\n"],"mappings":"A,4WA8DA,SAASW,EACP,CACE,WACA,YACA,QACA,YACA,YACA,SACA,YACA,cACA,UACA,GAAGC,GAEL,EACA,CACA,IAAMC,EAAYC,GAAa,MACzBC,EAAaL,EACjB,SACAM,EACA,CACE,QAAS,CAAC,CAACA,EACX,MAAOC,IAAY,QACnB,OAAQA,IAAY,SACpB,QAASA,IAAY,UACrB,eACC,OAAOC,GAAW,UAAY,gBAAkB,GAAGA,EAAO,iBAAkBA,CAC/E,EACAC,EACAC,CACF,EAEIC,EAgBJ,MAfA,CAYEA,EAZEC,EAEA,kBAAA,cAAC,MAAD,CACE,UAAWZ,EACT,YACAY,IAAc,QAAU,QAAUA,IAAc,IAAQA,CAC1D,CAGG,EADFC,CACE,EAGGA,EAIV,kBAAA,cAACV,EAAD,CAAW,UAAWE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,SAAS,UAAWL,EAAY,GAAIH,EAAW,KAOpD,EANLW,GACC,kBAAA,cAAAd,EAAA,SAAA,KACE,kBAAA,cAACJ,EAAD,CAAU,KAAK,OAAO,SAAU+B,EAAM,UAAU,qBAAuB,CAAA,EACvE,kBAAA,cAAC9B,EAAA,KAAgB+B,CAAsB,CACvC,CAEE,CAEZ,CACF,EAEA,EAAc,YAAc,gB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./polymorphic-CZIFszAy.js";import{n as t,r as n,t as r}from"./useToastRegionQueue-CuAMxAIA.js";import{t as i}from"./Icon-Dk5_q79o.js";import{n as a}from"./iconSlot-DU_WcSL_.js";import{t as o}from"./CloseButton-BPUI5iGX.js";import{t as s}from"./stack-DtzW54UK.js";import c,{createContext as l,forwardRef as u,useContext as d}from"react";import f from"classnames";import{mergeProps as p}from"react-aria";import{ToastQueue as m}from"react-stately";const h=l({close:()=>{}});function g({children:e,component:t,className:n,...r},i){let a=t??`div`,o=f(`notification-text`,n);return/* @__PURE__ */ c.createElement(a,{className:o,...r,ref:i},e)}const _=e(g,`NotificationText`);function v({children:e,className:t,component:n,...r},i){let a=n??`h4`,o=f(`notification-title`,t);return/* @__PURE__ */ c.createElement(a,{className:o,...r,ref:i},e)}const y=e(v,`NotificationTitle`),b=u(({actions:e,autohide:r=!1,children:i,className:s,closeLabel:l=`Close`,color:u=`primary`,defaultVisible:d=!0,delay:m=5e3,dismissible:g,icon:v,solid:b,text:x,title:S,titleComponent:C=`h4`,role:w=`status`,visible:T,onClose:E,onShow:D,onVisibleChange:O,...k},A)=>{let{close:j,entered:M,forkedRef:N,isMounted:P,textId:F,titleId:I,transitionClass:L,visible:R}=t({defaultVisible:d,displayName:`Notification`,onClose:E,onShow:D,onVisibleChange:O,ref:A,visible:T}),z=n({enabled:r,delay:m,visible:R&&M,onHide:j}),B=f(`notification`,`fade`,u,{solid:b},s);return P?/* @__PURE__ */ c.createElement(h.Provider,{value:{visible:R,close:j}},/* @__PURE__ */ c.createElement(`div`,{className:f(B,L),role:w,"aria-labelledby":S?I:void 0,"aria-describedby":S&&x?F:void 0,...p(k,z),ref:N},v&&(typeof v==`string`?/* @__PURE__ */ c.createElement(a,{value:v,className:f(`notification-icon`,{"align-self-start":!!S})}):v),S&&/* @__PURE__ */ c.createElement(y,{id:I,component:C},S),x&&/* @__PURE__ */ c.createElement(_,{id:F},x),i,e,g&&/* @__PURE__ */ c.createElement(o,{label:l,onClick:j}))):null});b.displayName=`Notification`;const x=u(({className:e,...t},n)=>{let r=f(`notification-icon`,e);return/* @__PURE__ */ c.createElement(i,{className:r,...t,ref:n})});x.displayName=`NotificationIcon`;const S=new m;function C(e,t={}){return S.add({children:e,...t})}function w(e){S.close(e)}const T=u(({children:e,className:t,reverse:n,...i},a)=>{let{forkedRef:o,regionProps:l,state:u}=r(S,a);if(u.visibleToasts.length===0&&!e)return null;let d=n?[...u.visibleToasts].reverse():u.visibleToasts;return/* @__PURE__ */ c.createElement(s,{direction:`vertical`,gap:`sm`,className:t,...l,...i,ref:o},e,d.map(e=>{let{children:t,...n}=e.content;return/* @__PURE__ */ c.createElement(b,{key:e.key,...n,onClose:()=>u.close(e.key)},t)}))});T.displayName=`NotificationStack`;const E=()=>d(h);export{S as a,y as c,w as i,_ as l,T as n,x as o,C as r,b as s,E as t};
|
|
2
|
+
//# sourceMappingURL=notification-oIrUtDhl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification-oIrUtDhl.js","names":["createPolymorphicComponent","useDismissibleTransition","useAutoDismiss","useToastRegionQueue","Icon","ResolvedIcon","CloseButton","Stack","React","classNames","NotificationContext","createContext","NotificationTextRender","rest","Component","component","_className","className","children","NotificationText","NotificationTitleRender","NotificationTitle","Notification","forwardRef","_visible","autoDismissProps","autohide","entered","close","color","isMounted","transitionClass","title","titleId","text","textId","mergeProps","forkedRef","icon","titleComponent","actions","dismissible","closeLabel","NotificationIcon","notificationQueue","ToastQueue","addNotification","options","closeNotification","key","NotificationStack","ref","state","queued","reverse","regionProps","notificationChildren","notificationProps","item","useNotification","useContext"],"sources":["../../src/components/notification/context.ts","../../src/components/notification/NotificationText.tsx","../../src/components/notification/NotificationTitle.tsx","../../src/components/notification/Notification.tsx","../../src/components/notification/NotificationIcon.tsx","../../src/components/notification/notificationQueue.ts","../../src/components/notification/NotificationStack.tsx","../../src/components/notification/useNotification.ts"],"sourcesContent":["import { createContext } from 'react'\n\nexport interface NotificationContextProps {\n /**\n * Whether the notification is currently visible.\n */\n visible?: boolean\n /**\n * Dismisses the notification. Wire this to any element's `onClick` — see `useNotification`.\n */\n close: () => void\n}\n\nexport const NotificationContext = createContext<NotificationContextProps>({ close: () => {} })\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 NotificationTextOwnProps<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 NotificationTextProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n NotificationTextOwnProps<C>\n>\n\ntype NotificationTextComponent = (<C extends ElementType = 'div'>(\n props: NotificationTextProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction NotificationTextRender<C extends ElementType = 'div'>(\n { children, component, className, ...rest }: NotificationTextProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('notification-text', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const NotificationText = createPolymorphicComponent<NotificationTextComponent>(\n NotificationTextRender as ForwardRefRenderFunction<Element, NotificationTextProps<ElementType>>,\n 'NotificationText'\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 NotificationTitleOwnProps<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 NotificationTitleProps<C extends ElementType = 'h4'> = PolymorphicComponentProps<\n C,\n NotificationTitleOwnProps<C>\n>\n\ntype NotificationTitleComponent = (<C extends ElementType = 'h4'>(\n props: NotificationTitleProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction NotificationTitleRender<C extends ElementType = 'h4'>(\n { children, className, component, ...rest }: NotificationTitleProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'h4'\n const _className = classNames('notification-title', className)\n\n return (\n <Component className={_className} {...rest} ref={ref}>\n {children}\n </Component>\n )\n}\n\nexport const NotificationTitle = createPolymorphicComponent<NotificationTitleComponent>(\n NotificationTitleRender as ForwardRefRenderFunction<Element, NotificationTitleProps<ElementType>>,\n 'NotificationTitle'\n)\n","import React, { ElementType, forwardRef, HTMLAttributes, ReactNode } from 'react'\nimport classNames from 'classnames'\nimport { mergeProps } from 'react-aria'\n\nimport { ContextColor } from '../../types'\nimport { CloseButton } from '../close-button/CloseButton'\nimport { useAutoDismiss, useDismissibleTransition } from '../../hooks'\nimport { NotificationContext } from './context'\nimport { ResolvedIcon } from '../icon/iconSlot'\nimport { NotificationText } from './NotificationText'\nimport { NotificationTitle } from './NotificationTitle'\nimport './Notification.scss'\n\nexport interface NotificationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title'> {\n /**\n * Optional trailing content — e.g. a row of `Button`s — rendered after `text`/`children`.\n */\n actions?: ReactNode\n /**\n * Automatically dismiss the notification after `delay`. The timer pauses while the pointer\n * or focus is on the notification, and only starts once the notification is visible.\n * Defaults to `false` — unlike `Toast`, notifications are persistent banners by default.\n */\n autohide?: boolean\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Overrides the dismiss button's accessible name (defaults to `'Close'`). Set this for\n * non-English UIs.\n */\n closeLabel?: string\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\n /**\n * Whether the notification is shown when it first renders. Such a notification is\n * uncontrolled: its close button and the `autohide` timer hide it. Use `visible` to show and\n * hide it from outside.\n *\n * @default true\n */\n defaultVisible?: boolean\n /**\n * Delay in ms before an `autohide` notification dismisses itself.\n */\n delay?: number\n /**\n * Optionally add a close button to the notification and allow it to self dismiss.\n */\n dismissible?: boolean\n /**\n * Leading icon. A string is an icon name, rendered like `<NotificationIcon name={icon} />` (or\n * by `IconProvider`'s `component`); pass any other\n * node for a fully custom icon. Automatically top-aligns with `title` when both are set —\n * a custom icon node is responsible for its own alignment.\n */\n icon?: string | ReactNode\n /**\n * Applies the solid context style to the notification.\n */\n solid?: boolean\n /**\n * Message body, rendered via a single `<NotificationText>`. For multi-block content, compose\n * `children` manually instead — `text` wraps everything in one element.\n */\n text?: ReactNode\n /**\n * Heading, rendered via `<NotificationTitle>`.\n */\n title?: ReactNode\n /**\n * Element or component used for the `title` heading. Passed through to `NotificationTitle`'s\n * own `component` prop. Defaults to `'h4'`.\n */\n titleComponent?: ElementType\n /**\n * Callback fired once the notification has hidden: after its exit transition.\n */\n onClose?: () => void\n /**\n * Callback fired when the notification starts to show.\n */\n onShow?: () => void\n /**\n * Callback fired with `false` when the notification asks to hide: its close button, `close`\n * from `useNotification`, or the `autohide` timer. With `visible` set, the notification hides\n * only when `visible` becomes `false`.\n */\n onVisibleChange?: (visible: boolean) => void\n /**\n * ARIA live-region role. Use `status` (the default) for confirmation, progress, and\n * informational messages, which announce politely. Use `alert` for messages that need\n * immediate attention — validation errors, failed operations — which interrupt speech.\n */\n role?: 'status' | 'alert'\n /**\n * Whether the notification is shown. Setting it makes the notification controlled: it hides\n * only when this becomes `false`, so pair it with `onVisibleChange`. Left unset, the\n * notification is shown and hides itself (see `defaultVisible`).\n */\n visible?: boolean\n}\n\nexport const Notification = forwardRef<HTMLDivElement, NotificationProps>(\n (\n {\n actions,\n autohide = false,\n children,\n className,\n closeLabel = 'Close',\n color = 'primary',\n defaultVisible = true,\n delay = 5000,\n dismissible,\n icon,\n solid,\n text,\n title,\n titleComponent = 'h4',\n role = 'status',\n visible,\n onClose,\n onShow,\n onVisibleChange,\n ...rest\n },\n ref\n ) => {\n const {\n close,\n entered,\n forkedRef,\n isMounted,\n textId,\n titleId,\n transitionClass,\n visible: _visible\n } = useDismissibleTransition({\n defaultVisible,\n displayName: 'Notification',\n onClose,\n onShow,\n onVisibleChange,\n ref,\n visible\n })\n\n // Gated on `entered`, not just `_visible` (see `Toast`'s identical comment) — the entrance\n // transition finishing is what `autohide`'s JSDoc means by \"the timer starts once the\n // notification is visible\".\n const autoDismissProps = useAutoDismiss({\n enabled: autohide,\n delay,\n visible: _visible && entered,\n onHide: close\n })\n\n const _className = classNames(\n 'notification',\n 'fade',\n color,\n {\n solid\n },\n className\n )\n\n if (!isMounted) return null\n\n return (\n <NotificationContext.Provider value={{ visible: _visible, close }}>\n <div\n className={classNames(_className, transitionClass)}\n role={role}\n aria-labelledby={title ? titleId : undefined}\n aria-describedby={title && text ? textId : undefined}\n {...mergeProps(rest, autoDismissProps)}\n ref={forkedRef}\n >\n {icon &&\n (typeof icon === 'string' ? (\n <ResolvedIcon\n value={icon}\n className={classNames('notification-icon', { 'align-self-start': !!title })}\n />\n ) : (\n icon\n ))}\n {title && (\n <NotificationTitle id={titleId} component={titleComponent}>\n {title}\n </NotificationTitle>\n )}\n {text && <NotificationText id={textId}>{text}</NotificationText>}\n {children}\n {actions}\n {dismissible && <CloseButton label={closeLabel} onClick={close} />}\n </div>\n </NotificationContext.Provider>\n )\n }\n)\n\nNotification.displayName = 'Notification'\n","import React, { forwardRef } from 'react'\nimport classNames from 'classnames'\n\nimport { Icon, IconProps } from '../icon/Icon'\n\nexport type NotificationIconProps = IconProps & {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n}\n\nexport const NotificationIcon = forwardRef<HTMLSpanElement | SVGSVGElement, NotificationIconProps>(\n ({ className, ...rest }, ref) => {\n const _className = classNames('notification-icon', className)\n\n return <Icon className={_className} {...rest} ref={ref} />\n }\n)\n\nNotificationIcon.displayName = 'NotificationIcon'\n","import { ReactNode } from 'react'\nimport { ToastQueue } from 'react-stately'\n\nimport { NotificationProps } from './Notification'\n\nexport interface NotificationContent extends Pick<\n NotificationProps,\n | 'actions'\n | 'autohide'\n | 'closeLabel'\n | 'color'\n | 'delay'\n | 'dismissible'\n | 'icon'\n | 'role'\n | 'solid'\n | 'text'\n | 'title'\n | 'titleComponent'\n> {\n /**\n * Content of the notification. Compose manually (typically a `NotificationIcon`/\n * `NotificationTitle`/`NotificationText`), or leave empty and use the `icon`/`title`/`text`\n * shorthand options instead.\n */\n children?: ReactNode\n}\n\n// The queue backing `NotificationStack` — a module-level singleton so `addNotification()` is\n// callable from anywhere (an event handler, an async callback) without threading a `push` prop\n// through render. `NotificationStack` subscribes to it via `useToastQueue`; nothing renders\n// until a `<NotificationStack />` is actually mounted somewhere to display the queue's contents.\nexport const notificationQueue = new ToastQueue<NotificationContent>()\n\n// Adds a notification to the queue. Returns the notification's key, which can be passed to\n// `closeNotification` to dismiss it programmatically. `children` is optional — omit it for a\n// notification composed entirely from the `icon`/`title`/`text` shorthand options.\nexport function addNotification(\n children?: ReactNode,\n options: Omit<NotificationContent, 'children'> = {}\n): string {\n return notificationQueue.add({ children, ...options })\n}\n\n// Removes a queued notification immediately, bypassing its own exit animation.\nexport function closeNotification(key: string): void {\n notificationQueue.close(key)\n}\n","import React, { forwardRef, HTMLAttributes } from 'react'\n\nimport { useToastRegionQueue } from '../../hooks'\nimport { Stack } from '../stack'\nimport { Notification } from './Notification'\nimport { notificationQueue } from './notificationQueue'\n\nexport interface NotificationStackProps extends HTMLAttributes<HTMLDivElement> {\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Queued notifications show newest-first by default — the typical toast pattern. Set\n * `reverse` for a chronological transcript instead, oldest-first.\n */\n reverse?: boolean\n}\n\n// Renders the shared `notificationQueue` (see `notificationQueue.ts` — `addNotification()` is\n// how notifications get added to it from anywhere in the app) plus any statically-passed\n// `children`, e.g. a permanently pinned notification alongside dynamic ones — the same static\n// children still render with nothing queued, so this doubles as a plain grouping/spacing\n// wrapper for hand-placed notifications. Unlike `Toaster`, this always renders in normal\n// document flow rather than a fixed/portaled overlay — Chassis notifications are in-page\n// banners, not floating toasts.\nexport const NotificationStack = forwardRef<HTMLDivElement, NotificationStackProps>(\n ({ children, className, reverse, ...rest }, ref) => {\n const { forkedRef, regionProps, state } = useToastRegionQueue(notificationQueue, ref)\n\n if (state.visibleToasts.length === 0 && !children) {\n return null\n }\n\n // The queue is already newest-first (each add unshifts); `reverse` opts into chronological\n // order instead.\n const queued = reverse ? [...state.visibleToasts].reverse() : state.visibleToasts\n\n return (\n <Stack\n direction=\"vertical\"\n gap=\"sm\"\n className={className}\n {...regionProps}\n {...rest}\n ref={forkedRef}\n >\n {children}\n {queued.map((item) => {\n const { children: notificationChildren, ...notificationProps } = item.content\n return (\n <Notification\n key={item.key}\n {...notificationProps}\n onClose={() => state.close(item.key)}\n >\n {notificationChildren}\n </Notification>\n )\n })}\n </Stack>\n )\n }\n)\n\nNotificationStack.displayName = 'NotificationStack'\n","import { useContext } from 'react'\nimport { NotificationContext, NotificationContextProps } from './context'\n\nexport type UseNotificationResult = NotificationContextProps\n\n// Reach the enclosing `Notification`'s dismiss handler from anywhere in its composed markup —\n// e.g. to close it from a plain `Button` placed alongside other `actions`, instead of the\n// built-in `dismissible` close button. Only meaningful inside a `Notification`; outside one it\n// returns a no-op `close`.\nexport const useNotification = (): UseNotificationResult => useContext(NotificationContext)\n"],"mappings":"A,ifAaA,MAAaU,EAAsBC,EAAwC,CAAE,UAAa,CAAC,CAAE,CAAC,ECgB9F,SAASC,EACP,CAAE,WAAU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AI1C,EACJ,IAAKwB,CAeA,EAbJnB,EACAmC,EAAO,IAAK,GAAS,CACpB,GAAM,CAAE,SAAUG,EAAsB,GAAGC,GAAsBC,EAAK,QACtE,MACE,kBAAA,cAACpC,EAAD,CACE,IAAKoC,EAAK,IACV,GAAID,EACJ,YAAeL,EAAM,MAAMM,EAAK,GAAG,CAGvB,EADXF,CACW,CAElB,CAAC,CACI,CAEX,CACF,EAEA,EAAkB,YAAc,oBCxDhC,MAAaG,MAA+CC,EAAWlD,CAAmB,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./useForkedRef-WoqMqsWE.js";import{t}from"./useHydrated-Dud4JEwp.js";import{t as n}from"./useFormField-DH2tlc3e.js";import{t as r}from"./useHeldBack-eeTfpa_t.js";import{t as i}from"./iconSlot-DU_WcSL_.js";import{t as a}from"./renderFormField-_6WswnEX.js";import{t as o}from"./validationClassName-gRGs4KBm.js";import{r as ee,t as s}from"./unhandledProps-9Kdj7WVf.js";import c,{forwardRef as l,useRef as u}from"react";import d from"classnames";import{mergeProps as te,useButton as f,useLocale as p,useNumberField as ne}from"react-aria";import{useNumberFieldState as re}from"react-stately";function m({buttonProps:e,className:t,icon:n,iconKey:r}){let a=u(null),{buttonProps:o}=f(e,a);return/* @__PURE__ */ c.createElement(`button`,{...o,className:t,ref:a},/* @__PURE__ */ c.createElement(i,{icon:r,override:n}))}const h=l(({adornEnd:i,adornStart:l,className:f,decrementAriaLabel:h,decrementIcon:g,defaultValue:_,disabled:v,form:y,formatOptions:ie,help:b,id:ae,incrementAriaLabel:x,incrementIcon:S,invalid:C,invalidFeedback:w,label:T,max:E,min:oe,name:D,onChange:se,readOnly:ce,required:O,size:k,step:le,stepButtons:A=!0,style:j,valid:M,validFeedback:N,value:P,...F},I)=>{let L=u(null),R=e(I,L),{invalid:z,valid:B}=r(L,{invalid:C,valid:M}),V=t(),{locale:H}=p(),{describedBy:U,feedbackId:ue,helpId:de,inputId:W,labelId:fe,labelledBy:pe}=n({ariaDescribedBy:F[`aria-describedby`],ariaLabelledBy:F[`aria-labelledby`],help:b,id:ae,invalid:z,invalidFeedback:w,label:T,valid:B,validFeedback:N}),G={...F,"aria-describedby":U,"aria-labelledby":pe,decrementAriaLabel:h,defaultValue:_,formatOptions:ie,id:W,incrementAriaLabel:x,isDisabled:v,isInvalid:z,isReadOnly:ce,isRequired:O,maxValue:E,minValue:oe,onChange:se,step:le,value:P},K=re({...G,locale:H}),{decrementButtonProps:me,groupProps:q,incrementButtonProps:J,inputProps:Y}=ne(G,K,L),X=A||l!=null||i!=null,Z={onBlur:q.onBlur,onFocus:q.onFocus},Q=/* @__PURE__ */ c.createElement(`input`,{...ee(X?Y:te(Y,Z),F,s),"aria-describedby":U,"aria-disabled":void 0,"aria-readonly":void 0,"aria-required":void 0,"aria-roledescription":V?Y[`aria-roledescription`]:void 0,className:d(X?`ghost-input`:`form-input`,!X&&k,o(z,B),!X&&f),form:y,inputMode:V?Y.inputMode:`numeric`,ref:R,required:O||void 0,style:X?void 0:j}),$=X?/* @__PURE__ */ c.createElement(`div`,{className:d(`form-input`,`number-field`,k,f),style:j,...Z},l,Q,i,A&&/* @__PURE__ */ c.createElement(`div`,{className:`number-field-buttons`},/* @__PURE__ */ c.createElement(m,{buttonProps:J,className:`number-field-increment`,icon:S,iconKey:`increment`}),/* @__PURE__ */ c.createElement(m,{buttonProps:me,className:`number-field-decrement`,icon:g,iconKey:`decrement`}))):Q,he=D?/* @__PURE__ */ c.createElement(c.Fragment,null,$,/* @__PURE__ */ c.createElement(`input`,{disabled:v||void 0,form:y,name:D,type:`hidden`,value:isNaN(K.numberValue)?``:K.numberValue})):$;return a({children:he,help:b,ids:{feedback:ue,help:de,input:W,label:fe},invalid:z,invalidFeedback:w,label:T,valid:B,validFeedback:N})});h.displayName=`NumberField`;export{h as t};
|
|
2
|
+
//# sourceMappingURL=number-field-ChPTSBwI.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-field-ChPTSBwI.js","names":["useForkedRef","useFormField","useHeldBack","IconSlot","renderFormField","validationClassName","mergeUnhandledProps","TEXT_FIELD_PROPS","React","classNames","StepButton","ref","useRef","props","useButton","buttonProps","iconKey","icon","NumberField","forwardRef","invalidProp","validProp","rest","inputRef","forkedRef","hydrated","useHydrated","useLocale","fieldProps","describedBy","labelledBy","inputId","disabled","invalid","readOnly","required","max","min","state","useNumberFieldState","useNumberField","hasWrapper","stepButtons","adornStart","adornEnd","focusWithin","groupProps","input","inputProps","mergeProps","size","valid","className","style","field","incrementButtonProps","incrementIcon","decrementButtonProps","decrementIcon","children","name","feedbackId","helpId","labelId"],"sources":["../../src/components/number-field/NumberField.tsx"],"sourcesContent":["import React, { forwardRef, InputHTMLAttributes, ReactNode, RefObject, useRef } from 'react'\nimport classNames from 'classnames'\nimport {\n AriaButtonProps,\n AriaNumberFieldProps,\n mergeProps,\n useButton,\n useLocale,\n useNumberField\n} from 'react-aria'\nimport { useNumberFieldState } from 'react-stately'\n\nimport './NumberField.scss'\nimport { useForkedRef, useFormField, useHeldBack } from '../../hooks'\nimport { IconValue } from '../../utils/iconConfig'\nimport { IconSlot } from '../icon/iconSlot'\nimport { mergeUnhandledProps, TEXT_FIELD_PROPS } from '../../utils/unhandledProps'\nimport { validationClassName } from '../../utils/validationClassName'\nimport { useHydrated } from '../../hooks/useHydrated'\nimport { renderFormField } from '../form-field/renderFormField'\n\nexport interface NumberFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'defaultValue' | 'inputMode' | 'max' | 'min' | 'onChange' | 'size' | 'step' | 'type' | 'value'\n> {\n /**\n * Content rendered at the input's trailing edge, before the step buttons, e.g. a unit as an\n * `InputAdorn`.\n */\n adornEnd?: ReactNode\n /**\n * Content rendered at the input's leading edge, e.g. an `InputAdorn` icon or text.\n */\n adornStart?: ReactNode\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * The name of the decrement button for screen readers. Defaults to \"Decrease\" and the field's\n * label, in the locale's language.\n */\n decrementAriaLabel?: string\n /**\n * The decrement button's icon, in place of `IconProvider`'s `decrement`.\n */\n decrementIcon?: IconValue\n /**\n * The value of the field, uncontrolled.\n */\n defaultValue?: number\n /**\n * Toggle the disabled state for the component.\n */\n disabled?: boolean\n /**\n * How the value is shown and typed: decimals, a percent, a currency or a unit, with the\n * locale's separators. `Intl.NumberFormat`'s options.\n */\n formatOptions?: Intl.NumberFormatOptions\n /**\n * A description for the field, rendered below the input.\n */\n help?: ReactNode\n /**\n * The name of the increment button for screen readers. Defaults to \"Increase\" and the field's\n * label, in the locale's language.\n */\n incrementAriaLabel?: string\n /**\n * The increment button's icon, in place of `IconProvider`'s `increment`.\n */\n incrementIcon?: IconValue\n /**\n * Set component validation state to invalid. Left unset, the component shows as invalid by itself\n * from a submit it held back (an empty `required` one, say) until it no longer would, or its\n * form is reset. Set it, to `false` too, and it alone decides.\n */\n invalid?: boolean\n /**\n * An error message for the field, rendered below the input when `invalid` is set, and after a\n * submit the field held back, until it no longer would.\n */\n invalidFeedback?: ReactNode\n /**\n * The field's caption, rendered as a `FormLabel` associated with this input.\n */\n label?: ReactNode\n /**\n * The largest value. A larger one typed in is clamped to it when the field loses focus.\n */\n max?: number\n /**\n * The smallest value. A smaller one typed in is clamped to it when the field loses focus.\n */\n min?: number\n /**\n * Handler that is called when the value is committed: on a step (a button, an arrow key, Home,\n * End, the mouse wheel), on Enter or when the field loses focus after typing, on a paste that\n * replaces the whole text, and on a form reset. `NaN` when the field is empty.\n */\n onChange?: (value: number) => void\n /**\n * Toggle the readonly state for the component.\n */\n readOnly?: boolean\n /**\n * Toggle the required state for the component.\n */\n required?: boolean\n /**\n * Size the component sm or lg.\n */\n size?: 'sm' | 'lg'\n /**\n * The amount the buttons and the arrow keys add or take away. A typed value snaps to it,\n * counted from `min`.\n *\n * @default 1\n */\n step?: number\n /**\n * Show the increment and decrement buttons. Without them the arrow keys still step the value.\n *\n * @default true\n */\n stepButtons?: boolean\n /**\n * Set component validation state to valid.\n */\n valid?: boolean\n /**\n * A success message for the field, rendered below the input when `valid` is set.\n */\n validFeedback?: ReactNode\n /**\n * The value of the field, controlled. `NaN` for an empty field.\n */\n value?: number\n}\n\n// One step button. A `<button>` react-aria keeps out of the tab order: the input's arrow keys do\n// the same. A mouse press leaves focus on the input; a touch focuses the button, so no software\n// keyboard opens.\nfunction StepButton({\n buttonProps,\n className,\n icon,\n iconKey\n}: {\n buttonProps: AriaButtonProps\n className: string\n icon?: IconValue\n iconKey: 'increment' | 'decrement'\n}) {\n const ref = useRef<HTMLButtonElement>(null)\n const { buttonProps: props } = useButton(buttonProps, ref as RefObject<HTMLButtonElement | null>)\n return (\n <button {...props} className={className} ref={ref}>\n <IconSlot icon={iconKey} override={icon} />\n </button>\n )\n}\n\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(\n (\n {\n adornEnd,\n adornStart,\n className,\n decrementAriaLabel,\n decrementIcon,\n defaultValue,\n disabled,\n form,\n formatOptions,\n help,\n id,\n incrementAriaLabel,\n incrementIcon,\n invalid: invalidProp,\n invalidFeedback,\n label,\n max,\n min,\n name,\n onChange,\n readOnly,\n required,\n size,\n step,\n stepButtons = true,\n style,\n valid: validProp,\n validFeedback,\n value,\n ...rest\n },\n ref\n ) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const forkedRef = useForkedRef(ref, inputRef)\n // Shown as invalid from a submit it held back until it no longer would (`useHeldBack`):\n // react-aria cancels the browser's own message, and the form stayed with nothing to say why.\n const { invalid, valid } = useHeldBack(inputRef, { invalid: invalidProp, valid: validProp })\n const hydrated = useHydrated()\n const { locale } = useLocale()\n\n const { describedBy, feedbackId, helpId, inputId, labelId, labelledBy } = useFormField({\n ariaDescribedBy: rest['aria-describedby'],\n ariaLabelledBy: rest['aria-labelledby'],\n help,\n id,\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n\n // `label` stays out: react-aria would label the input and the buttons with a label element of\n // its own, which this component doesn't render. The buttons are named from `aria-labelledby`,\n // which names the `FormLabel` (FORMS.md, gotcha 5).\n const fieldProps = {\n ...rest,\n 'aria-describedby': describedBy,\n 'aria-labelledby': labelledBy,\n decrementAriaLabel,\n defaultValue,\n formatOptions,\n id: inputId,\n incrementAriaLabel,\n isDisabled: disabled,\n isInvalid: invalid,\n isReadOnly: readOnly,\n isRequired: required,\n maxValue: max,\n minValue: min,\n onChange,\n step,\n value\n } as AriaNumberFieldProps\n const state = useNumberFieldState({ ...fieldProps, locale })\n const { decrementButtonProps, groupProps, incrementButtonProps, inputProps } = useNumberField(\n fieldProps,\n state,\n inputRef\n )\n\n const hasWrapper = stepButtons || adornStart != null || adornEnd != null\n\n // react-aria picks the keyboard (`inputMode`) and drops `aria-roledescription` by platform\n // (iPhone, Android, iOS), which the server can't know, and a hydrating render doesn't patch an\n // attribute. Until the page has hydrated, both are what the server renders: `numeric`, which\n // any platform but those picks, and no role description, whose text iOS doesn't get.\n // `aria-describedby` after the spread: react-aria's own adds ids it never renders (FORMS.md,\n // gotcha 6).\n // react-aria's focus-within handlers let the mouse wheel step the value while the field has\n // focus: on the wrapper when there is one, else on the input. The wrapper isn't a named group.\n const focusWithin = { onBlur: groupProps.onBlur, onFocus: groupProps.onFocus }\n // `form` reaches the visible input too, which has no `name`: react-aria resets the field on\n // the reset of the input's own form, and a form linked by id is the input's form only then.\n const input = (\n <input\n {...mergeUnhandledProps(\n hasWrapper ? inputProps : mergeProps(inputProps, focusWithin),\n rest,\n TEXT_FIELD_PROPS\n )}\n aria-describedby={describedBy}\n // react-aria's spin button props repeat the native `disabled` and `readOnly` the text\n // field sets; the Nu Html Checker flags the copies.\n aria-disabled={undefined}\n aria-readonly={undefined}\n // The native `required` below says the same.\n aria-required={undefined}\n aria-roledescription={hydrated ? inputProps['aria-roledescription'] : undefined}\n className={classNames(\n hasWrapper ? 'ghost-input' : 'form-input',\n !hasWrapper && size,\n validationClassName(invalid, valid),\n !hasWrapper && className\n )}\n form={form}\n inputMode={hydrated ? inputProps.inputMode : 'numeric'}\n ref={forkedRef}\n // On the visible input, not the hidden one that carries `name`: a hidden input is barred\n // from constraint validation, and this one is empty exactly when the value is. react-aria\n // writes `aria-required` alone, which no form checks.\n required={required || undefined}\n style={hasWrapper ? undefined : style}\n />\n )\n\n // The step buttons sit in their own element: chassis-css styles `.form-input` as disabled when\n // one of its direct children is, and a step button is disabled at `min` or `max`.\n const field = hasWrapper ? (\n <div\n className={classNames('form-input', 'number-field', size, className)}\n style={style}\n {...focusWithin}\n >\n {adornStart}\n {input}\n {adornEnd}\n {stepButtons && (\n <div className=\"number-field-buttons\">\n <StepButton\n buttonProps={incrementButtonProps}\n className=\"number-field-increment\"\n icon={incrementIcon}\n iconKey=\"increment\"\n />\n <StepButton\n buttonProps={decrementButtonProps}\n className=\"number-field-decrement\"\n icon={decrementIcon}\n iconKey=\"decrement\"\n />\n </div>\n )}\n </div>\n ) : (\n input\n )\n\n // The input shows the formatted text; a form receives the number, from a hidden input as\n // react-aria-components' `NumberField` renders it.\n const children = name ? (\n <>\n {field}\n <input\n disabled={disabled || undefined}\n form={form}\n name={name}\n type=\"hidden\"\n value={isNaN(state.numberValue) ? '' : state.numberValue}\n />\n </>\n ) : (\n field\n )\n\n return renderFormField({\n children,\n help,\n ids: { feedback: feedbackId, help: helpId, input: inputId, label: labelId },\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n }\n)\n\nNumberField.displayName = 'NumberField'\n"],"mappings":"A,+nBAgJA,SAASU,EAAW,CAClB,cACA,YACA,OACA,WAMC,CACD,IAAMC,EAAMC,EAA0B,IAAI,EACpC,CAAE,YAAaC,GAAUC,EAAUC,EAAaJ,CAA0C,EAChG,MACE,kBAAA,cAAC,SAAD,CAAQ,GAAIE,EAAkB,YAAgB,KAEtC,EADN,kBAAA,cAACV,EAAD,CAAU,KAAMa,EAAS,SAAUC,CAAO,CAAA,CACpC,CAEZ,CAEA,MAAaC,EAAcC,GAEvB,CACE,WACA,aACA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B,EAASkB,CAAK,EAClC,CAACV,GAAcW,CACjB,EACM,OACN,UAAW3B,EAAWuB,EAAW,UAAY,UAC7C,IAAKxB,EAIL,SAAUW,GAAY,IAAA,GACtB,MAAOM,EAAa,IAAA,GAAYY,CACjC,CAAA,EAKGC,EAAQb,EACZ,kBAAA,cAAC,MAAD,CACE,UAAWhC,EAAW,aAAc,eAAgByC,EAAME,CAAS,EAC5D,QACP,GAAIP,CAqBD,EAnBFF,EACAI,EACAH,EACAF,GACC,kBAAA,cAAC,MAAD,CAAK,UAAU,sBAaV,EAZH,kBAAA,cAAChC,EAAD,CACE,YAAa6C,EACb,UAAU,yBACV,KAAMC,EACN,QAAQ,WACT,CAAA,EACD,kBAAA,cAAC9C,EAAD,CACE,YAAa+C,GACb,UAAU,yBACV,KAAMC,EACN,QAAQ,WACT,CAAA,CACE,CAEJ,EAELX,EAKIY,GAAWC,EACf,kBAAA,cAAApD,EAAA,SAAA,KACG8C,EACD,kBAAA,cAAC,QAAD,CACE,SAAUtB,GAAY,IAAA,GAChB,OACA,OACN,KAAK,SACL,MAAO,MAAMM,EAAM,WAAW,EAAI,GAAKA,EAAM,WAC9C,CAAA,CACD,EAEFgB,EAGF,OAAOlD,EAAgB,CACrB,YACA,OACA,IAAK,CAAE,SAAUyD,GAAY,KAAMC,GAAQ,MAAO/B,EAAS,MAAOgC,EAAQ,EAC1E,UACA,kBACA,QACA,QACA,eACF,CAAC,CACH,CACF,EAEA,EAAY,YAAc,c"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./useForkedRef-WoqMqsWE.js";import{t}from"./useControllableState-CPUJxfKW.js";import{t as n}from"./useFormField-DH2tlc3e.js";import{t as r}from"./useHeldBack-eeTfpa_t.js";import{t as i}from"./renderFormField-_6WswnEX.js";import{t as a}from"./direction-LN6uwsK5.js";import{t as o}from"./validationClassName-gRGs4KBm.js";import s,{Fragment as c,forwardRef as l,useEffect as u,useMemo as d,useRef as f}from"react";import p from"classnames";import{mergeProps as m,useFocusRing as h,useObjectRef as g,useTextField as _}from"react-aria";const v=l(({disabled:e,index:t,invalid:n,mask:r,onChangeValue:i,onFocusBox:a,onKeyDownBox:c,onPasteBox:l,required:u,size:d,valid:f,value:v},y)=>{let b=g(y),{focusProps:x,isFocusVisible:S}=h(),{inputProps:C}=_({"aria-label":`Digit ${t+1}`,autoComplete:t===0||r?`one-time-code`:`off`,isDisabled:e,isInvalid:n,isRequired:u,maxLength:1,onFocus:e=>{e.target.select(),a()},onKeyDown:c,type:r?`password`:`text`,value:v},b);return/* @__PURE__ */ s.createElement(`input`,{...m(C,x),"aria-describedby":void 0,"aria-required":void 0,className:p(`form-input`,d,o(n,f)),"data-focus-visible":S||void 0,inputMode:`numeric`,onChange:e=>i(e.target.value),onPaste:l,pattern:`\\d*`,ref:b,required:u||void 0})});v.displayName=`OtpBox`;const y=e=>e.replace(/\D/g,``),b=(e,t)=>{let n=[...y(e)].slice(0,t);return Array.from({length:t},(e,t)=>n[t]??``)},x=l(({className:l,defaultValue:m,disabled:h,groupSizes:g,help:_,id:x,inputGroup:S,invalid:C,invalidFeedback:w,label:T,length:E=6,mask:D,name:O,onChange:k,onComplete:A,required:ee,separator:te=`–`,size:ne,valid:j,validFeedback:M,value:N,...P},F)=>{let I=g&&g.length>0?g.reduce((e,t)=>e+t,0):E,[L,R]=t(N,m??``,k),z=d(()=>b(L,I),[L,I]),B=f([]),V=e=>B.current[e]?.focus(),H=f(null),U=e(F,H),{invalid:W,valid:G}=r(H,{invalid:C,valid:j}),K=f(z);K.current=z;let q=e=>{let t=K.current.indexOf(``);t!==-1&&e>t&&V(t)},J=f(()=>{});J.current=()=>{let e=m??``;e!==L&&R(e)},u(()=>{let e=B.current[0]?.form;if(!e)return;let t=()=>J.current();return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)},[]);let Y=e=>{K.current=e;let t=e.join(``);R(t),e.length===I&&e.every(e=>e!==``)&&A?.(t)},X=(e,t)=>{let n=y(t);if(n.length>1){let t=[...n],r=[...z];for(let n=0;n<t.length&&e+n<I;n++)r[e+n]=t[n];Y(r),V(Math.min(e+t.length,I-1));return}let r=[...z];r[e]=n,Y(r),n&&e<I-1&&V(e+1)},re=(e,t)=>{if(!h)switch(t.key){case`Backspace`:if(!z[e]&&e>0){t.preventDefault();let n=[...z];n[e-1]=``,Y(n),V(e-1)}break;case`Delete`:{t.preventDefault();let n=[...z];for(let t=e;t<I-1;t++)n[t]=n[t+1];n[I-1]=``,Y(n);break}case`ArrowLeft`:case`ArrowRight`:{let n=t.key===`ArrowRight`===a(t.currentTarget)?e-1:e+1;n>=0&&n<I&&(t.preventDefault(),V(n));break}}},ie=e=>{if(e.preventDefault(),h)return;let t=y(e.clipboardData.getData(`text`)).slice(0,I);t&&(Y(b(t,I)),V(Math.min(t.length,I-1)))},Z=(e,t)=>Array.from({length:t},(t,n)=>e+n).map(e=>/* @__PURE__ */ s.createElement(v,{disabled:h,index:e,invalid:W,key:e,mask:D,onChangeValue:t=>X(e,t),onFocusBox:()=>q(e),onKeyDownBox:t=>re(e,t),onPasteBox:ie,ref:t=>{B.current[e]=t},required:ee,size:ne,valid:G,value:z[e]??``})),Q;if(g&&g.length>0){let e=0;Q=g.map((t,n)=>{let r=e;return e+=t,/* @__PURE__ */ s.createElement(c,{key:n},n>0&&/* @__PURE__ */ s.createElement(`span`,{className:`form-otp-separator`},te),S?/* @__PURE__ */ s.createElement(`div`,{className:`input-group`},Z(r,t)):Z(r,t))})}else Q=Z(0,I);let{describedBy:ae,feedbackId:oe,helpId:se,inputId:ce,labelId:le,labelledBy:$}=n({ariaDescribedBy:P[`aria-describedby`],ariaLabelledBy:P[`aria-labelledby`],help:_,id:x,invalid:W,invalidFeedback:w,label:T,valid:G,validFeedback:M});return i({children:/* @__PURE__ */ s.createElement(`div`,{...P,"aria-describedby":ae,"aria-labelledby":$,className:p(`form-otp`,{"input-group":S&&!(g&&g.length>0)},o(W,G),l),id:ce,ref:U,role:`group`},Q,O&&/* @__PURE__ */ s.createElement(`input`,{disabled:h,name:O,type:`hidden`,value:z.join(``)})),help:_,ids:{feedback:oe,help:se,label:le},invalid:W,invalidFeedback:w,label:T,valid:G,validFeedback:M})});x.displayName=`OtpInput`;export{x as t};
|
|
2
|
+
//# sourceMappingURL=otp-input-DUtCMg8P.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"otp-input-DUtCMg8P.js","names":["useForkedRef","useFormField","useHeldBack","renderFormField","isRTL","validationClassName","React","classNames","OtpBox","forwardRef","ref","useObjectRef","forwardedRef","useFocusRing","useTextField","index","mask","disabled","invalid","required","event","onFocusBox","onKeyDownBox","mergeProps","inputProps","focusProps","size","valid","isFocusVisible","onChangeValue","onPasteBox","onlyDigits","raw","toBoxes","digits","total","i","OtpInput","invalidProp","validProp","rest","groupSizes","a","b","length","rawValue","setRawValue","useControllableState","value","defaultValue","onChange","boxes","useMemo","boxRefs","useRef","focusBox","containerRef","forkedRef","latestBoxes","handleFocus","firstEmpty","resetCode","initial","useEffect","form","onReset","commit","nextBoxes","next","box","onComplete","handleChange","chars","handleKeyDown","nextIndex","handlePaste","renderBoxes","count","start","el","content","cursor","groupSize","Fragment","groupIndex","separator","inputGroup","groupId","describedBy","labelledBy","className","name","feedbackId","helpId","labelId"],"sources":["../../src/components/otp-input/OtpBox.tsx","../../src/components/otp-input/OtpInput.tsx"],"sourcesContent":["import React, { ClipboardEvent, ForwardedRef, forwardRef, KeyboardEvent } from 'react'\nimport classNames from 'classnames'\nimport { mergeProps, useFocusRing, useObjectRef, useTextField } from 'react-aria'\n\nimport { validationClassName } from '../../utils/validationClassName'\n\ninterface OtpBoxProps {\n disabled?: boolean\n index: number\n invalid?: boolean\n mask?: boolean\n onChangeValue: (value: string) => void\n onFocusBox: () => void\n onKeyDownBox: (event: KeyboardEvent<HTMLInputElement>) => void\n onPasteBox: (event: ClipboardEvent<HTMLInputElement>) => void\n required?: boolean\n size?: 'sm' | 'lg'\n valid?: boolean\n value: string\n}\n\nexport const OtpBox = forwardRef(\n (\n {\n disabled,\n index,\n invalid,\n mask,\n onChangeValue,\n onFocusBox,\n onKeyDownBox,\n onPasteBox,\n required,\n size,\n valid,\n value\n }: OtpBoxProps,\n forwardedRef: ForwardedRef<HTMLInputElement>\n ) => {\n const ref = useObjectRef(forwardedRef)\n const { focusProps, isFocusVisible } = useFocusRing()\n const { inputProps } = useTextField(\n {\n 'aria-label': `Digit ${index + 1}`,\n // Only the first box takes the whole code; the others turn autofill off. Browsers ignore\n // `off` on a password field, though, so a masked box would be offered saved passwords:\n // every masked box says it takes a one-time code instead, the one other value that fits.\n autoComplete: index === 0 || mask ? 'one-time-code' : 'off',\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n maxLength: 1,\n // No `onChange` here: react-aria resets each box to its first value on a form reset and\n // reports it there, and each box then wrote itself into the same code. `OtpInput` resets\n // the whole code once; the input's own `onChange` below reports what is typed.\n onFocus: (event) => {\n ;(event.target as HTMLInputElement).select()\n onFocusBox()\n },\n onKeyDown: onKeyDownBox,\n type: mask ? 'password' : 'text',\n value\n },\n ref\n )\n\n return (\n <input\n {...mergeProps(inputProps, focusProps)}\n // The group describes the boxes. react-aria's own ids here are never rendered (FORMS.md,\n // gotcha 6).\n aria-describedby={undefined}\n // The native `required` below says the same.\n aria-required={undefined}\n className={classNames('form-input', size, validationClassName(invalid, valid))}\n data-focus-visible={isFocusVisible || undefined}\n inputMode=\"numeric\"\n onChange={(event) => onChangeValue(event.target.value)}\n onPaste={onPasteBox}\n pattern=\"\\d*\"\n ref={ref}\n // A required code is one with every box filled, so each box is required: a form is held\n // back by the first empty one, which react-aria's listener then focuses. The hidden input\n // that carries `name` is barred from constraint validation (FORMS.md, gotcha 9), and\n // react-aria writes `aria-required` alone, which no form checks.\n required={required || undefined}\n />\n )\n }\n)\n\nOtpBox.displayName = 'OtpBox'\n","import React, {\n ClipboardEvent,\n forwardRef,\n Fragment,\n HTMLAttributes,\n KeyboardEvent,\n ReactNode,\n useEffect,\n useMemo,\n useRef\n} from 'react'\nimport classNames from 'classnames'\n\nimport { useControllableState, useForkedRef, useFormField, useHeldBack } from '../../hooks'\nimport { validationClassName } from '../../utils/validationClassName'\nimport { renderFormField } from '../form-field/renderFormField'\nimport { OtpBox } from './OtpBox'\nimport { isRTL } from '../../utils/direction'\n\nexport interface OtpInputProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /**\n * Identifies the element that describes the group, e.g. a `FormHelp` help element.\n */\n 'aria-describedby'?: string\n /**\n * An accessible label for the group, used when there's no visible `<label>`.\n */\n 'aria-label'?: string\n /**\n * Identifies a visible `<label>` element for the group.\n */\n 'aria-labelledby'?: string\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * The initial code (uncontrolled), e.g. `\"123\"` for a partially filled code.\n */\n defaultValue?: string\n /**\n * Prevents input and makes every box non-interactive.\n */\n disabled?: boolean\n /**\n * Splits the boxes into groups (e.g. `[3, 3]` for a \"123-456\" layout), rendering a\n * `.form-otp-separator` between each group. The total number of boxes becomes the sum of\n * `groupSizes`, overriding `length`.\n */\n groupSizes?: number[]\n /**\n * A description for the field, rendered below the boxes.\n */\n help?: ReactNode\n /**\n * `id` forwarded to the group container.\n */\n id?: string\n /**\n * Visually connects the boxes into a single bordered control. When `groupSizes` is set, each\n * group is connected separately.\n */\n inputGroup?: boolean\n /**\n * Set component validation state to invalid. Left unset, the component shows as invalid by itself\n * from a submit it held back (an empty `required` one, say) until it no longer would, or its\n * form is reset. Set it, to `false` too, and it alone decides.\n */\n invalid?: boolean\n /**\n * An error message for the field, rendered below the boxes when `invalid` is set, and after a\n * submit the field held back, until it no longer would.\n */\n invalidFeedback?: ReactNode\n /**\n * The field's caption, rendered as a `FormLabel` associated with the group via\n * `aria-labelledby` (there's no single input to target with `htmlFor`).\n */\n label?: ReactNode\n /**\n * Number of digit boxes. Ignored when `groupSizes` is set. Defaults to `6`.\n */\n length?: number\n /**\n * Mask entered digits using `type=\"password\"` boxes.\n */\n mask?: boolean\n /**\n * `name` of an auto-created hidden input kept in sync with the code, for native form\n * submission. Omit to skip creating it.\n */\n name?: string\n /**\n * Callback fired whenever the code changes.\n */\n onChange?: (value: string) => void\n /**\n * Callback fired once every box is filled.\n */\n onComplete?: (value: string) => void\n /**\n * Toggle the required state for the component. Every box is then required: a code with a box\n * left empty holds its form back from submitting, and the first empty box takes focus.\n */\n required?: boolean\n /**\n * Content of the separator rendered between groups when `groupSizes` is set. Defaults to `–`.\n */\n separator?: ReactNode\n /**\n * Size the boxes sm or lg.\n */\n size?: 'sm' | 'lg'\n /**\n * Set component validation state to valid.\n */\n valid?: boolean\n /**\n * A success message for the field, rendered below the boxes when `valid` is set.\n */\n validFeedback?: ReactNode\n /**\n * The code (controlled), digits only, e.g. `\"123456\"`.\n */\n value?: string\n}\n\nconst onlyDigits = (raw: string) => raw.replace(/\\D/g, '')\n\nconst toBoxes = (raw: string, total: number): string[] => {\n const digits = [...onlyDigits(raw)].slice(0, total)\n return Array.from({ length: total }, (_, i) => digits[i] ?? '')\n}\n\nexport const OtpInput = forwardRef<HTMLDivElement, OtpInputProps>(\n (\n {\n className,\n defaultValue,\n disabled,\n groupSizes,\n help,\n id,\n inputGroup,\n invalid: invalidProp,\n invalidFeedback,\n label,\n length = 6,\n mask,\n name,\n onChange,\n onComplete,\n required,\n separator = '–',\n size,\n valid: validProp,\n validFeedback,\n value,\n ...rest\n }: OtpInputProps,\n ref\n ): ReactNode => {\n const total =\n groupSizes && groupSizes.length > 0 ? groupSizes.reduce((a, b) => a + b, 0) : length\n\n const [rawValue, setRawValue] = useControllableState(value, defaultValue ?? '', onChange)\n const boxes = useMemo(() => toBoxes(rawValue, total), [rawValue, total])\n\n const boxRefs = useRef<Array<HTMLInputElement | null>>([])\n const focusBox = (index: number) => boxRefs.current[index]?.focus()\n const containerRef = useRef<HTMLDivElement>(null)\n const forkedRef = useForkedRef(ref, containerRef)\n // Shown as invalid from a submit it held back until it no longer would (`useHeldBack`):\n // react-aria cancels the browser's own message, and the form stayed with nothing to say why.\n // The container hears every box.\n const { invalid, valid } = useHeldBack(containerRef, { invalid: invalidProp, valid: validProp })\n\n // The boxes as last committed. A box focused by the handler that committed them (the next box,\n // after a digit) is focused before the render that shows them.\n const latestBoxes = useRef(boxes)\n latestBoxes.current = boxes\n\n // The code is one string with no gaps, so a digit typed past the first empty box would land in\n // that box. Focus on a box past it goes to it.\n const handleFocus = (index: number) => {\n const firstEmpty = latestBoxes.current.indexOf('')\n if (firstEmpty !== -1 && index > firstEmpty) focusBox(firstEmpty)\n }\n\n // A form reset puts the code back once. Each box restoring its own first digit wrote each into\n // the same stale code, which left one digit short and reported every box.\n const resetCode = useRef(() => {})\n resetCode.current = () => {\n const initial = defaultValue ?? ''\n if (initial !== rawValue) setRawValue(initial)\n }\n useEffect(() => {\n const form = boxRefs.current[0]?.form\n if (!form) return\n const onReset = () => resetCode.current()\n form.addEventListener('reset', onReset)\n return () => form.removeEventListener('reset', onReset)\n }, [])\n\n const commit = (nextBoxes: string[]) => {\n latestBoxes.current = nextBoxes\n const next = nextBoxes.join('')\n setRawValue(next)\n if (nextBoxes.length === total && nextBoxes.every((box) => box !== '')) {\n onComplete?.(next)\n }\n }\n\n const handleChange = (index: number, raw: string) => {\n const digits = onlyDigits(raw)\n\n if (digits.length > 1) {\n // Multi-character value landing in a single box (autofill, or a fast typist outrunning\n // the auto-advance) — distribute across this and subsequent boxes, matching chassis-css's\n // vanilla otp-input.js `_handleInput`.\n const chars = [...digits]\n const nextBoxes = [...boxes]\n for (let i = 0; i < chars.length && index + i < total; i++) {\n nextBoxes[index + i] = chars[i]!\n }\n commit(nextBoxes)\n focusBox(Math.min(index + chars.length, total - 1))\n return\n }\n\n const nextBoxes = [...boxes]\n nextBoxes[index] = digits\n commit(nextBoxes)\n if (digits && index < total - 1) focusBox(index + 1)\n }\n\n const handleKeyDown = (index: number, event: KeyboardEvent<HTMLInputElement>) => {\n if (disabled) return\n\n switch (event.key) {\n case 'Backspace': {\n if (!boxes[index] && index > 0) {\n event.preventDefault()\n const nextBoxes = [...boxes]\n nextBoxes[index - 1] = ''\n commit(nextBoxes)\n focusBox(index - 1)\n }\n break\n }\n case 'Delete': {\n event.preventDefault()\n // `boxes` (and every copy derived from it) is always exactly `total` entries long — see\n // `toBoxes` — so `i + 1` (bounded by `i < total - 1`) never reads past the end.\n const nextBoxes = [...boxes]\n for (let i = index; i < total - 1; i++) nextBoxes[i] = nextBoxes[i + 1]!\n nextBoxes[total - 1] = ''\n commit(nextBoxes)\n break\n }\n // Arrow keys move by *visual* direction, so they mirror under RTL: the box to the left of\n // the focused one is the next box, not the previous. `Carousel` and `MenuSubmenu` already\n // mirror their own arrow handling this way; this used to hardcode the LTR mapping and sent\n // an RTL user backwards through the field.\n case 'ArrowLeft':\n case 'ArrowRight': {\n const movesForward = (event.key === 'ArrowRight') !== isRTL(event.currentTarget)\n const nextIndex = movesForward ? index + 1 : index - 1\n if (nextIndex >= 0 && nextIndex < total) {\n event.preventDefault()\n focusBox(nextIndex)\n }\n break\n }\n default:\n break\n }\n }\n\n const handlePaste = (event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault()\n if (disabled) return\n const digits = onlyDigits(event.clipboardData.getData('text')).slice(0, total)\n if (!digits) return\n commit(toBoxes(digits, total))\n // The next empty box, as the autofill branch of `handleChange` does: a box selects its\n // content on focus, so on the last filled one the next digit typed would replace it.\n focusBox(Math.min(digits.length, total - 1))\n }\n\n const renderBoxes = (start: number, count: number) =>\n Array.from({ length: count }, (_, i) => start + i).map((i) => (\n <OtpBox\n disabled={disabled}\n index={i}\n invalid={invalid}\n key={i}\n mask={mask}\n onChangeValue={(next) => handleChange(i, next)}\n onFocusBox={() => handleFocus(i)}\n onKeyDownBox={(event) => handleKeyDown(i, event)}\n onPasteBox={handlePaste}\n ref={(el) => {\n boxRefs.current[i] = el\n }}\n required={required}\n size={size}\n valid={valid}\n value={boxes[i] ?? ''}\n />\n ))\n\n let content: ReactNode\n if (groupSizes && groupSizes.length > 0) {\n let cursor = 0\n content = groupSizes.map((groupSize, groupIndex) => {\n const start = cursor\n cursor += groupSize\n return (\n // eslint-disable-next-line react/no-array-index-key\n <Fragment key={groupIndex}>\n {groupIndex > 0 && <span className=\"form-otp-separator\">{separator}</span>}\n {inputGroup ? (\n <div className=\"input-group\">{renderBoxes(start, groupSize)}</div>\n ) : (\n renderBoxes(start, groupSize)\n )}\n </Fragment>\n )\n })\n } else {\n content = renderBoxes(0, total)\n }\n\n const {\n describedBy,\n feedbackId,\n helpId,\n inputId: groupId,\n labelId,\n labelledBy\n } = useFormField({\n ariaDescribedBy: rest['aria-describedby'],\n ariaLabelledBy: rest['aria-labelledby'],\n help,\n id,\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n\n return renderFormField({\n children: (\n <div\n {...rest}\n aria-describedby={describedBy}\n aria-labelledby={labelledBy}\n className={classNames(\n 'form-otp',\n { 'input-group': inputGroup && !(groupSizes && groupSizes.length > 0) },\n validationClassName(invalid, valid),\n className\n )}\n id={groupId}\n ref={forkedRef}\n role=\"group\"\n >\n {content}\n {name && <input disabled={disabled} name={name} type=\"hidden\" value={boxes.join('')} />}\n </div>\n ),\n help,\n ids: { feedback: feedbackId, help: helpId, label: labelId },\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n }\n)\n\nOtpInput.displayName = 'OtpInput'\n"],"mappings":"A,ukBAqBA,MAAaQ,EAASC,GAElB,CACE,WACA,QACA,UACA,OACA,gBACA,aACA,eACA,aACA,WACA,OACA,QACA,SAEF,IACG,CACH,IAAMC,EAAMC,EAAaC,CAAY,EAC/B,CAAE,aAAY,kBAAmBC,EAAa,EAC9C,CAAE,cAAeC,EACrB,CACE,aAAc,SAASC,EAAQ,IAI/B,aAAcA,IAAU,GAAKC,EAAO,gBAAkB,MACtD,WAAYC,EACZ,UAAWC,EACX,WAAYC,EACZ,UAAW,EAIX,QAAU,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