@weasel-js/ui 1.7.3 → 1.8.1
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/chunks/{ActionBar-xA73vzzF.js → ActionBar-CfXS7-9f.js} +2 -2
- package/dist/chunks/{ActionBar-xA73vzzF.js.map → ActionBar-CfXS7-9f.js.map} +1 -1
- package/dist/chunks/{Badge-jYQjrTKc.js → Badge-4ShpqA0h.js} +2 -2
- package/dist/chunks/{Badge-jYQjrTKc.js.map → Badge-4ShpqA0h.js.map} +1 -1
- package/dist/chunks/{Badge-CTc9Lkwn.js → Badge-qkV9EqKs.js} +6 -2
- package/dist/chunks/Badge-qkV9EqKs.js.map +1 -0
- package/dist/chunks/{Button-XB-T75YL.js → Button-CQA-K1g9.js} +17 -17
- package/dist/chunks/Button-CQA-K1g9.js.map +1 -0
- package/dist/chunks/Button-KF-qSGtA.js +11 -0
- package/dist/chunks/Button-KF-qSGtA.js.map +1 -0
- package/dist/chunks/{ButtonBar-CIMKPPRS.js → ButtonBar-B-cYuoem.js} +10 -4
- package/dist/chunks/ButtonBar-B-cYuoem.js.map +1 -0
- package/dist/chunks/{Callout-BUn0dP_S.js → Callout-VyYDIP7w.js} +26 -26
- package/dist/chunks/Callout-VyYDIP7w.js.map +1 -0
- package/dist/chunks/{Checkbox-DFn-x0JO.js → Checkbox-d4IfhiXh.js} +2 -2
- package/dist/chunks/{Checkbox-DFn-x0JO.js.map → Checkbox-d4IfhiXh.js.map} +1 -1
- package/dist/chunks/{CloseButton-BmNmRVtb.js → CloseButton-CKarkTT9.js} +3 -3
- package/dist/chunks/{CloseButton-BmNmRVtb.js.map → CloseButton-CKarkTT9.js.map} +1 -1
- package/dist/chunks/{Code-AsKpgnv6.js → Code-ChwKP1V0.js} +8 -2
- package/dist/chunks/Code-ChwKP1V0.js.map +1 -0
- package/dist/chunks/{ColorModeControl-DaVJ-SyX.js → ColorModeControl-CH9PmDlT.js} +6 -6
- package/dist/chunks/{ColorModeControl-DaVJ-SyX.js.map → ColorModeControl-CH9PmDlT.js.map} +1 -1
- package/dist/chunks/{ComboBox-DKln_mOd.js → ComboBox-BMj_IKBj.js} +4 -4
- package/dist/chunks/ComboBox-BMj_IKBj.js.map +1 -0
- package/dist/chunks/{DataGrid-CmHJe57v.js → DataGrid-CjiVKoaA.js} +3 -3
- package/dist/chunks/{DataGrid-CmHJe57v.js.map → DataGrid-CjiVKoaA.js.map} +1 -1
- package/dist/chunks/{DetentSlider-DNTAk8xP.js → DetentSlider-D40V8Oma.js} +2 -2
- package/dist/chunks/{DetentSlider-DNTAk8xP.js.map → DetentSlider-D40V8Oma.js.map} +1 -1
- package/dist/chunks/{Dialog-DKfsk5VN.js → Dialog-Du4POZ52.js} +12 -12
- package/dist/chunks/Dialog-Du4POZ52.js.map +1 -0
- package/dist/chunks/{Disclosure-Ch2KxYuB.js → Disclosure-CpWt87nO.js} +7 -7
- package/dist/chunks/{Disclosure-Ch2KxYuB.js.map → Disclosure-CpWt87nO.js.map} +1 -1
- package/dist/chunks/{DragGhost-BeYDJyLZ.js → DragGhost-_IpuN_xM.js} +2 -2
- package/dist/chunks/{DragGhost-BeYDJyLZ.js.map → DragGhost-_IpuN_xM.js.map} +1 -1
- package/dist/chunks/{FallthroughDiagram-CS1IhQaU.js → FallthroughDiagram-Cn6QLWKA.js} +9 -9
- package/dist/chunks/{FallthroughDiagram-CS1IhQaU.js.map → FallthroughDiagram-Cn6QLWKA.js.map} +1 -1
- package/dist/chunks/{FillStrokeSwatch-C4h3rUFM.js → FillStrokeSwatch-BkUhlpQL.js} +2 -2
- package/dist/chunks/{FillStrokeSwatch-C4h3rUFM.js.map → FillStrokeSwatch-BkUhlpQL.js.map} +1 -1
- package/dist/chunks/FitLabel-BzZGkWfL.js +76 -0
- package/dist/chunks/FitLabel-BzZGkWfL.js.map +1 -0
- package/dist/chunks/{FontFamilySelect-DEvMXyZd.js → FontFamilySelect-CXN7O2-p.js} +2 -2
- package/dist/chunks/{FontFamilySelect-DEvMXyZd.js.map → FontFamilySelect-CXN7O2-p.js.map} +1 -1
- package/dist/chunks/{FontWeightSelect-BLQ_LMJF.js → FontWeightSelect-BBuJGe_2.js} +2 -2
- package/dist/chunks/{FontWeightSelect-BLQ_LMJF.js.map → FontWeightSelect-BBuJGe_2.js.map} +1 -1
- package/dist/chunks/{GestureRoute-BXESrHI0.js → GestureRoute-BqHUrGeQ.js} +13 -13
- package/dist/chunks/{GestureRoute-BXESrHI0.js.map → GestureRoute-BqHUrGeQ.js.map} +1 -1
- package/dist/chunks/{GradientEditor-DD2OjQtn.js → GradientEditor-DX4sb1Hf.js} +4 -4
- package/dist/chunks/{GradientEditor-DD2OjQtn.js.map → GradientEditor-DX4sb1Hf.js.map} +1 -1
- package/dist/chunks/{Icon--B1ME-6c.js → Icon-BfqYtAX5.js} +33 -1
- package/dist/chunks/Icon-BfqYtAX5.js.map +1 -0
- package/dist/chunks/{ItemList-CRu9y7hL.js → ItemList-nbakLf3N.js} +32 -32
- package/dist/chunks/ItemList-nbakLf3N.js.map +1 -0
- package/dist/chunks/{Jog-BrkzdGV2.js → Jog-BU0xuM3G.js} +7 -7
- package/dist/chunks/{Jog-BrkzdGV2.js.map → Jog-BU0xuM3G.js.map} +1 -1
- package/dist/chunks/{Keycaps-C-FJyG8k.js → Keycaps-CM-gOj0e.js} +8 -2
- package/dist/chunks/Keycaps-CM-gOj0e.js.map +1 -0
- package/dist/chunks/LayerList-vfAoImxX.js +432 -0
- package/dist/chunks/LayerList-vfAoImxX.js.map +1 -0
- package/dist/chunks/{ListEditor-OQDzG4A5.js → ListEditor-BAKs47bN.js} +3 -3
- package/dist/chunks/{ListEditor-OQDzG4A5.js.map → ListEditor-BAKs47bN.js.map} +1 -1
- package/dist/chunks/{MenuButton-TAFg88Lp.js → MenuButton-CJGdhwGr.js} +5 -5
- package/dist/chunks/MenuButton-CJGdhwGr.js.map +1 -0
- package/dist/chunks/{MeshEditor-DWpvg8H6.js → MeshEditor-rhf7cXfG.js} +2 -2
- package/dist/chunks/{MeshEditor-DWpvg8H6.js.map → MeshEditor-rhf7cXfG.js.map} +1 -1
- package/dist/chunks/{NumberField-DS0WSiin.js → NumberField-BXFrOi5M.js} +8 -5
- package/dist/chunks/{NumberField-DS0WSiin.js.map → NumberField-BXFrOi5M.js.map} +1 -1
- package/dist/chunks/{OptionsBar-DeTAjVb7.js → OptionsBar-DyTXbev-.js} +9 -3
- package/dist/chunks/OptionsBar-DyTXbev-.js.map +1 -0
- package/dist/chunks/{PaintField-BdmQM53v.js → PaintField--GbF8sL7.js} +7 -7
- package/dist/chunks/PaintField--GbF8sL7.js.map +1 -0
- package/dist/chunks/{PaintInput-DaQMeBsI.js → PaintInput-DSS5IjXn.js} +5 -5
- package/dist/chunks/{PaintInput-DaQMeBsI.js.map → PaintInput-DSS5IjXn.js.map} +1 -1
- package/dist/chunks/{PatternPicker-B3HcMZWg.js → PatternPicker-82DCUvUk.js} +9 -9
- package/dist/chunks/PatternPicker-82DCUvUk.js.map +1 -0
- package/dist/chunks/{Powerline-6wIFmDik.js → Powerline-CogJv9VU.js} +2 -2
- package/dist/chunks/{Powerline-6wIFmDik.js.map → Powerline-CogJv9VU.js.map} +1 -1
- package/dist/chunks/{Prefs-BnVEyfWO.js → Prefs-BSSKOvPa.js} +41 -41
- package/dist/chunks/Prefs-BSSKOvPa.js.map +1 -0
- package/dist/chunks/{Properties-BoG2MMHR.js → Properties-DteSVEWs.js} +5 -5
- package/dist/chunks/{Properties-BoG2MMHR.js.map → Properties-DteSVEWs.js.map} +1 -1
- package/dist/chunks/PropertyField-CLbUOynA.js +751 -0
- package/dist/chunks/PropertyField-CLbUOynA.js.map +1 -0
- package/dist/chunks/{Select-ouV8O6cp.js → Select-BhHwjNsb.js} +13 -13
- package/dist/chunks/Select-BhHwjNsb.js.map +1 -0
- package/dist/chunks/{SelectionPanel-COZ6z9_P.js → SelectionPanel-B6HinSdB.js} +2 -2
- package/dist/chunks/{SelectionPanel-COZ6z9_P.js.map → SelectionPanel-B6HinSdB.js.map} +1 -1
- package/dist/chunks/{SidebarPanel-AXQ0jRDx.js → SidebarPanel-P3a8tIIj.js} +3 -3
- package/dist/chunks/{SidebarPanel-AXQ0jRDx.js.map → SidebarPanel-P3a8tIIj.js.map} +1 -1
- package/dist/chunks/Slider-CHBQ8uUC.js +439 -0
- package/dist/chunks/Slider-CHBQ8uUC.js.map +1 -0
- package/dist/chunks/{StatusBar-BEOfOX0D.js → StatusBar-DEh7J2Gj.js} +14 -9
- package/dist/chunks/StatusBar-DEh7J2Gj.js.map +1 -0
- package/dist/chunks/{SwatchGrid-9ZPiDmxd.js → SwatchGrid-DxK9e_IV.js} +3 -3
- package/dist/chunks/SwatchGrid-DxK9e_IV.js.map +1 -0
- package/dist/chunks/{SwatchStrip-Bi9iPLoh.js → SwatchStrip-D7YNn_p0.js} +3 -3
- package/dist/chunks/{SwatchStrip-Bi9iPLoh.js.map → SwatchStrip-D7YNn_p0.js.map} +1 -1
- package/dist/chunks/{ThemeSwitcher-DiBmMh_B.js → ThemeSwitcher-BJWP1l87.js} +6 -6
- package/dist/chunks/{ThemeSwitcher-DiBmMh_B.js.map → ThemeSwitcher-BJWP1l87.js.map} +1 -1
- package/dist/chunks/{Timeline-sMCH2fah.js → Timeline-CisRg82u.js} +4 -4
- package/dist/chunks/{Timeline-sMCH2fah.js.map → Timeline-CisRg82u.js.map} +1 -1
- package/dist/chunks/{Toast-C3ozq11V.js → Toast-DhkU9Z0b.js} +3 -3
- package/dist/chunks/{Toast-C3ozq11V.js.map → Toast-DhkU9Z0b.js.map} +1 -1
- package/dist/chunks/ToggleBar-CRc2k89_.js +10 -0
- package/dist/chunks/ToggleBar-CRc2k89_.js.map +1 -0
- package/dist/chunks/ToggleBar-CfYbMK3x.js +84 -0
- package/dist/chunks/ToggleBar-CfYbMK3x.js.map +1 -0
- package/dist/chunks/{TokenPanel-WtKGY2Db.js → TokenPanel-cL37E39j.js} +26 -26
- package/dist/chunks/{TokenPanel-WtKGY2Db.js.map → TokenPanel-cL37E39j.js.map} +1 -1
- package/dist/chunks/{ToolButton-BURp4YIO.js → ToolButton-Bo7WH1wt.js} +2 -2
- package/dist/chunks/{ToolButton-BURp4YIO.js.map → ToolButton-Bo7WH1wt.js.map} +1 -1
- package/dist/chunks/ToolOptionsBar-DmhzrOmd.js +94 -0
- package/dist/chunks/ToolOptionsBar-DmhzrOmd.js.map +1 -0
- package/dist/chunks/{ToolPalette-DKDFWOX-.js → ToolPalette-BTD84k9C.js} +2 -2
- package/dist/chunks/{ToolPalette-DKDFWOX-.js.map → ToolPalette-BTD84k9C.js.map} +1 -1
- package/dist/chunks/{Tooltip-C6eFCYxw.js → Tooltip-DljsPEQG.js} +4 -4
- package/dist/chunks/Tooltip-DljsPEQG.js.map +1 -0
- package/dist/chunks/Tree-B_PW6K-W.js +215 -0
- package/dist/chunks/Tree-B_PW6K-W.js.map +1 -0
- package/dist/chunks/checkbox.module-Dcx8ILgR.js +5 -0
- package/dist/chunks/checkbox.module-Dcx8ILgR.js.map +1 -0
- package/dist/chunks/{icons-Dr2-r30x.js → icons-B_fPKEis.js} +52 -43
- package/dist/chunks/icons-B_fPKEis.js.map +1 -0
- package/dist/chunks/{model-B6zuQg6b.js → model-Ca0f95r0.js} +134 -133
- package/dist/chunks/model-Ca0f95r0.js.map +1 -0
- package/dist/chunks/{portalHost-CE70wLzo.js → portalHost-RUQPxIoW.js} +3 -2
- package/dist/chunks/{portalHost-CE70wLzo.js.map → portalHost-RUQPxIoW.js.map} +1 -1
- package/dist/chunks/{prefField-BE_Ytr2H.js → prefField-DPPbAmRR.js} +81 -75
- package/dist/chunks/prefField-DPPbAmRR.js.map +1 -0
- package/dist/chunks/{segmentTooltip-CGxCOWNz.js → segmentTooltip-8VBPNgEc.js} +2 -2
- package/dist/chunks/{segmentTooltip-CGxCOWNz.js.map → segmentTooltip-8VBPNgEc.js.map} +1 -1
- package/dist/chunks/segmentedControl.module-62qjNWJk.js +11 -0
- package/dist/chunks/{segmentedControl.module-BzGXUL5G.js.map → segmentedControl.module-62qjNWJk.js.map} +1 -1
- package/dist/chunks/{useReorderDragList-CStYKjHl.js → useReorderDragList-DnqqvRGK.js} +38 -30
- package/dist/chunks/useReorderDragList-DnqqvRGK.js.map +1 -0
- package/dist/components/ActionBar/index.js +1 -1
- package/dist/components/Badge/index.d.ts +1 -0
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +3 -3
- package/dist/components/Badge/variantIcons.d.ts +5 -0
- package/dist/components/Badge/variantIcons.d.ts.map +1 -0
- package/dist/components/Button/index.d.ts +1 -0
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +3 -2
- package/dist/components/Button/variantIcons.d.ts +5 -0
- package/dist/components/Button/variantIcons.d.ts.map +1 -0
- package/dist/components/ButtonBar/index.d.ts +1 -0
- package/dist/components/ButtonBar/index.d.ts.map +1 -1
- package/dist/components/ButtonBar/index.js +2 -2
- package/dist/components/ButtonBar/variantIcons.d.ts +5 -0
- package/dist/components/ButtonBar/variantIcons.d.ts.map +1 -0
- package/dist/components/Callout/Callout.d.ts.map +1 -1
- package/dist/components/Callout/index.js +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/CloseButton/index.js +1 -1
- package/dist/components/Code/index.d.ts +1 -0
- package/dist/components/Code/index.d.ts.map +1 -1
- package/dist/components/Code/index.js +2 -2
- package/dist/components/Code/variantIcons.d.ts +5 -0
- package/dist/components/Code/variantIcons.d.ts.map +1 -0
- package/dist/components/ColorModeControl/index.js +1 -1
- package/dist/components/ComboBox/ComboBox.d.ts.map +1 -1
- package/dist/components/ComboBox/index.js +1 -1
- package/dist/components/DataGrid/index.js +1 -1
- package/dist/components/DetentSlider/index.js +1 -1
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Dialog/index.js +1 -1
- package/dist/components/Disclosure/index.js +1 -1
- package/dist/components/DragGhost/index.js +1 -1
- package/dist/components/FallthroughDiagram/index.js +1 -1
- package/dist/components/FillStrokeSwatch/index.js +1 -1
- package/dist/components/FitLabel/FitLabel.d.ts +41 -0
- package/dist/components/FitLabel/FitLabel.d.ts.map +1 -0
- package/dist/components/FitLabel/index.d.ts +3 -0
- package/dist/components/FitLabel/index.d.ts.map +1 -0
- package/dist/components/FitLabel/index.js +2 -0
- package/dist/components/FontFamilySelect/index.js +1 -1
- package/dist/components/FontWeightSelect/index.js +1 -1
- package/dist/components/GestureRoute/index.js +1 -1
- package/dist/components/GradientEditor/index.js +1 -1
- package/dist/components/InlineRange/InlineRange.d.ts +1 -1
- package/dist/components/ItemList/index.js +1 -1
- package/dist/components/Jog/index.js +1 -1
- package/dist/components/Keycaps/index.d.ts +1 -0
- package/dist/components/Keycaps/index.d.ts.map +1 -1
- package/dist/components/Keycaps/index.js +2 -2
- package/dist/components/Keycaps/variantIcons.d.ts +5 -0
- package/dist/components/Keycaps/variantIcons.d.ts.map +1 -0
- package/dist/components/LayerList/LayerList.d.ts.map +1 -1
- package/dist/components/LayerList/index.js +1 -1
- package/dist/components/ListEditor/index.js +1 -1
- package/dist/components/MenuButton/MenuButton.d.ts.map +1 -1
- package/dist/components/MenuButton/index.js +1 -1
- package/dist/components/MeshEditor/index.js +1 -1
- package/dist/components/NumberField/UnitField.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +1 -1
- package/dist/components/OptionsBar/index.d.ts +1 -0
- package/dist/components/OptionsBar/index.d.ts.map +1 -1
- package/dist/components/OptionsBar/index.js +2 -2
- package/dist/components/OptionsBar/variantIcons.d.ts +5 -0
- package/dist/components/OptionsBar/variantIcons.d.ts.map +1 -0
- package/dist/components/PaintField/PaintField.d.ts.map +1 -1
- package/dist/components/PaintField/index.js +1 -1
- package/dist/components/PaintInput/index.js +1 -1
- package/dist/components/PatternPicker/index.js +1 -1
- package/dist/components/Powerline/index.js +2 -2
- package/dist/components/Prefs/index.js +2 -2
- package/dist/components/Prefs/prefField.d.ts.map +1 -1
- package/dist/components/Properties/NumberControls.d.ts +16 -0
- package/dist/components/Properties/NumberControls.d.ts.map +1 -0
- package/dist/components/Properties/PropertyField.d.ts +18 -8
- package/dist/components/Properties/PropertyField.d.ts.map +1 -1
- package/dist/components/Properties/index.js +2 -2
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/index.js +1 -1
- package/dist/components/SelectionPanel/index.js +2 -2
- package/dist/components/SelectionPanel/renderLeaf.d.ts.map +1 -1
- package/dist/components/SidebarPanel/index.js +1 -1
- package/dist/components/Slider/Slider.d.ts +6 -0
- package/dist/components/Slider/Slider.d.ts.map +1 -1
- package/dist/components/Slider/index.js +1 -1
- package/dist/components/StatusBar/StatusBar.d.ts +2 -0
- package/dist/components/StatusBar/StatusBar.d.ts.map +1 -1
- package/dist/components/StatusBar/index.js +1 -1
- package/dist/components/SwatchGrid/index.js +1 -1
- package/dist/components/SwatchStrip/index.js +1 -1
- package/dist/components/ThemeSwitcher/index.js +1 -1
- package/dist/components/Timeline/index.js +1 -1
- package/dist/components/Toast/index.js +1 -1
- package/dist/components/ToggleBar/ToggleBar.d.ts.map +1 -1
- package/dist/components/ToggleBar/index.d.ts +1 -0
- package/dist/components/ToggleBar/index.d.ts.map +1 -1
- package/dist/components/ToggleBar/index.js +3 -2
- package/dist/components/ToggleBar/variantIcons.d.ts +5 -0
- package/dist/components/ToggleBar/variantIcons.d.ts.map +1 -0
- package/dist/components/TokenPanel/index.js +1 -1
- package/dist/components/ToolButton/index.js +1 -1
- package/dist/components/ToolOptionsBar/ToolOptionsBar.d.ts +1 -1
- package/dist/components/ToolOptionsBar/ToolOptionsBar.d.ts.map +1 -1
- package/dist/components/ToolOptionsBar/index.js +1 -1
- package/dist/components/ToolPalette/index.js +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/index.js +1 -1
- package/dist/components/Tree/Tree.d.ts +1 -1
- package/dist/components/Tree/Tree.d.ts.map +1 -1
- package/dist/components/Tree/index.js +1 -1
- package/dist/components/stanceCss.d.ts +6 -0
- package/dist/components/stanceCss.d.ts.map +1 -1
- package/dist/components/stanceSurfaces.d.ts.map +1 -1
- package/dist/endless.d.ts +7 -0
- package/dist/endless.d.ts.map +1 -0
- package/dist/icons/index.d.ts +6 -0
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/icons/paths.d.ts +14 -0
- package/dist/icons/paths.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +101 -97
- package/dist/index.js.map +1 -1
- package/dist/overlays/portalHost.d.ts +10 -4
- package/dist/overlays/portalHost.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/dist/useReorderDragList.d.ts +3 -0
- package/dist/useReorderDragList.d.ts.map +1 -1
- package/package.json +10 -9
- package/dist/chunks/Badge-CTc9Lkwn.js.map +0 -1
- package/dist/chunks/Button-XB-T75YL.js.map +0 -1
- package/dist/chunks/ButtonBar-CIMKPPRS.js.map +0 -1
- package/dist/chunks/Callout-BUn0dP_S.js.map +0 -1
- package/dist/chunks/Code-AsKpgnv6.js.map +0 -1
- package/dist/chunks/ComboBox-DKln_mOd.js.map +0 -1
- package/dist/chunks/Dialog-DKfsk5VN.js.map +0 -1
- package/dist/chunks/Icon--B1ME-6c.js.map +0 -1
- package/dist/chunks/ItemList-CRu9y7hL.js.map +0 -1
- package/dist/chunks/Keycaps-C-FJyG8k.js.map +0 -1
- package/dist/chunks/LayerList-BqeWFuGc.js +0 -421
- package/dist/chunks/LayerList-BqeWFuGc.js.map +0 -1
- package/dist/chunks/MenuButton-TAFg88Lp.js.map +0 -1
- package/dist/chunks/OptionsBar-DeTAjVb7.js.map +0 -1
- package/dist/chunks/PaintField-BdmQM53v.js.map +0 -1
- package/dist/chunks/PatternPicker-B3HcMZWg.js.map +0 -1
- package/dist/chunks/Prefs-BnVEyfWO.js.map +0 -1
- package/dist/chunks/PropertyField-PMrqBA0n.js +0 -743
- package/dist/chunks/PropertyField-PMrqBA0n.js.map +0 -1
- package/dist/chunks/Select-ouV8O6cp.js.map +0 -1
- package/dist/chunks/Slider-DSrlMEq8.js +0 -389
- package/dist/chunks/Slider-DSrlMEq8.js.map +0 -1
- package/dist/chunks/StatusBar-BEOfOX0D.js.map +0 -1
- package/dist/chunks/SwatchGrid-9ZPiDmxd.js.map +0 -1
- package/dist/chunks/ToggleBar-Z2jZiguF.js +0 -80
- package/dist/chunks/ToggleBar-Z2jZiguF.js.map +0 -1
- package/dist/chunks/ToolOptionsBar-BJKwnemU.js +0 -88
- package/dist/chunks/ToolOptionsBar-BJKwnemU.js.map +0 -1
- package/dist/chunks/Tooltip-C6eFCYxw.js.map +0 -1
- package/dist/chunks/Tree-Cc8lIzgM.js +0 -203
- package/dist/chunks/Tree-Cc8lIzgM.js.map +0 -1
- package/dist/chunks/checkbox.module-DLQV9tMX.js +0 -5
- package/dist/chunks/checkbox.module-DLQV9tMX.js.map +0 -1
- package/dist/chunks/icons-Dr2-r30x.js.map +0 -1
- package/dist/chunks/interactiveTarget-BNZmTow2.js +0 -24
- package/dist/chunks/interactiveTarget-BNZmTow2.js.map +0 -1
- package/dist/chunks/model-B6zuQg6b.js.map +0 -1
- package/dist/chunks/prefField-BE_Ytr2H.js.map +0 -1
- package/dist/chunks/segmentedControl.module-BzGXUL5G.js +0 -11
- package/dist/chunks/useReorderDragList-CStYKjHl.js.map +0 -1
- package/dist/interactiveTarget.d.ts +0 -9
- package/dist/interactiveTarget.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ListEditor-
|
|
1
|
+
{"version":3,"file":"ListEditor-BAKs47bN.js","names":["s","f","Button","field_module_default","ListEditor_module_default","ListEditor","ariaLabel","inputs","useRef","focus","setFocus","useState","insert","onChange","value","at","remove","i","onKeyDown","name","className","empty","el","entry","j","v","CloseButton","addLabel"],"sources":["../../src/components/ListEditor/ListEditor.module.css","../../src/components/ListEditor/ListEditor.tsx"],"sourcesContent":[".editor {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n min-width: min(28rem, calc(100vw - 64px));\n}\n\n.list {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-2);\n margin: 0;\n padding: 0;\n list-style: none;\n}\n\n.entry {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-2);\n}\n\n.input {\n flex: 1 1 auto;\n min-width: 0;\n padding: 0 var(--wzl-field-pad-x);\n}\n\n.empty {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-subtle);\n font-style: italic;\n}\n\n.actions {\n display: flex;\n}\n","import { useEffect, useRef, useState, type KeyboardEvent } from 'react';\nimport { Button } from '../Button';\nimport { CloseButton } from '../CloseButton';\nimport f from '../field.module.css';\nimport s from './ListEditor.module.css';\n\n/** Props for {@link ListEditor}. */\nexport interface ListEditorProps {\n value: readonly string[];\n /** Every edit, add and removal, with the whole list. Entries are written as\n * typed — an empty one stays until it is removed. */\n onChange: (next: string[]) => void;\n /** Shown in an empty entry. */\n placeholder?: string;\n /** Shown in place of the entries when there are none. */\n empty?: string;\n /** Text of the add button. */\n addLabel?: string;\n /** Names the list for assistive tech; each entry is named from it. */\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * An editable list of strings: one field per entry, a remove button beside\n * each, and an add button under them. Enter in an entry adds one after it;\n * Backspace in an empty one removes it.\n */\nexport function ListEditor({\n value,\n onChange,\n placeholder,\n empty = 'None',\n addLabel = 'Add',\n 'aria-label': ariaLabel,\n className,\n}: ListEditorProps) {\n const inputs = useRef<(HTMLInputElement | null)[]>([]);\n const [focus, setFocus] = useState<number | null>(null);\n\n useEffect(() => {\n if (focus === null) return;\n inputs.current[focus]?.focus();\n setFocus(null);\n }, [focus]);\n\n const insert = (at: number): void => {\n onChange([...value.slice(0, at), '', ...value.slice(at)]);\n setFocus(at);\n };\n const remove = (at: number): void => {\n onChange(value.filter((_, i) => i !== at));\n if (value.length > 1) setFocus(Math.max(0, at - 1));\n };\n const onKeyDown = (e: KeyboardEvent<HTMLInputElement>, at: number): void => {\n if (e.key === 'Enter') {\n e.preventDefault();\n insert(at + 1);\n } else if (e.key === 'Backspace' && value[at] === '') {\n e.preventDefault();\n remove(at);\n }\n };\n const name = (i: number): string => `${ariaLabel ?? 'Entry'} ${i + 1}`;\n\n return (\n <div className={[s.editor, className].filter(Boolean).join(' ')} role=\"group\" aria-label={ariaLabel}>\n {value.length === 0 ? (\n <div className={s.empty}>{empty}</div>\n ) : (\n <ul className={s.list}>\n {value.map((entry, i) => (\n // Entries have no identity beyond their position, and two may be equal.\n <li key={i} className={s.entry}>\n <input\n ref={(el) => {\n inputs.current[i] = el;\n }}\n type=\"text\"\n className={`${f.frame} ${s.input}`}\n aria-label={name(i)}\n value={entry}\n placeholder={placeholder}\n onChange={(e) => onChange(value.map((v, j) => (j === i ? e.target.value : v)))}\n onKeyDown={(e) => onKeyDown(e, i)}\n />\n <CloseButton ariaLabel={`Remove ${name(i)}`} onClick={() => remove(i)} />\n </li>\n ))}\n </ul>\n )}\n <div className={s.actions}>\n <Button size=\"sm\" onClick={() => insert(value.length)}>\n {addLabel}\n </Button>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AC4BA,SAAgBK,EAAW,EACzB,UACA,aACA,gBACA,WAAQ,QACR,cAAW,OACX,cAAcC,GACd,gBACkB;CAClB,IAAMC,IAASC,EAAoC,CAAC,CAAC,GAC/C,CAACC,GAAOC,KAAYC,EAAwB,IAAI;CAEtD,QAAgB;EACd,AAAIF,MAAU,SACdF,EAAO,QAAQE,EAAM,EAAE,MAAM,GAC7BC,EAAS,IAAI;CACf,GAAG,CAACD,CAAK,CAAC;CAEV,IAAMG,KAAU,MAAqB;EAEnC,AADAC,EAAS;GAAC,GAAGC,EAAM,MAAM,GAAGC,CAAE;GAAG;GAAI,GAAGD,EAAM,MAAMC,CAAE;EAAC,CAAC,GACxDL,EAASK,CAAE;CACb,GACMC,KAAU,MAAqB;EAEnC,AADAH,EAASC,EAAM,QAAQ,GAAG,MAAMG,MAAMF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,EAAM,MAAM;IACjD,UAAAa;GACK,CAAA;EACL,CAAA,CACF;;AAET"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as e } from "./portalHost-
|
|
2
|
-
import { n as t, r as n } from "./segmentTooltip-
|
|
1
|
+
import { i as e } from "./portalHost-RUQPxIoW.js";
|
|
2
|
+
import { n as t, r as n } from "./segmentTooltip-8VBPNgEc.js";
|
|
3
3
|
import { t as r } from "./field.module-B27pWv0i.js";
|
|
4
4
|
import { t as i } from "./listbox.module-BcdVJMbm.js";
|
|
5
5
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
@@ -14,7 +14,7 @@ var f = {
|
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/components/MenuButton/MenuButton.tsx
|
|
16
16
|
function p({ label: p, items: m, onAction: h, isDisabled: g, className: _, "aria-label": v, portalContainer: y, shortcut: b, tooltip: x }) {
|
|
17
|
-
let { anchor: S, portalProps: C } = e(y);
|
|
17
|
+
let { anchor: S, portalProps: C, ready: w } = e(y);
|
|
18
18
|
return /* @__PURE__ */ o(u, { children: [
|
|
19
19
|
S,
|
|
20
20
|
/* @__PURE__ */ a(t, {
|
|
@@ -51,7 +51,7 @@ function p({ label: p, items: m, onAction: h, isDisabled: g, className: _, "aria
|
|
|
51
51
|
})]
|
|
52
52
|
})
|
|
53
53
|
}),
|
|
54
|
-
/* @__PURE__ */ a(d, {
|
|
54
|
+
w && /* @__PURE__ */ a(d, {
|
|
55
55
|
className: f.popover,
|
|
56
56
|
"data-weasel-overlay": "",
|
|
57
57
|
...C,
|
|
@@ -72,4 +72,4 @@ function p({ label: p, items: m, onAction: h, isDisabled: g, className: _, "aria
|
|
|
72
72
|
//#endregion
|
|
73
73
|
export { p as t };
|
|
74
74
|
|
|
75
|
-
//# sourceMappingURL=MenuButton-
|
|
75
|
+
//# sourceMappingURL=MenuButton-CJGdhwGr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuButton-CJGdhwGr.js","names":["RACButton","f","s","RACPopover","RACMenu","listbox","RACMenuItem","useOverlayPortal","TriggerTooltip","segmentTooltipContent","field_module_default","listbox_module_default","MenuButton_module_default","MenuButton","ariaLabel","portalContainer","MenuTrigger","anchor","isDisabled","Button","className","label","ready","Popover","portalProps","Menu","onAction","key","items","MenuItem","item"],"sources":["../../src/components/MenuButton/MenuButton.module.css","../../src/components/MenuButton/MenuButton.tsx"],"sourcesContent":[".trigger {\n display: inline-flex;\n flex: none;\n align-items: center;\n gap: var(--wzl-space-3);\n padding: 0 var(--wzl-space-3) 0 var(--wzl-space-5);\n white-space: nowrap;\n cursor: pointer;\n}\n\n.label {\n color: var(--wzl-fg-subtle);\n}\n\n.chevron {\n width: 10px;\n height: 10px;\n color: var(--wzl-fg-muted);\n flex: 0 0 auto;\n}\n\n.popover {\n min-width: var(--trigger-width);\n max-height: inherit;\n outline: none;\n}\n\n.item {\n display: flex;\n align-items: center;\n padding: var(--wzl-space-2) var(--wzl-space-4);\n border-radius: var(--wzl-radius-sm);\n cursor: pointer;\n color: var(--wzl-fg);\n white-space: nowrap;\n outline: none;\n}\n\n.item[data-focused] {\n background: var(--wzl-surface-hover);\n}\n\n.item[data-disabled] {\n opacity: 0.4;\n cursor: not-allowed;\n}\n","import type { ReactNode } from 'react';\nimport {\n Button as RACButton,\n Menu as RACMenu,\n MenuItem as RACMenuItem,\n MenuTrigger,\n Popover as RACPopover,\n} from 'react-aria-components';\nimport { useOverlayPortal, type OverlayPortalProps } from '../../overlays/portalHost';\nimport f from '../field.module.css';\nimport listbox from '../listbox.module.css';\nimport s from './MenuButton.module.css';\nimport { TriggerTooltip, segmentTooltipContent, type SegmentTooltipFields } from '../segmentTooltip';\n\n/** One row in a {@link MenuButton}'s list. */\nexport type MenuButtonItem<T extends string = string> = {\n value: T;\n label: ReactNode;\n isDisabled?: boolean;\n /** Plain-text form of `label`, for type-to-select and screen readers. A\n * string label supplies this itself. */\n textValue?: string;\n};\n\n/** Props for {@link MenuButton}. */\nexport type MenuButtonProps<T extends string = string> = {\n /** What the button says. It never changes to show a chosen row. */\n label: ReactNode;\n items: ReadonlyArray<MenuButtonItem<T>>;\n /** Fired with the value of the row chosen. */\n onAction: (value: T) => void;\n isDisabled?: boolean;\n className?: string;\n 'aria-label'?: string;\n} & SegmentTooltipFields & OverlayPortalProps;\n\n/**\n * A button that opens a list and acts on the row chosen — \"Add trial…\",\n * \"Load…\". Unlike a {@link Select} it holds no value, so it sizes to its own\n * label rather than to its widest row.\n *\n * `shortcut` adds a kit tooltip reading `Name (⌘N)`, named by `aria-label` or\n * a string `label`, as `Button` does; `tooltip` replaces that text.\n */\nexport function MenuButton<T extends string = string>({\n label,\n items,\n onAction,\n isDisabled,\n className,\n 'aria-label': ariaLabel,\n portalContainer,\n shortcut,\n tooltip,\n}: MenuButtonProps<T>) {\n const { anchor, portalProps, ready } = useOverlayPortal(portalContainer);\n return (\n <MenuTrigger>\n {anchor}\n <TriggerTooltip\n content={segmentTooltipContent({ tooltip, shortcut, ariaLabel, label })}\n disabled={isDisabled}\n >\n <RACButton\n className={[f.frame, s.trigger, className].filter(Boolean).join(' ')}\n isDisabled={isDisabled}\n aria-label={ariaLabel}\n >\n <span className={s.label}>{label}</span>\n <svg className={s.chevron} viewBox=\"0 0 10 10\" aria-hidden=\"true\">\n <path d=\"M2 4 L5 7 L8 4\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"1.5\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n </svg>\n </RACButton>\n </TriggerTooltip>\n {/* `data-weasel-overlay`: see Select — the list renders in a portal,\n outside the subtree the trigger sits in. */}\n {ready && (\n <RACPopover className={s.popover} data-weasel-overlay=\"\" {...portalProps}>\n <RACMenu className={`${listbox.surface} ${listbox.list}`} onAction={(key) => onAction(key as T)}>\n {items.map((item) => (\n <RACMenuItem\n key={item.value}\n id={item.value}\n className={s.item}\n isDisabled={item.isDisabled}\n textValue={item.textValue ?? (typeof item.label === 'string' ? item.label : und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,CAAA;CAEH,EAAA,CAAA;AAEjB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { n as e } from "./handles-CqVANLtu.js";
|
|
2
2
|
import { t } from "./ColorField-BwlelY26.js";
|
|
3
3
|
import { t as n } from "./paintPreview-CuSZiHpR.js";
|
|
4
|
-
import { t as r } from "./ToggleBar-
|
|
4
|
+
import { t as r } from "./ToggleBar-CfYbMK3x.js";
|
|
5
5
|
import { asPaint as i, useHandleDrag as a } from "@weasel-js/core";
|
|
6
6
|
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
7
|
import { useRef as c } from "react";
|
|
@@ -196,4 +196,4 @@ function D(e) {
|
|
|
196
196
|
//#endregion
|
|
197
197
|
export { v as a, y as i, S as n, h as o, b as r, _ as s, E as t };
|
|
198
198
|
|
|
199
|
-
//# sourceMappingURL=MeshEditor-
|
|
199
|
+
//# sourceMappingURL=MeshEditor-rhf7cXfG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MeshEditor-DWpvg8H6.js","names":["s","s","handleHalf","paintPreviewCss","ToggleBar","MeshEditor_module_default","SPACES","MeshEditor","props","space","value","withCorner","asPaint","patchIndex","patch","b","c","d","next","corner","color","className","previewOf","ColorField","onInput","onChange","spaceSwitch","isMeshPaint","isMeshGradientFill","fill","handleOverlay_module_default","HandleOverlay","Guide","Edge","a","points","DragPoint","start","useRef","at","drag","useHandleDrag","p","moved","onDrag","point","variant","radius","label","amount","e","KEY_STEP","dx","dy","CORNER_RADIUS","CONTROL_RADIUS","MeshHandles","meshGuides","handles","meshHandles","emit","moveMeshHandle","handle","toLocal","phase","ordered","h","edges","toScreen","edge","i","arms","from","to","labelOf","prefix","index"],"sources":["../../src/components/MeshEditor/MeshEditor.module.css","../../src/components/MeshEditor/MeshEditor.tsx","../../src/components/GradientEditor/handleOverlay.module.css","../../src/components/GradientEditor/handleOverlay.tsx","../../src/components/MeshEditor/MeshHandles.tsx"],"sourcesContent":[".root {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n}\n\n.patch {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-4);\n}\n\n.preview {\n inline-size: 34px;\n block-size: 34px;\n flex: 0 0 auto;\n border-radius: var(--wzl-radius-sm);\n box-shadow: inset 0 0 0 1px var(--wzl-border);\n}\n\n.corners {\n display: grid;\n grid-template-columns: repeat(2, auto);\n gap: var(--wzl-space-2) var(--wzl-space-3);\n min-inline-size: 0;\n}\n\n.corner {\n min-inline-size: 0;\n}\n","import { type ReactElement } from 'react';\nimport { asPaint, type ColorSpace, type FillStyle } from '@weasel-js/core';\nimport { isMeshGradientFill, type MeshGradientFill } from '@weasel-js/core/mesh';\nimport { ColorField } from '../ColorField';\nimport { ToggleBar, type ToggleBarItem } from '../ToggleBar';\nimport { paintPreviewCss } from '../../paintPreview';\nimport s from './MeshEditor.module.css';\n\nconst SPACES: readonly ToggleBarItem<ColorSpace>[] = [\n { value: 'rgb', label: 'sRGB' },\n { value: 'oklab', label: 'OKLab' },\n { value: 'oklch', label: 'OKLCh' },\n];\n\n/** Props for {@link MeshEditor}. `onInput` fires throughout a gesture and\n * `onChange` once at its end. */\nexport interface MeshEditorProps {\n value: MeshGradientFill;\n /** Emitted as a `FillStyle`, which is what every paint control passes\n * around — `FillStyle`'s discriminant stays closed over the built-in\n * members, so a registered kind's own shape only travels through it. */\n onInput?: (next: FillStyle) => void;\n onChange: (next: FillStyle) => void;\n /** Show the sRGB / OKLab / OKLCh switch. Default true. */\n spaceSwitch?: boolean;\n className?: string;\n}\n\n/**\n * Editor for a mesh gradient's colors.\n *\n * Geometry is absent for the same reason it is absent from `GradientEditor`:\n * a patch's twelve control points are a thing to drag on the artwork\n * (`MeshHandles`), not a column of numbers in a panel. What is left is what a panel is good at — the\n * color at each corner, and the space the four of them blend through.\n *\n * Corners are numbered in the patch's own walk order, which is the order the\n * paint stores them in, so a corner's number is stable while it is dragged.\n */\nexport function MeshEditor(props: MeshEditorProps): ReactElement {\n const { value, onInput, onChange, spaceSwitch = true, className } = props;\n const space = value.interpolate ?? 'rgb';\n\n const withCorner = (patchIndex: number, corner: number, color: string): FillStyle => asPaint({\n ...value,\n patches: value.patches.map((patch, i) => {\n if (i !== patchIndex) return patch;\n const [a, b, c, d] = patch.colors;\n const next: [string, string, string, string] = [a, b, c, d];\n next[corner] = color;\n return { ...patch, colors: next };\n }),\n });\n\n return (\n <div className={[s.root, className].filter(Boolean).join(' ')}>\n {value.patches.map((patch, patchIndex) => (\n // A patch has no id; its position in the list is its identity, the way\n // a gradient stop's is.\n <div key={patchIndex} className={s.patch}>\n <span\n className={s.preview}\n aria-hidden=\"true\"\n style={{ background: previewOf(value, patchIndex) }}\n />\n <div className={s.corners}>\n {patch.colors.map((color, corner) => (\n <ColorField\n key={corner}\n value={color}\n alpha\n aria-label={`Patch ${patchIndex + 1} corner ${corner + 1}`}\n className={s.corner}\n onInput={(next) => onInput?.(withCorner(patchIndex, corner, next))}\n onChange={(next) => onChange(withCorner(patchIndex, corner, next))}\n />\n ))}\n </div>\n </div>\n ))}\n\n {spaceSwitch && (\n <ToggleBar<ColorSpace>\n items={SPACES}\n value={space}\n size=\"sm\"\n ariaLabel=\"Blend space\"\n onChange={(next) => next && onChange(asPaint({ ...value, interpolate: next }))}\n />\n )}\n </div>\n );\n}\n\n/** One patch as a swatch: the paint with the other patches taken out, so a\n * multi-patch mesh shows which row belongs to which part of it. */\nfunction previewOf(value: MeshGradientFill, patchIndex: number): string | undefined {\n return paintPreviewCss(\n { ...value, patches: [value.patches[patchIndex]] } as unknown as FillStyle,\n );\n}\n\n/** Narrowing for a consumer rendering this behind a kind switch. */\nexport function isMeshPaint(fill: FillStyle | null | undefined): fill is FillStyle & MeshGradientFill {\n return isMeshGradientFill(fill);\n}\n","/* The overlay covers the canvas but must not intercept tool input; only the\n * handles opt back into hit-testing. */\n.overlay {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n/* These sit over artwork of unknown color, not over the app's own surface,\n * so they are deliberately not themed: a themed handle disappears against\n * whatever the user painted underneath. White-on-dark reads on anything,\n * which is why every editor draws handles this way. */\n.guide {\n fill: none;\n stroke: #ffffff;\n stroke-opacity: 0.7;\n stroke-dasharray: 4 4;\n paint-order: stroke;\n}\n\n.handle {\n fill: #ffffff;\n stroke: #222222;\n stroke-width: 2;\n cursor: grab;\n pointer-events: auto;\n}\n\n.handle:active {\n cursor: grabbing;\n}\n\n.handle:focus-visible {\n outline: 2px solid var(--wzl-accent);\n outline-offset: 2px;\n}\n\n/* A point that shapes an edge rather than ending one — drawn dark-on-light,\n * the inverse of the handle it hangs off, so the two read apart at a glance. */\n.control {\n fill: #222222;\n stroke: #ffffff;\n stroke-width: 1.5;\n}\n\n/* A patch edge: the outline the handles reshape, solid so it reads as the\n * artwork's structure rather than as a construction line. */\n.edge {\n fill: none;\n stroke: #ffffff;\n stroke-opacity: 0.85;\n stroke-width: 1;\n}\n","import { useRef, type KeyboardEvent as ReactKeyboardEvent, type ReactElement, type ReactNode } from 'react';\nimport { useHandleDrag } from '@weasel-js/core';\nimport s from './handleOverlay.module.css';\n\n/** The pieces every paint-geometry overlay draws with — `GradientHandles`\n * and `MeshHandles` — kept here so the two drag, step and look alike. */\n\nexport interface OverlayPoint {\n x: number;\n y: number;\n}\n\n/** Which half of a gesture an edit belongs to: a live preview, or the one\n * write that ends it. */\nexport type EditPhase = 'input' | 'commit';\n\n/** The SVG overlay itself: covers its container, passes pointer input\n * through everywhere but the handles. */\nexport function HandleOverlay(props: {\n width: number;\n height: number;\n className?: string;\n children: ReactNode;\n}): ReactElement {\n return (\n <svg\n className={[s.overlay, props.className].filter(Boolean).join(' ')}\n width={props.width}\n height={props.height}\n >\n {props.children}\n </svg>\n );\n}\n\nexport function Guide(props: { x1: number; y1: number; x2: number; y2: number }): ReactElement {\n return <line className={s.guide} {...props} />;\n}\n\n/** A cubic Bézier edge through four overlay-space points. */\nexport function Edge({ points }: { points: readonly [OverlayPoint, OverlayPoint, OverlayPoint, OverlayPoint] }): ReactElement {\n const [a, b, c, d] = points;\n return <path className={s.edge} d={`M${a.x} ${a.y}C${b.x} ${b.y} ${c.x} ${c.y} ${d.x} ${d.y}`} />;\n}\n\n/**\n * One draggable point. `onDrag` receives overlay pixels; a press that never\n * moved writes nothing, and a canceled gesture puts the preview back.\n */\nexport function DragPoint({\n at,\n label,\n radius,\n variant = 'handle',\n onDrag,\n}: {\n at: OverlayPoint;\n label: string;\n radius: number;\n /** `control` draws the inverted style a secondary point wears. */\n variant?: 'handle' | 'control';\n onDrag: (p: OverlayPoint, phase: EditPhase) => void;\n}): ReactElement {\n const start = useRef<OverlayPoint>(at);\n const drag = useHandleDrag<SVGCircleElement>({\n onStart: () => { start.current = at; },\n onMove: (p) => { onDrag(p, 'input'); },\n onEnd: ({ point, moved }) => {\n if (moved) onDrag(point, 'commit');\n },\n onCancel: () => { onDrag(start.current, 'input'); },\n });\n const onKeyDown = (e: ReactKeyboardEvent<SVGCircleElement>): void => {\n const amount = e.shiftKey ? KEY_STEP * 10 : KEY_STEP;\n let dx = 0;\n let dy = 0;\n if (e.key === 'ArrowLeft') dx = -amount;\n else if (e.key === 'ArrowRight') dx = amount;\n else if (e.key === 'ArrowUp') dy = -amount;\n else if (e.key === 'ArrowDown') dy = amount;\n else return;\n e.preventDefault();\n const next = { x: at.x + dx, y: at.y + dy };\n onDrag(next, 'input');\n onDrag(next, 'commit');\n };\n return (\n <circle\n className={variant === 'control' ? `${s.handle} ${s.control}` : s.handle}\n cx={at.x}\n cy={at.y}\n r={radius}\n // Not `slider`: the handle carries a 2-D position, not one value, so\n // it has no `aria-valuenow` to honor the role's contract with.\n role=\"button\"\n aria-label={label}\n tabIndex={0}\n onKeyDown={onKeyDown}\n {...drag}\n />\n );\n}\n\n/** One arrow-key step, in overlay pixels. */\nconst KEY_STEP = 1;\n","import { type ReactElement } from 'react';\nimport { asPaint, type FillStyle } from '@weasel-js/core';\nimport {\n meshGuides,\n meshHandles,\n moveMeshHandle,\n type MeshGradientFill,\n type MeshHandle,\n} from '@weasel-js/core/mesh';\nimport { handleHalf } from '../../handles';\nimport {\n DragPoint,\n Edge,\n Guide,\n HandleOverlay,\n type EditPhase,\n type OverlayPoint as Point,\n} from '../GradientEditor/handleOverlay';\n\n/** Props for {@link MeshHandles}. `onInput` fires throughout a drag and\n * `onChange` once at its end. */\nexport interface MeshHandlesProps {\n /** The mesh whose points these handles move, in the space `toScreen`\n * maps from. A `units: 'bounds'` mesh is resolved first with\n * `fillInPoseFrame(fill, box)`, and edits converted back with\n * `fillToBoundsFrame(next, box)`. */\n value: MeshGradientFill;\n /** Mesh space → overlay pixels. */\n toScreen: (p: Point) => Point;\n /** Overlay pixels → mesh space. Must invert `toScreen`. */\n toLocal: (p: Point) => Point;\n /** Live during a drag — wire for preview, do not write to history. Emitted\n * as a `FillStyle`, which is what every paint control passes around. */\n onInput?: (next: FillStyle) => void;\n /** Committed at drag end: one call per gesture. */\n onChange: (next: FillStyle) => void;\n /** Overlay size in CSS pixels. */\n width: number;\n height: number;\n className?: string;\n}\n\nconst CORNER_RADIUS = handleHalf('--wzl-handle-size-lg');\nconst CONTROL_RADIUS = handleHalf('--wzl-handle-size');\n\n/**\n * Direct-manipulation handles for a mesh gradient's geometry, drawn as an\n * SVG overlay: every patch corner, the two controls of each edge, and a\n * tensor patch's interior points, over the patch outlines they shape.\n *\n * Dragging a corner carries its controls with it. Points two patches share\n * are one handle, so a drag moves the seam instead of tearing it.\n *\n * The overlay ignores pointer events except on the handles themselves.\n */\nexport function MeshHandles(props: MeshHandlesProps): ReactElement {\n const { value, toScreen, toLocal, onInput, onChange, width, height, className } = props;\n const { edges, arms } = meshGuides(value);\n const handles = meshHandles(value);\n\n const emit = (handle: MeshHandle, p: Point, phase: EditPhase): void => {\n const next = asPaint(moveMeshHandle(value, handle, toLocal(p)));\n if (phase === 'input') onInput?.(next);\n else onChange(next);\n };\n\n // Corners last, so where a control collapses onto its corner the corner\n // is the one on top.\n const ordered = [\n ...handles.filter((h) => h.kind !== 'corner'),\n ...handles.filter((h) => h.kind === 'corner'),\n ];\n\n return (\n <HandleOverlay width={width} height={height} className={className}>\n {edges.map((edge, i) => (\n // Guides have no identity beyond their place in the walk.\n <Edge key={`e${i}`} points={[toScreen(edge[0]), toScreen(edge[1]), toScreen(edge[2]), toScreen(edge[3])]} />\n ))}\n {arms.map(([from, to], i) => {\n const a = toScreen(from);\n const b = toScreen(to);\n return <Guide key={`a${i}`} x1={a.x} y1={a.y} x2={b.x} y2={b.y} />;\n })}\n {ordered.map((handle) => (\n <DragPoint\n key={handle.id}\n at={toScreen(handle.at)}\n label={labelOf(handle)}\n radius={handle.kind === 'corner' ? CORNER_RADIUS : CONTROL_RADIUS}\n variant={handle.kind === 'corner' ? 'handle' : 'control'}\n onDrag={(p, phase) => emit(handle, p, phase)}\n />\n ))}\n </HandleOverlay>\n );\n}\n\n/** Numbered in the patch's own walk, matching `MeshEditor`'s corner fields. */\nfunction labelOf(handle: MeshHandle): string {\n const { patch, index } = handle.refs[0];\n const prefix = `Patch ${patch + 1}`;\n if (handle.kind === 'corner') return `${prefix} corner ${index / 3 + 1}`;\n if (handle.kind === 'interior') return `${prefix} interior ${index - 11}`;\n return `${prefix} edge ${Math.floor(index / 3) + 1} control ${index % 3}`;\n}\n"],"mappings":";;;;;;;;;;;;;;GCQMM,IAA+C;CACnD;EAAE,OAAO;EAAO,OAAO;CAAO;CAC9B;EAAE,OAAO;EAAS,OAAO;CAAQ;CACjC;EAAE,OAAO;EAAS,OAAO;CAAQ;AACnC;AA2BA,SAAgBC,EAAW,GAAsC;CAC/D,IAAM,EAAE,UAAO,YAAS,aAAU,iBAAc,IAAM,iBAAcC,GAC9DC,IAAQC,EAAM,eAAe,OAE7BC,KAAc,GAAoB,GAAgB,MAA6BC,EAAQ;EAC3F,GAAGF;EACH,SAASA,EAAM,QAAQ,KAAK,GAAO,MAAM;GACvC,IAAI,MAAMG,GAAY,OAAOC;GAC7B,IAAM,CAAC,GAAGC,GAAGC,GAAG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,IAAK,MAAM;IAC3B,IAAMvC,IAAIkC,EAASI,CAAI,GACjBzD,IAAIqD,EAASK,CAAE;IACrB,OAAO,kBAACzC,GAAD;KAAqB,IAAIE,EAAE;KAAG,IAAIA,EAAE;KAAG,IAAInB,EAAE;KAAG,IAAIA,EAAE;IAAI,GAA9C,IAAIuD,GAA0C;GACnE,CAAC;GACAL,EAAQ,KAAK,MACZ,kBAAC7B,GAAD;IAEE,IAAIgC,EAASN,EAAO,EAAE;IACtB,OAAOY,EAAQZ,CAAM;IACrB,QAAQA,EAAO,SAAS,WAAWR,IAAgBC;IACnD,SAASO,EAAO,SAAS,WAAW,WAAW;IAC/C,SAAS,GAAG,MAAUF,EAAKE,GAAQpB,GAAGsB,CAAK;GAC5C,GANMF,EAAO,EAMb,CACF;EACY;;AAEnB;AAGA,SAASY,EAAQ,GAA4B;CAC3C,IAAM,EAAE,UAAO,aAAUZ,EAAO,KAAK,IAC/Ba,IAAS,SAAS7D,IAAQ;CAGhC,OAFIgD,EAAO,SAAS,WAAiB,GAAGa,EAAO,UAAUC,IAAQ,IAAI,MACjEd,EAAO,SAAS,aAAmB,GAAGa,EAAO,YAAYC,IAAQ,OAC9D,GAAGD,EAAO,QAAQ,KAAK,MAAMC,IAAQ,CAAC,IAAI,EAAE,WAAWA,IAAQ;AACxE"}
|
|
1
|
+
{"version":3,"file":"MeshEditor-rhf7cXfG.js","names":["s","s","handleHalf","paintPreviewCss","ToggleBar","MeshEditor_module_default","SPACES","MeshEditor","props","space","value","withCorner","asPaint","patchIndex","patch","b","c","d","next","corner","color","className","previewOf","ColorField","onInput","onChange","spaceSwitch","isMeshPaint","isMeshGradientFill","fill","handleOverlay_module_default","HandleOverlay","Guide","Edge","a","points","DragPoint","start","useRef","at","drag","useHandleDrag","p","moved","onDrag","point","variant","radius","label","amount","e","KEY_STEP","dx","dy","CORNER_RADIUS","CONTROL_RADIUS","MeshHandles","meshGuides","handles","meshHandles","emit","moveMeshHandle","handle","toLocal","phase","ordered","h","edges","toScreen","edge","i","arms","from","to","labelOf","prefix","index"],"sources":["../../src/components/MeshEditor/MeshEditor.module.css","../../src/components/MeshEditor/MeshEditor.tsx","../../src/components/GradientEditor/handleOverlay.module.css","../../src/components/GradientEditor/handleOverlay.tsx","../../src/components/MeshEditor/MeshHandles.tsx"],"sourcesContent":[".root {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-4);\n}\n\n.patch {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-4);\n}\n\n.preview {\n inline-size: 34px;\n block-size: 34px;\n flex: 0 0 auto;\n border-radius: var(--wzl-radius-sm);\n box-shadow: inset 0 0 0 1px var(--wzl-border);\n}\n\n.corners {\n display: grid;\n grid-template-columns: repeat(2, auto);\n gap: var(--wzl-space-2) var(--wzl-space-3);\n min-inline-size: 0;\n}\n\n.corner {\n min-inline-size: 0;\n}\n","import { type ReactElement } from 'react';\nimport { asPaint, type ColorSpace, type FillStyle } from '@weasel-js/core';\nimport { isMeshGradientFill, type MeshGradientFill } from '@weasel-js/core/mesh';\nimport { ColorField } from '../ColorField';\nimport { ToggleBar, type ToggleBarItem } from '../ToggleBar';\nimport { paintPreviewCss } from '../../paintPreview';\nimport s from './MeshEditor.module.css';\n\nconst SPACES: readonly ToggleBarItem<ColorSpace>[] = [\n { value: 'rgb', label: 'sRGB' },\n { value: 'oklab', label: 'OKLab' },\n { value: 'oklch', label: 'OKLCh' },\n];\n\n/** Props for {@link MeshEditor}. `onInput` fires throughout a gesture and\n * `onChange` once at its end. */\nexport interface MeshEditorProps {\n value: MeshGradientFill;\n /** Emitted as a `FillStyle`, which is what every paint control passes\n * around — `FillStyle`'s discriminant stays closed over the built-in\n * members, so a registered kind's own shape only travels through it. */\n onInput?: (next: FillStyle) => void;\n onChange: (next: FillStyle) => void;\n /** Show the sRGB / OKLab / OKLCh switch. Default true. */\n spaceSwitch?: boolean;\n className?: string;\n}\n\n/**\n * Editor for a mesh gradient's colors.\n *\n * Geometry is absent for the same reason it is absent from `GradientEditor`:\n * a patch's twelve control points are a thing to drag on the artwork\n * (`MeshHandles`), not a column of numbers in a panel. What is left is what a panel is good at — the\n * color at each corner, and the space the four of them blend through.\n *\n * Corners are numbered in the patch's own walk order, which is the order the\n * paint stores them in, so a corner's number is stable while it is dragged.\n */\nexport function MeshEditor(props: MeshEditorProps): ReactElement {\n const { value, onInput, onChange, spaceSwitch = true, className } = props;\n const space = value.interpolate ?? 'rgb';\n\n const withCorner = (patchIndex: number, corner: number, color: string): FillStyle => asPaint({\n ...value,\n patches: value.patches.map((patch, i) => {\n if (i !== patchIndex) return patch;\n const [a, b, c, d] = patch.colors;\n const next: [string, string, string, string] = [a, b, c, d];\n next[corner] = color;\n return { ...patch, colors: next };\n }),\n });\n\n return (\n <div className={[s.root, className].filter(Boolean).join(' ')}>\n {value.patches.map((patch, patchIndex) => (\n // A patch has no id; its position in the list is its identity, the way\n // a gradient stop's is.\n <div key={patchIndex} className={s.patch}>\n <span\n className={s.preview}\n aria-hidden=\"true\"\n style={{ background: previewOf(value, patchIndex) }}\n />\n <div className={s.corners}>\n {patch.colors.map((color, corner) => (\n <ColorField\n key={corner}\n value={color}\n alpha\n aria-label={`Patch ${patchIndex + 1} corner ${corner + 1}`}\n className={s.corner}\n onInput={(next) => onInput?.(withCorner(patchIndex, corner, next))}\n onChange={(next) => onChange(withCorner(patchIndex, corner, next))}\n />\n ))}\n </div>\n </div>\n ))}\n\n {spaceSwitch && (\n <ToggleBar<ColorSpace>\n items={SPACES}\n value={space}\n size=\"sm\"\n ariaLabel=\"Blend space\"\n onChange={(next) => next && onChange(asPaint({ ...value, interpolate: next }))}\n />\n )}\n </div>\n );\n}\n\n/** One patch as a swatch: the paint with the other patches taken out, so a\n * multi-patch mesh shows which row belongs to which part of it. */\nfunction previewOf(value: MeshGradientFill, patchIndex: number): string | undefined {\n return paintPreviewCss(\n { ...value, patches: [value.patches[patchIndex]] } as unknown as FillStyle,\n );\n}\n\n/** Narrowing for a consumer rendering this behind a kind switch. */\nexport function isMeshPaint(fill: FillStyle | null | undefined): fill is FillStyle & MeshGradientFill {\n return isMeshGradientFill(fill);\n}\n","/* The overlay covers the canvas but must not intercept tool input; only the\n * handles opt back into hit-testing. */\n.overlay {\n position: absolute;\n inset: 0;\n pointer-events: none;\n}\n\n/* These sit over artwork of unknown color, not over the app's own surface,\n * so they are deliberately not themed: a themed handle disappears against\n * whatever the user painted underneath. White-on-dark reads on anything,\n * which is why every editor draws handles this way. */\n.guide {\n fill: none;\n stroke: #ffffff;\n stroke-opacity: 0.7;\n stroke-dasharray: 4 4;\n paint-order: stroke;\n}\n\n.handle {\n fill: #ffffff;\n stroke: #222222;\n stroke-width: 2;\n cursor: grab;\n pointer-events: auto;\n}\n\n.handle:active {\n cursor: grabbing;\n}\n\n.handle:focus-visible {\n outline: 2px solid var(--wzl-accent);\n outline-offset: 2px;\n}\n\n/* A point that shapes an edge rather than ending one — drawn dark-on-light,\n * the inverse of the handle it hangs off, so the two read apart at a glance. */\n.control {\n fill: #222222;\n stroke: #ffffff;\n stroke-width: 1.5;\n}\n\n/* A patch edge: the outline the handles reshape, solid so it reads as the\n * artwork's structure rather than as a construction line. */\n.edge {\n fill: none;\n stroke: #ffffff;\n stroke-opacity: 0.85;\n stroke-width: 1;\n}\n","import { useRef, type KeyboardEvent as ReactKeyboardEvent, type ReactElement, type ReactNode } from 'react';\nimport { useHandleDrag } from '@weasel-js/core';\nimport s from './handleOverlay.module.css';\n\n/** The pieces every paint-geometry overlay draws with — `GradientHandles`\n * and `MeshHandles` — kept here so the two drag, step and look alike. */\n\nexport interface OverlayPoint {\n x: number;\n y: number;\n}\n\n/** Which half of a gesture an edit belongs to: a live preview, or the one\n * write that ends it. */\nexport type EditPhase = 'input' | 'commit';\n\n/** The SVG overlay itself: covers its container, passes pointer input\n * through everywhere but the handles. */\nexport function HandleOverlay(props: {\n width: number;\n height: number;\n className?: string;\n children: ReactNode;\n}): ReactElement {\n return (\n <svg\n className={[s.overlay, props.className].filter(Boolean).join(' ')}\n width={props.width}\n height={props.height}\n >\n {props.children}\n </svg>\n );\n}\n\nexport function Guide(props: { x1: number; y1: number; x2: number; y2: number }): ReactElement {\n return <line className={s.guide} {...props} />;\n}\n\n/** A cubic Bézier edge through four overlay-space points. */\nexport function Edge({ points }: { points: readonly [OverlayPoint, OverlayPoint, OverlayPoint, OverlayPoint] }): ReactElement {\n const [a, b, c, d] = points;\n return <path className={s.edge} d={`M${a.x} ${a.y}C${b.x} ${b.y} ${c.x} ${c.y} ${d.x} ${d.y}`} />;\n}\n\n/**\n * One draggable point. `onDrag` receives overlay pixels; a press that never\n * moved writes nothing, and a canceled gesture puts the preview back.\n */\nexport function DragPoint({\n at,\n label,\n radius,\n variant = 'handle',\n onDrag,\n}: {\n at: OverlayPoint;\n label: string;\n radius: number;\n /** `control` draws the inverted style a secondary point wears. */\n variant?: 'handle' | 'control';\n onDrag: (p: OverlayPoint, phase: EditPhase) => void;\n}): ReactElement {\n const start = useRef<OverlayPoint>(at);\n const drag = useHandleDrag<SVGCircleElement>({\n onStart: () => { start.current = at; },\n onMove: (p) => { onDrag(p, 'input'); },\n onEnd: ({ point, moved }) => {\n if (moved) onDrag(point, 'commit');\n },\n onCancel: () => { onDrag(start.current, 'input'); },\n });\n const onKeyDown = (e: ReactKeyboardEvent<SVGCircleElement>): void => {\n const amount = e.shiftKey ? KEY_STEP * 10 : KEY_STEP;\n let dx = 0;\n let dy = 0;\n if (e.key === 'ArrowLeft') dx = -amount;\n else if (e.key === 'ArrowRight') dx = amount;\n else if (e.key === 'ArrowUp') dy = -amount;\n else if (e.key === 'ArrowDown') dy = amount;\n else return;\n e.preventDefault();\n const next = { x: at.x + dx, y: at.y + dy };\n onDrag(next, 'input');\n onDrag(next, 'commit');\n };\n return (\n <circle\n className={variant === 'control' ? `${s.handle} ${s.control}` : s.handle}\n cx={at.x}\n cy={at.y}\n r={radius}\n // Not `slider`: the handle carries a 2-D position, not one value, so\n // it has no `aria-valuenow` to honor the role's contract with.\n role=\"button\"\n aria-label={label}\n tabIndex={0}\n onKeyDown={onKeyDown}\n {...drag}\n />\n );\n}\n\n/** One arrow-key step, in overlay pixels. */\nconst KEY_STEP = 1;\n","import { type ReactElement } from 'react';\nimport { asPaint, type FillStyle } from '@weasel-js/core';\nimport {\n meshGuides,\n meshHandles,\n moveMeshHandle,\n type MeshGradientFill,\n type MeshHandle,\n} from '@weasel-js/core/mesh';\nimport { handleHalf } from '../../handles';\nimport {\n DragPoint,\n Edge,\n Guide,\n HandleOverlay,\n type EditPhase,\n type OverlayPoint as Point,\n} from '../GradientEditor/handleOverlay';\n\n/** Props for {@link MeshHandles}. `onInput` fires throughout a drag and\n * `onChange` once at its end. */\nexport interface MeshHandlesProps {\n /** The mesh whose points these handles move, in the space `toScreen`\n * maps from. A `units: 'bounds'` mesh is resolved first with\n * `fillInPoseFrame(fill, box)`, and edits converted back with\n * `fillToBoundsFrame(next, box)`. */\n value: MeshGradientFill;\n /** Mesh space → overlay pixels. */\n toScreen: (p: Point) => Point;\n /** Overlay pixels → mesh space. Must invert `toScreen`. */\n toLocal: (p: Point) => Point;\n /** Live during a drag — wire for preview, do not write to history. Emitted\n * as a `FillStyle`, which is what every paint control passes around. */\n onInput?: (next: FillStyle) => void;\n /** Committed at drag end: one call per gesture. */\n onChange: (next: FillStyle) => void;\n /** Overlay size in CSS pixels. */\n width: number;\n height: number;\n className?: string;\n}\n\nconst CORNER_RADIUS = handleHalf('--wzl-handle-size-lg');\nconst CONTROL_RADIUS = handleHalf('--wzl-handle-size');\n\n/**\n * Direct-manipulation handles for a mesh gradient's geometry, drawn as an\n * SVG overlay: every patch corner, the two controls of each edge, and a\n * tensor patch's interior points, over the patch outlines they shape.\n *\n * Dragging a corner carries its controls with it. Points two patches share\n * are one handle, so a drag moves the seam instead of tearing it.\n *\n * The overlay ignores pointer events except on the handles themselves.\n */\nexport function MeshHandles(props: MeshHandlesProps): ReactElement {\n const { value, toScreen, toLocal, onInput, onChange, width, height, className } = props;\n const { edges, arms } = meshGuides(value);\n const handles = meshHandles(value);\n\n const emit = (handle: MeshHandle, p: Point, phase: EditPhase): void => {\n const next = asPaint(moveMeshHandle(value, handle, toLocal(p)));\n if (phase === 'input') onInput?.(next);\n else onChange(next);\n };\n\n // Corners last, so where a control collapses onto its corner the corner\n // is the one on top.\n const ordered = [\n ...handles.filter((h) => h.kind !== 'corner'),\n ...handles.filter((h) => h.kind === 'corner'),\n ];\n\n return (\n <HandleOverlay width={width} height={height} className={className}>\n {edges.map((edge, i) => (\n // Guides have no identity beyond their place in the walk.\n <Edge key={`e${i}`} points={[toScreen(edge[0]), toScreen(edge[1]), toScreen(edge[2]), toScreen(edge[3])]} />\n ))}\n {arms.map(([from, to], i) => {\n const a = toScreen(from);\n const b = toScreen(to);\n return <Guide key={`a${i}`} x1={a.x} y1={a.y} x2={b.x} y2={b.y} />;\n })}\n {ordered.map((handle) => (\n <DragPoint\n key={handle.id}\n at={toScreen(handle.at)}\n label={labelOf(handle)}\n radius={handle.kind === 'corner' ? CORNER_RADIUS : CONTROL_RADIUS}\n variant={handle.kind === 'corner' ? 'handle' : 'control'}\n onDrag={(p, phase) => emit(handle, p, phase)}\n />\n ))}\n </HandleOverlay>\n );\n}\n\n/** Numbered in the patch's own walk, matching `MeshEditor`'s corner fields. */\nfunction labelOf(handle: MeshHandle): string {\n const { patch, index } = handle.refs[0];\n const prefix = `Patch ${patch + 1}`;\n if (handle.kind === 'corner') return `${prefix} corner ${index / 3 + 1}`;\n if (handle.kind === 'interior') return `${prefix} interior ${index - 11}`;\n return `${prefix} edge ${Math.floor(index / 3) + 1} control ${index % 3}`;\n}\n"],"mappings":";;;;;;;;;;;;;;GCQMM,IAA+C;CACnD;EAAE,OAAO;EAAO,OAAO;CAAO;CAC9B;EAAE,OAAO;EAAS,OAAO;CAAQ;CACjC;EAAE,OAAO;EAAS,OAAO;CAAQ;AACnC;AA2BA,SAAgBC,EAAW,GAAsC;CAC/D,IAAM,EAAE,UAAO,YAAS,aAAU,iBAAc,IAAM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,MAEhB,kBAAClC,GAAD,EAAoB,QAAQ;IAACmC,EAASC,EAAK,EAAE;IAAGD,EAASC,EAAK,EAAE;IAAGD,EAASC,EAAK,EAAE;IAAGD,EAASC,EAAK,EAAE;GAAC,EAAI,GAAhG,IAAIC,GAA4F,CAC5G;GACAC,EAAK,KAAK,CAACC,GAAMC,IAAK,MAAM;IAC3B,IAAMvC,IAAIkC,EAASI,CAAI,GACjBzD,IAAIqD,EAASK,CAAE;IACrB,OAAO,kBAACzC,GAAD;KAAqB,IAAIE,EAAE;KAAG,IAAIA,EAAE;KAAG,IAAInB,EAAE;KAAG,IAAIA,EAAE;IAAI,GAA9C,IAAIuD,GAA0C;GACnE,CAAC;GACAL,EAAQ,KAAK,MACZ,kBAAC7B,GAAD;IAEE,IAAIgC,EAASN,EAAO,EAAE;IACtB,OAAOY,EAAQZ,CAAM;IACrB,QAAQA,EAAO,SAAS,WAAWR,IAAgBC;IACnD,SAASO,EAAO,SAAS,WAAW,WAAW;IAC/C,SAAS,GAAG,MAAUF,EAAKE,GAAQpB,GAAGsB,CAAK;GAC5C,GANMF,EAAO,EAMb,CACF;EACY;;AAEnB;AAGA,SAASY,EAAQ,GAA4B;CAC3C,IAAM,EAAE,UAAO,aAAUZ,EAAO,KAAK,IAC/Ba,IAAS,SAAS7D,IAAQ;CAGhC,OAFIgD,EAAO,SAAS,WAAiB,GAAGa,EAAO,UAAUC,IAAQ,IAAI,MACjEd,EAAO,SAAS,aAAmB,GAAGa,EAAO,YAAYC,IAAQ,OAC9D,GAAGD,EAAO,QAAQ,KAAK,MAAMC,IAAQ,CAAC,IAAI,EAAE,WAAWA,IAAQ;AACxE"}
|
|
@@ -95,7 +95,10 @@ var C = m({
|
|
|
95
95
|
grouping: !1
|
|
96
96
|
}), w = 400, T = 60;
|
|
97
97
|
function E({ value: r, onChange: s, onInput: c, minValue: l, maxValue: u, step: d = 1, accepts: f, display: p = C, placeholder: m, steppers: y, ghost: x, width: E = "fill", className: D, id: O, "aria-label": k }) {
|
|
98
|
-
let [A, j] = o(null), M = a(!1), N = a(null), P = Number.
|
|
98
|
+
let [A, j] = o(null), M = a(!1), N = a(null), P = !Number.isNaN(r), F = P ? _(r, p).text : "", I = (e) => {
|
|
99
|
+
let t = f ? g(e, f) : NaN;
|
|
100
|
+
return Number.isNaN(t) ? h(e, p) : t;
|
|
101
|
+
}, L = {
|
|
99
102
|
step: d,
|
|
100
103
|
min: l,
|
|
101
104
|
max: u
|
|
@@ -168,7 +171,7 @@ function E({ value: r, onChange: s, onInput: c, minValue: l, maxValue: u, step:
|
|
|
168
171
|
inputMode: "decimal",
|
|
169
172
|
autoComplete: "off",
|
|
170
173
|
"aria-label": k,
|
|
171
|
-
"aria-valuenow":
|
|
174
|
+
"aria-valuenow": Number.isFinite(r) ? r : void 0,
|
|
172
175
|
"aria-valuetext": P ? _(r, p).spoken : void 0,
|
|
173
176
|
"aria-valuemin": l,
|
|
174
177
|
"aria-valuemax": u,
|
|
@@ -178,7 +181,7 @@ function E({ value: r, onChange: s, onInput: c, minValue: l, maxValue: u, step:
|
|
|
178
181
|
let t = e.target.value;
|
|
179
182
|
j(t);
|
|
180
183
|
let n = I(t);
|
|
181
|
-
c && t.trim() !== "" && Number.
|
|
184
|
+
c && t.trim() !== "" && !Number.isNaN(n) && c(b(n, L));
|
|
182
185
|
},
|
|
183
186
|
onFocus: () => {
|
|
184
187
|
M.current = !1;
|
|
@@ -186,7 +189,7 @@ function E({ value: r, onChange: s, onInput: c, minValue: l, maxValue: u, step:
|
|
|
186
189
|
onBlur: () => {
|
|
187
190
|
if (A !== null && !M.current) {
|
|
188
191
|
let e = I(A);
|
|
189
|
-
if (Number.
|
|
192
|
+
if (!Number.isNaN(e)) {
|
|
190
193
|
let t = b(e, L);
|
|
191
194
|
t !== r && s(t);
|
|
192
195
|
}
|
|
@@ -206,4 +209,4 @@ function E({ value: r, onChange: s, onInput: c, minValue: l, maxValue: u, step:
|
|
|
206
209
|
//#endregion
|
|
207
210
|
export { S as n, y as r, E as t };
|
|
208
211
|
|
|
209
|
-
//# sourceMappingURL=NumberField-
|
|
212
|
+
//# sourceMappingURL=NumberField-BXFrOi5M.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField-DS0WSiin.js","names":["NumberField","RACNumberField","f","s","RACInput","RACButton","s","f","field_module_default","NumberField_module_default","NumberField$1","forwardRef","rest","props","NumberField","width","orientation","className","label","Label","Group","ghost","Input","hideSteppers","Button","description","Text","FieldError","errorMessage","clampToBounds","max","min","n","placesOf","text","e","dot","spinKey","by","places","from","bounds","key","FULL_PRECISION","decimal","REPEAT_DELAY_MS","REPEAT_EVERY_MS","UnitField","ariaLabel","draft","setDraft","useState","canceled","useRef","input","known","value","qty","display","read","accepts","parseNumber","typed","parseAs","minValue","maxValue","stepTo","onInput","next","onChange","spin","latestSpin","useEffect","el","onWheel","repeat","stopRepeat","startRepeat","tick","delay","stepper","atBound","glyph","steppers"],"sources":["../../src/components/NumberField/NumberField.module.css","../../src/components/NumberField/NumberField.tsx","../../src/components/spin.ts","../../src/components/NumberField/UnitField.tsx"],"sourcesContent":[".frame {\n composes: numeric from '@weasel-js/theme/numeric.module.css';\n display: flex;\n align-items: stretch;\n overflow: hidden;\n}\n\n.frame input {\n padding: 0 var(--wzl-field-pad-x);\n text-align: right;\n -moz-appearance: textfield;\n}\n\n.frame input::-webkit-outer-spin-button,\n.frame input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\n.steppers {\n display: flex;\n flex-direction: column;\n border-left: 1px solid var(--wzl-border);\n}\n\n.stepper {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--wzl-control-h-xs);\n flex: 1;\n /* The two share the frame's height; left to their glyphs' line boxes they\n overflow it, and the frame clips the lower one. */\n min-height: 0;\n height: auto;\n overflow: hidden;\n background: transparent;\n border: none;\n color: var(--wzl-fg-muted);\n cursor: pointer;\n padding: 0;\n font: inherit;\n font-size: min(var(--wzl-font-size-2xs), calc(var(--wzl-field-h, var(--wzl-control-h)) * 0.35));\n line-height: 1;\n}\n\n.stepper:not(:last-child) {\n border-bottom: 1px solid var(--wzl-border);\n}\n\n.stepper[data-hovered]:not([data-disabled]),\n.stepper:hover:not(:disabled):not([data-rac]) {\n background: var(--wzl-surface-hover);\n color: var(--wzl-fg);\n}\n\n.stepper[data-pressed]:not([data-disabled]),\n.stepper:active:not(:disabled):not([data-rac]) {\n background: var(--wzl-surface-pressed);\n}\n\n.stepper[data-disabled],\n.stepper:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n/* Mirrors the property rows' editable readout (`.readoutInput`), so a number\n sitting inside other chrome does not draw a second box around itself. */\n.ghost {\n --_frame-h: auto;\n --_frame-bg: transparent;\n --_frame-border: 1px solid transparent;\n --_frame-fg: var(--wzl-accent-fg);\n --_frame-focus-shadow: none;\n font-weight: var(--wzl-font-weight-medium);\n}\n\n.ghost input {\n padding: 1px 0;\n}\n\n.ghost:hover {\n background: color-mix(in srgb, currentColor 8%, transparent);\n}\n\n.ghost:focus-within {\n background: var(--wzl-surface-sunken);\n}\n\n/* `width='fit'` states the field's width in characters: left alone an `<input>`\n asks for its 20-character intrinsic width, wider than most rows it sits in. */\n.fit .frame {\n width: fit-content;\n max-width: 100%;\n}\n\n.fit .frame input {\n flex: 0 0 auto;\n width: var(--wzl-number-field-width, 9ch);\n}\n","import { forwardRef, type ReactNode, type Ref } from 'react';\nimport {\n NumberField as RACNumberField,\n Label,\n Input as RACInput,\n Group,\n Button as RACButton,\n Text,\n FieldError,\n type NumberFieldProps as RACNumberFieldProps,\n type ValidationResult,\n} from 'react-aria-components';\nimport type { FieldOrientation } from '../Field/Field';\nimport f from '../field.module.css';\nimport s from './NumberField.module.css';\n\n/** Props for {@link NumberField}, on top of React Aria's `NumberField` props. */\nexport type NumberFieldProps = Omit<RACNumberFieldProps, 'children' | 'className'> & {\n label?: ReactNode;\n /**\n * `'stacked'` (the default) puts the label above the field; `'row'` sets it\n * beside the field at its own width, with any description or error on a\n * line below. Same vocabulary as {@link Field}'s `orientation`.\n */\n orientation?: FieldOrientation;\n description?: ReactNode;\n errorMessage?: ReactNode | ((v: ValidationResult) => ReactNode);\n /** Hide the up/down stepper buttons. Defaults to false. */\n hideSteppers?: boolean;\n /** Render with no box until focused — the readout treatment the property\n * rows use, for a value that sits inside other chrome rather than in a form. */\n ghost?: boolean;\n /** Native input placeholder — e.g. `'Mixed'` for a multi-selection\n * editor with no shared value. */\n placeholder?: string;\n /**\n * `'fill'` (the default) takes the width of whatever row the field sits in.\n * `'fit'` sizes it to `--wzl-number-field-width` (`9ch` by default) plus its\n * own chrome, rather than to the input's 20-character intrinsic width.\n */\n width?: 'fill' | 'fit';\n className?: string;\n};\n\n/**\n * Numeric input with stepper buttons, wrapping React Aria's NumberField and\n * supplying the same label / description / errorMessage slots as `Input`.\n * Arrow keys and scroll step the value; parsing and formatting are React\n * Aria's.\n *\n * `ref` forwards to the underlying `<input>`.\n */\nexport const NumberField = forwardRef(function NumberField(\n props: NumberFieldProps,\n ref: Ref<HTMLInputElement>,\n) {\n const {\n label,\n orientation = 'stacked',\n description,\n errorMessage,\n hideSteppers,\n ghost,\n placeholder,\n width = 'fill',\n className,\n ...rest\n } = props;\n return (\n <RACNumberField\n {...rest}\n className={[\n f.field,\n f.control,\n width === 'fit' && `${f.fit} ${s.fit}`,\n orientation === 'row' && f.row,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {label !== undefined && <Label className={f.label}>{label}</Label>}\n <Group className={[f.frame, s.frame, ghost && s.ghost].filter(Boolean).join(' ')}>\n <RACInput ref={ref} placeholder={placeholder} />\n {!hideSteppers && (\n <div className={s.steppers}>\n <RACButton slot=\"increment\" className={s.stepper} aria-label=\"Increment\">▲</RACButton>\n <RACButton slot=\"decrement\" className={s.stepper} aria-label=\"Decrement\">▼</RACButton>\n </div>\n )}\n </Group>\n {description !== undefined && (\n <Text slot=\"description\" className={`${f.hint} ${f.below}`}>\n {description}\n </Text>\n )}\n <FieldError className={`${f.error} ${f.below}`}>{errorMessage}</FieldError>\n </RACNumberField>\n );\n});\n","/** The bounds a spin key moves a value within. */\nexport interface SpinBounds {\n step: number;\n min?: number;\n max?: number;\n}\n\n/** `n` held within the bounds. */\nexport function clampToBounds(n: number, { min, max }: SpinBounds): number {\n return Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n));\n}\n\n/** Decimal places `n` is written with, up to ten. */\nfunction placesOf(n: number): number {\n if (!Number.isFinite(n)) return 0;\n const text = String(n);\n const e = text.indexOf('e-');\n if (e >= 0) return Math.min(10, Number(text.slice(e + 2)));\n const dot = text.indexOf('.');\n return dot < 0 ? 0 : Math.min(10, text.length - dot - 1);\n}\n\n/**\n * The value a spin-button key moves `from` to, or `null` for a key that does\n * not spin: the arrows by a step, Page Up and Page Down by ten, and Home and\n * End to a bound, where there is one. A sum of steps is rounded to the places\n * its operands carry, so `0.1 + 0.2` lands on `0.3`.\n */\nexport function spinKey(key: string, from: number, bounds: SpinBounds): number | null {\n const by = (n: number) => {\n const places = Math.max(placesOf(from), placesOf(bounds.step));\n return clampToBounds(Number((from + n * bounds.step).toFixed(places)), bounds);\n };\n switch (key) {\n case 'ArrowUp':\n return by(1);\n case 'ArrowDown':\n return by(-1);\n case 'PageUp':\n return by(10);\n case 'PageDown':\n return by(-10);\n case 'Home':\n return bounds.min ?? null;\n case 'End':\n return bounds.max ?? null;\n default:\n return null;\n }\n}\n","import { useEffect, useRef, useState } from 'react';\nimport { decimal, parseAs, parseNumber, qty, type Display, type UnitTable } from '@weasel-js/quantity';\nimport { clampToBounds, spinKey } from '../spin';\nimport f from '../field.module.css';\nimport s from './NumberField.module.css';\n\n/** Props for {@link UnitField}. */\nexport interface UnitFieldProps {\n /** The value in the unit the field shows. NaN shows an empty field. */\n value: number;\n /** The committed value, read and clamped, in the unit the field shows: on\n * blur or Enter, and on every step. */\n onChange: (value: number) => void;\n /** The live value: every keystroke that reads as a number, and every step. */\n onInput?: (value: number) => void;\n minValue?: number;\n maxValue?: number;\n /** What an arrow key, a stepper or a wheel notch adds or takes away; Page Up\n * and Page Down move ten. Defaults to 1. */\n step?: number;\n /** Units a person may type, each mapped to the factor that turns a number\n * in it into the unit the field shows: `{ mm: 0.1, cm: 1 }`. */\n accepts?: Readonly<UnitTable>;\n /** How the value shows, is spoken, and reads back when typed: `fraction()`\n * shows `1/12` and reads `1/12` typed. `accepts`, when given, does the\n * reading instead. Default: the number with every decimal it has. */\n display?: Display;\n placeholder?: string;\n /** Up and down buttons beside the value, which repeat while held. */\n steppers?: boolean;\n /** Render with no box until focused, as {@link NumberField}'s `ghost` does. */\n ghost?: boolean;\n /** As {@link NumberField}'s `width`. */\n width?: 'fill' | 'fit';\n className?: string;\n /** Id for the input, for a `<label htmlFor>` outside it. */\n id?: string;\n 'aria-label'?: string;\n}\n\nconst FULL_PRECISION = decimal({ maxPlaces: 20, grouping: false });\n\nconst REPEAT_DELAY_MS = 400;\nconst REPEAT_EVERY_MS = 60;\n\n/**\n * A number typed as text, so it can carry a unit: `12mm` in a field showing\n * centimeters commits `1.2`. Commits on blur or Enter, reverts on Escape or on\n * text it cannot read, and clamps to its bounds. Steps like a spin button —\n * arrows, Page Up and Down, Home and End to a bound, the wheel while focused,\n * and optional steppers. React Aria's `NumberField` refuses letters as they\n * are typed, which is why this is not that.\n */\nexport function UnitField({\n value,\n onChange,\n onInput,\n minValue,\n maxValue,\n step = 1,\n accepts,\n display = FULL_PRECISION,\n placeholder,\n steppers,\n ghost,\n width = 'fill',\n className,\n id,\n 'aria-label': ariaLabel,\n}: UnitFieldProps) {\n const [draft, setDraft] = useState<string | null>(null);\n const canceled = useRef(false);\n const input = useRef<HTMLInputElement>(null);\n const known = Number.isFinite(value);\n const text = known ? qty(value, display).text : '';\n const read = (typed: string) => (accepts ? parseNumber(typed, accepts) : parseAs(typed, display));\n const bounds = { step, min: minValue, max: maxValue };\n\n // What a step starts from: the text as typed where it reads, else the value.\n const from = (): number => {\n const typed = draft === null ? value : read(draft);\n return Number.isFinite(typed) ? typed : Number.isFinite(value) ? value : 0;\n };\n const stepTo = (next: number) => {\n setDraft(null);\n onInput?.(next);\n if (next !== value) onChange(next);\n };\n const spin = (key: string): boolean => {\n const next = spinKey(key, from(), bounds);\n if (next === null) return false;\n stepTo(next);\n return true;\n };\n\n // The latest `spin`, for the listeners below, which outlive a render.\n const latestSpin = useRef(spin);\n useEffect(() => {\n latestSpin.current = spin;\n });\n\n // The wheel steps only a focused field, so scrolling past one changes nothing.\n // Not passive, so it can keep the page from scrolling under it.\n useEffect(() => {\n const el = input.current;\n if (!el) return;\n const onWheel = (e: WheelEvent) => {\n if (document.activeElement !== el || e.deltaY === 0) return;\n e.preventDefault();\n latestSpin.current(e.deltaY < 0 ? 'ArrowUp' : 'ArrowDown');\n };\n el.addEventListener('wheel', onWheel, { passive: false });\n return () => el.removeEventListener('wheel', onWheel);\n }, []);\n\n const repeat = useRef<ReturnType<typeof setTimeout> | null>(null);\n const stopRepeat = () => {\n if (repeat.current !== null) clearTimeout(repeat.current);\n repeat.current = null;\n };\n useEffect(() => stopRepeat, []);\n const startRepeat = (key: 'ArrowUp' | 'ArrowDown') => {\n stopRepeat();\n latestSpin.current(key);\n const tick = (delay: number) => {\n repeat.current = setTimeout(() => {\n latestSpin.current(key);\n tick(REPEAT_EVERY_MS);\n }, delay);\n };\n tick(REPEAT_DELAY_MS);\n };\n const stepper = (key: 'ArrowUp' | 'ArrowDown', label: string, glyph: string, atBound: boolean) => (\n <button\n type=\"button\"\n className={s.stepper}\n aria-label={label}\n tabIndex={-1}\n disabled={atBound}\n // Keeps focus in the input, where a press on the button would take it.\n onPointerDown={(e) => {\n e.preventDefault();\n startRepeat(key);\n }}\n onPointerUp={stopRepeat}\n onPointerLeave={stopRepeat}\n onPointerCancel={stopRepeat}\n // A click with no pointer down before it — assistive tech, or a test.\n onClick={(e) => {\n if (e.detail === 0) latestSpin.current(key);\n }}\n >\n {glyph}\n </button>\n );\n\n return (\n <div\n className={[f.field, f.control, width === 'fit' && `${f.fit} ${s.fit}`, className]\n .filter(Boolean)\n .join(' ')}\n >\n <div className={[f.frame, s.frame, ghost && s.ghost].filter(Boolean).join(' ')}>\n <input\n ref={input}\n id={id}\n type=\"text\"\n role=\"spinbutton\"\n inputMode=\"decimal\"\n autoComplete=\"off\"\n aria-label={ariaLabel}\n aria-valuenow={known ? value : undefined}\n aria-valuetext={known ? qty(value, display).spoken : undefined}\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n placeholder={placeholder}\n value={draft ?? text}\n onChange={(e) => {\n const typed = e.target.value;\n setDraft(typed);\n const n = read(typed);\n if (onInput && typed.trim() !== '' && Number.isFinite(n)) onInput(clampToBounds(n, bounds));\n }}\n onFocus={() => {\n canceled.current = false;\n }}\n onBlur={() => {\n if (draft !== null && !canceled.current) {\n const n = read(draft);\n if (Number.isFinite(n)) {\n const next = clampToBounds(n, bounds);\n if (next !== value) onChange(next);\n }\n }\n setDraft(null);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.currentTarget.blur();\n } else if (e.key === 'Escape') {\n canceled.current = true;\n e.currentTarget.blur();\n } else if (spin(e.key)) {\n e.preventDefault();\n }\n }}\n />\n {steppers && (\n <div className={s.steppers}>\n {stepper('ArrowUp', 'Increment', '▲', known && maxValue !== undefined && value >= maxValue)}\n {stepper('ArrowDown', 'Decrement', '▼', known && minValue !== undefined && value <= minValue)}\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;GCoDaA,IAAcW,EAAW,SACpC,GACA,GACA;CACA,IAAM,EACJ,UACA,iBAAc,WACd,gBACA,iBACA,iBACA,UACA,gBACA,WAAQ,QACR,cACA,GAAGC,MACDC;CACJ,OACE,kBAACZ,GAAD;EACE,GAAIW;EACJ,WAAW;GACTV,EAAE;GACFA,EAAE;GACFa,MAAU,SAAS,GAAGb,EAAE,IAAI,GAAGC,EAAE;GACjCa,MAAgB,SAASd,EAAE;GAC3Be;EACF,CAAC,CACE,OA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AASD,CAAI;MACnC;KACF;KACA,EAAS,IAAI;IACf;IACA,YAAY,MAAM;KAChB,AAAI,EAAE,QAAQ,UACZ,EAAE,cAAc,KAAK,IACZ,EAAE,QAAQ,YACnB,EAAS,UAAU,IACnB,EAAE,cAAc,KAAK,KACZE,EAAK,EAAE,GAAG,KACnB,EAAE,eAAe;IAErB;GACD,CAAA,GACAa,KACC,kBAAC,OAAD;IAAK,WAAW7E,EAAE;IAAlB,UAAA,CACG0E,EAAQ,WAAW,aAAa,KAAKzB,KAASU,MAAa,KAAA,KAAaT,KAASS,CAAQ,GACzFe,EAAQ,aAAa,aAAa,KAAKzB,KAASS,MAAa,KAAA,KAAaR,KAASQ,CAAQ,CACzF;GAEJ,CAAA,CAAA;;CACF,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"NumberField-BXFrOi5M.js","names":["NumberField","RACNumberField","f","s","RACInput","RACButton","s","f","field_module_default","NumberField_module_default","NumberField$1","forwardRef","rest","props","NumberField","width","orientation","className","label","Label","Group","ghost","Input","hideSteppers","Button","description","Text","FieldError","errorMessage","clampToBounds","max","min","n","placesOf","text","e","dot","spinKey","by","places","from","bounds","key","FULL_PRECISION","decimal","REPEAT_DELAY_MS","REPEAT_EVERY_MS","UnitField","ariaLabel","draft","setDraft","useState","canceled","useRef","input","known","value","qty","display","read","accepts","parseNumber","typed","parseAs","minValue","maxValue","stepTo","onInput","next","onChange","spin","latestSpin","useEffect","el","onWheel","repeat","stopRepeat","startRepeat","tick","delay","stepper","atBound","glyph","steppers"],"sources":["../../src/components/NumberField/NumberField.module.css","../../src/components/NumberField/NumberField.tsx","../../src/components/spin.ts","../../src/components/NumberField/UnitField.tsx"],"sourcesContent":[".frame {\n composes: numeric from '@weasel-js/theme/numeric.module.css';\n display: flex;\n align-items: stretch;\n overflow: hidden;\n}\n\n.frame input {\n padding: 0 var(--wzl-field-pad-x);\n text-align: right;\n -moz-appearance: textfield;\n}\n\n.frame input::-webkit-outer-spin-button,\n.frame input::-webkit-inner-spin-button {\n -webkit-appearance: none;\n margin: 0;\n}\n\n.steppers {\n display: flex;\n flex-direction: column;\n border-left: 1px solid var(--wzl-border);\n}\n\n.stepper {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: var(--wzl-control-h-xs);\n flex: 1;\n /* The two share the frame's height; left to their glyphs' line boxes they\n overflow it, and the frame clips the lower one. */\n min-height: 0;\n height: auto;\n overflow: hidden;\n background: transparent;\n border: none;\n color: var(--wzl-fg-muted);\n cursor: pointer;\n padding: 0;\n font: inherit;\n font-size: min(var(--wzl-font-size-2xs), calc(var(--wzl-field-h, var(--wzl-control-h)) * 0.35));\n line-height: 1;\n}\n\n.stepper:not(:last-child) {\n border-bottom: 1px solid var(--wzl-border);\n}\n\n.stepper[data-hovered]:not([data-disabled]),\n.stepper:hover:not(:disabled):not([data-rac]) {\n background: var(--wzl-surface-hover);\n color: var(--wzl-fg);\n}\n\n.stepper[data-pressed]:not([data-disabled]),\n.stepper:active:not(:disabled):not([data-rac]) {\n background: var(--wzl-surface-pressed);\n}\n\n.stepper[data-disabled],\n.stepper:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n/* Mirrors the property rows' editable readout (`.readoutInput`), so a number\n sitting inside other chrome does not draw a second box around itself. */\n.ghost {\n --_frame-h: auto;\n --_frame-bg: transparent;\n --_frame-border: 1px solid transparent;\n --_frame-fg: var(--wzl-accent-fg);\n --_frame-focus-shadow: none;\n font-weight: var(--wzl-font-weight-medium);\n}\n\n.ghost input {\n padding: 1px 0;\n}\n\n.ghost:hover {\n background: color-mix(in srgb, currentColor 8%, transparent);\n}\n\n.ghost:focus-within {\n background: var(--wzl-surface-sunken);\n}\n\n/* `width='fit'` states the field's width in characters: left alone an `<input>`\n asks for its 20-character intrinsic width, wider than most rows it sits in. */\n.fit .frame {\n width: fit-content;\n max-width: 100%;\n}\n\n.fit .frame input {\n flex: 0 0 auto;\n width: var(--wzl-number-field-width, 9ch);\n}\n","import { forwardRef, type ReactNode, type Ref } from 'react';\nimport {\n NumberField as RACNumberField,\n Label,\n Input as RACInput,\n Group,\n Button as RACButton,\n Text,\n FieldError,\n type NumberFieldProps as RACNumberFieldProps,\n type ValidationResult,\n} from 'react-aria-components';\nimport type { FieldOrientation } from '../Field/Field';\nimport f from '../field.module.css';\nimport s from './NumberField.module.css';\n\n/** Props for {@link NumberField}, on top of React Aria's `NumberField` props. */\nexport type NumberFieldProps = Omit<RACNumberFieldProps, 'children' | 'className'> & {\n label?: ReactNode;\n /**\n * `'stacked'` (the default) puts the label above the field; `'row'` sets it\n * beside the field at its own width, with any description or error on a\n * line below. Same vocabulary as {@link Field}'s `orientation`.\n */\n orientation?: FieldOrientation;\n description?: ReactNode;\n errorMessage?: ReactNode | ((v: ValidationResult) => ReactNode);\n /** Hide the up/down stepper buttons. Defaults to false. */\n hideSteppers?: boolean;\n /** Render with no box until focused — the readout treatment the property\n * rows use, for a value that sits inside other chrome rather than in a form. */\n ghost?: boolean;\n /** Native input placeholder — e.g. `'Mixed'` for a multi-selection\n * editor with no shared value. */\n placeholder?: string;\n /**\n * `'fill'` (the default) takes the width of whatever row the field sits in.\n * `'fit'` sizes it to `--wzl-number-field-width` (`9ch` by default) plus its\n * own chrome, rather than to the input's 20-character intrinsic width.\n */\n width?: 'fill' | 'fit';\n className?: string;\n};\n\n/**\n * Numeric input with stepper buttons, wrapping React Aria's NumberField and\n * supplying the same label / description / errorMessage slots as `Input`.\n * Arrow keys and scroll step the value; parsing and formatting are React\n * Aria's.\n *\n * `ref` forwards to the underlying `<input>`.\n */\nexport const NumberField = forwardRef(function NumberField(\n props: NumberFieldProps,\n ref: Ref<HTMLInputElement>,\n) {\n const {\n label,\n orientation = 'stacked',\n description,\n errorMessage,\n hideSteppers,\n ghost,\n placeholder,\n width = 'fill',\n className,\n ...rest\n } = props;\n return (\n <RACNumberField\n {...rest}\n className={[\n f.field,\n f.control,\n width === 'fit' && `${f.fit} ${s.fit}`,\n orientation === 'row' && f.row,\n className,\n ]\n .filter(Boolean)\n .join(' ')}\n >\n {label !== undefined && <Label className={f.label}>{label}</Label>}\n <Group className={[f.frame, s.frame, ghost && s.ghost].filter(Boolean).join(' ')}>\n <RACInput ref={ref} placeholder={placeholder} />\n {!hideSteppers && (\n <div className={s.steppers}>\n <RACButton slot=\"increment\" className={s.stepper} aria-label=\"Increment\">▲</RACButton>\n <RACButton slot=\"decrement\" className={s.stepper} aria-label=\"Decrement\">▼</RACButton>\n </div>\n )}\n </Group>\n {description !== undefined && (\n <Text slot=\"description\" className={`${f.hint} ${f.below}`}>\n {description}\n </Text>\n )}\n <FieldError className={`${f.error} ${f.below}`}>{errorMessage}</FieldError>\n </RACNumberField>\n );\n});\n","/** The bounds a spin key moves a value within. */\nexport interface SpinBounds {\n step: number;\n min?: number;\n max?: number;\n}\n\n/** `n` held within the bounds. */\nexport function clampToBounds(n: number, { min, max }: SpinBounds): number {\n return Math.min(max ?? Infinity, Math.max(min ?? -Infinity, n));\n}\n\n/** Decimal places `n` is written with, up to ten. */\nfunction placesOf(n: number): number {\n if (!Number.isFinite(n)) return 0;\n const text = String(n);\n const e = text.indexOf('e-');\n if (e >= 0) return Math.min(10, Number(text.slice(e + 2)));\n const dot = text.indexOf('.');\n return dot < 0 ? 0 : Math.min(10, text.length - dot - 1);\n}\n\n/**\n * The value a spin-button key moves `from` to, or `null` for a key that does\n * not spin: the arrows by a step, Page Up and Page Down by ten, and Home and\n * End to a bound, where there is one. A sum of steps is rounded to the places\n * its operands carry, so `0.1 + 0.2` lands on `0.3`.\n */\nexport function spinKey(key: string, from: number, bounds: SpinBounds): number | null {\n const by = (n: number) => {\n const places = Math.max(placesOf(from), placesOf(bounds.step));\n return clampToBounds(Number((from + n * bounds.step).toFixed(places)), bounds);\n };\n switch (key) {\n case 'ArrowUp':\n return by(1);\n case 'ArrowDown':\n return by(-1);\n case 'PageUp':\n return by(10);\n case 'PageDown':\n return by(-10);\n case 'Home':\n return bounds.min ?? null;\n case 'End':\n return bounds.max ?? null;\n default:\n return null;\n }\n}\n","import { useEffect, useRef, useState } from 'react';\nimport { decimal, parseAs, parseNumber, qty, type Display, type UnitTable } from '@weasel-js/quantity';\nimport { clampToBounds, spinKey } from '../spin';\nimport f from '../field.module.css';\nimport s from './NumberField.module.css';\n\n/** Props for {@link UnitField}. */\nexport interface UnitFieldProps {\n /** The value in the unit the field shows. NaN shows an empty field. */\n value: number;\n /** The committed value, read and clamped, in the unit the field shows: on\n * blur or Enter, and on every step. */\n onChange: (value: number) => void;\n /** The live value: every keystroke that reads as a number, and every step. */\n onInput?: (value: number) => void;\n minValue?: number;\n maxValue?: number;\n /** What an arrow key, a stepper or a wheel notch adds or takes away; Page Up\n * and Page Down move ten. Defaults to 1. */\n step?: number;\n /** Units a person may type, each mapped to the factor that turns a number\n * in it into the unit the field shows: `{ mm: 0.1, cm: 1 }`. */\n accepts?: Readonly<UnitTable>;\n /** How the value shows, is spoken, and reads back when typed: `fraction()`\n * shows `1/12` and reads `1/12` typed. `accepts`, when given, does the\n * reading instead. Default: the number with every decimal it has. */\n display?: Display;\n placeholder?: string;\n /** Up and down buttons beside the value, which repeat while held. */\n steppers?: boolean;\n /** Render with no box until focused, as {@link NumberField}'s `ghost` does. */\n ghost?: boolean;\n /** As {@link NumberField}'s `width`. */\n width?: 'fill' | 'fit';\n className?: string;\n /** Id for the input, for a `<label htmlFor>` outside it. */\n id?: string;\n 'aria-label'?: string;\n}\n\nconst FULL_PRECISION = decimal({ maxPlaces: 20, grouping: false });\n\nconst REPEAT_DELAY_MS = 400;\nconst REPEAT_EVERY_MS = 60;\n\n/**\n * A number typed as text, so it can carry a unit: `12mm` in a field showing\n * centimeters commits `1.2`. Commits on blur or Enter, reverts on Escape or on\n * text it cannot read, and clamps to its bounds. Steps like a spin button —\n * arrows, Page Up and Down, Home and End to a bound, the wheel while focused,\n * and optional steppers. React Aria's `NumberField` refuses letters as they\n * are typed, which is why this is not that.\n */\nexport function UnitField({\n value,\n onChange,\n onInput,\n minValue,\n maxValue,\n step = 1,\n accepts,\n display = FULL_PRECISION,\n placeholder,\n steppers,\n ghost,\n width = 'fill',\n className,\n id,\n 'aria-label': ariaLabel,\n}: UnitFieldProps) {\n const [draft, setDraft] = useState<string | null>(null);\n const canceled = useRef(false);\n const input = useRef<HTMLInputElement>(null);\n const known = !Number.isNaN(value);\n const text = known ? qty(value, display).text : '';\n // `accepts` reads units; the display still reads its own words, like infinity's.\n const read = (typed: string) => {\n const n = accepts ? parseNumber(typed, accepts) : Number.NaN;\n return Number.isNaN(n) ? parseAs(typed, display) : n;\n };\n const bounds = { step, min: minValue, max: maxValue };\n\n // What a step starts from: the text as typed where it reads, else the value.\n const from = (): number => {\n const typed = draft === null ? value : read(draft);\n return Number.isFinite(typed) ? typed : Number.isFinite(value) ? value : 0;\n };\n const stepTo = (next: number) => {\n setDraft(null);\n onInput?.(next);\n if (next !== value) onChange(next);\n };\n const spin = (key: string): boolean => {\n const next = spinKey(key, from(), bounds);\n if (next === null) return false;\n stepTo(next);\n return true;\n };\n\n // The latest `spin`, for the listeners below, which outlive a render.\n const latestSpin = useRef(spin);\n useEffect(() => {\n latestSpin.current = spin;\n });\n\n // The wheel steps only a focused field, so scrolling past one changes nothing.\n // Not passive, so it can keep the page from scrolling under it.\n useEffect(() => {\n const el = input.current;\n if (!el) return;\n const onWheel = (e: WheelEvent) => {\n if (document.activeElement !== el || e.deltaY === 0) return;\n e.preventDefault();\n latestSpin.current(e.deltaY < 0 ? 'ArrowUp' : 'ArrowDown');\n };\n el.addEventListener('wheel', onWheel, { passive: false });\n return () => el.removeEventListener('wheel', onWheel);\n }, []);\n\n const repeat = useRef<ReturnType<typeof setTimeout> | null>(null);\n const stopRepeat = () => {\n if (repeat.current !== null) clearTimeout(repeat.current);\n repeat.current = null;\n };\n useEffect(() => stopRepeat, []);\n const startRepeat = (key: 'ArrowUp' | 'ArrowDown') => {\n stopRepeat();\n latestSpin.current(key);\n const tick = (delay: number) => {\n repeat.current = setTimeout(() => {\n latestSpin.current(key);\n tick(REPEAT_EVERY_MS);\n }, delay);\n };\n tick(REPEAT_DELAY_MS);\n };\n const stepper = (key: 'ArrowUp' | 'ArrowDown', label: string, glyph: string, atBound: boolean) => (\n <button\n type=\"button\"\n className={s.stepper}\n aria-label={label}\n tabIndex={-1}\n disabled={atBound}\n // Keeps focus in the input, where a press on the button would take it.\n onPointerDown={(e) => {\n e.preventDefault();\n startRepeat(key);\n }}\n onPointerUp={stopRepeat}\n onPointerLeave={stopRepeat}\n onPointerCancel={stopRepeat}\n // A click with no pointer down before it — assistive tech, or a test.\n onClick={(e) => {\n if (e.detail === 0) latestSpin.current(key);\n }}\n >\n {glyph}\n </button>\n );\n\n return (\n <div\n className={[f.field, f.control, width === 'fit' && `${f.fit} ${s.fit}`, className]\n .filter(Boolean)\n .join(' ')}\n >\n <div className={[f.frame, s.frame, ghost && s.ghost].filter(Boolean).join(' ')}>\n <input\n ref={input}\n id={id}\n type=\"text\"\n role=\"spinbutton\"\n inputMode=\"decimal\"\n autoComplete=\"off\"\n aria-label={ariaLabel}\n aria-valuenow={Number.isFinite(value) ? value : undefined}\n aria-valuetext={known ? qty(value, display).spoken : undefined}\n aria-valuemin={minValue}\n aria-valuemax={maxValue}\n placeholder={placeholder}\n value={draft ?? text}\n onChange={(e) => {\n const typed = e.target.value;\n setDraft(typed);\n const n = read(typed);\n if (onInput && typed.trim() !== '' && !Number.isNaN(n)) onInput(clampToBounds(n, bounds));\n }}\n onFocus={() => {\n canceled.current = false;\n }}\n onBlur={() => {\n if (draft !== null && !canceled.current) {\n const n = read(draft);\n if (!Number.isNaN(n)) {\n const next = clampToBounds(n, bounds);\n if (next !== value) onChange(next);\n }\n }\n setDraft(null);\n }}\n onKeyDown={(e) => {\n if (e.key === 'Enter') {\n e.currentTarget.blur();\n } else if (e.key === 'Escape') {\n canceled.current = true;\n e.currentTarget.blur();\n } else if (spin(e.key)) {\n e.preventDefault();\n }\n }}\n />\n {steppers && (\n <div className={s.steppers}>\n {stepper('ArrowUp', 'Increment', '▲', known && maxValue !== undefined && value >= maxValue)}\n {stepper('ArrowDown', 'Decrement', '▼', known && minValue !== undefined && value <= minValue)}\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;GCoDaA,IAAcW,EAAW,SACpC,GACA,GACA;CACA,IAAM,EACJ,UACA,iBAAc,WACd,gBACA,iBACA,iBACA,UACA,gBACA,WAAQ,QACR,cACA,GAAGC,MACDC;CACJ,OACE,kBAACZ,GAAD;EACE,GAAIW;EACJ,WAAW;GACTV,EAAE;GACFA,EAAE;GACFa,MAAU,SAAS,GAAGb,EAAE,IAAI,GAAGC,EAAE;GACjCa,MAAgB,SAASd,EAAE;GAC3Be;EACF,CAAC,CACE,OAAO,OAAO,CAAC,CACf,KAAK,GAAG;EAVb,UAAA;GAYGC,MAAU,KAAA,KAAa,kBAACC,GAAD;IAAO,WAAWjB,EAAE;IAAQ,UAAAgB;GAAa,CAAA;GACjE,kBAACE,GAAD;IAAO,WAAW;KAAClB,EAAE;KAAOC,EAAE;KAAOkB,KAASlB,EAAE;IAAK,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;IAA/E,UAAA,CACE,kBAACC,GAAD;KAAe;KAAkB;IAAc,CAAA,GAC9C,CAACmB,KACA,kBAAC,OAAD;KAAK,WAAWpB,EAAE;KAAlB,UAAA,CACE,kBAACE,GAAD;MAAW,MAAK;MAAY,WAAWF,EAAE;MAAS,cAAW;MAAY,UAAA;KAAY,CAAA,GACrF,kBAACE,GAAD;MAAW,MAAK;MAAY,WAAWF,EAAE;MAAS,cAAW;MAAY,UAAA;KAAY,CAAA,CAClF;IAEF,CAAA,CAAA;;GACNsB,MAAgB,KAAA,KACf,kBAACC,GAAD;IAAM,MAAK;IAAc,WAAW,GAAGxB,EAAE,KAAK,GAAGA,EAAE;IAChD,UAAAuB;GACG,CAAA;GAER,kBAACE,GAAD;IAAY,WAAW,GAAGzB,EAAE,MAAM,GAAGA,EAAE;IAAU,UAAA0B;GAAy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AAID,GAAOE,CAAO,CAAC,CAAC,SAAS,KAAA;IACrD,iBAAeM;IACf,iBAAeC;IACF;IACb,OAAOhB,KAASf;IAChB,WAAW,MAAM;KACf,IAAM4B,IAAQ,EAAE,OAAO;KACvB,EAASA,CAAK;KACd,IAAM,IAAIH,EAAKG,CAAK;KACpB,AAAIK,KAAWL,EAAM,KAAK,MAAM,MAAM,CAAC,OAAO,MAAM,CAAC,KAAGK,EAAQtC,EAAc,GAAGY,CAAM,CAAC;IAC1F;IACA,eAAe;KACb,EAAS,UAAU;IACrB;IACA,cAAc;KACZ,IAAIQ,MAAU,QAAQ,CAACG,EAAS,SAAS;MACvC,IAAMpB,IAAI2B,EAAKV,CAAK;MACpB,IAAI,CAAC,OAAO,MAAMjB,CAAC,GAAG;OACpB,IAAMoC,IAAOvC,EAAcG,GAAGS,CAAM;OACpC,AAAI2B,MAASZ,KAAOa,EAASD,CAAI;MACnC;KACF;KACA,EAAS,IAAI;IACf;IACA,YAAY,MAAM;KAChB,AAAI,EAAE,QAAQ,UACZ,EAAE,cAAc,KAAK,IACZ,EAAE,QAAQ,YACnB,EAAS,UAAU,IACnB,EAAE,cAAc,KAAK,KACZE,EAAK,EAAE,GAAG,KACnB,EAAE,eAAe;IAErB;GACD,CAAA,GACAa,KACC,kBAAC,OAAD;IAAK,WAAW7E,EAAE;IAAlB,UAAA,CACG0E,EAAQ,WAAW,aAAa,KAAKzB,KAASU,MAAa,KAAA,KAAaT,KAASS,CAAQ,GACzFe,EAAQ,aAAa,aAAa,KAAKzB,KAASS,MAAa,KAAA,KAAaR,KAASQ,CAAQ,CACzF;GAEJ,CAAA,CAAA;;CACF,CAAA;AAET"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./useRovingTabIndex-D7u22Ia_.js";
|
|
2
|
-
import { t } from "./segmentedControl.module-
|
|
2
|
+
import { t } from "./segmentedControl.module-62qjNWJk.js";
|
|
3
3
|
import { jsx as n } from "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
5
|
//#region src/components/OptionsBar/OptionsBar.tsx
|
|
@@ -38,6 +38,12 @@ function r(r) {
|
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
//#endregion
|
|
41
|
-
|
|
41
|
+
//#region src/components/OptionsBar/variantIcons.ts
|
|
42
|
+
var i = {
|
|
43
|
+
default: "variantSegmented",
|
|
44
|
+
minimal: "variantSegmentedMinimal"
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { r as n, i as t };
|
|
42
48
|
|
|
43
|
-
//# sourceMappingURL=OptionsBar-
|
|
49
|
+
//# sourceMappingURL=OptionsBar-DyTXbev-.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OptionsBar-DyTXbev-.js","names":["s","useRovingTabIndex","OptionsBar","props","toggle","item","items","index","roving","segmentedControl_module_default","style","height","rootCls","size","variant","className","ariaLabel","cls","i","OPTIONS_BAR_VARIANT_ICONS"],"sources":["../../src/components/OptionsBar/OptionsBar.tsx","../../src/components/OptionsBar/variantIcons.ts"],"sourcesContent":["import { type CSSProperties, type ReactElement, type ReactNode } from 'react';\nimport s from '../segmentedControl.module.css';\nimport { useRovingTabIndex } from '../../useRovingTabIndex';\n\n/**\n * One segment of an {@link OptionsBar}. Unlike `ToggleBar`, each item carries\n * its own selected state and its own `onChange`.\n */\nexport type OptionsBarItem<V extends string | number = string> = {\n value: V;\n label?: ReactNode;\n ariaLabel?: string;\n disabled?: boolean;\n selected: boolean;\n onChange: (next: boolean) => void;\n};\n\n/** Segment height and type scale for an {@link OptionsBar}. */\nexport type OptionsBarSize = 'sm' | 'md';\n/** Visual treatment of an {@link OptionsBar}. */\nexport type OptionsBarVariant = 'default' | 'minimal';\n\n/** Props for {@link OptionsBar}. */\nexport type OptionsBarProps<V extends string | number = string> = {\n items: readonly OptionsBarItem<V>[];\n ariaLabel?: string;\n className?: string;\n height?: number;\n /** Size variant. `sm` is ~60% of the default height with reduced padding\n * and font size — sized for dense surfaces like lab control panels. */\n size?: OptionsBarSize;\n /** Visual variant. `minimal` strips the pill track and glass treatment;\n * selection becomes a flat accent. For dense diagnostic surfaces. */\n variant?: OptionsBarVariant;\n};\n\n/**\n * Segmented strip of independent on/off options, each owning its own state.\n * Use it when the segments are unrelated booleans; use `ToggleBar` when they\n * are values of one setting.\n */\nexport function OptionsBar<V extends string | number = string>(props: OptionsBarProps<V>): ReactElement {\n const { items, ariaLabel, className, height, size, variant } = props;\n\n const toggle = (index: number) => {\n const item = items[index];\n if (item.disabled) return;\n item.onChange(!item.selected);\n };\n\n const roving = useRovingTabIndex({ itemSelector: `.${s.segment}`, onActivate: toggle });\n\n const style: CSSProperties | undefined = height !== undefined\n ? ({ ['--tb-h' as string]: `${height}px` } as CSSProperties)\n : undefined;\n\n const rootCls = [\n s.root,\n size && s[`size_${size}`],\n variant && s[`variant_${variant}`],\n className,\n ].filter(Boolean).join(' ');\n\n return (\n <div\n ref={roving.rootRef}\n onKeyDown={roving.onKeyDown}\n className={rootCls}\n role=\"group\"\n aria-label={ariaLabel}\n style={style}\n >\n {items.map((item, i) => {\n const cls = `${s.segment}${item.selected ? ` ${s.segmentSelected}` : ''}`;\n return (\n <button\n key={item.value}\n type=\"button\"\n aria-pressed={item.selected}\n aria-label={item.ariaLabel}\n disabled={item.disabled}\n className={cls}\n onClick={() => toggle(i)}\n >\n {item.label}\n </button>\n );\n })}\n </div>\n );\n}\n","import type { IconName } from '../../icons/paths';\nimport type { OptionsBarVariant } from './OptionsBar';\n\n/** The glyph for each variant, for a picker that shows them. */\nexport const OPTIONS_BAR_VARIANT_ICONS: Readonly<Record<OptionsBarVariant, IconName>> = {\n default: 'variantSegmented',\n minimal: 'variantSegmentedMinimal',\n};\n"],"mappings":";;;;;AAyCA,SAAgBE,EAA+C,GAAyC;CACtG,IAAM,EAAE,UAAO,cAAW,cAAW,WAAQ,SAAM,eAAYC,GAEzDC,KAAU,MAAkB;EAChC,IAAMC,IAAOC,EAAMC;EACnB,AAAIF,EAAK,YACTA,EAAK,SAAS,CAACA,EAAK,QAAQ;CAC9B,GAEMG,IAASP,EAAkB;EAAE,cAAc,IAAID,EAAE;EAAW,YAAYI;CAAO,CAAC,GAEhFM,IAAmCC,MAAW,KAAA,IAEhD,KAAA,IADC,EAAG,UAAqB,GAAGA,EAAO,IAAI,GAGrCC,IAAU;EACdZ,EAAE;EACFa,KAAQb,EAAE,QAAQa;EAClBC,KAAWd,EAAE,WAAWc;EACxBC;CACF,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAE1B,OACE,kBAAC,OAAD;EACE,KAAKP,EAAO;EACZ,WAAWA,EAAO;EAClB,WAAWI;EACX,MAAK;EACL,cAAYI;EACL;EAEN,UAAAV,EAAM,KAAK,GAAM,MAAM;GACtB,IAAMW,IAAM,GAAGjB,EAAE,UAAUK,EAAK,WAAW,IAAIL,EAAE,oBAAoB;GACrE,OACE,kBAAC,UAAD;IAEE,MAAK;IACL,gBAAcK,EAAK;IACnB,cAAYA,EAAK;IACjB,UAAUA,EAAK;IACf,WAAWY;IACX,eAAeb,EAAOc,CAAC;IAEtB,UAAAb,EAAK;GACA,GATDA,EAAK,KASJ;EAEZ,CAAC;CACE,CAAA;AAET;;;ACtFA,IAAac,IAA2E;CACtF,SAAS;CACT,SAAS;AACX"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { i as e } from "./portalHost-
|
|
1
|
+
import { i as e } from "./portalHost-RUQPxIoW.js";
|
|
2
2
|
import { t } from "./listbox.module-BcdVJMbm.js";
|
|
3
3
|
import { t as n } from "./paintPreview-CuSZiHpR.js";
|
|
4
|
-
import { t as r } from "./PaintInput-
|
|
4
|
+
import { t as r } from "./PaintInput-DSS5IjXn.js";
|
|
5
5
|
import { usePaintKind as i } from "@weasel-js/core";
|
|
6
6
|
import { jsx as a, jsxs as o } from "react/jsx-runtime";
|
|
7
7
|
import "react";
|
|
@@ -19,7 +19,7 @@ function f(e, t, n) {
|
|
|
19
19
|
return t ? "Mixed" : e === null ? "None" : e === void 0 ? "—" : n ?? e.fill ?? "solid";
|
|
20
20
|
}
|
|
21
21
|
function p(p) {
|
|
22
|
-
let { value: m, mixed: h = !1, unset: g = !1, kinds: _, allowNone: v = !0, onInput: y, onChange: b, className: x, portalContainer: S } = p, C = p["aria-label"], { anchor: w, portalProps: T } = e(S),
|
|
22
|
+
let { value: m, mixed: h = !1, unset: g = !1, kinds: _, allowNone: v = !0, onInput: y, onChange: b, className: x, portalContainer: S } = p, C = p["aria-label"], { anchor: w, portalProps: T, ready: E } = e(S), D = h ? void 0 : n(m), O = i(m?.fill)?.label;
|
|
23
23
|
return /* @__PURE__ */ o(l, { children: [
|
|
24
24
|
w,
|
|
25
25
|
/* @__PURE__ */ o(s, {
|
|
@@ -30,13 +30,13 @@ function p(p) {
|
|
|
30
30
|
children: [/* @__PURE__ */ a("span", {
|
|
31
31
|
className: d.swatch,
|
|
32
32
|
"aria-hidden": "true",
|
|
33
|
-
...
|
|
33
|
+
...D ? { style: { background: D } } : { "data-empty": "" }
|
|
34
34
|
}), /* @__PURE__ */ a("span", {
|
|
35
35
|
className: d.label,
|
|
36
|
-
children: f(m, h,
|
|
36
|
+
children: f(m, h, O)
|
|
37
37
|
})]
|
|
38
38
|
}),
|
|
39
|
-
/* @__PURE__ */ a(u, {
|
|
39
|
+
E && /* @__PURE__ */ a(u, {
|
|
40
40
|
className: d.popover,
|
|
41
41
|
"data-weasel-overlay": "",
|
|
42
42
|
...T,
|
|
@@ -60,4 +60,4 @@ function p(p) {
|
|
|
60
60
|
//#endregion
|
|
61
61
|
export { p as t };
|
|
62
62
|
|
|
63
|
-
//# sourceMappingURL=PaintField
|
|
63
|
+
//# sourceMappingURL=PaintField--GbF8sL7.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PaintField--GbF8sL7.js","names":["RACButton","s","RACPopover","RACDialog","listbox","useOverlayPortal","paintPreviewCss","PaintInput","PaintField_module_default","kindLabel","mixed","paint","label","PaintField","props","ariaLabel","portalContainer","preview","value","usePaintKind","DialogTrigger","anchor","Button","className","unset","ready","Popover","portalProps","Dialog","listbox_module_default"],"sources":["../../src/components/PaintField/PaintField.module.css","../../src/components/PaintField/PaintField.tsx"],"sourcesContent":[".trigger {\n display: inline-flex;\n align-items: center;\n gap: var(--wzl-space-3);\n inline-size: 100%;\n min-inline-size: 0;\n padding: 1px var(--wzl-space-3) 1px 1px;\n border: 1px solid var(--wzl-border);\n border-radius: var(--wzl-radius-sm);\n background: var(--wzl-surface);\n color: var(--wzl-fg);\n font-family: var(--wzl-font-ui);\n font-size: var(--wzl-font-size-sm);\n cursor: pointer;\n}\n\n.trigger[data-unset] {\n opacity: 0.6;\n}\n\n.trigger[data-focus-visible] {\n outline: none;\n border-color: var(--wzl-focus-ring);\n box-shadow: 0 0 0 1px var(--wzl-focus-ring);\n}\n\n.swatch {\n /* A paint preview at a fixed 26:18 aspect, not a control box. */\n inline-size: 26px;\n block-size: 18px; /* not-a-control */\n flex: 0 0 auto;\n border-radius: calc(var(--wzl-radius-sm) - var(--wzl-border-w));\n /* Checker under the paint, so a translucent one reads as translucent. */\n background-color: var(--wzl-surface-raised);\n box-shadow: inset 0 0 0 1px var(--wzl-border);\n}\n\n/* No paint to show: the checker stands in rather than an invented color. */\n.swatch[data-empty],\n.trigger[data-mixed] .swatch {\n background: repeating-conic-gradient(\n var(--wzl-checker-a) 0% 25%,\n var(--wzl-checker-b) 0% 50%\n )\n 50% / var(--wzl-checker-size) var(--wzl-checker-size);\n}\n\n.label {\n flex: 1 1 auto;\n min-inline-size: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n text-align: start;\n}\n\n.popover {\n outline: none;\n}\n\n.body {\n inline-size: 240px;\n padding: var(--wzl-space-4);\n}\n","import { type ReactElement } from 'react';\nimport {\n Button as RACButton,\n Dialog as RACDialog,\n DialogTrigger,\n Popover as RACPopover,\n} from 'react-aria-components';\nimport { usePaintKind, type FillStyle, type PaintKind } from '@weasel-js/core';\nimport { useOverlayPortal, type OverlayPortalProps } from '../../overlays/portalHost';\nimport { paintPreviewCss } from '../../paintPreview';\nimport { PaintInput } from '../PaintInput';\nimport listbox from '../listbox.module.css';\nimport s from './PaintField.module.css';\n\n/** Props for {@link PaintField}. `onInput` fires throughout a gesture inside\n * the popover and `onChange` once at its end. */\nexport interface PaintFieldProps extends OverlayPortalProps {\n /** The paint being edited. `null` is an explicit \"no paint\"; `undefined` is\n * no value to show. */\n value: FillStyle | null | undefined;\n /** Indeterminate presentation: the trigger says \"Mixed\" and the editor\n * lights no kind. */\n mixed?: boolean;\n /** Dim the trigger — a value is in effect but was never chosen. */\n unset?: boolean;\n /** Restrict the editor's kind bar. Default: every registered kind. */\n kinds?: readonly PaintKind[];\n /** Offer \"None\" in the editor. Default `true`. */\n allowNone?: boolean;\n onInput?: (next: FillStyle | null) => void;\n onChange: (next: FillStyle | null) => void;\n /** Names the paint this field edits — `Fill`, `Color`. */\n 'aria-label'?: string;\n className?: string;\n}\n\n/** What the trigger says it is holding. */\nfunction kindLabel(paint: FillStyle | null | undefined, mixed: boolean, label: string | undefined): string {\n if (mixed) return 'Mixed';\n if (paint === null) return 'None';\n if (paint === undefined) return '—';\n return label ?? (paint.fill ?? 'solid');\n}\n\n/**\n * A whole `FillStyle` in one control slot: a swatch that says which kind it\n * holds, and a popover holding {@link PaintInput}.\n *\n * `PaintInput` itself is a kind bar over a body — six segments and a stop\n * editor — which a property row's control column cannot hold. This is the\n * shape for a narrow slot, and the difference that matters is fidelity: a\n * `ColorField` in that slot reads a gradient's first stop and writes a solid\n * back, so touching the control loses the paint.\n */\nexport function PaintField(props: PaintFieldProps): ReactElement {\n const {\n value, mixed = false, unset = false, kinds, allowNone = true,\n onInput, onChange, className, portalContainer,\n } = props;\n const ariaLabel = props['aria-label'];\n const { anchor, portalProps, ready } = useOverlayPortal(portalContainer);\n const preview = mixed ? undefined : paintPreviewCss(value);\n const label = usePaintKind(value?.fill)?.label;\n\n return (\n <DialogTrigger>\n {anchor}\n <RACButton\n className={[s.trigger, className].filter(Boolean).join(' ')}\n aria-label={ariaLabel}\n {...(unset ? { 'data-unset': '' } : {})}\n {...(mixed ? { 'data-mixed': '' } : {})}\n >\n <span\n className={s.swatch}\n aria-hidden=\"true\"\n {...(preview ? { style: { background: preview } } : { 'data-empty': '' })}\n />\n <span className={s.label}>{kindLabel(value, mixed, label)}</span>\n </RACButton>\n {/* `data-weasel-overlay`: see Select — the popover renders in a portal,\n outside the subtree the trigger sits in. */}\n {ready && (\n <RACPopover className={s.popover} data-weasel-overlay=\"\" {...portalProps}>\n <RACDialog className={`${listbox.surface} ${s.body}`} aria-label={ariaLabel ? `${ariaLabel} editor` : 'Paint editor'}>\n <PaintInput\n value={value}\n mixed={mixed}\n unset={unset}\n kinds={kinds}\n allowNone={allowNone}\n onInput={onInput}\n onChange={onChange}\n aria-label={ariaLabel}\n />\n </RACDialog>\n </RACPopover>\n )}\n </DialogTrigger>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;ACqCA,SAASS,EAAU,GAAqC,GAAgB,GAAmC;CAIzG,OAHIC,IAAc,UACdC,MAAU,OAAa,SACvBA,MAAU,KAAA,IAAkB,MACzBC,KAAUD,EAAM,QAAQ;AACjC;AAYA,SAAgBE,EAAW,GAAsC;CAC/D,IAAM,EACJ,UAAO,WAAQ,IAAO,WAAQ,IAAO,UAAO,eAAY,IACxD,YAAS,aAAU,cAAW,uBAC5BC,GACEC,IAAYD,EAAM,eAClB,EAAE,WAAQ,gBAAa,aAAUT,EAAiBW,CAAe,GACjEC,IAAUP,IAAQ,KAAA,IAAYJ,EAAgBY,CAAK,GACnDN,IAAQO,EAAaD,GAAO,IAAI,CAAC,EAAE;CAEzC,OACE,kBAACE,GAAD,EAAA,UAAA;EACGC;EACD,kBAACrB,GAAD;GACE,WAAW,CAACC,EAAE,SAASsB,CAAS,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;GAC1D,cAAYR;GACZ,GAAKS,IAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;GACrC,GAAKd,IAAQ,EAAE,cAAc,GAAG,IAAI,CAAC;GAJvC,UAAA,CAME,kBAAC,QAAD;IACE,WAAWT,EAAE;IACb,eAAY;IACZ,GAAKgB,IAAU,EAAE,OAAO,EAAE,YAAYA,EAAQ,EAAE,IAAI,EAAE,cAAc,GAAG;GACxE,CAAA,GACD,kBAAC,QAAD;IAAM,WAAWhB,EAAE;IAAQ,UAAAQ,EAAUS,GAAOR,GAAOE,CAAK;GAAQ,CAAA,CACvD;;EAGVa,KACC,kBAACvB,GAAD;GAAY,WAAWD,EAAE;GAAS,uBAAoB;GAAG,GAAI0B;GAC3D,UAAA,kBAACxB,GAAD;IAAW,WAAW,GAAGC,EAAQ,QAAQ,GAAGH,EAAE;IAAQ,cAAYc,IAAY,GAAGA,EAAU,WAAW;IACpG,UAAA,kBAACR,GAAD;KACS;KACA;KACA;KACA;KACI;KACF;KACC;KACV,cAAYQ;IACb,CAAA;GACQ,CAAA;EACD,CAAA;CAED,EAAA,CAAA;AAEnB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as e, t } from "./Icon
|
|
1
|
+
import { a as e, t } from "./Icon-BfqYtAX5.js";
|
|
2
2
|
import { n, t as r } from "./ColorField-BwlelY26.js";
|
|
3
|
-
import { t as i } from "./ToggleBar-
|
|
4
|
-
import { r as a } from "./GradientEditor-
|
|
5
|
-
import { t as o } from "./PatternPicker-
|
|
3
|
+
import { t as i } from "./ToggleBar-CfYbMK3x.js";
|
|
4
|
+
import { r as a } from "./GradientEditor-DX4sb1Hf.js";
|
|
5
|
+
import { t as o } from "./PatternPicker-82DCUvUk.js";
|
|
6
6
|
import { getAlpha01 as s, getPaintKind as c, paintAlpha as l, paintWithAlpha as u, solid as d, switchGradientKind as f, toHex8 as p, usePaintKind as m, usePaintKinds as h, withAlpha01 as g } from "@weasel-js/core";
|
|
7
7
|
import { Fragment as _, jsx as v, jsxs as y } from "react/jsx-runtime";
|
|
8
8
|
import { useCallback as b, useRef as x } from "react";
|
|
@@ -129,4 +129,4 @@ function k(s) {
|
|
|
129
129
|
//#endregion
|
|
130
130
|
export { k as t };
|
|
131
131
|
|
|
132
|
-
//# sourceMappingURL=PaintInput-
|
|
132
|
+
//# sourceMappingURL=PaintInput-DSS5IjXn.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PaintInput-DaQMeBsI.js","names":["s","_Fragment","ICON_PATHS","ColorField","ToggleBar","GradientEditor","PatternPicker","PaintInput_module_default","FALLBACK_COLOR","NONE","solidHex8","hex8","toHex8","paint","withAlpha01","getAlpha01","paintAlpha","solidFromField","solid","color","isPattern","kindOf","PaintInput","props","ariaLabel","remembered","useRef","active","mixed","value","valueKind","usePaintKind","entries","usePaintKinds","kinds","entry","segment","icon","id","Icon","label","items","allowNone","currentColor","useCallback","switchKind","kind","seen","converted","switchGradientKind","getPaintKind","onChange","unset","className","renderBody","withOpacity","Fragment","body","OpacityRange","onInput","paintWithAlpha","a01","Editor"],"sources":["../../src/components/PaintInput/PaintInput.module.css","../../src/components/PaintInput/PaintInput.tsx"],"sourcesContent":["/* Kind switch stacked over whichever paint body it selects. */\n.root {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n min-inline-size: 0;\n}\n\n/* A value is in effect but nobody chose it. Never louder than mixed. */\n.unset {\n opacity: 0.55;\n}\n\n/* A kind with no editor: named, not editable. */\n.noEditor {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-muted);\n}\n\n/* The opacity slider under a paint with no single color, laid out as the\n * solid's sits beside its swatch. */\n.opacity {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-3);\n}\n","import { useCallback, useRef, type ReactElement } from 'react';\nimport {\n getAlpha01,\n getPaintKind,\n paintAlpha,\n paintWithAlpha,\n solid,\n switchGradientKind,\n toHex8,\n usePaintKind,\n usePaintKinds,\n withAlpha01,\n type FillStyle,\n type PaintKind,\n} from '@weasel-js/core';\nimport { Icon } from '../../icons/Icon';\nimport { ICON_PATHS, type IconName } from '../../icons/paths';\nimport { ColorField } from '../ColorField';\nimport { OpacityRange } from '../ColorField/OpacityRange';\nimport { GradientEditor } from '../GradientEditor';\nimport { PatternPicker, type PatternFill } from '../PatternPicker';\nimport { ToggleBar, type ToggleBarItem } from '../ToggleBar';\nimport s from './PaintInput.module.css';\n\n/** What a kind with no color of its own seeds from. */\nconst FALLBACK_COLOR = '#000000ff';\n\n/** The bar's answer for \"no paint at all\". Not a registered kind — absence\n * has no seed, no color and nothing to render — so it is this control's own\n * segment rather than a registry entry. */\nconst NONE = 'none';\n\n/** A solid paint as the one `#rrggbbaa` a color field edits. Its alpha lives\n * in `opacity`; a hex alpha left in `color` multiplies with it when painted,\n * so both fold in. */\nfunction solidHex8(paint: FillStyle): string {\n const hex8 = toHex8((paint as { color: string }).color);\n return withAlpha01(hex8.slice(0, 7), getAlpha01(hex8) * paintAlpha(paint));\n}\n\n/** `solid(color)` at the slider's own 1% resolution: the alpha arrives\n * through a hex channel, which would turn 70% into 0.70196. */\nfunction solidFromField(color: string): FillStyle {\n const paint = solid(color);\n return paint.opacity === undefined\n ? paint\n : { ...paint, opacity: Math.round(paint.opacity * 100) / 100 };\n}\n\nfunction isPattern(paint: FillStyle | undefined): paint is PatternFill {\n return paint?.fill === 'pattern';\n}\n\n/** A paint's own discriminant. The solid member leaves `fill` off, and an\n * explicit `null` is the absence of paint rather than an unknown one. */\nfunction kindOf(paint: FillStyle | null | undefined): PaintKind | null {\n if (paint === null) return NONE;\n if (paint === undefined) return null;\n return paint.fill ?? 'solid';\n}\n\n/** Props for {@link PaintInput}. `onInput` fires throughout a gesture and\n * `onChange` once at its end. */\nexport interface PaintInputProps {\n /** The paint being edited. `null` is an explicit \"no paint\"; `undefined`\n * is no value to show. */\n value: FillStyle | null | undefined;\n /** Indeterminate presentation: no kind lit, and the body withheld because\n * there is no single paint to show. */\n mixed?: boolean;\n /** Dim the control — a value is in effect but was never chosen. */\n unset?: boolean;\n /** Restrict the kind bar. Default: every registered kind. */\n kinds?: readonly PaintKind[];\n /** Offer \"None\". Default `true` — the bar answers \"what kind of paint is\n * this?\" and no-paint is one of the answers. Turn it off where the slot\n * cannot express absence. */\n allowNone?: boolean;\n onInput?: (next: FillStyle | null) => void;\n onChange: (next: FillStyle | null) => void;\n /** Names the paint this control edits — `Fill`, `Color`. Carried by the\n * solid body's swatch, which is the part with a value to announce. */\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Editor for a whole `FillStyle` — a kind bar over whichever body that kind\n * wants.\n *\n * The bar is driven by the paint-kind registry rather than a fixed list, so a\n * consumer's registered kind appears in it and renders that entry's `Editor`.\n * The five built-in kinds keep their branch here: their editors live in this\n * package and `@weasel-js/core`, which owns the registry, cannot import it.\n *\n * Geometry is deliberately absent — on a canvas it belongs on the artwork,\n * via `<SceneGradientHandles>`.\n */\nexport function PaintInput(props: PaintInputProps): ReactElement {\n const {\n value, mixed = false, unset = false, kinds, allowNone = true,\n onInput, onChange, className,\n } = props;\n const ariaLabel = props['aria-label'];\n\n // Per-kind memory, so linear → solid → linear comes back with its stops.\n // A ref, not state: it must not survive the control being pointed at a\n // different selection, and nothing renders off it directly.\n const remembered = useRef(new Map<PaintKind, FillStyle>());\n\n const active = mixed ? null : kindOf(value);\n if (value != null && active !== null) remembered.current.set(active, value);\n\n const valueKind = usePaintKind(value?.fill);\n const entries = usePaintKinds().filter(\n (entry) => kinds === undefined || kinds.includes(entry.id),\n );\n const segment = (id: string, label: string, icon: string | undefined): ToggleBarItem<PaintKind> =>\n icon && icon in ICON_PATHS\n // Icon-only: six labelled segments do not fit a property row, and the\n // full label stays the accessible name.\n // 14 to match the panel's other glyph segments. A `sm` bar is 17px tall\n // over 1px of padding, so 15 fills the segment box edge to edge.\n ? { value: id, label: <Icon name={icon as IconName} size={14} />, ariaLabel: label }\n : { value: id, label };\n\n const items: readonly ToggleBarItem<PaintKind>[] = [\n ...(allowNone ? [segment(NONE, 'None', 'paintNone')] : []),\n ...entries.map((entry) => segment(entry.id, entry.label, entry.icon)),\n ];\n\n /** The color a switch seeds from: whatever the current paint shows. */\n const currentColor = useCallback((): string => {\n if (value == null) return FALLBACK_COLOR;\n return valueKind?.colorOf(value) ?? FALLBACK_COLOR;\n }, [value, valueKind]);\n\n const switchKind = (kind: PaintKind): void => {\n if (kind === active) return;\n if (kind === NONE) {\n onChange(null);\n return;\n }\n const seen = remembered.current.get(kind);\n if (seen !== undefined) {\n onChange(seen);\n return;\n }\n const converted = value != null ? switchGradientKind(value, kind) : undefined;\n if (converted !== undefined) {\n onChange(converted);\n return;\n }\n const entry = getPaintKind(kind);\n if (entry) onChange(entry.seed(currentColor()));\n };\n\n return (\n <div\n className={[s.root, unset && s.unset, className].filter(Boolean).join(' ')}\n title={unset ? 'Not set' : undefined}\n >\n <ToggleBar<PaintKind>\n items={items}\n value={active}\n size=\"sm\"\n ariaLabel=\"Paint kind\"\n onChange={(kind) => kind && switchKind(kind)}\n />\n {renderBody()}\n </div>\n );\n\n /** A solid's alpha rides its swatch; every other kind has no one color to\n * carry it, so its `opacity` gets the same slider under the body. */\n function withOpacity(paint: FillStyle, body: ReactElement): ReactElement {\n return (\n <>\n {body}\n <div className={s.opacity}>\n <OpacityRange\n value={paintAlpha(paint)}\n aria-label={ariaLabel}\n onInput={(a01) => onInput?.(paintWithAlpha(paint, a01))}\n onChange={(a01) => onChange(paintWithAlpha(paint, a01))}\n />\n </div>\n </>\n );\n }\n\n function renderBody(): ReactElement | null {\n if (mixed || value === undefined) {\n return (\n <ColorField\n mixed\n aria-label={ariaLabel}\n onChange={(color) => onChange(solidFromField(color))}\n />\n );\n }\n // Absence has nothing to edit. The lit segment is the whole statement.\n if (value === null) return null;\n // A registered `Editor` wins even for a built-in id: re-registering one is\n // how a consumer replaces a kit control, and the built-in branches below\n // are the fallback for the ids that ship without an entry editor.\n if (valueKind?.Editor) {\n const Editor = valueKind.Editor;\n return withOpacity(value, <Editor value={value} onInput={onInput} onChange={onChange} />);\n }\n if (valueKind?.stopsOf) {\n return withOpacity(value, (\n <GradientEditor\n value={value}\n kindSwitch={false}\n onInput={onInput}\n onChange={onChange}\n />\n ));\n }\n if (isPattern(value)) {\n return withOpacity(\n value,\n <PatternPicker value={value} color={currentColor()} onChange={onChange} />,\n );\n }\n const kind = kindOf(value);\n if (kind !== 'solid') {\n // Editing a paint this control cannot represent would overwrite it, so\n // a kind with no editor is shown and left alone.\n return <div className={s.noEditor}>{valueKind?.label ?? kind}: no editor</div>;\n }\n return (\n <ColorField\n value={solidHex8(value)}\n alpha\n aria-label={ariaLabel}\n onInput={(color) => onInput?.(solidFromField(color))}\n onChange={(color) => onChange(solidFromField(color))}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;GCyBMQ,IAAiB,aAKjBC,IAAO;AAKb,SAASC,EAAU,GAA0B;CAC3C,IAAMC,IAAOC,EAAQC,EAA4B,KAAK;CACtD,OAAOC,EAAYH,EAAK,MAAM,GAAG,CAAC,GAAGI,EAAWJ,CAAI,IAAIK,EAAWH,CAAK,CAAC;AAC3E;AAIA,SAASI,EAAe,GAA0B;CAChD,IAAMJ,IAAQK,EAAMC,CAAK;CACzB,OAAON,EAAM,YAAY,KAAA,IACrBA,IACA;EAAE,GAAGA;EAAO,SAAS,KAAK,MAAMA,EAAM,UAAU,GAAG,IAAI;CAAI;AACjE;AAEA,SAASO,EAAU,GAAoD;CACrE,OAAOP,GAAO,SAAS;AACzB;AAIA,SAASQ,EAAO,GAAuD;CAGrE,OAFIR,MAAU,OAAaJ,IACvBI,MAAU,KAAA,IAAkB,OACzBA,EAAM,QAAQ;AACvB;AAuCA,SAAgBS,EAAW,GAAsC;CAC/D,IAAM,EACJ,UAAO,WAAQ,IAAO,WAAQ,IAAO,UAAO,eAAY,IACxD,YAAS,aAAU,iBACjBC,GACEC,IAAYD,EAAM,eAKlBE,IAAaC,kBAAO,IAAI,IAA0B,CAAC,GAEnDC,IA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AUmB,CAAK;GACtB,OAAA;GACA,cAAYL;GACZ,UAAU,MAAUmC,IAAU1C,EAAeE,CAAK,CAAC;GACnD,WAAW,MAAUgC,EAASlC,EAAeE,CAAK,CAAC;EACpD,CAAA,IATM,kBAAC,OAAD;GAAK,WAAWnB,EAAE;GAAlB,UAAA,CAA6B8B,GAAW,SAASgB,GAAK,aAAgB;;CAWjF;AACF"}
|
|
1
|
+
{"version":3,"file":"PaintInput-DSS5IjXn.js","names":["s","_Fragment","ICON_PATHS","ColorField","ToggleBar","GradientEditor","PatternPicker","PaintInput_module_default","FALLBACK_COLOR","NONE","solidHex8","hex8","toHex8","paint","withAlpha01","getAlpha01","paintAlpha","solidFromField","solid","color","isPattern","kindOf","PaintInput","props","ariaLabel","remembered","useRef","active","mixed","value","valueKind","usePaintKind","entries","usePaintKinds","kinds","entry","segment","icon","id","Icon","label","items","allowNone","currentColor","useCallback","switchKind","kind","seen","converted","switchGradientKind","getPaintKind","onChange","unset","className","renderBody","withOpacity","Fragment","body","OpacityRange","onInput","paintWithAlpha","a01","Editor"],"sources":["../../src/components/PaintInput/PaintInput.module.css","../../src/components/PaintInput/PaintInput.tsx"],"sourcesContent":["/* Kind switch stacked over whichever paint body it selects. */\n.root {\n display: flex;\n flex-direction: column;\n gap: var(--wzl-space-3);\n min-inline-size: 0;\n}\n\n/* A value is in effect but nobody chose it. Never louder than mixed. */\n.unset {\n opacity: 0.55;\n}\n\n/* A kind with no editor: named, not editable. */\n.noEditor {\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg-muted);\n}\n\n/* The opacity slider under a paint with no single color, laid out as the\n * solid's sits beside its swatch. */\n.opacity {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-3);\n}\n","import { useCallback, useRef, type ReactElement } from 'react';\nimport {\n getAlpha01,\n getPaintKind,\n paintAlpha,\n paintWithAlpha,\n solid,\n switchGradientKind,\n toHex8,\n usePaintKind,\n usePaintKinds,\n withAlpha01,\n type FillStyle,\n type PaintKind,\n} from '@weasel-js/core';\nimport { Icon } from '../../icons/Icon';\nimport { ICON_PATHS, type IconName } from '../../icons/paths';\nimport { ColorField } from '../ColorField';\nimport { OpacityRange } from '../ColorField/OpacityRange';\nimport { GradientEditor } from '../GradientEditor';\nimport { PatternPicker, type PatternFill } from '../PatternPicker';\nimport { ToggleBar, type ToggleBarItem } from '../ToggleBar';\nimport s from './PaintInput.module.css';\n\n/** What a kind with no color of its own seeds from. */\nconst FALLBACK_COLOR = '#000000ff';\n\n/** The bar's answer for \"no paint at all\". Not a registered kind — absence\n * has no seed, no color and nothing to render — so it is this control's own\n * segment rather than a registry entry. */\nconst NONE = 'none';\n\n/** A solid paint as the one `#rrggbbaa` a color field edits. Its alpha lives\n * in `opacity`; a hex alpha left in `color` multiplies with it when painted,\n * so both fold in. */\nfunction solidHex8(paint: FillStyle): string {\n const hex8 = toHex8((paint as { color: string }).color);\n return withAlpha01(hex8.slice(0, 7), getAlpha01(hex8) * paintAlpha(paint));\n}\n\n/** `solid(color)` at the slider's own 1% resolution: the alpha arrives\n * through a hex channel, which would turn 70% into 0.70196. */\nfunction solidFromField(color: string): FillStyle {\n const paint = solid(color);\n return paint.opacity === undefined\n ? paint\n : { ...paint, opacity: Math.round(paint.opacity * 100) / 100 };\n}\n\nfunction isPattern(paint: FillStyle | undefined): paint is PatternFill {\n return paint?.fill === 'pattern';\n}\n\n/** A paint's own discriminant. The solid member leaves `fill` off, and an\n * explicit `null` is the absence of paint rather than an unknown one. */\nfunction kindOf(paint: FillStyle | null | undefined): PaintKind | null {\n if (paint === null) return NONE;\n if (paint === undefined) return null;\n return paint.fill ?? 'solid';\n}\n\n/** Props for {@link PaintInput}. `onInput` fires throughout a gesture and\n * `onChange` once at its end. */\nexport interface PaintInputProps {\n /** The paint being edited. `null` is an explicit \"no paint\"; `undefined`\n * is no value to show. */\n value: FillStyle | null | undefined;\n /** Indeterminate presentation: no kind lit, and the body withheld because\n * there is no single paint to show. */\n mixed?: boolean;\n /** Dim the control — a value is in effect but was never chosen. */\n unset?: boolean;\n /** Restrict the kind bar. Default: every registered kind. */\n kinds?: readonly PaintKind[];\n /** Offer \"None\". Default `true` — the bar answers \"what kind of paint is\n * this?\" and no-paint is one of the answers. Turn it off where the slot\n * cannot express absence. */\n allowNone?: boolean;\n onInput?: (next: FillStyle | null) => void;\n onChange: (next: FillStyle | null) => void;\n /** Names the paint this control edits — `Fill`, `Color`. Carried by the\n * solid body's swatch, which is the part with a value to announce. */\n 'aria-label'?: string;\n className?: string;\n}\n\n/**\n * Editor for a whole `FillStyle` — a kind bar over whichever body that kind\n * wants.\n *\n * The bar is driven by the paint-kind registry rather than a fixed list, so a\n * consumer's registered kind appears in it and renders that entry's `Editor`.\n * The five built-in kinds keep their branch here: their editors live in this\n * package and `@weasel-js/core`, which owns the registry, cannot import it.\n *\n * Geometry is deliberately absent — on a canvas it belongs on the artwork,\n * via `<SceneGradientHandles>`.\n */\nexport function PaintInput(props: PaintInputProps): ReactElement {\n const {\n value, mixed = false, unset = false, kinds, allowNone = true,\n onInput, onChange, className,\n } = props;\n const ariaLabel = props['aria-label'];\n\n // Per-kind memory, so linear → solid → linear comes back with its stops.\n // A ref, not state: it must not survive the control being pointed at a\n // different selection, and nothing renders off it directly.\n const remembered = useRef(new Map<PaintKind, FillStyle>());\n\n const active = mixed ? null : kindOf(value);\n if (value != null && active !== null) remembered.current.set(active, value);\n\n const valueKind = usePaintKind(value?.fill);\n const entries = usePaintKinds().filter(\n (entry) => kinds === undefined || kinds.includes(entry.id),\n );\n const segment = (id: string, label: string, icon: string | undefined): ToggleBarItem<PaintKind> =>\n icon && icon in ICON_PATHS\n // Icon-only: six labelled segments do not fit a property row, and the\n // full label stays the accessible name.\n // 14 to match the panel's other glyph segments. A `sm` bar is 17px tall\n // over 1px of padding, so 15 fills the segment box edge to edge.\n ? { value: id, label: <Icon name={icon as IconName} size={14} />, ariaLabel: label }\n : { value: id, label };\n\n const items: readonly ToggleBarItem<PaintKind>[] = [\n ...(allowNone ? [segment(NONE, 'None', 'paintNone')] : []),\n ...entries.map((entry) => segment(entry.id, entry.label, entry.icon)),\n ];\n\n /** The color a switch seeds from: whatever the current paint shows. */\n const currentColor = useCallback((): string => {\n if (value == null) return FALLBACK_COLOR;\n return valueKind?.colorOf(value) ?? FALLBACK_COLOR;\n }, [value, valueKind]);\n\n const switchKind = (kind: PaintKind): void => {\n if (kind === active) return;\n if (kind === NONE) {\n onChange(null);\n return;\n }\n const seen = remembered.current.get(kind);\n if (seen !== undefined) {\n onChange(seen);\n return;\n }\n const converted = value != null ? switchGradientKind(value, kind) : undefined;\n if (converted !== undefined) {\n onChange(converted);\n return;\n }\n const entry = getPaintKind(kind);\n if (entry) onChange(entry.seed(currentColor()));\n };\n\n return (\n <div\n className={[s.root, unset && s.unset, className].filter(Boolean).join(' ')}\n title={unset ? 'Not set' : undefined}\n >\n <ToggleBar<PaintKind>\n items={items}\n value={active}\n size=\"sm\"\n ariaLabel=\"Paint kind\"\n onChange={(kind) => kind && switchKind(kind)}\n />\n {renderBody()}\n </div>\n );\n\n /** A solid's alpha rides its swatch; every other kind has no one color to\n * carry it, so its `opacity` gets the same slider under the body. */\n function withOpacity(paint: FillStyle, body: ReactElement): ReactElement {\n return (\n <>\n {body}\n <div className={s.opacity}>\n <OpacityRange\n value={paintAlpha(paint)}\n aria-label={ariaLabel}\n onInput={(a01) => onInput?.(paintWithAlpha(paint, a01))}\n onChange={(a01) => onChange(paintWithAlpha(paint, a01))}\n />\n </div>\n </>\n );\n }\n\n function renderBody(): ReactElement | null {\n if (mixed || value === undefined) {\n return (\n <ColorField\n mixed\n aria-label={ariaLabel}\n onChange={(color) => onChange(solidFromField(color))}\n />\n );\n }\n // Absence has nothing to edit. The lit segment is the whole statement.\n if (value === null) return null;\n // A registered `Editor` wins even for a built-in id: re-registering one is\n // how a consumer replaces a kit control, and the built-in branches below\n // are the fallback for the ids that ship without an entry editor.\n if (valueKind?.Editor) {\n const Editor = valueKind.Editor;\n return withOpacity(value, <Editor value={value} onInput={onInput} onChange={onChange} />);\n }\n if (valueKind?.stopsOf) {\n return withOpacity(value, (\n <GradientEditor\n value={value}\n kindSwitch={false}\n onInput={onInput}\n onChange={onChange}\n />\n ));\n }\n if (isPattern(value)) {\n return withOpacity(\n value,\n <PatternPicker value={value} color={currentColor()} onChange={onChange} />,\n );\n }\n const kind = kindOf(value);\n if (kind !== 'solid') {\n // Editing a paint this control cannot represent would overwrite it, so\n // a kind with no editor is shown and left alone.\n return <div className={s.noEditor}>{valueKind?.label ?? kind}: no editor</div>;\n }\n return (\n <ColorField\n value={solidHex8(value)}\n alpha\n aria-label={ariaLabel}\n onInput={(color) => onInput?.(solidFromField(color))}\n onChange={(color) => onChange(solidFromField(color))}\n />\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;GCyBMQ,IAAiB,aAKjBC,IAAO;AAKb,SAASC,EAAU,GAA0B;CAC3C,IAAMC,IAAOC,EAAQC,EAA4B,KAAK;CACtD,OAAOC,EAAYH,EAAK,MAAM,GAAG,CAAC,GAAGI,EAAWJ,CAAI,IAAIK,EAAWH,CAAK,CAAC;AAC3E;AAIA,SAASI,EAAe,GAA0B;CAChD,IAAMJ,IAAQK,EAAMC,CAAK;CACzB,OAAON,EAAM,YAAY,KAAA,IACrBA,IACA;EAAE,GAAGA;EAAO,SAAS,KAAK,MAAMA,EAAM,UAAU,GAAG,IAAI;CAAI;AACjE;AAEA,SAASO,EAAU,GAAoD;CACrE,OAAOP,GAAO,SAAS;AACzB;AAIA,SAASQ,EAAO,GAAuD;CAGrE,OAFIR,MAAU,OAAaJ,IACvBI,MAAU,KAAA,IAAkB,OACzBA,EAAM,QAAQ;AACvB;AAuCA,SAAgBS,EAAW,GAAsC;CAC/D,IAAM,EACJ,UAAO,WAAQ,IAAO,WAAQ,IAAO,UAAO,eAAY,IACxD,YAAS,aAAU,iBACjBC,GACEC,IAAYD,EAAM,eAKlBE,IAAaC,kBAAO,IAAI,IAA0B,CAAC,GAEnDC,IAASC,IAAQ,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;GACtB,OAAA;GACA,cAAYL;GACZ,UAAU,MAAUmC,IAAU1C,EAAeE,CAAK,CAAC;GACnD,WAAW,MAAUgC,EAASlC,EAAeE,CAAK,CAAC;EACpD,CAAA,IATM,kBAAC,OAAD;GAAK,WAAWnB,EAAE;GAAlB,UAAA,CAA6B8B,GAAW,SAASgB,GAAK,aAAgB;;CAWjF;AACF"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t } from "./
|
|
1
|
+
import { t as e } from "./ToggleBar-CfYbMK3x.js";
|
|
2
|
+
import { r as t } from "./NumberField-BXFrOi5M.js";
|
|
3
3
|
import { composePatternTransform as n, decomposePatternTransform as r } from "@weasel-js/core";
|
|
4
4
|
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
5
|
import { tilePreviewCssUrl as o } from "@weasel-js/svg";
|
|
6
6
|
var s = {
|
|
7
|
-
root: "
|
|
8
|
-
grid: "
|
|
9
|
-
swatch: "
|
|
10
|
-
swatchActive: "
|
|
7
|
+
root: "_root_1bvfi_2",
|
|
8
|
+
grid: "_grid_1bvfi_9",
|
|
9
|
+
swatch: "_swatch_1bvfi_17",
|
|
10
|
+
swatchActive: "_swatchActive_1bvfi_38"
|
|
11
11
|
}, c = [
|
|
12
12
|
"hatch",
|
|
13
13
|
"crosshatch",
|
|
@@ -110,14 +110,14 @@ function _(n) {
|
|
|
110
110
|
}, e);
|
|
111
111
|
})
|
|
112
112
|
}),
|
|
113
|
-
/* @__PURE__ */ i(
|
|
113
|
+
/* @__PURE__ */ i(e, {
|
|
114
114
|
items: l,
|
|
115
115
|
value: S,
|
|
116
116
|
size: "sm",
|
|
117
117
|
ariaLabel: "Tile size",
|
|
118
118
|
onChange: (e) => e != null && w(e)
|
|
119
119
|
}),
|
|
120
|
-
/* @__PURE__ */ i(
|
|
120
|
+
/* @__PURE__ */ i(t, {
|
|
121
121
|
label: "Rotation",
|
|
122
122
|
orientation: "row",
|
|
123
123
|
width: "fit",
|
|
@@ -132,4 +132,4 @@ function _(n) {
|
|
|
132
132
|
//#endregion
|
|
133
133
|
export { g as n, _ as t };
|
|
134
134
|
|
|
135
|
-
//# sourceMappingURL=PatternPicker-
|
|
135
|
+
//# sourceMappingURL=PatternPicker-82DCUvUk.js.map
|