@techzyapp/ui-library 1.0.33 → 1.0.34
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 → AdminRoot-C_SNXQkB.js} +9 -9
- package/dist/{AdminRoot-CwUHa2us.js.map → AdminRoot-C_SNXQkB.js.map} +1 -1
- package/dist/{AdminRoot-cjP_Ad4r.cjs → AdminRoot-D97qDVTM.cjs} +2 -2
- package/dist/{AdminRoot-cjP_Ad4r.cjs.map → AdminRoot-D97qDVTM.cjs.map} +1 -1
- package/dist/{Alert-LJDrtkJy.js → Alert-BXtQFAVl.js} +3 -3
- package/dist/{Alert-LJDrtkJy.js.map → Alert-BXtQFAVl.js.map} +1 -1
- package/dist/{Alert-CfjDmLR8.cjs → Alert-CggrNMn5.cjs} +2 -2
- package/dist/{Alert-CfjDmLR8.cjs.map → Alert-CggrNMn5.cjs.map} +1 -1
- package/dist/{AuthLayout-m1BQ6Ixx.js → AuthLayout-C47vXKYp.js} +2 -2
- package/dist/{AuthLayout-m1BQ6Ixx.js.map → AuthLayout-C47vXKYp.js.map} +1 -1
- package/dist/{AuthLayout-DIcR__vo.cjs → AuthLayout-Cl3tb4-E.cjs} +2 -2
- package/dist/{AuthLayout-DIcR__vo.cjs.map → AuthLayout-Cl3tb4-E.cjs.map} +1 -1
- package/dist/{Breadcrumbs-COb2zmDk.cjs → Breadcrumbs-Cpa_LSY2.cjs} +2 -2
- package/dist/{Breadcrumbs-COb2zmDk.cjs.map → Breadcrumbs-Cpa_LSY2.cjs.map} +1 -1
- package/dist/{Breadcrumbs-DYeVrOns.js → Breadcrumbs-D_QnKw8q.js} +3 -3
- package/dist/{Breadcrumbs-DYeVrOns.js.map → Breadcrumbs-D_QnKw8q.js.map} +1 -1
- package/dist/{Button-PBZnkRNn.js → Button-BQ7jsm5P.js} +2 -2
- package/dist/{Button-PBZnkRNn.js.map → Button-BQ7jsm5P.js.map} +1 -1
- package/dist/{Button-BD5wpg-t.cjs → Button-Cm64ROip.cjs} +2 -2
- package/dist/{Button-BD5wpg-t.cjs.map → Button-Cm64ROip.cjs.map} +1 -1
- package/dist/{Calendar-Bb5Ekbpr.js → Calendar-BrpJOBTt.js} +3 -3
- package/dist/{Calendar-Bb5Ekbpr.js.map → Calendar-BrpJOBTt.js.map} +1 -1
- package/dist/{Calendar-842vjtdN.cjs → Calendar-C2x9ZtPV.cjs} +2 -2
- package/dist/{Calendar-842vjtdN.cjs.map → Calendar-C2x9ZtPV.cjs.map} +1 -1
- package/dist/{Card-CV_rHego.js → Card-kizK1B7N.js} +2 -2
- package/dist/{Card-CV_rHego.js.map → Card-kizK1B7N.js.map} +1 -1
- package/dist/{Card-DL7XnkOA.cjs → Card-yhly3Xdp.cjs} +2 -2
- package/dist/{Card-DL7XnkOA.cjs.map → Card-yhly3Xdp.cjs.map} +1 -1
- package/dist/{Chip-CLPIPC9a.cjs → Chip-BPcnO5WI.cjs} +2 -2
- package/dist/{Chip-CLPIPC9a.cjs.map → Chip-BPcnO5WI.cjs.map} +1 -1
- package/dist/{Chip-DdOUVF0Z.js → Chip-BzyzLEeX.js} +2 -2
- package/dist/{Chip-DdOUVF0Z.js.map → Chip-BzyzLEeX.js.map} +1 -1
- package/dist/{ChoiceCardGroup-BTbKjJdp.js → ChoiceCardGroup-BBD8ai4s.js} +2 -2
- package/dist/{ChoiceCardGroup-BTbKjJdp.js.map → ChoiceCardGroup-BBD8ai4s.js.map} +1 -1
- package/dist/{ChoiceCardGroup-Bg2jtFpe.cjs → ChoiceCardGroup-BWsG_Vh5.cjs} +2 -2
- package/dist/{ChoiceCardGroup-Bg2jtFpe.cjs.map → ChoiceCardGroup-BWsG_Vh5.cjs.map} +1 -1
- package/dist/{CodeBlock-B35NXZzd.js → CodeBlock-BTt40oh5.js} +3 -3
- package/dist/{CodeBlock-B35NXZzd.js.map → CodeBlock-BTt40oh5.js.map} +1 -1
- package/dist/{CodeBlock-C0dbyxcl.cjs → CodeBlock-BgSum_bB.cjs} +2 -2
- package/dist/{CodeBlock-C0dbyxcl.cjs.map → CodeBlock-BgSum_bB.cjs.map} +1 -1
- package/dist/{ColorPicker-6UraVYFy.js → ColorPicker-BNM75F5E.js} +4 -4
- package/dist/{ColorPicker-6UraVYFy.js.map → ColorPicker-BNM75F5E.js.map} +1 -1
- package/dist/{ColorPicker-DmLGKaYF.cjs → ColorPicker-C33dlkhN.cjs} +2 -2
- package/dist/{ColorPicker-DmLGKaYF.cjs.map → ColorPicker-C33dlkhN.cjs.map} +1 -1
- package/dist/{ColorPickerPanel-WuxwwfCI.cjs → ColorPickerPanel-BZ_ZNu2B.cjs} +2 -2
- package/dist/{ColorPickerPanel-WuxwwfCI.cjs.map → ColorPickerPanel-BZ_ZNu2B.cjs.map} +1 -1
- package/dist/{ColorPickerPanel-DZ-W_wOI.js → ColorPickerPanel-Bh1K0YS8.js} +2 -2
- package/dist/{ColorPickerPanel-DZ-W_wOI.js.map → ColorPickerPanel-Bh1K0YS8.js.map} +1 -1
- package/dist/{ColorRamp-D_9gsqJl.cjs → ColorRamp-BJWNKzoX.cjs} +2 -2
- package/dist/{ColorRamp-D_9gsqJl.cjs.map → ColorRamp-BJWNKzoX.cjs.map} +1 -1
- package/dist/{ColorRamp-CSqzzHZx.js → ColorRamp-BnuXrSxa.js} +3 -3
- package/dist/{ColorRamp-CSqzzHZx.js.map → ColorRamp-BnuXrSxa.js.map} +1 -1
- package/dist/{ConfigProvider-tvLbKiqu.js → ConfigProvider-DZMtq2Fz.js} +2 -2
- package/dist/ConfigProvider-DZMtq2Fz.js.map +1 -0
- package/dist/{ConfigProvider-CVLHPXQm.cjs → ConfigProvider-th4GYhcU.cjs} +2 -2
- package/dist/ConfigProvider-th4GYhcU.cjs.map +1 -0
- package/dist/{CopyButton-0w4OToIy.cjs → CopyButton-C9oHGs6W.cjs} +2 -2
- package/dist/{CopyButton-0w4OToIy.cjs.map → CopyButton-C9oHGs6W.cjs.map} +1 -1
- package/dist/{CopyButton-B_mYxcXV.js → CopyButton-hZqLdXJq.js} +3 -3
- package/dist/{CopyButton-B_mYxcXV.js.map → CopyButton-hZqLdXJq.js.map} +1 -1
- package/dist/{DatePicker-Bt-M87zX.js → DatePicker-B6ZL_T-E.js} +5 -5
- package/dist/{DatePicker-Bt-M87zX.js.map → DatePicker-B6ZL_T-E.js.map} +1 -1
- package/dist/{DatePicker-D1uFIm3M.cjs → DatePicker-DXwJB4MH.cjs} +2 -2
- package/dist/{DatePicker-D1uFIm3M.cjs.map → DatePicker-DXwJB4MH.cjs.map} +1 -1
- package/dist/{DateTimePicker-zJUc9crs.js → DateTimePicker-BynW1Eeg.js} +8 -8
- package/dist/{DateTimePicker-zJUc9crs.js.map → DateTimePicker-BynW1Eeg.js.map} +1 -1
- package/dist/{DateTimePicker-DPt-LDVJ.cjs → DateTimePicker-CHi1H2k1.cjs} +2 -2
- package/dist/{DateTimePicker-DPt-LDVJ.cjs.map → DateTimePicker-CHi1H2k1.cjs.map} +1 -1
- package/dist/{DescriptionList-CPCbzU9b.cjs → DescriptionList-BqYwp08t.cjs} +2 -2
- package/dist/{DescriptionList-CPCbzU9b.cjs.map → DescriptionList-BqYwp08t.cjs.map} +1 -1
- package/dist/{DescriptionList-BLx9NfAW.js → DescriptionList-C6Gfk6I_.js} +5 -5
- package/dist/{DescriptionList-BLx9NfAW.js.map → DescriptionList-C6Gfk6I_.js.map} +1 -1
- package/dist/{EmptyState-BEVEGcLx.js → EmptyState-BvAA5mYO.js} +2 -2
- package/dist/{EmptyState-BEVEGcLx.js.map → EmptyState-BvAA5mYO.js.map} +1 -1
- package/dist/{EmptyState-C54C0Qwc.cjs → EmptyState-CZ6X5-Zy.cjs} +2 -2
- package/dist/{EmptyState-C54C0Qwc.cjs.map → EmptyState-CZ6X5-Zy.cjs.map} +1 -1
- package/dist/{ErrorBoundary-BSJL381Y.js → ErrorBoundary-BS0x9RVO.js} +14 -6
- package/dist/ErrorBoundary-BS0x9RVO.js.map +1 -0
- package/dist/ErrorBoundary-WwmJrL6o.cjs +2 -0
- package/dist/ErrorBoundary-WwmJrL6o.cjs.map +1 -0
- package/dist/ErrorState-BTSGKrJq.js +178 -0
- package/dist/ErrorState-BTSGKrJq.js.map +1 -0
- package/dist/ErrorState-DRXuV6na.cjs +4 -0
- package/dist/ErrorState-DRXuV6na.cjs.map +1 -0
- package/dist/{FileCard-R_sB8Qbx.js → FileCard-CxZ3o4BO.js} +4 -4
- package/dist/{FileCard-R_sB8Qbx.js.map → FileCard-CxZ3o4BO.js.map} +1 -1
- package/dist/{FileCard-B3dfdTVN.cjs → FileCard-ZZNd_tUN.cjs} +2 -2
- package/dist/{FileCard-B3dfdTVN.cjs.map → FileCard-ZZNd_tUN.cjs.map} +1 -1
- package/dist/{FileUploader-4UMy0urx.cjs → FileUploader-B--hPV3b.cjs} +2 -2
- package/dist/{FileUploader-4UMy0urx.cjs.map → FileUploader-B--hPV3b.cjs.map} +1 -1
- package/dist/{FileUploader-B55atuxq.js → FileUploader-CPah0hUe.js} +6 -6
- package/dist/{FileUploader-B55atuxq.js.map → FileUploader-CPah0hUe.js.map} +1 -1
- package/dist/{Flag-CFvJHC0u.cjs → Flag-C4La35rA.cjs} +2 -2
- package/dist/{Flag-CFvJHC0u.cjs.map → Flag-C4La35rA.cjs.map} +1 -1
- package/dist/{Flag-D7fmMqqy.js → Flag-DikEV1jI.js} +2 -2
- package/dist/{Flag-D7fmMqqy.js.map → Flag-DikEV1jI.js.map} +1 -1
- package/dist/{FullscreenToggle-CXmPqxJv.js → FullscreenToggle-CTt7_Kv_.js} +3 -3
- package/dist/{FullscreenToggle-CXmPqxJv.js.map → FullscreenToggle-CTt7_Kv_.js.map} +1 -1
- package/dist/{FullscreenToggle-D7tUPCNI.cjs → FullscreenToggle-ejjFFd9a.cjs} +2 -2
- package/dist/{FullscreenToggle-D7tUPCNI.cjs.map → FullscreenToggle-ejjFFd9a.cjs.map} +1 -1
- package/dist/{IconButton-sC_E_TXd.js → IconButton-BUmXN_lD.js} +2 -2
- package/dist/{IconButton-sC_E_TXd.js.map → IconButton-BUmXN_lD.js.map} +1 -1
- package/dist/{IconButton-BVrO9TBP.cjs → IconButton-CYMvszcM.cjs} +2 -2
- package/dist/{IconButton-BVrO9TBP.cjs.map → IconButton-CYMvszcM.cjs.map} +1 -1
- package/dist/{Loader-DNCEHqZb.cjs → Loader-DkwiCGbB.cjs} +2 -2
- package/dist/{Loader-DNCEHqZb.cjs.map → Loader-DkwiCGbB.cjs.map} +1 -1
- package/dist/{Loader-ChrouvaR.js → Loader-jh7XMRhy.js} +2 -2
- package/dist/{Loader-ChrouvaR.js.map → Loader-jh7XMRhy.js.map} +1 -1
- package/dist/{LocationPicker-DxiQ27k6.js → LocationPicker-Cdm7BCX5.js} +7 -7
- package/dist/{LocationPicker-DxiQ27k6.js.map → LocationPicker-Cdm7BCX5.js.map} +1 -1
- package/dist/{LocationPicker-CJ6bCJC4.cjs → LocationPicker-D-9mrCVD.cjs} +2 -2
- package/dist/{LocationPicker-CJ6bCJC4.cjs.map → LocationPicker-D-9mrCVD.cjs.map} +1 -1
- package/dist/{Modal-Do8pzyMl.js → Modal-CrvOHbNy.js} +3 -3
- package/dist/{Modal-Do8pzyMl.js.map → Modal-CrvOHbNy.js.map} +1 -1
- package/dist/{Modal-BL_XihC8.cjs → Modal-eI6QL-LM.cjs} +2 -2
- package/dist/{Modal-BL_XihC8.cjs.map → Modal-eI6QL-LM.cjs.map} +1 -1
- package/dist/{MultiSelect-BfsEdXNa.js → MultiSelect-BTilYrXp.js} +5 -5
- package/dist/{MultiSelect-BfsEdXNa.js.map → MultiSelect-BTilYrXp.js.map} +1 -1
- package/dist/{MultiSelect-WS5YNGRD.cjs → MultiSelect-B_Jenpgv.cjs} +2 -2
- package/dist/{MultiSelect-WS5YNGRD.cjs.map → MultiSelect-B_Jenpgv.cjs.map} +1 -1
- package/dist/{MultilineTextField-BgfBFeeF.js → MultilineTextField-DJ26nTdF.js} +2 -2
- package/dist/{MultilineTextField-BgfBFeeF.js.map → MultilineTextField-DJ26nTdF.js.map} +1 -1
- package/dist/{MultilineTextField-B6EYAdik.cjs → MultilineTextField-ihcPDX3D.cjs} +2 -2
- package/dist/{MultilineTextField-B6EYAdik.cjs.map → MultilineTextField-ihcPDX3D.cjs.map} +1 -1
- package/dist/{NumberField-P68n6q5m.js → NumberField-DEoaxFJj.js} +4 -4
- package/dist/{NumberField-P68n6q5m.js.map → NumberField-DEoaxFJj.js.map} +1 -1
- package/dist/{NumberField-CxiEfRAi.cjs → NumberField-czWHuAyt.cjs} +2 -2
- package/dist/{NumberField-CxiEfRAi.cjs.map → NumberField-czWHuAyt.cjs.map} +1 -1
- package/dist/{OtpField-XieJfl1y.cjs → OtpField-DK5KikOt.cjs} +2 -2
- package/dist/{OtpField-XieJfl1y.cjs.map → OtpField-DK5KikOt.cjs.map} +1 -1
- package/dist/{OtpField-DjTJH4Kh.js → OtpField-v2RuXdsE.js} +3 -3
- package/dist/{OtpField-DjTJH4Kh.js.map → OtpField-v2RuXdsE.js.map} +1 -1
- package/dist/PageError-CIVYNLTW.cjs +2 -0
- package/dist/{PageError-D7_Q8wz8.cjs.map → PageError-CIVYNLTW.cjs.map} +1 -1
- package/dist/PageError-CyMdVrxL.js +70 -0
- package/dist/{PageError-ClR7k0Zb.js.map → PageError-CyMdVrxL.js.map} +1 -1
- package/dist/{PageLayout-XQ_aQTf5.js → PageLayout-BtukUUfe.js} +2 -2
- package/dist/{PageLayout-XQ_aQTf5.js.map → PageLayout-BtukUUfe.js.map} +1 -1
- package/dist/{PageLayout-DTG83hLL.cjs → PageLayout-C_daDKkg.cjs} +2 -2
- package/dist/{PageLayout-DTG83hLL.cjs.map → PageLayout-C_daDKkg.cjs.map} +1 -1
- package/dist/{PageNotFound-D3wJ4Job.cjs → PageNotFound-CHb8DlqC.cjs} +2 -2
- package/dist/{PageNotFound-D3wJ4Job.cjs.map → PageNotFound-CHb8DlqC.cjs.map} +1 -1
- package/dist/{PageNotFound-CpwHMTxG.js → PageNotFound-DQ-OvU_O.js} +5 -5
- package/dist/{PageNotFound-CpwHMTxG.js.map → PageNotFound-DQ-OvU_O.js.map} +1 -1
- package/dist/{Pagination-Df-F9i2o.js → Pagination-BjufY1mt.js} +2 -2
- package/dist/{Pagination-Df-F9i2o.js.map → Pagination-BjufY1mt.js.map} +1 -1
- package/dist/{Pagination-BF8cmQMi.cjs → Pagination-jLyJa8iL.cjs} +2 -2
- package/dist/{Pagination-BF8cmQMi.cjs.map → Pagination-jLyJa8iL.cjs.map} +1 -1
- package/dist/{PaletteField-BFRPv7AC.cjs → PaletteField-DGaV7VJ9.cjs} +2 -2
- package/dist/{PaletteField-BFRPv7AC.cjs.map → PaletteField-DGaV7VJ9.cjs.map} +1 -1
- package/dist/{PaletteField-DUu4jz1c.js → PaletteField-DTfV8Lny.js} +3 -3
- package/dist/{PaletteField-DUu4jz1c.js.map → PaletteField-DTfV8Lny.js.map} +1 -1
- package/dist/{PhoneField-CXIQX_hR.js → PhoneField-BSIhBMW2.js} +5 -5
- package/dist/{PhoneField-CXIQX_hR.js.map → PhoneField-BSIhBMW2.js.map} +1 -1
- package/dist/{PhoneField-O5syyH7u.cjs → PhoneField-DchrnSiE.cjs} +2 -2
- package/dist/{PhoneField-O5syyH7u.cjs.map → PhoneField-DchrnSiE.cjs.map} +1 -1
- package/dist/{Popconfirm-bEoOPmZY.cjs → Popconfirm-l9au66oY.cjs} +2 -2
- package/dist/{Popconfirm-bEoOPmZY.cjs.map → Popconfirm-l9au66oY.cjs.map} +1 -1
- package/dist/{Popconfirm-D4J7tlk_.js → Popconfirm-p2O8Vmz0.js} +3 -3
- package/dist/{Popconfirm-D4J7tlk_.js.map → Popconfirm-p2O8Vmz0.js.map} +1 -1
- package/dist/{Progress-BxvqmmGS.js → Progress-C-VGs3yJ.js} +2 -2
- package/dist/{Progress-BxvqmmGS.js.map → Progress-C-VGs3yJ.js.map} +1 -1
- package/dist/{Progress-CqXX0rRp.cjs → Progress-Cqr2_BF1.cjs} +2 -2
- package/dist/{Progress-CqXX0rRp.cjs.map → Progress-Cqr2_BF1.cjs.map} +1 -1
- package/dist/{QrCode-osD23Vkt.js → QrCode-B9YbQNVc.js} +2 -2
- package/dist/{QrCode-osD23Vkt.js.map → QrCode-B9YbQNVc.js.map} +1 -1
- package/dist/{QrCode-BQ1eUiAJ.cjs → QrCode-CNVYpz9j.cjs} +2 -2
- package/dist/{QrCode-BQ1eUiAJ.cjs.map → QrCode-CNVYpz9j.cjs.map} +1 -1
- package/dist/{RadioGroup-CvC2yc4p.cjs → RadioGroup-687BVZ7k.cjs} +2 -2
- package/dist/{RadioGroup-CvC2yc4p.cjs.map → RadioGroup-687BVZ7k.cjs.map} +1 -1
- package/dist/{RadioGroup-CTAayuMv.js → RadioGroup-CD209tlb.js} +2 -2
- package/dist/{RadioGroup-CTAayuMv.js.map → RadioGroup-CD209tlb.js.map} +1 -1
- package/dist/{RemoveDialog-DH3eNUxC.js → RemoveDialog-BKgWohkG.js} +6 -6
- package/dist/{RemoveDialog-DH3eNUxC.js.map → RemoveDialog-BKgWohkG.js.map} +1 -1
- package/dist/{RemoveDialog-FrieNcjL.cjs → RemoveDialog-eGCbOuuM.cjs} +2 -2
- package/dist/{RemoveDialog-FrieNcjL.cjs.map → RemoveDialog-eGCbOuuM.cjs.map} +1 -1
- package/dist/{RichTextEditor-B-C4NPDk.cjs → RichTextEditor-BPAD4ISz.cjs} +2 -2
- package/dist/{RichTextEditor-B-C4NPDk.cjs.map → RichTextEditor-BPAD4ISz.cjs.map} +1 -1
- package/dist/{RichTextEditor-6frB2C5G.js → RichTextEditor-C24uBIWh.js} +8 -8
- package/dist/{RichTextEditor-6frB2C5G.js.map → RichTextEditor-C24uBIWh.js.map} +1 -1
- package/dist/RootLayout-BY_BxQ0C.cjs +2 -0
- package/dist/RootLayout-BY_BxQ0C.cjs.map +1 -0
- package/dist/RootLayout-CicjlAUF.js +641 -0
- package/dist/RootLayout-CicjlAUF.js.map +1 -0
- package/dist/{Select-Bjq_p8_e.cjs → Select-BbgueWwN.cjs} +2 -2
- package/dist/{Select-Bjq_p8_e.cjs.map → Select-BbgueWwN.cjs.map} +1 -1
- package/dist/{Select-DO3zDQYV.js → Select-DEi_ZUHR.js} +4 -4
- package/dist/{Select-DO3zDQYV.js.map → Select-DEi_ZUHR.js.map} +1 -1
- package/dist/{Sidebar-2oH285Xs.cjs → Sidebar-D-nR8Cu6.cjs} +2 -2
- package/dist/{Sidebar-2oH285Xs.cjs.map → Sidebar-D-nR8Cu6.cjs.map} +1 -1
- package/dist/{Sidebar-CKbSWc5q.js → Sidebar-nORfjIg8.js} +4 -4
- package/dist/{Sidebar-CKbSWc5q.js.map → Sidebar-nORfjIg8.js.map} +1 -1
- package/dist/{Slider-Cu1FhxR2.cjs → Slider-0joKXhPo.cjs} +2 -2
- package/dist/{Slider-Cu1FhxR2.cjs.map → Slider-0joKXhPo.cjs.map} +1 -1
- package/dist/{Slider-DoQJWgGU.js → Slider-CwZYxDO0.js} +2 -2
- package/dist/{Slider-DoQJWgGU.js.map → Slider-CwZYxDO0.js.map} +1 -1
- package/dist/{SpeedDial-BZK-z_r9.js → SpeedDial-BMpJtYP6.js} +2 -2
- package/dist/{SpeedDial-BZK-z_r9.js.map → SpeedDial-BMpJtYP6.js.map} +1 -1
- package/dist/{SpeedDial-KGf8b4Gq.cjs → SpeedDial-D5uk_E5v.cjs} +2 -2
- package/dist/{SpeedDial-KGf8b4Gq.cjs.map → SpeedDial-D5uk_E5v.cjs.map} +1 -1
- package/dist/{Stepper-s9Vah5R2.cjs → Stepper-BRksGDK1.cjs} +2 -2
- package/dist/{Stepper-s9Vah5R2.cjs.map → Stepper-BRksGDK1.cjs.map} +1 -1
- package/dist/{Stepper-BI3pjWf_.js → Stepper-D8bRyyhl.js} +2 -2
- package/dist/{Stepper-BI3pjWf_.js.map → Stepper-D8bRyyhl.js.map} +1 -1
- package/dist/{SwatchPicker-CpwVq0xp.cjs → SwatchPicker-BVW_yhRU.cjs} +2 -2
- package/dist/{SwatchPicker-CpwVq0xp.cjs.map → SwatchPicker-BVW_yhRU.cjs.map} +1 -1
- package/dist/{SwatchPicker-BAKslSY4.js → SwatchPicker-C-_wLaf6.js} +2 -2
- package/dist/{SwatchPicker-BAKslSY4.js.map → SwatchPicker-C-_wLaf6.js.map} +1 -1
- package/dist/{Table-PsNnKn_j.js → Table-C0RDylA0.js} +18 -18
- package/dist/{Table-PsNnKn_j.js.map → Table-C0RDylA0.js.map} +1 -1
- package/dist/{Table-CLjLsYYS.cjs → Table-CGIip6UL.cjs} +2 -2
- package/dist/{Table-CLjLsYYS.cjs.map → Table-CGIip6UL.cjs.map} +1 -1
- package/dist/{Tabs-DQoNP0QT.cjs → Tabs-BzbSNmBj.cjs} +2 -2
- package/dist/{Tabs-DQoNP0QT.cjs.map → Tabs-BzbSNmBj.cjs.map} +1 -1
- package/dist/{Tabs-B2WzlRXI.js → Tabs-CQvfqazt.js} +2 -2
- package/dist/{Tabs-B2WzlRXI.js.map → Tabs-CQvfqazt.js.map} +1 -1
- package/dist/{TagsField-pdvQU4zh.js → TagsField-BdM-xre0.js} +5 -5
- package/dist/{TagsField-pdvQU4zh.js.map → TagsField-BdM-xre0.js.map} +1 -1
- package/dist/{TagsField-CLfAAz4N.cjs → TagsField-CGL1oI7b.cjs} +2 -2
- package/dist/{TagsField-CLfAAz4N.cjs.map → TagsField-CGL1oI7b.cjs.map} +1 -1
- package/dist/{TextField-CgPfN-4d.cjs → TextField-D49Lpbjt.cjs} +2 -2
- package/dist/{TextField-CgPfN-4d.cjs.map → TextField-D49Lpbjt.cjs.map} +1 -1
- package/dist/{TextField-LONfx4jy.js → TextField-otYGVuwF.js} +4 -4
- package/dist/{TextField-LONfx4jy.js.map → TextField-otYGVuwF.js.map} +1 -1
- package/dist/{ThemeToggle-9RBaRALj.cjs → ThemeToggle-B8rkRTis.cjs} +2 -2
- package/dist/{ThemeToggle-9RBaRALj.cjs.map → ThemeToggle-B8rkRTis.cjs.map} +1 -1
- package/dist/{ThemeToggle-DTkFppOd.js → ThemeToggle-D33Tqv2F.js} +3 -3
- package/dist/{ThemeToggle-DTkFppOd.js.map → ThemeToggle-D33Tqv2F.js.map} +1 -1
- package/dist/{TimeColumns-B7af5Cbj.js → TimeColumns-DyjTpZbD.js} +2 -2
- package/dist/{TimeColumns-B7af5Cbj.js.map → TimeColumns-DyjTpZbD.js.map} +1 -1
- package/dist/{TimeColumns-CJ13uf3K.cjs → TimeColumns-qEHHZC1N.cjs} +2 -2
- package/dist/{TimeColumns-CJ13uf3K.cjs.map → TimeColumns-qEHHZC1N.cjs.map} +1 -1
- package/dist/{TimePicker-Dshko7IJ.cjs → TimePicker-DJrNO01U.cjs} +2 -2
- package/dist/{TimePicker-Dshko7IJ.cjs.map → TimePicker-DJrNO01U.cjs.map} +1 -1
- package/dist/{TimePicker-BitZ7wv-.js → TimePicker-yfYqLbj3.js} +6 -6
- package/dist/{TimePicker-BitZ7wv-.js.map → TimePicker-yfYqLbj3.js.map} +1 -1
- package/dist/{Toaster-8ynQTcc0.cjs → Toaster-B7Xd2IaM.cjs} +2 -2
- package/dist/{Toaster-8ynQTcc0.cjs.map → Toaster-B7Xd2IaM.cjs.map} +1 -1
- package/dist/{Toaster-CYVETXVZ.js → Toaster-D8cxkhwr.js} +2 -2
- package/dist/{Toaster-CYVETXVZ.js.map → Toaster-D8cxkhwr.js.map} +1 -1
- package/dist/{TranslatedFields-BKI3jrNd.cjs → TranslatedFields-BvqqdNWz.cjs} +2 -2
- package/dist/{TranslatedFields-BKI3jrNd.cjs.map → TranslatedFields-BvqqdNWz.cjs.map} +1 -1
- package/dist/{TranslatedFields-dmb-0Yn7.js → TranslatedFields-CsSsTrnF.js} +5 -5
- package/dist/{TranslatedFields-dmb-0Yn7.js.map → TranslatedFields-CsSsTrnF.js.map} +1 -1
- package/dist/Typography-ChSuxgkc.js +74 -0
- package/dist/Typography-ChSuxgkc.js.map +1 -0
- package/dist/Typography-d97DdbNd.cjs +2 -0
- package/dist/Typography-d97DdbNd.cjs.map +1 -0
- package/dist/{UserCard-pEJZqiDF.js → UserCard-CsZ4Ogac.js} +4 -4
- package/dist/{UserCard-pEJZqiDF.js.map → UserCard-CsZ4Ogac.js.map} +1 -1
- package/dist/{UserCard-ah6K1y0H.cjs → UserCard-Die7JV4z.cjs} +2 -2
- package/dist/{UserCard-ah6K1y0H.cjs.map → UserCard-Die7JV4z.cjs.map} +1 -1
- package/dist/components/Alert/index.cjs +1 -1
- package/dist/components/Alert/index.js +1 -1
- package/dist/components/AuthLayout/index.cjs +1 -1
- package/dist/components/AuthLayout/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/ChoiceCard/index.cjs +1 -1
- package/dist/components/ChoiceCard/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/EmptyState/index.cjs +1 -1
- package/dist/components/EmptyState/index.js +1 -1
- package/dist/components/ErrorState/ErrorDetailsModal.d.cts +12 -0
- package/dist/components/ErrorState/ErrorDetailsModal.d.ts +12 -0
- package/dist/components/ErrorState/ErrorState.d.cts +23 -24
- package/dist/components/ErrorState/ErrorState.d.ts +23 -24
- package/dist/components/ErrorState/QueryError.d.cts +3 -3
- package/dist/components/ErrorState/QueryError.d.ts +3 -3
- package/dist/components/ErrorState/index.cjs +1 -1
- package/dist/components/ErrorState/index.js +2 -2
- 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/Loader/index.cjs +1 -1
- package/dist/components/Loader/index.js +1 -1
- package/dist/components/LocationPicker/index.cjs +1 -1
- package/dist/components/LocationPicker/index.js +1 -1
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/MultiSelect/index.cjs +1 -1
- package/dist/components/MultiSelect/index.js +1 -1
- package/dist/components/MultilineTextField/index.cjs +1 -1
- package/dist/components/MultilineTextField/index.js +1 -1
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.js +1 -1
- package/dist/components/OtpField/index.cjs +1 -1
- package/dist/components/OtpField/index.js +1 -1
- package/dist/components/PageError/index.cjs +1 -1
- package/dist/components/PageError/index.js +1 -1
- 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/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/QrCode/index.cjs +1 -1
- package/dist/components/QrCode/index.js +1 -1
- package/dist/components/Radio/index.cjs +1 -1
- package/dist/components/Radio/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/RootLayout.d.cts +6 -1
- package/dist/components/RootLayout/RootLayout.d.ts +6 -1
- package/dist/components/RootLayout/index.cjs +1 -1
- package/dist/components/RootLayout/index.js +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/Slider/index.cjs +1 -1
- package/dist/components/Slider/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/SwatchPicker/index.cjs +1 -1
- package/dist/components/SwatchPicker/index.js +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/index.cjs +1 -1
- package/dist/components/TagsField/index.js +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/Typography/Typography.d.cts +7 -1
- package/dist/components/Typography/Typography.d.ts +7 -1
- package/dist/components/Typography/index.cjs +1 -1
- package/dist/components/Typography/index.js +1 -1
- package/dist/components/UserCard/index.cjs +1 -1
- package/dist/components/UserCard/index.js +1 -1
- package/dist/entries/app.cjs +1 -1
- package/dist/entries/app.js +1 -1
- package/dist/entries/components.cjs +1 -1
- package/dist/entries/components.js +58 -58
- 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 +1 -1
- package/dist/entries/theme.d.ts +1 -1
- package/dist/entries/theme.js +1 -1
- package/dist/i18n/messages.d.cts +6 -0
- package/dist/i18n/messages.d.ts +6 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +61 -61
- package/dist/messages-DYXyWU3X.cjs +36 -0
- package/dist/messages-DYXyWU3X.cjs.map +1 -0
- package/dist/{messages-C1eTrGJy.js → messages-zarEtcsN.js} +25 -4
- package/dist/messages-zarEtcsN.js.map +1 -0
- package/dist/theme/ConfigProvider.d.cts +21 -2
- package/dist/theme/ConfigProvider.d.ts +21 -2
- package/dist/theme/index.d.cts +1 -1
- package/dist/theme/index.d.ts +1 -1
- package/dist/{useHomeTo-yTXajO22.js → useHomeTo-DVMyLZbb.js} +2 -2
- package/dist/{useHomeTo-yTXajO22.js.map → useHomeTo-DVMyLZbb.js.map} +1 -1
- package/dist/{useHomeTo-Cr6Usr_D.cjs → useHomeTo-Dnu6VAvU.cjs} +2 -2
- package/dist/{useHomeTo-Cr6Usr_D.cjs.map → useHomeTo-Dnu6VAvU.cjs.map} +1 -1
- package/dist/{useOptionMenu-DK0ixg-p.js → useOptionMenu-DNYlfNO_.js} +4 -4
- package/dist/{useOptionMenu-DK0ixg-p.js.map → useOptionMenu-DNYlfNO_.js.map} +1 -1
- package/dist/{useOptionMenu-DHGSbQmS.cjs → useOptionMenu-OAYGUWP_.cjs} +2 -2
- package/dist/{useOptionMenu-DHGSbQmS.cjs.map → useOptionMenu-OAYGUWP_.cjs.map} +1 -1
- package/package.json +1 -1
- package/dist/ConfigProvider-CVLHPXQm.cjs.map +0 -1
- package/dist/ConfigProvider-tvLbKiqu.js.map +0 -1
- package/dist/ErrorBoundary-8iu-mR5Y.cjs +0 -2
- package/dist/ErrorBoundary-8iu-mR5Y.cjs.map +0 -1
- package/dist/ErrorBoundary-BSJL381Y.js.map +0 -1
- package/dist/ErrorState-BXMjBWav.cjs +0 -4
- package/dist/ErrorState-BXMjBWav.cjs.map +0 -1
- package/dist/ErrorState-DKhZ4aJh.js +0 -142
- package/dist/ErrorState-DKhZ4aJh.js.map +0 -1
- package/dist/PageError-ClR7k0Zb.js +0 -69
- package/dist/PageError-D7_Q8wz8.cjs +0 -2
- package/dist/RootLayout-C7n79JjM.js +0 -621
- package/dist/RootLayout-C7n79JjM.js.map +0 -1
- package/dist/RootLayout-CtkpgPGV.cjs +0 -2
- package/dist/RootLayout-CtkpgPGV.cjs.map +0 -1
- package/dist/Typography-B6ASPrzT.cjs +0 -2
- package/dist/Typography-B6ASPrzT.cjs.map +0 -1
- package/dist/Typography-CJv5AnRP.js +0 -70
- package/dist/Typography-CJv5AnRP.js.map +0 -1
- package/dist/messages-C1eTrGJy.js.map +0 -1
- package/dist/messages-DCr7iFmv.cjs +0 -36
- package/dist/messages-DCr7iFmv.cjs.map +0 -1
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),V=require("react"),b=require("clsx"),Q=require("./Alert-CggrNMn5.cjs"),d=require("./Button-Cm64ROip.cjs"),U=require("./EmptyState-CZ6X5-Zy.cjs"),_=require("./Icon-BUP5_kRs.cjs"),W=require("./IconButton-CYMvszcM.cjs"),X=require("./Tooltip-Bw-1Xk2Z.cjs"),n=require("./errorMessage-C7N4KvUS.cjs"),Y=require("./useClipboard-BjTIX-4g.cjs"),Z=require("./Modal-eI6QL-LM.cjs"),w=require("./ConfigProvider-th4GYhcU.cjs"),P="_errorState_o523f_4",L="_actions_o523f_9",rr="_fieldErrors_o523f_18",er="_field_o523f_18",tr="_compact_o523f_32",or="_pre_o523f_37",sr="_alertVariant_o523f_53",nr="_alertTitle_o523f_56",lr="_alertBody_o523f_60",ar="_alertActions_o523f_65",t={errorState:P,actions:L,fieldErrors:rr,field:er,compact:tr,pre:or,alertVariant:sr,alertTitle:nr,alertBody:lr,alertActions:ar};function cr({open:I,onClose:o,report:u}){const s=w.useT(),{copy:h,copied:a}=Y.useClipboard();return r.jsx(Z.Modal,{open:I,onClose:o,title:s("errorState.detailsTitle"),icon:"Danger",color:"error",size:"lg",scrollBehavior:"inside",footer:r.jsxs(r.Fragment,{children:[r.jsx(d.Button,{variant:"text",color:"primary",onClick:o,children:s("common.close")}),r.jsx(d.Button,{startIcon:r.jsx(_.Icon,{name:a?"CopySuccess":"Copy"}),onClick:()=>void h(u),children:s(a?"clipboard.copied":"clipboard.copy")})]}),children:r.jsx("pre",{className:t.pre,children:u})})}const ir=V.forwardRef(function({error:o,variant:u="alert",title:s,description:h,icon:a,onRetry:c,retrying:m=!1,retryLabel:x,showDetails:C="dev",compact:S=!1,traceId:y,fieldErrors:T,fieldLabels:v,size:R,pattern:G,action:p,className:N,children:k,...A},z){const e=w.useT(),[H,E]=V.useState(!1),f=n.getErrorMessage(o,l=>e("errorState.requestFailed",{status:l})),g=y===!1?void 0:y??n.getErrorTraceId(o),B=T===!1?void 0:T??n.getErrorFieldErrors(o),J=B&&Object.keys(B).length>0?r.jsx("ul",{className:t.fieldErrors,children:Object.entries(B).map(([l,K])=>r.jsxs("li",{children:[r.jsx("span",{className:t.field,children:(v==null?void 0:v[l])??n.humanizeField(l)})," —"," ",K]},l))}):void 0,q=h??J??f??e("errorState.description"),$=a===void 0?n.isNetworkError(o)?"CloudCross":"Danger":a,j=(C==="dev"?n.isDev():C)?n.getErrorDetails(o):void 0,D=n.getErrorStatus(o),i=g!=null||j!=null?[g!=null&&`${e("errorState.traceId")}: ${g}`,D!=null&&`${e("errorState.status")}: ${D}`,f!=null&&(q===f||j!=null)&&`${e("errorState.message")}: ${f}`,j!=null&&`
|
|
2
|
+
${j}`].filter(Boolean).join(`
|
|
3
|
+
`):void 0,F=i!=null?r.jsx(cr,{open:H,onClose:()=>E(!1),report:i}):null;if(u==="alert"){const l=i!=null||c!=null||p!=null?r.jsxs("span",{className:t.alertActions,children:[c!=null&&r.jsx(X.Tooltip,{content:x??e("errorState.retry"),children:r.jsx(W.IconButton,{size:"sm",variant:"text",color:"error","aria-label":typeof x=="string"?x:e("errorState.retry"),loading:m,disabled:m,onClick:c,children:r.jsx(_.Icon,{name:"RefreshArrow2"})})}),i!=null&&r.jsx(d.Button,{size:"sm",variant:"filled",color:"error",onClick:()=>E(!0),children:e("errorState.details")}),p]}):void 0;return r.jsxs(r.Fragment,{children:[r.jsxs(Q.Alert,{ref:z,color:"error",icon:$,action:l,className:b.clsx(t.alertVariant,N),...A,children:[s!=null&&r.jsx("span",{className:t.alertTitle,children:s}),r.jsx("span",{className:t.alertBody,children:q}),k]}),F]})}const M=c!=null?r.jsx(d.Button,{size:"sm",variant:"outlined",color:"primary",startIcon:r.jsx(_.Icon,{name:"RefreshRight"}),loading:m,disabled:m,onClick:c,children:x??e("errorState.retry")}):null,O=i!=null?r.jsx(d.Button,{size:"sm",variant:"text",color:"primary",startIcon:r.jsx(_.Icon,{name:"DocumentText"}),onClick:()=>E(!0),children:e("errorState.details")}):null;return r.jsxs(r.Fragment,{children:[r.jsx(U.EmptyState,{ref:z,role:"alert",color:"error",icon:$,title:s??e("errorState.title"),description:q,size:R??(S?"sm":"md"),pattern:G??!S,action:M||O||p?r.jsxs("span",{className:t.actions,children:[M,O,p]}):void 0,className:b.clsx(t.errorState,S&&t.compact,N),...A,children:k}),F]})});exports.ErrorState=ir;
|
|
4
|
+
//# sourceMappingURL=ErrorState-DRXuV6na.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorState-DRXuV6na.cjs","sources":["../src/components/ErrorState/ErrorDetailsModal.tsx","../src/components/ErrorState/ErrorState.tsx"],"sourcesContent":["import { useT } from '../../theme'\nimport { useClipboard } from '../../hooks/useClipboard'\nimport { Button } from '../Button'\nimport { Icon } from '../Icon'\nimport { Modal } from '../Modal'\nimport styles from './ErrorState.module.css'\n\nexport interface ErrorDetailsModalProps {\n open: boolean\n onClose: () => void\n /** The whole report — shown as-is and copied by the Copy button. */\n report: string\n}\n\n/**\n * Internal to `ErrorState`: the \"Details\" dialog — the error report (trace id, status, message, then the stack /\n * raw dump when allowed) in one monospace block, with **Copy** (the whole report, flips to \"Copied!\") and\n * **Close** in the footer, so a user can paste it into a support ticket in one go.\n */\nexport function ErrorDetailsModal({ open, onClose, report }: ErrorDetailsModalProps) {\n const t = useT()\n const { copy, copied } = useClipboard()\n return (\n <Modal\n open={open}\n onClose={onClose}\n title={t('errorState.detailsTitle')}\n icon=\"Danger\"\n color=\"error\"\n size=\"lg\"\n scrollBehavior=\"inside\"\n footer={\n <>\n <Button variant=\"text\" color=\"primary\" onClick={onClose}>\n {t('common.close')}\n </Button>\n <Button\n startIcon={<Icon name={copied ? 'CopySuccess' : 'Copy'} />}\n onClick={() => void copy(report)}\n >\n {copied ? t('clipboard.copied') : t('clipboard.copy')}\n </Button>\n </>\n }\n >\n <pre className={styles.pre}>{report}</pre>\n </Modal>\n )\n}\n","import { forwardRef, useState, type ReactNode } from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { Alert } from '../Alert'\nimport { Button } from '../Button'\nimport { EmptyState, type EmptyStateProps } from '../EmptyState'\nimport { Icon } from '../Icon'\nimport { IconButton } from '../IconButton'\nimport { Tooltip } from '../Tooltip'\nimport type { IconName } from '../../icons/names'\nimport {\n getErrorDetails,\n getErrorFieldErrors,\n getErrorMessage,\n getErrorStatus,\n getErrorTraceId,\n humanizeField,\n isNetworkError,\n isDev,\n} from './errorMessage'\nimport { ErrorDetailsModal } from './ErrorDetailsModal'\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. `'alert'` (default) — a red `Alert` banner: the message (no default title), then Try Again /\n * Details / `action` in the alert's action slot; it fits anywhere — above a form, in a modal, in a card.\n * `'block'` — the `EmptyState`-style block (puck, title, centred message, the buttons below), for an area\n * whose data failed to load, or a whole page (`PageError`). `compact` and `pattern` apply to `'block'` only.\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. Alert: none unless given — the message is the point. Block: defaults to the localized \"Something\n * Went Wrong\".\n */\n title?: ReactNode\n /**\n * Leading icon — a known `IconName`, any node, or `false`. Defaults to `Danger` in both variants (the alert\n * replaces the Alert's own × icon), or `CloudCross` when the request never got a response (an explicit\n * `status: 0` / network error code), tinted `error`.\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 * Include the technical dump (the stack, or the raw error as JSON) in the **Details** dialog. `'dev'`\n * (default) only in development builds; `true` always; `false` never. The Details button itself shows\n * whenever there's a trace id or this dump — never inline on the page.\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 — it matches a report to the server log. It isn't shown on the page: it leads the\n * **Details** dialog (with a copy button), and its presence alone shows the Details button, production\n * included. 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 \"it broke\" counterpart of `EmptyState`. By default (`variant=\"alert\"`) a red `Alert` banner with a `Danger`\n * icon: the failure's own message (extracted from an `Error`, a string, an axios-style `response.data.message`, a\n * `{ message }`, or a raw `{ status }` → \"Request failed (404)\"), or a 400's per-field `fieldErrors` list; then\n * **Try Again** (`onRetry`, spinning while `retrying`) and **Details** in its action slot. `variant=\"block\"` is the\n * `EmptyState`-style block (an `error`-tinted puck, a \"Something Went Wrong\" title, the same buttons below);\n * `compact` is its inline size. **Details** opens a dialog with the full report — the server's `traceId`, the\n * status, the message, and the stack in development (`showDetails`) — in one block with a copy button. Announced\n * once (`role=\"alert\"`). `forwardRef` to the root; any other `EmptyState` prop passes through to the block.\n */\nexport const ErrorState = forwardRef<HTMLDivElement, ErrorStateProps>(function ErrorState(\n {\n error,\n variant = 'alert',\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 [detailsOpen, setDetailsOpen] = useState(false)\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 resolvedIcon = icon === undefined ? (isNetworkError(error) ? 'CloudCross' : 'Danger') : icon\n\n // the \"Details\" report — trace id, status, message, then the stack / raw dump (dev only by default). The\n // button shows when there's something worth opening: a trace id (always — it's what support asks for) or\n // the technical dump.\n const technical = (showDetails === 'dev' ? isDev() : showDetails)\n ? getErrorDetails(error)\n : undefined\n const status = getErrorStatus(error)\n const report =\n traceId != null || technical != null\n ? [\n traceId != null && `${t('errorState.traceId')}: ${traceId}`,\n status != null && `${t('errorState.status')}: ${status}`,\n // the raw message only where it's already visible, or with the dev dump — a `description` /\n // `fallback` (or PageError) hides it on purpose\n message != null &&\n (body === message || technical != null) &&\n `${t('errorState.message')}: ${message}`,\n technical != null && `\\n${technical}`,\n ]\n .filter(Boolean)\n .join('\\n')\n : undefined\n const detailsModal =\n report != null ? (\n <ErrorDetailsModal open={detailsOpen} onClose={() => setDetailsOpen(false)} report={report} />\n ) : null\n\n // ── alert (default): a banner — the message, then Try Again / Details / action in the action slot ──\n if (variant === 'alert') {\n const alertActions =\n report != null || onRetry != null || action != null ? (\n <span className={styles.alertActions}>\n {/* an icon-only retry (tooltip + aria-label) keeps the slot narrow, so the message keeps its room on\n small screens */}\n {onRetry != null && (\n <Tooltip content={retryLabel ?? t('errorState.retry')}>\n <IconButton\n size=\"sm\"\n variant=\"text\"\n color=\"error\"\n aria-label={typeof retryLabel === 'string' ? retryLabel : t('errorState.retry')}\n loading={retrying}\n disabled={retrying}\n onClick={onRetry}\n >\n <Icon name=\"RefreshArrow2\" />\n </IconButton>\n </Tooltip>\n )}\n {report != null && (\n <Button size=\"sm\" variant=\"filled\" color=\"error\" onClick={() => setDetailsOpen(true)}>\n {t('errorState.details')}\n </Button>\n )}\n {action}\n </span>\n ) : undefined\n return (\n <>\n <Alert\n ref={ref}\n color=\"error\"\n icon={resolvedIcon}\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 {children}\n </Alert>\n {detailsModal}\n </>\n )\n }\n\n // ── block: the EmptyState-style hero / compact block ──\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 const detailsButton =\n report != null ? (\n <Button\n size=\"sm\"\n variant=\"text\"\n color=\"primary\"\n startIcon={<Icon name=\"DocumentText\" />}\n onClick={() => setDetailsOpen(true)}\n >\n {t('errorState.details')}\n </Button>\n ) : null\n\n return (\n <>\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={resolvedIcon}\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 || detailsButton || action ? (\n <span className={styles.actions}>\n {retry}\n {detailsButton}\n {action}\n </span>\n ) : undefined\n }\n className={clsx(styles.errorState, compact && styles.compact, className)}\n {...props}\n >\n {children}\n </EmptyState>\n {detailsModal}\n </>\n )\n})\n"],"names":["ErrorDetailsModal","open","onClose","report","t","useT","copy","copied","useClipboard","jsx","Modal","jsxs","Fragment","Button","Icon","styles","ErrorState","forwardRef","error","variant","title","description","icon","onRetry","retrying","retryLabel","showDetails","compact","traceIdProp","fieldErrorsProp","fieldLabels","size","pattern","action","className","children","props","ref","detailsOpen","setDetailsOpen","useState","message","getErrorMessage","status","traceId","getErrorTraceId","fieldErrors","getErrorFieldErrors","fieldErrorList","field","msg","humanizeField","body","resolvedIcon","isNetworkError","technical","isDev","getErrorDetails","getErrorStatus","detailsModal","alertActions","Tooltip","IconButton","Alert","clsx","retry","detailsButton","EmptyState"],"mappings":"g0BAmBO,SAASA,GAAkB,CAAE,KAAAC,EAAM,QAAAC,EAAS,OAAAC,GAAkC,CACnF,MAAMC,EAAIC,EAAAA,KAAA,EACJ,CAAE,KAAAC,EAAM,OAAAC,CAAA,EAAWC,eAAA,EACzB,OACEC,EAAAA,IAACC,EAAAA,MAAA,CACC,KAAAT,EACA,QAAAC,EACA,MAAOE,EAAE,yBAAyB,EAClC,KAAK,SACL,MAAM,QACN,KAAK,KACL,eAAe,SACf,OACEO,EAAAA,KAAAC,WAAA,CACE,SAAA,CAAAH,EAAAA,IAACI,EAAAA,OAAA,CAAO,QAAQ,OAAO,MAAM,UAAU,QAASX,EAC7C,SAAAE,EAAE,cAAc,CAAA,CACnB,EACAK,EAAAA,IAACI,EAAAA,OAAA,CACC,UAAWJ,EAAAA,IAACK,OAAA,CAAK,KAAMP,EAAS,cAAgB,OAAQ,EACxD,QAAS,IAAM,KAAKD,EAAKH,CAAM,EAE9B,SAASC,EAATG,EAAW,mBAAwB,gBAAN,CAAsB,CAAA,CACtD,EACF,EAGF,SAAAE,EAAAA,IAAC,MAAA,CAAI,UAAWM,EAAO,IAAM,SAAAZ,CAAA,CAAO,CAAA,CAAA,CAG1C,CCgDO,MAAMa,GAAaC,EAAAA,WAA4C,SACpE,CACE,MAAAC,EACA,QAAAC,EAAU,QACV,MAAAC,EACA,YAAAC,EACA,KAAAC,EACA,QAAAC,EACA,SAAAC,EAAW,GACX,WAAAC,EACA,YAAAC,EAAc,MACd,QAAAC,EAAU,GACV,QAASC,EACT,YAAaC,EACb,YAAAC,EACA,KAA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AK,UAAWM,EAAO,UAAY,SAAAqC,EAAK,EACxCjB,CAAA,CAAA,CAAA,EAEFwB,CAAA,EACH,CAEJ,CAGA,MAAMM,EACJ1C,GAAW,KACTd,EAAAA,IAACI,EAAAA,OAAA,CACC,KAAK,KACL,QAAQ,WACR,MAAM,UACN,UAAWJ,EAAAA,IAACK,EAAAA,KAAA,CAAK,KAAK,cAAA,CAAe,EACrC,QAASU,EACT,SAAUA,EACV,QAASD,EAER,SAAAE,GAAcrB,EAAE,kBAAkB,CAAA,CAAA,EAEnC,KACA8D,EACJ/D,GAAU,KACRM,EAAAA,IAACI,EAAAA,OAAA,CACC,KAAK,KACL,QAAQ,OACR,MAAM,UACN,UAAWJ,EAAAA,IAACK,EAAAA,KAAA,CAAK,KAAK,cAAA,CAAe,EACrC,QAAS,IAAMyB,EAAe,EAAI,EAEjC,WAAE,oBAAoB,CAAA,CAAA,EAEvB,KAEN,OACE5B,EAAAA,KAAAC,WAAA,CACE,SAAA,CAAAH,EAAAA,IAAC0D,EAAAA,WAAA,CACC,IAAA9B,EAGA,KAAK,QACL,MAAM,QACN,KAAMgB,EACN,MAAOjC,GAAShB,EAAE,kBAAkB,EAEpC,YAAagD,EACb,KAAMrB,IAASJ,EAAU,KAAO,MAChC,QAASK,GAAW,CAACL,EACrB,OACEsC,GAASC,GAAiBjC,SACvB,OAAA,CAAK,UAAWlB,EAAO,QACrB,SAAA,CAAAkD,EACAC,EACAjC,CAAA,CAAA,CACH,EACE,OAEN,UAAW+B,EAAAA,KAAKjD,EAAO,WAAYY,GAAWZ,EAAO,QAASmB,CAAS,EACtE,GAAGE,EAEH,SAAAD,CAAA,CAAA,EAEFwB,CAAA,EACH,CAEJ,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-BUmXN_lD.js";
|
|
6
6
|
import { I as V } from "./Icon-CGQ5yGSZ.js";
|
|
7
|
-
import { T as G } from "./Typography-
|
|
8
|
-
import { a as H } from "./ConfigProvider-
|
|
7
|
+
import { T as G } from "./Typography-ChSuxgkc.js";
|
|
8
|
+
import { a as H } from "./ConfigProvider-DZMtq2Fz.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-CxZ3o4BO.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileCard-R_sB8Qbx.js","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":";;;;;;;;;;;;;;;;;;;;GAmBMA,yBAAiB,IAAI;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC,GAGKC,KAAuC;AAAA,EAC3C,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AACP;AAGA,SAASC,GAAYC,GAAcC,GAAuB;AACxD,QAAMC,IAAMF,EAAK,YAAY,GAAG;AAChC,SAAIE,IAAM,KAAKF,EAAK,SAASE,KAAO,IAAUF,EAAK,MAAME,IAAM,CAAC,EAAE,YAAA,IAC9DD,KAAQA,EAAK,SAAS,GAAG,IAAUA,EAAK,MAAMA,EAAK,QAAQ,GAAG,IAAI,CAAC,EAAE,YAAA,IAClE;AACT;AAGA,SAASE,GAAUH,GAA6C;AAC9D,QAAME,IAAMF,EAAK,YAAY,GAAG;AAChC,SAAOE,IAAM,KAAKF,EAAK,SAASE,KAAO,IACnC,EAAE,MAAMF,EAAK,MAAM,GAAGE,CAAG,GAAG,KAAKF,EAAK,MAAME,CAAG,MAC/C,EAAE,MAAMF,GAAM,KAAK,GAAA;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A,UAAA,gBAAAF,EAAC,QAAA,EAAK,WAAWE,EAAO,MAAM,OAAO5C,GACnC,UAAA;AAAA,YAAA,gBAAA6C,EAAC,QAAA,EAAK,WAAWD,EAAO,UAAW,UAAAhB,GAAK;AAAA,YACvCC,KAAW,gBAAAgB,EAAC,QAAA,EAAK,WAAWD,EAAO,SAAU,UAAAf,EAAA,CAAQ;AAAA,UAAA,GACxD;AAAA,UACCU,KAAY,QACX,gBAAAM,EAACE,GAAA,EAAW,IAAG,QAAO,SAAQ,aAAY,OAAM,SAAQ,WAAS,IAAC,WAAWH,EAAO,MACjF,UAAAL,EAAA,CACH;AAAA,QAAA,GAEJ;AAAA,QACCrB,MAAiBP,KAAOQ,MACvB,gBAAA0B;AAAA,UAACG;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAM/B,MAAS,OAAO,OAAO;AAAA,YAC7B,WAAW2B,EAAO;AAAA,YAClB,cAAYpB,EAAE,qBAAqB,EAAE,MAAAxB,GAAM;AAAA,YAC3C,SAASwC;AAAA,YAET,UAAA,gBAAAK,EAACI,GAAA,EAAK,MAAK,cAAA,CAAc;AAAA,UAAA;AAAA,QAAA;AAAA,MAC3B;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
1
|
+
{"version":3,"file":"FileCard-CxZ3o4BO.js","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":";;;;;;;;;;;;;;;;;;;;GAmBMA,yBAAiB,IAAI;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC,GAGKC,KAAuC;AAAA,EAC3C,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AAAA,EACL,MAAM;AAAA,EACN,KAAK;AAAA,EACL,KAAK;AACP;AAGA,SAASC,GAAYC,GAAcC,GAAuB;AACxD,QAAMC,IAAMF,EAAK,YAAY,GAAG;AAChC,SAAIE,IAAM,KAAKF,EAAK,SAASE,KAAO,IAAUF,EAAK,MAAME,IAAM,CAAC,EAAE,YAAA,IAC9DD,KAAQA,EAAK,SAAS,GAAG,IAAUA,EAAK,MAAMA,EAAK,QAAQ,GAAG,IAAI,CAAC,EAAE,YAAA,IAClE;AACT;AAGA,SAASE,GAAUH,GAA6C;AAC9D,QAAME,IAAMF,EAAK,YAAY,GAAG;AAChC,SAAOE,IAAM,KAAKF,EAAK,SAASE,KAAO,IACnC,EAAE,MAAMF,EAAK,MAAM,GAAGE,CAAG,GAAG,KAAKF,EAAK,MAAME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AAC,OAAA,EAAI,WAAWE,EAAO,MACrB,UAAA;AAAA,UAAA,gBAAAF,EAAC,QAAA,EAAK,WAAWE,EAAO,MAAM,OAAO5C,GACnC,UAAA;AAAA,YAAA,gBAAA6C,EAAC,QAAA,EAAK,WAAWD,EAAO,UAAW,UAAAhB,GAAK;AAAA,YACvCC,KAAW,gBAAAgB,EAAC,QAAA,EAAK,WAAWD,EAAO,SAAU,UAAAf,EAAA,CAAQ;AAAA,UAAA,GACxD;AAAA,UACCU,KAAY,QACX,gBAAAM,EAACE,GAAA,EAAW,IAAG,QAAO,SAAQ,aAAY,OAAM,SAAQ,WAAS,IAAC,WAAWH,EAAO,MACjF,UAAAL,EAAA,CACH;AAAA,QAAA,GAEJ;AAAA,QACCrB,MAAiBP,KAAOQ,MACvB,gBAAA0B;AAAA,UAACG;AAAA,UAAA;AAAA,YACC,SAAQ;AAAA,YACR,MAAM/B,MAAS,OAAO,OAAO;AAAA,YAC7B,WAAW2B,EAAO;AAAA,YAClB,cAAYpB,EAAE,qBAAqB,EAAE,MAAAxB,GAAM;AAAA,YAC3C,SAASwC;AAAA,YAET,UAAA,gBAAAK,EAACI,GAAA,EAAK,MAAK,cAAA,CAAc;AAAA,UAAA;AAAA,QAAA;AAAA,MAC3B;AAAA,IAAA;AAAA,EAAA;AAIR,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-CYMvszcM.cjs"),O=require("./Icon-BUP5_kRs.cjs"),L=require("./Typography-d97DdbNd.cjs"),$=require("./ConfigProvider-th4GYhcU.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-ZZNd_tUN.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileCard-B3dfdTVN.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,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,GAAG,EAAI,CAAC,EAAE,YAAA,EAClE,EACT,CAGA,SAASE,GAAUH,EAA6C,CAC9D,MAAME,EAAMF,EAAK,YAAY,GAAG,EAChC,OAAOE,EAAM,GAAKF,EAAK,OAASE,GAAO,EACnC,CAAE,KAAMF,EAAK,MAAM,EAAGE,CAAG,EAAG,IAAKF,EAAK,MAAME,CAAG,GAC/C,CAAE,KAAMF,EAAM,IAAK,EAAA,CACzB,CAGA,SAASI,EAAYC,EAAuB,CAC1C,GAAI,CAAC,OAAO,SAASA,CAAK,GAAKA,EAAQ,EAAG,MAAO,GACjD,GAAIA,EAAQ,KAAM,MAAO,GAAGA,CAAK,KACjC,MAAMC,EAAQ,CAAC,KAAM,KAAM,KAAM,IAAI,EACrC,IAAIC,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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"}
|
|
1
|
+
{"version":3,"file":"FileCard-ZZNd_tUN.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,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,IA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AAS,GAAGK,CAAA,EAC3D,GAAGC,EAEJ,SAAA,CAAAuB,EAAAA,IAACC,EAAAA,OAAA,CACC,UAAWF,EAAO,OAClB,IAAKjB,EAAUhB,EAAM,OACrB,KAAMgB,EAAU,OAAa7B,EAAW4B,CAAG,GAAK,WAChD,KAAA1B,EACA,MAAM,SACN,KAAAiB,EACA,MAAAD,CAAA,CAAA,EAEF0B,EAAAA,KAAC,MAAA,CAAI,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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const t=require("react/jsx-runtime"),d=require("react"),L=require("clsx"),V=require("@dnd-kit/core"),ae=require("@dnd-kit/sortable"),Et=require("@dnd-kit/utilities"),kt=require("@formkit/auto-animate/react"),Rt=require("react-dropzone"),zt=require("./formContext-bTWrqdEV.cjs"),Ve=require("./toastStore-B4Tk2Xk7.cjs"),M=require("./Icon-BUP5_kRs.cjs"),Ft=require("./Skeleton-DK0lAjS9.cjs"),ie=require("./Typography-B6ASPrzT.cjs"),Dt=require("react-image-crop"),Ge=require("./Button-BD5wpg-t.cjs"),Ye=require("./Modal-BL_XihC8.cjs"),Ct=require("./TextField-CgPfN-4d.cjs"),ce=require("./ConfigProvider-CVLHPXQm.cjs"),Ie=require("./TextField.module-DsNCo8vN.cjs"),Mt="_cropSection_1j2zs_4",Pt="_cropHead_1j2zs_10",qt="_cropStage_1j2zs_16",Lt="_crop_1j2zs_4",Bt="_cropImg_1j2zs_30",$t="_altFields_1j2zs_35",Q={cropSection:Mt,cropHead:Pt,cropStage:qt,crop:Lt,cropImg:Bt,altFields:$t};function Ot({mode:n,name:o,imageUrl:l,mimeType:p,editLocales:S,initialDraft:w,onClose:N,onSave:P}){const h=ce.useT(),z=d.useRef(null),[_,B]=d.useState(),[i,$]=d.useState(null),[O,G]=d.useState(null),[Y,A]=d.useState(w),[W,X]=d.useState(null),[E,T]=d.useState(!1),Z=(c,y)=>{B(y);const g=z.current;if(g&&g.width>0&&c.width>=1&&c.height>=1){const k=g.naturalWidth/g.width,q=g.naturalHeight/g.height;$({x:Math.round(c.x*k),y:Math.round(c.y*q),width:Math.round(c.width*k),height:Math.round(c.height*q)})}else $(null)},U=async()=>{const c=z.current;if(!c||!i||i.width<1||i.height<1)return;const y=document.createElement("canvas");y.width=i.width,y.height=i.height;const g=y.getContext("2d");if(!g)return;g.imageSmoothingEnabled=!1,g.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height);const k=await new Promise(q=>y.toBlob(q,p,1));if(!k)throw new Error("canvas.toBlob returned null");return new File([k],o,{type:p,lastModified:Date.now()})},J=async()=>{if(n==="altText"){P({draft:Y});return}T(!0);try{const c=i&&i.width>=1&&i.height>=1?await U():void 0;P({croppedFile:c})}catch{X(h("fileUploader.cropError")),T(!1)}};return t.jsx(Ye.Modal,{open:!0,onClose:N,size:n==="crop"?"lg":"sm",icon:n==="crop"?"Crop":"Text",title:h(n==="crop"?"fileUploader.cropTitle":"fileUploader.altTitle"),description:o,footer:t.jsxs(t.Fragment,{children:[t.jsx(Ge.Button,{variant:"text",color:"accent",size:"sm",onClick:N,disabled:E,children:h("common.cancel")}),t.jsx(Ge.Button,{size:"sm",onClick:J,loading:E,children:h("common.save")})]}),children:n==="crop"?t.jsxs("div",{className:Q.cropSection,children:[t.jsxs("div",{className:Q.cropHead,children:[t.jsx(ie.Typography,{variant:"bodySmall",color:"muted",children:h("fileUploader.cropHint")}),t.jsx(ie.Typography,{variant:"bodySmall",color:i?"text":"muted",children:i?`${i.width} × ${i.height} px`:O?`${O.w} × ${O.h} px`:""})]}),t.jsx("div",{className:Q.cropStage,children:t.jsx(Dt,{crop:_,onChange:Z,className:Q.crop,children:t.jsx("img",{ref:z,src:l??void 0,alt:"",className:Q.cropImg,onLoad:c=>G({w:c.currentTarget.naturalWidth,h:c.currentTarget.naturalHeight})})})}),W&&t.jsx(ie.Typography,{variant:"bodySmall",color:"error",children:W})]}):t.jsx("div",{className:Q.altFields,children:S.map(c=>t.jsx(Ct.TextField,{label:c.label??(c.code||h("fileUploader.altTitle")),placeholder:h("fileUploader.altPlaceholder"),value:Y[c.code]??"",onChange:y=>A(g=>({...g,[c.code]:y.target.value}))},c.code))})})}const At="_backdrop_uqdv2_5",Wt="_media_uqdv2_9",Ht="_mediaSvg_uqdv2_19",Kt="_close_uqdv2_27",re={backdrop:At,media:Wt,mediaSvg:Ht,close:Kt};function Vt({url:n,isVideo:o,isSvg:l,name:p,onClose:S}){const w=ce.useT();return t.jsxs(Ye.Overlay,{open:!0,onClose:S,dim:.85,className:re.backdrop,role:"dialog","aria-modal":"true","aria-label":w("fileUploader.preview",{name:p}),children:[t.jsx("button",{type:"button",className:re.close,"aria-label":w("fileUploader.closePreview"),onClick:S,autoFocus:!0,children:t.jsx(M.Icon,{name:"Close",size:"lg"})}),o?t.jsx("video",{src:n,className:re.media,controls:!0,playsInline:!0}):t.jsx("img",{src:n,alt:p,className:L.clsx(re.media,l&&re.mediaSvg)})]})}const Gt="_root_m8xag_4",Yt="_fullWidth_m8xag_9",Jt="_disabled_m8xag_14",Qt="_dropzone_m8xag_17",Xt="_dropText_m8xag_41",Zt="_dropping_m8xag_56",eo="_error_m8xag_61",to="_dropIcon_m8xag_65",oo="_prompt_m8xag_77",no="_accent_m8xag_82",so="_hint_m8xag_87",ro="_list_m8xag_93",ao="_populated_m8xag_103",lo="_tile_m8xag_121",io="_grabbable_m8xag_130",co="_entering_m8xag_139",uo="_dragging_m8xag_142",fo="_tileError_m8xag_148",po="_tileImg_m8xag_153",go="_tileImgPending_m8xag_161",mo="_tileSkeleton_m8xag_164",ho="_tileFallback_m8xag_169",xo="_tilePlay_m8xag_179",_o="_tileTop_m8xag_198",bo="_tileBottom_m8xag_208",yo="_tileRemove_m8xag_218",vo="_tileAction_m8xag_219",jo="_tileActionEnd_m8xag_254",So="_tileText_m8xag_257",To="_name_m8xag_264",Uo="_nameBase_m8xag_271",Io="_nameExt_m8xag_277",wo="_tileMeta_m8xag_281",No="_metaError_m8xag_285",r={root:Gt,fullWidth:Yt,disabled:Jt,dropzone:Qt,dropText:Xt,dropping:Zt,error:eo,dropIcon:to,prompt:oo,accent:no,hint:so,list:ro,populated:ao,tile:lo,grabbable:io,entering:co,dragging:uo,tileError:fo,tileImg:po,tileImgPending:go,tileSkeleton:mo,tileFallback:ho,tilePlay:xo,tileTop:_o,tileBottom:bo,tileRemove:yo,tileAction:vo,tileActionEnd:jo,tileText:So,name:To,nameBase:Uo,nameExt:Io,tileMeta:wo,metaError:No},Je=()=>typeof URL<"u"&&typeof URL.createObjectURL=="function",Eo=300,ko=(n,o,l,p)=>{let S=[{},{}],w=Eo;if(o==="add")w=0;else if(o==="remove")S=[{opacity:1,transform:"translateY(0)"},{opacity:0,transform:"translateY(-8px)"}];else if(l&&p){const N=l.left-p.left,P=l.top-p.top;S=[{transform:`translate(${N}px, ${P}px)`},{transform:"translate(0, 0)"}]}return new KeyframeEffect(n,S,{duration:w,easing:"ease-out"})},le=n=>{if(n<1024)return`${n} B`;const o=["KB","MB","GB","TB"];let l=n/1024,p=0;for(;l>=1024&&p<o.length-1;)l/=1024,p+=1;return`${l.toFixed(l<10?1:0)} ${o[p]}`},Ro=n=>{if(typeof n=="number")return n;const o=/^\s*([\d.]+)\s*(b|kb|mb|gb|tb)?\s*$/i.exec(n);if(!o)return;const l={b:1,kb:1024,mb:1024**2,gb:1024**3,tb:1024**4};return parseFloat(o[1])*(l[(o[2]||"b").toLowerCase()]??1)},Qe=n=>`f:${n.name}:${n.size}:${n.lastModified}`,zo=n=>n.file?Qe(n.file):`s:${n.source??""}`,me=n=>n.file?n.file.name:n.source?/^(data|blob):/i.test(n.source)?"File":n.source.split(/[?#]/)[0].split("/").pop()||"File":"File",we=n=>{if(n.file)return n.file.type.startsWith("image/");const o=n.source;return o?/^data:image\//i.test(o)?!0:/^data:/i.test(o)?!1:/\.(png|jpe?g|gif|webp|avif|svg|bmp|ico|heic|heif)(?:[?#]|$)/i.test(o)||!/\.[a-z0-9]{1,8}(?:[?#]|$)/i.test(o):!1},Ne=n=>{if(n.file)return n.file.type.startsWith("video/");const o=n.source;return o?/^data:video\//i.test(o)||/\.(mp4|webm|ogg|ogv|mov|m4v|avi|mkv)(?:[?#]|$)/i.test(o):!1},Fo=n=>{if(typeof document>"u")return;const o=document.createElement("a");if(o.style.display="none",n.file){if(!Je())return;const l=URL.createObjectURL(n.file);o.href=l,o.download=n.file.name,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(l),1e3)}else n.source&&(o.href=n.source,o.download=me(n),o.target="_blank",o.rel="noopener",document.body.appendChild(o),o.click(),o.remove())},Do=n=>{const o=n.lastIndexOf(".");return o>0&&n.length-o<=7?{base:n.slice(0,o),ext:n.slice(o)}:{base:n,ext:""}};function Co({id:n,item:o,preview:l,sortable:p,entering:S,disabled:w,error:N,onRemove:P,onCrop:h,onAltText:z,onDownload:_,onView:B,onPreviewError:i}){const{attributes:$,listeners:O,setNodeRef:G,transform:Y,transition:A,isDragging:W}=ae.useSortable({id:n,disabled:!p}),X={transform:Et.CSS.Transform.toString(Y),transition:A},E=ce.useT(),T=me(o),{base:Z,ext:U}=Do(T),[J,c]=d.useState(()=>!l||l.startsWith("blob:")),y=d.useRef(l);y.current!==l&&(y.current=l,c(!l||l.startsWith("blob:")));const g=d.useRef(null);d.useEffect(()=>{const m=g.current;m!=null&&m.complete&&m.naturalWidth>0&&c(!0)},[l]);const k=()=>{c(!0),i==null||i()},q=o.file?le(o.file.size):E("fileUploader.uploaded"),he=Ne(o),de=_?t.jsx("button",{type:"button",className:r.tileAction,"aria-label":E("fileUploader.download",{name:T}),onClick:_,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"DocumentDownload",size:"sm"})}):null;return t.jsxs("div",{ref:G,style:X,className:L.clsx(r.tile,p&&r.grabbable,S&&r.entering,W&&r.dragging,N&&r.tileError),...$,...O,children:[l&&!J&&t.jsx(Ft.Skeleton,{variant:"rect",width:"100%",height:"100%",className:r.tileSkeleton}),l?he?t.jsxs(t.Fragment,{children:[t.jsx("video",{src:l,className:r.tileImg,muted:!0,playsInline:!0,preload:"metadata",draggable:!1,onLoadedData:()=>c(!0),onError:k}),t.jsx("span",{className:r.tilePlay,"aria-hidden":"true",children:t.jsx(M.Icon,{name:"Play",size:"lg"})})]}):t.jsx("img",{ref:g,src:l,alt:"",className:L.clsx(r.tileImg,!J&&r.tileImgPending),draggable:!1,onLoad:()=>c(!0),onError:k}):t.jsx("span",{className:r.tileFallback,"aria-hidden":"true",children:t.jsx(M.Icon,{name:"Document",size:"lg"})}),t.jsxs("div",{className:r.tileTop,children:[t.jsxs("span",{className:r.tileText,children:[t.jsxs("span",{className:r.name,title:T,children:[t.jsx("span",{className:r.nameBase,children:Z}),U&&t.jsx("span",{className:r.nameExt,children:U})]}),t.jsx("span",{className:L.clsx(r.tileMeta,N&&r.metaError),children:N??q})]}),!w&&t.jsx("button",{type:"button",className:r.tileRemove,"aria-label":E("fileUploader.remove",{name:T}),onClick:P,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"Close",size:"sm"})})]}),(h||z||_||B)&&t.jsxs("div",{className:r.tileBottom,children:[h&&t.jsx("button",{type:"button",className:r.tileAction,"aria-label":E("fileUploader.crop",{name:T}),onClick:h,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"Crop",size:"sm"})}),z&&t.jsx("button",{type:"button",className:r.tileAction,"aria-label":E("fileUploader.editAlt",{name:T}),onClick:z,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"Text",size:"sm"})}),de,B&&t.jsx("button",{type:"button",className:L.clsx(r.tileAction,r.tileActionEnd),"aria-label":E("fileUploader.preview",{name:T}),onClick:B,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"Eye",size:"sm"})})]})]})}const Mo=d.forwardRef(function({multiple:o=!1,allowDrop:l=!0,allowReorder:p=!0,allowDownload:S=!0,allowPreview:w=!0,allowAltText:N=!0,altTextLocales:P,localizedAltText:h=!0,allowDuplicates:z=!1,disabled:_=!1,accept:B,maxFiles:i,maxFileSize:$,itemInsertLocation:O="end",value:G,defaultValue:Y,onChange:A,label:W,error:X,helperText:E,required:T=!1,fullWidth:Z=!0,name:U,id:J,onBlur:c,className:y,style:g,...k},q){var We;const he=d.useId(),de=J??he,m=`${de}-helper`,F=$!=null?Ro($):void 0,[ue,xe]=d.useState(null);d.useEffect(()=>{if(!ue)return;const e=window.setTimeout(()=>xe(null),4e3);return()=>window.clearTimeout(e)},[ue]);const ee=zt.useFormContext(),Ee=!!(ee&&U),D=ee&&U?ee.field(U):void 0,ke=o?[]:null,Re=G!==void 0?G:Ee?ee.values[U]??ke:void 0,ze=Re!==void 0,[Xe,Ze]=d.useState(Y??ke),te=ze?Re:Xe,x=te==null?[]:Array.isArray(te)?te:[te],_e=X??(D==null?void 0:D.error)??!1,et=E??(D==null?void 0:D.helperText),be=ue??et,tt=!!ue||_e,fe=p&&o&&!_,Fe=d.useRef(new WeakMap),De=d.useRef(0),ot=(e,s)=>{if(e.file){let a=Fe.current.get(e.file);return a||(De.current+=1,a=`f${De.current}`,Fe.current.set(e.file,a)),a}return e.source?`s:${e.source}`:`i:${s}`},I=x.map((e,s)=>ot(e,s)),Ce=d.useRef(new Set),nt=new Set(I.filter(e=>!Ce.current.has(e)));d.useEffect(()=>{Ce.current=new Set(I)});const[st,Me]=d.useState(()=>new Set),rt=e=>Me(s=>s.has(e)?s:new Set(s).add(e)),[at,lt]=d.useState(()=>new Set),it=e=>lt(s=>s.has(e)?s:new Set(s).add(e)),pe=d.useRef(new Map),ge=e=>{if(e.file){const s=e.file.type;if(!s.startsWith("image/")&&!s.startsWith("video/")||!Je()||at.has(e.file))return null;let a=pe.current.get(e.file);return a||(a=URL.createObjectURL(e.file),pe.current.set(e.file,a)),a}return e.source&&!st.has(e.source)?e.source:null},[C,Pe]=d.useState(null);d.useEffect(()=>{const e=pe.current,s=new Set(x.map(u=>u.file).filter(Boolean)),a=new Set(x.filter(u=>!u.file&&u.source).map(u=>u.source));for(const[u,f]of e)!s.has(u)&&f!==(C==null?void 0:C.url)&&(URL.revokeObjectURL(f),e.delete(u));Me(u=>{if(u.size===0)return u;const f=new Set([...u].filter(v=>a.has(v)));return f.size===u.size?u:f})},[te,C]),d.useEffect(()=>{const e=pe.current;return()=>{for(const s of e.values())URL.revokeObjectURL(s);e.clear()}},[]);const ct=e=>e.map((s,a)=>s.sortIndex===a?s:{...s,sortIndex:a}),oe=e=>{const s=ct(e),a=o?s:s[0]??null;ze||Ze(a),Ee&&ee.setValue(U,a),A==null||A(a)},ye=()=>D==null?void 0:D.onBlur({}),b=ce.useT(),dt=ce.useLocales(),qe=P??dt,ut=h&&qe.length>0?qe:[{code:""}],[ne,ve]=d.useState(null),[Le,Be]=d.useState("altText"),je=ne!=null?I.indexOf(ne):-1,R=je!==-1?x[je]:null,ft=e=>{Be("crop"),ve(I[e]??null)},pt=e=>{Be("altText"),ve(I[e]??null)},Se=()=>ve(null),gt=e=>{const s=ge(e);if(!s)return;const a=e.file?e.file.type==="image/svg+xml":/^data:image\/svg/i.test(e.source??"")||/\.svg(?:[?#]|$)/i.test(e.source??"");Pe({url:s,isVideo:Ne(e),isSvg:a,name:me(e)})},mt=R?h?R.altText&&typeof R.altText=="object"?{...R.altText}:{}:{"":typeof R.altText=="string"?R.altText:""}:{},ht=({draft:e,croppedFile:s})=>{if(je===-1)return Se();oe(x.map((a,u)=>{if(I[u]!==ne)return a;const f={...a};if(e!==void 0)if(h){const v=Object.fromEntries(Object.entries(e).map(([H,j])=>[H,j.trim()]).filter(([,H])=>H!==""));f.altText=Object.keys(v).length>0?v:void 0}else f.altText=(e[""]??"").trim()||void 0;return s&&(f.file=s,f.source=""),f})),Se()},xt=(e,s=[])=>{const a=s.filter(j=>j.errors.some(K=>K.code==="file-invalid-type")),u=s.filter(j=>j.errors.some(K=>K.code==="file-too-large"));a.length>0&&Ve.toast.error(a.length===1?b("fileUploader.wrongTypeOne",{name:a[0].file.name}):b("fileUploader.wrongTypeMany",{count:a.length})),u.length>0&&F!=null&&Ve.toast.error(u.length===1?b("fileUploader.tooLargeOne",{name:u[0].file.name,size:le(F)}):b("fileUploader.tooLargeMany",{count:u.length,size:le(F)}));const f=[];let v=e;if(o&&!z){const j=new Set(x.map(zo)),K=[];for(const He of v){const Ke=Qe(He);j.has(Ke)||(j.add(Ke),K.push(He))}K.length<v.length&&f.push(b("fileUploader.duplicate")),v=K}if(o&&i!=null){const j=Math.max(0,i-x.length);v.length>j&&(v=v.slice(0,j),f.push(i===1?b("fileUploader.hintUpToOne",{count:i}):b("fileUploader.hintUpToMany",{count:i})))}if(xe(f.length>0?f.join(" · "):null),v.length===0)return;const H=v.map(j=>({file:j,source:"",sortIndex:0}));if(!o){oe([H[0]]);return}oe(O==="start"?[...H,...x]:[...x,...H])},_t=e=>{xe(null),oe(x.filter((s,a)=>a!==e)),ye()},[bt,Te]=kt.useAutoAnimate(ko),$e=()=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>Te(!0)):Te(!0)},yt=()=>Te(!1),vt=()=>$e(),jt=e=>{const{active:s,over:a}=e;if(a&&s.id!==a.id){const u=I.indexOf(String(s.id)),f=I.indexOf(String(a.id));u!==-1&&f!==-1&&oe(ae.arrayMove(x,u,f))}$e()},St=V.useSensors(V.useSensor(V.PointerSensor,{activationConstraint:{distance:5}}),V.useSensor(V.KeyboardSensor,{coordinateGetter:ae.sortableKeyboardCoordinates})),se=d.useRef(!1),{getRootProps:Tt,getInputProps:Ut,isDragActive:It}=Rt.useDropzone({multiple:o,accept:B,maxSize:F,disabled:_,noKeyboard:!1,noDrag:!l,onFileDialogOpen:()=>{se.current=!0},onFileDialogCancel:()=>{se.current=!1,ye()},onDrop:(e,s)=>{se.current=!1,xt(e,s)}}),Oe=o||x.length===0,Ue=[];o&&i!=null&&Ue.push(i===1?b("fileUploader.hintUpToOne",{count:i}):b("fileUploader.hintUpToMany",{count:i})),F!=null&&Ue.push(b("fileUploader.hintMax",{size:le(F)}));const Ae=Ue.join(" · "),wt=l?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:r.accent,children:b("fileUploader.choose")})," ",b("fileUploader.dropSuffix")]}):t.jsx("span",{className:r.accent,children:b("fileUploader.choose")}),Nt=e=>{if(c==null||c(e),!e.currentTarget.contains(e.relatedTarget)&&ne==null){if(se.current){se.current=!1;return}ye()}};return t.jsxs("div",{ref:q,id:de,className:L.clsx(r.root,Z&&r.fullWidth,_e&&r.error,_&&r.disabled,y),style:g,"aria-invalid":_e||void 0,"aria-describedby":be!=null?m:void 0,onBlur:Nt,...k,...U?{name:U,tabIndex:-1}:{},children:[W!=null&&t.jsxs("label",{className:Ie.fieldStyles.label,children:[t.jsx(ie.Typography,{as:"span",variant:"bodySmall",color:"muted",children:W}),T&&t.jsx("span",{className:Ie.fieldStyles.required,"aria-hidden":"true",children:"*"})]}),Oe&&t.jsxs("div",{...Tt({className:L.clsx(r.dropzone,It&&r.dropping)}),children:[t.jsx("input",{...Ut()}),t.jsx("span",{className:r.dropIcon,"aria-hidden":"true",children:t.jsx(M.Icon,{name:"DocumentUpload",size:"lg"})}),t.jsxs("span",{className:r.dropText,children:[t.jsx("span",{className:r.prompt,children:wt}),Ae&&t.jsx("span",{className:r.hint,children:Ae})]})]}),t.jsx(V.DndContext,{sensors:St,collisionDetection:V.closestCenter,onDragStart:fe?yt:void 0,onDragEnd:fe?jt:void 0,onDragCancel:fe?vt:void 0,children:t.jsx(ae.SortableContext,{items:I,strategy:ae.rectSortingStrategy,children:t.jsx("div",{ref:bt,className:L.clsx(r.list,Oe&&x.length>0&&r.populated),children:x.map((e,s)=>t.jsx(Co,{id:I[s],item:e,preview:ge(e),sortable:fe&&x.length>1,entering:nt.has(I[s]),disabled:_,error:e.file&&F!=null&&e.file.size>F?b("fileUploader.exceedsLimit",{size:le(F)}):void 0,onRemove:()=>_t(s),onCrop:N&&!_&&we(e)?()=>ft(s):void 0,onAltText:N&&!_&&we(e)?()=>pt(s):void 0,onDownload:S&&!_?()=>Fo(e):void 0,onView:w&&!_&&ge(e)!=null&&(we(e)||Ne(e))?()=>gt(e):void 0,onPreviewError:e.file?()=>it(e.file):e.source?()=>rt(e.source):void 0},I[s]))})})}),be!=null&&t.jsx(ie.Typography,{as:"span",id:m,variant:"bodySmall",color:tt?"error":"muted",className:Ie.fieldStyles.helper,role:"status","aria-live":"polite",children:be}),R&&t.jsx(Ot,{mode:Le,name:me(R),imageUrl:ge(R),mimeType:((We=R.file)==null?void 0:We.type)||"image/png",editLocales:ut,initialDraft:mt,onClose:Se,onSave:ht},`${ne}:${Le}`),C&&t.jsx(Vt,{url:C.url,isVideo:C.isVideo,isSvg:C.isSvg,name:C.name,onClose:()=>Pe(null)})]})});exports.FileUploader=Mo;
|
|
2
|
-
//# sourceMappingURL=FileUploader-
|
|
1
|
+
"use strict";const t=require("react/jsx-runtime"),d=require("react"),L=require("clsx"),V=require("@dnd-kit/core"),ae=require("@dnd-kit/sortable"),Et=require("@dnd-kit/utilities"),kt=require("@formkit/auto-animate/react"),Rt=require("react-dropzone"),zt=require("./formContext-bTWrqdEV.cjs"),Ve=require("./toastStore-B4Tk2Xk7.cjs"),M=require("./Icon-BUP5_kRs.cjs"),Ft=require("./Skeleton-DK0lAjS9.cjs"),ie=require("./Typography-d97DdbNd.cjs"),Dt=require("react-image-crop"),Ge=require("./Button-Cm64ROip.cjs"),Ye=require("./Modal-eI6QL-LM.cjs"),Ct=require("./TextField-D49Lpbjt.cjs"),ce=require("./ConfigProvider-th4GYhcU.cjs"),Ie=require("./TextField.module-DsNCo8vN.cjs"),Mt="_cropSection_1j2zs_4",Pt="_cropHead_1j2zs_10",qt="_cropStage_1j2zs_16",Lt="_crop_1j2zs_4",Bt="_cropImg_1j2zs_30",$t="_altFields_1j2zs_35",Q={cropSection:Mt,cropHead:Pt,cropStage:qt,crop:Lt,cropImg:Bt,altFields:$t};function Ot({mode:n,name:o,imageUrl:l,mimeType:p,editLocales:S,initialDraft:w,onClose:N,onSave:P}){const h=ce.useT(),z=d.useRef(null),[_,B]=d.useState(),[i,$]=d.useState(null),[O,G]=d.useState(null),[Y,A]=d.useState(w),[W,X]=d.useState(null),[E,T]=d.useState(!1),Z=(c,y)=>{B(y);const g=z.current;if(g&&g.width>0&&c.width>=1&&c.height>=1){const k=g.naturalWidth/g.width,q=g.naturalHeight/g.height;$({x:Math.round(c.x*k),y:Math.round(c.y*q),width:Math.round(c.width*k),height:Math.round(c.height*q)})}else $(null)},U=async()=>{const c=z.current;if(!c||!i||i.width<1||i.height<1)return;const y=document.createElement("canvas");y.width=i.width,y.height=i.height;const g=y.getContext("2d");if(!g)return;g.imageSmoothingEnabled=!1,g.drawImage(c,i.x,i.y,i.width,i.height,0,0,i.width,i.height);const k=await new Promise(q=>y.toBlob(q,p,1));if(!k)throw new Error("canvas.toBlob returned null");return new File([k],o,{type:p,lastModified:Date.now()})},J=async()=>{if(n==="altText"){P({draft:Y});return}T(!0);try{const c=i&&i.width>=1&&i.height>=1?await U():void 0;P({croppedFile:c})}catch{X(h("fileUploader.cropError")),T(!1)}};return t.jsx(Ye.Modal,{open:!0,onClose:N,size:n==="crop"?"lg":"sm",icon:n==="crop"?"Crop":"Text",title:h(n==="crop"?"fileUploader.cropTitle":"fileUploader.altTitle"),description:o,footer:t.jsxs(t.Fragment,{children:[t.jsx(Ge.Button,{variant:"text",color:"accent",size:"sm",onClick:N,disabled:E,children:h("common.cancel")}),t.jsx(Ge.Button,{size:"sm",onClick:J,loading:E,children:h("common.save")})]}),children:n==="crop"?t.jsxs("div",{className:Q.cropSection,children:[t.jsxs("div",{className:Q.cropHead,children:[t.jsx(ie.Typography,{variant:"bodySmall",color:"muted",children:h("fileUploader.cropHint")}),t.jsx(ie.Typography,{variant:"bodySmall",color:i?"text":"muted",children:i?`${i.width} × ${i.height} px`:O?`${O.w} × ${O.h} px`:""})]}),t.jsx("div",{className:Q.cropStage,children:t.jsx(Dt,{crop:_,onChange:Z,className:Q.crop,children:t.jsx("img",{ref:z,src:l??void 0,alt:"",className:Q.cropImg,onLoad:c=>G({w:c.currentTarget.naturalWidth,h:c.currentTarget.naturalHeight})})})}),W&&t.jsx(ie.Typography,{variant:"bodySmall",color:"error",children:W})]}):t.jsx("div",{className:Q.altFields,children:S.map(c=>t.jsx(Ct.TextField,{label:c.label??(c.code||h("fileUploader.altTitle")),placeholder:h("fileUploader.altPlaceholder"),value:Y[c.code]??"",onChange:y=>A(g=>({...g,[c.code]:y.target.value}))},c.code))})})}const At="_backdrop_uqdv2_5",Wt="_media_uqdv2_9",Ht="_mediaSvg_uqdv2_19",Kt="_close_uqdv2_27",re={backdrop:At,media:Wt,mediaSvg:Ht,close:Kt};function Vt({url:n,isVideo:o,isSvg:l,name:p,onClose:S}){const w=ce.useT();return t.jsxs(Ye.Overlay,{open:!0,onClose:S,dim:.85,className:re.backdrop,role:"dialog","aria-modal":"true","aria-label":w("fileUploader.preview",{name:p}),children:[t.jsx("button",{type:"button",className:re.close,"aria-label":w("fileUploader.closePreview"),onClick:S,autoFocus:!0,children:t.jsx(M.Icon,{name:"Close",size:"lg"})}),o?t.jsx("video",{src:n,className:re.media,controls:!0,playsInline:!0}):t.jsx("img",{src:n,alt:p,className:L.clsx(re.media,l&&re.mediaSvg)})]})}const Gt="_root_m8xag_4",Yt="_fullWidth_m8xag_9",Jt="_disabled_m8xag_14",Qt="_dropzone_m8xag_17",Xt="_dropText_m8xag_41",Zt="_dropping_m8xag_56",eo="_error_m8xag_61",to="_dropIcon_m8xag_65",oo="_prompt_m8xag_77",no="_accent_m8xag_82",so="_hint_m8xag_87",ro="_list_m8xag_93",ao="_populated_m8xag_103",lo="_tile_m8xag_121",io="_grabbable_m8xag_130",co="_entering_m8xag_139",uo="_dragging_m8xag_142",fo="_tileError_m8xag_148",po="_tileImg_m8xag_153",go="_tileImgPending_m8xag_161",mo="_tileSkeleton_m8xag_164",ho="_tileFallback_m8xag_169",xo="_tilePlay_m8xag_179",_o="_tileTop_m8xag_198",bo="_tileBottom_m8xag_208",yo="_tileRemove_m8xag_218",vo="_tileAction_m8xag_219",jo="_tileActionEnd_m8xag_254",So="_tileText_m8xag_257",To="_name_m8xag_264",Uo="_nameBase_m8xag_271",Io="_nameExt_m8xag_277",wo="_tileMeta_m8xag_281",No="_metaError_m8xag_285",r={root:Gt,fullWidth:Yt,disabled:Jt,dropzone:Qt,dropText:Xt,dropping:Zt,error:eo,dropIcon:to,prompt:oo,accent:no,hint:so,list:ro,populated:ao,tile:lo,grabbable:io,entering:co,dragging:uo,tileError:fo,tileImg:po,tileImgPending:go,tileSkeleton:mo,tileFallback:ho,tilePlay:xo,tileTop:_o,tileBottom:bo,tileRemove:yo,tileAction:vo,tileActionEnd:jo,tileText:So,name:To,nameBase:Uo,nameExt:Io,tileMeta:wo,metaError:No},Je=()=>typeof URL<"u"&&typeof URL.createObjectURL=="function",Eo=300,ko=(n,o,l,p)=>{let S=[{},{}],w=Eo;if(o==="add")w=0;else if(o==="remove")S=[{opacity:1,transform:"translateY(0)"},{opacity:0,transform:"translateY(-8px)"}];else if(l&&p){const N=l.left-p.left,P=l.top-p.top;S=[{transform:`translate(${N}px, ${P}px)`},{transform:"translate(0, 0)"}]}return new KeyframeEffect(n,S,{duration:w,easing:"ease-out"})},le=n=>{if(n<1024)return`${n} B`;const o=["KB","MB","GB","TB"];let l=n/1024,p=0;for(;l>=1024&&p<o.length-1;)l/=1024,p+=1;return`${l.toFixed(l<10?1:0)} ${o[p]}`},Ro=n=>{if(typeof n=="number")return n;const o=/^\s*([\d.]+)\s*(b|kb|mb|gb|tb)?\s*$/i.exec(n);if(!o)return;const l={b:1,kb:1024,mb:1024**2,gb:1024**3,tb:1024**4};return parseFloat(o[1])*(l[(o[2]||"b").toLowerCase()]??1)},Qe=n=>`f:${n.name}:${n.size}:${n.lastModified}`,zo=n=>n.file?Qe(n.file):`s:${n.source??""}`,me=n=>n.file?n.file.name:n.source?/^(data|blob):/i.test(n.source)?"File":n.source.split(/[?#]/)[0].split("/").pop()||"File":"File",we=n=>{if(n.file)return n.file.type.startsWith("image/");const o=n.source;return o?/^data:image\//i.test(o)?!0:/^data:/i.test(o)?!1:/\.(png|jpe?g|gif|webp|avif|svg|bmp|ico|heic|heif)(?:[?#]|$)/i.test(o)||!/\.[a-z0-9]{1,8}(?:[?#]|$)/i.test(o):!1},Ne=n=>{if(n.file)return n.file.type.startsWith("video/");const o=n.source;return o?/^data:video\//i.test(o)||/\.(mp4|webm|ogg|ogv|mov|m4v|avi|mkv)(?:[?#]|$)/i.test(o):!1},Fo=n=>{if(typeof document>"u")return;const o=document.createElement("a");if(o.style.display="none",n.file){if(!Je())return;const l=URL.createObjectURL(n.file);o.href=l,o.download=n.file.name,document.body.appendChild(o),o.click(),o.remove(),setTimeout(()=>URL.revokeObjectURL(l),1e3)}else n.source&&(o.href=n.source,o.download=me(n),o.target="_blank",o.rel="noopener",document.body.appendChild(o),o.click(),o.remove())},Do=n=>{const o=n.lastIndexOf(".");return o>0&&n.length-o<=7?{base:n.slice(0,o),ext:n.slice(o)}:{base:n,ext:""}};function Co({id:n,item:o,preview:l,sortable:p,entering:S,disabled:w,error:N,onRemove:P,onCrop:h,onAltText:z,onDownload:_,onView:B,onPreviewError:i}){const{attributes:$,listeners:O,setNodeRef:G,transform:Y,transition:A,isDragging:W}=ae.useSortable({id:n,disabled:!p}),X={transform:Et.CSS.Transform.toString(Y),transition:A},E=ce.useT(),T=me(o),{base:Z,ext:U}=Do(T),[J,c]=d.useState(()=>!l||l.startsWith("blob:")),y=d.useRef(l);y.current!==l&&(y.current=l,c(!l||l.startsWith("blob:")));const g=d.useRef(null);d.useEffect(()=>{const m=g.current;m!=null&&m.complete&&m.naturalWidth>0&&c(!0)},[l]);const k=()=>{c(!0),i==null||i()},q=o.file?le(o.file.size):E("fileUploader.uploaded"),he=Ne(o),de=_?t.jsx("button",{type:"button",className:r.tileAction,"aria-label":E("fileUploader.download",{name:T}),onClick:_,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"DocumentDownload",size:"sm"})}):null;return t.jsxs("div",{ref:G,style:X,className:L.clsx(r.tile,p&&r.grabbable,S&&r.entering,W&&r.dragging,N&&r.tileError),...$,...O,children:[l&&!J&&t.jsx(Ft.Skeleton,{variant:"rect",width:"100%",height:"100%",className:r.tileSkeleton}),l?he?t.jsxs(t.Fragment,{children:[t.jsx("video",{src:l,className:r.tileImg,muted:!0,playsInline:!0,preload:"metadata",draggable:!1,onLoadedData:()=>c(!0),onError:k}),t.jsx("span",{className:r.tilePlay,"aria-hidden":"true",children:t.jsx(M.Icon,{name:"Play",size:"lg"})})]}):t.jsx("img",{ref:g,src:l,alt:"",className:L.clsx(r.tileImg,!J&&r.tileImgPending),draggable:!1,onLoad:()=>c(!0),onError:k}):t.jsx("span",{className:r.tileFallback,"aria-hidden":"true",children:t.jsx(M.Icon,{name:"Document",size:"lg"})}),t.jsxs("div",{className:r.tileTop,children:[t.jsxs("span",{className:r.tileText,children:[t.jsxs("span",{className:r.name,title:T,children:[t.jsx("span",{className:r.nameBase,children:Z}),U&&t.jsx("span",{className:r.nameExt,children:U})]}),t.jsx("span",{className:L.clsx(r.tileMeta,N&&r.metaError),children:N??q})]}),!w&&t.jsx("button",{type:"button",className:r.tileRemove,"aria-label":E("fileUploader.remove",{name:T}),onClick:P,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"Close",size:"sm"})})]}),(h||z||_||B)&&t.jsxs("div",{className:r.tileBottom,children:[h&&t.jsx("button",{type:"button",className:r.tileAction,"aria-label":E("fileUploader.crop",{name:T}),onClick:h,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"Crop",size:"sm"})}),z&&t.jsx("button",{type:"button",className:r.tileAction,"aria-label":E("fileUploader.editAlt",{name:T}),onClick:z,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"Text",size:"sm"})}),de,B&&t.jsx("button",{type:"button",className:L.clsx(r.tileAction,r.tileActionEnd),"aria-label":E("fileUploader.preview",{name:T}),onClick:B,onPointerDown:m=>m.stopPropagation(),children:t.jsx(M.Icon,{name:"Eye",size:"sm"})})]})]})}const Mo=d.forwardRef(function({multiple:o=!1,allowDrop:l=!0,allowReorder:p=!0,allowDownload:S=!0,allowPreview:w=!0,allowAltText:N=!0,altTextLocales:P,localizedAltText:h=!0,allowDuplicates:z=!1,disabled:_=!1,accept:B,maxFiles:i,maxFileSize:$,itemInsertLocation:O="end",value:G,defaultValue:Y,onChange:A,label:W,error:X,helperText:E,required:T=!1,fullWidth:Z=!0,name:U,id:J,onBlur:c,className:y,style:g,...k},q){var We;const he=d.useId(),de=J??he,m=`${de}-helper`,F=$!=null?Ro($):void 0,[ue,xe]=d.useState(null);d.useEffect(()=>{if(!ue)return;const e=window.setTimeout(()=>xe(null),4e3);return()=>window.clearTimeout(e)},[ue]);const ee=zt.useFormContext(),Ee=!!(ee&&U),D=ee&&U?ee.field(U):void 0,ke=o?[]:null,Re=G!==void 0?G:Ee?ee.values[U]??ke:void 0,ze=Re!==void 0,[Xe,Ze]=d.useState(Y??ke),te=ze?Re:Xe,x=te==null?[]:Array.isArray(te)?te:[te],_e=X??(D==null?void 0:D.error)??!1,et=E??(D==null?void 0:D.helperText),be=ue??et,tt=!!ue||_e,fe=p&&o&&!_,Fe=d.useRef(new WeakMap),De=d.useRef(0),ot=(e,s)=>{if(e.file){let a=Fe.current.get(e.file);return a||(De.current+=1,a=`f${De.current}`,Fe.current.set(e.file,a)),a}return e.source?`s:${e.source}`:`i:${s}`},I=x.map((e,s)=>ot(e,s)),Ce=d.useRef(new Set),nt=new Set(I.filter(e=>!Ce.current.has(e)));d.useEffect(()=>{Ce.current=new Set(I)});const[st,Me]=d.useState(()=>new Set),rt=e=>Me(s=>s.has(e)?s:new Set(s).add(e)),[at,lt]=d.useState(()=>new Set),it=e=>lt(s=>s.has(e)?s:new Set(s).add(e)),pe=d.useRef(new Map),ge=e=>{if(e.file){const s=e.file.type;if(!s.startsWith("image/")&&!s.startsWith("video/")||!Je()||at.has(e.file))return null;let a=pe.current.get(e.file);return a||(a=URL.createObjectURL(e.file),pe.current.set(e.file,a)),a}return e.source&&!st.has(e.source)?e.source:null},[C,Pe]=d.useState(null);d.useEffect(()=>{const e=pe.current,s=new Set(x.map(u=>u.file).filter(Boolean)),a=new Set(x.filter(u=>!u.file&&u.source).map(u=>u.source));for(const[u,f]of e)!s.has(u)&&f!==(C==null?void 0:C.url)&&(URL.revokeObjectURL(f),e.delete(u));Me(u=>{if(u.size===0)return u;const f=new Set([...u].filter(v=>a.has(v)));return f.size===u.size?u:f})},[te,C]),d.useEffect(()=>{const e=pe.current;return()=>{for(const s of e.values())URL.revokeObjectURL(s);e.clear()}},[]);const ct=e=>e.map((s,a)=>s.sortIndex===a?s:{...s,sortIndex:a}),oe=e=>{const s=ct(e),a=o?s:s[0]??null;ze||Ze(a),Ee&&ee.setValue(U,a),A==null||A(a)},ye=()=>D==null?void 0:D.onBlur({}),b=ce.useT(),dt=ce.useLocales(),qe=P??dt,ut=h&&qe.length>0?qe:[{code:""}],[ne,ve]=d.useState(null),[Le,Be]=d.useState("altText"),je=ne!=null?I.indexOf(ne):-1,R=je!==-1?x[je]:null,ft=e=>{Be("crop"),ve(I[e]??null)},pt=e=>{Be("altText"),ve(I[e]??null)},Se=()=>ve(null),gt=e=>{const s=ge(e);if(!s)return;const a=e.file?e.file.type==="image/svg+xml":/^data:image\/svg/i.test(e.source??"")||/\.svg(?:[?#]|$)/i.test(e.source??"");Pe({url:s,isVideo:Ne(e),isSvg:a,name:me(e)})},mt=R?h?R.altText&&typeof R.altText=="object"?{...R.altText}:{}:{"":typeof R.altText=="string"?R.altText:""}:{},ht=({draft:e,croppedFile:s})=>{if(je===-1)return Se();oe(x.map((a,u)=>{if(I[u]!==ne)return a;const f={...a};if(e!==void 0)if(h){const v=Object.fromEntries(Object.entries(e).map(([H,j])=>[H,j.trim()]).filter(([,H])=>H!==""));f.altText=Object.keys(v).length>0?v:void 0}else f.altText=(e[""]??"").trim()||void 0;return s&&(f.file=s,f.source=""),f})),Se()},xt=(e,s=[])=>{const a=s.filter(j=>j.errors.some(K=>K.code==="file-invalid-type")),u=s.filter(j=>j.errors.some(K=>K.code==="file-too-large"));a.length>0&&Ve.toast.error(a.length===1?b("fileUploader.wrongTypeOne",{name:a[0].file.name}):b("fileUploader.wrongTypeMany",{count:a.length})),u.length>0&&F!=null&&Ve.toast.error(u.length===1?b("fileUploader.tooLargeOne",{name:u[0].file.name,size:le(F)}):b("fileUploader.tooLargeMany",{count:u.length,size:le(F)}));const f=[];let v=e;if(o&&!z){const j=new Set(x.map(zo)),K=[];for(const He of v){const Ke=Qe(He);j.has(Ke)||(j.add(Ke),K.push(He))}K.length<v.length&&f.push(b("fileUploader.duplicate")),v=K}if(o&&i!=null){const j=Math.max(0,i-x.length);v.length>j&&(v=v.slice(0,j),f.push(i===1?b("fileUploader.hintUpToOne",{count:i}):b("fileUploader.hintUpToMany",{count:i})))}if(xe(f.length>0?f.join(" · "):null),v.length===0)return;const H=v.map(j=>({file:j,source:"",sortIndex:0}));if(!o){oe([H[0]]);return}oe(O==="start"?[...H,...x]:[...x,...H])},_t=e=>{xe(null),oe(x.filter((s,a)=>a!==e)),ye()},[bt,Te]=kt.useAutoAnimate(ko),$e=()=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>Te(!0)):Te(!0)},yt=()=>Te(!1),vt=()=>$e(),jt=e=>{const{active:s,over:a}=e;if(a&&s.id!==a.id){const u=I.indexOf(String(s.id)),f=I.indexOf(String(a.id));u!==-1&&f!==-1&&oe(ae.arrayMove(x,u,f))}$e()},St=V.useSensors(V.useSensor(V.PointerSensor,{activationConstraint:{distance:5}}),V.useSensor(V.KeyboardSensor,{coordinateGetter:ae.sortableKeyboardCoordinates})),se=d.useRef(!1),{getRootProps:Tt,getInputProps:Ut,isDragActive:It}=Rt.useDropzone({multiple:o,accept:B,maxSize:F,disabled:_,noKeyboard:!1,noDrag:!l,onFileDialogOpen:()=>{se.current=!0},onFileDialogCancel:()=>{se.current=!1,ye()},onDrop:(e,s)=>{se.current=!1,xt(e,s)}}),Oe=o||x.length===0,Ue=[];o&&i!=null&&Ue.push(i===1?b("fileUploader.hintUpToOne",{count:i}):b("fileUploader.hintUpToMany",{count:i})),F!=null&&Ue.push(b("fileUploader.hintMax",{size:le(F)}));const Ae=Ue.join(" · "),wt=l?t.jsxs(t.Fragment,{children:[t.jsx("span",{className:r.accent,children:b("fileUploader.choose")})," ",b("fileUploader.dropSuffix")]}):t.jsx("span",{className:r.accent,children:b("fileUploader.choose")}),Nt=e=>{if(c==null||c(e),!e.currentTarget.contains(e.relatedTarget)&&ne==null){if(se.current){se.current=!1;return}ye()}};return t.jsxs("div",{ref:q,id:de,className:L.clsx(r.root,Z&&r.fullWidth,_e&&r.error,_&&r.disabled,y),style:g,"aria-invalid":_e||void 0,"aria-describedby":be!=null?m:void 0,onBlur:Nt,...k,...U?{name:U,tabIndex:-1}:{},children:[W!=null&&t.jsxs("label",{className:Ie.fieldStyles.label,children:[t.jsx(ie.Typography,{as:"span",variant:"bodySmall",color:"muted",children:W}),T&&t.jsx("span",{className:Ie.fieldStyles.required,"aria-hidden":"true",children:"*"})]}),Oe&&t.jsxs("div",{...Tt({className:L.clsx(r.dropzone,It&&r.dropping)}),children:[t.jsx("input",{...Ut()}),t.jsx("span",{className:r.dropIcon,"aria-hidden":"true",children:t.jsx(M.Icon,{name:"DocumentUpload",size:"lg"})}),t.jsxs("span",{className:r.dropText,children:[t.jsx("span",{className:r.prompt,children:wt}),Ae&&t.jsx("span",{className:r.hint,children:Ae})]})]}),t.jsx(V.DndContext,{sensors:St,collisionDetection:V.closestCenter,onDragStart:fe?yt:void 0,onDragEnd:fe?jt:void 0,onDragCancel:fe?vt:void 0,children:t.jsx(ae.SortableContext,{items:I,strategy:ae.rectSortingStrategy,children:t.jsx("div",{ref:bt,className:L.clsx(r.list,Oe&&x.length>0&&r.populated),children:x.map((e,s)=>t.jsx(Co,{id:I[s],item:e,preview:ge(e),sortable:fe&&x.length>1,entering:nt.has(I[s]),disabled:_,error:e.file&&F!=null&&e.file.size>F?b("fileUploader.exceedsLimit",{size:le(F)}):void 0,onRemove:()=>_t(s),onCrop:N&&!_&&we(e)?()=>ft(s):void 0,onAltText:N&&!_&&we(e)?()=>pt(s):void 0,onDownload:S&&!_?()=>Fo(e):void 0,onView:w&&!_&&ge(e)!=null&&(we(e)||Ne(e))?()=>gt(e):void 0,onPreviewError:e.file?()=>it(e.file):e.source?()=>rt(e.source):void 0},I[s]))})})}),be!=null&&t.jsx(ie.Typography,{as:"span",id:m,variant:"bodySmall",color:tt?"error":"muted",className:Ie.fieldStyles.helper,role:"status","aria-live":"polite",children:be}),R&&t.jsx(Ot,{mode:Le,name:me(R),imageUrl:ge(R),mimeType:((We=R.file)==null?void 0:We.type)||"image/png",editLocales:ut,initialDraft:mt,onClose:Se,onSave:ht},`${ne}:${Le}`),C&&t.jsx(Vt,{url:C.url,isVideo:C.isVideo,isSvg:C.isSvg,name:C.name,onClose:()=>Pe(null)})]})});exports.FileUploader=Mo;
|
|
2
|
+
//# sourceMappingURL=FileUploader-B--hPV3b.cjs.map
|