@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"number-field-IBIX2IWH.js","names":[],"sources":["../../src/components/number-field/NumberField.tsx"],"sourcesContent":["import React, { forwardRef, InputHTMLAttributes, ReactNode, RefObject, useRef } from 'react'\nimport classNames from 'classnames'\nimport {\n AriaButtonProps,\n AriaNumberFieldProps,\n mergeProps,\n useButton,\n useLocale,\n useNumberField\n} from 'react-aria'\nimport { useNumberFieldState } from 'react-stately'\n\nimport './NumberField.scss'\nimport { useForkedRef, useFormField } from '../../hooks'\nimport { IconValue } from '../../utils/iconConfig'\nimport { IconSlot } from '../../utils/iconSlot'\nimport { mergeUnhandledProps, TEXT_FIELD_PROPS } from '../../utils/unhandledProps'\nimport { validationClassName } from '../../utils/validationClassName'\nimport { useHydrated } from '../portal/Portal'\nimport { renderFormField } from '../form-field/renderFormField'\n\nexport interface NumberFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'defaultValue' | 'inputMode' | 'max' | 'min' | 'onChange' | 'size' | 'step' | 'type' | 'value'\n> {\n /**\n * Content rendered at the input's trailing edge, before the step buttons, e.g. a unit as an\n * `InputAdorn`.\n */\n adornEnd?: ReactNode\n /**\n * Content rendered at the input's leading edge, e.g. an `InputAdorn` icon or text.\n */\n adornStart?: ReactNode\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * The name of the decrement button for screen readers. Defaults to \"Decrease\" and the field's\n * label, in the locale's language.\n */\n decrementAriaLabel?: string\n /**\n * The decrement button's icon, in place of `IconProvider`'s `decrement`.\n */\n decrementIcon?: IconValue\n /**\n * The value of the field, uncontrolled.\n */\n defaultValue?: number\n /**\n * Toggle the disabled state for the component.\n */\n disabled?: boolean\n /**\n * How the value is shown and typed: decimals, a percent, a currency or a unit, with the\n * locale's separators. `Intl.NumberFormat`'s options.\n */\n formatOptions?: Intl.NumberFormatOptions\n /**\n * A description for the field, rendered below the input.\n */\n help?: ReactNode\n /**\n * The name of the increment button for screen readers. Defaults to \"Increase\" and the field's\n * label, in the locale's language.\n */\n incrementAriaLabel?: string\n /**\n * The increment button's icon, in place of `IconProvider`'s `increment`.\n */\n incrementIcon?: IconValue\n /**\n * Set component validation state to invalid.\n */\n invalid?: boolean\n /**\n * An error message for the field, rendered below the input when `invalid` is set.\n */\n invalidFeedback?: ReactNode\n /**\n * The field's caption, rendered as a `FormLabel` associated with this input.\n */\n label?: ReactNode\n /**\n * The largest value. A larger one typed in is clamped to it when the field loses focus.\n */\n max?: number\n /**\n * The smallest value. A smaller one typed in is clamped to it when the field loses focus.\n */\n min?: number\n /**\n * Handler that is called when the value is committed: on a step (a button, an arrow key, Home,\n * End, the mouse wheel), on Enter or when the field loses focus after typing, on a paste that\n * replaces the whole text, and on a form reset. `NaN` when the field is empty.\n */\n onChange?: (value: number) => void\n /**\n * Toggle the readonly state for the component.\n */\n readOnly?: boolean\n /**\n * Toggle the required state for the component.\n */\n required?: boolean\n /**\n * Size the component sm or lg.\n */\n size?: 'sm' | 'lg'\n /**\n * The amount the buttons and the arrow keys add or take away. A typed value snaps to it,\n * counted from `min`.\n *\n * @default 1\n */\n step?: number\n /**\n * Show the increment and decrement buttons. Without them the arrow keys still step the value.\n *\n * @default true\n */\n stepButtons?: boolean\n /**\n * Set component validation state to valid.\n */\n valid?: boolean\n /**\n * A success message for the field, rendered below the input when `valid` is set.\n */\n validFeedback?: ReactNode\n /**\n * The value of the field, controlled. `NaN` for an empty field.\n */\n value?: number\n}\n\n// One step button. A `<button>` react-aria keeps out of the tab order: the input's arrow keys do\n// the same. A mouse press leaves focus on the input; a touch focuses the button, so no software\n// keyboard opens.\nfunction StepButton({\n buttonProps,\n className,\n icon,\n iconKey\n}: {\n buttonProps: AriaButtonProps\n className: string\n icon?: IconValue\n iconKey: 'increment' | 'decrement'\n}) {\n const ref = useRef<HTMLButtonElement>(null)\n const { buttonProps: props } = useButton(buttonProps, ref as RefObject<HTMLButtonElement | null>)\n return (\n <button {...props} className={className} ref={ref}>\n <IconSlot icon={iconKey} override={icon} />\n </button>\n )\n}\n\nexport const NumberField = forwardRef<HTMLInputElement, NumberFieldProps>(\n (\n {\n adornEnd,\n adornStart,\n className,\n decrementAriaLabel,\n decrementIcon,\n defaultValue,\n disabled,\n form,\n formatOptions,\n help,\n id,\n incrementAriaLabel,\n incrementIcon,\n invalid,\n invalidFeedback,\n label,\n max,\n min,\n name,\n onChange,\n readOnly,\n required,\n size,\n step,\n stepButtons = true,\n style,\n valid,\n validFeedback,\n value,\n ...rest\n },\n ref\n ) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const forkedRef = useForkedRef(ref, inputRef)\n const hydrated = useHydrated()\n const { locale } = useLocale()\n\n const { describedBy, feedbackId, helpId, inputId, labelId, labelledBy } = useFormField({\n ariaDescribedBy: rest['aria-describedby'],\n ariaLabelledBy: rest['aria-labelledby'],\n help,\n id,\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n\n // `label` stays out: react-aria would label the input and the buttons with a label element of\n // its own, which this component doesn't render. The buttons are named from `aria-labelledby`,\n // which names the `FormLabel` (FORMS.md, gotcha 5).\n const fieldProps = {\n ...rest,\n 'aria-describedby': describedBy,\n 'aria-labelledby': labelledBy,\n decrementAriaLabel,\n defaultValue,\n formatOptions,\n id: inputId,\n incrementAriaLabel,\n isDisabled: disabled,\n isInvalid: invalid,\n isReadOnly: readOnly,\n isRequired: required,\n maxValue: max,\n minValue: min,\n onChange,\n step,\n value\n } as AriaNumberFieldProps\n const state = useNumberFieldState({ ...fieldProps, locale })\n const { decrementButtonProps, groupProps, incrementButtonProps, inputProps } = useNumberField(\n fieldProps,\n state,\n inputRef\n )\n\n const hasWrapper = stepButtons || adornStart != null || adornEnd != null\n\n // react-aria picks the keyboard (`inputMode`) and drops `aria-roledescription` by platform\n // (iPhone, Android, iOS), which the server can't know, and a hydrating render doesn't patch an\n // attribute. Until the page has hydrated, both are what the server renders: `numeric`, which\n // any platform but those picks, and no role description, whose text iOS doesn't get.\n // `aria-describedby` after the spread: react-aria's own adds ids it never renders (FORMS.md,\n // gotcha 6).\n // react-aria's focus-within handlers let the mouse wheel step the value while the field has\n // focus: on the wrapper when there is one, else on the input. The wrapper isn't a named group.\n const focusWithin = { onBlur: groupProps.onBlur, onFocus: groupProps.onFocus }\n // `form` reaches the visible input too, which has no `name`: react-aria resets the field on\n // the reset of the input's own form, and a form linked by id is the input's form only then.\n const input = (\n <input\n {...mergeUnhandledProps(\n hasWrapper ? inputProps : mergeProps(inputProps, focusWithin),\n rest,\n TEXT_FIELD_PROPS\n )}\n aria-describedby={describedBy}\n // react-aria's spin button props repeat the native `disabled` and `readOnly` the text\n // field sets; the Nu Html Checker flags the copies.\n aria-disabled={undefined}\n aria-readonly={undefined}\n aria-roledescription={hydrated ? inputProps['aria-roledescription'] : undefined}\n className={classNames(\n hasWrapper ? 'ghost-input' : 'form-input',\n !hasWrapper && size,\n validationClassName(invalid, valid),\n !hasWrapper && className\n )}\n form={form}\n inputMode={hydrated ? inputProps.inputMode : 'numeric'}\n ref={forkedRef}\n style={hasWrapper ? undefined : style}\n />\n )\n\n // The step buttons sit in their own element: chassis-css styles `.form-input` as disabled when\n // one of its direct children is, and a step button is disabled at `min` or `max`.\n const field = hasWrapper ? (\n <div\n className={classNames('form-input', 'number-field', size, className)}\n style={style}\n {...focusWithin}\n >\n {adornStart}\n {input}\n {adornEnd}\n {stepButtons && (\n <div className=\"number-field-buttons\">\n <StepButton\n buttonProps={incrementButtonProps}\n className=\"number-field-increment\"\n icon={incrementIcon}\n iconKey=\"increment\"\n />\n <StepButton\n buttonProps={decrementButtonProps}\n className=\"number-field-decrement\"\n icon={decrementIcon}\n iconKey=\"decrement\"\n />\n </div>\n )}\n </div>\n ) : (\n input\n )\n\n // The input shows the formatted text; a form receives the number, from a hidden input as\n // react-aria-components' `NumberField` renders it.\n const children = name ? (\n <>\n {field}\n <input\n disabled={disabled || undefined}\n form={form}\n name={name}\n type=\"hidden\"\n value={isNaN(state.numberValue) ? '' : state.numberValue}\n />\n </>\n ) : (\n field\n )\n\n return renderFormField({\n children,\n help,\n ids: { feedback: feedbackId, help: helpId, input: inputId, label: labelId },\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n }\n)\n\nNumberField.displayName = 'NumberField'\n"],"mappings":"glBA6IA,SAAS,EAAW,CAClB,cACA,YACA,OACA,WAMC,CACD,IAAM,EAAM,EAA0B,IAAI,EACpC,CAAE,YAAa,GAAU,EAAU,EAAa,CAA0C,EAChG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AC,GAAc,CACjB,EACM,OACN,UAAW,EAAW,EAAW,UAAY,UAC7C,IAAK,EACL,MAAO,EAAa,IAAA,GAAY,CACjC,CAAA,EAKG,EAAQ,EACZ,EAAA,cAAC,MAAD,CACE,UAAW,EAAW,aAAc,eAAgB,EAAM,CAAS,EAC5D,QACP,GAAI,CAqBD,EAnBF,EACA,EACA,EACA,GACC,EAAA,cAAC,MAAD,CAAK,UAAU,sBAaV,EAZH,EAAA,cAAC,EAAD,CACE,YAAa,GACb,UAAU,yBACV,KAAM,EACN,QAAQ,WACT,CAAA,EACD,EAAA,cAAC,EAAD,CACE,YAAa,GACb,UAAU,yBACV,KAAM,EACN,QAAQ,WACT,CAAA,CACE,CAEJ,EAEL,EAKI,GAAW,EACf,EAAA,cAAA,EAAA,SAAA,KACG,EACD,EAAA,cAAC,QAAD,CACE,SAAU,GAAY,IAAA,GAChB,OACA,OACN,KAAK,SACL,MAAO,MAAM,EAAM,WAAW,EAAI,GAAK,EAAM,WAC9C,CAAA,CACD,EAEF,EAGF,OAAO,EAAgB,CACrB,YACA,OACA,IAAK,CAAE,SAAU,EAAY,KAAM,EAAQ,MAAO,EAAS,MAAO,EAAQ,EAC1E,UACA,kBACA,QACA,QACA,eACF,CAAC,CACH,CACF,EAEA,EAAY,YAAc"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{t as e}from"./useForkedRef-DVEfT-KI.js";import{t}from"./useControllableState-CPUJxfKW.js";import{t as n}from"./useFormField-BOqmBTC4.js";import{t as r}from"./renderFormField-Brkw1yA6.js";import{t as i}from"./direction-LN6uwsK5.js";import{t as a}from"./validationClassName-gRGs4KBm.js";import o,{Fragment as s,forwardRef as c,useMemo as l,useRef as u}from"react";import d from"classnames";import{mergeProps as f,useFocusRing as p,useObjectRef as m,useTextField as h}from"react-aria";const g=c(({disabled:e,index:t,invalid:n,mask:r,onChangeValue:i,onKeyDownBox:s,onPasteBox:c,size:l,valid:u,value:g},_)=>{let v=m(_),{focusProps:y,isFocusVisible:b}=p(),{inputProps:x}=h({"aria-label":`Digit ${t+1}`,autoComplete:t===0||r?`one-time-code`:`off`,isDisabled:e,isInvalid:n,maxLength:1,onChange:i,onFocus:e=>e.target.select(),onKeyDown:s,type:r?`password`:`text`,value:g},v);return o.createElement(`input`,{...f(x,y),"aria-describedby":void 0,className:d(`form-input`,l,a(n,u)),"data-focus-visible":b||void 0,inputMode:`numeric`,onPaste:c,pattern:`\\d*`,ref:v})});g.displayName=`OtpBox`;const _=e=>e.replace(/\D/g,``),v=(e,t)=>{let n=[..._(e)].slice(0,t);return Array.from({length:t},(e,t)=>n[t]??``)},y=c(({className:c,defaultValue:f,disabled:p,groupSizes:m,help:h,id:y,inputGroup:b,invalid:x,invalidFeedback:S,label:C,length:w=6,mask:T,name:E,onChange:D,onComplete:O,separator:k=`–`,size:A,valid:j,validFeedback:M,value:N,...P},F)=>{let I=m&&m.length>0?m.reduce((e,t)=>e+t,0):w,[L,R]=t(N,f??``,D),z=l(()=>v(L,I),[L,I]),B=u([]),V=e=>B.current[e]?.focus(),H=u(null),U=e(F,H),W=e=>{let t=e.join(``);R(t),e.length===I&&e.every(e=>e!==``)&&O?.(t)},G=(e,t)=>{let n=_(t);if(n.length>1){let t=[...n],r=[...z];for(let n=0;n<t.length&&e+n<I;n++)r[e+n]=t[n];W(r),V(Math.min(e+t.length,I-1));return}let r=[...z];r[e]=n,W(r),n&&e<I-1&&V(e+1)},K=(e,t)=>{if(!p)switch(t.key){case`Backspace`:if(!z[e]&&e>0){t.preventDefault();let n=[...z];n[e-1]=``,W(n),V(e-1)}break;case`Delete`:{t.preventDefault();let n=[...z];for(let t=e;t<I-1;t++)n[t]=n[t+1];n[I-1]=``,W(n);break}case`ArrowLeft`:case`ArrowRight`:{let n=t.key===`ArrowRight`===i(t.currentTarget)?e-1:e+1;n>=0&&n<I&&(t.preventDefault(),V(n));break}}},q=e=>{if(e.preventDefault(),p)return;let t=_(e.clipboardData.getData(`text`)).slice(0,I);t&&(W(v(t,I)),V(Math.min(t.length,I)-1))},J=(e,t)=>Array.from({length:t},(t,n)=>e+n).map(e=>o.createElement(g,{disabled:p,index:e,invalid:x,key:e,mask:T,onChangeValue:t=>G(e,t),onKeyDownBox:t=>K(e,t),onPasteBox:q,ref:t=>{B.current[e]=t},size:A,valid:j,value:z[e]??``})),Y;if(m&&m.length>0){let e=0;Y=m.map((t,n)=>{let r=e;return e+=t,o.createElement(s,{key:n},n>0&&o.createElement(`span`,{className:`form-otp-separator`},k),b?o.createElement(`div`,{className:`input-group`},J(r,t)):J(r,t))})}else Y=J(0,I);let{describedBy:X,feedbackId:Z,helpId:Q,inputId:$,labelId:ee,labelledBy:te}=n({ariaDescribedBy:P[`aria-describedby`],ariaLabelledBy:P[`aria-labelledby`],help:h,id:y,invalid:x,invalidFeedback:S,label:C,valid:j,validFeedback:M});return r({children:o.createElement(`div`,{...P,"aria-describedby":X,"aria-labelledby":te,className:d(`form-otp`,{"input-group":b&&!(m&&m.length>0)},a(x,j),c),id:$,ref:U,role:`group`},Y,E&&o.createElement(`input`,{disabled:p,name:E,type:`hidden`,value:z.join(``)})),help:h,ids:{feedback:Z,help:Q,label:ee},invalid:x,invalidFeedback:S,label:C,valid:j,validFeedback:M})});y.displayName=`OtpInput`;export{y as t};
|
|
2
|
-
//# sourceMappingURL=otp-input-ws393uPB.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"otp-input-ws393uPB.js","names":[],"sources":["../../src/components/otp-input/OtpBox.tsx","../../src/components/otp-input/OtpInput.tsx"],"sourcesContent":["import React, { ClipboardEvent, ForwardedRef, forwardRef, KeyboardEvent } from 'react'\nimport classNames from 'classnames'\nimport { mergeProps, useFocusRing, useObjectRef, useTextField } from 'react-aria'\n\nimport { validationClassName } from '../../utils/validationClassName'\n\ninterface OtpBoxProps {\n disabled?: boolean\n index: number\n invalid?: boolean\n mask?: boolean\n onChangeValue: (value: string) => void\n onKeyDownBox: (event: KeyboardEvent<HTMLInputElement>) => void\n onPasteBox: (event: ClipboardEvent<HTMLInputElement>) => void\n size?: 'sm' | 'lg'\n valid?: boolean\n value: string\n}\n\nexport const OtpBox = forwardRef(\n (\n {\n disabled,\n index,\n invalid,\n mask,\n onChangeValue,\n onKeyDownBox,\n onPasteBox,\n size,\n valid,\n value\n }: OtpBoxProps,\n forwardedRef: ForwardedRef<HTMLInputElement>\n ) => {\n const ref = useObjectRef(forwardedRef)\n const { focusProps, isFocusVisible } = useFocusRing()\n const { inputProps } = useTextField(\n {\n 'aria-label': `Digit ${index + 1}`,\n // Only the first box takes the whole code; the others turn autofill off. Browsers ignore\n // `off` on a password field, though, so a masked box would be offered saved passwords:\n // every masked box says it takes a one-time code instead, the one other value that fits.\n autoComplete: index === 0 || mask ? 'one-time-code' : 'off',\n isDisabled: disabled,\n isInvalid: invalid,\n maxLength: 1,\n onChange: onChangeValue,\n onFocus: (event) => (event.target as HTMLInputElement).select(),\n onKeyDown: onKeyDownBox,\n type: mask ? 'password' : 'text',\n value\n },\n ref\n )\n\n return (\n <input\n {...mergeProps(inputProps, focusProps)}\n // The group describes the boxes. react-aria's own ids here are never rendered (FORMS.md,\n // gotcha 6).\n aria-describedby={undefined}\n className={classNames('form-input', size, validationClassName(invalid, valid))}\n data-focus-visible={isFocusVisible || undefined}\n inputMode=\"numeric\"\n onPaste={onPasteBox}\n pattern=\"\\d*\"\n ref={ref}\n />\n )\n }\n)\n\nOtpBox.displayName = 'OtpBox'\n","import React, {\n ClipboardEvent,\n forwardRef,\n Fragment,\n HTMLAttributes,\n KeyboardEvent,\n ReactNode,\n useMemo,\n useRef\n} from 'react'\nimport classNames from 'classnames'\n\nimport { useControllableState, useForkedRef, useFormField } from '../../hooks'\nimport { validationClassName } from '../../utils/validationClassName'\nimport { renderFormField } from '../form-field/renderFormField'\nimport { OtpBox } from './OtpBox'\nimport { isRTL } from '../../utils/direction'\n\nexport interface OtpInputProps extends Omit<\n HTMLAttributes<HTMLDivElement>,\n 'onChange' | 'defaultValue'\n> {\n /**\n * Identifies the element that describes the group, e.g. a `FormHelp` help element.\n */\n 'aria-describedby'?: string\n /**\n * An accessible label for the group, used when there's no visible `<label>`.\n */\n 'aria-label'?: string\n /**\n * Identifies a visible `<label>` element for the group.\n */\n 'aria-labelledby'?: string\n /**\n * A string of all className you want applied to the base component.\n */\n className?: string\n /**\n * The initial code (uncontrolled), e.g. `\"123\"` for a partially filled code.\n */\n defaultValue?: string\n /**\n * Prevents input and makes every box non-interactive.\n */\n disabled?: boolean\n /**\n * Splits the boxes into groups (e.g. `[3, 3]` for a \"123-456\" layout), rendering a\n * `.form-otp-separator` between each group. The total number of boxes becomes the sum of\n * `groupSizes`, overriding `length`.\n */\n groupSizes?: number[]\n /**\n * A description for the field, rendered below the boxes.\n */\n help?: ReactNode\n /**\n * `id` forwarded to the group container.\n */\n id?: string\n /**\n * Visually connects the boxes into a single bordered control. When `groupSizes` is set, each\n * group is connected separately.\n */\n inputGroup?: boolean\n /**\n * Set component validation state to invalid.\n */\n invalid?: boolean\n /**\n * An error message for the field, rendered below the boxes when `invalid` is set.\n */\n invalidFeedback?: ReactNode\n /**\n * The field's caption, rendered as a `FormLabel` associated with the group via\n * `aria-labelledby` (there's no single input to target with `htmlFor`).\n */\n label?: ReactNode\n /**\n * Number of digit boxes. Ignored when `groupSizes` is set. Defaults to `6`.\n */\n length?: number\n /**\n * Mask entered digits using `type=\"password\"` boxes.\n */\n mask?: boolean\n /**\n * `name` of an auto-created hidden input kept in sync with the code, for native form\n * submission. Omit to skip creating it.\n */\n name?: string\n /**\n * Callback fired whenever the code changes.\n */\n onChange?: (value: string) => void\n /**\n * Callback fired once every box is filled.\n */\n onComplete?: (value: string) => void\n /**\n * Content of the separator rendered between groups when `groupSizes` is set. Defaults to `–`.\n */\n separator?: ReactNode\n /**\n * Size the boxes sm or lg.\n */\n size?: 'sm' | 'lg'\n /**\n * Set component validation state to valid.\n */\n valid?: boolean\n /**\n * A success message for the field, rendered below the boxes when `valid` is set.\n */\n validFeedback?: ReactNode\n /**\n * The code (controlled), digits only, e.g. `\"123456\"`.\n */\n value?: string\n}\n\nconst onlyDigits = (raw: string) => raw.replace(/\\D/g, '')\n\nconst toBoxes = (raw: string, total: number): string[] => {\n const digits = [...onlyDigits(raw)].slice(0, total)\n return Array.from({ length: total }, (_, i) => digits[i] ?? '')\n}\n\nexport const OtpInput = forwardRef<HTMLDivElement, OtpInputProps>(\n (\n {\n className,\n defaultValue,\n disabled,\n groupSizes,\n help,\n id,\n inputGroup,\n invalid,\n invalidFeedback,\n label,\n length = 6,\n mask,\n name,\n onChange,\n onComplete,\n separator = '–',\n size,\n valid,\n validFeedback,\n value,\n ...rest\n }: OtpInputProps,\n ref\n ): ReactNode => {\n const total =\n groupSizes && groupSizes.length > 0 ? groupSizes.reduce((a, b) => a + b, 0) : length\n\n const [rawValue, setRawValue] = useControllableState(value, defaultValue ?? '', onChange)\n const boxes = useMemo(() => toBoxes(rawValue, total), [rawValue, total])\n\n const boxRefs = useRef<Array<HTMLInputElement | null>>([])\n const focusBox = (index: number) => boxRefs.current[index]?.focus()\n const containerRef = useRef<HTMLDivElement>(null)\n const forkedRef = useForkedRef(ref, containerRef)\n\n const commit = (nextBoxes: string[]) => {\n const next = nextBoxes.join('')\n setRawValue(next)\n if (nextBoxes.length === total && nextBoxes.every((box) => box !== '')) {\n onComplete?.(next)\n }\n }\n\n const handleChange = (index: number, raw: string) => {\n const digits = onlyDigits(raw)\n\n if (digits.length > 1) {\n // Multi-character value landing in a single box (autofill, or a fast typist outrunning\n // the auto-advance) — distribute across this and subsequent boxes, matching chassis-css's\n // vanilla otp-input.js `_handleInput`.\n const chars = [...digits]\n const nextBoxes = [...boxes]\n for (let i = 0; i < chars.length && index + i < total; i++) {\n nextBoxes[index + i] = chars[i]!\n }\n commit(nextBoxes)\n focusBox(Math.min(index + chars.length, total - 1))\n return\n }\n\n const nextBoxes = [...boxes]\n nextBoxes[index] = digits\n commit(nextBoxes)\n if (digits && index < total - 1) focusBox(index + 1)\n }\n\n const handleKeyDown = (index: number, event: KeyboardEvent<HTMLInputElement>) => {\n if (disabled) return\n\n switch (event.key) {\n case 'Backspace': {\n if (!boxes[index] && index > 0) {\n event.preventDefault()\n const nextBoxes = [...boxes]\n nextBoxes[index - 1] = ''\n commit(nextBoxes)\n focusBox(index - 1)\n }\n break\n }\n case 'Delete': {\n event.preventDefault()\n // `boxes` (and every copy derived from it) is always exactly `total` entries long — see\n // `toBoxes` — so `i + 1` (bounded by `i < total - 1`) never reads past the end.\n const nextBoxes = [...boxes]\n for (let i = index; i < total - 1; i++) nextBoxes[i] = nextBoxes[i + 1]!\n nextBoxes[total - 1] = ''\n commit(nextBoxes)\n break\n }\n // Arrow keys move by *visual* direction, so they mirror under RTL: the box to the left of\n // the focused one is the next box, not the previous. `Carousel` and `MenuSubmenu` already\n // mirror their own arrow handling this way; this used to hardcode the LTR mapping and sent\n // an RTL user backwards through the field.\n case 'ArrowLeft':\n case 'ArrowRight': {\n const movesForward = (event.key === 'ArrowRight') !== isRTL(event.currentTarget)\n const nextIndex = movesForward ? index + 1 : index - 1\n if (nextIndex >= 0 && nextIndex < total) {\n event.preventDefault()\n focusBox(nextIndex)\n }\n break\n }\n default:\n break\n }\n }\n\n const handlePaste = (event: ClipboardEvent<HTMLInputElement>) => {\n event.preventDefault()\n if (disabled) return\n const digits = onlyDigits(event.clipboardData.getData('text')).slice(0, total)\n if (!digits) return\n commit(toBoxes(digits, total))\n focusBox(Math.min(digits.length, total) - 1)\n }\n\n const renderBoxes = (start: number, count: number) =>\n Array.from({ length: count }, (_, i) => start + i).map((i) => (\n <OtpBox\n disabled={disabled}\n index={i}\n invalid={invalid}\n key={i}\n mask={mask}\n onChangeValue={(next) => handleChange(i, next)}\n onKeyDownBox={(event) => handleKeyDown(i, event)}\n onPasteBox={handlePaste}\n ref={(el) => {\n boxRefs.current[i] = el\n }}\n size={size}\n valid={valid}\n value={boxes[i] ?? ''}\n />\n ))\n\n let content: ReactNode\n if (groupSizes && groupSizes.length > 0) {\n let cursor = 0\n content = groupSizes.map((groupSize, groupIndex) => {\n const start = cursor\n cursor += groupSize\n return (\n // eslint-disable-next-line react/no-array-index-key\n <Fragment key={groupIndex}>\n {groupIndex > 0 && <span className=\"form-otp-separator\">{separator}</span>}\n {inputGroup ? (\n <div className=\"input-group\">{renderBoxes(start, groupSize)}</div>\n ) : (\n renderBoxes(start, groupSize)\n )}\n </Fragment>\n )\n })\n } else {\n content = renderBoxes(0, total)\n }\n\n const {\n describedBy,\n feedbackId,\n helpId,\n inputId: groupId,\n labelId,\n labelledBy\n } = useFormField({\n ariaDescribedBy: rest['aria-describedby'],\n ariaLabelledBy: rest['aria-labelledby'],\n help,\n id,\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n\n return renderFormField({\n children: (\n <div\n {...rest}\n aria-describedby={describedBy}\n aria-labelledby={labelledBy}\n className={classNames(\n 'form-otp',\n { 'input-group': inputGroup && !(groupSizes && groupSizes.length > 0) },\n validationClassName(invalid, valid),\n className\n )}\n id={groupId}\n ref={forkedRef}\n role=\"group\"\n >\n {content}\n {name && <input disabled={disabled} name={name} type=\"hidden\" value={boxes.join('')} />}\n </div>\n ),\n help,\n ids: { feedback: feedbackId, help: helpId, label: labelId },\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n }\n)\n\nOtpInput.displayName = 'OtpInput'\n"],"mappings":"0gBAmBA,MAAa,EAAS,GAElB,CACE,WACA,QACA,UACA,OACA,gBACA,eACA,aACA,OACA,QACA,SAEF,IACG,CACH,IAAM,EAAM,EAAa,CAAY,EAC/B,CAAE,aAAY,kBAAmB,EAAa,EAC9C,CAAE,cAAe,EACrB,CACE,aAAc,SAAS,EAAQ,IAI/B,aAAc,IAAU,GAAK,EAAO,gBAAkB,MACtD,WAAY,EACZ,UAAW,EACX,UAAW,EACX,SAAU,EACV,QAAU,GAAW,EAAM,OAA4B,OAAO,EAC9D,UAAW,EACX,KAAM,EAAO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AFF,EACA,GAAQ,EAAA,cAAC,QAAD,CAAiB,WAAgB,OAAM,KAAK,SAAS,MAAO,EAAM,KAAK,EAAE,CAAI,CAAA,CACnF,EAEP,OACA,IAAK,CAAE,SAAU,EAAY,KAAM,EAAQ,MAAO,EAAQ,EAC1D,UACA,kBACA,QACA,QACA,eACF,CAAC,CACH,CACF,EAEA,EAAS,YAAc"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"overlayPlacement-BtS90IVf.js","names":[],"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`), and `data-cx-placement` needs the resolved main axis\n// reattached to the originally-requested cross-axis alignment. Lives here (rather than\n// `components/menu/`) for the same reason `renderMenuItemContent` does — `Combobox.tsx`/\n// `Autocomplete.tsx` need it too, and importing across that folder boundary from three call sites\n// is worse than housing it where none of the four has to reach into a sibling's folder.\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// `--menu-max-height`/`--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`). A consumer who customized either Sass variable needs to\n// re-override `--menu-max-height`/`--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 '--menu-max-height': '320px',\n '--menu-overflow-y': 'auto'\n} as CSSProperties\n"],"mappings":"AAsBA,MAAM,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,EAIa,EAAmB,GAAwC,EAAe,GAM1E,GACX,EACA,IACW,CACX,GAAI,CAAC,GAAgB,IAAiB,SAAU,OAAO,EACvD,IAAM,EAAQ,EAAU,MAAM,GAAG,CAAC,CAAC,GACnC,OAAO,EAAQ,GAAG,EAAa,GAAG,IAAU,CAC9C,EAea,GACX,EACA,EACA,KAC4B,CAC5B,UAAW,CACT,SAAU,GAAc,SACxB,IAAK,GAAc,IACnB,KAAM,GAAc,IACtB,EACA,cAAe,EAAqB,EAAoB,CAAiB,CAC3E,GAWa,EAA6C,CACxD,oBAAqB,QACrB,oBAAqB,MACvB"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{d as e,g as t,p as n}from"./slot-CNhFZdHF.js";import{t as r}from"./polymorphic-BhGNZQja.js";import{t as i}from"./useButtonSemantics-CILM_lhi.js";import{t as a}from"./focusRedirect-BrvK3U_o.js";import{t as o}from"./iconSlot-BNu2MrFI.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),_=n(c,u,`button`),v=t(_,u,m),y=e(v,u,`PaginationItem`),b=_,x=_,S=e=>{if(v===`anchor`&&l){e.preventDefault();return}p?.(e)},C=v!==`button`&&v!==`anchor`&&!!p,{buttonProps:w,forkedRef:T}=i(h,{disabled:l,onClick:p}),E=r?{"aria-current":`page`}:{};return s.createElement(`li`,{className:g},v===`button`?s.createElement(b,{...m,className:`pagination-link`,type:`button`,disabled:l,onClick:S,...E,ref:h},a):v===`anchor`?s.createElement(x,{...m,className:`pagination-link`,...y,onClick:S,...l&&{"aria-disabled":!0,tabIndex:-1},...E,ref:h},a):s.createElement(_,{className:`pagination-link`,...f(m,C?w:{}),...!C&&{onClick:S},...y,...E,ref:C?T:h},a))}const h=r(m,`PaginationItem`);function g(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 _=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:_=`Previous`,showPageNumbers:v=!0,showPrevNext:y=!0,size:b,...x},S)=>{let C=d(`pagination`,b,{[`justify-content-${t}`]:t},i),w=f?Math.min(Math.max(e,1),f):e,T=f?w<=1:!1,E=f?w>=f:!1,{prevRef:D,nextRef:O,handlePrevClick:k,handleNextClick:A}=p({prevDisabled:T,nextDisabled:E,onPrev:()=>u&&u(w-1),onNext:()=>u&&u(w+1)}),j=f?s.createElement(s.Fragment,null,y&&s.createElement(h,{ref:D,disabled:T,onClick:k,"aria-label":_},s.createElement(o,{icon:`previous`,override:m,className:`directional-icon`})),v&&g(w,f,a).map((e,t)=>e===`...`?s.createElement(h,{key:`ellipsis-${t}`,disabled:!0,component:`span`,"aria-hidden":`true`},`…`):s.createElement(h,{key:e,active:e===w,onClick:()=>u&&u(e)},e)),y&&s.createElement(h,{ref:O,disabled:E,onClick:A,"aria-label":l},s.createElement(o,{icon:`next`,override:c,className:`directional-icon`}))):null;return s.createElement(`nav`,{"aria-label":n,ref:S,...x},s.createElement(`ul`,{className:C},j??r))});_.displayName=`Pagination`;export{h as n,p as r,_ as t};
|
|
2
|
-
//# sourceMappingURL=pagination-BkOquk-x.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pagination-BkOquk-x.js","names":[],"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 '../../utils/iconSlot'\nimport classNames from 'classnames'\n\nimport { PaginationItem } from './PaginationItem'\nimport { usePagination } from '../../hooks'\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(\n 'pagination',\n size,\n {\n [`justify-content-${align}`]: align\n },\n className\n )\n\n const clampedActivePage = pages ? Math.min(Math.max(activePage, 1), pages) : activePage\n const prevDisabled = pages ? clampedActivePage <= 1 : false\n const nextDisabled = pages ? 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 = pages ? (\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":"uZAiDA,SAAgB,EAAyD,CACvE,eACA,eACA,SACA,UAC+C,CAC/C,IAAM,EAAU,EAAU,IAAI,EACxB,EAAU,EAAU,IAAI,EACxB,EAAU,EAAuB,IAAI,EAmB3C,OAXA,MAAgB,CACd,IAAM,EAAO,EAAQ,QACrB,EAAQ,QAAU,KACb,IACD,EAAK,OAAS,QAAU,EAC1B,EAAc,EAAQ,QAAS,EAAK,UAAU,EACrC,EAAK,OAAS,QAAU,GACjC,EAAc,EAAQ,QAAS,EAAK,UAAU,EAElD,CAAC,EAEM,CACL,UACA,UACA,gBAAkB,GAAU,CAC1B,EAAQ,QAAU,CAAE,KAAM,OAAQ,WAAY,EAAM,SAA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AAA,SAAA,KACG,GACC,EAAA,cAAC,EAAD,CACE,IAAK,EACL,SAAU,EACV,QAAS,EACT,aAAY,CAGE,EADd,EAAA,cAAC,EAAD,CAAU,KAAK,WAAW,SAAU,EAAc,UAAU,kBAAoB,CAAA,CAClE,EAEjB,GACC,EAAa,EAAmB,EAAO,CAAe,CAAC,CAAC,KAAK,EAAM,IACjE,IAAS,MAEP,EAAA,cAAC,EAAD,CAAgB,IAAK,YAAY,IAAO,SAAA,GAAS,UAAU,OAAO,cAAY,MAE9D,EAFqE,GAErE,EAEhB,EAAA,cAAC,EAAD,CACE,IAAK,EACL,OAAQ,IAAS,EACjB,YAAe,GAAsB,EAAmB,CAAI,CAG9C,EADb,CACa,CAEpB,EACD,GACC,EAAA,cAAC,EAAD,CACE,IAAK,EACL,SAAU,EACV,QAAS,EACT,aAAY,CAGE,EADd,EAAA,cAAC,EAAD,CAAU,KAAK,OAAO,SAAU,EAAU,UAAU,kBAAoB,CAAA,CAC1D,CAElB,EACA,KAEJ,OACE,EAAA,cAAC,MAAD,CAAK,aAAY,EAAgB,MAAK,GAAI,CAErC,EADH,EAAA,cAAC,KAAD,CAAI,UAAW,CAA0C,EAA7B,GAAgB,CAAa,CACtD,CAET,CACF,EAEA,EAAW,YAAc"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"password-strength-DDK8pHRq.js","names":[],"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":"6LAEA,MAAa,EAAmC,CAAC,OAAQ,OAAQ,OAAQ,QAAQ,EAapE,EAAkC,CAC7C,YAAa,EACb,UAAW,EACX,aAAc,EACd,UAAW,EACX,gBAAiB,EACjB,QAAS,EACT,QAAS,EACT,UAAW,CACb,EAEa,EA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AU,EAAG,CAAC,EAAO,CAAU,CAAC,EAChF,EAAmB,MACjB,GAAY,OAAO,OAAO,CAAa,CAAC,CAAC,QAAQ,EAAO,IAAW,EAAQ,EAAQ,CAAC,EAC1F,CAAC,EAAU,CAAa,CAC1B,EAKM,EAAmB,EAAyC,IAAA,EAAS,EAC3E,MAAgB,CACV,EAAiB,UAAY,IAC/B,EAAiB,QAAU,EAC3B,IAAmB,CAAE,QAAO,UAAS,CAAC,EAE1C,EAAG,CAAC,EAAU,EAAO,CAAgB,CAAC,EAEtC,GAAM,CAAE,cAAe,EAAS,CAC9B,aAAc,EACd,SAAU,EACV,SAAU,EACV,MAAO,EACP,WAAY,EAAW,EAAe,GAAY,IAAA,EACpD,CAAC,EAEK,EAAgB,EAAW,EAAgB,QAAQ,CAAQ,EAAI,GAErE,OACE,EAAA,cAAC,EAAA,KACC,EAAA,cAAC,MAAD,CACE,GAAI,EACJ,UAAW,EAAW,IAAY,MAAQ,eAAiB,WAAY,CAAS,EAChF,mBAAkB,GAAY,IAAA,GAC1B,KACJ,GAAI,EACC,KASF,EAPF,IAAY,aACX,EAAgB,KAAK,EAAO,IAC1B,EAAA,cAAC,MAAD,CACE,UAAW,EAAW,mBAAoB,CAAE,OAAQ,GAAS,CAAc,CAAC,EAC5E,IAAK,CACN,CAAA,CACF,CACA,EACJ,GACC,EAAA,cAAC,OAAD,CACE,YAAU,SACV,UAAU,gBACV,mBAAkB,GAAY,IAAA,EAG1B,EADH,EAAW,EAAe,GAAY,EACnC,CAEA,CAEd,CACF,EAEA,EAAiB,YAAc"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{a as e}from"./slot-CNhFZdHF.js";import{t}from"./polymorphic-BhGNZQja.js";import n from"react";import r from"classnames";const i=e=>[e===`start`||e===`end`?`float-${e}`:null,e===`center`?`d-block mx-auto`:null];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},i(t),o);return 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 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&&n.createElement(`title`,null,h),S&&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-BCr83sUn.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"placeholder-BCr83sUn.js","names":[],"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\nconst alignClassNames = (align: PlaceholderAlign | undefined) => [\n align === 'start' || align === 'end' ? `float-${align}` : null,\n align === 'center' ? 'd-block mx-auto' : null\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 alignClassNames(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":"gKAyFA,MAAM,EAAmB,GAAwC,CAC/D,IAAU,SAAW,IAAU,MAAQ,SAAS,IAAU,KAC1D,IAAU,SAAW,kBAAoB,IAC3C,EAEA,SAAS,EACP,CACE,QACA,MACA,YACA,QACA,YACA,QACA,SACA,UACA,MACA,OACA,YACA,QAAQ,cACR,UACA,QACA,GAAG,GAEL,EACA,CACA,IAAM,EAAY,IAAU,GACtB,EACJ,IAAS,GACL,IAAA,GACC,IAAS,IAAU,IAAA,IAAa,IAAW,IAAA,GAAY,GAAG,EAAM,GAAG,IAAW,IAAA,IAC/E,EAAW,IAAgB,IAAA,GAC3B,EACJ,CAAC,GAAa,EAAO,GAAY,CAAW,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,IAAI,GAAK,IAAA,GAI9E,GAAI,GAAO,EAAO,CAAS,EAAG,CAC5B,IAAM,EAAY,GAAa,MACzB,EAAa,EACjB,CAAE,MAAO,GAAS,EAAW,QAAO,UAAS,WAAU,EACvD,EAAgB,CAAK,EACrB,CACF,EAEA,OACE,EAAA,cAAC,EAAD,CACO,MACE,QACC,SACR,IAAK,GAAO,GAAS,GACrB,UAAW,EACX,GAAI,EACC,KACN,CAAA,CAEL,CAEA,IAAM,EAAa,EACjB,QACA,CAAE,QAAS,GAAQ,GAAS,EAAS,EACrC,EACA,GAAoB,aACpB,YACA,CACF,EAEA,OACE,EAAA,cAAC,MAAD,CACE,MAAM,6BACC,QACC,SACR,aAAY,EACZ,cAAa,IAAQ,IAAA,GACrB,UAAW,EACX,oBAAoB,iBACpB,KAAM,EAAQ,MAAQ,IAAA,GACtB,GAAI,EACC,KAQF,EANF,GAAa,EAAA,cAAC,QAAA,KAAO,CAAa,EAClC,GACC,EAAA,cAAC,OAAD,CAAM,GAAG,OAAO,KAAK,eAAe,WAAW,SAAS,EAAE,MAAM,EAAE,KAE5D,EADH,CACG,CAEL,CAET,CAEA,MAAa,EAAc,EACzB,EACA,aACF"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e,r as t,t as n,v as r}from"./slot-CNhFZdHF.js";import{createElement as i,forwardRef as a}from"react";function o(o,s){let c=a(({asChild:a,...c},l)=>{let u=a?t(c.children,s):null;return u?(r(c.component!==void 0,`${s}: both \`asChild\` and \`component\` were passed; \`asChild\` wins and \`component\` is ignored.`),i(n,{value:u},o({...c,component:e(u),children:u.props.children},l))):o(c,l)});return c.displayName=s,c}export{o as t};
|
|
2
|
-
//# sourceMappingURL=polymorphic-BhGNZQja.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"polymorphic-BhGNZQja.js","names":[],"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 { getSlot, getSlotChild, SlotProvider } 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.\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 const child = asChild ? getSlotChild(props.children, displayName) : null\n if (!child) return render(props, ref)\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 return createElement(\n SlotProvider,\n { value: child },\n render(\n {\n ...props,\n component: getSlot(child),\n children: (child.props as PropsWithChildren).children\n },\n ref\n )\n )\n }) as unknown as T & { displayName?: string }\n Component.displayName = displayName\n return Component\n}\n\ntype PropsWithChildren = { children?: unknown }\n"],"mappings":"kHAuEA,SAAgB,EAEd,EACA,EACG,CAEH,IAAM,EAAY,GAA0B,CAAE,UAAS,GAAG,GAAS,IAAQ,CACzE,IAAM,EAAQ,EAAU,EAAa,EAAM,SAAU,CAAW,EAAI,KASpE,OARK,GAEL,EACE,EAAM,YAAc,IAAA,GACpB,GAAG,EAAY,iGAEjB,EAEO,EACL,EACA,CAAE,MAAO,CAAM,EACf,EACE,CACE,GAAG,EACH,UAAW,EAAQ,CAAK,EACxB,SAAW,EAAM,MAA4B,QAC/C,EACA,CACF,CACF,GAnBmB,EAAO,EAAO,CAAG,CAoBtC,CAAC,EAED,MADA,GAAU,YAAc,EACjB,CACT"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{i as e,o as t}from"./slot-CNhFZdHF.js";import{t as n}from"./useForkedRef-DVEfT-KI.js";import{n as r,t as i}from"./Portal-CgeR1WXV.js";import{t as a}from"./useTransitionState-e5ToY7eX.js";import{n as o,r as s,t as c}from"./useFloatingOverlay-DLIvwx-8.js";import{t as l}from"./useOpenStateProps-DykUbnPJ.js";import{i as u,n as d}from"./overlayPlacement-BtS90IVf.js";import f,{forwardRef as p,useEffect as m,useRef as h}from"react";import g from"classnames";import{mergeProps as _,useDialog as v,useOverlayPosition as y,useOverlayTrigger as b}from"react-aria";import{useOverlayTriggerState as x}from"react-stately";const S=({arrowProps:e,content:t,overlayRef:r,overlayTriggerProps:i,title:a,...o})=>{let s=h(null),l=n(r,s),{dialogProps:u,titleProps:d}=v({},s);return f.createElement(`div`,{..._(i,u,o),ref:l},f.createElement(`div`,{className:`popover-arrow`,...e,style:c(e)}),a&&f.createElement(`div`,{className:`popover-header`,...d},a),f.createElement(`div`,{className:`popover-body`},t))},C=p(function({children:c,className:p,content:_,defaultVisible:v,placement:C=`right`,offset:w=[0,8],onHide:T,onShow:E,onVisibleChange:D,style:O,title:k,visible:A,...j},M){let N=h(null),P=h(null),F=h(null),I=n(M,F),L=e(c,`Popover`),R=x(l({defaultVisible:v,onVisibleChange:D,visible:A},`Popover`)),{triggerProps:{onPress:z,...B},overlayProps:V}=b({type:`dialog`},R,P),H=s({close:R.close,isOpen:R.isOpen,onHide:T,onShow:E,triggerRef:P});m(()=>{if(!R.isOpen)return;let e=e=>{e.key===`Escape`&&R.close()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[R.isOpen,R.close]),m(()=>{if(!R.isOpen)return;let e=e=>{let t=e.target;P.current?.contains(t)||F.current?.contains(t)||R.close()},t=window.setTimeout(()=>{window.addEventListener(`click`,e)});return()=>{window.clearTimeout(t),window.removeEventListener(`click`,e)}},[R.isOpen,R.close]);let{overlayProps:U,arrowProps:W,placement:G}=y({targetRef:P,overlayRef:F,placement:u(C),offset:w[1],crossOffset:w[0],arrowSize:8,arrowRef:N,isOpen:R.isOpen,onClose:null}),K={...O,position:U.style?.position,top:U.style?.top,left:U.style?.left},q=d(C,G),{isMounted:J,phase:Y}=a({in:R.isOpen,mountOnEnter:!0,nodeRef:F,onExited:()=>{let e=P.current;if(!e||!document.contains(e))return;let t=document.activeElement,n=!t||t===document.body,r=!!t&&!!F.current?.contains(t);(n||r)&&e.focus()},unmountOnExit:!0}),X=r();return f.createElement(f.Fragment,null,L?t(L,{onClick:()=>R.toggle()},P,X?B:{...B,"aria-controls":void 0}):c,f.createElement(i,{container:H},J&&f.createElement(S,{className:g(`popover cx-popover-auto`,o(Y),p),"data-cx-placement":q,style:K,overlayTriggerProps:V,overlayRef:I,arrowProps:W,title:k,content:_,...j})))});C.displayName=`Popover`;export{C as t};
|
|
2
|
-
//# sourceMappingURL=popover-Bdg8D4sm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"popover-Bdg8D4sm.js","names":[],"sources":["../../src/components/popover/Popover.tsx"],"sourcesContent":["import React, {\n forwardRef,\n HTMLAttributes,\n ReactElement,\n ReactNode,\n Ref,\n useEffect,\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 { Placement, resolveDataPlacement, toAriaPlacement } from '../../utils/overlayPlacement'\nimport { Portal, useHydrated } 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 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 // 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. Mirrors\n // `Menu.tsx`'s own window-level Escape handling. `onExited` below already returns focus to the\n // trigger once the exit transition finishes, so this doesn't need to do that itself.\n useEffect(() => {\n if (!state.isOpen) return undefined\n\n const handleEscape = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n state.close()\n }\n\n window.addEventListener('keydown', handleEscape)\n return () => window.removeEventListener('keydown', handleEscape)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [state.isOpen, state.close])\n\n // Deferred so the click that opened the popover doesn't immediately close it again — mirrors\n // `Menu.tsx`'s own outside-click handling.\n useEffect(() => {\n if (!state.isOpen) return undefined\n\n const handleDismiss = (event: MouseEvent) => {\n const target = event.target as Node\n if (triggerRef.current?.contains(target)) return\n if (floatingRef.current?.contains(target)) return\n state.close()\n }\n\n const id = window.setTimeout(() => {\n window.addEventListener('click', handleDismiss)\n })\n\n return () => {\n window.clearTimeout(id)\n window.removeEventListener('click', 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 const { isMounted, phase } = useTransitionState({\n in: state.isOpen,\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 { 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 {...rest}\n />\n )}\n </Portal>\n </>\n )\n})\n\nPopover.displayName = 'Popover'\n"],"mappings":"4oBAqCA,MAAM,GAAgB,CACpB,aACA,UACA,aACA,sBACA,QACA,GAAG,KACoB,CAGvB,IAAM,EAAW,EAAuB,IAAI,EACtC,EAAY,EAAa,EAAY,CAAQ,EAC7C,CAAE,cAAa,cAAe,EAAU,CAAC,EAA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B,CACF,EACA,oBAAmB,EACnB,MAAO,EACc,sBACrB,WAAY,EACA,aACL,QACE,UACT,GAAI,CACL,CAAA,CAEG,CACR,CAEN,CAAC,EAED,EAAQ,YAAc"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{t as e}from"./polymorphic-BhGNZQja.js";import t,{useId as n}from"react";import r from"classnames";function i({children:e,animated:n,className:i,color:a,component:o,striped:s,style:c,value:l=0,...u},d){let f=o??`div`,p=Math.min(100,Math.max(0,l)),m=r(`progress-bar`,a&&`bg-${a} fg-contrast`,{striped:s,animated:n},i);return t.createElement(f,{...u,className:m,style:{width:`${p}%`,...c},ref:d},t.createElement(`span`,{className:`mx-2xs`},e))}const a=e(i,`ProgressBar`);function o({"aria-label":e,animated:i,children:o,className:s,color:c,component:l,height:u,inlineValue:d,label:f,showValue:p,striped:m,style:h,value:g=0,..._},v){let y=l??`div`,b=r(`progress`,s),x=Math.min(100,Math.max(0,g)),S=o===void 0?d?`${x}%`:void 0:o,C=!!(f||p),w=n(),T=f!=null&&typeof f!=`string`,E={...h};u!==void 0&&(E[`--cx-height`]=`${u}px`);let D=t.createElement(y,{..._,className:b,role:`progressbar`,"aria-valuenow":x,"aria-valuemin":0,"aria-valuemax":100,"aria-label":e??(typeof f==`string`?f:void 0),"aria-labelledby":!e&&T?w:void 0,style:E,ref:v},t.createElement(a,{animated:i,color:c,striped:m,value:x},S));return C?t.createElement(`div`,{className:`d-flex flex-column gap-xs`},t.createElement(`div`,{className:r(`d-flex`,f?`justify-content-between`:`justify-content-end`)},f?t.createElement(`span`,{className:`font-strong`,id:T?w:void 0},f):null,p?t.createElement(`span`,{className:`font-strong`},x,`%`):null),D):D}const s=e(o,`Progress`);export{a as n,s as t};
|
|
2
|
-
//# sourceMappingURL=progress-zWkTltor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"progress-zWkTltor.js","names":[],"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 {\n createPolymorphicComponent,\n PolymorphicComponentProps,\n PolymorphicRef\n} from '../../utils/polymorphic'\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 * 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 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} fg-contrast`,\n {\n striped,\n animated\n },\n className\n )\n\n return (\n <Component\n {...rest}\n className={_className}\n 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 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 animated,\n children,\n className,\n color,\n component,\n height,\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 ? children : inlineValue ? `${clampedValue}%` : 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={clampedValue}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-label={ariaLabel ?? (typeof label === 'string' ? label : undefined)}\n aria-labelledby={!ariaLabel && isNodeLabel ? labelId : undefined}\n style={_style}\n ref={ref}\n >\n <ProgressBar animated={animated} color={color} striped={striped} value={clampedValue}>\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 {showValue ? <span className=\"font-strong\">{clampedValue}%</span> : 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":"0IA8CA,SAAS,EACP,CACE,WACA,WACA,YACA,QACA,YACA,UACA,QACA,QAAQ,EACR,GAAG,GAEL,EACA,CACA,IAAM,EAAY,GAAa,MACzB,EAAe,KAAK,IAAI,IAAK,KAAK,IAAI,EAAG,CAAK,CAAC,EAC/C,EAAa,EACjB,eACA,GAAS,MAAM,EAAM,cACrB,CACE,UACA,UACF,EACA,CACF,EAEA,OACE,EAAA,cAAC,EAAD,CACE,GAAI,EACJ,UAAW,EACX,MAAO,CAAE,MAAO,GAAG,EAAa,GAAI,GAAG,CAAM,EACxC,KAGI,EADT,EAAA,cAAC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+0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{c as e}from"./slot-CNhFZdHF.js";import{t}from"./useForkedRef-DVEfT-KI.js";import{n,t as r}from"./FormHelp-AE6_iSLJ.js";import{t as i}from"./validationClassName-gRGs4KBm.js";import{t as a}from"./renderFormCheck-DN_-V62U.js";import{n as o,r as s}from"./unhandledProps-9Kdj7WVf.js";import{t as c}from"./flex-B52oLCCC.js";import l,{createContext as u,forwardRef as d,useContext as f,useRef as p}from"react";import m from"classnames";import{useRadio as h,useRadioGroup as g}from"react-aria";import{useRadioGroupState as _}from"react-stately";const v=u(null),y=[...o,`form`,`name`,`required`,`tabIndex`],b=d(({button:n,children:r,className:o,color:c,disabled:u,id:d,label:g,size:_,style:b,...x},S)=>{let C=f(v);if(!C)throw Error(`Radio must be rendered inside a RadioGroup.`);let{describedBy:w,state:T,valid:E}=C,D=T.isInvalid,O=p(null),k=t(S,O),A=g??r,{inputProps:j}=h({...x,children:A,isDisabled:u},T,O),M=m(i(D,E));return a({button:n,className:o,color:c,input:l.createElement(`input`,{...s(j,x,y),"aria-describedby":e(x[`aria-describedby`],w),className:M,id:d,ref:k}),invalid:D,label:A,size:_,style:b,valid:E})});b.displayName=`Radio`;const x=d(({children:t,className:a,defaultValue:o,description:u,disabled:d,errorMessage:f,invalid:p,label:h,name:y,onChange:b,orientation:x,required:S,valid:C,value:w,...T},E)=>{let D={...T,defaultValue:o,description:u,errorMessage:f,isDisabled:d,isInvalid:p,isRequired:S,label:h,name:y,onChange:b,orientation:x,value:w},O=_(D),{radioGroupProps:k,labelProps:A,descriptionProps:j,errorMessageProps:M}=g(D,O),N=m(`form-field`,i(p,C),a),P=e(!!u&&j.id,!!(p&&f)&&M.id),F=l.createElement(v.Provider,{value:{describedBy:P,state:O,valid:C}},t);return l.createElement(`fieldset`,{...s(k,T,[`onBlur`,`onFocus`]),"aria-describedby":e(P,T[`aria-describedby`]),className:N,ref:E},h&&l.createElement(`legend`,{className:`form-label`,...A},h),x===`horizontal`?l.createElement(c,{wrap:`wrap`,gap:`md`},F):F,u&&l.createElement(r,j,u),p&&f&&l.createElement(n,{invalid:!0,...M},f))});x.displayName=`RadioGroup`;export{b as n,x as t};
|
|
2
|
-
//# sourceMappingURL=radio-B6gJdtoN.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"radio-B6gJdtoN.js","names":[],"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`, `form` and required state, and which one is the tab stop.\nconst RADIO_PROPS = [...TOGGLE_PROPS, 'form', '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 />\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 } from 'react'\nimport classNames from 'classnames'\nimport { AriaRadioGroupProps, useRadioGroup } from 'react-aria'\nimport { RadioGroupProps as StatelyRadioGroupProps, useRadioGroupState } from 'react-stately'\n\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.\n */\n errorMessage?: ReactNode\n /**\n * Set group validation state to invalid.\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.\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 invalid,\n label,\n name,\n onChange,\n orientation,\n required,\n valid,\n value,\n ...rest\n },\n ref\n ) => {\n const groupProps = {\n ...rest,\n defaultValue,\n description,\n errorMessage,\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 ref={ref}\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 {...errorMessageProps}>\n {errorMessage}\n </FormFeedback>\n )}\n </fieldset>\n )\n }\n)\n\nRadioGroup.displayName = 'RadioGroup'\n"],"mappings":"ikBAkBA,MAAa,EAAoB,EAA6C,IAAI,ECmC5E,EAAc,CAAC,GAAG,EAAc,OAAQ,OAAQ,WAAY,UAAU,EAK/D,EAAQ,GAClB,CAAE,SAAQ,WAAU,YAAW,QAAO,WAAU,KAAI,QAAO,OAAM,QAAO,GAAG,GAAQ,IAAQ,CAC1F,IAAM,EAAQ,EAAW,CAAiB,EAE1C,GAAI,CAAC,EACH,MAAU,MAAM,6CA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C,EAAA,cAAC,SAAD,CAAQ,UAAU,aAAa,GAAI,CAE3B,EADL,CACK,EAET,IAAgB,aACf,EAAA,cAAC,EAAD,CAAM,KAAK,OAAO,IAAI,IAEhB,EADH,CACG,EAEN,EAED,GAAe,EAAA,cAAC,EAAa,EAAmB,CAAsB,EACtE,GAAW,GACV,EAAA,cAAC,EAAD,CAAc,QAAA,GAAQ,GAAI,CAEZ,EADX,CACW,CAER,CAEd,CACF,EAEA,EAAW,YAAc"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{t as e}from"./useFormField-BOqmBTC4.js";import{t}from"./renderFormField-Brkw1yA6.js";import{t as n}from"./validationClassName-gRGs4KBm.js";import r,{forwardRef as i}from"react";import a from"classnames";const o=i(({className:i,help:o,id:s,invalid:c,invalidFeedback:l,label:u,valid:d,validFeedback:f,...p},m)=>{let{describedBy:h,feedbackId:g,helpId:_,inputId:v}=e({ariaDescribedBy:p[`aria-describedby`],help:o,id:s,invalid:c,invalidFeedback:l,valid:d,validFeedback:f}),y=a(`form-range`,n(c,d),i);return t({children:r.createElement(`input`,{...p,"aria-describedby":h,"aria-invalid":c||void 0,className:y,id:v,ref:m,type:`range`}),help:o,ids:{feedback:g,help:_,input:v},invalid:c,invalidFeedback:l,label:u,valid:d,validFeedback:f})});o.displayName=`RangeInput`;export{o as t};
|
|
2
|
-
//# sourceMappingURL=range-input-CT_8TKL7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"range-input-CT_8TKL7.js","names":[],"sources":["../../src/components/range-input/RangeInput.tsx"],"sourcesContent":["import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes, ReactNode } from 'react'\nimport classNames from 'classnames'\n\nimport { useFormField } 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 { className, help, id, invalid, invalidFeedback, label, valid, validFeedback, ...rest },\n ref\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={ref}\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":"mPAoEA,MAAa,EAAa,GAEtB,CAAE,YAAW,OAAM,KAAI,UAAS,kBAAiB,QAAO,QAAO,gBAAe,GAAG,GACjF,IACG,CACH,GAAM,CAAE,cAAa,aAAY,SAAQ,WAAY,EAAa,CAChE,gBAAiB,EAAK,oBACtB,OACA,KACA,UACA,kBACA,QACA,eACF,CAAC,EAEK,EAAa,EAAW,aAAc,EAAoB,EAAS,CAAK,EAAG,CAAS,EAE1F,OAAO,EAAgB,CACrB,SACE,EAAA,cAAC,QAAD,CACE,GAAI,EACJ,mBAAkB,EAClB,eAAc,GAAW,IAAA,GACzB,UAAW,EACX,GAAI,EACC,MACL,KAAK,OACN,CAAA,EAEH,OACA,IAAK,CAAE,SAAU,EAAY,KAAM,EAAQ,MAAO,CAAQ,EAC1D,UACA,kBACA,QACA,QACA,eACF,CAAC,CACH,CACF,EAEA,EAAW,YAAc"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./FormLabel-CYcQiFUI.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 n.createElement(e,{customClassName:o,style:d},s,l)}let p=r(`check-input`,o,t(c,f));if(!l)return n.createElement(`span`,{className:p,style:d},s);let m=r(`form-check`,u,t(c,f),a);return n.createElement(e,{customClassName:m,style:d},n.createElement(`span`,{className:p},s),l)};export{i as t};
|
|
2
|
-
//# sourceMappingURL=renderFormCheck-DN_-V62U.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderFormCheck-DN_-V62U.js","names":[],"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. `style` goes 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 if (!label) {\n return (\n <span className={checkInputClassName} 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":"4IA2CA,MAAa,GAAmB,CAC9B,SACA,YACA,QACA,QACA,UACA,QACA,OACA,QACA,WAC4B,CAC5B,GAAI,EAAQ,CACV,IAAM,EAAa,EACjB,SACA,eACA,EAAO,MACP,EAAO,QACP,EAAO,KACP,EAAO,MACP,EAAoB,EAAS,CAAK,EAClC,CACF,EACA,OACE,EAAA,cAAC,EAAD,CAAW,gBAAiB,EAAmB,OAGpC,EAFR,EACA,CACQ,CAEf,CAEA,IAAM,EAAsB,EAAW,cAAe,EAAO,EAAoB,EAAS,CAAK,CAAC,EAEhG,GAAI,CAAC,EACH,OACE,EAAA,cAAC,OAAD,CAAM,UAAW,EAA4B,OAEvC,EADH,CACG,EAIV,IAAM,EAAa,EAAW,aAAc,EAAM,EAAoB,EAAS,CAAK,EAAG,CAAS,EAEhG,OACE,EAAA,cAAC,EAAD,CAAW,gBAAiB,EAAmB,OAGpC,EAFT,EAAA,cAAC,OAAD,CAAM,UAAW,CAAkC,EAAZ,CAAY,EAClD,CACQ,CAEf"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{n as e,t}from"./FormHelp-AE6_iSLJ.js";import{t as n}from"./FormLabel-CYcQiFUI.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:r.createElement(`div`,{className:i(`form-field`,o),ref:f},d&&r.createElement(n,{htmlFor:c.input,id:c.label},d),a,s&&r.createElement(t,{id:c.help},s),h&&r.createElement(e,{id:c.feedback,invalid:!0},u),g&&r.createElement(e,{id:c.feedback,valid:!0},m))};export{a as t};
|
|
2
|
-
//# sourceMappingURL=renderFormField-Brkw1yA6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderFormField-Brkw1yA6.js","names":[],"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":"wIAmCA,MAAa,GAAmB,CAC9B,WACA,YACA,OACA,MAAM,CAAC,EACP,UACA,kBACA,QACA,MACA,QACA,mBACuC,CAOvC,IAAM,EAAsB,GAAQ,GAAW,GACzC,EAAoB,GAAQ,GAAS,IAAkB,CAAC,EAc9D,MAJI,CAAC,GAAS,CAAC,GAAQ,CAAC,GAAmB,CAAC,GAAiB,CAAC,EACrD,EAIP,EAAA,cAAC,MAAD,CAAK,UAAW,EAAW,aAAc,CAAS,EAAQ,KAkBrD,EAjBF,GACC,EAAA,cAAC,EAAD,CAAW,QAAS,EAAI,MAAO,GAAI,EAAI,KAE5B,EADR,CACQ,EAEZ,EACA,GAAQ,EAAA,cAAC,EAAD,CAAU,GAAI,EAAI,IAAsB,EAAf,CAAe,EAChD,GACC,EAAA,cAAC,EAAD,CAAc,GAAI,EAAI,SAAU,QAAA,EAElB,EADX,CACW,EAEf,GACC,EAAA,cAAC,EAAD,CAAc,GAAI,EAAI,SAAU,MAAA,EAElB,EADX,CACW,CAEb,CAET"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./iconSlot-BNu2MrFI.js";import t from"react";const n=({icon:n,label:r,description:i,selected:a})=>n==null&&i==null&&!a?r:t.createElement(t.Fragment,null,n!=null&&t.createElement(`span`,{className:`menu-item-icon`,"aria-hidden":`true`},n),i==null?r:t.createElement(`span`,{className:`menu-item-content`},t.createElement(`span`,null,r),t.createElement(`small`,{className:`menu-item-description`},i)),a&&t.createElement(e,{icon:`check`,className:`menu-item-check`}));export{n as t};
|
|
2
|
-
//# sourceMappingURL=renderMenuItemContent-DUezZrpj.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"renderMenuItemContent-DUezZrpj.js","names":[],"sources":["../../src/utils/renderMenuItemContent.tsx"],"sourcesContent":["import React, { ReactNode } from 'react'\n\nimport { IconSlot } from './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":"gEA8BA,MAAa,GAAyB,CACpC,OACA,QACA,cACA,cAEI,GAAQ,MAAQ,GAAe,MAAQ,CAAC,EAAiB,EAG3D,EAAA,cAAA,EAAA,SAAA,KACG,GAAQ,MACP,EAAA,cAAC,OAAD,CAAM,UAAU,iBAAiB,cAAY,MAEvC,EADH,CACG,EAEP,GAAe,KAMd,EALA,EAAA,cAAC,OAAD,CAAM,UAAU,mBAGV,EAFJ,EAAA,cAAC,OAAA,KAAM,CAAY,EACnB,EAAA,cAAC,QAAD,CAAO,UAAU,uBAA4C,EAAnB,CAAmB,CACzD,EAIP,GAAY,EAAA,cAAC,EAAD,CAAU,KAAK,QAAQ,UAAU,iBAAmB,CAAA,CACjE"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.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,t){let n=null,r=null,i=!1;for(let a of e){let e=a.getBoundingClientRect();(e.width!==0||e.height!==0)&&(e.top>=t.bottom||(n===null&&(n=a.id,i=e.top>=t.top),r=a.id))}return i?{id:n,atStart:i}:{id:r,atStart:i}}function f(e,t){return e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1}function p(e,t={}){let{root:n,rootMargin:i=`0px 0px -25%`}=t,[a,l]=o(null),p=e.join(`\0`),[m,h]=o(0);return r(()=>{let e=p?p.split(`\0`):[];if(!e.length||typeof IntersectionObserver>`u`){l(null);return}let t=s(n),r=t??window,a=[],o=!1,m=()=>{let{id:e,atStart:n}=d(a,u(t,i));l(e),n!==o&&(o=n,n?r.addEventListener(`scroll`,_,{passive:!0}):r.removeEventListener(`scroll`,_))},g=0,_=()=>{g||=requestAnimationFrame(()=>{g=0,m()})},v=new IntersectionObserver(m,{root:t,rootMargin:i,threshold:[0,1]}),y=()=>{let n=e.map(e=>c(e,t)).filter(e=>e!==null).sort(f);if(n.length===a.length&&n.every((e,t)=>e===a[t]))return!1;for(let e of a)n.includes(e)||v.unobserve(e);for(let e of n)a.includes(e)||v.observe(e);return a=n,!0};y()||m();let b=0,x=new MutationObserver(()=>{b||=requestAnimationFrame(()=>{if(b=0,s(n)!==t){h(e=>e+1);return}y()&&m()})});return x.observe(document.body,{attributeFilter:[`id`],childList:!0,subtree:!0}),r.addEventListener(`scrollend`,m),()=>{v.disconnect(),x.disconnect(),cancelAnimationFrame(b),cancelAnimationFrame(g),r.removeEventListener(`scrollend`,m),r.removeEventListener(`scroll`,_)}},[p,n,i,m]),a}function m(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 h(e){let t=[],n=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 g(){return typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches}function _(e,t){let n=g()?`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 v({children:l,onActiveChange:u,root:d,rootMargin:f,smoothScroll:g=!1}){let v=a(new Map),[y,b]=o(0),[x,S]=o([]),C=n((e,t)=>{v.current.set(e,t),b(e=>e+1);let n=new MutationObserver(()=>b(e=>e+1));return n.observe(e,{attributeFilter:[`href`]}),()=>{n.disconnect(),v.current.delete(e),t(!1),b(e=>e+1)}},[]);r(()=>{let e=[];for(let t of v.current.keys()){let n=m(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=p(x,{root:d,rootMargin:f});r(()=>{let e=new Map;if(w!==null){for(let t of v.current.keys())m(t)===w&&e.set(t,`current`);for(let t of[...e.keys()])for(let n of h(t))v.current.has(n)&&!e.has(n)&&e.set(n,`parent`)}for(let[t,n]of v.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:g});r(()=>{D.current={root:d,smoothScroll:g}});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=m(e.currentTarget),i=s(t),a=r===null?null:c(r,i);a&&(e.preventDefault(),_(a,i))},[]),k=i(()=>({register:C,onLinkClick:O}),[C,O]);return t.createElement(e.Provider,{value:k},l)}v.displayName=`Scrollspy`;export{p as n,v as t};
|
|
2
|
-
//# sourceMappingURL=scrollspy-C2HmrnZ4.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"scrollspy-C2HmrnZ4.js","names":[],"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\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. A section that isn't rendered\n * (`display: none`) takes no part.\n */\nfunction pickActive(sections: readonly HTMLElement[], zone: Zone): 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 (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`. Returns\n * its id, or `null` when no section has 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\n const update = () => {\n const { id, atStart } = pickActive(sections, activationZone(rootElement, rootMargin))\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 if (atStart !== followingScroll) {\n followingScroll = atStart\n if (atStart) scroller.addEventListener('scroll', onScroll, { passive: true })\n else scroller.removeEventListener('scroll', onScroll)\n }\n }\n\n let scrollFrame = 0\n const onScroll = () => {\n if (scrollFrame) return\n scrollFrame = requestAnimationFrame(() => {\n scrollFrame = 0\n update()\n })\n }\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.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F,EAAG,CAAC,EAAU,CAAO,CAAC,EAEtB,IAAM,EAAoB,EAAO,CAAc,EACzC,EAAc,EAAsB,IAAI,EAC9C,MAAgB,CACd,EAAkB,QAAU,CAC9B,CAAC,EACD,MAAgB,CACV,EAAY,UAAY,IAC5B,EAAY,QAAU,EACtB,EAAkB,UAAU,CAAQ,EACtC,EAAG,CAAC,CAAQ,CAAC,EAEb,IAAM,EAAa,EAAO,CAAE,OAAM,cAAa,CAAC,EAChD,MAAgB,CACd,EAAW,QAAU,CAAE,OAAM,cAAa,CAC5C,CAAC,EAED,IAAM,EAAc,EAAa,GAA+B,CAC9D,GAAM,CAAE,OAAM,gBAAiB,EAAW,QAC1C,GACE,CAAC,GACD,EAAM,kBACN,EAAM,SAAW,GACjB,EAAM,SACN,EAAM,SACN,EAAM,UACN,EAAM,OAEN,OAEF,IAAM,EAAK,EAAW,EAAM,aAAa,EACnC,EAAc,EAAY,CAAI,EAC9B,EAAU,IAAO,KAAO,KAAO,EAAY,EAAI,CAAW,EAC3D,IACL,EAAM,eAAe,EACrB,EAAgB,EAAS,CAAW,EACtC,EAAG,CAAC,CAAC,EAEC,EAAa,OACV,CAAE,WAAU,aAAY,GAC/B,CAAC,EAAU,CAAW,CACxB,EAEA,OAAO,EAAA,cAAC,EAAiB,SAAlB,CAA2B,MAAO,CAAiD,EAApC,CAAoC,CAC5F,CAEA,EAAU,YAAc"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{t as e}from"./useForkedRef-DVEfT-KI.js";import{t}from"./useFormField-BOqmBTC4.js";import{t as n}from"./iconSlot-BNu2MrFI.js";import{t as r}from"./renderFormField-Brkw1yA6.js";import{t as i}from"./validationClassName-gRGs4KBm.js";import{r as a,t as o}from"./unhandledProps-9Kdj7WVf.js";import s,{forwardRef as c,useRef as l}from"react";import u from"classnames";import{mergeProps as d,useButton as f,useSearchField as p}from"react-aria";import{useSearchFieldState as m}from"react-stately";function h({ariaLabel:e,buttonProps:t,icon:r}){let i=l(null),{buttonProps:a}=f({...t,"aria-label":e??t[`aria-label`]},i);return s.createElement(`button`,{...a,className:`button icon-only input-adorn search-field-clear`,ref:i},s.createElement(n,{icon:`clear`,override:r}))}const g=c(({className:c,clearAriaLabel:f,clearIcon:g,defaultValue:_,disabled:v,help:y,id:b,invalid:x,invalidFeedback:S,label:C,onChange:w,onClear:T,onSubmit:E,readOnly:D,searchIcon:O,size:k,style:A,valid:j,validFeedback:M,value:N,...P},F)=>{let I=l(null),L=e(F,I),{describedBy:R,feedbackId:z,helpId:B,inputId:V,labelId:H,labelledBy:U}=t({ariaDescribedBy:P[`aria-describedby`],ariaLabelledBy:P[`aria-labelledby`],help:y,id:b,invalid:x,invalidFeedback:S,label:C,valid:j,validFeedback:M}),W={...P,"aria-describedby":R,"aria-labelledby":U,defaultValue:_,id:V,isDisabled:v,isInvalid:x,isReadOnly:D,onChange:w,onClear:T,onSubmit:E,value:N},G=m(W),{clearButtonProps:K,inputProps:q}=p(W,G,I);return r({children:s.createElement(`div`,{className:u(`form-input`,`search-field`,k,c),style:A},O!==!1&&s.createElement(`span`,{className:`input-adorn search-field-icon`},s.createElement(n,{icon:`search`,override:O})),s.createElement(`input`,{...a(d(q,{onKeyDown:e=>{let t=e.shiftKey||e.altKey||e.ctrlKey||e.metaKey;E&&e.key===`Enter`&&!e.nativeEvent.isComposing&&(t||D)&&(e.preventDefault(),E(G.value))}}),P,o),"aria-describedby":R,className:u(`ghost-input`,i(x,j)),ref:L}),G.value!==``&&!v&&!D&&s.createElement(h,{ariaLabel:f,buttonProps:K,icon:g})),help:y,ids:{feedback:z,help:B,input:V,label:H},invalid:x,invalidFeedback:S,label:C,valid:j,validFeedback:M})});g.displayName=`SearchField`;export{g as t};
|
|
2
|
-
//# sourceMappingURL=search-field--nDoCI_E.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"search-field--nDoCI_E.js","names":[],"sources":["../../src/components/search-field/SearchField.tsx"],"sourcesContent":["import React, {\n forwardRef,\n InputHTMLAttributes,\n KeyboardEvent,\n ReactNode,\n RefObject,\n useRef\n} from 'react'\nimport classNames from 'classnames'\nimport { AriaSearchFieldProps, mergeProps, useButton, useSearchField } from 'react-aria'\nimport { useSearchFieldState } from 'react-stately'\n\nimport './SearchField.scss'\nimport { useForkedRef, useFormField } from '../../hooks'\nimport { IconValue } from '../../utils/iconConfig'\nimport { IconSlot } from '../../utils/iconSlot'\nimport { mergeUnhandledProps, TEXT_FIELD_PROPS } from '../../utils/unhandledProps'\nimport { validationClassName } from '../../utils/validationClassName'\nimport { renderFormField } from '../form-field/renderFormField'\n\nexport interface SearchFieldProps extends Omit<\n InputHTMLAttributes<HTMLInputElement>,\n 'defaultValue' | 'onChange' | 'onSubmit' | 'size' | 'type' | 'value'\n> {\n /**\n * The accessible name of the clear button. Defaults to react-aria's, in the locale's language\n * (\"Clear search\").\n */\n clearAriaLabel?: string\n /**\n * The icon of the clear button, in place of `IconProvider`'s `clear` icon.\n */\n clearIcon?: IconValue\n /**\n * A string of all className you want applied to the component.\n */\n className?: string\n /**\n * The value of the field, uncontrolled.\n */\n defaultValue?: string\n /**\n * Toggle the disabled state for the component.\n */\n disabled?: boolean\n /**\n * A description for the field, rendered below it.\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 it when `invalid` is set.\n */\n invalidFeedback?: ReactNode\n /**\n * The field's caption, rendered as a `FormLabel` associated with the input.\n */\n label?: ReactNode\n /**\n * Handler that is called when the value changes.\n */\n onChange?: (value: string) => void\n /**\n * Handler that is called when the field is cleared, by the clear button or the Escape key.\n */\n onClear?: () => void\n /**\n * Handler that is called when the Enter key is pressed, with the value. When set, Enter, with\n * or without a modifier key, no longer submits the input's form.\n */\n onSubmit?: (value: string) => void\n /**\n * Toggle the readonly state for the component.\n */\n readOnly?: boolean\n /**\n * The icon at the field's start, in place of `IconProvider`'s `search` icon. `false` leaves it\n * out.\n */\n searchIcon?: IconValue | false\n /**\n * Size the component sm or lg.\n */\n size?: 'sm' | 'lg'\n /**\n * Set component validation state to valid.\n */\n valid?: boolean\n /**\n * A success message for the field, rendered below it when `valid` is set.\n */\n validFeedback?: ReactNode\n /**\n * The value of the field, controlled.\n */\n value?: string\n}\n\n// The clear button. A `<button>` react-aria keeps out of the tab order, since Escape does the\n// same; a press leaves focus on the input.\nfunction ClearButton({\n ariaLabel,\n buttonProps,\n icon\n}: {\n ariaLabel?: string\n buttonProps: ReturnType<typeof useSearchField>['clearButtonProps']\n icon?: IconValue\n}) {\n const ref = useRef<HTMLButtonElement>(null)\n const { buttonProps: props } = useButton(\n { ...buttonProps, 'aria-label': ariaLabel ?? buttonProps['aria-label'] },\n ref as RefObject<HTMLButtonElement | null>\n )\n return (\n <button {...props} className=\"button icon-only input-adorn search-field-clear\" ref={ref}>\n <IconSlot icon=\"clear\" override={icon} />\n </button>\n )\n}\n\nexport const SearchField = forwardRef<HTMLInputElement, SearchFieldProps>(\n (\n {\n className,\n clearAriaLabel,\n clearIcon,\n defaultValue,\n disabled,\n help,\n id,\n invalid,\n invalidFeedback,\n label,\n onChange,\n onClear,\n onSubmit,\n readOnly,\n searchIcon,\n size,\n style,\n valid,\n validFeedback,\n value,\n ...rest\n },\n ref\n ) => {\n const inputRef = useRef<HTMLInputElement>(null)\n const forkedRef = useForkedRef(ref, inputRef)\n\n const { describedBy, feedbackId, helpId, inputId, labelId, labelledBy } = useFormField({\n ariaDescribedBy: rest['aria-describedby'],\n ariaLabelledBy: rest['aria-labelledby'],\n help,\n id,\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n\n const fieldProps = {\n ...rest,\n 'aria-describedby': describedBy,\n 'aria-labelledby': labelledBy,\n defaultValue,\n id: inputId,\n isDisabled: disabled,\n isInvalid: invalid,\n isReadOnly: readOnly,\n onChange,\n onClear,\n onSubmit,\n value\n } as AriaSearchFieldProps\n const state = useSearchFieldState(fieldProps)\n const { clearButtonProps, inputProps } = useSearchField(fieldProps, state, inputRef)\n\n // react-aria's Enter shortcut matches Enter alone, and a read-only field has none, so with\n // `onSubmit` Shift+Enter, or Enter in a read-only field, would still submit the form.\n const submitProps = {\n onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => {\n const modified = event.shiftKey || event.altKey || event.ctrlKey || event.metaKey\n if (!onSubmit || event.key !== 'Enter' || event.nativeEvent.isComposing) return\n if (!modified && !readOnly) return\n event.preventDefault()\n onSubmit(state.value)\n }\n }\n\n return renderFormField({\n // The input adorn shape of chassis-css: a `.form-input` around a `.ghost-input`, which takes\n // the validation classes, with the icon and the clear button as `.input-adorn`s. `style`\n // goes on the wrapper, with `className`. `aria-describedby` after the spread: react-aria's\n // own adds ids it never renders (FORMS.md, gotcha 6).\n children: (\n <div className={classNames('form-input', 'search-field', size, className)} style={style}>\n {searchIcon !== false && (\n <span className=\"input-adorn search-field-icon\">\n <IconSlot icon=\"search\" override={searchIcon} />\n </span>\n )}\n <input\n {...mergeUnhandledProps(mergeProps(inputProps, submitProps), rest, TEXT_FIELD_PROPS)}\n aria-describedby={describedBy}\n className={classNames('ghost-input', validationClassName(invalid, valid))}\n ref={forkedRef}\n />\n {state.value !== '' && !disabled && !readOnly && (\n <ClearButton\n ariaLabel={clearAriaLabel}\n buttonProps={clearButtonProps}\n icon={clearIcon}\n />\n )}\n </div>\n ),\n help,\n ids: { feedback: feedbackId, help: helpId, input: inputId, label: labelId },\n invalid,\n invalidFeedback,\n label,\n valid,\n validFeedback\n })\n }\n)\n\nSearchField.displayName = 'SearchField'\n"],"mappings":"ghBAuGA,SAAS,EAAY,CACnB,YACA,cACA,QAKC,CACD,IAAM,EAAM,EAA0B,IAAI,EACpC,CAAE,YAAa,GAAU,EAC7B,CAAE,GAAG,EAAa,aAAc,GAAa,EAAY,aAAc,EACvE,CACF,EACA,OACE,EAAA,cAAC,SAAD,CAAQ,GAAI,EAAO,UAAU,kDAAuD,KAE5E,EADN,EAAA,cAAC,EAAD,CAA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AAC,GACnC,EAAA,cAAC,EAAD,CACE,UAAW,EACX,YAAa,EACb,KAAM,CACP,CAAA,CAEA,EAEP,OACA,IAAK,CAAE,SAAU,EAAY,KAAM,EAAQ,MAAO,EAAS,MAAO,CAAQ,EAC1E,UACA,kBACA,QACA,QACA,eACF,CAAC,CACH,CACF,EAEA,EAAY,YAAc"}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import"./focus-ring-SR_LwaN7.js";import{v as e}from"./slot-CNhFZdHF.js";import{t}from"./useForkedRef-DVEfT-KI.js";import{t as n}from"./useFormField-BOqmBTC4.js";import{t as r}from"./renderFormField-Brkw1yA6.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(({adornEnd:o,adornStart:l,children:u,className:d,help:f,htmlSize:p,id:m,invalid:h,invalidFeedback:g,label:_,multiple:v,options:y,placeholder:b,size:x,valid:S,validFeedback:C,...w},T)=>{let E=s(null),D=t(T,E),O=Array.isArray(y)?y.filter(e=>typeof e==`object`&&!!e.selected).map(e=>String(e.value??``)):[];e(!v&&O.length>1,"Select: more than one option has `selected: true` but `multiple` is not set — only the last one will be selected, matching native <select> behavior.");let k=O.length&&w.value===void 0&&w.defaultValue===void 0?v?O:O[O.length-1]:void 0,{describedBy:A,feedbackId:j,helpId:M,inputId:N}=n({ariaDescribedBy:w[`aria-describedby`],help:f,id:m,invalid:h,invalidFeedback:g,valid:S,validFeedback:C}),P=l!=null||o!=null,F=!v&&(!p||p<=1),I=c(P?`ghost-input`:`form-input`,!P&&x,i(h,S),!P&&d),L=e=>{let t=E.current,n=e.target;if(t&&!t.disabled&&F&&n!==t&&!n.closest(`button, a`)){t.focus();try{t.showPicker?.()}catch{}}},R=a.createElement(`select`,{...w,"aria-describedby":A,"aria-invalid":h||void 0,className:I,id:N,multiple:v,ref:D,size:p,...k!==void 0&&{defaultValue:k}},b&&a.createElement(`option`,{value:``,disabled:!0},b),y?y.map((e,t)=>a.createElement(`option`,{...typeof e==`object`&&e.disabled&&{disabled:e.disabled},...typeof e==`object`&&e.value!=null&&{value:e.value},key:t},typeof e==`string`?e:e.label??String(e.value??``))):u),z=P?a.createElement(`div`,{className:c(`form-input`,F&&`form-caret`,x,d),onClick:L},l,R,o):R;return r({children:z,help:f,ids:{feedback:j,help:M,input:N},invalid:h,invalidFeedback:g,label:_,valid:S,validFeedback:C})});l.displayName=`Select`;export{l as t};
|
|
2
|
-
//# sourceMappingURL=select-BwJIfv9f.js.map
|