@weasel-js/ui 1.5.2 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/ActionBar-CYvfmEz0.js +57 -0
- package/dist/chunks/ActionBar-CYvfmEz0.js.map +1 -0
- package/dist/chunks/{Badge-CW9pBPFl.js → Badge-DZ0lFs14.js} +755 -738
- package/dist/chunks/Badge-DZ0lFs14.js.map +1 -0
- package/dist/chunks/{BandEditor-jY-PFKY6.js → BandEditor-D-nVrVO4.js} +34 -34
- package/dist/chunks/{BandEditor-jY-PFKY6.js.map → BandEditor-D-nVrVO4.js.map} +1 -1
- package/dist/chunks/Button-Dyp31jMt.js +111 -0
- package/dist/chunks/Button-Dyp31jMt.js.map +1 -0
- package/dist/chunks/ButtonBar-smZzFuEo.js +46 -0
- package/dist/chunks/ButtonBar-smZzFuEo.js.map +1 -0
- package/dist/chunks/Callout-xLjnx7Mp.js +119 -0
- package/dist/chunks/Callout-xLjnx7Mp.js.map +1 -0
- package/dist/chunks/{Checkbox-BOsDAY2F.js → Checkbox-ChZz30Ds.js} +1 -1
- package/dist/chunks/{Checkbox-BOsDAY2F.js.map → Checkbox-ChZz30Ds.js.map} +1 -1
- package/dist/chunks/Code-v4tDWuuN.js +24 -0
- package/dist/chunks/Code-v4tDWuuN.js.map +1 -0
- package/dist/chunks/{ColorField-BYzgZM9o.js → ColorField-DJSCuSJv.js} +15 -15
- package/dist/chunks/ColorField-DJSCuSJv.js.map +1 -0
- package/dist/chunks/ColorModeControl-JOEiqtE0.js +47 -0
- package/dist/chunks/ColorModeControl-JOEiqtE0.js.map +1 -0
- package/dist/chunks/{ComboBox-Cz3f0Y_8.js → ComboBox-C1JgIpML.js} +2 -2
- package/dist/chunks/{ComboBox-Cz3f0Y_8.js.map → ComboBox-C1JgIpML.js.map} +1 -1
- package/dist/chunks/{CurveEditor-DXwSP-iA.js → CurveEditor-f1R4kSbD.js} +2 -2
- package/dist/chunks/{CurveEditor-DXwSP-iA.js.map → CurveEditor-f1R4kSbD.js.map} +1 -1
- package/dist/chunks/DataGrid-CZPrB_3a.js +152 -0
- package/dist/chunks/DataGrid-CZPrB_3a.js.map +1 -0
- package/dist/chunks/DetailList-DHaXX4TG.js +43 -0
- package/dist/chunks/DetailList-DHaXX4TG.js.map +1 -0
- package/dist/chunks/{DetentSlider-CAubVX0J.js → DetentSlider-BYyaZha6.js} +2 -2
- package/dist/chunks/{DetentSlider-CAubVX0J.js.map → DetentSlider-BYyaZha6.js.map} +1 -1
- package/dist/chunks/Dialog-GIvjoDQj.js +66 -0
- package/dist/chunks/Dialog-GIvjoDQj.js.map +1 -0
- package/dist/chunks/Disclosure-D79jhmh2.js +58 -0
- package/dist/chunks/Disclosure-D79jhmh2.js.map +1 -0
- package/dist/chunks/DragGhost-DcU7cOwy.js +30 -0
- package/dist/chunks/DragGhost-DcU7cOwy.js.map +1 -0
- package/dist/chunks/{DragHandleGlyph-CppAz4_8.js → DragHandleGlyph-BtBxHjZS.js} +1 -1
- package/dist/chunks/{DragHandleGlyph-CppAz4_8.js.map → DragHandleGlyph-BtBxHjZS.js.map} +1 -1
- package/dist/chunks/{Field-DWnV8WZY.js → Field-xbqRmjsI.js} +1 -1
- package/dist/chunks/{Field-DWnV8WZY.js.map → Field-xbqRmjsI.js.map} +1 -1
- package/dist/chunks/FillStrokeSwatch-BViKXIPx.js +111 -0
- package/dist/chunks/FillStrokeSwatch-BViKXIPx.js.map +1 -0
- package/dist/chunks/{FontFamilySelect-DxfgTC3G.js → FontFamilySelect-r9TV_xIH.js} +2 -2
- package/dist/chunks/{FontFamilySelect-DxfgTC3G.js.map → FontFamilySelect-r9TV_xIH.js.map} +1 -1
- package/dist/chunks/GradientEditor-BRTxHG-W.js +333 -0
- package/dist/chunks/{GradientEditor-rRBmf3G0.js.map → GradientEditor-BRTxHG-W.js.map} +1 -1
- package/dist/chunks/{Icon-DT0x6HaQ.js → Icon-BW0qv_U7.js} +28 -20
- package/dist/chunks/Icon-BW0qv_U7.js.map +1 -0
- package/dist/chunks/InlineRange-BwGFDhpT.js +29 -0
- package/dist/chunks/InlineRange-BwGFDhpT.js.map +1 -0
- package/dist/chunks/{Input-DbMKpkXy.js → Input-Bx2cuUbS.js} +24 -19
- package/dist/chunks/Input-Bx2cuUbS.js.map +1 -0
- package/dist/chunks/ItemList-DzJ2lK0R.js +175 -0
- package/dist/chunks/ItemList-DzJ2lK0R.js.map +1 -0
- package/dist/chunks/ItemList.module-DDUXfuZL.js +14 -0
- package/dist/chunks/ItemList.module-DDUXfuZL.js.map +1 -0
- package/dist/chunks/{Jog-DkkTlL3_.js → Jog-LPoac9s4.js} +6 -6
- package/dist/chunks/{Jog-DkkTlL3_.js.map → Jog-LPoac9s4.js.map} +1 -1
- package/dist/chunks/{Keycaps-DunVpejA.js → Keycaps-CKiKOJnJ.js} +71 -65
- package/dist/chunks/Keycaps-CKiKOJnJ.js.map +1 -0
- package/dist/chunks/LayerList-BeGrkLb9.js +427 -0
- package/dist/chunks/LayerList-BeGrkLb9.js.map +1 -0
- package/dist/chunks/ListEditor-C6zLzCsJ.js +74 -0
- package/dist/chunks/ListEditor-C6zLzCsJ.js.map +1 -0
- package/dist/chunks/MenuButton-BcdhrNGh.js +70 -0
- package/dist/chunks/MenuButton-BcdhrNGh.js.map +1 -0
- package/dist/chunks/MeshEditor-BOOIFWnz.js +87 -0
- package/dist/chunks/MeshEditor-BOOIFWnz.js.map +1 -0
- package/dist/chunks/{NumberField-CCjEDZCg.js → NumberField-C1Y7zP-a.js} +27 -22
- package/dist/chunks/NumberField-C1Y7zP-a.js.map +1 -0
- package/dist/chunks/{OptionsBar-DeQ-vUeZ.js → OptionsBar-DlcagPYK.js} +3 -3
- package/dist/chunks/{OptionsBar-DeQ-vUeZ.js.map → OptionsBar-DlcagPYK.js.map} +1 -1
- package/dist/chunks/{PaintField-jBOJ32rL.js → PaintField-B2mLRZa4.js} +20 -20
- package/dist/chunks/PaintField-B2mLRZa4.js.map +1 -0
- package/dist/chunks/{PaintInput-Qs7Rul5R.js → PaintInput-BFKhd83I.js} +24 -24
- package/dist/chunks/{PaintInput-Qs7Rul5R.js.map → PaintInput-BFKhd83I.js.map} +1 -1
- package/dist/chunks/{PatternPicker-BMpXWboq.js → PatternPicker-DdfpxoQy.js} +2 -2
- package/dist/chunks/{PatternPicker-BMpXWboq.js.map → PatternPicker-DdfpxoQy.js.map} +1 -1
- package/dist/chunks/{Plot2D-CXf_f7QD.js → Plot2D-lyO7waPQ.js} +1 -1
- package/dist/chunks/{Plot2D-CXf_f7QD.js.map → Plot2D-lyO7waPQ.js.map} +1 -1
- package/dist/chunks/{PointPlotter-S_gz7VYt.js → PointPlotter-DGs9i5P-.js} +2 -2
- package/dist/chunks/{PointPlotter-S_gz7VYt.js.map → PointPlotter-DGs9i5P-.js.map} +1 -1
- package/dist/chunks/{Powerline-Ak5AWUlK.js → Powerline-DBEPceLE.js} +4 -2
- package/dist/chunks/Powerline-DBEPceLE.js.map +1 -0
- package/dist/chunks/Prefs-Ctu0H4-b.js +475 -0
- package/dist/chunks/Prefs-Ctu0H4-b.js.map +1 -0
- package/dist/chunks/Properties-Bbneh1ws.js +281 -0
- package/dist/chunks/Properties-Bbneh1ws.js.map +1 -0
- package/dist/chunks/PropertyField-CDb19d3F.js +756 -0
- package/dist/chunks/PropertyField-CDb19d3F.js.map +1 -0
- package/dist/chunks/{RadioGroup-CsVp3SEu.js → RadioGroup-BK2mD6Q0.js} +2 -2
- package/dist/chunks/{RadioGroup-CsVp3SEu.js.map → RadioGroup-BK2mD6Q0.js.map} +1 -1
- package/dist/chunks/{RangeSlider-DNr-pJpZ.js → RangeSlider-BiRAOsTh.js} +1 -1
- package/dist/chunks/{RangeSlider-DNr-pJpZ.js.map → RangeSlider-BiRAOsTh.js.map} +1 -1
- package/dist/chunks/{ResizeHandle-RXFf5fXr.js → ResizeHandle-Cc6EOehs.js} +9 -9
- package/dist/chunks/{ResizeHandle-RXFf5fXr.js.map → ResizeHandle-Cc6EOehs.js.map} +1 -1
- package/dist/chunks/Select-DVValBe1.js +225 -0
- package/dist/chunks/Select-DVValBe1.js.map +1 -0
- package/dist/chunks/{SelectionPanel-CEbLS-0D.js → SelectionPanel-C5LmZA7b.js} +21 -20
- package/dist/chunks/{SelectionPanel-CEbLS-0D.js.map → SelectionPanel-C5LmZA7b.js.map} +1 -1
- package/dist/chunks/{Sidebar-qn_oSCNX.js → Sidebar-DKKd4R-x.js} +1 -1
- package/dist/chunks/{Sidebar-qn_oSCNX.js.map → Sidebar-DKKd4R-x.js.map} +1 -1
- package/dist/chunks/{SidebarPanel-Bs6V21hg.js → SidebarPanel-u5NsuAZY.js} +15 -19
- package/dist/chunks/SidebarPanel-u5NsuAZY.js.map +1 -0
- package/dist/chunks/{Slider-CIIrqiFS.js → Slider-BwRrWHFW.js} +42 -42
- package/dist/chunks/{Slider-CIIrqiFS.js.map → Slider-BwRrWHFW.js.map} +1 -1
- package/dist/chunks/{StatusBar-B4L15DSm.js → StatusBar-CdPdmmda.js} +1 -1
- package/dist/chunks/{StatusBar-B4L15DSm.js.map → StatusBar-CdPdmmda.js.map} +1 -1
- package/dist/chunks/SwatchGrid-C-Zx2Exd.js +73 -0
- package/dist/chunks/SwatchGrid-C-Zx2Exd.js.map +1 -0
- package/dist/chunks/{Switch-DH5POG0T.js → Switch-DxF7TsEu.js} +1 -1
- package/dist/chunks/{Switch-DH5POG0T.js.map → Switch-DxF7TsEu.js.map} +1 -1
- package/dist/chunks/{Tabs-BFHikpml.js → Tabs-GXEfoe3o.js} +1 -1
- package/dist/chunks/{Tabs-BFHikpml.js.map → Tabs-GXEfoe3o.js.map} +1 -1
- package/dist/chunks/{Timeline-DNKY_yiK.js → Timeline-SgmpQtUV.js} +128 -132
- package/dist/chunks/Timeline-SgmpQtUV.js.map +1 -0
- package/dist/chunks/{Toast-CI1UDuK6.js → Toast-BfcljZz6.js} +1 -1
- package/dist/chunks/{Toast-CI1UDuK6.js.map → Toast-BfcljZz6.js.map} +1 -1
- package/dist/chunks/ToggleBar-Btnl5r7F.js +80 -0
- package/dist/chunks/{ToggleBar-CClus5Cd.js.map → ToggleBar-Btnl5r7F.js.map} +1 -1
- package/dist/chunks/{TokenPanel-BPHq24dc.js → TokenPanel-5ajHEHha.js} +40 -40
- package/dist/chunks/{TokenPanel-BPHq24dc.js.map → TokenPanel-5ajHEHha.js.map} +1 -1
- package/dist/chunks/{ToolButton-9QzJCmuM.js → ToolButton-rzqlFlAc.js} +4 -4
- package/dist/chunks/{ToolButton-9QzJCmuM.js.map → ToolButton-rzqlFlAc.js.map} +1 -1
- package/dist/chunks/{ToolGroup-BJiDrH_i.js → ToolGroup-4bUBV5k6.js} +1 -1
- package/dist/chunks/{ToolGroup-BJiDrH_i.js.map → ToolGroup-4bUBV5k6.js.map} +1 -1
- package/dist/chunks/{ToolOptionsBar-CAM6RcUH.js → ToolOptionsBar-BF3TNXA3.js} +2 -2
- package/dist/chunks/{ToolOptionsBar-CAM6RcUH.js.map → ToolOptionsBar-BF3TNXA3.js.map} +1 -1
- package/dist/chunks/ToolPalette-Uw4PvWwa.js +83 -0
- package/dist/chunks/ToolPalette-Uw4PvWwa.js.map +1 -0
- package/dist/chunks/{Tooltip-C4YBczLq.js → Tooltip-9XiJF937.js} +13 -13
- package/dist/chunks/Tooltip-9XiJF937.js.map +1 -0
- package/dist/chunks/Tree-BGt6P8tI.js +203 -0
- package/dist/chunks/Tree-BGt6P8tI.js.map +1 -0
- package/dist/chunks/{createKeyframeLayer-DKtO0Sw_.js → createKeyframeLayer-BzDRCrrh.js} +71 -71
- package/dist/chunks/{createKeyframeLayer-DKtO0Sw_.js.map → createKeyframeLayer-BzDRCrrh.js.map} +1 -1
- package/dist/chunks/formatShortcut-BoGqUoWi.js +15 -0
- package/dist/chunks/formatShortcut-BoGqUoWi.js.map +1 -0
- package/dist/chunks/icons-DbScMMqX.js +179 -0
- package/dist/chunks/icons-DbScMMqX.js.map +1 -0
- package/dist/chunks/interactiveTarget-C7QUBaJN.js +24 -0
- package/dist/chunks/interactiveTarget-C7QUBaJN.js.map +1 -0
- package/dist/chunks/{keyGlyph-Bp0wnLHn.js → keyGlyph-CLvUHU8c.js} +1 -1
- package/dist/chunks/{keyGlyph-Bp0wnLHn.js.map → keyGlyph-CLvUHU8c.js.map} +1 -1
- package/dist/chunks/model-BQMvTLnW.js +360 -0
- package/dist/chunks/model-BQMvTLnW.js.map +1 -0
- package/dist/chunks/{number-BHz66zQO.js → number-6S8IzXVt.js} +3 -3
- package/dist/chunks/number-6S8IzXVt.js.map +1 -0
- package/dist/chunks/paintPreview-DPtZS4yU.js +42 -0
- package/dist/chunks/paintPreview-DPtZS4yU.js.map +1 -0
- package/dist/chunks/paintValue-Bz6AVuh3.js +18 -0
- package/dist/chunks/paintValue-Bz6AVuh3.js.map +1 -0
- package/dist/chunks/prefField-CLkhrvYl.js +197 -0
- package/dist/chunks/prefField-CLkhrvYl.js.map +1 -0
- package/dist/chunks/segmentTooltip-CAkZlW-t.js +29 -0
- package/dist/chunks/segmentTooltip-CAkZlW-t.js.map +1 -0
- package/dist/chunks/segmentedControl.module-D2nw68Yo.js +11 -0
- package/dist/chunks/segmentedControl.module-D2nw68Yo.js.map +1 -0
- package/dist/chunks/{snap-CEjuWOhN.js → snap-DC4Km8xG.js} +1 -1
- package/dist/chunks/{snap-CEjuWOhN.js.map → snap-DC4Km8xG.js.map} +1 -1
- package/dist/chunks/stance-CarrcbbP.js +17 -0
- package/dist/chunks/stance-CarrcbbP.js.map +1 -0
- package/dist/chunks/useReorderDragList-Dcezzgix.js +131 -0
- package/dist/chunks/useReorderDragList-Dcezzgix.js.map +1 -0
- package/dist/chunks/{useRovingTabIndex-Dkpf_KhN.js → useRovingTabIndex-B4uJqiKP.js} +1 -1
- package/dist/chunks/useRovingTabIndex-B4uJqiKP.js.map +1 -0
- package/dist/color/ramp.d.ts +38 -0
- package/dist/color/ramp.d.ts.map +1 -0
- package/dist/components/ActionBar/ActionBar.d.ts +6 -4
- package/dist/components/ActionBar/ActionBar.d.ts.map +1 -1
- package/dist/components/ActionBar/index.js +1 -1
- package/dist/components/Badge/Badge.d.ts +21 -7
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Badge/effects/Aqua.d.ts +1 -1
- package/dist/components/Badge/effects/Aqua.d.ts.map +1 -1
- package/dist/components/Badge/index.d.ts +1 -1
- package/dist/components/Badge/index.d.ts.map +1 -1
- package/dist/components/Badge/index.js +1 -1
- package/dist/components/Badge/types.d.ts +6 -5
- package/dist/components/Badge/types.d.ts.map +1 -1
- package/dist/components/BandEditor/index.js +1 -1
- package/dist/components/Button/Button.d.ts +17 -3
- package/dist/components/Button/Button.d.ts.map +1 -1
- package/dist/components/Button/index.d.ts +1 -1
- package/dist/components/Button/index.d.ts.map +1 -1
- package/dist/components/Button/index.js +1 -1
- package/dist/components/ButtonBar/ButtonBar.d.ts +36 -0
- package/dist/components/ButtonBar/ButtonBar.d.ts.map +1 -0
- package/dist/components/ButtonBar/index.d.ts +3 -0
- package/dist/components/ButtonBar/index.d.ts.map +1 -0
- package/dist/components/ButtonBar/index.js +2 -0
- package/dist/components/Callout/Callout.d.ts +2 -5
- package/dist/components/Callout/Callout.d.ts.map +1 -1
- package/dist/components/Callout/index.d.ts +1 -1
- package/dist/components/Callout/index.d.ts.map +1 -1
- package/dist/components/Callout/index.js +1 -1
- package/dist/components/Checkbox/index.js +1 -1
- package/dist/components/Code/Code.d.ts +28 -0
- package/dist/components/Code/Code.d.ts.map +1 -0
- package/dist/components/Code/index.d.ts +3 -0
- package/dist/components/Code/index.d.ts.map +1 -0
- package/dist/components/Code/index.js +2 -0
- package/dist/components/ColorField/index.js +1 -1
- package/dist/components/ColorModeControl/ColorModeControl.d.ts +21 -0
- package/dist/components/ColorModeControl/ColorModeControl.d.ts.map +1 -0
- package/dist/components/ColorModeControl/index.d.ts +3 -0
- package/dist/components/ColorModeControl/index.d.ts.map +1 -0
- package/dist/components/ColorModeControl/index.js +2 -0
- package/dist/components/ComboBox/index.js +1 -1
- package/dist/components/CurveEditor/index.js +3 -3
- package/dist/components/DataGrid/DataGrid.d.ts +22 -0
- package/dist/components/DataGrid/DataGrid.d.ts.map +1 -1
- package/dist/components/DataGrid/index.js +1 -1
- package/dist/components/DetailList/DetailList.d.ts +36 -0
- package/dist/components/DetailList/DetailList.d.ts.map +1 -0
- package/dist/components/DetailList/index.d.ts +3 -0
- package/dist/components/DetailList/index.d.ts.map +1 -0
- package/dist/components/DetailList/index.js +2 -0
- package/dist/components/DetentSlider/index.js +1 -1
- package/dist/components/Dialog/Dialog.d.ts +8 -2
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Dialog/index.js +1 -1
- package/dist/components/Disclosure/Disclosure.d.ts +25 -17
- package/dist/components/Disclosure/Disclosure.d.ts.map +1 -1
- package/dist/components/Disclosure/index.d.ts +2 -2
- package/dist/components/Disclosure/index.d.ts.map +1 -1
- package/dist/components/Disclosure/index.js +2 -2
- package/dist/components/DragGhost/DragGhost.d.ts +21 -0
- package/dist/components/DragGhost/DragGhost.d.ts.map +1 -0
- package/dist/components/DragGhost/index.d.ts +3 -0
- package/dist/components/DragGhost/index.d.ts.map +1 -0
- package/dist/components/DragGhost/index.js +2 -0
- package/dist/components/DragHandleGlyph/index.js +1 -1
- package/dist/components/Field/index.js +1 -1
- package/dist/components/FillStrokeSwatch/FillStrokeSwatch.d.ts +45 -0
- package/dist/components/FillStrokeSwatch/FillStrokeSwatch.d.ts.map +1 -0
- package/dist/components/FillStrokeSwatch/index.d.ts +3 -0
- package/dist/components/FillStrokeSwatch/index.d.ts.map +1 -0
- package/dist/components/FillStrokeSwatch/index.js +2 -0
- package/dist/components/FontFamilySelect/index.js +1 -1
- package/dist/components/GradientEditor/SceneGradientHandles.d.ts.map +1 -1
- package/dist/components/GradientEditor/index.js +1 -1
- package/dist/components/InlineRange/InlineRange.d.ts +6 -2
- package/dist/components/InlineRange/InlineRange.d.ts.map +1 -1
- package/dist/components/InlineRange/index.js +1 -1
- package/dist/components/Input/Input.d.ts +13 -0
- package/dist/components/Input/Input.d.ts.map +1 -1
- package/dist/components/Input/index.js +1 -1
- package/dist/components/ItemList/ItemList.d.ts +70 -10
- package/dist/components/ItemList/ItemList.d.ts.map +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 +3 -3
- package/dist/components/Keycaps/keySpecsFromMods.d.ts +2 -0
- package/dist/components/Keycaps/keySpecsFromMods.d.ts.map +1 -1
- package/dist/components/Keycaps/keySpecsFromShortcut.d.ts +16 -0
- package/dist/components/Keycaps/keySpecsFromShortcut.d.ts.map +1 -0
- package/dist/components/LayerList/LayerList.d.ts +79 -0
- package/dist/components/LayerList/LayerList.d.ts.map +1 -0
- package/dist/components/LayerList/index.d.ts +3 -0
- package/dist/components/LayerList/index.d.ts.map +1 -0
- package/dist/components/LayerList/index.js +2 -0
- package/dist/components/LayerList/useSceneLayerList.d.ts +20 -0
- package/dist/components/LayerList/useSceneLayerList.d.ts.map +1 -0
- package/dist/components/ListEditor/ListEditor.d.ts +23 -0
- package/dist/components/ListEditor/ListEditor.d.ts.map +1 -0
- package/dist/components/ListEditor/index.d.ts +3 -0
- package/dist/components/ListEditor/index.d.ts.map +1 -0
- package/dist/components/ListEditor/index.js +2 -0
- package/dist/components/MenuButton/MenuButton.d.ts +6 -2
- 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/NumberField.d.ts +13 -0
- package/dist/components/NumberField/NumberField.d.ts.map +1 -1
- package/dist/components/NumberField/index.js +1 -1
- package/dist/components/OptionsBar/index.js +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/Plot2D/index.js +1 -1
- package/dist/components/PointPlotter/index.js +1 -1
- package/dist/components/Powerline/Powerline.d.ts +4 -3
- package/dist/components/Powerline/Powerline.d.ts.map +1 -1
- package/dist/components/Powerline/index.js +2 -2
- package/dist/components/Prefs/PrefsDialog.d.ts +10 -2
- package/dist/components/Prefs/PrefsDialog.d.ts.map +1 -1
- package/dist/components/Prefs/PrefsForm.d.ts +26 -25
- package/dist/components/Prefs/PrefsForm.d.ts.map +1 -1
- package/dist/components/Prefs/PrefsPane.d.ts +24 -0
- package/dist/components/Prefs/PrefsPane.d.ts.map +1 -0
- package/dist/components/Prefs/PrefsRail.d.ts +32 -0
- package/dist/components/Prefs/PrefsRail.d.ts.map +1 -0
- package/dist/components/Prefs/PrefsRow.d.ts +32 -0
- package/dist/components/Prefs/PrefsRow.d.ts.map +1 -0
- package/dist/components/Prefs/index.d.ts +5 -2
- package/dist/components/Prefs/index.d.ts.map +1 -1
- package/dist/components/Prefs/index.js +3 -3
- package/dist/components/Prefs/prefField.d.ts +36 -0
- package/dist/components/Prefs/prefField.d.ts.map +1 -0
- package/dist/components/Prefs/schema.d.ts +30 -0
- package/dist/components/Prefs/schema.d.ts.map +1 -1
- package/dist/components/Properties/DialogRow.d.ts +33 -0
- package/dist/components/Properties/DialogRow.d.ts.map +1 -0
- package/dist/components/Properties/PropertyField.d.ts +238 -0
- package/dist/components/Properties/PropertyField.d.ts.map +1 -0
- package/dist/components/Properties/PropertyGroup.d.ts +12 -3
- package/dist/components/Properties/PropertyGroup.d.ts.map +1 -1
- package/dist/components/Properties/PropertyPanel.d.ts +32 -236
- package/dist/components/Properties/PropertyPanel.d.ts.map +1 -1
- package/dist/components/Properties/Subpanel.d.ts +14 -0
- package/dist/components/Properties/Subpanel.d.ts.map +1 -0
- package/dist/components/Properties/index.d.ts +8 -4
- package/dist/components/Properties/index.d.ts.map +1 -1
- package/dist/components/Properties/index.js +3 -2
- package/dist/components/Properties/storyLayouts.d.ts.map +1 -1
- package/dist/components/RadioGroup/index.js +1 -1
- package/dist/components/RangeSlider/index.js +1 -1
- package/dist/components/ResizeHandle/index.js +1 -1
- package/dist/components/Select/Select.d.ts +38 -5
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Select/index.d.ts +2 -2
- package/dist/components/Select/index.d.ts.map +1 -1
- package/dist/components/Select/index.js +2 -2
- package/dist/components/SelectionPanel/index.js +2 -2
- package/dist/components/SelectionPanel/renderLeaf.d.ts +14 -8
- package/dist/components/SelectionPanel/renderLeaf.d.ts.map +1 -1
- package/dist/components/Sidebar/index.js +1 -1
- package/dist/components/SidebarPanel/SidebarPanel.d.ts +2 -2
- package/dist/components/SidebarPanel/SidebarPanel.d.ts.map +1 -1
- package/dist/components/SidebarPanel/index.js +1 -1
- package/dist/components/Slider/index.js +1 -1
- package/dist/components/StatusBar/index.js +1 -1
- package/dist/components/SwatchGrid/SwatchGrid.d.ts +34 -0
- package/dist/components/SwatchGrid/SwatchGrid.d.ts.map +1 -0
- package/dist/components/SwatchGrid/index.d.ts +3 -0
- package/dist/components/SwatchGrid/index.d.ts.map +1 -0
- package/dist/components/SwatchGrid/index.js +2 -0
- package/dist/components/Switch/index.js +1 -1
- package/dist/components/Tabs/index.js +1 -1
- package/dist/components/Timeline/Lane.d.ts.map +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 +2 -1
- package/dist/components/ToggleBar/ToggleBar.d.ts.map +1 -1
- package/dist/components/ToggleBar/index.js +1 -1
- package/dist/components/TokenPanel/index.js +1 -1
- package/dist/components/ToolButton/index.js +1 -1
- package/dist/components/ToolGroup/index.js +1 -1
- package/dist/components/ToolOptionsBar/index.js +1 -1
- package/dist/components/ToolPalette/index.d.ts +1 -0
- package/dist/components/ToolPalette/index.d.ts.map +1 -1
- package/dist/components/ToolPalette/index.js +3 -2
- package/dist/components/Tooltip/Tooltip.d.ts +6 -2
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/Tooltip/index.d.ts +1 -1
- package/dist/components/Tooltip/index.d.ts.map +1 -1
- package/dist/components/Tooltip/index.js +2 -2
- package/dist/components/Tree/Tree.d.ts +84 -0
- package/dist/components/Tree/Tree.d.ts.map +1 -0
- package/dist/components/Tree/index.d.ts +3 -0
- package/dist/components/Tree/index.d.ts.map +1 -0
- package/dist/components/Tree/index.js +2 -0
- package/dist/components/segmentTooltip.d.ts +30 -0
- package/dist/components/segmentTooltip.d.ts.map +1 -0
- package/dist/components/stance.d.ts +30 -0
- package/dist/components/stance.d.ts.map +1 -0
- package/dist/components/stanceCss.d.ts +31 -0
- package/dist/components/stanceCss.d.ts.map +1 -0
- package/dist/components/stanceSurfaces.d.ts +4 -0
- package/dist/components/stanceSurfaces.d.ts.map +1 -0
- package/dist/format/number.d.ts +3 -2
- package/dist/format/number.d.ts.map +1 -1
- package/dist/icons/Icon.d.ts.map +1 -1
- package/dist/icons/ShapeKindIcon.d.ts +10 -0
- package/dist/icons/ShapeKindIcon.d.ts.map +1 -0
- package/dist/icons/index.d.ts +5 -3
- package/dist/icons/index.d.ts.map +1 -1
- package/dist/icons/paths.d.ts +2 -0
- package/dist/icons/paths.d.ts.map +1 -1
- package/dist/index.d.ts +16 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +110 -78
- package/dist/index.js.map +1 -1
- package/dist/interactiveTarget.d.ts +9 -0
- package/dist/interactiveTarget.d.ts.map +1 -0
- package/dist/style.css +1 -1
- package/dist/useReorderDragList.d.ts +36 -7
- package/dist/useReorderDragList.d.ts.map +1 -1
- package/dist/useRovingTabIndex.d.ts +1 -1
- package/dist/useScrollSpy.d.ts +48 -0
- package/dist/useScrollSpy.d.ts.map +1 -0
- package/package.json +8 -8
- package/dist/chunks/ActionBar-CLwiY3Jg.js +0 -62
- package/dist/chunks/ActionBar-CLwiY3Jg.js.map +0 -1
- package/dist/chunks/ActionsBar-D84a4eGy.js +0 -41
- package/dist/chunks/ActionsBar-D84a4eGy.js.map +0 -1
- package/dist/chunks/Badge-CW9pBPFl.js.map +0 -1
- package/dist/chunks/Button-DRSApvnK.js +0 -90
- package/dist/chunks/Button-DRSApvnK.js.map +0 -1
- package/dist/chunks/Callout-DrNu-9Qr.js +0 -122
- package/dist/chunks/Callout-DrNu-9Qr.js.map +0 -1
- package/dist/chunks/ColorField-BYzgZM9o.js.map +0 -1
- package/dist/chunks/DataGrid-C8KrYtw7.js +0 -104
- package/dist/chunks/DataGrid-C8KrYtw7.js.map +0 -1
- package/dist/chunks/Dialog-fGqqQ6o_.js +0 -61
- package/dist/chunks/Dialog-fGqqQ6o_.js.map +0 -1
- package/dist/chunks/Disclosure-CILDfWsU.js +0 -47
- package/dist/chunks/Disclosure-CILDfWsU.js.map +0 -1
- package/dist/chunks/GradientEditor-rRBmf3G0.js +0 -333
- package/dist/chunks/Icon-DT0x6HaQ.js.map +0 -1
- package/dist/chunks/InlineRange-DdIlfGqG.js +0 -29
- package/dist/chunks/InlineRange-DdIlfGqG.js.map +0 -1
- package/dist/chunks/Input-DbMKpkXy.js.map +0 -1
- package/dist/chunks/ItemList-B9zYb0GE.js +0 -42
- package/dist/chunks/ItemList-B9zYb0GE.js.map +0 -1
- package/dist/chunks/Keycaps-DunVpejA.js.map +0 -1
- package/dist/chunks/LayerStack-CfQ6GsRz.js +0 -142
- package/dist/chunks/LayerStack-CfQ6GsRz.js.map +0 -1
- package/dist/chunks/MenuButton-C_4nox39.js +0 -60
- package/dist/chunks/MenuButton-C_4nox39.js.map +0 -1
- package/dist/chunks/MeshEditor-Bipz-Ocl.js +0 -123
- package/dist/chunks/MeshEditor-Bipz-Ocl.js.map +0 -1
- package/dist/chunks/NumberField-CCjEDZCg.js.map +0 -1
- package/dist/chunks/PaintField-jBOJ32rL.js.map +0 -1
- package/dist/chunks/Powerline-Ak5AWUlK.js.map +0 -1
- package/dist/chunks/Prefs-CNC8tzyN.js +0 -308
- package/dist/chunks/Prefs-CNC8tzyN.js.map +0 -1
- package/dist/chunks/Properties-Rnb6TAbN.js +0 -891
- package/dist/chunks/Properties-Rnb6TAbN.js.map +0 -1
- package/dist/chunks/Select-BEope086.js +0 -190
- package/dist/chunks/Select-BEope086.js.map +0 -1
- package/dist/chunks/SidebarPanel-Bs6V21hg.js.map +0 -1
- package/dist/chunks/Timeline-DNKY_yiK.js.map +0 -1
- package/dist/chunks/ToggleBar-CClus5Cd.js +0 -75
- package/dist/chunks/ToolPalette-DGkKwE7D.js +0 -97
- package/dist/chunks/ToolPalette-DGkKwE7D.js.map +0 -1
- package/dist/chunks/Tooltip-C4YBczLq.js.map +0 -1
- package/dist/chunks/icons-DFLytcui.js +0 -165
- package/dist/chunks/icons-DFLytcui.js.map +0 -1
- package/dist/chunks/model-13kZ_-mE.js +0 -483
- package/dist/chunks/model-13kZ_-mE.js.map +0 -1
- package/dist/chunks/number-BHz66zQO.js.map +0 -1
- package/dist/chunks/range.module-DSsOIq1R.js +0 -8
- package/dist/chunks/range.module-DSsOIq1R.js.map +0 -1
- package/dist/chunks/schema-Dft4Cu2p.js +0 -47
- package/dist/chunks/schema-Dft4Cu2p.js.map +0 -1
- package/dist/chunks/segmentedControl.module-DS72X1ns.js +0 -11
- package/dist/chunks/segmentedControl.module-DS72X1ns.js.map +0 -1
- package/dist/chunks/useReorderDragList-CSQGd7zQ.js +0 -102
- package/dist/chunks/useReorderDragList-CSQGd7zQ.js.map +0 -1
- package/dist/chunks/useRovingTabIndex-Dkpf_KhN.js.map +0 -1
- package/dist/components/ActionsBar/ActionsBar.d.ts +0 -35
- package/dist/components/ActionsBar/ActionsBar.d.ts.map +0 -1
- package/dist/components/ActionsBar/index.d.ts +0 -3
- package/dist/components/ActionsBar/index.d.ts.map +0 -1
- package/dist/components/ActionsBar/index.js +0 -2
- package/dist/components/LayerStack/LayerStack.d.ts +0 -62
- package/dist/components/LayerStack/LayerStack.d.ts.map +0 -1
- package/dist/components/LayerStack/index.d.ts +0 -2
- package/dist/components/LayerStack/index.d.ts.map +0 -1
- package/dist/components/LayerStack/index.js +0 -2
- package/dist/components/Properties/EffectCard.d.ts +0 -69
- package/dist/components/Properties/EffectCard.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-BQMvTLnW.js","names":[],"sources":["../../src/components/SelectionPanel/SelectionPanel.module.css","../../src/components/SelectionPanel/renderLeaf.tsx","../../src/components/SelectionPanel/model.ts"],"sourcesContent":[".root {\n display: flex;\n flex-direction: column;\n font-size: var(--wzl-font-size-sm);\n color: var(--wzl-fg);\n}\n\n.header {\n display: flex;\n align-items: baseline;\n gap: var(--wzl-space-4);\n padding: var(--wzl-space-4) 0;\n border-block-end: 1px solid var(--wzl-border);\n}\n\n.kind {\n font-weight: var(--wzl-font-weight-bold);\n font-size: var(--wzl-font-size);\n}\n\n.breakdown {\n font-size: var(--wzl-font-size-sm);\n opacity: 0.6;\n}\n\n.section {\n padding: var(--wzl-space-3) 0 var(--wzl-space-4);\n border-block-end: 1px solid var(--wzl-border);\n}\n\n.section:last-child {\n border-block-end: none;\n}\n\n.sectionTitle {\n margin: 0 0 var(--wzl-space-3);\n font-size: var(--wzl-font-size-xs);\n font-weight: var(--wzl-font-weight-bold);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n opacity: 0.55;\n}\n\n.row {\n display: grid;\n grid-template-columns: 64px 1fr;\n gap: var(--wzl-space-3);\n align-items: center;\n margin-block-end: 5px;\n}\n\n.rowLabel {\n opacity: 0.75;\n}\n\n.rowControls {\n display: flex;\n flex-wrap: wrap;\n gap: var(--wzl-space-3);\n align-items: center;\n min-inline-size: 0;\n}\n\n/* Glyph plus its control, held together so the pair row wraps between\n fields rather than between a field and the icon naming it. */\n.namedField {\n display: flex;\n align-items: center;\n gap: var(--wzl-space-2);\n min-inline-size: 0;\n}\n\n.namedField > svg {\n flex: none;\n opacity: 0.75;\n}\n\n.blockRow {\n margin-block-end: 5px;\n}\n\n/* Fields paired into one row split it evenly, the way Position's x/y do. */\n.rowControls > .namedField {\n flex: 1 1 0;\n}\n\n/* Except around a segmented bar, which is sized by its segments: an equal\n share of the row is wider than the buttons want to be. */\n.rowControls > .namedField:has(> .toggle) {\n flex: 0 1 auto;\n}\n\n.rowControls > * {\n flex: 1;\n min-inline-size: 0;\n}\n\n/* Bars sharing a row split the leftover between them, so the gap stays fixed\n and the width lands on the segments. A bar with the row to itself is sized\n by its segments instead — a third of 240px is a plate, not a button. */\n.rowControls > .toggle {\n flex: 1 1 auto;\n}\n\n.rowControls > .toggle:only-child {\n flex: 0 1 auto;\n}\n\n/* A flag bar is sized by its glyphs rather than by a share of the row: an\n even split would fling one-letter segments to the margins. */\n.rowControls > .flagToggle {\n flex: 0 0 auto;\n}\n\n.number :global(input),\n.select {\n font-size: var(--wzl-font-size-sm);\n}\n\n.unrenderable {\n font-size: var(--wzl-font-size-sm);\n opacity: 0.5;\n font-style: italic;\n}\n\n/* A `block` leaf that renders its own rows — an object leaf's fields. */\n.objectLeaf {\n margin-block: var(--wzl-space-4) var(--wzl-space-2);\n}\n\n.objectLeaf .sectionTitle {\n margin-block: 7px 5px;\n}\n\n/* Fields under a heading inside an object read as belonging to it. */\n.objectGroup {\n padding-inline-start: var(--wzl-space-4);\n border-inline-start: 1px solid var(--wzl-border);\n margin-block-end: var(--wzl-space-2);\n}\n\n/* The slider's track; the row only says how it shares the space. */\n.slider {\n flex: 1;\n}\n","/**\n * A selection's leaves as cells: one `ToolPrefLeaf` and its aggregated value\n * in, one rendered cell out, plus the run logic that turns a row of paired\n * toggles into a single segmented bar and the rows of an object leaf.\n *\n * The control itself is `PropertyControl`'s, through `prefFieldProps`; what\n * is decided here is how a selection surface sizes and composes it.\n * `ToolOptionsBar` renders a tool's options through the same functions.\n */\nimport { Fragment, type ReactNode } from 'react';\nimport type {\n ToolPrefBoolean,\n ToolPrefGroup,\n ToolPrefLeaf,\n ToolPrefObject,\n} from '@weasel-js/core';\nimport { prefFieldProps } from '../Prefs/prefField';\nimport { PropertyControl } from '../Properties/PropertyField';\nimport { ToggleBar } from '../ToggleBar';\nimport { Icon } from '../../icons/Icon';\nimport { ICON_PATHS, type IconName } from '../../icons/paths';\nimport s from './SelectionPanel.module.css';\n\n\n/** What a {@link PropertyRenderer} is given for the property it is rendering. */\nexport interface PropertyRenderContext {\n /** Dotted node path of the leaf (`pose.x`, `data.fill`). */\n path: string;\n /** The schema leaf. App renderers narrow it to their own kind shape. */\n pref: ToolPrefLeaf;\n /** Aggregated value across the selection; `undefined` when mixed or unset. */\n value: unknown;\n /** True when selected nodes disagree at this path. */\n mixed: boolean;\n /**\n * True when the nodes agree and what they agree on is nothing — the field\n * is absent, and whatever paints comes from a fallback further down.\n *\n * Distinct from `mixed`, and both leave `value` undefined. A control must\n * not substitute its schema default here: doing so shows a value the node\n * does not hold, and the next edit writes that invention back.\n */\n unset: boolean;\n /**\n * The fields of the object this leaf is a field of — `undefined` for a\n * top-level leaf, and for a field of an object the node does not hold.\n *\n * What a control needs when its own field doesn't carry the whole answer:\n * a stroke's dash lengths are multiples of the stroke's width, so reading\n * the array as a style takes both.\n */\n siblings?: Record<string, unknown>;\n /** Commit a value — fans out to every selected node in one undo step. */\n setValue: (value: unknown) => void;\n /**\n * The aggregated value at another node path — what `value` and `mixed` are\n * for this leaf's own path, for any path.\n *\n * A control whose subject spans more than one field needs it: a font picker\n * reporting which variant will actually paint has to read the node's weight\n * and style. Reading it off `value` is impossible — a leaf is handed one\n * field.\n */\n valueAt: (path: string) => { value: unknown; mixed: boolean };\n /**\n * The ids of the nodes the values were read from, joined. It changes exactly\n * when the selection does, so a control holding scratch that belongs to one\n * selection can key on it and be remounted rather than carry it to the next.\n * Absent where the values come from no selection, as in a tool options bar.\n */\n selectionKey?: string;\n}\n\n/**\n * Renders the control for one property across the whole selection.\n * Returning `null` collapses the leaf.\n */\nexport type PropertyRenderer = (ctx: PropertyRenderContext) => ReactNode;\n\n\n/**\n * One leaf with its context built but nothing rendered yet.\n *\n * Deferring the render is what lets a run of sibling flags become one bar:\n * whether a leaf joins its neighbors is a fact about the run, which no leaf\n * rendering itself can see.\n */\nexport interface LeafCell {\n key: string;\n leaf: ToolPrefLeaf;\n ctx: PropertyRenderContext;\n /** The accessible name this leaf's control carries — qualified by the row's\n * pair where the row holds more than one leaf. */\n ariaLabel: string;\n /** Renders the leaf on its own, chrome and all. */\n render: () => ReactNode;\n}\n\n/** A cell's content, once the run it belongs to has been decided. */\nexport interface RenderedCell {\n key: string;\n /** The leaf that names the cell — the run's first, for a flag bar. */\n leaf: ToolPrefLeaf;\n block: boolean;\n content: ReactNode;\n}\n\n/**\n * True for a leaf that can join a flag bar: a paired toggle boolean the\n * consumer has not claimed with a renderer of its own.\n */\nexport function isFlagCell(cell: LeafCell, renderers?: Record<string, PropertyRenderer>): boolean {\n const { leaf } = cell;\n return (\n leaf.kind === 'boolean' &&\n (leaf as ToolPrefBoolean).control === 'toggle' &&\n leaf.pair !== undefined &&\n renderers?.[cell.ctx.path] === undefined &&\n renderers?.[leaf.kind] === undefined\n );\n}\n\n/**\n * Renders a row's cells, collapsing each run of adjacent same-`pair` toggle\n * booleans into one segmented bar — the idiom the enum toggle a row away\n * already uses, rather than one detached pill per flag.\n */\nexport function renderCells(\n cells: readonly LeafCell[],\n renderers?: Record<string, PropertyRenderer>,\n): RenderedCell[] {\n const out: RenderedCell[] = [];\n for (let i = 0; i < cells.length; ) {\n const cell = cells[i];\n if (!isFlagCell(cell, renderers)) {\n const content = cell.render();\n if (content != null) {\n out.push({ key: cell.key, leaf: cell.leaf, block: cell.leaf.block === true, content });\n }\n i += 1;\n continue;\n }\n let j = i + 1;\n while (\n j < cells.length &&\n isFlagCell(cells[j], renderers) &&\n cells[j].leaf.pair === cell.leaf.pair\n ) {\n j += 1;\n }\n const run = cells.slice(i, j);\n out.push({\n key: cell.key,\n leaf: cell.leaf,\n block: run.every((c) => c.leaf.block === true),\n content: <FlagBar run={run} ariaLabel={cell.leaf.pair as string} />,\n });\n i = j;\n }\n return out;\n}\n\n/**\n * A run of paired boolean flags as one multi-select bar — U / S / O, the way\n * every text editor draws them.\n */\nfunction FlagBar({ run, ariaLabel }: { run: readonly LeafCell[]; ariaLabel: string }): ReactNode {\n const on = run.filter((c) => c.ctx.value === true).map((c) => c.key);\n return (\n <ToggleBar<string>\n mode=\"multiple\"\n size=\"sm\"\n variant=\"flat\"\n className={s.flagToggle}\n ariaLabel={ariaLabel}\n items={run.map((c) => {\n const p = c.leaf as ToolPrefBoolean;\n return {\n value: c.key,\n label:\n p.icon && p.icon in ICON_PATHS ? (\n <Icon name={p.icon as IconName} size={14} />\n ) : (\n (p.short ?? p.name.slice(0, 1))\n ),\n ariaLabel: c.ariaLabel,\n };\n })}\n value={on}\n // Each flag owns its own path, so only the segment that moved is\n // written — committing the run would write two fields nobody touched,\n // and inside an object leaf would fabricate values for the other two.\n mixedValues={run.filter((c) => c.ctx.mixed).map((c) => c.key)}\n onChange={(next) => {\n for (const c of run) {\n const now = next.includes(c.key);\n if (now !== on.includes(c.key)) c.ctx.setValue(now);\n }\n }}\n />\n );\n}\n\nexport function renderBuiltin(\n ctx: PropertyRenderContext,\n ariaLabel: string,\n renderers?: Record<string, PropertyRenderer>,\n /** Identifies the current selection, so a control holding per-selection\n * scratch (the paint kind memory) is remounted rather than carried over. */\n selectionKey = '',\n /** True for a field of an object leaf. Such a field writes itself into its\n * parent, so it can only hold values its parent's type permits — which is\n * what rules \"none\" out for a nested paint. */\n nested = false,\n): ReactNode {\n const { pref, value, mixed, unset, setValue } = ctx;\n if (pref.kind === 'object') {\n // One value with fields hanging off it. Each child writes the parent\n // whole, so a field is never set on a half-built object.\n return <ObjectLeaf ctx={ctx} renderers={renderers} selectionKey={selectionKey} />;\n }\n const field = prefFieldProps(pref, {\n value,\n mixed,\n unset,\n siblings: ctx.siblings,\n setValue,\n // The substitution probe runs at the node's own weight and style, so the\n // picker names the variant that will actually paint. A mixed selection\n // has no single one; the probe falls back to 400/normal there.\n fontVariant: {\n weight: ctx.valueAt('data.style.fontWeight').value,\n style: ctx.valueAt('data.style.fontStyle').value,\n },\n });\n if (field === null) {\n return <span className={s.unrenderable}>({pref.kind}: no renderer)</span>;\n }\n switch (field.kind) {\n case 'boolean':\n // A panel's flag is a switch unless it asks otherwise.\n return (\n <PropertyControl\n {...field}\n {...framed(ariaLabel)}\n control={field.control ?? 'switch'}\n className={field.control === 'toggle' ? s.flagToggle : undefined}\n />\n );\n case 'number':\n return (\n <PropertyControl\n {...field}\n {...framed(ariaLabel)}\n className={field.control === 'slider' ? s.slider : s.number}\n steppers={false}\n />\n );\n case 'string':\n // Settled values only: a live write per keystroke would be one undo\n // step per character.\n return <PropertyControl {...field} {...framed(ariaLabel)} onInput={settledOnly} />;\n case 'enum':\n return (\n <PropertyControl\n {...field}\n {...framed(ariaLabel)}\n className={field.control === 'toggle' ? s.toggle : field.control === 'radio' ? undefined : s.select}\n />\n );\n case 'font-family':\n return <PropertyControl {...field} {...framed(ariaLabel)} className={s.select} />;\n case 'paint':\n return (\n <PropertyControl\n {...field}\n {...framed(ariaLabel)}\n // Per-kind switch memory is scratch for one selection; carrying it\n // across would recall the previous node's gradient.\n key={selectionKey}\n control=\"inline\"\n // A nested paint writes one field of its parent, and no kit paint\n // field is optional — `Stroke.paint` is required. Removing the\n // whole parent is a different edit than repainting it, so the\n // control must not offer one as the other.\n allowNone={!nested}\n />\n );\n default:\n return <PropertyControl {...field} {...framed(ariaLabel)} />;\n }\n}\n\nconst framed = (name: string) => ({ chrome: 'framed' as const, name });\n\nconst settledOnly = (): void => {};\n\n/**\n * Renders an object leaf: a titled block whose rows are the object's own\n * fields. A child's edit commits the parent object, never the child's path —\n * writing into a path whose value is not an object yet would corrupt it.\n */\n/** One labeled row inside an object leaf; `pair` merges adjacent fields into\n * it, exactly as the section rows merge theirs. */\ninterface ObjectRow {\n key: string;\n pair?: string;\n label: string;\n title?: string;\n /** Every field in the row brought its own chrome, so the row drops the\n * label column and spans the block. One unlabeled field in an otherwise\n * labeled pair would leave the row named after half of itself. */\n block: boolean;\n controls: ReactNode[];\n}\n\n/**\n * Renders an object leaf: the object's own fields, as rows. A child's edit\n * commits the parent object, never the child's path — writing into a path\n * whose value is not an object yet would corrupt it.\n */\nfunction ObjectLeaf({\n ctx,\n renderers,\n selectionKey = '',\n}: {\n ctx: PropertyRenderContext;\n renderers?: Record<string, PropertyRenderer>;\n selectionKey?: string;\n}): ReactNode {\n const pref = ctx.pref as ToolPrefObject;\n const held = typeof ctx.value === 'object' && ctx.value !== null\n ? (ctx.value as Record<string, unknown>)\n : undefined;\n\n // A value whose fields are entirely grouped is titled by those groups — its\n // own heading would stack onto the first one and name nothing new.\n const allGrouped = Object.values(pref.children).every((child) => !('kind' in child));\n\n // `indent` is false when nothing visible sits above these rows: depth is\n // drawn only where a label marks it.\n const rowsOf = (\n children: Record<string, ToolPrefLeaf | ToolPrefGroup>,\n indent: boolean,\n ): ReactNode[] => {\n const out: (ReactNode | ObjectRow)[] = [];\n const isRow = (v: ReactNode | ObjectRow): v is ObjectRow =>\n typeof v === 'object' && v !== null && 'controls' in v;\n\n // Cells accumulate unrendered so a run of adjacent same-`pair` flags can\n // be seen as a run before any of them draws; a group heading between two\n // fields ends the run, exactly as it ends a paired row.\n let pending: LeafCell[] = [];\n const flush = (): void => {\n for (const { key, leaf, block, content } of renderCells(pending, renderers)) {\n const prev = out[out.length - 1];\n if (leaf.pair !== undefined && isRow(prev) && prev.pair === leaf.pair) {\n prev.controls.push(<Fragment key={key}>{content}</Fragment>);\n prev.block &&= block;\n continue;\n }\n out.push({\n key,\n pair: leaf.pair,\n label: leaf.pair ?? leaf.name,\n title: leaf.description,\n block,\n controls: [<Fragment key={key}>{content}</Fragment>],\n });\n }\n pending = [];\n };\n\n for (const [key, child] of Object.entries(children)) {\n // A group among the children organises the fields under a heading\n // without contributing to the path — the rule group keys follow at the\n // top level.\n if (!('kind' in child)) {\n const labeled = child.name !== '';\n const inner = rowsOf(child.children, labeled);\n if (inner.length === 0) continue;\n flush();\n out.push(\n <div key={`group:${key}`} className={labeled && indent ? s.objectGroup : undefined}>\n {labeled && <h5 className={s.sectionTitle}>{child.name}</h5>}\n {inner}\n </div>,\n );\n continue;\n }\n const childPath = `${ctx.path}.${key}`;\n const childCtx: PropertyRenderContext = {\n path: childPath,\n pref: child,\n value: held?.[key],\n mixed: ctx.mixed,\n // A field of an object the node does not hold is unset, and so is one\n // the object omits — `data.stroke` absent leaves every stroke field\n // with nothing behind it, not with the schema's defaults.\n unset: !ctx.mixed && held?.[key] === undefined,\n siblings: held,\n valueAt: ctx.valueAt,\n selectionKey: ctx.selectionKey,\n setValue: (v) => {\n // The node holds no object yet, so writing one field has to\n // materialize the rest: the leaf's `default` is what a complete\n // value looks like. Starting from `{}` instead committed the one\n // field on its own — a `data.stroke` of `{ width: 2 }` with no\n // `paint`, which the type forbids and the painter threw on, taking\n // the whole frame and the visible document with it.\n const base = held\n ?? pref.fromScalar?.(ctx.value)\n ?? (typeof pref.default === 'object' && pref.default !== null\n ? { ...(pref.default as Record<string, unknown>) }\n : {});\n if (v === undefined) {\n // A field written as absent is absent — leaving the key holding\n // `undefined` says the object has a dash of nothing.\n const { [key]: _dropped, ...rest } = base;\n ctx.setValue(rest);\n return;\n }\n ctx.setValue({ ...base, [key]: v });\n },\n };\n pending.push({\n key: childPath,\n leaf: child,\n ctx: childCtx,\n ariaLabel: child.name,\n render: () => {\n const custom = renderers?.[childPath] ?? renderers?.[child.kind];\n const rendered = custom\n ? custom(childCtx)\n : renderBuiltin(childCtx, child.name, renderers, selectionKey, true);\n if (rendered == null) return null;\n // Neither a paired row nor a block one gives a field its own label\n // column, so the glyph is all that names it on screen. The control\n // already carries `name` as its accessible name, which leaves the\n // glyph decorative.\n const unlabeled = child.pair !== undefined || child.block === true;\n const glyph = unlabeled && child.icon && child.icon in ICON_PATHS;\n if (!glyph) return rendered;\n return (\n <span className={s.namedField}>\n <Icon name={child.icon as IconName} size={14} />\n {rendered}\n </span>\n );\n },\n });\n }\n flush();\n return out.map((entry) =>\n typeof entry === 'object' && entry !== null && 'controls' in entry ? (\n entry.block ? (\n <div key={entry.key} className={`${s.rowControls} ${s.blockRow}`} title={entry.title}>\n {entry.controls}\n </div>\n ) : (\n <div key={entry.key} className={s.row}>\n <span className={s.rowLabel} title={entry.title}>{entry.label}</span>\n <span className={s.rowControls}>{entry.controls}</span>\n </div>\n )\n ) : (\n entry\n ),\n );\n };\n\n const rows = rowsOf(pref.children, !allGrouped);\n if (rows.length === 0) return null;\n return (\n <div className={s.objectLeaf}>\n {!allGrouped && <h4 className={s.sectionTitle}>{pref.name}</h4>}\n {rows}\n </div>\n );\n}\n","// Pure selection→panel derivations for SelectionPanel. Kept free of\n// React so intersection/aggregation semantics are unit-testable.\n//\n// Path convention (see core `NodePropertiesEntry`): a leaf's OWN KEY in\n// the schema is its node path — a dotted path of any depth rooted at\n// `pose` or `data` (`pose.x`, `data.fill`, `data.style.fontSize`). Group\n// keys are organizational only.\n\nimport {\n MIXED,\n type Mixed,\n type NodePropertiesEntry,\n type NodeRoutingEntry,\n type SceneNode,\n type ToolPrefGroup,\n type ToolPrefLeaf,\n} from '@weasel-js/core';\n\n// Re-exported under its existing public name here: the kit-wide \"these\n// values disagree\" sentinel (`@weasel-js/core`'s `MIXED`) also covers\n// multi-node aggregation, so this panel doesn't get its own symbol.\nexport { MIXED };\nexport type { Mixed };\n\nexport type AnyNode = SceneNode<unknown, string, unknown>;\n\n/**\n * One editable property in a {@link SelectionPanel}, paired with the dotted\n * node path it reads and writes.\n */\nexport interface PanelLeaf {\n /** Dotted node path — the leaf's key in the schema. */\n path: string;\n leaf: ToolPrefLeaf;\n}\n\n/**\n * One labeled row of a panel section. Holds several leaves when the schema\n * paired them.\n */\nexport interface PanelRow {\n label: string;\n leaves: PanelLeaf[];\n}\n\n/**\n * A titled block of rows, derived from one top-level group of a properties\n * schema. `key` is that group's schema key.\n */\nexport interface PanelSection {\n key: string;\n name: string;\n rows: PanelRow[];\n}\n\n/** Derive a node's kind: containers are `'group'`; leaves classify their\n * `data` through the routing entries (first match wins, `'unknown'`\n * otherwise) — same semantics as core's `NodeRouting.classify`. */\nexport function classifyKind(\n node: AnyNode,\n routing: readonly NodeRoutingEntry[],\n): string {\n if (node.kind === 'container') return 'group';\n for (const entry of routing) {\n if (entry.matches(node.data)) return entry.name;\n }\n return 'unknown';\n}\n\nexport function isGroup(n: ToolPrefLeaf | ToolPrefGroup): n is ToolPrefGroup {\n return !('kind' in n);\n}\n\n/** Flatten a schema to sections of leaves. Nested groups fold into their\n * top-level section; top-level leaves get an untitled leading section. */\nfunction flatten(schema: ToolPrefGroup): PanelSection[] {\n const sections: PanelSection[] = [];\n const untitled: PanelLeaf[] = [];\n\n const collect = (group: ToolPrefGroup, into: PanelLeaf[]): void => {\n for (const [key, child] of Object.entries(group.children)) {\n if (isGroup(child)) collect(child, into);\n else into.push({ path: key, leaf: child });\n }\n };\n\n for (const [key, child] of Object.entries(schema.children)) {\n if (isGroup(child)) {\n const leaves: PanelLeaf[] = [];\n collect(child, leaves);\n sections.push({ key, name: child.name, rows: pairRows(leaves) });\n } else {\n untitled.push({ path: key, leaf: child });\n }\n }\n if (untitled.length > 0) {\n sections.unshift({ key: '', name: '', rows: pairRows(untitled) });\n }\n return sections;\n}\n\n/** Merge consecutive leaves sharing a `pair` id into one labeled row. */\nexport function pairRows(leaves: readonly PanelLeaf[]): PanelRow[] {\n const rows: PanelRow[] = [];\n for (const item of leaves) {\n const pair = item.leaf.pair;\n const prev = rows[rows.length - 1];\n if (pair !== undefined && prev !== undefined && prev.label === pair) {\n prev.leaves.push(item);\n } else {\n rows.push({ label: pair ?? item.leaf.name, leaves: [item] });\n }\n }\n return rows;\n}\n\n/**\n * The schema the panel shows for a set of kinds: one kind → its full\n * schema; several → the intersection by (path, leaf kind), shaped by the\n * first kind's section/row layout. Kinds without a registered schema\n * contribute nothing, so their presence collapses the intersection.\n */\nexport function effectiveSections(\n kinds: readonly string[],\n entries: readonly NodePropertiesEntry[],\n): PanelSection[] {\n const uniq = [...new Set(kinds)];\n if (uniq.length === 0) return [];\n const byName = new Map(entries.map((e) => [e.name, e]));\n const schemas = uniq.map((k) => byName.get(k)?.schema);\n if (schemas.some((s) => s === undefined)) return [];\n const [first, ...rest] = schemas as ToolPrefGroup[];\n\n const flatFirst = flatten(first);\n if (rest.length === 0) return flatFirst;\n\n // '\\0' delimiter: path and kind strings are unconstrained, so a\n // printable separator could collide with real content.\n const leafKey = (l: PanelLeaf): string => `${l.path}\\0${l.leaf.kind}`;\n const restKeys = rest.map(\n (schema) =>\n new Set(\n flatten(schema)\n .flatMap((s) => s.rows)\n .flatMap((r) => r.leaves)\n .map(leafKey),\n ),\n );\n const keep = (l: PanelLeaf): boolean =>\n restKeys.every((set) => set.has(leafKey(l)));\n\n return flatFirst\n .map((section) => ({\n ...section,\n rows: section.rows\n .map((row) => ({ ...row, leaves: row.leaves.filter(keep) }))\n .filter((row) => row.leaves.length > 0),\n }))\n .filter((section) => section.rows.length > 0);\n}\n\n/** Read a node value at a dotted path of any depth (`pose.x`,\n * `data.style.fontSize`, `data.style.fill.color`). Returns `undefined` if\n * the path is dotless (mirrors `commit`'s no-op on a malformed schema\n * key) or if any intermediate segment is missing or not an object. */\nexport function nodeValueAt(node: AnyNode, path: string): unknown {\n const segments = path.split('.');\n if (segments.length < 2) return undefined;\n const head = segments[0];\n let cursor: unknown = head === 'pose' ? node.pose : head === 'data' ? node.data : undefined;\n for (let i = 1; i < segments.length; i++) {\n if (cursor == null || typeof cursor !== 'object') return undefined;\n cursor = (cursor as Record<string, unknown>)[segments[i]];\n }\n return cursor;\n}\n\n/** Immutably set `value` at a dotted path within `root`, cloning each level\n * on the way down so React sees new object identities. Arrays stay arrays\n * (an array intermediate is shallow-copied, not flattened into `{0: ...}`)\n * — this is the write-side twin of `nodeValueAt`, so a schema author who\n * gets a working read gets a working write. */\nexport function setAtPath(root: object, segments: readonly string[], value: unknown): object {\n const [head, ...rest] = segments;\n if (rest.length === 0) {\n return Array.isArray(root)\n ? Object.assign([...root], { [head]: value })\n : { ...root, [head]: value };\n }\n const child = (root as Record<string, unknown>)[head];\n const childObj = Array.isArray(child)\n ? [...child]\n : child != null && typeof child === 'object'\n ? { ...child }\n : {};\n const nested = setAtPath(childObj, rest, value);\n return Array.isArray(root)\n ? Object.assign([...root], { [head]: nested })\n : { ...root, [head]: nested };\n}\n\n/** Aggregate a path across nodes: the shared value, or `MIXED`. */\nexport function aggregateValue(\n nodes: readonly AnyNode[],\n path: string,\n): unknown | Mixed {\n let value: unknown;\n let first = true;\n for (const node of nodes) {\n const v = nodeValueAt(node, path);\n if (first) {\n value = v;\n first = false;\n } else if (!Object.is(v, value)) {\n return MIXED;\n }\n }\n return value;\n}\n\n/** `'rect ×2 · text'` — kinds in first-seen order with counts. */\nexport function kindBreakdown(kinds: readonly string[]): string {\n const counts = new Map<string, number>();\n for (const k of kinds) counts.set(k, (counts.get(k) ?? 0) + 1);\n return [...counts.entries()]\n .map(([k, n]) => (n > 1 ? `${k} ×${n}` : k))\n .join(' · ');\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC+GA,SAAgB,EAAW,GAAgB,GAAuD;CAChG,IAAM,EAAE,YAAS;AACjB,QACE,EAAK,SAAS,aACb,EAAyB,YAAY,YACtC,EAAK,SAAS,KAAA,KACd,IAAY,EAAK,IAAI,UAAU,KAAA,KAC/B,IAAY,EAAK,UAAU,KAAA;;AAS/B,SAAgB,EACd,GACA,GACgB;CAChB,IAAM,IAAsB,EAAE;AAC9B,MAAK,IAAI,IAAI,GAAG,IAAI,EAAM,SAAU;EAClC,IAAM,IAAO,EAAM;AACnB,MAAI,CAAC,EAAW,GAAM,EAAU,EAAE;GAChC,IAAM,IAAU,EAAK,QAAQ;AAI7B,GAHI,KAAW,QACb,EAAI,KAAK;IAAE,KAAK,EAAK;IAAK,MAAM,EAAK;IAAM,OAAO,EAAK,KAAK,UAAU;IAAM;IAAS,CAAC,EAExF,KAAK;AACL;;EAEF,IAAI,IAAI,IAAI;AAC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QAAO;;AAGX,QAAO;;AAIT,SAAgB,EAAc,GAAkC;CAC9D,IAAM,oBAAS,IAAI,KAAqB;AACxC,MAAK,IAAM,KAAK,EAAO,GAAO,IAAI,IAAI,EAAO,IAAI,EAAE,IAAI,KAAK,EAAE;AAC9D,QAAO,CAAC,GAAG,EAAO,SAAS,CAAC,CACzB,KAAK,CAAC,GAAG,OAAQ,IAAI,IAAI,GAAG,EAAE,IAAI,MAAM,EAAG,CAC3C,KAAK,MAAM"}
|
|
@@ -20,8 +20,8 @@ function i(e, n = 0) {
|
|
|
20
20
|
maximumFractionDigits: n
|
|
21
21
|
} : {
|
|
22
22
|
notation: "compact",
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
minimumSignificantDigits: 3,
|
|
24
|
+
maximumSignificantDigits: 3
|
|
25
25
|
};
|
|
26
26
|
return e.toLocaleString("en-US", r).replace(/^-/, "−");
|
|
27
27
|
}
|
|
@@ -86,4 +86,4 @@ function f(e) {
|
|
|
86
86
|
//#endregion
|
|
87
87
|
export { a, f as i, i as n, n as o, t as r, e as t };
|
|
88
88
|
|
|
89
|
-
//# sourceMappingURL=number-
|
|
89
|
+
//# sourceMappingURL=number-6S8IzXVt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"number-6S8IzXVt.js","names":[],"sources":["../../src/format/number.ts"],"sourcesContent":["/**\n * Display-formatter for numbers. Use this anywhere a number is shown to\n * a user. The whole point: negative values get prefixed with the real\n * MINUS SIGN (U+2212) instead of the ASCII HYPHEN-MINUS (U+002D) that\n * `toLocaleString` and template literals produce by default.\n *\n * U+2212 is the same visual width as `+` and reads as a sign rather\n * than a hyphen — columns of signed numbers align cleanly and the\n * glyph doesn't get confused with a bullet or list dash.\n */\nexport const MINUS_SIGN = '−';\n\n/**\n * Formats a number for display, substituting {@link MINUS_SIGN} for the ASCII\n * hyphen `toLocaleString` emits. Non-finite values stringify as-is.\n */\nexport function formatNumber(value: number, options?: Intl.NumberFormatOptions): string {\n const formatted = Number.isFinite(value)\n ? value.toLocaleString(undefined, options)\n : String(value);\n return formatted.replace(/^-/, MINUS_SIGN);\n}\n\n/**\n * Parses a string that may carry {@link MINUS_SIGN} in place of the ASCII\n * hyphen. The inverse of {@link formatNumber} for any editing surface that\n * renders its value through it and reads the edited text back.\n */\nexport function parseSignedNumber(text: string): number {\n return Number(text.replace(MINUS_SIGN, '-'));\n}\n\n/** Powers of ten a typed magnitude suffix stands for. */\nconst EXPONENTS: Record<string, number> = { k: 3, m: 6, b: 9, t: 12 };\n\n/**\n * Formats a number the way a `compact` readout shows it: below 1,000 at\n * `decimals` places, from 1,000 up at three significant figures with a magnitude\n * suffix (`40.0K`, `294K`, `2.00M`), so the readout holds one width whatever the\n * value. Always `en-US`, so {@link parseNumber} reads it back.\n */\nexport function formatCompact(value: number, decimals = 0): string {\n if (!Number.isFinite(value)) return formatNumber(value);\n const options: Intl.NumberFormatOptions =\n Math.abs(value) < 1000\n ? { useGrouping: false, minimumFractionDigits: decimals, maximumFractionDigits: decimals }\n : { notation: 'compact', minimumSignificantDigits: 3, maximumSignificantDigits: 3 };\n return value.toLocaleString('en-US', options).replace(/^-/, MINUS_SIGN);\n}\n\n/**\n * Reads a typed number: anything {@link parseSignedNumber} reads, plus\n * thousands commas in the `40,000` shape and a `k`/`m`/`b`/`t` suffix in either\n * case (`2.5m` is 2,500,000). Empty text is NaN rather than zero.\n *\n * Given `units` — a suffix mapped to the factor it scales by — a trailing unit\n * name is read first: the longest match wins, exact case before any case, and\n * a unit beats a magnitude suffix, so with `m` accepted `2m` is `2 * units.m`.\n */\nexport function parseNumber(text: string, units?: Readonly<UnitTable>): number {\n if (units) {\n const trimmed = text.trim();\n const name = unitSuffixOf(trimmed, units);\n if (name !== undefined) {\n const terms = compoundTermsOf(trimmed, units);\n if (terms !== undefined && terms.length > 1) return compoundValue(terms, trimmed, units);\n const { factor, offset } = scaleOf(units[name]!);\n return scaled(parseNumber(trimmed.slice(0, -name.length)), factor) + offset;\n }\n }\n let t = text.trim().replace(MINUS_SIGN, '-');\n const exponent = EXPONENTS[t.slice(-1).toLowerCase()];\n if (exponent !== undefined) t = t.slice(0, -1).trimEnd();\n if (/^[-+]?\\d{1,3}(,\\d{3})+(\\.\\d*)?$/.test(t)) t = t.replace(/,/g, '');\n if (!/\\d/.test(t)) return Number.NaN;\n // Scaled through the exponent rather than by multiplying: 1.1 * 1000 is 1100.0000000000002.\n return Number(exponent === undefined ? t : `${t}e${exponent}`);\n}\n\n/** One unit's conversion into the shown unit: a bare factor, or a scale that\n * also moves zero. Structurally the kit's `UnitEntry`, kept local so this\n * formatting helper stays free of the scene vocabulary. */\nexport type UnitTableEntry = number | { factor: number; offset?: number };\n/** Suffixes a person may type, each mapped to its conversion. */\nexport type UnitTable = Record<string, UnitTableEntry>;\n\n/** Divided by the reciprocal below 1: 12 * 0.1 is 1.2000000000000002, 12 / 10 is 1.2. */\nfunction scaled(n: number, factor: number): number {\n return factor < 1 ? n / (1 / factor) : n * factor;\n}\n\n/** A unit table entry's scale, with the bare-factor shorthand widened. */\nfunction scaleOf(entry: UnitTableEntry): { factor: number; offset: number } {\n return typeof entry === 'number'\n ? { factor: entry, offset: 0 }\n : { factor: entry.factor, offset: entry.offset ?? 0 };\n}\n\n/**\n * The unit names in `text`, in reading order, when every one of them closes a\n * `<number><unit>` term — which is what tells `5ft 3in` from a malformed\n * `5ft 3`. Undefined when the text is not a run of whole terms.\n */\nfunction compoundTermsOf(text: string, units: Readonly<UnitTable>): string[] | undefined {\n const names: string[] = [];\n let rest = text.trimEnd();\n while (rest !== '') {\n const name = unitSuffixOf(rest, units);\n if (name === undefined) return undefined;\n names.push(name);\n const before = rest.slice(0, -name.length);\n const m = /(\\d+(?:\\.\\d+)?|\\.\\d+)\\s*$/.exec(before);\n if (!m) return undefined;\n rest = before.slice(0, m.index).trimEnd();\n // A sign leads the whole value, so it ends the walk rather than a term.\n if (rest === '-' || rest === '+' || rest === MINUS_SIGN) rest = '';\n }\n return names.length === 0 ? undefined : names.reverse();\n}\n\n/**\n * `5ft 3in` as one number in the shown unit. Every term scales and they sum;\n * a leading sign carries across all of them, so `-5ft 3in` is −63in and not\n * −57. Offsets have no meaning in a sum — 1K + 2degC is not a temperature —\n * so a term carrying one makes the whole value unreadable.\n */\nfunction compoundValue(names: string[], text: string, units: Readonly<UnitTable>): number {\n const digits = text.match(/\\d+(?:\\.\\d+)?|\\.\\d+/g);\n if (!digits || digits.length !== names.length) return Number.NaN;\n const sign = /^\\s*[-\\u2212]/.test(text) ? -1 : 1;\n let total = 0;\n for (const [i, name] of names.entries()) {\n const { factor, offset } = scaleOf(units[name]!);\n if (offset !== 0) return Number.NaN;\n total += scaled(Number(digits[i]), factor);\n }\n return sign * total;\n}\n\n/** The longest unit name `text` ends with — exact case first, then any case. */\nfunction unitSuffixOf(text: string, units: Readonly<UnitTable>): string | undefined {\n const names = Object.keys(units).filter((n) => n !== '').sort((a, b) => b.length - a.length);\n const lower = text.toLowerCase();\n return names.find((n) => text.endsWith(n)) ?? names.find((n) => lower.endsWith(n.toLowerCase()));\n}\n\n/** {@link String} with the leading ASCII hyphen swapped for {@link MINUS_SIGN}.\n * Locale-independent, unlike `toLocaleString`. */\nfunction signedString(value: number): string {\n return String(value).replace(/^-/, MINUS_SIGN);\n}\n\n/**\n * Formats a zoom factor for display. Below 2x a percentage reads naturally;\n * past it the numbers get long and a multiplier is what people say out loud,\n * so 250% shows as `2.5x`. Past 100x a tenth is noise, so the decimal is\n * dropped and thousands are grouped: `1009.74` reads as `1,010x`.\n */\nexport function formatZoom(zoom: number): string {\n if (!Number.isFinite(zoom)) return String(zoom);\n if (zoom <= 2) return `${signedString(Math.round(zoom * 100))}%`;\n if (zoom >= 100) return `${Math.round(zoom).toLocaleString('en-US')}x`;\n return `${signedString(Math.round(zoom * 10) / 10)}x`;\n}\n"],"mappings":";AAUA,IAAa,IAAa;AAM1B,SAAgB,EAAa,GAAe,GAA4C;AAItF,SAHkB,OAAO,SAAS,EAAM,GACp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AQ,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG,MAAM,EAAE,SAAS,EAAE,OAAO,EACtF,IAAQ,EAAK,aAAa;AAChC,QAAO,EAAM,MAAM,MAAM,EAAK,SAAS,EAAE,CAAC,IAAI,EAAM,MAAM,MAAM,EAAM,SAAS,EAAE,aAAa,CAAC,CAAC;;AAKlG,SAAS,EAAa,GAAuB;AAC3C,QAAO,OAAO,EAAM,CAAC,QAAQ,MAAA,IAAiB;;AAShD,SAAgB,EAAW,GAAsB;AAI/C,QAHK,OAAO,SAAS,EAAK,GACtB,KAAQ,IAAU,GAAG,EAAa,KAAK,MAAM,IAAO,IAAI,CAAC,CAAC,KAC1D,KAAQ,MAAY,GAAG,KAAK,MAAM,EAAK,CAAC,eAAe,QAAQ,CAAC,KAC7D,GAAG,EAAa,KAAK,MAAM,IAAO,GAAG,GAAG,GAAG,CAAC,KAHhB,OAAO,EAAK"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { sampleGradientStops as e } from "@weasel-js/core";
|
|
2
|
+
//#region src/paintPreview.ts
|
|
3
|
+
var t = 24;
|
|
4
|
+
function n(e) {
|
|
5
|
+
let t = e.patches?.[0]?.colors;
|
|
6
|
+
if (!t || t.length < 4) return;
|
|
7
|
+
let n = (e) => `color-mix(in srgb, ${e} 0%, transparent)`, r = [
|
|
8
|
+
["0% 0%", t[0]],
|
|
9
|
+
["100% 0%", t[1]],
|
|
10
|
+
["100% 100%", t[2]],
|
|
11
|
+
["0% 100%", t[3]]
|
|
12
|
+
].map(([e, t]) => `radial-gradient(farthest-corner at ${e}, ${t}, ${n(t)})`);
|
|
13
|
+
return r.push(`linear-gradient(to bottom, ${t[0]}, ${t[2]})`), r.join(", ");
|
|
14
|
+
}
|
|
15
|
+
function r(n) {
|
|
16
|
+
let r = n.interpolate ?? "rgb", i = [];
|
|
17
|
+
for (let a = 0; a <= t; a++) {
|
|
18
|
+
let o = a / t;
|
|
19
|
+
i.push(`${e(n.stops, o, r)} ${(o * 100).toFixed(1)}%`);
|
|
20
|
+
}
|
|
21
|
+
return i.join(", ");
|
|
22
|
+
}
|
|
23
|
+
var i = 180 / Math.PI;
|
|
24
|
+
function a(e) {
|
|
25
|
+
return `${(e * 100).toFixed(1)}%`;
|
|
26
|
+
}
|
|
27
|
+
function o(e) {
|
|
28
|
+
if (e != null) {
|
|
29
|
+
if ((e.fill ?? "solid") === "solid") return e.color;
|
|
30
|
+
if (e.fill === "linear-gradient") {
|
|
31
|
+
let t = e.to.x - e.from.x, n = e.to.y - e.from.y;
|
|
32
|
+
return `linear-gradient(${(t === 0 && n === 0 ? 90 : Math.atan2(t, -n) * i).toFixed(1)}deg, ${r(e)})`;
|
|
33
|
+
}
|
|
34
|
+
if (e.fill === "radial-gradient") return `radial-gradient(circle ${`at ${a(e.center.x)} ${a(e.center.y)}`}, ${r(e)})`;
|
|
35
|
+
if (e.fill === "mesh-gradient") return n(e);
|
|
36
|
+
if (e.fill === "conic-gradient") return `conic-gradient(from ${(e.angle * i + 90).toFixed(1)}deg at ${a(e.center.x)} ${a(e.center.y)}, ${r(e)})`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { o as t };
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=paintPreview-DPtZS4yU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paintPreview-DPtZS4yU.js","names":[],"sources":["../../src/paintPreview.ts"],"sourcesContent":["// A `FillStyle` as one CSS background string, for the swatches and chips that\n// stand in for a paint in a panel.\n//\n// The gradient kinds are sampled rather than translated stop for stop: CSS\n// blends its own stops in sRGB, so an OKLCh gradient handed over as two stops\n// would preview as the sRGB blend of its ends. Sampling through\n// `sampleGradientStops` in the paint's own space puts the curve into the\n// stops themselves, and the browser only interpolates the short hops between.\n\nimport { sampleGradientStops, type FillStyle } from '@weasel-js/core';\n\n/** Sample count along a previewed gradient. Enough that a hue arc reads as a\n * curve at chip size; a straight sRGB ramp would need a fraction of it. */\nconst SAMPLES = 24;\n\n/**\n * A mesh patch as four corner radials over a flat base.\n *\n * This is an approximation and cannot be anything else — CSS has no mesh, and\n * the real surface only exists once the renderer has baked it. Each corner\n * fades out across the chip and they composite to something bilinear-ish,\n * which is enough for a swatch to say \"this one, not that one\". Zero alpha is\n * written as `color-mix` with `transparent` so a named or packed-alpha color\n * works without being parsed here.\n */\nfunction meshPreview(paint: { patches?: { colors: string[] }[] }): string | undefined {\n const colors = paint.patches?.[0]?.colors;\n if (!colors || colors.length < 4) return undefined;\n const fade = (c: string): string => `color-mix(in srgb, ${c} 0%, transparent)`;\n const at: [string, string][] = [\n ['0% 0%', colors[0]], ['100% 0%', colors[1]],\n ['100% 100%', colors[2]], ['0% 100%', colors[3]],\n ];\n const layers = at.map(([pos, c]) =>\n `radial-gradient(farthest-corner at ${pos}, ${c}, ${fade(c)})`);\n // The base keeps the middle opaque where the four fades have all thinned.\n layers.push(`linear-gradient(to bottom, ${colors[0]}, ${colors[2]})`);\n return layers.join(', ');\n}\n\n/** CSS color stops across the whole ramp, in the gradient's own blend space. */\nfunction sampledStops(paint: Extract<FillStyle, { stops: unknown }>): string {\n const space = paint.interpolate ?? 'rgb';\n const out: string[] = [];\n for (let i = 0; i <= SAMPLES; i++) {\n const t = i / SAMPLES;\n out.push(`${sampleGradientStops(paint.stops, t, space)} ${(t * 100).toFixed(1)}%`);\n }\n return out.join(', ');\n}\n\nconst DEG = 180 / Math.PI;\n\n/** A fraction of the box as a CSS percentage. A gradient in absolute units has\n * no box to be a fraction of, so its geometry only ever approximates here. */\nfunction pct(v: number): string {\n return `${(v * 100).toFixed(1)}%`;\n}\n\n/**\n * `paint` as a CSS `background` value, or `undefined` for a paint with no CSS\n * form — a pattern, a registered kind — which a caller shows as a checker or\n * a placeholder rather than as an invented color.\n *\n * Gradient geometry is honored as far as CSS can carry it: the angle of a\n * linear gradient, the center of a radial or conic one. A paint in `'world'`\n * or `'local'` units is measured in the scene rather than in the chip, so its\n * preview shows the ramp and not the placement.\n */\nexport function paintPreviewCss(paint: FillStyle | null | undefined): string | undefined {\n if (paint == null) return undefined;\n const kind = paint.fill ?? 'solid';\n if (kind === 'solid') return (paint as { color: string }).color;\n\n if (paint.fill === 'linear-gradient') {\n const dx = paint.to.x - paint.from.x;\n const dy = paint.to.y - paint.from.y;\n // CSS measures from \"to top\", clockwise; the paint measures in a\n // y-down plane from +x.\n const angle = dx === 0 && dy === 0 ? 90 : Math.atan2(dx, -dy) * DEG;\n return `linear-gradient(${angle.toFixed(1)}deg, ${sampledStops(paint)})`;\n }\n if (paint.fill === 'radial-gradient') {\n const at = `at ${pct(paint.center.x)} ${pct(paint.center.y)}`;\n return `radial-gradient(circle ${at}, ${sampledStops(paint)})`;\n }\n if ((paint.fill as string) === 'mesh-gradient') {\n return meshPreview(paint as unknown as { patches?: { colors: string[] }[] });\n }\n if (paint.fill === 'conic-gradient') {\n // CSS starts a conic gradient at \"to top\"; the paint starts at +x.\n const from = (paint.angle * DEG + 90).toFixed(1);\n return `conic-gradient(from ${from}deg at ${pct(paint.center.x)} ${pct(paint.center.y)}, ${sampledStops(paint)})`;\n }\n return undefined;\n}\n"],"mappings":";;AAaA,IAAM,IAAU;AAYhB,SAAS,EAAY,GAAiE;CACpF,IAAM,IAAS,EAAM,UAAU,IAAI;AACnC,KAAI,CAAC,KAAU,EAAO,SAAS,EAAG;CAClC,IAAM,KAAQ,MAAsB,sBAAsB,EAAE,oBAKtD,IAAS;EAHb,CAAC,SAAS,EAAO,GAAG;EAAE,CAAC,WAAW,EAAO,GAAG;EAC5C,CAAC,aAAa,EAAO,GAAG;EAAE,CAAC,WAAW,EAAO,GAAG;EAEnC,CAAG,KAAK,CAAC,GAAK,OAC3B,sCAAsC,EAAI,IAAI,EAAE,IAAI,EAAK,EAAE,CAAC,GAAG;AAGjE,QADA,EAAO,KAAK,8BAA8B,EAAO,GAAG,IAAI,EAAO,GAAG,GAAG,EAC9D,EAAO,KAAK,KAAK;;AAI1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e) return !1;
|
|
4
|
+
let t = e;
|
|
5
|
+
return typeof t.fill == "string" || typeof t.color == "string";
|
|
6
|
+
}
|
|
7
|
+
function t(e) {
|
|
8
|
+
if (typeof e != "object" || !e) return;
|
|
9
|
+
let t = e;
|
|
10
|
+
if (!(t.fill !== void 0 && t.fill !== "solid")) return typeof t.color == "string" ? t.color : void 0;
|
|
11
|
+
}
|
|
12
|
+
function n(e) {
|
|
13
|
+
if (!(typeof e != "object" || !e || !("paint" in e))) return t(e.paint);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { t as n, n as r, e as t };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=paintValue-Bz6AVuh3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paintValue-Bz6AVuh3.js","names":[],"sources":["../../src/components/paintValue.ts"],"sourcesContent":["// Reading and writing the paint objects a property control may be pointed at.\n//\n// `data.fill` is a `FillStyle` and `data.stroke` a `Stroke`, so a control that\n// assumes either is a hex string reads `undefined` off it and writes a bare\n// string back over it. These helpers are what keep a control honest about the\n// shape it is holding.\n\n/** Whether a value is a `FillStyle` at all: an object naming a kind, or one\n * carrying a color, which is the solid member with its optional tag left off.\n * A pref's stored value is `unknown`, so this is what stands between a paint\n * control and a string someone saved there. */\nexport function isPaint(value: unknown): value is { fill?: string; color?: string } {\n if (typeof value !== 'object' || value === null) return false;\n const paint = value as { fill?: unknown; color?: unknown };\n return typeof paint.fill === 'string' || typeof paint.color === 'string';\n}\n\n/** The color of a solid paint, or `undefined` for anything else — including a\n * value that isn't a paint at all. `fill` is optional on the solid member of\n * the union, so the tag alone can't decide it. */\nexport function solidColorOf(value: unknown): string | undefined {\n if (typeof value !== 'object' || value === null) return undefined;\n const paint = value as { fill?: string; color?: unknown };\n if (paint.fill !== undefined && paint.fill !== 'solid') return undefined;\n return typeof paint.color === 'string' ? paint.color : undefined;\n}\n\n/** The single color a stroke shows, or `undefined` when it has none to show —\n * a gradient or pattern stroke, or no stroke at all. */\nexport function strokeColorOf(value: unknown): string | undefined {\n if (typeof value !== 'object' || value === null || !('paint' in value)) return undefined;\n return solidColorOf((value as { paint: unknown }).paint);\n}\n"],"mappings":";AAWA,SAAgB,EAAQ,GAA4D;AAClF,KAAI,OAAO,KAAU,aAAY,EAAgB,QAAO;CACxD,IAAM,IAAQ;AACd,QAAO,OAAO,EAAM,QAAS,YAAY,OAAO,EAAM,SAAU;;AAMlE,SAAgB,EAAa,GAAoC;AAC/D,KAAI,OAAO,KAAU,aAAY,EAAgB;CACjD,IAAM,IAAQ;AACV,SAAM,SAAS,KAAA,KAAa,EAAM,SAAS,SAC/C,QAAO,OAAO,EAAM,SAAU,WAAW,EAAM,QAAQ,KAAA;;AAKzD,SAAgB,EAAc,GAAoC;AAC5D,cAAO,KAAU,aAAY,KAAkB,EAAE,WAAW,IAChE,QAAO,EAAc,EAA6B,MAAM"}
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { a as e, t } from "./Icon-BW0qv_U7.js";
|
|
2
|
+
import { t as n } from "./paintValue-Bz6AVuh3.js";
|
|
3
|
+
import { isBuiltinToolPref as r } from "@weasel-js/core";
|
|
4
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
5
|
+
//#region src/components/Prefs/schema.ts
|
|
6
|
+
function a(e) {
|
|
7
|
+
if (!e.unit) return {
|
|
8
|
+
min: e.min,
|
|
9
|
+
max: e.max,
|
|
10
|
+
step: e.step ?? 1
|
|
11
|
+
};
|
|
12
|
+
let { toDisplay: t } = e.unit, n = e.min === void 0 ? void 0 : t(e.min), r = e.max === void 0 ? void 0 : t(e.max), i = n !== void 0 && r !== void 0 && n > r, a = e.step === void 0 ? 1 : Math.abs(t(e.step) - t(0)) || e.step;
|
|
13
|
+
return {
|
|
14
|
+
min: i ? r : n,
|
|
15
|
+
max: i ? n : r,
|
|
16
|
+
step: a
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function o(e) {
|
|
20
|
+
return e.suffix === void 0 ? { ...e.accepts } : {
|
|
21
|
+
[e.suffix]: 1,
|
|
22
|
+
...e.accepts
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function s(e) {
|
|
26
|
+
return "kind" in e;
|
|
27
|
+
}
|
|
28
|
+
function c(e, t) {
|
|
29
|
+
let n = e;
|
|
30
|
+
for (let e of t.split(".")) {
|
|
31
|
+
if (typeof n != "object" || !n) return;
|
|
32
|
+
n = n[e];
|
|
33
|
+
}
|
|
34
|
+
return n;
|
|
35
|
+
}
|
|
36
|
+
function l(e, t) {
|
|
37
|
+
if (s(e)) return e.hidden && !t ? null : e;
|
|
38
|
+
let n = e, r = {};
|
|
39
|
+
for (let [e, i] of Object.entries(n.children)) {
|
|
40
|
+
let n = l(i, t);
|
|
41
|
+
n && (r[e] = n);
|
|
42
|
+
}
|
|
43
|
+
return Object.keys(r).length === 0 ? null : {
|
|
44
|
+
...e,
|
|
45
|
+
children: r
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function u(e) {
|
|
49
|
+
if (s(e)) return 1;
|
|
50
|
+
let t = 0;
|
|
51
|
+
for (let n of Object.values(e.children)) t += u(n);
|
|
52
|
+
return t;
|
|
53
|
+
}
|
|
54
|
+
function d(e) {
|
|
55
|
+
let t = [], n = Object.values(e.children).filter(s).length;
|
|
56
|
+
n > 0 && t.push({
|
|
57
|
+
path: "",
|
|
58
|
+
name: e.name,
|
|
59
|
+
depth: 0,
|
|
60
|
+
section: "",
|
|
61
|
+
matches: n
|
|
62
|
+
});
|
|
63
|
+
for (let [n, r] of Object.entries(e.children)) if (!s(r)) {
|
|
64
|
+
t.push({
|
|
65
|
+
path: n,
|
|
66
|
+
name: r.name,
|
|
67
|
+
depth: 0,
|
|
68
|
+
section: n,
|
|
69
|
+
matches: u(r)
|
|
70
|
+
});
|
|
71
|
+
for (let [e, i] of Object.entries(r.children)) s(i) || t.push({
|
|
72
|
+
path: `${n}.${e}`,
|
|
73
|
+
name: i.name,
|
|
74
|
+
depth: 1,
|
|
75
|
+
section: n,
|
|
76
|
+
matches: u(i)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return t;
|
|
80
|
+
}
|
|
81
|
+
function f(e, t, n) {
|
|
82
|
+
return e.name.toLowerCase().includes(n) || e.description?.toLowerCase().includes(n) ? !0 : t.toLowerCase().includes(n);
|
|
83
|
+
}
|
|
84
|
+
function p(e, t, n = "") {
|
|
85
|
+
let r = t.trim().toLowerCase();
|
|
86
|
+
if (r === "") return e;
|
|
87
|
+
if (s(e)) return f(e, n, r) ? e : null;
|
|
88
|
+
let i = e;
|
|
89
|
+
if (i.name.toLowerCase().includes(r)) return e;
|
|
90
|
+
let a = {};
|
|
91
|
+
for (let [e, t] of Object.entries(i.children)) {
|
|
92
|
+
let i = p(t, r, n === "" ? e : `${n}.${e}`);
|
|
93
|
+
i && (a[e] = i);
|
|
94
|
+
}
|
|
95
|
+
return Object.keys(a).length === 0 ? null : {
|
|
96
|
+
...e,
|
|
97
|
+
children: a
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/components/Prefs/prefField.tsx
|
|
102
|
+
function m(e, t) {
|
|
103
|
+
let { value: i, mixed: s = !1, unset: c = !1, siblings: l, setValue: u } = t;
|
|
104
|
+
if (e.kind === "font-family") {
|
|
105
|
+
let e = t.fontVariant ? t.fontVariant.weight : l?.fontWeight, n = t.fontVariant ? t.fontVariant.style : l?.fontStyle;
|
|
106
|
+
return {
|
|
107
|
+
kind: "font-family",
|
|
108
|
+
value: typeof i == "string" ? i : void 0,
|
|
109
|
+
mixed: s,
|
|
110
|
+
unset: c,
|
|
111
|
+
onChange: u,
|
|
112
|
+
weight: typeof e == "number" ? e : void 0,
|
|
113
|
+
fontStyle: n === "italic" ? "italic" : void 0
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
if (!r(e)) return null;
|
|
117
|
+
switch (e.kind) {
|
|
118
|
+
case "boolean": return {
|
|
119
|
+
kind: "boolean",
|
|
120
|
+
control: e.control,
|
|
121
|
+
value: typeof i == "boolean" ? i : void 0,
|
|
122
|
+
mixed: s,
|
|
123
|
+
unset: c,
|
|
124
|
+
glyph: h(e.icon) ?? e.short,
|
|
125
|
+
onChange: u
|
|
126
|
+
};
|
|
127
|
+
case "number": {
|
|
128
|
+
let t = e.unit, n = typeof i == "number" && Number.isFinite(i) ? i : void 0, r = a(e), l = (e) => Math.min(r.max ?? Infinity, Math.max(r.min ?? -Infinity, e));
|
|
129
|
+
return {
|
|
130
|
+
kind: "number",
|
|
131
|
+
control: e.control,
|
|
132
|
+
value: n === void 0 ? void 0 : t ? t.toDisplay(n) : n,
|
|
133
|
+
mixed: s,
|
|
134
|
+
unset: c,
|
|
135
|
+
min: r.min,
|
|
136
|
+
max: r.max,
|
|
137
|
+
step: r.step,
|
|
138
|
+
unit: t?.suffix,
|
|
139
|
+
accepts: t ? o(t) : void 0,
|
|
140
|
+
notation: e.format,
|
|
141
|
+
onChange: (e) => u(t ? t.fromDisplay(l(e)) : l(e))
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
case "string": return {
|
|
145
|
+
kind: "string",
|
|
146
|
+
control: e.control,
|
|
147
|
+
value: typeof i == "string" ? i : "",
|
|
148
|
+
mixed: s,
|
|
149
|
+
unset: c,
|
|
150
|
+
onChange: u
|
|
151
|
+
};
|
|
152
|
+
case "enum": {
|
|
153
|
+
let t = e.encoding, n = t ? s ? void 0 : t.read(i, l) : s || c ? void 0 : typeof i == "string" ? i : e.default;
|
|
154
|
+
return {
|
|
155
|
+
kind: "enum",
|
|
156
|
+
control: e.control,
|
|
157
|
+
value: n,
|
|
158
|
+
mixed: s,
|
|
159
|
+
unset: c,
|
|
160
|
+
options: e.options.map((e) => ({
|
|
161
|
+
value: e.value,
|
|
162
|
+
label: e.label,
|
|
163
|
+
glyph: h(e.icon) ?? e.short,
|
|
164
|
+
disabled: e.disabled
|
|
165
|
+
})),
|
|
166
|
+
onChange: (e) => u(t ? t.write(e, l) : e)
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
case "color": return {
|
|
170
|
+
kind: "color",
|
|
171
|
+
value: typeof i == "string" ? i : e.default,
|
|
172
|
+
mixed: s,
|
|
173
|
+
unset: c,
|
|
174
|
+
alpha: e.alpha ? !0 : void 0,
|
|
175
|
+
onChange: u
|
|
176
|
+
};
|
|
177
|
+
case "paint": return {
|
|
178
|
+
kind: "paint",
|
|
179
|
+
value: i === null ? null : n(i) ? i : s ? void 0 : n(e.default) ? e.default : null,
|
|
180
|
+
mixed: s,
|
|
181
|
+
unset: c,
|
|
182
|
+
onChange: u
|
|
183
|
+
};
|
|
184
|
+
case "object": return null;
|
|
185
|
+
default: throw Error(`prefFieldProps: no control for built-in pref kind "${e.kind}"`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
function h(n) {
|
|
189
|
+
return n && n in e ? /* @__PURE__ */ i(t, {
|
|
190
|
+
name: n,
|
|
191
|
+
size: 14
|
|
192
|
+
}) : void 0;
|
|
193
|
+
}
|
|
194
|
+
//#endregion
|
|
195
|
+
export { d as a, a as i, p as n, c as o, s as r, l as s, m as t };
|
|
196
|
+
|
|
197
|
+
//# sourceMappingURL=prefField-CLkhrvYl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefField-CLkhrvYl.js","names":[],"sources":["../../src/components/Prefs/schema.ts","../../src/components/Prefs/prefField.tsx"],"sourcesContent":["// Preference-schema vocabulary for PrefsForm / PrefsDialog / SelectionPanel:\n// core's `ToolPref*` family under this package's names. Never re-declare them\n// here — this was a hand-kept structural copy until it drifted, and the\n// independence from `@weasel-js/core` it bought is long gone anyway.\n\nexport type {\n ToolPref as BuiltinPref,\n ToolPrefBoolean as PrefBoolean,\n ToolPrefBooleanControl as PrefBooleanControl,\n ToolPrefColor as PrefColor,\n ToolPrefCustom as PrefCustom,\n ToolPrefEnum as PrefEnum,\n ToolPrefEnumControl as PrefEnumControl,\n ToolPrefEnumEncoding as PrefEnumEncoding,\n ToolPrefGroup as PrefGroup,\n ToolPrefKind as PrefKind,\n ToolPrefLeaf as PrefLeaf,\n ToolPrefNumber as PrefNumber,\n ToolPrefNumberControl as PrefNumberControl,\n ToolPrefNumberFormat as PrefNumberFormat,\n ToolPrefNumberUnit as PrefNumberUnit,\n ToolPrefObject as PrefObject,\n ToolPrefPaint as PrefPaint,\n ToolPrefString as PrefString,\n ToolPrefStringControl as PrefStringControl,\n} from '@weasel-js/core';\n\nimport type { UnitTable } from '../../format/number';\nimport type { ToolPrefGroup, ToolPrefLeaf, ToolPrefNumber, ToolPrefNumberUnit as PrefNumberUnitType } from '@weasel-js/core';\n\n/**\n * A number leaf's bounds in the unit it is displayed in.\n *\n * Only what the leaf declares converts: an omitted bound has no stored\n * counterpart to put through the conversion, and its fallback — 0..100 for a\n * slider's track, a step of 1 — is a display-space number already. `min` and\n * `max` are points, so they convert the way the value does; `step` is a\n * distance, and a unit with an offset maps zero somewhere else, so converting\n * it as a point would scale it wrong. A decreasing conversion swaps which end\n * is the lower one.\n */\nexport function prefDisplayBounds(\n p: ToolPrefNumber,\n): { min?: number; max?: number; step: number } {\n if (!p.unit) return { min: p.min, max: p.max, step: p.step ?? 1 };\n const { toDisplay } = p.unit;\n const lo = p.min === undefined ? undefined : toDisplay(p.min);\n const hi = p.max === undefined ? undefined : toDisplay(p.max);\n const flipped = lo !== undefined && hi !== undefined && lo > hi;\n const step = p.step === undefined\n ? 1\n : Math.abs(toDisplay(p.step) - toDisplay(0)) || p.step;\n return { min: flipped ? hi : lo, max: flipped ? lo : hi, step };\n}\n\n/** What a unit leaf's field reads as typed text: its `accepts` table, and its\n * `suffix` as the display unit itself. */\nexport function prefUnitAccepts(unit: PrefNumberUnitType): Readonly<UnitTable> {\n return unit.suffix === undefined ? { ...unit.accepts } : { [unit.suffix]: 1, ...unit.accepts };\n}\n\n/** Distinguishes a leaf from a group while walking a schema tree. */\nexport function isPrefLeaf(node: ToolPrefLeaf | ToolPrefGroup): node is ToolPrefLeaf {\n return 'kind' in node;\n}\n\n/** Get the value at a dotted path inside a nested value tree. Returns\n * `undefined` when a segment is missing or hits a non-object. */\nexport function prefValueAtPath(values: unknown, path: string): unknown {\n let cur: unknown = values;\n for (const seg of path.split('.')) {\n if (cur == null || typeof cur !== 'object') return undefined;\n cur = (cur as Record<string, unknown>)[seg];\n }\n return cur;\n}\n\n/**\n * Recursively drop `hidden` leaves (unless `showHidden`), pruning groups\n * that end up empty. Returns null when the entire subtree is hidden.\n */\nexport function visiblePrefSubtree<T extends ToolPrefLeaf | ToolPrefGroup>(\n node: T,\n showHidden: boolean,\n): T | null {\n if (isPrefLeaf(node)) return node.hidden && !showHidden ? null : node;\n const group = node as ToolPrefGroup;\n const children: Record<string, ToolPrefLeaf | ToolPrefGroup> = {};\n for (const [key, child] of Object.entries(group.children)) {\n const kept = visiblePrefSubtree(child, showHidden);\n if (kept) children[key] = kept;\n }\n if (Object.keys(children).length === 0) return null;\n return { ...node, children };\n}\n\n/** One entry in a {@link PrefsForm} rail: a group the reader can navigate to. */\nexport interface PrefRailItem {\n /** Dotted path of the group. Empty for the entry holding loose root leaves. */\n path: string;\n name: string;\n /** 0 opens a pane; 1 scrolls within the open one. The rail goes no deeper. */\n depth: 0 | 1;\n /** Path of the depth-0 ancestor — its own path when `depth` is 0. */\n section: string;\n /** Leaves surviving the active filter, counted over the whole subtree. */\n matches: number;\n}\n\n/** Leaves anywhere under `node`, counted. */\nfunction countPrefLeaves(node: ToolPrefLeaf | ToolPrefGroup): number {\n if (isPrefLeaf(node)) return 1;\n let n = 0;\n for (const child of Object.values(node.children)) n += countPrefLeaves(child);\n return n;\n}\n\n/**\n * The rail's model for a schema: depth-0 groups, each followed by its depth-1\n * children. Deeper groups render inside a pane and get no entry — a schema\n * that nests ten deep still navigates two levels.\n *\n * Loose leaves directly under the root lead the list under an entry named for\n * the root itself, since they belong to no group that could name them.\n */\nexport function prefRailItems(root: ToolPrefGroup): PrefRailItem[] {\n const items: PrefRailItem[] = [];\n const loose = Object.values(root.children).filter(isPrefLeaf).length;\n if (loose > 0) {\n items.push({ path: '', name: root.name, depth: 0, section: '', matches: loose });\n }\n for (const [key, child] of Object.entries(root.children)) {\n if (isPrefLeaf(child)) continue;\n items.push({\n path: key,\n name: child.name,\n depth: 0,\n section: key,\n matches: countPrefLeaves(child),\n });\n for (const [subKey, sub] of Object.entries(child.children)) {\n if (isPrefLeaf(sub)) continue;\n items.push({\n path: `${key}.${subKey}`,\n name: sub.name,\n depth: 1,\n section: key,\n matches: countPrefLeaves(sub),\n });\n }\n }\n return items;\n}\n\n/** Whether one leaf answers to a filter query, by name, description or path. */\nfunction prefLeafMatches(pref: ToolPrefLeaf, path: string, query: string): boolean {\n if (pref.name.toLowerCase().includes(query)) return true;\n if (pref.description?.toLowerCase().includes(query)) return true;\n return path.toLowerCase().includes(query);\n}\n\n/**\n * Drop every leaf that does not answer to `query`, pruning groups left empty.\n * A group whose own name matches keeps all of its leaves — a reader who typed\n * the group's name is asking for the group, not for leaves repeating it.\n *\n * An empty or whitespace query matches everything, so a cleared field restores\n * the tree rather than emptying it.\n */\nexport function filterPrefSubtree<T extends ToolPrefLeaf | ToolPrefGroup>(\n node: T,\n query: string,\n path = '',\n): T | null {\n const q = query.trim().toLowerCase();\n if (q === '') return node;\n if (isPrefLeaf(node)) return prefLeafMatches(node, path, q) ? node : null;\n const group = node as ToolPrefGroup;\n if (group.name.toLowerCase().includes(q)) return node;\n const children: Record<string, ToolPrefLeaf | ToolPrefGroup> = {};\n for (const [key, child] of Object.entries(group.children)) {\n const kept = filterPrefSubtree(child, q, path === '' ? key : `${path}.${key}`);\n if (kept) children[key] = kept;\n }\n if (Object.keys(children).length === 0) return null;\n return { ...node, children };\n}\n","import type { ReactNode } from 'react';\nimport { isBuiltinToolPref, type FillStyle } from '@weasel-js/core';\nimport { Icon } from '../../icons/Icon';\nimport { ICON_PATHS, type IconName } from '../../icons/paths';\nimport { isPaint } from '../paintValue';\nimport type { PropertyControlProps } from '../Properties/PropertyField';\nimport { prefDisplayBounds, prefUnitAccepts, type PrefLeaf } from './schema';\n\n/** What {@link prefFieldProps} is told about one leaf's value. */\nexport interface PrefFieldState {\n /** The value held at the leaf. `undefined` when `mixed` or `unset`. */\n value: unknown;\n mixed?: boolean;\n unset?: boolean;\n /** The object the leaf is a field of, for an enum `encoding` and a font's\n * weight and slant. `undefined` for a top-level leaf. */\n siblings?: Record<string, unknown>;\n /** Writes a value in the leaf's stored form. */\n setValue: (value: unknown) => void;\n /** A font family's weight and slant, where they are not `siblings`' own\n * `fontWeight` / `fontStyle`. */\n fontVariant?: { weight?: unknown; style?: unknown };\n}\n\n/**\n * A schema leaf as {@link PropertyControl} props: its value, bounds and\n * options in the form it is shown in, and a writer that stores what the\n * control reports in the form the leaf holds.\n *\n * The conversions every schema-driven surface needs live here once — a\n * number's display unit and its bounds, an enum's `encoding`, a color's\n * alpha, an icon resolved to a glyph. A leaf that is not a single control —\n * an `object`, whose fields each are, or an app-defined kind — returns\n * `null`, and the surface draws it.\n *\n * Spread the result and add what the surface decides: `chrome`, `name`, a\n * class, a different default `control`.\n */\nexport function prefFieldProps(leaf: PrefLeaf, state: PrefFieldState): PropertyControlProps | null {\n const { value, mixed = false, unset = false, siblings, setValue } = state;\n if (leaf.kind === 'font-family') {\n const weight = state.fontVariant ? state.fontVariant.weight : siblings?.fontWeight;\n const style = state.fontVariant ? state.fontVariant.style : siblings?.fontStyle;\n return {\n kind: 'font-family',\n value: typeof value === 'string' ? value : undefined,\n mixed,\n unset,\n onChange: setValue,\n weight: typeof weight === 'number' ? weight : undefined,\n fontStyle: style === 'italic' ? 'italic' : undefined,\n };\n }\n if (!isBuiltinToolPref(leaf)) return null;\n switch (leaf.kind) {\n case 'boolean':\n return {\n kind: 'boolean',\n control: leaf.control,\n value: typeof value === 'boolean' ? value : undefined,\n mixed,\n unset,\n glyph: glyphOf(leaf.icon) ?? leaf.short,\n onChange: setValue,\n };\n case 'number': {\n const unit = leaf.unit;\n const stored = typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n // `min`/`max`/`step` are declared in the stored unit, like the value, so\n // they convert with it — a leaf storing radians and showing degrees was\n // clamping typed degrees against 0..6.28.\n const bounds = prefDisplayBounds(leaf);\n const clamp = (n: number) =>\n Math.min(bounds.max ?? Infinity, Math.max(bounds.min ?? -Infinity, n));\n const store = (shown: number) => setValue(unit ? unit.fromDisplay(clamp(shown)) : clamp(shown));\n return {\n kind: 'number',\n control: leaf.control,\n value: stored === undefined ? undefined : unit ? unit.toDisplay(stored) : stored,\n mixed,\n unset,\n min: bounds.min,\n max: bounds.max,\n step: bounds.step,\n unit: unit?.suffix,\n accepts: unit ? prefUnitAccepts(unit) : undefined,\n notation: leaf.format,\n onChange: store,\n };\n }\n case 'string':\n return {\n kind: 'string',\n control: leaf.control,\n value: typeof value === 'string' ? value : '',\n mixed,\n unset,\n onChange: setValue,\n };\n case 'enum': {\n const encoding = leaf.encoding;\n // An encoded leaf stores something other than the option string (a dash\n // array), so the option comes from the encoding — and an absent field is\n // one of the things it reads (no dash is `solid`), which is why `unset`\n // does not blank it.\n const option = encoding\n ? mixed\n ? undefined\n : encoding.read(value, siblings)\n : mixed || unset\n ? undefined\n : typeof value === 'string'\n ? value\n : leaf.default;\n return {\n kind: 'enum',\n control: leaf.control,\n value: option,\n mixed,\n unset,\n options: leaf.options.map((o) => ({\n value: o.value,\n label: o.label,\n glyph: glyphOf(o.icon) ?? o.short,\n disabled: o.disabled,\n })),\n onChange: (next: string) => setValue(encoding ? encoding.write(next, siblings) : next),\n };\n }\n case 'color':\n return {\n kind: 'color',\n value: typeof value === 'string' ? value : leaf.default,\n mixed,\n unset,\n alpha: leaf.alpha ? true : undefined,\n onChange: setValue,\n };\n case 'paint': {\n // `??` would read an explicit `null` — \"no paint\" — as absent and show\n // the default over it. Unset shows the fallback actually in effect,\n // dimmed by the control: true, but not chosen.\n const paint =\n value === null\n ? null\n : isPaint(value)\n ? value\n : mixed\n ? undefined\n : isPaint(leaf.default)\n ? leaf.default\n : null;\n return {\n kind: 'paint',\n value: paint as FillStyle | null | undefined,\n mixed,\n unset,\n onChange: setValue,\n };\n }\n case 'object':\n return null;\n default: {\n // Not reachable while every built-in kind has an arm — and a new kind\n // that lacks one is a compile error here, never a blank row.\n const _exhaustive: never = leaf;\n throw new Error(\n `prefFieldProps: no control for built-in pref kind \"${(_exhaustive as { kind: string }).kind}\"`,\n );\n }\n }\n}\n\n/** A leaf's `icon` as a glyph, where the kit's icon set has it. */\nfunction glyphOf(icon: string | undefined): ReactNode {\n return icon && icon in ICON_PATHS ? <Icon name={icon as IconName} size={14} /> : undefined;\n}\n"],"mappings":";;;;;AAyCA,SAAgB,EACd,GAC8C;AAC9C,KAAI,CAAC,EAAE,KAAM,QAAO;EAAE,KAAK,EAAE;EAAK,KAAK,EAAE;EAAK,MAAM,EAAE,QAAQ;EAAG;CACjE,IAAM,EAAE,iBAAc,EAAE,MAClB,IAAK,EAAE,QAAQ,KAAA,IAAY,KAAA,IAAY,EAAU,EAAE,IAAI,EACvD,IAAK,EAAE,QAAQ,KAAA,IAAY,KAAA,IAAY,EAAU,EAAE,IAAI,EACvD,IAAU,MAAO,KAAA,KAAa,MAAO,KAAA,KAAa,IAAK,GACvD,IAAO,EAAE,SAAS,KAAA,IACpB,IACA,KAAK,IAAI,EAAU,EAAE,KAAK,GAAG,EAAU,EAAE,CAAC,IAAI,EAAE;AACpD,QAAO;EAAE,KAAK,IAAU,IAAK;EAAI,KAAK,IAAU,IAAK;EAAI;EAAM;;AAKjE,SAAgB,EAAgB,GAA+C;AAC7E,QAAO,EAAK,WAAW,KAAA,IAAY,EAAE,GAAG,EAAK,SAAS,GAAG;GAAG,EAAK,SAAS;EAAG,GAAG,EAAK;EAAS;;AAIhG,SAAgB,EAAW,GAA0D;AACnF,QAAO,UAAU;;AAKnB,SAAgB,EAAgB,GAAiB,GAAuB;CACtE,IAAI,IAAe;AACnB,MAAK,IAAM,KAAO,EAAK,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,EAAS,GAAG,EAAK;IACvF;;EAEH,KAAK,QACH,QAAO;GACL,MAAM;GACN,OAAO,OAAO,KAAU,WAAW,IAAQ,EAAK;GAChD;GACA;GACA,OAAO,EAAK,QAAQ,KAAO,KAAA;GAC3B,UAAU;GACX;EACH,KAAK,QAcH,QAAO;GACL,MAAM;GACN,OAXA,MAAU,OACN,OACA,EAAQ,EAAM,GACZ,IACA,IACE,KAAA,IACA,EAAQ,EAAK,QAAQ,GACnB,EAAK,UACL;GAIV;GACA;GACA,UAAU;GACX;EAEH,KAAK,SACH,QAAO;EACT,QAIE,OAAU,MACR,sDAAuD,EAAiC,KAAK,GAC9F;;;AAMP,SAAS,EAAQ,GAAqC;AACpD,QAAO,KAAQ,KAAQ,IAAa,kBAAC,GAAD;EAAM,MAAM;EAAkB,MAAM;EAAM,CAAA,GAAG,KAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { n as e, r as t } from "./Tooltip-9XiJF937.js";
|
|
2
|
+
import { jsx as n, jsxs as r } from "react/jsx-runtime";
|
|
3
|
+
import { Focusable as i } from "react-aria-components";
|
|
4
|
+
//#region src/components/segmentTooltip.tsx
|
|
5
|
+
function a(e) {
|
|
6
|
+
if (e.tooltip !== void 0) return e.tooltip;
|
|
7
|
+
if (!e.shortcut) return;
|
|
8
|
+
let t = e.ariaLabel ?? (typeof e.label == "string" ? e.label : void 0);
|
|
9
|
+
return t ? `${t} (${e.shortcut})` : e.shortcut;
|
|
10
|
+
}
|
|
11
|
+
function o({ content: a, disabled: o, children: s }) {
|
|
12
|
+
return a == null || a === !1 ? s : /* @__PURE__ */ r(t, {
|
|
13
|
+
isDisabled: o,
|
|
14
|
+
children: [/* @__PURE__ */ n(i, {
|
|
15
|
+
isDisabled: o,
|
|
16
|
+
children: s
|
|
17
|
+
}), /* @__PURE__ */ n(e, { children: a })]
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function s({ content: i, disabled: a, children: o }) {
|
|
21
|
+
return i == null || i === !1 ? o : /* @__PURE__ */ r(t, {
|
|
22
|
+
isDisabled: a,
|
|
23
|
+
children: [o, /* @__PURE__ */ n(e, { children: i })]
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { s as n, a as r, o as t };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=segmentTooltip-CAkZlW-t.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segmentTooltip-CAkZlW-t.js","names":[],"sources":["../../src/components/segmentTooltip.tsx"],"sourcesContent":["import type { DOMAttributes, ReactElement, ReactNode } from 'react';\nimport { Focusable } from 'react-aria-components';\nimport { Tooltip, TooltipTrigger } from './Tooltip';\n\n/** The tooltip fields a segmented bar's item carries. */\nexport interface SegmentTooltipFields {\n /** Tooltip content. Overrides the name-plus-`shortcut` default. */\n tooltip?: ReactNode;\n /** Shortcut hint shown in the tooltip as `Name (⌘Z)`, the way `ToolButton`\n * and `ActionBar` show theirs. The name is `ariaLabel`, else a string\n * `label`. */\n shortcut?: string;\n}\n\n/** Tooltip content for an item, or `undefined` for none. */\nexport function segmentTooltipContent(\n item: SegmentTooltipFields & { label?: ReactNode; ariaLabel?: string },\n): ReactNode | undefined {\n if (item.tooltip !== undefined) return item.tooltip;\n if (!item.shortcut) return undefined;\n const name = item.ariaLabel ?? (typeof item.label === 'string' ? item.label : undefined);\n return name ? `${name} (${item.shortcut})` : item.shortcut;\n}\n\n/** Wraps a segment's `<button>` in a kit tooltip when there is content for one. */\nexport function SegmentTooltip({ content, disabled, children }: {\n content: ReactNode | undefined;\n disabled?: boolean;\n children: ReactElement<DOMAttributes<HTMLButtonElement>, 'button'>;\n}): ReactElement {\n if (content === undefined || content === null || content === false) return children;\n return (\n <TooltipTrigger isDisabled={disabled}>\n <Focusable isDisabled={disabled}>{children}</Focusable>\n <Tooltip>{content}</Tooltip>\n </TooltipTrigger>\n );\n}\n\n/** {@link SegmentTooltip} for a React Aria trigger (`Button` inside a\n * `MenuTrigger` or `Select`), which takes the tooltip's hover and focus props\n * itself and so needs no `Focusable` around it. */\nexport function TriggerTooltip({ content, disabled, children }: {\n content: ReactNode | undefined;\n disabled?: boolean;\n children: ReactElement;\n}): ReactElement {\n if (content === undefined || content === null || content === false) return children;\n return (\n <TooltipTrigger isDisabled={disabled}>\n {children}\n <Tooltip>{content}</Tooltip>\n </TooltipTrigger>\n );\n}\n"],"mappings":";;;;AAeA,SAAgB,EACd,GACuB;AACvB,KAAI,EAAK,YAAY,KAAA,EAAW,QAAO,EAAK;AAC5C,KAAI,CAAC,EAAK,SAAU;CACpB,IAAM,IAAO,EAAK,cAAc,OAAO,EAAK,SAAU,WAAW,EAAK,QAAQ,KAAA;AAC9E,QAAO,IAAO,GAAG,EAAK,IAAI,EAAK,SAAS,KAAK,EAAK;;AAIpD,SAAgB,EAAe,EAAE,YAAS,aAAU,eAInC;AAEf,QADI,KAAqC,QAAQ,MAAY,KAAc,IAEzE,kBAAC,GAAD;EAAgB,YAAY;YAA5B,CACE,kBAAC,GAAD;GAAW,YAAY;GAAW;GAAqB,CAAA,EACvD,kBAAC,GAAD,EAAA,UAAU,GAAkB,CAAA,CACb;;;AAOrB,SAAgB,EAAe,EAAE,YAAS,aAAU,eAInC;AAEf,QADI,KAAqC,QAAQ,MAAY,KAAc,IAEzE,kBAAC,GAAD;EAAgB,YAAY;YAA5B,CACG,GACD,kBAAC,GAAD,EAAA,UAAU,GAAkB,CAAA,CACb"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var e = {
|
|
2
|
+
root: "_root_4jvk7_10",
|
|
3
|
+
segment: "_segment_4jvk7_32",
|
|
4
|
+
segmentSelected: "_segmentSelected_4jvk7_81",
|
|
5
|
+
size_sm: "_size_sm_4jvk7_139",
|
|
6
|
+
variant_minimal: "_variant_minimal_4jvk7_152"
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { e as t };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=segmentedControl.module-D2nw68Yo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segmentedControl.module-D2nw68Yo.js","names":[],"sources":["../../src/components/segmentedControl.module.css"],"sourcesContent":["/* Shared by ButtonBar and OptionsBar, which look identical and differ only\n in what a segment does. Lives here rather than in either component so\n neither owns the other's styling.\n\n Aqua-glass segmented control. The track is a pill-shaped well; the\n selected segment becomes a tinted glass cylinder that reads as the same\n \"lozenge\" family as the standalone Button. Visual params come from the\n `--btn-*` custom properties (see Button.module.css) so the Button Lab\n can tune both surfaces with one set of sliders. */\n.root {\n display: inline-flex;\n height: var(--tb-h, var(--wzl-control-h, 24px));\n padding: var(--wzl-space-1);\n background: linear-gradient(\n 180deg,\n rgba(0, 0, 0, 0.18) 0%,\n rgba(0, 0, 0, 0.05) 100%\n );\n border-radius: var(--wzl-radius-pill);\n /* Clip segments to the track outline so interior corners read crisp and\n the selected segment's glass treatment doesn't paint over the rounded\n outer pixels. */\n overflow: hidden;\n box-shadow:\n inset 0 1px 2px rgba(0, 0, 0, 0.4),\n 0 1px 0 rgba(255, 255, 255, 0.06);\n user-select: none;\n -webkit-user-select: none;\n touch-action: none;\n}\n\n.segment {\n position: relative;\n flex: 1 1 0;\n min-width: 0;\n /* The track's stretch sizes a segment; without this, labkit's :where(button) height wins and overflows a small bar. */\n height: auto;\n padding: 0 var(--wzl-space-6);\n display: inline-flex;\n align-items: center;\n justify-content: center;\n background: transparent;\n border: none;\n margin: 0;\n font-family: var(--wzl-font-ui);\n font-weight: var(--wzl-font-weight-normal);\n font-size: var(--btn-fontsize, var(--wzl-font-size));\n line-height: 1;\n color: var(--wzl-fg-muted);\n cursor: pointer;\n /* Only round the outer corners of the bar — middle segments stay square\n so the seams between them don't render as facing parentheses. */\n border-radius: 0;\n isolation: isolate;\n overflow: hidden;\n transition: color var(--wzl-motion-fast);\n}\n\n.segment:first-child {\n border-radius: var(--wzl-radius-pill) 0 0 var(--wzl-radius-pill);\n}\n\n.segment:last-child {\n border-radius: 0 var(--wzl-radius-pill) var(--wzl-radius-pill) 0;\n}\n\n.segment:only-child {\n border-radius: var(--wzl-radius-pill);\n}\n\n.segment:focus-visible {\n outline: 2px solid var(--wzl-accent);\n outline-offset: -2px;\n}\n\n.segment:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.segment:hover:not(:disabled):not(.segmentSelected) {\n color: var(--wzl-fg);\n}\n\n/* Selected segment — full Aqua glass cylinder. Mirrors Button.variant_primary. */\n.segmentSelected {\n background: linear-gradient(\n 180deg,\n color-mix(in srgb, var(--wzl-accent) var(--btn-top-alpha, 45%), transparent) 0%,\n color-mix(in srgb, var(--wzl-accent) var(--btn-upper-alpha, 70%), transparent) calc(var(--btn-equator, 52%) - var(--btn-equator-spread, 12%)),\n color-mix(in srgb, var(--wzl-accent) var(--btn-equator-tint, 95%), white) var(--btn-equator, 52%),\n var(--wzl-accent) calc(var(--btn-equator, 52%) + var(--btn-equator-spread, 12%) * 1.6),\n color-mix(in srgb, var(--wzl-accent) var(--btn-base-tint, 70%), black) 100%\n );\n backdrop-filter: blur(var(--btn-blur, 6px)) saturate(var(--btn-saturate, 1.3));\n -webkit-backdrop-filter: blur(var(--btn-blur, 6px)) saturate(var(--btn-saturate, 1.3));\n color: var(--wzl-fg-on-accent);\n text-shadow:\n 0 1px 0 rgba(0, 0, 0, var(--btn-text-shadow, 0.35)),\n var(--btn-text-inset-x, 0px) var(--btn-text-inset-y, 1px) 0 rgba(0, 0, 0, var(--btn-text-inset, 0.55)),\n 0 0 6px rgba(0, 0, 0, calc(var(--btn-text-shadow, 0.35) * 0.5));\n box-shadow:\n inset 0 1px 0 rgba(255, 255, 255, var(--btn-inset-hi, 0.42)),\n inset 0 -1px 2px rgba(0, 0, 0, var(--btn-inset-lo, 0.3)),\n 0 0 0 1px rgba(0, 0, 0, var(--btn-rim, 0.22)),\n 0 1px 2px rgba(0, 0, 0, var(--btn-drop-near, 0.3)),\n 0 2px 4px rgba(0, 0, 0, calc(var(--btn-drop-far, 0.18) * 0.8));\n}\n\n/* Specular gloss on the selected segment. Top corners inherit the\n segment's radius so they hug the upper edge cleanly; bottom corners\n are flattened so the gloss ends in a straight line at the equator\n instead of two little curves that read as `)(` brackets. */\n.segmentSelected::before {\n content: '';\n position: absolute;\n inset: 1px 1px var(--btn-gloss-bottom, 50%) 1px;\n border-radius: inherit;\n border-bottom-left-radius: 0;\n border-bottom-right-radius: 0;\n background: linear-gradient(\n 180deg,\n rgba(255, 255, 255, var(--btn-gloss-top, 0.42)) 0%,\n rgba(255, 255, 255, var(--btn-gloss-mid, 0.12)) 60%,\n rgba(255, 255, 255, 0) 100%\n );\n pointer-events: none;\n z-index: 1;\n}\n\n.segmentSelected > * {\n position: relative;\n z-index: 2;\n}\n\n/* Small variant — ~60% of the default height, with proportionally reduced\n padding and font. Sized for dense surfaces (lab control panels, inline\n filters, etc.). */\n.size_sm {\n height: 17px;\n padding: 1px;\n}\n\n.size_sm .segment {\n padding: 0 var(--wzl-space-4);\n font-size: var(--wzl-font-size-sm);\n}\n\n/* Minimal variant — strips the pill track, glass selected state, inset\n shadows, and outer padding. Used in dense diagnostic surfaces (dispatch\n trace, lab inspectors) where the bar must read as plain text controls. */\n.variant_minimal {\n height: auto;\n padding: 0;\n background: none;\n border-radius: 0;\n box-shadow: none;\n gap: var(--wzl-space-1);\n}\n\n.variant_minimal .segment {\n padding: 0 var(--wzl-space-2);\n font-size: var(--wzl-font-size-sm);\n font-weight: var(--wzl-font-weight-medium);\n line-height: 1.4;\n border-radius: var(--wzl-radius-sm);\n color: var(--wzl-fg-muted);\n transition: none;\n}\n\n.variant_minimal .segment:first-child,\n.variant_minimal .segment:last-child,\n.variant_minimal .segment:only-child {\n border-radius: var(--wzl-radius-sm);\n}\n\n.variant_minimal .segment:hover:not(:disabled):not(.segmentSelected) {\n color: var(--wzl-fg);\n background: var(--wzl-surface-hover);\n}\n\n.variant_minimal .segmentSelected {\n background: none;\n backdrop-filter: none;\n -webkit-backdrop-filter: none;\n color: var(--wzl-accent-fg, var(--wzl-accent));\n text-shadow: none;\n box-shadow: none;\n font-weight: var(--wzl-font-weight-medium);\n}\n\n.variant_minimal .segmentSelected::before {\n content: none;\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snap-
|
|
1
|
+
{"version":3,"file":"snap-DC4Km8xG.js","names":[],"sources":["../../src/snap.ts"],"sourcesContent":["/** How close, in screen pixels, a drag has to come to a candidate to snap to it. */\nexport const SNAP_RADIUS_PX = 6;\n\n/** Snap `value` to the nearest candidate within `tolerance`, else return it. */\nexport function snapToNearest(value: number, candidates: readonly number[], tolerance: number): number {\n let best = value;\n let bestDist = tolerance;\n for (const c of candidates) {\n const d = Math.abs(c - value);\n if (d <= bestDist) {\n best = c;\n bestDist = d;\n }\n }\n return best;\n}\n"],"mappings":";AAIA,SAAgB,EAAc,GAAe,GAA+B,GAA2B;CACrG,IAAI,IAAO,GACP,IAAW;AACf,MAAK,IAAM,KAAK,GAAY;EAC1B,IAAM,IAAI,KAAK,IAAI,IAAI,EAAM;AAC7B,EAAI,KAAK,MACP,IAAO,GACP,IAAW;;AAGf,QAAO"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { colorCssAt as e } from "@weasel-js/theme";
|
|
2
|
+
import { useTones as t } from "@weasel-js/theme/react";
|
|
3
|
+
//#region src/components/stance.ts
|
|
4
|
+
function n({ stance: n, tone: r }) {
|
|
5
|
+
let i = t();
|
|
6
|
+
if (n === void 0 && r === void 0) return {};
|
|
7
|
+
let a = r === void 0 ? void 0 : typeof r == "number" ? e(i.tones, r, i) : r;
|
|
8
|
+
return {
|
|
9
|
+
"data-stance": n,
|
|
10
|
+
"data-tone": r === void 0 ? void 0 : String(r),
|
|
11
|
+
style: a === void 0 ? void 0 : { "--wzl-tone": a }
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { n as t };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=stance-CarrcbbP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stance-CarrcbbP.js","names":[],"sources":["../../src/components/stance.ts"],"sourcesContent":["import { colorCssAt, type Stance } from '@weasel-js/theme';\nimport { useTones } from '@weasel-js/theme/react';\nimport type { CSSProperties } from 'react';\n\nexport type { Stance } from '@weasel-js/theme';\n\n/**\n * What a surface holds, and which of its peers it is. Every surface that takes\n * these takes both, and the theme decides how each looks.\n */\nexport interface StanceProps {\n /** The class of content the surface holds. Omitted, it draws as it always has. */\n stance?: Stance;\n /**\n * Which of its peers this is: an index into the theme's tone list, wrapping,\n * or a color given directly. Independent of `stance`, and allowed without one.\n */\n tone?: number | string;\n}\n\n/** The attributes a stanced surface renders, and the style carrying its resolved tone. */\nexport interface StanceAttrs {\n 'data-stance'?: Stance;\n 'data-tone'?: string;\n style?: CSSProperties;\n}\n\n/**\n * Resolves `stance` and `tone` for a surface's root element. The tone is\n * written inline as `--wzl-tone`; a tone-list index resolves through the nearest\n * `<ThemeProvider>`'s tones, as a custom-property reference where the list is\n * a theme ramp, so it follows the mode without a re-render.\n */\nexport function useStance({ stance, tone }: StanceProps): StanceAttrs {\n const ctx = useTones();\n if (stance === undefined && tone === undefined) return {};\n const color = tone === undefined ? undefined : typeof tone === 'number' ? colorCssAt(ctx.tones, tone, ctx) : tone;\n return {\n 'data-stance': stance,\n 'data-tone': tone === undefined ? undefined : String(tone),\n style: color === undefined ? undefined : ({ '--wzl-tone': color } as CSSProperties),\n };\n}\n"],"mappings":";;;AAiCA,SAAgB,EAAU,EAAE,WAAQ,WAAkC;CACpE,IAAM,IAAM,GAAU;AACtB,KAAI,MAAW,KAAA,KAAa,MAAS,KAAA,EAAW,QAAO,EAAE;CACzD,IAAM,IAAQ,MAAS,KAAA,IAAY,KAAA,IAAY,OAAO,KAAS,WAAW,EAAW,EAAI,OAAO,GAAM,EAAI,GAAG;AAC7G,QAAO;EACL,eAAe;EACf,aAAa,MAAS,KAAA,IAAY,KAAA,IAAY,OAAO,EAAK;EAC1D,OAAO,MAAU,KAAA,IAAY,KAAA,IAAa,EAAE,cAAc,GAAO;EAClE"}
|