@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
|
@@ -2,41 +2,71 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { NiceMenu } from '@nice2dev/ui';
|
|
3
3
|
import { NiceIcon } from '@nice2dev/ui-core';
|
|
4
4
|
import React from 'react';
|
|
5
|
+
import { useNiceTranslation } from '../core/i18n.js';
|
|
5
6
|
import styles from './PixelEditor.module.css.js';
|
|
6
7
|
|
|
7
8
|
const PixelEditorMenuBar = /* @__PURE__ */ Object.assign(
|
|
8
9
|
/* @__PURE__ */ React.memo(({ api, hasOnSaveToLibrary, onOpenGenerator }) => {
|
|
10
|
+
const { t } = useNiceTranslation();
|
|
9
11
|
const items = [
|
|
10
12
|
{
|
|
11
13
|
id: 'file',
|
|
12
|
-
label: 'File',
|
|
14
|
+
label: t('pixelEditorMenuBar.file', 'File'),
|
|
13
15
|
children: [
|
|
14
16
|
{
|
|
15
17
|
id: 'new',
|
|
16
|
-
label: 'New…',
|
|
18
|
+
label: t('pixelEditorMenuBar.new', 'New…'),
|
|
17
19
|
icon: jsx(NiceIcon, { name: "file", size: 14 }),
|
|
18
20
|
onClick: () => api.setDlgNew(true),
|
|
19
21
|
},
|
|
20
22
|
{
|
|
21
23
|
id: 'open',
|
|
22
|
-
label: 'Open…',
|
|
24
|
+
label: t('pixelEditorMenuBar.open', 'Open…'),
|
|
23
25
|
icon: jsx(NiceIcon, { name: "folder", size: 14 }),
|
|
24
26
|
onClick: () => { var _a; return (_a = api.fInp.current) === null || _a === void 0 ? void 0 : _a.click(); },
|
|
25
27
|
},
|
|
26
28
|
{ id: 'sep-file-1', divider: true },
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{
|
|
33
|
-
|
|
29
|
+
{
|
|
30
|
+
id: 'ase',
|
|
31
|
+
label: t('pixelEditorMenuBar.saveAse', 'Save .ase'),
|
|
32
|
+
onClick: api.exportAse,
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: 'png',
|
|
36
|
+
label: t('pixelEditorMenuBar.exportPng', 'Export PNG'),
|
|
37
|
+
onClick: api.exportPNG,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'jpg',
|
|
41
|
+
label: t('pixelEditorMenuBar.exportJpg', 'Export JPG'),
|
|
42
|
+
onClick: api.exportJPG,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
id: 'webp',
|
|
46
|
+
label: t('pixelEditorMenuBar.exportWebp', 'Export WebP'),
|
|
47
|
+
onClick: api.exportWebP,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: 'bmp',
|
|
51
|
+
label: t('pixelEditorMenuBar.exportBmp', 'Export BMP'),
|
|
52
|
+
onClick: api.exportBMP,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'svg',
|
|
56
|
+
label: t('pixelEditorMenuBar.exportSvg', 'Export SVG'),
|
|
57
|
+
onClick: api.exportSVG,
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'sheet',
|
|
61
|
+
label: t('pixelEditorMenuBar.exportSpriteSheet', 'Export sprite sheet'),
|
|
62
|
+
onClick: api.exportSheet,
|
|
63
|
+
},
|
|
34
64
|
...(hasOnSaveToLibrary
|
|
35
65
|
? [
|
|
36
66
|
{ id: 'sep-file-2', divider: true },
|
|
37
67
|
{
|
|
38
68
|
id: 'lib',
|
|
39
|
-
label: 'Save to Library',
|
|
69
|
+
label: t('pixelEditorMenuBar.saveToLibrary', 'Save to Library'),
|
|
40
70
|
icon: jsx(NiceIcon, { name: "box", size: 14 }),
|
|
41
71
|
onClick: api.saveToLibrary,
|
|
42
72
|
},
|
|
@@ -46,35 +76,70 @@ const PixelEditorMenuBar = /* @__PURE__ */ Object.assign(
|
|
|
46
76
|
},
|
|
47
77
|
{
|
|
48
78
|
id: 'edit',
|
|
49
|
-
label: 'Edit',
|
|
79
|
+
label: t('pixelEditorMenuBar.edit', 'Edit'),
|
|
50
80
|
children: [
|
|
51
|
-
{ id: 'undo', label: 'Undo', onClick: api.undo },
|
|
52
|
-
{ id: 'redo', label: 'Redo', onClick: api.redo },
|
|
81
|
+
{ id: 'undo', label: t('pixelEditorMenuBar.undo', 'Undo'), onClick: api.undo },
|
|
82
|
+
{ id: 'redo', label: t('pixelEditorMenuBar.redo', 'Redo'), onClick: api.redo },
|
|
53
83
|
{ id: 'sep-edit-1', divider: true },
|
|
54
|
-
{
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
84
|
+
{
|
|
85
|
+
id: 'copy',
|
|
86
|
+
label: t('pixelEditorMenuBar.copy', 'Copy'),
|
|
87
|
+
onClick: api.doCopy,
|
|
88
|
+
disabled: !api.sel,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'cut',
|
|
92
|
+
label: t('pixelEditorMenuBar.cut', 'Cut'),
|
|
93
|
+
onClick: api.doCut,
|
|
94
|
+
disabled: !api.sel,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
id: 'paste',
|
|
98
|
+
label: t('pixelEditorMenuBar.paste', 'Paste'),
|
|
99
|
+
onClick: api.doPaste,
|
|
100
|
+
disabled: !api.clipboard.current,
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: 'selall',
|
|
104
|
+
label: t('pixelEditorMenuBar.selectAll', 'Select all'),
|
|
105
|
+
onClick: api.doSelectAll,
|
|
106
|
+
},
|
|
58
107
|
],
|
|
59
108
|
},
|
|
60
109
|
{
|
|
61
110
|
id: 'image',
|
|
62
|
-
label: 'Image',
|
|
111
|
+
label: t('pixelEditorMenuBar.image', 'Image'),
|
|
63
112
|
children: [
|
|
64
|
-
{
|
|
65
|
-
|
|
66
|
-
|
|
113
|
+
{
|
|
114
|
+
id: 'fliph',
|
|
115
|
+
label: t('pixelEditorMenuBar.flipHorizontal', 'Flip horizontal'),
|
|
116
|
+
onClick: () => api.flipCv('h'),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: 'flipv',
|
|
120
|
+
label: t('pixelEditorMenuBar.flipVertical', 'Flip vertical'),
|
|
121
|
+
onClick: () => api.flipCv('v'),
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: 'rot',
|
|
125
|
+
label: t('pixelEditorMenuBar.rotate90', 'Rotate 90°'),
|
|
126
|
+
onClick: api.rotateCv,
|
|
127
|
+
},
|
|
67
128
|
{ id: 'sep-image-1', divider: true },
|
|
68
|
-
{
|
|
129
|
+
{
|
|
130
|
+
id: 'clear',
|
|
131
|
+
label: t('pixelEditorMenuBar.clearCanvas', 'Clear canvas'),
|
|
132
|
+
onClick: api.clearCv,
|
|
133
|
+
},
|
|
69
134
|
],
|
|
70
135
|
},
|
|
71
136
|
{
|
|
72
137
|
id: 'view',
|
|
73
|
-
label: 'View',
|
|
138
|
+
label: t('pixelEditorMenuBar.view', 'View'),
|
|
74
139
|
children: [
|
|
75
140
|
{
|
|
76
141
|
id: 'grid',
|
|
77
|
-
label: 'Show grid',
|
|
142
|
+
label: t('pixelEditorMenuBar.showGrid', 'Show grid'),
|
|
78
143
|
badge: api.grid ? 'On' : 'Off',
|
|
79
144
|
onClick: () => api.setGrid((g) => !g),
|
|
80
145
|
},
|
|
@@ -82,11 +147,11 @@ const PixelEditorMenuBar = /* @__PURE__ */ Object.assign(
|
|
|
82
147
|
},
|
|
83
148
|
{
|
|
84
149
|
id: 'tools',
|
|
85
|
-
label: 'Tools',
|
|
150
|
+
label: t('pixelEditorMenuBar.tools', 'Tools'),
|
|
86
151
|
children: [
|
|
87
152
|
{
|
|
88
153
|
id: 'gen',
|
|
89
|
-
label: 'Sprite generator…',
|
|
154
|
+
label: t('pixelEditorMenuBar.spriteGenerator', 'Sprite generator…'),
|
|
90
155
|
icon: jsx(NiceIcon, { name: "palette", size: 14 }),
|
|
91
156
|
onClick: onOpenGenerator,
|
|
92
157
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { NiceCollapse, NiceSlider, NiceButton, NiceCheckbox, NiceTextInput, NiceSelect } from '@nice2dev/ui';
|
|
3
|
-
import { NiceIcon } from '@nice2dev/ui-core';
|
|
3
|
+
import { NiceIcon, clickOnActivationKey } from '@nice2dev/ui-core';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useNiceTranslation } from '../core/i18n.js';
|
|
6
6
|
import { HSVPicker } from './HSVPicker.js';
|
|
@@ -15,24 +15,28 @@ const PixelEditorRightPanel = /* @__PURE__ */ Object.assign(
|
|
|
15
15
|
return (jsxs("div", { className: styles.rightPanel, children: [jsxs(NiceCollapse, { className: styles.panelSection, defaultExpanded: true, trigger: sectionTrigger('Brush'), children: [jsxs("div", { className: styles.brushSlider, children: [jsx("label", { children: t('pixelEditorRightPanel.size', 'Size') }), jsx(NiceSlider, { min: 1, max: 64, value: api.brush.size, onChange: (val) => api.setBrush((b) => ({ ...b, size: val })), "aria-label": t('pixelEditorRightPanel.brushSize', 'Brush size') }), jsx("span", { children: api.brush.size })] }), jsxs("div", { className: styles.brushSlider, children: [jsx("label", { children: t('pixelEditorRightPanel.opacity', 'Opacity') }), jsx(NiceSlider, { min: 1, max: 100, value: api.brush.opacity, onChange: (val) => api.setBrush((b) => ({ ...b, opacity: val })), "aria-label": t('pixelEditorRightPanel.brushOpacity', 'Brush opacity') }), jsxs("span", { children: [api.brush.opacity, "%"] })] }), jsxs("div", { className: styles.brushSlider, children: [jsx("label", { children: t('pixelEditorRightPanel.flow', 'Flow') }), jsx(NiceSlider, { min: 1, max: 100, value: api.brush.flow, onChange: (val) => api.setBrush((b) => ({ ...b, flow: val })), "aria-label": t('pixelEditorRightPanel.brushFlow', 'Brush flow') }), jsxs("span", { children: [api.brush.flow, "%"] })] }), jsxs("div", { className: styles.brushSlider, children: [jsx("label", { children: t('pixelEditorRightPanel.hard', 'Hard') }), jsx(NiceSlider, { min: 0, max: 100, value: api.brush.hardness, onChange: (val) => api.setBrush((b) => ({ ...b, hardness: val })), "aria-label": t('pixelEditorRightPanel.brushHardness', 'Brush hardness') }), jsxs("span", { children: [api.brush.hardness, "%"] })] }), jsxs("div", { className: styles.brushSlider, children: [jsx("label", { children: t('pixelEditorRightPanel.space', 'Space') }), jsx(NiceSlider, { min: 1, max: 100, value: api.brush.spacing, onChange: (val) => api.setBrush((b) => ({ ...b, spacing: val })), "aria-label": t('pixelEditorRightPanel.brushSpacing', 'Brush spacing') }), jsxs("span", { children: [api.brush.spacing, "%"] })] }), jsx("div", { className: styles.brushShapes, children: BRUSH_SHAPES.map((s) => (jsx(NiceButton, { className: `${styles.miniBtn} ${api.brush.shape === s.id ? styles.miniBtnActive : ''}`, variant: api.brush.shape === s.id ? 'primary' : 'ghost', size: "sm", onClick: () => api.setBrush((b) => ({ ...b, shape: s.id })), title: s.label, "aria-label": s.label, children: jsx(NiceIcon, { name: s.icon, size: 16 }) }, s.id))) }), jsxs("div", { className: styles.pressureToggles, children: [jsx(NiceCheckbox, { checked: api.brush.pressureSize, onChange: (checked) => api.setBrush((b) => ({ ...b, pressureSize: checked })), label: t('pixelEditorRightPanel.pressureSize', 'Pressure→Size'), className: styles.checkLabel }), jsx(NiceCheckbox, { checked: api.brush.pressureOpacity, onChange: (checked) => api.setBrush((b) => ({ ...b, pressureOpacity: checked })), label: t('pixelEditorRightPanel.pressureOpacity', 'Pressure→Opacity'), className: styles.checkLabel })] })] }), jsx(NiceCollapse, { className: styles.panelSection, defaultExpanded: true, trigger: sectionTrigger('Colour'), children: jsx(HSVPicker, { color: api.col1, onChange: api.setCol1 }) }), jsxs(NiceCollapse, { className: styles.panelSection, defaultExpanded: true, trigger: sectionTrigger('Layers'), children: [jsxs("div", { className: styles.layerActions, children: [jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.addLayer, title: t('pixelEditorRightPanel.addLayer', 'Add Layer'), "aria-label": t('pixelEditorRightPanel.addLayer', 'Add Layer'), children: jsx(NiceIcon, { name: "plus", size: 16 }) }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.dupLayer, title: t('pixelEditorRightPanel.duplicateLayer', 'Duplicate Layer'), "aria-label": t('pixelEditorRightPanel.duplicateLayer', 'Duplicate Layer'), children: jsx(NiceIcon, { name: "copy", size: 16 }) }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.rmLayer, title: t('pixelEditorRightPanel.removeLayer', 'Remove Layer'), "aria-label": t('pixelEditorRightPanel.removeLayer', 'Remove Layer'), children: jsx(NiceIcon, { name: "minus", size: 16 }) }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.mergeDown, title: t('pixelEditorRightPanel.mergeDown', 'Merge Down'), "aria-label": t('pixelEditorRightPanel.mergeDown', 'Merge Down'), children: jsx(NiceIcon, { name: "arrow-down", size: 16 }) }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.moveLayerUp, title: t('pixelEditorRightPanel.moveUp', 'Move Up'), "aria-label": t('pixelEditorRightPanel.moveUp', 'Move Up'), children: jsx(NiceIcon, { name: "arrow-up", size: 16 }) }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.moveLayerDown, title: t('pixelEditorRightPanel.moveDown', 'Move Down'), "aria-label": t('pixelEditorRightPanel.moveDown', 'Move Down'), children: jsx(NiceIcon, { name: "arrow-down", size: 16 }) })] }), [...api.layers]
|
|
16
16
|
.map((l, i) => ({ l, i }))
|
|
17
17
|
.reverse()
|
|
18
|
-
.map(({ l, i }) => (jsxs("div", { className: `${styles.layerItem} ${i === api.aLi ? styles.layerItemActive : ''}`, onClick: () => api.setALi(i), children: [jsx("span", { className: styles.layerVis, onClick: (e) => {
|
|
18
|
+
.map(({ l, i }) => (jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, className: `${styles.layerItem} ${i === api.aLi ? styles.layerItemActive : ''}`, onClick: () => api.setALi(i), children: [jsx("span", { role: "button", tabIndex: 0, "aria-pressed": l.visible, onKeyDown: clickOnActivationKey, className: styles.layerVis, onClick: (e) => {
|
|
19
19
|
e.stopPropagation();
|
|
20
20
|
api.toggleVis(i);
|
|
21
|
-
}, title: l.visible
|
|
21
|
+
}, title: l.visible
|
|
22
|
+
? t('pixelEditorRightPanel.visible', 'Visible')
|
|
23
|
+
: t('pixelEditorRightPanel.hidden', 'Hidden'), children: jsx(NiceIcon, { name: l.visible ? 'eye' : 'eye-off', size: 14 }) }), jsx("span", { role: "button", tabIndex: 0, "aria-pressed": l.locked, onKeyDown: clickOnActivationKey, className: styles.layerLock, onClick: (e) => {
|
|
22
24
|
e.stopPropagation();
|
|
23
25
|
api.toggleLock(i);
|
|
24
|
-
}, title: l.locked
|
|
26
|
+
}, title: l.locked
|
|
27
|
+
? t('pixelEditorRightPanel.locked', 'Locked')
|
|
28
|
+
: t('pixelEditorRightPanel.unlocked', 'Unlocked'), children: jsx(NiceIcon, { name: "lock", size: 14 }) }), api.editingLayerName === l.id ? (jsx(NiceTextInput, { className: styles.layerNameInput, value: l.name, onChange: (val) => api.renameLayer(i, val), onBlur: () => api.setEditingLayerName(null), onKeyDown: (e) => {
|
|
25
29
|
if (e.key === 'Enter') {
|
|
26
30
|
api.setEditingLayerName(null);
|
|
27
31
|
}
|
|
28
32
|
}, autoFocus: true, "aria-label": t('pixelEditorRightPanel.layerName', 'Layer name') })) : (jsx("span", { className: styles.layerName, onDoubleClick: (e) => {
|
|
29
33
|
e.stopPropagation();
|
|
30
34
|
api.setEditingLayerName(l.id);
|
|
31
|
-
}, children: l.name })), jsxs("span", { className: styles.layerOpacity, children: [Math.round((l.opacity / 255) * 100), "%"] })] }, l.id))), api.layers[api.aLi] && (jsxs("div", { className: styles.layerControls, children: [jsx(NiceSelect, { value: api.layers[api.aLi].blendMode, onChange: (val) => api.setLayerBlendMode(api.aLi, val), className: styles.blendSelect, "aria-label": t('pixelEditorRightPanel.blendMode', 'Blend mode'), options: BLEND_MODES.map((m) => ({ value: m, label: m })) }), jsx(NiceSlider, { min: 0, max: 255, value: api.layers[api.aLi].opacity, onChange: (val) => api.setLayerOpacity(api.aLi, val), className: styles.layerOpSlider, title:
|
|
35
|
+
}, children: l.name })), jsxs("span", { className: styles.layerOpacity, children: [Math.round((l.opacity / 255) * 100), "%"] })] }, l.id))), api.layers[api.aLi] && (jsxs("div", { className: styles.layerControls, children: [jsx(NiceSelect, { value: api.layers[api.aLi].blendMode, onChange: (val) => api.setLayerBlendMode(api.aLi, val), className: styles.blendSelect, "aria-label": t('pixelEditorRightPanel.blendMode', 'Blend mode'), options: BLEND_MODES.map((m) => ({ value: m, label: m })) }), jsx(NiceSlider, { min: 0, max: 255, value: api.layers[api.aLi].opacity, onChange: (val) => api.setLayerOpacity(api.aLi, val), className: styles.layerOpSlider, title: t('pixelEditorRightPanel.opacity2', 'Opacity: {opacity}%').replace('{opacity}', String(Math.round((api.layers[api.aLi].opacity / 255) * 100))) })] }))] }), jsxs(NiceCollapse, { className: styles.panelSection, defaultExpanded: true, trigger: sectionTrigger('Palette'), children: [jsx("div", { className: styles.layerActions, children: jsx(NiceButton, { variant: "ghost", size: "sm", onClick: () => {
|
|
32
36
|
if (!api.pal.includes(api.col1)) {
|
|
33
37
|
api.setPal((p) => [...p, api.col1]);
|
|
34
38
|
}
|
|
35
|
-
}, title: t('pixelEditorRightPanel.addCurrentColour', 'Add current colour'), "aria-label": t('pixelEditorRightPanel.addCurrentColour', 'Add current colour'), children: jsx(NiceIcon, { name: "plus", size: 16 }) }) }), jsx("div", { className: styles.paletteGrid, children: api.pal.map((c, i) => (jsx("div", { className: `${styles.paletteSwatch} ${c === api.col1 ? styles.paletteSwatchActive : ''}`, style: { backgroundColor: c }, onClick: () => api.setCol1(c), onContextMenu: (e) => {
|
|
39
|
+
}, title: t('pixelEditorRightPanel.addCurrentColour', 'Add current colour'), "aria-label": t('pixelEditorRightPanel.addCurrentColour', 'Add current colour'), children: jsx(NiceIcon, { name: "plus", size: 16 }) }) }), jsx("div", { className: styles.paletteGrid, children: api.pal.map((c, i) => (jsx("div", { role: "button", tabIndex: 0, "aria-pressed": c === api.col1, onKeyDown: clickOnActivationKey, className: `${styles.paletteSwatch} ${c === api.col1 ? styles.paletteSwatchActive : ''}`, style: { backgroundColor: c }, onClick: () => api.setCol1(c), onContextMenu: (e) => {
|
|
36
40
|
e.preventDefault();
|
|
37
41
|
api.setCol2(c);
|
|
38
42
|
}, title: c }, i))) })] })] }));
|
|
@@ -8,9 +8,13 @@ const PixelEditorStatusBar = /* @__PURE__ */ Object.assign(
|
|
|
8
8
|
/* @__PURE__ */ React.memo(({ api }) => {
|
|
9
9
|
var _a;
|
|
10
10
|
const { t } = useNiceTranslation();
|
|
11
|
-
return (jsxs("div", { className: styles.statusBar, children: [jsxs("span", { children: [api.dw, "\u00D7", api.dh] }), jsx("span", { children: t('pixelEditorStatusBar.zoom', 'Zoom {zoom}%').replace('{zoom}', String(Math.round(api.zoom * 100))) }), api.cursor && inB(api.cursor.x, api.cursor.y, api.dw, api.dh) && (jsxs("span", { children: ["(", api.cursor.x, ", ", api.cursor.y, ")"] })), jsx("span", { children: api.tool }),
|
|
11
|
+
return (jsxs("div", { className: styles.statusBar, children: [jsxs("span", { children: [api.dw, "\u00D7", api.dh] }), jsx("span", { children: t('pixelEditorStatusBar.zoom', 'Zoom {zoom}%').replace('{zoom}', String(Math.round(api.zoom * 100))) }), api.cursor && inB(api.cursor.x, api.cursor.y, api.dw, api.dh) && (jsxs("span", { children: ["(", api.cursor.x, ", ", api.cursor.y, ")"] })), jsx("span", { children: api.tool }), jsx("span", { children: t('pixelEditorStatusBar.brushPx', 'Brush: {size}px {shape}')
|
|
12
|
+
.replace('{size}', String(api.brush.size))
|
|
13
|
+
.replace('{shape}', String(api.brush.shape)) }), jsx("span", { children: t('pixelEditorStatusBar.pressure', 'Pressure: {pressure}%').replace('{pressure}', String(Math.round(api.pressure * 100))) }), jsx("span", { children: t('pixelEditorStatusBar.layer', 'Layer: {name}').replace('{name}', String((_a = api.layers[api.aLi]) === null || _a === void 0 ? void 0 : _a.name)) }), jsx("span", { children: t('pixelEditorStatusBar.frame', 'Frame {current}/{total}')
|
|
12
14
|
.replace('{current}', String(api.afi + 1))
|
|
13
|
-
.replace('{total}', String(api.fc)) }), api.symmetry !== 'none' &&
|
|
15
|
+
.replace('{total}', String(api.fc)) }), api.symmetry !== 'none' && (jsx("span", { children: t('pixelEditorStatusBar.sym', 'Sym: {symmetry}').replace('{symmetry}', String(api.symmetry)) })), api.shapeFilled && jsx("span", { children: t('pixelEditorStatusBar.filled', 'Filled') }), api.sel && (jsx("span", { children: t('pixelEditorStatusBar.sel', 'Sel: {w}×{h}')
|
|
16
|
+
.replace('{w}', String(api.sel.w))
|
|
17
|
+
.replace('{h}', String(api.sel.h)) }))] }));
|
|
14
18
|
}), { displayName: 'PixelEditorStatusBar' });
|
|
15
19
|
|
|
16
20
|
export { PixelEditorStatusBar as default };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { NiceButton, NiceNumberInput, NiceCheckbox } from '@nice2dev/ui';
|
|
3
|
-
import { NiceIcon } from '@nice2dev/ui-core';
|
|
3
|
+
import { NiceIcon, clickOnActivationKey } from '@nice2dev/ui-core';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useNiceTranslation } from '../core/i18n.js';
|
|
6
6
|
import styles from './PixelEditor.module.css.js';
|
|
@@ -8,7 +8,11 @@ import styles from './PixelEditor.module.css.js';
|
|
|
8
8
|
const PixelEditorTimeline = /* @__PURE__ */ Object.assign(
|
|
9
9
|
/* @__PURE__ */ React.memo(({ api }) => {
|
|
10
10
|
const { t } = useNiceTranslation();
|
|
11
|
-
return (jsxs("div", { className: styles.bottomPanel, children: [jsxs("div", { className: styles.timelineControls, children: [jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.addFrame, children:
|
|
11
|
+
return (jsxs("div", { className: styles.bottomPanel, children: [jsxs("div", { className: styles.timelineControls, children: [jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.addFrame, children: t('pixelEditorTimeline.frame', '+ Frame') }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.dupFrame, "aria-label": t('pixelEditorTimeline.duplicateFrame', 'Duplicate frame'), children: t('pixelEditorTimeline.dup', 'Dup') }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.rmFrame, "aria-label": t('pixelEditorTimeline.removeFrame', 'Remove frame'), children: t('pixelEditorTimeline.frame2', '− Frame') }), jsx("div", { className: styles.menuSep }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: () => api.setPlaying((p) => !p), "aria-label": api.playing
|
|
12
|
+
? t('pixelEditorTimeline.pause', 'Pause')
|
|
13
|
+
: t('pixelEditorTimeline.play', 'Play'), children: jsx(NiceIcon, { name: api.playing ? 'pause' : 'play', size: 16 }) }), jsx("label", { children: t('pixelEditorTimeline.fps', 'FPS:') }), jsx(NiceNumberInput, { min: 1, max: 60, value: api.fps, onChange: (val) => api.setFps(val !== null && val !== void 0 ? val : 8), "aria-label": t('pixelEditorTimeline.framesPerSecond', 'Frames per second') }), jsx("div", { className: styles.menuSep }), jsx(NiceCheckbox, { checked: api.onion, onChange: (checked) => api.setOnion(checked), label: t('pixelEditorTimeline.onion', 'Onion') }), jsx("div", { style: { flex: 1 } }), jsx("span", { children: api.fc !== 1
|
|
14
|
+
? t('pixelEditorTimeline.framesMany', '{fc} frames').replace('{fc}', String(api.fc))
|
|
15
|
+
: t('pixelEditorTimeline.framesOne', '{fc} frame').replace('{fc}', String(api.fc)) })] }), jsx("div", { className: styles.timelineFrames, children: Array.from({ length: api.fc }, (_, fi) => (jsxs("div", { role: "button", tabIndex: 0, "aria-label": t('pixelEditorTimeline.frame3', 'Frame {fi}').replace('{fi}', String(fi + 1)), "aria-pressed": fi === api.afi, onKeyDown: clickOnActivationKey, className: `${styles.frameThumb} ${fi === api.afi ? styles.frameThumbActive : ''}`, onClick: () => api.setAfi(fi), children: [api.thumbs[fi] && (jsx("img", { src: api.thumbs[fi], alt: t('pixelEditorTimeline.frame3', 'Frame {fi}').replace('{fi}', String(fi + 1)), style: {
|
|
12
16
|
width: 36,
|
|
13
17
|
height: 36,
|
|
14
18
|
imageRendering: 'pixelated',
|
|
@@ -9,7 +9,9 @@ import { TOOLS, SYMMETRY_MODES } from './pixelEditorTypes.js';
|
|
|
9
9
|
const PixelEditorToolbar = /* @__PURE__ */ Object.assign(
|
|
10
10
|
/* @__PURE__ */ React.memo(({ api }) => {
|
|
11
11
|
const { t } = useNiceTranslation();
|
|
12
|
-
return (jsxs("div", { className: styles.toolbar, children: [TOOLS.map((t) => (jsx(NiceButton, { className: `${styles.toolBtn} ${api.tool === t.id ? styles.toolBtnActive : ''}`, variant: api.tool === t.id ? 'primary' : 'ghost', size: "sm", onClick: () => api.setTool(t.id), title: `${t.label} (${t.key})`, "aria-label": t.label, children: jsx(NiceIcon, { name: t.icon, size: 16 }) }, t.id))), jsx("div", { className: styles.toolSep }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.shapeFilled ? styles.toolBtnActive : ''}`, variant: api.shapeFilled ? 'primary' : 'ghost', size: "sm", onClick: () => api.setShapeFilled((f) => !f), title: `${api.shapeFilled ? 'Filled' : 'Outline'} (F)`, "aria-label": api.shapeFilled
|
|
12
|
+
return (jsxs("div", { className: styles.toolbar, children: [TOOLS.map((t) => (jsx(NiceButton, { className: `${styles.toolBtn} ${api.tool === t.id ? styles.toolBtnActive : ''}`, variant: api.tool === t.id ? 'primary' : 'ghost', size: "sm", onClick: () => api.setTool(t.id), title: `${t.label} (${t.key})`, "aria-label": t.label, children: jsx(NiceIcon, { name: t.icon, size: 16 }) }, t.id))), jsx("div", { className: styles.toolSep }), jsx(NiceButton, { className: `${styles.toolBtn} ${api.shapeFilled ? styles.toolBtnActive : ''}`, variant: api.shapeFilled ? 'primary' : 'ghost', size: "sm", onClick: () => api.setShapeFilled((f) => !f), title: `${api.shapeFilled ? 'Filled' : 'Outline'} (F)`, "aria-label": api.shapeFilled
|
|
13
|
+
? t('pixelEditorToolbar.filledShape', 'Filled shape')
|
|
14
|
+
: t('pixelEditorToolbar.outlineShape', 'Outline shape'), children: jsx(NiceIcon, { name: api.shapeFilled ? 'check-square' : 'square', size: 16 }) }), jsx("div", { className: styles.toolGroup, children: SYMMETRY_MODES.map((m) => (jsx(NiceButton, { className: `${styles.miniBtn} ${api.symmetry === m.id ? styles.miniBtnActive : ''}`, variant: api.symmetry === m.id ? 'primary' : 'ghost', size: "sm", onClick: () => api.setSymmetry(m.id), title: t('pixelEditorToolbar.symmetry', 'Symmetry: {label}').replace('{label}', String(m.label)), "aria-label": t('pixelEditorToolbar.symmetry', 'Symmetry: {label}').replace('{label}', String(m.label)), children: jsx(NiceIcon, { name: m.icon, size: 14 }) }, m.id))) }), jsxs("div", { className: styles.colorSwatches, children: [jsx("label", { style: { position: 'relative', width: 28, height: 28, cursor: 'pointer' }, title: t('pixelEditorToolbar.primaryColourClickForHsv', 'Primary Colour (click for HSV)'), children: jsx(NiceColorPicker, { value: api.col1, onChange: (c) => api.setCol1(c) }) }), jsx("label", { style: { position: 'relative', width: 22, height: 22, cursor: 'pointer' }, title: t('pixelEditorToolbar.secondaryColour', 'Secondary Colour'), children: jsx(NiceColorPicker, { value: api.col2, onChange: (c) => api.setCol2(c) }) }), jsx(NiceButton, { className: styles.toolBtn, variant: "ghost", size: "sm", onClick: () => {
|
|
13
15
|
const tmp = api.col1;
|
|
14
16
|
api.setCol1(api.col2);
|
|
15
17
|
api.setCol2(tmp);
|
|
@@ -226,19 +226,19 @@ const NiceSpriteGeneratorPanel = ({ onSendToCanvas, onClose, mode,
|
|
|
226
226
|
case 'character':
|
|
227
227
|
return [
|
|
228
228
|
{
|
|
229
|
-
label: 'Skin',
|
|
229
|
+
label: t('spriteGeneratorPanel.skin', 'Skin'),
|
|
230
230
|
options: palettesToOptions(SKIN_PALETTES),
|
|
231
231
|
value: skinPalette,
|
|
232
232
|
set: setSkinPalette,
|
|
233
233
|
},
|
|
234
234
|
{
|
|
235
|
-
label: 'Hair',
|
|
235
|
+
label: t('spriteGeneratorPanel.hair', 'Hair'),
|
|
236
236
|
options: palettesToOptions(HAIR_PALETTES),
|
|
237
237
|
value: hairPalette,
|
|
238
238
|
set: setHairPalette,
|
|
239
239
|
},
|
|
240
240
|
{
|
|
241
|
-
label: 'Clothing',
|
|
241
|
+
label: t('spriteGeneratorPanel.clothing', 'Clothing'),
|
|
242
242
|
options: palettesToOptions(CLOTHING_PALETTES),
|
|
243
243
|
value: clothPalette,
|
|
244
244
|
set: setClothPalette,
|
|
@@ -247,13 +247,13 @@ const NiceSpriteGeneratorPanel = ({ onSendToCanvas, onClose, mode,
|
|
|
247
247
|
case 'building':
|
|
248
248
|
return [
|
|
249
249
|
{
|
|
250
|
-
label: 'Walls',
|
|
250
|
+
label: t('spriteGeneratorPanel.walls', 'Walls'),
|
|
251
251
|
options: palettesToOptions(WALL_PALETTES),
|
|
252
252
|
value: wallPalette,
|
|
253
253
|
set: setWallPalette,
|
|
254
254
|
},
|
|
255
255
|
{
|
|
256
|
-
label: 'Roof',
|
|
256
|
+
label: t('spriteGeneratorPanel.roof', 'Roof'),
|
|
257
257
|
options: palettesToOptions(ROOF_PALETTES),
|
|
258
258
|
value: roofPalette,
|
|
259
259
|
set: setRoofPalette,
|
|
@@ -262,14 +262,14 @@ const NiceSpriteGeneratorPanel = ({ onSendToCanvas, onClose, mode,
|
|
|
262
262
|
case 'animal':
|
|
263
263
|
return [
|
|
264
264
|
{
|
|
265
|
-
label: 'Fur',
|
|
265
|
+
label: t('spriteGeneratorPanel.fur', 'Fur'),
|
|
266
266
|
options: palettesToOptions(FUR_PALETTES),
|
|
267
267
|
value: furPalette,
|
|
268
268
|
set: setFurPalette,
|
|
269
269
|
},
|
|
270
270
|
];
|
|
271
271
|
}
|
|
272
|
-
}, [tab, skinPalette, hairPalette, clothPalette, wallPalette, roofPalette, furPalette]);
|
|
272
|
+
}, [tab, skinPalette, hairPalette, clothPalette, wallPalette, roofPalette, furPalette, t]);
|
|
273
273
|
/* ── Render ── */
|
|
274
274
|
return (jsx(NiceModal, { open: true, onClose: onClose !== null && onClose !== void 0 ? onClose : (() => { }), title: t('spriteGeneratorPanel.spriteGenerator', 'Sprite Generator'), size: "xl", children: jsxs("div", { className: styles.genPanel, children: [jsx("div", { className: styles.genTabs, children: ['character', 'building', 'animal'].map((t) => (jsxs(NiceButton, { className: `${styles.genTabBtn} ${tab === t ? styles.genTabBtnActive : ''}`, variant: tab === t ? 'primary' : 'ghost', size: "sm", onClick: () => setTab(t), children: [jsx(NiceIcon, { name: t === 'character' ? 'user' : t === 'building' ? 'home' : 'heart', size: 14 }), ' ', t.charAt(0).toUpperCase() + t.slice(1)] }, t))) }), jsxs("div", { className: styles.genBody, children: [jsxs("div", { className: styles.genLeft, children: [jsxs("div", { className: styles.panelSection, children: [jsx("div", { className: styles.panelTitle, children: jsx("span", { children: t('spriteGeneratorPanel.presets', 'Presets') }) }), jsx("div", { className: styles.genPresetGrid, children: presets.map((preset, i) => (jsx(NiceButton, { className: `${styles.genPresetBtn} ${i === selectedPresetIdx ? styles.genPresetBtnActive : ''}`, variant: i === selectedPresetIdx ? 'primary' : 'ghost', size: "sm", onClick: () => applyPreset(i), title: preset.name, children: preset.name }, i))) })] }), jsxs("div", { className: styles.panelSection, style: { flex: 1, overflowY: 'auto' }, children: [jsx("div", { className: styles.panelTitle, children: jsx("span", { children: t('spriteGeneratorPanel.parts', 'Parts') }) }), categories.map((cat) => {
|
|
275
275
|
const parts = getPartsByCategory(cat);
|
|
@@ -286,9 +286,12 @@ const NiceSpriteGeneratorPanel = ({ onSendToCanvas, onClose, mode,
|
|
|
286
286
|
return (jsx(NiceButton, { className: `${styles.miniBtn} ${styles.genPartBtn} ${active ? styles.miniBtnActive : ''}`, variant: active ? 'primary' : 'ghost', size: "sm", onClick: () => (active ? removePart(part.id) : addPart(part.id)), title: part.name, children: part.name }, part.id));
|
|
287
287
|
}) })] }, cat));
|
|
288
288
|
})] })] }), jsxs("div", { className: styles.genCenter, children: [jsx("div", { className: styles.genPreviewWrap, children: jsx("canvas", { ref: previewRef, className: styles.genPreviewCanvas }) }), jsx("div", { className: styles.genDirGrid, children: ALL_DIRECTIONS.map((d) => (jsx(NiceButton, { className: `${styles.miniBtn} ${direction === d ? styles.miniBtnActive : ''}`, variant: direction === d ? 'primary' : 'ghost', size: "sm", onClick: () => setDirection(d), children: d }, d))) }), jsxs("div", { className: styles.genRow, children: [jsx("label", { style: { fontSize: 10, color: 'var(--nice-text-muted)' }, children: t('spriteGeneratorPanel.projection', 'Projection') }), jsx(NiceSelect, { className: styles.propSelect, value: projection, onChange: (val) => setProjection(val), options: [
|
|
289
|
-
{ value: 'topDown', label: 'Top-Down' },
|
|
290
|
-
{ value: 'sideView', label: 'Side View' },
|
|
291
|
-
{
|
|
289
|
+
{ value: 'topDown', label: t('spriteGeneratorPanel.topDown', 'Top-Down') },
|
|
290
|
+
{ value: 'sideView', label: t('spriteGeneratorPanel.sideView', 'Side View') },
|
|
291
|
+
{
|
|
292
|
+
value: 'iso25d',
|
|
293
|
+
label: t('spriteGeneratorPanel.n25dIsometric', '2.5D Isometric'),
|
|
294
|
+
},
|
|
292
295
|
] })] }), jsxs("div", { className: styles.genRow, children: [jsx("label", { style: { fontSize: 10, color: 'var(--nice-text-muted)' }, children: t('spriteGeneratorPanel.size', 'Size') }), jsx(NiceNumberInput, { min: 8, max: 256, value: canvasW, onChange: (val) => setCanvasW(val !== null && val !== void 0 ? val : 32) }), jsx("span", { style: { fontSize: 10, color: 'var(--nice-text-muted)' }, children: "\u00D7" }), jsx(NiceNumberInput, { min: 8, max: 256, value: canvasH, onChange: (val) => setCanvasH(val !== null && val !== void 0 ? val : 32) })] }), jsx(NiceCheckbox, { checked: generate8Dir, onChange: (checked) => setGenerate8Dir(checked), label: t('spriteGeneratorPanel.generate8DirectionSheet', 'Generate 8-direction sheet'), className: styles.checkLabel })] }), jsxs("div", { className: styles.genRight, children: [jsxs("div", { className: styles.panelSection, children: [jsx("div", { className: styles.panelTitle, children: jsx("span", { children: t('spriteGeneratorPanel.colors', 'Colors') }) }), paletteGroups.map((group) => {
|
|
293
296
|
var _a;
|
|
294
297
|
return (jsxs("div", { style: { marginBottom: 6 }, children: [jsx("div", { style: { fontSize: 9, color: 'var(--nice-text-muted)', marginBottom: 2 }, children: group.label }), jsx(NiceSelect, { className: styles.propSelect, value: group.value, onChange: (val) => group.set(val), options: group.options.map((opt) => ({
|
|
@@ -302,7 +305,11 @@ const NiceSpriteGeneratorPanel = ({ onSendToCanvas, onClose, mode,
|
|
|
302
305
|
return (
|
|
303
306
|
// A part can be placed twice (left and right leg, flipped), so its id
|
|
304
307
|
// alone is not a unique key.
|
|
305
|
-
jsxs("div", { className: styles.genAssemblyItem, children: [jsx(NiceButton, { className: styles.btnIcon, variant: "ghost", size: "sm", onClick: () => togglePart(ap.partId), title: ((_a = ap.visible) !== null && _a !== void 0 ? _a : true)
|
|
308
|
+
jsxs("div", { className: styles.genAssemblyItem, children: [jsx(NiceButton, { className: styles.btnIcon, variant: "ghost", size: "sm", onClick: () => togglePart(ap.partId), title: ((_a = ap.visible) !== null && _a !== void 0 ? _a : true)
|
|
309
|
+
? t('spriteGeneratorPanel.hide', 'Hide')
|
|
310
|
+
: t('spriteGeneratorPanel.show', 'Show'), "aria-label": ((_b = ap.visible) !== null && _b !== void 0 ? _b : true)
|
|
311
|
+
? t('spriteGeneratorPanel.hide', 'Hide')
|
|
312
|
+
: t('spriteGeneratorPanel.show', 'Show'), children: jsx(NiceIcon, { name: ((_c = ap.visible) !== null && _c !== void 0 ? _c : true) ? 'eye' : 'eye-off', size: 14 }) }), jsx("span", { className: styles.genAssemblyName, children: (_d = part === null || part === void 0 ? void 0 : part.name) !== null && _d !== void 0 ? _d : ap.partId }), jsxs("span", { style: { fontSize: 9, color: 'var(--nice-text-muted)' }, children: ["z:", (_e = part === null || part === void 0 ? void 0 : part.zOrder) !== null && _e !== void 0 ? _e : 0] }), jsx(NiceButton, { className: styles.btnIcon, variant: "ghost", size: "sm", onClick: () => removePart(ap.partId), title: t('spriteGeneratorPanel.remove', 'Remove'), "aria-label": t('spriteGeneratorPanel.remove', 'Remove'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, `${ap.partId}-${i}`));
|
|
306
313
|
})] })] })] }), jsxs("div", { className: styles.genFooter, children: [jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: onClose, children: t('spriteGeneratorPanel.cancel', 'Cancel') }), jsxs(NiceButton, { className: styles.btnPrimary, variant: "primary", onClick: handleSendToCanvas, children: [jsx(NiceIcon, { name: "clipboard", size: 14 }), ' ', t('spriteGeneratorPanel.sendToCanvas', 'Send to Canvas')] })] })] }) }));
|
|
307
314
|
};
|
|
308
315
|
if (process.env.NODE_ENV !== 'production') {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { resolveCssColor, NiceIcon } from '@nice2dev/ui-core';
|
|
2
|
+
import { resolveCssColor, NiceIcon, clickOnActivationKey } from '@nice2dev/ui-core';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import { useNiceTranslation } from '../core/i18n.js';
|
|
5
5
|
|
|
@@ -344,7 +344,7 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
344
344
|
borderTop: '1px solid var(--nice-border, #373a40)',
|
|
345
345
|
width: '100%',
|
|
346
346
|
margin: '4px 0',
|
|
347
|
-
} }),
|
|
347
|
+
} }), jsx("label", { children: t('texturePainter3d.sizePx', 'Size: {size}px').replace('{size}', String(painter.brush.size)) }), jsx("input", { type: "range", min: 1, max: 100, value: painter.brush.size, onChange: (e) => painter.setBrush({ ...painter.brush, size: Number(e.target.value) }), style: { width: '100%' } }), jsx("label", { children: t('texturePainter3d.opacity', 'Opacity: {opacity}%').replace('{opacity}', String(Math.round(painter.brush.opacity * 100))) }), jsx("input", { type: "range", min: 0, max: 1, step: 0.01, value: painter.brush.opacity, onChange: (e) => painter.setBrush({ ...painter.brush, opacity: Number(e.target.value) }), style: { width: '100%' } }), jsx("label", { children: t('texturePainter3d.hardness', 'Hardness: {hardness}%').replace('{hardness}', String(Math.round(painter.brush.hardness * 100))) }), jsx("input", { type: "range", min: 0, max: 1, step: 0.01, value: painter.brush.hardness, onChange: (e) => painter.setBrush({ ...painter.brush, hardness: Number(e.target.value) }), style: { width: '100%' } }), jsx("label", { children: t('texturePainter3d.blendMode', 'Blend Mode') }), jsxs("select", { value: painter.brush.blendMode, onChange: (e) => painter.setBrush({
|
|
348
348
|
...painter.brush,
|
|
349
349
|
blendMode: e.target.value,
|
|
350
350
|
}), style: {
|
|
@@ -360,7 +360,7 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
360
360
|
borderTop: '1px solid var(--nice-border, #373a40)',
|
|
361
361
|
width: '100%',
|
|
362
362
|
margin: '4px 0',
|
|
363
|
-
} }),
|
|
363
|
+
} }), jsx("label", { children: t('texturePainter3d.zoom', 'Zoom: {zoom}%').replace('{zoom}', String(Math.round(zoom * 100))) }), jsxs("div", { style: { display: 'flex', gap: 2 }, children: [jsx("button", { onClick: () => setZoom((z) => Math.max(0.1, z - 0.1)), style: btnStyle(false), children: "\u2212" }), jsx("button", { onClick: () => setZoom(0.5), style: btnStyle(false), children: t('texturePainter3d.reset', 'Reset') }), jsx("button", { onClick: () => setZoom((z) => Math.min(4, z + 0.1)), style: btnStyle(false), children: "+" })] })] }), jsxs("div", { style: {
|
|
364
364
|
flex: 1,
|
|
365
365
|
overflow: 'hidden',
|
|
366
366
|
position: 'relative',
|
|
@@ -382,7 +382,7 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
382
382
|
color: 'var(--nice-text-secondary, #868e96)',
|
|
383
383
|
display: 'flex',
|
|
384
384
|
gap: 12,
|
|
385
|
-
}, children: [jsxs("span", { children: [textureWidth, "\u00D7", textureHeight] }), cursorPos && (jsxs("span", { children: ["X: ", cursorPos.x, " Y: ", cursorPos.y] })),
|
|
385
|
+
}, children: [jsxs("span", { children: [textureWidth, "\u00D7", textureHeight] }), cursorPos && (jsxs("span", { children: ["X: ", cursorPos.x, " Y: ", cursorPos.y] })), jsx("span", { children: t('texturePainter3d.zoom', 'Zoom: {zoom}%').replace('{zoom}', String(Math.round(zoom * 100))) })] })] }), jsxs("div", { style: { width: 160, fontSize: 11, display: 'flex', flexDirection: 'column', gap: 4 }, children: [jsx("strong", { style: { fontSize: 12 }, children: t('texturePainter3d.layers', 'Layers') }), jsx("div", { style: { flex: 1, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: 2 }, children: [...painter.layers].reverse().map((l) => (jsxs("div", { style: {
|
|
386
386
|
padding: '4px 6px',
|
|
387
387
|
borderRadius: 3,
|
|
388
388
|
background: painter.activeLayerId === l.id
|
|
@@ -391,7 +391,7 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
391
391
|
color: painter.activeLayerId === l.id
|
|
392
392
|
? 'var(--nice-color-white, #fff)'
|
|
393
393
|
: 'var(--nice-text, #c1c2c5)',
|
|
394
|
-
}, children: [jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4, cursor: 'pointer' }, onClick: () => painter.setActiveLayerId(l.id), children: [jsx("button", { onClick: (e) => {
|
|
394
|
+
}, children: [jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, style: { display: 'flex', alignItems: 'center', gap: 4, cursor: 'pointer' }, onClick: () => painter.setActiveLayerId(l.id), children: [jsx("button", { onClick: (e) => {
|
|
395
395
|
e.stopPropagation();
|
|
396
396
|
painter.toggleLayerVisibility(l.id);
|
|
397
397
|
}, style: {
|
|
@@ -403,7 +403,11 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
403
403
|
? 'var(--nice-text, #c1c2c5)'
|
|
404
404
|
: 'var(--nice-text-secondary, #5c5f66)',
|
|
405
405
|
fontSize: 12,
|
|
406
|
-
}, title: l.visible
|
|
406
|
+
}, title: l.visible
|
|
407
|
+
? t('texturePainter3d.hideLayer', 'Hide layer')
|
|
408
|
+
: t('texturePainter3d.showLayer', 'Show layer'), "aria-label": l.visible
|
|
409
|
+
? t('texturePainter3d.hideLayer', 'Hide layer')
|
|
410
|
+
: t('texturePainter3d.showLayer', 'Show layer'), children: jsx(NiceIcon, { name: l.visible ? 'eye' : 'eye-off', size: 14 }) }), jsx("span", { style: {
|
|
407
411
|
flex: 1,
|
|
408
412
|
overflow: 'hidden',
|
|
409
413
|
textOverflow: 'ellipsis',
|
|
@@ -425,7 +429,7 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
425
429
|
cursor: 'pointer',
|
|
426
430
|
background: 'var(--nice-bg-secondary, #2c2e33)',
|
|
427
431
|
color: 'var(--nice-text, #c1c2c5)',
|
|
428
|
-
}, children:
|
|
432
|
+
}, children: t('texturePainter3d.addLayer', '+ Add Layer') }), jsx("hr", { style: {
|
|
429
433
|
border: 'none',
|
|
430
434
|
borderTop: '1px solid var(--nice-border, #373a40)',
|
|
431
435
|
width: '100%',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { NiceTutorialButton, resolveTutorial, NiceAppShell } from '@nice2dev/ui';
|
|
3
|
-
import { NiceIcon } from '@nice2dev/ui-core';
|
|
3
|
+
import { NiceIcon, clickOnActivationKey } from '@nice2dev/ui-core';
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import { useNiceTranslation } from '../core/i18n.js';
|
|
6
6
|
|
|
@@ -373,7 +373,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
373
373
|
var _a, _b, _c, _d;
|
|
374
374
|
const isSelected = designer.selectedId === node.id;
|
|
375
375
|
const def = COMPONENT_DEFS.find((d) => d.type === node.type);
|
|
376
|
-
return (jsxs("div", { onClick: (e) => {
|
|
376
|
+
return (jsxs("div", { role: "presentation", onClick: (e) => {
|
|
377
377
|
e.stopPropagation();
|
|
378
378
|
designer.setSelectedId(node.id);
|
|
379
379
|
}, onDrop: (e) => ((def === null || def === void 0 ? void 0 : def.allowChildren) ? handleDrop(e, node.id) : undefined), onDragOver: (def === null || def === void 0 ? void 0 : def.allowChildren) ? handleDragOver : undefined, style: {
|
|
@@ -413,7 +413,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
413
413
|
};
|
|
414
414
|
const renderTreeItem = (node, depth = 0) => {
|
|
415
415
|
const def = COMPONENT_DEFS.find((d) => d.type === node.type);
|
|
416
|
-
return (jsxs(React.Fragment, { children: [jsxs("div", { onClick: () => designer.setSelectedId(node.id), style: {
|
|
416
|
+
return (jsxs(React.Fragment, { children: [jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, onClick: () => designer.setSelectedId(node.id), style: {
|
|
417
417
|
padding: '2px 4px',
|
|
418
418
|
paddingLeft: 4 + depth * 12,
|
|
419
419
|
fontSize: 10,
|
|
@@ -437,14 +437,14 @@ const NiceSvgToCode = ({ initialSvg = '', onConvert, className = '', }) => {
|
|
|
437
437
|
navigator.clipboard.writeText(result.code);
|
|
438
438
|
}
|
|
439
439
|
};
|
|
440
|
-
return (jsxs("div", { className: `nice-svg-to-code ${className}`, style: { display: 'grid', gap: 8, fontSize: 13 }, children: [jsxs("strong", { children: [jsx(NiceIcon, { name: "refresh", size: 14 }), " SVG
|
|
440
|
+
return (jsxs("div", { className: `nice-svg-to-code ${className}`, style: { display: 'grid', gap: 8, fontSize: 13 }, children: [jsxs("strong", { children: [jsx(NiceIcon, { name: "refresh", size: 14 }), " ", t('svgToCode.svgCode', 'SVG → Code')] }), jsx("textarea", { value: svgInput, onChange: (e) => setSvgInput(e.target.value), placeholder: t('svgToCode.pasteSvgMarkupHere', 'Paste SVG markup here…'), rows: 6, style: {
|
|
441
441
|
width: '100%',
|
|
442
442
|
fontFamily: 'monospace',
|
|
443
443
|
fontSize: 11,
|
|
444
444
|
padding: 6,
|
|
445
445
|
borderRadius: 4,
|
|
446
446
|
border: '1px solid var(--nice-border, #e2e8f0)',
|
|
447
|
-
} }), jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [
|
|
447
|
+
} }), jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: [t('svgToCode.framework', 'Framework:'), jsxs("select", { value: config.framework, onChange: (e) => updateConfig({ framework: e.target.value }), style: { width: '100%' }, children: [jsx("option", { value: "react", children: "React (JSX/TSX)" }), jsx("option", { value: "vue", children: "Vue (SFC)" }), jsx("option", { value: "web-component", children: t('svgToCode.webComponent', 'Web Component') }), jsx("option", { value: "typescript", children: t('svgToCode.typescriptUtility', 'TypeScript (utility)') })] })] }), jsxs("label", { children: [t('svgToCode.componentName', 'Component name:'), jsx("input", { type: "text", value: config.componentName, onChange: (e) => updateConfig({ componentName: e.target.value.replace(/[^a-zA-Z0-9]/g, '') }), style: { width: '100%', padding: '3px 6px' } })] }), jsxs("div", { style: { display: 'flex', gap: 8, flexWrap: 'wrap', fontSize: 11 }, children: [jsxs("label", { children: [jsx("input", { type: "checkbox", checked: config.typescript, onChange: (e) => updateConfig({ typescript: e.target.checked }) }), ' ', t('svgToCode.typescript', 'TypeScript')] }), jsxs("label", { children: [jsx("input", { type: "checkbox", checked: config.optimize, onChange: (e) => updateConfig({ optimize: e.target.checked }) }), ' ', t('svgToCode.optimize', 'Optimize')] }), jsxs("label", { children: [jsx("input", { type: "checkbox", checked: config.sizeProps, onChange: (e) => updateConfig({ sizeProps: e.target.checked }) }), ' ', t('svgToCode.sizeProps', 'Size props')] }), jsxs("label", { children: [jsx("input", { type: "checkbox", checked: config.useCurrentColor, onChange: (e) => updateConfig({ useCurrentColor: e.target.checked }) }), ' ', "currentColor"] }), jsxs("label", { children: [jsx("input", { type: "checkbox", checked: config.memo, onChange: (e) => updateConfig({ memo: e.target.checked }) }), ' ', "memo"] })] })] }), jsxs("button", { type: "button", onClick: handleConvert, disabled: !svgInput.trim(), style: {
|
|
448
448
|
background: 'var(--nice-color-accent, #6366f1)',
|
|
449
449
|
color: 'var(--nice-text-on-primary, #fff)',
|
|
450
450
|
border: 'none',
|
|
@@ -472,7 +472,7 @@ const NiceSvgToCode = ({ initialSvg = '', onConvert, className = '', }) => {
|
|
|
472
472
|
overflow: 'auto',
|
|
473
473
|
maxHeight: 300,
|
|
474
474
|
whiteSpace: 'pre-wrap',
|
|
475
|
-
}, children: result.code }), result.extractedColors.length > 0 && (jsxs("div", { style: { fontSize: 11, marginTop: 4 }, children: [
|
|
475
|
+
}, children: result.code }), result.extractedColors.length > 0 && (jsxs("div", { style: { fontSize: 11, marginTop: 4 }, children: [t('svgToCode.colors', 'Colors:'), ' ', result.extractedColors.map((c) => (jsx("span", { style: {
|
|
476
476
|
display: 'inline-block',
|
|
477
477
|
width: 12,
|
|
478
478
|
height: 12,
|
|
@@ -110,7 +110,7 @@ const NiceVectorEditor = ({ width: artW = 512, height: artH = 512, className, on
|
|
|
110
110
|
}
|
|
111
111
|
const node = (jsx(ShapeRenderer, { shape: s, selected: s.id === selId, zoom: zoom }, s.id));
|
|
112
112
|
return previewTr ? (jsx("g", { transform: previewTr, children: node }, s.id)) : (node);
|
|
113
|
-
})] }) }) }), jsxs(NiceModal, { open: dlgSvg, onClose: () => setDlgSvg(false), title: t('vectorEditor.pasteSvg', 'Paste SVG'), children: [jsx("label", { children:
|
|
113
|
+
})] }) }) }), jsxs(NiceModal, { open: dlgSvg, onClose: () => setDlgSvg(false), title: t('vectorEditor.pasteSvg', 'Paste SVG'), children: [jsx("label", { children: t('vectorEditor.pasteSvgSourceCodeBelow', 'Paste SVG source code below:') }), jsx(NiceTextArea, { value: svgText, onChange: (val) => setSvgText(val), placeholder: t('vectorEditor.svgXmlnsHttpWwwW3', '<svg xmlns="http://www.w3.org/2000/svg" ...>') }), jsxs("div", { className: styles.dialogActions, children: [jsx(NiceButton, { variant: "ghost", onClick: () => setDlgSvg(false), children: t('vectorEditor.cancel', 'Cancel') }), jsx(NiceButton, { variant: "primary", onClick: () => importSVGString(svgText), children: t('vectorEditor.import', 'Import') })] })] }), jsxs(NiceModal, { open: snippetOpen, onClose: () => setSnippetOpen(false), title: t('vectorEditor.snippet.title', 'Icon snippet copied to clipboard'), children: [jsxs("p", { style: { marginTop: 0 }, children: [t('vectorEditor.snippet.pasteHint', 'Paste into'), ' ', jsxs("code", { children: ["packages/icons/src/icons/", iconCategory ? `${iconCategory.toLowerCase()}` : '<category>', ".tsx"] }), ":"] }), jsx(NiceTextArea, { value: snippetText, onChange: (val) => setSnippetText(val), rows: 16 }), jsxs("div", { className: styles.dialogActions, children: [jsx(NiceButton, { variant: "primary", onClick: () => {
|
|
114
114
|
if (typeof navigator !== 'undefined' && navigator.clipboard) {
|
|
115
115
|
navigator.clipboard.writeText(snippetText).catch(() => { });
|
|
116
116
|
}
|
|
@@ -262,7 +262,13 @@ const VectorEditorMenuBar$1 = ({ api, hasOnSaveToLibrary, onExportIconSnippet })
|
|
|
262
262
|
{ value: '', label: t('vectorEditor.menu.secondShape', '2nd Shape') },
|
|
263
263
|
...shapes
|
|
264
264
|
.filter((s) => s.id !== selId)
|
|
265
|
-
.map((s, i) => {
|
|
265
|
+
.map((s, i) => {
|
|
266
|
+
var _a;
|
|
267
|
+
return ({
|
|
268
|
+
value: s.id,
|
|
269
|
+
label: (_a = s.name) !== null && _a !== void 0 ? _a : t('vectorEditor.shape', 'Shape {i}').replace('{i}', String(i + 1)),
|
|
270
|
+
});
|
|
271
|
+
}),
|
|
266
272
|
], style: { minWidth: 100 } })), jsxs("label", { className: styles.menuLabel, children: [jsx(NiceCheckbox, { checked: snapGrid, onChange: () => setSnapGrid((v) => !v) }), t('vectorEditor.menu.snap', 'Snap')] }), onExportIconSnippet && (jsxs(Fragment, { children: [jsx("div", { className: styles.menuSep }), jsxs(NiceButton, { className: styles.menuBtn, variant: "primary", size: "sm", onClick: onExportIconSnippet, children: [jsx(NiceIcon, { name: "clipboard", size: 14 }), ' ', t('vectorEditor.menu.exportIcon', 'Export Icon')] })] }))] }));
|
|
267
273
|
};
|
|
268
274
|
var VectorEditorMenuBar = React.memo(VectorEditorMenuBar$1);
|