@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { generateMirroredDirections, createPartData, registerParts } from './spriteGeneratorCore.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* characterGeneratorPresets.ts — Extensive library of character parts
|
|
@@ -47,7 +47,7 @@ const CLOTHING_PALETTES = {
|
|
|
47
47
|
16×16 CHARACTER PARTS — HEADS
|
|
48
48
|
════════════════════════════════════════════════════════════════ */
|
|
49
49
|
const _ = -1; // transparent shorthand
|
|
50
|
-
const HEAD_ROUND_S = createPartData(8, 8, [
|
|
50
|
+
const HEAD_ROUND_S = /* @__PURE__ */ createPartData(8, 8, [
|
|
51
51
|
[_, _, 1, 1, 1, 1, _, _],
|
|
52
52
|
[_, 1, 0, 0, 0, 0, 1, _],
|
|
53
53
|
[1, 0, 0, 0, 0, 0, 0, 1],
|
|
@@ -57,7 +57,7 @@ const HEAD_ROUND_S = createPartData(8, 8, [
|
|
|
57
57
|
[_, 1, 0, 0, 0, 0, 1, _],
|
|
58
58
|
[_, _, 1, 1, 1, 1, _, _],
|
|
59
59
|
], ['var(--nice-warning-bg, #ffecd2)', '#c07848', '#e05050', '#2a2a4e']);
|
|
60
|
-
const HEAD_ROUND_E = createPartData(7, 8, [
|
|
60
|
+
const HEAD_ROUND_E = /* @__PURE__ */ createPartData(7, 8, [
|
|
61
61
|
[_, _, 1, 1, 1, _, _],
|
|
62
62
|
[_, 1, 0, 0, 0, 1, _],
|
|
63
63
|
[1, 0, 0, 0, 0, 0, 1],
|
|
@@ -67,7 +67,7 @@ const HEAD_ROUND_E = createPartData(7, 8, [
|
|
|
67
67
|
[_, 1, 0, 0, 0, 1, _],
|
|
68
68
|
[_, _, 1, 1, 1, _, _],
|
|
69
69
|
], ['var(--nice-warning-bg, #ffecd2)', '#c07848', '#e05050', '#2a2a4e']);
|
|
70
|
-
const HEAD_ROUND_N = createPartData(8, 8, [
|
|
70
|
+
const HEAD_ROUND_N = /* @__PURE__ */ createPartData(8, 8, [
|
|
71
71
|
[_, _, 1, 1, 1, 1, _, _],
|
|
72
72
|
[_, 1, 0, 0, 0, 0, 1, _],
|
|
73
73
|
[1, 0, 0, 0, 0, 0, 0, 1],
|
|
@@ -77,7 +77,7 @@ const HEAD_ROUND_N = createPartData(8, 8, [
|
|
|
77
77
|
[_, 1, 0, 0, 0, 0, 1, _],
|
|
78
78
|
[_, _, 1, 1, 1, 1, _, _],
|
|
79
79
|
], ['var(--nice-warning-bg, #ffecd2)', '#c07848', '#e05050', '#2a2a4e']);
|
|
80
|
-
const HEAD_SQUARE_S = createPartData(8, 7, [
|
|
80
|
+
const HEAD_SQUARE_S = /* @__PURE__ */ createPartData(8, 7, [
|
|
81
81
|
[_, 1, 1, 1, 1, 1, 1, _],
|
|
82
82
|
[1, 0, 0, 0, 0, 0, 0, 1],
|
|
83
83
|
[1, 0, 3, 0, 0, 3, 0, 1],
|
|
@@ -86,7 +86,7 @@ const HEAD_SQUARE_S = createPartData(8, 7, [
|
|
|
86
86
|
[1, 0, 0, 0, 0, 0, 0, 1],
|
|
87
87
|
[_, 1, 1, 1, 1, 1, 1, _],
|
|
88
88
|
], ['var(--nice-warning-bg, #ffecd2)', '#c07848', '#e05050', '#2a2a4e']);
|
|
89
|
-
const HEAD_CHIBI_S = createPartData(10, 10, [
|
|
89
|
+
const HEAD_CHIBI_S = /* @__PURE__ */ createPartData(10, 10, [
|
|
90
90
|
[_, _, _, 1, 1, 1, 1, _, _, _],
|
|
91
91
|
[_, _, 1, 0, 0, 0, 0, 1, _, _],
|
|
92
92
|
[_, 1, 0, 0, 0, 0, 0, 0, 1, _],
|
|
@@ -99,13 +99,13 @@ const HEAD_CHIBI_S = createPartData(10, 10, [
|
|
|
99
99
|
[_, _, 1, 1, 1, 1, 1, 1, _, _],
|
|
100
100
|
], ['var(--nice-warning-bg, #ffecd2)', '#c07848', '#e05050', '#2a2a4e']);
|
|
101
101
|
/* ── HAIR ── */
|
|
102
|
-
const HAIR_SHORT_S = createPartData(8, 4, [
|
|
102
|
+
const HAIR_SHORT_S = /* @__PURE__ */ createPartData(8, 4, [
|
|
103
103
|
[_, _, 0, 0, 0, 0, _, _],
|
|
104
104
|
[_, 0, 0, 0, 0, 0, 0, _],
|
|
105
105
|
[0, 0, 1, 1, 1, 1, 0, 0],
|
|
106
106
|
[0, 1, _, _, _, _, 1, 0],
|
|
107
107
|
], ['#4a3508', '#6b4e0a']);
|
|
108
|
-
const HAIR_LONG_S = createPartData(10, 10, [
|
|
108
|
+
const HAIR_LONG_S = /* @__PURE__ */ createPartData(10, 10, [
|
|
109
109
|
[_, _, _, 0, 0, 0, 0, _, _, _],
|
|
110
110
|
[_, _, 0, 0, 0, 0, 0, 0, _, _],
|
|
111
111
|
[_, 0, 0, 1, 1, 1, 1, 0, 0, _],
|
|
@@ -117,7 +117,7 @@ const HAIR_LONG_S = createPartData(10, 10, [
|
|
|
117
117
|
[_, 0, _, _, _, _, _, _, 0, _],
|
|
118
118
|
[_, 0, 0, _, _, _, _, 0, 0, _],
|
|
119
119
|
], ['#4a3508', '#6b4e0a']);
|
|
120
|
-
const HAIR_MOHAWK_S = createPartData(8, 6, [
|
|
120
|
+
const HAIR_MOHAWK_S = /* @__PURE__ */ createPartData(8, 6, [
|
|
121
121
|
[_, _, _, 0, 0, _, _, _],
|
|
122
122
|
[_, _, 0, 0, 0, 0, _, _],
|
|
123
123
|
[_, _, 0, 0, 0, 0, _, _],
|
|
@@ -125,7 +125,7 @@ const HAIR_MOHAWK_S = createPartData(8, 6, [
|
|
|
125
125
|
[_, 0, 1, _, _, 1, 0, _],
|
|
126
126
|
[0, 1, _, _, _, _, 1, 0],
|
|
127
127
|
], ['#d03020', '#a02018']);
|
|
128
|
-
const HAIR_PONYTAIL_S = createPartData(10, 8, [
|
|
128
|
+
const HAIR_PONYTAIL_S = /* @__PURE__ */ createPartData(10, 8, [
|
|
129
129
|
[_, _, _, 0, 0, 0, 0, _, _, _],
|
|
130
130
|
[_, _, 0, 0, 0, 0, 0, 0, _, _],
|
|
131
131
|
[_, 0, 0, 1, 1, 1, 1, 0, 0, _],
|
|
@@ -135,7 +135,7 @@ const HAIR_PONYTAIL_S = createPartData(10, 8, [
|
|
|
135
135
|
[_, _, _, _, _, _, _, _, _, 0],
|
|
136
136
|
[_, _, _, _, _, _, _, _, 0, _],
|
|
137
137
|
], ['#f0d060', '#d0b040']);
|
|
138
|
-
const HAIR_SPIKY_S = createPartData(10, 6, [
|
|
138
|
+
const HAIR_SPIKY_S = /* @__PURE__ */ createPartData(10, 6, [
|
|
139
139
|
[_, 0, _, _, 0, _, 0, _, _, _],
|
|
140
140
|
[_, 0, 0, 0, 0, 0, 0, 0, _, _],
|
|
141
141
|
[0, 0, 0, 0, 0, 0, 0, 0, 0, _],
|
|
@@ -144,7 +144,7 @@ const HAIR_SPIKY_S = createPartData(10, 6, [
|
|
|
144
144
|
[_, _, _, _, _, _, _, _, _, _],
|
|
145
145
|
], ['var(--nice-bg, #1a1a2e)', '#101020']);
|
|
146
146
|
/* ── TORSOS ── */
|
|
147
|
-
const TORSO_BASIC_S = createPartData(8, 6, [
|
|
147
|
+
const TORSO_BASIC_S = /* @__PURE__ */ createPartData(8, 6, [
|
|
148
148
|
[_, _, 1, 1, 1, 1, _, _],
|
|
149
149
|
[_, 1, 0, 0, 0, 0, 1, _],
|
|
150
150
|
[1, 0, 0, 0, 0, 0, 0, 1],
|
|
@@ -152,7 +152,7 @@ const TORSO_BASIC_S = createPartData(8, 6, [
|
|
|
152
152
|
[_, 1, 0, 0, 0, 0, 1, _],
|
|
153
153
|
[_, _, 1, 1, 1, 1, _, _],
|
|
154
154
|
], ['#4060d0', '#3040b0']);
|
|
155
|
-
const TORSO_ARMOR_S = createPartData(10, 7, [
|
|
155
|
+
const TORSO_ARMOR_S = /* @__PURE__ */ createPartData(10, 7, [
|
|
156
156
|
[_, _, _, 1, 1, 1, 1, _, _, _],
|
|
157
157
|
[_, _, 1, 0, 2, 2, 0, 1, _, _],
|
|
158
158
|
[_, 1, 0, 0, 2, 2, 0, 0, 1, _],
|
|
@@ -161,7 +161,7 @@ const TORSO_ARMOR_S = createPartData(10, 7, [
|
|
|
161
161
|
[_, 1, 0, 0, 0, 0, 0, 0, 1, _],
|
|
162
162
|
[_, _, 1, 1, 1, 1, 1, 1, _, _],
|
|
163
163
|
], ['var(--nice-border, #c0c0c8)', '#909098', '#f0d060']);
|
|
164
|
-
const TORSO_ROBE_S = createPartData(10, 10, [
|
|
164
|
+
const TORSO_ROBE_S = /* @__PURE__ */ createPartData(10, 10, [
|
|
165
165
|
[_, _, _, 1, 1, 1, 1, _, _, _],
|
|
166
166
|
[_, _, 1, 0, 0, 0, 0, 1, _, _],
|
|
167
167
|
[_, 1, 0, 0, 2, 2, 0, 0, 1, _],
|
|
@@ -174,14 +174,14 @@ const TORSO_ROBE_S = createPartData(10, 10, [
|
|
|
174
174
|
[_, _, _, 1, 1, 1, 1, _, _, _],
|
|
175
175
|
], ['#8020a0', '#601080', '#f0d060']);
|
|
176
176
|
/* ── ARMS ── */
|
|
177
|
-
const ARM_BASIC_S = createPartData(3, 5, [
|
|
177
|
+
const ARM_BASIC_S = /* @__PURE__ */ createPartData(3, 5, [
|
|
178
178
|
[_, 0, _],
|
|
179
179
|
[0, 0, 1],
|
|
180
180
|
[0, 0, 1],
|
|
181
181
|
[0, 0, 1],
|
|
182
182
|
[_, 0, _],
|
|
183
183
|
], ['var(--nice-warning-bg, #ffecd2)', '#c07848']);
|
|
184
|
-
const ARM_ARMORED_S = createPartData(4, 5, [
|
|
184
|
+
const ARM_ARMORED_S = /* @__PURE__ */ createPartData(4, 5, [
|
|
185
185
|
[_, 0, 1, _],
|
|
186
186
|
[0, 0, 0, 1],
|
|
187
187
|
[0, 0, 0, 1],
|
|
@@ -189,14 +189,14 @@ const ARM_ARMORED_S = createPartData(4, 5, [
|
|
|
189
189
|
[_, 0, 1, _],
|
|
190
190
|
], ['var(--nice-border, #c0c0c8)', '#909098']);
|
|
191
191
|
/* ── LEGS ── */
|
|
192
|
-
const LEG_BASIC_S = createPartData(3, 5, [
|
|
192
|
+
const LEG_BASIC_S = /* @__PURE__ */ createPartData(3, 5, [
|
|
193
193
|
[_, 0, _],
|
|
194
194
|
[0, 0, 1],
|
|
195
195
|
[0, 0, 1],
|
|
196
196
|
[0, 0, 1],
|
|
197
197
|
[0, 1, 1],
|
|
198
198
|
], ['#4060d0', '#3040b0']);
|
|
199
|
-
const LEG_BOOT_S = createPartData(4, 5, [
|
|
199
|
+
const LEG_BOOT_S = /* @__PURE__ */ createPartData(4, 5, [
|
|
200
200
|
[_, 0, 0, _],
|
|
201
201
|
[_, 0, 0, _],
|
|
202
202
|
[_, 0, 0, _],
|
|
@@ -204,7 +204,7 @@ const LEG_BOOT_S = createPartData(4, 5, [
|
|
|
204
204
|
[0, 0, 0, 1],
|
|
205
205
|
], ['#b08060', '#906840']);
|
|
206
206
|
/* ── HATS ── */
|
|
207
|
-
const HAT_WIZARD_S = createPartData(10, 8, [
|
|
207
|
+
const HAT_WIZARD_S = /* @__PURE__ */ createPartData(10, 8, [
|
|
208
208
|
[_, _, _, _, 0, _, _, _, _, _],
|
|
209
209
|
[_, _, _, 0, 0, 0, _, _, _, _],
|
|
210
210
|
[_, _, 0, 0, 0, 0, 0, _, _, _],
|
|
@@ -214,7 +214,7 @@ const HAT_WIZARD_S = createPartData(10, 8, [
|
|
|
214
214
|
[0, 1, 1, 1, 1, 1, 1, 1, 0, _],
|
|
215
215
|
[_, _, _, _, _, _, _, _, _, _],
|
|
216
216
|
], ['#8020a0', '#601080', '#f0d060']);
|
|
217
|
-
const HAT_KNIGHT_S = createPartData(10, 6, [
|
|
217
|
+
const HAT_KNIGHT_S = /* @__PURE__ */ createPartData(10, 6, [
|
|
218
218
|
[_, _, _, 0, 0, 0, 0, _, _, _],
|
|
219
219
|
[_, _, 0, 0, 0, 0, 0, 0, _, _],
|
|
220
220
|
[_, 0, 0, 0, 0, 0, 0, 0, 0, _],
|
|
@@ -222,14 +222,14 @@ const HAT_KNIGHT_S = createPartData(10, 6, [
|
|
|
222
222
|
[0, 0, 2, 2, 2, 2, 2, 2, 0, 0],
|
|
223
223
|
[_, _, _, 1, 1, 1, 1, _, _, _],
|
|
224
224
|
], ['var(--nice-border, #c0c0c8)', '#606068', '#f0d060']);
|
|
225
|
-
const HAT_CROWN_S = createPartData(10, 5, [
|
|
225
|
+
const HAT_CROWN_S = /* @__PURE__ */ createPartData(10, 5, [
|
|
226
226
|
[_, 2, _, _, 2, _, _, 2, _, _],
|
|
227
227
|
[_, 0, 2, _, 0, _, 2, 0, _, _],
|
|
228
228
|
[_, 0, 0, 2, 0, 2, 0, 0, _, _],
|
|
229
229
|
[_, 0, 0, 0, 0, 0, 0, 0, _, _],
|
|
230
230
|
[_, 1, 1, 1, 1, 1, 1, 1, _, _],
|
|
231
231
|
], ['#f0d060', '#d0b040', '#ff4040']);
|
|
232
|
-
const HAT_CAP_S = createPartData(9, 5, [
|
|
232
|
+
const HAT_CAP_S = /* @__PURE__ */ createPartData(9, 5, [
|
|
233
233
|
[_, _, _, 0, 0, 0, _, _, _],
|
|
234
234
|
[_, _, 0, 0, 0, 0, 0, _, _],
|
|
235
235
|
[_, 0, 0, 0, 0, 0, 0, 0, _],
|
|
@@ -237,7 +237,7 @@ const HAT_CAP_S = createPartData(9, 5, [
|
|
|
237
237
|
[_, _, 1, 1, 1, 1, 1, _, _],
|
|
238
238
|
], ['#d04040', '#b02020']);
|
|
239
239
|
/* ── WEAPONS ── */
|
|
240
|
-
const WEAPON_SWORD_S = createPartData(3, 10, [
|
|
240
|
+
const WEAPON_SWORD_S = /* @__PURE__ */ createPartData(3, 10, [
|
|
241
241
|
[_, 0, _],
|
|
242
242
|
[_, 0, _],
|
|
243
243
|
[_, 0, _],
|
|
@@ -249,7 +249,7 @@ const WEAPON_SWORD_S = createPartData(3, 10, [
|
|
|
249
249
|
[_, 2, _],
|
|
250
250
|
[_, 2, _],
|
|
251
251
|
], ['var(--nice-border, #c0c0c8)', '#f0d060', '#8b5e3c']);
|
|
252
|
-
const WEAPON_STAFF_S = createPartData(3, 12, [
|
|
252
|
+
const WEAPON_STAFF_S = /* @__PURE__ */ createPartData(3, 12, [
|
|
253
253
|
[_, 1, _],
|
|
254
254
|
[1, 1, 1],
|
|
255
255
|
[_, 1, _],
|
|
@@ -263,7 +263,7 @@ const WEAPON_STAFF_S = createPartData(3, 12, [
|
|
|
263
263
|
[_, 0, _],
|
|
264
264
|
[_, 0, _],
|
|
265
265
|
], ['#8b5e3c', '#4080e0']);
|
|
266
|
-
const WEAPON_BOW_S = createPartData(5, 10, [
|
|
266
|
+
const WEAPON_BOW_S = /* @__PURE__ */ createPartData(5, 10, [
|
|
267
267
|
[_, _, _, 0, _],
|
|
268
268
|
[_, _, 0, _, 1],
|
|
269
269
|
[_, 0, _, _, 1],
|
|
@@ -275,7 +275,7 @@ const WEAPON_BOW_S = createPartData(5, 10, [
|
|
|
275
275
|
[_, _, 0, _, 1],
|
|
276
276
|
[_, _, _, 0, _],
|
|
277
277
|
], ['#8b5e3c', 'var(--nice-border, #c0c0c8)']);
|
|
278
|
-
const SHIELD_ROUND_S = createPartData(6, 7, [
|
|
278
|
+
const SHIELD_ROUND_S = /* @__PURE__ */ createPartData(6, 7, [
|
|
279
279
|
[_, _, 1, 1, _, _],
|
|
280
280
|
[_, 1, 0, 0, 1, _],
|
|
281
281
|
[1, 0, 0, 2, 0, 1],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveCssColor } from '@nice2dev/ui-core';
|
|
2
2
|
import { useState, useRef, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
+
import { useEditorAsk } from '../core/editorAsk.js';
|
|
3
4
|
import { aseColorToHex, parseAseFile } from './asepriteFormat.js';
|
|
4
5
|
import { exportAse, exportPNG, exportJPG, exportWebP, exportBMP, exportSVG, exportSheet } from './pixelEditorExports.js';
|
|
5
6
|
import { lid, DEFAULT_PALETTE, celKey, PIXEL_CHECKER_DARK, hex2t, inB, plotEllipse } from './pixelEditorTypes.js';
|
|
@@ -9,11 +10,12 @@ import { DEFAULT_BRUSH, createBlankImageData, cloneImageData, bresenhamLine, set
|
|
|
9
10
|
* usePixelEditor — custom hook encapsulating ALL state, refs, callbacks,
|
|
10
11
|
* side-effects and memos for the PixelEditor component.
|
|
11
12
|
*/
|
|
12
|
-
const log = { warn: console.warn, error: console.error
|
|
13
|
+
const log = { warn: console.warn, error: console.error };
|
|
13
14
|
/* ═══════════════════════════════════════════
|
|
14
15
|
Hook
|
|
15
16
|
═══════════════════════════════════════════ */
|
|
16
17
|
function usePixelEditor({ initialWidth = 64, initialHeight = 64, onSaveToLibrary, }) {
|
|
18
|
+
const { pendingAsk, ask } = useEditorAsk();
|
|
17
19
|
/* ── state ── */
|
|
18
20
|
const [dw, setDw] = useState(initialWidth);
|
|
19
21
|
const [dh, setDh] = useState(initialHeight);
|
|
@@ -294,7 +296,7 @@ function usePixelEditor({ initialWidth = 64, initialHeight = 64, onSaveToLibrary
|
|
|
294
296
|
}
|
|
295
297
|
// symmetry guides
|
|
296
298
|
if (symmetry !== 'none') {
|
|
297
|
-
ctx.strokeStyle = 'rgba(255,100,100,0.3)';
|
|
299
|
+
ctx.strokeStyle = resolveCssColor('var(--nice-danger-tint-30, rgba(255,100,100,0.3))', ctx.canvas);
|
|
298
300
|
ctx.lineWidth = 1 / zoom;
|
|
299
301
|
ctx.setLineDash([4 / zoom, 4 / zoom]);
|
|
300
302
|
if (symmetry === 'h' || symmetry === 'both') {
|
|
@@ -329,6 +331,7 @@ function usePixelEditor({ initialWidth = 64, initialHeight = 64, onSaveToLibrary
|
|
|
329
331
|
}
|
|
330
332
|
// grid
|
|
331
333
|
if (grid && zoom >= 4) {
|
|
334
|
+
// audit-allow: literal-color — a faint light grid over the pixels, the same on every theme's canvas
|
|
332
335
|
ctx.strokeStyle = 'rgba(255,255,255,0.07)';
|
|
333
336
|
ctx.lineWidth = 1 / zoom;
|
|
334
337
|
for (let x = 0; x <= dw; x++) {
|
|
@@ -345,7 +348,7 @@ function usePixelEditor({ initialWidth = 64, initialHeight = 64, onSaveToLibrary
|
|
|
345
348
|
}
|
|
346
349
|
}
|
|
347
350
|
// border
|
|
348
|
-
ctx.strokeStyle = 'rgba(80,100,200,0.4)';
|
|
351
|
+
ctx.strokeStyle = resolveCssColor('var(--nice-primary-tint-40, rgba(80,100,200,0.4))', ctx.canvas);
|
|
349
352
|
ctx.lineWidth = 1 / zoom;
|
|
350
353
|
ctx.strokeRect(-0.5 / zoom, -0.5 / zoom, dw + 1 / zoom, dh + 1 / zoom);
|
|
351
354
|
// brush cursor preview
|
|
@@ -832,13 +835,12 @@ function usePixelEditor({ initialWidth = 64, initialHeight = 64, onSaveToLibrary
|
|
|
832
835
|
cv.height = dh;
|
|
833
836
|
cv.getContext('2d').putImageData(data, 0, 0);
|
|
834
837
|
const dataUrl = cv.toDataURL('image/png');
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
}
|
|
840
|
-
|
|
841
|
-
}, [onSaveToLibrary, afi, dw, dh, compFrame]);
|
|
838
|
+
void ask('prompt', 'Save to library as:', `sprite-${dw}x${dh}.png`).then((name) => {
|
|
839
|
+
if (name && name.trim()) {
|
|
840
|
+
onSaveToLibrary(dataUrl, name.trim(), 'image/png');
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
}, [onSaveToLibrary, afi, dw, dh, compFrame, ask]);
|
|
842
844
|
/* ── layer management ── */
|
|
843
845
|
const addLayer = useCallback(() => {
|
|
844
846
|
snap('Add Layer');
|
|
@@ -1272,6 +1274,7 @@ function usePixelEditor({ initialWidth = 64, initialHeight = 64, onSaveToLibrary
|
|
|
1272
1274
|
}, [fc, dw, dh, layers, tick]);
|
|
1273
1275
|
/* ── return API ── */
|
|
1274
1276
|
return {
|
|
1277
|
+
pendingAsk,
|
|
1275
1278
|
dw,
|
|
1276
1279
|
dh,
|
|
1277
1280
|
layers,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { resolveCssColor, NiceIcon } from '@nice2dev/ui-core';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { useNiceTranslation } from '../core/i18n.js';
|
|
4
5
|
|
|
5
6
|
// ── Default Config ──────────────────────────────────────────────
|
|
6
7
|
const DEFAULT_BRUSH = {
|
|
@@ -201,6 +202,7 @@ function useTexturePainter(width, height) {
|
|
|
201
202
|
// ── Component ───────────────────────────────────────────────────
|
|
202
203
|
/** 3D texture painting tool with UV-space brush painting, zoom/pan, and layers. */
|
|
203
204
|
const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSave, className = '', }) => {
|
|
205
|
+
const { t } = useNiceTranslation();
|
|
204
206
|
const painter = useTexturePainter(textureWidth, textureHeight);
|
|
205
207
|
const canvasRef = React.useRef(null);
|
|
206
208
|
const isPainting = React.useRef(false);
|
|
@@ -332,17 +334,17 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
332
334
|
color: 'var(--nice-text, #c1c2c5)',
|
|
333
335
|
padding: 12,
|
|
334
336
|
borderRadius: 8,
|
|
335
|
-
}, children: [jsxs("div", { style: { width: 140, fontSize: 11, display: 'flex', flexDirection: 'column', gap: 4 }, children: [jsx("strong", { style: { fontSize: 12 }, children:
|
|
337
|
+
}, children: [jsxs("div", { style: { width: 140, fontSize: 11, display: 'flex', flexDirection: 'column', gap: 4 }, children: [jsx("strong", { style: { fontSize: 12 }, children: t('texturePainter3d.tools', 'Tools') }), ['brush', 'eraser', 'eyedropper', 'fill'].map((t) => (jsxs("button", { onClick: () => painter.setTool(t), style: btnStyle(painter.tool === t), children: [jsx(NiceIcon, { name: toolIcons[t], size: 14 }), " ", t.charAt(0).toUpperCase() + t.slice(1), ' ', jsx("span", { style: { color: 'var(--nice-text-secondary, #868e96)', marginLeft: 'auto' }, children: t === 'brush' ? 'B' : t === 'eraser' ? 'E' : t === 'eyedropper' ? 'I' : 'G' })] }, t))), jsx("hr", { style: {
|
|
336
338
|
border: 'none',
|
|
337
339
|
borderTop: '1px solid var(--nice-border, #373a40)',
|
|
338
340
|
width: '100%',
|
|
339
341
|
margin: '4px 0',
|
|
340
|
-
} }), jsx("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: jsxs("button", { onClick: () => painter.undo(), style: btnStyle(false), title:
|
|
342
|
+
} }), jsx("div", { style: { display: 'flex', justifyContent: 'space-between' }, children: jsxs("button", { onClick: () => painter.undo(), style: btnStyle(false), title: t('texturePainter3d.undoCtrlZ', 'Undo (Ctrl+Z)'), children: [jsx(NiceIcon, { name: "reply", size: 14 }), " ", t('texturePainter3d.undo', 'Undo')] }) }), jsx("hr", { style: {
|
|
341
343
|
border: 'none',
|
|
342
344
|
borderTop: '1px solid var(--nice-border, #373a40)',
|
|
343
345
|
width: '100%',
|
|
344
346
|
margin: '4px 0',
|
|
345
|
-
} }), jsxs("label", { children: ["Size: ", painter.brush.size, "px"] }), 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%' } }), jsxs("label", { children: ["Opacity: ", 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%' } }), jsxs("label", { children: ["Hardness: ", 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:
|
|
347
|
+
} }), jsxs("label", { children: ["Size: ", painter.brush.size, "px"] }), 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%' } }), jsxs("label", { children: ["Opacity: ", 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%' } }), jsxs("label", { children: ["Hardness: ", 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({
|
|
346
348
|
...painter.brush,
|
|
347
349
|
blendMode: e.target.value,
|
|
348
350
|
}), style: {
|
|
@@ -353,12 +355,12 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
353
355
|
border: '1px solid var(--nice-border, #373a40)',
|
|
354
356
|
borderRadius: 3,
|
|
355
357
|
fontSize: 10,
|
|
356
|
-
}, children: [jsx("option", { value: "normal", children:
|
|
358
|
+
}, children: [jsx("option", { value: "normal", children: t('texturePainter3d.normal', 'Normal') }), jsx("option", { value: "multiply", children: t('texturePainter3d.multiply', 'Multiply') }), jsx("option", { value: "screen", children: t('texturePainter3d.screen', 'Screen') }), jsx("option", { value: "overlay", children: t('texturePainter3d.overlay', 'Overlay') })] }), jsx("label", { children: t('texturePainter3d.color', 'Color') }), jsxs("div", { style: { display: 'flex', gap: 4, alignItems: 'center' }, children: [jsx("input", { type: "color", value: painter.brush.color, onChange: (e) => painter.setBrush({ ...painter.brush, color: e.target.value }), style: { width: 32, height: 24, border: 'none', cursor: 'pointer' } }), jsx("span", { style: { fontFamily: 'monospace', fontSize: 10 }, children: painter.brush.color })] }), jsx("hr", { style: {
|
|
357
359
|
border: 'none',
|
|
358
360
|
borderTop: '1px solid var(--nice-border, #373a40)',
|
|
359
361
|
width: '100%',
|
|
360
362
|
margin: '4px 0',
|
|
361
|
-
} }), jsxs("label", { children: ["Zoom: ", 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:
|
|
363
|
+
} }), jsxs("label", { children: ["Zoom: ", 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: {
|
|
362
364
|
flex: 1,
|
|
363
365
|
overflow: 'hidden',
|
|
364
366
|
position: 'relative',
|
|
@@ -380,7 +382,7 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
380
382
|
color: 'var(--nice-text-secondary, #868e96)',
|
|
381
383
|
display: 'flex',
|
|
382
384
|
gap: 12,
|
|
383
|
-
}, children: [jsxs("span", { children: [textureWidth, "\u00D7", textureHeight] }), cursorPos && (jsxs("span", { children: ["X: ", cursorPos.x, " Y: ", cursorPos.y] })), jsxs("span", { children: ["Zoom: ", Math.round(zoom * 100), "%"] })] })] }), jsxs("div", { style: { width: 160, fontSize: 11, display: 'flex', flexDirection: 'column', gap: 4 }, children: [jsx("strong", { style: { fontSize: 12 }, children:
|
|
385
|
+
}, children: [jsxs("span", { children: [textureWidth, "\u00D7", textureHeight] }), cursorPos && (jsxs("span", { children: ["X: ", cursorPos.x, " Y: ", cursorPos.y] })), jsxs("span", { children: ["Zoom: ", 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: {
|
|
384
386
|
padding: '4px 6px',
|
|
385
387
|
borderRadius: 3,
|
|
386
388
|
background: painter.activeLayerId === l.id
|
|
@@ -416,7 +418,7 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
416
418
|
cursor: 'pointer',
|
|
417
419
|
padding: 0,
|
|
418
420
|
fontSize: 10,
|
|
419
|
-
}, "aria-label":
|
|
421
|
+
}, "aria-label": t('texturePainter3d.removeLayer', 'Remove layer'), title: t('texturePainter3d.removeLayer', 'Remove layer'), children: jsx(NiceIcon, { name: "close", size: 10 }) }))] }), jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4, marginTop: 2 }, children: [jsx("span", { style: { fontSize: 9, color: 'var(--nice-text-secondary, #868e96)' }, children: "\u03B1" }), jsx("input", { type: "range", min: 0, max: 1, step: 0.01, value: l.opacity, onChange: (e) => painter.setLayerOpacity(l.id, Number(e.target.value)), style: { flex: 1, height: 12 } }), jsxs("span", { style: { fontSize: 9, minWidth: 24, textAlign: 'right' }, children: [Math.round(l.opacity * 100), "%"] })] })] }, l.id))) }), jsx("button", { onClick: () => painter.addLayer(`Layer ${painter.layers.length + 1}`), style: {
|
|
420
422
|
padding: '4px 8px',
|
|
421
423
|
border: 'none',
|
|
422
424
|
borderRadius: 3,
|
|
@@ -436,7 +438,7 @@ const Nice3DTexturePainter = ({ textureWidth = 1024, textureHeight = 1024, onSav
|
|
|
436
438
|
borderRadius: 3,
|
|
437
439
|
cursor: 'pointer',
|
|
438
440
|
fontWeight: 'bold',
|
|
439
|
-
}, children:
|
|
441
|
+
}, children: t('texturePainter3d.saveTexture', 'Save Texture') })] })] }));
|
|
440
442
|
};
|
|
441
443
|
|
|
442
444
|
export { Nice3DTexturePainter, useTexturePainter };
|
|
@@ -2,6 +2,7 @@ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
|
2
2
|
import { NiceTutorialButton, resolveTutorial, NiceAppShell } 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
|
|
|
6
7
|
/** Built-in guided tour (EN inline + i18n keys → PL and other locales). */
|
|
7
8
|
const UI_DESIGNER_TOUR = [
|
|
@@ -310,6 +311,7 @@ function updateInTree(nodes, id, updates) {
|
|
|
310
311
|
/** Visual drag & drop UI builder that generates React code. */
|
|
311
312
|
const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
312
313
|
var _a, _b, _c, _d, _e;
|
|
314
|
+
const { t } = useNiceTranslation();
|
|
313
315
|
const designer = useUIDesigner();
|
|
314
316
|
const [breakpoint, setBreakpoint] = React.useState('desktop');
|
|
315
317
|
const [dragType, setDragType] = React.useState(null);
|
|
@@ -393,7 +395,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
393
395
|
color: 'var(--nice-text-secondary, #868e96)',
|
|
394
396
|
fontSize: 11,
|
|
395
397
|
gap: 4,
|
|
396
|
-
}, children: [jsx(NiceIcon, { name: "image", size: 14 }), " Image
|
|
398
|
+
}, children: [jsx(NiceIcon, { name: "image", size: 14 }), " ", t('uiDesigner.image', 'Image')] })) : node.type === 'List' ? (jsx("ul", { style: { margin: 0, ...node.style }, children: ((_d = node.props.items) !== null && _d !== void 0 ? _d : []).map((item, i) => (jsx("li", { children: item }, i))) })) : node.type === 'Divider' ? (jsx("hr", { style: {
|
|
397
399
|
margin: 0,
|
|
398
400
|
border: 'none',
|
|
399
401
|
borderTop: '1px solid var(--nice-border, #dee2e6)',
|
|
@@ -419,7 +421,9 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
419
421
|
display: 'flex',
|
|
420
422
|
alignItems: 'center',
|
|
421
423
|
gap: 4,
|
|
422
|
-
background: designer.selectedId === node.id
|
|
424
|
+
background: designer.selectedId === node.id
|
|
425
|
+
? 'color-mix(in srgb, var(--nice-color-primary, #339af0) 20%, transparent)'
|
|
426
|
+
: 'transparent',
|
|
423
427
|
borderRadius: 2,
|
|
424
428
|
}, children: [(def === null || def === void 0 ? void 0 : def.icon) && jsx(NiceIcon, { name: def.icon, size: 12 }), jsxs("span", { style: { flex: 1, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, children: [node.type, node.props.text ? `: ${String(node.props.text).slice(0, 15)}` : ''] })] }), node.children.map((c) => renderTreeItem(c, depth + 1))] }, node.id));
|
|
425
429
|
};
|
|
@@ -433,7 +437,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
433
437
|
height: '100%',
|
|
434
438
|
overflowY: 'auto',
|
|
435
439
|
boxSizing: 'border-box',
|
|
436
|
-
}, children: [jsxs("div", { children: [jsx("strong", { style: { fontSize: 12, display: 'block', marginBottom: 4 }, children:
|
|
440
|
+
}, children: [jsxs("div", { children: [jsx("strong", { style: { fontSize: 12, display: 'block', marginBottom: 4 }, children: t('uiDesigner.components', 'Components') }), jsx("div", { style: { display: 'flex', flexDirection: 'column', gap: 2 }, children: COMPONENT_DEFS.map((def) => (jsxs("button", { draggable: true, onDragStart: () => setDragType(def.type), onDragEnd: () => setDragType(null), onClick: () => { var _a; return designer.addNode(def.type, (_a = designer.selectedId) !== null && _a !== void 0 ? _a : undefined); }, style: {
|
|
437
441
|
display: 'flex',
|
|
438
442
|
alignItems: 'center',
|
|
439
443
|
gap: 4,
|
|
@@ -445,8 +449,8 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
445
449
|
cursor: 'grab',
|
|
446
450
|
textAlign: 'left',
|
|
447
451
|
fontSize: 11,
|
|
448
|
-
}, children: [jsx(NiceIcon, { name: def.icon, size: 14 }), " ", def.label] }, def.type))) })] }), jsxs("div", { children: [jsx("strong", { style: { fontSize: 12, display: 'block', marginBottom: 4 }, children:
|
|
449
|
-
const toolbarContent = (jsxs("div", { style: { display: 'flex', gap: 4, alignItems: 'center', fontSize: 11, padding: '4px 8px' }, children: [jsx("button", { onClick: () => designer.undo(), disabled: !designer.canUndo, style: { ...btnStyle(false), opacity: designer.canUndo ? 1 : 0.4 }, title:
|
|
452
|
+
}, children: [jsx(NiceIcon, { name: def.icon, size: 14 }), " ", def.label] }, def.type))) })] }), jsxs("div", { children: [jsx("strong", { style: { fontSize: 12, display: 'block', marginBottom: 4 }, children: t('uiDesigner.tree', 'Tree') }), jsx("div", { style: { maxHeight: 200, overflowY: 'auto' }, children: designer.tree.length === 0 ? (jsx("div", { style: { color: 'var(--nice-text-secondary, #5c5f66)', padding: 4 }, children: t('uiDesigner.empty', 'Empty') })) : (designer.tree.map((n) => renderTreeItem(n))) })] })] }));
|
|
453
|
+
const toolbarContent = (jsxs("div", { style: { display: 'flex', gap: 4, alignItems: 'center', fontSize: 11, padding: '4px 8px' }, children: [jsx("button", { onClick: () => designer.undo(), disabled: !designer.canUndo, style: { ...btnStyle(false), opacity: designer.canUndo ? 1 : 0.4 }, title: t('uiDesigner.undoCtrlZ', 'Undo (Ctrl+Z)'), "aria-label": t('uiDesigner.undo', 'Undo'), children: jsx(NiceIcon, { name: "reply", size: 14 }) }), jsx("button", { onClick: () => designer.redo(), disabled: !designer.canRedo, style: { ...btnStyle(false), opacity: designer.canRedo ? 1 : 0.4 }, title: t('uiDesigner.redoCtrlY', 'Redo (Ctrl+Y)'), "aria-label": t('uiDesigner.redo', 'Redo'), children: jsx(NiceIcon, { name: "forward", size: 14 }) }), jsx("div", { style: { width: 1, height: 16, background: 'var(--nice-border, #373a40)' } }), jsxs("button", { onClick: () => setBreakpoint('desktop'), style: btnStyle(breakpoint === 'desktop'), children: [jsx(NiceIcon, { name: "monitor", size: 14 }), " ", t('uiDesigner.desktop', 'Desktop')] }), jsxs("button", { onClick: () => setBreakpoint('tablet'), style: btnStyle(breakpoint === 'tablet'), children: [jsx(NiceIcon, { name: "window", size: 14 }), " ", t('uiDesigner.tablet', 'Tablet')] }), jsxs("button", { onClick: () => setBreakpoint('mobile'), style: btnStyle(breakpoint === 'mobile'), children: [jsx(NiceIcon, { name: "phone", size: 14 }), " ", t('uiDesigner.mobile', 'Mobile')] }), jsx("div", { style: { flex: 1 } }), designer.selectedId && (jsxs("button", { onClick: () => designer.removeNode(designer.selectedId), style: { ...btnStyle(false), color: 'var(--nice-danger, #ff6b6b)' }, children: [jsx(NiceIcon, { name: "trash", size: 14 }), " ", t('uiDesigner.delete', 'Delete')] })), jsxs("button", { onClick: () => setShowCode((v) => !v), style: btnStyle(showCode), children: ['</>', " ", t('uiDesigner.code', 'Code')] }), jsx("button", { onClick: () => onExport === null || onExport === void 0 ? void 0 : onExport(designer.exportCode()), style: {
|
|
450
454
|
padding: '4px 8px',
|
|
451
455
|
background: 'var(--nice-primary, #228be6)',
|
|
452
456
|
color: 'var(--nice-text-on-primary, #fff)',
|
|
@@ -454,7 +458,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
454
458
|
borderRadius: 3,
|
|
455
459
|
cursor: 'pointer',
|
|
456
460
|
fontSize: 11,
|
|
457
|
-
}, children:
|
|
461
|
+
}, children: t('uiDesigner.export', 'Export') })] }));
|
|
458
462
|
const mainContent = (jsx("div", { style: {
|
|
459
463
|
flex: 1,
|
|
460
464
|
display: 'flex',
|
|
@@ -470,7 +474,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
470
474
|
margin: 0,
|
|
471
475
|
overflow: 'auto',
|
|
472
476
|
fontSize: 11,
|
|
473
|
-
color: '#a6e3a1',
|
|
477
|
+
color: 'var(--nice-color-success, #a6e3a1)',
|
|
474
478
|
fontFamily: 'monospace',
|
|
475
479
|
}, children: designer.exportCode() })) : (jsx("div", { style: {
|
|
476
480
|
flex: 1,
|
|
@@ -487,7 +491,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
487
491
|
textAlign: 'center',
|
|
488
492
|
padding: 40,
|
|
489
493
|
color: 'var(--nice-text-secondary, #868e96)',
|
|
490
|
-
}, children:
|
|
494
|
+
}, children: t('uiDesigner.dragOrClickAComponent', 'Drag or click a component to add it') })) : (designer.tree.map((n) => renderNode(n))) })) }));
|
|
491
495
|
const rightPanel = (jsxs("div", { style: {
|
|
492
496
|
width: 200,
|
|
493
497
|
fontSize: 11,
|
|
@@ -498,7 +502,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
498
502
|
overflowY: 'auto',
|
|
499
503
|
padding: 8,
|
|
500
504
|
boxSizing: 'border-box',
|
|
501
|
-
}, children: [jsx("strong", { style: { fontSize: 12 }, children:
|
|
505
|
+
}, children: [jsx("strong", { style: { fontSize: 12 }, children: t('uiDesigner.properties', 'Properties') }), selectedNode ? (jsxs("div", { style: { display: 'flex', flexDirection: 'column', gap: 6 }, children: [jsxs("div", { style: {
|
|
502
506
|
color: 'var(--nice-text-secondary, #868e96)',
|
|
503
507
|
display: 'flex',
|
|
504
508
|
alignItems: 'center',
|
|
@@ -507,13 +511,13 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
507
511
|
var _a;
|
|
508
512
|
const di = (_a = COMPONENT_DEFS.find((d) => d.type === selectedNode.type)) === null || _a === void 0 ? void 0 : _a.icon;
|
|
509
513
|
return di ? jsx(NiceIcon, { name: di, size: 14 }) : null;
|
|
510
|
-
})(), ' ', selectedNode.type] }), selectedNode.props.text !== undefined && (jsxs("div", { children: [jsx("label", { children:
|
|
514
|
+
})(), ' ', selectedNode.type] }), selectedNode.props.text !== undefined && (jsxs("div", { children: [jsx("label", { children: t('uiDesigner.text', 'Text') }), jsx("input", { value: String(selectedNode.props.text), onChange: (e) => designer.updateNode(selectedNode.id, { props: { text: e.target.value } }), style: fieldStyle })] })), selectedNode.props.placeholder !== undefined && (jsxs("div", { children: [jsx("label", { children: t('uiDesigner.placeholder', 'Placeholder') }), jsx("input", { value: String(selectedNode.props.placeholder), onChange: (e) => designer.updateNode(selectedNode.id, { props: { placeholder: e.target.value } }), style: fieldStyle })] })), selectedNode.props.level !== undefined && (jsxs("div", { children: [jsx("label", { children: t('uiDesigner.headingLevel', 'Heading Level') }), jsx("select", { value: Number(selectedNode.props.level), onChange: (e) => designer.updateNode(selectedNode.id, {
|
|
511
515
|
props: { level: Number(e.target.value) },
|
|
512
|
-
}), style: fieldStyle, children: [1, 2, 3, 4, 5, 6].map((v) => (jsxs("option", { value: v, children: ["H", v] }, v))) })] })), selectedNode.props.variant !== undefined && (jsxs("div", { children: [jsx("label", { children:
|
|
516
|
+
}), style: fieldStyle, children: [1, 2, 3, 4, 5, 6].map((v) => (jsxs("option", { value: v, children: ["H", v] }, v))) })] })), selectedNode.props.variant !== undefined && (jsxs("div", { children: [jsx("label", { children: t('uiDesigner.variant', 'Variant') }), jsx("select", { value: String(selectedNode.props.variant), onChange: (e) => designer.updateNode(selectedNode.id, { props: { variant: e.target.value } }), style: fieldStyle, children: ['primary', 'secondary', 'outline', 'ghost'].map((v) => (jsx("option", { value: v, children: v }, v))) })] })), selectedNode.props.src !== undefined && (jsxs("div", { children: [jsx("label", { children: t('uiDesigner.imageUrl', 'Image URL') }), jsx("input", { value: String(selectedNode.props.src), onChange: (e) => designer.updateNode(selectedNode.id, { props: { src: e.target.value } }), style: fieldStyle })] })), selectedNode.props.alt !== undefined && (jsxs("div", { children: [jsx("label", { children: t('uiDesigner.altText', 'Alt Text') }), jsx("input", { value: String(selectedNode.props.alt), onChange: (e) => designer.updateNode(selectedNode.id, { props: { alt: e.target.value } }), style: fieldStyle })] })), jsx("hr", { style: {
|
|
513
517
|
border: 'none',
|
|
514
518
|
borderTop: '1px solid var(--nice-border, #373a40)',
|
|
515
519
|
margin: '4px 0',
|
|
516
|
-
} }), jsx("strong", { style: { color: 'var(--nice-text-secondary, #868e96)' }, children:
|
|
520
|
+
} }), jsx("strong", { style: { color: 'var(--nice-text-secondary, #868e96)' }, children: t('uiDesigner.style', 'Style') }), ['padding', 'margin', 'gap', 'borderRadius'].map((prop) => (jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: prop }), jsx("input", { type: "number", value: typeof selectedNode.style[prop] === 'number'
|
|
517
521
|
? selectedNode.style[prop]
|
|
518
522
|
: 0, onChange: (e) => designer.updateNode(selectedNode.id, {
|
|
519
523
|
style: { [prop]: Number(e.target.value) },
|
|
@@ -543,7 +547,7 @@ const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
|
|
|
543
547
|
color: 'var(--nice-text-secondary, #5c5f66)',
|
|
544
548
|
padding: 8,
|
|
545
549
|
textAlign: 'center',
|
|
546
|
-
}, children:
|
|
550
|
+
}, children: t('uiDesigner.selectAnElement', 'Select an element') }))] }));
|
|
547
551
|
return (jsxs("div", { className: `nice-ui-designer ${className}`, style: { position: 'relative', height: '100%' }, children: [jsx("span", { style: { position: 'absolute', top: 6, right: 6, zIndex: 20 }, children: jsx(NiceTutorialButton, { steps: resolveTutorial(tutorial, UI_DESIGNER_TOUR) }) }), jsx(NiceAppShell, { flush: true, toolbar: toolbarContent, sidebar: leftPanel, rightSidebar: rightPanel, children: mainContent })] }));
|
|
548
552
|
};
|
|
549
553
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { NiceIcon } from '@nice2dev/ui-core';
|
|
3
3
|
import React, { useState, useCallback } from 'react';
|
|
4
|
+
import { useNiceTranslation } from '../core/i18n.js';
|
|
4
5
|
|
|
5
6
|
/* ── Default config ── */
|
|
6
7
|
const DEFAULT_CONFIG = {
|
|
@@ -417,6 +418,7 @@ function useSvgToCode() {
|
|
|
417
418
|
}
|
|
418
419
|
/* ── Component ── */
|
|
419
420
|
const NiceSvgToCode = ({ initialSvg = '', onConvert, className = '', }) => {
|
|
421
|
+
const { t } = useNiceTranslation();
|
|
420
422
|
const { svgInput, setSvgInput, config, updateConfig, convert, result } = useSvgToCode();
|
|
421
423
|
// Initialize with provided SVG
|
|
422
424
|
React.useEffect(() => {
|
|
@@ -435,21 +437,21 @@ const NiceSvgToCode = ({ initialSvg = '', onConvert, className = '', }) => {
|
|
|
435
437
|
navigator.clipboard.writeText(result.code);
|
|
436
438
|
}
|
|
437
439
|
};
|
|
438
|
-
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 \u2192 Code"] }), jsx("textarea", { value: svgInput, onChange: (e) => setSvgInput(e.target.value), placeholder:
|
|
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 \u2192 Code"] }), jsx("textarea", { value: svgInput, onChange: (e) => setSvgInput(e.target.value), placeholder: t('svgToCode.pasteSvgMarkupHere', 'Paste SVG markup here…'), rows: 6, style: {
|
|
439
441
|
width: '100%',
|
|
440
442
|
fontFamily: 'monospace',
|
|
441
443
|
fontSize: 11,
|
|
442
444
|
padding: 6,
|
|
443
445
|
borderRadius: 4,
|
|
444
446
|
border: '1px solid var(--nice-border, #e2e8f0)',
|
|
445
|
-
} }), jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: ["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:
|
|
447
|
+
} }), jsxs("div", { style: { display: 'grid', gap: 4 }, children: [jsxs("label", { children: ["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: "TypeScript (utility)" })] })] }), jsxs("label", { children: ["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: {
|
|
446
448
|
background: 'var(--nice-color-accent, #6366f1)',
|
|
447
449
|
color: 'var(--nice-text-on-primary, #fff)',
|
|
448
450
|
border: 'none',
|
|
449
451
|
borderRadius: 4,
|
|
450
452
|
padding: '8px 12px',
|
|
451
453
|
cursor: 'pointer',
|
|
452
|
-
}, children: [jsx(NiceIcon, { name: "refresh", size: 14 }),
|
|
454
|
+
}, children: [jsx(NiceIcon, { name: "refresh", size: 14 }), ' ', t('svgToCode.convertTo', 'Convert to {framework}').replace('{framework}', config.framework.charAt(0).toUpperCase() + config.framework.slice(1))] }), result && (jsxs("div", { children: [jsxs("div", { style: {
|
|
453
455
|
display: 'flex',
|
|
454
456
|
justifyContent: 'space-between',
|
|
455
457
|
alignItems: 'center',
|
|
@@ -461,7 +463,7 @@ const NiceSvgToCode = ({ initialSvg = '', onConvert, className = '', }) => {
|
|
|
461
463
|
borderRadius: 3,
|
|
462
464
|
border: '1px solid var(--nice-border, #e2e8f0)',
|
|
463
465
|
background: 'transparent',
|
|
464
|
-
}, children: [jsx(NiceIcon, { name: "clipboard", size: 12 }), " Copy
|
|
466
|
+
}, children: [jsx(NiceIcon, { name: "clipboard", size: 12 }), " ", t('svgToCode.copy', 'Copy')] })] }), jsx("pre", { style: {
|
|
465
467
|
background: 'var(--nice-code-bg, #1e293b)',
|
|
466
468
|
color: 'var(--nice-code-color, #e2e8f0)',
|
|
467
469
|
padding: 8,
|
|
@@ -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,7 +110,7 @@ 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
|
}
|