@techzyapp/ui-library 1.0.31 → 1.0.33
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/dist/AdminRoot-CwUHa2us.js +107 -0
- package/dist/AdminRoot-CwUHa2us.js.map +1 -0
- package/dist/AdminRoot-cjP_Ad4r.cjs +2 -0
- package/dist/AdminRoot-cjP_Ad4r.cjs.map +1 -0
- package/dist/{Alert-BM5WOI_u.cjs → Alert-CfjDmLR8.cjs} +2 -2
- package/dist/{Alert-BM5WOI_u.cjs.map → Alert-CfjDmLR8.cjs.map} +1 -1
- package/dist/{Alert-BLqAcEoT.js → Alert-LJDrtkJy.js} +3 -3
- package/dist/{Alert-BLqAcEoT.js.map → Alert-LJDrtkJy.js.map} +1 -1
- package/dist/{Breadcrumbs-Di4-Acfb.cjs → Breadcrumbs-COb2zmDk.cjs} +2 -2
- package/dist/{Breadcrumbs-Di4-Acfb.cjs.map → Breadcrumbs-COb2zmDk.cjs.map} +1 -1
- package/dist/{Breadcrumbs-CzHGbN2c.js → Breadcrumbs-DYeVrOns.js} +3 -3
- package/dist/{Breadcrumbs-CzHGbN2c.js.map → Breadcrumbs-DYeVrOns.js.map} +1 -1
- package/dist/{Button-BQhiJq8e.cjs → Button-BD5wpg-t.cjs} +2 -2
- package/dist/{Button-BQhiJq8e.cjs.map → Button-BD5wpg-t.cjs.map} +1 -1
- package/dist/{Button-9Qcdkw-y.js → Button-PBZnkRNn.js} +2 -2
- package/dist/{Button-9Qcdkw-y.js.map → Button-PBZnkRNn.js.map} +1 -1
- package/dist/{Calendar-dXhLgOUH.cjs → Calendar-842vjtdN.cjs} +2 -2
- package/dist/{Calendar-dXhLgOUH.cjs.map → Calendar-842vjtdN.cjs.map} +1 -1
- package/dist/{Calendar-BB-C0qXO.js → Calendar-Bb5Ekbpr.js} +3 -3
- package/dist/{Calendar-BB-C0qXO.js.map → Calendar-Bb5Ekbpr.js.map} +1 -1
- package/dist/{Card-BERQfyhJ.js → Card-CV_rHego.js} +2 -2
- package/dist/{Card-BERQfyhJ.js.map → Card-CV_rHego.js.map} +1 -1
- package/dist/{Card-DULpoOfj.cjs → Card-DL7XnkOA.cjs} +2 -2
- package/dist/{Card-DULpoOfj.cjs.map → Card-DL7XnkOA.cjs.map} +1 -1
- package/dist/{Chip-BuydTI6V.cjs → Chip-CLPIPC9a.cjs} +2 -2
- package/dist/{Chip-BuydTI6V.cjs.map → Chip-CLPIPC9a.cjs.map} +1 -1
- package/dist/{Chip-DZ5Fz7jx.js → Chip-DdOUVF0Z.js} +2 -2
- package/dist/{Chip-DZ5Fz7jx.js.map → Chip-DdOUVF0Z.js.map} +1 -1
- package/dist/{CodeBlock-BySsTAtY.js → CodeBlock-B35NXZzd.js} +3 -3
- package/dist/{CodeBlock-BySsTAtY.js.map → CodeBlock-B35NXZzd.js.map} +1 -1
- package/dist/{CodeBlock-BPraYPoS.cjs → CodeBlock-C0dbyxcl.cjs} +2 -2
- package/dist/{CodeBlock-BPraYPoS.cjs.map → CodeBlock-C0dbyxcl.cjs.map} +1 -1
- package/dist/{ColorPicker-DJow7m2v.js → ColorPicker-6UraVYFy.js} +3 -3
- package/dist/{ColorPicker-DJow7m2v.js.map → ColorPicker-6UraVYFy.js.map} +1 -1
- package/dist/{ColorPicker-BTBTQD39.cjs → ColorPicker-DmLGKaYF.cjs} +2 -2
- package/dist/{ColorPicker-BTBTQD39.cjs.map → ColorPicker-DmLGKaYF.cjs.map} +1 -1
- package/dist/{ColorPickerPanel-D6agWM6y.js → ColorPickerPanel-DZ-W_wOI.js} +2 -2
- package/dist/{ColorPickerPanel-D6agWM6y.js.map → ColorPickerPanel-DZ-W_wOI.js.map} +1 -1
- package/dist/{ColorPickerPanel-DXIYwUoE.cjs → ColorPickerPanel-WuxwwfCI.cjs} +2 -2
- package/dist/{ColorPickerPanel-DXIYwUoE.cjs.map → ColorPickerPanel-WuxwwfCI.cjs.map} +1 -1
- package/dist/{ColorRamp-Bhj28c_6.js → ColorRamp-CSqzzHZx.js} +2 -2
- package/dist/{ColorRamp-Bhj28c_6.js.map → ColorRamp-CSqzzHZx.js.map} +1 -1
- package/dist/{ColorRamp-B45Rtwgw.cjs → ColorRamp-D_9gsqJl.cjs} +2 -2
- package/dist/{ColorRamp-B45Rtwgw.cjs.map → ColorRamp-D_9gsqJl.cjs.map} +1 -1
- package/dist/ConfigProvider-CVLHPXQm.cjs +2 -0
- package/dist/ConfigProvider-CVLHPXQm.cjs.map +1 -0
- package/dist/ConfigProvider-tvLbKiqu.js +347 -0
- package/dist/ConfigProvider-tvLbKiqu.js.map +1 -0
- package/dist/{CopyButton-Bfte6TJF.cjs → CopyButton-0w4OToIy.cjs} +2 -2
- package/dist/{CopyButton-Bfte6TJF.cjs.map → CopyButton-0w4OToIy.cjs.map} +1 -1
- package/dist/{CopyButton-CBk85MQ7.js → CopyButton-B_mYxcXV.js} +3 -3
- package/dist/{CopyButton-CBk85MQ7.js.map → CopyButton-B_mYxcXV.js.map} +1 -1
- package/dist/{DatePicker-eAzDnO2Y.js → DatePicker-Bt-M87zX.js} +4 -4
- package/dist/{DatePicker-eAzDnO2Y.js.map → DatePicker-Bt-M87zX.js.map} +1 -1
- package/dist/{DatePicker-DBiU4Mb6.cjs → DatePicker-D1uFIm3M.cjs} +2 -2
- package/dist/{DatePicker-DBiU4Mb6.cjs.map → DatePicker-D1uFIm3M.cjs.map} +1 -1
- package/dist/{DateTimePicker-CvaD8IkF.cjs → DateTimePicker-DPt-LDVJ.cjs} +2 -2
- package/dist/{DateTimePicker-CvaD8IkF.cjs.map → DateTimePicker-DPt-LDVJ.cjs.map} +1 -1
- package/dist/{DateTimePicker-M2UBjFVc.js → DateTimePicker-zJUc9crs.js} +7 -7
- package/dist/{DateTimePicker-M2UBjFVc.js.map → DateTimePicker-zJUc9crs.js.map} +1 -1
- package/dist/{DescriptionList-BhsmdtS1.js → DescriptionList-BLx9NfAW.js} +4 -4
- package/dist/{DescriptionList-BhsmdtS1.js.map → DescriptionList-BLx9NfAW.js.map} +1 -1
- package/dist/{DescriptionList-DQHNOTWl.cjs → DescriptionList-CPCbzU9b.cjs} +2 -2
- package/dist/{DescriptionList-DQHNOTWl.cjs.map → DescriptionList-CPCbzU9b.cjs.map} +1 -1
- package/dist/{Dropdown-BbaU1WDC.cjs → Dropdown-CMqWq6J_.cjs} +2 -2
- package/dist/{Dropdown-BbaU1WDC.cjs.map → Dropdown-CMqWq6J_.cjs.map} +1 -1
- package/dist/{Dropdown-BlmbYp1X.js → Dropdown-zlv96RLy.js} +2 -2
- package/dist/{Dropdown-BlmbYp1X.js.map → Dropdown-zlv96RLy.js.map} +1 -1
- package/dist/{EmptyState-2pA3XlOX.js → EmptyState-BEVEGcLx.js} +2 -2
- package/dist/{EmptyState-2pA3XlOX.js.map → EmptyState-BEVEGcLx.js.map} +1 -1
- package/dist/{EmptyState-ByBpy2vN.cjs → EmptyState-C54C0Qwc.cjs} +2 -2
- package/dist/{EmptyState-ByBpy2vN.cjs.map → EmptyState-C54C0Qwc.cjs.map} +1 -1
- package/dist/ErrorBoundary-8iu-mR5Y.cjs +2 -0
- package/dist/ErrorBoundary-8iu-mR5Y.cjs.map +1 -0
- package/dist/ErrorBoundary-BSJL381Y.js +49 -0
- package/dist/ErrorBoundary-BSJL381Y.js.map +1 -0
- package/dist/ErrorState-BXMjBWav.cjs +4 -0
- package/dist/ErrorState-BXMjBWav.cjs.map +1 -0
- package/dist/ErrorState-DKhZ4aJh.js +142 -0
- package/dist/ErrorState-DKhZ4aJh.js.map +1 -0
- package/dist/{FileCard-BYNJVmp0.cjs → FileCard-B3dfdTVN.cjs} +2 -2
- package/dist/{FileCard-BYNJVmp0.cjs.map → FileCard-B3dfdTVN.cjs.map} +1 -1
- package/dist/{FileCard-BNfUAgsF.js → FileCard-R_sB8Qbx.js} +3 -3
- package/dist/{FileCard-BNfUAgsF.js.map → FileCard-R_sB8Qbx.js.map} +1 -1
- package/dist/{FileUploader-DdICa5UC.cjs → FileUploader-4UMy0urx.cjs} +2 -2
- package/dist/{FileUploader-DdICa5UC.cjs.map → FileUploader-4UMy0urx.cjs.map} +1 -1
- package/dist/{FileUploader-TOWwDOSS.js → FileUploader-B55atuxq.js} +5 -5
- package/dist/{FileUploader-TOWwDOSS.js.map → FileUploader-B55atuxq.js.map} +1 -1
- package/dist/{Flag-DXPQ2t8z.cjs → Flag-CFvJHC0u.cjs} +2 -2
- package/dist/{Flag-DXPQ2t8z.cjs.map → Flag-CFvJHC0u.cjs.map} +1 -1
- package/dist/{Flag-DDR6OANA.js → Flag-D7fmMqqy.js} +2 -2
- package/dist/{Flag-DDR6OANA.js.map → Flag-D7fmMqqy.js.map} +1 -1
- package/dist/{FullscreenToggle-DmH1541W.js → FullscreenToggle-CXmPqxJv.js} +3 -3
- package/dist/{FullscreenToggle-DmH1541W.js.map → FullscreenToggle-CXmPqxJv.js.map} +1 -1
- package/dist/{FullscreenToggle-BKo1lDSE.cjs → FullscreenToggle-D7tUPCNI.cjs} +2 -2
- package/dist/{FullscreenToggle-BKo1lDSE.cjs.map → FullscreenToggle-D7tUPCNI.cjs.map} +1 -1
- package/dist/{IconButton-CvIXSFsr.cjs → IconButton-BVrO9TBP.cjs} +2 -2
- package/dist/{IconButton-CvIXSFsr.cjs.map → IconButton-BVrO9TBP.cjs.map} +1 -1
- package/dist/{IconButton-CL_6iMQh.js → IconButton-sC_E_TXd.js} +2 -2
- package/dist/{IconButton-CL_6iMQh.js.map → IconButton-sC_E_TXd.js.map} +1 -1
- package/dist/List-CXHlAI5w.js +38 -0
- package/dist/List-CXHlAI5w.js.map +1 -0
- package/dist/List-DOsh6w-d.cjs +2 -0
- package/dist/List-DOsh6w-d.cjs.map +1 -0
- package/dist/ListItem-CUeIBhOF.cjs +2 -0
- package/dist/ListItem-CUeIBhOF.cjs.map +1 -0
- package/dist/ListItem-ehFB7TUW.js +77 -0
- package/dist/ListItem-ehFB7TUW.js.map +1 -0
- package/dist/{Loader-Czzb450N.js → Loader-ChrouvaR.js} +2 -2
- package/dist/{Loader-Czzb450N.js.map → Loader-ChrouvaR.js.map} +1 -1
- package/dist/{Loader-CI1j71X8.cjs → Loader-DNCEHqZb.cjs} +2 -2
- package/dist/{Loader-CI1j71X8.cjs.map → Loader-DNCEHqZb.cjs.map} +1 -1
- package/dist/LocationPicker-CJ6bCJC4.cjs +2 -0
- package/dist/LocationPicker-CJ6bCJC4.cjs.map +1 -0
- package/dist/LocationPicker-DxiQ27k6.js +781 -0
- package/dist/LocationPicker-DxiQ27k6.js.map +1 -0
- package/dist/{Modal-DPObz0b-.cjs → Modal-BL_XihC8.cjs} +2 -2
- package/dist/{Modal-DPObz0b-.cjs.map → Modal-BL_XihC8.cjs.map} +1 -1
- package/dist/{Modal-DMJMw6kT.js → Modal-Do8pzyMl.js} +3 -3
- package/dist/{Modal-DMJMw6kT.js.map → Modal-Do8pzyMl.js.map} +1 -1
- package/dist/{MultiSelect-BTR6w5Ot.js → MultiSelect-BfsEdXNa.js} +4 -4
- package/dist/{MultiSelect-BTR6w5Ot.js.map → MultiSelect-BfsEdXNa.js.map} +1 -1
- package/dist/{MultiSelect-IDAJ5a5K.cjs → MultiSelect-WS5YNGRD.cjs} +2 -2
- package/dist/{MultiSelect-IDAJ5a5K.cjs.map → MultiSelect-WS5YNGRD.cjs.map} +1 -1
- package/dist/{NumberField-Cg0XEDgW.cjs → NumberField-CxiEfRAi.cjs} +2 -2
- package/dist/{NumberField-Cg0XEDgW.cjs.map → NumberField-CxiEfRAi.cjs.map} +1 -1
- package/dist/{NumberField-DlaW-g3Z.js → NumberField-P68n6q5m.js} +3 -3
- package/dist/{NumberField-DlaW-g3Z.js.map → NumberField-P68n6q5m.js.map} +1 -1
- package/dist/{OtpField-vxQuo-uR.js → OtpField-DjTJH4Kh.js} +2 -2
- package/dist/{OtpField-vxQuo-uR.js.map → OtpField-DjTJH4Kh.js.map} +1 -1
- package/dist/{OtpField-DsedK1nQ.cjs → OtpField-XieJfl1y.cjs} +2 -2
- package/dist/{OtpField-DsedK1nQ.cjs.map → OtpField-XieJfl1y.cjs.map} +1 -1
- package/dist/PageError-ClR7k0Zb.js +69 -0
- package/dist/PageError-ClR7k0Zb.js.map +1 -0
- package/dist/PageError-D7_Q8wz8.cjs +2 -0
- package/dist/PageError-D7_Q8wz8.cjs.map +1 -0
- package/dist/{PageLayout-BPbjTYS3.cjs → PageLayout-DTG83hLL.cjs} +2 -2
- package/dist/{PageLayout-BPbjTYS3.cjs.map → PageLayout-DTG83hLL.cjs.map} +1 -1
- package/dist/{PageLayout-Rk6KSxmn.js → PageLayout-XQ_aQTf5.js} +2 -2
- package/dist/{PageLayout-Rk6KSxmn.js.map → PageLayout-XQ_aQTf5.js.map} +1 -1
- package/dist/PageNotFound-CpwHMTxG.js +24 -0
- package/dist/PageNotFound-CpwHMTxG.js.map +1 -0
- package/dist/PageNotFound-D3wJ4Job.cjs +2 -0
- package/dist/PageNotFound-D3wJ4Job.cjs.map +1 -0
- package/dist/{Pagination-DNGKNQy0.cjs → Pagination-BF8cmQMi.cjs} +2 -2
- package/dist/{Pagination-DNGKNQy0.cjs.map → Pagination-BF8cmQMi.cjs.map} +1 -1
- package/dist/{Pagination-CNdkfXp2.js → Pagination-Df-F9i2o.js} +2 -2
- package/dist/{Pagination-CNdkfXp2.js.map → Pagination-Df-F9i2o.js.map} +1 -1
- package/dist/{PaletteField-BSIF5jI6.cjs → PaletteField-BFRPv7AC.cjs} +2 -2
- package/dist/{PaletteField-BSIF5jI6.cjs.map → PaletteField-BFRPv7AC.cjs.map} +1 -1
- package/dist/{PaletteField-Bp5Fgygh.js → PaletteField-DUu4jz1c.js} +3 -3
- package/dist/{PaletteField-Bp5Fgygh.js.map → PaletteField-DUu4jz1c.js.map} +1 -1
- package/dist/{PhoneField-BdmvslXQ.js → PhoneField-CXIQX_hR.js} +4 -4
- package/dist/{PhoneField-BdmvslXQ.js.map → PhoneField-CXIQX_hR.js.map} +1 -1
- package/dist/{PhoneField-BMhZeZkW.cjs → PhoneField-O5syyH7u.cjs} +2 -2
- package/dist/{PhoneField-BMhZeZkW.cjs.map → PhoneField-O5syyH7u.cjs.map} +1 -1
- package/dist/{Popconfirm-Cyaeybtj.js → Popconfirm-D4J7tlk_.js} +3 -3
- package/dist/{Popconfirm-Cyaeybtj.js.map → Popconfirm-D4J7tlk_.js.map} +1 -1
- package/dist/{Popconfirm-IhlIINtZ.cjs → Popconfirm-bEoOPmZY.cjs} +2 -2
- package/dist/{Popconfirm-IhlIINtZ.cjs.map → Popconfirm-bEoOPmZY.cjs.map} +1 -1
- package/dist/{Progress-T7PLrJ0Y.js → Progress-BxvqmmGS.js} +2 -2
- package/dist/{Progress-T7PLrJ0Y.js.map → Progress-BxvqmmGS.js.map} +1 -1
- package/dist/{Progress-CAY1p06_.cjs → Progress-CqXX0rRp.cjs} +2 -2
- package/dist/{Progress-CAY1p06_.cjs.map → Progress-CqXX0rRp.cjs.map} +1 -1
- package/dist/{RemoveDialog-DdGsqaWV.js → RemoveDialog-DH3eNUxC.js} +5 -5
- package/dist/{RemoveDialog-DdGsqaWV.js.map → RemoveDialog-DH3eNUxC.js.map} +1 -1
- package/dist/{RemoveDialog-D12B4x80.cjs → RemoveDialog-FrieNcjL.cjs} +2 -2
- package/dist/{RemoveDialog-D12B4x80.cjs.map → RemoveDialog-FrieNcjL.cjs.map} +1 -1
- package/dist/{RichTextEditor-DL4y5xVv.js → RichTextEditor-6frB2C5G.js} +9 -9
- package/dist/{RichTextEditor-DL4y5xVv.js.map → RichTextEditor-6frB2C5G.js.map} +1 -1
- package/dist/RichTextEditor-B-C4NPDk.cjs +2 -0
- package/dist/{RichTextEditor-BVXY25sz.cjs.map → RichTextEditor-B-C4NPDk.cjs.map} +1 -1
- package/dist/{RootLayout-BK3t6Mm0.js → RootLayout-C7n79JjM.js} +219 -202
- package/dist/RootLayout-C7n79JjM.js.map +1 -0
- package/dist/RootLayout-CtkpgPGV.cjs +2 -0
- package/dist/RootLayout-CtkpgPGV.cjs.map +1 -0
- package/dist/{Select-DlFDOZtn.cjs → Select-Bjq_p8_e.cjs} +2 -2
- package/dist/{Select-DlFDOZtn.cjs.map → Select-Bjq_p8_e.cjs.map} +1 -1
- package/dist/{Select-tVI_qer3.js → Select-DO3zDQYV.js} +3 -3
- package/dist/{Select-tVI_qer3.js.map → Select-DO3zDQYV.js.map} +1 -1
- package/dist/Sidebar-2oH285Xs.cjs +2 -0
- package/dist/{Sidebar-gB-X4VLX.cjs.map → Sidebar-2oH285Xs.cjs.map} +1 -1
- package/dist/{Sidebar-CjrD3nNp.js → Sidebar-CKbSWc5q.js} +33 -32
- package/dist/{Sidebar-CjrD3nNp.js.map → Sidebar-CKbSWc5q.js.map} +1 -1
- package/dist/{SpeedDial-xQr4JH0x.js → SpeedDial-BZK-z_r9.js} +2 -2
- package/dist/{SpeedDial-xQr4JH0x.js.map → SpeedDial-BZK-z_r9.js.map} +1 -1
- package/dist/{SpeedDial-BIOkkLKO.cjs → SpeedDial-KGf8b4Gq.cjs} +2 -2
- package/dist/{SpeedDial-BIOkkLKO.cjs.map → SpeedDial-KGf8b4Gq.cjs.map} +1 -1
- package/dist/{Stepper-CkYcIc15.js → Stepper-BI3pjWf_.js} +13 -13
- package/dist/{Stepper-CkYcIc15.js.map → Stepper-BI3pjWf_.js.map} +1 -1
- package/dist/{Stepper-CBdhvPoz.cjs → Stepper-s9Vah5R2.cjs} +2 -2
- package/dist/{Stepper-CBdhvPoz.cjs.map → Stepper-s9Vah5R2.cjs.map} +1 -1
- package/dist/Table-CLjLsYYS.cjs +2 -0
- package/dist/Table-CLjLsYYS.cjs.map +1 -0
- package/dist/{Table-CwQKfXGn.js → Table-PsNnKn_j.js} +174 -173
- package/dist/Table-PsNnKn_j.js.map +1 -0
- package/dist/{Tabs-Bztnezt9.js → Tabs-B2WzlRXI.js} +10 -10
- package/dist/{Tabs-Bztnezt9.js.map → Tabs-B2WzlRXI.js.map} +1 -1
- package/dist/{Tabs-651xbRe4.cjs → Tabs-DQoNP0QT.cjs} +2 -2
- package/dist/{Tabs-651xbRe4.cjs.map → Tabs-DQoNP0QT.cjs.map} +1 -1
- package/dist/{TagsField-B7ZARHzD.cjs → TagsField-CLfAAz4N.cjs} +2 -2
- package/dist/{TagsField-B7ZARHzD.cjs.map → TagsField-CLfAAz4N.cjs.map} +1 -1
- package/dist/{TagsField-CdymON69.js → TagsField-pdvQU4zh.js} +4 -4
- package/dist/{TagsField-CdymON69.js.map → TagsField-pdvQU4zh.js.map} +1 -1
- package/dist/{TextField-B22NRQ91.cjs → TextField-CgPfN-4d.cjs} +2 -2
- package/dist/{TextField-B22NRQ91.cjs.map → TextField-CgPfN-4d.cjs.map} +1 -1
- package/dist/{TextField-DkaYK1DI.js → TextField-LONfx4jy.js} +3 -3
- package/dist/{TextField-DkaYK1DI.js.map → TextField-LONfx4jy.js.map} +1 -1
- package/dist/{ThemeToggle-D5dWHQFb.cjs → ThemeToggle-9RBaRALj.cjs} +2 -2
- package/dist/{ThemeToggle-D5dWHQFb.cjs.map → ThemeToggle-9RBaRALj.cjs.map} +1 -1
- package/dist/ThemeToggle-DTkFppOd.js +28 -0
- package/dist/{ThemeToggle-DqzUvcK5.js.map → ThemeToggle-DTkFppOd.js.map} +1 -1
- package/dist/{TimeColumns-BEoHh961.js → TimeColumns-B7af5Cbj.js} +2 -2
- package/dist/{TimeColumns-BEoHh961.js.map → TimeColumns-B7af5Cbj.js.map} +1 -1
- package/dist/{TimeColumns-o2xhvSGE.cjs → TimeColumns-CJ13uf3K.cjs} +2 -2
- package/dist/{TimeColumns-o2xhvSGE.cjs.map → TimeColumns-CJ13uf3K.cjs.map} +1 -1
- package/dist/{TimePicker-DCryZCmh.js → TimePicker-BitZ7wv-.js} +5 -5
- package/dist/{TimePicker-DCryZCmh.js.map → TimePicker-BitZ7wv-.js.map} +1 -1
- package/dist/{TimePicker-CACmHwNn.cjs → TimePicker-Dshko7IJ.cjs} +2 -2
- package/dist/{TimePicker-CACmHwNn.cjs.map → TimePicker-Dshko7IJ.cjs.map} +1 -1
- package/dist/{Toaster-BwREV06e.cjs → Toaster-8ynQTcc0.cjs} +2 -2
- package/dist/{Toaster-BwREV06e.cjs.map → Toaster-8ynQTcc0.cjs.map} +1 -1
- package/dist/{Toaster-DwVLab3k.js → Toaster-CYVETXVZ.js} +2 -2
- package/dist/{Toaster-DwVLab3k.js.map → Toaster-CYVETXVZ.js.map} +1 -1
- package/dist/{TranslatedFields-sio1Qfy7.cjs → TranslatedFields-BKI3jrNd.cjs} +2 -2
- package/dist/{TranslatedFields-sio1Qfy7.cjs.map → TranslatedFields-BKI3jrNd.cjs.map} +1 -1
- package/dist/{TranslatedFields-B0LMXgiu.js → TranslatedFields-dmb-0Yn7.js} +13 -13
- package/dist/{TranslatedFields-B0LMXgiu.js.map → TranslatedFields-dmb-0Yn7.js.map} +1 -1
- package/dist/{UserCard-Dzc4zmPj.cjs → UserCard-ah6K1y0H.cjs} +2 -2
- package/dist/{UserCard-Dzc4zmPj.cjs.map → UserCard-ah6K1y0H.cjs.map} +1 -1
- package/dist/{UserCard-B5FVcJaK.js → UserCard-pEJZqiDF.js} +3 -3
- package/dist/{UserCard-B5FVcJaK.js.map → UserCard-pEJZqiDF.js.map} +1 -1
- package/dist/app/AdminRoot.d.cts +75 -4
- package/dist/app/AdminRoot.d.ts +75 -4
- package/dist/components/Alert/index.cjs +1 -1
- package/dist/components/Alert/index.js +1 -1
- package/dist/components/Breadcrumbs/index.cjs +1 -1
- package/dist/components/Breadcrumbs/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Card/index.cjs +1 -1
- package/dist/components/Card/index.js +1 -1
- package/dist/components/Chip/index.cjs +1 -1
- package/dist/components/Chip/index.js +1 -1
- package/dist/components/CodeBlock/index.cjs +1 -1
- package/dist/components/CodeBlock/index.js +1 -1
- package/dist/components/ColorPicker/index.cjs +1 -1
- package/dist/components/ColorPicker/index.js +1 -1
- package/dist/components/ColorRamp/index.cjs +1 -1
- package/dist/components/ColorRamp/index.js +1 -1
- package/dist/components/CopyButton/index.cjs +1 -1
- package/dist/components/CopyButton/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DateTimePicker/index.cjs +1 -1
- package/dist/components/DateTimePicker/index.js +1 -1
- package/dist/components/DescriptionList/index.cjs +1 -1
- package/dist/components/DescriptionList/index.js +1 -1
- package/dist/components/Dropdown/index.cjs +1 -1
- package/dist/components/Dropdown/index.js +1 -1
- package/dist/components/EmptyState/index.cjs +1 -1
- package/dist/components/EmptyState/index.js +1 -1
- package/dist/components/ErrorState/ErrorBoundary.d.cts +3 -3
- package/dist/components/ErrorState/ErrorBoundary.d.ts +3 -3
- package/dist/components/ErrorState/ErrorState.d.cts +37 -9
- package/dist/components/ErrorState/ErrorState.d.ts +37 -9
- package/dist/components/ErrorState/errorMessage.d.cts +35 -3
- package/dist/components/ErrorState/errorMessage.d.ts +35 -3
- package/dist/components/ErrorState/index.cjs +1 -1
- package/dist/components/ErrorState/index.d.cts +2 -2
- package/dist/components/ErrorState/index.d.ts +2 -2
- package/dist/components/ErrorState/index.js +15 -10
- package/dist/components/ErrorState/index.js.map +1 -1
- package/dist/components/FileCard/index.cjs +1 -1
- package/dist/components/FileCard/index.js +1 -1
- package/dist/components/FileUploader/index.cjs +1 -1
- package/dist/components/FileUploader/index.js +1 -1
- package/dist/components/Flag/index.cjs +1 -1
- package/dist/components/Flag/index.js +1 -1
- package/dist/components/FullscreenToggle/index.cjs +1 -1
- package/dist/components/FullscreenToggle/index.js +1 -1
- package/dist/components/IconButton/index.cjs +1 -1
- package/dist/components/IconButton/index.js +1 -1
- package/dist/components/List/index.cjs +1 -1
- package/dist/components/List/index.js +5 -4
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/Loader/index.cjs +1 -1
- package/dist/components/Loader/index.js +1 -1
- package/dist/components/LocationPicker/LocationPicker.d.cts +87 -0
- package/dist/components/LocationPicker/LocationPicker.d.ts +87 -0
- package/dist/components/LocationPicker/PlaceSearch.d.cts +20 -0
- package/dist/components/LocationPicker/PlaceSearch.d.ts +20 -0
- package/dist/components/LocationPicker/googleMaps.d.cts +89 -0
- package/dist/components/LocationPicker/googleMaps.d.ts +89 -0
- package/dist/components/LocationPicker/index.cjs +2 -0
- package/dist/components/LocationPicker/index.cjs.map +1 -0
- package/dist/components/LocationPicker/index.d.cts +2 -0
- package/dist/components/LocationPicker/index.d.ts +2 -0
- package/dist/components/LocationPicker/index.js +7 -0
- package/dist/components/LocationPicker/index.js.map +1 -0
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.cts +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/dist/components/MultiSelect/index.cjs +1 -1
- package/dist/components/MultiSelect/index.js +1 -1
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.js +1 -1
- package/dist/components/OptionMenu/OptionMenu.d.cts +1 -1
- package/dist/components/OptionMenu/OptionMenu.d.ts +1 -1
- package/dist/components/OtpField/index.cjs +1 -1
- package/dist/components/OtpField/index.js +1 -1
- package/dist/components/PageError/PageError.d.cts +53 -0
- package/dist/components/PageError/PageError.d.ts +53 -0
- package/dist/components/PageError/index.cjs +2 -0
- package/dist/components/PageError/index.cjs.map +1 -0
- package/dist/components/PageError/index.d.cts +2 -0
- package/dist/components/PageError/index.d.ts +2 -0
- package/dist/components/PageError/index.js +6 -0
- package/dist/components/PageError/index.js.map +1 -0
- package/dist/components/PageLayout/index.cjs +1 -1
- package/dist/components/PageLayout/index.js +1 -1
- package/dist/components/PageNotFound/index.cjs +1 -1
- package/dist/components/PageNotFound/index.js +1 -1
- package/dist/components/PageNotFound/useHomeTo.d.cts +10 -0
- package/dist/components/PageNotFound/useHomeTo.d.ts +10 -0
- package/dist/components/Pagination/index.cjs +1 -1
- package/dist/components/Pagination/index.js +1 -1
- package/dist/components/PaletteField/index.cjs +1 -1
- package/dist/components/PaletteField/index.js +1 -1
- package/dist/components/PhoneField/index.cjs +1 -1
- package/dist/components/PhoneField/index.js +1 -1
- package/dist/components/Popconfirm/index.cjs +1 -1
- package/dist/components/Popconfirm/index.js +1 -1
- package/dist/components/Progress/index.cjs +1 -1
- package/dist/components/Progress/index.js +1 -1
- package/dist/components/RemoveDialog/index.cjs +1 -1
- package/dist/components/RemoveDialog/index.js +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RootLayout/index.cjs +1 -1
- package/dist/components/RootLayout/index.js +1 -1
- package/dist/components/Select/Select.d.cts +1 -1
- package/dist/components/Select/Select.d.ts +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Sidebar/index.cjs +1 -1
- package/dist/components/Sidebar/index.js +1 -1
- package/dist/components/SpeedDial/index.cjs +1 -1
- package/dist/components/SpeedDial/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/Table/Table.d.cts +1 -1
- package/dist/components/Table/Table.d.ts +1 -1
- package/dist/components/Table/index.cjs +1 -1
- package/dist/components/Table/index.js +1 -1
- package/dist/components/Tabs/index.cjs +1 -1
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/TagsField/TagsField.d.cts +1 -1
- package/dist/components/TagsField/TagsField.d.ts +1 -1
- package/dist/components/TagsField/index.cjs +1 -1
- package/dist/components/TagsField/index.js +1 -1
- package/dist/components/TextField/TextField.d.cts +1 -1
- package/dist/components/TextField/TextField.d.ts +1 -1
- package/dist/components/TextField/index.cjs +1 -1
- package/dist/components/TextField/index.js +1 -1
- package/dist/components/ThemeToggle/index.cjs +1 -1
- package/dist/components/ThemeToggle/index.js +1 -1
- package/dist/components/TimePicker/index.cjs +1 -1
- package/dist/components/TimePicker/index.js +1 -1
- package/dist/components/Toast/index.cjs +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/TranslatedFields/index.cjs +1 -1
- package/dist/components/TranslatedFields/index.js +1 -1
- package/dist/components/UserCard/UserCard.d.cts +1 -1
- package/dist/components/UserCard/UserCard.d.ts +1 -1
- package/dist/components/UserCard/index.cjs +1 -1
- package/dist/components/UserCard/index.js +1 -1
- package/dist/components/index.d.cts +2 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/entries/app.cjs +1 -1
- package/dist/entries/app.d.cts +1 -1
- package/dist/entries/app.d.ts +1 -1
- package/dist/entries/app.js +1 -1
- package/dist/entries/components.cjs +1 -1
- package/dist/entries/components.js +172 -161
- package/dist/entries/components.js.map +1 -1
- package/dist/entries/i18n.cjs +1 -1
- package/dist/entries/i18n.js +2 -2
- package/dist/entries/theme.cjs +1 -1
- package/dist/entries/theme.d.cts +2 -2
- package/dist/entries/theme.d.ts +2 -2
- package/dist/entries/theme.js +15 -13
- package/dist/errorMessage-C7N4KvUS.cjs +2 -0
- package/dist/errorMessage-C7N4KvUS.cjs.map +1 -0
- package/dist/errorMessage-C83fB2h5.js +98 -0
- package/dist/errorMessage-C83fB2h5.js.map +1 -0
- package/dist/i18n/messages.d.cts +56 -0
- package/dist/i18n/messages.d.ts +56 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +229 -216
- package/dist/index.js.map +1 -1
- package/dist/{messages-DswDgGe2.js → messages-C1eTrGJy.js} +286 -90
- package/dist/messages-C1eTrGJy.js.map +1 -0
- package/dist/messages-DCr7iFmv.cjs +36 -0
- package/dist/messages-DCr7iFmv.cjs.map +1 -0
- package/dist/theme/ConfigProvider.d.cts +39 -3
- package/dist/theme/ConfigProvider.d.ts +39 -3
- package/dist/theme/index.d.cts +2 -2
- package/dist/theme/index.d.ts +2 -2
- package/dist/useHomeTo-Cr6Usr_D.cjs +2 -0
- package/dist/useHomeTo-Cr6Usr_D.cjs.map +1 -0
- package/dist/useHomeTo-yTXajO22.js +25 -0
- package/dist/useHomeTo-yTXajO22.js.map +1 -0
- package/dist/useOptionMenu-DHGSbQmS.cjs +2 -0
- package/dist/{useOptionMenu-BYeSUee6.cjs.map → useOptionMenu-DHGSbQmS.cjs.map} +1 -1
- package/dist/{useOptionMenu-DtTvY9EC.js → useOptionMenu-DK0ixg-p.js} +9 -8
- package/dist/{useOptionMenu-DtTvY9EC.js.map → useOptionMenu-DK0ixg-p.js.map} +1 -1
- package/package.json +1 -1
- package/dist/AdminRoot-BYkmCGNx.js +0 -57
- package/dist/AdminRoot-BYkmCGNx.js.map +0 -1
- package/dist/AdminRoot-BbkfFQEn.cjs +0 -2
- package/dist/AdminRoot-BbkfFQEn.cjs.map +0 -1
- package/dist/ConfigProvider-Ct0Pe3Ku.js +0 -335
- package/dist/ConfigProvider-Ct0Pe3Ku.js.map +0 -1
- package/dist/ConfigProvider-CtpfSy1i.cjs +0 -2
- package/dist/ConfigProvider-CtpfSy1i.cjs.map +0 -1
- package/dist/ErrorBoundary-B-37hGZW.js +0 -163
- package/dist/ErrorBoundary-B-37hGZW.js.map +0 -1
- package/dist/ErrorBoundary-gRGxeuM1.cjs +0 -2
- package/dist/ErrorBoundary-gRGxeuM1.cjs.map +0 -1
- package/dist/List-BLPB3-B8.js +0 -107
- package/dist/List-BLPB3-B8.js.map +0 -1
- package/dist/List-ah2PNWeY.cjs +0 -2
- package/dist/List-ah2PNWeY.cjs.map +0 -1
- package/dist/PageNotFound-CBNhKZ9Y.js +0 -39
- package/dist/PageNotFound-CBNhKZ9Y.js.map +0 -1
- package/dist/PageNotFound-PUQ1o9R4.cjs +0 -2
- package/dist/PageNotFound-PUQ1o9R4.cjs.map +0 -1
- package/dist/QueryError-DP22IUnp.cjs +0 -2
- package/dist/QueryError-DP22IUnp.cjs.map +0 -1
- package/dist/QueryError-Dtspj9l4.js +0 -19
- package/dist/QueryError-Dtspj9l4.js.map +0 -1
- package/dist/RichTextEditor-BVXY25sz.cjs +0 -2
- package/dist/RootLayout-BK3t6Mm0.js.map +0 -1
- package/dist/RootLayout-DDuzPlJe.cjs +0 -2
- package/dist/RootLayout-DDuzPlJe.cjs.map +0 -1
- package/dist/Sidebar-gB-X4VLX.cjs +0 -2
- package/dist/Table-CwQKfXGn.js.map +0 -1
- package/dist/Table-Cwxqo7Br.cjs +0 -2
- package/dist/Table-Cwxqo7Br.cjs.map +0 -1
- package/dist/ThemeToggle-DqzUvcK5.js +0 -28
- package/dist/messages-DS38X5W2.cjs +0 -36
- package/dist/messages-DS38X5W2.cjs.map +0 -1
- package/dist/messages-DswDgGe2.js.map +0 -1
- package/dist/useOptionMenu-BYeSUee6.cjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dropdown-BlmbYp1X.js","sources":["../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import {\n cloneElement,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport { clsx } from 'clsx'\nimport { List, type ListItemSize } from '../List'\nimport { useLockBodyScroll } from '../../hooks/useLockBodyScroll'\nimport styles from './Dropdown.module.css'\n\nexport type DropdownPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end'\n\ninterface Position {\n top: number\n left: number\n side: 'top' | 'bottom'\n maxHeight: number\n minWidth?: number\n}\n\nexport interface DropdownProps {\n /** The element that opens the menu (e.g. a `Button` / `IconButton`). Cloned to wire click + a11y. */\n trigger: ReactElement\n /** Menu content — typically `ListItem`s (composed inside a `role=\"menu\"` `List`). */\n children: ReactNode\n /** Preferred placement. Flips to the opposite side automatically when it would overflow. Default `bottom-start`. */\n placement?: DropdownPlacement\n /** Menu size — sets the panel min-width (`sm` 150 · `md` 190 · `lg` 220) and the items' density. Default `md`. */\n size?: ListItemSize\n /**\n * Apply the size-based min-width (`sm` 150 · `md` 190 · `lg` 220px). Defaults to `true`; set `false`\n * to let the menu size to its content instead (the items' density still tracks `size`).\n */\n minWidth?: boolean\n /** Controlled open state. */\n open?: boolean\n /** Initial open state for uncontrolled use. Defaults to `false`. */\n defaultOpen?: boolean\n /** Fires with the next open state. */\n onOpenChange?: (open: boolean) => void\n /** Close the menu when an item inside is clicked. Defaults to `true`. */\n closeOnSelect?: boolean\n /** Make the menu at least as wide as the trigger (select-like). Defaults to `false`. */\n matchTriggerWidth?: boolean\n /** Prevents opening. */\n disabled?: boolean\n /** Gap between the trigger and the menu, in px. Defaults to `6`. */\n offset?: number\n /** Class applied to the floating panel. */\n className?: string\n /** Style applied to the floating panel. */\n style?: CSSProperties\n}\n\n/** Distance the menu is kept from the viewport edges (px). */\nconst VIEWPORT_PADDING = 8\n/** Focusable menu items, used for arrow-key roving. */\nconst FOCUSABLE =\n '[role=\"menuitem\"],[role=\"button\"],a[href],button:not([disabled]),[tabindex]:not([tabindex=\"-1\"])'\n\nfunction focusableItems(panel: HTMLElement | null): HTMLElement[] {\n if (!panel) return []\n return Array.from(panel.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (el) => el.getAttribute('aria-disabled') !== 'true' && el.offsetParent !== null,\n )\n}\n\n/**\n * A floating menu anchored to a `trigger`. Opens on trigger click; closes on outside click, `Escape`,\n * or selecting an item. The panel is portaled to `document.body` and positioned with collision\n * handling — it **flips** to the opposite side when it would overflow, clamps within the viewport, and\n * re-positions on scroll/resize (a too-tall menu caps its height and scrolls). Arrow keys move between\n * items; `Escape` returns focus to the trigger. Compose `ListItem`s as `children`.\n */\nexport function Dropdown({\n trigger,\n children,\n placement = 'bottom-start',\n size = 'md',\n minWidth = true,\n open,\n defaultOpen = false,\n onOpenChange,\n closeOnSelect = true,\n matchTriggerWidth = false,\n disabled = false,\n offset = 6,\n className,\n style,\n}: DropdownProps) {\n const menuId = useId()\n const triggerRef = useRef<HTMLElement | null>(null)\n const panelRef = useRef<HTMLDivElement | null>(null)\n\n const isControlled = open !== undefined\n const [internalOpen, setInternalOpen] = useState(defaultOpen)\n const isOpen = isControlled ? open : internalOpen\n const [visible, setVisible] = useState(false)\n const [pos, setPos] = useState<Position | null>(null)\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalOpen(next)\n onOpenChange?.(next)\n },\n [isControlled, onOpenChange],\n )\n const close = useCallback(() => setOpen(false), [setOpen])\n\n // lock page scroll while the menu is open (no scrollbar shift)\n useLockBodyScroll(isOpen)\n\n // ── positioning: flip when it would overflow, clamp inside the viewport ──\n const update = useCallback(() => {\n const triggerEl = triggerRef.current\n const panel = panelRef.current\n if (!triggerEl || !panel) return\n\n const rect = triggerEl.getBoundingClientRect()\n const panelW = panel.offsetWidth\n const panelH = panel.offsetHeight\n const vw = window.innerWidth\n const vh = window.innerHeight\n const pad = VIEWPORT_PADDING\n\n const spaceBelow = vh - rect.bottom - offset - pad\n const spaceAbove = rect.top - offset - pad\n let side: 'top' | 'bottom' = placement.startsWith('bottom') ? 'bottom' : 'top'\n // flip only when the preferred side can't fit AND the opposite side has more room\n if (side === 'bottom' && panelH > spaceBelow && spaceAbove > spaceBelow) side = 'top'\n else if (side === 'top' && panelH > spaceAbove && spaceBelow > spaceAbove) side = 'bottom'\n\n const available = side === 'bottom' ? spaceBelow : spaceAbove\n const maxHeight = Math.max(0, available)\n const usedH = Math.min(panelH, maxHeight)\n\n let top = side === 'bottom' ? rect.bottom + offset : rect.top - offset - usedH\n top = Math.min(Math.max(top, pad), Math.max(pad, vh - pad - usedH))\n\n let left = placement.endsWith('end') ? rect.right - panelW : rect.left\n left = Math.min(Math.max(left, pad), Math.max(pad, vw - pad - panelW))\n\n setPos({ top, left, side, maxHeight, minWidth: matchTriggerWidth ? rect.width : undefined })\n }, [placement, offset, matchTriggerWidth])\n\n // position synchronously before paint whenever the menu is open\n useLayoutEffect(() => {\n if (!isOpen) {\n setVisible(false)\n return\n }\n update()\n }, [isOpen, update])\n\n // enter transition + reposition listeners while open\n useEffect(() => {\n if (!isOpen) return\n const raf = requestAnimationFrame(() => setVisible(true))\n\n const onReposition = () => update()\n window.addEventListener('resize', onReposition)\n window.addEventListener('scroll', onReposition, true)\n let ro: ResizeObserver | undefined\n if (typeof ResizeObserver !== 'undefined') {\n ro = new ResizeObserver(onReposition)\n if (panelRef.current) ro.observe(panelRef.current)\n if (triggerRef.current) ro.observe(triggerRef.current)\n }\n\n return () => {\n cancelAnimationFrame(raf)\n window.removeEventListener('resize', onReposition)\n window.removeEventListener('scroll', onReposition, true)\n ro?.disconnect()\n }\n }, [isOpen, update])\n\n // outside click + keyboard (Escape, arrow roving)\n useEffect(() => {\n if (!isOpen) return\n const onPointerDown = (event: PointerEvent) => {\n const target = event.target as Node\n if (triggerRef.current?.contains(target) || panelRef.current?.contains(target)) return\n close()\n }\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n close()\n triggerRef.current?.focus()\n } else if (event.key === 'Tab') {\n // Tab would move focus by portal DOM order (end of <body>), orphaning the open menu — close it\n // and let focus continue naturally from the trigger (Select/MultiSelect do the same)\n close()\n } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n const items = focusableItems(panelRef.current)\n if (!items.length) return\n const current = items.indexOf(document.activeElement as HTMLElement)\n const delta = event.key === 'ArrowDown' ? 1 : -1\n const next = (current + delta + items.length) % items.length\n items[next]?.focus()\n }\n }\n document.addEventListener('pointerdown', onPointerDown, true)\n document.addEventListener('keydown', onKeyDown)\n return () => {\n document.removeEventListener('pointerdown', onPointerDown, true)\n document.removeEventListener('keydown', onKeyDown)\n }\n }, [isOpen, close])\n\n // focus the first item once the menu is open and positioned\n useEffect(() => {\n if (!isOpen) return\n const raf = requestAnimationFrame(() => focusableItems(panelRef.current)[0]?.focus())\n return () => cancelAnimationFrame(raf)\n }, [isOpen])\n\n const triggerProps = trigger.props as {\n onClick?: (event: ReactMouseEvent) => void\n ref?: Ref<HTMLElement>\n }\n const originalRef = triggerProps.ref\n\n const clonedTrigger = cloneElement(trigger as ReactElement<Record<string, unknown>>, {\n ref: (node: HTMLElement | null) => {\n triggerRef.current = node\n if (typeof originalRef === 'function') originalRef(node)\n else if (originalRef) (originalRef as { current: HTMLElement | null }).current = node\n },\n onClick: (event: ReactMouseEvent) => {\n triggerProps.onClick?.(event)\n if (!disabled) setOpen(!isOpen)\n },\n 'aria-haspopup': 'menu',\n 'aria-expanded': isOpen,\n 'aria-controls': isOpen ? menuId : undefined,\n })\n\n const handlePanelClick = (event: ReactMouseEvent) => {\n if (!closeOnSelect) return\n const item = (event.target as HTMLElement).closest(FOCUSABLE)\n if (item && item.getAttribute('aria-disabled') !== 'true') {\n close()\n triggerRef.current?.focus()\n }\n }\n\n return (\n <>\n {clonedTrigger}\n {isOpen &&\n createPortal(\n <div\n ref={panelRef}\n id={menuId}\n className={clsx(styles.panel, minWidth && styles[size], className)}\n data-open={visible ? 'true' : 'false'}\n data-side={pos?.side ?? 'bottom'}\n style={{\n position: 'fixed',\n top: pos?.top ?? 0,\n left: pos?.left ?? 0,\n maxHeight: pos?.maxHeight,\n minWidth: pos?.minWidth,\n visibility: pos ? 'visible' : 'hidden',\n ...style,\n }}\n onClick={handlePanelClick}\n >\n <List role=\"menu\" size={size} padding=\"xs\">\n {children}\n </List>\n </div>,\n document.body,\n )}\n </>\n )\n}\n"],"names":["VIEWPORT_PADDING","FOCUSABLE","focusableItems","panel","el","Dropdown","trigger","children","placement","size","minWidth","open","defaultOpen","onOpenChange","closeOnSelect","matchTriggerWidth","disabled","offset","className","style","menuId","useId","triggerRef","useRef","panelRef","isControlled","internalOpen","setInternalOpen","useState","isOpen","visible","setVisible","pos","setPos","setOpen","useCallback","next","close","useLockBodyScroll","update","triggerEl","rect","panelW","panelH","vw","vh","pad","spaceBelow","spaceAbove","side","maxHeight","usedH","top","left","useLayoutEffect","useEffect","raf","onReposition","ro","onPointerDown","event","target","_a","_b","onKeyDown","items","current","delta","triggerProps","originalRef","clonedTrigger","cloneElement","node","handlePanelClick","item","jsxs","Fragment","createPortal","js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;AAAA,EAExB;AAEA,SACE,gBAAAa,GAAAC,IAAA,EACG,UAAA;AAAA,IAAAN;AAAA,IACAzC,KACCgD;AAAA,MACE,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UACC,KAAKtD;AAAA,UACL,IAAIJ;AAAA,UACJ,WAAW2D,GAAKC,EAAO,OAAOtE,KAAYsE,EAAOvE,CAAI,GAAGS,CAAS;AAAA,UACjE,aAAWY,IAAU,SAAS;AAAA,UAC9B,cAAWE,KAAA,gBAAAA,EAAK,SAAQ;AAAA,UACxB,OAAO;AAAA,YACL,UAAU;AAAA,YACV,MAAKA,KAAA,gBAAAA,EAAK,QAAO;AAAA,YACjB,OAAMA,KAAA,gBAAAA,EAAK,SAAQ;AAAA,YACnB,WAAWA,KAAA,gBAAAA,EAAK;AAAA,YAChB,UAAUA,KAAA,gBAAAA,EAAK;AAAA,YACf,YAAYA,IAAM,YAAY;AAAA,YAC9B,GAAGb;AAAA,UAAA;AAAA,UAEL,SAASsD;AAAA,UAET,4BAACQ,IAAA,EAAK,MAAK,QAAO,MAAAxE,GAAY,SAAQ,MACnC,UAAAF,EAAA,CACH;AAAA,QAAA;AAAA,MAAA;AAAA,MAEF,SAAS;AAAA,IAAA;AAAA,EACX,GACJ;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Dropdown-zlv96RLy.js","sources":["../src/components/Dropdown/Dropdown.tsx"],"sourcesContent":["import {\n cloneElement,\n useCallback,\n useEffect,\n useId,\n useLayoutEffect,\n useRef,\n useState,\n type CSSProperties,\n type MouseEvent as ReactMouseEvent,\n type ReactElement,\n type ReactNode,\n type Ref,\n} from 'react'\nimport { createPortal } from 'react-dom'\nimport { clsx } from 'clsx'\nimport { List, type ListItemSize } from '../List'\nimport { useLockBodyScroll } from '../../hooks/useLockBodyScroll'\nimport styles from './Dropdown.module.css'\n\nexport type DropdownPlacement = 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end'\n\ninterface Position {\n top: number\n left: number\n side: 'top' | 'bottom'\n maxHeight: number\n minWidth?: number\n}\n\nexport interface DropdownProps {\n /** The element that opens the menu (e.g. a `Button` / `IconButton`). Cloned to wire click + a11y. */\n trigger: ReactElement\n /** Menu content — typically `ListItem`s (composed inside a `role=\"menu\"` `List`). */\n children: ReactNode\n /** Preferred placement. Flips to the opposite side automatically when it would overflow. Default `bottom-start`. */\n placement?: DropdownPlacement\n /** Menu size — sets the panel min-width (`sm` 150 · `md` 190 · `lg` 220) and the items' density. Default `md`. */\n size?: ListItemSize\n /**\n * Apply the size-based min-width (`sm` 150 · `md` 190 · `lg` 220px). Defaults to `true`; set `false`\n * to let the menu size to its content instead (the items' density still tracks `size`).\n */\n minWidth?: boolean\n /** Controlled open state. */\n open?: boolean\n /** Initial open state for uncontrolled use. Defaults to `false`. */\n defaultOpen?: boolean\n /** Fires with the next open state. */\n onOpenChange?: (open: boolean) => void\n /** Close the menu when an item inside is clicked. Defaults to `true`. */\n closeOnSelect?: boolean\n /** Make the menu at least as wide as the trigger (select-like). Defaults to `false`. */\n matchTriggerWidth?: boolean\n /** Prevents opening. */\n disabled?: boolean\n /** Gap between the trigger and the menu, in px. Defaults to `6`. */\n offset?: number\n /** Class applied to the floating panel. */\n className?: string\n /** Style applied to the floating panel. */\n style?: CSSProperties\n}\n\n/** Distance the menu is kept from the viewport edges (px). */\nconst VIEWPORT_PADDING = 8\n/** Focusable menu items, used for arrow-key roving. */\nconst FOCUSABLE =\n '[role=\"menuitem\"],[role=\"button\"],a[href],button:not([disabled]),[tabindex]:not([tabindex=\"-1\"])'\n\nfunction focusableItems(panel: HTMLElement | null): HTMLElement[] {\n if (!panel) return []\n return Array.from(panel.querySelectorAll<HTMLElement>(FOCUSABLE)).filter(\n (el) => el.getAttribute('aria-disabled') !== 'true' && el.offsetParent !== null,\n )\n}\n\n/**\n * A floating menu anchored to a `trigger`. Opens on trigger click; closes on outside click, `Escape`,\n * or selecting an item. The panel is portaled to `document.body` and positioned with collision\n * handling — it **flips** to the opposite side when it would overflow, clamps within the viewport, and\n * re-positions on scroll/resize (a too-tall menu caps its height and scrolls). Arrow keys move between\n * items; `Escape` returns focus to the trigger. Compose `ListItem`s as `children`.\n */\nexport function Dropdown({\n trigger,\n children,\n placement = 'bottom-start',\n size = 'md',\n minWidth = true,\n open,\n defaultOpen = false,\n onOpenChange,\n closeOnSelect = true,\n matchTriggerWidth = false,\n disabled = false,\n offset = 6,\n className,\n style,\n}: DropdownProps) {\n const menuId = useId()\n const triggerRef = useRef<HTMLElement | null>(null)\n const panelRef = useRef<HTMLDivElement | null>(null)\n\n const isControlled = open !== undefined\n const [internalOpen, setInternalOpen] = useState(defaultOpen)\n const isOpen = isControlled ? open : internalOpen\n const [visible, setVisible] = useState(false)\n const [pos, setPos] = useState<Position | null>(null)\n\n const setOpen = useCallback(\n (next: boolean) => {\n if (!isControlled) setInternalOpen(next)\n onOpenChange?.(next)\n },\n [isControlled, onOpenChange],\n )\n const close = useCallback(() => setOpen(false), [setOpen])\n\n // lock page scroll while the menu is open (no scrollbar shift)\n useLockBodyScroll(isOpen)\n\n // ── positioning: flip when it would overflow, clamp inside the viewport ──\n const update = useCallback(() => {\n const triggerEl = triggerRef.current\n const panel = panelRef.current\n if (!triggerEl || !panel) return\n\n const rect = triggerEl.getBoundingClientRect()\n const panelW = panel.offsetWidth\n const panelH = panel.offsetHeight\n const vw = window.innerWidth\n const vh = window.innerHeight\n const pad = VIEWPORT_PADDING\n\n const spaceBelow = vh - rect.bottom - offset - pad\n const spaceAbove = rect.top - offset - pad\n let side: 'top' | 'bottom' = placement.startsWith('bottom') ? 'bottom' : 'top'\n // flip only when the preferred side can't fit AND the opposite side has more room\n if (side === 'bottom' && panelH > spaceBelow && spaceAbove > spaceBelow) side = 'top'\n else if (side === 'top' && panelH > spaceAbove && spaceBelow > spaceAbove) side = 'bottom'\n\n const available = side === 'bottom' ? spaceBelow : spaceAbove\n const maxHeight = Math.max(0, available)\n const usedH = Math.min(panelH, maxHeight)\n\n let top = side === 'bottom' ? rect.bottom + offset : rect.top - offset - usedH\n top = Math.min(Math.max(top, pad), Math.max(pad, vh - pad - usedH))\n\n let left = placement.endsWith('end') ? rect.right - panelW : rect.left\n left = Math.min(Math.max(left, pad), Math.max(pad, vw - pad - panelW))\n\n setPos({ top, left, side, maxHeight, minWidth: matchTriggerWidth ? rect.width : undefined })\n }, [placement, offset, matchTriggerWidth])\n\n // position synchronously before paint whenever the menu is open\n useLayoutEffect(() => {\n if (!isOpen) {\n setVisible(false)\n return\n }\n update()\n }, [isOpen, update])\n\n // enter transition + reposition listeners while open\n useEffect(() => {\n if (!isOpen) return\n const raf = requestAnimationFrame(() => setVisible(true))\n\n const onReposition = () => update()\n window.addEventListener('resize', onReposition)\n window.addEventListener('scroll', onReposition, true)\n let ro: ResizeObserver | undefined\n if (typeof ResizeObserver !== 'undefined') {\n ro = new ResizeObserver(onReposition)\n if (panelRef.current) ro.observe(panelRef.current)\n if (triggerRef.current) ro.observe(triggerRef.current)\n }\n\n return () => {\n cancelAnimationFrame(raf)\n window.removeEventListener('resize', onReposition)\n window.removeEventListener('scroll', onReposition, true)\n ro?.disconnect()\n }\n }, [isOpen, update])\n\n // outside click + keyboard (Escape, arrow roving)\n useEffect(() => {\n if (!isOpen) return\n const onPointerDown = (event: PointerEvent) => {\n const target = event.target as Node\n if (triggerRef.current?.contains(target) || panelRef.current?.contains(target)) return\n close()\n }\n const onKeyDown = (event: KeyboardEvent) => {\n if (event.key === 'Escape') {\n event.preventDefault()\n close()\n triggerRef.current?.focus()\n } else if (event.key === 'Tab') {\n // Tab would move focus by portal DOM order (end of <body>), orphaning the open menu — close it\n // and let focus continue naturally from the trigger (Select/MultiSelect do the same)\n close()\n } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {\n event.preventDefault()\n const items = focusableItems(panelRef.current)\n if (!items.length) return\n const current = items.indexOf(document.activeElement as HTMLElement)\n const delta = event.key === 'ArrowDown' ? 1 : -1\n const next = (current + delta + items.length) % items.length\n items[next]?.focus()\n }\n }\n document.addEventListener('pointerdown', onPointerDown, true)\n document.addEventListener('keydown', onKeyDown)\n return () => {\n document.removeEventListener('pointerdown', onPointerDown, true)\n document.removeEventListener('keydown', onKeyDown)\n }\n }, [isOpen, close])\n\n // focus the first item once the menu is open and positioned\n useEffect(() => {\n if (!isOpen) return\n const raf = requestAnimationFrame(() => focusableItems(panelRef.current)[0]?.focus())\n return () => cancelAnimationFrame(raf)\n }, [isOpen])\n\n const triggerProps = trigger.props as {\n onClick?: (event: ReactMouseEvent) => void\n ref?: Ref<HTMLElement>\n }\n const originalRef = triggerProps.ref\n\n const clonedTrigger = cloneElement(trigger as ReactElement<Record<string, unknown>>, {\n ref: (node: HTMLElement | null) => {\n triggerRef.current = node\n if (typeof originalRef === 'function') originalRef(node)\n else if (originalRef) (originalRef as { current: HTMLElement | null }).current = node\n },\n onClick: (event: ReactMouseEvent) => {\n triggerProps.onClick?.(event)\n if (!disabled) setOpen(!isOpen)\n },\n 'aria-haspopup': 'menu',\n 'aria-expanded': isOpen,\n 'aria-controls': isOpen ? menuId : undefined,\n })\n\n const handlePanelClick = (event: ReactMouseEvent) => {\n if (!closeOnSelect) return\n const item = (event.target as HTMLElement).closest(FOCUSABLE)\n if (item && item.getAttribute('aria-disabled') !== 'true') {\n close()\n triggerRef.current?.focus()\n }\n }\n\n return (\n <>\n {clonedTrigger}\n {isOpen &&\n createPortal(\n <div\n ref={panelRef}\n id={menuId}\n className={clsx(styles.panel, minWidth && styles[size], className)}\n data-open={visible ? 'true' : 'false'}\n data-side={pos?.side ?? 'bottom'}\n style={{\n position: 'fixed',\n top: pos?.top ?? 0,\n left: pos?.left ?? 0,\n maxHeight: pos?.maxHeight,\n minWidth: pos?.minWidth,\n visibility: pos ? 'visible' : 'hidden',\n ...style,\n }}\n onClick={handlePanelClick}\n >\n <List role=\"menu\" size={size} padding=\"xs\">\n {children}\n </List>\n </div>,\n document.body,\n )}\n </>\n )\n}\n"],"names":["VIEWPORT_PADDING","FOCUSABLE","focusableItems","panel","el","Dropdown","trigger","children","placement","size","minWidth","open","defaultOpen","onOpenChange","closeOnSelect","matchTriggerWidth","disabled","offset","className","style","menuId","useId","triggerRef","useRef","panelRef","isControlled","internalOpen","setInternalOpen","useState","isOpen","visible","setVisible","pos","setPos","setOpen","useCallback","next","close","useLockBodyScroll","update","triggerEl","rect","panelW","panelH","vw","vh","pad","spaceBelow","spaceAbove","side","maxHeight","usedH","top","left","useLayoutEffect","useEffect","raf","onReposition","ro","onPointerDown","event","target","_a","_b","onKeyDown","items","current","delta","triggerProps","originalRef","clonedTrigger","cloneElement","node","handlePanelClick","item","jsxs","Fragment","createPortal","jsx","clsx","styles","List"],"mappings":";;;;;;;;;;;GAiEMA,KAAmB,GAEnBC,IACJ;AAEF,SAASC,EAAeC,GAA0C;AAChE,SAAKA,IACE,MAAM,KAAKA,EAAM,iBAA8BF,CAAS,CAAC,EAAE;AAAA,IAChE,CAACG,MAAOA,EAAG,aAAa,eAAe,MAAM,UAAUA,EAAG,iBAAiB;AAAA,EAAA,IAF1D,CAAA;AAIrB;AASO,SAASC,GAAS;AAAA,EACvB,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AAAA,EACX,MAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,cAAAC;AAAA,EACA,eAAAC,IAAgB;AAAA,EAChB,mBAAAC,IAAoB;AAAA,EACpB,UAAAC,IAAW;AAAA,EACX,QAAAC,IAAS;AAAA,EACT,WAAAC;AAAA,EACA,OAAAC;AACF,GAAkB;AAChB,QAAMC,IAASC,GAAA,GACTC,IAAaC,EAA2B,IAAI,GAC5CC,IAAWD,EAA8B,IAAI,GAE7CE,IAAed,MAAS,QACxB,CAACe,GAAcC,CAAe,IAAIC,EAAShB,CAAW,GACtDiB,IAASJ,IAAed,IAAOe,GAC/B,CAACI,GAASC,CAAU,IAAIH,EAAS,EAAK,GACtC,CAACI,GAAKC,CAA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3
|
import { clsx as N } from "clsx";
|
|
4
4
|
import { I as c } from "./Icon-CGQ5yGSZ.js";
|
|
5
5
|
import { a as h } from "./names-BR1uJs0-.js";
|
|
6
|
-
import { a as g } from "./ConfigProvider-
|
|
6
|
+
import { a as g } from "./ConfigProvider-tvLbKiqu.js";
|
|
7
7
|
const E = "_emptyState_1vpxy_3", I = "_sm_1vpxy_17", b = "_md_1vpxy_23", O = "_lg_1vpxy_29", T = "_icon_1vpxy_37", j = "_title_1vpxy_55", w = "_description_1vpxy_61", z = "_action_1vpxy_70", A = "_pattern_1vpxy_77", C = "_tinted_1vpxy_100", t = {
|
|
8
8
|
emptyState: E,
|
|
9
9
|
sm: I,
|
|
@@ -55,4 +55,4 @@ const E = "_emptyState_1vpxy_3", I = "_sm_1vpxy_17", b = "_md_1vpxy_23", O = "_l
|
|
|
55
55
|
export {
|
|
56
56
|
G as E
|
|
57
57
|
};
|
|
58
|
-
//# sourceMappingURL=EmptyState-
|
|
58
|
+
//# sourceMappingURL=EmptyState-BEVEGcLx.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState-
|
|
1
|
+
{"version":3,"file":"EmptyState-BEVEGcLx.js","sources":["../src/components/EmptyState/EmptyState.tsx"],"sourcesContent":["import { forwardRef, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react'\nimport { clsx } from 'clsx'\nimport { useT, type ThemeColor } from '../../theme'\nimport { Icon } from '../Icon'\nimport { ICON_NAMES, type IconName } from '../../icons/names'\nimport styles from './EmptyState.module.css'\n\nexport type EmptyStateSize = 'sm' | 'md' | 'lg'\n\nconst ICON_NAME_SET = new Set<string>(ICON_NAMES)\n\nexport interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'color'> {\n /** Leading glyph shown in a soft circle — an `IconName`, any node, or `false` to hide it. Defaults to `FolderOpen`. */\n icon?: IconName | ReactNode | false\n /** Heading line. Defaults to `\"No Results Found\"`. */\n title?: ReactNode\n /** Muted description under the title (e.g. a hint on what to do next). */\n description?: ReactNode\n /** Action slot under the text — e.g. an \"Add Item\" or \"Clear Filters\" button. */\n action?: ReactNode\n /** Size — scales the icon, text, and vertical padding. Defaults to `md`. */\n size?: EmptyStateSize\n /**\n * Polished \"hero\" look: a faded grid backdrop (fades out toward the edges) + an elevated icon\n * (gradient + drop shadow). Defaults to `true`; pass `pattern={false}` for the flat, compact placeholder.\n */\n pattern?: boolean\n /** Tint the icon puck with a theme color (e.g. `error` for a failure). Omitted → the neutral muted puck. */\n color?: ThemeColor\n /** Extra content rendered below the action. */\n children?: ReactNode\n}\n\n/**\n * The empty-state placeholder — drop it in wherever a page, table, list, or gallery has nothing to\n * show (no records yet, no search matches). A centered, muted glyph in a soft circle + a `title` +\n * an optional `description` and `action` (e.g. a \"Add Item\" / \"Clear Filters\" button). Neutral by\n * design; pass a custom `icon` node for a tinted glyph. Token-only styling.\n */\nexport const EmptyState = forwardRef<HTMLDivElement, EmptyStateProps>(function EmptyState(\n {\n icon,\n title,\n description,\n action,\n size = 'md',\n pattern = true,\n color,\n className,\n style,\n children,\n ...props\n },\n ref,\n) {\n const t = useT()\n const resolvedTitle = title ?? t('emptyState.title')\n const renderedIcon =\n icon === false ? null : icon == null ? (\n <Icon name=\"FolderOpen\" />\n ) : typeof icon === 'string' && ICON_NAME_SET.has(icon) ? (\n <Icon name={icon as IconName} />\n ) : (\n icon\n )\n\n return (\n <div\n ref={ref}\n className={clsx(\n styles.emptyState,\n styles[size],\n pattern && styles.pattern,\n color && styles.tinted,\n className,\n )}\n style={\n (color\n ? { '--tz-btn-rgb': `var(--tz-color-${color}-rgb)`, ...style }\n : style) as CSSProperties\n }\n {...props}\n >\n {renderedIcon != null && (\n <div className={styles.icon} aria-hidden>\n {renderedIcon}\n </div>\n )}\n {resolvedTitle != null && <div className={styles.title}>{resolvedTitle}</div>}\n {description != null && <div className={styles.description}>{description}</div>}\n {action != null && <div className={styles.action}>{action}</div>}\n {children}\n </div>\n )\n})\n"],"names":["ICON_NAME_SET","ICON_NAMES","EmptyState","forwardRef","icon","title","description","action","size","pattern","color","className","style","children","props","ref","t","useT","resolvedTitle","renderedIcon","jsx","Icon","jsxs","clsx","styles"],"mappings":";;;;;;;;;;;;;;;;;GASMA,IAAgB,IAAI,IAAYC,CAAU,GA8BnCC,IAAaC,EAA4C,SACpE;AAAA,EACE,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,QAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,SAAAC,IAAU;AAAA,EACV,OAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAMC,IAAIC,EAAA,GACJC,IAAgBb,KAASW,EAAE,kBAAkB,GAC7CG,IACJf,MAAS,KAAQ,OAAOA,KAAQ,OAC9B,gBAAAgB,EAACC,GAAA,EAAK,MAAK,aAAA,CAAa,IACtB,OAAOjB,KAAS,YAAYJ,EAAc,IAAII,CAAI,IACpD,gBAAAgB,EAACC,GAAA,EAAK,MAAMjB,EAAA,CAAkB,IAE9BA;AAGJ,SACE,gBAAAkB;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,KAAAP;AAAA,MACA,WAAWQ;AAAA,QACTC,EAAO;AAAA,QACPA,EAAOhB,CAAI;AAAA,QACXC,KAAWe,EAAO;AAAA,QAClBd,KAASc,EAAO;AAAA,QAChBb;AAAA,MAAA;AAAA,MAEF,OACGD,IACG,EAAE,gBAAgB,kBAAkBA,CAAK,SAAS,GAAGE,EAAA,IACrDA;AAAA,MAEL,GAAGE;AAAA,MAEH,UAAA;AAAA,QAAAK,KAAgB,0BACd,OAAA,EAAI,WAAWK,EAAO,MAAM,eAAW,IACrC,UAAAL,EAAA,CACH;AAAA,QAEDD,KAAiB,QAAQ,gBAAAE,EAAC,SAAI,WAAWI,EAAO,OAAQ,UAAAN,GAAc;AAAA,QACtEZ,KAAe,QAAQ,gBAAAc,EAAC,SAAI,WAAWI,EAAO,aAAc,UAAAlB,GAAY;AAAA,QACxEC,KAAU,QAAQ,gBAAAa,EAAC,SAAI,WAAWI,EAAO,QAAS,UAAAjB,GAAO;AAAA,QACzDM;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const e=require("react/jsx-runtime"),S=require("react"),N=require("clsx"),a=require("./Icon-BUP5_kRs.cjs"),j=require("./names-YOCJ4B5J.cjs"),g=require("./ConfigProvider-
|
|
2
|
-
//# sourceMappingURL=EmptyState-
|
|
1
|
+
"use strict";const e=require("react/jsx-runtime"),S=require("react"),N=require("clsx"),a=require("./Icon-BUP5_kRs.cjs"),j=require("./names-YOCJ4B5J.cjs"),g=require("./ConfigProvider-CVLHPXQm.cjs"),h="_emptyState_1vpxy_3",f="_sm_1vpxy_17",q="_md_1vpxy_23",E="_lg_1vpxy_29",I="_icon_1vpxy_37",b="_title_1vpxy_55",C="_description_1vpxy_61",O="_action_1vpxy_70",T="_pattern_1vpxy_77",w="_tinted_1vpxy_100",t={emptyState:h,sm:f,md:q,lg:E,icon:I,title:b,description:C,action:O,pattern:T,tinted:w},z=new Set(j.ICON_NAMES),A=S.forwardRef(function({icon:n,title:_,description:c,action:i,size:d="md",pattern:p=!0,color:s,className:m,style:r,children:x,...y},u){const v=g.useT(),l=_??v("emptyState.title"),o=n===!1?null:n==null?e.jsx(a.Icon,{name:"FolderOpen"}):typeof n=="string"&&z.has(n)?e.jsx(a.Icon,{name:n}):n;return e.jsxs("div",{ref:u,className:N.clsx(t.emptyState,t[d],p&&t.pattern,s&&t.tinted,m),style:s?{"--tz-btn-rgb":`var(--tz-color-${s}-rgb)`,...r}:r,...y,children:[o!=null&&e.jsx("div",{className:t.icon,"aria-hidden":!0,children:o}),l!=null&&e.jsx("div",{className:t.title,children:l}),c!=null&&e.jsx("div",{className:t.description,children:c}),i!=null&&e.jsx("div",{className:t.action,children:i}),x]})});exports.EmptyState=A;
|
|
2
|
+
//# sourceMappingURL=EmptyState-C54C0Qwc.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmptyState-
|
|
1
|
+
{"version":3,"file":"EmptyState-C54C0Qwc.cjs","sources":["../src/components/EmptyState/EmptyState.tsx"],"sourcesContent":["import { forwardRef, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react'\nimport { clsx } from 'clsx'\nimport { useT, type ThemeColor } from '../../theme'\nimport { Icon } from '../Icon'\nimport { ICON_NAMES, type IconName } from '../../icons/names'\nimport styles from './EmptyState.module.css'\n\nexport type EmptyStateSize = 'sm' | 'md' | 'lg'\n\nconst ICON_NAME_SET = new Set<string>(ICON_NAMES)\n\nexport interface EmptyStateProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'color'> {\n /** Leading glyph shown in a soft circle — an `IconName`, any node, or `false` to hide it. Defaults to `FolderOpen`. */\n icon?: IconName | ReactNode | false\n /** Heading line. Defaults to `\"No Results Found\"`. */\n title?: ReactNode\n /** Muted description under the title (e.g. a hint on what to do next). */\n description?: ReactNode\n /** Action slot under the text — e.g. an \"Add Item\" or \"Clear Filters\" button. */\n action?: ReactNode\n /** Size — scales the icon, text, and vertical padding. Defaults to `md`. */\n size?: EmptyStateSize\n /**\n * Polished \"hero\" look: a faded grid backdrop (fades out toward the edges) + an elevated icon\n * (gradient + drop shadow). Defaults to `true`; pass `pattern={false}` for the flat, compact placeholder.\n */\n pattern?: boolean\n /** Tint the icon puck with a theme color (e.g. `error` for a failure). Omitted → the neutral muted puck. */\n color?: ThemeColor\n /** Extra content rendered below the action. */\n children?: ReactNode\n}\n\n/**\n * The empty-state placeholder — drop it in wherever a page, table, list, or gallery has nothing to\n * show (no records yet, no search matches). A centered, muted glyph in a soft circle + a `title` +\n * an optional `description` and `action` (e.g. a \"Add Item\" / \"Clear Filters\" button). Neutral by\n * design; pass a custom `icon` node for a tinted glyph. Token-only styling.\n */\nexport const EmptyState = forwardRef<HTMLDivElement, EmptyStateProps>(function EmptyState(\n {\n icon,\n title,\n description,\n action,\n size = 'md',\n pattern = true,\n color,\n className,\n style,\n children,\n ...props\n },\n ref,\n) {\n const t = useT()\n const resolvedTitle = title ?? t('emptyState.title')\n const renderedIcon =\n icon === false ? null : icon == null ? (\n <Icon name=\"FolderOpen\" />\n ) : typeof icon === 'string' && ICON_NAME_SET.has(icon) ? (\n <Icon name={icon as IconName} />\n ) : (\n icon\n )\n\n return (\n <div\n ref={ref}\n className={clsx(\n styles.emptyState,\n styles[size],\n pattern && styles.pattern,\n color && styles.tinted,\n className,\n )}\n style={\n (color\n ? { '--tz-btn-rgb': `var(--tz-color-${color}-rgb)`, ...style }\n : style) as CSSProperties\n }\n {...props}\n >\n {renderedIcon != null && (\n <div className={styles.icon} aria-hidden>\n {renderedIcon}\n </div>\n )}\n {resolvedTitle != null && <div className={styles.title}>{resolvedTitle}</div>}\n {description != null && <div className={styles.description}>{description}</div>}\n {action != null && <div className={styles.action}>{action}</div>}\n {children}\n </div>\n )\n})\n"],"names":["ICON_NAME_SET","ICON_NAMES","EmptyState","forwardRef","icon","title","description","action","size","pattern","color","className","style","children","props","ref","t","useT","resolvedTitle","renderedIcon","jsx","Icon","jsxs","clsx","styles"],"mappings":"2eASMA,EAAgB,IAAI,IAAYC,YAAU,EA8BnCC,EAAaC,EAAAA,WAA4C,SACpE,CACE,KAAAC,EACA,MAAAC,EACA,YAAAC,EACA,OAAAC,EACA,KAAAC,EAAO,KACP,QAAAC,EAAU,GACV,MAAAC,EACA,UAAAC,EACA,MAAAC,EACA,SAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAMC,EAAIC,EAAAA,KAAA,EACJC,EAAgBb,GAASW,EAAE,kBAAkB,EAC7CG,EACJf,IAAS,GAAQ,KAAOA,GAAQ,KAC9BgB,MAACC,EAAAA,KAAA,CAAK,KAAK,YAAA,CAAa,EACtB,OAAOjB,GAAS,UAAYJ,EAAc,IAAII,CAAI,EACpDgB,MAACC,EAAAA,KAAA,CAAK,KAAMjB,CAAA,CAAkB,EAE9BA,EAGJ,OACEkB,EAAAA,KAAC,MAAA,CACC,IAAAP,EACA,UAAWQ,EAAAA,KACTC,EAAO,WACPA,EAAOhB,CAAI,EACXC,GAAWe,EAAO,QAClBd,GAASc,EAAO,OAChBb,CAAA,EAEF,MACGD,EACG,CAAE,eAAgB,kBAAkBA,CAAK,QAAS,GAAGE,CAAA,EACrDA,EAEL,GAAGE,EAEH,SAAA,CAAAK,GAAgB,YACd,MAAA,CAAI,UAAWK,EAAO,KAAM,cAAW,GACrC,SAAAL,CAAA,CACH,EAEDD,GAAiB,MAAQE,EAAAA,IAAC,OAAI,UAAWI,EAAO,MAAQ,SAAAN,EAAc,EACtEZ,GAAe,MAAQc,EAAAA,IAAC,OAAI,UAAWI,EAAO,YAAc,SAAAlB,EAAY,EACxEC,GAAU,MAAQa,EAAAA,IAAC,OAAI,UAAWI,EAAO,OAAS,SAAAjB,EAAO,EACzDM,CAAA,CAAA,CAAA,CAGP,CAAC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const n=require("react/jsx-runtime"),c=require("react"),u=require("./ErrorState-BXMjBWav.cjs"),h=require("./ConfigProvider-CVLHPXQm.cjs"),d=c.forwardRef(function({error:r,fallback:t,description:s,compact:o=!0,...a},p){return r==null||r===!1?null:n.jsx(u.ErrorState,{ref:p,error:r,description:s??t,compact:o,...a})}),f=(e=[],r=[])=>e.length!==r.length||e.some((t,s)=>!Object.is(t,r[s])),i=e=>e instanceof Error?e:new Error(String(e));function l({error:e,reset:r}){const t=h.useT();return n.jsx(u.ErrorState,{error:e,description:t("errorState.description"),onRetry:r})}class E extends c.Component{constructor(){super(...arguments),this.state={error:null},this.reset=()=>{var r,t;this.setState({error:null}),(t=(r=this.props).onReset)==null||t.call(r)}}static getDerivedStateFromError(r){return{error:i(r)}}componentDidCatch(r,t){var s,o;(o=(s=this.props).onError)==null||o.call(s,i(r),t)}componentDidUpdate(r,t){this.state.error&&t.error&&f(r.resetKeys,this.props.resetKeys)&&this.reset()}render(){const{error:r}=this.state;if(!r)return this.props.children;const{fallback:t}=this.props;return typeof t=="function"?t(r,this.reset):t!==void 0?t:n.jsx(l,{error:r,reset:this.reset})}}exports.ErrorBoundary=E;exports.QueryError=d;
|
|
2
|
+
//# sourceMappingURL=ErrorBoundary-8iu-mR5Y.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary-8iu-mR5Y.cjs","sources":["../src/components/ErrorState/QueryError.tsx","../src/components/ErrorState/ErrorBoundary.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from 'react'\nimport { ErrorState, type ErrorStateProps } from './ErrorState'\n\nexport interface QueryErrorProps extends ErrorStateProps {\n /** The query's error (`query.error`). `null` / `undefined` → renders nothing. */\n error: unknown\n /**\n * The user-facing sentence (\"Could not load players.\"). Shown instead of the raw message, which then\n * only appears in the (dev) details panel. Same as `description`, which wins when both are set.\n */\n fallback?: ReactNode\n}\n\n/**\n * The react-query-style one-liner: `<QueryError error={users.error} onRetry={users.refetch}\n * fallback=\"Could not load players.\" />`. Renders nothing while `error` is empty, otherwise an\n * `ErrorState` — **compact by default** (it usually sits where the data would, inside a card or table\n * area; pass `compact={false}` for the hero). Everything else passes through to `ErrorState`.\n */\nexport const QueryError = forwardRef<HTMLDivElement, QueryErrorProps>(function QueryError(\n { error, fallback, description, compact = true, ...props },\n ref,\n) {\n if (error == null || error === false) return null\n return (\n <ErrorState\n ref={ref}\n error={error}\n description={description ?? fallback}\n compact={compact}\n {...props}\n />\n )\n})\n","import { Component, type ErrorInfo, type ReactNode } from 'react'\nimport { useT } from '../../theme'\nimport { ErrorState } from './ErrorState'\n\nexport interface ErrorBoundaryProps {\n /**\n * What to render after a crash — a node, or `(error, reset) => node`. Defaults to an `ErrorState` with\n * a friendly description, a **Try Again** button (`reset`) and the stack in dev.\n */\n fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode)\n /** Report the crash (e.g. `Sentry.captureException`). */\n onError?: (error: Error, info: ErrorInfo) => void\n /** Called after the boundary resets (Try Again, or a `resetKeys` change). */\n onReset?: () => void\n /** Reset automatically when any of these change (shallow) — e.g. `[location.pathname]` clears on navigation. */\n resetKeys?: unknown[]\n children?: ReactNode\n}\n\ninterface ErrorBoundaryState {\n error: Error | null\n}\n\nconst keysChanged = (a: unknown[] = [], b: unknown[] = []) =>\n a.length !== b.length || a.some((v, i) => !Object.is(v, b[i]))\n\nconst toError = (value: unknown) => (value instanceof Error ? value : new Error(String(value)))\n\n/** The default crash screen — a function component so it can read the localized strings. */\nfunction DefaultFallback({ error, reset }: { error: Error; reset: () => void }) {\n const t = useT()\n // a render crash message (\"Cannot read properties of undefined\") is for developers, not users —\n // the description stays friendly and the raw error lives in the dev-only details panel\n return <ErrorState error={error} description={t('errorState.description')} onRetry={reset} />\n}\n\n/**\n * Catches render errors in its subtree and shows a fallback instead of unmounting the whole app (a\n * white screen). The one class component in the library — React only offers error boundaries as\n * classes. `fallback` is a node or `(error, reset) => node` (default: an `ErrorState` with Try Again);\n * `onError` reports the crash (Sentry); `resetKeys` resets it when they change (e.g. the route path, so\n * navigating away recovers); `onReset` runs after any reset. `AdminRoot` mounts one around the page\n * content automatically, so a crashing page keeps the sidebar + header.\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n state: ErrorBoundaryState = { error: null }\n\n static getDerivedStateFromError(error: unknown): ErrorBoundaryState {\n return { error: toError(error) }\n }\n\n componentDidCatch(error: unknown, info: ErrorInfo) {\n this.props.onError?.(toError(error), info)\n }\n\n componentDidUpdate(prev: ErrorBoundaryProps, prevState: ErrorBoundaryState) {\n // reset only an error that was ALREADY showing before the keys changed — if the key change itself is\n // what crashed the subtree (same render), resetting would just re-render it into a second throw\n if (this.state.error && prevState.error && keysChanged(prev.resetKeys, this.props.resetKeys)) {\n this.reset()\n }\n }\n\n reset = () => {\n this.setState({ error: null })\n this.props.onReset?.()\n }\n\n render() {\n const { error } = this.state\n if (!error) return this.props.children\n const { fallback } = this.props\n if (typeof fallback === 'function') return fallback(error, this.reset)\n if (fallback !== undefined) return fallback\n return <DefaultFallback error={error} reset={this.reset} />\n }\n}\n"],"names":["QueryError","forwardRef","error","fallback","description","compact","props","ref","jsx","ErrorState","keysChanged","a","b","v","i","toError","value","DefaultFallback","reset","useT","ErrorBoundary","Component","_b","_a","info","prev","prevState"],"mappings":"uJAmBaA,EAAaC,EAAAA,WAA4C,SACpE,CAAE,MAAAC,EAAO,SAAAC,EAAU,YAAAC,EAAa,QAAAC,EAAU,GAAM,GAAGC,CAAA,EACnDC,EACA,CACA,OAAIL,GAAS,MAAQA,IAAU,GAAc,KAE3CM,EAAAA,IAACC,EAAAA,WAAA,CACC,IAAAF,EACA,MAAAL,EACA,YAAaE,GAAeD,EAC5B,QAAAE,EACC,GAAGC,CAAA,CAAA,CAGV,CAAC,ECVKI,EAAc,CAACC,EAAe,CAAA,EAAIC,EAAe,CAAA,IACrDD,EAAE,SAAWC,EAAE,QAAUD,EAAE,KAAK,CAACE,EAAGC,IAAM,CAAC,OAAO,GAAGD,EAAGD,EAAEE,CAAC,CAAC,CAAC,EAEzDC,EAAWC,GAAoBA,aAAiB,MAAQA,EAAQ,IAAI,MAAM,OAAOA,CAAK,CAAC,EAG7F,SAASC,EAAgB,CAAE,MAAAf,EAAO,MAAAgB,GAA8C,CAC9E,MAAM,EAAIC,EAAAA,KAAA,EAGV,OAAOX,EAAAA,IAACC,cAAW,MAAAP,EAAc,YAAa,EAAE,wBAAwB,EAAG,QAASgB,EAAO,CAC7F,CAUO,MAAME,UAAsBC,EAAAA,SAAkD,CAA9E,aAAA,CAAA,MAAA,GAAA,SAAA,EACL,KAAA,MAA4B,CAAE,MAAO,IAAA,EAkBrC,KAAA,MAAQ,IAAM,SACZ,KAAK,SAAS,CAAE,MAAO,IAAA,CAAM,GAC7BC,GAAAC,EAAA,KAAK,OAAM,UAAX,MAAAD,EAAA,KAAAC,EACF,CAAA,CAnBA,OAAO,yBAAyBrB,EAAoC,CAClE,MAAO,CAAE,MAAOa,EAAQb,CAAK,CAAA,CAC/B,CAEA,kBAAkBA,EAAgBsB,EAAiB,UACjDF,GAAAC,EAAA,KAAK,OAAM,UAAX,MAAAD,EAAA,KAAAC,EAAqBR,EAAQb,CAAK,EAAGsB,EACvC,CAEA,mBAAmBC,EAA0BC,EAA+B,CAGtE,KAAK,MAAM,OAASA,EAAU,OAAShB,EAAYe,EAAK,UAAW,KAAK,MAAM,SAAS,GACzF,KAAK,MAAA,CAET,CAOA,QAAS,CACP,KAAM,CAAE,MAAAvB,GAAU,KAAK,MACvB,GAAI,CAACA,EAAO,OAAO,KAAK,MAAM,SAC9B,KAAM,CAAE,SAAAC,GAAa,KAAK,MAC1B,OAAI,OAAOA,GAAa,WAAmBA,EAASD,EAAO,KAAK,KAAK,EACjEC,IAAa,OAAkBA,EAC5BK,EAAAA,IAACS,EAAA,CAAgB,MAAAf,EAAc,MAAO,KAAK,MAAO,CAC3D,CACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as u, Component as f } from "react";
|
|
3
|
+
import { E as a } from "./ErrorState-DKhZ4aJh.js";
|
|
4
|
+
import { a as h } from "./ConfigProvider-tvLbKiqu.js";
|
|
5
|
+
const S = u(function({ error: r, fallback: t, description: o, compact: s = !0, ...c }, p) {
|
|
6
|
+
return r == null || r === !1 ? null : /* @__PURE__ */ n(
|
|
7
|
+
a,
|
|
8
|
+
{
|
|
9
|
+
ref: p,
|
|
10
|
+
error: r,
|
|
11
|
+
description: o ?? t,
|
|
12
|
+
compact: s,
|
|
13
|
+
...c
|
|
14
|
+
}
|
|
15
|
+
);
|
|
16
|
+
}), l = (e = [], r = []) => e.length !== r.length || e.some((t, o) => !Object.is(t, r[o])), i = (e) => e instanceof Error ? e : new Error(String(e));
|
|
17
|
+
function d({ error: e, reset: r }) {
|
|
18
|
+
const t = h();
|
|
19
|
+
return /* @__PURE__ */ n(a, { error: e, description: t("errorState.description"), onRetry: r });
|
|
20
|
+
}
|
|
21
|
+
class D extends f {
|
|
22
|
+
constructor() {
|
|
23
|
+
super(...arguments), this.state = { error: null }, this.reset = () => {
|
|
24
|
+
var r, t;
|
|
25
|
+
this.setState({ error: null }), (t = (r = this.props).onReset) == null || t.call(r);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static getDerivedStateFromError(r) {
|
|
29
|
+
return { error: i(r) };
|
|
30
|
+
}
|
|
31
|
+
componentDidCatch(r, t) {
|
|
32
|
+
var o, s;
|
|
33
|
+
(s = (o = this.props).onError) == null || s.call(o, i(r), t);
|
|
34
|
+
}
|
|
35
|
+
componentDidUpdate(r, t) {
|
|
36
|
+
this.state.error && t.error && l(r.resetKeys, this.props.resetKeys) && this.reset();
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
const { error: r } = this.state;
|
|
40
|
+
if (!r) return this.props.children;
|
|
41
|
+
const { fallback: t } = this.props;
|
|
42
|
+
return typeof t == "function" ? t(r, this.reset) : t !== void 0 ? t : /* @__PURE__ */ n(d, { error: r, reset: this.reset });
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
D as E,
|
|
47
|
+
S as Q
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=ErrorBoundary-BSJL381Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorBoundary-BSJL381Y.js","sources":["../src/components/ErrorState/QueryError.tsx","../src/components/ErrorState/ErrorBoundary.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from 'react'\nimport { ErrorState, type ErrorStateProps } from './ErrorState'\n\nexport interface QueryErrorProps extends ErrorStateProps {\n /** The query's error (`query.error`). `null` / `undefined` → renders nothing. */\n error: unknown\n /**\n * The user-facing sentence (\"Could not load players.\"). Shown instead of the raw message, which then\n * only appears in the (dev) details panel. Same as `description`, which wins when both are set.\n */\n fallback?: ReactNode\n}\n\n/**\n * The react-query-style one-liner: `<QueryError error={users.error} onRetry={users.refetch}\n * fallback=\"Could not load players.\" />`. Renders nothing while `error` is empty, otherwise an\n * `ErrorState` — **compact by default** (it usually sits where the data would, inside a card or table\n * area; pass `compact={false}` for the hero). Everything else passes through to `ErrorState`.\n */\nexport const QueryError = forwardRef<HTMLDivElement, QueryErrorProps>(function QueryError(\n { error, fallback, description, compact = true, ...props },\n ref,\n) {\n if (error == null || error === false) return null\n return (\n <ErrorState\n ref={ref}\n error={error}\n description={description ?? fallback}\n compact={compact}\n {...props}\n />\n )\n})\n","import { Component, type ErrorInfo, type ReactNode } from 'react'\nimport { useT } from '../../theme'\nimport { ErrorState } from './ErrorState'\n\nexport interface ErrorBoundaryProps {\n /**\n * What to render after a crash — a node, or `(error, reset) => node`. Defaults to an `ErrorState` with\n * a friendly description, a **Try Again** button (`reset`) and the stack in dev.\n */\n fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode)\n /** Report the crash (e.g. `Sentry.captureException`). */\n onError?: (error: Error, info: ErrorInfo) => void\n /** Called after the boundary resets (Try Again, or a `resetKeys` change). */\n onReset?: () => void\n /** Reset automatically when any of these change (shallow) — e.g. `[location.pathname]` clears on navigation. */\n resetKeys?: unknown[]\n children?: ReactNode\n}\n\ninterface ErrorBoundaryState {\n error: Error | null\n}\n\nconst keysChanged = (a: unknown[] = [], b: unknown[] = []) =>\n a.length !== b.length || a.some((v, i) => !Object.is(v, b[i]))\n\nconst toError = (value: unknown) => (value instanceof Error ? value : new Error(String(value)))\n\n/** The default crash screen — a function component so it can read the localized strings. */\nfunction DefaultFallback({ error, reset }: { error: Error; reset: () => void }) {\n const t = useT()\n // a render crash message (\"Cannot read properties of undefined\") is for developers, not users —\n // the description stays friendly and the raw error lives in the dev-only details panel\n return <ErrorState error={error} description={t('errorState.description')} onRetry={reset} />\n}\n\n/**\n * Catches render errors in its subtree and shows a fallback instead of unmounting the whole app (a\n * white screen). The one class component in the library — React only offers error boundaries as\n * classes. `fallback` is a node or `(error, reset) => node` (default: an `ErrorState` with Try Again);\n * `onError` reports the crash (Sentry); `resetKeys` resets it when they change (e.g. the route path, so\n * navigating away recovers); `onReset` runs after any reset. `AdminRoot` mounts one around the page\n * content automatically, so a crashing page keeps the sidebar + header.\n */\nexport class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {\n state: ErrorBoundaryState = { error: null }\n\n static getDerivedStateFromError(error: unknown): ErrorBoundaryState {\n return { error: toError(error) }\n }\n\n componentDidCatch(error: unknown, info: ErrorInfo) {\n this.props.onError?.(toError(error), info)\n }\n\n componentDidUpdate(prev: ErrorBoundaryProps, prevState: ErrorBoundaryState) {\n // reset only an error that was ALREADY showing before the keys changed — if the key change itself is\n // what crashed the subtree (same render), resetting would just re-render it into a second throw\n if (this.state.error && prevState.error && keysChanged(prev.resetKeys, this.props.resetKeys)) {\n this.reset()\n }\n }\n\n reset = () => {\n this.setState({ error: null })\n this.props.onReset?.()\n }\n\n render() {\n const { error } = this.state\n if (!error) return this.props.children\n const { fallback } = this.props\n if (typeof fallback === 'function') return fallback(error, this.reset)\n if (fallback !== undefined) return fallback\n return <DefaultFallback error={error} reset={this.reset} />\n }\n}\n"],"names":["QueryError","forwardRef","error","fallback","description","compact","props","ref","jsx","ErrorState","keysChanged","a","b","v","i","toError","value","DefaultFallback","reset","useT","ErrorBoundary","Component","_b","_a","info","prev","prevState"],"mappings":";;;;AAmBO,MAAMA,IAAaC,EAA4C,SACpE,EAAE,OAAAC,GAAO,UAAAC,GAAU,aAAAC,GAAa,SAAAC,IAAU,IAAM,GAAGC,EAAA,GACnDC,GACA;AACA,SAAIL,KAAS,QAAQA,MAAU,KAAc,OAE3C,gBAAAM;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,KAAAF;AAAA,MACA,OAAAL;AAAA,MACA,aAAaE,KAAeD;AAAA,MAC5B,SAAAE;AAAA,MACC,GAAGC;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C,MAAa,KAAK;AAC1B,WAAI,OAAOA,KAAa,aAAmBA,EAASD,GAAO,KAAK,KAAK,IACjEC,MAAa,SAAkBA,IAC5B,gBAAAK,EAACS,GAAA,EAAgB,OAAAf,GAAc,OAAO,KAAK,OAAO;AAAA,EAC3D;AACF;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),w=require("react"),B=require("clsx"),M=require("./Alert-CfjDmLR8.cjs"),T=require("./Button-BD5wpg-t.cjs"),C=require("./CopyButton-0w4OToIy.cjs"),O=require("./EmptyState-C54C0Qwc.cjs"),G=require("./Icon-BUP5_kRs.cjs"),l=require("./errorMessage-C7N4KvUS.cjs"),H=require("./ConfigProvider-CVLHPXQm.cjs"),J="_errorState_19ba2_4",K="_actions_19ba2_9",Q="_fieldErrors_19ba2_18",R="_field_19ba2_18",U="_trace_19ba2_32",W="_traceId_19ba2_39",X="_compact_19ba2_45",Y="_details_19ba2_50",Z="_summary_19ba2_56",P="_pre_19ba2_63",L="_alertVariant_19ba2_80",rr="_alertTitle_19ba2_83",er="_alertBody_19ba2_87",tr="_alertTrace_19ba2_92",sr="_alertActions_19ba2_99",e={errorState:J,actions:K,fieldErrors:Q,field:R,trace:U,traceId:W,compact:X,details:Y,summary:Z,pre:P,alertVariant:L,alertTitle:rr,alertBody:er,alertTrace:tr,alertActions:sr},ar=w.forwardRef(function({error:c,variant:A="block",title:d,description:z,icon:u,onRetry:o,retrying:n=!1,retryLabel:h,showDetails:b="dev",compact:_=!1,traceId:v,fieldErrors:E,fieldLabels:m,size:k,pattern:F,action:i,className:S,children:y,...N},f){const s=H.useT(),V=l.getErrorMessage(c,a=>s("errorState.requestFailed",{status:a})),t=v===!1?void 0:v??l.getErrorTraceId(c),x=E===!1?void 0:E??l.getErrorFieldErrors(c),D=x&&Object.keys(x).length>0?r.jsx("ul",{className:e.fieldErrors,children:Object.entries(x).map(([a,$])=>r.jsxs("li",{children:[r.jsx("span",{className:e.field,children:(m==null?void 0:m[a])??l.humanizeField(a)})," —"," ",$]},a))}):void 0,g=z??D??V??s("errorState.description"),j=t!=null&&r.jsxs(r.Fragment,{children:[s("errorState.traceId"),": ",r.jsx("code",{className:e.traceId,children:t})]});if(A==="alert"){const a=t!=null||o!=null||i!=null?r.jsxs("span",{className:e.alertActions,children:[t!=null&&r.jsx(C.CopyButton,{value:t,size:"sm",variant:"text",color:"error"}),o!=null&&r.jsx(T.Button,{size:"sm",variant:"text",color:"error",loading:n,disabled:n,onClick:o,children:h??s("errorState.retry")}),i]}):void 0;return r.jsxs(M.Alert,{ref:f,color:"error",icon:u,action:a,className:B.clsx(e.alertVariant,S),...N,children:[d!=null&&r.jsx("span",{className:e.alertTitle,children:d}),r.jsx("span",{className:e.alertBody,children:g}),j&&r.jsx("span",{className:e.alertTrace,children:j}),y]})}const p=(b==="dev"?l.isDev():b)?l.getErrorDetails(c):void 0,q=p!=null&&t!=null?`${s("errorState.traceId")}: ${t}
|
|
2
|
+
|
|
3
|
+
${p}`:p,I=o!=null?r.jsx(T.Button,{size:"sm",variant:"outlined",color:"primary",startIcon:r.jsx(G.Icon,{name:"RefreshRight"}),loading:n,disabled:n,onClick:o,children:h??s("errorState.retry")}):null;return r.jsxs(O.EmptyState,{ref:f,role:"alert",color:"error",icon:u===void 0?l.isNetworkError(c)?"CloudCross":"Danger":u,title:d??s("errorState.title"),description:g,size:k??(_?"sm":"md"),pattern:F??!_,action:I||i?r.jsxs("span",{className:e.actions,children:[I,i]}):void 0,className:B.clsx(e.errorState,_&&e.compact,S),...N,children:[t!=null&&r.jsxs("span",{className:e.trace,children:[r.jsx("span",{children:j}),r.jsx(C.CopyButton,{value:t,size:"sm",variant:"text",color:"primary"})]}),q!=null&&r.jsxs("details",{className:e.details,children:[r.jsx("summary",{className:e.summary,children:s("errorState.details")}),r.jsx("pre",{className:e.pre,children:q})]}),y]})});exports.ErrorState=ar;
|
|
4
|
+
//# sourceMappingURL=ErrorState-BXMjBWav.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorState-BXMjBWav.cjs","sources":["../src/components/ErrorState/ErrorState.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { Alert } from '../Alert'\nimport { Button } from '../Button'\nimport { CopyButton } from '../CopyButton'\nimport { EmptyState, type EmptyStateProps } from '../EmptyState'\nimport { Icon } from '../Icon'\nimport type { IconName } from '../../icons/names'\nimport {\n getErrorDetails,\n getErrorFieldErrors,\n getErrorMessage,\n getErrorTraceId,\n humanizeField,\n isNetworkError,\n isDev,\n} from './errorMessage'\nimport styles from './ErrorState.module.css'\n\nexport type ErrorStateVariant = 'block' | 'alert'\n\nexport interface ErrorStateProps extends Omit<EmptyStateProps, 'icon' | 'title' | 'color'> {\n /**\n * The shape. `'block'` (default) — the `EmptyState`-style block (puck, title, centred message), for a read\n * that failed where its data would be. `'alert'` — a one-line red `Alert` banner for a **failed save**\n * above a form or in a modal, where the form stays on screen: the message (no default title), a muted\n * trace id line, and the copy / retry / `action` buttons in the alert's action slot. `showDetails`,\n * `compact` and `pattern` don't apply to `'alert'`.\n */\n variant?: ErrorStateVariant\n /**\n * What failed — an `Error`, a string, an axios-style error, a `{ message }` or a raw `{ status }`\n * response. Its message becomes the description (unless `description` is given) and its stack feeds\n * the details panel.\n */\n error?: unknown\n /**\n * Heading. Block: defaults to the localized \"Something Went Wrong\". Alert: none unless given — the message\n * is the point.\n */\n title?: ReactNode\n /**\n * Leading icon — a known `IconName`, any node, or `false`. Block: defaults to `Danger` (or `CloudCross` when\n * the request never got a response — an explicit `status: 0` / network error code), tinted `error`. Alert:\n * the alert's own error icon unless overridden.\n */\n icon?: IconName | ReactNode | false\n /** Adds a \"Try Again\" button that calls this (e.g. a query's `refetch`). */\n onRetry?: () => void\n /**\n * The retry is running (e.g. `query.isFetching`) — the \"Try Again\" button shows its loader and is disabled,\n * so a slow refetch doesn't look like a dead click. Defaults to `false`.\n */\n retrying?: boolean\n /** Retry button label. Defaults to the localized \"Try Again\". */\n retryLabel?: ReactNode\n /**\n * Show a collapsible technical details panel (stack / raw error). `'dev'` (default) shows it only in\n * development builds; `true` always; `false` never.\n */\n showDetails?: boolean | 'dev'\n /** The inline variant — small, no hero pattern — for inside a table, card or panel. Defaults to `false`. */\n compact?: boolean\n /**\n * The server's trace id, shown under the message with a copy button (it matches a report to the server\n * log). Defaults to the one on `error` (`error.traceId` / `error.response.data.traceId`); `false` hides it.\n */\n traceId?: string | false\n /**\n * Per-field validation messages (`{ field: message }`), listed as the description when there's no explicit\n * `description`. Defaults to the ones on `error` (`getErrorFieldErrors`: `error.fieldErrors` — an object, a\n * method or a `{ field, message }[]` —, `error.details`, `error.response.data.errors`); `false` hides them. In a form, put them on the inputs instead.\n */\n fieldErrors?: Record<string, string> | false\n /**\n * Labels for the field-error keys (`{ newPassword: 'New Password' }`). A key without one is shown humanized\n * and Title Cased (`newPassword` / `new_password` → \"New Password\"; a dotted path keeps its last segment).\n */\n fieldLabels?: Record<string, ReactNode>\n}\n\n/**\n * The \"loading failed\" counterpart of `EmptyState` — a semantic preset over it: an `error`-tinted\n * `Danger` puck, a localized \"Something Went Wrong\" title, the failure's own message as the description\n * (extracted from an `Error`, a string, an axios-style `response.data.message`, a `{ message }`, or a raw\n * `{ status }` response → \"Request failed (404)\"), an optional **Try Again** button (`onRetry`), and a\n * developer-only details panel with the stack (`showDetails`, default `'dev'`). `compact` is the inline\n * variant for a table / card. The server's `traceId` (copyable) and a 400's per-field `fieldErrors` are shown\n * when the error carries them. `variant=\"alert\"` renders the same data as a one-line `Alert` banner — for a\n * failed save above a form or in a modal. `retrying` puts the retry button in its loading state. Announced to\n * assistive tech once (`role=\"alert\"`).\n * `forwardRef` to the root; any other `EmptyState` prop (`size`, `pattern`, `action`, …) passes through.\n */\nexport const ErrorState = forwardRef<HTMLDivElement, ErrorStateProps>(function ErrorState(\n {\n error,\n variant = 'block',\n title,\n description,\n icon,\n onRetry,\n retrying = false,\n retryLabel,\n showDetails = 'dev',\n compact = false,\n traceId: traceIdProp,\n fieldErrors: fieldErrorsProp,\n fieldLabels,\n size,\n pattern,\n action,\n className,\n children,\n ...props\n },\n ref,\n) {\n const t = useT()\n const message = getErrorMessage(error, (status) => t('errorState.requestFailed', { status }))\n const traceId = traceIdProp === false ? undefined : (traceIdProp ?? getErrorTraceId(error))\n const fieldErrors =\n fieldErrorsProp === false ? undefined : (fieldErrorsProp ?? getErrorFieldErrors(error))\n const fieldErrorList =\n fieldErrors && Object.keys(fieldErrors).length > 0 ? (\n <ul className={styles.fieldErrors}>\n {Object.entries(fieldErrors).map(([field, msg]) => (\n <li key={field}>\n <span className={styles.field}>{fieldLabels?.[field] ?? humanizeField(field)}</span> —{' '}\n {msg}\n </li>\n ))}\n </ul>\n ) : undefined\n const body = description ?? fieldErrorList ?? message ?? t('errorState.description')\n const traceLabel = traceId != null && (\n <>\n {t('errorState.traceId')}: <code className={styles.traceId}>{traceId}</code>\n </>\n )\n\n // ── alert: a one-line banner for a failed save above a form / in a modal ──\n if (variant === 'alert') {\n const alertActions =\n traceId != null || onRetry != null || action != null ? (\n <span className={styles.alertActions}>\n {traceId != null && <CopyButton value={traceId} size=\"sm\" variant=\"text\" color=\"error\" />}\n {onRetry != null && (\n <Button\n size=\"sm\"\n variant=\"text\"\n color=\"error\"\n loading={retrying}\n disabled={retrying}\n onClick={onRetry}\n >\n {retryLabel ?? t('errorState.retry')}\n </Button>\n )}\n {action}\n </span>\n ) : undefined\n return (\n <Alert\n ref={ref}\n color=\"error\"\n icon={icon}\n action={alertActions}\n className={clsx(styles.alertVariant, className)}\n {...props}\n >\n {title != null && <span className={styles.alertTitle}>{title}</span>}\n <span className={styles.alertBody}>{body}</span>\n {traceLabel && <span className={styles.alertTrace}>{traceLabel}</span>}\n {children}\n </Alert>\n )\n }\n\n // ── block ──\n // the trace id leads the developer panel too (it's what matches the server log)\n const rawDetails = (showDetails === 'dev' ? isDev() : showDetails)\n ? getErrorDetails(error)\n : undefined\n const details =\n rawDetails != null && traceId != null\n ? `${t('errorState.traceId')}: ${traceId}\\n\\n${rawDetails}`\n : rawDetails\n\n const retry =\n onRetry != null ? (\n <Button\n size=\"sm\"\n variant=\"outlined\"\n color=\"primary\"\n startIcon={<Icon name=\"RefreshRight\" />}\n loading={retrying}\n disabled={retrying}\n onClick={onRetry}\n >\n {retryLabel ?? t('errorState.retry')}\n </Button>\n ) : null\n\n return (\n <EmptyState\n ref={ref}\n // one announcement, assertive: an error is what the user needs to know now (role=\"alert\" already\n // implies aria-live=\"assertive\" — pairing it with \"polite\" was contradictory)\n role=\"alert\"\n color=\"error\"\n icon={icon === undefined ? (isNetworkError(error) ? 'CloudCross' : 'Danger') : icon}\n title={title ?? t('errorState.title')}\n // a 400's message is the generic \"validation errors occurred\" — the per-field list is the useful part\n description={body}\n size={size ?? (compact ? 'sm' : 'md')}\n pattern={pattern ?? !compact}\n action={\n retry || action ? (\n <span className={styles.actions}>\n {retry}\n {action}\n </span>\n ) : undefined\n }\n className={clsx(styles.errorState, compact && styles.compact, className)}\n {...props}\n >\n {traceId != null && (\n <span className={styles.trace}>\n <span>{traceLabel}</span>\n <CopyButton value={traceId} size=\"sm\" variant=\"text\" color=\"primary\" />\n </span>\n )}\n {details != null && (\n <details className={styles.details}>\n <summary className={styles.summary}>{t('errorState.details')}</summary>\n <pre className={styles.pre}>{details}</pre>\n </details>\n )}\n {children}\n </EmptyState>\n )\n})\n"],"names":["ErrorState","forwardRef","error","variant","title","description","icon","onRetry","retrying","retryLabel","showDetails","compact","traceIdProp","fieldErrorsProp","fieldLabels","size","pattern","action","className","children","props","ref","t","useT","message","getErrorMessage","status","traceId","getErrorTraceId","fieldErrors","getErrorFieldErrors","fieldErrorList","jsx","styles","field","msg","jsxs","humanizeField","body","traceLabel","Fragment","alertActions","CopyButton","Button","Alert","clsx","rawDetails","isDev","getErrorDetails","details","retry","Icon","EmptyState","isNetworkError"],"mappings":"22BA8Fa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,CAAA,EAEnC,KAEN,OACEc,EAAAA,KAACgB,EAAAA,WAAA,CACC,IAAA/B,EAGA,KAAK,QACL,MAAM,QACN,KAAMf,IAAS,OAAa+C,EAAAA,eAAenD,CAAK,EAAI,aAAe,SAAYI,EAC/E,MAAOF,GAASkB,EAAE,kBAAkB,EAEpC,YAAagB,EACb,KAAMvB,IAASJ,EAAU,KAAO,MAChC,QAASK,GAAW,CAACL,EACrB,OACEuC,GAASjC,SACN,OAAA,CAAK,UAAWgB,EAAO,QACrB,SAAA,CAAAiB,EACAjC,CAAA,CAAA,CACH,EACE,OAEN,UAAW4B,EAAAA,KAAKZ,EAAO,WAAYtB,GAAWsB,EAAO,QAASf,CAAS,EACtE,GAAGE,EAEH,SAAA,CAAAO,GAAW,MACVS,EAAAA,KAAC,OAAA,CAAK,UAAWH,EAAO,MACtB,SAAA,CAAAD,EAAAA,IAAC,QAAM,SAAAO,CAAA,CAAW,EAClBP,EAAAA,IAACU,EAAAA,YAAW,MAAOf,EAAS,KAAK,KAAK,QAAQ,OAAO,MAAM,SAAA,CAAU,CAAA,EACvE,EAEDsB,GAAW,MACVb,EAAAA,KAAC,UAAA,CAAQ,UAAWH,EAAO,QACzB,SAAA,CAAAD,MAAC,WAAQ,UAAWC,EAAO,QAAU,SAAAX,EAAE,oBAAoB,EAAE,EAC7DU,EAAAA,IAAC,MAAA,CAAI,UAAWC,EAAO,IAAM,SAAAgB,CAAA,CAAQ,CAAA,EACvC,EAED9B,CAAA,CAAA,CAAA,CAGP,CAAC"}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { jsx as a, jsxs as s, Fragment as O } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as q } from "react";
|
|
3
|
+
import { clsx as B } from "clsx";
|
|
4
|
+
import { A as M } from "./Alert-LJDrtkJy.js";
|
|
5
|
+
import { B as z } from "./Button-PBZnkRNn.js";
|
|
6
|
+
import { C } from "./CopyButton-B_mYxcXV.js";
|
|
7
|
+
import { E as G } from "./EmptyState-BEVEGcLx.js";
|
|
8
|
+
import { I as H } from "./Icon-CGQ5yGSZ.js";
|
|
9
|
+
import { b as J, d as K, a as Q, h as U, f as W, g as X, i as Y } from "./errorMessage-C83fB2h5.js";
|
|
10
|
+
import { a as Z } from "./ConfigProvider-tvLbKiqu.js";
|
|
11
|
+
const R = "_errorState_19ba2_4", P = "_actions_19ba2_9", L = "_fieldErrors_19ba2_18", rr = "_field_19ba2_18", ar = "_trace_19ba2_32", er = "_traceId_19ba2_39", tr = "_compact_19ba2_45", sr = "_details_19ba2_50", lr = "_summary_19ba2_56", or = "_pre_19ba2_63", cr = "_alertVariant_19ba2_80", nr = "_alertTitle_19ba2_83", ir = "_alertBody_19ba2_87", dr = "_alertTrace_19ba2_92", mr = "_alertActions_19ba2_99", r = {
|
|
12
|
+
errorState: R,
|
|
13
|
+
actions: P,
|
|
14
|
+
fieldErrors: L,
|
|
15
|
+
field: rr,
|
|
16
|
+
trace: ar,
|
|
17
|
+
traceId: er,
|
|
18
|
+
compact: tr,
|
|
19
|
+
details: sr,
|
|
20
|
+
summary: lr,
|
|
21
|
+
pre: or,
|
|
22
|
+
alertVariant: cr,
|
|
23
|
+
alertTitle: nr,
|
|
24
|
+
alertBody: ir,
|
|
25
|
+
alertTrace: dr,
|
|
26
|
+
alertActions: mr
|
|
27
|
+
}, Ir = q(function({
|
|
28
|
+
error: o,
|
|
29
|
+
variant: k = "block",
|
|
30
|
+
title: d,
|
|
31
|
+
description: j,
|
|
32
|
+
icon: m,
|
|
33
|
+
onRetry: c,
|
|
34
|
+
retrying: n = !1,
|
|
35
|
+
retryLabel: b,
|
|
36
|
+
showDetails: E = "dev",
|
|
37
|
+
compact: _ = !1,
|
|
38
|
+
traceId: v,
|
|
39
|
+
fieldErrors: S,
|
|
40
|
+
fieldLabels: u,
|
|
41
|
+
size: F,
|
|
42
|
+
pattern: V,
|
|
43
|
+
action: i,
|
|
44
|
+
className: N,
|
|
45
|
+
children: y,
|
|
46
|
+
...I
|
|
47
|
+
}, g) {
|
|
48
|
+
const t = Z(), D = J(o, (l) => t("errorState.requestFailed", { status: l })), e = v === !1 ? void 0 : v ?? K(o), p = S === !1 ? void 0 : S ?? Q(o), $ = p && Object.keys(p).length > 0 ? /* @__PURE__ */ a("ul", { className: r.fieldErrors, children: Object.entries(p).map(([l, w]) => /* @__PURE__ */ s("li", { children: [
|
|
49
|
+
/* @__PURE__ */ a("span", { className: r.field, children: (u == null ? void 0 : u[l]) ?? U(l) }),
|
|
50
|
+
" —",
|
|
51
|
+
" ",
|
|
52
|
+
w
|
|
53
|
+
] }, l)) }) : void 0, T = j ?? $ ?? D ?? t("errorState.description"), f = e != null && /* @__PURE__ */ s(O, { children: [
|
|
54
|
+
t("errorState.traceId"),
|
|
55
|
+
": ",
|
|
56
|
+
/* @__PURE__ */ a("code", { className: r.traceId, children: e })
|
|
57
|
+
] });
|
|
58
|
+
if (k === "alert") {
|
|
59
|
+
const l = e != null || c != null || i != null ? /* @__PURE__ */ s("span", { className: r.alertActions, children: [
|
|
60
|
+
e != null && /* @__PURE__ */ a(C, { value: e, size: "sm", variant: "text", color: "error" }),
|
|
61
|
+
c != null && /* @__PURE__ */ a(
|
|
62
|
+
z,
|
|
63
|
+
{
|
|
64
|
+
size: "sm",
|
|
65
|
+
variant: "text",
|
|
66
|
+
color: "error",
|
|
67
|
+
loading: n,
|
|
68
|
+
disabled: n,
|
|
69
|
+
onClick: c,
|
|
70
|
+
children: b ?? t("errorState.retry")
|
|
71
|
+
}
|
|
72
|
+
),
|
|
73
|
+
i
|
|
74
|
+
] }) : void 0;
|
|
75
|
+
return /* @__PURE__ */ s(
|
|
76
|
+
M,
|
|
77
|
+
{
|
|
78
|
+
ref: g,
|
|
79
|
+
color: "error",
|
|
80
|
+
icon: m,
|
|
81
|
+
action: l,
|
|
82
|
+
className: B(r.alertVariant, N),
|
|
83
|
+
...I,
|
|
84
|
+
children: [
|
|
85
|
+
d != null && /* @__PURE__ */ a("span", { className: r.alertTitle, children: d }),
|
|
86
|
+
/* @__PURE__ */ a("span", { className: r.alertBody, children: T }),
|
|
87
|
+
f && /* @__PURE__ */ a("span", { className: r.alertTrace, children: f }),
|
|
88
|
+
y
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
const h = (E === "dev" ? W() : E) ? X(o) : void 0, x = h != null && e != null ? `${t("errorState.traceId")}: ${e}
|
|
94
|
+
|
|
95
|
+
${h}` : h, A = c != null ? /* @__PURE__ */ a(
|
|
96
|
+
z,
|
|
97
|
+
{
|
|
98
|
+
size: "sm",
|
|
99
|
+
variant: "outlined",
|
|
100
|
+
color: "primary",
|
|
101
|
+
startIcon: /* @__PURE__ */ a(H, { name: "RefreshRight" }),
|
|
102
|
+
loading: n,
|
|
103
|
+
disabled: n,
|
|
104
|
+
onClick: c,
|
|
105
|
+
children: b ?? t("errorState.retry")
|
|
106
|
+
}
|
|
107
|
+
) : null;
|
|
108
|
+
return /* @__PURE__ */ s(
|
|
109
|
+
G,
|
|
110
|
+
{
|
|
111
|
+
ref: g,
|
|
112
|
+
role: "alert",
|
|
113
|
+
color: "error",
|
|
114
|
+
icon: m === void 0 ? Y(o) ? "CloudCross" : "Danger" : m,
|
|
115
|
+
title: d ?? t("errorState.title"),
|
|
116
|
+
description: T,
|
|
117
|
+
size: F ?? (_ ? "sm" : "md"),
|
|
118
|
+
pattern: V ?? !_,
|
|
119
|
+
action: A || i ? /* @__PURE__ */ s("span", { className: r.actions, children: [
|
|
120
|
+
A,
|
|
121
|
+
i
|
|
122
|
+
] }) : void 0,
|
|
123
|
+
className: B(r.errorState, _ && r.compact, N),
|
|
124
|
+
...I,
|
|
125
|
+
children: [
|
|
126
|
+
e != null && /* @__PURE__ */ s("span", { className: r.trace, children: [
|
|
127
|
+
/* @__PURE__ */ a("span", { children: f }),
|
|
128
|
+
/* @__PURE__ */ a(C, { value: e, size: "sm", variant: "text", color: "primary" })
|
|
129
|
+
] }),
|
|
130
|
+
x != null && /* @__PURE__ */ s("details", { className: r.details, children: [
|
|
131
|
+
/* @__PURE__ */ a("summary", { className: r.summary, children: t("errorState.details") }),
|
|
132
|
+
/* @__PURE__ */ a("pre", { className: r.pre, children: x })
|
|
133
|
+
] }),
|
|
134
|
+
y
|
|
135
|
+
]
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
export {
|
|
140
|
+
Ir as E
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=ErrorState-DKhZ4aJh.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorState-DKhZ4aJh.js","sources":["../src/components/ErrorState/ErrorState.tsx"],"sourcesContent":["import { forwardRef, type ReactNode } from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { Alert } from '../Alert'\nimport { Button } from '../Button'\nimport { CopyButton } from '../CopyButton'\nimport { EmptyState, type EmptyStateProps } from '../EmptyState'\nimport { Icon } from '../Icon'\nimport type { IconName } from '../../icons/names'\nimport {\n getErrorDetails,\n getErrorFieldErrors,\n getErrorMessage,\n getErrorTraceId,\n humanizeField,\n isNetworkError,\n isDev,\n} from './errorMessage'\nimport styles from './ErrorState.module.css'\n\nexport type ErrorStateVariant = 'block' | 'alert'\n\nexport interface ErrorStateProps extends Omit<EmptyStateProps, 'icon' | 'title' | 'color'> {\n /**\n * The shape. `'block'` (default) — the `EmptyState`-style block (puck, title, centred message), for a read\n * that failed where its data would be. `'alert'` — a one-line red `Alert` banner for a **failed save**\n * above a form or in a modal, where the form stays on screen: the message (no default title), a muted\n * trace id line, and the copy / retry / `action` buttons in the alert's action slot. `showDetails`,\n * `compact` and `pattern` don't apply to `'alert'`.\n */\n variant?: ErrorStateVariant\n /**\n * What failed — an `Error`, a string, an axios-style error, a `{ message }` or a raw `{ status }`\n * response. Its message becomes the description (unless `description` is given) and its stack feeds\n * the details panel.\n */\n error?: unknown\n /**\n * Heading. Block: defaults to the localized \"Something Went Wrong\". Alert: none unless given — the message\n * is the point.\n */\n title?: ReactNode\n /**\n * Leading icon — a known `IconName`, any node, or `false`. Block: defaults to `Danger` (or `CloudCross` when\n * the request never got a response — an explicit `status: 0` / network error code), tinted `error`. Alert:\n * the alert's own error icon unless overridden.\n */\n icon?: IconName | ReactNode | false\n /** Adds a \"Try Again\" button that calls this (e.g. a query's `refetch`). */\n onRetry?: () => void\n /**\n * The retry is running (e.g. `query.isFetching`) — the \"Try Again\" button shows its loader and is disabled,\n * so a slow refetch doesn't look like a dead click. Defaults to `false`.\n */\n retrying?: boolean\n /** Retry button label. Defaults to the localized \"Try Again\". */\n retryLabel?: ReactNode\n /**\n * Show a collapsible technical details panel (stack / raw error). `'dev'` (default) shows it only in\n * development builds; `true` always; `false` never.\n */\n showDetails?: boolean | 'dev'\n /** The inline variant — small, no hero pattern — for inside a table, card or panel. Defaults to `false`. */\n compact?: boolean\n /**\n * The server's trace id, shown under the message with a copy button (it matches a report to the server\n * log). Defaults to the one on `error` (`error.traceId` / `error.response.data.traceId`); `false` hides it.\n */\n traceId?: string | false\n /**\n * Per-field validation messages (`{ field: message }`), listed as the description when there's no explicit\n * `description`. Defaults to the ones on `error` (`getErrorFieldErrors`: `error.fieldErrors` — an object, a\n * method or a `{ field, message }[]` —, `error.details`, `error.response.data.errors`); `false` hides them. In a form, put them on the inputs instead.\n */\n fieldErrors?: Record<string, string> | false\n /**\n * Labels for the field-error keys (`{ newPassword: 'New Password' }`). A key without one is shown humanized\n * and Title Cased (`newPassword` / `new_password` → \"New Password\"; a dotted path keeps its last segment).\n */\n fieldLabels?: Record<string, ReactNode>\n}\n\n/**\n * The \"loading failed\" counterpart of `EmptyState` — a semantic preset over it: an `error`-tinted\n * `Danger` puck, a localized \"Something Went Wrong\" title, the failure's own message as the description\n * (extracted from an `Error`, a string, an axios-style `response.data.message`, a `{ message }`, or a raw\n * `{ status }` response → \"Request failed (404)\"), an optional **Try Again** button (`onRetry`), and a\n * developer-only details panel with the stack (`showDetails`, default `'dev'`). `compact` is the inline\n * variant for a table / card. The server's `traceId` (copyable) and a 400's per-field `fieldErrors` are shown\n * when the error carries them. `variant=\"alert\"` renders the same data as a one-line `Alert` banner — for a\n * failed save above a form or in a modal. `retrying` puts the retry button in its loading state. Announced to\n * assistive tech once (`role=\"alert\"`).\n * `forwardRef` to the root; any other `EmptyState` prop (`size`, `pattern`, `action`, …) passes through.\n */\nexport const ErrorState = forwardRef<HTMLDivElement, ErrorStateProps>(function ErrorState(\n {\n error,\n variant = 'block',\n title,\n description,\n icon,\n onRetry,\n retrying = false,\n retryLabel,\n showDetails = 'dev',\n compact = false,\n traceId: traceIdProp,\n fieldErrors: fieldErrorsProp,\n fieldLabels,\n size,\n pattern,\n action,\n className,\n children,\n ...props\n },\n ref,\n) {\n const t = useT()\n const message = getErrorMessage(error, (status) => t('errorState.requestFailed', { status }))\n const traceId = traceIdProp === false ? undefined : (traceIdProp ?? getErrorTraceId(error))\n const fieldErrors =\n fieldErrorsProp === false ? undefined : (fieldErrorsProp ?? getErrorFieldErrors(error))\n const fieldErrorList =\n fieldErrors && Object.keys(fieldErrors).length > 0 ? (\n <ul className={styles.fieldErrors}>\n {Object.entries(fieldErrors).map(([field, msg]) => (\n <li key={field}>\n <span className={styles.field}>{fieldLabels?.[field] ?? humanizeField(field)}</span> —{' '}\n {msg}\n </li>\n ))}\n </ul>\n ) : undefined\n const body = description ?? fieldErrorList ?? message ?? t('errorState.description')\n const traceLabel = traceId != null && (\n <>\n {t('errorState.traceId')}: <code className={styles.traceId}>{traceId}</code>\n </>\n )\n\n // ── alert: a one-line banner for a failed save above a form / in a modal ──\n if (variant === 'alert') {\n const alertActions =\n traceId != null || onRetry != null || action != null ? (\n <span className={styles.alertActions}>\n {traceId != null && <CopyButton value={traceId} size=\"sm\" variant=\"text\" color=\"error\" />}\n {onRetry != null && (\n <Button\n size=\"sm\"\n variant=\"text\"\n color=\"error\"\n loading={retrying}\n disabled={retrying}\n onClick={onRetry}\n >\n {retryLabel ?? t('errorState.retry')}\n </Button>\n )}\n {action}\n </span>\n ) : undefined\n return (\n <Alert\n ref={ref}\n color=\"error\"\n icon={icon}\n action={alertActions}\n className={clsx(styles.alertVariant, className)}\n {...props}\n >\n {title != null && <span className={styles.alertTitle}>{title}</span>}\n <span className={styles.alertBody}>{body}</span>\n {traceLabel && <span className={styles.alertTrace}>{traceLabel}</span>}\n {children}\n </Alert>\n )\n }\n\n // ── block ──\n // the trace id leads the developer panel too (it's what matches the server log)\n const rawDetails = (showDetails === 'dev' ? isDev() : showDetails)\n ? getErrorDetails(error)\n : undefined\n const details =\n rawDetails != null && traceId != null\n ? `${t('errorState.traceId')}: ${traceId}\\n\\n${rawDetails}`\n : rawDetails\n\n const retry =\n onRetry != null ? (\n <Button\n size=\"sm\"\n variant=\"outlined\"\n color=\"primary\"\n startIcon={<Icon name=\"RefreshRight\" />}\n loading={retrying}\n disabled={retrying}\n onClick={onRetry}\n >\n {retryLabel ?? t('errorState.retry')}\n </Button>\n ) : null\n\n return (\n <EmptyState\n ref={ref}\n // one announcement, assertive: an error is what the user needs to know now (role=\"alert\" already\n // implies aria-live=\"assertive\" — pairing it with \"polite\" was contradictory)\n role=\"alert\"\n color=\"error\"\n icon={icon === undefined ? (isNetworkError(error) ? 'CloudCross' : 'Danger') : icon}\n title={title ?? t('errorState.title')}\n // a 400's message is the generic \"validation errors occurred\" — the per-field list is the useful part\n description={body}\n size={size ?? (compact ? 'sm' : 'md')}\n pattern={pattern ?? !compact}\n action={\n retry || action ? (\n <span className={styles.actions}>\n {retry}\n {action}\n </span>\n ) : undefined\n }\n className={clsx(styles.errorState, compact && styles.compact, className)}\n {...props}\n >\n {traceId != null && (\n <span className={styles.trace}>\n <span>{traceLabel}</span>\n <CopyButton value={traceId} size=\"sm\" variant=\"text\" color=\"primary\" />\n </span>\n )}\n {details != null && (\n <details className={styles.details}>\n <summary className={styles.summary}>{t('errorState.details')}</summary>\n <pre className={styles.pre}>{details}</pre>\n </details>\n )}\n {children}\n </EmptyState>\n )\n})\n"],"names":["ErrorState","forwardRef","error","variant","title","description","icon","onRetry","retrying","retryLabel","showDetails","compact","traceIdProp","fieldErrorsProp","fieldLabels","size","pattern","action","className","children","props","ref","useT","message","getErrorMessage","status","traceId","getErrorTraceId","fieldErrors","getErrorFieldErrors","fieldErrorList","jsx","styles","field","msg","jsxs","humanizeField","body","traceLabel","Fragment","alertActions","CopyButton","Button","Alert","clsx","rawDetails","isDev","getErrorDetails","details","retry","Icon","EmptyState","isNetworkError"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;GA8FaA,KAAaC,EAA4C,SACpE;AAAA,EACE,OAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,YAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,SAAAC,IAAU;AAAA,EACV,SAASC;AAAA,EACT,aAAaC;AAAA,EACb,aAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AACL,GACAC,GACA;AACA,QAAM,IAAIC,EAAA,GACJC,IAAUC,EAAgBtB,GAAO,CAACuB,MAAW,EAAE,4BAA4B,EAAE,QAAAA,EAAA,CAAQ,CAAC,GACtFC,IAAUd,MAAgB,KAAQ,SAAaA,KAAee,EAAgBzB,CAAK,GACnF0B,IACJf,MAAoB,KAAQ,SAAaA,KAAmBgB,EAAoB3B,CAAK,GACjF4B,IACJF,KAAe,OAAO,KAAKA,CAAW,EAAE,SAAS,IAC/C,gBAAAG,EAAC,MAAA,EAAG,WAAWC,EAAO,aACnB,UAAA,OAAO,QAAQJ,CAAW,EAAE,IAAI,CAAC,CAACK,GAAOC,CAAG,MAC3C,gBAAAC,EAAC,MAAA,EACC,UAAA;AAAA,IAAA,gBAAAJ,EAAC,QAAA,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,QAAAM,KAAW,QACV,gBAAAS,EAAC,QAAA,EAAK,WAAWH,EAAO,OACtB,UAAA;AAAA,UAAA,gBAAAD,EAAC,UAAM,UAAAO,EAAA,CAAW;AAAA,UAClB,gBAAAP,EAACU,KAAW,OAAOf,GAAS,MAAK,MAAK,SAAQ,QAAO,OAAM,UAAA,CAAU;AAAA,QAAA,GACvE;AAAA,QAEDsB,KAAW,QACV,gBAAAb,EAAC,WAAA,EAAQ,WAAWH,EAAO,SACzB,UAAA;AAAA,UAAA,gBAAAD,EAAC,aAAQ,WAAWC,EAAO,SAAU,UAAA,EAAE,oBAAoB,GAAE;AAAA,UAC7D,gBAAAD,EAAC,OAAA,EAAI,WAAWC,EAAO,KAAM,UAAAgB,EAAA,CAAQ;AAAA,QAAA,GACvC;AAAA,QAED7B;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGP,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const o=require("react/jsx-runtime"),u=require("react"),M=require("clsx"),S=require("./Avatar-CQ--wGWS.cjs"),A=require("./IconButton-
|
|
2
|
-
//# sourceMappingURL=FileCard-
|
|
1
|
+
"use strict";const o=require("react/jsx-runtime"),u=require("react"),M=require("clsx"),S=require("./Avatar-CQ--wGWS.cjs"),A=require("./IconButton-BVrO9TBP.cjs"),O=require("./Icon-BUP5_kRs.cjs"),L=require("./Typography-B6ASPrzT.cjs"),$=require("./ConfigProvider-CVLHPXQm.cjs"),V="_fileCard_kpeb5_3",G="_avatar_kpeb5_24",R="_body_kpeb5_29",H="_name_kpeb5_38",K="_nameBase_kpeb5_45",P="_nameExt_kpeb5_51",U="_type_kpeb5_57",W="_download_kpeb5_61",X="_sm_kpeb5_66",z="_md_kpeb5_77",J="_lg_kpeb5_81",s={fileCard:V,avatar:G,body:R,name:H,nameBase:K,nameExt:P,type:U,download:W,sm:X,md:z,lg:J},Q=new Set(["png","jpg","jpeg","webp","svg","gif","avif","bmp","ico","heic"]),Y={pdf:"DocumentText",doc:"DocumentText",docx:"DocumentText",txt:"DocumentText",rtf:"DocumentText",md:"DocumentText",csv:"DocumentText",xls:"DocumentText",xlsx:"DocumentText",json:"DocumentCode",xml:"DocumentCode",zip:"Folder",rar:"Folder","7z":"Folder",mp4:"VideoSquare",mov:"VideoSquare",webm:"VideoSquare",mp3:"MusicSquare",wav:"MusicSquare"};function Z(n,e){const t=n.lastIndexOf(".");return t>0&&n.length-t<=7?n.slice(t+1).toLowerCase():e&&e.includes("/")?e.slice(e.indexOf("/")+1).toLowerCase():""}function ee(n){const e=n.lastIndexOf(".");return e>0&&n.length-e<=7?{base:n.slice(0,e),ext:n.slice(e)}:{base:n,ext:""}}function g(n){if(!Number.isFinite(n)||n<0)return"";if(n<1024)return`${n} B`;const e=["KB","MB","GB","TB"];let t=n/1024,a=0;for(;t>=1024&&a<e.length-1;)t/=1024,a+=1;return`${t<10?t.toFixed(1):Math.round(t)} ${e[a]}`}const te=u.forwardRef(function({name:e,src:t,type:a,image:v,fileSize:c,fetchSize:m=!1,meta:C,color:x="accent",size:d="md",downloadable:T=!0,onDownload:i,className:j,style:q,...w},k){const B=$.useT(),l=Z(e,a),f=v??((a==null?void 0:a.startsWith("image/"))||Q.has(l)),{base:D,ext:_}=ee(e),[p,N]=u.useState(null);u.useEffect(()=>{if(!m||c!=null||!t||typeof fetch>"u")return;let r=!1;return fetch(t,{method:"HEAD"}).then(y=>{const b=y.headers.get("content-length");!r&&b&&N(Number(b))}).catch(()=>{}),()=>{r=!0}},[m,c,t]);const E=c!=null?typeof c=="number"?g(c):c:p!=null?g(p):"",I=[l?l.toUpperCase():"",E].filter(Boolean).join(" · "),h=C??(I||null),F=()=>{if(i)return i();if(!t)return;const r=document.createElement("a");r.href=t,r.download=e,r.rel="noopener",r.click()};return o.jsxs("div",{ref:k,className:M.clsx(s.fileCard,s[d],j),style:{"--tz-btn-rgb":`var(--tz-color-${x}-rgb)`,...q},...w,children:[o.jsx(S.Avatar,{className:s.avatar,src:f?t:void 0,icon:f?void 0:Y[l]??"Document",name:e,shape:"square",size:d,color:x}),o.jsxs("div",{className:s.body,children:[o.jsxs("span",{className:s.name,title:e,children:[o.jsx("span",{className:s.nameBase,children:D}),_&&o.jsx("span",{className:s.nameExt,children:_})]}),h!=null&&o.jsx(L.Typography,{as:"span",variant:"bodySmall",color:"muted",uppercase:!0,className:s.type,children:h})]}),T&&(t||i)&&o.jsx(A.IconButton,{variant:"filled",size:d==="lg"?"md":"sm",className:s.download,"aria-label":B("fileCard.download",{name:e}),onClick:F,children:o.jsx(O.Icon,{name:"ImportArrow"})})]})});exports.FileCard=te;
|
|
2
|
+
//# sourceMappingURL=FileCard-B3dfdTVN.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileCard-BYNJVmp0.cjs","sources":["../src/components/FileCard/FileCard.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useState,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useT, type ThemeColor } from '../../theme'\nimport { Avatar, type AvatarSize } from '../Avatar'\nimport { IconButton } from '../IconButton'\nimport { Icon } from '../Icon'\nimport { Typography } from '../Typography'\nimport type { IconName } from '../../icons/names'\nimport styles from './FileCard.module.css'\n\nexport type FileCardSize = AvatarSize\n\nconst IMAGE_EXTS = new Set([\n 'png',\n 'jpg',\n 'jpeg',\n 'webp',\n 'svg',\n 'gif',\n 'avif',\n 'bmp',\n 'ico',\n 'heic',\n])\n\n// a leading icon per file family (non-image); everything else gets the generic document icon\nconst FILE_ICONS: Record<string, IconName> = {\n pdf: 'DocumentText',\n doc: 'DocumentText',\n docx: 'DocumentText',\n txt: 'DocumentText',\n rtf: 'DocumentText',\n md: 'DocumentText',\n csv: 'DocumentText',\n xls: 'DocumentText',\n xlsx: 'DocumentText',\n json: 'DocumentCode',\n xml: 'DocumentCode',\n zip: 'Folder',\n rar: 'Folder',\n '7z': 'Folder',\n mp4: 'VideoSquare',\n mov: 'VideoSquare',\n webm: 'VideoSquare',\n mp3: 'MusicSquare',\n wav: 'MusicSquare',\n}\n\n/** The lowercased extension from a file name, else the subtype from a MIME `type` (`image/png` → `png`). */\nfunction extensionOf(name: string, type?: string): string {\n const dot = name.lastIndexOf('.')\n if (dot > 0 && name.length - dot <= 7) return name.slice(dot + 1).toLowerCase()\n if (type && type.includes('/')) return type.slice(type.indexOf('/') + 1).toLowerCase()\n return ''\n}\n\n/** Split `report.pdf` into `{ base: 'report', ext: '.pdf' }` so the base can ellipsize and the type stays. */\nfunction splitName(name: string): { base: string; ext: string } {\n const dot = name.lastIndexOf('.')\n return dot > 0 && name.length - dot <= 7\n ? { base: name.slice(0, dot), ext: name.slice(dot) }\n : { base: name, ext: '' }\n}\n\n/** Human-readable byte size — `2411724` → `\"2.3 MB\"`. */\nfunction formatBytes(bytes: number): string {\n if (!Number.isFinite(bytes) || bytes < 0) return ''\n if (bytes < 1024) return `${bytes} B`\n const units = ['KB', 'MB', 'GB', 'TB']\n let value = bytes / 1024\n let i = 0\n while (value >= 1024 && i < units.length - 1) {\n value /= 1024\n i += 1\n }\n return `${value < 10 ? value.toFixed(1) : Math.round(value)} ${units[i]}`\n}\n\nexport interface FileCardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'color'> {\n /** File name — shown middle-truncated (`test-file-na….pdf`) so the extension always stays visible. */\n name: string\n /** File URL — the download target and, for an image, the thumbnail `src`. */\n src?: string\n /** File type — an extension (`'pdf'`) or MIME (`'image/png'`). Derived from `name` when omitted. */\n type?: string\n /** Force image vs. file rendering. Inferred from `type` / `name` / `src` when omitted. */\n image?: boolean\n /** File size — a **bytes** number (auto-formatted to `\"2.3 MB\"`) or a preformatted string. Shown after the type. */\n fileSize?: number | string\n /**\n * When no `fileSize` is given, fetch it from `src` via a `HEAD` request (reads `Content-Length`). Off\n * by default — it's a network call and needs CORS to expose the header; prefer passing `fileSize` from\n * the backend. Fails silently (no size shown) when unavailable.\n */\n fetchSize?: boolean\n /** Meta line under the name — overrides the derived `TYPE · size`. */\n meta?: ReactNode\n /** Theme token tinting the avatar / file-icon box. Defaults to `accent`. */\n color?: ThemeColor\n /** Size — scales the avatar, text and padding. Defaults to `md`. */\n size?: FileCardSize\n /** Show the download control (only when there's a `src` or `onDownload`). Defaults to `true`. */\n downloadable?: boolean\n /** Custom download handler — replaces the default (a download of `src`). */\n onDownload?: () => void\n}\n\n/**\n * A compact, read-only **file card** for displaying a file that already exists (e.g. from the backend) —\n * an image or a document (`pdf` / `docx` / `csv` / `svg` / …). Shows a leading **`Avatar`** (the image\n * thumbnail via `src`, or a type-based file icon in a tinted square), the **name** middle-truncated so\n * the extension is never lost, the **type** underneath, and a **download** control. Simple to drop in —\n * pass `name` (+ `src` for the thumbnail/download). Not to be confused with `FileUploader` (which\n * *collects* files to upload); this only *displays* one. Token-only styling.\n *\n * @example\n * <FileCard name=\"annual-report.pdf\" src=\"/files/annual-report.pdf\" />\n * <FileCard name=\"avatar.png\" src={url} meta=\"240 KB\" />\n */\nexport const FileCard = forwardRef<HTMLDivElement, FileCardProps>(function FileCard(\n {\n name,\n src,\n type,\n image,\n fileSize,\n fetchSize = false,\n meta,\n color = 'accent',\n size = 'md',\n downloadable = true,\n onDownload,\n className,\n style,\n ...props\n },\n ref,\n) {\n const t = useT()\n const ext = extensionOf(name, type)\n const isImage = image ?? (type?.startsWith('image/') || IMAGE_EXTS.has(ext))\n const { base, ext: nameExt } = splitName(name)\n\n // optional auto size via a HEAD request (only when opted in and no explicit fileSize)\n const [fetchedSize, setFetchedSize] = useState<number | null>(null)\n useEffect(() => {\n if (!fetchSize || fileSize != null || !src || typeof fetch === 'undefined') return\n let cancelled = false\n fetch(src, { method: 'HEAD' })\n .then((res) => {\n const len = res.headers.get('content-length')\n if (!cancelled && len) setFetchedSize(Number(len))\n })\n .catch(() => {})\n return () => {\n cancelled = true\n }\n }, [fetchSize, fileSize, src])\n\n const sizeText =\n fileSize != null\n ? typeof fileSize === 'number'\n ? formatBytes(fileSize)\n : fileSize\n : fetchedSize != null\n ? formatBytes(fetchedSize)\n : ''\n // \"TYPE · 2.3 MB\" (either part optional) — overridden wholesale by `meta`\n const derivedMeta = [ext ? ext.toUpperCase() : '', sizeText].filter(Boolean).join(' · ')\n const metaLine = meta ?? (derivedMeta || null)\n\n const handleDownload = () => {\n if (onDownload) return onDownload()\n if (!src) return\n const a = document.createElement('a')\n a.href = src\n a.download = name\n a.rel = 'noopener'\n a.click()\n }\n\n return (\n <div\n ref={ref}\n className={clsx(styles.fileCard, styles[size], className)}\n style={{ '--tz-btn-rgb': `var(--tz-color-${color}-rgb)`, ...style } as CSSProperties}\n {...props}\n >\n <Avatar\n className={styles.avatar}\n src={isImage ? src : undefined}\n icon={isImage ? undefined : (FILE_ICONS[ext] ?? 'Document')}\n name={name}\n shape=\"square\"\n size={size}\n color={color}\n />\n <div className={styles.body}>\n <span className={styles.name} title={name}>\n <span className={styles.nameBase}>{base}</span>\n {nameExt && <span className={styles.nameExt}>{nameExt}</span>}\n </span>\n {metaLine != null && (\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\" uppercase className={styles.type}>\n {metaLine}\n </Typography>\n )}\n </div>\n {downloadable && (src || onDownload) && (\n <IconButton\n variant=\"filled\"\n size={size === 'lg' ? 'md' : 'sm'}\n className={styles.download}\n aria-label={t('fileCard.download', { name })}\n onClick={handleDownload}\n >\n <Icon name=\"ImportArrow\" />\n </IconButton>\n )}\n </div>\n )\n})\n"],"names":["IMAGE_EXTS","FILE_ICONS","extensionOf","name","type","dot","splitName","formatBytes","bytes","units","value","i","FileCard","forwardRef","src","image","fileSize","fetchSize","meta","color","size","downloadable","onDownload","className","style","props","ref","t","useT","ext","isImage","base","nameExt","fetchedSize","setFetchedSize","useState","useEffect","cancelled","res","len","sizeText","derivedMeta","metaLine","handleDownload","a","jsxs","clsx","styles","jsx","Avatar","Typography","IconButton","Icon"],"mappings":"2kBAmBMA,MAAiB,IAAI,CACzB,MACA,MACA,OACA,OAC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s","sources":["../src/components/FileCard/FileCard.tsx"],"sourcesContent":["import {\n forwardRef,\n useEffect,\n useState,\n type CSSProperties,\n type HTMLAttributes,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useT, type ThemeColor } from '../../theme'\nimport { Avatar, type AvatarSize } from '../Avatar'\nimport { IconButton } from '../IconButton'\nimport { Icon } from '../Icon'\nimport { Typography } from '../Typography'\nimport type { IconName } from '../../icons/names'\nimport styles from './FileCard.module.css'\n\nexport type FileCardSize = AvatarSize\n\nconst IMAGE_EXTS = new Set([\n 'png',\n 'jpg',\n 'jpeg',\n 'webp',\n 'svg',\n 'gif',\n 'avif',\n 'bmp',\n 'ico',\n 'heic',\n])\n\n// a leading icon per file family (non-image); everything else gets the generic document icon\nconst FILE_ICONS: Record<string, IconName> = {\n pdf: 'DocumentText',\n doc: 'DocumentText',\n docx: 'DocumentText',\n txt: 'DocumentText',\n rtf: 'DocumentText',\n md: 'DocumentText',\n csv: 'DocumentText',\n xls: 'DocumentText',\n xlsx: 'DocumentText',\n json: 'DocumentCode',\n xml: 'DocumentCode',\n zip: 'Folder',\n rar: 'Folder',\n '7z': 'Folder',\n mp4: 'VideoSquare',\n mov: 'VideoSquare',\n webm: 'VideoSquare',\n mp3: 'MusicSquare',\n wav: 'MusicSquare',\n}\n\n/** The lowercased extension from a file name, else the subtype from a MIME `type` (`image/png` → `png`). */\nfunction extensionOf(name: string, type?: string): string {\n const dot = name.lastIndexOf('.')\n if (dot > 0 && name.length - dot <= 7) return name.slice(dot + 1).toLowerCase()\n if (type && type.includes('/')) return type.slice(type.indexOf('/') + 1).toLowerCase()\n return ''\n}\n\n/** Split `report.pdf` into `{ base: 'report', ext: '.pdf' }` so the base can ellipsize and the type stays. */\nfunction splitName(name: string): { base: string; ext: string } {\n const dot = name.lastIndexOf('.')\n return dot > 0 && name.length - dot <= 7\n ? { base: name.slice(0, dot), ext: name.slice(dot) }\n : { base: name, ext: '' }\n}\n\n/** Human-readable byte size — `2411724` → `\"2.3 MB\"`. */\nfunction formatBytes(bytes: number): string {\n if (!Number.isFinite(bytes) || bytes < 0) return ''\n if (bytes < 1024) return `${bytes} B`\n const units = ['KB', 'MB', 'GB', 'TB']\n let value = bytes / 1024\n let i = 0\n while (value >= 1024 && i < units.length - 1) {\n value /= 1024\n i += 1\n }\n return `${value < 10 ? value.toFixed(1) : Math.round(value)} ${units[i]}`\n}\n\nexport interface FileCardProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'color'> {\n /** File name — shown middle-truncated (`test-file-na….pdf`) so the extension always stays visible. */\n name: string\n /** File URL — the download target and, for an image, the thumbnail `src`. */\n src?: string\n /** File type — an extension (`'pdf'`) or MIME (`'image/png'`). Derived from `name` when omitted. */\n type?: string\n /** Force image vs. file rendering. Inferred from `type` / `name` / `src` when omitted. */\n image?: boolean\n /** File size — a **bytes** number (auto-formatted to `\"2.3 MB\"`) or a preformatted string. Shown after the type. */\n fileSize?: number | string\n /**\n * When no `fileSize` is given, fetch it from `src` via a `HEAD` request (reads `Content-Length`). Off\n * by default — it's a network call and needs CORS to expose the header; prefer passing `fileSize` from\n * the backend. Fails silently (no size shown) when unavailable.\n */\n fetchSize?: boolean\n /** Meta line under the name — overrides the derived `TYPE · size`. */\n meta?: ReactNode\n /** Theme token tinting the avatar / file-icon box. Defaults to `accent`. */\n color?: ThemeColor\n /** Size — scales the avatar, text and padding. Defaults to `md`. */\n size?: FileCardSize\n /** Show the download control (only when there's a `src` or `onDownload`). Defaults to `true`. */\n downloadable?: boolean\n /** Custom download handler — replaces the default (a download of `src`). */\n onDownload?: () => void\n}\n\n/**\n * A compact, read-only **file card** for displaying a file that already exists (e.g. from the backend) —\n * an image or a document (`pdf` / `docx` / `csv` / `svg` / …). Shows a leading **`Avatar`** (the image\n * thumbnail via `src`, or a type-based file icon in a tinted square), the **name** middle-truncated so\n * the extension is never lost, the **type** underneath, and a **download** control. Simple to drop in —\n * pass `name` (+ `src` for the thumbnail/download). Not to be confused with `FileUploader` (which\n * *collects* files to upload); this only *displays* one. Token-only styling.\n *\n * @example\n * <FileCard name=\"annual-report.pdf\" src=\"/files/annual-report.pdf\" />\n * <FileCard name=\"avatar.png\" src={url} meta=\"240 KB\" />\n */\nexport const FileCard = forwardRef<HTMLDivElement, FileCardProps>(function FileCard(\n {\n name,\n src,\n type,\n image,\n fileSize,\n fetchSize = false,\n meta,\n color = 'accent',\n size = 'md',\n downloadable = true,\n onDownload,\n className,\n style,\n ...props\n },\n ref,\n) {\n const t = useT()\n const ext = extensionOf(name, type)\n const isImage = image ?? (type?.startsWith('image/') || IMAGE_EXTS.has(ext))\n const { base, ext: nameExt } = splitName(name)\n\n // optional auto size via a HEAD request (only when opted in and no explicit fileSize)\n const [fetchedSize, setFetchedSize] = useState<number | null>(null)\n useEffect(() => {\n if (!fetchSize || fileSize != null || !src || typeof fetch === 'undefined') return\n let cancelled = false\n fetch(src, { method: 'HEAD' })\n .then((res) => {\n const len = res.headers.get('content-length')\n if (!cancelled && len) setFetchedSize(Number(len))\n })\n .catch(() => {})\n return () => {\n cancelled = true\n }\n }, [fetchSize, fileSize, src])\n\n const sizeText =\n fileSize != null\n ? typeof fileSize === 'number'\n ? formatBytes(fileSize)\n : fileSize\n : fetchedSize != null\n ? formatBytes(fetchedSize)\n : ''\n // \"TYPE · 2.3 MB\" (either part optional) — overridden wholesale by `meta`\n const derivedMeta = [ext ? ext.toUpperCase() : '', sizeText].filter(Boolean).join(' · ')\n const metaLine = meta ?? (derivedMeta || null)\n\n const handleDownload = () => {\n if (onDownload) return onDownload()\n if (!src) return\n const a = document.createElement('a')\n a.href = src\n a.download = name\n a.rel = 'noopener'\n a.click()\n }\n\n return (\n <div\n ref={ref}\n className={clsx(styles.fileCard, styles[size], className)}\n style={{ '--tz-btn-rgb': `var(--tz-color-${color}-rgb)`, ...style } as CSSProperties}\n {...props}\n >\n <Avatar\n className={styles.avatar}\n src={isImage ? src : undefined}\n icon={isImage ? undefined : (FILE_ICONS[ext] ?? 'Document')}\n name={name}\n shape=\"square\"\n size={size}\n color={color}\n />\n <div className={styles.body}>\n <span className={styles.name} title={name}>\n <span className={styles.nameBase}>{base}</span>\n {nameExt && <span className={styles.nameExt}>{nameExt}</span>}\n </span>\n {metaLine != null && (\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\" uppercase className={styles.type}>\n {metaLine}\n </Typography>\n )}\n </div>\n {downloadable && (src || onDownload) && (\n <IconButton\n variant=\"filled\"\n size={size === 'lg' ? 'md' : 'sm'}\n className={styles.download}\n aria-label={t('fileCard.download', { name })}\n onClick={handleDownload}\n >\n <Icon name=\"ImportArrow\" />\n </IconButton>\n )}\n </div>\n )\n})\n"],"names":["IMAGE_EXTS","FILE_ICONS","extensionOf","name","type","dot","splitName","formatBytes","bytes","units","value","i","FileCard","forwardRef","src","image","fileSize","fetchSize","meta","color","size","downloadable","onDownload","className","style","props","ref","t","useT","ext","isImage","base","nameExt","fetchedSize","setFetchedSize","useState","useEffect","cancelled","res","len","sizeText","derivedMeta","metaLine","handleDownload","a","jsxs","clsx","styles","jsx","Avatar","Typography","IconButton","Icon"],"mappings":"2kBAmBMA,MAAiB,IAAI,CACzB,MACA,MACA,OACA,OACA,MACA,MACA,OACA,MACA,MACA,MACF,CAAC,EAGKC,EAAuC,CAC3C,IAAK,eACL,IAAK,eACL,KAAM,eACN,IAAK,eACL,IAAK,eACL,GAAI,eACJ,IAAK,eACL,IAAK,eACL,KAAM,eACN,KAAM,eACN,IAAK,eACL,IAAK,SACL,IAAK,SACL,KAAM,SACN,IAAK,cACL,IAAK,cACL,KAAM,cACN,IAAK,cACL,IAAK,aACP,EAGA,SAASC,EAAYC,EAAcC,EAAuB,CACxD,MAAMC,EAAMF,EAAK,YAAY,GAAG,EAChC,OAAIE,EAAM,GAAKF,EAAK,OAASE,GAAO,EAAUF,EAAK,MAAME,EAAM,CAAC,EAAE,YAAA,EAC9DD,GAAQA,EAAK,SAAS,GAAG,EAAUA,EAAK,MAAMA,EAAK,QAAQ,G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AI,UAAWE,EAAO,KACrB,SAAA,CAAAF,OAAC,OAAA,CAAK,UAAWE,EAAO,KAAM,MAAO5C,EACnC,SAAA,CAAA6C,EAAAA,IAAC,OAAA,CAAK,UAAWD,EAAO,SAAW,SAAAhB,EAAK,EACvCC,GAAWgB,EAAAA,IAAC,OAAA,CAAK,UAAWD,EAAO,QAAU,SAAAf,CAAA,CAAQ,CAAA,EACxD,EACCU,GAAY,MACXM,MAACE,EAAAA,WAAA,CAAW,GAAG,OAAO,QAAQ,YAAY,MAAM,QAAQ,UAAS,GAAC,UAAWH,EAAO,KACjF,SAAAL,CAAA,CACH,CAAA,EAEJ,EACCrB,IAAiBP,GAAOQ,IACvB0B,EAAAA,IAACG,EAAAA,WAAA,CACC,QAAQ,SACR,KAAM/B,IAAS,KAAO,KAAO,KAC7B,UAAW2B,EAAO,SAClB,aAAYpB,EAAE,oBAAqB,CAAE,KAAAxB,EAAM,EAC3C,QAASwC,EAET,SAAAK,EAAAA,IAACI,EAAAA,KAAA,CAAK,KAAK,aAAA,CAAc,CAAA,CAAA,CAC3B,CAAA,CAAA,CAIR,CAAC"}
|
|
@@ -2,10 +2,10 @@ import { jsxs as m, jsx as c } from "react/jsx-runtime";
|
|
|
2
2
|
import { forwardRef as S, useState as A, useEffect as O } from "react";
|
|
3
3
|
import { clsx as y } from "clsx";
|
|
4
4
|
import { A as L } from "./Avatar-MwWIcj8z.js";
|
|
5
|
-
import { I as $ } from "./IconButton-
|
|
5
|
+
import { I as $ } from "./IconButton-sC_E_TXd.js";
|
|
6
6
|
import { I as V } from "./Icon-CGQ5yGSZ.js";
|
|
7
7
|
import { T as G } from "./Typography-CJv5AnRP.js";
|
|
8
|
-
import { a as H } from "./ConfigProvider-
|
|
8
|
+
import { a as H } from "./ConfigProvider-tvLbKiqu.js";
|
|
9
9
|
const K = "_fileCard_kpeb5_3", R = "_avatar_kpeb5_24", U = "_body_kpeb5_29", W = "_name_kpeb5_38", X = "_nameBase_kpeb5_45", z = "_nameExt_kpeb5_51", J = "_type_kpeb5_57", P = "_download_kpeb5_61", Q = "_sm_kpeb5_66", Y = "_md_kpeb5_77", Z = "_lg_kpeb5_81", o = {
|
|
10
10
|
fileCard: K,
|
|
11
11
|
avatar: R,
|
|
@@ -146,4 +146,4 @@ const ue = S(function({
|
|
|
146
146
|
export {
|
|
147
147
|
ue as F
|
|
148
148
|
};
|
|
149
|
-
//# sourceMappingURL=FileCard-
|
|
149
|
+
//# sourceMappingURL=FileCard-R_sB8Qbx.js.map
|