@nice2dev/ui-graphics 1.2.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +103 -0
- package/dist/cjs/animation/Audience.js +3 -1
- package/dist/cjs/animation/rig/RigPlayer.js +1 -1
- package/dist/cjs/animation/rig/presets.js +67 -55
- package/dist/cjs/animation/shapes/headwear.js +4 -1
- package/dist/cjs/core/NiceBrushEngine.js +5 -3
- package/dist/cjs/core/editorAsk.js +48 -0
- package/dist/cjs/core/i18n.js +7 -3
- package/dist/cjs/core/plugins.js +1 -1
- package/dist/cjs/core/rtl.js +1 -1
- package/dist/cjs/core/theme.js +1 -1
- package/dist/cjs/font/NiceFontEditor.js +13 -11
- package/dist/cjs/game/GameAsset2dEditor.js +28 -16
- package/dist/cjs/nice2dev-ui-graphics.css +1 -1
- package/dist/cjs/photo/FilterThumb.js +3 -3
- package/dist/cjs/photo/NiceAITools.js +5 -3
- package/dist/cjs/photo/PhotoEditor.js +3 -1
- package/dist/cjs/photo/PhotoEditorCanvas.js +8 -6
- package/dist/cjs/photo/PhotoEditorLeftPanel.js +19 -19
- package/dist/cjs/photo/PhotoEditorToolbar.js +4 -4
- package/dist/cjs/photo/photoFilters.js +1 -0
- package/dist/cjs/pixel/PixelEditor.js +6 -3
- package/dist/cjs/pixel/PixelEditorCanvas.js +10 -6
- package/dist/cjs/pixel/PixelEditorMenuBar.js +3 -3
- package/dist/cjs/pixel/PixelEditorRightPanel.js +28 -24
- package/dist/cjs/pixel/PixelEditorStatusBar.js +8 -4
- package/dist/cjs/pixel/PixelEditorTimeline.js +11 -2
- package/dist/cjs/pixel/PixelEditorToolbar.js +10 -6
- package/dist/cjs/pixel/SpriteGeneratorPanel.js +11 -7
- package/dist/cjs/pixel/animalGeneratorPresets.js +31 -31
- package/dist/cjs/pixel/buildingGeneratorPresets.js +24 -24
- package/dist/cjs/pixel/characterGeneratorPresets.js +25 -25
- package/dist/cjs/pixel/usePixelEditor.js +13 -10
- package/dist/cjs/texture/Nice3DTexturePainter.js +10 -8
- package/dist/cjs/ui/NiceUIDesigner.js +17 -13
- package/dist/cjs/vector/NiceSvgToCode.js +6 -4
- package/dist/cjs/vector/VectorEditor.js +3 -2
- package/dist/cjs/vector/VectorEditorShapeRenderer.js +3 -1
- package/dist/cjs/vector/useVectorEditor.js +38 -29
- package/dist/cjs/vector/vectorEditorImport.js +1 -0
- package/dist/cjs/vector/vectorIconImport.js +1 -0
- package/dist/esm/animation/Audience.js +3 -1
- package/dist/esm/animation/rig/RigPlayer.js +1 -1
- package/dist/esm/animation/rig/presets.js +68 -56
- package/dist/esm/animation/shapes/headwear.js +4 -1
- package/dist/esm/animation/spineExport.js +1 -1
- package/dist/esm/core/NiceBrushEngine.js +5 -3
- package/dist/esm/core/editorAsk.js +45 -0
- package/dist/esm/core/i18n.js +8 -4
- package/dist/esm/core/plugins.js +1 -1
- package/dist/esm/core/rtl.js +1 -1
- package/dist/esm/core/theme.js +1 -1
- package/dist/esm/font/NiceFontEditor.js +13 -11
- package/dist/esm/game/GameAsset2dEditor.js +28 -16
- package/dist/esm/nice2dev-ui-graphics.css +1 -1
- package/dist/esm/photo/FilterThumb.js +3 -3
- package/dist/esm/photo/NiceAITools.js +5 -3
- package/dist/esm/photo/PhotoEditor.js +3 -1
- package/dist/esm/photo/PhotoEditorCanvas.js +8 -6
- package/dist/esm/photo/PhotoEditorLeftPanel.js +19 -19
- package/dist/esm/photo/PhotoEditorToolbar.js +4 -4
- package/dist/esm/photo/photoFilters.js +1 -0
- package/dist/esm/pixel/PixelEditor.js +6 -3
- package/dist/esm/pixel/PixelEditorCanvas.js +10 -6
- package/dist/esm/pixel/PixelEditorMenuBar.js +3 -3
- package/dist/esm/pixel/PixelEditorRightPanel.js +28 -24
- package/dist/esm/pixel/PixelEditorStatusBar.js +8 -4
- package/dist/esm/pixel/PixelEditorTimeline.js +11 -2
- package/dist/esm/pixel/PixelEditorToolbar.js +10 -6
- package/dist/esm/pixel/SpriteGeneratorPanel.js +11 -7
- package/dist/esm/pixel/animalGeneratorPresets.js +32 -32
- package/dist/esm/pixel/buildingGeneratorPresets.js +25 -25
- package/dist/esm/pixel/characterGeneratorPresets.js +26 -26
- package/dist/esm/pixel/usePixelEditor.js +13 -10
- package/dist/esm/texture/Nice3DTexturePainter.js +10 -8
- package/dist/esm/ui/NiceUIDesigner.js +17 -13
- package/dist/esm/vector/NiceSvgToCode.js +6 -4
- package/dist/esm/vector/VectorEditor.js +3 -2
- package/dist/esm/vector/VectorEditorShapeRenderer.js +3 -1
- package/dist/esm/vector/useVectorEditor.js +38 -29
- package/dist/esm/vector/vectorEditorImport.js +1 -0
- package/dist/esm/vector/vectorIconImport.js +1 -0
- package/dist/types/core/LocalUI.d.ts +1 -2
- package/dist/types/core/editorAsk.d.ts +26 -0
- package/dist/types/core/i18n.d.ts +1 -17
- package/dist/types/pixel/usePixelEditor.d.ts +3 -0
- package/dist/types/vector/useVectorEditor.d.ts +2 -0
- package/package.json +5 -5
|
@@ -15,13 +15,14 @@ const OverlayToolbar = ({ api }) => {
|
|
|
15
15
|
if (!selectedOverlay) {
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
|
-
return (jsxs("div", { className: cs.overlayToolbar, children: [jsxs("span", { className: cs.overlayToolbarLabel, children: [jsx(NiceIcon, { name: "box", size: 14, style: { marginRight: 4 } }),
|
|
18
|
+
return (jsxs("div", { className: cs.overlayToolbar, children: [jsxs("span", { className: cs.overlayToolbarLabel, children: [jsx(NiceIcon, { name: "box", size: 14, style: { marginRight: 4 } }), t('photoEditor.layer', 'Layer')] }), jsx(RangeInput, { min: 0, max: 100, value: ((_a = selectedOverlay.opacity) !== null && _a !== void 0 ? _a : 1) * 100, onChange: (e) => updateOverlay(selectedOverlay.id, { opacity: Number(e.target.value) / 100 }), onMouseUp: pushHistory, accentColor: accent, style: { maxWidth: 70 }, title: t('photoEditor.opacity', 'Opacity') }), jsxs("span", { className: cs.sliderValueSm, style: { color: accent }, children: [Math.round(((_b = selectedOverlay.opacity) !== null && _b !== void 0 ? _b : 1) * 100), "%"] }), selectedOverlay.type !== 'drawing' && selectedOverlay.type !== 'frame' && (jsxs(Fragment, { children: [jsx(RangeInput, { min: 20, max: 500, value: ((_c = selectedOverlay.scaleX) !== null && _c !== void 0 ? _c : 1) * 100, onChange: (e) => {
|
|
19
19
|
const s = Number(e.target.value) / 100;
|
|
20
20
|
updateOverlay(selectedOverlay.id, { scaleX: s, scaleY: s });
|
|
21
|
-
}, onMouseUp: pushHistory, accentColor: accent, style: { maxWidth: 60 }, title:
|
|
21
|
+
}, onMouseUp: pushHistory, accentColor: accent, style: { maxWidth: 60 }, title: t('photoEditor.scale', 'Scale') }), jsxs("span", { className: cs.sliderValueSm, style: { color: 'var(--nice-text-muted, #aaa)' }, children: [Math.round(((_d = selectedOverlay.scaleX) !== null && _d !== void 0 ? _d : 1) * 100), "%"] })] })), selectedOverlay.type !== 'drawing' && selectedOverlay.type !== 'frame' && (jsx(RangeInput, { min: -180, max: 180, value: (_e = selectedOverlay.rotation) !== null && _e !== void 0 ? _e : 0, onChange: (e) => updateOverlay(selectedOverlay.id, { rotation: Number(e.target.value) }), onMouseUp: pushHistory, accentColor: accent, style: { maxWidth: 60 }, title: t('photoEditor.rotation', 'Rotation') })), jsx(Button, { variant: "dark", size: "sm", onClick: () => moveOverlayBack(selectedOverlay.id), title: t('photoEditor.moveBack', 'Move back'), className: cs.overlayToolbarBtn, children: jsx(NiceIcon, { name: "arrow-down", size: 14 }) }), jsx(Button, { variant: "dark", size: "sm", onClick: () => moveOverlayForward(selectedOverlay.id), title: t('photoEditor.moveForward', 'Move forward'), className: cs.overlayToolbarBtn, children: jsx(NiceIcon, { name: "arrow-up", size: 14 }) }), jsx(Button, { variant: "outline-danger", size: "sm", onClick: () => deleteOverlay(selectedOverlay.id), className: cs.overlayToolbarBtn, title: t('photoEditor.deleteLayer', 'Delete layer'), children: jsx(NiceIcon, { name: "trash", size: 14 }) })] }));
|
|
22
22
|
};
|
|
23
23
|
// ── Left Panel ──
|
|
24
|
-
const PhotoEditorLeftPanel =
|
|
24
|
+
const PhotoEditorLeftPanel = /* @__PURE__ */ Object.assign(
|
|
25
|
+
/* @__PURE__ */ React.memo(({ api }) => {
|
|
25
26
|
var _a;
|
|
26
27
|
const { t, accent, accentDim, activeTab, setActiveTab, setCropMode,
|
|
27
28
|
// Filters
|
|
@@ -70,16 +71,16 @@ const PhotoEditorLeftPanel = React.memo(({ api }) => {
|
|
|
70
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: () => {
|
|
71
72
|
setSelectedFilter(filter.id);
|
|
72
73
|
pushHistory();
|
|
73
|
-
}, 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 } }),
|
|
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
75
|
color: adjustments[sl.key] !== 0 ? accent : 'var(--nice-text-secondary, #666)',
|
|
75
|
-
}, onClick: () => handleAdjChange(sl.key, sl.key === 'blur' ? 0 : 0), title:
|
|
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: () => {
|
|
76
77
|
handleAdjChange('brightness', 0);
|
|
77
78
|
const defaults = { ...DEFAULT_ADJUSTMENTS };
|
|
78
79
|
for (const key of Object.keys(defaults)) {
|
|
79
80
|
handleAdjChange(key, defaults[key]);
|
|
80
81
|
}
|
|
81
82
|
pushHistory();
|
|
82
|
-
}, children: [jsx(NiceIcon, { name: "refresh", size: 14, style: { marginRight: 4 } }), t('photoEditor.resetAdjustments', 'Reset adjustments')] })] })), activeTab === 'crop' && (jsxs("div", { children: [jsxs("div", { className: cs.cropInfo, children: [jsx(NiceIcon, { name: "info", size: 14, style: { marginRight: 4 } }),
|
|
83
|
+
}, children: [jsx(NiceIcon, { name: "refresh", size: 14, style: { marginRight: 4 } }), t('photoEditor.resetAdjustments', 'Reset adjustments')] })] })), activeTab === 'crop' && (jsxs("div", { children: [jsxs("div", { className: cs.cropInfo, children: [jsx(NiceIcon, { name: "info", size: 14, style: { marginRight: 4 } }), t('photoEditor.dragCornersOrEdgesTo', 'Drag corners or edges to crop the photo.')] }), jsx("div", { className: cs.cropAspectLabel, children: t('photoEditor.aspectRatio', 'Aspect ratio') }), jsx("div", { className: cs.cropAspectRow, children: ASPECT_RATIOS.map((ar) => (jsx("button", { onClick: () => {
|
|
83
84
|
setCropAspect(ar.value);
|
|
84
85
|
if (ar.value && cropRect && image) {
|
|
85
86
|
let newW = cropRect.w;
|
|
@@ -104,7 +105,7 @@ const PhotoEditorLeftPanel = React.memo(({ api }) => {
|
|
|
104
105
|
setCropAspect(null);
|
|
105
106
|
pushHistory();
|
|
106
107
|
}
|
|
107
|
-
}, children: [jsx(NiceIcon, { name: "expand", size: 14, style: { marginRight: 4 } }), t('photoEditor.resetCrop', 'Reset crop')] })] })), activeTab === 'transform' && (jsxs("div", { children: [jsx("div", { className: cs.sectionTitleMb8, children:
|
|
108
|
+
}, children: [jsx(NiceIcon, { name: "expand", size: 14, style: { marginRight: 4 } }), t('photoEditor.resetCrop', 'Reset crop')] })] })), activeTab === 'transform' && (jsxs("div", { children: [jsx("div", { className: cs.sectionTitleMb8, children: t('photoEditor.rotation', 'Rotation') }), jsxs("div", { className: cs.transformRow, children: [jsxs(Button, { variant: "dark", size: "sm", onClick: () => {
|
|
108
109
|
setRotation((rotation - 90 + 360) % 360);
|
|
109
110
|
pushHistory();
|
|
110
111
|
}, children: [jsx(NiceIcon, { name: "reply", size: 14, style: { marginRight: 4 } }), " -90\u00B0"] }), jsxs(Button, { variant: "dark", size: "sm", onClick: () => {
|
|
@@ -113,13 +114,13 @@ const PhotoEditorLeftPanel = React.memo(({ api }) => {
|
|
|
113
114
|
}, children: [jsx(NiceIcon, { name: "forward", size: 14, style: { marginRight: 4 } }), " +90\u00B0"] }), jsx(Button, { variant: "dark", size: "sm", onClick: () => {
|
|
114
115
|
setRotation(0);
|
|
115
116
|
pushHistory();
|
|
116
|
-
}, children: "0\u00B0" })] }), jsx("div", { className: cs.sectionTitleMb8, children:
|
|
117
|
+
}, children: "0\u00B0" })] }), jsx("div", { className: cs.sectionTitleMb8, children: t('photoEditor.flip', 'Flip') }), jsxs("div", { className: cs.transformRow, children: [jsxs(Button, { variant: flipH ? 'outline-info' : 'dark', size: "sm", onClick: () => {
|
|
117
118
|
setFlipH(!flipH);
|
|
118
119
|
pushHistory();
|
|
119
|
-
}, children: [jsx(NiceIcon, { name: "move", size: 14, style: { marginRight: 4 } }),
|
|
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: () => {
|
|
120
121
|
setFlipV(!flipV);
|
|
121
122
|
pushHistory();
|
|
122
|
-
}, children: [jsx(NiceIcon, { name: "move", size: 14, style: { marginRight: 4 } }),
|
|
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: "Rotation:" }), " ", rotation, "\u00B0"] }), jsxs("div", { children: [jsx("strong", { children: "Flip H:" }), " ", flipH ? 'Yes' : 'No'] }), jsxs("div", { children: [jsx("strong", { children: "Flip V:" }), " ", flipV ? 'Yes' : 'No'] }), cropRect && (jsxs("div", { children: [jsx("strong", { children: "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 } }), " 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: {
|
|
123
124
|
borderColor: emojiCat === cat.id ? accent : undefined,
|
|
124
125
|
background: emojiCat === cat.id ? accentDim : undefined,
|
|
125
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: () => {
|
|
@@ -140,7 +141,7 @@ const PhotoEditorLeftPanel = React.memo(({ api }) => {
|
|
|
140
141
|
: '' }), jsx("button", { onClick: (e) => {
|
|
141
142
|
e.stopPropagation();
|
|
142
143
|
deleteOverlay(ov.id);
|
|
143
|
-
}, className: cs.overlayDeleteBtn, "aria-label": t('photoEditor.deleteLayer', 'Delete layer'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, ov.id)))] }))] })), activeTab === 'text' && (jsxs("div", { children: [jsx(OverlayToolbar, { api: api }), jsxs("div", { className: cs.sectionTitleMb8, children: [jsx(NiceIcon, { name: "type", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.addCaption', 'Add caption')] }), jsx(TextArea, { rows: 2, value: textDraft, onChange: (e) => setTextDraft(e.target.value), placeholder: t('photoEditor.textPlaceholder', 'Enter text…'), className: cs.textArea }), jsxs("div", { className: cs.textBtnRow, children: [jsx(Button, { variant: textBold ? 'light' : 'dark', size: "sm", onClick: () => setTextBold(!textBold), title:
|
|
144
|
+
}, className: cs.overlayDeleteBtn, "aria-label": t('photoEditor.deleteLayer', 'Delete layer'), children: jsx(NiceIcon, { name: "close", size: 14 }) })] }, ov.id)))] }))] })), activeTab === 'text' && (jsxs("div", { children: [jsx(OverlayToolbar, { api: api }), jsxs("div", { className: cs.sectionTitleMb8, children: [jsx(NiceIcon, { name: "type", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.addCaption', 'Add caption')] }), jsx(TextArea, { rows: 2, value: textDraft, onChange: (e) => setTextDraft(e.target.value), placeholder: t('photoEditor.textPlaceholder', 'Enter text…'), className: cs.textArea }), jsxs("div", { className: cs.textBtnRow, children: [jsx(Button, { variant: textBold ? 'light' : 'dark', size: "sm", onClick: () => setTextBold(!textBold), title: t('photoEditor.bold', 'Bold'), className: cs.textFormatBtn, style: { fontWeight: 700 }, children: "B" }), jsx(Button, { variant: textItalic ? 'light' : 'dark', size: "sm", onClick: () => setTextItalic(!textItalic), title: t('photoEditor.italic', 'Italic'), className: cs.textFormatBtn, style: { fontStyle: 'italic' }, children: "I" }), jsx(Button, { variant: textOutline ? 'light' : 'dark', size: "sm", onClick: () => setTextOutline(!textOutline), title: t('photoEditor.outline', 'Outline'), className: cs.textFormatBtn, children: "O" }), jsx(Button, { variant: textBg ? 'light' : 'dark', size: "sm", onClick: () => setTextBg(!textBg), title: t('photoEditor.background', 'Background'), className: cs.textFormatBtn, children: jsx(NiceIcon, { name: "square", size: 14 }) }), jsx("input", { type: "color", value: textColor, onChange: (e) => setTextColor(e.target.value), className: cs.colorInputLg, title: t('photoEditor.textColour', 'Text colour') })] }), jsxs("div", { className: cs.sliderRow, children: [jsxs("span", { className: cs.sliderLabel, children: [t('photoEditor.size', 'Size'), ":"] }), jsx(RangeInput, { min: 12, max: 120, value: textFontSize, onChange: (e) => setTextFontSize(Number(e.target.value)), accentColor: accent, style: { flex: 1 } }), jsxs("span", { className: cs.sliderValue, style: { color: accent }, children: [textFontSize, "px"] })] }), jsxs(Button, { size: "sm", className: cs.accentBtn, style: { background: accent, borderColor: accent }, disabled: !textDraft.trim(), onClick: () => {
|
|
144
145
|
const ov = createTextOverlay(textDraft);
|
|
145
146
|
ov.color = textColor;
|
|
146
147
|
ov.bold = textBold;
|
|
@@ -164,13 +165,13 @@ const PhotoEditorLeftPanel = React.memo(({ api }) => {
|
|
|
164
165
|
italic: !selectedOverlay.italic,
|
|
165
166
|
});
|
|
166
167
|
pushHistory();
|
|
167
|
-
}, 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 } }),
|
|
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: "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: "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 ? 'Off' : 'On' })] }), jsxs("div", { className: cs.sliderRow, children: [jsx("span", { className: cs.sliderLabel, children: "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: () => {
|
|
168
169
|
const ov = createShapeOverlay(sh.id);
|
|
169
170
|
ov.strokeColor = shapeStroke;
|
|
170
171
|
ov.fillColor = shapeFill || null;
|
|
171
172
|
ov.strokeWidth = shapeStrokeW;
|
|
172
173
|
addOverlay(ov);
|
|
173
|
-
}, 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 } }),
|
|
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: "Grub.:" }), 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: () => {
|
|
174
175
|
setOverlays((prev) => prev.filter((o) => o.type !== 'frame'));
|
|
175
176
|
const ov = createFrameOverlay(fr.id, frameColor);
|
|
176
177
|
ov.thickness = frameThick / 100;
|
|
@@ -178,7 +179,7 @@ const PhotoEditorLeftPanel = React.memo(({ api }) => {
|
|
|
178
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: () => {
|
|
179
180
|
setOverlays((prev) => prev.filter((o) => o.type !== 'frame'));
|
|
180
181
|
pushHistory();
|
|
181
|
-
}, 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 } }),
|
|
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: "Color:" }), jsx("input", { type: "color", value: drawColor, onChange: (e) => setDrawColor(e.target.value), className: cs.colorInputDraw, "aria-label": t('photoEditor.drawColor', 'Drawing color') }), [
|
|
182
183
|
'#ff0000',
|
|
183
184
|
'#ff8800',
|
|
184
185
|
'#ffff00',
|
|
@@ -212,15 +213,14 @@ const PhotoEditorLeftPanel = React.memo(({ api }) => {
|
|
|
212
213
|
}));
|
|
213
214
|
pushHistory();
|
|
214
215
|
}
|
|
215
|
-
}, className: cs.drawActionBtn, children: [jsx(NiceIcon, { name: "reply", size: 14, style: { marginRight: 4 } }),
|
|
216
|
+
}, className: cs.drawActionBtn, children: [jsx(NiceIcon, { name: "reply", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.undoStroke', 'Undo stroke')] }), jsxs(Button, { variant: "outline-danger", size: "sm", onClick: () => {
|
|
216
217
|
if (drawingOverlayRef.current) {
|
|
217
218
|
deleteOverlay(drawingOverlayRef.current.id);
|
|
218
219
|
drawingOverlayRef.current = null;
|
|
219
220
|
}
|
|
220
|
-
}, className: cs.drawActionBtn, children: [jsx(NiceIcon, { name: "trash", size: 14, style: { marginRight: 4 } }),
|
|
221
|
+
}, className: cs.drawActionBtn, children: [jsx(NiceIcon, { name: "trash", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.clear', 'Clear')] })] }), jsxs(Button, { variant: "dark", size: "sm", className: "mt-2 w-100", onClick: () => {
|
|
221
222
|
drawingOverlayRef.current = null;
|
|
222
|
-
}, children: [jsx(NiceIcon, { name: "plus", size: 14, style: { marginRight: 4 } }),
|
|
223
|
-
});
|
|
224
|
-
PhotoEditorLeftPanel.displayName = 'PhotoEditorLeftPanel';
|
|
223
|
+
}, children: [jsx(NiceIcon, { name: "plus", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.newDrawingLayer', 'New drawing layer')] })] }))] })] }));
|
|
224
|
+
}), { displayName: 'PhotoEditorLeftPanel' });
|
|
225
225
|
|
|
226
226
|
export { PhotoEditorLeftPanel as default };
|
|
@@ -4,15 +4,15 @@ import React from 'react';
|
|
|
4
4
|
import { Button } from '../core/LocalUI.js';
|
|
5
5
|
import cs from './PhotoEditor.module.css.js';
|
|
6
6
|
|
|
7
|
-
const PhotoEditorToolbar =
|
|
7
|
+
const PhotoEditorToolbar = /* @__PURE__ */ Object.assign(
|
|
8
|
+
/* @__PURE__ */ React.memo(({ api }) => {
|
|
8
9
|
const { t, accent, historyIdx, historyLength, undo, redo, handleReset, showCompare, setShowCompare, handleDownload, handleCopyToClipboard, handleShareNative, onCancel, handleSave, } = api;
|
|
9
|
-
return (jsxs("div", { className: cs.toolbar, children: [jsxs("div", { className: cs.toolbarGroup, children: [jsx(Button, { variant: "dark", size: "sm", onClick: undo, disabled: historyIdx <= 0, title: `${t('photoEditor.undo', 'Undo')} (Ctrl+Z)`, children: jsx(NiceIcon, { name: "reply", size: 14 }) }), jsx(Button, { variant: "dark", size: "sm", onClick: redo, disabled: historyIdx >= historyLength - 1, title: t('photoEditor.redo', 'Redo (Ctrl+Y)'), children: jsx(NiceIcon, { name: "forward", size: 14 }) }), jsx(Button, { variant: "dark", size: "sm", onClick: handleReset, title:
|
|
10
|
+
return (jsxs("div", { className: cs.toolbar, children: [jsxs("div", { className: cs.toolbarGroup, children: [jsx(Button, { variant: "dark", size: "sm", onClick: undo, disabled: historyIdx <= 0, title: `${t('photoEditor.undo', 'Undo')} (Ctrl+Z)`, children: jsx(NiceIcon, { name: "reply", size: 14 }) }), jsx(Button, { variant: "dark", size: "sm", onClick: redo, disabled: historyIdx >= historyLength - 1, title: t('photoEditor.redo', 'Redo (Ctrl+Y)'), children: jsx(NiceIcon, { name: "forward", size: 14 }) }), jsx(Button, { variant: "dark", size: "sm", onClick: handleReset, title: t('photoEditor.reset', 'Reset'), children: jsx(NiceIcon, { name: "refresh", size: 14 }) }), jsx("div", { className: cs.toolbarDivider }), jsx(Button, { variant: showCompare ? 'outline-info' : 'dark', size: "sm", onClick: () => setShowCompare(!showCompare), title: t('photoEditor.compareOriginal', 'Compare with original'), children: jsx(NiceIcon, { name: "columns", size: 14 }) }), jsx("div", { className: cs.toolbarDivider }), jsx(Button, { variant: "dark", size: "sm", onClick: handleDownload, title: t('photoEditor.download', 'Download'), children: jsx(NiceIcon, { name: "download", size: 14 }) }), jsx(Button, { variant: "dark", size: "sm", onClick: handleCopyToClipboard, title: t('photoEditor.copyToClipboard', 'Copy to clipboard'), children: jsx(NiceIcon, { name: "clipboard", size: 14 }) }), jsx(Button, { variant: "dark", size: "sm", onClick: handleShareNative, title: t('common.share', 'Share'), children: jsx(NiceIcon, { name: "send", size: 14 }) })] }), jsxs("div", { className: cs.toolbarTitle, style: { color: accent }, children: [jsx(NiceIcon, { name: "wand", size: 14, style: { marginRight: 8 } }), t('photoEditor.title', 'Photo Editor')] }), jsxs("div", { className: cs.toolbarGroup, children: [jsxs(Button, { variant: "outline-secondary", size: "sm", onClick: onCancel, children: [jsx(NiceIcon, { name: "close", size: 14, style: { marginRight: 4 } }), ' ', t('common.cancel', 'Cancel')] }), jsxs(Button, { size: "sm", style: {
|
|
10
11
|
background: accent,
|
|
11
12
|
borderColor: accent,
|
|
12
13
|
color: 'var(--nice-color-white, #fff)',
|
|
13
14
|
fontWeight: 600,
|
|
14
15
|
}, onClick: handleSave, children: [jsx(NiceIcon, { name: "check", size: 14, style: { marginRight: 4 } }), ' ', t('photoEditor.apply', 'Apply')] })] })] }));
|
|
15
|
-
});
|
|
16
|
-
PhotoEditorToolbar.displayName = 'PhotoEditorToolbar';
|
|
16
|
+
}), { displayName: 'PhotoEditorToolbar' });
|
|
17
17
|
|
|
18
18
|
export { PhotoEditorToolbar as default };
|
|
@@ -285,6 +285,7 @@ function brownie(data) {
|
|
|
285
285
|
function duotone(data, params) {
|
|
286
286
|
const out = cloneImageData(data);
|
|
287
287
|
const d = out.data;
|
|
288
|
+
// audit-allow: literal-color +2 — the duotone filter's default inks, written into the photo
|
|
288
289
|
const dark = hexToRgb((params === null || params === void 0 ? void 0 : params.darkColor) || '#001f3f');
|
|
289
290
|
const light = hexToRgb((params === null || params === void 0 ? void 0 : params.lightColor) || '#ff851b');
|
|
290
291
|
for (let i = 0; i < d.length; i += 4) {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { NiceAppShell, NiceModal, NiceNumberInput, NiceButton } from '@nice2dev/ui';
|
|
3
3
|
import { useState, useCallback } from 'react';
|
|
4
|
+
import { EditorAskDialog } from '../core/editorAsk.js';
|
|
5
|
+
import { useNiceTranslation } from '../core/i18n.js';
|
|
4
6
|
import styles from './PixelEditor.module.css.js';
|
|
5
7
|
import PixelEditorCanvas from './PixelEditorCanvas.js';
|
|
6
8
|
import PixelEditorMenuBar from './PixelEditorMenuBar.js';
|
|
@@ -12,20 +14,21 @@ import NiceSpriteGeneratorPanel from './SpriteGeneratorPanel.js';
|
|
|
12
14
|
import { usePixelEditor } from './usePixelEditor.js';
|
|
13
15
|
|
|
14
16
|
const NicePixelEditor = ({ initialWidth = 64, initialHeight = 64, className, onSaveToLibrary, }) => {
|
|
17
|
+
const { t } = useNiceTranslation();
|
|
15
18
|
const api = usePixelEditor({ initialWidth, initialHeight, onSaveToLibrary });
|
|
16
19
|
const [showGenerator, setShowGenerator] = useState(false);
|
|
17
20
|
const handleGeneratorSend = useCallback((imageData) => {
|
|
18
21
|
var _a;
|
|
19
22
|
(_a = api.importImageData) === null || _a === void 0 ? void 0 : _a.call(api, imageData);
|
|
20
23
|
}, [api]);
|
|
21
|
-
return (jsxs(Fragment, { children: [jsx("input", { ref: api.fInp, type: "file", accept: ".ase,.aseprite,.png,.jpg,.jpeg,.gif,.bmp,.webp,.svg,.tga,.ico,.tiff,.tif,.avif", style: { display: 'none' }, onChange: (e) => {
|
|
24
|
+
return (jsxs(Fragment, { children: [jsx(EditorAskDialog, { ask: api.pendingAsk }), jsx("input", { ref: api.fInp, type: "file", accept: ".ase,.aseprite,.png,.jpg,.jpeg,.gif,.bmp,.webp,.svg,.tga,.ico,.tiff,.tif,.avif", style: { display: 'none' }, onChange: (e) => {
|
|
22
25
|
var _a;
|
|
23
26
|
const f = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
24
27
|
if (f) {
|
|
25
28
|
api.openFile(f);
|
|
26
29
|
}
|
|
27
30
|
e.target.value = '';
|
|
28
|
-
} }), 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:
|
|
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: "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: "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: [
|
|
29
32
|
[16, 16],
|
|
30
33
|
[32, 32],
|
|
31
34
|
[48, 48],
|
|
@@ -39,7 +42,7 @@ const NicePixelEditor = ({ initialWidth = 64, initialHeight = 64, className, onS
|
|
|
39
42
|
].map(([w, h]) => (jsxs(NiceButton, { className: styles.btnSecondary, variant: "ghost", size: "sm", style: { fontSize: 10, padding: '2px 6px' }, onClick: () => {
|
|
40
43
|
api.setNw(w);
|
|
41
44
|
api.setNh(h);
|
|
42
|
-
}, children: [w, "x", h] }, `${w}x${h}`))) }), jsxs("div", { className: styles.dialogActions, children: [jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: () => api.setDlgNew(false), children:
|
|
45
|
+
}, children: [w, "x", h] }, `${w}x${h}`))) }), jsxs("div", { className: styles.dialogActions, children: [jsx(NiceButton, { className: styles.btnSecondary, variant: "ghost", onClick: () => api.setDlgNew(false), children: t('pixelEditor.cancel', 'Cancel') }), jsx(NiceButton, { className: styles.btnPrimary, variant: "primary", onClick: () => api.newDoc(api.nw, api.nh), children: t('pixelEditor.create', 'Create') })] })] })] }));
|
|
43
46
|
};
|
|
44
47
|
|
|
45
48
|
export { NicePixelEditor };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useNiceTranslation } from '../core/i18n.js';
|
|
3
4
|
import styles from './PixelEditor.module.css.js';
|
|
4
5
|
|
|
5
|
-
const PixelEditorCanvas =
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
const PixelEditorCanvas = /* @__PURE__ */ Object.assign(
|
|
7
|
+
/* @__PURE__ */ React.memo(({ api }) => {
|
|
8
|
+
const { t } = useNiceTranslation();
|
|
9
|
+
return (jsx("div", { ref: api.boxRef, className: styles.canvasContainer, children: jsx("canvas", { ref: api.cvRef, onPointerDown: api.onDown, onPointerMove: api.onMove, onPointerUp: api.onUp, onPointerLeave: () => {
|
|
10
|
+
api.drawing.current = false;
|
|
11
|
+
api.panning.current = false;
|
|
12
|
+
api.setCursor(null);
|
|
13
|
+
}, onWheel: api.onWheel, onContextMenu: (e) => e.preventDefault(), style: { inset: 0, width: '100%', height: '100%', touchAction: 'none' }, "aria-label": t('pixelEditorCanvas.pixelEditorCanvas', 'Pixel editor canvas') }) }));
|
|
14
|
+
}), { displayName: 'PixelEditorCanvas' });
|
|
11
15
|
|
|
12
16
|
export { PixelEditorCanvas as default };
|
|
@@ -4,7 +4,8 @@ import { NiceIcon } from '@nice2dev/ui-core';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import styles from './PixelEditor.module.css.js';
|
|
6
6
|
|
|
7
|
-
const PixelEditorMenuBar =
|
|
7
|
+
const PixelEditorMenuBar = /* @__PURE__ */ Object.assign(
|
|
8
|
+
/* @__PURE__ */ React.memo(({ api, hasOnSaveToLibrary, onOpenGenerator }) => {
|
|
8
9
|
const items = [
|
|
9
10
|
{
|
|
10
11
|
id: 'file',
|
|
@@ -93,7 +94,6 @@ const PixelEditorMenuBar = React.memo(({ api, hasOnSaveToLibrary, onOpenGenerato
|
|
|
93
94
|
},
|
|
94
95
|
];
|
|
95
96
|
return (jsx("div", { className: styles.menuBar, children: jsx(NiceMenu, { items: items, orientation: "horizontal", variant: "ghost", density: "compact" }) }));
|
|
96
|
-
});
|
|
97
|
-
PixelEditorMenuBar.displayName = 'PixelEditorMenuBar';
|
|
97
|
+
}), { displayName: 'PixelEditorMenuBar' });
|
|
98
98
|
|
|
99
99
|
export { PixelEditorMenuBar as default };
|
|
@@ -2,36 +2,40 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { NiceCollapse, NiceSlider, NiceButton, NiceCheckbox, NiceTextInput, NiceSelect } 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 { HSVPicker } from './HSVPicker.js';
|
|
6
7
|
import styles from './PixelEditor.module.css.js';
|
|
7
8
|
import { BRUSH_SHAPES, BLEND_MODES } from './pixelEditorTypes.js';
|
|
8
9
|
|
|
9
10
|
/** A collapsible section header: rotating chevron + title. */
|
|
10
11
|
const sectionTrigger = (title) => (jsxs(Fragment, { children: [jsx("span", { className: styles.collapseChevron, children: jsx(NiceIcon, { name: "chevron-right", size: 12 }) }), jsx("span", { children: title })] }));
|
|
11
|
-
const PixelEditorRightPanel =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
api.
|
|
12
|
+
const PixelEditorRightPanel = /* @__PURE__ */ Object.assign(
|
|
13
|
+
/* @__PURE__ */ React.memo(({ api }) => {
|
|
14
|
+
const { t } = useNiceTranslation();
|
|
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
|
+
.map((l, i) => ({ l, i }))
|
|
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) => {
|
|
19
|
+
e.stopPropagation();
|
|
20
|
+
api.toggleVis(i);
|
|
21
|
+
}, title: l.visible ? 'Visible' : 'Hidden', children: jsx(NiceIcon, { name: l.visible ? 'eye' : 'eye-off', size: 14 }) }), jsx("span", { className: styles.layerLock, onClick: (e) => {
|
|
22
|
+
e.stopPropagation();
|
|
23
|
+
api.toggleLock(i);
|
|
24
|
+
}, title: l.locked ? 'Locked' : '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
|
+
if (e.key === 'Enter') {
|
|
26
|
+
api.setEditingLayerName(null);
|
|
27
|
+
}
|
|
28
|
+
}, autoFocus: true, "aria-label": t('pixelEditorRightPanel.layerName', 'Layer name') })) : (jsx("span", { className: styles.layerName, onDoubleClick: (e) => {
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
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: `Opacity: ${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
|
+
if (!api.pal.includes(api.col1)) {
|
|
33
|
+
api.setPal((p) => [...p, api.col1]);
|
|
23
34
|
}
|
|
24
|
-
},
|
|
25
|
-
e.
|
|
26
|
-
api.
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
api.setPal((p) => [...p, api.col1]);
|
|
30
|
-
}
|
|
31
|
-
}, title: "Add current colour", "aria-label": "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) => {
|
|
32
|
-
e.preventDefault();
|
|
33
|
-
api.setCol2(c);
|
|
34
|
-
}, title: c }, i))) })] })] })));
|
|
35
|
-
PixelEditorRightPanel.displayName = 'PixelEditorRightPanel';
|
|
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) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
api.setCol2(c);
|
|
38
|
+
}, title: c }, i))) })] })] }));
|
|
39
|
+
}), { displayName: 'PixelEditorRightPanel' });
|
|
36
40
|
|
|
37
41
|
export { PixelEditorRightPanel as default };
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useNiceTranslation } from '../core/i18n.js';
|
|
3
4
|
import styles from './PixelEditor.module.css.js';
|
|
4
5
|
import { inB } from './pixelEditorTypes.js';
|
|
5
6
|
|
|
6
|
-
const PixelEditorStatusBar =
|
|
7
|
+
const PixelEditorStatusBar = /* @__PURE__ */ Object.assign(
|
|
8
|
+
/* @__PURE__ */ React.memo(({ api }) => {
|
|
7
9
|
var _a;
|
|
8
|
-
|
|
9
|
-
})
|
|
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 }), jsxs("span", { children: ["Brush: ", api.brush.size, "px ", api.brush.shape] }), jsxs("span", { children: ["Pressure: ", Math.round(api.pressure * 100), "%"] }), jsxs("span", { children: ["Layer: ", (_a = api.layers[api.aLi]) === null || _a === void 0 ? void 0 : _a.name] }), jsx("span", { children: t('pixelEditorStatusBar.frame', 'Frame {current}/{total}')
|
|
12
|
+
.replace('{current}', String(api.afi + 1))
|
|
13
|
+
.replace('{total}', String(api.fc)) }), api.symmetry !== 'none' && jsxs("span", { children: ["Sym: ", api.symmetry] }), api.shapeFilled && jsx("span", { children: t('pixelEditorStatusBar.filled', 'Filled') }), api.sel && (jsxs("span", { children: ["Sel: ", api.sel.w, "\u00D7", api.sel.h] }))] }));
|
|
14
|
+
}), { displayName: 'PixelEditorStatusBar' });
|
|
11
15
|
|
|
12
16
|
export { PixelEditorStatusBar as default };
|
|
@@ -2,9 +2,18 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { NiceButton, NiceNumberInput, NiceCheckbox } 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
|
-
const PixelEditorTimeline =
|
|
8
|
-
|
|
8
|
+
const PixelEditorTimeline = /* @__PURE__ */ Object.assign(
|
|
9
|
+
/* @__PURE__ */ React.memo(({ api }) => {
|
|
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: "+ Frame" }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.dupFrame, "aria-label": t('pixelEditorTimeline.duplicateFrame', 'Duplicate frame'), children: "Dup" }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: api.rmFrame, "aria-label": t('pixelEditorTimeline.removeFrame', 'Remove frame'), children: "\u2212 Frame" }), jsx("div", { className: styles.menuSep }), jsx(NiceButton, { variant: "ghost", size: "sm", onClick: () => api.setPlaying((p) => !p), "aria-label": api.playing ? 'Pause' : 'Play', children: jsx(NiceIcon, { name: api.playing ? 'pause' : 'play', size: 16 }) }), jsx("label", { children: "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 } }), jsxs("span", { children: [api.fc, " frame", api.fc !== 1 ? 's' : ''] })] }), jsx("div", { className: styles.timelineFrames, children: Array.from({ length: api.fc }, (_, fi) => (jsxs("div", { className: `${styles.frameThumb} ${fi === api.afi ? styles.frameThumbActive : ''}`, onClick: () => api.setAfi(fi), children: [api.thumbs[fi] && (jsx("img", { src: api.thumbs[fi], alt: `Frame ${fi + 1}`, style: {
|
|
12
|
+
width: 36,
|
|
13
|
+
height: 36,
|
|
14
|
+
imageRendering: 'pixelated',
|
|
15
|
+
objectFit: 'contain',
|
|
16
|
+
} })), jsx("span", { className: styles.frameNum, children: fi + 1 })] }, fi))) })] }));
|
|
17
|
+
}), { displayName: 'PixelEditorTimeline' });
|
|
9
18
|
|
|
10
19
|
export { PixelEditorTimeline as default };
|
|
@@ -2,14 +2,18 @@ import { jsxs, jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { NiceButton, NiceColorPicker } 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
|
import { TOOLS, SYMMETRY_MODES } from './pixelEditorTypes.js';
|
|
7
8
|
|
|
8
|
-
const PixelEditorToolbar =
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
const PixelEditorToolbar = /* @__PURE__ */ Object.assign(
|
|
10
|
+
/* @__PURE__ */ React.memo(({ api }) => {
|
|
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 ? 'Filled shape' : '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: `Symmetry: ${m.label}`, "aria-label": `Symmetry: ${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
|
+
const tmp = api.col1;
|
|
14
|
+
api.setCol1(api.col2);
|
|
15
|
+
api.setCol2(tmp);
|
|
16
|
+
}, title: t('pixelEditorToolbar.swapX', 'Swap (X)'), "aria-label": t('pixelEditorToolbar.swapColours', 'Swap colours'), style: { fontSize: 12, width: 24, height: 24 }, children: jsx(NiceIcon, { name: "shuffle", size: 14 }) })] })] }));
|
|
17
|
+
}), { displayName: 'PixelEditorToolbar' });
|
|
14
18
|
|
|
15
19
|
export { PixelEditorToolbar as default };
|