@nice2dev/ui-graphics 1.2.1 → 1.3.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/CHANGELOG.md +464 -0
- package/dist/cjs/animation/AnimatedPerson.js +3 -1
- package/dist/cjs/core/NiceBrushEngine.js +5 -4
- package/dist/cjs/core/collaboration.js +11 -6
- package/dist/cjs/core/minimap.js +21 -20
- package/dist/cjs/font/NiceFontEditor.js +6 -6
- package/dist/cjs/game/GameAsset2dEditor.js +58 -39
- package/dist/cjs/photo/NiceAITools.js +3 -3
- package/dist/cjs/photo/PhotoEditorLeftPanel.js +16 -16
- package/dist/cjs/pixel/PixelEditor.js +1 -1
- package/dist/cjs/pixel/PixelEditorMenuBar.js +92 -27
- package/dist/cjs/pixel/PixelEditorRightPanel.js +9 -5
- package/dist/cjs/pixel/PixelEditorStatusBar.js +6 -2
- package/dist/cjs/pixel/PixelEditorTimeline.js +5 -1
- package/dist/cjs/pixel/PixelEditorToolbar.js +3 -1
- package/dist/cjs/pixel/SpriteGeneratorPanel.js +18 -11
- package/dist/cjs/texture/Nice3DTexturePainter.js +10 -6
- package/dist/cjs/ui/NiceUIDesigner.js +2 -2
- package/dist/cjs/vector/NiceSvgToCode.js +3 -3
- package/dist/cjs/vector/VectorEditor.js +1 -1
- package/dist/cjs/vector/VectorEditorMenuBar.js +7 -1
- package/dist/cjs/vector/VectorEditorRightPanel.js +3 -3
- package/dist/cjs/vector/useVectorEditor.js +26 -16
- package/dist/esm/animation/AnimatedPerson.js +3 -1
- package/dist/esm/core/NiceBrushEngine.js +5 -4
- package/dist/esm/core/collaboration.js +11 -6
- package/dist/esm/core/minimap.js +21 -20
- package/dist/esm/font/NiceFontEditor.js +7 -7
- package/dist/esm/game/GameAsset2dEditor.js +59 -40
- package/dist/esm/photo/NiceAITools.js +3 -3
- package/dist/esm/photo/PhotoEditorLeftPanel.js +17 -17
- package/dist/esm/pixel/PixelEditor.js +1 -1
- package/dist/esm/pixel/PixelEditorMenuBar.js +92 -27
- package/dist/esm/pixel/PixelEditorRightPanel.js +10 -6
- package/dist/esm/pixel/PixelEditorStatusBar.js +6 -2
- package/dist/esm/pixel/PixelEditorTimeline.js +6 -2
- package/dist/esm/pixel/PixelEditorToolbar.js +3 -1
- package/dist/esm/pixel/SpriteGeneratorPanel.js +18 -11
- package/dist/esm/texture/Nice3DTexturePainter.js +11 -7
- package/dist/esm/ui/NiceUIDesigner.js +3 -3
- package/dist/esm/vector/NiceSvgToCode.js +3 -3
- package/dist/esm/vector/VectorEditor.js +1 -1
- package/dist/esm/vector/VectorEditorMenuBar.js +7 -1
- package/dist/esm/vector/VectorEditorRightPanel.js +4 -4
- package/dist/esm/vector/useVectorEditor.js +26 -16
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { NiceAppShell, NiceButton, NiceTextInput, NiceSelect, NiceNumberInput } from '@nice2dev/ui';
|
|
3
|
-
import { NiceIcon, resolveCssColor } from '@nice2dev/ui-core';
|
|
3
|
+
import { NiceIcon, clickOnActivationKey, resolveCssColor } from '@nice2dev/ui-core';
|
|
4
4
|
import { useRef, useState, useMemo, useEffect, useCallback } from 'react';
|
|
5
5
|
import { useNiceTranslation } from '../core/i18n.js';
|
|
6
6
|
import styles from './GameAsset2dEditor.module.css.js';
|
|
@@ -12,7 +12,7 @@ import { useGameAssetEditor } from './useGameAssetEditor.js';
|
|
|
12
12
|
const MenuBar = ({ api }) => {
|
|
13
13
|
const { t } = useNiceTranslation();
|
|
14
14
|
const fileInputRef = useRef(null);
|
|
15
|
-
return (jsxs("div", { className: styles.menuBar, children: [jsxs("h3", { children: [jsx(NiceIcon, { name: "gamepad", size: 16 }), ' ', t('gameAsset2dEditor.gameAssetEditor', 'Game Asset Editor')] }), jsxs("div", { className: styles.menuGroup, children: [jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.newProject('New Project'), children: [jsx(NiceIcon, { name: "file", size: 14 }), " New
|
|
15
|
+
return (jsxs("div", { className: styles.menuBar, children: [jsxs("h3", { children: [jsx(NiceIcon, { name: "gamepad", size: 16 }), ' ', t('gameAsset2dEditor.gameAssetEditor', 'Game Asset Editor')] }), jsxs("div", { className: styles.menuGroup, children: [jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.newProject('New Project'), children: [jsx(NiceIcon, { name: "file", size: 14 }), " ", t('gameAsset2dEditor.new', 'New')] }), jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: [jsx(NiceIcon, { name: "folder", size: 14 }), " ", t('gameAsset2dEditor.open', 'Open')] }), jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.saveProject, children: [jsx(NiceIcon, { name: "save", size: 14 }), " ", t('gameAsset2dEditor.save', 'Save')] })] }), jsx("div", { className: styles.spacer }), jsxs("div", { className: styles.menuGroup, children: [jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.undo, disabled: !api.canUndo, children: [jsx(NiceIcon, { name: "arrow-left", size: 14 }), " ", t('gameAsset2dEditor.undo', 'Undo')] }), jsxs(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.redo, disabled: !api.canRedo, children: [jsx(NiceIcon, { name: "arrow-right", size: 14 }), " ", t('gameAsset2dEditor.redo', 'Redo')] })] }), jsx("input", { ref: fileInputRef, type: "file", accept: ".json", style: { display: 'none' }, onChange: (e) => {
|
|
16
16
|
var _a;
|
|
17
17
|
const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
18
18
|
if (file) {
|
|
@@ -25,11 +25,12 @@ const MenuBar = ({ api }) => {
|
|
|
25
25
|
MODE TABS
|
|
26
26
|
──────────────────────────────────────────────────────────────── */
|
|
27
27
|
const ModeTabs = ({ api }) => {
|
|
28
|
+
const { t } = useNiceTranslation();
|
|
28
29
|
const modes = [
|
|
29
|
-
{ id: 'tilemap', label: 'Tile Map', icon: 'grid' },
|
|
30
|
-
{ id: 'spritesheet', label: 'Sprite Sheet', icon: 'image' },
|
|
31
|
-
{ id: 'animation', label: 'Animation', icon: 'video' },
|
|
32
|
-
{ id: 'effects', label: 'Effects', icon: 'wand' },
|
|
30
|
+
{ id: 'tilemap', label: t('gameAsset2dEditor.tileMap', 'Tile Map'), icon: 'grid' },
|
|
31
|
+
{ id: 'spritesheet', label: t('gameAsset2dEditor.spriteSheet', 'Sprite Sheet'), icon: 'image' },
|
|
32
|
+
{ id: 'animation', label: t('gameAsset2dEditor.animation', 'Animation'), icon: 'video' },
|
|
33
|
+
{ id: 'effects', label: t('gameAsset2dEditor.effects2', 'Effects'), icon: 'wand' },
|
|
33
34
|
];
|
|
34
35
|
return (jsx("div", { className: styles.modeTabs, children: modes.map((mode) => (jsxs(NiceButton, { className: `${styles.modeTab} ${api.editorState.mode === mode.id ? styles.active : ''}`, variant: api.editorState.mode === mode.id ? 'primary' : 'ghost', onClick: () => api.setMode(mode.id), children: [jsx(NiceIcon, { name: mode.icon, size: 16 }), " ", mode.label] }, mode.id))) }));
|
|
35
36
|
};
|
|
@@ -39,13 +40,17 @@ const ModeTabs = ({ api }) => {
|
|
|
39
40
|
const TileMapToolbar = ({ api }) => {
|
|
40
41
|
const { t } = useNiceTranslation();
|
|
41
42
|
const tools = [
|
|
42
|
-
{ id: 'select', icon: 'square', label: 'Select' },
|
|
43
|
-
{ id: 'brush', icon: 'brush', label: 'Brush' },
|
|
44
|
-
{ id: 'eraser', icon: 'eraser', label: 'Eraser' },
|
|
45
|
-
{ id: 'fill', icon: 'bucket', label: 'Fill' },
|
|
46
|
-
{ id: 'rectangle', icon: 'square', label: 'Rectangle' },
|
|
47
|
-
{ id: 'line', icon: 'line', label: 'Line' },
|
|
48
|
-
{
|
|
43
|
+
{ id: 'select', icon: 'square', label: t('gameAsset2dEditor.select', 'Select') },
|
|
44
|
+
{ id: 'brush', icon: 'brush', label: t('gameAsset2dEditor.brush', 'Brush') },
|
|
45
|
+
{ id: 'eraser', icon: 'eraser', label: t('gameAsset2dEditor.eraser', 'Eraser') },
|
|
46
|
+
{ id: 'fill', icon: 'bucket', label: t('gameAsset2dEditor.fill', 'Fill') },
|
|
47
|
+
{ id: 'rectangle', icon: 'square', label: t('gameAsset2dEditor.rectangle', 'Rectangle') },
|
|
48
|
+
{ id: 'line', icon: 'line', label: t('gameAsset2dEditor.line', 'Line') },
|
|
49
|
+
{
|
|
50
|
+
id: 'eyedropper',
|
|
51
|
+
icon: 'eyedropper',
|
|
52
|
+
label: t('gameAsset2dEditor.eyedropper', 'Eyedropper'),
|
|
53
|
+
},
|
|
49
54
|
];
|
|
50
55
|
return (jsxs("div", { className: styles.toolbar, children: [jsx("div", { className: styles.toolGroup, children: tools.map((tool) => (jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.tileMapTool === tool.id ? styles.active : ''}`, variant: api.editorState.tileMapTool === tool.id ? 'primary' : 'ghost', size: "sm", onClick: () => api.setTileMapTool(tool.id), title: tool.label, children: jsx(NiceIcon, { name: tool.icon, size: 16 }) }, tool.id))) }), jsx("div", { className: styles.spacer }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.showGrid ? styles.active : ''}`, variant: api.editorState.showGrid ? 'primary' : 'ghost', size: "sm", onClick: api.toggleGrid, title: t('gameAsset2dEditor.toggleGrid', 'Toggle Grid'), "aria-label": t('gameAsset2dEditor.toggleGrid', 'Toggle Grid'), children: jsx(NiceIcon, { name: "grid", size: 16 }) }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.showCollision ? styles.active : ''}`, variant: api.editorState.showCollision ? 'primary' : 'ghost', size: "sm", onClick: api.toggleCollision, title: t('gameAsset2dEditor.showCollision', 'Show Collision'), "aria-label": t('gameAsset2dEditor.showCollision', 'Show Collision'), children: jsx(NiceIcon, { name: "square", size: 16 }) }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.snapToGrid ? styles.active : ''}`, variant: api.editorState.snapToGrid ? 'primary' : 'ghost', size: "sm", onClick: api.toggleSnap, title: t('gameAsset2dEditor.snapToGrid', 'Snap to Grid'), "aria-label": t('gameAsset2dEditor.snapToGrid', 'Snap to Grid'), children: jsx(NiceIcon, { name: "grid", size: 16 }) })] }));
|
|
51
56
|
};
|
|
@@ -56,7 +61,7 @@ const SpriteSheetToolbar = ({ api }) => {
|
|
|
56
61
|
const { t } = useNiceTranslation();
|
|
57
62
|
const [sliceWidth, setSliceWidth] = useState(16);
|
|
58
63
|
const [sliceHeight, setSliceHeight] = useState(16);
|
|
59
|
-
return (jsxs("div", { className: styles.toolbar, children: [jsxs("div", { className: styles.toolGroup, children: [jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.spriteSheetTool === 'select' ? styles.active : ''}`, variant: api.editorState.spriteSheetTool === 'select' ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSpriteSheetTool('select'), title: t('gameAsset2dEditor.select', 'Select'), "aria-label": t('gameAsset2dEditor.select', 'Select'), children: jsx(NiceIcon, { name: "square", size: 16 }) }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.spriteSheetTool === 'slice' ? styles.active : ''}`, variant: api.editorState.spriteSheetTool === 'slice' ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSpriteSheetTool('slice'), title: t('gameAsset2dEditor.manualSlice', 'Manual Slice'), "aria-label": t('gameAsset2dEditor.manualSlice', 'Manual Slice'), children: jsx(NiceIcon, { name: "scissors", size: 16 }) })] }), jsx("div", { className: styles.spacer }), jsxs("label", { style: { fontSize: 11, color: 'var(--nice-text-secondary, #8892a8)' }, children: [
|
|
64
|
+
return (jsxs("div", { className: styles.toolbar, children: [jsxs("div", { className: styles.toolGroup, children: [jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.spriteSheetTool === 'select' ? styles.active : ''}`, variant: api.editorState.spriteSheetTool === 'select' ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSpriteSheetTool('select'), title: t('gameAsset2dEditor.select', 'Select'), "aria-label": t('gameAsset2dEditor.select', 'Select'), children: jsx(NiceIcon, { name: "square", size: 16 }) }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.editorState.spriteSheetTool === 'slice' ? styles.active : ''}`, variant: api.editorState.spriteSheetTool === 'slice' ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSpriteSheetTool('slice'), title: t('gameAsset2dEditor.manualSlice', 'Manual Slice'), "aria-label": t('gameAsset2dEditor.manualSlice', 'Manual Slice'), children: jsx(NiceIcon, { name: "scissors", size: 16 }) })] }), jsx("div", { className: styles.spacer }), jsxs("label", { style: { fontSize: 11, color: 'var(--nice-text-secondary, #8892a8)' }, children: [t('gameAsset2dEditor.frameSize', 'Frame size:'), jsx(NiceNumberInput, { value: sliceWidth, onChange: (val) => setSliceWidth(val !== null && val !== void 0 ? val : 16), style: { width: 40, margin: '0 4px' }, className: styles.panelInput }), "\u00D7", jsx(NiceNumberInput, { value: sliceHeight, onChange: (val) => setSliceHeight(val !== null && val !== void 0 ? val : 16), style: { width: 40, marginLeft: 4 }, className: styles.panelInput })] }), jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: () => api.autoSlice(sliceWidth, sliceHeight), style: { marginLeft: 8 }, children: t('gameAsset2dEditor.autoSlice', 'Auto Slice') }), jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: api.detectSprites, style: { marginLeft: 4 }, children: t('gameAsset2dEditor.detectSprites', 'Detect Sprites') })] }));
|
|
60
65
|
};
|
|
61
66
|
/* ────────────────────────────────────────────────────────────────
|
|
62
67
|
TILE PALETTE (LEFT PANEL)
|
|
@@ -64,7 +69,7 @@ const SpriteSheetToolbar = ({ api }) => {
|
|
|
64
69
|
const TilePalette = ({ api }) => {
|
|
65
70
|
const { t } = useNiceTranslation();
|
|
66
71
|
const fileInputRef = useRef(null);
|
|
67
|
-
return (jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.tiles', 'Tiles') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children:
|
|
72
|
+
return (jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.tiles', 'Tiles') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: t('gameAsset2dEditor.add', '+ Add') })] }), jsx("div", { className: styles.panelContent, children: api.project.tileSets.length === 0 ? (jsxs("div", { className: styles.emptyState, children: [jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.noTilesYet', 'No tiles yet') }), jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: t('gameAsset2dEditor.importTiles', 'Import Tiles') })] })) : (jsx("div", { className: styles.tilePalette, children: api.project.tileSets.map((tile) => (jsx("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.tileItem} ${api.editorState.selectedTileId === tile.id ? styles.selected : ''}`, onClick: () => api.selectTile(tile.id), title: tile.name, children: jsx("img", { src: tile.thumbnail, alt: tile.name }) }, tile.id))) })) }), jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", style: { display: 'none' }, onChange: (e) => {
|
|
68
73
|
var _a;
|
|
69
74
|
const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
70
75
|
if (file) {
|
|
@@ -79,10 +84,12 @@ const TilePalette = ({ api }) => {
|
|
|
79
84
|
const LayersPanel = ({ api }) => {
|
|
80
85
|
const { t } = useNiceTranslation();
|
|
81
86
|
const activeMap = api.project.tileMaps.find((m) => m.id === api.editorState.activeTileMapId);
|
|
82
|
-
return (jsxs("div", { className: styles.rightPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.layers', 'Layers') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.addLayer, disabled: !activeMap, children:
|
|
87
|
+
return (jsxs("div", { className: styles.rightPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.layers', 'Layers') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: api.addLayer, disabled: !activeMap, children: t('gameAsset2dEditor.add', '+ Add') })] }), jsx("div", { className: styles.panelContent, children: activeMap ? (jsx("div", { className: styles.layersList, children: [...activeMap.layers].reverse().map((layer) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.layerItem} ${api.editorState.activeLayerId === layer.id ? styles.selected : ''}`, onClick: () => api.selectLayer(layer.id), children: [jsx(NiceButton, { className: `${styles.layerVisibility} ${!layer.visible ? styles.hidden : ''}`, variant: "ghost", size: "sm", onClick: (e) => {
|
|
83
88
|
e.stopPropagation();
|
|
84
89
|
api.toggleLayerVisibility(layer.id);
|
|
85
|
-
}, "aria-label": layer.visible
|
|
90
|
+
}, "aria-label": layer.visible
|
|
91
|
+
? t('gameAsset2dEditor.hideLayer', 'Hide layer')
|
|
92
|
+
: t('gameAsset2dEditor.showLayer', 'Show layer'), children: jsx(NiceIcon, { name: layer.visible ? 'eye' : 'eye-off', size: 16 }) }), jsx("span", { className: styles.layerName, children: layer.name }), jsxs("span", { className: styles.layerOpacity, children: [Math.round(layer.opacity * 100), "%"] })] }, layer.id))) })) : (jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.noTileMapSelected', 'No tile map selected') }) })) }), jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.maps', 'Maps') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.createTileMap('New Map', 32, 32), children: t('gameAsset2dEditor.new2', '+ New') })] }), jsx("div", { className: styles.panelContent, children: api.project.tileMaps.map((map) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.layerItem} ${api.editorState.activeTileMapId === map.id ? styles.selected : ''}`, onClick: () => api.selectTileMap(map.id), children: [jsx("span", { className: styles.layerName, children: map.name }), jsxs("span", { className: styles.layerOpacity, children: [map.width, "\u00D7", map.height] })] }, map.id))) })] }));
|
|
86
93
|
};
|
|
87
94
|
/* ────────────────────────────────────────────────────────────────
|
|
88
95
|
TILE MAP CANVAS
|
|
@@ -264,7 +271,7 @@ const SpriteSheetCanvas = ({ api }) => {
|
|
|
264
271
|
const SpriteSheetsList = ({ api }) => {
|
|
265
272
|
const { t } = useNiceTranslation();
|
|
266
273
|
const fileInputRef = useRef(null);
|
|
267
|
-
return (jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.spriteSheets', 'Sprite Sheets') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children:
|
|
274
|
+
return (jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.spriteSheets', 'Sprite Sheets') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => { var _a; return (_a = fileInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }, children: t('gameAsset2dEditor.import', '+ Import') })] }), jsx("div", { className: styles.panelContent, children: api.project.spriteSheets.length === 0 ? (jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.noSpriteSheets', 'No sprite sheets') }) })) : (jsx("div", { className: styles.layersList, children: api.project.spriteSheets.map((sheet) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.layerItem} ${api.editorState.activeSpriteSheetId === sheet.id ? styles.selected : ''}`, onClick: () => api.selectSpriteSheet(sheet.id), children: [jsx("span", { className: styles.layerName, children: sheet.name }), jsx("span", { className: styles.layerOpacity, children: t('gameAsset2dEditor.frames', '{frames} frames').replace('{frames}', String(sheet.frames.length)) })] }, sheet.id))) })) }), jsx("input", { ref: fileInputRef, type: "file", accept: "image/*", style: { display: 'none' }, onChange: (e) => {
|
|
268
275
|
var _a;
|
|
269
276
|
const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
270
277
|
if (file) {
|
|
@@ -287,7 +294,7 @@ const FramesPanel = ({ api }) => {
|
|
|
287
294
|
setAnimName('');
|
|
288
295
|
}
|
|
289
296
|
}, [animName, api]);
|
|
290
|
-
return (jsxs("div", { className: styles.rightPanel, children: [jsx("div", { className: styles.panelHeader, children:
|
|
297
|
+
return (jsxs("div", { className: styles.rightPanel, children: [jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.frames2', 'Frames ({frames})').replace('{frames}', String((_a = activeSheet === null || activeSheet === void 0 ? void 0 : activeSheet.frames.length) !== null && _a !== void 0 ? _a : 0)) }) }), jsx("div", { className: styles.panelContent, style: { maxHeight: 200 }, children: activeSheet === null || activeSheet === void 0 ? void 0 : activeSheet.frames.map((frame) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.layerItem} ${api.editorState.selectedFrameIds.includes(frame.id) ? styles.selected : ''}`, onClick: () => api.selectFrames([frame.id]), children: [jsx("span", { className: styles.layerName, children: frame.name }), jsxs("span", { className: styles.layerOpacity, children: [frame.width, "\u00D7", frame.height] })] }, frame.id))) }), jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.animations', 'Animations') }) }), jsxs("div", { className: styles.panelContent, children: [api.editorState.selectedFrameIds.length > 0 && (jsxs("div", { className: styles.panelSection, children: [jsx(NiceTextInput, { className: styles.panelInput, placeholder: t('gameAsset2dEditor.animationName', 'Animation name...'), value: animName, onChange: (val) => setAnimName(val) }), jsx(NiceButton, { className: styles.btnPrimary, variant: "primary", onClick: createAnimationFromSelection, style: { marginTop: 8, width: '100%' }, disabled: !animName, children: t('gameAsset2dEditor.createFromFrames', 'Create from {count} frames').replace('{count}', String(api.editorState.selectedFrameIds.length)) })] })), activeSheet === null || activeSheet === void 0 ? void 0 : activeSheet.animations.map((anim) => (jsxs("div", { className: styles.layerItem, children: [jsx("span", { className: styles.layerName, children: anim.name }), jsxs("span", { className: styles.layerOpacity, children: [anim.frameIds.length, "f"] }), jsx(NiceButton, { className: styles.effectRemove, variant: "ghost", size: "sm", onClick: () => api.removeAnimation(anim.id), "aria-label": t('gameAsset2dEditor.removeAnimation', 'Remove animation'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, anim.id)))] })] }));
|
|
291
298
|
};
|
|
292
299
|
/* ────────────────────────────────────────────────────────────────
|
|
293
300
|
ANIMATION STATE MACHINE
|
|
@@ -307,18 +314,21 @@ const AnimationStateMachineView = ({ api }) => {
|
|
|
307
314
|
}
|
|
308
315
|
return result;
|
|
309
316
|
}, [api.project.spriteSheets]);
|
|
310
|
-
return (jsxs("div", { style: { display: 'flex', flex: 1, overflow: 'hidden' }, children: [jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.stateMachines', 'State Machines') }), jsx("button", { className: styles.menuBtn, onClick: () => api.createStateMachine('New State Machine'), children:
|
|
317
|
+
return (jsxs("div", { style: { display: 'flex', flex: 1, overflow: 'hidden' }, children: [jsxs("div", { className: styles.leftPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.stateMachines', 'State Machines') }), jsx("button", { className: styles.menuBtn, onClick: () => api.createStateMachine('New State Machine'), children: t('gameAsset2dEditor.new2', '+ New') })] }), jsx("div", { className: styles.panelContent, style: { maxHeight: 150 }, children: api.project.stateMachines.map((sm) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.layerItem} ${api.editorState.activeStateMachineId === sm.id ? styles.selected : ''}`, onClick: () => api.selectStateMachine(sm.id), children: [jsx("span", { className: styles.layerName, children: sm.name }), jsx("span", { className: styles.layerOpacity, children: t('gameAsset2dEditor.states2', '{states} states').replace('{states}', String(sm.states.length)) })] }, sm.id))) }), activeSM && (jsxs(Fragment, { children: [jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.states', 'States') }) }), jsxs("div", { className: styles.panelContent, children: [jsxs("div", { className: styles.panelSection, children: [jsx(NiceTextInput, { className: styles.panelInput, placeholder: t('gameAsset2dEditor.stateName', 'State name...'), value: newStateName, onChange: (val) => setNewStateName(val) }), allAnimations.length > 0 && newStateName && (jsx(NiceSelect, { className: styles.panelInput, style: { marginTop: 4 }, onChange: (val) => {
|
|
311
318
|
if (val) {
|
|
312
319
|
api.addState(newStateName, val);
|
|
313
320
|
setNewStateName('');
|
|
314
321
|
}
|
|
315
322
|
}, options: [
|
|
316
|
-
{
|
|
323
|
+
{
|
|
324
|
+
value: '',
|
|
325
|
+
label: t('gameAsset2dEditor.selectAnimation', 'Select animation...'),
|
|
326
|
+
},
|
|
317
327
|
...allAnimations.map((anim) => ({
|
|
318
328
|
value: anim.id,
|
|
319
329
|
label: `${anim.sheetName}: ${anim.name}`,
|
|
320
330
|
})),
|
|
321
|
-
] }))] }), activeSM.states.map((state) => (jsxs("div", { className: `${styles.layerItem} ${api.editorState.selectedStateId === state.id ? styles.selected : ''} ${activeSM.entryStateId === state.id ? styles.entry : ''}`, onClick: () => api.selectState(state.id), children: [jsxs("span", { className: styles.layerName, children: [activeSM.entryStateId === state.id && jsx(NiceIcon, { name: "play", size: 12 }), ' ', state.name] }), jsx(NiceButton, { className: styles.effectRemove, variant: "ghost", size: "sm", onClick: (e) => {
|
|
331
|
+
] }))] }), activeSM.states.map((state) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.layerItem} ${api.editorState.selectedStateId === state.id ? styles.selected : ''} ${activeSM.entryStateId === state.id ? styles.entry : ''}`, onClick: () => api.selectState(state.id), children: [jsxs("span", { className: styles.layerName, children: [activeSM.entryStateId === state.id && jsx(NiceIcon, { name: "play", size: 12 }), ' ', state.name] }), jsx(NiceButton, { className: styles.effectRemove, variant: "ghost", size: "sm", onClick: (e) => {
|
|
322
332
|
e.stopPropagation();
|
|
323
333
|
api.removeState(state.id);
|
|
324
334
|
}, "aria-label": t('gameAsset2dEditor.removeState', 'Remove state'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, state.id)))] })] }))] }), jsx("div", { className: styles.stateGraph, children: activeSM ? (jsxs("svg", { width: "100%", height: "100%", children: [jsx("defs", { children: jsx("marker", { id: "arrowhead", markerWidth: "10", markerHeight: "7", refX: "9", refY: "3.5", orient: "auto", children: jsx("polygon", { points: "0 0, 10 3.5, 0 7", fill: "var(--nice-text-secondary, #4a5a7e)" }) }) }), activeSM.transitions.map((trans) => {
|
|
@@ -330,18 +340,21 @@ const AnimationStateMachineView = ({ api }) => {
|
|
|
330
340
|
return (jsx("line", { x1: from.position.x + 60, y1: from.position.y + 20, x2: to.position.x + 60, y2: to.position.y + 20, className: styles.transition, onClick: () => api.removeTransition(trans.id) }, trans.id));
|
|
331
341
|
}), activeSM.states.map((state) => {
|
|
332
342
|
var _a, _b;
|
|
333
|
-
return (jsx("foreignObject", { x: state.position.x, y: state.position.y, width: 120, height: 50, children: jsxs("div", { className: `${styles.stateNode} ${api.editorState.selectedStateId === state.id ? styles.selected : ''} ${activeSM.entryStateId === state.id ? styles.entry : ''}`, onClick: () => api.selectState(state.id), children: [jsx("div", { className: styles.stateNodeName, children: state.name }), jsx("div", { className: styles.stateNodeAnim, children: (_b = (_a = allAnimations.find((a) => a.id === state.animationId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : 'No animation' })] }) }, state.id));
|
|
334
|
-
})] })) : (jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.createAStateMachineTo', 'Create a state machine to design animation flows') }) })) }), jsxs("div", { className: styles.rightPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.parameters', 'Parameters') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.addParameter('new_param', 'trigger'), disabled: !activeSM, children:
|
|
343
|
+
return (jsx("foreignObject", { x: state.position.x, y: state.position.y, width: 120, height: 50, children: jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.stateNode} ${api.editorState.selectedStateId === state.id ? styles.selected : ''} ${activeSM.entryStateId === state.id ? styles.entry : ''}`, onClick: () => api.selectState(state.id), children: [jsx("div", { className: styles.stateNodeName, children: state.name }), jsx("div", { className: styles.stateNodeAnim, children: (_b = (_a = allAnimations.find((a) => a.id === state.animationId)) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : t('gameAsset2dEditor.noAnimation', 'No animation') })] }) }, state.id));
|
|
344
|
+
})] })) : (jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.createAStateMachineTo', 'Create a state machine to design animation flows') }) })) }), jsxs("div", { className: styles.rightPanel, children: [jsxs("div", { className: styles.panelHeader, children: [jsx("span", { children: t('gameAsset2dEditor.parameters', 'Parameters') }), jsx(NiceButton, { className: styles.menuBtn, variant: "ghost", size: "sm", onClick: () => api.addParameter('new_param', 'trigger'), disabled: !activeSM, children: t('gameAsset2dEditor.add', '+ Add') })] }), jsx("div", { className: styles.panelContent, children: activeSM === null || activeSM === void 0 ? void 0 : activeSM.parameters.map((param) => (jsxs("div", { className: styles.layerItem, children: [jsx("span", { className: styles.layerOpacity, children: param.type }), jsx("span", { className: styles.layerName, children: param.name }), jsx(NiceButton, { className: styles.effectRemove, variant: "ghost", size: "sm", onClick: () => api.removeParameter(param.id), "aria-label": t('gameAsset2dEditor.removeParameter', 'Remove parameter'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, param.id))) }), jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.transitions', 'Transitions') }) }), jsxs("div", { className: styles.panelContent, children: [activeSM === null || activeSM === void 0 ? void 0 : activeSM.transitions.map((trans) => {
|
|
335
345
|
var _a, _b;
|
|
336
346
|
const from = activeSM.states.find((s) => s.id === trans.fromStateId);
|
|
337
347
|
const to = activeSM.states.find((s) => s.id === trans.toStateId);
|
|
338
348
|
return (jsxs("div", { className: styles.layerItem, children: [jsxs("span", { className: styles.layerName, children: [(_a = from === null || from === void 0 ? void 0 : from.name) !== null && _a !== void 0 ? _a : '?', " ", jsx(NiceIcon, { name: "arrow-right", size: 12 }), " ", (_b = to === null || to === void 0 ? void 0 : to.name) !== null && _b !== void 0 ? _b : '?'] }), jsx(NiceButton, { className: styles.effectRemove, variant: "ghost", size: "sm", onClick: () => api.removeTransition(trans.id), "aria-label": t('gameAsset2dEditor.removeTransition', 'Remove transition'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, trans.id));
|
|
339
|
-
}), api.editorState.selectedStateId && (jsxs("div", { className: styles.panelSection, style: { marginTop: 12 }, children: [jsx("label", { className: styles.panelLabel, children:
|
|
349
|
+
}), api.editorState.selectedStateId && (jsxs("div", { className: styles.panelSection, style: { marginTop: 12 }, children: [jsx("label", { className: styles.panelLabel, children: t('gameAsset2dEditor.addTransitionTo', 'Add transition to:') }), jsx(NiceSelect, { className: styles.panelInput, onChange: (val) => {
|
|
340
350
|
if (val && api.editorState.selectedStateId) {
|
|
341
351
|
api.addTransition(api.editorState.selectedStateId, val);
|
|
342
352
|
}
|
|
343
353
|
}, options: [
|
|
344
|
-
{
|
|
354
|
+
{
|
|
355
|
+
value: '',
|
|
356
|
+
label: t('gameAsset2dEditor.selectTargetState', 'Select target state...'),
|
|
357
|
+
},
|
|
345
358
|
...((_a = activeSM === null || activeSM === void 0 ? void 0 : activeSM.states.filter((s) => s.id !== api.editorState.selectedStateId).map((s) => ({ value: s.id, label: s.name }))) !== null && _a !== void 0 ? _a : []),
|
|
346
359
|
] })] }))] })] })] }));
|
|
347
360
|
};
|
|
@@ -353,33 +366,39 @@ const EffectsView = ({ api }) => {
|
|
|
353
366
|
const [_currentEffects, _setCurrentEffects] = useState([]);
|
|
354
367
|
const [presetName, setPresetName] = useState('');
|
|
355
368
|
const effectTypes = [
|
|
356
|
-
{ type: 'brightness', label: 'Brightness' },
|
|
357
|
-
{ type: 'contrast', label: 'Contrast' },
|
|
358
|
-
{ type: 'saturation', label: 'Saturation' },
|
|
359
|
-
{ type: 'hue-shift', label: 'Hue Shift' },
|
|
360
|
-
{ type: 'invert', label: 'Invert' },
|
|
361
|
-
{ type: 'pixelate', label: 'Pixelate' },
|
|
362
|
-
{ type: 'outline', label: 'Outline' },
|
|
363
|
-
{ type: 'tint', label: 'Tint' },
|
|
364
|
-
{ type: 'blur', label: 'Blur' },
|
|
365
|
-
{ type: 'glow', label: 'Glow' },
|
|
366
|
-
{ type: 'shadow', label: 'Shadow' },
|
|
367
|
-
{ type: 'palette-swap', label: 'Palette Swap' },
|
|
369
|
+
{ type: 'brightness', label: t('gameAsset2dEditor.brightness', 'Brightness') },
|
|
370
|
+
{ type: 'contrast', label: t('gameAsset2dEditor.contrast', 'Contrast') },
|
|
371
|
+
{ type: 'saturation', label: t('gameAsset2dEditor.saturation', 'Saturation') },
|
|
372
|
+
{ type: 'hue-shift', label: t('gameAsset2dEditor.hueShift', 'Hue Shift') },
|
|
373
|
+
{ type: 'invert', label: t('gameAsset2dEditor.invert', 'Invert') },
|
|
374
|
+
{ type: 'pixelate', label: t('gameAsset2dEditor.pixelate', 'Pixelate') },
|
|
375
|
+
{ type: 'outline', label: t('gameAsset2dEditor.outline', 'Outline') },
|
|
376
|
+
{ type: 'tint', label: t('gameAsset2dEditor.tint', 'Tint') },
|
|
377
|
+
{ type: 'blur', label: t('gameAsset2dEditor.blur', 'Blur') },
|
|
378
|
+
{ type: 'glow', label: t('gameAsset2dEditor.glow', 'Glow') },
|
|
379
|
+
{ type: 'shadow', label: t('gameAsset2dEditor.shadow', 'Shadow') },
|
|
380
|
+
{ type: 'palette-swap', label: t('gameAsset2dEditor.paletteSwap', 'Palette Swap') },
|
|
368
381
|
];
|
|
369
382
|
return (jsxs("div", { style: { display: 'flex', flex: 1, overflow: 'hidden' }, children: [jsxs("div", { className: styles.leftPanel, children: [jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.addEffect', 'Add Effect') }) }), jsx("div", { className: styles.panelContent, children: effectTypes.map(({ type, label }) => (jsx(NiceButton, { className: styles.layerItem, variant: "ghost", onClick: () => api.addEffect(type), style: { cursor: 'pointer', border: 'none', textAlign: 'left' }, children: jsx("span", { className: styles.layerName, children: label }) }, type))) }), jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.presets', 'Presets') }) }), jsxs("div", { className: styles.panelContent, children: [jsxs("div", { className: styles.panelSection, children: [jsx(NiceTextInput, { className: styles.panelInput, placeholder: t('gameAsset2dEditor.presetName', 'Preset name...'), value: presetName, onChange: (val) => setPresetName(val) }), jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", style: { marginTop: 4, width: '100%' }, onClick: () => {
|
|
370
383
|
if (presetName) {
|
|
371
384
|
api.saveEffectPreset(presetName);
|
|
372
385
|
setPresetName('');
|
|
373
386
|
}
|
|
374
|
-
}, disabled: !presetName, children: t('gameAsset2dEditor.saveCurrentEffects', 'Save Current Effects') })] }), api.project.effectPresets.map((preset) => (jsxs("div", { className: styles.layerItem, onClick: () => api.loadEffectPreset(preset.id), style: { cursor: 'pointer' }, children: [jsx("span", { className: styles.layerName, children: preset.name }),
|
|
387
|
+
}, disabled: !presetName, children: t('gameAsset2dEditor.saveCurrentEffects', 'Save Current Effects') })] }), api.project.effectPresets.map((preset) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: styles.layerItem, onClick: () => api.loadEffectPreset(preset.id), style: { cursor: 'pointer' }, children: [jsx("span", { className: styles.layerName, children: preset.name }), jsx("span", { className: styles.layerOpacity, children: t('gameAsset2dEditor.effects', '{effects} effects').replace('{effects}', String(preset.effects.length)) })] }, preset.id)))] })] }), jsx("div", { className: styles.viewport, children: jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.selectASpriteOrTile', 'Select a sprite or tile to preview effects') }) }) }), jsxs("div", { className: styles.rightPanel, children: [jsx("div", { className: styles.panelHeader, children: jsx("span", { children: t('gameAsset2dEditor.activeEffects', 'Active Effects') }) }), jsx("div", { className: styles.panelContent, children: jsx("div", { className: styles.effectsList, children: jsx("div", { className: styles.emptyState, children: jsx("div", { className: styles.emptyStateText, children: t('gameAsset2dEditor.addEffectsFromTheLeft', 'Add effects from the left panel') }) }) }) })] })] }));
|
|
375
388
|
};
|
|
376
389
|
/* ────────────────────────────────────────────────────────────────
|
|
377
390
|
STATUS BAR
|
|
378
391
|
──────────────────────────────────────────────────────────────── */
|
|
379
392
|
const StatusBar = ({ api }) => {
|
|
393
|
+
const { t } = useNiceTranslation();
|
|
380
394
|
const activeMap = api.project.tileMaps.find((m) => m.id === api.editorState.activeTileMapId);
|
|
381
395
|
const activeSheet = api.project.spriteSheets.find((s) => s.id === api.editorState.activeSpriteSheetId);
|
|
382
|
-
return (jsxs("div", { className: styles.statusBar, children: [
|
|
396
|
+
return (jsxs("div", { className: styles.statusBar, children: [jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.mode', 'Mode: {mode}').replace('{mode}', String(api.editorState.mode)) }), api.editorState.mode === 'tilemap' && activeMap && (jsxs(Fragment, { children: [jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.map', 'Map: {name} ({width}×{height})')
|
|
397
|
+
.replace('{name}', String(activeMap.name))
|
|
398
|
+
.replace('{width}', String(activeMap.width))
|
|
399
|
+
.replace('{height}', String(activeMap.height)) }), jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.tilePx', 'Tile: {tileWidth}×{tileHeight}px')
|
|
400
|
+
.replace('{tileWidth}', String(activeMap.tileWidth))
|
|
401
|
+
.replace('{tileHeight}', String(activeMap.tileHeight)) })] })), api.editorState.mode === 'spritesheet' && activeSheet && (jsxs(Fragment, { children: [jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.sheet', 'Sheet: {name}').replace('{name}', String(activeSheet.name)) }), jsx("span", { className: styles.statusItem, children: t('gameAsset2dEditor.selectedFrames', 'Selected: {selectedFrameIds} frames').replace('{selectedFrameIds}', String(api.editorState.selectedFrameIds.length)) })] })), jsxs("div", { className: styles.zoomControl, children: [jsx(NiceButton, { className: styles.zoomBtn, variant: "ghost", size: "sm", onClick: () => api.setZoom(api.editorState.zoom - 0.25), children: "\u2212" }), jsxs("span", { children: [Math.round(api.editorState.zoom * 100), "%"] }), jsx(NiceButton, { className: styles.zoomBtn, variant: "ghost", size: "sm", onClick: () => api.setZoom(api.editorState.zoom + 0.25), children: "+" }), jsx(NiceButton, { className: styles.zoomBtn, variant: "ghost", size: "sm", onClick: () => api.setZoom(1), children: "\u2299" })] })] }));
|
|
383
402
|
};
|
|
384
403
|
/* ────────────────────────────────────────────────────────────────
|
|
385
404
|
MAIN COMPONENT
|
|
@@ -481,10 +481,10 @@ const NiceAITools = ({ sourceImage, onResult, className = '', }) => {
|
|
|
481
481
|
alignItems: 'center',
|
|
482
482
|
justifyContent: 'center',
|
|
483
483
|
gap: 4,
|
|
484
|
-
}, children: [jsx(NiceIcon, { name: TOOL_ICONS[key], size: 14 }), " ", label] }, key))) }), ai.activeTool === 'colorize' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [
|
|
484
|
+
}, children: [jsx(NiceIcon, { name: TOOL_ICONS[key], size: 14 }), " ", label] }, key))) }), ai.activeTool === 'colorize' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('aiTools.intensity', 'Intensity: {intensity}').replace('{intensity}', String(ai.colorizeOptions.intensity.toFixed(2))), jsx("input", { type: "range", min: 0, max: 1, step: 0.05, value: ai.colorizeOptions.intensity, onChange: (e) => ai.setColorizeOptions({ ...ai.colorizeOptions, intensity: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.saturation', 'Saturation: {saturation}').replace('{saturation}', String(ai.colorizeOptions.saturation.toFixed(1))), jsx("input", { type: "range", min: 0, max: 2, step: 0.1, value: ai.colorizeOptions.saturation, onChange: (e) => ai.setColorizeOptions({ ...ai.colorizeOptions, saturation: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.temperature', 'Temperature:'), jsxs("select", { value: ai.colorizeOptions.temperature, onChange: (e) => ai.setColorizeOptions({
|
|
485
485
|
...ai.colorizeOptions,
|
|
486
486
|
temperature: e.target.value,
|
|
487
|
-
}), style: { width: '100%' }, children: [jsx("option", { value: "warm", children: t('aiTools.warm', 'Warm') }), jsx("option", { value: "neutral", children: t('aiTools.neutral', 'Neutral') }), jsx("option", { value: "cool", children: t('aiTools.cool', 'Cool') })] })] })] })), ai.activeTool === 'background-remove' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [
|
|
487
|
+
}), style: { width: '100%' }, children: [jsx("option", { value: "warm", children: t('aiTools.warm', 'Warm') }), jsx("option", { value: "neutral", children: t('aiTools.neutral', 'Neutral') }), jsx("option", { value: "cool", children: t('aiTools.cool', 'Cool') })] })] })] })), ai.activeTool === 'background-remove' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('aiTools.threshold', 'Threshold: {threshold}').replace('{threshold}', String(ai.bgRemoveOptions.threshold.toFixed(2))), jsx("input", { type: "range", min: 0.1, max: 0.9, step: 0.05, value: ai.bgRemoveOptions.threshold, onChange: (e) => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, threshold: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.iterations', 'Iterations: {iterations}').replace('{iterations}', String(ai.bgRemoveOptions.iterations)), jsx("input", { type: "range", min: 1, max: 20, step: 1, value: ai.bgRemoveOptions.iterations, onChange: (e) => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, iterations: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.featherPx', 'Feather: {featherRadius}px').replace('{featherRadius}', String(ai.bgRemoveOptions.featherRadius)), jsx("input", { type: "range", min: 0, max: 10, step: 1, value: ai.bgRemoveOptions.featherRadius, onChange: (e) => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, featherRadius: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { style: { display: 'flex', gap: 4, alignItems: 'center' }, children: [t('aiTools.replaceBg', 'Replace BG:'), jsx("input", { type: "color", value: (_a = ai.bgRemoveOptions.replacementColor) !== null && _a !== void 0 ? _a : '#ffffff', onChange: (e) => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, replacementColor: e.target.value }) }), jsx("button", { type: "button", onClick: () => ai.setBgRemoveOptions({ ...ai.bgRemoveOptions, replacementColor: null }), style: { fontSize: 10 }, children: t('aiTools.transparent', 'Transparent') })] })] })), ai.activeTool === 'upscale' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('aiTools.scale', 'Scale:'), jsxs("select", { value: ai.upscaleOptions.scale, onChange: (e) => ai.setUpscaleOptions({ ...ai.upscaleOptions, scale: +e.target.value }), style: { width: '100%' }, children: [jsx("option", { value: 2, children: "2x" }), jsx("option", { value: 3, children: "3x" }), jsx("option", { value: 4, children: "4x" })] })] }), jsxs("label", { children: [t('aiTools.sharpen', 'Sharpen: {sharpen}').replace('{sharpen}', String(ai.upscaleOptions.sharpen.toFixed(2))), jsx("input", { type: "range", min: 0, max: 1, step: 0.05, value: ai.upscaleOptions.sharpen, onChange: (e) => ai.setUpscaleOptions({ ...ai.upscaleOptions, sharpen: +e.target.value }), style: { width: '100%' } })] })] })), ai.activeTool === 'denoise' && (jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('aiTools.strength', 'Strength: {strength}').replace('{strength}', String(ai.denoiseOptions.strength.toFixed(2))), jsx("input", { type: "range", min: 0, max: 1, step: 0.05, value: ai.denoiseOptions.strength, onChange: (e) => ai.setDenoiseOptions({ ...ai.denoiseOptions, strength: +e.target.value }), style: { width: '100%' } })] }), jsxs("label", { children: [t('aiTools.detail', 'Detail: {detailPreservation}').replace('{detailPreservation}', String(ai.denoiseOptions.detailPreservation.toFixed(2))), jsx("input", { type: "range", min: 0, max: 1, step: 0.05, value: ai.denoiseOptions.detailPreservation, onChange: (e) => ai.setDenoiseOptions({ ...ai.denoiseOptions, detailPreservation: +e.target.value }), style: { width: '100%' } })] })] })), jsx("button", { type: "button", onClick: handleProcess, disabled: ai.isProcessing || !sourceImage, style: {
|
|
488
488
|
background: ai.isProcessing
|
|
489
489
|
? 'var(--nice-bg-tertiary, #94a3b8)'
|
|
490
490
|
: 'var(--nice-color-accent, #6366f1)',
|
|
@@ -497,7 +497,7 @@ const NiceAITools = ({ sourceImage, onResult, className = '', }) => {
|
|
|
497
497
|
alignItems: 'center',
|
|
498
498
|
justifyContent: 'center',
|
|
499
499
|
gap: 4,
|
|
500
|
-
}, children: ai.isProcessing ? (jsxs(Fragment, { children: [jsx(NiceIcon, { name: "refresh", size: 14 }), " Processing
|
|
500
|
+
}, children: ai.isProcessing ? (jsxs(Fragment, { children: [jsx(NiceIcon, { name: "refresh", size: 14 }), " ", t('aiTools.processing', 'Processing…')] })) : (jsxs(Fragment, { children: [jsx(NiceIcon, { name: "play", size: 14 }), " ", TOOL_LABELS[ai.activeTool]] })) }), ai.lastResult && (jsxs("div", { style: { fontSize: 11, color: 'var(--nice-text-muted, #64748b)' }, children: [t('aiTools.processedInMs', 'Processed in {ms}ms').replace('{ms}', ai.lastResult.processingTimeMs.toFixed(0)), ai.activeTool === 'upscale' &&
|
|
501
501
|
` → ${ai.lastResult.imageData.width}×${ai.lastResult.imageData.height}`] }))] }));
|
|
502
502
|
};
|
|
503
503
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import { NiceIcon } from '@nice2dev/ui-core';
|
|
2
|
+
import { NiceIcon, clickOnActivationKey } from '@nice2dev/ui-core';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { RangeInput, Button, TextArea } from '../core/LocalUI.js';
|
|
5
5
|
import FilterThumb from './FilterThumb.js';
|
|
@@ -59,19 +59,19 @@ const PhotoEditorLeftPanel = /* @__PURE__ */ Object.assign(
|
|
|
59
59
|
color: activeTab === tab.key ? accent : undefined,
|
|
60
60
|
borderBottomColor: activeTab === tab.key ? accent : undefined,
|
|
61
61
|
}, children: [jsx(NiceIcon, { name: tab.icon, size: 14 }), tab.label] }, tab.key))) }), jsxs("div", { className: cs.panelContent, children: [activeTab === 'filters' && (jsxs(Fragment, { children: [jsx("div", { className: cs.pillRow, children: [
|
|
62
|
-
{ key: 'all', label: 'All' },
|
|
63
|
-
{ key: 'color', label: 'Color' },
|
|
64
|
-
{ key: 'light', label: 'Light' },
|
|
65
|
-
{ key: 'vintage', label: 'Vintage' },
|
|
66
|
-
{ key: 'artistic', label: 'Artistic' },
|
|
67
|
-
{ key: 'fun', label: 'Fun' },
|
|
62
|
+
{ key: 'all', label: t('photoEditor.all', 'All') },
|
|
63
|
+
{ key: 'color', label: t('photoEditor.color', 'Color') },
|
|
64
|
+
{ key: 'light', label: t('photoEditor.light', 'Light') },
|
|
65
|
+
{ key: 'vintage', label: t('photoEditor.vintage', 'Vintage') },
|
|
66
|
+
{ key: 'artistic', label: t('photoEditor.artistic', 'Artistic') },
|
|
67
|
+
{ key: 'fun', label: t('photoEditor.fun', 'Fun') },
|
|
68
68
|
].map((cat) => (jsx("button", { onClick: () => setFilterCategory(cat.key), className: filterCategory === cat.key ? cs.pillActive : cs.pill, style: {
|
|
69
69
|
borderColor: filterCategory === cat.key ? accent : undefined,
|
|
70
70
|
background: filterCategory === cat.key ? accentDim : undefined,
|
|
71
71
|
}, children: cat.label }, cat.key))) }), jsx("div", { className: cs.filterGrid, children: filteredList.map((filter) => (jsx(FilterThumb, { filter: filter, selected: selectedFilter === filter.id, accent: accent, onSelect: () => {
|
|
72
72
|
setSelectedFilter(filter.id);
|
|
73
73
|
pushHistory();
|
|
74
|
-
}, generateThumbnail: generateThumbnail }, filter.id))) }), selectedFilter !== 'none' && (jsxs("div", { className: cs.intensitySection, children: [jsxs("div", { className: cs.intensityHeader, children: [jsxs("span", { className: cs.sliderLabel, children: [jsx(NiceIcon, { name: "bar-chart", size: 14, style: { marginRight: 4 } }), t('photoEditor.intensity', 'Intensity')] }), jsxs("span", { className: cs.sliderValue, style: { color: accent }, children: [Math.round(filterIntensity * 100), "%"] })] }), jsx(RangeInput, { min: 0, max: 100, value: filterIntensity * 100, onChange: (e) => setFilterIntensity(Number(e.target.value) / 100), onMouseUp: () => pushHistory(), accentColor: accent })] }))] })), activeTab === 'adjust' && (jsxs("div", { className: cs.adjustColumn, children: [ADJUSTMENT_SLIDERS.map((sl) => (jsxs("div", { children: [jsxs("div", { className: cs.adjustHeader, children: [jsxs("span", { className: cs.sliderLabel, children: [jsx(NiceIcon, { name: sl.icon, size: 14, style: { marginRight: 4 } }), sl.label] }), jsx("span", { className: cs.adjustValue, style: {
|
|
74
|
+
}, generateThumbnail: generateThumbnail }, filter.id))) }), selectedFilter !== 'none' && (jsxs("div", { className: cs.intensitySection, children: [jsxs("div", { className: cs.intensityHeader, children: [jsxs("span", { className: cs.sliderLabel, children: [jsx(NiceIcon, { name: "bar-chart", size: 14, style: { marginRight: 4 } }), t('photoEditor.intensity', 'Intensity')] }), jsxs("span", { className: cs.sliderValue, style: { color: accent }, children: [Math.round(filterIntensity * 100), "%"] })] }), jsx(RangeInput, { min: 0, max: 100, value: filterIntensity * 100, onChange: (e) => setFilterIntensity(Number(e.target.value) / 100), onMouseUp: () => pushHistory(), accentColor: accent })] }))] })), activeTab === 'adjust' && (jsxs("div", { className: cs.adjustColumn, children: [ADJUSTMENT_SLIDERS.map((sl) => (jsxs("div", { children: [jsxs("div", { className: cs.adjustHeader, children: [jsxs("span", { className: cs.sliderLabel, children: [jsx(NiceIcon, { name: sl.icon, size: 14, style: { marginRight: 4 } }), sl.label] }), jsx("span", { role: "button", tabIndex: 0, "aria-label": t('photoEditor.reset', 'Reset'), onKeyDown: clickOnActivationKey, className: cs.adjustValue, style: {
|
|
75
75
|
color: adjustments[sl.key] !== 0 ? accent : 'var(--nice-text-secondary, #666)',
|
|
76
76
|
}, onClick: () => handleAdjChange(sl.key, sl.key === 'blur' ? 0 : 0), title: t('photoEditor.reset', 'Reset'), children: adjustments[sl.key] })] }), jsx(RangeInput, { min: sl.min, max: sl.max, value: adjustments[sl.key], onChange: (e) => handleAdjChange(sl.key, Number(e.target.value)), onMouseUp: handleAdjChangeEnd, accentColor: accent })] }, sl.key))), jsxs(Button, { variant: "outline-secondary", size: "sm", className: "mt-2", onClick: () => {
|
|
77
77
|
handleAdjChange('brightness', 0);
|
|
@@ -120,7 +120,7 @@ const PhotoEditorLeftPanel = /* @__PURE__ */ Object.assign(
|
|
|
120
120
|
}, children: [jsx(NiceIcon, { name: "move", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.horizontal', 'Horizontal')] }), jsxs(Button, { variant: flipV ? 'outline-info' : 'dark', size: "sm", onClick: () => {
|
|
121
121
|
setFlipV(!flipV);
|
|
122
122
|
pushHistory();
|
|
123
|
-
}, children: [jsx(NiceIcon, { name: "move", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.vertical', 'Vertical')] })] }), jsx("div", { className: cs.sectionTitleMb8, children: t('photoEditor.previewZoom', 'Preview zoom') }), jsxs("div", { className: cs.transformZoomRow, children: [jsx(RangeInput, { min: 50, max: 300, value: zoom * 100, onChange: (e) => setZoom(Number(e.target.value) / 100), accentColor: accent }), jsxs("span", { className: cs.transformZoomValue, style: { color: accent }, children: [Math.round(zoom * 100), "%"] })] }), jsxs("div", { className: cs.transformInfo, children: [jsxs("div", { children: [jsx("strong", { children:
|
|
123
|
+
}, children: [jsx(NiceIcon, { name: "move", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.vertical', 'Vertical')] })] }), jsx("div", { className: cs.sectionTitleMb8, children: t('photoEditor.previewZoom', 'Preview zoom') }), jsxs("div", { className: cs.transformZoomRow, children: [jsx(RangeInput, { min: 50, max: 300, value: zoom * 100, onChange: (e) => setZoom(Number(e.target.value) / 100), accentColor: accent }), jsxs("span", { className: cs.transformZoomValue, style: { color: accent }, children: [Math.round(zoom * 100), "%"] })] }), jsxs("div", { className: cs.transformInfo, children: [jsxs("div", { children: [jsx("strong", { children: t('photoEditor.rotation2', 'Rotation:') }), " ", rotation, "\u00B0"] }), jsxs("div", { children: [jsx("strong", { children: t('photoEditor.flipH', 'Flip H:') }), ' ', flipH ? t('photoEditor.yes', 'Yes') : t('photoEditor.no', 'No')] }), jsxs("div", { children: [jsx("strong", { children: t('photoEditor.flipV', 'Flip V:') }), ' ', flipV ? t('photoEditor.yes', 'Yes') : t('photoEditor.no', 'No')] }), cropRect && (jsxs("div", { children: [jsx("strong", { children: t('photoEditor.crop', 'Crop:') }), " ", Math.round(cropRect.w), " \u00D7", ' ', Math.round(cropRect.h), ' (', "x:", Math.round(cropRect.x), ", y:", Math.round(cropRect.y), ")"] }))] })] })), activeTab === 'stickers' && (jsxs("div", { children: [jsx(OverlayToolbar, { api: api }), jsxs("div", { className: cs.sectionTitle, children: [jsx(NiceIcon, { name: "circle", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.stickersEmoji', 'Stickers / Emoji')] }), jsx("div", { className: cs.pillRowGap3, children: EMOJI_CATALOG.map((cat) => (jsxs("button", { onClick: () => setEmojiCat(cat.id), className: emojiCat === cat.id ? cs.pillEmojiActive : cs.pillEmoji, style: {
|
|
124
124
|
borderColor: emojiCat === cat.id ? accent : undefined,
|
|
125
125
|
background: emojiCat === cat.id ? accentDim : undefined,
|
|
126
126
|
}, children: [cat.icon, " ", cat.label] }, cat.id))) }), jsx("div", { className: cs.emojiGrid, children: (_a = EMOJI_CATALOG.find((c) => c.id === emojiCat)) === null || _a === void 0 ? void 0 : _a.emojis.map((em, idx) => (jsx("button", { onClick: () => {
|
|
@@ -128,14 +128,14 @@ const PhotoEditorLeftPanel = /* @__PURE__ */ Object.assign(
|
|
|
128
128
|
const cw = (_b = (_a = mainCanvasRef.current) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : 400;
|
|
129
129
|
const ch = (_d = (_c = mainCanvasRef.current) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : 400;
|
|
130
130
|
addOverlay(createEmojiOverlay(em, cw, ch));
|
|
131
|
-
}, className: cs.emojiBtn, title: em, children: em }, idx))) }), overlays.length > 0 && (jsxs("div", { className: cs.overlaySection, children: [
|
|
131
|
+
}, className: cs.emojiBtn, title: em, children: em }, idx))) }), overlays.length > 0 && (jsxs("div", { className: cs.overlaySection, children: [jsx("div", { className: cs.overlaySectionTitle, children: t('photoEditor.layers', 'Layers ({overlays})').replace('{overlays}', String(overlays.length)) }), overlays.map((ov) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, onClick: () => setSelectedOverlayId(ov.id), className: cs.overlayItem, style: { background: selectedOverlayId === ov.id ? accentDim : undefined }, children: [jsx("span", { className: cs.overlayIcon, children: ov.type === 'emoji' ? (ov.emoji) : ov.type === 'text' ? ('T') : ov.type === 'shape' ? (jsx(NiceIcon, { name: "star", size: 14 })) : ov.type === 'drawing' ? (jsx(NiceIcon, { name: "pen", size: 14 })) : (jsx(NiceIcon, { name: "square", size: 14 })) }), jsx("span", { className: cs.overlayName, children: ov.type === 'text'
|
|
132
132
|
? ov.text.slice(0, 20)
|
|
133
133
|
: ov.type === 'emoji'
|
|
134
|
-
? 'Emoji'
|
|
134
|
+
? t('photoEditor.emoji', 'Emoji')
|
|
135
135
|
: ov.type === 'shape'
|
|
136
136
|
? ov.shapeKind
|
|
137
137
|
: ov.type === 'drawing'
|
|
138
|
-
?
|
|
138
|
+
? t('photoEditor.drawing', 'Drawing ({strokes})').replace('{strokes}', String(ov.strokes.length))
|
|
139
139
|
: ov.type === 'frame'
|
|
140
140
|
? ov.frameStyle
|
|
141
141
|
: '' }), jsx("button", { onClick: (e) => {
|
|
@@ -165,13 +165,13 @@ const PhotoEditorLeftPanel = /* @__PURE__ */ Object.assign(
|
|
|
165
165
|
italic: !selectedOverlay.italic,
|
|
166
166
|
});
|
|
167
167
|
pushHistory();
|
|
168
|
-
}, className: cs.textFormatBtnSm, style: { fontStyle: 'italic' }, children: "I" })] })] }))] })), activeTab === 'shapes' && (jsxs("div", { children: [jsx(OverlayToolbar, { api: api }), jsxs("div", { className: cs.sectionTitle, children: [jsx(NiceIcon, { name: "star", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.shapes', 'Shapes')] }), jsxs("div", { className: cs.shapeColorRow, children: [jsx("span", { className: cs.shapeColorLabel, children:
|
|
168
|
+
}, className: cs.textFormatBtnSm, style: { fontStyle: 'italic' }, children: "I" })] })] }))] })), activeTab === 'shapes' && (jsxs("div", { children: [jsx(OverlayToolbar, { api: api }), jsxs("div", { className: cs.sectionTitle, children: [jsx(NiceIcon, { name: "star", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.shapes', 'Shapes')] }), jsxs("div", { className: cs.shapeColorRow, children: [jsx("span", { className: cs.shapeColorLabel, children: t('photoEditor.stroke', 'Stroke:') }), jsx("input", { type: "color", value: shapeStroke, onChange: (e) => setShapeStroke(e.target.value), className: cs.colorInput, title: t('photoEditor.strokeColor', 'Stroke color') }), jsx("span", { className: cs.shapeColorLabelMl, children: t('photoEditor.fill', 'Fill:') }), jsx("input", { type: "color", value: shapeFill || '#ffffff', onChange: (e) => setShapeFill(e.target.value), className: cs.colorInput, title: t('photoEditor.fillColor', 'Fill color') }), jsx(Button, { variant: shapeFill ? 'light' : 'dark', size: "sm", onClick: () => setShapeFill(shapeFill ? '' : '#ffffff'), className: cs.shapeFillToggle, children: shapeFill ? t('photoEditor.off', 'Off') : t('photoEditor.on', 'On') })] }), jsxs("div", { className: cs.sliderRow, children: [jsx("span", { className: cs.sliderLabel, children: t('photoEditor.width', 'Width:') }), jsx(RangeInput, { min: 1, max: 20, value: shapeStrokeW, onChange: (e) => setShapeStrokeW(Number(e.target.value)), accentColor: accent, style: { flex: 1 } }), jsxs("span", { className: cs.sliderValue, style: { color: accent }, children: [shapeStrokeW, "px"] })] }), jsx("div", { className: cs.shapeGrid, children: SHAPE_CATALOG.map((sh) => (jsx("button", { title: sh.label, onClick: () => {
|
|
169
169
|
const ov = createShapeOverlay(sh.id);
|
|
170
170
|
ov.strokeColor = shapeStroke;
|
|
171
171
|
ov.fillColor = shapeFill || null;
|
|
172
172
|
ov.strokeWidth = shapeStrokeW;
|
|
173
173
|
addOverlay(ov);
|
|
174
|
-
}, className: cs.shapeBtn, children: jsx(NiceIcon, { name: sh.icon, size: 18 }) }, sh.id))) }), jsxs("div", { className: cs.sectionTitle, children: [jsx(NiceIcon, { name: "image", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.frames', 'Frames')] }), jsxs("div", { className: cs.frameColorRow, children: [jsx("input", { type: "color", value: frameColor, onChange: (e) => setFrameColor(e.target.value), className: cs.colorInput, "aria-label": t('photoEditor.frameColor', 'Frame color') }), jsxs("div", { className: cs.frameThicknessWrap, children: [jsx("span", { className: cs.sliderLabel, children:
|
|
174
|
+
}, className: cs.shapeBtn, children: jsx(NiceIcon, { name: sh.icon, size: 18 }) }, sh.id))) }), jsxs("div", { className: cs.sectionTitle, children: [jsx(NiceIcon, { name: "image", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.frames', 'Frames')] }), jsxs("div", { className: cs.frameColorRow, children: [jsx("input", { type: "color", value: frameColor, onChange: (e) => setFrameColor(e.target.value), className: cs.colorInput, "aria-label": t('photoEditor.frameColor', 'Frame color') }), jsxs("div", { className: cs.frameThicknessWrap, children: [jsx("span", { className: cs.sliderLabel, children: t('photoEditor.thickness', 'Thickness:') }), jsx(RangeInput, { min: 1, max: 10, value: frameThick, onChange: (e) => setFrameThick(Number(e.target.value)), accentColor: accent, style: { flex: 1 } }), jsx("span", { className: cs.frameThicknessValue, style: { color: accent }, children: frameThick })] })] }), jsxs("div", { className: cs.frameGrid, children: [FRAME_CATALOG.map((fr) => (jsx("button", { title: fr.label, onClick: () => {
|
|
175
175
|
setOverlays((prev) => prev.filter((o) => o.type !== 'frame'));
|
|
176
176
|
const ov = createFrameOverlay(fr.id, frameColor);
|
|
177
177
|
ov.thickness = frameThick / 100;
|
|
@@ -179,7 +179,7 @@ const PhotoEditorLeftPanel = /* @__PURE__ */ Object.assign(
|
|
|
179
179
|
}, className: cs.frameBtn, children: jsx(NiceIcon, { name: fr.icon, size: 18 }) }, fr.id))), jsx("button", { title: t('photoEditor.removeFrame', 'Remove frame'), "aria-label": t('photoEditor.removeFrame', 'Remove frame'), onClick: () => {
|
|
180
180
|
setOverlays((prev) => prev.filter((o) => o.type !== 'frame'));
|
|
181
181
|
pushHistory();
|
|
182
|
-
}, className: cs.removeFrameBtn, children: jsx(NiceIcon, { name: "close", size: 14 }) })] })] })), activeTab === 'draw' && (jsxs("div", { children: [jsx(OverlayToolbar, { api: api }), jsxs("div", { className: cs.sectionTitleMb8, children: [jsx(NiceIcon, { name: "brush", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.freehandDrawing', 'Freehand drawing')] }), jsxs("div", { className: cs.sectionInfoMb, children: [jsx(NiceIcon, { name: "info", size: 14, style: { marginRight: 4 } }), t('photoEditor.drawDirectlyOnThePhoto', 'Draw directly on the photo by holding the left mouse button.')] }), jsxs("div", { className: cs.quickColorRow, children: [jsx("span", { className: cs.sliderLabel, children:
|
|
182
|
+
}, className: cs.removeFrameBtn, children: jsx(NiceIcon, { name: "close", size: 14 }) })] })] })), activeTab === 'draw' && (jsxs("div", { children: [jsx(OverlayToolbar, { api: api }), jsxs("div", { className: cs.sectionTitleMb8, children: [jsx(NiceIcon, { name: "brush", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.freehandDrawing', 'Freehand drawing')] }), jsxs("div", { className: cs.sectionInfoMb, children: [jsx(NiceIcon, { name: "info", size: 14, style: { marginRight: 4 } }), t('photoEditor.drawDirectlyOnThePhoto', 'Draw directly on the photo by holding the left mouse button.')] }), jsxs("div", { className: cs.quickColorRow, children: [jsx("span", { className: cs.sliderLabel, children: t('photoEditor.color2', 'Color:') }), jsx("input", { type: "color", value: drawColor, onChange: (e) => setDrawColor(e.target.value), className: cs.colorInputDraw, "aria-label": t('photoEditor.drawColor', 'Drawing color') }), [
|
|
183
183
|
'#ff0000',
|
|
184
184
|
'#ff8800',
|
|
185
185
|
'#ffff00',
|
|
@@ -189,10 +189,10 @@ const PhotoEditorLeftPanel = /* @__PURE__ */ Object.assign(
|
|
|
189
189
|
'#ff00ff',
|
|
190
190
|
'#ffffff',
|
|
191
191
|
'#000000',
|
|
192
|
-
].map((c) => (jsx("div", { onClick: () => setDrawColor(c), className: cs.quickColorSwatch, style: {
|
|
192
|
+
].map((c) => (jsx("div", { role: "button", tabIndex: 0, "aria-label": c, "aria-pressed": drawColor === c, onKeyDown: clickOnActivationKey, onClick: () => setDrawColor(c), className: cs.quickColorSwatch, style: {
|
|
193
193
|
background: c,
|
|
194
194
|
border: drawColor === c ? `2px solid ${accent}` : undefined,
|
|
195
|
-
} }, c)))] }), jsxs("div", { className: cs.sliderRow, style: { marginBottom: 12 }, children: [jsx("span", { className: cs.sliderLabel, children:
|
|
195
|
+
} }, c)))] }), jsxs("div", { className: cs.sliderRow, style: { marginBottom: 12 }, children: [jsx("span", { className: cs.sliderLabel, children: t('photoEditor.width', 'Width:') }), jsx(RangeInput, { min: 1, max: 30, value: drawWidth, onChange: (e) => setDrawWidth(Number(e.target.value)), accentColor: accent, style: { flex: 1 } }), jsxs("span", { className: cs.sliderValue, style: { color: accent }, children: [drawWidth, "px"] })] }), jsx("div", { className: cs.drawPreview, children: jsx("div", { style: {
|
|
196
196
|
width: Math.max(drawWidth, 4),
|
|
197
197
|
height: Math.max(drawWidth, 4),
|
|
198
198
|
borderRadius: '50%',
|
|
@@ -28,7 +28,7 @@ const NicePixelEditor = ({ initialWidth = 64, initialHeight = 64, className, onS
|
|
|
28
28
|
api.openFile(f);
|
|
29
29
|
}
|
|
30
30
|
e.target.value = '';
|
|
31
|
-
} }), jsx(NiceAppShell, { className: className, flush: true, menubar: jsx(PixelEditorMenuBar, { api: api, hasOnSaveToLibrary: !!onSaveToLibrary, onOpenGenerator: () => setShowGenerator(true) }), sidebar: jsx(PixelEditorToolbar, { api: api }), rightSidebar: jsx(PixelEditorRightPanel, { api: api }), bottomPanel: jsx(PixelEditorTimeline, { api: api }), statusBar: jsx(PixelEditorStatusBar, { api: api }), children: jsx(PixelEditorCanvas, { api: api }) }), showGenerator && (jsx(NiceSpriteGeneratorPanel, { onSendToCanvas: handleGeneratorSend, onClose: () => setShowGenerator(false) })), jsxs(NiceModal, { open: api.dlgNew, onClose: () => api.setDlgNew(false), title: t('pixelEditor.newDocument', 'New Document'), children: [jsx("label", { children:
|
|
31
|
+
} }), jsx(NiceAppShell, { className: className, flush: true, menubar: jsx(PixelEditorMenuBar, { api: api, hasOnSaveToLibrary: !!onSaveToLibrary, onOpenGenerator: () => setShowGenerator(true) }), sidebar: jsx(PixelEditorToolbar, { api: api }), rightSidebar: jsx(PixelEditorRightPanel, { api: api }), bottomPanel: jsx(PixelEditorTimeline, { api: api }), statusBar: jsx(PixelEditorStatusBar, { api: api }), children: jsx(PixelEditorCanvas, { api: api }) }), showGenerator && (jsx(NiceSpriteGeneratorPanel, { onSendToCanvas: handleGeneratorSend, onClose: () => setShowGenerator(false) })), jsxs(NiceModal, { open: api.dlgNew, onClose: () => api.setDlgNew(false), title: t('pixelEditor.newDocument', 'New Document'), children: [jsx("label", { children: t('pixelEditor.widthPx', 'Width (px)') }), jsx(NiceNumberInput, { min: 1, max: 4096, value: api.nw, onChange: (val) => api.setNw(val !== null && val !== void 0 ? val : 64), "aria-label": t('pixelEditor.documentWidth', 'Document width') }), jsx("label", { children: t('pixelEditor.heightPx', 'Height (px)') }), jsx(NiceNumberInput, { min: 1, max: 4096, value: api.nh, onChange: (val) => api.setNh(val !== null && val !== void 0 ? val : 64), "aria-label": t('pixelEditor.documentHeight', 'Document height') }), jsx("div", { style: { display: 'flex', gap: 4, flexWrap: 'wrap', marginTop: 8 }, children: [
|
|
32
32
|
[16, 16],
|
|
33
33
|
[32, 32],
|
|
34
34
|
[48, 48],
|