@nice2dev/ui-graphics 1.1.10 → 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 +173 -0
- package/README.md +60 -63
- package/dist/cjs/animation/AnimationEditor.js +0 -3
- package/dist/cjs/animation/Audience.js +3 -1
- package/dist/cjs/animation/BodyRenderer.js +1 -4
- package/dist/cjs/animation/rig/RigPlayer.js +1 -1
- package/dist/cjs/animation/rig/presets.js +67 -55
- package/dist/cjs/animation/shapes/heads.js +0 -3
- package/dist/cjs/animation/shapes/headwear.js +4 -1
- package/dist/cjs/core/NiceBrushEngine.js +6 -6
- 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 +16 -14
- package/dist/cjs/game/GameAsset2dEditor.js +28 -19
- package/dist/cjs/index.js +0 -11
- package/dist/cjs/nice2dev-ui-graphics.css +1 -1
- package/dist/cjs/photo/FilterThumb.js +3 -3
- package/dist/cjs/photo/NiceAITools.js +7 -5
- 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 +5 -5
- package/dist/cjs/photo/photoFilters.js +1 -0
- package/dist/cjs/pixel/PixelEditor.js +6 -6
- package/dist/cjs/pixel/PixelEditor.module.css.js +1 -1
- 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 +12 -8
- 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 +12 -10
- package/dist/cjs/ui/NiceUIDesigner.js +18 -14
- package/dist/cjs/vector/NiceSvgToCode.js +6 -4
- package/dist/cjs/vector/VectorEditor.js +3 -5
- 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/AnimationEditor.js +1 -3
- package/dist/esm/animation/Audience.js +3 -1
- package/dist/esm/animation/BodyRenderer.js +3 -5
- package/dist/esm/animation/rig/RigPlayer.js +1 -1
- package/dist/esm/animation/rig/presets.js +68 -56
- package/dist/esm/animation/shapes/heads.js +1 -3
- package/dist/esm/animation/shapes/headwear.js +4 -1
- package/dist/esm/animation/spineExport.js +1 -1
- package/dist/esm/core/NiceBrushEngine.js +6 -6
- 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 +16 -14
- package/dist/esm/game/GameAsset2dEditor.js +29 -19
- package/dist/esm/index.js +10 -10
- package/dist/esm/nice2dev-ui-graphics.css +1 -1
- package/dist/esm/photo/FilterThumb.js +3 -3
- package/dist/esm/photo/NiceAITools.js +7 -5
- 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 +5 -5
- package/dist/esm/photo/photoFilters.js +1 -0
- package/dist/esm/pixel/PixelEditor.js +7 -6
- package/dist/esm/pixel/PixelEditor.module.css.js +1 -1
- 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 +12 -8
- 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 +12 -10
- package/dist/esm/ui/NiceUIDesigner.js +18 -14
- package/dist/esm/vector/NiceSvgToCode.js +6 -4
- package/dist/esm/vector/VectorEditor.js +4 -5
- 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/animation/AnimatedPerson.d.ts +0 -4
- package/dist/types/animation/AnimationEditor.d.ts +1 -5
- package/dist/types/animation/Audience.d.ts +0 -4
- package/dist/types/animation/BodyRenderer.d.ts +0 -4
- package/dist/types/animation/rig/RigPlayer.d.ts +0 -7
- package/dist/types/animation/rig/RiggedBody.d.ts +0 -4
- package/dist/types/animation/shapes/heads.d.ts +0 -4
- 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/game/GameAsset2dEditor.d.ts +0 -4
- package/dist/types/game/index.d.ts +1 -1
- package/dist/types/index.d.ts +9 -19
- package/dist/types/photo/index.d.ts +0 -2
- package/dist/types/pixel/PixelEditor.d.ts +0 -4
- package/dist/types/pixel/SpriteGeneratorPanel.d.ts +0 -4
- package/dist/types/pixel/usePixelEditor.d.ts +3 -0
- package/dist/types/vector/VectorEditor.d.ts +0 -4
- package/dist/types/vector/useVectorEditor.d.ts +2 -0
- package/package.json +5 -5
|
@@ -2,6 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { NiceButton, NiceAppShell, NiceModal, NiceTextArea } from '@nice2dev/ui';
|
|
3
3
|
import { NiceIcon } from '@nice2dev/ui-core';
|
|
4
4
|
import { useRef, useState, useCallback, useEffect } from 'react';
|
|
5
|
+
import { EditorAskDialog } from '../core/editorAsk.js';
|
|
5
6
|
import { useNiceTranslation } from '../core/i18n.js';
|
|
6
7
|
import { useVectorEditor } from './useVectorEditor.js';
|
|
7
8
|
import { frameToTransform, sampleAnimation } from './vectorAnimation.js';
|
|
@@ -63,7 +64,7 @@ const NiceVectorEditor = ({ width: artW = 512, height: artH = 512, className, on
|
|
|
63
64
|
}, [initialIcon, artW, artH, api]);
|
|
64
65
|
const { shapes, selId, tool, zoom, px, py, dlgSvg, svgText, gridSize, boxRef, fInp, animations, previewTime, isPlaying, onDown, onMove, onUp, onWheel, onDblClick, openFile, switchTool, importSVGString, setDlgSvg, setSvgText, } = api;
|
|
65
66
|
const toolRail = (jsx("div", { className: styles.toolbar, children: TOOLS.map((t) => (jsx(NiceButton, { className: `${styles.toolBtn} ${tool === t.id ? styles.toolBtnActive : ''}`, onClick: () => switchTool(t.id), "aria-label": `${t.label} (${t.key})`, variant: tool === t.id ? 'primary' : 'ghost', size: "sm", children: jsx(NiceIcon, { name: t.icon, size: "sm" }) }, t.id))) }));
|
|
66
|
-
return (jsxs(Fragment, { children: [jsx("input", { ref: fInp, type: "file", accept: ".svg", style: { display: 'none' }, onChange: (e) => {
|
|
67
|
+
return (jsxs(Fragment, { children: [jsx(EditorAskDialog, { ask: api.pendingAsk }), jsx("input", { ref: fInp, type: "file", accept: ".svg", style: { display: 'none' }, onChange: (e) => {
|
|
67
68
|
var _a;
|
|
68
69
|
const f = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
|
|
69
70
|
if (f) {
|
|
@@ -109,13 +110,11 @@ const NiceVectorEditor = ({ width: artW = 512, height: artH = 512, className, on
|
|
|
109
110
|
}
|
|
110
111
|
const node = (jsx(ShapeRenderer, { shape: s, selected: s.id === selId, zoom: zoom }, s.id));
|
|
111
112
|
return previewTr ? (jsx("g", { transform: previewTr, children: node }, s.id)) : (node);
|
|
112
|
-
})] }) }) }), jsxs(NiceModal, { open: dlgSvg, onClose: () => setDlgSvg(false), title:
|
|
113
|
+
})] }) }) }), jsxs(NiceModal, { open: dlgSvg, onClose: () => setDlgSvg(false), title: t('vectorEditor.pasteSvg', 'Paste SVG'), children: [jsx("label", { children: "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: () => {
|
|
113
114
|
if (typeof navigator !== 'undefined' && navigator.clipboard) {
|
|
114
115
|
navigator.clipboard.writeText(snippetText).catch(() => { });
|
|
115
116
|
}
|
|
116
117
|
}, children: t('vectorEditor.snippet.copyAgain', 'Copy again') }), jsx(NiceButton, { variant: "ghost", onClick: () => setSnippetOpen(false), children: t('vectorEditor.snippet.close', 'Close') })] })] })] }));
|
|
117
118
|
};
|
|
118
|
-
/** @deprecated Use NiceVectorEditor */
|
|
119
|
-
const VectorEditor = NiceVectorEditor;
|
|
120
119
|
|
|
121
|
-
export { NiceVectorEditor
|
|
120
|
+
export { NiceVectorEditor };
|
|
@@ -6,7 +6,9 @@ const ShapeRenderer = ({ shape: s, selected, zoom }) => {
|
|
|
6
6
|
if (s.hidden) {
|
|
7
7
|
return null;
|
|
8
8
|
}
|
|
9
|
-
const selStroke = selected
|
|
9
|
+
const selStroke = selected
|
|
10
|
+
? 'color-mix(in srgb, var(--nice-color-primary, #5566cc) 60%, transparent)'
|
|
11
|
+
: undefined;
|
|
10
12
|
const gProps = {};
|
|
11
13
|
if (s.opacity < 1) {
|
|
12
14
|
gProps.opacity = s.opacity;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState, useRef, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
+
import { useEditorAsk } from '../core/editorAsk.js';
|
|
2
3
|
import { booleanOperation, flattenToOutline } from './vectorBooleanOps.js';
|
|
3
4
|
import { buildSVGString, exportSVGFile, exportPNGFile, exportJPGFile, exportWebPFile, exportBMPFile } from './vectorEditorExport.js';
|
|
4
5
|
import { parseSVGToShapes } from './vectorEditorImport.js';
|
|
@@ -10,10 +11,13 @@ import { cloneShapes, sid, snapToGrid } from './vectorEditorTypes.js';
|
|
|
10
11
|
* so the component file is pure layout.
|
|
11
12
|
*/
|
|
12
13
|
function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
14
|
+
// the library's dialogs for the text tool and the library name (not window.prompt)
|
|
15
|
+
const { pendingAsk, ask } = useEditorAsk();
|
|
13
16
|
/* ── state ── */
|
|
14
17
|
const [shapes, setShapes] = useState([]);
|
|
15
18
|
const [selId, setSelId] = useState(null);
|
|
16
19
|
const [tool, setTool] = useState('pointer');
|
|
20
|
+
// audit-allow: literal-color — the first fill of a new shape - document data
|
|
17
21
|
const [fillCol, setFillCol] = useState('#5566cc');
|
|
18
22
|
const [strokeCol, setStrokeCol] = useState('#000000');
|
|
19
23
|
const [strokeW, setStrokeW] = useState(2);
|
|
@@ -176,28 +180,30 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
176
180
|
return;
|
|
177
181
|
}
|
|
178
182
|
if (tool === 'text') {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
183
|
+
// the text comes from a dialog: the shape is added once it is entered
|
|
184
|
+
void ask('prompt', 'Enter text:', 'Hello').then((txt) => {
|
|
185
|
+
if (!txt) {
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
const ns = {
|
|
189
|
+
id: sid(),
|
|
190
|
+
type: 'text',
|
|
191
|
+
x: p.x,
|
|
192
|
+
y: p.y,
|
|
193
|
+
w: txt.length * fontSize * 0.6,
|
|
194
|
+
h: fontSize,
|
|
195
|
+
...defaultBase,
|
|
196
|
+
stroke: 'none',
|
|
197
|
+
strokeWidth: 0,
|
|
198
|
+
text: txt,
|
|
199
|
+
fontSize,
|
|
200
|
+
fontFamily,
|
|
201
|
+
};
|
|
202
|
+
const next = [...shapes, ns];
|
|
203
|
+
snap(next);
|
|
204
|
+
setShapes(next);
|
|
205
|
+
setSelId(ns.id);
|
|
206
|
+
});
|
|
201
207
|
return;
|
|
202
208
|
}
|
|
203
209
|
if (tool === 'polygon') {
|
|
@@ -283,6 +289,7 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
283
289
|
starPoints2,
|
|
284
290
|
starInnerRatio,
|
|
285
291
|
cornerRadius,
|
|
292
|
+
ask,
|
|
286
293
|
]);
|
|
287
294
|
const onMove = useCallback((e) => {
|
|
288
295
|
if (panning.current) {
|
|
@@ -697,15 +704,15 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
697
704
|
const blob = new Blob([svg], { type: 'image/svg+xml' });
|
|
698
705
|
const reader = new FileReader();
|
|
699
706
|
reader.onload = () => {
|
|
700
|
-
const
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
707
|
+
const dataUrl = reader.result;
|
|
708
|
+
void ask('prompt', 'Save to library as:', 'drawing.svg').then((name) => {
|
|
709
|
+
if (name && name.trim()) {
|
|
710
|
+
onSaveToLibrary(dataUrl, name.trim(), 'image/svg+xml');
|
|
711
|
+
}
|
|
712
|
+
});
|
|
706
713
|
};
|
|
707
714
|
reader.readAsDataURL(blob);
|
|
708
|
-
}, [shapes, artW, artH, onSaveToLibrary]);
|
|
715
|
+
}, [shapes, artW, artH, onSaveToLibrary, ask]);
|
|
709
716
|
/* ── export shortcuts ── */
|
|
710
717
|
const exportSVG = useCallback(() => exportSVGFile(shapes, artW, artH, animations), [shapes, artW, artH, animations]);
|
|
711
718
|
const exportPNG = useCallback(() => exportPNGFile(shapes, artW, artH), [shapes, artW, artH]);
|
|
@@ -791,6 +798,8 @@ function useVectorEditor({ artW, artH, onSaveToLibrary }) {
|
|
|
791
798
|
/* ── return ── */
|
|
792
799
|
return {
|
|
793
800
|
// state
|
|
801
|
+
/** The question the editor waits on; render it with `EditorAskDialog`. */
|
|
802
|
+
pendingAsk,
|
|
794
803
|
shapes,
|
|
795
804
|
selId,
|
|
796
805
|
tool,
|
|
@@ -16,6 +16,7 @@ function parseSVGToShapes(raw) {
|
|
|
16
16
|
const elems = doc.querySelectorAll('rect, ellipse, circle, line, polyline, polygon, text, path');
|
|
17
17
|
elems.forEach((el) => {
|
|
18
18
|
const tag = el.tagName.toLowerCase();
|
|
19
|
+
// audit-allow: literal-color — an imported shape without a fill gets a visible default - document data
|
|
19
20
|
const fill = el.getAttribute('fill') || (tag === 'line' ? 'none' : '#cccccc');
|
|
20
21
|
const stroke = el.getAttribute('stroke') || 'none';
|
|
21
22
|
const sw = parseFloat(el.getAttribute('stroke-width') || '1');
|
|
@@ -37,6 +37,7 @@ function iconComponentToShapes(Icon, options) {
|
|
|
37
37
|
// Force a generous size and visible colors so the parser sees concrete strokes/fills.
|
|
38
38
|
const renderProps = {
|
|
39
39
|
size: 'lg',
|
|
40
|
+
// audit-allow: literal-color +2 — an imported icon's default colours - document data
|
|
40
41
|
primaryColor: '#5566cc',
|
|
41
42
|
secondaryColor: '#a29bfe',
|
|
42
43
|
strokeWidth: 2,
|
|
@@ -25,9 +25,5 @@ export type NiceAnimatedPersonProps = {
|
|
|
25
25
|
/** Convenience height — currently informational, retained for API symmetry. */
|
|
26
26
|
height?: number;
|
|
27
27
|
};
|
|
28
|
-
/** @deprecated Use NiceAnimatedPersonProps */
|
|
29
|
-
export type AnimatedPersonProps = NiceAnimatedPersonProps;
|
|
30
28
|
declare const NiceAnimatedPerson: React.FC<NiceAnimatedPersonProps>;
|
|
31
|
-
/** @deprecated Use NiceAnimatedPerson */
|
|
32
|
-
export declare const AnimatedPerson: React.FC<NiceAnimatedPersonProps>;
|
|
33
29
|
export default NiceAnimatedPerson;
|
|
@@ -16,9 +16,5 @@ export interface NiceAnimationEditorProps {
|
|
|
16
16
|
className?: string;
|
|
17
17
|
style?: React.CSSProperties;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
export type AnimationEditorProps = NiceAnimationEditorProps;
|
|
21
|
-
export declare function NiceAnimationEditor({ initialConfig, onChange, storageKey, onNotify, showJsonPanel, showPreview, className, style, }: AnimationEditorProps): React.JSX.Element;
|
|
22
|
-
/** @deprecated Use NiceAnimationEditor */
|
|
23
|
-
export declare const AnimationEditor: typeof NiceAnimationEditor;
|
|
19
|
+
export declare function NiceAnimationEditor({ initialConfig, onChange, storageKey, onNotify, showJsonPanel, showPreview, className, style, }: NiceAnimationEditorProps): React.JSX.Element;
|
|
24
20
|
export default NiceAnimationEditor;
|
|
@@ -12,10 +12,6 @@ export type NiceAudienceProps = {
|
|
|
12
12
|
/** Optional explicit height (forwarded to grid container). */
|
|
13
13
|
height?: number | string;
|
|
14
14
|
};
|
|
15
|
-
/** @deprecated Use NiceAudienceProps */
|
|
16
|
-
export type AudienceProps = NiceAudienceProps;
|
|
17
15
|
/** Grid of animated audience members with wave/cheer actions. */
|
|
18
16
|
declare const NiceAudience: React.FC<NiceAudienceProps>;
|
|
19
|
-
/** @deprecated Use NiceAudience */
|
|
20
|
-
export declare const Audience: React.FC<NiceAudienceProps>;
|
|
21
17
|
export default NiceAudience;
|
|
@@ -7,10 +7,6 @@ export type NiceBodyRendererProps = {
|
|
|
7
7
|
/** Optional pixel size. Defaults to character.size (or 180). */
|
|
8
8
|
size?: number;
|
|
9
9
|
};
|
|
10
|
-
/** @deprecated Use NiceBodyRendererProps */
|
|
11
|
-
export type BodyRendererProps = NiceBodyRendererProps;
|
|
12
10
|
/** Static character body composed from modular SVG shapes. */
|
|
13
11
|
export declare const NiceBodyRenderer: React.FC<NiceBodyRendererProps>;
|
|
14
|
-
/** @deprecated Use NiceBodyRenderer */
|
|
15
|
-
export declare const BodyRenderer: React.FC<NiceBodyRendererProps>;
|
|
16
12
|
export default NiceBodyRenderer;
|
|
@@ -2,9 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import type { ChoreoStep } from '../animationHelper';
|
|
3
3
|
import type { CharacterConfig } from '../characterTypes';
|
|
4
4
|
import { type RigConfig, type RigPose } from './rigTypes';
|
|
5
|
-
/** @deprecated Use NiceRigPlayerHandle */
|
|
6
|
-
export interface RigPlayerHandle extends NiceRigPlayerHandle {
|
|
7
|
-
}
|
|
8
5
|
/** Public methods exposed via ref. */
|
|
9
6
|
export interface NiceRigPlayerHandle {
|
|
10
7
|
/** Set pose immediately (no tween). */
|
|
@@ -31,9 +28,5 @@ export type NiceRigPlayerProps = {
|
|
|
31
28
|
/** Show debug joints. */
|
|
32
29
|
debug?: boolean;
|
|
33
30
|
};
|
|
34
|
-
/** @deprecated Use NiceRigPlayerProps */
|
|
35
|
-
export type RigPlayerProps = NiceRigPlayerProps;
|
|
36
31
|
declare const NiceRigPlayer: React.ForwardRefExoticComponent<NiceRigPlayerProps & React.RefAttributes<NiceRigPlayerHandle>>;
|
|
37
|
-
/** @deprecated Use NiceRigPlayer */
|
|
38
|
-
export declare const RigPlayer: React.ForwardRefExoticComponent<NiceRigPlayerProps & React.RefAttributes<NiceRigPlayerHandle>>;
|
|
39
32
|
export default NiceRigPlayer;
|
|
@@ -2,8 +2,6 @@ import React from 'react';
|
|
|
2
2
|
import type { CharacterConfig } from '../characterTypes';
|
|
3
3
|
import { type RigConfig, type RigPose } from './rigTypes';
|
|
4
4
|
/** Props for the rigged body renderer (pure SVG). */
|
|
5
|
-
/** @deprecated Use NiceRiggedBodyProps */
|
|
6
|
-
export type RiggedBodyProps = NiceRiggedBodyProps;
|
|
7
5
|
export type NiceRiggedBodyProps = {
|
|
8
6
|
/** Character visuals (colors). */
|
|
9
7
|
character: CharacterConfig;
|
|
@@ -18,6 +16,4 @@ export type NiceRiggedBodyProps = {
|
|
|
18
16
|
};
|
|
19
17
|
/** Render a multi-bone body (arms: 3, legs: 3, torso: 3, neck+head). */
|
|
20
18
|
declare const NiceRiggedBody: React.FC<NiceRiggedBodyProps>;
|
|
21
|
-
/** @deprecated Use NiceRiggedBody */
|
|
22
|
-
export declare const RiggedBody: React.FC<NiceRiggedBodyProps>;
|
|
23
19
|
export default NiceRiggedBody;
|
|
@@ -18,7 +18,3 @@ export declare const HEAD_RENDERERS: Record<string, React.FC<HeadProps>>;
|
|
|
18
18
|
export declare const NiceHead: React.FC<HeadProps & {
|
|
19
19
|
variant: string;
|
|
20
20
|
}>;
|
|
21
|
-
/** @deprecated Use NiceHead */
|
|
22
|
-
export declare const Head: React.FC<HeadProps & {
|
|
23
|
-
variant: string;
|
|
24
|
-
}>;
|
|
@@ -16,6 +16,5 @@ export interface RangeInputProps extends Omit<React.InputHTMLAttributes<HTMLInpu
|
|
|
16
16
|
onChange?: React.ChangeEventHandler<HTMLInputElement>;
|
|
17
17
|
}
|
|
18
18
|
export declare const RangeInput: React.FC<RangeInputProps>;
|
|
19
|
-
export
|
|
20
|
-
}
|
|
19
|
+
export type TextAreaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
|
|
21
20
|
export declare const TextArea: React.FC<TextAreaProps>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
/** A question an editor hook waits on; {@link EditorAskDialog} shows it. */
|
|
3
|
+
export interface EditorAsk {
|
|
4
|
+
/** `prompt` asks for a value, `confirm` for a yes / no. */
|
|
5
|
+
kind: 'prompt' | 'confirm';
|
|
6
|
+
/** The prompt's title, or the question to confirm. */
|
|
7
|
+
text: string;
|
|
8
|
+
/** Initial value of a prompt. */
|
|
9
|
+
defaultValue?: string;
|
|
10
|
+
/** Settles it: the entered value (`''` for an accepted confirm), or `null` when cancelled. */
|
|
11
|
+
answer: (value: string | null) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The library's dialogs in place of `window.prompt` / `window.confirm` for the editor hooks,
|
|
15
|
+
* which hold state but render nothing: `ask` resolves with the answer (`null` when cancelled)
|
|
16
|
+
* and `pendingAsk` is the open question, for the editor component to pass to
|
|
17
|
+
* {@link EditorAskDialog}. One question at a time: a new one settles the open one as cancelled.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useEditorAsk(): {
|
|
20
|
+
pendingAsk: EditorAsk | null;
|
|
21
|
+
ask: (kind: EditorAsk["kind"], text: string, defaultValue?: string) => Promise<string | null>;
|
|
22
|
+
};
|
|
23
|
+
/** Shows the question {@link useEditorAsk} is waiting on, if any. */
|
|
24
|
+
export declare const EditorAskDialog: React.FC<{
|
|
25
|
+
ask: EditorAsk | null;
|
|
26
|
+
}>;
|
|
@@ -1,26 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* i18n — Lightweight translation context for @nice2dev/ui-graphics.
|
|
3
|
-
*
|
|
4
|
-
* Drop-in replacement for react-i18next's useTranslation, requires NO
|
|
5
|
-
* external dependencies. Consumers can optionally wrap with NiceI18nProvider
|
|
6
|
-
* to supply their own translation function. Falls back to the default
|
|
7
|
-
* (English key strings) when no provider is present.
|
|
8
|
-
*
|
|
9
|
-
* Usage in components:
|
|
10
|
-
* const { t } = useNiceTranslation();
|
|
11
|
-
* <button>{t('actions.save', 'Save')}</button>
|
|
12
|
-
*
|
|
13
|
-
* Usage in apps:
|
|
14
|
-
* <NiceI18nProvider t={(key, fallback) => myI18n(key) ?? fallback}>
|
|
15
|
-
* <App />
|
|
16
|
-
* </NiceI18nProvider>
|
|
17
|
-
*/
|
|
18
1
|
import React from 'react';
|
|
19
2
|
export type NiceTranslateFn = (key: string, defaultValue: string) => string;
|
|
20
3
|
export interface NiceI18nProviderProps {
|
|
21
4
|
t: NiceTranslateFn;
|
|
22
5
|
children: React.ReactNode;
|
|
23
6
|
}
|
|
7
|
+
/** Overrides the app's global translator for the graphics controls below it. */
|
|
24
8
|
export declare const NiceI18nProvider: React.FC<NiceI18nProviderProps>;
|
|
25
9
|
export declare function useNiceTranslation(): {
|
|
26
10
|
t: NiceTranslateFn;
|
|
@@ -13,9 +13,5 @@ export interface NiceGameAsset2dEditorProps {
|
|
|
13
13
|
onSave?: (project: unknown) => void;
|
|
14
14
|
onExport?: (data: string, format: string) => void;
|
|
15
15
|
}
|
|
16
|
-
/** @deprecated Use NiceGameAsset2dEditorProps */
|
|
17
|
-
export type GameAsset2dEditorProps = NiceGameAsset2dEditorProps;
|
|
18
16
|
export declare const NiceGameAsset2dEditor: React.FC<NiceGameAsset2dEditorProps>;
|
|
19
|
-
/** @deprecated Use NiceGameAsset2dEditor */
|
|
20
|
-
export declare const GameAsset2dEditor: React.FC<NiceGameAsset2dEditorProps>;
|
|
21
17
|
export default NiceGameAsset2dEditor;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* game/index.ts — Public exports for GameAsset2dEditor
|
|
3
3
|
*/
|
|
4
|
-
export { NiceGameAsset2dEditor,
|
|
4
|
+
export { NiceGameAsset2dEditor, type NiceGameAsset2dEditorProps } from './GameAsset2dEditor';
|
|
5
5
|
export { useGameAssetEditor, type GameAssetEditorApi, type UseGameAssetEditorOptions, } from './useGameAssetEditor';
|
|
6
6
|
export type { TileMapMode, TileDefinition, CollisionShape, TileLayer, TileMap, SpriteFrame, SpriteSheet, SpriteAnimation, AnimationState, AnimationTransition, TransitionCondition, AnimationParameter, AnimationStateMachine, EffectType, Effect, EffectPreset, GameAssetProject, ProjectSettings, EditorMode, TileMapTool, SpriteSheetTool, EditorState, ExportOptions, TiledExport, UnityExport, HistoryEntry, } from './gameAssetTypes';
|
|
7
7
|
export { TILE_MAP_TOOLS, EFFECT_DEFAULTS, DEFAULT_PROJECT_SETTINGS } from './gameAssetTypes';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -5,24 +5,18 @@
|
|
|
5
5
|
* import { PixelEditor } from '@nice2dev/ui-graphics';
|
|
6
6
|
* import { NiceI18nProvider } from '@nice2dev/ui-graphics';
|
|
7
7
|
*/
|
|
8
|
-
export { NicePixelEditor,
|
|
9
|
-
export { NiceVectorEditor,
|
|
8
|
+
export { NicePixelEditor, type NicePixelEditorProps } from './pixel/PixelEditor';
|
|
9
|
+
export { NiceVectorEditor, type NiceVectorEditorProps } from './vector/VectorEditor';
|
|
10
10
|
export { default as NicePhotoEditor } from './photo/PhotoEditor';
|
|
11
|
-
/** @deprecated Use NicePhotoEditor */
|
|
12
|
-
export { default as PhotoEditor } from './photo/PhotoEditor';
|
|
13
11
|
export type { PhotoEditorProps } from './photo/photoEditorTypes';
|
|
14
|
-
export { NiceAnimationEditor,
|
|
12
|
+
export { NiceAnimationEditor, type NiceAnimationEditorProps } from './animation/AnimationEditor';
|
|
15
13
|
export { default as NiceAnimatedPerson, type NiceAnimatedPersonProps, } from './animation/AnimatedPerson';
|
|
16
|
-
/** @deprecated Use NiceAnimatedPerson / NiceAnimatedPersonProps */
|
|
17
|
-
export { default as AnimatedPerson, type AnimatedPersonProps } from './animation/AnimatedPerson';
|
|
18
14
|
export { type SpritePart, type SpriteAssembly, type AssembledPart, type SpritePartCategory, type SpriteDirection, type GeneratedSprite, type ProjectionMode, type PartPixelData, ALL_DIRECTIONS, createPartData, mirrorPartH, generateMirroredDirections, renderPart, assembleSprite, generateAllDirections, applyIsometricProjection, render8DirSpriteSheet, shiftHue, generateRecolorMap, registerPart, registerParts, getPart, getPartsByCategory, getPartsBySlot, getAllParts, } from './pixel/spriteGeneratorCore';
|
|
19
15
|
export { SKIN_PALETTES, HAIR_PALETTES, CLOTHING_PALETTES, CHARACTER_PRESETS, initCharacterParts, } from './pixel/characterGeneratorPresets';
|
|
20
16
|
export { WALL_PALETTES, ROOF_PALETTES, BUILDING_PRESETS, assembleBuildingFromConfig, initBuildingParts, type BuildingConfig, type FloorConfig, } from './pixel/buildingGeneratorPresets';
|
|
21
17
|
export { FUR_PALETTES, SCALE_PALETTES, FEATHER_PALETTES, ANIMAL_PRESETS, initAnimalParts, } from './pixel/animalGeneratorPresets';
|
|
22
18
|
export { default as NiceSpriteGeneratorPanel, type NiceSpriteGeneratorPanelProps, } from './pixel/SpriteGeneratorPanel';
|
|
23
|
-
|
|
24
|
-
export { default as SpriteGeneratorPanel, type SpriteGeneratorPanelProps, } from './pixel/SpriteGeneratorPanel';
|
|
25
|
-
export { NiceGameAsset2dEditor, GameAsset2dEditor, type NiceGameAsset2dEditorProps, type GameAsset2dEditorProps, useGameAssetEditor, type GameAssetEditorApi, } from './game';
|
|
19
|
+
export { NiceGameAsset2dEditor, type NiceGameAsset2dEditorProps, useGameAssetEditor, type GameAssetEditorApi, } from './game';
|
|
26
20
|
export type { TileMap, TileLayer, TileDefinition, SpriteSheet, SpriteFrame, SpriteAnimation, AnimationStateMachine, AnimationState, AnimationTransition, GameAssetProject, Effect, EffectType, } from './game';
|
|
27
21
|
export { NiceI18nProvider, useNiceTranslation, type NiceTranslateFn, type NiceI18nProviderProps, } from './core/i18n';
|
|
28
22
|
export type { Layer, Tool as PixelTool, BlendMode } from './pixel/pixelEditorTypes';
|
|
@@ -47,20 +41,16 @@ export { default as NiceRiggedBody } from './animation/rig/RiggedBody';
|
|
|
47
41
|
export { default as RiggedBody } from './animation/rig/RiggedBody';
|
|
48
42
|
export { default as NiceRigPlayer } from './animation/rig/RigPlayer';
|
|
49
43
|
export { default as RigPlayer } from './animation/rig/RigPlayer';
|
|
50
|
-
export type { NiceRigPlayerHandle
|
|
44
|
+
export type { NiceRigPlayerHandle } from './animation/rig/RigPlayer';
|
|
51
45
|
export { rigPoseFor, playRigFromChoreo } from './animation/rig/choreoRigBridge';
|
|
52
46
|
export { ChoreoBuilder, seq, compile, runSeq, runWave, runCannon, runRounds, } from './animation/choreoDSL';
|
|
53
47
|
export { waveScoreChoreo, booChoreo, danceParty, showcaseAll } from './animation/choreography';
|
|
54
48
|
export { default as NiceAudience } from './animation/Audience';
|
|
55
|
-
|
|
56
|
-
export { default as Audience } from './animation/Audience';
|
|
57
|
-
export type { NiceAudienceProps, AudienceProps } from './animation/Audience';
|
|
49
|
+
export type { NiceAudienceProps } from './animation/Audience';
|
|
58
50
|
export { scoreBus, onScore, reactionForScore, playIntro, simulateScore, attachScoreReactions, } from './animation/karaokeIntegration';
|
|
59
|
-
export { NiceBodyRenderer,
|
|
60
|
-
|
|
61
|
-
export {
|
|
62
|
-
export type { NiceBodyRendererProps, BodyRendererProps } from './animation/BodyRenderer';
|
|
63
|
-
export { NiceHead, Head, HEAD_RENDERERS } from './animation/shapes/heads';
|
|
51
|
+
export { NiceBodyRenderer, default as NiceBodyRendererDefault } from './animation/BodyRenderer';
|
|
52
|
+
export type { NiceBodyRendererProps } from './animation/BodyRenderer';
|
|
53
|
+
export { NiceHead, HEAD_RENDERERS } from './animation/shapes/heads';
|
|
64
54
|
export type { HeadProps } from './animation/shapes/heads';
|
|
65
55
|
export { Eyes, EYES_RENDERERS } from './animation/shapes/eyes';
|
|
66
56
|
export type { EyesProps } from './animation/shapes/eyes';
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { default as NicePhotoEditor } from './PhotoEditor';
|
|
2
|
-
/** @deprecated Use NicePhotoEditor */
|
|
3
|
-
export { default as PhotoEditor } from './PhotoEditor';
|
|
4
2
|
export { usePhotoEditor } from './usePhotoEditor';
|
|
5
3
|
export type * from './photoEditorTypes';
|
|
6
4
|
export * from './photoFilters';
|
|
@@ -13,9 +13,5 @@ export interface NicePixelEditorProps {
|
|
|
13
13
|
className?: string;
|
|
14
14
|
onSaveToLibrary?: (dataUrl: string, name: string, mimeType: string) => void;
|
|
15
15
|
}
|
|
16
|
-
/** @deprecated Use NicePixelEditorProps */
|
|
17
|
-
export type PixelEditorProps = NicePixelEditorProps;
|
|
18
16
|
export declare const NicePixelEditor: React.FC<NicePixelEditorProps>;
|
|
19
|
-
/** @deprecated Use NicePixelEditor */
|
|
20
|
-
export declare const PixelEditor: React.FC<NicePixelEditorProps>;
|
|
21
17
|
export default NicePixelEditor;
|
|
@@ -15,9 +15,5 @@ export interface NiceSpriteGeneratorPanelProps {
|
|
|
15
15
|
/** Convenience callback fired whenever a sprite sheet is generated. */
|
|
16
16
|
onGenerate?: (sheet: unknown) => void;
|
|
17
17
|
}
|
|
18
|
-
/** @deprecated Use NiceSpriteGeneratorPanelProps */
|
|
19
|
-
export type SpriteGeneratorPanelProps = NiceSpriteGeneratorPanelProps;
|
|
20
18
|
declare const NiceSpriteGeneratorPanel: React.FC<NiceSpriteGeneratorPanelProps>;
|
|
21
|
-
/** @deprecated Use NiceSpriteGeneratorPanel */
|
|
22
|
-
export declare const SpriteGeneratorPanel: React.FC<NiceSpriteGeneratorPanelProps>;
|
|
23
19
|
export default NiceSpriteGeneratorPanel;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* usePixelEditor — custom hook encapsulating ALL state, refs, callbacks,
|
|
3
3
|
* side-effects and memos for the PixelEditor component.
|
|
4
4
|
*/
|
|
5
|
+
import { type EditorAsk } from '../core/editorAsk';
|
|
5
6
|
import { type Tool, type Layer, type BlendMode, type Selection } from './pixelEditorTypes';
|
|
6
7
|
import { type BrushConfig, type SymmetryMode } from './pixelEditorUtils';
|
|
7
8
|
export interface UsePixelEditorProps {
|
|
@@ -81,6 +82,8 @@ export interface PixelEditorAPI {
|
|
|
81
82
|
exportSVG: () => void;
|
|
82
83
|
exportSheet: () => void;
|
|
83
84
|
saveToLibrary: () => void;
|
|
85
|
+
/** The question the editor waits on (library name); render it with `EditorAskDialog`. */
|
|
86
|
+
pendingAsk: EditorAsk | null;
|
|
84
87
|
addLayer: () => void;
|
|
85
88
|
rmLayer: () => void;
|
|
86
89
|
toggleVis: (i: number) => void;
|
|
@@ -43,9 +43,5 @@ export interface NiceVectorEditorProps {
|
|
|
43
43
|
/** Called when the user exports the current canvas as a createIcon snippet. */
|
|
44
44
|
onExportIconSnippet?: (snippet: string, iconName: string, category?: string) => void;
|
|
45
45
|
}
|
|
46
|
-
/** @deprecated Use NiceVectorEditorProps */
|
|
47
|
-
export type VectorEditorProps = NiceVectorEditorProps;
|
|
48
46
|
export declare const NiceVectorEditor: React.FC<NiceVectorEditorProps>;
|
|
49
|
-
/** @deprecated Use NiceVectorEditor */
|
|
50
|
-
export declare const VectorEditor: React.FC<NiceVectorEditorProps>;
|
|
51
47
|
export default NiceVectorEditor;
|
|
@@ -11,6 +11,8 @@ export interface UseVectorEditorOptions {
|
|
|
11
11
|
onSaveToLibrary?: (dataUrl: string, name: string, mimeType: string) => void;
|
|
12
12
|
}
|
|
13
13
|
export declare function useVectorEditor({ artW, artH, onSaveToLibrary }: UseVectorEditorOptions): {
|
|
14
|
+
/** The question the editor waits on; render it with `EditorAskDialog`. */
|
|
15
|
+
readonly pendingAsk: import("../core/editorAsk").EditorAsk | null;
|
|
14
16
|
readonly shapes: VShape[];
|
|
15
17
|
readonly selId: string | null;
|
|
16
18
|
readonly tool: VTool;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nice2dev/ui-graphics",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Nice2Dev Graphics Editors — Pixel, Vector, Photo and Animation editors for React",
|
|
5
5
|
"author": "NiceToDev <contact@nicetodev.com>",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE",
|
|
@@ -64,15 +64,15 @@
|
|
|
64
64
|
"nicetodev"
|
|
65
65
|
],
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@nice2dev/ui-core": "^1.0
|
|
68
|
-
"@nice2dev/ui": "^1.0
|
|
67
|
+
"@nice2dev/ui-core": "^1.2.0",
|
|
68
|
+
"@nice2dev/ui": "^1.2.0",
|
|
69
69
|
"framer-motion": ">=10.0.0",
|
|
70
70
|
"react": ">=17.0.0",
|
|
71
71
|
"react-dom": ">=17.0.0"
|
|
72
72
|
},
|
|
73
73
|
"devDependencies": {
|
|
74
|
-
"@nice2dev/ui": "^1.1
|
|
75
|
-
"@nice2dev/ui-core": "^1.1
|
|
74
|
+
"@nice2dev/ui": "^1.2.1",
|
|
75
|
+
"@nice2dev/ui-core": "^1.2.1",
|
|
76
76
|
"@rollup/plugin-commonjs": "^29.0.3",
|
|
77
77
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
78
78
|
"@rollup/plugin-typescript": "^12.3.0",
|