@techzyapp/ui-library 1.0.31 → 1.0.32
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-BYkmCGNx.js → AdminRoot-B9A4Hoz0.js} +5 -5
- package/dist/{AdminRoot-BYkmCGNx.js.map → AdminRoot-B9A4Hoz0.js.map} +1 -1
- package/dist/{AdminRoot-BbkfFQEn.cjs → AdminRoot-BVUEWczU.cjs} +2 -2
- package/dist/{AdminRoot-BbkfFQEn.cjs.map → AdminRoot-BVUEWczU.cjs.map} +1 -1
- package/dist/{Alert-BLqAcEoT.js → Alert-B7w9xD2p.js} +3 -3
- package/dist/{Alert-BLqAcEoT.js.map → Alert-B7w9xD2p.js.map} +1 -1
- package/dist/{Alert-BM5WOI_u.cjs → Alert-B9l1VhIr.cjs} +2 -2
- package/dist/{Alert-BM5WOI_u.cjs.map → Alert-B9l1VhIr.cjs.map} +1 -1
- package/dist/{Breadcrumbs-Di4-Acfb.cjs → Breadcrumbs-B1JMwCjO.cjs} +2 -2
- package/dist/{Breadcrumbs-Di4-Acfb.cjs.map → Breadcrumbs-B1JMwCjO.cjs.map} +1 -1
- package/dist/{Breadcrumbs-CzHGbN2c.js → Breadcrumbs-Cl1CgKkk.js} +3 -3
- package/dist/{Breadcrumbs-CzHGbN2c.js.map → Breadcrumbs-Cl1CgKkk.js.map} +1 -1
- package/dist/{Button-9Qcdkw-y.js → Button-BJ5Xd10u.js} +2 -2
- package/dist/{Button-9Qcdkw-y.js.map → Button-BJ5Xd10u.js.map} +1 -1
- package/dist/{Button-BQhiJq8e.cjs → Button-BZq1mIUH.cjs} +2 -2
- package/dist/{Button-BQhiJq8e.cjs.map → Button-BZq1mIUH.cjs.map} +1 -1
- package/dist/{Calendar-dXhLgOUH.cjs → Calendar-r-dDXWEp.cjs} +2 -2
- package/dist/{Calendar-dXhLgOUH.cjs.map → Calendar-r-dDXWEp.cjs.map} +1 -1
- package/dist/{Calendar-BB-C0qXO.js → Calendar-rRPnaU9M.js} +3 -3
- package/dist/{Calendar-BB-C0qXO.js.map → Calendar-rRPnaU9M.js.map} +1 -1
- package/dist/{Card-BERQfyhJ.js → Card-Cr3D2bzJ.js} +2 -2
- package/dist/{Card-BERQfyhJ.js.map → Card-Cr3D2bzJ.js.map} +1 -1
- package/dist/{Card-DULpoOfj.cjs → Card-KsczbH5c.cjs} +2 -2
- package/dist/{Card-DULpoOfj.cjs.map → Card-KsczbH5c.cjs.map} +1 -1
- package/dist/{Chip-BuydTI6V.cjs → Chip-BZ3I4Lbe.cjs} +2 -2
- package/dist/{Chip-BuydTI6V.cjs.map → Chip-BZ3I4Lbe.cjs.map} +1 -1
- package/dist/{Chip-DZ5Fz7jx.js → Chip-DEp1zWh1.js} +2 -2
- package/dist/{Chip-DZ5Fz7jx.js.map → Chip-DEp1zWh1.js.map} +1 -1
- package/dist/{CodeBlock-BySsTAtY.js → CodeBlock-CMHqvoBJ.js} +3 -3
- package/dist/{CodeBlock-BySsTAtY.js.map → CodeBlock-CMHqvoBJ.js.map} +1 -1
- package/dist/{CodeBlock-BPraYPoS.cjs → CodeBlock-DIkyeG4S.cjs} +2 -2
- package/dist/{CodeBlock-BPraYPoS.cjs.map → CodeBlock-DIkyeG4S.cjs.map} +1 -1
- package/dist/{ColorPicker-DJow7m2v.js → ColorPicker-5SMyU5oh.js} +3 -3
- package/dist/{ColorPicker-DJow7m2v.js.map → ColorPicker-5SMyU5oh.js.map} +1 -1
- package/dist/{ColorPicker-BTBTQD39.cjs → ColorPicker-B1riGs1z.cjs} +2 -2
- package/dist/{ColorPicker-BTBTQD39.cjs.map → ColorPicker-B1riGs1z.cjs.map} +1 -1
- package/dist/{ColorPickerPanel-D6agWM6y.js → ColorPickerPanel-4Y6oXL7v.js} +2 -2
- package/dist/{ColorPickerPanel-D6agWM6y.js.map → ColorPickerPanel-4Y6oXL7v.js.map} +1 -1
- package/dist/{ColorPickerPanel-DXIYwUoE.cjs → ColorPickerPanel-CzBlh0zw.cjs} +2 -2
- package/dist/{ColorPickerPanel-DXIYwUoE.cjs.map → ColorPickerPanel-CzBlh0zw.cjs.map} +1 -1
- package/dist/{ColorRamp-B45Rtwgw.cjs → ColorRamp-D_h-hp7n.cjs} +2 -2
- package/dist/{ColorRamp-B45Rtwgw.cjs.map → ColorRamp-D_h-hp7n.cjs.map} +1 -1
- package/dist/{ColorRamp-Bhj28c_6.js → ColorRamp-Qc8ZtPDh.js} +2 -2
- package/dist/{ColorRamp-Bhj28c_6.js.map → ColorRamp-Qc8ZtPDh.js.map} +1 -1
- package/dist/ConfigProvider-CzAQf_d_.cjs +2 -0
- package/dist/ConfigProvider-CzAQf_d_.cjs.map +1 -0
- package/dist/ConfigProvider-D2svpXFu.js +347 -0
- package/dist/ConfigProvider-D2svpXFu.js.map +1 -0
- package/dist/{CopyButton-CBk85MQ7.js → CopyButton-BNcW9-KU.js} +3 -3
- package/dist/{CopyButton-CBk85MQ7.js.map → CopyButton-BNcW9-KU.js.map} +1 -1
- package/dist/{CopyButton-Bfte6TJF.cjs → CopyButton-DUtx2-Gi.cjs} +2 -2
- package/dist/{CopyButton-Bfte6TJF.cjs.map → CopyButton-DUtx2-Gi.cjs.map} +1 -1
- package/dist/{DatePicker-eAzDnO2Y.js → DatePicker-D2PyGdec.js} +4 -4
- package/dist/{DatePicker-eAzDnO2Y.js.map → DatePicker-D2PyGdec.js.map} +1 -1
- package/dist/{DatePicker-DBiU4Mb6.cjs → DatePicker-D_PqDvKt.cjs} +2 -2
- package/dist/{DatePicker-DBiU4Mb6.cjs.map → DatePicker-D_PqDvKt.cjs.map} +1 -1
- package/dist/{DateTimePicker-CvaD8IkF.cjs → DateTimePicker-C3Kq5hKE.cjs} +2 -2
- package/dist/{DateTimePicker-CvaD8IkF.cjs.map → DateTimePicker-C3Kq5hKE.cjs.map} +1 -1
- package/dist/{DateTimePicker-M2UBjFVc.js → DateTimePicker-DdXFzqO_.js} +7 -7
- package/dist/{DateTimePicker-M2UBjFVc.js.map → DateTimePicker-DdXFzqO_.js.map} +1 -1
- package/dist/{DescriptionList-DQHNOTWl.cjs → DescriptionList-C7AOcw_2.cjs} +2 -2
- package/dist/{DescriptionList-DQHNOTWl.cjs.map → DescriptionList-C7AOcw_2.cjs.map} +1 -1
- package/dist/{DescriptionList-BhsmdtS1.js → DescriptionList-DxRgKNEJ.js} +4 -4
- package/dist/{DescriptionList-BhsmdtS1.js.map → DescriptionList-DxRgKNEJ.js.map} +1 -1
- package/dist/{Dropdown-BbaU1WDC.cjs → Dropdown-CMqWq6J_.cjs} +2 -2
- package/dist/{Dropdown-BbaU1WDC.cjs.map → Dropdown-CMqWq6J_.cjs.map} +1 -1
- package/dist/{Dropdown-BlmbYp1X.js → Dropdown-zlv96RLy.js} +2 -2
- package/dist/{Dropdown-BlmbYp1X.js.map → Dropdown-zlv96RLy.js.map} +1 -1
- package/dist/{EmptyState-2pA3XlOX.js → EmptyState-CvpKSYY4.js} +2 -2
- package/dist/{EmptyState-2pA3XlOX.js.map → EmptyState-CvpKSYY4.js.map} +1 -1
- package/dist/{EmptyState-ByBpy2vN.cjs → EmptyState-ECc6e_En.cjs} +2 -2
- package/dist/{EmptyState-ByBpy2vN.cjs.map → EmptyState-ECc6e_En.cjs.map} +1 -1
- package/dist/{ErrorBoundary-B-37hGZW.js → ErrorBoundary-CJx5E9wJ.js} +5 -5
- package/dist/{ErrorBoundary-B-37hGZW.js.map → ErrorBoundary-CJx5E9wJ.js.map} +1 -1
- package/dist/{ErrorBoundary-gRGxeuM1.cjs → ErrorBoundary-DbKRtdgS.cjs} +2 -2
- package/dist/{ErrorBoundary-gRGxeuM1.cjs.map → ErrorBoundary-DbKRtdgS.cjs.map} +1 -1
- package/dist/{FileCard-BYNJVmp0.cjs → FileCard-Bjqsgi7S.cjs} +2 -2
- package/dist/{FileCard-BYNJVmp0.cjs.map → FileCard-Bjqsgi7S.cjs.map} +1 -1
- package/dist/{FileCard-BNfUAgsF.js → FileCard-D4t0-ms2.js} +3 -3
- package/dist/{FileCard-BNfUAgsF.js.map → FileCard-D4t0-ms2.js.map} +1 -1
- package/dist/{FileUploader-DdICa5UC.cjs → FileUploader-DWM8WrY6.cjs} +2 -2
- package/dist/{FileUploader-DdICa5UC.cjs.map → FileUploader-DWM8WrY6.cjs.map} +1 -1
- package/dist/{FileUploader-TOWwDOSS.js → FileUploader-DdcvZoUb.js} +5 -5
- package/dist/{FileUploader-TOWwDOSS.js.map → FileUploader-DdcvZoUb.js.map} +1 -1
- package/dist/{Flag-DDR6OANA.js → Flag-BLEBMdb-.js} +2 -2
- package/dist/{Flag-DDR6OANA.js.map → Flag-BLEBMdb-.js.map} +1 -1
- package/dist/{Flag-DXPQ2t8z.cjs → Flag-D5rqScYG.cjs} +2 -2
- package/dist/{Flag-DXPQ2t8z.cjs.map → Flag-D5rqScYG.cjs.map} +1 -1
- package/dist/{FullscreenToggle-BKo1lDSE.cjs → FullscreenToggle-CZoc5pYg.cjs} +2 -2
- package/dist/{FullscreenToggle-BKo1lDSE.cjs.map → FullscreenToggle-CZoc5pYg.cjs.map} +1 -1
- package/dist/{FullscreenToggle-DmH1541W.js → FullscreenToggle-DZnKK1Lj.js} +3 -3
- package/dist/{FullscreenToggle-DmH1541W.js.map → FullscreenToggle-DZnKK1Lj.js.map} +1 -1
- package/dist/{IconButton-CL_6iMQh.js → IconButton-CqFgam3J.js} +2 -2
- package/dist/{IconButton-CL_6iMQh.js.map → IconButton-CqFgam3J.js.map} +1 -1
- package/dist/{IconButton-CvIXSFsr.cjs → IconButton-V8tjArlt.cjs} +2 -2
- package/dist/{IconButton-CvIXSFsr.cjs.map → IconButton-V8tjArlt.cjs.map} +1 -1
- package/dist/List-CXHlAI5w.js +38 -0
- package/dist/List-CXHlAI5w.js.map +1 -0
- package/dist/List-DOsh6w-d.cjs +2 -0
- package/dist/List-DOsh6w-d.cjs.map +1 -0
- package/dist/ListItem-CUeIBhOF.cjs +2 -0
- package/dist/ListItem-CUeIBhOF.cjs.map +1 -0
- package/dist/ListItem-ehFB7TUW.js +77 -0
- package/dist/ListItem-ehFB7TUW.js.map +1 -0
- package/dist/{Loader-Czzb450N.js → Loader-Bsz0BkGr.js} +2 -2
- package/dist/{Loader-Czzb450N.js.map → Loader-Bsz0BkGr.js.map} +1 -1
- package/dist/{Loader-CI1j71X8.cjs → Loader-CqRaCdzF.cjs} +2 -2
- package/dist/{Loader-CI1j71X8.cjs.map → Loader-CqRaCdzF.cjs.map} +1 -1
- package/dist/LocationPicker-BRGNcTd_.cjs +2 -0
- package/dist/LocationPicker-BRGNcTd_.cjs.map +1 -0
- package/dist/LocationPicker-DtMDpPFZ.js +781 -0
- package/dist/LocationPicker-DtMDpPFZ.js.map +1 -0
- package/dist/{Modal-DPObz0b-.cjs → Modal-CcrqM4kn.cjs} +2 -2
- package/dist/{Modal-DPObz0b-.cjs.map → Modal-CcrqM4kn.cjs.map} +1 -1
- package/dist/{Modal-DMJMw6kT.js → Modal-DCee1a9m.js} +3 -3
- package/dist/{Modal-DMJMw6kT.js.map → Modal-DCee1a9m.js.map} +1 -1
- package/dist/{MultiSelect-IDAJ5a5K.cjs → MultiSelect-BJ-qMpA5.cjs} +2 -2
- package/dist/{MultiSelect-IDAJ5a5K.cjs.map → MultiSelect-BJ-qMpA5.cjs.map} +1 -1
- package/dist/{MultiSelect-BTR6w5Ot.js → MultiSelect-JQ6iKHyI.js} +4 -4
- package/dist/{MultiSelect-BTR6w5Ot.js.map → MultiSelect-JQ6iKHyI.js.map} +1 -1
- package/dist/{NumberField-DlaW-g3Z.js → NumberField-Bf-vDNLy.js} +3 -3
- package/dist/{NumberField-DlaW-g3Z.js.map → NumberField-Bf-vDNLy.js.map} +1 -1
- package/dist/{NumberField-Cg0XEDgW.cjs → NumberField-mZjwZB8E.cjs} +2 -2
- package/dist/{NumberField-Cg0XEDgW.cjs.map → NumberField-mZjwZB8E.cjs.map} +1 -1
- package/dist/{OtpField-vxQuo-uR.js → OtpField-DaAIBp6C.js} +2 -2
- package/dist/{OtpField-vxQuo-uR.js.map → OtpField-DaAIBp6C.js.map} +1 -1
- package/dist/{OtpField-DsedK1nQ.cjs → OtpField-TdjMkgQi.cjs} +2 -2
- package/dist/{OtpField-DsedK1nQ.cjs.map → OtpField-TdjMkgQi.cjs.map} +1 -1
- package/dist/{PageLayout-BPbjTYS3.cjs → PageLayout-BoHvt2cT.cjs} +2 -2
- package/dist/{PageLayout-BPbjTYS3.cjs.map → PageLayout-BoHvt2cT.cjs.map} +1 -1
- package/dist/{PageLayout-Rk6KSxmn.js → PageLayout-Bwv8Oohb.js} +2 -2
- package/dist/{PageLayout-Rk6KSxmn.js.map → PageLayout-Bwv8Oohb.js.map} +1 -1
- package/dist/{PageNotFound-CBNhKZ9Y.js → PageNotFound-CMt8vnky.js} +5 -5
- package/dist/{PageNotFound-CBNhKZ9Y.js.map → PageNotFound-CMt8vnky.js.map} +1 -1
- package/dist/{PageNotFound-PUQ1o9R4.cjs → PageNotFound-DDm6nwQh.cjs} +2 -2
- package/dist/{PageNotFound-PUQ1o9R4.cjs.map → PageNotFound-DDm6nwQh.cjs.map} +1 -1
- package/dist/{Pagination-CNdkfXp2.js → Pagination-C0xr3D-g.js} +2 -2
- package/dist/{Pagination-CNdkfXp2.js.map → Pagination-C0xr3D-g.js.map} +1 -1
- package/dist/{Pagination-DNGKNQy0.cjs → Pagination-DzkTjEZL.cjs} +2 -2
- package/dist/{Pagination-DNGKNQy0.cjs.map → Pagination-DzkTjEZL.cjs.map} +1 -1
- package/dist/{PaletteField-BSIF5jI6.cjs → PaletteField-CQV2dll0.cjs} +2 -2
- package/dist/{PaletteField-BSIF5jI6.cjs.map → PaletteField-CQV2dll0.cjs.map} +1 -1
- package/dist/{PaletteField-Bp5Fgygh.js → PaletteField-CQv6MBKe.js} +3 -3
- package/dist/{PaletteField-Bp5Fgygh.js.map → PaletteField-CQv6MBKe.js.map} +1 -1
- package/dist/{PhoneField-BdmvslXQ.js → PhoneField-Bqj5-33G.js} +4 -4
- package/dist/{PhoneField-BdmvslXQ.js.map → PhoneField-Bqj5-33G.js.map} +1 -1
- package/dist/{PhoneField-BMhZeZkW.cjs → PhoneField-Dzdm5hfY.cjs} +2 -2
- package/dist/{PhoneField-BMhZeZkW.cjs.map → PhoneField-Dzdm5hfY.cjs.map} +1 -1
- package/dist/{Popconfirm-Cyaeybtj.js → Popconfirm-CYkwGTh-.js} +3 -3
- package/dist/{Popconfirm-Cyaeybtj.js.map → Popconfirm-CYkwGTh-.js.map} +1 -1
- package/dist/{Popconfirm-IhlIINtZ.cjs → Popconfirm-DS6tCxV0.cjs} +2 -2
- package/dist/{Popconfirm-IhlIINtZ.cjs.map → Popconfirm-DS6tCxV0.cjs.map} +1 -1
- package/dist/{Progress-T7PLrJ0Y.js → Progress-DZUtn3Sh.js} +2 -2
- package/dist/{Progress-T7PLrJ0Y.js.map → Progress-DZUtn3Sh.js.map} +1 -1
- package/dist/{Progress-CAY1p06_.cjs → Progress-lf9vIKIk.cjs} +2 -2
- package/dist/{Progress-CAY1p06_.cjs.map → Progress-lf9vIKIk.cjs.map} +1 -1
- package/dist/{QueryError-Dtspj9l4.js → QueryError-Dl8yzdxw.js} +2 -2
- package/dist/{QueryError-Dtspj9l4.js.map → QueryError-Dl8yzdxw.js.map} +1 -1
- package/dist/{QueryError-DP22IUnp.cjs → QueryError-RF7Mh5zg.cjs} +2 -2
- package/dist/{QueryError-DP22IUnp.cjs.map → QueryError-RF7Mh5zg.cjs.map} +1 -1
- package/dist/{RemoveDialog-D12B4x80.cjs → RemoveDialog-Csfhv9ve.cjs} +2 -2
- package/dist/{RemoveDialog-D12B4x80.cjs.map → RemoveDialog-Csfhv9ve.cjs.map} +1 -1
- package/dist/{RemoveDialog-DdGsqaWV.js → RemoveDialog-DaWh4xmW.js} +5 -5
- package/dist/{RemoveDialog-DdGsqaWV.js.map → RemoveDialog-DaWh4xmW.js.map} +1 -1
- package/dist/{RichTextEditor-DL4y5xVv.js → RichTextEditor-BLEDQq2H.js} +9 -9
- package/dist/{RichTextEditor-DL4y5xVv.js.map → RichTextEditor-BLEDQq2H.js.map} +1 -1
- package/dist/RichTextEditor-Eo8uLXlI.cjs +2 -0
- package/dist/{RichTextEditor-BVXY25sz.cjs.map → RichTextEditor-Eo8uLXlI.cjs.map} +1 -1
- package/dist/RootLayout-BvyeNM9_.cjs +2 -0
- package/dist/{RootLayout-DDuzPlJe.cjs.map → RootLayout-BvyeNM9_.cjs.map} +1 -1
- package/dist/{RootLayout-BK3t6Mm0.js → RootLayout-D-ZlsTXF.js} +23 -23
- package/dist/{RootLayout-BK3t6Mm0.js.map → RootLayout-D-ZlsTXF.js.map} +1 -1
- package/dist/{Select-tVI_qer3.js → Select-C0UBQXhg.js} +3 -3
- package/dist/{Select-tVI_qer3.js.map → Select-C0UBQXhg.js.map} +1 -1
- package/dist/{Select-DlFDOZtn.cjs → Select-CH3mF6y1.cjs} +2 -2
- package/dist/{Select-DlFDOZtn.cjs.map → Select-CH3mF6y1.cjs.map} +1 -1
- package/dist/{Sidebar-CjrD3nNp.js → Sidebar--rOPtrqa.js} +33 -32
- package/dist/{Sidebar-CjrD3nNp.js.map → Sidebar--rOPtrqa.js.map} +1 -1
- package/dist/Sidebar-6wu2fuPT.cjs +2 -0
- package/dist/{Sidebar-gB-X4VLX.cjs.map → Sidebar-6wu2fuPT.cjs.map} +1 -1
- package/dist/{SpeedDial-xQr4JH0x.js → SpeedDial-BIodC6td.js} +2 -2
- package/dist/{SpeedDial-xQr4JH0x.js.map → SpeedDial-BIodC6td.js.map} +1 -1
- package/dist/{SpeedDial-BIOkkLKO.cjs → SpeedDial-BtxXH6Ij.cjs} +2 -2
- package/dist/{SpeedDial-BIOkkLKO.cjs.map → SpeedDial-BtxXH6Ij.cjs.map} +1 -1
- package/dist/{Stepper-CBdhvPoz.cjs → Stepper-B38I8PBS.cjs} +2 -2
- package/dist/{Stepper-CBdhvPoz.cjs.map → Stepper-B38I8PBS.cjs.map} +1 -1
- package/dist/{Stepper-CkYcIc15.js → Stepper-CPBPTxbP.js} +13 -13
- package/dist/{Stepper-CkYcIc15.js.map → Stepper-CPBPTxbP.js.map} +1 -1
- package/dist/Table-1RVWzyS6.cjs +2 -0
- package/dist/{Table-Cwxqo7Br.cjs.map → Table-1RVWzyS6.cjs.map} +1 -1
- package/dist/{Table-CwQKfXGn.js → Table-BV-dr36o.js} +45 -45
- package/dist/{Table-CwQKfXGn.js.map → Table-BV-dr36o.js.map} +1 -1
- package/dist/{Tabs-651xbRe4.cjs → Tabs-DIs8iFA-.cjs} +2 -2
- package/dist/{Tabs-651xbRe4.cjs.map → Tabs-DIs8iFA-.cjs.map} +1 -1
- package/dist/{Tabs-Bztnezt9.js → Tabs-RjyUkLTB.js} +10 -10
- package/dist/{Tabs-Bztnezt9.js.map → Tabs-RjyUkLTB.js.map} +1 -1
- package/dist/{TagsField-CdymON69.js → TagsField-B3MtFiFs.js} +4 -4
- package/dist/{TagsField-CdymON69.js.map → TagsField-B3MtFiFs.js.map} +1 -1
- package/dist/{TagsField-B7ZARHzD.cjs → TagsField-CJ10-kFr.cjs} +2 -2
- package/dist/{TagsField-B7ZARHzD.cjs.map → TagsField-CJ10-kFr.cjs.map} +1 -1
- package/dist/{TextField-DkaYK1DI.js → TextField-CInaL0FR.js} +3 -3
- package/dist/{TextField-DkaYK1DI.js.map → TextField-CInaL0FR.js.map} +1 -1
- package/dist/{TextField-B22NRQ91.cjs → TextField-D_hzd5Gf.cjs} +2 -2
- package/dist/{TextField-B22NRQ91.cjs.map → TextField-D_hzd5Gf.cjs.map} +1 -1
- package/dist/ThemeToggle-CWfuK0tZ.js +28 -0
- package/dist/{ThemeToggle-DqzUvcK5.js.map → ThemeToggle-CWfuK0tZ.js.map} +1 -1
- package/dist/{ThemeToggle-D5dWHQFb.cjs → ThemeToggle-DkhhlH_r.cjs} +2 -2
- package/dist/{ThemeToggle-D5dWHQFb.cjs.map → ThemeToggle-DkhhlH_r.cjs.map} +1 -1
- package/dist/{TimeColumns-BEoHh961.js → TimeColumns-fD6dosYP.js} +2 -2
- package/dist/{TimeColumns-BEoHh961.js.map → TimeColumns-fD6dosYP.js.map} +1 -1
- package/dist/{TimeColumns-o2xhvSGE.cjs → TimeColumns-t3Pn01v5.cjs} +2 -2
- package/dist/{TimeColumns-o2xhvSGE.cjs.map → TimeColumns-t3Pn01v5.cjs.map} +1 -1
- package/dist/{TimePicker-CACmHwNn.cjs → TimePicker-DOwQF7sX.cjs} +2 -2
- package/dist/{TimePicker-CACmHwNn.cjs.map → TimePicker-DOwQF7sX.cjs.map} +1 -1
- package/dist/{TimePicker-DCryZCmh.js → TimePicker-DypTHDW0.js} +5 -5
- package/dist/{TimePicker-DCryZCmh.js.map → TimePicker-DypTHDW0.js.map} +1 -1
- package/dist/{Toaster-DwVLab3k.js → Toaster-BwNAKDMc.js} +2 -2
- package/dist/{Toaster-DwVLab3k.js.map → Toaster-BwNAKDMc.js.map} +1 -1
- package/dist/{Toaster-BwREV06e.cjs → Toaster-DdUOwi7L.cjs} +2 -2
- package/dist/{Toaster-BwREV06e.cjs.map → Toaster-DdUOwi7L.cjs.map} +1 -1
- package/dist/{TranslatedFields-B0LMXgiu.js → TranslatedFields-C_-qPixE.js} +13 -13
- package/dist/{TranslatedFields-B0LMXgiu.js.map → TranslatedFields-C_-qPixE.js.map} +1 -1
- package/dist/{TranslatedFields-sio1Qfy7.cjs → TranslatedFields-D9FQlxiQ.cjs} +2 -2
- package/dist/{TranslatedFields-sio1Qfy7.cjs.map → TranslatedFields-D9FQlxiQ.cjs.map} +1 -1
- package/dist/{UserCard-Dzc4zmPj.cjs → UserCard-C-q2s2Cw.cjs} +2 -2
- package/dist/{UserCard-Dzc4zmPj.cjs.map → UserCard-C-q2s2Cw.cjs.map} +1 -1
- package/dist/{UserCard-B5FVcJaK.js → UserCard-CwWv0HXD.js} +3 -3
- package/dist/{UserCard-B5FVcJaK.js.map → UserCard-CwWv0HXD.js.map} +1 -1
- package/dist/components/Alert/index.cjs +1 -1
- package/dist/components/Alert/index.js +1 -1
- package/dist/components/Breadcrumbs/index.cjs +1 -1
- package/dist/components/Breadcrumbs/index.js +1 -1
- package/dist/components/Button/index.cjs +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/Card/index.cjs +1 -1
- package/dist/components/Card/index.js +1 -1
- package/dist/components/Chip/index.cjs +1 -1
- package/dist/components/Chip/index.js +1 -1
- package/dist/components/CodeBlock/index.cjs +1 -1
- package/dist/components/CodeBlock/index.js +1 -1
- package/dist/components/ColorPicker/index.cjs +1 -1
- package/dist/components/ColorPicker/index.js +1 -1
- package/dist/components/ColorRamp/index.cjs +1 -1
- package/dist/components/ColorRamp/index.js +1 -1
- package/dist/components/CopyButton/index.cjs +1 -1
- package/dist/components/CopyButton/index.js +1 -1
- package/dist/components/DatePicker/index.cjs +1 -1
- package/dist/components/DatePicker/index.js +1 -1
- package/dist/components/DateTimePicker/index.cjs +1 -1
- package/dist/components/DateTimePicker/index.js +1 -1
- package/dist/components/DescriptionList/index.cjs +1 -1
- package/dist/components/DescriptionList/index.js +1 -1
- package/dist/components/Dropdown/index.cjs +1 -1
- package/dist/components/Dropdown/index.js +1 -1
- package/dist/components/EmptyState/index.cjs +1 -1
- package/dist/components/EmptyState/index.js +1 -1
- package/dist/components/ErrorState/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/List/index.cjs +1 -1
- package/dist/components/List/index.js +5 -4
- package/dist/components/List/index.js.map +1 -1
- package/dist/components/Loader/index.cjs +1 -1
- package/dist/components/Loader/index.js +1 -1
- package/dist/components/LocationPicker/LocationPicker.d.cts +87 -0
- package/dist/components/LocationPicker/LocationPicker.d.ts +87 -0
- package/dist/components/LocationPicker/PlaceSearch.d.cts +20 -0
- package/dist/components/LocationPicker/PlaceSearch.d.ts +20 -0
- package/dist/components/LocationPicker/googleMaps.d.cts +89 -0
- package/dist/components/LocationPicker/googleMaps.d.ts +89 -0
- package/dist/components/LocationPicker/index.cjs +2 -0
- package/dist/components/LocationPicker/index.cjs.map +1 -0
- package/dist/components/LocationPicker/index.d.cts +2 -0
- package/dist/components/LocationPicker/index.d.ts +2 -0
- package/dist/components/LocationPicker/index.js +7 -0
- package/dist/components/LocationPicker/index.js.map +1 -0
- package/dist/components/Modal/index.cjs +1 -1
- package/dist/components/Modal/index.js +1 -1
- package/dist/components/MultiSelect/index.cjs +1 -1
- package/dist/components/MultiSelect/index.js +1 -1
- package/dist/components/NumberField/index.cjs +1 -1
- package/dist/components/NumberField/index.js +1 -1
- package/dist/components/OtpField/index.cjs +1 -1
- package/dist/components/OtpField/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/RemoveDialog/index.cjs +1 -1
- package/dist/components/RemoveDialog/index.js +1 -1
- package/dist/components/RichTextEditor/index.cjs +1 -1
- package/dist/components/RichTextEditor/index.js +1 -1
- package/dist/components/RootLayout/index.cjs +1 -1
- package/dist/components/RootLayout/index.js +1 -1
- package/dist/components/Select/index.cjs +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/Sidebar/index.cjs +1 -1
- package/dist/components/Sidebar/index.js +1 -1
- package/dist/components/SpeedDial/index.cjs +1 -1
- package/dist/components/SpeedDial/index.js +1 -1
- package/dist/components/Stepper/index.cjs +1 -1
- package/dist/components/Stepper/index.js +1 -1
- package/dist/components/Table/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/UserCard/index.cjs +1 -1
- package/dist/components/UserCard/index.js +1 -1
- package/dist/components/index.d.cts +1 -0
- package/dist/components/index.d.ts +1 -0
- 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 +136 -132
- package/dist/entries/components.js.map +1 -1
- package/dist/entries/i18n.cjs +1 -1
- package/dist/entries/i18n.js +2 -2
- package/dist/entries/theme.cjs +1 -1
- package/dist/entries/theme.d.cts +2 -2
- package/dist/entries/theme.d.ts +2 -2
- package/dist/entries/theme.js +15 -13
- package/dist/i18n/messages.d.cts +42 -0
- package/dist/i18n/messages.d.ts +42 -0
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.js +238 -232
- package/dist/index.js.map +1 -1
- package/dist/{messages-DswDgGe2.js → messages-BOJsnD0O.js} +180 -33
- package/dist/messages-BOJsnD0O.js.map +1 -0
- package/dist/{messages-DS38X5W2.cjs → messages-ejfYfHwL.cjs} +9 -9
- package/dist/messages-ejfYfHwL.cjs.map +1 -0
- package/dist/theme/ConfigProvider.d.cts +22 -0
- package/dist/theme/ConfigProvider.d.ts +22 -0
- package/dist/theme/index.d.cts +2 -2
- package/dist/theme/index.d.ts +2 -2
- package/dist/useOptionMenu-8hjCTNL4.cjs +2 -0
- package/dist/{useOptionMenu-BYeSUee6.cjs.map → useOptionMenu-8hjCTNL4.cjs.map} +1 -1
- package/dist/{useOptionMenu-DtTvY9EC.js → useOptionMenu-C1wOZ9NT.js} +9 -8
- package/dist/{useOptionMenu-DtTvY9EC.js.map → useOptionMenu-C1wOZ9NT.js.map} +1 -1
- package/package.json +1 -1
- package/dist/ConfigProvider-Ct0Pe3Ku.js +0 -335
- package/dist/ConfigProvider-Ct0Pe3Ku.js.map +0 -1
- package/dist/ConfigProvider-CtpfSy1i.cjs +0 -2
- package/dist/ConfigProvider-CtpfSy1i.cjs.map +0 -1
- package/dist/List-BLPB3-B8.js +0 -107
- package/dist/List-BLPB3-B8.js.map +0 -1
- package/dist/List-ah2PNWeY.cjs +0 -2
- package/dist/List-ah2PNWeY.cjs.map +0 -1
- package/dist/RichTextEditor-BVXY25sz.cjs +0 -2
- package/dist/RootLayout-DDuzPlJe.cjs +0 -2
- package/dist/Sidebar-gB-X4VLX.cjs +0 -2
- package/dist/Table-Cwxqo7Br.cjs +0 -2
- package/dist/ThemeToggle-DqzUvcK5.js +0 -28
- package/dist/messages-DS38X5W2.cjs.map +0 -1
- package/dist/messages-DswDgGe2.js.map +0 -1
- package/dist/useOptionMenu-BYeSUee6.cjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker-DJow7m2v.js","sources":["../src/components/ColorPicker/ColorPicker.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type FocusEvent,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT } from '../../theme'\nimport { FloatingPanel } from '../FloatingPanel/FloatingPanel'\nimport { Typography } from '../Typography'\nimport { ColorPickerPanel } from './ColorPickerPanel'\nimport { formatColor, parseColor } from './colorUtils'\nimport styles from './ColorPicker.module.css'\n\nexport type ColorPickerSize = 'sm' | 'md' | 'lg'\n\n/** Popover width (px). */\nconst POPOVER_WIDTH = 232\n\nexport interface ColorPickerProps {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — control height, swatch and font. */\n size?: ColorPickerSize\n /** Marks the field invalid: red border/ring + the `helperText` in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Disables the field. */\n disabled?: boolean\n /** Controlled value — a CSS color string: `#rrggbb` hex, or `rgba(r, g, b, a)` when translucent. */\n value?: string\n /** Initial value for uncontrolled use (hex or `rgb()`/`rgba()`). */\n defaultValue?: string\n /** Fires with the next color: `#rrggbb` when opaque, `rgba(r, g, b, a)` when not (or `''` when cleared). */\n onChange?: (color: string) => void\n /** Quick-pick swatches shown in the popover. Defaults to a curated palette. */\n swatches?: string[]\n /**\n * Offer opacity. Defaults to `true`. `false` hides the alpha slider and the field only ever emits\n * `#rrggbb` (never `rgba()`) — for colors that must be opaque, e.g. brand colors.\n */\n alpha?: boolean\n /** Form field name — auto-binds to a surrounding `<Form>` (value is the hex string). */\n name?: string\n /** Placeholder shown in the trigger when no color is set. Omit to show nothing. */\n placeholder?: string\n /** Id for the trigger (label association). */\n id?: string\n className?: string\n style?: CSSProperties\n}\n\n/**\n * A color field with a beautiful popover picker: a saturation/value square, a hue slider, an alpha\n * (opacity) slider, a color input, quick-pick swatches and a clear button. The input accepts hex\n * (`#rgb`/`#rrggbb`/`#rrggbbaa`) or `rgb()`/`rgba()`, and the value comes back as `#rrggbb` when\n * fully opaque or `rgba(r, g, b, a)` when translucent. Clicking the trigger opens the popover, which\n * — like `Dropdown` — is portaled to `<body>`, opens below (flips above only when it would\n * overflow), locks page scroll and re-positions on scroll/resize. Controlled (`value` + `onChange`)\n * or uncontrolled (`defaultValue`), and binds to a surrounding `<Form>` by `name` (its form value is\n * the color string; validate with e.g. `z.string().regex(/^#[0-9a-f]{6}$/i, 'Pick a color')`, or a\n * looser pattern if you allow `rgba()`). Styling uses `--tz-*` tokens (the spectrum gradients and\n * the alpha checkerboard are the unavoidable exceptions).\n */\nexport const ColorPicker = forwardRef<HTMLButtonElement, ColorPickerProps>(function ColorPicker(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n disabled = false,\n value,\n defaultValue,\n onChange,\n swatches,\n alpha = true,\n name,\n placeholder,\n id: idProp,\n className,\n style,\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name` — the form value is the hex string.\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue: string | undefined =\n value !== undefined\n ? value\n : isFormBound\n ? ((form!.values[name!] as string | undefined) ?? '')\n : undefined\n const isControlled = externalValue !== undefined\n const [internal, setInternal] = useState<string>(defaultValue ?? '')\n const currentColor = isControlled ? externalValue! : internal\n const parsed = parseColor(currentColor || '')\n // canonical string for the value (`#rrggbb` when opaque, `rgba(...)` when not), null when unset\n const displayValue = parsed ? formatColor(parsed) : null\n // hex shows uppercase in the trigger; rgba() stays as-is\n const displayText = displayValue\n ? displayValue[0] === '#'\n ? displayValue.toUpperCase()\n : displayValue\n : null\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const commit = (color: string) => {\n if (!isControlled) setInternal(color)\n if (isFormBound) form!.setValue(name!, color)\n onChange?.(color)\n }\n\n // ── popover (positioning / scroll-lock / dismiss come from FloatingPanel) ──────────────────────\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n const popoverRef = useRef<HTMLDivElement | null>(null)\n const [open, setOpen] = useState(false)\n\n const setTriggerRef = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) (ref as { current: HTMLButtonElement | null }).current = node\n },\n [ref],\n )\n\n const closePopover = useCallback((refocus: boolean) => {\n setOpen(false)\n if (refocus) triggerRef.current?.focus()\n }, [])\n\n // mark the form field touched when focus leaves the whole widget — but not when it moves into the\n // (portaled) popover or stays on the trigger, so a form-bound picker shows its error like every\n // other popover field (Select/DatePicker) instead of only after submit\n const handleTriggerBlur = (event: FocusEvent<HTMLButtonElement>) => {\n const next = event.relatedTarget as Node | null\n if (next && (popoverRef.current?.contains(next) || triggerRef.current?.contains(next))) return\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n }\n\n return (\n <div\n className={clsx(\n styles.field,\n styles[size],\n fullWidth && styles.fullWidth,\n resolvedError && styles.error,\n disabled && styles.disabled,\n className,\n )}\n style={style}\n >\n {label != null && (\n <label htmlFor={id} className={styles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <button\n ref={setTriggerRef}\n id={id}\n name={name}\n type=\"button\"\n className={clsx(styles.control, open && styles.open)}\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n aria-label={label || parsed || placeholder ? undefined : t('colorPicker.pick')}\n onClick={() => setOpen((o) => !o)}\n onBlur={handleTriggerBlur}\n >\n <span className={clsx(styles.value, !parsed && styles.placeholder)}>\n {displayText ?? placeholder}\n </span>\n <span\n className={clsx(styles.preview, !parsed && styles.previewEmpty)}\n style={parsed ? ({ '--cp-fill': displayValue } as CSSProperties) : undefined}\n aria-hidden=\"true\"\n />\n </button>\n\n <FloatingPanel\n ref={popoverRef}\n open={open}\n triggerRef={triggerRef}\n onClose={closePopover}\n role=\"dialog\"\n ariaLabel=\"Color picker\"\n width={POPOVER_WIDTH}\n >\n <ColorPickerPanel\n value={currentColor}\n onChange={commit}\n swatches={swatches}\n alpha={alpha}\n />\n </FloatingPanel>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={styles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["POPOVER_WIDTH","ColorPicker","forwardRef","label","size","error","helperText","required","fullWidth","disabled","value","defaultValue","onChange","swatches","alpha","name","placeholder","idProp","className","style","ref","t","useT","reactId","useId","id","helperId","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","currentColor","parsed","parseColor","displayValue","formatColor","displayText","resolvedError","resolvedHelperText","commit","color","triggerRef","useRef","popoverRef","open","setOpen","setTriggerRef","useCallback","node","closePopover","refocus","_a","handleTriggerBlur","event","next","_b","jsxs","clsx","styles","jsx","Typography","o","FloatingPanel","ColorPickerPanel"],"mappings":";;;;;;;;AAsBA,MAAMA,KAAgB,KAoDTC,KAAcC,GAAgD,SACzE;AAAA,EACE,OAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,UAAAC,IAAW;AAAA,EACX,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,IAAIC;AAAA,EACJ,WAAAC;AAAA,EACA,OAAAC;AACF,GACAC,GACA;AACA,QAAMC,IAAIC,GAAA,GACJC,IAAUC,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AW,GAC9D,UAAAtB,KAAezB,EAAA,CAClB;AAAA,cACA,gBAAAgD;AAAA,gBAAC;AAAA,gBAAA;AAAA,kBACC,WAAWF,EAAKC,EAAO,SAAS,CAAC1B,KAAU0B,EAAO,YAAY;AAAA,kBAC9D,OAAO1B,IAAU,EAAE,aAAaE,MAAmC;AAAA,kBACnE,eAAY;AAAA,gBAAA;AAAA,cAAA;AAAA,YACd;AAAA,UAAA;AAAA,QAAA;AAAA,QAGF,gBAAAyB;AAAA,UAACG;AAAA,UAAA;AAAA,YACC,KAAKnB;AAAA,YACL,MAAAC;AAAA,YACA,YAAAH;AAAA,YACA,SAASQ;AAAA,YACT,MAAK;AAAA,YACL,WAAU;AAAA,YACV,OAAOtD;AAAA,YAEP,UAAA,gBAAAgE;AAAA,cAACI;AAAA,cAAA;AAAA,gBACC,OAAOhC;AAAA,gBACP,UAAUQ;AAAA,gBACV,UAAA/B;AAAA,gBACA,OAAAC;AAAA,cAAA;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,QAGD6B,KAAsB,QACrB,gBAAAqB;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,IAAG;AAAA,YACH,IAAIvC;AAAA,YACJ,SAAQ;AAAA,YACR,OAAOgB,IAAgB,UAAU;AAAA,YACjC,WAAWqB,EAAO;AAAA,YAEjB,UAAApB;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
1
|
+
{"version":3,"file":"ColorPicker-5SMyU5oh.js","sources":["../src/components/ColorPicker/ColorPicker.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type FocusEvent,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT } from '../../theme'\nimport { FloatingPanel } from '../FloatingPanel/FloatingPanel'\nimport { Typography } from '../Typography'\nimport { ColorPickerPanel } from './ColorPickerPanel'\nimport { formatColor, parseColor } from './colorUtils'\nimport styles from './ColorPicker.module.css'\n\nexport type ColorPickerSize = 'sm' | 'md' | 'lg'\n\n/** Popover width (px). */\nconst POPOVER_WIDTH = 232\n\nexport interface ColorPickerProps {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — control height, swatch and font. */\n size?: ColorPickerSize\n /** Marks the field invalid: red border/ring + the `helperText` in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Disables the field. */\n disabled?: boolean\n /** Controlled value — a CSS color string: `#rrggbb` hex, or `rgba(r, g, b, a)` when translucent. */\n value?: string\n /** Initial value for uncontrolled use (hex or `rgb()`/`rgba()`). */\n defaultValue?: string\n /** Fires with the next color: `#rrggbb` when opaque, `rgba(r, g, b, a)` when not (or `''` when cleared). */\n onChange?: (color: string) => void\n /** Quick-pick swatches shown in the popover. Defaults to a curated palette. */\n swatches?: string[]\n /**\n * Offer opacity. Defaults to `true`. `false` hides the alpha slider and the field only ever emits\n * `#rrggbb` (never `rgba()`) — for colors that must be opaque, e.g. brand colors.\n */\n alpha?: boolean\n /** Form field name — auto-binds to a surrounding `<Form>` (value is the hex string). */\n name?: string\n /** Placeholder shown in the trigger when no color is set. Omit to show nothing. */\n placeholder?: string\n /** Id for the trigger (label association). */\n id?: string\n className?: string\n style?: CSSProperties\n}\n\n/**\n * A color field with a beautiful popover picker: a saturation/value square, a hue slider, an alpha\n * (opacity) slider, a color input, quick-pick swatches and a clear button. The input accepts hex\n * (`#rgb`/`#rrggbb`/`#rrggbbaa`) or `rgb()`/`rgba()`, and the value comes back as `#rrggbb` when\n * fully opaque or `rgba(r, g, b, a)` when translucent. Clicking the trigger opens the popover, which\n * — like `Dropdown` — is portaled to `<body>`, opens below (flips above only when it would\n * overflow), locks page scroll and re-positions on scroll/resize. Controlled (`value` + `onChange`)\n * or uncontrolled (`defaultValue`), and binds to a surrounding `<Form>` by `name` (its form value is\n * the color string; validate with e.g. `z.string().regex(/^#[0-9a-f]{6}$/i, 'Pick a color')`, or a\n * looser pattern if you allow `rgba()`). Styling uses `--tz-*` tokens (the spectrum gradients and\n * the alpha checkerboard are the unavoidable exceptions).\n */\nexport const ColorPicker = forwardRef<HTMLButtonElement, ColorPickerProps>(function ColorPicker(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n disabled = false,\n value,\n defaultValue,\n onChange,\n swatches,\n alpha = true,\n name,\n placeholder,\n id: idProp,\n className,\n style,\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name` — the form value is the hex string.\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue: string | undefined =\n value !== undefined\n ? value\n : isFormBound\n ? ((form!.values[name!] as string | undefined) ?? '')\n : undefined\n const isControlled = externalValue !== undefined\n const [internal, setInternal] = useState<string>(defaultValue ?? '')\n const currentColor = isControlled ? externalValue! : internal\n const parsed = parseColor(currentColor || '')\n // canonical string for the value (`#rrggbb` when opaque, `rgba(...)` when not), null when unset\n const displayValue = parsed ? formatColor(parsed) : null\n // hex shows uppercase in the trigger; rgba() stays as-is\n const displayText = displayValue\n ? displayValue[0] === '#'\n ? displayValue.toUpperCase()\n : displayValue\n : null\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const commit = (color: string) => {\n if (!isControlled) setInternal(color)\n if (isFormBound) form!.setValue(name!, color)\n onChange?.(color)\n }\n\n // ── popover (positioning / scroll-lock / dismiss come from FloatingPanel) ──────────────────────\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n const popoverRef = useRef<HTMLDivElement | null>(null)\n const [open, setOpen] = useState(false)\n\n const setTriggerRef = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) (ref as { current: HTMLButtonElement | null }).current = node\n },\n [ref],\n )\n\n const closePopover = useCallback((refocus: boolean) => {\n setOpen(false)\n if (refocus) triggerRef.current?.focus()\n }, [])\n\n // mark the form field touched when focus leaves the whole widget — but not when it moves into the\n // (portaled) popover or stays on the trigger, so a form-bound picker shows its error like every\n // other popover field (Select/DatePicker) instead of only after submit\n const handleTriggerBlur = (event: FocusEvent<HTMLButtonElement>) => {\n const next = event.relatedTarget as Node | null\n if (next && (popoverRef.current?.contains(next) || triggerRef.current?.contains(next))) return\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n }\n\n return (\n <div\n className={clsx(\n styles.field,\n styles[size],\n fullWidth && styles.fullWidth,\n resolvedError && styles.error,\n disabled && styles.disabled,\n className,\n )}\n style={style}\n >\n {label != null && (\n <label htmlFor={id} className={styles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <button\n ref={setTriggerRef}\n id={id}\n name={name}\n type=\"button\"\n className={clsx(styles.control, open && styles.open)}\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n aria-label={label || parsed || placeholder ? undefined : t('colorPicker.pick')}\n onClick={() => setOpen((o) => !o)}\n onBlur={handleTriggerBlur}\n >\n <span className={clsx(styles.value, !parsed && styles.placeholder)}>\n {displayText ?? placeholder}\n </span>\n <span\n className={clsx(styles.preview, !parsed && styles.previewEmpty)}\n style={parsed ? ({ '--cp-fill': displayValue } as CSSProperties) : undefined}\n aria-hidden=\"true\"\n />\n </button>\n\n <FloatingPanel\n ref={popoverRef}\n open={open}\n triggerRef={triggerRef}\n onClose={closePopover}\n role=\"dialog\"\n ariaLabel=\"Color picker\"\n width={POPOVER_WIDTH}\n >\n <ColorPickerPanel\n value={currentColor}\n onChange={commit}\n swatches={swatches}\n alpha={alpha}\n />\n </FloatingPanel>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={styles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["POPOVER_WIDTH","ColorPicker","forwardRef","label","size","error","helperText","required","fullWidth","disabled","value","defaultValue","onChange","swatches","alpha","name","placeholder","idProp","className","style","ref","t","useT","reactId","useId","id","helperId","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","currentColor","parsed","parseColor","displayValue","formatColor","displayText","resolvedError","resolvedHelperText","commit","color","triggerRef","useRef","popoverRef","open","setOpen","setTriggerRef","useCallback","node","closePopover","refocus","_a","handleTriggerBlur","event","next","_b","jsxs","clsx","styles","jsx","Typography","o","FloatingPanel","ColorPickerPanel"],"mappings":";;;;;;;;AAsBA,MAAMA,KAAgB,KAoDTC,KAAcC,GAAgD,SACzE;AAAA,EACE,OAAAC;AAAA,EACA,MAAAC,IAAO;AAAA,EACP,OAAAC;AAAA,EACA,YAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,UAAAC,IAAW;AAAA,EACX,OAAAC;AAAA,EACA,cAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,MAAAC;AAAA,EACA,aAAAC;AAAA,EACA,IAAIC;AAAA,EACJ,WAAAC;AAAA,EACA,OAAAC;AACF,GACAC,GACA;AACA,QAAMC,IAAIC,GAAA,GACJC,IAAUC,GAAA,GACVC,IAAKR,KAAUM,GACfG,IAAW,GAAGD,CAAE,WAGhBE,IAAOC,GAAA,GACPC,IAAc,GAAQF,KAAQZ,IAC9Be,IAAQH,KAAQZ,IAAOY,EAAK,MAAMZ,CAAI,IAAI,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kBAC9D,OAAO1B,IAAU,EAAE,aAAaE,MAAmC;AAAA,kBACnE,eAAY;AAAA,gBAAA;AAAA,cAAA;AAAA,YACd;AAAA,UAAA;AAAA,QAAA;AAAA,QAGF,gBAAAyB;AAAA,UAACG;AAAA,UAAA;AAAA,YACC,KAAKnB;AAAA,YACL,MAAAC;AAAA,YACA,YAAAH;AAAA,YACA,SAASQ;AAAA,YACT,MAAK;AAAA,YACL,WAAU;AAAA,YACV,OAAOtD;AAAA,YAEP,UAAA,gBAAAgE;AAAA,cAACI;AAAA,cAAA;AAAA,gBACC,OAAOhC;AAAA,gBACP,UAAUQ;AAAA,gBACV,UAAA/B;AAAA,gBACA,OAAAC;AAAA,cAAA;AAAA,YAAA;AAAA,UACF;AAAA,QAAA;AAAA,QAGD6B,KAAsB,QACrB,gBAAAqB;AAAA,UAACC;AAAA,UAAA;AAAA,YACC,IAAG;AAAA,YACH,IAAIvC;AAAA,YACJ,SAAQ;AAAA,YACR,OAAOgB,IAAgB,UAAU;AAAA,YACjC,WAAWqB,EAAO;AAAA,YAEjB,UAAApB;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAIR,CAAC;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const r=require("react/jsx-runtime"),t=require("react"),p=require("clsx"),Y=require("./formContext-bTWrqdEV.cjs"),Z=require("./FloatingPanel-tGCG2nhA.cjs"),I=require("./Typography-B6ASPrzT.cjs"),e=require("./ColorPickerPanel-
|
|
2
|
-
//# sourceMappingURL=ColorPicker-
|
|
1
|
+
"use strict";const r=require("react/jsx-runtime"),t=require("react"),p=require("clsx"),Y=require("./formContext-bTWrqdEV.cjs"),Z=require("./FloatingPanel-tGCG2nhA.cjs"),I=require("./Typography-B6ASPrzT.cjs"),e=require("./ColorPickerPanel-CzBlh0zw.cjs"),ee=require("./ConfigProvider-CzAQf_d_.cjs"),se=232,re=t.forwardRef(function({label:y,size:w="md",error:S,helperText:V,required:E=!1,fullWidth:O=!0,disabled:C=!1,value:P,defaultValue:H,onChange:f,swatches:W,alpha:D=!0,name:o,placeholder:g,id:L,className:U,style:_},a){const $=ee.useT(),z=t.useId(),x=L??z,j=`${x}-helper`,c=Y.useFormContext(),k=!!(c&&o),l=c&&o?c.field(o):void 0,T=P!==void 0?P:k?c.values[o]??"":void 0,q=T!==void 0,[A,G]=t.useState(H??""),R=q?T:A,i=e.parseColor(R||""),u=i?e.formatColor(i):null,J=u?u[0]==="#"?u.toUpperCase():u:null,v=S??(l==null?void 0:l.error)??!1,h=V??(l==null?void 0:l.helperText),K=s=>{q||G(s),k&&c.setValue(o,s),f==null||f(s)},d=t.useRef(null),N=t.useRef(null),[m,b]=t.useState(!1),M=t.useCallback(s=>{d.current=s,typeof a=="function"?a(s):a&&(a.current=s)},[a]),Q=t.useCallback(s=>{var n;b(!1),s&&((n=d.current)==null||n.focus())},[]),X=s=>{var B,F;const n=s.relatedTarget;n&&((B=N.current)!=null&&B.contains(n)||(F=d.current)!=null&&F.contains(n))||l==null||l.onBlur(s)};return r.jsxs("div",{className:p.clsx(e.styles.field,e.styles[w],O&&e.styles.fullWidth,v&&e.styles.error,C&&e.styles.disabled,U),style:_,children:[y!=null&&r.jsxs("label",{htmlFor:x,className:e.styles.label,children:[r.jsx(I.Typography,{as:"span",variant:"bodySmall",color:"muted",children:y}),E&&r.jsx("span",{className:e.styles.required,"aria-hidden":"true",children:"*"})]}),r.jsxs("button",{ref:M,id:x,name:o,type:"button",className:p.clsx(e.styles.control,m&&e.styles.open),disabled:C,"aria-haspopup":"dialog","aria-expanded":m,"aria-invalid":v||void 0,"aria-describedby":h!=null?j:void 0,"aria-label":y||i||g?void 0:$("colorPicker.pick"),onClick:()=>b(s=>!s),onBlur:X,children:[r.jsx("span",{className:p.clsx(e.styles.value,!i&&e.styles.placeholder),children:J??g}),r.jsx("span",{className:p.clsx(e.styles.preview,!i&&e.styles.previewEmpty),style:i?{"--cp-fill":u}:void 0,"aria-hidden":"true"})]}),r.jsx(Z.FloatingPanel,{ref:N,open:m,triggerRef:d,onClose:Q,role:"dialog",ariaLabel:"Color picker",width:se,children:r.jsx(e.ColorPickerPanel,{value:R,onChange:K,swatches:W,alpha:D})}),h!=null&&r.jsx(I.Typography,{as:"span",id:j,variant:"bodySmall",color:v?"error":"muted",className:e.styles.helper,children:h})]})});exports.ColorPicker=re;
|
|
2
|
+
//# sourceMappingURL=ColorPicker-B1riGs1z.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPicker-BTBTQD39.cjs","sources":["../src/components/ColorPicker/ColorPicker.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type FocusEvent,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT } from '../../theme'\nimport { FloatingPanel } from '../FloatingPanel/FloatingPanel'\nimport { Typography } from '../Typography'\nimport { ColorPickerPanel } from './ColorPickerPanel'\nimport { formatColor, parseColor } from './colorUtils'\nimport styles from './ColorPicker.module.css'\n\nexport type ColorPickerSize = 'sm' | 'md' | 'lg'\n\n/** Popover width (px). */\nconst POPOVER_WIDTH = 232\n\nexport interface ColorPickerProps {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — control height, swatch and font. */\n size?: ColorPickerSize\n /** Marks the field invalid: red border/ring + the `helperText` in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Disables the field. */\n disabled?: boolean\n /** Controlled value — a CSS color string: `#rrggbb` hex, or `rgba(r, g, b, a)` when translucent. */\n value?: string\n /** Initial value for uncontrolled use (hex or `rgb()`/`rgba()`). */\n defaultValue?: string\n /** Fires with the next color: `#rrggbb` when opaque, `rgba(r, g, b, a)` when not (or `''` when cleared). */\n onChange?: (color: string) => void\n /** Quick-pick swatches shown in the popover. Defaults to a curated palette. */\n swatches?: string[]\n /**\n * Offer opacity. Defaults to `true`. `false` hides the alpha slider and the field only ever emits\n * `#rrggbb` (never `rgba()`) — for colors that must be opaque, e.g. brand colors.\n */\n alpha?: boolean\n /** Form field name — auto-binds to a surrounding `<Form>` (value is the hex string). */\n name?: string\n /** Placeholder shown in the trigger when no color is set. Omit to show nothing. */\n placeholder?: string\n /** Id for the trigger (label association). */\n id?: string\n className?: string\n style?: CSSProperties\n}\n\n/**\n * A color field with a beautiful popover picker: a saturation/value square, a hue slider, an alpha\n * (opacity) slider, a color input, quick-pick swatches and a clear button. The input accepts hex\n * (`#rgb`/`#rrggbb`/`#rrggbbaa`) or `rgb()`/`rgba()`, and the value comes back as `#rrggbb` when\n * fully opaque or `rgba(r, g, b, a)` when translucent. Clicking the trigger opens the popover, which\n * — like `Dropdown` — is portaled to `<body>`, opens below (flips above only when it would\n * overflow), locks page scroll and re-positions on scroll/resize. Controlled (`value` + `onChange`)\n * or uncontrolled (`defaultValue`), and binds to a surrounding `<Form>` by `name` (its form value is\n * the color string; validate with e.g. `z.string().regex(/^#[0-9a-f]{6}$/i, 'Pick a color')`, or a\n * looser pattern if you allow `rgba()`). Styling uses `--tz-*` tokens (the spectrum gradients and\n * the alpha checkerboard are the unavoidable exceptions).\n */\nexport const ColorPicker = forwardRef<HTMLButtonElement, ColorPickerProps>(function ColorPicker(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n disabled = false,\n value,\n defaultValue,\n onChange,\n swatches,\n alpha = true,\n name,\n placeholder,\n id: idProp,\n className,\n style,\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name` — the form value is the hex string.\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue: string | undefined =\n value !== undefined\n ? value\n : isFormBound\n ? ((form!.values[name!] as string | undefined) ?? '')\n : undefined\n const isControlled = externalValue !== undefined\n const [internal, setInternal] = useState<string>(defaultValue ?? '')\n const currentColor = isControlled ? externalValue! : internal\n const parsed = parseColor(currentColor || '')\n // canonical string for the value (`#rrggbb` when opaque, `rgba(...)` when not), null when unset\n const displayValue = parsed ? formatColor(parsed) : null\n // hex shows uppercase in the trigger; rgba() stays as-is\n const displayText = displayValue\n ? displayValue[0] === '#'\n ? displayValue.toUpperCase()\n : displayValue\n : null\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const commit = (color: string) => {\n if (!isControlled) setInternal(color)\n if (isFormBound) form!.setValue(name!, color)\n onChange?.(color)\n }\n\n // ── popover (positioning / scroll-lock / dismiss come from FloatingPanel) ──────────────────────\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n const popoverRef = useRef<HTMLDivElement | null>(null)\n const [open, setOpen] = useState(false)\n\n const setTriggerRef = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) (ref as { current: HTMLButtonElement | null }).current = node\n },\n [ref],\n )\n\n const closePopover = useCallback((refocus: boolean) => {\n setOpen(false)\n if (refocus) triggerRef.current?.focus()\n }, [])\n\n // mark the form field touched when focus leaves the whole widget — but not when it moves into the\n // (portaled) popover or stays on the trigger, so a form-bound picker shows its error like every\n // other popover field (Select/DatePicker) instead of only after submit\n const handleTriggerBlur = (event: FocusEvent<HTMLButtonElement>) => {\n const next = event.relatedTarget as Node | null\n if (next && (popoverRef.current?.contains(next) || triggerRef.current?.contains(next))) return\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n }\n\n return (\n <div\n className={clsx(\n styles.field,\n styles[size],\n fullWidth && styles.fullWidth,\n resolvedError && styles.error,\n disabled && styles.disabled,\n className,\n )}\n style={style}\n >\n {label != null && (\n <label htmlFor={id} className={styles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <button\n ref={setTriggerRef}\n id={id}\n name={name}\n type=\"button\"\n className={clsx(styles.control, open && styles.open)}\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n aria-label={label || parsed || placeholder ? undefined : t('colorPicker.pick')}\n onClick={() => setOpen((o) => !o)}\n onBlur={handleTriggerBlur}\n >\n <span className={clsx(styles.value, !parsed && styles.placeholder)}>\n {displayText ?? placeholder}\n </span>\n <span\n className={clsx(styles.preview, !parsed && styles.previewEmpty)}\n style={parsed ? ({ '--cp-fill': displayValue } as CSSProperties) : undefined}\n aria-hidden=\"true\"\n />\n </button>\n\n <FloatingPanel\n ref={popoverRef}\n open={open}\n triggerRef={triggerRef}\n onClose={closePopover}\n role=\"dialog\"\n ariaLabel=\"Color picker\"\n width={POPOVER_WIDTH}\n >\n <ColorPickerPanel\n value={currentColor}\n onChange={commit}\n swatches={swatches}\n alpha={alpha}\n />\n </FloatingPanel>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={styles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["POPOVER_WIDTH","ColorPicker","forwardRef","label","size","error","helperText","required","fullWidth","disabled","value","defaultValue","onChange","swatches","alpha","name","placeholder","idProp","className","style","ref","t","useT","reactId","useId","id","helperId","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","currentColor","parsed","parseColor","displayValue","formatColor","displayText","resolvedError","resolvedHelperText","commit","color","triggerRef","useRef","popoverRef","open","setOpen","setTriggerRef","useCallback","node","closePopover","refocus","_a","handleTriggerBlur","event","next","_b","jsxs","clsx","styles","jsx","Typography","o","Flo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AC1D,aAAYvB,GAASkC,GAAUrB,EAAc,OAAYK,EAAE,kBAAkB,EAC7E,QAAS,IAAM6B,EAASgB,GAAM,CAACA,CAAC,EAChC,OAAQT,EAER,SAAA,CAAAO,EAAAA,IAAC,OAAA,CAAK,UAAWF,EAAAA,KAAKC,EAAAA,OAAO,MAAO,CAAC1B,GAAU0B,EAAAA,OAAO,WAAW,EAC9D,SAAAtB,GAAezB,CAAA,CAClB,EACAgD,EAAAA,IAAC,OAAA,CACC,UAAWF,EAAAA,KAAKC,SAAO,QAAS,CAAC1B,GAAU0B,EAAAA,OAAO,YAAY,EAC9D,MAAO1B,EAAU,CAAE,YAAaE,GAAmC,OACnE,cAAY,MAAA,CAAA,CACd,CAAA,CAAA,EAGFyB,EAAAA,IAACG,EAAAA,cAAA,CACC,IAAKnB,EACL,KAAAC,EACA,WAAAH,EACA,QAASQ,EACT,KAAK,SACL,UAAU,eACV,MAAOtD,GAEP,SAAAgE,EAAAA,IAACI,EAAAA,iBAAA,CACC,MAAOhC,EACP,SAAUQ,EACV,SAAA/B,EACA,MAAAC,CAAA,CAAA,CACF,CAAA,EAGD6B,GAAsB,MACrBqB,EAAAA,IAACC,EAAAA,WAAA,CACC,GAAG,OACH,GAAIvC,EACJ,QAAQ,YACR,MAAOgB,EAAgB,QAAU,QACjC,UAAWqB,EAAAA,OAAO,OAEjB,SAAApB,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CAAC"}
|
|
1
|
+
{"version":3,"file":"ColorPicker-B1riGs1z.cjs","sources":["../src/components/ColorPicker/ColorPicker.tsx"],"sourcesContent":["import {\n forwardRef,\n useCallback,\n useId,\n useRef,\n useState,\n type CSSProperties,\n type FocusEvent,\n type ReactNode,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useFormContext } from '../../form/formContext'\nimport { useT } from '../../theme'\nimport { FloatingPanel } from '../FloatingPanel/FloatingPanel'\nimport { Typography } from '../Typography'\nimport { ColorPickerPanel } from './ColorPickerPanel'\nimport { formatColor, parseColor } from './colorUtils'\nimport styles from './ColorPicker.module.css'\n\nexport type ColorPickerSize = 'sm' | 'md' | 'lg'\n\n/** Popover width (px). */\nconst POPOVER_WIDTH = 232\n\nexport interface ColorPickerProps {\n /** Label rendered above the field. */\n label?: ReactNode\n /** Preset size — control height, swatch and font. */\n size?: ColorPickerSize\n /** Marks the field invalid: red border/ring + the `helperText` in the error color. */\n error?: boolean\n /** Helper / validation text under the field. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Adds a red asterisk after the label. */\n required?: boolean\n /** Stretches the field to fill its container width. Defaults to `true`. */\n fullWidth?: boolean\n /** Disables the field. */\n disabled?: boolean\n /** Controlled value — a CSS color string: `#rrggbb` hex, or `rgba(r, g, b, a)` when translucent. */\n value?: string\n /** Initial value for uncontrolled use (hex or `rgb()`/`rgba()`). */\n defaultValue?: string\n /** Fires with the next color: `#rrggbb` when opaque, `rgba(r, g, b, a)` when not (or `''` when cleared). */\n onChange?: (color: string) => void\n /** Quick-pick swatches shown in the popover. Defaults to a curated palette. */\n swatches?: string[]\n /**\n * Offer opacity. Defaults to `true`. `false` hides the alpha slider and the field only ever emits\n * `#rrggbb` (never `rgba()`) — for colors that must be opaque, e.g. brand colors.\n */\n alpha?: boolean\n /** Form field name — auto-binds to a surrounding `<Form>` (value is the hex string). */\n name?: string\n /** Placeholder shown in the trigger when no color is set. Omit to show nothing. */\n placeholder?: string\n /** Id for the trigger (label association). */\n id?: string\n className?: string\n style?: CSSProperties\n}\n\n/**\n * A color field with a beautiful popover picker: a saturation/value square, a hue slider, an alpha\n * (opacity) slider, a color input, quick-pick swatches and a clear button. The input accepts hex\n * (`#rgb`/`#rrggbb`/`#rrggbbaa`) or `rgb()`/`rgba()`, and the value comes back as `#rrggbb` when\n * fully opaque or `rgba(r, g, b, a)` when translucent. Clicking the trigger opens the popover, which\n * — like `Dropdown` — is portaled to `<body>`, opens below (flips above only when it would\n * overflow), locks page scroll and re-positions on scroll/resize. Controlled (`value` + `onChange`)\n * or uncontrolled (`defaultValue`), and binds to a surrounding `<Form>` by `name` (its form value is\n * the color string; validate with e.g. `z.string().regex(/^#[0-9a-f]{6}$/i, 'Pick a color')`, or a\n * looser pattern if you allow `rgba()`). Styling uses `--tz-*` tokens (the spectrum gradients and\n * the alpha checkerboard are the unavoidable exceptions).\n */\nexport const ColorPicker = forwardRef<HTMLButtonElement, ColorPickerProps>(function ColorPicker(\n {\n label,\n size = 'md',\n error,\n helperText,\n required = false,\n fullWidth = true,\n disabled = false,\n value,\n defaultValue,\n onChange,\n swatches,\n alpha = true,\n name,\n placeholder,\n id: idProp,\n className,\n style,\n },\n ref,\n) {\n const t = useT()\n const reactId = useId()\n const id = idProp ?? reactId\n const helperId = `${id}-helper`\n\n // Auto-bind to a surrounding <Form> by `name` — the form value is the hex string.\n const form = useFormContext()\n const isFormBound = Boolean(form && name)\n const bound = form && name ? form.field(name) : undefined\n\n const externalValue: string | undefined =\n value !== undefined\n ? value\n : isFormBound\n ? ((form!.values[name!] as string | undefined) ?? '')\n : undefined\n const isControlled = externalValue !== undefined\n const [internal, setInternal] = useState<string>(defaultValue ?? '')\n const currentColor = isControlled ? externalValue! : internal\n const parsed = parseColor(currentColor || '')\n // canonical string for the value (`#rrggbb` when opaque, `rgba(...)` when not), null when unset\n const displayValue = parsed ? formatColor(parsed) : null\n // hex shows uppercase in the trigger; rgba() stays as-is\n const displayText = displayValue\n ? displayValue[0] === '#'\n ? displayValue.toUpperCase()\n : displayValue\n : null\n\n const resolvedError = error ?? bound?.error ?? false\n const resolvedHelperText = helperText ?? bound?.helperText\n\n const commit = (color: string) => {\n if (!isControlled) setInternal(color)\n if (isFormBound) form!.setValue(name!, color)\n onChange?.(color)\n }\n\n // ── popover (positioning / scroll-lock / dismiss come from FloatingPanel) ──────────────────────\n const triggerRef = useRef<HTMLButtonElement | null>(null)\n const popoverRef = useRef<HTMLDivElement | null>(null)\n const [open, setOpen] = useState(false)\n\n const setTriggerRef = useCallback(\n (node: HTMLButtonElement | null) => {\n triggerRef.current = node\n if (typeof ref === 'function') ref(node)\n else if (ref) (ref as { current: HTMLButtonElement | null }).current = node\n },\n [ref],\n )\n\n const closePopover = useCallback((refocus: boolean) => {\n setOpen(false)\n if (refocus) triggerRef.current?.focus()\n }, [])\n\n // mark the form field touched when focus leaves the whole widget — but not when it moves into the\n // (portaled) popover or stays on the trigger, so a form-bound picker shows its error like every\n // other popover field (Select/DatePicker) instead of only after submit\n const handleTriggerBlur = (event: FocusEvent<HTMLButtonElement>) => {\n const next = event.relatedTarget as Node | null\n if (next && (popoverRef.current?.contains(next) || triggerRef.current?.contains(next))) return\n bound?.onBlur(event as unknown as FocusEvent<HTMLInputElement>)\n }\n\n return (\n <div\n className={clsx(\n styles.field,\n styles[size],\n fullWidth && styles.fullWidth,\n resolvedError && styles.error,\n disabled && styles.disabled,\n className,\n )}\n style={style}\n >\n {label != null && (\n <label htmlFor={id} className={styles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={styles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n <button\n ref={setTriggerRef}\n id={id}\n name={name}\n type=\"button\"\n className={clsx(styles.control, open && styles.open)}\n disabled={disabled}\n aria-haspopup=\"dialog\"\n aria-expanded={open}\n aria-invalid={resolvedError || undefined}\n aria-describedby={resolvedHelperText != null ? helperId : undefined}\n aria-label={label || parsed || placeholder ? undefined : t('colorPicker.pick')}\n onClick={() => setOpen((o) => !o)}\n onBlur={handleTriggerBlur}\n >\n <span className={clsx(styles.value, !parsed && styles.placeholder)}>\n {displayText ?? placeholder}\n </span>\n <span\n className={clsx(styles.preview, !parsed && styles.previewEmpty)}\n style={parsed ? ({ '--cp-fill': displayValue } as CSSProperties) : undefined}\n aria-hidden=\"true\"\n />\n </button>\n\n <FloatingPanel\n ref={popoverRef}\n open={open}\n triggerRef={triggerRef}\n onClose={closePopover}\n role=\"dialog\"\n ariaLabel=\"Color picker\"\n width={POPOVER_WIDTH}\n >\n <ColorPickerPanel\n value={currentColor}\n onChange={commit}\n swatches={swatches}\n alpha={alpha}\n />\n </FloatingPanel>\n\n {resolvedHelperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={resolvedError ? 'error' : 'muted'}\n className={styles.helper}\n >\n {resolvedHelperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["POPOVER_WIDTH","ColorPicker","forwardRef","label","size","error","helperText","required","fullWidth","disabled","value","defaultValue","onChange","swatches","alpha","name","placeholder","idProp","className","style","ref","t","useT","reactId","useId","id","helperId","form","useFormContext","isFormBound","bound","externalValue","isControlled","internal","setInternal","useState","currentColor","parsed","parseColor","displayValue","formatColor","displayText","resolvedError","resolvedHelperText","commit","color","triggerRef","useRef","popoverRef","open","setOpen","setTriggerRef","useCallback","node","closePopover","refocus","_a","handleTriggerBlur","event","next","_b","jsxs","clsx","styles","jsx","Typography","o","FloatingPanel","ColorPickerPanel"],"mappings":"ySAsBMA,GAAgB,IAoDTC,GAAcC,EAAAA,WAAgD,SACzE,CACE,MAAAC,EACA,KAAAC,EAAO,KACP,MAAAC,EACA,WAAAC,EACA,SAAAC,EAAW,GACX,UAAAC,EAAY,GACZ,SAAAC,EAAW,GACX,MAAAC,EACA,aAAAC,EACA,SAAAC,EACA,SAAAC,EACA,MAAAC,EAAQ,GACR,KAAAC,EACA,YAAAC,EACA,GAAIC,EACJ,UAAAC,EACA,MAAAC,CACF,EACAC,EACA,CACA,MAAMC,EAAIC,GAAAA,KAAA,EACJC,EAAUC,EAAAA,MAAA,EACVC,EAAKR,GAAUM,EACfG,EAAW,GAAGD,CAAE,UAGhBE,EAAOC,EAAAA,eAAA,EACPC,EAAc,GAAQF,GAAQZ,GAC9Be,EAAQH,GAAQZ,EAAOY,EAAK,MAAMZ,CAAI,EAAI,OAE1CgB,EACJrB,IAAU,OACNA,EACAmB,EACIF,EAAM,OAAOZ,CAAK,GAA4B,GAChD,OACFiB,EAAeD,IAAkB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SAAA/B,EACA,MAAAC,CAAA,CAAA,CACF,CAAA,EAGD6B,GAAsB,MACrBqB,EAAAA,IAACC,EAAAA,WAAA,CACC,GAAG,OACH,GAAIvC,EACJ,QAAQ,YACR,MAAOgB,EAAgB,QAAU,QACjC,UAAWqB,EAAAA,OAAO,OAEjB,SAAApB,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { useState as P, useRef as L, useEffect as K } from "react";
|
|
|
3
3
|
import { clsx as se } from "clsx";
|
|
4
4
|
import { I as U } from "./Icon-CGQ5yGSZ.js";
|
|
5
5
|
import { c as p, r as j, h as q } from "./color-EQJ2DrcQ.js";
|
|
6
|
-
import { a as ae } from "./ConfigProvider-
|
|
6
|
+
import { a as ae } from "./ConfigProvider-D2svpXFu.js";
|
|
7
7
|
const A = (o) => Math.min(255, Math.max(0, Math.round(o)));
|
|
8
8
|
function D({ r: o, g: h, b: a }) {
|
|
9
9
|
const t = o / 255, c = h / 255, _ = a / 255, l = Math.max(t, c, _), n = Math.min(t, c, _), u = l - n;
|
|
@@ -319,4 +319,4 @@ export {
|
|
|
319
319
|
E as p,
|
|
320
320
|
d as s
|
|
321
321
|
};
|
|
322
|
-
//# sourceMappingURL=ColorPickerPanel-
|
|
322
|
+
//# sourceMappingURL=ColorPickerPanel-4Y6oXL7v.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerPanel-D6agWM6y.js","sources":["../src/components/ColorPicker/colorUtils.ts","../src/components/ColorPicker/ColorPickerPanel.tsx"],"sourcesContent":["/** Color math for the ColorPicker: hex ⇄ rgb ⇄ hsv, plus hex validation. All internal, no deps. */\n\nexport interface HSV {\n /** Hue 0–360 */\n h: number\n /** Saturation 0–1 */\n s: number\n /** Value/brightness 0–1 */\n v: number\n}\n\nimport { clamp01, hexToRgb, rgbToHex, type RGB } from '../../helpers/color'\n\n// the hex ⇄ rgb primitives are shared with the palette helpers — re-exported so nothing else changes\nexport { clamp01, normalizeHex, isValidHex, hexToRgb, rgbToHex } from '../../helpers/color'\nexport type { RGB } from '../../helpers/color'\n\nexport interface RGBA extends RGB {\n /** Alpha 0–1 */\n a: number\n}\n\nconst clamp255 = (n: number): number => Math.min(255, Math.max(0, Math.round(n)))\n\n/** RGB (0–255) → HSV. */\nexport function rgbToHsv({ r, g, b }: RGB): HSV {\n const rn = r / 255\n const gn = g / 255\n const bn = b / 255\n const max = Math.max(rn, gn, bn)\n const min = Math.min(rn, gn, bn)\n const d = max - min\n\n let h = 0\n if (d !== 0) {\n if (max === rn) h = ((gn - bn) / d) % 6\n else if (max === gn) h = (bn - rn) / d + 2\n else h = (rn - gn) / d + 4\n h *= 60\n if (h < 0) h += 360\n }\n const s = max === 0 ? 0 : d / max\n return { h, s, v: max }\n}\n\n/** HSV → RGB (0–255). */\nexport function hsvToRgb({ h, s, v }: HSV): RGB {\n const c = v * s\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1))\n const m = v - c\n let r = 0\n let g = 0\n let b = 0\n if (h < 60) [r, g, b] = [c, x, 0]\n else if (h < 120) [r, g, b] = [x, c, 0]\n else if (h < 180) [r, g, b] = [0, c, x]\n else if (h < 240) [r, g, b] = [0, x, c]\n else if (h < 300) [r, g, b] = [x, 0, c]\n else [r, g, b] = [c, 0, x]\n return { r: (r + m) * 255, g: (g + m) * 255, b: (b + m) * 255 }\n}\n\nexport const hexToHsv = (hex: string): HSV => rgbToHsv(hexToRgb(hex))\nexport const hsvToHex = (hsv: HSV): string => rgbToHex(hsvToRgb(hsv))\n\n/** A readable text/handle color (near-black or white) for sitting on top of a given hex fill. */\nexport function contrastOn(hex: string): string {\n const { r, g, b } = hexToRgb(hex)\n return (r * 299 + g * 587 + b * 114) / 1000 >= 150 ? '#04202b' : '#ffffff'\n}\n\nconst RGB_FUNC =\n /^rgba?\\(\\s*([\\d.]+)\\s*[, ]\\s*([\\d.]+)\\s*[, ]\\s*([\\d.]+)\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)$/i\n\n/**\n * Parses any CSS color the picker understands — `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa` hex (with\n * or without `#`), or `rgb()` / `rgba()` (alpha as `0–1` or a `%`) — to `{ r, g, b, a }` (`a` is\n * `0–1`), or `null` when it doesn't match.\n */\nexport function parseColor(input: string): RGBA | null {\n const s = input.trim()\n if (!s) return null\n\n // hex (with or without #) — 3 / 4 / 6 / 8 digits (3 & 4 expand each nibble to a byte)\n let h = s.replace(/^#/, '')\n if (/^[0-9a-fA-F]{3,4}$/.test(h)) {\n h = h\n .split('')\n .map((c) => c + c)\n .join('')\n }\n if (/^[0-9a-fA-F]{6}$/.test(h)) {\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n a: 1,\n }\n }\n if (/^[0-9a-fA-F]{8}$/.test(h)) {\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n a: clamp01(parseInt(h.slice(6, 8), 16) / 255),\n }\n }\n\n // rgb() / rgba()\n const m = s.match(RGB_FUNC)\n if (m) {\n let a = 1\n if (m[4] != null) {\n a = m[4].endsWith('%') ? clamp01(parseFloat(m[4]) / 100) : clamp01(parseFloat(m[4]))\n }\n return { r: clamp255(+m[1]), g: clamp255(+m[2]), b: clamp255(+m[3]), a }\n }\n return null\n}\n\n/**\n * Formats `{ r, g, b, a }` back to a CSS string: `#rrggbb` when fully opaque (`a >= 1`), else\n * `rgba(r, g, b, a)` with alpha rounded to 2 decimals.\n */\nexport function formatColor({ r, g, b, a }: RGBA): string {\n if (a >= 1) return rgbToHex({ r, g, b })\n return `rgba(${clamp255(r)}, ${clamp255(g)}, ${clamp255(b)}, ${Math.round(clamp01(a) * 100) / 100})`\n}\n","import {\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { Icon } from '../Icon'\nimport {\n clamp01,\n contrastOn,\n formatColor,\n hexToHsv,\n hsvToRgb,\n parseColor,\n rgbToHex,\n rgbToHsv,\n type HSV,\n} from './colorUtils'\nimport styles from './ColorPicker.module.css'\n\n/** A pleasant default palette shown as quick-pick swatches. */\nexport const DEFAULT_SWATCHES = [\n '#13404e',\n '#039aa1',\n '#00a854',\n '#0ea5e9',\n '#6366f1',\n '#7c3aed',\n '#f04134',\n '#f59e0b',\n '#ffbf00',\n '#10b981',\n '#64748b',\n '#0f172a',\n '#ffffff',\n]\n\nconst FALLBACK_HSV: HSV = hexToHsv('#13404e')\n\nexport interface ColorPickerPanelProps {\n /** Current color — a CSS color string (`#rrggbb`, `rgba(...)`, or `''` when unset). */\n value: string\n /** Fires with the next color: `#rrggbb` when opaque, `rgba(r, g, b, a)` when translucent, `''` when cleared. */\n onChange: (color: string) => void\n /** Quick-pick swatches. Defaults to a curated palette. */\n swatches?: string[]\n /** Show the leading \"no color\" swatch that clears the value. Defaults to `true`. */\n clearable?: boolean\n /**\n * Offer opacity. Defaults to `true`. `false` hides the alpha rail and pins alpha to `1`, so the\n * panel only ever emits `#rrggbb` — for values that must be opaque (brand colors).\n */\n alpha?: boolean\n}\n\n/**\n * The color-picking surface — a saturation/value square, hue + alpha sliders, a color input and\n * quick-pick swatches. Controlled by a single color `string` (`value` / `onChange`), so it drops into\n * any popover. Working state is kept as HSV + alpha (hue survives dragging at grey/black), re-derived\n * from `value` only on external changes. Used by `ColorPicker` (the field) and the `RichTextEditor`\n * text-color control. Token-styled except the spectrum gradients + alpha checkerboard (literal colors).\n */\nexport function ColorPickerPanel({\n value,\n onChange,\n swatches = DEFAULT_SWATCHES,\n clearable = true,\n alpha: alphaEnabled = true,\n}: ColorPickerPanelProps) {\n // with opacity off every emitted color is opaque, whatever the working alpha happens to be\n const emitAlpha = (a: number) => (alphaEnabled ? a : 1)\n const t = useT()\n const parsed = parseColor(value || '')\n // canonical string for the value (`#rrggbb` when opaque, `rgba(...)` when not), null when unset\n const displayValue = parsed ? formatColor(parsed) : null\n\n // working HSV + alpha (HSV keeps hue stable while dragging at grey/black; alpha is the opacity)\n const [hsv, setHsv] = useState<HSV>(parsed ? rgbToHsv(parsed) : FALLBACK_HSV)\n const hsvRef = useRef(hsv)\n hsvRef.current = hsv\n const [alpha, setAlpha] = useState<number>(parsed?.a ?? 1)\n const alphaRef = useRef(alpha)\n alphaRef.current = alpha\n\n // re-derive HSV + alpha only when the value changes from OUTSIDE our own edits (prop/preset/input)\n useEffect(() => {\n if (!parsed) return\n const cur = formatColor({ ...hsvToRgb(hsvRef.current), a: alphaRef.current })\n if (displayValue !== cur) {\n setHsv(rgbToHsv(parsed))\n setAlpha(parsed.a)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [displayValue])\n\n const applyHsv = (next: HSV) => {\n setHsv(next)\n onChange(formatColor({ ...hsvToRgb(next), a: emitAlpha(alphaRef.current) }))\n }\n\n const applyAlpha = (next: number) => {\n setAlpha(next)\n onChange(formatColor({ ...hsvToRgb(hsvRef.current), a: emitAlpha(next) }))\n }\n\n // drag (SV square + hue/alpha sliders)\n const drag =\n (onMove: (clientX: number, clientY: number, rect: DOMRect) => void) =>\n (event: ReactPointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n const el = event.currentTarget\n const move = (clientX: number, clientY: number) =>\n onMove(clientX, clientY, el.getBoundingClientRect())\n move(event.clientX, event.clientY)\n const onPointerMove = (e: PointerEvent) => move(e.clientX, e.clientY)\n const onPointerUp = () => {\n window.removeEventListener('pointermove', onPointerMove)\n window.removeEventListener('pointerup', onPointerUp)\n }\n window.addEventListener('pointermove', onPointerMove)\n window.addEventListener('pointerup', onPointerUp)\n }\n\n const onSvDown = drag((x, y, rect) => {\n const s = clamp01((x - rect.left) / rect.width)\n const v = clamp01(1 - (y - rect.top) / rect.height)\n applyHsv({ ...hsvRef.current, s, v })\n })\n\n const onHueDown = drag((x, _y, rect) => {\n const h = clamp01((x - rect.left) / rect.width) * 360\n applyHsv({ ...hsvRef.current, h })\n })\n\n const onAlphaDown = drag((x, _y, rect) => {\n applyAlpha(clamp01((x - rect.left) / rect.width))\n })\n\n // keyboard control — arrows nudge, Home/End jump to the extents (mirrors Calendar/TimeColumns a11y)\n const SV_STEP = 0.01\n const onSvKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { h, s, v } = hsvRef.current\n let ns = s\n let nv = v\n switch (event.key) {\n case 'ArrowLeft':\n ns = clamp01(s - SV_STEP)\n break\n case 'ArrowRight':\n ns = clamp01(s + SV_STEP)\n break\n case 'ArrowUp':\n nv = clamp01(v + SV_STEP)\n break\n case 'ArrowDown':\n nv = clamp01(v - SV_STEP)\n break\n default:\n return\n }\n event.preventDefault()\n applyHsv({ h, s: ns, v: nv })\n }\n const onHueKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { h } = hsvRef.current\n let nh = h\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n nh = Math.max(0, h - 1)\n break\n case 'ArrowRight':\n case 'ArrowUp':\n nh = Math.min(360, h + 1)\n break\n case 'Home':\n nh = 0\n break\n case 'End':\n nh = 360\n break\n default:\n return\n }\n event.preventDefault()\n applyHsv({ ...hsvRef.current, h: nh })\n }\n const onAlphaKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n let na = alphaRef.current\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n na = clamp01(alphaRef.current - 0.01)\n break\n case 'ArrowRight':\n case 'ArrowUp':\n na = clamp01(alphaRef.current + 0.01)\n break\n case 'Home':\n na = 0\n break\n case 'End':\n na = 1\n break\n default:\n return\n }\n event.preventDefault()\n applyAlpha(na)\n }\n\n // color input (accepts hex / rgb() / rgba()) + clear\n const [colorDraft, setColorDraft] = useState('')\n useEffect(() => {\n setColorDraft(displayValue ?? '')\n }, [displayValue])\n\n const onColorInput = (raw: string) => {\n setColorDraft(raw)\n const p = parseColor(raw)\n if (p) {\n setHsv(rgbToHsv(p))\n setAlpha(p.a)\n onChange(formatColor({ ...p, a: emitAlpha(p.a) }))\n }\n }\n\n const handleClear = () => {\n onChange('')\n setHsv(FALLBACK_HSV)\n setAlpha(1)\n }\n\n // working color (hsv + alpha): the current swatch + the SV thumb (opaque) + the alpha track base\n const workingColor = formatColor({ ...hsvToRgb(hsv), a: alpha })\n const solidHex = rgbToHex(hsvToRgb(hsv))\n const cur = hsvToRgb(hsv)\n const cpRgb = `${Math.round(cur.r)}, ${Math.round(cur.g)}, ${Math.round(cur.b)}`\n\n return (\n <div className={styles.popover} style={{ '--cp-hue': hsv.h } as CSSProperties}>\n <div\n className={styles.sv}\n onPointerDown={onSvDown}\n onKeyDown={onSvKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.saturation')}\n aria-valuetext={`${Math.round(hsv.s * 100)}% saturation, ${Math.round(hsv.v * 100)}% brightness`}\n >\n <span\n className={styles.svThumb}\n style={{ left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%`, background: solidHex }}\n />\n </div>\n\n <div\n className={styles.hue}\n onPointerDown={onHueDown}\n onKeyDown={onHueKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.hue')}\n aria-valuemin={0}\n aria-valuemax={360}\n aria-valuenow={Math.round(hsv.h)}\n >\n <span className={styles.hueThumb} style={{ left: `${(hsv.h / 360) * 100}%` }} />\n </div>\n\n {alphaEnabled && (\n <div\n className={styles.alpha}\n onPointerDown={onAlphaDown}\n onKeyDown={onAlphaKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.opacity')}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(alpha * 100)}\n style={{ '--cp-rgb': cpRgb } as CSSProperties}\n >\n <span className={styles.alphaThumb} style={{ left: `${alpha * 100}%` }} />\n </div>\n )}\n\n <div className={styles.hexRow}>\n <span\n className={styles.currentSwatch}\n style={{ '--cp-fill': workingColor } as CSSProperties}\n />\n <span className={styles.hexField}>\n <input\n className={styles.hexInput}\n value={colorDraft}\n spellCheck={false}\n maxLength={28}\n aria-label={t('colorPicker.value')}\n onChange={(e) => onColorInput(e.target.value)}\n />\n </span>\n </div>\n\n <div className={styles.swatches}>\n {/* \"no color\" — clears the value (the diagonal-stripe swatch); hidden when not clearable */}\n {clearable && (\n <button\n type=\"button\"\n className={clsx(styles.swatch, styles.swatchClear)}\n aria-label={t('colorPicker.noColor')}\n aria-pressed={!parsed}\n onClick={handleClear}\n >\n {!parsed && <Icon name=\"TickCircle\" size=\"sm\" />}\n </button>\n )}\n {swatches.map((sw) => {\n const p = parseColor(sw)\n if (!p) return null\n const swHex = formatColor({ r: p.r, g: p.g, b: p.b, a: 1 })\n const selected = displayValue === swHex\n return (\n <button\n key={sw}\n type=\"button\"\n className={styles.swatch}\n style={{ background: swHex, color: contrastOn(swHex) }}\n aria-label={swHex}\n aria-pressed={selected}\n onClick={() => {\n setHsv(rgbToHsv(p))\n onChange(formatColor({ r: p.r, g: p.g, b: p.b, a: emitAlpha(alphaRef.current) }))\n }}\n >\n {selected && <Icon name=\"TickCircle\" size=\"sm\" />}\n </button>\n )\n })}\n </div>\n </div>\n )\n}\n"],"names":["clamp255","n","rgbToHsv","r","g","b","rn","gn","bn","max","min","d","h","s","hsvToRgb","v","c","x","m","hexToHsv","hex","hexToRgb","contrastOn","RGB_FUNC","parseColor","input","clamp01","a","formatColor","rgbToHex","DEFAULT_SWATCHES","FALLBACK_HSV","ColorPickerPanel","value","onChange","swatches","clearable","alphaEnabled","emitAlpha","t","useT","parsed","displayValue","hsv","setHsv","useState","hsvRef","useRef","alpha","setAlpha","alphaRef","useEffect","cur","applyHsv","next","applyAlpha","drag","onMove","event","el","move","clientX","clientY","onPointerMove","e","onPointerUp","onSvDown","y","rect","onHueDown","_y","onAlphaDown","SV_STEP","onSvKey","ns","nv","onHueKey","nh","onAlphaKey","na","colorDraft","setColorDraft","onColorInput","raw","p","handleClear","workingColor","solidHex","cpRgb","jsxs","styles","jsx","clsx","Icon","sw","swHex","selected"],"mappings":";;;;;;AAsBA,MAAMA,IAAW,CAACC,MAAsB,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,MAAMA,CAAC,CAAC,CAAC;AAGzE,SAASC,EAAS,EAAE,GAAAC,GAAG,GAAAC,GAAG,GAAAC,KAAe;AAC9C,QAAMC,IAAKH,IAAI,KACTI,IAAKH,IAAI,KACTI,IAAKH,IAAI,KACTI,IAAM,KAAK,IAAIH,GAAIC,GAAIC,CAAE,GACzBE,IAAM,KAAK,IAAIJ,GAAIC,GAAIC,CAAE,GACzBG,IAAIF,IAAMC;AAEhB,MAAIE,IAAI;AACR,EAAID,MAAM,MACJF,MAAQH,IAAIM,KAAML,IAAKC,KAAMG,IAAK,IAC7BF,MAAQF,IAAIK,KAAKJ,IAAKF,KAAMK,IAAI,IACpCC,KAAKN,IAAKC,KAAMI,IAAI,GACzBC,KAAK,IACDA,IAAI,MAAGA,KAAK;AAElB,QAAMC,IAAIJ,MAAQ,IAAI,IAAIE,IAAIF;AAC9B,SAAO,EAAE,GAAAG,GAAG,GAAAC,GAAG,GAAGJ,EAAA;AACpB;AAGO,SAASK,EAAS,EAAE,GAAAF,GAAG,GAAAC,GAAG,GAAAE,KAAe;AAC9C,QAAMC,IAAID,IAAIF,GACRI,IAAID,KAAK,IAAI,KAAK,IAAMJ,IAAI,KAAM,IAAK,CAAC,IACxCM,IAAIH,IAAIC;AACd,MAAIb,IAAI,GACJC,IAAI,GACJC,IAAI;AACR,SAAIO,IAAI,KAAI,CAACT,GAAGC,GAAGC,CAAC,IAAI,CAACW,GAAGC,GAAG,CAAC,IACvBL,IAAI,MAAK,CAACT,GAAGC,GAAGC,CAAC,IAAI,CAACY,GAAGD,GAAG,CAAC,IAC7BJ,IAAI,MAAK,CAACT,GAAGC,GAAGC,CAAC,IAAI,CAAC,GAAGW,GAAGC,CAAC,IAC7BL,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,eAAY,gBAAAyC,EAACE,GAAA,EAAK,MAAK,cAAa,MAAK,KAAA,CAAK;AAAA,UAAA;AAAA,UAX1CC;AAAA,QAAA;AAAA,MAcX,CAAC;AAAA,IAAA,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ColorPickerPanel-4Y6oXL7v.js","sources":["../src/components/ColorPicker/colorUtils.ts","../src/components/ColorPicker/ColorPickerPanel.tsx"],"sourcesContent":["/** Color math for the ColorPicker: hex ⇄ rgb ⇄ hsv, plus hex validation. All internal, no deps. */\n\nexport interface HSV {\n /** Hue 0–360 */\n h: number\n /** Saturation 0–1 */\n s: number\n /** Value/brightness 0–1 */\n v: number\n}\n\nimport { clamp01, hexToRgb, rgbToHex, type RGB } from '../../helpers/color'\n\n// the hex ⇄ rgb primitives are shared with the palette helpers — re-exported so nothing else changes\nexport { clamp01, normalizeHex, isValidHex, hexToRgb, rgbToHex } from '../../helpers/color'\nexport type { RGB } from '../../helpers/color'\n\nexport interface RGBA extends RGB {\n /** Alpha 0–1 */\n a: number\n}\n\nconst clamp255 = (n: number): number => Math.min(255, Math.max(0, Math.round(n)))\n\n/** RGB (0–255) → HSV. */\nexport function rgbToHsv({ r, g, b }: RGB): HSV {\n const rn = r / 255\n const gn = g / 255\n const bn = b / 255\n const max = Math.max(rn, gn, bn)\n const min = Math.min(rn, gn, bn)\n const d = max - min\n\n let h = 0\n if (d !== 0) {\n if (max === rn) h = ((gn - bn) / d) % 6\n else if (max === gn) h = (bn - rn) / d + 2\n else h = (rn - gn) / d + 4\n h *= 60\n if (h < 0) h += 360\n }\n const s = max === 0 ? 0 : d / max\n return { h, s, v: max }\n}\n\n/** HSV → RGB (0–255). */\nexport function hsvToRgb({ h, s, v }: HSV): RGB {\n const c = v * s\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1))\n const m = v - c\n let r = 0\n let g = 0\n let b = 0\n if (h < 60) [r, g, b] = [c, x, 0]\n else if (h < 120) [r, g, b] = [x, c, 0]\n else if (h < 180) [r, g, b] = [0, c, x]\n else if (h < 240) [r, g, b] = [0, x, c]\n else if (h < 300) [r, g, b] = [x, 0, c]\n else [r, g, b] = [c, 0, x]\n return { r: (r + m) * 255, g: (g + m) * 255, b: (b + m) * 255 }\n}\n\nexport const hexToHsv = (hex: string): HSV => rgbToHsv(hexToRgb(hex))\nexport const hsvToHex = (hsv: HSV): string => rgbToHex(hsvToRgb(hsv))\n\n/** A readable text/handle color (near-black or white) for sitting on top of a given hex fill. */\nexport function contrastOn(hex: string): string {\n const { r, g, b } = hexToRgb(hex)\n return (r * 299 + g * 587 + b * 114) / 1000 >= 150 ? '#04202b' : '#ffffff'\n}\n\nconst RGB_FUNC =\n /^rgba?\\(\\s*([\\d.]+)\\s*[, ]\\s*([\\d.]+)\\s*[, ]\\s*([\\d.]+)\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)$/i\n\n/**\n * Parses any CSS color the picker understands — `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa` hex (with\n * or without `#`), or `rgb()` / `rgba()` (alpha as `0–1` or a `%`) — to `{ r, g, b, a }` (`a` is\n * `0–1`), or `null` when it doesn't match.\n */\nexport function parseColor(input: string): RGBA | null {\n const s = input.trim()\n if (!s) return null\n\n // hex (with or without #) — 3 / 4 / 6 / 8 digits (3 & 4 expand each nibble to a byte)\n let h = s.replace(/^#/, '')\n if (/^[0-9a-fA-F]{3,4}$/.test(h)) {\n h = h\n .split('')\n .map((c) => c + c)\n .join('')\n }\n if (/^[0-9a-fA-F]{6}$/.test(h)) {\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n a: 1,\n }\n }\n if (/^[0-9a-fA-F]{8}$/.test(h)) {\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n a: clamp01(parseInt(h.slice(6, 8), 16) / 255),\n }\n }\n\n // rgb() / rgba()\n const m = s.match(RGB_FUNC)\n if (m) {\n let a = 1\n if (m[4] != null) {\n a = m[4].endsWith('%') ? clamp01(parseFloat(m[4]) / 100) : clamp01(parseFloat(m[4]))\n }\n return { r: clamp255(+m[1]), g: clamp255(+m[2]), b: clamp255(+m[3]), a }\n }\n return null\n}\n\n/**\n * Formats `{ r, g, b, a }` back to a CSS string: `#rrggbb` when fully opaque (`a >= 1`), else\n * `rgba(r, g, b, a)` with alpha rounded to 2 decimals.\n */\nexport function formatColor({ r, g, b, a }: RGBA): string {\n if (a >= 1) return rgbToHex({ r, g, b })\n return `rgba(${clamp255(r)}, ${clamp255(g)}, ${clamp255(b)}, ${Math.round(clamp01(a) * 100) / 100})`\n}\n","import {\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { Icon } from '../Icon'\nimport {\n clamp01,\n contrastOn,\n formatColor,\n hexToHsv,\n hsvToRgb,\n parseColor,\n rgbToHex,\n rgbToHsv,\n type HSV,\n} from './colorUtils'\nimport styles from './ColorPicker.module.css'\n\n/** A pleasant default palette shown as quick-pick swatches. */\nexport const DEFAULT_SWATCHES = [\n '#13404e',\n '#039aa1',\n '#00a854',\n '#0ea5e9',\n '#6366f1',\n '#7c3aed',\n '#f04134',\n '#f59e0b',\n '#ffbf00',\n '#10b981',\n '#64748b',\n '#0f172a',\n '#ffffff',\n]\n\nconst FALLBACK_HSV: HSV = hexToHsv('#13404e')\n\nexport interface ColorPickerPanelProps {\n /** Current color — a CSS color string (`#rrggbb`, `rgba(...)`, or `''` when unset). */\n value: string\n /** Fires with the next color: `#rrggbb` when opaque, `rgba(r, g, b, a)` when translucent, `''` when cleared. */\n onChange: (color: string) => void\n /** Quick-pick swatches. Defaults to a curated palette. */\n swatches?: string[]\n /** Show the leading \"no color\" swatch that clears the value. Defaults to `true`. */\n clearable?: boolean\n /**\n * Offer opacity. Defaults to `true`. `false` hides the alpha rail and pins alpha to `1`, so the\n * panel only ever emits `#rrggbb` — for values that must be opaque (brand colors).\n */\n alpha?: boolean\n}\n\n/**\n * The color-picking surface — a saturation/value square, hue + alpha sliders, a color input and\n * quick-pick swatches. Controlled by a single color `string` (`value` / `onChange`), so it drops into\n * any popover. Working state is kept as HSV + alpha (hue survives dragging at grey/black), re-derived\n * from `value` only on external changes. Used by `ColorPicker` (the field) and the `RichTextEditor`\n * text-color control. Token-styled except the spectrum gradients + alpha checkerboard (literal colors).\n */\nexport function ColorPickerPanel({\n value,\n onChange,\n swatches = DEFAULT_SWATCHES,\n clearable = true,\n alpha: alphaEnabled = true,\n}: ColorPickerPanelProps) {\n // with opacity off every emitted color is opaque, whatever the working alpha happens to be\n const emitAlpha = (a: number) => (alphaEnabled ? a : 1)\n const t = useT()\n const parsed = parseColor(value || '')\n // canonical string for the value (`#rrggbb` when opaque, `rgba(...)` when not), null when unset\n const displayValue = parsed ? formatColor(parsed) : null\n\n // working HSV + alpha (HSV keeps hue stable while dragging at grey/black; alpha is the opacity)\n const [hsv, setHsv] = useState<HSV>(parsed ? rgbToHsv(parsed) : FALLBACK_HSV)\n const hsvRef = useRef(hsv)\n hsvRef.current = hsv\n const [alpha, setAlpha] = useState<number>(parsed?.a ?? 1)\n const alphaRef = useRef(alpha)\n alphaRef.current = alpha\n\n // re-derive HSV + alpha only when the value changes from OUTSIDE our own edits (prop/preset/input)\n useEffect(() => {\n if (!parsed) return\n const cur = formatColor({ ...hsvToRgb(hsvRef.current), a: alphaRef.current })\n if (displayValue !== cur) {\n setHsv(rgbToHsv(parsed))\n setAlpha(parsed.a)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [displayValue])\n\n const applyHsv = (next: HSV) => {\n setHsv(next)\n onChange(formatColor({ ...hsvToRgb(next), a: emitAlpha(alphaRef.current) }))\n }\n\n const applyAlpha = (next: number) => {\n setAlpha(next)\n onChange(formatColor({ ...hsvToRgb(hsvRef.current), a: emitAlpha(next) }))\n }\n\n // drag (SV square + hue/alpha sliders)\n const drag =\n (onMove: (clientX: number, clientY: number, rect: DOMRect) => void) =>\n (event: ReactPointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n const el = event.currentTarget\n const move = (clientX: number, clientY: number) =>\n onMove(clientX, clientY, el.getBoundingClientRect())\n move(event.clientX, event.clientY)\n const onPointerMove = (e: PointerEvent) => move(e.clientX, e.clientY)\n const onPointerUp = () => {\n window.removeEventListener('pointermove', onPointerMove)\n window.removeEventListener('pointerup', onPointerUp)\n }\n window.addEventListener('pointermove', onPointerMove)\n window.addEventListener('pointerup', onPointerUp)\n }\n\n const onSvDown = drag((x, y, rect) => {\n const s = clamp01((x - rect.left) / rect.width)\n const v = clamp01(1 - (y - rect.top) / rect.height)\n applyHsv({ ...hsvRef.current, s, v })\n })\n\n const onHueDown = drag((x, _y, rect) => {\n const h = clamp01((x - rect.left) / rect.width) * 360\n applyHsv({ ...hsvRef.current, h })\n })\n\n const onAlphaDown = drag((x, _y, rect) => {\n applyAlpha(clamp01((x - rect.left) / rect.width))\n })\n\n // keyboard control — arrows nudge, Home/End jump to the extents (mirrors Calendar/TimeColumns a11y)\n const SV_STEP = 0.01\n const onSvKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { h, s, v } = hsvRef.current\n let ns = s\n let nv = v\n switch (event.key) {\n case 'ArrowLeft':\n ns = clamp01(s - SV_STEP)\n break\n case 'ArrowRight':\n ns = clamp01(s + SV_STEP)\n break\n case 'ArrowUp':\n nv = clamp01(v + SV_STEP)\n break\n case 'ArrowDown':\n nv = clamp01(v - SV_STEP)\n break\n default:\n return\n }\n event.preventDefault()\n applyHsv({ h, s: ns, v: nv })\n }\n const onHueKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { h } = hsvRef.current\n let nh = h\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n nh = Math.max(0, h - 1)\n break\n case 'ArrowRight':\n case 'ArrowUp':\n nh = Math.min(360, h + 1)\n break\n case 'Home':\n nh = 0\n break\n case 'End':\n nh = 360\n break\n default:\n return\n }\n event.preventDefault()\n applyHsv({ ...hsvRef.current, h: nh })\n }\n const onAlphaKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n let na = alphaRef.current\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n na = clamp01(alphaRef.current - 0.01)\n break\n case 'ArrowRight':\n case 'ArrowUp':\n na = clamp01(alphaRef.current + 0.01)\n break\n case 'Home':\n na = 0\n break\n case 'End':\n na = 1\n break\n default:\n return\n }\n event.preventDefault()\n applyAlpha(na)\n }\n\n // color input (accepts hex / rgb() / rgba()) + clear\n const [colorDraft, setColorDraft] = useState('')\n useEffect(() => {\n setColorDraft(displayValue ?? '')\n }, [displayValue])\n\n const onColorInput = (raw: string) => {\n setColorDraft(raw)\n const p = parseColor(raw)\n if (p) {\n setHsv(rgbToHsv(p))\n setAlpha(p.a)\n onChange(formatColor({ ...p, a: emitAlpha(p.a) }))\n }\n }\n\n const handleClear = () => {\n onChange('')\n setHsv(FALLBACK_HSV)\n setAlpha(1)\n }\n\n // working color (hsv + alpha): the current swatch + the SV thumb (opaque) + the alpha track base\n const workingColor = formatColor({ ...hsvToRgb(hsv), a: alpha })\n const solidHex = rgbToHex(hsvToRgb(hsv))\n const cur = hsvToRgb(hsv)\n const cpRgb = `${Math.round(cur.r)}, ${Math.round(cur.g)}, ${Math.round(cur.b)}`\n\n return (\n <div className={styles.popover} style={{ '--cp-hue': hsv.h } as CSSProperties}>\n <div\n className={styles.sv}\n onPointerDown={onSvDown}\n onKeyDown={onSvKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.saturation')}\n aria-valuetext={`${Math.round(hsv.s * 100)}% saturation, ${Math.round(hsv.v * 100)}% brightness`}\n >\n <span\n className={styles.svThumb}\n style={{ left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%`, background: solidHex }}\n />\n </div>\n\n <div\n className={styles.hue}\n onPointerDown={onHueDown}\n onKeyDown={onHueKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.hue')}\n aria-valuemin={0}\n aria-valuemax={360}\n aria-valuenow={Math.round(hsv.h)}\n >\n <span className={styles.hueThumb} style={{ left: `${(hsv.h / 360) * 100}%` }} />\n </div>\n\n {alphaEnabled && (\n <div\n className={styles.alpha}\n onPointerDown={onAlphaDown}\n onKeyDown={onAlphaKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.opacity')}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(alpha * 100)}\n style={{ '--cp-rgb': cpRgb } as CSSProperties}\n >\n <span className={styles.alphaThumb} style={{ left: `${alpha * 100}%` }} />\n </div>\n )}\n\n <div className={styles.hexRow}>\n <span\n className={styles.currentSwatch}\n style={{ '--cp-fill': workingColor } as CSSProperties}\n />\n <span className={styles.hexField}>\n <input\n className={styles.hexInput}\n value={colorDraft}\n spellCheck={false}\n maxLength={28}\n aria-label={t('colorPicker.value')}\n onChange={(e) => onColorInput(e.target.value)}\n />\n </span>\n </div>\n\n <div className={styles.swatches}>\n {/* \"no color\" — clears the value (the diagonal-stripe swatch); hidden when not clearable */}\n {clearable && (\n <button\n type=\"button\"\n className={clsx(styles.swatch, styles.swatchClear)}\n aria-label={t('colorPicker.noColor')}\n aria-pressed={!parsed}\n onClick={handleClear}\n >\n {!parsed && <Icon name=\"TickCircle\" size=\"sm\" />}\n </button>\n )}\n {swatches.map((sw) => {\n const p = parseColor(sw)\n if (!p) return null\n const swHex = formatColor({ r: p.r, g: p.g, b: p.b, a: 1 })\n const selected = displayValue === swHex\n return (\n <button\n key={sw}\n type=\"button\"\n className={styles.swatch}\n style={{ background: swHex, color: contrastOn(swHex) }}\n aria-label={swHex}\n aria-pressed={selected}\n onClick={() => {\n setHsv(rgbToHsv(p))\n onChange(formatColor({ r: p.r, g: p.g, b: p.b, a: emitAlpha(alphaRef.current) }))\n }}\n >\n {selected && <Icon name=\"TickCircle\" size=\"sm\" />}\n </button>\n )\n })}\n </div>\n </div>\n )\n}\n"],"names":["clamp255","n","rgbToHsv","r","g","b","rn","gn","bn","max","min","d","h","s","hsvToRgb","v","c","x","m","hexToHsv","hex","hexToRgb","contrastOn","RGB_FUNC","parseColor","input","clamp01","a","formatColor","rgbToHex","DEFAULT_SWATCHES","FALLBACK_HSV","ColorPickerPanel","value","onChange","swatches","clearable","alphaEnabled","emitAlpha","t","useT","parsed","displayValue","hsv","setHsv","useState","hsvRef","useRef","alpha","setAlpha","alphaRef","useEffect","cur","applyHsv","next","applyAlpha","drag","onMove","event","el","move","clientX","clientY","onPointerMove","e","onPointerUp","onSvDown","y","rect","onHueDown","_y","onAlphaDown","SV_STEP","onSvKey","ns","nv","onHueKey","nh","onAlphaKey","na","colorDraft","setColorDraft","onColorInput","raw","p","handleClear","workingColor","solidHex","cpRgb","jsxs","styles","jsx","clsx","Icon","sw","swHex","selected"],"mappings":";;;;;;AAsBA,MAAMA,IAAW,CAACC,MAAsB,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,KAAK,MAAMA,CAAC,CAAC,CAAC;AAGzE,SAASC,EAAS,EAAE,GAAAC,GAAG,GAAAC,GAAG,GAAAC,KAAe;AAC9C,QAAMC,IAAKH,IAAI,KACTI,IAAKH,IAAI,KACTI,IAAKH,IAAI,KACTI,IAAM,KAAK,IAAIH,GAAIC,GAAIC,CAAE,GACzBE,IAAM,KAAK,IAAIJ,GAAIC,GAAIC,CAAE,GACzBG,IAAIF,IAAMC;AAEhB,MAAIE,IAAI;AACR,EAAID,MAAM,MACJF,MAAQH,IAAIM,KAAML,IAAKC,KAAMG,IAAK,IAC7BF,MAAQF,IAAIK,KAAKJ,IAAKF,KAAMK,IAAI,IACpCC,KAAKN,IAAKC,KAAMI,IAAI,GACzBC,KAAK,IACDA,IAAI,MAAGA,KAAK;AAElB,QAAMC,IAAIJ,MAAQ,IAAI,IAA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AAO;AACf,cAAMW,IAAQnE,EAAY,EAAE,GAAGwD,EAAE,GAAG,GAAGA,EAAE,GAAG,GAAGA,EAAE,GAAG,GAAG,GAAG,GACpDY,IAAWtD,MAAiBqD;AAClC,eACE,gBAAAJ;AAAA,UAAC;AAAA,UAAA;AAAA,YAEC,MAAK;AAAA,YACL,WAAWD,EAAO;AAAA,YAClB,OAAO,EAAE,YAAYK,GAAO,OAAOzE,GAAWyE,CAAK,EAAA;AAAA,YACnD,cAAYA;AAAA,YACZ,gBAAcC;AAAA,YACd,SAAS,MAAM;AACb,cAAApD,EAAO1C,EAASkF,CAAC,CAAC,GAClBlD,EAASN,EAAY,EAAE,GAAGwD,EAAE,GAAG,GAAGA,EAAE,GAAG,GAAGA,EAAE,GAAG,GAAG9C,EAAUY,EAAS,OAAO,EAAA,CAAG,CAAC;AAAA,YAClF;AAAA,YAEC,eAAY,gBAAAyC,EAACE,GAAA,EAAK,MAAK,cAAa,MAAK,KAAA,CAAK;AAAA,UAAA;AAAA,UAX1CC;AAAA,QAAA;AAAA,MAcX,CAAC;AAAA,IAAA,EAAA,CACH;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const p=require("react/jsx-runtime"),k=require("react"),Z=require("clsx"),N=require("./Icon-BUP5_kRs.cjs"),d=require("./color-CgR8ybWZ.cjs"),ee=require("./ConfigProvider-
|
|
2
|
-
//# sourceMappingURL=ColorPickerPanel-
|
|
1
|
+
"use strict";const p=require("react/jsx-runtime"),k=require("react"),Z=require("clsx"),N=require("./Icon-BUP5_kRs.cjs"),d=require("./color-CgR8ybWZ.cjs"),ee=require("./ConfigProvider-CzAQf_d_.cjs"),A=o=>Math.min(255,Math.max(0,Math.round(o)));function D({r:o,g:h,b:a}){const t=o/255,c=h/255,f=a/255,l=Math.max(t,c,f),n=Math.min(t,c,f),u=l-n;let i=0;u!==0&&(l===t?i=(c-f)/u%6:l===c?i=(f-t)/u+2:i=(t-c)/u+4,i*=60,i<0&&(i+=360));const x=l===0?0:u/l;return{h:i,s:x,v:l}}function T({h:o,s:h,v:a}){const t=a*h,c=t*(1-Math.abs(o/60%2-1)),f=a-t;let l=0,n=0,u=0;return o<60?[l,n,u]=[t,c,0]:o<120?[l,n,u]=[c,t,0]:o<180?[l,n,u]=[0,t,c]:o<240?[l,n,u]=[0,c,t]:o<300?[l,n,u]=[c,0,t]:[l,n,u]=[t,0,c],{r:(l+f)*255,g:(n+f)*255,b:(u+f)*255}}const re=o=>D(d.hexToRgb(o));function te(o){const{r:h,g:a,b:t}=d.hexToRgb(o);return(h*299+a*587+t*114)/1e3>=150?"#04202b":"#ffffff"}const se=/^rgba?\(\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*[, ]\s*([\d.]+)\s*(?:[,/]\s*([\d.]+%?)\s*)?\)$/i;function $(o){const h=o.trim();if(!h)return null;let a=h.replace(/^#/,"");if(/^[0-9a-fA-F]{3,4}$/.test(a)&&(a=a.split("").map(c=>c+c).join("")),/^[0-9a-fA-F]{6}$/.test(a))return{r:parseInt(a.slice(0,2),16),g:parseInt(a.slice(2,4),16),b:parseInt(a.slice(4,6),16),a:1};if(/^[0-9a-fA-F]{8}$/.test(a))return{r:parseInt(a.slice(0,2),16),g:parseInt(a.slice(2,4),16),b:parseInt(a.slice(4,6),16),a:d.clamp01(parseInt(a.slice(6,8),16)/255)};const t=h.match(se);if(t){let c=1;return t[4]!=null&&(c=t[4].endsWith("%")?d.clamp01(parseFloat(t[4])/100):d.clamp01(parseFloat(t[4]))),{r:A(+t[1]),g:A(+t[2]),b:A(+t[3]),a:c}}return null}function b({r:o,g:h,b:a,a:t}){return t>=1?d.rgbToHex({r:o,g:h,b:a}):`rgba(${A(o)}, ${A(h)}, ${A(a)}, ${Math.round(d.clamp01(t)*100)/100})`}const ae="_field_16rd0_1",ne="_fullWidth_16rd0_6",oe="_label_16rd0_11",ce="_required_16rd0_17",le="_control_16rd0_23",ie="_open_16rd0_44",ue="_error_16rd0_49",he="_disabled_16rd0_57",de="_value_16rd0_64",pe="_placeholder_16rd0_73",_e="_preview_16rd0_81",fe="_previewEmpty_16rd0_101",me="_helper_16rd0_113",be="_popover_16rd0_118",we="_sv_16rd0_128",ve="_svThumb_16rd0_139",xe="_hue_16rd0_150",ge="_hueThumb_16rd0_168",ke="_alphaThumb_16rd0_169",ye="_alpha_16rd0_169",Te="_hexRow_16rd0_202",Ae="_currentSwatch_16rd0_207",Ce="_hexField_16rd0_223",De="_hexInput_16rd0_235",je="_swatches_16rd0_247",Ie="_swatch_16rd0_247",Re="_swatchClear_16rd0_264",Me="_sm_16rd0_278",$e="_md_16rd0_282",Pe="_lg_16rd0_286",_={field:ae,fullWidth:ne,label:oe,required:ce,control:le,open:ie,error:ue,disabled:he,value:de,placeholder:pe,preview:_e,previewEmpty:fe,helper:me,popover:be,sv:we,svThumb:ve,hue:xe,hueThumb:ge,alphaThumb:ke,alpha:ye,hexRow:Te,currentSwatch:Ae,hexField:Ce,hexInput:De,swatches:je,swatch:Ie,swatchClear:Re,sm:Me,md:$e,lg:Pe},L=["#13404e","#039aa1","#00a854","#0ea5e9","#6366f1","#7c3aed","#f04134","#f59e0b","#ffbf00","#10b981","#64748b","#0f172a","#ffffff"],F=re("#13404e");function Se({value:o,onChange:h,swatches:a=L,clearable:t=!0,alpha:c=!0}){const f=r=>c?r:1,l=ee.useT(),n=$(o||""),u=n?b(n):null,[i,x]=k.useState(n?D(n):F),w=k.useRef(i);w.current=i;const[C,j]=k.useState((n==null?void 0:n.a)??1),g=k.useRef(C);g.current=C,k.useEffect(()=>{if(!n)return;const r=b({...T(w.current),a:g.current});u!==r&&(x(D(n)),j(n.a))},[u]);const I=r=>{x(r),h(b({...T(r),a:f(g.current)}))},E=r=>{j(r),h(b({...T(w.current),a:f(r)}))},P=r=>e=>{e.preventDefault();const s=e.currentTarget,m=(M,Q)=>r(M,Q,s.getBoundingClientRect());m(e.clientX,e.clientY);const v=M=>m(M.clientX,M.clientY),y=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",y)};window.addEventListener("pointermove",v),window.addEventListener("pointerup",y)},q=P((r,e,s)=>{const m=d.clamp01((r-s.left)/s.width),v=d.clamp01(1-(e-s.top)/s.height);I({...w.current,s:m,v})}),K=P((r,e,s)=>{const m=d.clamp01((r-s.left)/s.width)*360;I({...w.current,h:m})}),U=P((r,e,s)=>{E(d.clamp01((r-s.left)/s.width))}),R=.01,W=r=>{const{h:e,s,v:m}=w.current;let v=s,y=m;switch(r.key){case"ArrowLeft":v=d.clamp01(s-R);break;case"ArrowRight":v=d.clamp01(s+R);break;case"ArrowUp":y=d.clamp01(m+R);break;case"ArrowDown":y=d.clamp01(m-R);break;default:return}r.preventDefault(),I({h:e,s:v,v:y})},B=r=>{const{h:e}=w.current;let s=e;switch(r.key){case"ArrowLeft":case"ArrowDown":s=Math.max(0,e-1);break;case"ArrowRight":case"ArrowUp":s=Math.min(360,e+1);break;case"Home":s=0;break;case"End":s=360;break;default:return}r.preventDefault(),I({...w.current,h:s})},V=r=>{let e=g.current;switch(r.key){case"ArrowLeft":case"ArrowDown":e=d.clamp01(g.current-.01);break;case"ArrowRight":case"ArrowUp":e=d.clamp01(g.current+.01);break;case"Home":e=0;break;case"End":e=1;break;default:return}r.preventDefault(),E(e)},[z,H]=k.useState("");k.useEffect(()=>{H(u??"")},[u]);const X=r=>{H(r);const e=$(r);e&&(x(D(e)),j(e.a),h(b({...e,a:f(e.a)})))},Y=()=>{h(""),x(F),j(1)},G=b({...T(i),a:C}),O=d.rgbToHex(T(i)),S=T(i),J=`${Math.round(S.r)}, ${Math.round(S.g)}, ${Math.round(S.b)}`;return p.jsxs("div",{className:_.popover,style:{"--cp-hue":i.h},children:[p.jsx("div",{className:_.sv,onPointerDown:q,onKeyDown:W,role:"slider",tabIndex:0,"aria-label":l("colorPicker.saturation"),"aria-valuetext":`${Math.round(i.s*100)}% saturation, ${Math.round(i.v*100)}% brightness`,children:p.jsx("span",{className:_.svThumb,style:{left:`${i.s*100}%`,top:`${(1-i.v)*100}%`,background:O}})}),p.jsx("div",{className:_.hue,onPointerDown:K,onKeyDown:B,role:"slider",tabIndex:0,"aria-label":l("colorPicker.hue"),"aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(i.h),children:p.jsx("span",{className:_.hueThumb,style:{left:`${i.h/360*100}%`}})}),c&&p.jsx("div",{className:_.alpha,onPointerDown:U,onKeyDown:V,role:"slider",tabIndex:0,"aria-label":l("colorPicker.opacity"),"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(C*100),style:{"--cp-rgb":J},children:p.jsx("span",{className:_.alphaThumb,style:{left:`${C*100}%`}})}),p.jsxs("div",{className:_.hexRow,children:[p.jsx("span",{className:_.currentSwatch,style:{"--cp-fill":G}}),p.jsx("span",{className:_.hexField,children:p.jsx("input",{className:_.hexInput,value:z,spellCheck:!1,maxLength:28,"aria-label":l("colorPicker.value"),onChange:r=>X(r.target.value)})})]}),p.jsxs("div",{className:_.swatches,children:[t&&p.jsx("button",{type:"button",className:Z.clsx(_.swatch,_.swatchClear),"aria-label":l("colorPicker.noColor"),"aria-pressed":!n,onClick:Y,children:!n&&p.jsx(N.Icon,{name:"TickCircle",size:"sm"})}),a.map(r=>{const e=$(r);if(!e)return null;const s=b({r:e.r,g:e.g,b:e.b,a:1}),m=u===s;return p.jsx("button",{type:"button",className:_.swatch,style:{background:s,color:te(s)},"aria-label":s,"aria-pressed":m,onClick:()=>{x(D(e)),h(b({r:e.r,g:e.g,b:e.b,a:f(g.current)}))},children:m&&p.jsx(N.Icon,{name:"TickCircle",size:"sm"})},r)})]})]})}exports.ColorPickerPanel=Se;exports.DEFAULT_SWATCHES=L;exports.formatColor=b;exports.parseColor=$;exports.styles=_;
|
|
2
|
+
//# sourceMappingURL=ColorPickerPanel-CzBlh0zw.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerPanel-DXIYwUoE.cjs","sources":["../src/components/ColorPicker/colorUtils.ts","../src/components/ColorPicker/ColorPickerPanel.tsx"],"sourcesContent":["/** Color math for the ColorPicker: hex ⇄ rgb ⇄ hsv, plus hex validation. All internal, no deps. */\n\nexport interface HSV {\n /** Hue 0–360 */\n h: number\n /** Saturation 0–1 */\n s: number\n /** Value/brightness 0–1 */\n v: number\n}\n\nimport { clamp01, hexToRgb, rgbToHex, type RGB } from '../../helpers/color'\n\n// the hex ⇄ rgb primitives are shared with the palette helpers — re-exported so nothing else changes\nexport { clamp01, normalizeHex, isValidHex, hexToRgb, rgbToHex } from '../../helpers/color'\nexport type { RGB } from '../../helpers/color'\n\nexport interface RGBA extends RGB {\n /** Alpha 0–1 */\n a: number\n}\n\nconst clamp255 = (n: number): number => Math.min(255, Math.max(0, Math.round(n)))\n\n/** RGB (0–255) → HSV. */\nexport function rgbToHsv({ r, g, b }: RGB): HSV {\n const rn = r / 255\n const gn = g / 255\n const bn = b / 255\n const max = Math.max(rn, gn, bn)\n const min = Math.min(rn, gn, bn)\n const d = max - min\n\n let h = 0\n if (d !== 0) {\n if (max === rn) h = ((gn - bn) / d) % 6\n else if (max === gn) h = (bn - rn) / d + 2\n else h = (rn - gn) / d + 4\n h *= 60\n if (h < 0) h += 360\n }\n const s = max === 0 ? 0 : d / max\n return { h, s, v: max }\n}\n\n/** HSV → RGB (0–255). */\nexport function hsvToRgb({ h, s, v }: HSV): RGB {\n const c = v * s\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1))\n const m = v - c\n let r = 0\n let g = 0\n let b = 0\n if (h < 60) [r, g, b] = [c, x, 0]\n else if (h < 120) [r, g, b] = [x, c, 0]\n else if (h < 180) [r, g, b] = [0, c, x]\n else if (h < 240) [r, g, b] = [0, x, c]\n else if (h < 300) [r, g, b] = [x, 0, c]\n else [r, g, b] = [c, 0, x]\n return { r: (r + m) * 255, g: (g + m) * 255, b: (b + m) * 255 }\n}\n\nexport const hexToHsv = (hex: string): HSV => rgbToHsv(hexToRgb(hex))\nexport const hsvToHex = (hsv: HSV): string => rgbToHex(hsvToRgb(hsv))\n\n/** A readable text/handle color (near-black or white) for sitting on top of a given hex fill. */\nexport function contrastOn(hex: string): string {\n const { r, g, b } = hexToRgb(hex)\n return (r * 299 + g * 587 + b * 114) / 1000 >= 150 ? '#04202b' : '#ffffff'\n}\n\nconst RGB_FUNC =\n /^rgba?\\(\\s*([\\d.]+)\\s*[, ]\\s*([\\d.]+)\\s*[, ]\\s*([\\d.]+)\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)$/i\n\n/**\n * Parses any CSS color the picker understands — `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa` hex (with\n * or without `#`), or `rgb()` / `rgba()` (alpha as `0–1` or a `%`) — to `{ r, g, b, a }` (`a` is\n * `0–1`), or `null` when it doesn't match.\n */\nexport function parseColor(input: string): RGBA | null {\n const s = input.trim()\n if (!s) return null\n\n // hex (with or without #) — 3 / 4 / 6 / 8 digits (3 & 4 expand each nibble to a byte)\n let h = s.replace(/^#/, '')\n if (/^[0-9a-fA-F]{3,4}$/.test(h)) {\n h = h\n .split('')\n .map((c) => c + c)\n .join('')\n }\n if (/^[0-9a-fA-F]{6}$/.test(h)) {\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n a: 1,\n }\n }\n if (/^[0-9a-fA-F]{8}$/.test(h)) {\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n a: clamp01(parseInt(h.slice(6, 8), 16) / 255),\n }\n }\n\n // rgb() / rgba()\n const m = s.match(RGB_FUNC)\n if (m) {\n let a = 1\n if (m[4] != null) {\n a = m[4].endsWith('%') ? clamp01(parseFloat(m[4]) / 100) : clamp01(parseFloat(m[4]))\n }\n return { r: clamp255(+m[1]), g: clamp255(+m[2]), b: clamp255(+m[3]), a }\n }\n return null\n}\n\n/**\n * Formats `{ r, g, b, a }` back to a CSS string: `#rrggbb` when fully opaque (`a >= 1`), else\n * `rgba(r, g, b, a)` with alpha rounded to 2 decimals.\n */\nexport function formatColor({ r, g, b, a }: RGBA): string {\n if (a >= 1) return rgbToHex({ r, g, b })\n return `rgba(${clamp255(r)}, ${clamp255(g)}, ${clamp255(b)}, ${Math.round(clamp01(a) * 100) / 100})`\n}\n","import {\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { Icon } from '../Icon'\nimport {\n clamp01,\n contrastOn,\n formatColor,\n hexToHsv,\n hsvToRgb,\n parseColor,\n rgbToHex,\n rgbToHsv,\n type HSV,\n} from './colorUtils'\nimport styles from './ColorPicker.module.css'\n\n/** A pleasant default palette shown as quick-pick swatches. */\nexport const DEFAULT_SWATCHES = [\n '#13404e',\n '#039aa1',\n '#00a854',\n '#0ea5e9',\n '#6366f1',\n '#7c3aed',\n '#f04134',\n '#f59e0b',\n '#ffbf00',\n '#10b981',\n '#64748b',\n '#0f172a',\n '#ffffff',\n]\n\nconst FALLBACK_HSV: HSV = hexToHsv('#13404e')\n\nexport interface ColorPickerPanelProps {\n /** Current color — a CSS color string (`#rrggbb`, `rgba(...)`, or `''` when unset). */\n value: string\n /** Fires with the next color: `#rrggbb` when opaque, `rgba(r, g, b, a)` when translucent, `''` when cleared. */\n onChange: (color: string) => void\n /** Quick-pick swatches. Defaults to a curated palette. */\n swatches?: string[]\n /** Show the leading \"no color\" swatch that clears the value. Defaults to `true`. */\n clearable?: boolean\n /**\n * Offer opacity. Defaults to `true`. `false` hides the alpha rail and pins alpha to `1`, so the\n * panel only ever emits `#rrggbb` — for values that must be opaque (brand colors).\n */\n alpha?: boolean\n}\n\n/**\n * The color-picking surface — a saturation/value square, hue + alpha sliders, a color input and\n * quick-pick swatches. Controlled by a single color `string` (`value` / `onChange`), so it drops into\n * any popover. Working state is kept as HSV + alpha (hue survives dragging at grey/black), re-derived\n * from `value` only on external changes. Used by `ColorPicker` (the field) and the `RichTextEditor`\n * text-color control. Token-styled except the spectrum gradients + alpha checkerboard (literal colors).\n */\nexport function ColorPickerPanel({\n value,\n onChange,\n swatches = DEFAULT_SWATCHES,\n clearable = true,\n alpha: alphaEnabled = true,\n}: ColorPickerPanelProps) {\n // with opacity off every emitted color is opaque, whatever the working alpha happens to be\n const emitAlpha = (a: number) => (alphaEnabled ? a : 1)\n const t = useT()\n const parsed = parseColor(value || '')\n // canonical string for the value (`#rrggbb` when opaque, `rgba(...)` when not), null when unset\n const displayValue = parsed ? formatColor(parsed) : null\n\n // working HSV + alpha (HSV keeps hue stable while dragging at grey/black; alpha is the opacity)\n const [hsv, setHsv] = useState<HSV>(parsed ? rgbToHsv(parsed) : FALLBACK_HSV)\n const hsvRef = useRef(hsv)\n hsvRef.current = hsv\n const [alpha, setAlpha] = useState<number>(parsed?.a ?? 1)\n const alphaRef = useRef(alpha)\n alphaRef.current = alpha\n\n // re-derive HSV + alpha only when the value changes from OUTSIDE our own edits (prop/preset/input)\n useEffect(() => {\n if (!parsed) return\n const cur = formatColor({ ...hsvToRgb(hsvRef.current), a: alphaRef.current })\n if (displayValue !== cur) {\n setHsv(rgbToHsv(parsed))\n setAlpha(parsed.a)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [displayValue])\n\n const applyHsv = (next: HSV) => {\n setHsv(next)\n onChange(formatColor({ ...hsvToRgb(next), a: emitAlpha(alphaRef.current) }))\n }\n\n const applyAlpha = (next: number) => {\n setAlpha(next)\n onChange(formatColor({ ...hsvToRgb(hsvRef.current), a: emitAlpha(next) }))\n }\n\n // drag (SV square + hue/alpha sliders)\n const drag =\n (onMove: (clientX: number, clientY: number, rect: DOMRect) => void) =>\n (event: ReactPointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n const el = event.currentTarget\n const move = (clientX: number, clientY: number) =>\n onMove(clientX, clientY, el.getBoundingClientRect())\n move(event.clientX, event.clientY)\n const onPointerMove = (e: PointerEvent) => move(e.clientX, e.clientY)\n const onPointerUp = () => {\n window.removeEventListener('pointermove', onPointerMove)\n window.removeEventListener('pointerup', onPointerUp)\n }\n window.addEventListener('pointermove', onPointerMove)\n window.addEventListener('pointerup', onPointerUp)\n }\n\n const onSvDown = drag((x, y, rect) => {\n const s = clamp01((x - rect.left) / rect.width)\n const v = clamp01(1 - (y - rect.top) / rect.height)\n applyHsv({ ...hsvRef.current, s, v })\n })\n\n const onHueDown = drag((x, _y, rect) => {\n const h = clamp01((x - rect.left) / rect.width) * 360\n applyHsv({ ...hsvRef.current, h })\n })\n\n const onAlphaDown = drag((x, _y, rect) => {\n applyAlpha(clamp01((x - rect.left) / rect.width))\n })\n\n // keyboard control — arrows nudge, Home/End jump to the extents (mirrors Calendar/TimeColumns a11y)\n const SV_STEP = 0.01\n const onSvKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { h, s, v } = hsvRef.current\n let ns = s\n let nv = v\n switch (event.key) {\n case 'ArrowLeft':\n ns = clamp01(s - SV_STEP)\n break\n case 'ArrowRight':\n ns = clamp01(s + SV_STEP)\n break\n case 'ArrowUp':\n nv = clamp01(v + SV_STEP)\n break\n case 'ArrowDown':\n nv = clamp01(v - SV_STEP)\n break\n default:\n return\n }\n event.preventDefault()\n applyHsv({ h, s: ns, v: nv })\n }\n const onHueKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { h } = hsvRef.current\n let nh = h\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n nh = Math.max(0, h - 1)\n break\n case 'ArrowRight':\n case 'ArrowUp':\n nh = Math.min(360, h + 1)\n break\n case 'Home':\n nh = 0\n break\n case 'End':\n nh = 360\n break\n default:\n return\n }\n event.preventDefault()\n applyHsv({ ...hsvRef.current, h: nh })\n }\n const onAlphaKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n let na = alphaRef.current\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n na = clamp01(alphaRef.current - 0.01)\n break\n case 'ArrowRight':\n case 'ArrowUp':\n na = clamp01(alphaRef.current + 0.01)\n break\n case 'Home':\n na = 0\n break\n case 'End':\n na = 1\n break\n default:\n return\n }\n event.preventDefault()\n applyAlpha(na)\n }\n\n // color input (accepts hex / rgb() / rgba()) + clear\n const [colorDraft, setColorDraft] = useState('')\n useEffect(() => {\n setColorDraft(displayValue ?? '')\n }, [displayValue])\n\n const onColorInput = (raw: string) => {\n setColorDraft(raw)\n const p = parseColor(raw)\n if (p) {\n setHsv(rgbToHsv(p))\n setAlpha(p.a)\n onChange(formatColor({ ...p, a: emitAlpha(p.a) }))\n }\n }\n\n const handleClear = () => {\n onChange('')\n setHsv(FALLBACK_HSV)\n setAlpha(1)\n }\n\n // working color (hsv + alpha): the current swatch + the SV thumb (opaque) + the alpha track base\n const workingColor = formatColor({ ...hsvToRgb(hsv), a: alpha })\n const solidHex = rgbToHex(hsvToRgb(hsv))\n const cur = hsvToRgb(hsv)\n const cpRgb = `${Math.round(cur.r)}, ${Math.round(cur.g)}, ${Math.round(cur.b)}`\n\n return (\n <div className={styles.popover} style={{ '--cp-hue': hsv.h } as CSSProperties}>\n <div\n className={styles.sv}\n onPointerDown={onSvDown}\n onKeyDown={onSvKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.saturation')}\n aria-valuetext={`${Math.round(hsv.s * 100)}% saturation, ${Math.round(hsv.v * 100)}% brightness`}\n >\n <span\n className={styles.svThumb}\n style={{ left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%`, background: solidHex }}\n />\n </div>\n\n <div\n className={styles.hue}\n onPointerDown={onHueDown}\n onKeyDown={onHueKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.hue')}\n aria-valuemin={0}\n aria-valuemax={360}\n aria-valuenow={Math.round(hsv.h)}\n >\n <span className={styles.hueThumb} style={{ left: `${(hsv.h / 360) * 100}%` }} />\n </div>\n\n {alphaEnabled && (\n <div\n className={styles.alpha}\n onPointerDown={onAlphaDown}\n onKeyDown={onAlphaKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.opacity')}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(alpha * 100)}\n style={{ '--cp-rgb': cpRgb } as CSSProperties}\n >\n <span className={styles.alphaThumb} style={{ left: `${alpha * 100}%` }} />\n </div>\n )}\n\n <div className={styles.hexRow}>\n <span\n className={styles.currentSwatch}\n style={{ '--cp-fill': workingColor } as CSSProperties}\n />\n <span className={styles.hexField}>\n <input\n className={styles.hexInput}\n value={colorDraft}\n spellCheck={false}\n maxLength={28}\n aria-label={t('colorPicker.value')}\n onChange={(e) => onColorInput(e.target.value)}\n />\n </span>\n </div>\n\n <div className={styles.swatches}>\n {/* \"no color\" — clears the value (the diagonal-stripe swatch); hidden when not clearable */}\n {clearable && (\n <button\n type=\"button\"\n className={clsx(styles.swatch, styles.swatchClear)}\n aria-label={t('colorPicker.noColor')}\n aria-pressed={!parsed}\n onClick={handleClear}\n >\n {!parsed && <Icon name=\"TickCircle\" size=\"sm\" />}\n </button>\n )}\n {swatches.map((sw) => {\n const p = parseColor(sw)\n if (!p) return null\n const swHex = formatColor({ r: p.r, g: p.g, b: p.b, a: 1 })\n const selected = displayValue === swHex\n return (\n <button\n key={sw}\n type=\"button\"\n className={styles.swatch}\n style={{ background: swHex, color: contrastOn(swHex) }}\n aria-label={swHex}\n aria-pressed={selected}\n onClick={() => {\n setHsv(rgbToHsv(p))\n onChange(formatColor({ r: p.r, g: p.g, b: p.b, a: emitAlpha(alphaRef.current) }))\n }}\n >\n {selected && <Icon name=\"TickCircle\" size=\"sm\" />}\n </button>\n )\n })}\n </div>\n </div>\n )\n}\n"],"names":["clamp255","n","rgbToHsv","r","g","b","rn","gn","bn","max","min","d","h","s","hsvToRgb","v","c","x","m","hexToHsv","hex","hexToRgb","contrastOn","RGB_FUNC","parseColor","input","clamp01","a","formatColor","rgbToHex","DEFAULT_SWATCHES","FALLBACK_HSV","ColorPickerPanel","value","onChange","swatches","clearable","alphaEnabled","emitAlpha","t","useT","parsed","displayValue","hsv","setHsv","useState","hsvRef","useRef","alpha","setAlpha","alphaRef","useEffect","cur","applyHsv","next","applyAlpha","drag","onMove","event","el","move","clientX","clientY","onPointerMove","e","onPointerUp","onSvDown","y","rect","onHueDown","_y","onAlphaDown","SV_STEP","onSvKey","ns","nv","onHueKey","nh","onAlphaKey","na","colorDraft","setColorDraft","onColorInput","raw","p","handleClear","workingColor","solidHex","cpRgb","jsxs","styles","jsx","clsx","Icon","sw","swHex","selected"],"mappings":"sMAsBMA,EAAYC,GAAsB,KAAK,IAAI,IAAK,KAAK,IAAI,EAAG,KAAK,MAAMA,CAAC,CAAC,CAAC,EAGzE,SAASC,EAAS,CAAE,EAAAC,EAAG,EAAAC,EAAG,EAAAC,GAAe,CAC9C,MAAMC,EAAKH,EAAI,IACTI,EAAKH,EAAI,IACTI,EAAKH,EAAI,IACTI,EAAM,KAAK,IAAIH,EAAIC,EAAIC,CAAE,EACzBE,EAAM,KAAK,IAAIJ,EAAIC,EAAIC,CAAE,EACzBG,EAAIF,EAAMC,EAEhB,IAAIE,EAAI,EACJD,IAAM,IACJF,IAAQH,EAAIM,GAAML,EAAKC,GAAMG,EAAK,EAC7BF,IAAQF,EAAIK,GAAKJ,EAAKF,GAAMK,EAAI,EACpCC,GAAKN,EAAKC,GAAMI,EAAI,EACzBC,GAAK,GACDA,EAAI,IAAGA,GAAK,MAElB,MAAMC,EAAIJ,IAAQ,EAAI,EAAIE,EAAIF,EAC9B,MAAO,CAAE,EAAAG,EAAG,EAAAC,EAAG,EAAGJ,CAAA,CACpB,CAGO,SAASK,EAAS,CAAE,EAAAF,EAAG,EAAAC,EAAG,EAAAE,GAAe,CAC9C,MAAMC,EAAID,EAAIF,EACRI,EAAID,GAAK,EAAI,KAAK,IAAMJ,EAAI,GAAM,EAAK,CAAC,GACxCM,EAAIH,EAAIC,EACd,IAAI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AAE,EAAGwD,EAAE,EAAG,EAAGA,EAAE,EAAG,EAAGA,EAAE,EAAG,EAAG,EAAG,EACpDY,EAAWtD,IAAiBqD,EAClC,OACEJ,EAAAA,IAAC,SAAA,CAEC,KAAK,SACL,UAAWD,EAAO,OAClB,MAAO,CAAE,WAAYK,EAAO,MAAOzE,GAAWyE,CAAK,CAAA,EACnD,aAAYA,EACZ,eAAcC,EACd,QAAS,IAAM,CACbpD,EAAO1C,EAASkF,CAAC,CAAC,EAClBlD,EAASN,EAAY,CAAE,EAAGwD,EAAE,EAAG,EAAGA,EAAE,EAAG,EAAGA,EAAE,EAAG,EAAG9C,EAAUY,EAAS,OAAO,CAAA,CAAG,CAAC,CAClF,EAEC,YAAYyC,EAAAA,IAACE,EAAAA,KAAA,CAAK,KAAK,aAAa,KAAK,IAAA,CAAK,CAAA,EAX1CC,CAAA,CAcX,CAAC,CAAA,CAAA,CACH,CAAA,EACF,CAEJ"}
|
|
1
|
+
{"version":3,"file":"ColorPickerPanel-CzBlh0zw.cjs","sources":["../src/components/ColorPicker/colorUtils.ts","../src/components/ColorPicker/ColorPickerPanel.tsx"],"sourcesContent":["/** Color math for the ColorPicker: hex ⇄ rgb ⇄ hsv, plus hex validation. All internal, no deps. */\n\nexport interface HSV {\n /** Hue 0–360 */\n h: number\n /** Saturation 0–1 */\n s: number\n /** Value/brightness 0–1 */\n v: number\n}\n\nimport { clamp01, hexToRgb, rgbToHex, type RGB } from '../../helpers/color'\n\n// the hex ⇄ rgb primitives are shared with the palette helpers — re-exported so nothing else changes\nexport { clamp01, normalizeHex, isValidHex, hexToRgb, rgbToHex } from '../../helpers/color'\nexport type { RGB } from '../../helpers/color'\n\nexport interface RGBA extends RGB {\n /** Alpha 0–1 */\n a: number\n}\n\nconst clamp255 = (n: number): number => Math.min(255, Math.max(0, Math.round(n)))\n\n/** RGB (0–255) → HSV. */\nexport function rgbToHsv({ r, g, b }: RGB): HSV {\n const rn = r / 255\n const gn = g / 255\n const bn = b / 255\n const max = Math.max(rn, gn, bn)\n const min = Math.min(rn, gn, bn)\n const d = max - min\n\n let h = 0\n if (d !== 0) {\n if (max === rn) h = ((gn - bn) / d) % 6\n else if (max === gn) h = (bn - rn) / d + 2\n else h = (rn - gn) / d + 4\n h *= 60\n if (h < 0) h += 360\n }\n const s = max === 0 ? 0 : d / max\n return { h, s, v: max }\n}\n\n/** HSV → RGB (0–255). */\nexport function hsvToRgb({ h, s, v }: HSV): RGB {\n const c = v * s\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1))\n const m = v - c\n let r = 0\n let g = 0\n let b = 0\n if (h < 60) [r, g, b] = [c, x, 0]\n else if (h < 120) [r, g, b] = [x, c, 0]\n else if (h < 180) [r, g, b] = [0, c, x]\n else if (h < 240) [r, g, b] = [0, x, c]\n else if (h < 300) [r, g, b] = [x, 0, c]\n else [r, g, b] = [c, 0, x]\n return { r: (r + m) * 255, g: (g + m) * 255, b: (b + m) * 255 }\n}\n\nexport const hexToHsv = (hex: string): HSV => rgbToHsv(hexToRgb(hex))\nexport const hsvToHex = (hsv: HSV): string => rgbToHex(hsvToRgb(hsv))\n\n/** A readable text/handle color (near-black or white) for sitting on top of a given hex fill. */\nexport function contrastOn(hex: string): string {\n const { r, g, b } = hexToRgb(hex)\n return (r * 299 + g * 587 + b * 114) / 1000 >= 150 ? '#04202b' : '#ffffff'\n}\n\nconst RGB_FUNC =\n /^rgba?\\(\\s*([\\d.]+)\\s*[, ]\\s*([\\d.]+)\\s*[, ]\\s*([\\d.]+)\\s*(?:[,/]\\s*([\\d.]+%?)\\s*)?\\)$/i\n\n/**\n * Parses any CSS color the picker understands — `#rgb` / `#rgba` / `#rrggbb` / `#rrggbbaa` hex (with\n * or without `#`), or `rgb()` / `rgba()` (alpha as `0–1` or a `%`) — to `{ r, g, b, a }` (`a` is\n * `0–1`), or `null` when it doesn't match.\n */\nexport function parseColor(input: string): RGBA | null {\n const s = input.trim()\n if (!s) return null\n\n // hex (with or without #) — 3 / 4 / 6 / 8 digits (3 & 4 expand each nibble to a byte)\n let h = s.replace(/^#/, '')\n if (/^[0-9a-fA-F]{3,4}$/.test(h)) {\n h = h\n .split('')\n .map((c) => c + c)\n .join('')\n }\n if (/^[0-9a-fA-F]{6}$/.test(h)) {\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n a: 1,\n }\n }\n if (/^[0-9a-fA-F]{8}$/.test(h)) {\n return {\n r: parseInt(h.slice(0, 2), 16),\n g: parseInt(h.slice(2, 4), 16),\n b: parseInt(h.slice(4, 6), 16),\n a: clamp01(parseInt(h.slice(6, 8), 16) / 255),\n }\n }\n\n // rgb() / rgba()\n const m = s.match(RGB_FUNC)\n if (m) {\n let a = 1\n if (m[4] != null) {\n a = m[4].endsWith('%') ? clamp01(parseFloat(m[4]) / 100) : clamp01(parseFloat(m[4]))\n }\n return { r: clamp255(+m[1]), g: clamp255(+m[2]), b: clamp255(+m[3]), a }\n }\n return null\n}\n\n/**\n * Formats `{ r, g, b, a }` back to a CSS string: `#rrggbb` when fully opaque (`a >= 1`), else\n * `rgba(r, g, b, a)` with alpha rounded to 2 decimals.\n */\nexport function formatColor({ r, g, b, a }: RGBA): string {\n if (a >= 1) return rgbToHex({ r, g, b })\n return `rgba(${clamp255(r)}, ${clamp255(g)}, ${clamp255(b)}, ${Math.round(clamp01(a) * 100) / 100})`\n}\n","import {\n useEffect,\n useRef,\n useState,\n type CSSProperties,\n type KeyboardEvent as ReactKeyboardEvent,\n type PointerEvent as ReactPointerEvent,\n} from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { Icon } from '../Icon'\nimport {\n clamp01,\n contrastOn,\n formatColor,\n hexToHsv,\n hsvToRgb,\n parseColor,\n rgbToHex,\n rgbToHsv,\n type HSV,\n} from './colorUtils'\nimport styles from './ColorPicker.module.css'\n\n/** A pleasant default palette shown as quick-pick swatches. */\nexport const DEFAULT_SWATCHES = [\n '#13404e',\n '#039aa1',\n '#00a854',\n '#0ea5e9',\n '#6366f1',\n '#7c3aed',\n '#f04134',\n '#f59e0b',\n '#ffbf00',\n '#10b981',\n '#64748b',\n '#0f172a',\n '#ffffff',\n]\n\nconst FALLBACK_HSV: HSV = hexToHsv('#13404e')\n\nexport interface ColorPickerPanelProps {\n /** Current color — a CSS color string (`#rrggbb`, `rgba(...)`, or `''` when unset). */\n value: string\n /** Fires with the next color: `#rrggbb` when opaque, `rgba(r, g, b, a)` when translucent, `''` when cleared. */\n onChange: (color: string) => void\n /** Quick-pick swatches. Defaults to a curated palette. */\n swatches?: string[]\n /** Show the leading \"no color\" swatch that clears the value. Defaults to `true`. */\n clearable?: boolean\n /**\n * Offer opacity. Defaults to `true`. `false` hides the alpha rail and pins alpha to `1`, so the\n * panel only ever emits `#rrggbb` — for values that must be opaque (brand colors).\n */\n alpha?: boolean\n}\n\n/**\n * The color-picking surface — a saturation/value square, hue + alpha sliders, a color input and\n * quick-pick swatches. Controlled by a single color `string` (`value` / `onChange`), so it drops into\n * any popover. Working state is kept as HSV + alpha (hue survives dragging at grey/black), re-derived\n * from `value` only on external changes. Used by `ColorPicker` (the field) and the `RichTextEditor`\n * text-color control. Token-styled except the spectrum gradients + alpha checkerboard (literal colors).\n */\nexport function ColorPickerPanel({\n value,\n onChange,\n swatches = DEFAULT_SWATCHES,\n clearable = true,\n alpha: alphaEnabled = true,\n}: ColorPickerPanelProps) {\n // with opacity off every emitted color is opaque, whatever the working alpha happens to be\n const emitAlpha = (a: number) => (alphaEnabled ? a : 1)\n const t = useT()\n const parsed = parseColor(value || '')\n // canonical string for the value (`#rrggbb` when opaque, `rgba(...)` when not), null when unset\n const displayValue = parsed ? formatColor(parsed) : null\n\n // working HSV + alpha (HSV keeps hue stable while dragging at grey/black; alpha is the opacity)\n const [hsv, setHsv] = useState<HSV>(parsed ? rgbToHsv(parsed) : FALLBACK_HSV)\n const hsvRef = useRef(hsv)\n hsvRef.current = hsv\n const [alpha, setAlpha] = useState<number>(parsed?.a ?? 1)\n const alphaRef = useRef(alpha)\n alphaRef.current = alpha\n\n // re-derive HSV + alpha only when the value changes from OUTSIDE our own edits (prop/preset/input)\n useEffect(() => {\n if (!parsed) return\n const cur = formatColor({ ...hsvToRgb(hsvRef.current), a: alphaRef.current })\n if (displayValue !== cur) {\n setHsv(rgbToHsv(parsed))\n setAlpha(parsed.a)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [displayValue])\n\n const applyHsv = (next: HSV) => {\n setHsv(next)\n onChange(formatColor({ ...hsvToRgb(next), a: emitAlpha(alphaRef.current) }))\n }\n\n const applyAlpha = (next: number) => {\n setAlpha(next)\n onChange(formatColor({ ...hsvToRgb(hsvRef.current), a: emitAlpha(next) }))\n }\n\n // drag (SV square + hue/alpha sliders)\n const drag =\n (onMove: (clientX: number, clientY: number, rect: DOMRect) => void) =>\n (event: ReactPointerEvent<HTMLDivElement>) => {\n event.preventDefault()\n const el = event.currentTarget\n const move = (clientX: number, clientY: number) =>\n onMove(clientX, clientY, el.getBoundingClientRect())\n move(event.clientX, event.clientY)\n const onPointerMove = (e: PointerEvent) => move(e.clientX, e.clientY)\n const onPointerUp = () => {\n window.removeEventListener('pointermove', onPointerMove)\n window.removeEventListener('pointerup', onPointerUp)\n }\n window.addEventListener('pointermove', onPointerMove)\n window.addEventListener('pointerup', onPointerUp)\n }\n\n const onSvDown = drag((x, y, rect) => {\n const s = clamp01((x - rect.left) / rect.width)\n const v = clamp01(1 - (y - rect.top) / rect.height)\n applyHsv({ ...hsvRef.current, s, v })\n })\n\n const onHueDown = drag((x, _y, rect) => {\n const h = clamp01((x - rect.left) / rect.width) * 360\n applyHsv({ ...hsvRef.current, h })\n })\n\n const onAlphaDown = drag((x, _y, rect) => {\n applyAlpha(clamp01((x - rect.left) / rect.width))\n })\n\n // keyboard control — arrows nudge, Home/End jump to the extents (mirrors Calendar/TimeColumns a11y)\n const SV_STEP = 0.01\n const onSvKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { h, s, v } = hsvRef.current\n let ns = s\n let nv = v\n switch (event.key) {\n case 'ArrowLeft':\n ns = clamp01(s - SV_STEP)\n break\n case 'ArrowRight':\n ns = clamp01(s + SV_STEP)\n break\n case 'ArrowUp':\n nv = clamp01(v + SV_STEP)\n break\n case 'ArrowDown':\n nv = clamp01(v - SV_STEP)\n break\n default:\n return\n }\n event.preventDefault()\n applyHsv({ h, s: ns, v: nv })\n }\n const onHueKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n const { h } = hsvRef.current\n let nh = h\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n nh = Math.max(0, h - 1)\n break\n case 'ArrowRight':\n case 'ArrowUp':\n nh = Math.min(360, h + 1)\n break\n case 'Home':\n nh = 0\n break\n case 'End':\n nh = 360\n break\n default:\n return\n }\n event.preventDefault()\n applyHsv({ ...hsvRef.current, h: nh })\n }\n const onAlphaKey = (event: ReactKeyboardEvent<HTMLDivElement>) => {\n let na = alphaRef.current\n switch (event.key) {\n case 'ArrowLeft':\n case 'ArrowDown':\n na = clamp01(alphaRef.current - 0.01)\n break\n case 'ArrowRight':\n case 'ArrowUp':\n na = clamp01(alphaRef.current + 0.01)\n break\n case 'Home':\n na = 0\n break\n case 'End':\n na = 1\n break\n default:\n return\n }\n event.preventDefault()\n applyAlpha(na)\n }\n\n // color input (accepts hex / rgb() / rgba()) + clear\n const [colorDraft, setColorDraft] = useState('')\n useEffect(() => {\n setColorDraft(displayValue ?? '')\n }, [displayValue])\n\n const onColorInput = (raw: string) => {\n setColorDraft(raw)\n const p = parseColor(raw)\n if (p) {\n setHsv(rgbToHsv(p))\n setAlpha(p.a)\n onChange(formatColor({ ...p, a: emitAlpha(p.a) }))\n }\n }\n\n const handleClear = () => {\n onChange('')\n setHsv(FALLBACK_HSV)\n setAlpha(1)\n }\n\n // working color (hsv + alpha): the current swatch + the SV thumb (opaque) + the alpha track base\n const workingColor = formatColor({ ...hsvToRgb(hsv), a: alpha })\n const solidHex = rgbToHex(hsvToRgb(hsv))\n const cur = hsvToRgb(hsv)\n const cpRgb = `${Math.round(cur.r)}, ${Math.round(cur.g)}, ${Math.round(cur.b)}`\n\n return (\n <div className={styles.popover} style={{ '--cp-hue': hsv.h } as CSSProperties}>\n <div\n className={styles.sv}\n onPointerDown={onSvDown}\n onKeyDown={onSvKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.saturation')}\n aria-valuetext={`${Math.round(hsv.s * 100)}% saturation, ${Math.round(hsv.v * 100)}% brightness`}\n >\n <span\n className={styles.svThumb}\n style={{ left: `${hsv.s * 100}%`, top: `${(1 - hsv.v) * 100}%`, background: solidHex }}\n />\n </div>\n\n <div\n className={styles.hue}\n onPointerDown={onHueDown}\n onKeyDown={onHueKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.hue')}\n aria-valuemin={0}\n aria-valuemax={360}\n aria-valuenow={Math.round(hsv.h)}\n >\n <span className={styles.hueThumb} style={{ left: `${(hsv.h / 360) * 100}%` }} />\n </div>\n\n {alphaEnabled && (\n <div\n className={styles.alpha}\n onPointerDown={onAlphaDown}\n onKeyDown={onAlphaKey}\n role=\"slider\"\n tabIndex={0}\n aria-label={t('colorPicker.opacity')}\n aria-valuemin={0}\n aria-valuemax={100}\n aria-valuenow={Math.round(alpha * 100)}\n style={{ '--cp-rgb': cpRgb } as CSSProperties}\n >\n <span className={styles.alphaThumb} style={{ left: `${alpha * 100}%` }} />\n </div>\n )}\n\n <div className={styles.hexRow}>\n <span\n className={styles.currentSwatch}\n style={{ '--cp-fill': workingColor } as CSSProperties}\n />\n <span className={styles.hexField}>\n <input\n className={styles.hexInput}\n value={colorDraft}\n spellCheck={false}\n maxLength={28}\n aria-label={t('colorPicker.value')}\n onChange={(e) => onColorInput(e.target.value)}\n />\n </span>\n </div>\n\n <div className={styles.swatches}>\n {/* \"no color\" — clears the value (the diagonal-stripe swatch); hidden when not clearable */}\n {clearable && (\n <button\n type=\"button\"\n className={clsx(styles.swatch, styles.swatchClear)}\n aria-label={t('colorPicker.noColor')}\n aria-pressed={!parsed}\n onClick={handleClear}\n >\n {!parsed && <Icon name=\"TickCircle\" size=\"sm\" />}\n </button>\n )}\n {swatches.map((sw) => {\n const p = parseColor(sw)\n if (!p) return null\n const swHex = formatColor({ r: p.r, g: p.g, b: p.b, a: 1 })\n const selected = displayValue === swHex\n return (\n <button\n key={sw}\n type=\"button\"\n className={styles.swatch}\n style={{ background: swHex, color: contrastOn(swHex) }}\n aria-label={swHex}\n aria-pressed={selected}\n onClick={() => {\n setHsv(rgbToHsv(p))\n onChange(formatColor({ r: p.r, g: p.g, b: p.b, a: emitAlpha(alphaRef.current) }))\n }}\n >\n {selected && <Icon name=\"TickCircle\" size=\"sm\" />}\n </button>\n )\n })}\n </div>\n </div>\n )\n}\n"],"names":["clamp255","n","rgbToHsv","r","g","b","rn","gn","bn","max","min","d","h","s","hsvToRgb","v","c","x","m","hexToHsv","hex","hexToRgb","contrastOn","RGB_FUNC","parseColor","input","clamp01","a","formatColor","rgbToHex","DEFAULT_SWATCHES","FALLBACK_HSV","ColorPickerPanel","value","onChange","swatches","clearable","alphaEnabled","emitAlpha","t","useT","parsed","displayValue","hsv","setHsv","useState","hsvRef","useRef","alpha","setAlpha","alphaRef","useEffect","cur","applyHsv","next","applyAlpha","drag","onMove","event","el","move","clientX","clientY","onPointerMove","e","onPointerUp","onSvDown","y","rect","onHueDown","_y","onAlphaDown","SV_STEP","onSvKey","ns","nv","onHueKey","nh","onAlphaKey","na","colorDraft","setColorDraft","onColorInput","raw","p","handleClear","workingColor","solidHex","cpRgb","jsxs","styles","jsx","clsx","Icon","sw","swHex","selected"],"mappings":"sMAsBMA,EAAYC,GAAsB,KAAK,IAAI,IAAK,KAAK,IAAI,EAAG,KAAK,MAAMA,CAAC,CAAC,CAAC,EAGzE,SAASC,EAAS,CAAE,EAAAC,EAAG,EAAAC,EAAG,EAAAC,GAAe,CAC9C,MAAMC,EAAKH,EAAI,IAC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,CAEJ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const s=require("react/jsx-runtime"),v=require("react"),m=require("clsx"),L=require("./useClipboard-BjTIX-4g.cjs"),h=require("./palette-BycMHbED.cjs"),D=require("./Tooltip-Bw-1Xk2Z.cjs"),i=require("./Typography-B6ASPrzT.cjs"),T=require("./toastStore-B4Tk2Xk7.cjs"),n=require("./TextField.module-DsNCo8vN.cjs"),W=require("./ConfigProvider-
|
|
2
|
-
//# sourceMappingURL=ColorRamp-
|
|
1
|
+
"use strict";const s=require("react/jsx-runtime"),v=require("react"),m=require("clsx"),L=require("./useClipboard-BjTIX-4g.cjs"),h=require("./palette-BycMHbED.cjs"),D=require("./Tooltip-Bw-1Xk2Z.cjs"),i=require("./Typography-B6ASPrzT.cjs"),T=require("./toastStore-B4Tk2Xk7.cjs"),n=require("./TextField.module-DsNCo8vN.cjs"),W=require("./ConfigProvider-CzAQf_d_.cjs"),z="_band_1d0th_5",G="_sm_1d0th_15",H="_md_1d0th_18",J="_lg_1d0th_21",K="_num_1d0th_42",M="_step_1d0th_47",O="_bounds_1d0th_94",Q="_tip_1d0th_101",U="_tipTitle_1d0th_107",o={band:z,sm:G,md:H,lg:J,num:K,step:M,static:"_static_1d0th_61",bounds:O,tip:Q,tipTitle:U},$=(x,l)=>`${x} ${l.ratio.toFixed(2)}${l.small?` ${l.small}`:""}`,V=v.forwardRef(function({baseColor:l,name:a="color",options:f,size:N="md",copyable:_=!0,onCopy:c,showBounds:S=!0,label:d,helperText:p,error:b=!1,required:q=!1,className:k,...C},E){const t=W.useT(),y=v.useId(),j=`${y}-label`,g=`${y}-helper`,{copy:F}=L.useClipboard(),R=h.generatePalette(l,f),P=async e=>{const r=`${a}-${e.step}`;await F(e.hex)?(T.toast.success(t("colorRamp.copied",{step:r,hex:e.hex})),c==null||c(e)):T.toast.error(t("colorRamp.copyFailed",{step:r}))},A=e=>s.jsxs("span",{className:o.tip,children:[s.jsxs("span",{className:o.tipTitle,children:[a,"-",e.step,e.step===h.BASE_STEP?` · ${t("colorRamp.base")}`:""]}),s.jsx("span",{children:e.hex}),s.jsxs("span",{children:[$(t("colorRamp.black"),e.onDark)," ·"," ",$(t("colorRamp.white"),e.onWhite)]}),_&&s.jsx("span",{children:t("colorRamp.clickToCopy")})]});return s.jsxs("div",{ref:E,className:m.clsx(n.fieldStyles.field,b&&n.fieldStyles.error,k),...C,children:[d!=null&&s.jsxs("label",{id:j,className:n.fieldStyles.label,children:[s.jsx(i.Typography,{as:"span",variant:"bodySmall",color:"muted",children:d}),q&&s.jsx("span",{className:n.fieldStyles.required,"aria-hidden":"true",children:"*"})]}),R?s.jsxs(s.Fragment,{children:[s.jsx("div",{role:"group","aria-label":t("colorRamp.groupLabel",{name:a}),"aria-labelledby":d!=null?j:void 0,"aria-describedby":p!=null?g:void 0,className:m.clsx(o.band,o[N]),children:R.map(e=>{const r=e.step===h.BASE_STEP,u={backgroundColor:e.hex,color:e.textColor},B=`${a}-${e.step}`,I=_?s.jsx("button",{type:"button",className:o.step,style:u,"data-base":r||void 0,"aria-label":t("colorRamp.copyAria",{name:a,step:e.step,hex:e.hex}),onClick:()=>void P(e),children:s.jsx("span",{className:o.num,"aria-hidden":"true",children:e.step})}):s.jsx("span",{className:m.clsx(o.step,o.static),style:u,"data-base":r||void 0,role:"img","aria-label":`${B} ${e.hex}`,children:s.jsx("span",{className:o.num,"aria-hidden":"true",children:e.step})});return s.jsx(D.Tooltip,{content:A(e),children:I},e.step)})}),S&&s.jsxs("div",{className:o.bounds,children:[s.jsx(i.Typography,{as:"span",variant:"caption",color:"muted",children:t("colorRamp.lightest")}),s.jsx(i.Typography,{as:"span",variant:"caption",color:"muted",children:t("colorRamp.darkest")})]})]}):s.jsx(i.Typography,{as:"span",variant:"caption",color:"muted",children:t("colorRamp.invalid")}),p!=null&&s.jsx(i.Typography,{as:"span",id:g,variant:"bodySmall",color:b?"error":"muted",className:n.fieldStyles.helper,children:p})]})});exports.ColorRamp=V;
|
|
2
|
+
//# sourceMappingURL=ColorRamp-D_h-hp7n.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorRamp-B45Rtwgw.cjs","sources":["../src/components/ColorRamp/ColorRamp.tsx"],"sourcesContent":["import { forwardRef, useId, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { useClipboard } from '../../hooks/useClipboard'\nimport {\n BASE_STEP,\n generatePalette,\n type GeneratePaletteOptions,\n type Legibility,\n type PaletteSwatch,\n} from '../../helpers/palette'\nimport { Tooltip } from '../Tooltip'\nimport { Typography } from '../Typography'\nimport { toast } from '../Toast'\n// shared field chrome (wrapper / label / helper / required / error)\nimport fieldStyles from '../TextField/TextField.module.css'\nimport styles from './ColorRamp.module.css'\n\nexport type ColorRampSize = 'sm' | 'md' | 'lg'\n\n// `onCopy` here is the swatch callback, so the DOM clipboard `onCopy` handler is omitted alongside `color`\nexport interface ColorRampProps extends Omit<HTMLAttributes<HTMLDivElement>, 'color' | 'onCopy'> {\n /** The base (500) color — any value `generatePalette` accepts. Invalid → the empty-state caption. */\n baseColor: string\n /** Token prefix for step names (`primary` → \"primary-500\") — used in tooltips, aria-labels and the copy toast. Default `'color'`. */\n name?: string\n /** Passed to `generatePalette` (override any subset of the tint / shade fractions). */\n options?: GeneratePaletteOptions\n /** Band height. `sm` 32 · `md` 40 (default) · `lg` 48 px. */\n size?: ColorRampSize\n /** Click a step to copy its hex (default `true`). `false` renders the steps as non-interactive cells. */\n copyable?: boolean\n /** After a successful copy — in addition to the built-in toast. */\n onCopy?: (swatch: PaletteSwatch) => void\n /** Show the \"Lightest … Darkest\" caption row under the band (default `true`). */\n showBounds?: boolean\n /** Label rendered above the band (field-family chrome, like `Slider` / `SwatchPicker`). */\n label?: ReactNode\n /** Helper / validation text under the band. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Marks the field invalid — reddens the label/asterisk and shows `helperText` in the error color. */\n error?: boolean\n /** Adds a red asterisk after the label. */\n required?: boolean\n}\n\n/** `black 4.52 AA` — ratio to 2 decimals, the body-text rating appended when it exists. */\nconst contrastLine = (who: string, l: Legibility) =>\n `${who} ${l.ratio.toFixed(2)}${l.small ? ` ${l.small}` : ''}`\n\n/**\n * The generated tonal scale for one color as **a single horizontal band of ten equal steps** sharing\n * one rounded, clipped frame (reads as a continuous ramp, not ten chips). Display + copy only — it never\n * edits the color; pair it with `ColorPicker` (or use `PaletteField`, which composes both). Each step\n * is a `Tooltip`-wrapped button whose fill / ink are the swatch's own colors (inline — the color IS the\n * data), showing its number on the base step and on hover / focus; clicking copies the hex with a toast.\n * `role=\"group\"` labelled \"{name} color scale\"; an invalid `baseColor` renders only a muted caption.\n */\nexport const ColorRamp = forwardRef<HTMLDivElement, ColorRampProps>(function ColorRamp(\n {\n baseColor,\n name = 'color',\n options,\n size = 'md',\n copyable = true,\n onCopy,\n showBounds = true,\n label,\n helperText,\n error = false,\n required = false,\n className,\n ...props\n },\n ref,\n) {\n const t = useT()\n const id = useId()\n const labelId = `${id}-label`\n const helperId = `${id}-helper`\n const { copy } = useClipboard()\n const palette = generatePalette(baseColor, options)\n\n const handleCopy = async (swatch: PaletteSwatch) => {\n const step = `${name}-${swatch.step}`\n const ok = await copy(swatch.hex)\n if (ok) {\n toast.success(t('colorRamp.copied', { step, hex: swatch.hex }))\n onCopy?.(swatch)\n } else {\n toast.error(t('colorRamp.copyFailed', { step }))\n }\n }\n\n const tip = (swatch: PaletteSwatch) => (\n <span className={styles.tip}>\n <span className={styles.tipTitle}>\n {name}-{swatch.step}\n {swatch.step === BASE_STEP ? ` · ${t('colorRamp.base')}` : ''}\n </span>\n <span>{swatch.hex}</span>\n <span>\n {contrastLine(t('colorRamp.black'), swatch.onDark)} ·{' '}\n {contrastLine(t('colorRamp.white'), swatch.onWhite)}\n </span>\n {copyable && <span>{t('colorRamp.clickToCopy')}</span>}\n </span>\n )\n\n return (\n <div\n ref={ref}\n className={clsx(fieldStyles.field, error && fieldStyles.error, className)}\n {...props}\n >\n {label != null && (\n <label id={labelId} className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n {palette ? (\n <>\n <div\n role=\"group\"\n aria-label={t('colorRamp.groupLabel', { name })}\n aria-labelledby={label != null ? labelId : undefined}\n aria-describedby={helperText != null ? helperId : undefined}\n className={clsx(styles.band, styles[size])}\n >\n {palette.map((swatch) => {\n const isBase = swatch.step === BASE_STEP\n // the swatch's own colors are the data — the one legitimate inline-color exception\n const ink = { backgroundColor: swatch.hex, color: swatch.textColor } as CSSProperties\n const stepName = `${name}-${swatch.step}`\n const cell = copyable ? (\n <button\n type=\"button\"\n className={styles.step}\n style={ink}\n data-base={isBase || undefined}\n aria-label={t('colorRamp.copyAria', { name, step: swatch.step, hex: swatch.hex })}\n onClick={() => void handleCopy(swatch)}\n >\n <span className={styles.num} aria-hidden=\"true\">\n {swatch.step}\n </span>\n </button>\n ) : (\n <span\n className={clsx(styles.step, styles.static)}\n style={ink}\n data-base={isBase || undefined}\n role=\"img\"\n aria-label={`${stepName} ${swatch.hex}`}\n >\n <span className={styles.num} aria-hidden=\"true\">\n {swatch.step}\n </span>\n </span>\n )\n // the Tooltip's wrapper span is the band's real flex child (sized by `.band > *`)\n return (\n <Tooltip key={swatch.step} content={tip(swatch)}>\n {cell}\n </Tooltip>\n )\n })}\n </div>\n {showBounds && (\n <div className={styles.bounds}>\n <Typography as=\"span\" variant=\"caption\" color=\"muted\">\n {t('colorRamp.lightest')}\n </Typography>\n <Typography as=\"span\" variant=\"caption\" color=\"muted\">\n {t('colorRamp.darkest')}\n </Typography>\n </div>\n )}\n </>\n ) : (\n <Typography as=\"span\" variant=\"caption\" color=\"muted\">\n {t('colorRamp.invalid')}\n </Typography>\n )}\n\n {helperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={error ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {helperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["contrastLine","who","ColorRamp","forwardRef","baseColor","name","options","size","copyable","onCopy","showBounds","label","helperText","error","required","className","props","ref","useT","id","useId","labelId","helperId","copy","useClipboard","palette","generatePalette","handleCopy","swatch","step","toast","tip","styles","jsxs","BASE_STEP","jsx","clsx","fieldStyles","Typography","Fragment","isBase","ink","stepName","cell","Tooltip"],"mappings":"mnBA+CMA,EAAe,CAACC,EAAa,IACjC,GAAGA,CAAG,IAAI,EAAE,MAAM,QAAQ,CAAC,CAAC,GAAG,EAAE,MAAQ,IAAI,EAAE,KAAK,GAAK,EAAE,GAUhDC,EAAYC,EAAAA,WAA2C,SAClE,CACE,UAAAC,EACA,KAAAC,EAAO,QACP,QAAAC,EACA,KAAAC,EAAO,KACP,SAAAC,EAAW,GACX,OAAAC,EACA,WAAAC,EAAa,GACb,MAAAC,EACA,WAAAC,EACA,MAAAC,EAAQ,GACR,SAAAC,EAAW,GACX,UAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAM,EAAIC,EAAAA,KAAA,EACJC,EAAKC,EAAAA,MAAA,EACLC,EAAU,GAAGF,CAAE,SACfG,EAAW,GAAGH,CAAE,UAChB,CAAE,KAAAI,CAAA,EAASC,eAAA,EACXC,EAAUC,EAAAA,gBAAgBtB,EAAWE,CAAO,EAE5CqB,EAAa,MAAOC,GAA0B,CAClD,MAAMC,EAAO,GAAGxB,CAAI,IAAIuB,EAAO,IAAI,GACxB,MAAML,EAAKK,EAAO,GAAG,GAE9BE,QAAM,QAAQ,EAAE,mBAAoB,CAAE,KAAAD,EAAM,IAAKD,EAAO,GAAA,CAAK,CAAC,EAC9DnB,GAAA,MAAAA,EAASmB,IAETE,EAAAA,MAAM,MAAM,EAAE,uBAAwB,CAAE,KAAAD,CAAA,CAAM,CAAC,CAEnD,EAEME,EAAOH,UACV,OAAA,CAAK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CACxB,EAGD1B,GAAc,MACbuB,EAAAA,IAACG,EAAAA,WAAA,CACC,GAAG,OACH,GAAIhB,EACJ,QAAQ,YACR,MAAOT,EAAQ,QAAU,QACzB,UAAWwB,EAAAA,YAAY,OAEtB,SAAAzB,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CAAC"}
|
|
1
|
+
{"version":3,"file":"ColorRamp-D_h-hp7n.cjs","sources":["../src/components/ColorRamp/ColorRamp.tsx"],"sourcesContent":["import { forwardRef, useId, type CSSProperties, type HTMLAttributes, type ReactNode } from 'react'\nimport { clsx } from 'clsx'\nimport { useT } from '../../theme'\nimport { useClipboard } from '../../hooks/useClipboard'\nimport {\n BASE_STEP,\n generatePalette,\n type GeneratePaletteOptions,\n type Legibility,\n type PaletteSwatch,\n} from '../../helpers/palette'\nimport { Tooltip } from '../Tooltip'\nimport { Typography } from '../Typography'\nimport { toast } from '../Toast'\n// shared field chrome (wrapper / label / helper / required / error)\nimport fieldStyles from '../TextField/TextField.module.css'\nimport styles from './ColorRamp.module.css'\n\nexport type ColorRampSize = 'sm' | 'md' | 'lg'\n\n// `onCopy` here is the swatch callback, so the DOM clipboard `onCopy` handler is omitted alongside `color`\nexport interface ColorRampProps extends Omit<HTMLAttributes<HTMLDivElement>, 'color' | 'onCopy'> {\n /** The base (500) color — any value `generatePalette` accepts. Invalid → the empty-state caption. */\n baseColor: string\n /** Token prefix for step names (`primary` → \"primary-500\") — used in tooltips, aria-labels and the copy toast. Default `'color'`. */\n name?: string\n /** Passed to `generatePalette` (override any subset of the tint / shade fractions). */\n options?: GeneratePaletteOptions\n /** Band height. `sm` 32 · `md` 40 (default) · `lg` 48 px. */\n size?: ColorRampSize\n /** Click a step to copy its hex (default `true`). `false` renders the steps as non-interactive cells. */\n copyable?: boolean\n /** After a successful copy — in addition to the built-in toast. */\n onCopy?: (swatch: PaletteSwatch) => void\n /** Show the \"Lightest … Darkest\" caption row under the band (default `true`). */\n showBounds?: boolean\n /** Label rendered above the band (field-family chrome, like `Slider` / `SwatchPicker`). */\n label?: ReactNode\n /** Helper / validation text under the band. Adopts the error color while `error`. */\n helperText?: ReactNode\n /** Marks the field invalid — reddens the label/asterisk and shows `helperText` in the error color. */\n error?: boolean\n /** Adds a red asterisk after the label. */\n required?: boolean\n}\n\n/** `black 4.52 AA` — ratio to 2 decimals, the body-text rating appended when it exists. */\nconst contrastLine = (who: string, l: Legibility) =>\n `${who} ${l.ratio.toFixed(2)}${l.small ? ` ${l.small}` : ''}`\n\n/**\n * The generated tonal scale for one color as **a single horizontal band of ten equal steps** sharing\n * one rounded, clipped frame (reads as a continuous ramp, not ten chips). Display + copy only — it never\n * edits the color; pair it with `ColorPicker` (or use `PaletteField`, which composes both). Each step\n * is a `Tooltip`-wrapped button whose fill / ink are the swatch's own colors (inline — the color IS the\n * data), showing its number on the base step and on hover / focus; clicking copies the hex with a toast.\n * `role=\"group\"` labelled \"{name} color scale\"; an invalid `baseColor` renders only a muted caption.\n */\nexport const ColorRamp = forwardRef<HTMLDivElement, ColorRampProps>(function ColorRamp(\n {\n baseColor,\n name = 'color',\n options,\n size = 'md',\n copyable = true,\n onCopy,\n showBounds = true,\n label,\n helperText,\n error = false,\n required = false,\n className,\n ...props\n },\n ref,\n) {\n const t = useT()\n const id = useId()\n const labelId = `${id}-label`\n const helperId = `${id}-helper`\n const { copy } = useClipboard()\n const palette = generatePalette(baseColor, options)\n\n const handleCopy = async (swatch: PaletteSwatch) => {\n const step = `${name}-${swatch.step}`\n const ok = await copy(swatch.hex)\n if (ok) {\n toast.success(t('colorRamp.copied', { step, hex: swatch.hex }))\n onCopy?.(swatch)\n } else {\n toast.error(t('colorRamp.copyFailed', { step }))\n }\n }\n\n const tip = (swatch: PaletteSwatch) => (\n <span className={styles.tip}>\n <span className={styles.tipTitle}>\n {name}-{swatch.step}\n {swatch.step === BASE_STEP ? ` · ${t('colorRamp.base')}` : ''}\n </span>\n <span>{swatch.hex}</span>\n <span>\n {contrastLine(t('colorRamp.black'), swatch.onDark)} ·{' '}\n {contrastLine(t('colorRamp.white'), swatch.onWhite)}\n </span>\n {copyable && <span>{t('colorRamp.clickToCopy')}</span>}\n </span>\n )\n\n return (\n <div\n ref={ref}\n className={clsx(fieldStyles.field, error && fieldStyles.error, className)}\n {...props}\n >\n {label != null && (\n <label id={labelId} className={fieldStyles.label}>\n <Typography as=\"span\" variant=\"bodySmall\" color=\"muted\">\n {label}\n </Typography>\n {required && (\n <span className={fieldStyles.required} aria-hidden=\"true\">\n *\n </span>\n )}\n </label>\n )}\n\n {palette ? (\n <>\n <div\n role=\"group\"\n aria-label={t('colorRamp.groupLabel', { name })}\n aria-labelledby={label != null ? labelId : undefined}\n aria-describedby={helperText != null ? helperId : undefined}\n className={clsx(styles.band, styles[size])}\n >\n {palette.map((swatch) => {\n const isBase = swatch.step === BASE_STEP\n // the swatch's own colors are the data — the one legitimate inline-color exception\n const ink = { backgroundColor: swatch.hex, color: swatch.textColor } as CSSProperties\n const stepName = `${name}-${swatch.step}`\n const cell = copyable ? (\n <button\n type=\"button\"\n className={styles.step}\n style={ink}\n data-base={isBase || undefined}\n aria-label={t('colorRamp.copyAria', { name, step: swatch.step, hex: swatch.hex })}\n onClick={() => void handleCopy(swatch)}\n >\n <span className={styles.num} aria-hidden=\"true\">\n {swatch.step}\n </span>\n </button>\n ) : (\n <span\n className={clsx(styles.step, styles.static)}\n style={ink}\n data-base={isBase || undefined}\n role=\"img\"\n aria-label={`${stepName} ${swatch.hex}`}\n >\n <span className={styles.num} aria-hidden=\"true\">\n {swatch.step}\n </span>\n </span>\n )\n // the Tooltip's wrapper span is the band's real flex child (sized by `.band > *`)\n return (\n <Tooltip key={swatch.step} content={tip(swatch)}>\n {cell}\n </Tooltip>\n )\n })}\n </div>\n {showBounds && (\n <div className={styles.bounds}>\n <Typography as=\"span\" variant=\"caption\" color=\"muted\">\n {t('colorRamp.lightest')}\n </Typography>\n <Typography as=\"span\" variant=\"caption\" color=\"muted\">\n {t('colorRamp.darkest')}\n </Typography>\n </div>\n )}\n </>\n ) : (\n <Typography as=\"span\" variant=\"caption\" color=\"muted\">\n {t('colorRamp.invalid')}\n </Typography>\n )}\n\n {helperText != null && (\n <Typography\n as=\"span\"\n id={helperId}\n variant=\"bodySmall\"\n color={error ? 'error' : 'muted'}\n className={fieldStyles.helper}\n >\n {helperText}\n </Typography>\n )}\n </div>\n )\n})\n"],"names":["contrastLine","who","ColorRamp","forwardRef","baseColor","name","options","size","copyable","onCopy","showBounds","label","helperText","error","required","className","props","ref","useT","id","useId","labelId","helperId","copy","useClipboard","palette","generatePalette","handleCopy","swatch","step","toast","tip","styles","jsxs","BASE_STEP","jsx","clsx","fieldStyles","Typography","Fragment","isBase","ink","stepName","cell","Tooltip"],"mappings":"mnBA+CMA,EAAe,CAACC,EAAa,IACjC,GAAGA,CAAG,IAAI,EAAE,MAAM,QAAQ,CAAC,CAAC,GAAG,EAAE,MAAQ,IAAI,EAAE,KAAK,GAAK,EAAE,GAUhDC,EAAYC,EAAAA,WAA2C,SAClE,CACE,UAAAC,EACA,KAAAC,EAAO,QACP,QAAAC,EACA,KAAAC,EAAO,KACP,SAAAC,EAAW,GACX,OAAAC,EACA,WAAAC,EAAa,GACb,MAAAC,EACA,WAAAC,EACA,MAAAC,EAAQ,GACR,SAAAC,EAAW,GACX,UAAAC,EACA,GAAGC,CACL,EACAC,EACA,CACA,MAAM,EAAIC,EAAAA,KAAA,EACJC,EAAKC,EAAAA,MAAA,EACLC,EAAU,GAAGF,CAAE,SACfG,EAAW,GAAGH,CAAE,UAChB,CAAE,KAAAI,CAAA,EAASC,eAAA,EACXC,EAAUC,EAAAA,gBAAgBtB,EAAWE,CAAO,EAE5CqB,EAAa,MAAOC,GAA0B,CAClD,MAAMC,EAAO,GAAGxB,CAAI,IAAIuB,EAAO,IAAI,GACxB,MAAML,EAAKK,EAAO,GAAG,GAE9BE,QAAM,QAAQ,EAAE,mBAAoB,CAAE,KAAAD,EAAM,IAAKD,EAAO,GAAA,CAAK,CAAC,EAC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AAA,CACF,CAAA,CAAA,CAEJ,EAEAH,EAAAA,IAACG,EAAAA,WAAA,CAAW,GAAG,OAAO,QAAQ,UAAU,MAAM,QAC3C,SAAA,EAAE,mBAAmB,CAAA,CACxB,EAGD1B,GAAc,MACbuB,EAAAA,IAACG,EAAAA,WAAA,CACC,GAAG,OACH,GAAIhB,EACJ,QAAQ,YACR,MAAOT,EAAQ,QAAU,QACzB,UAAWwB,EAAAA,YAAY,OAEtB,SAAAzB,CAAA,CAAA,CACH,CAAA,CAAA,CAIR,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { T as H } from "./Tooltip-DsDv4NOq.js";
|
|
|
7
7
|
import { T as n } from "./Typography-CJv5AnRP.js";
|
|
8
8
|
import { t as x } from "./toastStore-Cx_JOKwS.js";
|
|
9
9
|
import { f as d } from "./TextField.module-6gYcR9TL.js";
|
|
10
|
-
import { a as J } from "./ConfigProvider-
|
|
10
|
+
import { a as J } from "./ConfigProvider-D2svpXFu.js";
|
|
11
11
|
const K = "_band_1d0th_5", M = "_sm_1d0th_15", O = "_md_1d0th_18", Q = "_lg_1d0th_21", U = "_num_1d0th_42", V = "_step_1d0th_47", X = "_bounds_1d0th_94", Y = "_tip_1d0th_101", Z = "_tipTitle_1d0th_107", t = {
|
|
12
12
|
band: K,
|
|
13
13
|
sm: M,
|
|
@@ -123,4 +123,4 @@ const K = "_band_1d0th_5", M = "_sm_1d0th_15", O = "_md_1d0th_18", Q = "_lg_1d0t
|
|
|
123
123
|
export {
|
|
124
124
|
de as C
|
|
125
125
|
};
|
|
126
|
-
//# sourceMappingURL=ColorRamp-
|
|
126
|
+
//# sourceMappingURL=ColorRamp-Qc8ZtPDh.js.map
|