@chassis-ui/react 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +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-264aGoBR.js +2 -0
- package/dist/chunks/Menu-264aGoBR.js.map +1 -0
- package/dist/chunks/{Menu-QeYOzrUL.d.ts → Menu-CCYshRuL.d.ts} +3 -2
- package/dist/chunks/MenuToggle-DcPEh55c.js +2 -0
- package/dist/chunks/MenuToggle-DcPEh55c.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-99usnvgh.js +2 -0
- package/dist/chunks/autocomplete-99usnvgh.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-BQh3uJWB.js +2 -0
- package/dist/chunks/combobox-BQh3uJWB.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-8KIuH4cJ.js +2 -0
- package/dist/chunks/context-menu-8KIuH4cJ.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-B5bF1JxF.d.ts → index-DsU3M0oP.d.ts} +3 -3
- 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-DEu-Nbv8.js +2 -0
- package/dist/chunks/menu-DEu-Nbv8.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-DpX_lRYf.js +2 -0
- package/dist/chunks/nav-overflow-DpX_lRYf.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-8mQL2Q6d.js +2 -0
- package/dist/chunks/useOverlayMaxHeight-8mQL2Q6d.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-CZsWCnQb.js +0 -2
- package/dist/chunks/Link-CZsWCnQb.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-BdQtF7FV.js +0 -2
- package/dist/chunks/MenuToggle-BdQtF7FV.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-BXI-_qlt.js +0 -2
- package/dist/chunks/alert-BXI-_qlt.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-S3dGy6Qc.js +0 -2
- package/dist/chunks/avatar-S3dGy6Qc.js.map +0 -1
- package/dist/chunks/badge-D2oztCvs.js.map +0 -1
- package/dist/chunks/breadcrumb-s6J9itez.js +0 -2
- package/dist/chunks/breadcrumb-s6J9itez.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-CobeDpf1.js +0 -2
- package/dist/chunks/card-CobeDpf1.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/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-CH3Cy-q7.js +0 -3
- package/dist/chunks/datagrid-CH3Cy-q7.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-BQCkwWjF.js +0 -2
- package/dist/chunks/list-BQCkwWjF.js.map +0 -1
- package/dist/chunks/menu-98EAD9nj.js +0 -2
- package/dist/chunks/menu-98EAD9nj.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-TiZuTHC6.js +0 -2
- package/dist/chunks/nav-TiZuTHC6.js.map +0 -1
- package/dist/chunks/nav-overflow-Ay5mM5Gc.js +0 -2
- package/dist/chunks/nav-overflow-Ay5mM5Gc.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-BkOquk-x.js +0 -2
- package/dist/chunks/pagination-BkOquk-x.js.map +0 -1
- package/dist/chunks/password-strength-DDK8pHRq.js.map +0 -1
- package/dist/chunks/placeholder-BCr83sUn.js +0 -2
- package/dist/chunks/placeholder-BCr83sUn.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-zWkTltor.js +0 -2
- package/dist/chunks/progress-zWkTltor.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-CmZBLJwp.js +0 -2
- package/dist/chunks/skeleton-CmZBLJwp.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-DblhvrHL.js +0 -2
- package/dist/chunks/spinner-DblhvrHL.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-D0M4oc_t.js +0 -2
- package/dist/chunks/static-table-D0M4oc_t.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-Cy6uEuEP.js +0 -2
- package/dist/chunks/table-Cy6uEuEP.js.map +0 -1
- package/dist/chunks/tableClassName-CZA2Bse8.js +0 -2
- package/dist/chunks/tableClassName-CZA2Bse8.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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e={top:`top`,"top-start":`top start`,"top-end":`top end`,bottom:`bottom`,"bottom-start":`bottom start`,"bottom-end":`bottom end`,left:`left`,"left-start":`left top`,"left-end":`left bottom`,right:`right`,"right-start":`right top`,"right-end":`right bottom`},t=t=>e[t],n=(e,t)=>{if(!t||t===`center`)return e;let n=e.split(`-`)[1];return n?`${t}-${n}`:t},r=(e,t,r)=>({menuStyle:{position:e?.position,top:e?.top,left:e?.left},placementAttr:n(t,r)}),i={"--menu-max-height":`320px`,"--menu-overflow-y":`auto`};export{t as i,n,r,i as t};
|
|
2
|
-
//# sourceMappingURL=overlayPlacement-
|
|
1
|
+
const e={top:`top`,"top-start":`top start`,"top-end":`top end`,bottom:`bottom`,"bottom-start":`bottom start`,"bottom-end":`bottom end`,left:`left`,"left-start":`left top`,"left-end":`left bottom`,right:`right`,"right-start":`right top`,"right-end":`right bottom`},t=t=>e[t],n=(e,t)=>{if(!t||t===`center`)return e;let n=e.split(`-`)[1];return n?`${t}-${n}`:t},r=(e,t,r)=>({menuStyle:{position:e?.position,top:e?.top,left:e?.left},placementAttr:n(t,r)}),i={"--cx-menu-max-height":`320px`,"--cx-menu-overflow-y":`auto`};export{t as i,n,r,i as t};
|
|
2
|
+
//# sourceMappingURL=overlayPlacement-Q6bcbXA5.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlayPlacement-Q6bcbXA5.js","names":["ARIA_PLACEMENT","toAriaPlacement","placement","resolveDataPlacement","resolvedMain","requested","cross","resolveMenuOverlayPositioning","overlayStyle","requestedPlacement","resolvedPlacement","COMBOBOX_MENU_OVERLAY_STYLE"],"sources":["../../src/utils/overlayPlacement.ts"],"sourcesContent":["import type { CSSProperties } from 'react'\nimport type { Placement as AriaPlacement, PlacementAxis } from 'react-aria'\n\n// Chassis CSS's floating components (`.menu`, `.tooltip`, `.popover`) read a `data-cx-placement`\n// attribute in this hyphenated, compound form (`\"bottom-end\"`, `\"top-start\"`, ...) to pick the\n// right transform-origin for the open/close animation. React Aria's `useOverlayPosition` speaks a\n// different, space-separated placement vocabulary (`\"bottom end\"`) and only reports back the\n// resolved main axis after flipping, not the full compound value — this module bridges the two.\nexport type Placement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end'\n\nconst ARIA_PLACEMENT: Record<Placement, AriaPlacement> = {\n top: 'top',\n 'top-start': 'top start',\n 'top-end': 'top end',\n bottom: 'bottom',\n 'bottom-start': 'bottom start',\n 'bottom-end': 'bottom end',\n left: 'left',\n 'left-start': 'left top',\n 'left-end': 'left bottom',\n right: 'right',\n 'right-start': 'right top',\n 'right-end': 'right bottom'\n}\n\n// Translates chassis-react's public `placement` prop values into the strings\n// `useOverlayPosition` expects.\nexport const toAriaPlacement = (placement: Placement): AriaPlacement => ARIA_PLACEMENT[placement]\n\n// `useOverlayPosition`'s own `shouldFlip` only ever swaps the main axis (top<->bottom or\n// left<->right) — it never changes the requested cross-axis alignment — so the resolved compound\n// value is always the requested cross-axis suffix reattached to the (possibly flipped) main axis\n// `useOverlayPosition` reports back.\nexport const resolveDataPlacement = (\n requested: Placement,\n resolvedMain: PlacementAxis | null\n): string => {\n if (!resolvedMain || resolvedMain === 'center') return requested\n const cross = requested.split('-')[1]\n return cross ? `${resolvedMain}-${cross}` : resolvedMain\n}\n\n// Shared between `Menu`/`MenuSubmenu` and `Combobox`/`Autocomplete`, whose floating panels all\n// position via `useOverlayPosition` the same way: only `position`/`top`/`left` are taken from the\n// hook's computed style (`zIndex`/`maxHeight` stay owned by chassis-css's own `--zindex`/\n// `--max-height` tokens, see `_menu.scss`; the inline `max-height` the hook writes on the element\n// itself is taken off by `useOverlayMaxHeight`), and `data-cx-placement` needs the resolved main axis\n// reattached to the originally-requested cross-axis alignment. Pure positioning that renders\n// nothing and belongs to none of the four, so it lives here and not in `components/menu/`.\nexport interface MenuOverlayPositioning {\n menuStyle: CSSProperties\n placementAttr: string\n}\n\nexport const resolveMenuOverlayPositioning = (\n overlayStyle: CSSProperties | undefined,\n requestedPlacement: Placement,\n resolvedPlacement: PlacementAxis | null\n): MenuOverlayPositioning => ({\n menuStyle: {\n position: overlayStyle?.position,\n top: overlayStyle?.top,\n left: overlayStyle?.left\n },\n placementAttr: resolveDataPlacement(requestedPlacement, resolvedPlacement)\n})\n\n// chassis-css's `.combobox + .menu` sibling-selector rule (`_combobox.scss`) sets\n// `--cx-menu-max-height`/`--cx-menu-overflow-y` from `$combobox-menu-max-height`/\n// `$combobox-menu-overflow-y` (320px/auto by default) — but only while the panel is an adjacent\n// DOM sibling of `.combobox`. `Autocomplete`/`Combobox` portal their panel to `document.body` (or\n// an enclosing open `<dialog>`, via `useFloatingOverlay`), breaking that adjacency, so both inline\n// this as a fallback matching the shipped Sass defaults instead of the generic, uncapped `.menu`\n// fallback (`max-height: none`). The names carry the `cx-` prefix of chassis-css's built CSS:\n// unprefixed, as they were, nothing read them, and only the inline `max-height` react-aria wrote\n// (`useOverlayMaxHeight`) capped the list. A consumer who customized either Sass variable needs to\n// re-override `--cx-menu-max-height`/`--cx-menu-overflow-y` on `.menu` directly, since the\n// sibling-selector auto-application can no longer reach a portaled panel.\nexport const COMBOBOX_MENU_OVERLAY_STYLE: CSSProperties = {\n '--cx-menu-max-height': '320px',\n '--cx-menu-overflow-y': 'auto'\n} as CSSProperties\n"],"mappings":"AAsBA,MAAMA,EAAmD,CACvD,IAAK,MACL,YAAa,YACb,UAAW,UACX,OAAQ,SACR,eAAgB,eAChB,aAAc,aACd,KAAM,OACN,aAAc,WACd,WAAY,cACZ,MAAO,QACP,cAAe,YACf,YAAa,cACf,EAIaC,EAAmB,GAAwCD,EAAeE,GAM1EC,GACX,EACA,IACW,CACX,GAAI,CAACC,GAAgBA,IAAiB,SAAU,OAAOC,EACvD,IAAMC,EAAQD,EAAU,MAAM,GAAG,CAAC,CAAC,GACnC,OAAOC,EAAQ,GAAGF,EAAa,GAAGE,IAAUF,CAC9C,EAcaG,GACX,EACA,EACA,KAC4B,CAC5B,UAAW,CACT,SAAUC,GAAc,SACxB,IAAKA,GAAc,IACnB,KAAMA,GAAc,IACtB,EACA,cAAeL,EAAqBM,EAAoBC,CAAiB,CAC3E,GAaaC,EAA6C,CACxD,uBAAwB,QACxB,uBAAwB,MAC1B,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=[],t=t=>{if(t.key!==`Escape`||t.defaultPrevented)return;let n=e[e.length-1];n?.onEscape&&(t.preventDefault(),n.onEscape())},n=(e,t)=>{let n=t.nodes();return e.nodes().some(e=>!!e&&n.some(t=>!!t&&t!==e&&t.contains(e)))};function r(r){e.length===0&&window.addEventListener(`keydown`,t);let i=e.findIndex(e=>n(e,r));return i===-1?e.push(r):e.splice(i,0,r),()=>{let n=e.indexOf(r);n!==-1&&e.splice(n,1),e.length===0&&window.removeEventListener(`keydown`,t)}}function i(t){return e.some(e=>e.nodes().some(e=>!!e&&e!==t&&t.contains(e)))}export{r as n,i as t};
|
|
2
|
+
//# sourceMappingURL=overlayStack-BXtTGCRm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overlayStack-BXtTGCRm.js","names":["stack","handleKeyDown","event","top","isWithin","containers","outer","inner","node","container","pushOverlay","other","entry","index","hasOverlayWithin"],"sources":["../../src/utils/overlayStack.ts"],"sourcesContent":["// The overlays that are open, in the order they opened: `Popover`, `Menu`, `ContextMenu`, and a\n// dialog opened with `showModal()`. Escape belongs to the last of them only. Each of these used\n// to listen for the key by itself, so one press closed a menu, the popover it was in and the\n// dialog around both.\nexport interface OverlayStackEntry {\n /**\n * The elements the overlay is made of: its panel and its trigger. A non-modal dialog reads them\n * to leave Escape to an overlay that is open inside it (`hasOverlayWithin`).\n */\n nodes: () => Array<Element | null | undefined>\n /**\n * Closes the overlay. A modal dialog has none: the browser sends it a `cancel` event for the\n * key itself, so its entry only keeps the overlays under it from taking the key first.\n */\n onEscape?: () => void\n}\n\nconst stack: OverlayStackEntry[] = []\n\n// On `window`, in the bubble phase: whatever handles Escape closer to the focused element (a\n// submenu, a combobox's list, react-aria's tooltip) has stopped or prevented the event by then.\nconst handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape' || event.defaultPrevented) return\n const top = stack[stack.length - 1]\n if (!top?.onEscape) return\n // Prevented, so the browser doesn't also send `cancel` to a modal dialog the overlay is in.\n event.preventDefault()\n top.onEscape()\n}\n\n// Whether one of `outer`'s elements contains one of `inner`'s: `inner` was opened from inside it.\nconst isWithin = (inner: OverlayStackEntry, outer: OverlayStackEntry) => {\n const containers = outer.nodes()\n return inner\n .nodes()\n .some(\n (node) =>\n !!node &&\n containers.some(\n (container) => !!container && container !== node && container.contains(node)\n )\n )\n}\n\n/**\n * Adds an open overlay to the stack, and returns the function that takes it out. It goes on top,\n * unless an overlay already there is open inside it: overlays mounted open in one commit push\n * from their effects, the inner one first, and Escape would have closed the outer one.\n */\nexport function pushOverlay(entry: OverlayStackEntry): () => void {\n if (stack.length === 0) window.addEventListener('keydown', handleKeyDown)\n const inner = stack.findIndex((other) => isWithin(other, entry))\n if (inner === -1) stack.push(entry)\n else stack.splice(inner, 0, entry)\n\n return () => {\n const index = stack.indexOf(entry)\n if (index !== -1) stack.splice(index, 1)\n if (stack.length === 0) window.removeEventListener('keydown', handleKeyDown)\n }\n}\n\n/**\n * Whether an overlay of the stack is open inside `container`, which is then not the innermost.\n */\nexport function hasOverlayWithin(container: Element): boolean {\n return stack.some((entry) =>\n entry.nodes().some((node) => !!node && node !== container && container.contains(node))\n )\n}\n"],"mappings":"AAiBA,MAAMA,EAA6B,CAAC,EAI9BC,EAAiB,GAAyB,CAC9C,GAAIC,EAAM,MAAQ,UAAYA,EAAM,iBAAkB,OACtD,IAAMC,EAAMH,EAAMA,EAAM,OAAS,GAC5BG,GAAK,WAEVD,EAAM,eAAe,EACrBC,EAAI,SAAS,EACf,EAGMC,GAAY,EAA0B,IAA6B,CACvE,IAAMC,EAAaC,EAAM,MAAM,EAC/B,OAAOC,EACJ,MAAM,CAAC,CACP,KACE,GACC,CAAC,CAACC,GACFH,EAAW,KACR,GAAc,CAAC,CAACI,GAAaA,IAAcD,GAAQC,EAAU,SAASD,CAAI,CAC7E,CACJ,CACJ,EAOA,SAAgBE,EAAY,EAAsC,CAC5DV,EAAM,SAAW,GAAG,OAAO,iBAAiB,UAAWC,CAAa,EACxE,IAAMM,EAAQP,EAAM,UAAW,GAAUI,EAASO,EAAOC,CAAK,CAAC,EAI/D,OAHIL,IAAU,GAAIP,EAAM,KAAKY,CAAK,EAC7BZ,EAAM,OAAOO,EAAO,EAAGK,CAAK,MAEpB,CACX,IAAMC,EAAQb,EAAM,QAAQY,CAAK,EAC7BC,IAAU,IAAIb,EAAM,OAAOa,EAAO,CAAC,EACnCb,EAAM,SAAW,GAAG,OAAO,oBAAoB,UAAWC,CAAa,CAC7E,CACF,CAKA,SAAgBa,EAAiB,EAA6B,CAC5D,OAAOd,EAAM,KAAM,GACjBY,EAAM,MAAM,CAAC,CAAC,KAAM,GAAS,CAAC,CAACJ,GAAQA,IAASC,GAAaA,EAAU,SAASD,CAAI,CAAC,CACvF,CACF,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{f as e,m as t,v as n}from"./slot-BQVx1Eew.js";import{t as r}from"./polymorphic-CZIFszAy.js";import{t as i}from"./useButtonSemantics-B1SbGaDO.js";import{t as a}from"./focusRedirect-CrBl4p_n.js";import{t as o}from"./iconSlot-DU_WcSL_.js";import s,{forwardRef as c,useEffect as l,useRef as u}from"react";import d from"classnames";import{mergeProps as f}from"react-aria";function p({prevDisabled:e,nextDisabled:t,onPrev:n,onNext:r}){let i=u(null),o=u(null),s=u(null);return l(()=>{let n=s.current;s.current=null,n&&(n.from===`prev`&&e?a(o.current,n.viaPointer):n.from===`next`&&t&&a(i.current,n.viaPointer))}),{prevRef:i,nextRef:o,handlePrevClick:e=>{s.current={from:`prev`,viaPointer:e.detail!==0},n()},handleNextClick:e=>{s.current={from:`next`,viaPointer:e.detail!==0},r()}}}function m({active:r,children:a,className:o,component:c,disabled:l,href:u,onClick:p,...m},h){let g=d(`pagination-item`,{active:r,disabled:l},o),_=t(c,u,`button`),v=n(_,u,m),y=e(v,u,`PaginationItem`),b=_,x=_,S=e=>{v===`anchor`&&l?e.preventDefault():p?.(e)},C=v!==`button`&&v!==`anchor`&&!!p,{buttonProps:w,forkedRef:T}=i(h,{disabled:l,onClick:p}),E=r?{"aria-current":`page`}:{};return/* @__PURE__ */ s.createElement(`li`,{className:g},v===`button`?/* @__PURE__ */ s.createElement(b,{...m,className:`pagination-link`,type:`button`,disabled:l,onClick:S,...E,ref:h},a):v===`anchor`?/* @__PURE__ */ s.createElement(x,{...m,className:`pagination-link`,...y,onClick:S,...l&&{"aria-disabled":!0,tabIndex:-1},...E,ref:h},a):/* @__PURE__ */ s.createElement(_,{className:`pagination-link`,...f(m,C?w:{}),...!C&&{onClick:S},...y,...E,ref:C?T:h},a))}const h=r(m,`PaginationItem`),g={start:`justify-content-start`,center:`justify-content-center`,end:`justify-content-end`};function _(e,t,n){let r=Math.max(1,n);if(t<=r)return Array.from({length:t},(e,t)=>t+1);let i=Math.floor(r/2),a=Math.max(1,e-i),o=Math.min(t,a+r-1);o-a<r-1&&(a=Math.max(1,o-r+1));let s=[];a>1&&(s.push(1),a>2&&s.push(`...`));for(let e=a;e<=o;e++)s.push(e);return o<t&&(o<t-1&&s.push(`...`),s.push(t)),s}const v=c(({activePage:e=1,align:t,"aria-label":n=`Pagination`,children:r,className:i,maxVisiblePages:a=5,nextIcon:c,nextLabel:l=`Next`,onActivePageChange:u,pages:f,previousIcon:m,previousLabel:v=`Previous`,showPageNumbers:y=!0,showPrevNext:b=!0,size:x,...S},C)=>{let w=d(`pagination`,x,t&&g[t],i),T=f!=null,E=T?Math.min(Math.max(e,1),f):e,D=T?E<=1:!1,O=T?E>=f:!1,{prevRef:k,nextRef:A,handlePrevClick:j,handleNextClick:M}=p({prevDisabled:D,nextDisabled:O,onPrev:()=>u&&u(E-1),onNext:()=>u&&u(E+1)}),N=T?/* @__PURE__ */ s.createElement(s.Fragment,null,b&&/* @__PURE__ */ s.createElement(h,{ref:k,disabled:D,onClick:j,"aria-label":v},/* @__PURE__ */ s.createElement(o,{icon:`previous`,override:m,className:`directional-icon`})),y&&_(E,f,a).map((e,t)=>e===`...`?/* @__PURE__ */ s.createElement(h,{key:`ellipsis-${t}`,disabled:!0,component:`span`,"aria-hidden":`true`},`…`):/* @__PURE__ */ s.createElement(h,{key:e,active:e===E,onClick:()=>u&&u(e)},e)),b&&/* @__PURE__ */ s.createElement(h,{ref:A,disabled:O,onClick:M,"aria-label":l},/* @__PURE__ */ s.createElement(o,{icon:`next`,override:c,className:`directional-icon`}))):null;return/* @__PURE__ */ s.createElement(`nav`,{"aria-label":n,ref:C,...S},/* @__PURE__ */ s.createElement(`ul`,{className:w},N??r))});v.displayName=`Pagination`;export{h as n,p as r,v as t};
|
|
2
|
+
//# sourceMappingURL=pagination-Dvz8lccd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination-Dvz8lccd.js","names":["hrefProps","linkElement","resolveLinkKind","createPolymorphicComponent","useButtonSemantics","focusRedirect","IconSlot","React","classNames","usePagination","prevRef","useRef","nextRef","pending","useEffect","from","prevDisabled","nextDisabled","event","onPrev","onNext","PaginationItemRender","rest","_className","className","Component","component","href","kind","linkProps","NativeButton","Anchor","handleClick","disabled","onClick","needsButtonSemantics","ref","currentProps","active","children","mergeProps","buttonProps","forkedRef","PaginationItem","ALIGN_CLASS_NAMES","getPageRange","safeMaxVisible","maxVisible","pages","i","half","start","activePage","end","result","Pagination","forwardRef","ariaLabel","size","align","isSmart","clampedActivePage","onActivePageChange","smartContent","showPrevNext","handlePrevClick","previousLabel","previousIcon","showPageNumbers","maxVisiblePages","page","idx","handleNextClick","nextLabel","nextIcon"],"sources":["../../src/hooks/usePagination.ts","../../src/components/pagination/PaginationItem.tsx","../../src/components/pagination/Pagination.tsx"],"sourcesContent":["import { MouseEvent, RefObject, useEffect, useRef } from 'react'\n\nimport { focusRedirect } from '../utils/focusRedirect'\n\nexport interface UsePaginationOptions {\n /**\n * Whether the Previous control is currently disabled.\n */\n prevDisabled: boolean\n /**\n * Whether the Next control is currently disabled.\n */\n nextDisabled: boolean\n /**\n * Called when Previous is clicked, before the state change that may disable it.\n */\n onPrev: () => void\n /**\n * Called when Next is clicked, before the state change that may disable it.\n */\n onNext: () => void\n}\n\nexport interface UsePaginationResult<T extends HTMLElement = HTMLButtonElement> {\n // `RefObject<T | null>`, not `RefObject<T>`: these come from `useRef<T>(null)`, so `.current`\n // really is null before mount (and whenever the control isn't rendered — a hand-composed\n // pagination may omit Prev/Next entirely). Declaring the non-null form let a consumer write\n // `prevRef.current.focus()` with no type error and crash at runtime.\n prevRef: RefObject<T | null>\n nextRef: RefObject<T | null>\n handlePrevClick: (event: MouseEvent<T>) => void\n handleNextClick: (event: MouseEvent<T>) => void\n}\n\ninterface Pending {\n from: 'prev' | 'next'\n // A `click` fired by real pointer activation has `detail >= 1`; one fired by keyboard\n // activation (Enter/Space on a focused button) has `detail === 0`.\n viaPointer: boolean\n}\n\n// Native `disabled` buttons are blurred by the browser the instant they're disabled. Clicking a\n// Prev/Next control into the first/last page disables that very control, silently dropping focus\n// to `<body>`. Wire `handlePrevClick`/`handleNextClick` up as each control's `onClick` — they call\n// `onPrev`/`onNext` and redirect focus to the still-enabled sibling in one step, so callers don't\n// hand-wrap their own click handler around a separate mark-then-focus call.\n// Works for `Pagination`'s built-in smart mode and for hand-composed Prev/Next controls alike —\n// pass the element type of whatever you're attaching the refs to (`PaginationItem` defaults to\n// an `HTMLButtonElement`, but renders an `HTMLAnchorElement` when given `href` or `component`).\nexport function usePagination<T extends HTMLElement = HTMLButtonElement>({\n prevDisabled,\n nextDisabled,\n onPrev,\n onNext\n}: UsePaginationOptions): UsePaginationResult<T> {\n const prevRef = useRef<T>(null)\n const nextRef = useRef<T>(null)\n const pending = useRef<Pending | null>(null)\n\n // Deliberately no dependency array: this must run after every render, not just ones where\n // prevDisabled/nextDisabled change value. A Prev/Next click that doesn't cross a boundary\n // (e.g. moving between two enabled middle pages) leaves both booleans unchanged, so a\n // dependency-gated effect would skip and leave `pending` stale — a later, unrelated render\n // that does flip one of the booleans (e.g. jumping straight to the first/last page via a\n // page-number click) would then wrongly consume that stale mark and redirect focus.\n useEffect(() => {\n const from = pending.current\n pending.current = null\n if (!from) return\n if (from.from === 'prev' && prevDisabled) {\n focusRedirect(nextRef.current, from.viaPointer)\n } else if (from.from === 'next' && nextDisabled) {\n focusRedirect(prevRef.current, from.viaPointer)\n }\n })\n\n return {\n prevRef,\n nextRef,\n handlePrevClick: (event) => {\n pending.current = { from: 'prev', viaPointer: event.detail !== 0 }\n onPrev()\n },\n handleNextClick: (event) => {\n pending.current = { from: 'next', viaPointer: event.detail !== 0 }\n onNext()\n }\n }\n}\n","import React, {\n ElementType,\n ForwardRefRenderFunction,\n MouseEvent,\n MouseEventHandler,\n ReactElement,\n Ref\n} from 'react'\nimport classNames from 'classnames'\nimport { mergeProps } from 'react-aria'\n\nimport { useButtonSemantics } from '../../hooks'\nimport { hrefProps, linkElement, resolveLinkKind } from '../../utils/elementKind'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef,\n PolymorphicRefWithFallback\n} from '../../utils/polymorphic'\n\ntype PaginationItemOwnProps<C extends ElementType> = {\n /**\n * Toggle the active state for the component.\n */\n active?: boolean\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 * Toggle the disabled state for the component.\n */\n disabled?: boolean\n /**\n * The href attribute. When provided the item renders as an `<a>` tag; otherwise as a `<button>`.\n */\n href?: string\n}\n\nexport type PaginationItemProps<C extends ElementType = 'button'> = PolymorphicComponentProps<\n C,\n PaginationItemOwnProps<C>\n>\n\ntype PaginationItemComponent = (<C extends ElementType = 'button'>(\n props: PaginationItemProps<C> & {\n ref?: PolymorphicRefWithFallback<C, HTMLButtonElement | HTMLAnchorElement | HTMLSpanElement>\n }\n) => ReactElement | null) & { displayName?: string }\n\nfunction PaginationItemRender<C extends ElementType = 'button'>(\n {\n active,\n children,\n className,\n component,\n disabled,\n href,\n onClick,\n ...rest\n }: PaginationItemProps<C>,\n ref: PolymorphicRef<C>\n) {\n const _className = classNames(\n 'pagination-item',\n {\n active,\n disabled\n },\n className\n )\n\n // The active page keeps whatever element it would render anyway (`<button>`, or `<a>` when\n // given `href`) rather than collapsing to a `<span>`. Swapping the tag on activation made React\n // unmount the focused control and mount a different element in its place, so a keyboard user who\n // activated a page was dropped to `<body>` and had to tab in from the top of the document again\n // (WCAG 2.4.3). The `<span>` wasn't even inert: `Pagination`'s smart mode passes an `onClick`,\n // so `useButtonSemantics` gave it `role=\"button\"` and `tabIndex={0}` — a synthetic button,\n // strictly worse than the real one it replaced. Styling is unaffected either way: chassis-css\n // matches `.pagination-link { &.active, .active > & }`, and `active` still lands on the `<li>`.\n const Component = linkElement(component, href, 'button')\n // The kind rather than the tag, counting a router link with `href` or `to` as an anchor: under `asChild`, `Component` is a `Slot` standing in for the\n // caller's element, and a slotted `<a>` needs what `component=\"a\"` gets. Each branch below\n // renders `Component` typed as its tag, which is the tag itself or that `Slot`.\n const kind = resolveLinkKind(Component, href, rest)\n // A router link as `component` takes `href` too; it used to get none.\n const linkProps = hrefProps(kind, href, 'PaginationItem')\n const NativeButton = Component as 'button'\n const Anchor = Component as 'a'\n\n // `<a>` has no real `disabled` attribute, so a disabled anchor pagination item still fires\n // click (and still navigates) unless it's blocked here, same guard `Button` applies.\n const handleClick = (event: MouseEvent<HTMLAnchorElement | HTMLButtonElement>) => {\n if (kind === 'anchor' && disabled) {\n event.preventDefault()\n return\n }\n onClick?.(event as never)\n }\n\n // A custom `component`/default (non-`button`/`a`) branch gets a raw `onClick` with no keyboard\n // semantics otherwise — the same gap `Link` fills via `useButtonSemantics`.\n const needsButtonSemantics = kind !== 'button' && kind !== 'anchor' && !!onClick\n const { buttonProps, forkedRef } = useButtonSemantics<HTMLElement>(ref as Ref<HTMLElement>, {\n disabled,\n onClick: onClick as MouseEventHandler<HTMLElement> | undefined\n })\n\n // `aria-current=\"page\"` goes on the control itself, not the wrapping `<li>` — that's where the\n // WAI-ARIA pagination pattern puts it, and it's what a screen reader conveys when focus lands on\n // the control. On the `<li>` it was attached to a presentational list item nothing focuses.\n const currentProps = active ? { 'aria-current': 'page' as const } : {}\n\n return (\n <li className={_className}>\n {kind === 'button' ? (\n <NativeButton\n {...(rest as Record<string, unknown>)}\n className=\"pagination-link\"\n type=\"button\"\n disabled={disabled}\n onClick={handleClick}\n {...currentProps}\n ref={ref as Ref<HTMLButtonElement>}\n >\n {children}\n </NativeButton>\n ) : kind === 'anchor' ? (\n <Anchor\n {...(rest as Record<string, unknown>)}\n className=\"pagination-link\"\n {...linkProps}\n onClick={handleClick}\n {...(disabled && { 'aria-disabled': true, tabIndex: -1 })}\n {...currentProps}\n ref={ref as Ref<HTMLAnchorElement>}\n >\n {children}\n </Anchor>\n ) : (\n <Component\n className=\"pagination-link\"\n {...(mergeProps(rest, needsButtonSemantics ? buttonProps : {}) as Record<\n string,\n unknown\n >)}\n {...(!needsButtonSemantics && { onClick: handleClick })}\n {...linkProps}\n {...currentProps}\n ref={needsButtonSemantics ? forkedRef : ref}\n >\n {children}\n </Component>\n )}\n </li>\n )\n}\n\nexport const PaginationItem = createPolymorphicComponent<PaginationItemComponent>(\n PaginationItemRender as ForwardRefRenderFunction<Element, PaginationItemProps<ElementType>>,\n 'PaginationItem'\n)\n","import React, { forwardRef, HTMLAttributes } from 'react'\nimport { IconValue } from '../../utils/iconConfig'\nimport { IconSlot } from '../icon/iconSlot'\nimport classNames from 'classnames'\n\nimport { PaginationItem } from './PaginationItem'\nimport { usePagination } from '../../hooks'\n\n// Whole class names, not `justify-content-${align}`: see `utils/colorClassNames.ts`.\nconst ALIGN_CLASS_NAMES: Record<NonNullable<PaginationProps['align']>, string> = {\n start: 'justify-content-start',\n center: 'justify-content-center',\n end: 'justify-content-end'\n}\n\nexport interface PaginationProps extends HTMLAttributes<HTMLElement> {\n /**\n * Current active page (1-indexed). Used with `pages` for data-driven mode.\n */\n activePage?: number\n /**\n * Set the alignment of pagination components.\n */\n align?: 'start' | 'center' | 'end'\n /**\n * Accessible label for the pagination `<nav>` landmark. Override for non-English locales,\n * or when multiple paginators appear on the same page.\n *\n * @default 'Pagination'\n */\n 'aria-label'?: string\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * Maximum number of visible page buttons (default: 5). Flanking pages are collapsed to ellipsis.\n */\n maxVisiblePages?: number\n /**\n * The \"next page\" control's icon in smart pagination mode: an icon name, or an element of your\n * own icon set. Defaults to `IconProvider`'s `next` icon.\n */\n nextIcon?: IconValue\n /**\n * Accessible label for the \"next page\" control, used in smart pagination mode. Override for\n * non-English locales.\n *\n * @default 'Next'\n */\n nextLabel?: string\n /**\n * Callback fired when the active page changes.\n */\n onActivePageChange?: (page: number) => void\n /**\n * Total number of pages. When provided alongside `activePage` and `onActivePageChange`,\n * the component renders a fully-controlled smart paginator with Prev/Next and ellipsis.\n */\n pages?: number\n /**\n * The \"previous page\" control's icon in smart pagination mode: an icon name, or an element of\n * your own icon set. Defaults to `IconProvider`'s `previous` icon.\n */\n previousIcon?: IconValue\n /**\n * Accessible label for the \"previous page\" control, used in smart pagination mode. Override\n * for non-English locales.\n *\n * @default 'Previous'\n */\n previousLabel?: string\n /**\n * Show the numbered page buttons in smart pagination mode. Set `false` alongside\n * `showPrevNext` to build a Prev/Next-only paginator.\n *\n * @default true\n */\n showPageNumbers?: boolean\n /**\n * Show the Prev/Next controls in smart pagination mode. Set `false` alongside\n * `showPageNumbers` to build a page-numbers-only paginator.\n *\n * @default true\n */\n showPrevNext?: boolean\n /**\n * Size the component sm or lg.\n */\n size?: 'sm' | 'lg'\n}\n\nfunction getPageRange(activePage: number, pages: number, maxVisible: number): (number | '...')[] {\n const safeMaxVisible = Math.max(1, maxVisible)\n\n if (pages <= safeMaxVisible) {\n return Array.from({ length: pages }, (_, i) => i + 1)\n }\n\n const half = Math.floor(safeMaxVisible / 2)\n let start = Math.max(1, activePage - half)\n const end = Math.min(pages, start + safeMaxVisible - 1)\n\n if (end - start < safeMaxVisible - 1) {\n start = Math.max(1, end - safeMaxVisible + 1)\n }\n\n const result: (number | '...')[] = []\n\n if (start > 1) {\n result.push(1)\n if (start > 2) result.push('...')\n }\n\n for (let i = start; i <= end; i++) {\n result.push(i)\n }\n\n if (end < pages) {\n if (end < pages - 1) result.push('...')\n result.push(pages)\n }\n\n return result\n}\n\nexport const Pagination = forwardRef<HTMLElement, PaginationProps>(\n (\n {\n activePage = 1,\n align,\n 'aria-label': ariaLabel = 'Pagination',\n children,\n className,\n maxVisiblePages = 5,\n nextIcon,\n nextLabel = 'Next',\n onActivePageChange,\n pages,\n previousIcon,\n previousLabel = 'Previous',\n showPageNumbers = true,\n showPrevNext = true,\n size,\n ...rest\n },\n ref\n ) => {\n const _className = classNames('pagination', size, align && ALIGN_CLASS_NAMES[align], className)\n\n // `pages != null`, not truthiness: `pages={0}` is a pagination with no pages, both of its\n // controls disabled. It rendered `children` instead, an empty navigation landmark.\n const isSmart = pages != null\n const clampedActivePage = isSmart ? Math.min(Math.max(activePage, 1), pages) : activePage\n const prevDisabled = isSmart ? clampedActivePage <= 1 : false\n const nextDisabled = isSmart ? clampedActivePage >= pages : false\n\n const { prevRef, nextRef, handlePrevClick, handleNextClick } = usePagination({\n prevDisabled,\n nextDisabled,\n onPrev: () => onActivePageChange && onActivePageChange(clampedActivePage - 1),\n onNext: () => onActivePageChange && onActivePageChange(clampedActivePage + 1)\n })\n\n const smartContent = isSmart ? (\n <>\n {showPrevNext && (\n <PaginationItem\n ref={prevRef}\n disabled={prevDisabled}\n onClick={handlePrevClick}\n aria-label={previousLabel}\n >\n <IconSlot icon=\"previous\" override={previousIcon} className=\"directional-icon\" />\n </PaginationItem>\n )}\n {showPageNumbers &&\n getPageRange(clampedActivePage, pages, maxVisiblePages).map((page, idx) =>\n page === '...' ? (\n // eslint-disable-next-line react/no-array-index-key\n <PaginationItem key={`ellipsis-${idx}`} disabled component=\"span\" aria-hidden=\"true\">\n …\n </PaginationItem>\n ) : (\n <PaginationItem\n key={page}\n active={page === clampedActivePage}\n onClick={() => onActivePageChange && onActivePageChange(page)}\n >\n {page}\n </PaginationItem>\n )\n )}\n {showPrevNext && (\n <PaginationItem\n ref={nextRef}\n disabled={nextDisabled}\n onClick={handleNextClick}\n aria-label={nextLabel}\n >\n <IconSlot icon=\"next\" override={nextIcon} className=\"directional-icon\" />\n </PaginationItem>\n )}\n </>\n ) : null\n\n return (\n <nav aria-label={ariaLabel} ref={ref} {...rest}>\n <ul className={_className}>{smartContent ?? children}</ul>\n </nav>\n )\n }\n)\n\nPagination.displayName = 'Pagination'\n"],"mappings":"A,uZAiDA,SAAgBS,EAAyD,CACvE,eACA,eACA,SACA,UAC+C,CAC/C,IAAMC,EAAUC,EAAU,IAAI,EACxBC,EAAUD,EAAU,IAAI,EACxBE,EAAUF,EAAuB,IAAI,EAmB3C,OAXAG,MAAgB,CACd,IAAMC,EAAOF,EAAQ,QACrB,EAAQ,QAAU,KACbE,IACDA,EAAK,OAAS,QAAUC,EAC1BX,EAAcO,EAAQ,QAASG,EAAK,UAAU,EACrCA,EAAK,OAAS,QAAUE,GACjCZ,EAAcK,EAAQ,QAASK,EAAK,UAAU,EAElD,CAAC,EAEM,CACL,UACA,UACA,gBAAkB,GAAU,CAC1B,EAAQ,QAAU,CAAE,KAAM,OAAQ,WAAYG,EAAM,SAAW,CAAE,EACjEC,EAAO,CACT,EACA,gBAAkB,GAAU,CAC1B,EAAQ,QAAU,CAAE,KAAM,OAAQ,WAAYD,EAAM,SAAW,CAAE,EACjEE,EAAO,CACT,CACF,CACF,CCtCA,SAASC,EACP,CACE,SACA,WACA,YACA,YACA,WACA,OACA,UACA,GAAGC,GAEL,EACA,CACA,IAAMC,EAAaf,EACjB,kBACA,CACE,SACA,UACF,EACAgB,CACF,EAUMC,EAAYxB,EAAYyB,EAAWC,EAAM,QAAQ,EAIjDC,EAAO1B,EAAgBuB,EAAWE,EAAML,CAAI,EAE5CO,EAAY7B,EAAU4B,EAAMD,EAAM,gBAAgB,EAClDG,EAAeL,EACfM,EAASN,EAITO,EAA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AAmBb,EAAOqB,CAAe,CAAC,CAAC,KAAK,EAAM,IACjEC,IAAS,MAEP,kBAAA,cAAC3B,EAAD,CAAgB,IAAK,YAAY4B,IAAO,SAAA,GAAS,UAAU,OAAO,cAAY,MAE9D,EAFqE,GAErE,EAEhB,kBAAA,cAAC5B,EAAD,CACE,IAAK2B,EACL,OAAQA,IAAST,EACjB,YAAeC,GAAsBA,EAAmBQ,CAAI,CAG9C,EADbA,CACa,CAEpB,EACDN,GACC,kBAAA,cAACrB,EAAD,CACE,IAAK/B,EACL,SAAUK,EACV,QAASuD,EACT,aAAYC,CAGE,EADd,kBAAA,cAACnE,EAAD,CAAU,KAAK,OAAO,SAAUoE,EAAU,UAAU,kBAAoB,CAAA,CAC1D,CAElB,EACA,KAEJ,MACE,kBAAA,cAAC,MAAD,CAAK,aAAYjB,EAAgB,MAAK,GAAInC,CAErC,EADH,kBAAA,cAAC,KAAD,CAAI,UAAWC,CAA0C,EAA7BwC,GAAgBxB,CAAa,CACtD,CAET,CACF,EAEA,EAAW,YAAc,a"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./focus-ring-
|
|
2
|
-
//# sourceMappingURL=password-strength-
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import e,{Fragment as t,forwardRef as n,useEffect as r,useMemo as i,useRef as a}from"react";import o from"classnames";import{useMeter as s}from"react-aria";const c=[`weak`,`fair`,`good`,`strong`],l={extraLength:1,lowercase:1,longPassword:1,minLength:1,multipleSpecial:1,numbers:1,special:1,uppercase:1},u={fair:`Fair`,good:`Good`,strong:`Strong`,weak:`Weak`},d=[2,4,6],f=/[!"#$%&()*,.:<>?@^{|}]/,p=/[!"#$%&()*,.:<>?@^{|}].*[!"#$%&()*,.:<>?@^{|}]/,m=(e,{minLength:t,scorer:n,weights:r})=>{if(!e)return 0;if(n)return n(e);let i=0;return e.length>=t&&(i+=r.minLength),e.length>=t+4&&(i+=r.extraLength),/[a-z]/.test(e)&&(i+=r.lowercase),/[A-Z]/.test(e)&&(i+=r.uppercase),/\d/.test(e)&&(i+=r.numbers),f.test(e)&&(i+=r.special),p.test(e)&&(i+=r.multipleSpecial),e.length>=16&&(i+=r.longPassword),i},h=(e,t)=>{if(e===0)return null;let[n,r,i]=t;return e<=n?`weak`:e<=r?`fair`:e<=i?`good`:`strong`},g=n(function({"aria-label":n=`Password strength`,className:f,id:p,maxScore:g,messages:_,minLength:v=8,onStrengthChange:y,scorer:b,showText:x=!0,thresholds:S=d,value:C,variant:w=`segmented`,weights:T,...E},D){let O=i(()=>({...l,...T}),[T]),k=i(()=>({...u,..._}),[_]),A=i(()=>m(C,{minLength:v,scorer:b,weights:O}),[C,v,b,O]),j=i(()=>h(A,S),[A,S]),M=i(()=>g??Object.values(O).reduce((e,t)=>e+t,0),[g,O]),N=a(void 0);r(()=>{N.current!==j&&(N.current=j,y?.({score:A,strength:j}))},[j,A,y]);let{meterProps:P}=s({"aria-label":n,maxValue:M,minValue:0,value:A,valueLabel:j?k[j]:void 0}),F=j?c.indexOf(j):-1;return/* @__PURE__ */ e.createElement(t,null,/* @__PURE__ */ e.createElement(`div`,{...P,className:o(w===`bar`?`strength-bar`:`strength`,f),"data-cx-strength":j??void 0,id:p,...E,ref:D},w===`segmented`&&c.map((t,n)=>/* @__PURE__ */ e.createElement(`div`,{className:o(`strength-segment`,{active:n<=F}),key:t}))),x&&/* @__PURE__ */ e.createElement(`span`,{"aria-live":`polite`,className:`strength-text`,"data-cx-strength":j??void 0},j?k[j]:``))});g.displayName=`PasswordStrength`;export{g as t};
|
|
2
|
+
//# sourceMappingURL=password-strength-Qg5GHBmu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"password-strength-Qg5GHBmu.js","names":["React","classNames","STRENGTH_LEVELS","defaultWeights","defaultMessages","defaultThresholds","SPECIAL_CHARS","MULTIPLE_SPECIAL_CHARS","calculateScore","password","scorer","score","minLength","weights","scoreToStrength","weak","fair","good","thresholds","PasswordStrength","forwardRef","ariaLabel","rest","mergedWeights","useMemo","mergedMessages","messages","value","strength","resolvedMaxScore","maxScore","total","weight","previousStrength","useRef","useEffect","onStrengthChange","useMeter","strengthIndex","Fragment","meterProps","variant","className","index","level","showText"],"sources":["../../src/components/password-strength/strengthScore.ts","../../src/components/password-strength/PasswordStrength.tsx"],"sourcesContent":["export type StrengthLevel = 'weak' | 'fair' | 'good' | 'strong'\n\nexport const STRENGTH_LEVELS: StrengthLevel[] = ['weak', 'fair', 'good', 'strong']\n\nexport interface StrengthWeights {\n extraLength: number\n lowercase: number\n longPassword: number\n minLength: number\n multipleSpecial: number\n numbers: number\n special: number\n uppercase: number\n}\n\nexport const defaultWeights: StrengthWeights = {\n extraLength: 1,\n lowercase: 1,\n longPassword: 1,\n minLength: 1,\n multipleSpecial: 1,\n numbers: 1,\n special: 1,\n uppercase: 1\n}\n\nexport const defaultMessages: Record<StrengthLevel, string> = {\n fair: 'Fair',\n good: 'Good',\n strong: 'Strong',\n weak: 'Weak'\n}\n\nexport const defaultThresholds: [number, number, number] = [2, 4, 6]\n\nconst SPECIAL_CHARS = /[!\"#$%&()*,.:<>?@^{|}]/\nconst MULTIPLE_SPECIAL_CHARS = /[!\"#$%&()*,.:<>?@^{|}].*[!\"#$%&()*,.:<>?@^{|}]/\n\ninterface CalculateScoreOptions {\n minLength: number\n scorer?: (password: string) => number\n weights: StrengthWeights\n}\n\n// Ported from chassis-css's vanilla strength.js `_calculateScore` — kept in lockstep with it so\n// a password scores identically whether evaluated by the vanilla JS or this component.\nexport const calculateScore = (\n password: string,\n { minLength, scorer, weights }: CalculateScoreOptions\n): number => {\n if (!password) return 0\n if (scorer) return scorer(password)\n\n let score = 0\n\n if (password.length >= minLength) score += weights.minLength\n if (password.length >= minLength + 4) score += weights.extraLength\n if (/[a-z]/.test(password)) score += weights.lowercase\n if (/[A-Z]/.test(password)) score += weights.uppercase\n if (/\\d/.test(password)) score += weights.numbers\n if (SPECIAL_CHARS.test(password)) score += weights.special\n if (MULTIPLE_SPECIAL_CHARS.test(password)) score += weights.multipleSpecial\n if (password.length >= 16) score += weights.longPassword\n\n return score\n}\n\nexport const scoreToStrength = (\n score: number,\n thresholds: [number, number, number]\n): StrengthLevel | null => {\n if (score === 0) return null\n\n const [weak, fair, good] = thresholds\n if (score <= weak) return 'weak'\n if (score <= fair) return 'fair'\n if (score <= good) return 'good'\n return 'strong'\n}\n","import React, { forwardRef, Fragment, HTMLAttributes, useEffect, useMemo, useRef } from 'react'\nimport classNames from 'classnames'\nimport { useMeter } from 'react-aria'\n\nimport {\n calculateScore,\n defaultMessages,\n defaultThresholds,\n defaultWeights,\n scoreToStrength,\n STRENGTH_LEVELS,\n StrengthLevel,\n StrengthWeights\n} from './strengthScore'\n\nexport interface PasswordStrengthProps extends Omit<HTMLAttributes<HTMLDivElement>, 'onChange'> {\n /**\n * An accessible label for the meter. Defaults to `\"Password strength\"`.\n */\n 'aria-label'?: string\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * `id` forwarded to the meter element.\n */\n id?: string\n /**\n * The maximum possible score, used to compute the meter's `aria-valuemax`. Defaults to the sum\n * of `weights`' values — set this explicitly when pairing a custom `scorer` whose scale doesn't\n * match the built-in criteria weights, otherwise `aria-valuenow`/`aria-valuemax` get silently\n * clamped to the built-in max.\n */\n maxScore?: number\n /**\n * Minimum password length required to earn the first strength point. Defaults to `8`.\n */\n minLength?: number\n /**\n * Feedback message shown for each strength level, when `showText` is `true`.\n */\n messages?: Partial<Record<StrengthLevel, string>>\n /**\n * Callback fired whenever the strength level changes, including once on mount with the\n * initial `value`'s strength.\n */\n onStrengthChange?: (result: { score: number; strength: StrengthLevel | null }) => void\n /**\n * Custom scoring function overriding the built-in criteria. Receives the password and returns\n * a numeric score.\n */\n scorer?: (password: string) => number\n /**\n * Renders a `.strength-text` element below the meter with the current level's message.\n * Defaults to `true`.\n */\n showText?: boolean\n /**\n * Score boundaries `[weak, fair, good]` — scores above the last value are `\"strong\"`. Defaults\n * to `[2, 4, 6]`.\n */\n thresholds?: [number, number, number]\n /**\n * The current password value to evaluate.\n */\n value: string\n /**\n * Render as four discrete segments, or a single growing bar. Defaults to `\"segmented\"`.\n */\n variant?: 'bar' | 'segmented'\n /**\n * Point values for each scoring criterion. Set a criterion to `0` to disable it. Merged with\n * the built-in defaults.\n */\n weights?: Partial<StrengthWeights>\n}\n\n// The ref goes to the meter, the element the other attributes go to.\nexport const PasswordStrength = forwardRef<HTMLDivElement, PasswordStrengthProps>(\n function PasswordStrength(\n {\n 'aria-label': ariaLabel = 'Password strength',\n className,\n id,\n maxScore,\n messages,\n minLength = 8,\n onStrengthChange,\n scorer,\n showText = true,\n thresholds = defaultThresholds,\n value,\n variant = 'segmented',\n weights,\n ...rest\n },\n ref\n ) {\n const mergedWeights = useMemo(() => ({ ...defaultWeights, ...weights }), [weights])\n const mergedMessages = useMemo(() => ({ ...defaultMessages, ...messages }), [messages])\n\n const score = useMemo(\n () => calculateScore(value, { minLength, scorer, weights: mergedWeights }),\n [value, minLength, scorer, mergedWeights]\n )\n const strength = useMemo(() => scoreToStrength(score, thresholds), [score, thresholds])\n const resolvedMaxScore = useMemo(\n () => maxScore ?? Object.values(mergedWeights).reduce((total, weight) => total + weight, 0),\n [maxScore, mergedWeights]\n )\n\n // Deliberately not initialized to `strength` — that would make the effect below skip firing\n // for the mount-time value, and a consumer using this to gate e.g. a submit button needs the\n // real initial state, not just subsequent changes.\n const previousStrength = useRef<StrengthLevel | null | undefined>(undefined)\n useEffect(() => {\n if (previousStrength.current !== strength) {\n previousStrength.current = strength\n onStrengthChange?.({ score, strength })\n }\n }, [strength, score, onStrengthChange])\n\n const { meterProps } = useMeter({\n 'aria-label': ariaLabel,\n maxValue: resolvedMaxScore,\n minValue: 0,\n value: score,\n valueLabel: strength ? mergedMessages[strength] : undefined\n })\n\n const strengthIndex = strength ? STRENGTH_LEVELS.indexOf(strength) : -1\n\n return (\n <Fragment>\n <div\n {...meterProps}\n className={classNames(variant === 'bar' ? 'strength-bar' : 'strength', className)}\n data-cx-strength={strength ?? undefined}\n id={id}\n {...rest}\n ref={ref}\n >\n {variant === 'segmented' &&\n STRENGTH_LEVELS.map((level, index) => (\n <div\n className={classNames('strength-segment', { active: index <= strengthIndex })}\n key={level}\n />\n ))}\n </div>\n {showText && (\n <span\n aria-live=\"polite\"\n className=\"strength-text\"\n data-cx-strength={strength ?? undefined}\n >\n {strength ? mergedMessages[strength] : ''}\n </span>\n )}\n </Fragment>\n )\n }\n)\n\nPasswordStrength.displayName = 'PasswordStrength'\n"],"mappings":"A,6LAEA,MAAaE,EAAmC,CAAC,OAAQ,OAAQ,OAAQ,QAAQ,EAapEC,EAAkC,CAC7C,YAAa,EACb,UAAW,EACX,aAAc,EACd,UAAW,EACX,gBAAiB,EACjB,QAAS,EACT,QAAS,EACT,UAAW,CACb,EAEaC,EAAiD,CAC5D,KAAM,OACN,KAAM,OACN,OAAQ,SACR,KAAM,MACR,EAEaC,EAA8C,CAAC,EAAG,EAAG,CAAC,EAE7DC,EAAgB,yBAChBC,EAAyB,iDAUlBC,GACX,EACA,CAAE,YAAW,SAAQ,aACV,CACX,GAAI,CAACC,EAAU,MAAO,GACtB,GAAIC,EAAQ,OAAOA,EAAOD,CAAQ,EAElC,IAAIE,EAAQ,EAWZ,OATIF,EAAS,QAAUG,IAAW,GAASC,EAAQ,WAC/CJ,EAAS,QAAUG,EAAY,IAAG,GAASC,EAAQ,aACnD,QAAQ,KAAKJ,CAAQ,IAAG,GAASI,EAAQ,WACzC,QAAQ,KAAKJ,CAAQ,IAAG,GAASI,EAAQ,WACzC,KAAK,KAAKJ,CAAQ,IAAG,GAASI,EAAQ,SACtCP,EAAc,KAAKG,CAAQ,IAAG,GAASI,EAAQ,SAC/CN,EAAuB,KAAKE,CAAQ,IAAG,GAASI,EAAQ,iBACxDJ,EAAS,QAAU,KAAI,GAASI,EAAQ,cAErCF,CACT,EAEaG,GACX,EACA,IACyB,CACzB,GAAIH,IAAU,EAAG,OAAO,KAExB,GAAM,CA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MAAQ,eAAiB,WAAYC,CAAS,EAChF,mBAAkBd,GAAY,IAAA,GAC1B,KACJ,GAAIN,EACC,KASF,EAPFmB,IAAY,aACXvC,EAAgB,KAAK,EAAO,IAC1B,kBAAA,cAAC,MAAD,CACE,UAAWD,EAAW,mBAAoB,CAAE,OAAQ0C,GAASL,CAAc,CAAC,EAC5E,IAAKM,CACN,CAAA,CACF,CACA,EACJC,GACC,kBAAA,cAAC,OAAD,CACE,YAAU,SACV,UAAU,gBACV,mBAAkBjB,GAAY,IAAA,EAG1B,EADHA,EAAWH,EAAeG,GAAY,EACnC,CAEA,CAEd,CACF,EAEA,EAAiB,YAAc,mB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{a as e}from"./slot-BQVx1Eew.js";import{t}from"./polymorphic-CZIFszAy.js";import n from"react";import r from"classnames";const i={start:`float-start`,center:`d-block mx-auto`,end:`float-end`};function a({align:t,alt:a,className:o,color:s,component:c,fluid:l,height:u,rounded:d,src:f,text:p,thumbnail:m,title:h=`Placeholder`,variant:g,width:_,...v},y){let b=h!==!1,x=p===!1?void 0:p??(_!==void 0&&u!==void 0?`${_}x${u}`:void 0),S=x!==void 0,C=[b&&h,S&&x].filter(Boolean).join(`: `)||void 0;if(f||e(c)){let e=c??`img`,s=r({image:l||m,fluid:l,rounded:d,thumbnail:m},t&&i[t],o);return/* @__PURE__ */ n.createElement(e,{src:f,width:_,height:u,alt:a??C??``,className:s,...v,ref:y})}let w=r(`image`,{context:!!(s||g)},s,g||`bg-evident`,`fg-subtle`,o);return/* @__PURE__ */ n.createElement(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:_,height:u,"aria-label":C,"aria-hidden":!C||void 0,className:w,preserveAspectRatio:`xMidYMid slice`,role:C?`img`:void 0,...v,ref:y},b&&/* @__PURE__ */ n.createElement(`title`,null,h),S&&/* @__PURE__ */ n.createElement(`text`,{dy:`.3em`,fill:`currentColor`,textAnchor:`middle`,x:`50%`,y:`50%`},x))}const o=t(a,`Placeholder`);export{o as t};
|
|
2
|
+
//# sourceMappingURL=placeholder-SPoVRkKE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placeholder-SPoVRkKE.js","names":["isSlot","React","classNames","ALIGN_CLASS_NAMES","PlaceholderRender","rest","showTitle","title","displayText","text","width","height","showText","label","src","component","Component","_className","fluid","thumbnail","align","className","alt","color","variant","Placeholder","createPolymorphicComponent"],"sources":["../../src/components/placeholder/Placeholder.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor, ContextStyle } from '../../types'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { isSlot } from '../../utils/slot'\n\ntype PlaceholderAlign = 'start' | 'center' | 'end'\n\ntype PlaceholderOwnProps<C extends ElementType> = {\n /**\n * Set the horizontal alignment. Only applies when `src` is set.\n */\n align?: PlaceholderAlign\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Sets the color of the generated placeholder graphic to one of Chassis context colors. Has no\n * effect when `src` is set.\n */\n color?: ContextColor\n /**\n * Sets the variant of the generated placeholder graphic to one of Chassis context styles. Has no\n * effect when `src` is set.\n */\n variant?: Exclude<ContextStyle, 'basic' | 'outline'>\n /**\n * Component used for the root node when `src` is set. Either a string to use an HTML element\n * or a component — e.g. a framework's own `Image` component. Its own props (`src`, `fill`,\n * `priority`, etc.) are type-checked at the call site once passed here. With `asChild`, the\n * child element is the image and carries its own `src`.\n */\n component?: C\n /**\n * Make the image responsive, so it never grows larger than its parent. Only applies when `src`\n * is set.\n */\n fluid?: boolean\n /**\n * Placeholder height.\n */\n height?: number | string\n /**\n * Give the image a rounded border-radius. Only applies when `src` is set.\n */\n rounded?: boolean\n /**\n * Renders a real image instead of the generated placeholder graphic, e.g. a default asset or a\n * `placehold.co` URL.\n */\n src?: string\n /**\n * Text shown in the generated placeholder graphic. Defaults to `{width}x{height}`. Pass `false`\n * to hide it. Has no effect when `src` is set.\n */\n text?: string | false\n /**\n * Give the image a thumbnail appearance (padding, background, border, box-shadow). Only\n * applies when `src` is set.\n */\n thumbnail?: boolean\n /**\n * Accessible title for the generated placeholder graphic, rendered as an SVG `<title>`. Pass\n * `false` to hide it. Has no effect when `src` is set.\n *\n * @default 'Placeholder'\n */\n title?: string | false\n /**\n * Placeholder width.\n */\n width?: number | string\n}\n\nexport type PlaceholderProps<C extends ElementType = 'img'> = PolymorphicComponentProps<\n C,\n PlaceholderOwnProps<C>\n>\n\ntype PlaceholderComponent = (<C extends ElementType = 'img'>(\n props: PlaceholderProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\n// Whole class names, not `float-${align}`: see `utils/colorClassNames.ts`.\nconst ALIGN_CLASS_NAMES: Record<PlaceholderAlign, string> = {\n start: 'float-start',\n center: 'd-block mx-auto',\n end: 'float-end'\n}\n\nfunction PlaceholderRender<C extends ElementType = 'img'>(\n {\n align,\n alt,\n className,\n color,\n component,\n fluid,\n height,\n rounded,\n src,\n text,\n thumbnail,\n title = 'Placeholder',\n variant,\n width,\n ...rest\n }: PlaceholderProps<C>,\n ref: PolymorphicRef<C>\n) {\n const showTitle = title !== false\n const displayText =\n text === false\n ? undefined\n : (text ?? (width !== undefined && height !== undefined ? `${width}x${height}` : undefined))\n const showText = displayText !== undefined\n const label =\n [showTitle && title, showText && displayText].filter(Boolean).join(': ') || undefined\n\n // Under `asChild` the caller's element is the image and holds the `src`, so there is none here\n // to choose the branch by.\n if (src || isSlot(component)) {\n const Component = component ?? 'img'\n const _className = classNames(\n { image: fluid || thumbnail, fluid, rounded, thumbnail },\n align && ALIGN_CLASS_NAMES[align],\n className\n )\n\n return (\n <Component\n src={src}\n width={width}\n height={height}\n alt={alt ?? label ?? ''}\n className={_className}\n {...rest}\n ref={ref}\n />\n )\n }\n\n const _className = classNames(\n 'image',\n { context: Boolean(color || variant) },\n color,\n variant ? variant : 'bg-evident',\n 'fg-subtle',\n className\n )\n\n return (\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width={width}\n height={height}\n aria-label={label}\n aria-hidden={label ? undefined : true}\n className={_className}\n preserveAspectRatio=\"xMidYMid slice\"\n role={label ? 'img' : undefined}\n {...rest}\n ref={ref as PolymorphicRef<'svg'>}\n >\n {showTitle && <title>{title}</title>}\n {showText && (\n <text dy=\".3em\" fill=\"currentColor\" textAnchor=\"middle\" x=\"50%\" y=\"50%\">\n {displayText}\n </text>\n )}\n </svg>\n )\n}\n\nexport const Placeholder = createPolymorphicComponent<PlaceholderComponent>(\n PlaceholderRender as ForwardRefRenderFunction<Element, PlaceholderProps<ElementType>>,\n 'Placeholder'\n)\n"],"mappings":"A,gKA0FA,MAAMG,EAAsD,CAC1D,MAAO,cACP,OAAQ,kBACR,IAAK,WACP,EAEA,SAASC,EACP,CACE,QACA,MACA,YACA,QACA,YACA,QACA,SACA,UACA,MACA,OACA,YACA,QAAQ,cACR,UACA,QACA,GAAGC,GAEL,EACA,CACA,IAAMC,EAAYC,IAAU,GACtBC,EACJC,IAAS,GACL,IAAA,GACCA,IAASC,IAAU,IAAA,IAAaC,IAAW,IAAA,GAAY,GAAGD,EAAM,GAAGC,IAAW,IAAA,IAC/EC,EAAWJ,IAAgB,IAAA,GAC3BK,EACJ,CAACP,GAAaC,EAAOK,GAAYJ,CAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,GAAK,IAAA,GAI9E,GAAIM,GAAOd,EAAOe,CAAS,EAAG,CAC5B,IAAMC,EAAYD,GAAa,MACzBE,EAAaf,EACjB,CAAE,MAAOgB,GAASC,EAAW,QAAO,UAAS,WAAU,EACvDC,GAASjB,EAAkBiB,GAC3BC,CACF,EAEA,MACE,kBAAA,cAACL,EAAD,CACO,MACE,QACC,SACR,IAAKM,GAAOT,GAAS,GACrB,UAAWI,EACX,GAAIZ,EACC,KACN,CAAA,CAEL,CAEA,IAAMY,EAAaf,EACjB,QACA,CAAE,QAAS,GAAQqB,GAASC,EAAS,EACrCD,EACAC,GAAoB,aACpB,YACAH,CACF,EAEA,MACE,kBAAA,cAAC,MAAD,CACE,MAAM,6BACC,QACC,SACR,aAAYR,EACZ,cAAa,IAAQ,IAAA,GACrB,UAAWI,EACX,oBAAoB,iBACpB,KAAMJ,EAAQ,MAAQ,IAAA,GACtB,GAAIR,EACC,KAQF,EANFC,GAAa,kBAAA,cAAC,QAAA,KAAOC,CAAa,EAClCK,GACC,kBAAA,cAAC,OAAD,CAAM,GAAG,OAAO,KAAK,eAAe,WAAW,SAAS,EAAE,MAAM,EAAE,KAE5D,EADHJ,CACG,CAEL,CAET,CAEA,MAAaiB,EAAcC,EACzBtB,EACA,aACF,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{S as e,a as t,b as n,n as r,r as i,s as a,t as o}from"./slot-BQVx1Eew.js";import{createElement as s,forwardRef as c}from"react";function l(l,u){let d=c(({asChild:c,...d},f)=>{let p=a(),m=c?i(d.children,u):null;return m?(e(d.component!==void 0,`${u}: both \`asChild\` and \`component\` were passed; \`asChild\` wins and \`component\` is ignored.`),s(o,{value:m},n(m,()=>l({...d,component:r(m),children:m.props.children},f)))):t(d.component)?n(p,()=>l(d,f)):l(d,f)});return d.displayName=u,d}export{l as t};
|
|
2
|
+
//# sourceMappingURL=polymorphic-CZIFszAy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"polymorphic-CZIFszAy.js","names":["devWarning","isSlot","withSlottedElement","getSlot","getSlotChild","useSlotElement","SlotProvider","createPolymorphicComponent","Component","forwardRef","props","inherited","child","asChild","displayName","createElement","render","ref"],"sources":["../../src/utils/polymorphic.ts"],"sourcesContent":["import {\n ComponentPropsWithoutRef,\n ComponentPropsWithRef,\n createElement,\n ElementType,\n ForwardRefRenderFunction,\n forwardRef,\n Ref\n} from 'react'\n\nimport { devWarning } from './devWarning'\nimport { withSlottedElement } from './elementKind'\nimport { getSlot, getSlotChild, isSlot, SlotProvider, useSlotElement } from './slot'\n\n// Ref type inferred from a polymorphic component's currently-selected `component` element type.\nexport type PolymorphicRef<C extends ElementType> = ComponentPropsWithRef<C>['ref']\n\n/**\n * Ref type for a polymorphic component that can also pick its element from a prop *other* than\n * `component` — `Button`, `Chip`, `Avatar`, `NavbarBrand` and `PaginationItem` all render an\n * `<a>` when given `href`, and `PaginationItem` a `<span>` when `active`, none of which moves `C`\n * off its default. A plain `PolymorphicRef<C>` describes only the `component` branch, so a caller\n * holding a ref for the element that actually gets rendered (`<Button href=\"/x\" ref={anchorRef}>`)\n * got a spurious type error while the runtime happily populated it.\n *\n * `Ref` over the *union* rather than a union of `Ref`s is what makes a\n * `createRef<HTMLButtonElement | HTMLAnchorElement>()` assignable here: `RefObject` is invariant\n * in its type argument, so `RefObject<A | B>` satisfies `Ref<A | B>` but neither `Ref<A>` nor\n * `Ref<B>` on its own.\n */\nexport type PolymorphicRefWithFallback<C extends ElementType, Fallback extends HTMLElement> =\n PolymorphicRef<C> | Ref<Fallback>\n\n/**\n * The `asChild` prop every polymorphic component accepts alongside `component` — see\n * `createPolymorphicComponent` below for how it's implemented once for all of them.\n */\nexport interface AsChildProps {\n /**\n * Render the single child element in place of this component's own element, with this\n * component's classes, props and ref merged onto it: `<Button asChild><Link href=\"/login\">Log\n * in</Link></Button>`. The alternative to `component` for React Server Components — an element\n * can be passed from the server to this package's client components, a component reference\n * (`component={Link}`) can't.\n */\n asChild?: boolean\n}\n\n/**\n * Props for a polymorphic component: `OwnProps` (which must declare `component?: C`) plus\n * whatever props `C` itself accepts, minus any name already claimed by `OwnProps` so the two\n * don't conflict. Lets consumers swap `component` for e.g. a framework's `Image` and get full\n * type-checking/autocomplete for that component's own props at the call site.\n */\nexport type PolymorphicComponentProps<C extends ElementType, OwnProps extends object> = OwnProps &\n AsChildProps &\n Omit<ComponentPropsWithoutRef<C>, keyof OwnProps | keyof AsChildProps>\n\n/**\n * Wraps a polymorphic component's render function in `forwardRef` and stamps `displayName` — the\n * two-step wiring every polymorphic component in this library repeats identically. `T` is the\n * fully generic component type (e.g. `ButtonComponent`) that `forwardRef`'s own return type can't\n * express, since `forwardRef` only accepts a non-generic render function — the caller still casts\n * the render function to a concrete `Element`-typed instance before passing it in here.\n *\n * Also implements `asChild` for every polymorphic component at once (#23): the render function\n * gets a `Slot` as its `component` and the child element's own children, so it computes its\n * classes, props and ref as it would for `component` — the `Slot` then clones the caller's child\n * element with all of that merged on (see `./slot`). No render function needs to know `asChild`\n * exists. One that treats elements differently (`disabled` on a `<button>` versus an `<a>`) asks\n * `resolveElementKind(Component)`, which answers for a tag and for a `Slot` alike. It has to ask\n * while it renders: the kind of a component element is read from the element then, not kept on\n * its `Slot`.\n */\nexport function createPolymorphicComponent<T>(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n render: ForwardRefRenderFunction<Element, any>,\n displayName: string\n): T {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const Component = forwardRef<Element, any>(({ asChild, ...props }, ref) => {\n // The `asChild` element of a component above, for when that component hands its `Slot` on as\n // this one's `component` (`ListItem` and `NavLink` render a `Link` that way).\n const inherited = useSlotElement()\n const child = asChild ? getSlotChild(props.children, displayName) : null\n if (!child) {\n return isSlot(props.component)\n ? withSlottedElement(inherited, () => render(props, ref))\n : render(props, ref)\n }\n\n devWarning(\n props.component !== undefined,\n `${displayName}: both \\`asChild\\` and \\`component\\` were passed; \\`asChild\\` wins and ` +\n `\\`component\\` is ignored.`\n )\n\n // The render function reads the child's kind off the `Slot` while it runs (see\n // `withSlottedElement`).\n return createElement(\n SlotProvider,\n { value: child },\n withSlottedElement(child, () =>\n render(\n {\n ...props,\n component: getSlot(child),\n children: (child.props as PropsWithChildren).children\n },\n ref\n )\n )\n )\n }) as unknown as T & { displayName?: string }\n Component.displayName = displayName\n return Component\n}\n\ntype PropsWithChildren = { children?: unknown }\n"],"mappings":"A,uIA0EA,SAAgBO,EAEd,EACA,EACG,CAEH,IAAMC,EAAYC,GAA0B,CAAE,UAAS,GAAGC,GAAS,IAAQ,CAGzE,IAAMC,EAAYN,EAAe,EAC3BO,EAAQC,EAAUT,EAAaM,EAAM,SAAUI,CAAW,EAAI,KAepE,OAdKF,GAMLZ,EACEU,EAAM,YAAc,IAAA,GACpB,GAAGI,EAAY,iGAEjB,EAIOC,EACLT,EACA,CAAE,MAAOM,CAAM,EACfV,EAAmBU,MACjBI,EACE,CACE,GAAGN,EACH,UAAWP,EAAQS,CAAK,EACxB,SAAWA,EAAM,MAA4B,QAC/C,EACAK,CACF,CACF,CACF,GA1BShB,EAAOS,EAAM,SAAS,EACzBR,EAAmBS,MAAiBK,EAAON,EAAOO,CAAG,CAAC,EACtDD,EAAON,EAAOO,CAAG,CAyBzB,CAAC,EAED,MADA,GAAU,YAAcH,EACjBN,CACT,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{i as e,o as t}from"./slot-BQVx1Eew.js";import{t as n}from"./useForkedRef-WoqMqsWE.js";import{n as r}from"./overlayStack-BXtTGCRm.js";import{t as i}from"./useHydrated-Dud4JEwp.js";import{t as a}from"./useTransitionState-sQUQey74.js";import{n as o,r as s,t as c}from"./useFloatingOverlay-BuiI_CCn.js";import{t as l}from"./useOpenStateProps-BhjSQ3f6.js";import{i as u,n as d}from"./overlayPlacement-Q6bcbXA5.js";import{t as f}from"./Portal-BTDylxAi.js";import{n as p,t as m}from"./insideEvents-CWcNrMu7.js";import h,{forwardRef as g,useEffect as _,useId as v,useRef as y}from"react";import b from"classnames";import{mergeProps as x,useDialog as S,useOverlayPosition as C,useOverlayTrigger as w}from"react-aria";import{useOverlayTriggerState as T}from"react-stately";const E=({arrowProps:e,content:t,overlayRef:r,overlayTriggerProps:i,title:a,...o})=>{let s=y(null),l=n(r,s),{dialogProps:u,titleProps:d}=S({},s);return/* @__PURE__ */ h.createElement(`div`,{...x(i,u,o),ref:l},/* @__PURE__ */ h.createElement(`div`,{className:`popover-arrow`,...e,style:c(e)}),a&&/* @__PURE__ */ h.createElement(`div`,{className:`popover-header`,...d},a),/* @__PURE__ */ h.createElement(`div`,{className:`popover-body`},t))},D=g(function({children:c,className:g,content:S,defaultVisible:D,placement:O=`right`,offset:k=[0,8],onHide:A,onShow:j,onVisibleChange:M,style:N,title:P,visible:F,...I},L){let R=y(null),z=y(null),B=y(null),V=n(L,B),H=e(c,`Popover`),U=v(),W=H&&!P&&I[`aria-label`]==null&&I[`aria-labelledby`]==null?H.props.id??`${U}-trigger`:void 0,G=T(l({defaultVisible:D,onVisibleChange:M,visible:F},`Popover`)),{triggerProps:{onPress:ee,...K},overlayProps:q}=w({type:`dialog`},G,z),J=s({close:G.close,isOpen:G.isOpen,onHide:A,onShow:j,triggerRef:z}),Y=F!==void 0&&!M;_(()=>{if(G.isOpen&&!Y)return r({nodes:()=>[B.current,z.current],onEscape:()=>G.close()})},[G.isOpen,G.close,Y]),_(()=>{if(!G.isOpen)return;let e=(e,t)=>!!t&&e.includes(t),t=t=>{let n=t.composedPath();e(n,z.current)||e(n,B.current)||p(t,B)||G.close()},n=window.setTimeout(()=>{window.addEventListener(`pointerdown`,t)});return()=>{window.clearTimeout(n),window.removeEventListener(`pointerdown`,t)}},[G.isOpen,G.close]);let{overlayProps:X,arrowProps:Z,placement:Q}=C({targetRef:z,overlayRef:B,placement:u(O),offset:k[1],crossOffset:k[0],arrowSize:8,arrowRef:R,isOpen:G.isOpen,onClose:null}),$={...N,position:X.style?.position,top:X.style?.top,left:X.style?.left},te=d(O,Q),{isMounted:ne,phase:re}=a({in:G.isOpen&&J!==null,mountOnEnter:!0,nodeRef:B,onExited:()=>{let e=z.current;if(!e||!document.contains(e))return;let t=document.activeElement,n=!t||t===document.body,r=!!t&&!!B.current?.contains(t);(n||r)&&e.focus()},unmountOnExit:!0}),ie=i();return/* @__PURE__ */ h.createElement(h.Fragment,null,H?t(H,{...W&&{id:W},onClick:()=>G.toggle()},z,ie?K:{...K,"aria-controls":void 0}):c,/* @__PURE__ */ h.createElement(f,{container:J},ne&&/* @__PURE__ */ h.createElement(E,{className:b(`popover cx-popover-auto`,o(re),g),"data-cx-placement":te,style:$,overlayTriggerProps:q,overlayRef:V,arrowProps:Z,title:P,content:S,"aria-labelledby":W,...x(I,m(B))})))});D.displayName=`Popover`;export{D as t};
|
|
2
|
+
//# sourceMappingURL=popover-C_32yD9W.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"popover-C_32yD9W.js","names":["getTriggerChild","renderSlotted","useForkedRef","pushOverlay","useHydrated","useTransitionState","getOverlayTransitionClass","useFloatingOverlay","getOverlayArrowStyle","useOpenStateProps","toAriaPlacement","resolveDataPlacement","Portal","isEventInside","insideEventProps","React","classNames","PopoverPanel","rest","panelRef","useRef","forkedRef","overlayRef","useDialog","mergeProps","overlayTriggerProps","dialogProps","arrowProps","title","titleProps","content","Popover","forwardRef","offsetProp","arrowRef","triggerRef","floatingRef","forkedFloatingRef","ref","triggerElement","children","generatedId","useId","triggerId","state","useOverlayTriggerState","_onPress","triggerProps","useOverlayTrigger","portalContainer","isHeld","visible","onVisibleChange","useEffect","isInside","node","path","handleDismiss","event","id","resolvedPlacement","useOverlayPosition","placement","floatingStyle","style","overlayProps","placementAttr","trigger","active","focusIsLoose","focusIsInPanel","hydrated","isMounted","phase","className"],"sources":["../../src/components/popover/Popover.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n Ref,\n useEffect,\n useId,\n useRef\n} from 'react'\nimport classNames from 'classnames'\nimport { mergeProps, useDialog, useOverlayPosition, useOverlayTrigger } from 'react-aria'\nimport { useOverlayTriggerState } from 'react-stately'\n\nimport {\n getOverlayArrowStyle,\n getOverlayTransitionClass,\n useFloatingOverlay,\n useForkedRef,\n useOpenStateProps,\n useTransitionState\n} from '../../hooks'\nimport { insideEventProps, isEventInside } from '../../utils/insideEvents'\nimport { Placement, resolveDataPlacement, toAriaPlacement } from '../../utils/overlayPlacement'\nimport { pushOverlay } from '../../utils/overlayStack'\nimport { useHydrated } from '../../hooks/useHydrated'\nimport { Portal } from '../portal/Portal'\nimport { getTriggerChild, renderSlotted } from '../../utils/slot'\n\ninterface PopoverPanelProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'content'> {\n arrowProps: HTMLAttributes<HTMLDivElement>\n content: ReactNode | string\n overlayRef: Ref<HTMLDivElement>\n overlayTriggerProps: HTMLAttributes<HTMLDivElement>\n title?: ReactNode | string\n}\n\n// A distinct component (rather than inline JSX in `Popover`) so `useDialog`'s own mount-focus\n// effect — which only fires on this component's mount, not on `overlayRef.current` merely\n// becoming non-null — actually runs each time the popover opens. `Popover` unmounts this once\n// it has exited and mounts it again on every open, giving `useDialog` a fresh mount each time.\nconst PopoverPanel = ({\n arrowProps,\n content,\n overlayRef,\n overlayTriggerProps,\n title,\n ...rest\n}: PopoverPanelProps) => {\n // `useDialog` focuses the panel through a ref object; the caller's ref is forked onto the same\n // node.\n const panelRef = useRef<HTMLDivElement>(null)\n const forkedRef = useForkedRef(overlayRef, panelRef)\n const { dialogProps, titleProps } = useDialog({}, panelRef)\n\n return (\n <div {...mergeProps(overlayTriggerProps, dialogProps, rest)} ref={forkedRef}>\n <div className=\"popover-arrow\" {...arrowProps} style={getOverlayArrowStyle(arrowProps)}></div>\n {title && (\n <div className=\"popover-header\" {...titleProps}>\n {title}\n </div>\n )}\n <div className=\"popover-body\">{content}</div>\n </div>\n )\n}\n\n// Every attribute besides the component's own props goes to the panel, the `.popover` element:\n// `className`, `style`, `id`, `data-*`, ARIA attributes and event handlers. So does the ref.\nexport interface PopoverProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'children' | 'content' | 'title'\n> {\n /**\n * The trigger: a single element, which opens the popover on click.\n */\n children: ReactElement\n /**\n * Content node for your component.\n */\n content: ReactNode | string\n /**\n * Whether the popover is open when it first renders. Use it instead of `visible` when nothing\n * outside needs to control the popover.\n */\n defaultVisible?: boolean\n /**\n * Offset of the popover relative to its target, as `[crossAxis, mainAxis]`.\n */\n offset?: [number, number]\n /**\n * Callback fired when the popover hides.\n */\n onHide?: () => void\n /**\n * Callback fired when the popover shows.\n */\n onShow?: () => void\n /**\n * Callback fired when the popover asks to show or hide: a click on the trigger, a click\n * outside, the Escape key, or the closing of the dialog it is in. Receives the state it asks\n * for. With `visible` set, the popover changes only when `visible` does.\n */\n onVisibleChange?: (visible: boolean) => void\n /**\n * Title node for your component.\n */\n title?: ReactNode | string\n /**\n * Describes the preferred placement of your component. Chassis will flip it to keep it in\n * view.\n */\n placement?: Placement\n /**\n * Whether the popover is open. Setting it makes the popover controlled: it shows and hides\n * only when this changes, so pair it with `onVisibleChange`. Leave it unset, or use\n * `defaultVisible`, for a popover that opens and closes itself.\n */\n visible?: boolean\n}\n\nexport const Popover = forwardRef<HTMLDivElement, PopoverProps>(function Popover(\n {\n children,\n className,\n content,\n defaultVisible,\n placement = 'right',\n offset: offsetProp = [0, 8],\n onHide,\n onShow,\n onVisibleChange,\n style,\n title,\n visible,\n ...rest\n },\n ref\n) {\n const arrowRef = useRef<HTMLDivElement>(null)\n const triggerRef = useRef<HTMLElement | null>(null)\n const floatingRef = useRef<HTMLDivElement>(null)\n const forkedFloatingRef = useForkedRef(ref, floatingRef)\n\n // The trigger is rendered as `asChild` renders a child (`renderSlotted`): the child's own\n // `onClick` chains after this one, and `triggerRef` is forked with the ref the caller put on\n // the child. `triggerProps` state the popover's condition (`aria-expanded`, `aria-controls`),\n // so they win over the child's own.\n const triggerElement = getTriggerChild(children, 'Popover')\n\n // A popover is a dialog, which needs a name. With no `title` to label it and none given, it is\n // named by its trigger, under the trigger's own id when it has one.\n const generatedId = useId()\n const triggerId =\n triggerElement && !title && rest['aria-label'] == null && rest['aria-labelledby'] == null\n ? ((triggerElement.props.id as string | undefined) ?? `${generatedId}-trigger`)\n : undefined\n\n const state = useOverlayTriggerState(\n useOpenStateProps({ defaultVisible, onVisibleChange, visible }, 'Popover')\n )\n const {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n triggerProps: { onPress: _onPress, ...triggerProps },\n overlayProps: overlayTriggerProps\n } = useOverlayTrigger({ type: 'dialog' }, state, triggerRef)\n\n const portalContainer = useFloatingOverlay({\n close: state.close,\n isOpen: state.isOpen,\n onHide,\n onShow,\n triggerRef\n })\n\n // A popover held open by `visible` with no `onVisibleChange` can't close on the key, and takes no\n // place in the stack: on top of it, it prevented every Escape, so a dialog under it couldn't\n // close either. `Tooltip` keeps such a tooltip out of react-aria's Escape handling the same way.\n const isHeld = visible !== undefined && !onVisibleChange\n\n // Escape should always close the popover, regardless of where focus currently is — a\n // mouse-opened popover leaves focus on the trigger, not inside the panel. Through the stack of\n // open overlays, so the key closes this popover only while nothing opened since is still open\n // (a menu or another popover in its content), and never the dialog around it with it.\n // `onExited` below already returns focus to the trigger once the exit transition finishes, so\n // this doesn't need to do that itself.\n useEffect(() => {\n if (!state.isOpen || isHeld) return undefined\n return pushOverlay({\n nodes: () => [floatingRef.current, triggerRef.current],\n onEscape: () => state.close()\n })\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [state.isOpen, state.close, isHeld])\n\n // A press outside closes the popover. A press rather than a click, as `ContextMenu` reads it:\n // an element its own click handler takes out of the document (a chip's remove button) is no\n // longer inside anything by the time a click listener here would ask. Inside is the trigger,\n // and anything React renders under the panel, wherever it is portaled (`insideEvents`): a\n // popover or a menu opened from the content, a date picker's calendar.\n // Deferred so a press whose own handler opens the popover doesn't close it again on its way\n // up to `window`.\n useEffect(() => {\n if (!state.isOpen) return undefined\n\n // By the event's path rather than its target: a trigger inside a shadow root is seen from\n // `window` as the shadow host, which the trigger doesn't contain, so pressing the trigger\n // closed the popover and its click opened it again.\n const isInside = (path: EventTarget[], node: Element | null) => !!node && path.includes(node)\n\n const handleDismiss = (event: PointerEvent) => {\n const path = event.composedPath()\n if (isInside(path, triggerRef.current)) return\n if (isInside(path, floatingRef.current) || isEventInside(event, floatingRef)) return\n state.close()\n }\n\n const id = window.setTimeout(() => {\n window.addEventListener('pointerdown', handleDismiss)\n })\n\n return () => {\n window.clearTimeout(id)\n window.removeEventListener('pointerdown', handleDismiss)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [state.isOpen, state.close])\n\n const {\n overlayProps,\n arrowProps,\n placement: resolvedPlacement\n } = useOverlayPosition({\n targetRef: triggerRef,\n overlayRef: floatingRef,\n placement: toAriaPlacement(placement),\n offset: offsetProp[1],\n crossOffset: offsetProp[0],\n arrowSize: 8,\n arrowRef,\n isOpen: state.isOpen,\n // `useOverlayPosition` closes on any window scroll via a backward-compat `WeakMap` that\n // `useOverlayTrigger` populates for `triggerRef.current` above. Passing `null` opts out so\n // the popover repositions with its trigger instead of vanishing — matching\n // `Autocomplete`/`Combobox`, neither of which is wired into that map.\n onClose: null\n })\n\n // The caller's `style` first: the position is the component's to set.\n const floatingStyle: React.CSSProperties = {\n ...style,\n position: overlayProps.style?.position as React.CSSProperties['position'],\n top: overlayProps.style?.top,\n left: overlayProps.style?.left\n }\n const placementAttr = resolveDataPlacement(placement, resolvedPlacement)\n\n // The panel mounts once its container is known (`useFloatingOverlay`), and only there.\n const { isMounted, phase } = useTransitionState({\n in: state.isOpen && portalContainer !== null,\n mountOnEnter: true,\n nodeRef: floatingRef,\n onExited: () => {\n const trigger = triggerRef.current\n if (!trigger || !document.contains(trigger)) return\n // Only reclaim focus when the popover still owns it, or when nothing does.\n // `useDialog` moves focus into the panel on open, so the panel still holds it here\n // for an Escape/inside close (`onExited` runs before the panel is taken out of the DOM,\n // so this reads the pre-removal state); an outside click on plain page\n // content instead leaves focus loose on `<body>`. Both are worth restoring. Any\n // other active element means the user deliberately put focus there — dismissing by\n // clicking another control, or the app closing the popover via `visible` while\n // they were typing somewhere else — and this used to steal it straight back off\n // them. Mirrors react-aria's own `shouldRestoreFocus` condition.\n const active = document.activeElement\n const focusIsLoose = !active || active === document.body\n const focusIsInPanel = !!active && !!floatingRef.current?.contains(active)\n if (!focusIsLoose && !focusIsInPanel) return\n trigger.focus()\n },\n unmountOnExit: true\n })\n\n // The panel is portaled, so it exists only once hydration has finished: until then the trigger\n // doesn't point `aria-controls` at it, or its HTML would refer to an id no element has.\n const hydrated = useHydrated()\n\n return (\n <>\n {triggerElement\n ? renderSlotted(\n triggerElement,\n { ...(triggerId && { id: triggerId }), onClick: () => state.toggle() },\n triggerRef,\n hydrated ? triggerProps : { ...triggerProps, 'aria-controls': undefined }\n )\n : children}\n <Portal container={portalContainer}>\n {isMounted && (\n <PopoverPanel\n className={classNames(\n 'popover cx-popover-auto',\n getOverlayTransitionClass(phase),\n className\n )}\n data-cx-placement={placementAttr}\n style={floatingStyle}\n overlayTriggerProps={overlayTriggerProps}\n overlayRef={forkedFloatingRef}\n arrowProps={arrowProps}\n title={title}\n content={content}\n aria-labelledby={triggerId}\n {...mergeProps(rest, insideEventProps(floatingRef))}\n />\n )}\n </Portal>\n </>\n )\n})\n\nPopover.displayName = 'Popover'\n"],"mappings":"A,myBAyCA,MAAMiB,GAAgB,CACpB,aACA,UACA,aACA,sBACA,QACA,GAAGC,KACoB,CAGvB,IAAMC,EAAWC,EAAuB,IAAI,EACtCC,EAAYnB,EAAaoB,EAAYH,CAAQ,EAC7C,CAAE,cAAa,cAAeI,EAAU,CAAC,EAAGJ,CAAQ,EAE1D,MACE,kBAAA,cAAC,MAAD,CAAK,GAAIK,EAAWC,EAAqBC,EAAaR,CAAI,EAAG,IAAKG,CAQ7D,EAPH,kBAAA,cAAC,MAAD,CAAK,UAAU,gBAAgB,GAAIM,EAAY,MAAOnB,EAAqBmB,CAAU,CAAQ,CAAA,EAC5FC,GACC,kBAAA,cAAC,MAAD,CAAK,UAAU,iBAAiB,GAAIC,CAE/B,EADFD,CACE,EAEP,kBAAA,cAAC,MAAD,CAAK,UAAU,cAA6B,EAAbE,CAAa,CACzC,CAET,EAwDaC,EAAUC,EAAyC,SAC9D,CACE,WACA,YACA,UACA,iBAC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EAlBLuB,IACC,kBAAA,cAACvD,EAAD,CACE,UAAWD,EACT,0BACAV,EAA0BmE,EAAK,EAC/BC,CACF,EACA,oBAAmBR,GACnB,MAAOH,EACc,sBACrB,WAAY1B,EACA,aACL,QACE,UACT,kBAAiBM,EACjB,GAAInB,EAAWN,EAAMJ,EAAiBsB,CAAW,CAAC,CACnD,CAAA,CAEG,CACR,CAEN,CAAC,EAED,EAAQ,YAAc,U"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./polymorphic-CZIFszAy.js";import{t}from"./colorClassNames-YzGWu6qm.js";import n,{useId as r}from"react";import i from"classnames";function a({children:e,animated:r,className:a,color:o,component:s,indeterminate:c,striped:l,style:u,value:d=0,...f},p){let m=s??`div`,h=Math.min(100,Math.max(0,d)),g=i(`progress-bar`,o&&[t[o],`fg-contrast`],{striped:l,animated:r,indeterminate:c},a);return/* @__PURE__ */ n.createElement(m,{...f,className:g,style:c?u:{width:`${h}%`,...u},ref:p},/* @__PURE__ */ n.createElement(`span`,{className:`mx-2xs`},e))}const o=e(a,`ProgressBar`);function s({"aria-label":e,"aria-labelledby":t,animated:a,children:s,className:c,color:l,component:u,height:d,indeterminate:f,inlineValue:p,label:m,showValue:h,striped:g,style:_,value:v=0,...y},b){let x=u??`div`,S=i(`progress`,c),C=Math.min(100,Math.max(0,v)),w=s===void 0?p&&!f?`${C}%`:void 0:s,T=!!(m||h),E=r(),D=m!=null&&typeof m!=`string`,O={..._};d!==void 0&&(O[`--cx-height`]=`${d}px`);let k=/* @__PURE__ */ n.createElement(x,{...y,className:S,role:`progressbar`,"aria-valuenow":f?void 0:C,"aria-valuemin":f?void 0:0,"aria-valuemax":f?void 0:100,"aria-label":e??(typeof m==`string`?m:void 0),"aria-labelledby":t??(!e&&D?E:void 0),style:O,ref:b},/* @__PURE__ */ n.createElement(o,{animated:a,color:l,indeterminate:f,striped:g,value:C},w));return T?/* @__PURE__ */ n.createElement(`div`,{className:`d-flex flex-column gap-xs`},/* @__PURE__ */ n.createElement(`div`,{className:i(`d-flex`,m?`justify-content-between`:`justify-content-end`)},m?/* @__PURE__ */ n.createElement(`span`,{className:`font-strong`,id:D?E:void 0},m):null,h?/* @__PURE__ */ n.createElement(`span`,{className:`font-strong`},f?`\xA0`:`${C}%`):null),k):k}const c=e(s,`Progress`);export{o as n,c as t};
|
|
2
|
+
//# sourceMappingURL=progress-CiSJDNwx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progress-CiSJDNwx.js","names":["createPolymorphicComponent","React","classNames","ProgressBarRender","rest","Component","component","clampedValue","value","_className","color","BG_COLOR_CLASS_NAMES","className","indeterminate","style","children","ProgressBar","ProgressRender","ariaLabel","ariaLabelledBy","barChildren","inlineValue","hasCaption","label","showValue","labelId","useId","isNodeLabel","_style","height","progressElement","Progress"],"sources":["../../src/components/progress/ProgressBar.tsx","../../src/components/progress/Progress.tsx"],"sourcesContent":["import React, { ElementType, ForwardRefRenderFunction, ReactElement } from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor } from '../../types'\nimport { BG_COLOR_CLASS_NAMES } from '../../utils/colorClassNames'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\n\nimport './Progress.scss'\n\ntype ProgressBarOwnProps<C extends ElementType> = {\n /**\n * Use to animate the stripes right to left via CSS3 animations.\n */\n animated?: boolean\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 * Shows that work is under way without saying how much: the bar fills the track and sweeps\n * across it, or shows its stripes when `striped` is set. `value` is ignored.\n */\n indeterminate?: boolean\n /**\n * Adds a diagonal stripe pattern over the bar's background.\n */\n striped?: boolean\n /**\n * The percent to progress the ProgressBar.\n */\n value?: number\n}\n\nexport type ProgressBarProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ProgressBarOwnProps<C>\n>\n\ntype ProgressBarComponent = (<C extends ElementType = 'div'>(\n props: ProgressBarProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ProgressBarRender<C extends ElementType = 'div'>(\n {\n children,\n animated,\n className,\n color,\n component,\n indeterminate,\n striped,\n style,\n value = 0,\n ...rest\n }: ProgressBarProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const clampedValue = Math.min(100, Math.max(0, value))\n const _className = classNames(\n 'progress-bar',\n color && [BG_COLOR_CLASS_NAMES[color], 'fg-contrast'],\n {\n striped,\n animated,\n indeterminate\n },\n className\n )\n\n return (\n <Component\n {...rest}\n className={_className}\n // An indeterminate bar takes its width from `Progress.scss`.\n style={indeterminate ? style : { width: `${clampedValue}%`, ...style }}\n ref={ref}\n >\n <span className=\"mx-2xs\">{children}</span>\n </Component>\n )\n}\n\nexport const ProgressBar = createPolymorphicComponent<ProgressBarComponent>(\n ProgressBarRender as ForwardRefRenderFunction<Element, ProgressBarProps<ElementType>>,\n 'ProgressBar'\n)\n","import React, {\n CSSProperties,\n ElementType,\n ForwardRefRenderFunction,\n ReactElement,\n ReactNode,\n useId\n} from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor } from '../../types'\nimport {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\nimport { ProgressBar } from './ProgressBar'\n\ntype ProgressStyle = CSSProperties & {\n '--cx-height'?: string\n}\n\ntype ProgressOwnProps<C extends ElementType> = {\n /**\n * Use to animate the stripes right to left via CSS3 animations.\n */\n animated?: boolean\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 * Sets the height of the component, via the `--cx-height` custom property. If you set that\n * value the inner bar (and the striped pattern's tile size) automatically resizes accordingly.\n */\n height?: number\n /**\n * Shows that work is under way without saying how much, for a request with no progress events.\n * The bar sweeps across the track, or fills it with stripes when `striped` is set, and the\n * `aria-valuenow`, `aria-valuemin` and `aria-valuemax` attributes are left out. `value` and\n * `inlineValue` are ignored, and `showValue` keeps its place in the caption row empty.\n */\n indeterminate?: boolean\n /**\n * Shows the current value as text inside the bar, independently of `showValue` — combine both\n * to get a `label` + `showValue` caption above the bar alongside an `inlineValue` reading\n * inside it.\n */\n inlineValue?: boolean\n /**\n * A text label describing the progress. Rendered in a caption row above the bar. Also used as\n * the default accessible name when no `aria-label`/`aria-labelledby` is supplied.\n */\n label?: ReactNode\n /**\n * Shows the current value as text in the caption row above the bar, alongside `label` when\n * both are set, or alone otherwise. Use `inlineValue` to show it inside the bar instead.\n */\n showValue?: boolean\n /**\n * Adds a diagonal stripe pattern over the bar's background.\n */\n striped?: boolean\n /**\n * The percent to progress the ProgressBar (out of 100).\n */\n value?: number\n}\n\nexport type ProgressProps<C extends ElementType = 'div'> = PolymorphicComponentProps<\n C,\n ProgressOwnProps<C>\n>\n\ntype ProgressComponent = (<C extends ElementType = 'div'>(\n props: ProgressProps<C> & { ref?: PolymorphicRef<C> }\n) => ReactElement | null) & { displayName?: string }\n\nfunction ProgressRender<C extends ElementType = 'div'>(\n {\n 'aria-label': ariaLabel,\n 'aria-labelledby': ariaLabelledBy,\n animated,\n children,\n className,\n color,\n component,\n height,\n indeterminate,\n inlineValue,\n label,\n showValue,\n striped,\n style,\n value = 0,\n ...rest\n }: ProgressProps<C>,\n ref: PolymorphicRef<C>\n) {\n const Component = component ?? 'div'\n const _className = classNames('progress', className)\n const clampedValue = Math.min(100, Math.max(0, value))\n\n const barChildren =\n children !== undefined\n ? children\n : inlineValue && !indeterminate\n ? `${clampedValue}%`\n : undefined\n const hasCaption = Boolean(label || showValue)\n\n const labelId = useId()\n const isNodeLabel = label != null && typeof label !== 'string'\n\n const _style: ProgressStyle = { ...style }\n if (height !== undefined) _style['--cx-height'] = `${height}px`\n\n const progressElement = (\n <Component\n {...rest}\n className={_className}\n role=\"progressbar\"\n aria-valuenow={indeterminate ? undefined : clampedValue}\n aria-valuemin={indeterminate ? undefined : 0}\n aria-valuemax={indeterminate ? undefined : 100}\n aria-label={ariaLabel ?? (typeof label === 'string' ? label : undefined)}\n // The caller's own wins: written after the spread, the label's id replaced it, and with no\n // node label it was `undefined` that did.\n aria-labelledby={ariaLabelledBy ?? (!ariaLabel && isNodeLabel ? labelId : undefined)}\n style={_style}\n ref={ref}\n >\n <ProgressBar\n animated={animated}\n color={color}\n indeterminate={indeterminate}\n striped={striped}\n value={clampedValue}\n >\n {barChildren}\n </ProgressBar>\n </Component>\n )\n\n if (!hasCaption) return progressElement\n\n return (\n <div className=\"d-flex flex-column gap-xs\">\n <div\n className={classNames('d-flex', label ? 'justify-content-between' : 'justify-content-end')}\n >\n {label ? (\n <span className=\"font-strong\" id={isNodeLabel ? labelId : undefined}>\n {label}\n </span>\n ) : null}\n {/* An indeterminate bar has no value to show. The row keeps its height, so nothing moves\n when the value arrives. */}\n {showValue ? (\n <span className=\"font-strong\">{indeterminate ? '\\u00A0' : `${clampedValue}%`}</span>\n ) : null}\n </div>\n {progressElement}\n </div>\n )\n}\n\nexport const Progress = createPolymorphicComponent<ProgressComponent>(\n ProgressRender as ForwardRefRenderFunction<Element, ProgressProps<ElementType>>,\n 'Progress'\n)\n"],"mappings":"A,uLAsDA,SAASG,EACP,CACE,WACA,WACA,YACA,QACA,YACA,gBACA,UACA,QACA,QAAQ,EACR,GAAGC,GAEL,EACA,CACA,IAAMC,EAAYC,GAAa,MACzBC,EAAe,KAAK,IAAI,IAAK,KAAK,IAAI,EAAGC,CAAK,CAAC,EAC/CC,EAAaP,EACjB,eACAQ,GAAS,CAACC,EAAqBD,GAAQ,aAAa,EACpD,CACE,UACA,WACA,eACF,EACAE,CACF,EAEA,MACE,kBAAA,cAACP,EAAD,CACE,GAAID,EACJ,UAAW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0BAA4B,qBAAqB,CAYtF,EAVFA,EACC,kBAAA,cAAC,OAAD,CAAM,UAAU,cAAc,GAAII,EAAcF,EAAU,IAAA,EAEpD,EADHF,CACG,EACJ,KAGHC,EACC,kBAAA,cAAC,OAAD,CAAM,UAAU,aAAmE,EAApDX,EAAgB,OAAW,GAAGN,EAAa,EAAS,EACjF,IACD,EACJuB,CACE,EAnBiBA,CAqB1B,CAEA,MAAaC,EAAW/B,EACtBiB,EACA,UACF,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{c as e}from"./slot-BQVx1Eew.js";import{t}from"./useForkedRef-WoqMqsWE.js";import{t as n}from"./useHeldBack-eeTfpa_t.js";import{n as r,t as i}from"./FormHelp-B1eSoack.js";import{t as a}from"./validationClassName-gRGs4KBm.js";import{t as o}from"./renderFormCheck-DvpfK_I4.js";import{n as s,r as c}from"./unhandledProps-9Kdj7WVf.js";import{t as l}from"./flex-C2jV5LyV.js";import u,{createContext as d,forwardRef as f,useContext as p,useRef as m}from"react";import h from"classnames";import{useRadio as g,useRadioGroup as _}from"react-aria";import{useRadioGroupState as v}from"react-stately";const y=d(null),b=[...s,`name`,`required`,`tabIndex`],x=f(({button:n,children:r,className:i,color:s,disabled:l,id:d,label:f,size:_,style:v,...x},S)=>{let C=p(y);if(!C)throw Error(`Radio must be rendered inside a RadioGroup.`);let{describedBy:w,state:T,valid:E}=C,D=T.isInvalid,O=m(null),k=t(S,O),A=f??r,{inputProps:j}=g({...x,children:A,isDisabled:l},T,O),M=h(a(D,E));return o({button:n,className:i,color:s,input:/* @__PURE__ */ u.createElement(`input`,{...c(j,x,b),"aria-describedby":e(x[`aria-describedby`],w),className:M,id:d,ref:k,required:T.isRequired||void 0}),invalid:D,label:A,size:_,style:v,valid:E})});x.displayName=`Radio`;const S=f(({children:o,className:s,defaultValue:d,description:f,disabled:p,errorMessage:g,form:b,invalid:x,label:S,name:C,onChange:w,orientation:T,required:E,valid:D,value:O,...k},A)=>{let j=m(null),M=t(A,j),{invalid:N,valid:P}=n(j,{invalid:x,valid:D}),F={...k,defaultValue:d,description:f,errorMessage:g,form:b,isDisabled:p,isInvalid:N,isRequired:E,label:S,name:C,onChange:w,orientation:T,value:O},I=v(F),{radioGroupProps:L,labelProps:R,descriptionProps:z,errorMessageProps:B}=_(F,I),V=h(`form-field`,a(N,P),s),H=e(!!f&&z.id,!!(N&&g)&&B.id),U=/* @__PURE__ */ u.createElement(y.Provider,{value:{describedBy:H,state:I,valid:P}},o);return/* @__PURE__ */ u.createElement(`fieldset`,{...c(L,k,[`onBlur`,`onFocus`]),"aria-describedby":e(H,k[`aria-describedby`]),className:V,form:b,ref:M},S&&/* @__PURE__ */ u.createElement(`legend`,{className:`form-label`,...R},S),T===`horizontal`?/* @__PURE__ */ u.createElement(l,{wrap:`wrap`,gap:`md`},U):U,f&&/* @__PURE__ */ u.createElement(i,z,f),N&&g&&/* @__PURE__ */ u.createElement(r,{invalid:!0,...B},g))});S.displayName=`RadioGroup`;export{x as n,S as t};
|
|
2
|
+
//# sourceMappingURL=radio-C42F_5OD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"radio-C42F_5OD.js","names":["joinIds","useHeldBack","FormFeedback","FormHelp","validationClassName","renderFormCheck","TOGGLE_PROPS","mergeUnhandledProps","Flex","React","classNames","RadioGroupContext","createContext","RADIO_PROPS","Radio","forwardRef","rest","group","useContext","groupDescribedBy","groupState","invalid","inputRef","useRef","forkedRef","useForkedRef","ref","resolvedLabel","label","children","useRadio","disabled","inputClassName","valid","inputProps","RadioGroup","invalidProp","validProp","fieldsetRef","groupProps","required","state","useRadioGroupState","useRadioGroup","_className","className","describedBy","description","descriptionProps","errorMessage","errorMessageProps","items","radioGroupProps","labelProps","orientation"],"sources":["../../src/components/radio/context.ts","../../src/components/radio/Radio.tsx","../../src/components/radio/RadioGroup.tsx"],"sourcesContent":["import { createContext } from 'react'\nimport { RadioGroupState } from 'react-stately'\n\nexport interface RadioGroupContextValue {\n state: RadioGroupState\n /**\n * `RadioGroup`'s own `valid` prop, mirrored here since it has no react-stately equivalent to\n * read off `state` the way `isInvalid` does — each `Radio` needs it to apply its own\n * `is-valid` class.\n */\n valid?: boolean\n /**\n * The ids of the group's description and error message, when they are rendered. Each item is\n * described by them too.\n */\n describedBy?: string\n}\n\nexport const RadioGroupContext = createContext<RadioGroupContextValue | null>(null)\n","import React, { forwardRef, InputHTMLAttributes, ReactNode, useContext, useRef } from 'react'\nimport classNames from 'classnames'\nimport { AriaRadioProps, useRadio } from 'react-aria'\n\nimport { useForkedRef } from '../../hooks'\nimport { ContextColor } from '../../types'\nimport { validationClassName } from '../../utils/validationClassName'\nimport { joinIds } from '../../utils/idRefs'\nimport { mergeUnhandledProps, TOGGLE_PROPS } from '../../utils/unhandledProps'\n\nimport { RadioGroupContext } from './context'\nimport { ButtonObject, renderFormCheck } from '../form/renderFormCheck'\n\nexport interface RadioProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'checked' | 'defaultChecked' | 'onChange' | 'size'\n> {\n /**\n * Create button-like radios. Combine with `<RadioGroup>` to build radio toggle-button groups.\n */\n button?: ButtonObject\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * Sets the color of the radio indicator to one of Chassis context colors. Ignored when `button` is set.\n */\n color?: ContextColor\n /**\n * The id global attribute defines an identifier (ID) that must be unique in the whole document.\n */\n id?: string\n /**\n * The element represents a caption for a component.\n *\n * Children are accepted as an alias for this prop — `label` wins when both are given.\n * react-aria, which backs this component, calls the same thing `children`; this package renames\n * it to `label`, and honouring both means the shape React developers reach for first still\n * names the control instead of silently producing an unlabelled one.\n */\n label?: ReactNode\n /**\n * Size the component sm or lg.\n */\n size?: 'sm' | 'lg'\n /**\n * The value of the radio button, used to identify it within its `<RadioGroup>`.\n */\n value: string\n}\n\n// The group owns its radios' `name` and required state, and which one is the tab stop. `form`\n// is the radio's own, as a `Checkbox` in a `CheckboxGroup` keeps its own.\nconst RADIO_PROPS = [...TOGGLE_PROPS, 'name', 'required', 'tabIndex']\n\n// `<Radio>` must be rendered inside a `<RadioGroup>` — react-aria has no standalone\n// radio hook, only useRadio(props, RadioGroupState, ref), because a lone radio with no group is\n// not a meaningful accessible control (see https://chassis-ui.com/css/docs/forms/checkbox-radio).\nexport const Radio = forwardRef<HTMLInputElement, RadioProps>(\n ({ button, children, className, color, disabled, id, label, size, style, ...rest }, ref) => {\n const group = useContext(RadioGroupContext)\n\n if (!group) {\n throw new Error('Radio must be rendered inside a RadioGroup.')\n }\n\n const { describedBy: groupDescribedBy, state: groupState, valid } = group\n const invalid = groupState.isInvalid\n\n const inputRef = useRef<HTMLInputElement>(null)\n const forkedRef = useForkedRef(ref, inputRef)\n\n // `label` is this package's name for what react-aria calls `children`. Accept either, so the\n // shape React developers reach for first (`<Radio>Label</Radio>`) names the control instead of\n // being silently dropped — see the note on `label` in `RadioProps`.\n const resolvedLabel = label ?? children\n\n const { inputProps } = useRadio(\n {\n ...rest,\n children: resolvedLabel,\n isDisabled: disabled\n } as AriaRadioProps,\n groupState,\n inputRef\n )\n\n const inputClassName = classNames(validationClassName(invalid, valid))\n\n return renderFormCheck({\n button,\n className,\n color,\n // Described by the group's description and error message, as react-aria intends, but only\n // by those the group renders (FORMS.md, gotcha 6).\n input: (\n <input\n {...mergeUnhandledProps(inputProps, rest, RADIO_PROPS)}\n aria-describedby={joinIds(rest['aria-describedby'], groupDescribedBy)}\n className={inputClassName}\n id={id}\n ref={forkedRef}\n // A required group is the native `required` on its radios, which share a `name`: a\n // form then asks for one of them. react-aria writes `aria-required` on the group alone.\n required={groupState.isRequired || undefined}\n />\n ),\n invalid,\n label: resolvedLabel,\n size,\n style,\n valid\n })\n }\n)\n\nRadio.displayName = 'Radio'\n","import React, { forwardRef, HTMLAttributes, ReactNode, useRef } from 'react'\nimport classNames from 'classnames'\nimport { AriaRadioGroupProps, useRadioGroup } from 'react-aria'\nimport { RadioGroupProps as StatelyRadioGroupProps, useRadioGroupState } from 'react-stately'\n\nimport { useForkedRef, useHeldBack } from '../../hooks'\nimport { validationClassName } from '../../utils/validationClassName'\nimport { joinIds } from '../../utils/idRefs'\nimport { mergeUnhandledProps } from '../../utils/unhandledProps'\n\nimport { RadioGroupContext } from './context'\nimport { FormFeedback } from '../form/FormFeedback'\nimport { FormHelp } from '../form/FormHelp'\nimport { Flex } from '../flex'\n\nexport interface RadioGroupProps extends Omit<\n HTMLAttributes<HTMLFieldSetElement>,\n 'defaultValue' | 'onChange'\n> {\n /**\n * One or more `<Radio>` elements.\n */\n children: ReactNode\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * The selected value, uncontrolled.\n */\n defaultValue?: string\n /**\n * A description for the group, rendered below the options.\n */\n description?: ReactNode\n /**\n * Disables every radio in the group.\n */\n disabled?: boolean\n /**\n * An error message for the group, rendered below the options when `invalid` is set, and after\n * a submit the group held back, until it no longer would.\n */\n errorMessage?: ReactNode\n /**\n * The id of the `<form>` the group belongs to, for a group rendered outside it. Reaches every\n * radio; a `Radio` with its own `form` keeps it.\n */\n form?: string\n /**\n * Set group validation state to invalid. Left unset, the group 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 * The group's caption, rendered as a `<legend>`.\n */\n label?: ReactNode\n /**\n * The name for the group, used for native form submission.\n */\n name?: string\n /**\n * Callback fired when the selected value changes.\n */\n onChange?: (value: string) => void\n /**\n * Lay the group's radios out on the same horizontal row instead of stacking them.\n */\n orientation?: 'horizontal' | 'vertical'\n /**\n * Marks the group as required: `aria-required` on the group and the native `required` on its\n * radios, so a form isn't submitted until one of them is selected.\n */\n required?: boolean\n /**\n * Set group validation state to valid.\n */\n valid?: boolean\n /**\n * The selected value, controlled.\n */\n value?: string\n}\n\nexport const RadioGroup = forwardRef<HTMLFieldSetElement, RadioGroupProps>(\n (\n {\n children,\n className,\n defaultValue,\n description,\n disabled,\n errorMessage,\n form,\n invalid: invalidProp,\n label,\n name,\n onChange,\n orientation,\n required,\n valid: validProp,\n value,\n ...rest\n },\n ref\n ) => {\n const fieldsetRef = useRef<HTMLFieldSetElement>(null)\n const forkedRef = useForkedRef(ref, fieldsetRef)\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 fieldset hears every radio, and the group shows it for them all, with `errorMessage`.\n const { invalid, valid } = useHeldBack(fieldsetRef, { invalid: invalidProp, valid: validProp })\n\n const groupProps = {\n ...rest,\n defaultValue,\n description,\n errorMessage,\n form,\n isDisabled: disabled,\n isInvalid: invalid,\n isRequired: required,\n label,\n name,\n onChange,\n orientation,\n value\n }\n\n const state = useRadioGroupState(groupProps as StatelyRadioGroupProps)\n const { radioGroupProps, labelProps, descriptionProps, errorMessageProps } = useRadioGroup(\n groupProps as AriaRadioGroupProps,\n state\n )\n\n const _className = classNames('form-field', validationClassName(invalid, valid), className)\n\n // Only the ids this group renders. react-aria's own describe the group and every item by a\n // description and an error message whether or not they exist (FORMS.md, gotcha 6).\n const describedBy = joinIds(\n Boolean(description) && descriptionProps.id,\n Boolean(invalid && errorMessage) && errorMessageProps.id\n )\n\n const items = (\n <RadioGroupContext.Provider value={{ describedBy, state, valid }}>\n {children}\n </RadioGroupContext.Provider>\n )\n\n return (\n <fieldset\n {...mergeUnhandledProps(radioGroupProps, rest, ['onBlur', 'onFocus'])}\n aria-describedby={joinIds(describedBy, rest['aria-describedby'])}\n className={_className}\n // The fieldset's own form owner. react-aria hands the group's `form` to each of its\n // radios, under one that has its own.\n form={form}\n ref={forkedRef}\n >\n {label && (\n <legend className=\"form-label\" {...labelProps}>\n {label}\n </legend>\n )}\n {orientation === 'horizontal' ? (\n <Flex wrap=\"wrap\" gap=\"md\">\n {items}\n </Flex>\n ) : (\n items\n )}\n {description && <FormHelp {...descriptionProps}>{description}</FormHelp>}\n {invalid && errorMessage && (\n <FormFeedback invalid {...errorM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a,CAAE,QAASF,EAAa,MAAOC,CAAU,CAAC,EAExFE,EAAa,CACjB,GAAGvB,EACH,eACA,cACA,eACA,OACA,WAAYe,EACZ,UAAWV,EACX,WAAYmB,EACZ,QACA,OACA,WACA,cACA,OACF,EAEMC,EAAQC,EAAmBH,CAAoC,EAC/D,CAAE,kBAAiB,aAAY,mBAAkB,qBAAsBI,EAC3EJ,EACAE,CACF,EAEMG,EAAalC,EAAW,aAAcN,EAAoBiB,EAASY,CAAK,EAAGY,CAAS,EAIpFC,EAAc9C,EAClB,EAAQ+C,GAAgBC,EAAiB,GACzC,GAAQ3B,GAAW4B,IAAiBC,EAAkB,EACxD,EAEMC,EACJ,kBAAA,cAACxC,EAAkB,SAAnB,CAA4B,MAAO,CAAE,cAAa,QAAO,OAAM,CAEnC,EADzBkB,CACyB,EAG9B,MACE,kBAAA,cAAC,WAAD,CACE,GAAItB,EAAoB6C,EAAiBpC,EAAM,CAAC,SAAU,SAAS,CAAC,EACpE,mBAAkBhB,EAAQ8C,EAAa9B,EAAK,mBAAmB,EAC/D,UAAW4B,EAGL,OACN,IAAKpB,CAoBG,EAlBPI,GACC,kBAAA,cAAC,SAAD,CAAQ,UAAU,aAAa,GAAIyB,CAE3B,EADLzB,CACK,EAET0B,IAAgB,aACf,kBAAA,cAAC9C,EAAD,CAAM,KAAK,OAAO,IAAI,IAEhB,EADH2C,CACG,EAENA,EAEDJ,GAAe,kBAAA,cAAC5C,EAAa6C,EAAmBD,CAAsB,EACtE1B,GAAW4B,GACV,kBAAA,cAAC/C,EAAD,CAAc,QAAA,GAAQ,GAAIgD,CAEZ,EADXD,CACW,CAER,CAEd,CACF,EAEA,EAAW,YAAc,a"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./useForkedRef-WoqMqsWE.js";import{t}from"./useFormField-DH2tlc3e.js";import{t as n}from"./useHeldBack-eeTfpa_t.js";import{t as r}from"./renderFormField-_6WswnEX.js";import{t as i}from"./validationClassName-gRGs4KBm.js";import a,{forwardRef as o,useRef as s}from"react";import c from"classnames";const l=o(({className:o,help:l,id:u,invalid:d,invalidFeedback:f,label:p,valid:m,validFeedback:h,...g},_)=>{let v=s(null),y=e(_,v),{invalid:b,valid:x}=n(v,{invalid:d,valid:m}),{describedBy:S,feedbackId:C,helpId:w,inputId:T}=t({ariaDescribedBy:g[`aria-describedby`],help:l,id:u,invalid:b,invalidFeedback:f,valid:x,validFeedback:h}),E=c(`form-range`,i(b,x),o);return r({children:/* @__PURE__ */ a.createElement(`input`,{...g,"aria-describedby":S,"aria-invalid":b||void 0,className:E,id:T,ref:y,type:`range`}),help:l,ids:{feedback:C,help:w,input:T},invalid:b,invalidFeedback:f,label:p,valid:x,validFeedback:h})});l.displayName=`RangeInput`;export{l as t};
|
|
2
|
+
//# sourceMappingURL=range-input-DeZq_9S7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"range-input-DeZq_9S7.js","names":["useForkedRef","useHeldBack","renderFormField","validationClassName","React","classNames","RangeInput","forwardRef","invalidProp","validProp","rest","inputRef","useRef","forkedRef","ref","useFormField","_className","invalid","valid","className","describedBy","inputId","feedbackId","helpId"],"sources":["../../src/components/range-input/RangeInput.tsx"],"sourcesContent":["import React, {\n ChangeEventHandler,\n forwardRef,\n InputHTMLAttributes,\n ReactNode,\n useRef\n} from 'react'\nimport classNames from 'classnames'\n\nimport { useForkedRef, useFormField, useHeldBack } from '../../hooks'\nimport { validationClassName } from '../../utils/validationClassName'\nimport { renderFormField } from '../form-field/renderFormField'\n\nexport interface RangeInputProps extends InputHTMLAttributes<HTMLInputElement> {\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 * A description for the field, rendered below the range input.\n */\n help?: ReactNode\n /**\n * Set component validation state to invalid.\n */\n invalid?: boolean\n /**\n * An error message for the field, rendered below the range input when `invalid` is set.\n */\n invalidFeedback?: ReactNode\n /**\n * The field's caption, rendered as a `FormLabel` associated with this range input.\n */\n label?: ReactNode\n /**\n * Specifies the maximum value for the component.\n */\n max?: number\n /**\n * Specifies the minimum value for the component.\n */\n min?: number\n /**\n * Method called immediately after the `value` prop changes.\n */\n onChange?: ChangeEventHandler<HTMLInputElement>\n /**\n * Toggle the readonly state for the component.\n */\n readOnly?: boolean\n /**\n * Specifies the interval between legal numbers in the component.\n */\n step?: number\n /**\n * Set component validation state to valid.\n */\n valid?: boolean\n /**\n * A success message for the field, rendered below the range input when `valid` is set.\n */\n validFeedback?: ReactNode\n /**\n * The `value` attribute of component.\n *\n * @controllable onChange\n * */\n value?: string | number\n}\n\nexport const RangeInput = forwardRef<HTMLInputElement, RangeInputProps>(\n (\n {\n className,\n help,\n id,\n invalid: invalidProp,\n invalidFeedback,\n label,\n valid: validProp,\n validFeedback,\n ...rest\n },\n ref\n ) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const forkedRef = useForkedRef(ref, inputRef)\n // A range input always has a value and holds no form back, but a `validated` form shows it\n // as valid (`useHeldBack`).\n const { invalid, valid } = useHeldBack(inputRef, { invalid: invalidProp, valid: validProp })\n\n const { describedBy, feedbackId, helpId, inputId } = useFormField({\n ariaDescribedBy: rest['aria-describedby'],\n help,\n id,\n invalid,\n invalidFeedback,\n valid,\n validFeedback\n })\n\n const _className = classNames('form-range', validationClassName(invalid, valid), className)\n\n return renderFormField({\n children: (\n <input\n {...rest}\n aria-describedby={describedBy}\n aria-invalid={invalid || undefined}\n className={_className}\n id={inputId}\n ref={forkedRef}\n type=\"range\"\n />\n ),\n help,\n ids: { feedback: feedbackId, help: helpId, input: inputId },\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n }\n)\n\nRangeInput.displayName = 'RangeInput'\n"],"mappings":"A,4VA0EA,MAAaM,EAAaC,GAEtB,CACE,YACA,OACA,KACA,QAASC,EACT,kBACA,QACA,MAAOC,EACP,gBACA,GAAGC,GAEL,IACG,CACH,IAAMC,EAAWC,EAAyB,IAAI,EACxCC,EAAYb,EAAac,EAAKH,CAAQ,EAGtC,CAAE,UAAS,SAAUV,EAAYU,EAAU,CAAE,QAASH,EAAa,MAAOC,CAAU,CAAC,EAErF,CAAE,cAAa,aAAY,SAAQ,WAAYM,EAAa,CAChE,gBAAiBL,EAAK,oBACtB,OACA,KACA,UACA,kBACA,QACA,eACF,CAAC,EAEKM,EAAaX,EAAW,aAAcF,EAAoBc,EAASC,CAAK,EAAGC,CAAS,EAE1F,OAAOjB,EAAgB,CACrB,SACE,kBAAA,cAAC,QAAD,CACE,GAAIQ,EACJ,mBAAkBU,EAClB,eAAcH,GAAW,IAAA,GACzB,UAAWD,EACX,GAAIK,EACJ,IAAKR,EACL,KAAK,OACN,CAAA,EAEH,OACA,IAAK,CAAE,SAAUS,EAAY,KAAMC,EAAQ,MAAOF,CAAQ,EAC1D,UACA,kBACA,QACA,QACA,eACF,CAAC,CACH,CACF,EAEA,EAAW,YAAc,a"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./FormLabel-CpzWYh6U.js";import{t}from"./validationClassName-gRGs4KBm.js";import n from"react";import r from"classnames";const i=({button:i,className:a,color:o,input:s,invalid:c,label:l,size:u,style:d,valid:f})=>{if(i){let o=r(`button`,`button-check`,i.color,i.variant,i.size,i.shape,t(c,f),a);return/* @__PURE__ */ n.createElement(e,{customClassName:o,style:d},s,l)}let p=r(`check-input`,o,t(c,f));if(!l)return/* @__PURE__ */ n.createElement(`span`,{className:r(p,a),style:d},s);let m=r(`form-check`,u,t(c,f),a);return/* @__PURE__ */ n.createElement(e,{customClassName:m,style:d},/* @__PURE__ */ n.createElement(`span`,{className:p},s),l)};export{i as t};
|
|
2
|
+
//# sourceMappingURL=renderFormCheck-DvpfK_I4.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderFormCheck-DvpfK_I4.js","names":["FormLabel","React","classNames","renderFormCheck","button","_className","validationClassName","invalid","valid","className","input","label","checkInputClassName","color","size"],"sources":["../../src/components/form/renderFormCheck.tsx"],"sourcesContent":["import React, { CSSProperties, ReactNode } from 'react'\nimport classNames from 'classnames'\n\nimport { ContextColor, Shapes } from '../../types'\nimport { validationClassName } from '../../utils/validationClassName'\n\nimport { FormLabel } from './FormLabel'\n\nexport type ButtonObject = {\n /**\n * Sets the color of the component to one of Chassis context colors.\n */\n color?: ContextColor\n /**\n * Select the shape of the component.\n */\n shape?: Shapes\n /**\n * Size the component sm or lg.\n */\n size?: 'sm' | 'lg'\n /**\n * Set the button variant to an outlined button or a ghost button.\n */\n variant?: 'outline' | 'ghost'\n}\n\nexport interface RenderFormCheckOptions {\n button?: ButtonObject\n className?: string\n color?: ContextColor\n input: ReactNode\n invalid?: boolean\n label?: ReactNode\n size?: 'sm' | 'lg'\n style?: CSSProperties\n valid?: boolean\n}\n\n// Shared nested, modern `.form-check`/`.check-input` markup for Checkbox and Radio —\n// see https://chassis-ui.com/css/docs/forms/checkbox-radio/#modern-inputs. Everything renders\n// nested inside a single <label> (or a bare <span class=\"check-input\"> when there's no label);\n// there is no sibling/`for`-linked layout. `className` and `style` go on the outermost element.\nexport const renderFormCheck = ({\n button,\n className,\n color,\n input,\n invalid,\n label,\n size,\n style,\n valid\n}: RenderFormCheckOptions) => {\n if (button) {\n const _className = classNames(\n 'button',\n 'button-check',\n button.color,\n button.variant,\n button.size,\n button.shape,\n validationClassName(invalid, valid),\n className\n )\n return (\n <FormLabel customClassName={_className} style={style}>\n {input}\n {label}\n </FormLabel>\n )\n }\n\n const checkInputClassName = classNames('check-input', color, validationClassName(invalid, valid))\n\n // With no label the `.check-input` is the outermost element, so it takes `className` as it\n // takes `style`.\n if (!label) {\n return (\n <span className={classNames(checkInputClassName, className)} style={style}>\n {input}\n </span>\n )\n }\n\n const _className = classNames('form-check', size, validationClassName(invalid, valid), className)\n\n return (\n <FormLabel customClassName={_className} style={style}>\n <span className={checkInputClassName}>{input}</span>\n {label}\n </FormLabel>\n )\n}\n"],"mappings":"A,4IA2CA,MAAaG,GAAmB,CAC9B,SACA,YACA,QACA,QACA,UACA,QACA,OACA,QACA,WAC4B,CAC5B,GAAIC,EAAQ,CACV,IAAMC,EAAaH,EACjB,SACA,eACAE,EAAO,MACPA,EAAO,QACPA,EAAO,KACPA,EAAO,MACPE,EAAoBC,EAASC,CAAK,EAClCC,CACF,EACA,MACE,kBAAA,cAACT,EAAD,CAAW,gBAAiBK,EAAmB,OAGpC,EAFRK,EACAC,CACQ,CAEf,CAEA,IAAMC,EAAsBV,EAAW,cAAeW,EAAOP,EAAoBC,EAASC,CAAK,CAAC,EAIhG,GAAI,CAACG,EACH,MACE,kBAAA,cAAC,OAAD,CAAM,UAAWT,EAAWU,EAAqBH,CAAS,EAAU,OAE9D,EADHC,CACG,EAIV,IAAML,EAAaH,EAAW,aAAcY,EAAMR,EAAoBC,EAASC,CAAK,EAAGC,CAAS,EAEhG,MACE,kBAAA,cAACT,EAAD,CAAW,gBAAiBK,EAAmB,OAGpC,EAFT,kBAAA,cAAC,OAAD,CAAM,UAAWO,CAAkC,EAAZF,CAAY,EAClDC,CACQ,CAEf,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{n as e,t}from"./FormHelp-B1eSoack.js";import{t as n}from"./FormLabel-CpzWYh6U.js";import r from"react";import i from"classnames";const a=({children:a,className:o,help:s,ids:c={},invalid:l,invalidFeedback:u,label:d,ref:f,valid:p,validFeedback:m})=>{let h=!!(l&&u),g=!!(p&&m)&&!h;return!d&&!s&&!u&&!m&&!o?a:/* @__PURE__ */ r.createElement(`div`,{className:i(`form-field`,o),ref:f},d&&/* @__PURE__ */ r.createElement(n,{htmlFor:c.input,id:c.label},d),a,s&&/* @__PURE__ */ r.createElement(t,{id:c.help},s),h&&/* @__PURE__ */ r.createElement(e,{id:c.feedback,invalid:!0},u),g&&/* @__PURE__ */ r.createElement(e,{id:c.feedback,valid:!0},m))};export{a as t};
|
|
2
|
+
//# sourceMappingURL=renderFormField-_6WswnEX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderFormField-_6WswnEX.js","names":["FormFeedback","FormLabel","React","classNames","renderFormField","showInvalidFeedback","invalid","invalidFeedback","showValidFeedback","valid","validFeedback","label","help","className","children","ids","FormHelp"],"sources":["../../src/components/form-field/renderFormField.tsx"],"sourcesContent":["import React, { ReactNode, Ref } from 'react'\nimport classNames from 'classnames'\n\nimport { FormFeedback } from '../form/FormFeedback'\nimport { FormHelp } from '../form/FormHelp'\nimport { FormLabel } from '../form/FormLabel'\n\nexport interface FormFieldIds {\n feedback?: string\n help?: string\n input?: string\n /**\n * The label's own id, for controls with no single input to associate via `htmlFor` (e.g. a\n * multi-input group) — reference it from the control's own `aria-labelledby` instead.\n */\n label?: string\n}\n\nexport interface RenderFormFieldOptions {\n children: ReactNode\n className?: string\n help?: ReactNode\n ids?: FormFieldIds\n invalid?: boolean\n invalidFeedback?: ReactNode\n label?: ReactNode\n ref?: Ref<HTMLDivElement>\n valid?: boolean\n validFeedback?: ReactNode\n}\n\n// Shared `.form-field` grid wrapper for label/control/help/feedback — see\n// https://chassis-ui.com/css/docs/forms/form-field. Renders `children` bare when none of\n// label/help/validFeedback/invalidFeedback are set, so field-capable leaves stay drop-in\n// compatible until a consumer opts into the wrapping.\nexport const renderFormField = ({\n children,\n className,\n help,\n ids = {},\n invalid,\n invalidFeedback,\n label,\n ref,\n valid,\n validFeedback\n}: RenderFormFieldOptions): ReactNode => {\n // At most one feedback node renders, and `invalid` wins: both carry the same `ids.feedback`,\n // so rendering the pair (which `invalid` + `valid` set together used to do) put a duplicate id\n // in the DOM and left every control's `aria-describedby` pointing at an ambiguous target —\n // axe's `duplicate-id-aria`. `useFormField` only ever budgets one feedback id for the same\n // reason. Contradictory state, but nothing in the types rules it out and ten components route\n // through here.\n const showInvalidFeedback = Boolean(invalid && invalidFeedback)\n const showValidFeedback = Boolean(valid && validFeedback) && !showInvalidFeedback\n\n // `className` alone is enough to warrant the wrapper: it has nowhere else to land, and\n // returning `children` bare (the drop-in-compatibility path every field-capable leaf relies on\n // until a consumer opts into wrapping) silently dropped it. Only `FormField` — the standalone\n // \"wrap this yourself\" component — passes one, so this is exactly the case where the caller\n // asked for a `.form-field` element by hand.\n // Feedback that is given wraps the control whether or not it shows: a control whose validity\n // changes while it has focus (a `TimeField` typed out of its range) was otherwise moved into\n // the new wrapper, which remounts it, and focus fell to the page.\n if (!label && !help && !invalidFeedback && !validFeedback && !className) {\n return children\n }\n\n return (\n <div className={classNames('form-field', className)} ref={ref}>\n {label && (\n <FormLabel htmlFor={ids.input} id={ids.label}>\n {label}\n </FormLabel>\n )}\n {children}\n {help && <FormHelp id={ids.help}>{help}</FormHelp>}\n {showInvalidFeedback && (\n <FormFeedback id={ids.feedback} invalid>\n {invalidFeedback}\n </FormFeedback>\n )}\n {showValidFeedback && (\n <FormFeedback id={ids.feedback} valid>\n {validFeedback}\n </FormFeedback>\n )}\n </div>\n )\n}\n"],"mappings":"A,wIAmCA,MAAaI,GAAmB,CAC9B,WACA,YACA,OACA,MAAM,CAAC,EACP,UACA,kBACA,QACA,MACA,QACA,mBACuC,CAOvC,IAAMC,EAAsB,GAAQC,GAAWC,GACzCC,EAAoB,GAAQC,GAASC,IAAkB,CAACL,EAc9D,MAJI,CAACM,GAAS,CAACC,GAAQ,CAACL,GAAmB,CAACG,GAAiB,CAACG,EACrDC,EAIP,kBAAA,cAAC,MAAD,CAAK,UAAWX,EAAW,aAAcU,CAAS,EAAQ,KAkBrD,EAjBFF,GACC,kBAAA,cAACV,EAAD,CAAW,QAASc,EAAI,MAAO,GAAIA,EAAI,KAE5B,EADRJ,CACQ,EAEZG,EACAF,GAAQ,kBAAA,cAACI,EAAD,CAAU,GAAID,EAAI,IAAsB,EAAfH,CAAe,EAChDP,GACC,kBAAA,cAACL,EAAD,CAAc,GAAIe,EAAI,SAAU,QAAA,EAElB,EADXR,CACW,EAEfC,GACC,kBAAA,cAACR,EAAD,CAAc,GAAIe,EAAI,SAAU,MAAA,EAElB,EADXL,CACW,CAEb,CAET,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{t as e}from"./iconSlot-DU_WcSL_.js";import t from"react";const n=({icon:n,label:r,description:i,selected:a})=>n==null&&i==null&&!a?r:/* @__PURE__ */ t.createElement(t.Fragment,null,n!=null&&/* @__PURE__ */ t.createElement(`span`,{className:`menu-item-icon`,"aria-hidden":`true`},n),i==null?r:/* @__PURE__ */ t.createElement(`span`,{className:`menu-item-content`},/* @__PURE__ */ t.createElement(`span`,null,r),/* @__PURE__ */ t.createElement(`small`,{className:`menu-item-description`},i)),a&&/* @__PURE__ */ t.createElement(e,{icon:`check`,className:`menu-item-check`}));export{n as t};
|
|
2
|
+
//# sourceMappingURL=renderMenuItemContent-DNdj-Ukz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderMenuItemContent-DNdj-Ukz.js","names":["IconSlot","React","renderMenuItemContent","icon","description","selected","label"],"sources":["../../src/components/menu/renderMenuItemContent.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\n\nimport { IconSlot } from '../icon/iconSlot'\n\nexport interface MenuItemContentDef {\n /**\n * Icon rendered at the item's leading edge (`.menu-item-icon`).\n */\n icon?: ReactNode\n /**\n * Label content.\n */\n label: ReactNode\n /**\n * Secondary line of text rendered below the label (`.menu-item-description`).\n */\n description?: ReactNode\n /**\n * Renders a `.menu-item-check` at the trailing edge when true — `IconProvider`'s `check` icon.\n */\n selected?: boolean\n}\n\n// Chassis-css defines identical markup for rich item content in both Menu and Combobox items\n// (and, by extension, Autocomplete) — `.menu-item-icon` / `.menu-item-content` (label +\n// `.menu-item-description`) / `.menu-item-check`. Shared here so every consumer produces\n// byte-identical DOM instead of three near-duplicate implementations. Lives in `utils/` rather\n// than `components/menu/` because it crosses that folder boundary — Combobox.tsx and\n// Autocomplete.tsx both import it too. Renders bare `label` when there's nothing else to show,\n// keeping simple items' markup as minimal as chassis-css's own simplest example.\nexport const renderMenuItemContent = ({\n icon,\n label,\n description,\n selected\n}: MenuItemContentDef): ReactNode => {\n if (icon == null && description == null && !selected) return label\n\n return (\n <>\n {icon != null && (\n <span className=\"menu-item-icon\" aria-hidden=\"true\">\n {icon}\n </span>\n )}\n {description != null ? (\n <span className=\"menu-item-content\">\n <span>{label}</span>\n <small className=\"menu-item-description\">{description}</small>\n </span>\n ) : (\n label\n )}\n {selected && <IconSlot icon=\"check\" className=\"menu-item-check\" />}\n </>\n )\n}\n"],"mappings":"A,gEA8BA,MAAaE,GAAyB,CACpC,OACA,QACA,cACA,cAEIC,GAAQ,MAAQC,GAAe,MAAQ,CAACC,EAAiBC,EAG3D,kBAAA,cAAAL,EAAA,SAAA,KACGE,GAAQ,MACP,kBAAA,cAAC,OAAD,CAAM,UAAU,iBAAiB,cAAY,MAEvC,EADHA,CACG,EAEPC,GAAe,KAMdE,EALA,kBAAA,cAAC,OAAD,CAAM,UAAU,mBAGV,EAFJ,kBAAA,cAAC,OAAA,KAAMA,CAAY,EACnB,kBAAA,cAAC,QAAD,CAAO,UAAU,uBAA4C,EAAnBF,CAAmB,CACzD,EAIPC,GAAY,kBAAA,cAACL,EAAD,CAAU,KAAK,QAAQ,UAAU,iBAAmB,CAAA,CACjE,E"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./scrollspy-D_lPjb92.js";import t,{useCallback as n,useEffect as r,useMemo as i,useRef as a,useState as o}from"react";function s(e){return e?`current`in e?e.current:e:null}function c(e,t){let n=document.getElementById(e);return!n||t&&!t.contains(n)?null:n}function l(e,t){return e?e.endsWith(`%`)?Number.parseFloat(e)/100*t:Number.parseFloat(e)||0:0}function u(e,t){let n,r;e?(n=e.getBoundingClientRect().top+e.clientTop,r=e.clientHeight):(n=0,r=document.documentElement.clientHeight);let i=t.trim().split(/\s+/),a=i[0],o=i.length>=3?i[2]:i[0];return{top:n-l(a,r),bottom:n+r+l(o,r)}}function d(e){let t=e??document.scrollingElement??document.documentElement;return t.scrollTop>0&&t.scrollTop+t.clientHeight>=t.scrollHeight-1}function f(e,t,n){let r=null,i=null,a=!1;for(let o of e){let e=o.getBoundingClientRect();(e.width!==0||e.height!==0)&&(n?i=o.id:e.top>=t.bottom||(r===null&&(r=o.id,a=e.top>=t.top),i=o.id))}return a?{id:r,atStart:a}:{id:i,atStart:a}}function p(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function m(e,t={}){let{root:n,rootMargin:i=`0px 0px -25%`}=t,[a,l]=o(null),m=e.join(`\0`),[h,g]=o(0);return r(()=>{let e=m?m.split(`\0`):[];if(!e.length||typeof IntersectionObserver>`u`){l(null);return}let t=s(n),r=t??window,a=[],o=!1,h=!1,_=()=>{h=d(t);let{id:e,atStart:n}=f(a,u(t,i),h);l(e),o=n},v=0,y=()=>{v||=requestAnimationFrame(()=>{v=0,(o||d(t)!==h)&&_()})};r.addEventListener(`scroll`,y,{passive:!0});let b=new IntersectionObserver(_,{root:t,rootMargin:i,threshold:[0,1]}),x=()=>{let n=e.map(e=>c(e,t)).filter(e=>e!==null).sort(p);if(n.length===a.length&&n.every((e,t)=>e===a[t]))return!1;for(let e of a)n.includes(e)||b.unobserve(e);for(let e of n)a.includes(e)||b.observe(e);return a=n,!0};x()||_();let S=0,C=new MutationObserver(()=>{S||=requestAnimationFrame(()=>{S=0,s(n)===t?x()&&_():g(e=>e+1)})});return C.observe(document.body,{attributeFilter:[`id`],childList:!0,subtree:!0}),r.addEventListener(`scrollend`,_),()=>{b.disconnect(),C.disconnect(),cancelAnimationFrame(S),cancelAnimationFrame(v),r.removeEventListener(`scrollend`,_),r.removeEventListener(`scroll`,y)}},[m,n,i,h]),a}function h(e){let t=e.getAttribute(`href`);if(!t||!t.includes(`#`))return null;let n;try{n=new URL(t,document.baseURI)}catch{return null}let r=new URL(window.location.href);if(n.origin!==r.origin||n.pathname!==r.pathname||n.search!==r.search||n.hash.length<2)return null;try{return decodeURIComponent(n.hash.slice(1))}catch{return n.hash.slice(1)}}function g(e){let t=[],n=/* @__PURE__ */ new Set([e]),r=[e];for(;r.length;){let e=r.shift(),i,a=e.classList.contains(`menu-item`)?e.closest(`.menu`):null;if(a){let e=a.getAttribute(`aria-labelledby`);i=e&&document.getElementById(e)||a.previousElementSibling||null}else{let t=e.parentElement?.closest(`.nav, .list`)?.previousElementSibling??null;for(;t&&!t.matches(`.nav-link, .list-item`);)t=t.previousElementSibling;i=t}i&&!n.has(i)&&(n.add(i),t.push(i),r.push(i))}return t}function _(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function v(e,t){let n=_()?`auto`:`smooth`,r=Number.parseFloat(getComputedStyle(e).scrollMarginTop)||0,i=Number.parseFloat(getComputedStyle(t??document.documentElement).scrollPaddingTop)||0,a=e.getBoundingClientRect().top-r-i;if(t){let e=a-t.getBoundingClientRect().top-t.clientTop+t.scrollTop;t.scrollTo({top:e,behavior:n})}else window.scrollTo({top:a+window.scrollY,behavior:n})}function y({children:l,onActiveChange:u,root:d,rootMargin:f,smoothScroll:p=!1}){let _=a(/* @__PURE__ */ new Map),[y,b]=o(0),[x,S]=o([]),C=n((e,t)=>{_.current.set(e,t),b(e=>e+1);let n=new MutationObserver(()=>b(e=>e+1));return n.observe(e,{attributeFilter:[`href`]}),()=>{n.disconnect(),_.current.delete(e),t(!1),b(e=>e+1)}},[]);r(()=>{let e=[];for(let t of _.current.keys()){let n=h(t);n!==null&&!e.includes(n)&&e.push(n)}S(t=>t.length===e.length&&t.every((t,n)=>t===e[n])?t:e)},[y]);let w=m(x,{root:d,rootMargin:f});r(()=>{let e=/* @__PURE__ */ new Map;if(w!==null){for(let t of _.current.keys())h(t)===w&&e.set(t,`current`);for(let t of[...e.keys()])for(let n of g(t))_.current.has(n)&&!e.has(n)&&e.set(n,`parent`)}for(let[t,n]of _.current)n(e.get(t)??!1)},[w,y]);let T=a(u),E=a(null);r(()=>{T.current=u}),r(()=>{E.current!==w&&(E.current=w,T.current?.(w))},[w]);let D=a({root:d,smoothScroll:p});r(()=>{D.current={root:d,smoothScroll:p}});let O=n(e=>{let{root:t,smoothScroll:n}=D.current;if(!n||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let r=h(e.currentTarget),i=s(t),a=r===null?null:c(r,i);a&&(e.preventDefault(),v(a,i))},[]),k=i(()=>({register:C,onLinkClick:O}),[C,O]);return/* @__PURE__ */ t.createElement(e.Provider,{value:k},l)}y.displayName=`Scrollspy`;export{m as n,y as t};
|
|
2
|
+
//# sourceMappingURL=scrollspy-BEZEVyIw.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scrollspy-BEZEVyIw.js","names":["ScrollspyContext","React","resolveRoot","root","findSection","section","id","marginLength","value","height","activationZone","top","values","rootMargin","marginTop","marginBottom","isAtScrollEnd","scroller","pickActive","first","last","atStart","sections","rect","atEnd","zone","inDocumentOrder","a","b","useScrollspy","options","activeId","setActiveId","useState","key","ids","generation","setGeneration","useEffect","idList","rootElement","followingScroll","update","scrollFrame","onScroll","observer","resolve","next","i","mutationFrame","mutations","linkTarget","href","element","url","page","parentsOf","parents","seen","queue","current","parent","menu","labelledBy","sibling","prefersReducedMotion","scrollToSection","behavior","margin","padding","offset","Scrollspy","links","useRef","version","setVersion","setIds","register","useCallback","setMark","targetChanges","previous","marks","onActiveChangeRef","onActiveChange","reportedRef","optionsRef","onLinkClick","smoothScroll","event","controller","useMemo","children"],"sources":["../../src/components/scrollspy/useScrollspy.ts","../../src/components/scrollspy/Scrollspy.tsx"],"sourcesContent":["import { RefObject, useEffect, useState } from 'react'\n\nexport interface UseScrollspyOptions {\n /**\n * The element that scrolls, or a ref to it. The viewport when unset.\n */\n root?: Element | RefObject<Element | null> | null\n /**\n * The margin around `root`, as `IntersectionObserver` takes it: one to four lengths in `px` or\n * `%`. Its bottom edge is the line a section's top has to pass to become the active one;\n * `-25%` puts it a quarter of the root's height above the root's bottom.\n *\n * @default '0px 0px -25%'\n */\n rootMargin?: string\n}\n\nexport const DEFAULT_ROOT_MARGIN = '0px 0px -25%'\n\n/**\n * The element `root` names: the element itself, or what a ref holds. `null` for the viewport.\n */\nexport function resolveRoot(root: UseScrollspyOptions['root']): Element | null {\n if (!root) return null\n return 'current' in root ? root.current : root\n}\n\n/**\n * The section with this `id`, when it is inside `root` (anywhere in the document for the\n * viewport).\n */\nexport function findSection(id: string, root: Element | null): HTMLElement | null {\n const section = document.getElementById(id)\n if (!section || (root && !root.contains(section))) return null\n return section\n}\n\ninterface Zone {\n top: number\n bottom: number\n}\n\n// A length of `rootMargin`: `px`, or `%` of the root's height.\nfunction marginLength(value: string | undefined, height: number): number {\n if (!value) return 0\n if (value.endsWith('%')) return (Number.parseFloat(value) / 100) * height\n return Number.parseFloat(value) || 0\n}\n\n// The root's box grown by `rootMargin` (shrunk, for negative lengths), in viewport coordinates:\n// the box an `IntersectionObserver` with the same options observes. A section's top crosses its\n// bottom edge, the activation line, exactly when the section starts or stops intersecting from\n// below, so the observer reports it.\nfunction activationZone(root: Element | null, rootMargin: string): Zone {\n let top: number\n let height: number\n if (root) {\n // The root's padding box: what an observer with an element root clips to.\n top = root.getBoundingClientRect().top + root.clientTop\n height = root.clientHeight\n } else {\n top = 0\n height = document.documentElement.clientHeight\n }\n const values = rootMargin.trim().split(/\\s+/)\n const marginTop = values[0]\n const marginBottom = values.length >= 3 ? values[2] : values[0]\n return {\n top: top - marginLength(marginTop, height),\n bottom: top + height + marginLength(marginBottom, height)\n }\n}\n\n// Whether `root` (the viewport for `null`) has been scrolled as far down as it goes. One that\n// doesn't scroll at all is at its start, not its end. A pixel short counts: a zoomed page stops\n// on a fraction.\nfunction isAtScrollEnd(root: Element | null): boolean {\n const scroller = root ?? document.scrollingElement ?? document.documentElement\n return (\n scroller.scrollTop > 0 &&\n scroller.scrollTop + scroller.clientHeight >= scroller.scrollHeight - 1\n )\n}\n\ninterface Pick {\n id: string | null\n /**\n * The first section is active because its top is still in the zone. Leaving that state is a\n * scroll the observer doesn't always report (see `useScrollspy`).\n */\n atStart: boolean\n}\n\n/**\n * The id of the last section, in document order, whose top has passed the activation line, or\n * `null` when none has. While the first of those hasn't scrolled past the top of the zone, the\n * reader is at its start, and it is the active one: at the top of a page of short sections,\n * several have passed the line before anything scrolled. At the end of the scroll (`atEnd`) the\n * last section is the active one wherever its top is: one shorter than what lies below the line\n * never brings its top past it, and the links stopped one short of the end of the page. A\n * section that isn't rendered (`display: none`) takes no part.\n */\nfunction pickActive(sections: readonly HTMLElement[], zone: Zone, atEnd: boolean): Pick {\n let first: string | null = null\n let last: string | null = null\n let atStart = false\n for (const section of sections) {\n const rect = section.getBoundingClientRect()\n if (rect.width === 0 && rect.height === 0) continue\n if (atEnd) {\n last = section.id\n continue\n }\n if (rect.top >= zone.bottom) continue\n if (first === null) {\n first = section.id\n atStart = rect.top >= zone.top\n }\n last = section.id\n }\n return atStart ? { id: first, atStart } : { id: last, atStart }\n}\n\nfunction inDocumentOrder(a: Node, b: Node): number {\n return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1\n}\n\n// A separator no id contains, to depend on the ids' values rather than the array's identity.\nconst SEPARATOR = '\\u0000'\n\n/**\n * Tracks which of the sections named by `ids` the reader is in, as a scrollspy does: the last\n * section, in document order, whose top has scrolled past a line near the bottom of `root` (set\n * by `rootMargin`), or the first one while its top is still in view at the top of `root`, or the\n * last one once `root` is scrolled to its end. Returns its id, or `null` when no section has\n * reached the line yet.\n *\n * It returns `null` on the server and on the first render in the browser, so hydration matches,\n * and the active id from the first observation after that. Sections added, removed or renamed\n * later are picked up; an id with no element in `root` is ignored.\n */\nexport function useScrollspy(\n ids: readonly string[],\n options: UseScrollspyOptions = {}\n): string | null {\n const { root, rootMargin = DEFAULT_ROOT_MARGIN } = options\n const [activeId, setActiveId] = useState<string | null>(null)\n const key = ids.join(SEPARATOR)\n // Bumped when `root` names another element than the one observed: a ref's element can mount\n // after the hook's effect ran, or be replaced, without anything rendering the hook again.\n const [generation, setGeneration] = useState(0)\n\n useEffect(() => {\n const idList = key ? key.split(SEPARATOR) : []\n if (!idList.length || typeof IntersectionObserver === 'undefined') {\n setActiveId(null)\n return\n }\n const rootElement = resolveRoot(root)\n const scroller: EventTarget = rootElement ?? window\n let sections: HTMLElement[] = []\n let followingScroll = false\n let atEnd = false\n\n const update = () => {\n atEnd = isAtScrollEnd(rootElement)\n const { id, atStart } = pickActive(sections, activationZone(rootElement, rootMargin), atEnd)\n setActiveId(id)\n // The first section stops being active when its top leaves the top of the zone. The\n // observer reports that only for a section that was wholly inside the zone (its threshold\n // of 1), which a section holding the others, or wider than the root, never is. So while\n // it is active for that reason, every scroll measures again.\n followingScroll = atStart\n }\n\n // Arriving at the end of the scroll, and leaving it, move no section across the line, so\n // the observer reports neither: each scroll reads where the scroller is, three numbers, and\n // measures the sections only when that changed or while the first section is followed.\n let scrollFrame = 0\n const onScroll = () => {\n if (scrollFrame) return\n scrollFrame = requestAnimationFrame(() => {\n scrollFrame = 0\n if (followingScroll || isAtScrollEnd(rootElement) !== atEnd) update()\n })\n }\n scroller.addEventListener('scroll', onScroll, { passive: true })\n\n // Called for every change of an intersection. The entries alone aren't enough: a section\n // that a jump scrolls from below the root to above it never intersects, and isn't reported.\n // So every section is measured again. A threshold of 1 also reports a section that starts\n // leaving the top of the zone, which ends the start of the first one (see `pickActive`).\n const observer = new IntersectionObserver(update, {\n root: rootElement,\n rootMargin,\n threshold: [0, 1]\n })\n\n // Returns whether the sections changed.\n const resolve = () => {\n const next = idList\n .map((id) => findSection(id, rootElement))\n .filter((section): section is HTMLElement => section !== null)\n .sort(inDocumentOrder)\n if (next.length === sections.length && next.every((section, i) => section === sections[i])) {\n return false\n }\n for (const section of sections) if (!next.includes(section)) observer.unobserve(section)\n for (const section of next) if (!sections.includes(section)) observer.observe(section)\n sections = next\n return true\n }\n\n // The observer reports each section once when it starts observing it, which sets the first\n // active id. With no section found, nothing would report, so that case updates here.\n if (!resolve()) update()\n\n // Sections rendered, removed or renamed later, such as content loaded after the links, and\n // a `root` ref whose element mounts later or is replaced. The whole document is watched, since\n // a replaced root is no longer in the one observed.\n let mutationFrame = 0\n const mutations = new MutationObserver(() => {\n if (mutationFrame) return\n mutationFrame = requestAnimationFrame(() => {\n mutationFrame = 0\n if (resolveRoot(root) !== rootElement) {\n setGeneration((value) => value + 1)\n return\n }\n if (resolve()) update()\n })\n })\n mutations.observe(document.body, {\n attributeFilter: ['id'],\n childList: true,\n subtree: true\n })\n\n // What a jump between two places with no section in view leaves out: nothing intersects\n // before or after it, so the observer has nothing to report. Where `scrollend` exists, the\n // end of every scroll measures again.\n scroller.addEventListener('scrollend', update)\n\n return () => {\n observer.disconnect()\n mutations.disconnect()\n cancelAnimationFrame(mutationFrame)\n cancelAnimationFrame(scrollFrame)\n scroller.removeEventListener('scrollend', update)\n scroller.removeEventListener('scroll', onScroll)\n }\n }, [key, root, rootMargin, generation])\n\n return activeId\n}\n","import React, {\n MouseEvent,\n ReactElement,\n ReactNode,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n useState\n} from 'react'\n\nimport { ScrollspyContext, ScrollspyController, ScrollspyMark } from '../../utils/scrollspy'\nimport { findSection, resolveRoot, useScrollspy, UseScrollspyOptions } from './useScrollspy'\n\nexport interface ScrollspyProps extends UseScrollspyOptions {\n /**\n * The navigation whose links are marked: a `Nav`, a `List`, `Link`s, or anything holding them.\n */\n children?: ReactNode\n /**\n * Fires when the active section changes, with its id, or `null` when no section is active.\n */\n onActiveChange?: (id: string | null) => void\n /**\n * Scrolls smoothly to a section when one of the links is clicked, instead of jumping to it. The\n * page's address doesn't change. When the reader asks for reduced motion, it jumps.\n *\n * @default false\n */\n smoothScroll?: boolean\n}\n\n// The section a link points to: its fragment, when it points into the current page.\nfunction linkTarget(element: Element): string | null {\n const href = element.getAttribute('href')\n if (!href || !href.includes('#')) return null\n let url: URL\n try {\n url = new URL(href, document.baseURI)\n } catch {\n // Not a URL a browser could follow either, such as `http://#top`.\n return null\n }\n const page = new URL(window.location.href)\n if (url.origin !== page.origin || url.pathname !== page.pathname || url.search !== page.search) {\n return null\n }\n if (url.hash.length < 2) return null\n try {\n return decodeURIComponent(url.hash.slice(1))\n } catch {\n return url.hash.slice(1)\n }\n}\n\nconst LIST = '.nav, .list'\nconst LIST_LINK = '.nav-link, .list-item'\n\n// The links a marked link belongs under, as chassis-css's plugin finds them: the toggle of the\n// menu a menu item is in, and the link just before a nested `.nav` or `.list`. Each of those is\n// followed up in turn, so every level of a nested navigation is marked.\nfunction parentsOf(element: Element): Element[] {\n const parents: Element[] = []\n const seen = new Set<Element>([element])\n const queue = [element]\n while (queue.length) {\n const current = queue.shift() as Element\n let parent: Element | null\n const menu = current.classList.contains('menu-item') ? current.closest('.menu') : null\n if (menu) {\n // A `Menu`'s list is labelled by its toggle, wherever the list is rendered.\n const labelledBy = menu.getAttribute('aria-labelledby')\n parent =\n (labelledBy && document.getElementById(labelledBy)) || menu.previousElementSibling || null\n } else {\n const list = current.parentElement?.closest(LIST)\n let sibling = list?.previousElementSibling ?? null\n while (sibling && !sibling.matches(LIST_LINK)) sibling = sibling.previousElementSibling\n parent = sibling\n }\n if (parent && !seen.has(parent)) {\n seen.add(parent)\n parents.push(parent)\n queue.push(parent)\n }\n }\n return parents\n}\n\nfunction prefersReducedMotion(): boolean {\n return (\n typeof window.matchMedia === 'function' &&\n window.matchMedia('(prefers-reduced-motion: reduce)').matches\n )\n}\n\n// Where a section lands, as a jump to it would put it: below the scroll container's\n// `scroll-padding-top` (a sticky header's usual fix) and the section's own `scroll-margin-top`.\nfunction scrollToSection(section: HTMLElement, root: Element | null) {\n const behavior: ScrollBehavior = prefersReducedMotion() ? 'auto' : 'smooth'\n const margin = Number.parseFloat(getComputedStyle(section).scrollMarginTop) || 0\n const padding =\n Number.parseFloat(getComputedStyle(root ?? document.documentElement).scrollPaddingTop) || 0\n const offset = section.getBoundingClientRect().top - margin - padding\n if (root) {\n const top = offset - root.getBoundingClientRect().top - root.clientTop + root.scrollTop\n root.scrollTo({ top, behavior })\n } else {\n window.scrollTo({ top: offset + window.scrollY, behavior })\n }\n}\n\n/**\n * Marks the link to the section being read as active, in the navigation it wraps. The links are\n * `Link`s and the components built on it (`NavLink`, `ListItem`, `MenuItem`) whose `href` points\n * to an element's `id` on the page. It renders no element of its own.\n */\nexport function Scrollspy({\n children,\n onActiveChange,\n root,\n rootMargin,\n smoothScroll = false\n}: ScrollspyProps): ReactElement {\n const links = useRef(new Map<Element, (mark: ScrollspyMark) => void>())\n // Bumped when a link comes or goes, which changes the sections to observe and the marks.\n const [version, setVersion] = useState(0)\n const [ids, setIds] = useState<string[]>([])\n\n const register = useCallback<ScrollspyController['register']>((element, setMark) => {\n links.current.set(element, setMark)\n setVersion((value) => value + 1)\n // A link's target can change without its component rendering with another `href`: the\n // element given with `asChild` has it, and a router link renders it from `to`.\n const targetChanges = new MutationObserver(() => setVersion((value) => value + 1))\n targetChanges.observe(element, { attributeFilter: ['href'] })\n return () => {\n targetChanges.disconnect()\n links.current.delete(element)\n setMark(false)\n setVersion((value) => value + 1)\n }\n }, [])\n\n // The targets are read from the elements, which is where a link given with `asChild` or a\n // router link has its `href`.\n useEffect(() => {\n const next: string[] = []\n for (const element of links.current.keys()) {\n const id = linkTarget(element)\n if (id !== null && !next.includes(id)) next.push(id)\n }\n setIds((previous) =>\n previous.length === next.length && previous.every((id, i) => id === next[i]) ? previous : next\n )\n }, [version])\n\n const activeId = useScrollspy(ids, { root, rootMargin })\n\n useEffect(() => {\n const marks = new Map<Element, ScrollspyMark>()\n if (activeId !== null) {\n for (const element of links.current.keys()) {\n if (linkTarget(element) === activeId) marks.set(element, 'current')\n }\n for (const element of [...marks.keys()]) {\n for (const parent of parentsOf(element)) {\n if (links.current.has(parent) && !marks.has(parent)) marks.set(parent, 'parent')\n }\n }\n }\n for (const [element, setMark] of links.current) setMark(marks.get(element) ?? false)\n }, [activeId, version])\n\n const onActiveChangeRef = useRef(onActiveChange)\n const reportedRef = useRef<string | null>(null)\n useEffect(() => {\n onActiveChangeRef.current = onActiveChange\n })\n useEffect(() => {\n if (reportedRef.current === activeId) return\n reportedRef.current = activeId\n onActiveChangeRef.current?.(activeId)\n }, [activeId])\n\n const optionsRef = useRef({ root, smoothScroll })\n useEffect(() => {\n optionsRef.current = { root, smoothScroll }\n })\n\n const onLinkClick = useCallback((event: MouseEvent<Element>) => {\n const { root, smoothScroll } = optionsRef.current\n if (\n !smoothScroll ||\n event.defaultPrevented ||\n event.button !== 0 ||\n event.metaKey ||\n event.ctrlKey ||\n event.shiftKey ||\n event.altKey\n ) {\n return\n }\n const id = linkTarget(event.currentTarget)\n const rootElement = resolveRoot(root)\n const section = id === null ? null : findSection(id, rootElement)\n if (!section) return\n event.preventDefault()\n scrollToSection(section, rootElement)\n }, [])\n\n const controller = useMemo<ScrollspyController>(\n () => ({ register, onLinkClick }),\n [register, onLinkClick]\n )\n\n return <ScrollspyContext.Provider value={controller}>{children}</ScrollspyContext.Provider>\n}\n\nScrollspy.displayName = 'Scrollspy'\n"],"mappings":"A,0KAsBA,SAAgBE,EAAY,EAAmD,CAE7E,OADKC,EACE,YAAaA,EAAOA,EAAK,QAAUA,EADxB,IAEpB,CAMA,SAAgBC,EAAY,EAAY,EAA0C,CAChF,IAAMC,EAAU,SAAS,eAAeC,CAAE,EAE1C,MADI,CAACD,GAAYF,GAAQ,CAACA,EAAK,SAASE,CAAO,EAAW,KACnDA,CACT,CAQA,SAASE,EAAa,EAA2B,EAAwB,CAGvE,OAFKC,EACDA,EAAM,SAAS,GAAG,EAAW,OAAO,WAAWA,CAAK,EAAI,IAAOC,EAC5D,OAAO,WAAWD,CAAK,GAAK,EAFhB,CAGrB,CAMA,SAASE,EAAe,EAAsB,EAA0B,CACtE,IAAIC,EACAF,EACAN,GAEF,EAAMA,EAAK,sBAAsB,CAAC,CAAC,IAAMA,EAAK,UAC9C,EAASA,EAAK,eAEd,EAA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qB,EAAM,IAAIrB,EAAQ,QAAQ,CAGrF,CACA,IAAK,GAAM,CAACR,EAAS0B,KAAYP,EAAM,QAASO,EAAQG,EAAM,IAAI7B,CAAO,GAAK,EAAK,CACrF,EAAG,CAACtB,EAAU2C,CAAO,CAAC,EAEtB,IAAMS,EAAoBV,EAAOW,CAAc,EACzCC,EAAcZ,EAAsB,IAAI,EAC9CnC,MAAgB,CACd,EAAkB,QAAU8C,CAC9B,CAAC,EACD9C,MAAgB,CACV+C,EAAY,UAAYtD,IAC5B,EAAY,QAAUA,EACtBoD,EAAkB,UAAUpD,CAAQ,EACtC,EAAG,CAACA,CAAQ,CAAC,EAEb,IAAMuD,EAAab,EAAO,CAAE,OAAM,cAAa,CAAC,EAChDnC,MAAgB,CACd,EAAW,QAAU,CAAE,OAAM,cAAa,CAC5C,CAAC,EAED,IAAMiD,EAAcT,EAAa,GAA+B,CAC9D,GAAM,CAAE,OAAM,gBAAiBQ,EAAW,QAC1C,GACE,CAACE,GACDC,EAAM,kBACNA,EAAM,SAAW,GACjBA,EAAM,SACNA,EAAM,SACNA,EAAM,UACNA,EAAM,OAEN,OAEF,IAAMnF,EAAK6C,EAAWsC,EAAM,aAAa,EACnCjD,EAActC,EAAYC,CAAI,EAC9BE,EAAUC,IAAO,KAAO,KAAOF,EAAYE,EAAIkC,CAAW,EAC3DnC,IACLoF,EAAM,eAAe,EACrBvB,EAAgB7D,EAASmC,CAAW,EACtC,EAAG,CAAC,CAAC,EAECkD,EAAaC,OACV,CAAE,WAAU,aAAY,GAC/B,CAACd,EAAUU,CAAW,CACxB,EAEA,MAAO,kBAAA,cAACvF,EAAiB,SAAlB,CAA2B,MAAO0F,CAAiD,EAApCE,CAAoC,CAC5F,CAEA,EAAU,YAAc,Y"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrollspy-D_lPjb92.js","names":[],"sources":["../../src/utils/scrollspy.ts"],"sourcesContent":["import { createContext, MouseEvent, RefCallback, useContext, useEffect, useState } from 'react'\n\n// How `Scrollspy` (`components/scrollspy`) and the links inside it work together.\n//\n// chassis-css's plugin finds the links in its target with a selector and toggles their `.active`\n// class. Here a link's markup belongs to React, so each `Link` inside a `Scrollspy` registers its\n// element and a setter instead, and renders the mark it is given. `NavLink`, `ListItem` and\n// `MenuItem` render through `Link`, so they take part without code of their own; so does a\n// `MenuToggle` rendered as a `NavLink`, which is marked as the parent of its menu's items.\n//\n// This lives here, not in `components/scrollspy`, so that `Link` imports a context and a hook and\n// nothing else: the observer and the rest stay out of the bundle of a page with no `Scrollspy`.\n\n/**\n * What a link shows: `'current'` for a link to the active section, `'parent'` for the link its\n * nested list or menu belongs to, `false` for any other.\n */\nexport type ScrollspyMark = 'current' | 'parent' | false\n\nexport interface ScrollspyController {\n /**\n * Adds a link's element. Returns the function that removes it.\n */\n register: (element: Element, setMark: (mark: ScrollspyMark) => void) => () => void\n /**\n * A link's click, after its own `onClick`: scrolls to the section smoothly, when the\n * `Scrollspy` is set to.\n */\n onLinkClick: (event: MouseEvent<Element>) => void\n}\n\nexport const ScrollspyContext = createContext<ScrollspyController | null>(null)\n\nexport interface ScrollspyLink {\n mark: ScrollspyMark\n /**\n * For the link's element, inside a `Scrollspy`.\n */\n ref?: RefCallback<Element>\n onClick?: (event: MouseEvent<Element>) => void\n}\n\n/**\n * A link's part in the nearest `Scrollspy`. Outside one, it returns no mark, no ref and no handler.\n * A disabled link takes no part, as under chassis-css's plugin. The `Scrollspy` reads the target\n * from the element, where a link given with `asChild` has it too, and follows it when it changes.\n */\nexport function useScrollspyLink(disabled: boolean | undefined): ScrollspyLink {\n const spy = useContext(ScrollspyContext)\n const [mark, setMark] = useState<ScrollspyMark>(false)\n const [element, setElement] = useState<Element | null>(null)\n\n useEffect(() => {\n if (!spy || !element || disabled) return\n return spy.register(element, setMark)\n }, [spy, element, disabled])\n\n if (!spy) return { mark: false }\n return { mark: disabled ? false : mark, ref: setElement, onClick: spy.onLinkClick }\n}\n"],"mappings":"mFA+BA,
|
|
1
|
+
{"version":3,"file":"scrollspy-D_lPjb92.js","names":["ScrollspyContext","createContext","useScrollspyLink","spy","useContext","mark","setMark","useState","element","setElement","useEffect","disabled"],"sources":["../../src/utils/scrollspy.ts"],"sourcesContent":["import { createContext, MouseEvent, RefCallback, useContext, useEffect, useState } from 'react'\n\n// How `Scrollspy` (`components/scrollspy`) and the links inside it work together.\n//\n// chassis-css's plugin finds the links in its target with a selector and toggles their `.active`\n// class. Here a link's markup belongs to React, so each `Link` inside a `Scrollspy` registers its\n// element and a setter instead, and renders the mark it is given. `NavLink`, `ListItem` and\n// `MenuItem` render through `Link`, so they take part without code of their own; so does a\n// `MenuToggle` rendered as a `NavLink`, which is marked as the parent of its menu's items.\n//\n// This lives here, not in `components/scrollspy`, so that `Link` imports a context and a hook and\n// nothing else: the observer and the rest stay out of the bundle of a page with no `Scrollspy`.\n\n/**\n * What a link shows: `'current'` for a link to the active section, `'parent'` for the link its\n * nested list or menu belongs to, `false` for any other.\n */\nexport type ScrollspyMark = 'current' | 'parent' | false\n\nexport interface ScrollspyController {\n /**\n * Adds a link's element. Returns the function that removes it.\n */\n register: (element: Element, setMark: (mark: ScrollspyMark) => void) => () => void\n /**\n * A link's click, after its own `onClick`: scrolls to the section smoothly, when the\n * `Scrollspy` is set to.\n */\n onLinkClick: (event: MouseEvent<Element>) => void\n}\n\nexport const ScrollspyContext = createContext<ScrollspyController | null>(null)\n\nexport interface ScrollspyLink {\n mark: ScrollspyMark\n /**\n * For the link's element, inside a `Scrollspy`.\n */\n ref?: RefCallback<Element>\n onClick?: (event: MouseEvent<Element>) => void\n}\n\n/**\n * A link's part in the nearest `Scrollspy`. Outside one, it returns no mark, no ref and no handler.\n * A disabled link takes no part, as under chassis-css's plugin. The `Scrollspy` reads the target\n * from the element, where a link given with `asChild` has it too, and follows it when it changes.\n */\nexport function useScrollspyLink(disabled: boolean | undefined): ScrollspyLink {\n const spy = useContext(ScrollspyContext)\n const [mark, setMark] = useState<ScrollspyMark>(false)\n const [element, setElement] = useState<Element | null>(null)\n\n useEffect(() => {\n if (!spy || !element || disabled) return\n return spy.register(element, setMark)\n }, [spy, element, disabled])\n\n if (!spy) return { mark: false }\n return { mark: disabled ? false : mark, ref: setElement, onClick: spy.onLinkClick }\n}\n"],"mappings":"A,mFA+BA,MAAaA,EAAmBC,EAA0C,IAAI,EAgB9E,SAAgBC,EAAiB,EAA8C,CAC7E,IAAMC,EAAMC,EAAWJ,CAAgB,EACjC,CAACK,EAAMC,GAAWC,EAAwB,EAAK,EAC/C,CAACC,EAASC,GAAcF,EAAyB,IAAI,EAQ3D,OANAG,MAAgB,CACd,GAAKP,GAAQK,GAAW,GACxB,OAAOL,EAAI,SAASK,EAASF,CAAO,CACtC,EAAG,CAACH,EAAKK,EAASG,CAAQ,CAAC,EAEtBR,EACE,CAAE,KAAM,IAAmBE,EAAM,IAAKI,EAAY,QAASN,EAAI,WAAY,EADjE,CAAE,KAAM,EAAM,CAEjC,C"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import"./focus-ring-Bs80iIBN.js";import{t as e}from"./useForkedRef-WoqMqsWE.js";import{t}from"./useFormField-DH2tlc3e.js";import{t as n}from"./useHeldBack-eeTfpa_t.js";import{t as r}from"./iconSlot-DU_WcSL_.js";import{t as i}from"./renderFormField-_6WswnEX.js";import{t as a}from"./validationClassName-gRGs4KBm.js";import{r as o,t as s}from"./unhandledProps-9Kdj7WVf.js";import c,{forwardRef as l,useRef as u}from"react";import d from"classnames";import{mergeProps as f,useButton as p,useSearchField as m}from"react-aria";import{useSearchFieldState as h}from"react-stately";function g({ariaLabel:e,buttonProps:t,icon:n}){let i=u(null),{buttonProps:a}=p({...t,"aria-label":e??t[`aria-label`]},i);return/* @__PURE__ */ c.createElement(`button`,{...a,className:`button icon-only input-adorn search-field-clear`,ref:i},/* @__PURE__ */ c.createElement(r,{icon:`clear`,override:n}))}const _=l(({className:l,clearAriaLabel:p,clearIcon:_,defaultValue:v,disabled:y,help:b,id:x,invalid:S,invalidFeedback:C,label:w,onChange:T,onClear:E,onSubmit:D,readOnly:O,searchIcon:k,size:A,style:j,valid:M,validFeedback:N,value:P,...F},I)=>{let L=u(null),R=e(I,L),{invalid:z,valid:B}=n(L,{invalid:S,valid:M}),{describedBy:V,feedbackId:H,helpId:U,inputId:W,labelId:G,labelledBy:K}=t({ariaDescribedBy:F[`aria-describedby`],ariaLabelledBy:F[`aria-labelledby`],help:b,id:x,invalid:z,invalidFeedback:C,label:w,valid:B,validFeedback:N}),q={...F,"aria-describedby":V,"aria-labelledby":K,defaultValue:v,id:W,isDisabled:y,isInvalid:z,isReadOnly:O,onChange:T,onClear:E,onSubmit:D,value:P},J=h(q),{clearButtonProps:Y,inputProps:X}=m(q,J,L);return i({children:/* @__PURE__ */ c.createElement(`div`,{className:d(`form-input`,`search-field`,A,l),style:j},k!==!1&&/* @__PURE__ */ c.createElement(`span`,{className:`input-adorn search-field-icon`},/* @__PURE__ */ c.createElement(r,{icon:`search`,override:k})),/* @__PURE__ */ c.createElement(`input`,{...o(f(X,{onKeyDown:e=>{let t=e.shiftKey||e.altKey||e.ctrlKey||e.metaKey;D&&e.key===`Enter`&&!e.nativeEvent.isComposing&&(t||O)&&(e.preventDefault(),D(J.value))}}),F,s),"aria-describedby":V,className:d(`ghost-input`,a(z,B)),ref:R}),J.value!==``&&!y&&!O&&/* @__PURE__ */ c.createElement(g,{ariaLabel:p,buttonProps:Y,icon:_})),help:b,ids:{feedback:H,help:U,input:W,label:G},invalid:z,invalidFeedback:C,label:w,valid:B,validFeedback:N})});_.displayName=`SearchField`;export{_ as t};
|
|
2
|
+
//# sourceMappingURL=search-field-OFsb3t4L.js.map
|