@weasel-js/ui 1.5.1 → 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-Bf8Rd1R6.js → Badge-DZ0lFs14.js} +755 -738
- package/dist/chunks/Badge-DZ0lFs14.js.map +1 -0
- package/dist/chunks/{BandEditor-D8I5Uun-.js → BandEditor-D-nVrVO4.js} +44 -44
- package/dist/chunks/BandEditor-D-nVrVO4.js.map +1 -0
- 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-BZZsPaVF.js → Checkbox-ChZz30Ds.js} +5 -5
- package/dist/chunks/Checkbox-ChZz30Ds.js.map +1 -0
- package/dist/chunks/Code-v4tDWuuN.js +24 -0
- package/dist/chunks/Code-v4tDWuuN.js.map +1 -0
- package/dist/chunks/{ColorField-YVf8irfr.js → ColorField-DJSCuSJv.js} +15 -15
- package/dist/chunks/{ColorField-YVf8irfr.js.map → ColorField-DJSCuSJv.js.map} +1 -1
- package/dist/chunks/ColorModeControl-JOEiqtE0.js +47 -0
- package/dist/chunks/ColorModeControl-JOEiqtE0.js.map +1 -0
- package/dist/chunks/{ComboBox-D57tNYDD.js → ComboBox-C1JgIpML.js} +13 -13
- package/dist/chunks/ComboBox-C1JgIpML.js.map +1 -0
- package/dist/chunks/{CurveEditor-BXiMoN9d.js → CurveEditor-f1R4kSbD.js} +2 -2
- package/dist/chunks/{CurveEditor-BXiMoN9d.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-BWNSv07Z.js → DetentSlider-BYyaZha6.js} +2 -2
- package/dist/chunks/{DetentSlider-BWNSv07Z.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-BNqvUJfg.js → Field-xbqRmjsI.js} +6 -6
- package/dist/chunks/Field-xbqRmjsI.js.map +1 -0
- package/dist/chunks/FillStrokeSwatch-BViKXIPx.js +111 -0
- package/dist/chunks/FillStrokeSwatch-BViKXIPx.js.map +1 -0
- package/dist/chunks/{FontFamilySelect-CO19kyOO.js → FontFamilySelect-r9TV_xIH.js} +2 -2
- package/dist/chunks/{FontFamilySelect-CO19kyOO.js.map → FontFamilySelect-r9TV_xIH.js.map} +1 -1
- package/dist/chunks/GradientEditor-BRTxHG-W.js +333 -0
- package/dist/chunks/GradientEditor-BRTxHG-W.js.map +1 -0
- package/dist/chunks/{Icon-QhLhaGFe.js → Icon-BW0qv_U7.js} +50 -21
- 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-B9Vh7ASP.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-BYrxbAQU.js → Jog-LPoac9s4.js} +10 -10
- package/dist/chunks/Jog-LPoac9s4.js.map +1 -0
- package/dist/chunks/{Keycaps-CGNQV2Pz.js → Keycaps-CKiKOJnJ.js} +75 -69
- 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-CQzS6TjF.js → NumberField-C1Y7zP-a.js} +27 -22
- package/dist/chunks/NumberField-C1Y7zP-a.js.map +1 -0
- package/dist/chunks/{OptionsBar-BWaYG_OH.js → OptionsBar-DlcagPYK.js} +3 -3
- package/dist/chunks/{OptionsBar-BWaYG_OH.js.map → OptionsBar-DlcagPYK.js.map} +1 -1
- package/dist/chunks/{PaintField-BVYMu3OI.js → PaintField-B2mLRZa4.js} +20 -20
- package/dist/chunks/PaintField-B2mLRZa4.js.map +1 -0
- package/dist/chunks/{PaintInput-BzAHCKro.js → PaintInput-BFKhd83I.js} +27 -27
- package/dist/chunks/PaintInput-BFKhd83I.js.map +1 -0
- package/dist/chunks/{PatternPicker-C4OryrYi.js → PatternPicker-DdfpxoQy.js} +6 -6
- package/dist/chunks/PatternPicker-DdfpxoQy.js.map +1 -0
- package/dist/chunks/{Plot2D-Czvyt_vG.js → Plot2D-lyO7waPQ.js} +1 -1
- package/dist/chunks/{Plot2D-Czvyt_vG.js.map → Plot2D-lyO7waPQ.js.map} +1 -1
- package/dist/chunks/{PointPlotter-Xvb98GwB.js → PointPlotter-DGs9i5P-.js} +2 -2
- package/dist/chunks/{PointPlotter-Xvb98GwB.js.map → PointPlotter-DGs9i5P-.js.map} +1 -1
- package/dist/chunks/{Powerline-B_EH-7Z-.js → Powerline-DBEPceLE.js} +7 -5
- 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-C6xpdQNg.js → RadioGroup-BK2mD6Q0.js} +6 -6
- package/dist/chunks/RadioGroup-BK2mD6Q0.js.map +1 -0
- package/dist/chunks/{RangeSlider-CzgeGLVS.js → RangeSlider-BiRAOsTh.js} +8 -8
- package/dist/chunks/RangeSlider-BiRAOsTh.js.map +1 -0
- package/dist/chunks/{ResizeHandle-1Ey8AOij.js → ResizeHandle-Cc6EOehs.js} +9 -9
- package/dist/chunks/{ResizeHandle-1Ey8AOij.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-C5LmZA7b.js +103 -0
- package/dist/chunks/SelectionPanel-C5LmZA7b.js.map +1 -0
- package/dist/chunks/{Sidebar-BlUjn8lD.js → Sidebar-DKKd4R-x.js} +4 -4
- package/dist/chunks/Sidebar-DKKd4R-x.js.map +1 -0
- package/dist/chunks/{SidebarPanel-BqHfz6VK.js → SidebarPanel-u5NsuAZY.js} +15 -19
- package/dist/chunks/SidebarPanel-u5NsuAZY.js.map +1 -0
- package/dist/chunks/{Slider-B2ywUZH6.js → Slider-BwRrWHFW.js} +58 -58
- package/dist/chunks/Slider-BwRrWHFW.js.map +1 -0
- package/dist/chunks/{StatusBar-BFt7Yw5O.js → StatusBar-CdPdmmda.js} +6 -6
- package/dist/chunks/StatusBar-CdPdmmda.js.map +1 -0
- package/dist/chunks/SwatchGrid-C-Zx2Exd.js +73 -0
- package/dist/chunks/SwatchGrid-C-Zx2Exd.js.map +1 -0
- package/dist/chunks/{Switch-Om3t3ASc.js → Switch-DxF7TsEu.js} +5 -5
- package/dist/chunks/Switch-DxF7TsEu.js.map +1 -0
- package/dist/chunks/{Tabs-EAvYywil.js → Tabs-GXEfoe3o.js} +5 -5
- package/dist/chunks/Tabs-GXEfoe3o.js.map +1 -0
- package/dist/chunks/{Timeline-BEyKaBXl.js → Timeline-SgmpQtUV.js} +128 -132
- package/dist/chunks/Timeline-SgmpQtUV.js.map +1 -0
- package/dist/chunks/{Toast-iqLDD_XZ.js → Toast-BfcljZz6.js} +15 -15
- package/dist/chunks/Toast-BfcljZz6.js.map +1 -0
- package/dist/chunks/ToggleBar-Btnl5r7F.js +80 -0
- package/dist/chunks/ToggleBar-Btnl5r7F.js.map +1 -0
- package/dist/chunks/TokenPanel-5ajHEHha.js +634 -0
- package/dist/chunks/TokenPanel-5ajHEHha.js.map +1 -0
- package/dist/chunks/{ToolButton-Dd-1T5aX.js → ToolButton-rzqlFlAc.js} +9 -9
- package/dist/chunks/ToolButton-rzqlFlAc.js.map +1 -0
- package/dist/chunks/{ToolGroup-BBI-W-Gm.js → ToolGroup-4bUBV5k6.js} +3 -3
- package/dist/chunks/ToolGroup-4bUBV5k6.js.map +1 -0
- package/dist/chunks/ToolOptionsBar-BF3TNXA3.js +85 -0
- package/dist/chunks/ToolOptionsBar-BF3TNXA3.js.map +1 -0
- package/dist/chunks/ToolPalette-Uw4PvWwa.js +83 -0
- package/dist/chunks/ToolPalette-Uw4PvWwa.js.map +1 -0
- package/dist/chunks/Tooltip-9XiJF937.js +42 -0
- 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-7j7ukrSx.js → createKeyframeLayer-BzDRCrrh.js} +71 -71
- package/dist/chunks/{createKeyframeLayer-7j7ukrSx.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-6S8IzXVt.js +89 -0
- 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-B0WQwetQ.js → snap-DC4Km8xG.js} +1 -1
- package/dist/chunks/{snap-B0WQwetQ.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/oklch.d.ts +2 -1
- package/dist/color/oklch.d.ts.map +1 -1
- 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/UnitField.d.ts +2 -1
- package/dist/components/NumberField/UnitField.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 +32 -1
- 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 +18 -3
- package/dist/components/Properties/PropertyGroup.d.ts.map +1 -1
- package/dist/components/Properties/PropertyPanel.d.ts +50 -256
- 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 -6
- 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 +56 -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/SelectionPanel.d.ts +3 -50
- package/dist/components/SelectionPanel/SelectionPanel.d.ts.map +1 -1
- package/dist/components/SelectionPanel/index.js +3 -2
- package/dist/components/SelectionPanel/model.d.ts +4 -1
- package/dist/components/SelectionPanel/model.d.ts.map +1 -1
- package/dist/components/SelectionPanel/renderLeaf.d.ts +112 -0
- package/dist/components/SelectionPanel/renderLeaf.d.ts.map +1 -0
- 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/TokenPanel.d.ts +10 -4
- package/dist/components/TokenPanel/TokenPanel.d.ts.map +1 -1
- package/dist/components/TokenPanel/index.d.ts +2 -2
- package/dist/components/TokenPanel/index.d.ts.map +1 -1
- package/dist/components/TokenPanel/index.js +2 -2
- package/dist/components/TokenPanel/tokenTypes.d.ts +24 -0
- package/dist/components/TokenPanel/tokenTypes.d.ts.map +1 -1
- package/dist/components/ToolButton/index.js +1 -1
- package/dist/components/ToolGroup/index.js +1 -1
- package/dist/components/ToolOptionsBar/ToolOptionsBar.d.ts +29 -18
- package/dist/components/ToolOptionsBar/ToolOptionsBar.d.ts.map +1 -1
- package/dist/components/ToolOptionsBar/index.js +1 -1
- package/dist/components/ToolPalette/ToolPalette.d.ts +5 -4
- package/dist/components/ToolPalette/ToolPalette.d.ts.map +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 +13 -3
- 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 +11 -1
- 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 -84
- 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 +8 -6
- package/dist/useRovingTabIndex.d.ts.map +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-GZdcfdQL.js +0 -62
- package/dist/chunks/ActionBar-GZdcfdQL.js.map +0 -1
- package/dist/chunks/ActionsBar-Fhx_40iP.js +0 -41
- package/dist/chunks/ActionsBar-Fhx_40iP.js.map +0 -1
- package/dist/chunks/Badge-Bf8Rd1R6.js.map +0 -1
- package/dist/chunks/BandEditor-D8I5Uun-.js.map +0 -1
- package/dist/chunks/Button-CExdkQcU.js +0 -90
- package/dist/chunks/Button-CExdkQcU.js.map +0 -1
- package/dist/chunks/Callout-cx5_CWcW.js +0 -122
- package/dist/chunks/Callout-cx5_CWcW.js.map +0 -1
- package/dist/chunks/Checkbox-BZZsPaVF.js.map +0 -1
- package/dist/chunks/ComboBox-D57tNYDD.js.map +0 -1
- package/dist/chunks/DataGrid-BVdDMZkQ.js +0 -104
- package/dist/chunks/DataGrid-BVdDMZkQ.js.map +0 -1
- package/dist/chunks/Dialog-DuOzsR2g.js +0 -61
- package/dist/chunks/Dialog-DuOzsR2g.js.map +0 -1
- package/dist/chunks/Disclosure-9UgDzc7Z.js +0 -47
- package/dist/chunks/Disclosure-9UgDzc7Z.js.map +0 -1
- package/dist/chunks/Field-BNqvUJfg.js.map +0 -1
- package/dist/chunks/GradientEditor-B_ymIr4Q.js +0 -333
- package/dist/chunks/GradientEditor-B_ymIr4Q.js.map +0 -1
- package/dist/chunks/Icon-QhLhaGFe.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-B9Vh7ASP.js.map +0 -1
- package/dist/chunks/ItemList-BZJQReXD.js +0 -42
- package/dist/chunks/ItemList-BZJQReXD.js.map +0 -1
- package/dist/chunks/Jog-BYrxbAQU.js.map +0 -1
- package/dist/chunks/Keycaps-CGNQV2Pz.js.map +0 -1
- package/dist/chunks/LayerStack-DOylrQcm.js +0 -142
- package/dist/chunks/LayerStack-DOylrQcm.js.map +0 -1
- package/dist/chunks/MenuButton-DGE-0DP0.js +0 -60
- package/dist/chunks/MenuButton-DGE-0DP0.js.map +0 -1
- package/dist/chunks/MeshEditor-CHoGQ9K8.js +0 -123
- package/dist/chunks/MeshEditor-CHoGQ9K8.js.map +0 -1
- package/dist/chunks/NumberField-CQzS6TjF.js.map +0 -1
- package/dist/chunks/PaintField-BVYMu3OI.js.map +0 -1
- package/dist/chunks/PaintInput-BzAHCKro.js.map +0 -1
- package/dist/chunks/PatternPicker-C4OryrYi.js.map +0 -1
- package/dist/chunks/Powerline-B_EH-7Z-.js.map +0 -1
- package/dist/chunks/Prefs-FuaJBs3t.js +0 -308
- package/dist/chunks/Prefs-FuaJBs3t.js.map +0 -1
- package/dist/chunks/Properties-B3KU69NI.js +0 -874
- package/dist/chunks/Properties-B3KU69NI.js.map +0 -1
- package/dist/chunks/RadioGroup-C6xpdQNg.js.map +0 -1
- package/dist/chunks/RangeSlider-CzgeGLVS.js.map +0 -1
- package/dist/chunks/Select-BMYVh10x.js +0 -127
- package/dist/chunks/Select-BMYVh10x.js.map +0 -1
- package/dist/chunks/SelectionPanel-DTpcQidl.js +0 -572
- package/dist/chunks/SelectionPanel-DTpcQidl.js.map +0 -1
- package/dist/chunks/Sidebar-BlUjn8lD.js.map +0 -1
- package/dist/chunks/SidebarPanel-BqHfz6VK.js.map +0 -1
- package/dist/chunks/Slider-B2ywUZH6.js.map +0 -1
- package/dist/chunks/StatusBar-BFt7Yw5O.js.map +0 -1
- package/dist/chunks/Switch-Om3t3ASc.js.map +0 -1
- package/dist/chunks/Tabs-EAvYywil.js.map +0 -1
- package/dist/chunks/Timeline-BEyKaBXl.js.map +0 -1
- package/dist/chunks/Toast-iqLDD_XZ.js.map +0 -1
- package/dist/chunks/ToggleBar--9As2PWG.js +0 -75
- package/dist/chunks/ToggleBar--9As2PWG.js.map +0 -1
- package/dist/chunks/TokenPanel-BL9hlq7x.js +0 -374
- package/dist/chunks/TokenPanel-BL9hlq7x.js.map +0 -1
- package/dist/chunks/ToolButton-Dd-1T5aX.js.map +0 -1
- package/dist/chunks/ToolGroup-BBI-W-Gm.js.map +0 -1
- package/dist/chunks/ToolOptionsBar-B2xPWzJf.js +0 -27
- package/dist/chunks/ToolOptionsBar-B2xPWzJf.js.map +0 -1
- package/dist/chunks/ToolPalette-BmTDDpmz.js +0 -97
- package/dist/chunks/ToolPalette-BmTDDpmz.js.map +0 -1
- package/dist/chunks/Tooltip-BHre_vbI.js +0 -42
- package/dist/chunks/Tooltip-BHre_vbI.js.map +0 -1
- package/dist/chunks/icons-Btrs-JD7.js +0 -165
- package/dist/chunks/icons-Btrs-JD7.js.map +0 -1
- package/dist/chunks/number-f6PydOZK.js +0 -52
- package/dist/chunks/number-f6PydOZK.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-MCVT1MLv.js +0 -47
- package/dist/chunks/schema-MCVT1MLv.js.map +0 -1
- package/dist/chunks/segmentedControl.module-DmeUMYe3.js +0 -11
- package/dist/chunks/segmentedControl.module-DmeUMYe3.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
- package/dist/components/Properties/PinDot.d.ts +0 -18
- package/dist/components/Properties/PinDot.d.ts.map +0 -1
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
import { a as e, t } from "./Icon-BW0qv_U7.js";
|
|
2
|
+
import { t as n } from "./PropertyField-CDb19d3F.js";
|
|
3
|
+
import { t as r } from "./ToggleBar-Btnl5r7F.js";
|
|
4
|
+
import { t as i } from "./prefField-CLkhrvYl.js";
|
|
5
|
+
import { MIXED as a } from "@weasel-js/core";
|
|
6
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
import { Fragment as c, createElement as l } from "react";
|
|
8
|
+
var u = {
|
|
9
|
+
root: "_root_11o7u_1",
|
|
10
|
+
header: "_header_11o7u_8",
|
|
11
|
+
kind: "_kind_11o7u_16",
|
|
12
|
+
breakdown: "_breakdown_11o7u_21",
|
|
13
|
+
section: "_section_11o7u_26",
|
|
14
|
+
sectionTitle: "_sectionTitle_11o7u_35",
|
|
15
|
+
row: "_row_11o7u_44",
|
|
16
|
+
rowLabel: "_rowLabel_11o7u_52",
|
|
17
|
+
rowControls: "_rowControls_11o7u_56",
|
|
18
|
+
namedField: "_namedField_11o7u_66",
|
|
19
|
+
blockRow: "_blockRow_11o7u_78",
|
|
20
|
+
toggle: "_toggle_11o7u_89",
|
|
21
|
+
flagToggle: "_flagToggle_11o7u_111",
|
|
22
|
+
number: "_number_11o7u_115",
|
|
23
|
+
select: "_select_11o7u_116",
|
|
24
|
+
unrenderable: "_unrenderable_11o7u_120",
|
|
25
|
+
objectLeaf: "_objectLeaf_11o7u_127",
|
|
26
|
+
objectGroup: "_objectGroup_11o7u_136",
|
|
27
|
+
slider: "_slider_11o7u_143"
|
|
28
|
+
};
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/components/SelectionPanel/renderLeaf.tsx
|
|
31
|
+
function d(e, t) {
|
|
32
|
+
let { leaf: n } = e;
|
|
33
|
+
return n.kind === "boolean" && n.control === "toggle" && n.pair !== void 0 && t?.[e.ctx.path] === void 0 && t?.[n.kind] === void 0;
|
|
34
|
+
}
|
|
35
|
+
function f(e, t) {
|
|
36
|
+
let n = [];
|
|
37
|
+
for (let r = 0; r < e.length;) {
|
|
38
|
+
let i = e[r];
|
|
39
|
+
if (!d(i, t)) {
|
|
40
|
+
let e = i.render();
|
|
41
|
+
e != null && n.push({
|
|
42
|
+
key: i.key,
|
|
43
|
+
leaf: i.leaf,
|
|
44
|
+
block: i.leaf.block === !0,
|
|
45
|
+
content: e
|
|
46
|
+
}), r += 1;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
let a = r + 1;
|
|
50
|
+
for (; a < e.length && d(e[a], t) && e[a].leaf.pair === i.leaf.pair;) a += 1;
|
|
51
|
+
let s = e.slice(r, a);
|
|
52
|
+
n.push({
|
|
53
|
+
key: i.key,
|
|
54
|
+
leaf: i.leaf,
|
|
55
|
+
block: s.every((e) => e.leaf.block === !0),
|
|
56
|
+
content: /* @__PURE__ */ o(p, {
|
|
57
|
+
run: s,
|
|
58
|
+
ariaLabel: i.leaf.pair
|
|
59
|
+
})
|
|
60
|
+
}), r = a;
|
|
61
|
+
}
|
|
62
|
+
return n;
|
|
63
|
+
}
|
|
64
|
+
function p({ run: n, ariaLabel: i }) {
|
|
65
|
+
let a = n.filter((e) => e.ctx.value === !0).map((e) => e.key);
|
|
66
|
+
return /* @__PURE__ */ o(r, {
|
|
67
|
+
mode: "multiple",
|
|
68
|
+
size: "sm",
|
|
69
|
+
variant: "flat",
|
|
70
|
+
className: u.flagToggle,
|
|
71
|
+
ariaLabel: i,
|
|
72
|
+
items: n.map((n) => {
|
|
73
|
+
let r = n.leaf;
|
|
74
|
+
return {
|
|
75
|
+
value: n.key,
|
|
76
|
+
label: r.icon && r.icon in e ? /* @__PURE__ */ o(t, {
|
|
77
|
+
name: r.icon,
|
|
78
|
+
size: 14
|
|
79
|
+
}) : r.short ?? r.name.slice(0, 1),
|
|
80
|
+
ariaLabel: n.ariaLabel
|
|
81
|
+
};
|
|
82
|
+
}),
|
|
83
|
+
value: a,
|
|
84
|
+
mixedValues: n.filter((e) => e.ctx.mixed).map((e) => e.key),
|
|
85
|
+
onChange: (e) => {
|
|
86
|
+
for (let t of n) {
|
|
87
|
+
let n = e.includes(t.key);
|
|
88
|
+
n !== a.includes(t.key) && t.ctx.setValue(n);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
function m(e, t, r, a = "", c = !1) {
|
|
94
|
+
let { pref: d, value: f, mixed: p, unset: m, setValue: v } = e;
|
|
95
|
+
if (d.kind === "object") return /* @__PURE__ */ o(_, {
|
|
96
|
+
ctx: e,
|
|
97
|
+
renderers: r,
|
|
98
|
+
selectionKey: a
|
|
99
|
+
});
|
|
100
|
+
let y = i(d, {
|
|
101
|
+
value: f,
|
|
102
|
+
mixed: p,
|
|
103
|
+
unset: m,
|
|
104
|
+
siblings: e.siblings,
|
|
105
|
+
setValue: v,
|
|
106
|
+
fontVariant: {
|
|
107
|
+
weight: e.valueAt("data.style.fontWeight").value,
|
|
108
|
+
style: e.valueAt("data.style.fontStyle").value
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
if (y === null) return /* @__PURE__ */ s("span", {
|
|
112
|
+
className: u.unrenderable,
|
|
113
|
+
children: [
|
|
114
|
+
"(",
|
|
115
|
+
d.kind,
|
|
116
|
+
": no renderer)"
|
|
117
|
+
]
|
|
118
|
+
});
|
|
119
|
+
switch (y.kind) {
|
|
120
|
+
case "boolean": return /* @__PURE__ */ o(n, {
|
|
121
|
+
...y,
|
|
122
|
+
...h(t),
|
|
123
|
+
control: y.control ?? "switch",
|
|
124
|
+
className: y.control === "toggle" ? u.flagToggle : void 0
|
|
125
|
+
});
|
|
126
|
+
case "number": return /* @__PURE__ */ o(n, {
|
|
127
|
+
...y,
|
|
128
|
+
...h(t),
|
|
129
|
+
className: y.control === "slider" ? u.slider : u.number,
|
|
130
|
+
steppers: !1
|
|
131
|
+
});
|
|
132
|
+
case "string": return /* @__PURE__ */ o(n, {
|
|
133
|
+
...y,
|
|
134
|
+
...h(t),
|
|
135
|
+
onInput: g
|
|
136
|
+
});
|
|
137
|
+
case "enum": return /* @__PURE__ */ o(n, {
|
|
138
|
+
...y,
|
|
139
|
+
...h(t),
|
|
140
|
+
className: y.control === "toggle" ? u.toggle : y.control === "radio" ? void 0 : u.select
|
|
141
|
+
});
|
|
142
|
+
case "font-family": return /* @__PURE__ */ o(n, {
|
|
143
|
+
...y,
|
|
144
|
+
...h(t),
|
|
145
|
+
className: u.select
|
|
146
|
+
});
|
|
147
|
+
case "paint": return /* @__PURE__ */ l(n, {
|
|
148
|
+
...y,
|
|
149
|
+
...h(t),
|
|
150
|
+
key: a,
|
|
151
|
+
control: "inline",
|
|
152
|
+
allowNone: !c
|
|
153
|
+
});
|
|
154
|
+
default: return /* @__PURE__ */ o(n, {
|
|
155
|
+
...y,
|
|
156
|
+
...h(t)
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
var h = (e) => ({
|
|
161
|
+
chrome: "framed",
|
|
162
|
+
name: e
|
|
163
|
+
}), g = () => {};
|
|
164
|
+
function _({ ctx: n, renderers: r, selectionKey: i = "" }) {
|
|
165
|
+
let a = n.pref, l = typeof n.value == "object" && n.value !== null ? n.value : void 0, d = Object.values(a.children).every((e) => !("kind" in e)), p = (d, h) => {
|
|
166
|
+
let g = [], _ = (e) => typeof e == "object" && !!e && "controls" in e, v = [], y = () => {
|
|
167
|
+
for (let { key: e, leaf: t, block: n, content: i } of f(v, r)) {
|
|
168
|
+
let r = g[g.length - 1];
|
|
169
|
+
if (t.pair !== void 0 && _(r) && r.pair === t.pair) {
|
|
170
|
+
r.controls.push(/* @__PURE__ */ o(c, { children: i }, e)), r.block &&= n;
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
g.push({
|
|
174
|
+
key: e,
|
|
175
|
+
pair: t.pair,
|
|
176
|
+
label: t.pair ?? t.name,
|
|
177
|
+
title: t.description,
|
|
178
|
+
block: n,
|
|
179
|
+
controls: [/* @__PURE__ */ o(c, { children: i }, e)]
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
v = [];
|
|
183
|
+
};
|
|
184
|
+
for (let [c, f] of Object.entries(d)) {
|
|
185
|
+
if (!("kind" in f)) {
|
|
186
|
+
let e = f.name !== "", t = p(f.children, e);
|
|
187
|
+
if (t.length === 0) continue;
|
|
188
|
+
y(), g.push(/* @__PURE__ */ s("div", {
|
|
189
|
+
className: e && h ? u.objectGroup : void 0,
|
|
190
|
+
children: [e && /* @__PURE__ */ o("h5", {
|
|
191
|
+
className: u.sectionTitle,
|
|
192
|
+
children: f.name
|
|
193
|
+
}), t]
|
|
194
|
+
}, `group:${c}`));
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
let d = `${n.path}.${c}`, _ = {
|
|
198
|
+
path: d,
|
|
199
|
+
pref: f,
|
|
200
|
+
value: l?.[c],
|
|
201
|
+
mixed: n.mixed,
|
|
202
|
+
unset: !n.mixed && l?.[c] === void 0,
|
|
203
|
+
siblings: l,
|
|
204
|
+
valueAt: n.valueAt,
|
|
205
|
+
selectionKey: n.selectionKey,
|
|
206
|
+
setValue: (e) => {
|
|
207
|
+
let t = l ?? a.fromScalar?.(n.value) ?? (typeof a.default == "object" && a.default !== null ? { ...a.default } : {});
|
|
208
|
+
if (e === void 0) {
|
|
209
|
+
let { [c]: e, ...r } = t;
|
|
210
|
+
n.setValue(r);
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
n.setValue({
|
|
214
|
+
...t,
|
|
215
|
+
[c]: e
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
v.push({
|
|
220
|
+
key: d,
|
|
221
|
+
leaf: f,
|
|
222
|
+
ctx: _,
|
|
223
|
+
ariaLabel: f.name,
|
|
224
|
+
render: () => {
|
|
225
|
+
let n = r?.[d] ?? r?.[f.kind], a = n ? n(_) : m(_, f.name, r, i, !0);
|
|
226
|
+
return a == null ? null : (f.pair !== void 0 || f.block === !0) && f.icon && f.icon in e ? /* @__PURE__ */ s("span", {
|
|
227
|
+
className: u.namedField,
|
|
228
|
+
children: [/* @__PURE__ */ o(t, {
|
|
229
|
+
name: f.icon,
|
|
230
|
+
size: 14
|
|
231
|
+
}), a]
|
|
232
|
+
}) : a;
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return y(), g.map((e) => typeof e == "object" && e && "controls" in e ? e.block ? /* @__PURE__ */ o("div", {
|
|
237
|
+
className: `${u.rowControls} ${u.blockRow}`,
|
|
238
|
+
title: e.title,
|
|
239
|
+
children: e.controls
|
|
240
|
+
}, e.key) : /* @__PURE__ */ s("div", {
|
|
241
|
+
className: u.row,
|
|
242
|
+
children: [/* @__PURE__ */ o("span", {
|
|
243
|
+
className: u.rowLabel,
|
|
244
|
+
title: e.title,
|
|
245
|
+
children: e.label
|
|
246
|
+
}), /* @__PURE__ */ o("span", {
|
|
247
|
+
className: u.rowControls,
|
|
248
|
+
children: e.controls
|
|
249
|
+
})]
|
|
250
|
+
}, e.key) : e);
|
|
251
|
+
}, h = p(a.children, !d);
|
|
252
|
+
return h.length === 0 ? null : /* @__PURE__ */ s("div", {
|
|
253
|
+
className: u.objectLeaf,
|
|
254
|
+
children: [!d && /* @__PURE__ */ o("h4", {
|
|
255
|
+
className: u.sectionTitle,
|
|
256
|
+
children: a.name
|
|
257
|
+
}), h]
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
//#endregion
|
|
261
|
+
//#region src/components/SelectionPanel/model.ts
|
|
262
|
+
function v(e, t) {
|
|
263
|
+
if (e.kind === "container") return "group";
|
|
264
|
+
for (let n of t) if (n.matches(e.data)) return n.name;
|
|
265
|
+
return "unknown";
|
|
266
|
+
}
|
|
267
|
+
function y(e) {
|
|
268
|
+
return !("kind" in e);
|
|
269
|
+
}
|
|
270
|
+
function b(e) {
|
|
271
|
+
let t = [], n = [], r = (e, t) => {
|
|
272
|
+
for (let [n, i] of Object.entries(e.children)) y(i) ? r(i, t) : t.push({
|
|
273
|
+
path: n,
|
|
274
|
+
leaf: i
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
for (let [i, a] of Object.entries(e.children)) if (y(a)) {
|
|
278
|
+
let e = [];
|
|
279
|
+
r(a, e), t.push({
|
|
280
|
+
key: i,
|
|
281
|
+
name: a.name,
|
|
282
|
+
rows: x(e)
|
|
283
|
+
});
|
|
284
|
+
} else n.push({
|
|
285
|
+
path: i,
|
|
286
|
+
leaf: a
|
|
287
|
+
});
|
|
288
|
+
return n.length > 0 && t.unshift({
|
|
289
|
+
key: "",
|
|
290
|
+
name: "",
|
|
291
|
+
rows: x(n)
|
|
292
|
+
}), t;
|
|
293
|
+
}
|
|
294
|
+
function x(e) {
|
|
295
|
+
let t = [];
|
|
296
|
+
for (let n of e) {
|
|
297
|
+
let e = n.leaf.pair, r = t[t.length - 1];
|
|
298
|
+
e !== void 0 && r !== void 0 && r.label === e ? r.leaves.push(n) : t.push({
|
|
299
|
+
label: e ?? n.leaf.name,
|
|
300
|
+
leaves: [n]
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
return t;
|
|
304
|
+
}
|
|
305
|
+
function S(e, t) {
|
|
306
|
+
let n = [...new Set(e)];
|
|
307
|
+
if (n.length === 0) return [];
|
|
308
|
+
let r = new Map(t.map((e) => [e.name, e])), i = n.map((e) => r.get(e)?.schema);
|
|
309
|
+
if (i.some((e) => e === void 0)) return [];
|
|
310
|
+
let [a, ...o] = i, s = b(a);
|
|
311
|
+
if (o.length === 0) return s;
|
|
312
|
+
let c = (e) => `${e.path}\0${e.leaf.kind}`, l = o.map((e) => new Set(b(e).flatMap((e) => e.rows).flatMap((e) => e.leaves).map(c))), u = (e) => l.every((t) => t.has(c(e)));
|
|
313
|
+
return s.map((e) => ({
|
|
314
|
+
...e,
|
|
315
|
+
rows: e.rows.map((e) => ({
|
|
316
|
+
...e,
|
|
317
|
+
leaves: e.leaves.filter(u)
|
|
318
|
+
})).filter((e) => e.leaves.length > 0)
|
|
319
|
+
})).filter((e) => e.rows.length > 0);
|
|
320
|
+
}
|
|
321
|
+
function C(e, t) {
|
|
322
|
+
let n = t.split(".");
|
|
323
|
+
if (n.length < 2) return;
|
|
324
|
+
let r = n[0], i = r === "pose" ? e.pose : r === "data" ? e.data : void 0;
|
|
325
|
+
for (let e = 1; e < n.length; e++) {
|
|
326
|
+
if (typeof i != "object" || !i) return;
|
|
327
|
+
i = i[n[e]];
|
|
328
|
+
}
|
|
329
|
+
return i;
|
|
330
|
+
}
|
|
331
|
+
function w(e, t, n) {
|
|
332
|
+
let [r, ...i] = t;
|
|
333
|
+
if (i.length === 0) return Array.isArray(e) ? Object.assign([...e], { [r]: n }) : {
|
|
334
|
+
...e,
|
|
335
|
+
[r]: n
|
|
336
|
+
};
|
|
337
|
+
let a = e[r], o = w(Array.isArray(a) ? [...a] : typeof a == "object" && a ? { ...a } : {}, i, n);
|
|
338
|
+
return Array.isArray(e) ? Object.assign([...e], { [r]: o }) : {
|
|
339
|
+
...e,
|
|
340
|
+
[r]: o
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
function T(e, t) {
|
|
344
|
+
let n, r = !0;
|
|
345
|
+
for (let i of e) {
|
|
346
|
+
let e = C(i, t);
|
|
347
|
+
if (r) n = e, r = !1;
|
|
348
|
+
else if (!Object.is(e, n)) return a;
|
|
349
|
+
}
|
|
350
|
+
return n;
|
|
351
|
+
}
|
|
352
|
+
function E(e) {
|
|
353
|
+
let t = /* @__PURE__ */ new Map();
|
|
354
|
+
for (let n of e) t.set(n, (t.get(n) ?? 0) + 1);
|
|
355
|
+
return [...t.entries()].map(([e, t]) => t > 1 ? `${e} ×${t}` : e).join(" · ");
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
export { y as a, x as c, f as d, u as f, S as i, w as l, T as n, E as o, v as r, C as s, a as t, m as u };
|
|
359
|
+
|
|
360
|
+
//# sourceMappingURL=model-BQMvTLnW.js.map
|
|
@@ -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;AACZ,SACE,IAAI,EAAM,UACV,EAAW,EAAM,IAAI,EAAU,IAC/B,EAAM,GAAG,KAAK,SAAS,EAAK,KAAK,MAEjC,MAAK;EAEP,I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AO,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"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
//#region src/format/number.ts
|
|
2
|
+
var e = "−";
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
return (Number.isFinite(e) ? e.toLocaleString(void 0, t) : String(e)).replace(/^-/, "−");
|
|
5
|
+
}
|
|
6
|
+
function n(e) {
|
|
7
|
+
return Number(e.replace("−", "-"));
|
|
8
|
+
}
|
|
9
|
+
var r = {
|
|
10
|
+
k: 3,
|
|
11
|
+
m: 6,
|
|
12
|
+
b: 9,
|
|
13
|
+
t: 12
|
|
14
|
+
};
|
|
15
|
+
function i(e, n = 0) {
|
|
16
|
+
if (!Number.isFinite(e)) return t(e);
|
|
17
|
+
let r = Math.abs(e) < 1e3 ? {
|
|
18
|
+
useGrouping: !1,
|
|
19
|
+
minimumFractionDigits: n,
|
|
20
|
+
maximumFractionDigits: n
|
|
21
|
+
} : {
|
|
22
|
+
notation: "compact",
|
|
23
|
+
minimumSignificantDigits: 3,
|
|
24
|
+
maximumSignificantDigits: 3
|
|
25
|
+
};
|
|
26
|
+
return e.toLocaleString("en-US", r).replace(/^-/, "−");
|
|
27
|
+
}
|
|
28
|
+
function a(e, t) {
|
|
29
|
+
if (t) {
|
|
30
|
+
let n = e.trim(), r = u(n, t);
|
|
31
|
+
if (r !== void 0) {
|
|
32
|
+
let e = c(n, t);
|
|
33
|
+
if (e !== void 0 && e.length > 1) return l(e, n, t);
|
|
34
|
+
let { factor: i, offset: u } = s(t[r]);
|
|
35
|
+
return o(a(n.slice(0, -r.length)), i) + u;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
let n = e.trim().replace("−", "-"), i = r[n.slice(-1).toLowerCase()];
|
|
39
|
+
return i !== void 0 && (n = n.slice(0, -1).trimEnd()), /^[-+]?\d{1,3}(,\d{3})+(\.\d*)?$/.test(n) && (n = n.replace(/,/g, "")), /\d/.test(n) ? Number(i === void 0 ? n : `${n}e${i}`) : NaN;
|
|
40
|
+
}
|
|
41
|
+
function o(e, t) {
|
|
42
|
+
return t < 1 ? e / (1 / t) : e * t;
|
|
43
|
+
}
|
|
44
|
+
function s(e) {
|
|
45
|
+
return typeof e == "number" ? {
|
|
46
|
+
factor: e,
|
|
47
|
+
offset: 0
|
|
48
|
+
} : {
|
|
49
|
+
factor: e.factor,
|
|
50
|
+
offset: e.offset ?? 0
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function c(e, t) {
|
|
54
|
+
let n = [], r = e.trimEnd();
|
|
55
|
+
for (; r !== "";) {
|
|
56
|
+
let e = u(r, t);
|
|
57
|
+
if (e === void 0) return;
|
|
58
|
+
n.push(e);
|
|
59
|
+
let i = r.slice(0, -e.length), a = /(\d+(?:\.\d+)?|\.\d+)\s*$/.exec(i);
|
|
60
|
+
if (!a) return;
|
|
61
|
+
r = i.slice(0, a.index).trimEnd(), (r === "-" || r === "+" || r === "−") && (r = "");
|
|
62
|
+
}
|
|
63
|
+
return n.length === 0 ? void 0 : n.reverse();
|
|
64
|
+
}
|
|
65
|
+
function l(e, t, n) {
|
|
66
|
+
let r = t.match(/\d+(?:\.\d+)?|\.\d+/g);
|
|
67
|
+
if (!r || r.length !== e.length) return NaN;
|
|
68
|
+
let i = /^\s*[-\u2212]/.test(t) ? -1 : 1, a = 0;
|
|
69
|
+
for (let [t, i] of e.entries()) {
|
|
70
|
+
let { factor: e, offset: c } = s(n[i]);
|
|
71
|
+
if (c !== 0) return NaN;
|
|
72
|
+
a += o(Number(r[t]), e);
|
|
73
|
+
}
|
|
74
|
+
return i * a;
|
|
75
|
+
}
|
|
76
|
+
function u(e, t) {
|
|
77
|
+
let n = Object.keys(t).filter((e) => e !== "").sort((e, t) => t.length - e.length), r = e.toLowerCase();
|
|
78
|
+
return n.find((t) => e.endsWith(t)) ?? n.find((e) => r.endsWith(e.toLowerCase()));
|
|
79
|
+
}
|
|
80
|
+
function d(e) {
|
|
81
|
+
return String(e).replace(/^-/, "−");
|
|
82
|
+
}
|
|
83
|
+
function f(e) {
|
|
84
|
+
return Number.isFinite(e) ? e <= 2 ? `${d(Math.round(e * 100))}%` : e >= 100 ? `${Math.round(e).toLocaleString("en-US")}x` : `${d(Math.round(e * 10) / 10)}x` : String(e);
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { a, f as i, i as n, n as o, t as r, e as t };
|
|
88
|
+
|
|
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,GACpC,EAAM,eAAe,KAAA,GAAW,EAAQ,GACxC,OAAO,EAAM,EACA,QAAQ,MAAA,IAAiB;;AAQ5C,SAAgB,EAAkB,GAAsB;AACtD,QAAO,OAAO,EAAK,QAAA,KAAoB,IAAI,CAAC;;AAI9C,IAAM,IAAoC;CAAE,GAAG;CAAG,GAAG;CAAG,GAAG;CAAG,GAAG;CAAI;AAQrE,SAAgB,EAAc,GAAe,IAAW,GAAW;AACjE,KAAI,CAAC,OAAO,SAAS,E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,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;;AAI1B,SAAS,EAAa,GAAuD;CAC3E,IAAM,IAAQ,EAAM,eAAe,OAC7B,IAAgB,EAAE;AACxB,MAAK,IAAI,IAAI,GAAG,KAAK,GAAS,KAAK;EACjC,IAAM,IAAI,IAAI;AACd,IAAI,KAAK,GAAG,EAAoB,EAAM,OAAO,GAAG,EAAM,CAAC,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC,GAAG;;AAEpF,QAAO,EAAI,KAAK,KAAK;;AAGvB,IAAM,IAAM,MAAM,KAAK;AAIvB,SAAS,EAAI,GAAmB;AAC9B,QAAO,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;;AAajC,SAAgB,EAAgB,GAAyD;AACnF,UAAS,MAEb;OADa,EAAM,QAAQ,aACd,QAAS,QAAQ,EAA4B;AAE1D,MAAI,EAAM,SAAS,mBAAmB;GACpC,IAAM,IAAK,EAAM,GAAG,IAAI,EAAM,KAAK,GAC7B,IAAK,EAAM,GAAG,IAAI,EAAM,KAAK;AAInC,UAAO,oBADO,MAAO,KAAK,MAAO,IAAI,KAAK,KAAK,MAAM,GAAI,CAAC,EAAG,GAAG,GAChC,QAAQ,EAAE,CAAC,OAAO,EAAa,EAAM,CAAC;;AAExE,MAAI,EAAM,SAAS,kBAEjB,QAAO,0BAA0B,MADhB,EAAI,EAAM,OAAO,EAAE,CAAC,GAAG,EAAI,EAAM,OAAO,EAAE,GACvB,IAAI,EAAa,EAAM,CAAC;AAE9D,MAAK,EAAM,SAAoB,gBAC7B,QAAO,EAAY,EAAyD;AAE9E,MAAI,EAAM,SAAS,iBAGjB,QAAO,wBADO,EAAM,QAAQ,IAAM,IAAI,QAAQ,EAChB,CAAK,SAAS,EAAI,EAAM,OAAO,EAAE,CAAC,GAAG,EAAI,EAAM,OAAO,EAAE,CAAC,IAAI,EAAa,EAAM,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/components/paintValue.ts
|
|
2
|
+
function e(e) {
|
|
3
|
+
if (typeof e != "object" || !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"}
|