@nice2dev/ui-graphics 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/animation/AnimatedPerson.js +69 -63
- package/dist/cjs/animation/AnimatedPerson.js.map +1 -1
- package/dist/cjs/animation/AnimationEditor.js +27 -20
- package/dist/cjs/animation/AnimationEditor.js.map +1 -1
- package/dist/cjs/animation/Audience.js +17 -11
- package/dist/cjs/animation/Audience.js.map +1 -1
- package/dist/cjs/animation/BodyRenderer.js +7 -7
- package/dist/cjs/animation/BodyRenderer.js.map +1 -1
- package/dist/cjs/animation/animationHelper.js +83 -52
- package/dist/cjs/animation/animationHelper.js.map +1 -1
- package/dist/cjs/animation/characterTypes.js +171 -30
- package/dist/cjs/animation/characterTypes.js.map +1 -1
- package/dist/cjs/animation/choreoDSL.js +114 -62
- package/dist/cjs/animation/choreoDSL.js.map +1 -1
- package/dist/cjs/animation/karaokeIntegration.js +10 -11
- package/dist/cjs/animation/karaokeIntegration.js.map +1 -1
- package/dist/cjs/animation/lottieExport.js +15 -9
- package/dist/cjs/animation/lottieExport.js.map +1 -1
- package/dist/cjs/animation/motionPath.js +125 -30
- package/dist/cjs/animation/motionPath.js.map +1 -1
- package/dist/cjs/animation/physics.js +157 -57
- package/dist/cjs/animation/physics.js.map +1 -1
- package/dist/cjs/animation/rig/RigPlayer.js +7 -6
- package/dist/cjs/animation/rig/RigPlayer.js.map +1 -1
- package/dist/cjs/animation/rig/RiggedBody.js +7 -7
- package/dist/cjs/animation/rig/RiggedBody.js.map +1 -1
- package/dist/cjs/animation/rig/choreoRigBridge.js +52 -29
- package/dist/cjs/animation/rig/choreoRigBridge.js.map +1 -1
- package/dist/cjs/animation/rig/poseOps.js +6 -3
- package/dist/cjs/animation/rig/poseOps.js.map +1 -1
- package/dist/cjs/animation/shapes/arms.js +7 -6
- package/dist/cjs/animation/shapes/arms.js.map +1 -1
- package/dist/cjs/animation/shapes/eyes.js +31 -18
- package/dist/cjs/animation/shapes/eyes.js.map +1 -1
- package/dist/cjs/animation/shapes/hair.js +39 -23
- package/dist/cjs/animation/shapes/hair.js.map +1 -1
- package/dist/cjs/animation/shapes/heads.js +47 -29
- package/dist/cjs/animation/shapes/heads.js.map +1 -1
- package/dist/cjs/animation/shapes/headwear.js +26 -14
- package/dist/cjs/animation/shapes/headwear.js.map +1 -1
- package/dist/cjs/animation/shapes/legs.js +7 -6
- package/dist/cjs/animation/shapes/legs.js.map +1 -1
- package/dist/cjs/animation/shapes/mouths.js +28 -18
- package/dist/cjs/animation/shapes/mouths.js.map +1 -1
- package/dist/cjs/animation/shapes/noses.js +18 -9
- package/dist/cjs/animation/shapes/noses.js.map +1 -1
- package/dist/cjs/animation/shapes/outfits.js +25 -14
- package/dist/cjs/animation/shapes/outfits.js.map +1 -1
- package/dist/cjs/animation/shapes/torsos.js +5 -4
- package/dist/cjs/animation/shapes/torsos.js.map +1 -1
- package/dist/cjs/animation/spineExport.js +33 -26
- package/dist/cjs/animation/spineExport.js.map +1 -1
- package/dist/cjs/core/LocalUI.js +16 -16
- package/dist/cjs/core/LocalUI.js.map +1 -1
- package/dist/cjs/core/NiceBrushEngine.js +205 -69
- package/dist/cjs/core/NiceBrushEngine.js.map +1 -1
- package/dist/cjs/core/collaboration.js +35 -21
- package/dist/cjs/core/collaboration.js.map +1 -1
- package/dist/cjs/core/colorBlindness.js +64 -24
- package/dist/cjs/core/colorBlindness.js.map +1 -1
- package/dist/cjs/core/dragDrop.js +34 -26
- package/dist/cjs/core/dragDrop.js.map +1 -1
- package/dist/cjs/core/fixes.js +26 -14
- package/dist/cjs/core/fixes.js.map +1 -1
- package/dist/cjs/core/gridGuides.js +24 -16
- package/dist/cjs/core/gridGuides.js.map +1 -1
- package/dist/cjs/core/historyVisual.js +42 -23
- package/dist/cjs/core/historyVisual.js.map +1 -1
- package/dist/cjs/core/integrations.js +65 -48
- package/dist/cjs/core/integrations.js.map +1 -1
- package/dist/cjs/core/minimap.js +40 -24
- package/dist/cjs/core/minimap.js.map +1 -1
- package/dist/cjs/core/plugins.js +10 -6
- package/dist/cjs/core/plugins.js.map +1 -1
- package/dist/cjs/core/rtl.js +32 -27
- package/dist/cjs/core/rtl.js.map +1 -1
- package/dist/cjs/core/shortcuts.js +77 -39
- package/dist/cjs/core/shortcuts.js.map +1 -1
- package/dist/cjs/core/theme.js +68 -61
- package/dist/cjs/core/theme.js.map +1 -1
- package/dist/cjs/core/yjsCollaboration.js +61 -28
- package/dist/cjs/core/yjsCollaboration.js.map +1 -1
- package/dist/cjs/font/NiceFontEditor.js +160 -57
- package/dist/cjs/font/NiceFontEditor.js.map +1 -1
- package/dist/cjs/font/fontFormatUtils.js +37 -24
- package/dist/cjs/font/fontFormatUtils.js.map +1 -1
- package/dist/cjs/game/GameAsset2dEditor.js +73 -60
- package/dist/cjs/game/GameAsset2dEditor.js.map +1 -1
- package/dist/cjs/game/gameAssetUtils.js +18 -13
- package/dist/cjs/game/gameAssetUtils.js.map +1 -1
- package/dist/cjs/game/useGameAssetEditor.js +160 -143
- package/dist/cjs/game/useGameAssetEditor.js.map +1 -1
- package/dist/cjs/icon/NiceIconEditor.js +329 -106
- package/dist/cjs/icon/NiceIconEditor.js.map +1 -1
- package/dist/cjs/packages/ui/dist/NiceErrorBoundary-D75yr_WE.js +572 -0
- package/dist/cjs/packages/ui/dist/NiceErrorBoundary-D75yr_WE.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceForm-CKoJA6NG.js +4979 -0
- package/dist/cjs/packages/ui/dist/NiceForm-CKoJA6NG.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceModal-1QX7NhyH.js +98 -0
- package/dist/cjs/packages/ui/dist/NiceModal-1QX7NhyH.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js +5244 -0
- package/dist/cjs/packages/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NicePagination-DbE-uOkl.js +174 -0
- package/dist/cjs/packages/ui/dist/NicePagination-DbE-uOkl.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NicePinCodeInput-B8cI8zu8.js +10459 -0
- package/dist/cjs/packages/ui/dist/NicePinCodeInput-B8cI8zu8.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js +6313 -0
- package/dist/cjs/packages/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceTabs-DzLHzwuA.js +1639 -0
- package/dist/cjs/packages/ui/dist/NiceTabs-DzLHzwuA.js.map +1 -0
- package/dist/cjs/packages/ui/dist/NiceWindow-DeC83yfE.js +807 -0
- package/dist/cjs/packages/ui/dist/NiceWindow-DeC83yfE.js.map +1 -0
- package/dist/cjs/packages/ui/dist/charts-BAS21jkC.js +3833 -0
- package/dist/cjs/packages/ui/dist/charts-BAS21jkC.js.map +1 -0
- package/dist/cjs/packages/ui/dist/core-Da43q-pO.js +11683 -0
- package/dist/cjs/packages/ui/dist/core-Da43q-pO.js.map +1 -0
- package/dist/cjs/packages/ui/dist/index-pAuGTbuB.js +28876 -0
- package/dist/cjs/packages/ui/dist/index-pAuGTbuB.js.map +1 -0
- package/dist/cjs/photo/FilterThumb.js +7 -5
- package/dist/cjs/photo/FilterThumb.js.map +1 -1
- package/dist/cjs/photo/NiceAITools.js +78 -32
- package/dist/cjs/photo/NiceAITools.js.map +1 -1
- package/dist/cjs/photo/PhotoEditor.js +4 -4
- package/dist/cjs/photo/PhotoEditor.js.map +1 -1
- package/dist/cjs/photo/PhotoEditorCanvas.js +56 -22
- package/dist/cjs/photo/PhotoEditorCanvas.js.map +1 -1
- package/dist/cjs/photo/PhotoEditorLeftPanel.js +106 -48
- package/dist/cjs/photo/PhotoEditorLeftPanel.js.map +1 -1
- package/dist/cjs/photo/PhotoEditorToolbar.js +2 -2
- package/dist/cjs/photo/PhotoEditorToolbar.js.map +1 -1
- package/dist/cjs/photo/photoEditorActions.js +27 -18
- package/dist/cjs/photo/photoEditorActions.js.map +1 -1
- package/dist/cjs/photo/photoFilters.js +316 -81
- package/dist/cjs/photo/photoFilters.js.map +1 -1
- package/dist/cjs/photo/photoOverlays.js +521 -165
- package/dist/cjs/photo/photoOverlays.js.map +1 -1
- package/dist/cjs/photo/photoSelection.js +69 -35
- package/dist/cjs/photo/photoSelection.js.map +1 -1
- package/dist/cjs/photo/usePhotoEditor.js +203 -97
- package/dist/cjs/photo/usePhotoEditor.js.map +1 -1
- package/dist/cjs/pixel/HSVPicker.js +32 -19
- package/dist/cjs/pixel/HSVPicker.js.map +1 -1
- package/dist/cjs/pixel/PixelEditor.js +25 -14
- package/dist/cjs/pixel/PixelEditor.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorCanvas.js +2 -2
- package/dist/cjs/pixel/PixelEditorCanvas.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorMenuBar.js +3 -3
- package/dist/cjs/pixel/PixelEditorMenuBar.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorRightPanel.js +28 -8
- package/dist/cjs/pixel/PixelEditorRightPanel.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorStatusBar.js +2 -2
- package/dist/cjs/pixel/PixelEditorStatusBar.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorTimeline.js +3 -4
- package/dist/cjs/pixel/PixelEditorTimeline.js.map +1 -1
- package/dist/cjs/pixel/PixelEditorToolbar.js +3 -3
- package/dist/cjs/pixel/PixelEditorToolbar.js.map +1 -1
- package/dist/cjs/pixel/SpriteGeneratorPanel.js +136 -54
- package/dist/cjs/pixel/SpriteGeneratorPanel.js.map +1 -1
- package/dist/cjs/pixel/asepriteFormat.js +122 -38
- package/dist/cjs/pixel/asepriteFormat.js.map +1 -1
- package/dist/cjs/pixel/characterGeneratorPresets.js +208 -54
- package/dist/cjs/pixel/characterGeneratorPresets.js.map +1 -1
- package/dist/cjs/pixel/pixelEditorExports.js +42 -35
- package/dist/cjs/pixel/pixelEditorExports.js.map +1 -1
- package/dist/cjs/pixel/pixelEditorTypes.js +67 -33
- package/dist/cjs/pixel/pixelEditorTypes.js.map +1 -1
- package/dist/cjs/pixel/pixelEditorUtils.js +62 -38
- package/dist/cjs/pixel/pixelEditorUtils.js.map +1 -1
- package/dist/cjs/pixel/spriteGeneratorCore.js +47 -24
- package/dist/cjs/pixel/spriteGeneratorCore.js.map +1 -1
- package/dist/cjs/pixel/usePixelEditor.js +475 -213
- package/dist/cjs/pixel/usePixelEditor.js.map +1 -1
- package/dist/cjs/texture/Nice3DTexturePainter.js +201 -71
- package/dist/cjs/texture/Nice3DTexturePainter.js.map +1 -1
- package/dist/cjs/ui/NiceUIDesigner.js +280 -91
- package/dist/cjs/ui/NiceUIDesigner.js.map +1 -1
- package/dist/cjs/vector/NiceSvgToCode.js +96 -34
- package/dist/cjs/vector/NiceSvgToCode.js.map +1 -1
- package/dist/cjs/vector/VectorEditor.js +14 -13
- package/dist/cjs/vector/VectorEditor.js.map +1 -1
- package/dist/cjs/vector/VectorEditorMenuBar.js +7 -6
- package/dist/cjs/vector/VectorEditorMenuBar.js.map +1 -1
- package/dist/cjs/vector/VectorEditorRightPanel.js +87 -32
- package/dist/cjs/vector/VectorEditorRightPanel.js.map +1 -1
- package/dist/cjs/vector/VectorEditorShapeRenderer.js +17 -15
- package/dist/cjs/vector/VectorEditorShapeRenderer.js.map +1 -1
- package/dist/cjs/vector/VectorEditorStatusBar.js.map +1 -1
- package/dist/cjs/vector/useVectorEditor.js +312 -122
- package/dist/cjs/vector/useVectorEditor.js.map +1 -1
- package/dist/cjs/vector/vectorBooleanOps.js +60 -42
- package/dist/cjs/vector/vectorBooleanOps.js.map +1 -1
- package/dist/cjs/vector/vectorEditorExport.js +40 -34
- package/dist/cjs/vector/vectorEditorExport.js.map +1 -1
- package/dist/cjs/vector/vectorGradients.js +41 -40
- package/dist/cjs/vector/vectorGradients.js.map +1 -1
- package/dist/esm/animation/AnimatedPerson.js +69 -63
- package/dist/esm/animation/AnimatedPerson.js.map +1 -1
- package/dist/esm/animation/AnimationEditor.js +27 -20
- package/dist/esm/animation/AnimationEditor.js.map +1 -1
- package/dist/esm/animation/Audience.js +17 -11
- package/dist/esm/animation/Audience.js.map +1 -1
- package/dist/esm/animation/BodyRenderer.js +7 -7
- package/dist/esm/animation/BodyRenderer.js.map +1 -1
- package/dist/esm/animation/animationHelper.js +83 -52
- package/dist/esm/animation/animationHelper.js.map +1 -1
- package/dist/esm/animation/characterTypes.js +171 -30
- package/dist/esm/animation/characterTypes.js.map +1 -1
- package/dist/esm/animation/choreoDSL.js +114 -62
- package/dist/esm/animation/choreoDSL.js.map +1 -1
- package/dist/esm/animation/karaokeIntegration.js +10 -11
- package/dist/esm/animation/karaokeIntegration.js.map +1 -1
- package/dist/esm/animation/lottieExport.js +15 -9
- package/dist/esm/animation/lottieExport.js.map +1 -1
- package/dist/esm/animation/motionPath.js +125 -30
- package/dist/esm/animation/motionPath.js.map +1 -1
- package/dist/esm/animation/physics.js +157 -57
- package/dist/esm/animation/physics.js.map +1 -1
- package/dist/esm/animation/rig/RigPlayer.js +7 -6
- package/dist/esm/animation/rig/RigPlayer.js.map +1 -1
- package/dist/esm/animation/rig/RiggedBody.js +7 -7
- package/dist/esm/animation/rig/RiggedBody.js.map +1 -1
- package/dist/esm/animation/rig/choreoRigBridge.js +52 -29
- package/dist/esm/animation/rig/choreoRigBridge.js.map +1 -1
- package/dist/esm/animation/rig/poseOps.js +6 -3
- package/dist/esm/animation/rig/poseOps.js.map +1 -1
- package/dist/esm/animation/shapes/arms.js +7 -6
- package/dist/esm/animation/shapes/arms.js.map +1 -1
- package/dist/esm/animation/shapes/eyes.js +31 -18
- package/dist/esm/animation/shapes/eyes.js.map +1 -1
- package/dist/esm/animation/shapes/hair.js +39 -23
- package/dist/esm/animation/shapes/hair.js.map +1 -1
- package/dist/esm/animation/shapes/heads.js +47 -29
- package/dist/esm/animation/shapes/heads.js.map +1 -1
- package/dist/esm/animation/shapes/headwear.js +26 -14
- package/dist/esm/animation/shapes/headwear.js.map +1 -1
- package/dist/esm/animation/shapes/legs.js +7 -6
- package/dist/esm/animation/shapes/legs.js.map +1 -1
- package/dist/esm/animation/shapes/mouths.js +28 -18
- package/dist/esm/animation/shapes/mouths.js.map +1 -1
- package/dist/esm/animation/shapes/noses.js +18 -9
- package/dist/esm/animation/shapes/noses.js.map +1 -1
- package/dist/esm/animation/shapes/outfits.js +25 -14
- package/dist/esm/animation/shapes/outfits.js.map +1 -1
- package/dist/esm/animation/shapes/torsos.js +5 -4
- package/dist/esm/animation/shapes/torsos.js.map +1 -1
- package/dist/esm/animation/spineExport.js +33 -26
- package/dist/esm/animation/spineExport.js.map +1 -1
- package/dist/esm/core/LocalUI.js +16 -16
- package/dist/esm/core/LocalUI.js.map +1 -1
- package/dist/esm/core/NiceBrushEngine.js +205 -69
- package/dist/esm/core/NiceBrushEngine.js.map +1 -1
- package/dist/esm/core/collaboration.js +35 -21
- package/dist/esm/core/collaboration.js.map +1 -1
- package/dist/esm/core/colorBlindness.js +64 -24
- package/dist/esm/core/colorBlindness.js.map +1 -1
- package/dist/esm/core/dragDrop.js +34 -26
- package/dist/esm/core/dragDrop.js.map +1 -1
- package/dist/esm/core/fixes.js +26 -14
- package/dist/esm/core/fixes.js.map +1 -1
- package/dist/esm/core/gridGuides.js +24 -16
- package/dist/esm/core/gridGuides.js.map +1 -1
- package/dist/esm/core/historyVisual.js +42 -23
- package/dist/esm/core/historyVisual.js.map +1 -1
- package/dist/esm/core/integrations.js +65 -48
- package/dist/esm/core/integrations.js.map +1 -1
- package/dist/esm/core/minimap.js +40 -24
- package/dist/esm/core/minimap.js.map +1 -1
- package/dist/esm/core/plugins.js +10 -6
- package/dist/esm/core/plugins.js.map +1 -1
- package/dist/esm/core/rtl.js +32 -27
- package/dist/esm/core/rtl.js.map +1 -1
- package/dist/esm/core/shortcuts.js +77 -39
- package/dist/esm/core/shortcuts.js.map +1 -1
- package/dist/esm/core/theme.js +68 -61
- package/dist/esm/core/theme.js.map +1 -1
- package/dist/esm/core/yjsCollaboration.js +61 -28
- package/dist/esm/core/yjsCollaboration.js.map +1 -1
- package/dist/esm/font/NiceFontEditor.js +160 -57
- package/dist/esm/font/NiceFontEditor.js.map +1 -1
- package/dist/esm/font/fontFormatUtils.js +37 -24
- package/dist/esm/font/fontFormatUtils.js.map +1 -1
- package/dist/esm/game/GameAsset2dEditor.js +73 -60
- package/dist/esm/game/GameAsset2dEditor.js.map +1 -1
- package/dist/esm/game/gameAssetUtils.js +18 -13
- package/dist/esm/game/gameAssetUtils.js.map +1 -1
- package/dist/esm/game/useGameAssetEditor.js +160 -143
- package/dist/esm/game/useGameAssetEditor.js.map +1 -1
- package/dist/esm/icon/NiceIconEditor.js +329 -106
- package/dist/esm/icon/NiceIconEditor.js.map +1 -1
- package/dist/esm/packages/ui/dist/NiceErrorBoundary-D75yr_WE.js +563 -0
- package/dist/esm/packages/ui/dist/NiceErrorBoundary-D75yr_WE.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceForm-CKoJA6NG.js +4960 -0
- package/dist/esm/packages/ui/dist/NiceForm-CKoJA6NG.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceModal-1QX7NhyH.js +96 -0
- package/dist/esm/packages/ui/dist/NiceModal-1QX7NhyH.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js +5201 -0
- package/dist/esm/packages/ui/dist/NiceModuleLifecyclePanel-CMrPbSw9.js.map +1 -0
- package/dist/esm/packages/ui/dist/NicePagination-DbE-uOkl.js +172 -0
- package/dist/esm/packages/ui/dist/NicePagination-DbE-uOkl.js.map +1 -0
- package/dist/esm/packages/ui/dist/NicePinCodeInput-B8cI8zu8.js +10408 -0
- package/dist/esm/packages/ui/dist/NicePinCodeInput-B8cI8zu8.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js +6296 -0
- package/dist/esm/packages/ui/dist/NiceSavedQueryPanel-CZ5bYOe_.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceTabs-DzLHzwuA.js +1630 -0
- package/dist/esm/packages/ui/dist/NiceTabs-DzLHzwuA.js.map +1 -0
- package/dist/esm/packages/ui/dist/NiceWindow-DeC83yfE.js +796 -0
- package/dist/esm/packages/ui/dist/NiceWindow-DeC83yfE.js.map +1 -0
- package/dist/esm/packages/ui/dist/charts-BAS21jkC.js +3809 -0
- package/dist/esm/packages/ui/dist/charts-BAS21jkC.js.map +1 -0
- package/dist/esm/packages/ui/dist/core-Da43q-pO.js +11502 -0
- package/dist/esm/packages/ui/dist/core-Da43q-pO.js.map +1 -0
- package/dist/esm/packages/ui/dist/index-pAuGTbuB.js +28792 -0
- package/dist/esm/packages/ui/dist/index-pAuGTbuB.js.map +1 -0
- package/dist/esm/photo/FilterThumb.js +7 -5
- package/dist/esm/photo/FilterThumb.js.map +1 -1
- package/dist/esm/photo/NiceAITools.js +78 -32
- package/dist/esm/photo/NiceAITools.js.map +1 -1
- package/dist/esm/photo/PhotoEditor.js +4 -4
- package/dist/esm/photo/PhotoEditor.js.map +1 -1
- package/dist/esm/photo/PhotoEditorCanvas.js +56 -22
- package/dist/esm/photo/PhotoEditorCanvas.js.map +1 -1
- package/dist/esm/photo/PhotoEditorLeftPanel.js +106 -48
- package/dist/esm/photo/PhotoEditorLeftPanel.js.map +1 -1
- package/dist/esm/photo/PhotoEditorToolbar.js +2 -2
- package/dist/esm/photo/PhotoEditorToolbar.js.map +1 -1
- package/dist/esm/photo/photoEditorActions.js +27 -18
- package/dist/esm/photo/photoEditorActions.js.map +1 -1
- package/dist/esm/photo/photoFilters.js +316 -81
- package/dist/esm/photo/photoFilters.js.map +1 -1
- package/dist/esm/photo/photoOverlays.js +521 -165
- package/dist/esm/photo/photoOverlays.js.map +1 -1
- package/dist/esm/photo/photoSelection.js +69 -35
- package/dist/esm/photo/photoSelection.js.map +1 -1
- package/dist/esm/photo/usePhotoEditor.js +203 -97
- package/dist/esm/photo/usePhotoEditor.js.map +1 -1
- package/dist/esm/pixel/HSVPicker.js +32 -19
- package/dist/esm/pixel/HSVPicker.js.map +1 -1
- package/dist/esm/pixel/PixelEditor.js +25 -14
- package/dist/esm/pixel/PixelEditor.js.map +1 -1
- package/dist/esm/pixel/PixelEditorCanvas.js +2 -2
- package/dist/esm/pixel/PixelEditorCanvas.js.map +1 -1
- package/dist/esm/pixel/PixelEditorMenuBar.js +3 -3
- package/dist/esm/pixel/PixelEditorMenuBar.js.map +1 -1
- package/dist/esm/pixel/PixelEditorRightPanel.js +28 -8
- package/dist/esm/pixel/PixelEditorRightPanel.js.map +1 -1
- package/dist/esm/pixel/PixelEditorStatusBar.js +2 -2
- package/dist/esm/pixel/PixelEditorStatusBar.js.map +1 -1
- package/dist/esm/pixel/PixelEditorTimeline.js +3 -4
- package/dist/esm/pixel/PixelEditorTimeline.js.map +1 -1
- package/dist/esm/pixel/PixelEditorToolbar.js +3 -3
- package/dist/esm/pixel/PixelEditorToolbar.js.map +1 -1
- package/dist/esm/pixel/SpriteGeneratorPanel.js +136 -54
- package/dist/esm/pixel/SpriteGeneratorPanel.js.map +1 -1
- package/dist/esm/pixel/asepriteFormat.js +122 -38
- package/dist/esm/pixel/asepriteFormat.js.map +1 -1
- package/dist/esm/pixel/characterGeneratorPresets.js +208 -54
- package/dist/esm/pixel/characterGeneratorPresets.js.map +1 -1
- package/dist/esm/pixel/pixelEditorExports.js +42 -35
- package/dist/esm/pixel/pixelEditorExports.js.map +1 -1
- package/dist/esm/pixel/pixelEditorTypes.js +67 -33
- package/dist/esm/pixel/pixelEditorTypes.js.map +1 -1
- package/dist/esm/pixel/pixelEditorUtils.js +62 -38
- package/dist/esm/pixel/pixelEditorUtils.js.map +1 -1
- package/dist/esm/pixel/spriteGeneratorCore.js +47 -24
- package/dist/esm/pixel/spriteGeneratorCore.js.map +1 -1
- package/dist/esm/pixel/usePixelEditor.js +475 -213
- package/dist/esm/pixel/usePixelEditor.js.map +1 -1
- package/dist/esm/texture/Nice3DTexturePainter.js +201 -71
- package/dist/esm/texture/Nice3DTexturePainter.js.map +1 -1
- package/dist/esm/ui/NiceUIDesigner.js +280 -91
- package/dist/esm/ui/NiceUIDesigner.js.map +1 -1
- package/dist/esm/vector/NiceSvgToCode.js +96 -34
- package/dist/esm/vector/NiceSvgToCode.js.map +1 -1
- package/dist/esm/vector/VectorEditor.js +14 -13
- package/dist/esm/vector/VectorEditor.js.map +1 -1
- package/dist/esm/vector/VectorEditorMenuBar.js +7 -6
- package/dist/esm/vector/VectorEditorMenuBar.js.map +1 -1
- package/dist/esm/vector/VectorEditorRightPanel.js +87 -32
- package/dist/esm/vector/VectorEditorRightPanel.js.map +1 -1
- package/dist/esm/vector/VectorEditorShapeRenderer.js +17 -15
- package/dist/esm/vector/VectorEditorShapeRenderer.js.map +1 -1
- package/dist/esm/vector/VectorEditorStatusBar.js.map +1 -1
- package/dist/esm/vector/useVectorEditor.js +312 -122
- package/dist/esm/vector/useVectorEditor.js.map +1 -1
- package/dist/esm/vector/vectorBooleanOps.js +60 -42
- package/dist/esm/vector/vectorBooleanOps.js.map +1 -1
- package/dist/esm/vector/vectorEditorExport.js +40 -34
- package/dist/esm/vector/vectorEditorExport.js.map +1 -1
- package/dist/esm/vector/vectorGradients.js +41 -40
- package/dist/esm/vector/vectorGradients.js.map +1 -1
- package/package.json +2 -2
|
@@ -5,30 +5,31 @@ import React from 'react';
|
|
|
5
5
|
const DEFAULT_ICON_CONFIG = {
|
|
6
6
|
viewBox: 24,
|
|
7
7
|
strokeWidth: 2,
|
|
8
|
-
strokeLinecap:
|
|
9
|
-
strokeLinejoin:
|
|
10
|
-
fill:
|
|
11
|
-
stroke:
|
|
12
|
-
variant:
|
|
8
|
+
strokeLinecap: 'round',
|
|
9
|
+
strokeLinejoin: 'round',
|
|
10
|
+
fill: 'none',
|
|
11
|
+
stroke: 'currentColor',
|
|
12
|
+
variant: 'outline',
|
|
13
13
|
};
|
|
14
14
|
// ── Hook ────────────────────────────────────────────────────────
|
|
15
15
|
function useIconEditor(initialSvg) {
|
|
16
16
|
const [config, setConfig] = React.useState(DEFAULT_ICON_CONFIG);
|
|
17
17
|
const [shapes, setShapes] = React.useState([]);
|
|
18
18
|
const [selectedId, setSelectedId] = React.useState(null);
|
|
19
|
-
const [tool, setTool] = React.useState(
|
|
19
|
+
const [tool, setTool] = React.useState('select');
|
|
20
20
|
const [snapToGrid, setSnapToGrid] = React.useState(true);
|
|
21
21
|
const [historyIdx, setHistoryIdx] = React.useState(0);
|
|
22
22
|
const historyRef = React.useRef([[]]);
|
|
23
23
|
// Parse initial SVG
|
|
24
24
|
React.useEffect(() => {
|
|
25
|
-
if (!initialSvg)
|
|
25
|
+
if (!initialSvg) {
|
|
26
26
|
return;
|
|
27
|
+
}
|
|
27
28
|
const pathMatches = initialSvg.matchAll(/<path[^>]*d="([^"]*)"[^>]*\/?>/g);
|
|
28
29
|
const parsed = [];
|
|
29
30
|
let id = 0;
|
|
30
31
|
for (const match of pathMatches) {
|
|
31
|
-
parsed.push({ id: `shape-${id++}`, type:
|
|
32
|
+
parsed.push({ id: `shape-${id++}`, type: 'path', d: match[1] });
|
|
32
33
|
}
|
|
33
34
|
if (parsed.length > 0) {
|
|
34
35
|
setShapes(parsed);
|
|
@@ -40,20 +41,23 @@ function useIconEditor(initialSvg) {
|
|
|
40
41
|
const snap = JSON.parse(JSON.stringify(newShapes));
|
|
41
42
|
historyRef.current = historyRef.current.slice(0, historyIdx + 1);
|
|
42
43
|
historyRef.current.push(snap);
|
|
43
|
-
if (historyRef.current.length > 50)
|
|
44
|
+
if (historyRef.current.length > 50) {
|
|
44
45
|
historyRef.current.shift();
|
|
46
|
+
}
|
|
45
47
|
setHistoryIdx(historyRef.current.length - 1);
|
|
46
48
|
}, [historyIdx]);
|
|
47
49
|
const undo = React.useCallback(() => {
|
|
48
|
-
if (historyIdx <= 0)
|
|
50
|
+
if (historyIdx <= 0) {
|
|
49
51
|
return;
|
|
52
|
+
}
|
|
50
53
|
const newIdx = historyIdx - 1;
|
|
51
54
|
setHistoryIdx(newIdx);
|
|
52
55
|
setShapes(JSON.parse(JSON.stringify(historyRef.current[newIdx])));
|
|
53
56
|
}, [historyIdx]);
|
|
54
57
|
const redo = React.useCallback(() => {
|
|
55
|
-
if (historyIdx >= historyRef.current.length - 1)
|
|
58
|
+
if (historyIdx >= historyRef.current.length - 1) {
|
|
56
59
|
return;
|
|
60
|
+
}
|
|
57
61
|
const newIdx = historyIdx + 1;
|
|
58
62
|
setHistoryIdx(newIdx);
|
|
59
63
|
setShapes(JSON.parse(JSON.stringify(historyRef.current[newIdx])));
|
|
@@ -73,61 +77,73 @@ function useIconEditor(initialSvg) {
|
|
|
73
77
|
const deleteShape = React.useCallback((id) => {
|
|
74
78
|
const newShapes = shapes.filter((s) => s.id !== id);
|
|
75
79
|
setShapes(newShapes);
|
|
76
|
-
if (selectedId === id)
|
|
80
|
+
if (selectedId === id) {
|
|
77
81
|
setSelectedId(null);
|
|
82
|
+
}
|
|
78
83
|
pushHistory(newShapes);
|
|
79
84
|
}, [shapes, selectedId, pushHistory]);
|
|
80
85
|
const toSvg = React.useCallback(() => {
|
|
81
86
|
const vb = config.viewBox;
|
|
82
|
-
const children = shapes
|
|
87
|
+
const children = shapes
|
|
88
|
+
.map((s) => {
|
|
83
89
|
var _a, _b, _c;
|
|
84
90
|
const fill = (_a = s.fill) !== null && _a !== void 0 ? _a : config.fill;
|
|
85
91
|
const stroke = (_b = s.stroke) !== null && _b !== void 0 ? _b : config.stroke;
|
|
86
92
|
const sw = (_c = s.strokeWidth) !== null && _c !== void 0 ? _c : config.strokeWidth;
|
|
87
93
|
switch (s.type) {
|
|
88
|
-
case
|
|
94
|
+
case 'path':
|
|
89
95
|
return ` <path d="${s.d}" fill="${fill}" stroke="${stroke}" stroke-width="${sw}" stroke-linecap="${config.strokeLinecap}" stroke-linejoin="${config.strokeLinejoin}" />`;
|
|
90
|
-
case
|
|
96
|
+
case 'circle':
|
|
91
97
|
return ` <circle cx="${s.cx}" cy="${s.cy}" r="${s.r}" fill="${fill}" stroke="${stroke}" stroke-width="${sw}" />`;
|
|
92
|
-
case
|
|
98
|
+
case 'rect':
|
|
93
99
|
return ` <rect x="${s.x}" y="${s.y}" width="${s.width}" height="${s.height}" fill="${fill}" stroke="${stroke}" stroke-width="${sw}" rx="1" />`;
|
|
94
|
-
case
|
|
100
|
+
case 'line':
|
|
95
101
|
return ` <line x1="${s.x1}" y1="${s.y1}" x2="${s.x2}" y2="${s.y2}" stroke="${stroke}" stroke-width="${sw}" stroke-linecap="${config.strokeLinecap}" />`;
|
|
96
102
|
default:
|
|
97
|
-
return
|
|
103
|
+
return '';
|
|
98
104
|
}
|
|
99
|
-
})
|
|
105
|
+
})
|
|
106
|
+
.join('\n');
|
|
100
107
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${vb}" height="${vb}" viewBox="0 0 ${vb} ${vb}" fill="${config.fill}" stroke="${config.stroke}" stroke-width="${config.strokeWidth}" stroke-linecap="${config.strokeLinecap}" stroke-linejoin="${config.strokeLinejoin}">\n${children}\n</svg>`;
|
|
101
108
|
}, [shapes, config]);
|
|
102
109
|
const toReactComponent = React.useCallback((name) => {
|
|
103
110
|
const svg = toSvg();
|
|
104
111
|
const inner = svg
|
|
105
|
-
.replace(/<svg[^>]*>/,
|
|
106
|
-
.replace(/<\/svg>/,
|
|
112
|
+
.replace(/<svg[^>]*>/, '')
|
|
113
|
+
.replace(/<\/svg>/, '')
|
|
107
114
|
.trim()
|
|
108
|
-
.replace(/stroke-width/g,
|
|
109
|
-
.replace(/stroke-linecap/g,
|
|
110
|
-
.replace(/stroke-linejoin/g,
|
|
111
|
-
.replace(/fill-rule/g,
|
|
112
|
-
.replace(/clip-rule/g,
|
|
115
|
+
.replace(/stroke-width/g, 'strokeWidth')
|
|
116
|
+
.replace(/stroke-linecap/g, 'strokeLinecap')
|
|
117
|
+
.replace(/stroke-linejoin/g, 'strokeLinejoin')
|
|
118
|
+
.replace(/fill-rule/g, 'fillRule')
|
|
119
|
+
.replace(/clip-rule/g, 'clipRule');
|
|
113
120
|
return `import React from "react";\n\nexport const ${name}: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (\n <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 ${config.viewBox} ${config.viewBox}" fill="${config.fill}" stroke="${config.stroke}" strokeWidth="${config.strokeWidth}" strokeLinecap="${config.strokeLinecap}" strokeLinejoin="${config.strokeLinejoin}" {...props}>\n ${inner}\n </svg>\n);\n`;
|
|
114
121
|
}, [toSvg, config]);
|
|
115
122
|
return {
|
|
116
|
-
config,
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
config,
|
|
124
|
+
setConfig,
|
|
125
|
+
shapes,
|
|
126
|
+
setShapes,
|
|
127
|
+
selectedId,
|
|
128
|
+
setSelectedId,
|
|
129
|
+
tool,
|
|
130
|
+
setTool,
|
|
131
|
+
addShape,
|
|
132
|
+
updateShape,
|
|
133
|
+
deleteShape,
|
|
134
|
+
toSvg,
|
|
135
|
+
toReactComponent,
|
|
136
|
+
undo,
|
|
137
|
+
redo,
|
|
123
138
|
canUndo: historyIdx > 0,
|
|
124
139
|
canRedo: historyIdx < historyRef.current.length - 1,
|
|
125
|
-
snapToGrid,
|
|
140
|
+
snapToGrid,
|
|
141
|
+
setSnapToGrid,
|
|
126
142
|
};
|
|
127
143
|
}
|
|
128
144
|
// ── Component ───────────────────────────────────────────────────
|
|
129
145
|
/** SVG icon editor with grid, snap, drawing, and export capabilities. */
|
|
130
|
-
const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className =
|
|
146
|
+
const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className = '', }) => {
|
|
131
147
|
const editor = useIconEditor(initialSvg);
|
|
132
148
|
const svgRef = React.useRef(null);
|
|
133
149
|
const drawing = React.useRef(false);
|
|
@@ -139,47 +155,56 @@ const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className
|
|
|
139
155
|
// Keyboard shortcuts
|
|
140
156
|
React.useEffect(() => {
|
|
141
157
|
const handler = (e) => {
|
|
142
|
-
if (e.key ===
|
|
158
|
+
if (e.key === 'Delete' && editor.selectedId) {
|
|
143
159
|
editor.deleteShape(editor.selectedId);
|
|
144
160
|
return;
|
|
145
161
|
}
|
|
146
|
-
if (e.ctrlKey && e.key ===
|
|
162
|
+
if (e.ctrlKey && e.key === 'z') {
|
|
147
163
|
e.preventDefault();
|
|
148
164
|
editor.undo();
|
|
149
165
|
return;
|
|
150
166
|
}
|
|
151
|
-
if (e.ctrlKey && e.key ===
|
|
167
|
+
if (e.ctrlKey && e.key === 'y') {
|
|
152
168
|
e.preventDefault();
|
|
153
169
|
editor.redo();
|
|
154
170
|
return;
|
|
155
171
|
}
|
|
156
|
-
if (e.key ===
|
|
157
|
-
editor.setTool(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (e.key ===
|
|
163
|
-
editor.setTool(
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
if (e.key ===
|
|
172
|
+
if (e.key === 'v' && !e.ctrlKey) {
|
|
173
|
+
editor.setTool('select');
|
|
174
|
+
}
|
|
175
|
+
if (e.key === 'c' && !e.ctrlKey) {
|
|
176
|
+
editor.setTool('circle');
|
|
177
|
+
}
|
|
178
|
+
if (e.key === 'r' && !e.ctrlKey) {
|
|
179
|
+
editor.setTool('rect');
|
|
180
|
+
}
|
|
181
|
+
if (e.key === 'l' && !e.ctrlKey) {
|
|
182
|
+
editor.setTool('line');
|
|
183
|
+
}
|
|
184
|
+
if (e.key === 'p' && !e.ctrlKey) {
|
|
185
|
+
editor.setTool('path');
|
|
186
|
+
}
|
|
187
|
+
if (e.key === 'g' && !e.ctrlKey) {
|
|
188
|
+
editor.setSnapToGrid((s) => !s);
|
|
189
|
+
}
|
|
190
|
+
if (e.key === 'Escape') {
|
|
169
191
|
editor.setSelectedId(null);
|
|
192
|
+
}
|
|
170
193
|
};
|
|
171
|
-
window.addEventListener(
|
|
172
|
-
return () => window.removeEventListener(
|
|
194
|
+
window.addEventListener('keydown', handler);
|
|
195
|
+
return () => window.removeEventListener('keydown', handler);
|
|
173
196
|
}, [editor]);
|
|
174
197
|
const snapCoord = (v) => {
|
|
175
|
-
if (!editor.snapToGrid)
|
|
198
|
+
if (!editor.snapToGrid) {
|
|
176
199
|
return v;
|
|
200
|
+
}
|
|
177
201
|
return Math.round(v * 2) / 2; // snap to 0.5 grid
|
|
178
202
|
};
|
|
179
203
|
const getSvgCoord = (e) => {
|
|
180
204
|
const svg = svgRef.current;
|
|
181
|
-
if (!svg)
|
|
205
|
+
if (!svg) {
|
|
182
206
|
return { x: 0, y: 0 };
|
|
207
|
+
}
|
|
183
208
|
const rect = svg.getBoundingClientRect();
|
|
184
209
|
return {
|
|
185
210
|
x: snapCoord(((e.clientX - rect.left) / rect.width) * vb),
|
|
@@ -188,14 +213,19 @@ const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className
|
|
|
188
213
|
};
|
|
189
214
|
const handleMouseDown = (e) => {
|
|
190
215
|
const { x, y } = getSvgCoord(e);
|
|
191
|
-
if (editor.tool ===
|
|
216
|
+
if (editor.tool === 'select') {
|
|
192
217
|
// Check if clicking on a shape for drag
|
|
193
|
-
const hit = editor.shapes.find(s => {
|
|
218
|
+
const hit = editor.shapes.find((s) => {
|
|
194
219
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
195
|
-
if (s.type ===
|
|
196
|
-
return x >= ((_a = s.x) !== null && _a !== void 0 ? _a : 0) &&
|
|
197
|
-
|
|
220
|
+
if (s.type === 'rect') {
|
|
221
|
+
return (x >= ((_a = s.x) !== null && _a !== void 0 ? _a : 0) &&
|
|
222
|
+
x <= ((_b = s.x) !== null && _b !== void 0 ? _b : 0) + ((_c = s.width) !== null && _c !== void 0 ? _c : 0) &&
|
|
223
|
+
y >= ((_d = s.y) !== null && _d !== void 0 ? _d : 0) &&
|
|
224
|
+
y <= ((_e = s.y) !== null && _e !== void 0 ? _e : 0) + ((_f = s.height) !== null && _f !== void 0 ? _f : 0));
|
|
225
|
+
}
|
|
226
|
+
if (s.type === 'circle') {
|
|
198
227
|
return Math.hypot(x - ((_g = s.cx) !== null && _g !== void 0 ? _g : 0), y - ((_h = s.cy) !== null && _h !== void 0 ? _h : 0)) <= ((_j = s.r) !== null && _j !== void 0 ? _j : 0);
|
|
228
|
+
}
|
|
199
229
|
return false;
|
|
200
230
|
});
|
|
201
231
|
if (hit) {
|
|
@@ -210,14 +240,14 @@ const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className
|
|
|
210
240
|
}
|
|
211
241
|
drawing.current = true;
|
|
212
242
|
drawStart.current = { x, y };
|
|
213
|
-
if (editor.tool ===
|
|
214
|
-
setPendingShape({ id:
|
|
243
|
+
if (editor.tool === 'circle') {
|
|
244
|
+
setPendingShape({ id: 'pending', type: 'circle', cx: x, cy: y, r: 0 });
|
|
215
245
|
}
|
|
216
|
-
else if (editor.tool ===
|
|
217
|
-
setPendingShape({ id:
|
|
246
|
+
else if (editor.tool === 'rect') {
|
|
247
|
+
setPendingShape({ id: 'pending', type: 'rect', x, y, width: 0, height: 0 });
|
|
218
248
|
}
|
|
219
|
-
else if (editor.tool ===
|
|
220
|
-
setPendingShape({ id:
|
|
249
|
+
else if (editor.tool === 'line') {
|
|
250
|
+
setPendingShape({ id: 'pending', type: 'line', x1: x, y1: y, x2: x, y2: y });
|
|
221
251
|
}
|
|
222
252
|
};
|
|
223
253
|
const handleMouseMove = (e) => {
|
|
@@ -227,27 +257,43 @@ const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className
|
|
|
227
257
|
if (draggingShape.current) {
|
|
228
258
|
const dx = x - dragStart.current.x;
|
|
229
259
|
const dy = y - dragStart.current.y;
|
|
230
|
-
const shape = editor.shapes.find(s => s.id === draggingShape.current);
|
|
260
|
+
const shape = editor.shapes.find((s) => s.id === draggingShape.current);
|
|
231
261
|
if (shape) {
|
|
232
|
-
if (shape.type ===
|
|
262
|
+
if (shape.type === 'rect') {
|
|
233
263
|
editor.updateShape(shape.id, { x: ((_a = shape.x) !== null && _a !== void 0 ? _a : 0) + dx, y: ((_b = shape.y) !== null && _b !== void 0 ? _b : 0) + dy });
|
|
234
|
-
|
|
264
|
+
}
|
|
265
|
+
if (shape.type === 'circle') {
|
|
235
266
|
editor.updateShape(shape.id, { cx: ((_c = shape.cx) !== null && _c !== void 0 ? _c : 0) + dx, cy: ((_d = shape.cy) !== null && _d !== void 0 ? _d : 0) + dy });
|
|
267
|
+
}
|
|
236
268
|
dragStart.current = { x, y };
|
|
237
269
|
}
|
|
238
270
|
return;
|
|
239
271
|
}
|
|
240
|
-
if (!drawing.current)
|
|
272
|
+
if (!drawing.current) {
|
|
241
273
|
return;
|
|
274
|
+
}
|
|
242
275
|
const sx = drawStart.current.x, sy = drawStart.current.y;
|
|
243
|
-
if (editor.tool ===
|
|
244
|
-
setPendingShape({
|
|
276
|
+
if (editor.tool === 'circle') {
|
|
277
|
+
setPendingShape({
|
|
278
|
+
id: 'pending',
|
|
279
|
+
type: 'circle',
|
|
280
|
+
cx: sx,
|
|
281
|
+
cy: sy,
|
|
282
|
+
r: Math.hypot(x - sx, y - sy),
|
|
283
|
+
});
|
|
245
284
|
}
|
|
246
|
-
else if (editor.tool ===
|
|
247
|
-
setPendingShape({
|
|
285
|
+
else if (editor.tool === 'rect') {
|
|
286
|
+
setPendingShape({
|
|
287
|
+
id: 'pending',
|
|
288
|
+
type: 'rect',
|
|
289
|
+
x: Math.min(sx, x),
|
|
290
|
+
y: Math.min(sy, y),
|
|
291
|
+
width: Math.abs(x - sx),
|
|
292
|
+
height: Math.abs(y - sy),
|
|
293
|
+
});
|
|
248
294
|
}
|
|
249
|
-
else if (editor.tool ===
|
|
250
|
-
setPendingShape({ id:
|
|
295
|
+
else if (editor.tool === 'line') {
|
|
296
|
+
setPendingShape({ id: 'pending', type: 'line', x1: sx, y1: sy, x2: x, y2: y });
|
|
251
297
|
}
|
|
252
298
|
};
|
|
253
299
|
const handleMouseUp = () => {
|
|
@@ -260,17 +306,20 @@ const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className
|
|
|
260
306
|
drawing.current = false;
|
|
261
307
|
// Only add if shape has non-zero size
|
|
262
308
|
const { id: _, ...shapeData } = pendingShape;
|
|
263
|
-
if (pendingShape.type ===
|
|
309
|
+
if (pendingShape.type === 'circle' && ((_a = pendingShape.r) !== null && _a !== void 0 ? _a : 0) > 0.2) {
|
|
264
310
|
editor.addShape(shapeData);
|
|
265
311
|
}
|
|
266
|
-
else if (pendingShape.type ===
|
|
312
|
+
else if (pendingShape.type === 'rect' &&
|
|
313
|
+
((_b = pendingShape.width) !== null && _b !== void 0 ? _b : 0) > 0.2 &&
|
|
314
|
+
((_c = pendingShape.height) !== null && _c !== void 0 ? _c : 0) > 0.2) {
|
|
267
315
|
editor.addShape(shapeData);
|
|
268
316
|
}
|
|
269
|
-
else if (pendingShape.type ===
|
|
317
|
+
else if (pendingShape.type === 'line') {
|
|
270
318
|
const dx = ((_d = pendingShape.x2) !== null && _d !== void 0 ? _d : 0) - ((_e = pendingShape.x1) !== null && _e !== void 0 ? _e : 0);
|
|
271
319
|
const dy = ((_f = pendingShape.y2) !== null && _f !== void 0 ? _f : 0) - ((_g = pendingShape.y1) !== null && _g !== void 0 ? _g : 0);
|
|
272
|
-
if (Math.hypot(dx, dy) > 0.2)
|
|
320
|
+
if (Math.hypot(dx, dy) > 0.2) {
|
|
273
321
|
editor.addShape(shapeData);
|
|
322
|
+
}
|
|
274
323
|
}
|
|
275
324
|
setPendingShape(null);
|
|
276
325
|
};
|
|
@@ -279,20 +328,28 @@ const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className
|
|
|
279
328
|
const svg = editor.toSvg();
|
|
280
329
|
const pngSizes = new Map();
|
|
281
330
|
for (const size of sizes) {
|
|
282
|
-
const canvas = document.createElement(
|
|
331
|
+
const canvas = document.createElement('canvas');
|
|
283
332
|
canvas.width = size;
|
|
284
333
|
canvas.height = size;
|
|
285
|
-
const ctx = canvas.getContext(
|
|
334
|
+
const ctx = canvas.getContext('2d');
|
|
286
335
|
const img = new Image();
|
|
287
|
-
const blob = new Blob([svg], { type:
|
|
336
|
+
const blob = new Blob([svg], { type: 'image/svg+xml' });
|
|
288
337
|
const url = URL.createObjectURL(blob);
|
|
289
338
|
await new Promise((resolve) => {
|
|
290
|
-
img.onload = () => {
|
|
291
|
-
|
|
339
|
+
img.onload = () => {
|
|
340
|
+
ctx.drawImage(img, 0, 0, size, size);
|
|
341
|
+
canvas.toBlob((b) => {
|
|
342
|
+
if (b) {
|
|
343
|
+
pngSizes.set(size, b);
|
|
344
|
+
}
|
|
345
|
+
URL.revokeObjectURL(url);
|
|
346
|
+
resolve();
|
|
347
|
+
}, 'image/png');
|
|
348
|
+
};
|
|
292
349
|
img.src = url;
|
|
293
350
|
});
|
|
294
351
|
}
|
|
295
|
-
onExport === null || onExport === void 0 ? void 0 : onExport({ svg, reactComponent: editor.toReactComponent(
|
|
352
|
+
onExport === null || onExport === void 0 ? void 0 : onExport({ svg, reactComponent: editor.toReactComponent('MyIcon'), pngSizes });
|
|
296
353
|
};
|
|
297
354
|
const renderShape = (s, isPending = false) => {
|
|
298
355
|
var _a, _b, _c;
|
|
@@ -300,31 +357,197 @@ const NiceIconEditor = ({ initialSvg, gridSize = 24, onSave, onExport, className
|
|
|
300
357
|
const stroke = (_b = s.stroke) !== null && _b !== void 0 ? _b : editor.config.stroke;
|
|
301
358
|
const sw = (_c = s.strokeWidth) !== null && _c !== void 0 ? _c : editor.config.strokeWidth;
|
|
302
359
|
const isSelected = !isPending && s.id === editor.selectedId;
|
|
303
|
-
const selProps = isSelected ? { strokeDasharray:
|
|
304
|
-
const evtProps = isPending
|
|
360
|
+
const selProps = isSelected ? { strokeDasharray: '0.5 0.3' } : {};
|
|
361
|
+
const evtProps = isPending
|
|
362
|
+
? {}
|
|
363
|
+
: {
|
|
364
|
+
onClick: (e) => {
|
|
365
|
+
e.stopPropagation();
|
|
366
|
+
editor.setSelectedId(s.id);
|
|
367
|
+
},
|
|
368
|
+
style: { cursor: 'pointer' },
|
|
369
|
+
};
|
|
305
370
|
switch (s.type) {
|
|
306
|
-
case
|
|
307
|
-
|
|
308
|
-
case
|
|
309
|
-
|
|
310
|
-
|
|
371
|
+
case 'path':
|
|
372
|
+
return (jsx("path", { d: s.d, fill: fill, stroke: isSelected ? '#339af0' : stroke, strokeWidth: sw * (vb / 400), strokeLinecap: editor.config.strokeLinecap, strokeLinejoin: editor.config.strokeLinejoin, ...evtProps }, s.id));
|
|
373
|
+
case 'circle':
|
|
374
|
+
return (jsx("circle", { cx: s.cx, cy: s.cy, r: s.r, fill: isPending ? 'rgba(51,154,240,0.15)' : fill, stroke: isSelected ? '#339af0' : isPending ? '#339af0' : stroke, strokeWidth: sw * (vb / 400), ...selProps, ...evtProps }, s.id));
|
|
375
|
+
case 'rect':
|
|
376
|
+
return (jsx("rect", { x: s.x, y: s.y, width: s.width, height: s.height, fill: isPending ? 'rgba(51,154,240,0.15)' : fill, stroke: isSelected ? '#339af0' : isPending ? '#339af0' : stroke, strokeWidth: sw * (vb / 400), rx: 0.3, ...selProps, ...evtProps }, s.id));
|
|
377
|
+
case 'line':
|
|
378
|
+
return (jsx("line", { x1: s.x1, y1: s.y1, x2: s.x2, y2: s.y2, stroke: isSelected ? '#339af0' : isPending ? '#339af0' : stroke, strokeWidth: sw * (vb / 400), strokeLinecap: editor.config.strokeLinecap, ...selProps, ...evtProps }, s.id));
|
|
379
|
+
default:
|
|
380
|
+
return null;
|
|
311
381
|
}
|
|
312
382
|
};
|
|
313
383
|
const toolBtnStyle = (active) => ({
|
|
314
|
-
padding:
|
|
315
|
-
|
|
384
|
+
padding: '4px 8px',
|
|
385
|
+
borderRadius: 4,
|
|
386
|
+
border: 'none',
|
|
387
|
+
cursor: 'pointer',
|
|
388
|
+
background: active ? '#339af0' : '#2c2e33',
|
|
389
|
+
color: active ? '#fff' : '#c1c2c5',
|
|
390
|
+
fontSize: 11,
|
|
316
391
|
});
|
|
317
|
-
return (jsxs("div", { className: `nice-icon-editor ${className}`, style: {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
392
|
+
return (jsxs("div", { className: `nice-icon-editor ${className}`, style: {
|
|
393
|
+
display: 'flex',
|
|
394
|
+
flexDirection: 'column',
|
|
395
|
+
gap: 8,
|
|
396
|
+
background: '#1a1b1e',
|
|
397
|
+
color: '#c1c2c5',
|
|
398
|
+
padding: 12,
|
|
399
|
+
borderRadius: 8,
|
|
400
|
+
}, children: [jsxs("div", { style: { display: 'flex', gap: 4, fontSize: 12, alignItems: 'center', flexWrap: 'wrap' }, children: [['select', 'path', 'circle', 'rect', 'line'].map((t) => (jsxs("button", { onClick: () => editor.setTool(t), style: toolBtnStyle(editor.tool === t), children: [t, " (", t[0], ")"] }, t))), jsx("div", { style: { width: 1, height: 20, background: '#373a40' } }), jsx("button", { onClick: editor.undo, disabled: !editor.canUndo, style: toolBtnStyle(false), title: "Undo (Ctrl+Z)", children: "\u21A9" }), jsx("button", { onClick: editor.redo, disabled: !editor.canRedo, style: toolBtnStyle(false), title: "Redo (Ctrl+Y)", children: "\u21AA" }), jsx("div", { style: { width: 1, height: 20, background: '#373a40' } }), jsx("button", { onClick: () => editor.setSnapToGrid((s) => !s), style: toolBtnStyle(editor.snapToGrid), title: "Snap to Grid (G)", children: "\u229E" }), editor.selectedId && (jsx("button", { onClick: () => editor.deleteShape(editor.selectedId), style: { ...toolBtnStyle(false), color: '#ff6b6b' }, title: "Delete (Del)", children: "\u2715" })), jsx("div", { style: { flex: 1 } }), jsx("button", { onClick: handleSave, style: {
|
|
401
|
+
padding: '4px 12px',
|
|
402
|
+
borderRadius: 4,
|
|
403
|
+
border: 'none',
|
|
404
|
+
cursor: 'pointer',
|
|
405
|
+
background: '#2f9e44',
|
|
406
|
+
color: '#fff',
|
|
407
|
+
fontSize: 11,
|
|
408
|
+
}, children: "Save SVG" }), jsx("button", { onClick: () => handleExportPng(), style: {
|
|
409
|
+
padding: '4px 12px',
|
|
410
|
+
borderRadius: 4,
|
|
411
|
+
border: 'none',
|
|
412
|
+
cursor: 'pointer',
|
|
413
|
+
background: '#228be6',
|
|
414
|
+
color: '#fff',
|
|
415
|
+
fontSize: 11,
|
|
416
|
+
}, children: "Export PNG" })] }), jsxs("div", { style: { display: 'flex', gap: 12 }, children: [jsx("div", { style: {
|
|
417
|
+
width: 400,
|
|
418
|
+
height: 400,
|
|
419
|
+
background: '#141517',
|
|
420
|
+
borderRadius: 6,
|
|
421
|
+
position: 'relative',
|
|
422
|
+
overflow: 'hidden',
|
|
423
|
+
}, children: jsxs("svg", { ref: svgRef, width: 400, height: 400, viewBox: `0 0 ${vb} ${vb}`, style: {
|
|
424
|
+
position: 'absolute',
|
|
425
|
+
inset: 0,
|
|
426
|
+
cursor: editor.tool === 'select' ? 'default' : 'crosshair',
|
|
427
|
+
}, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseUp: handleMouseUp, onMouseLeave: handleMouseUp, children: [Array.from({ length: vb + 1 }, (_, i) => (jsxs(React.Fragment, { children: [jsx("line", { x1: i, y1: 0, x2: i, y2: vb, stroke: "rgba(255,255,255,0.08)", strokeWidth: 0.05 }), jsx("line", { x1: 0, y1: i, x2: vb, y2: i, stroke: "rgba(255,255,255,0.08)", strokeWidth: 0.05 })] }, `g${i}`))), jsx("line", { x1: vb / 2, y1: 0, x2: vb / 2, y2: vb, stroke: "rgba(255,255,255,0.15)", strokeWidth: 0.05 }), jsx("line", { x1: 0, y1: vb / 2, x2: vb, y2: vb / 2, stroke: "rgba(255,255,255,0.15)", strokeWidth: 0.05 }), editor.shapes.map((s) => renderShape(s)), pendingShape && renderShape(pendingShape, true)] }) }), jsxs("div", { style: { flex: 1, display: 'flex', flexDirection: 'column', gap: 8, fontSize: 12 }, children: [jsxs("div", { children: [jsx("label", { children: "Grid Size: " }), jsxs("select", { value: editor.config.viewBox, onChange: (e) => editor.setConfig({ ...editor.config, viewBox: Number(e.target.value) }), style: {
|
|
428
|
+
background: '#2c2e33',
|
|
429
|
+
color: '#c1c2c5',
|
|
430
|
+
border: '1px solid #373a40',
|
|
431
|
+
borderRadius: 3,
|
|
432
|
+
padding: 2,
|
|
433
|
+
}, children: [jsx("option", { value: 16, children: "16\u00D716" }), jsx("option", { value: 24, children: "24\u00D724" }), jsx("option", { value: 32, children: "32\u00D732" }), jsx("option", { value: 48, children: "48\u00D748" })] })] }), jsxs("div", { children: [jsx("label", { children: "Stroke Width: " }), jsx("input", { type: "range", min: 0.5, max: 4, step: 0.25, value: editor.config.strokeWidth, onChange: (e) => editor.setConfig({ ...editor.config, strokeWidth: Number(e.target.value) }), style: { width: 100 } }), jsxs("span", { children: [" ", editor.config.strokeWidth] })] }), jsxs("div", { children: [jsx("label", { children: "Variant: " }), ['outline', 'filled', 'duotone'].map((v) => (jsx("button", { onClick: () => editor.setConfig({ ...editor.config, variant: v }), style: {
|
|
434
|
+
padding: '2px 6px',
|
|
435
|
+
marginLeft: 2,
|
|
436
|
+
borderRadius: 3,
|
|
437
|
+
border: 'none',
|
|
438
|
+
cursor: 'pointer',
|
|
439
|
+
background: editor.config.variant === v ? '#339af0' : '#2c2e33',
|
|
440
|
+
color: editor.config.variant === v ? '#fff' : '#c1c2c5',
|
|
441
|
+
fontSize: 11,
|
|
442
|
+
}, children: v }, v)))] }), editor.selectedId &&
|
|
443
|
+
(() => {
|
|
444
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
445
|
+
const sel = editor.shapes.find((s) => s.id === editor.selectedId);
|
|
446
|
+
if (!sel) {
|
|
447
|
+
return null;
|
|
448
|
+
}
|
|
449
|
+
return (jsxs("div", { style: { borderTop: '1px solid #373a40', paddingTop: 8 }, children: [jsxs("strong", { children: ["Selected: ", sel.type] }), sel.type === 'rect' && (jsxs("div", { style: {
|
|
450
|
+
display: 'grid',
|
|
451
|
+
gridTemplateColumns: '60px 1fr',
|
|
452
|
+
gap: 2,
|
|
453
|
+
marginTop: 4,
|
|
454
|
+
fontSize: 11,
|
|
455
|
+
}, children: [jsx("span", { children: "X:" }), jsx("input", { type: "number", value: (_a = sel.x) !== null && _a !== void 0 ? _a : 0, step: 0.5, onChange: (e) => editor.updateShape(sel.id, { x: Number(e.target.value) }), style: {
|
|
456
|
+
background: '#2c2e33',
|
|
457
|
+
color: '#c1c2c5',
|
|
458
|
+
border: '1px solid #373a40',
|
|
459
|
+
borderRadius: 2,
|
|
460
|
+
padding: 1,
|
|
461
|
+
fontSize: 10,
|
|
462
|
+
} }), jsx("span", { children: "Y:" }), jsx("input", { type: "number", value: (_b = sel.y) !== null && _b !== void 0 ? _b : 0, step: 0.5, onChange: (e) => editor.updateShape(sel.id, { y: Number(e.target.value) }), style: {
|
|
463
|
+
background: '#2c2e33',
|
|
464
|
+
color: '#c1c2c5',
|
|
465
|
+
border: '1px solid #373a40',
|
|
466
|
+
borderRadius: 2,
|
|
467
|
+
padding: 1,
|
|
468
|
+
fontSize: 10,
|
|
469
|
+
} }), jsx("span", { children: "Width:" }), jsx("input", { type: "number", value: (_c = sel.width) !== null && _c !== void 0 ? _c : 0, step: 0.5, onChange: (e) => editor.updateShape(sel.id, { width: Number(e.target.value) }), style: {
|
|
470
|
+
background: '#2c2e33',
|
|
471
|
+
color: '#c1c2c5',
|
|
472
|
+
border: '1px solid #373a40',
|
|
473
|
+
borderRadius: 2,
|
|
474
|
+
padding: 1,
|
|
475
|
+
fontSize: 10,
|
|
476
|
+
} }), jsx("span", { children: "Height:" }), jsx("input", { type: "number", value: (_d = sel.height) !== null && _d !== void 0 ? _d : 0, step: 0.5, onChange: (e) => editor.updateShape(sel.id, { height: Number(e.target.value) }), style: {
|
|
477
|
+
background: '#2c2e33',
|
|
478
|
+
color: '#c1c2c5',
|
|
479
|
+
border: '1px solid #373a40',
|
|
480
|
+
borderRadius: 2,
|
|
481
|
+
padding: 1,
|
|
482
|
+
fontSize: 10,
|
|
483
|
+
} })] })), sel.type === 'circle' && (jsxs("div", { style: {
|
|
484
|
+
display: 'grid',
|
|
485
|
+
gridTemplateColumns: '60px 1fr',
|
|
486
|
+
gap: 2,
|
|
487
|
+
marginTop: 4,
|
|
488
|
+
fontSize: 11,
|
|
489
|
+
}, children: [jsx("span", { children: "CX:" }), jsx("input", { type: "number", value: (_e = sel.cx) !== null && _e !== void 0 ? _e : 0, step: 0.5, onChange: (e) => editor.updateShape(sel.id, { cx: Number(e.target.value) }), style: {
|
|
490
|
+
background: '#2c2e33',
|
|
491
|
+
color: '#c1c2c5',
|
|
492
|
+
border: '1px solid #373a40',
|
|
493
|
+
borderRadius: 2,
|
|
494
|
+
padding: 1,
|
|
495
|
+
fontSize: 10,
|
|
496
|
+
} }), jsx("span", { children: "CY:" }), jsx("input", { type: "number", value: (_f = sel.cy) !== null && _f !== void 0 ? _f : 0, step: 0.5, onChange: (e) => editor.updateShape(sel.id, { cy: Number(e.target.value) }), style: {
|
|
497
|
+
background: '#2c2e33',
|
|
498
|
+
color: '#c1c2c5',
|
|
499
|
+
border: '1px solid #373a40',
|
|
500
|
+
borderRadius: 2,
|
|
501
|
+
padding: 1,
|
|
502
|
+
fontSize: 10,
|
|
503
|
+
} }), jsx("span", { children: "Radius:" }), jsx("input", { type: "number", value: (_g = sel.r) !== null && _g !== void 0 ? _g : 0, step: 0.5, onChange: (e) => editor.updateShape(sel.id, { r: Number(e.target.value) }), style: {
|
|
504
|
+
background: '#2c2e33',
|
|
505
|
+
color: '#c1c2c5',
|
|
506
|
+
border: '1px solid #373a40',
|
|
507
|
+
borderRadius: 2,
|
|
508
|
+
padding: 1,
|
|
509
|
+
fontSize: 10,
|
|
510
|
+
} })] })), sel.type === 'path' && (jsxs("div", { style: { marginTop: 4 }, children: [jsx("label", { style: { fontSize: 10 }, children: "SVG Path:" }), jsx("textarea", { value: (_h = sel.d) !== null && _h !== void 0 ? _h : '', onChange: (e) => editor.updateShape(sel.id, { d: e.target.value }), rows: 3, style: {
|
|
511
|
+
width: '100%',
|
|
512
|
+
background: '#2c2e33',
|
|
513
|
+
color: '#c1c2c5',
|
|
514
|
+
border: '1px solid #373a40',
|
|
515
|
+
borderRadius: 3,
|
|
516
|
+
padding: 4,
|
|
517
|
+
fontSize: 10,
|
|
518
|
+
fontFamily: 'monospace',
|
|
519
|
+
resize: 'vertical',
|
|
520
|
+
} })] })), jsxs("div", { style: { marginTop: 4, display: 'flex', gap: 4, alignItems: 'center' }, children: [jsx("span", { style: { fontSize: 10 }, children: "Fill:" }), jsx("input", { type: "color", value: (_j = sel.fill) !== null && _j !== void 0 ? _j : '#000000', onChange: (e) => editor.updateShape(sel.id, { fill: e.target.value }), style: {
|
|
521
|
+
width: 24,
|
|
522
|
+
height: 18,
|
|
523
|
+
border: 'none',
|
|
524
|
+
padding: 0,
|
|
525
|
+
cursor: 'pointer',
|
|
526
|
+
} }), jsx("span", { style: { fontSize: 10 }, children: "Stroke:" }), jsx("input", { type: "color", value: (_k = sel.stroke) !== null && _k !== void 0 ? _k : '#000000', onChange: (e) => editor.updateShape(sel.id, { stroke: e.target.value }), style: {
|
|
527
|
+
width: 24,
|
|
528
|
+
height: 18,
|
|
529
|
+
border: 'none',
|
|
530
|
+
padding: 0,
|
|
531
|
+
cursor: 'pointer',
|
|
532
|
+
} })] })] }));
|
|
533
|
+
})(), jsxs("div", { style: { borderTop: '1px solid #373a40', paddingTop: 8 }, children: [jsxs("strong", { children: ["Shapes (", editor.shapes.length, ")"] }), jsx("div", { style: { marginTop: 4, maxHeight: 120, overflowY: 'auto' }, children: editor.shapes.map((s) => (jsxs("div", { onClick: () => editor.setSelectedId(s.id), style: {
|
|
534
|
+
padding: '2px 4px',
|
|
535
|
+
cursor: 'pointer',
|
|
536
|
+
borderRadius: 2,
|
|
537
|
+
fontSize: 11,
|
|
538
|
+
background: editor.selectedId === s.id ? '#339af0' : 'transparent',
|
|
539
|
+
color: editor.selectedId === s.id ? '#fff' : '#c1c2c5',
|
|
540
|
+
}, children: [s.type, " ", s.id.slice(-4)] }, s.id))) })] }), jsxs("div", { style: { borderTop: '1px solid #373a40', paddingTop: 8 }, children: [jsx("strong", { children: "Preview" }), jsx("div", { style: { display: 'flex', gap: 8, marginTop: 8, alignItems: 'end' }, children: [16, 24, 32, 48].map((size) => (jsxs("div", { style: { textAlign: 'center', fontSize: 10, color: '#868e96' }, children: [jsx("div", { style: {
|
|
541
|
+
background: '#fff',
|
|
542
|
+
display: 'inline-block',
|
|
543
|
+
padding: 4,
|
|
544
|
+
borderRadius: 3,
|
|
545
|
+
}, dangerouslySetInnerHTML: {
|
|
546
|
+
__html: editor
|
|
547
|
+
.toSvg()
|
|
548
|
+
.replace(/width="\d+"/, `width="${size}"`)
|
|
549
|
+
.replace(/height="\d+"/, `height="${size}"`),
|
|
550
|
+
} }), jsxs("div", { children: [size, "px"] })] }, size))) })] })] })] })] }));
|
|
328
551
|
};
|
|
329
552
|
|
|
330
553
|
export { NiceIconEditor, useIconEditor };
|