@nice2dev/ui-graphics 1.3.15 → 1.3.17

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.
Files changed (294) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/animation/AnimatedPerson.js +470 -143
  3. package/dist/cjs/animation/AnimationEditor.js +289 -101
  4. package/dist/cjs/animation/Audience.js +83 -61
  5. package/dist/cjs/animation/BodyRenderer.js +69 -28
  6. package/dist/cjs/animation/animationHelper.js +281 -288
  7. package/dist/cjs/animation/characterTypes.js +200 -203
  8. package/dist/cjs/animation/choreoDSL.js +205 -219
  9. package/dist/cjs/animation/choreography.js +4 -32
  10. package/dist/cjs/animation/karaokeIntegration.js +68 -77
  11. package/dist/cjs/animation/lottieExport.js +108 -114
  12. package/dist/cjs/animation/motionPath.js +225 -248
  13. package/dist/cjs/animation/physics.js +227 -254
  14. package/dist/cjs/animation/rig/RigPlayer.js +53 -56
  15. package/dist/cjs/animation/rig/RiggedBody.js +71 -26
  16. package/dist/cjs/animation/rig/choreoRigBridge.js +72 -77
  17. package/dist/cjs/animation/rig/ik.js +13 -18
  18. package/dist/cjs/animation/rig/poseOps.js +34 -41
  19. package/dist/cjs/animation/rig/presets.js +64 -72
  20. package/dist/cjs/animation/rig/rigMath.js +25 -32
  21. package/dist/cjs/animation/rig/rigTypes.js +59 -63
  22. package/dist/cjs/animation/shapes/arms.js +31 -13
  23. package/dist/cjs/animation/shapes/eyes.js +129 -47
  24. package/dist/cjs/animation/shapes/hair.js +72 -45
  25. package/dist/cjs/animation/shapes/heads.js +131 -57
  26. package/dist/cjs/animation/shapes/headwear.js +47 -38
  27. package/dist/cjs/animation/shapes/legs.js +31 -13
  28. package/dist/cjs/animation/shapes/mouths.js +120 -44
  29. package/dist/cjs/animation/shapes/noses.js +80 -25
  30. package/dist/cjs/animation/shapes/outfits.js +101 -39
  31. package/dist/cjs/animation/shapes/torsos.js +15 -11
  32. package/dist/cjs/animation/spineExport.js +103 -121
  33. package/dist/cjs/core/LocalUI.js +108 -43
  34. package/dist/cjs/core/NiceBrushEngine.js +758 -552
  35. package/dist/cjs/core/collaboration.js +249 -251
  36. package/dist/cjs/core/colorBlindness.js +100 -115
  37. package/dist/cjs/core/dragDrop.js +155 -158
  38. package/dist/cjs/core/editorAsk.js +51 -41
  39. package/dist/cjs/core/fixes.js +140 -171
  40. package/dist/cjs/core/gridGuides.js +166 -201
  41. package/dist/cjs/core/historyVisual.js +156 -135
  42. package/dist/cjs/core/i18n.js +13 -14
  43. package/dist/cjs/core/integrations.js +238 -249
  44. package/dist/cjs/core/minimap.js +149 -151
  45. package/dist/cjs/core/plugins.js +98 -113
  46. package/dist/cjs/core/rtl.js +71 -83
  47. package/dist/cjs/core/shortcuts.js +196 -225
  48. package/dist/cjs/core/theme.js +142 -149
  49. package/dist/cjs/core/yjsCollaboration.js +232 -293
  50. package/dist/cjs/design/design-tools.js +12 -22
  51. package/dist/cjs/font/NiceFontEditor.js +877 -316
  52. package/dist/cjs/font/fontFormatUtils.js +388 -448
  53. package/dist/cjs/game/GameAsset2dEditor.js +1201 -392
  54. package/dist/cjs/game/GameAsset2dEditor.module.css.js +146 -5
  55. package/dist/cjs/game/gameAssetTypes.js +7 -16
  56. package/dist/cjs/game/gameAssetUtils.js +390 -413
  57. package/dist/cjs/game/useGameAssetEditor.js +820 -763
  58. package/dist/cjs/index.js +81 -84
  59. package/dist/cjs/nice2dev-ui-graphics.css +1 -1
  60. package/dist/cjs/node_modules/lib0/array.js +8 -70
  61. package/dist/cjs/node_modules/lib0/binary.js +3 -20
  62. package/dist/cjs/node_modules/lib0/broadcastchannel.js +24 -86
  63. package/dist/cjs/node_modules/lib0/buffer.js +15 -82
  64. package/dist/cjs/node_modules/lib0/conditions.js +3 -16
  65. package/dist/cjs/node_modules/lib0/decoding.js +108 -287
  66. package/dist/cjs/node_modules/lib0/dom.js +14 -44
  67. package/dist/cjs/node_modules/lib0/encoding.js +68 -418
  68. package/dist/cjs/node_modules/lib0/environment.js +26 -92
  69. package/dist/cjs/node_modules/lib0/error.js +5 -29
  70. package/dist/cjs/node_modules/lib0/function.js +27 -66
  71. package/dist/cjs/node_modules/lib0/iterator.js +8 -33
  72. package/dist/cjs/node_modules/lib0/logging.common.js +12 -22
  73. package/dist/cjs/node_modules/lib0/logging.js +32 -71
  74. package/dist/cjs/node_modules/lib0/map.js +16 -86
  75. package/dist/cjs/node_modules/lib0/math.js +3 -32
  76. package/dist/cjs/node_modules/lib0/number.js +4 -15
  77. package/dist/cjs/node_modules/lib0/object.js +14 -88
  78. package/dist/cjs/node_modules/lib0/observable.js +38 -78
  79. package/dist/cjs/node_modules/lib0/pair.js +3 -20
  80. package/dist/cjs/node_modules/lib0/prng.js +8 -77
  81. package/dist/cjs/node_modules/lib0/promise.js +6 -30
  82. package/dist/cjs/node_modules/lib0/random.js +8 -23
  83. package/dist/cjs/node_modules/lib0/schema.js +313 -687
  84. package/dist/cjs/node_modules/lib0/set.js +3 -10
  85. package/dist/cjs/node_modules/lib0/storage.js +20 -55
  86. package/dist/cjs/node_modules/lib0/string.js +17 -72
  87. package/dist/cjs/node_modules/lib0/symbol.js +2 -12
  88. package/dist/cjs/node_modules/lib0/time.js +2 -15
  89. package/dist/cjs/node_modules/lib0/trait/equality.js +3 -28
  90. package/dist/cjs/node_modules/lib0/url.js +4 -18
  91. package/dist/cjs/node_modules/lib0/webcrypto.js +2 -5
  92. package/dist/cjs/node_modules/y-protocols/auth.js +5 -19
  93. package/dist/cjs/node_modules/y-protocols/awareness.js +53 -116
  94. package/dist/cjs/node_modules/y-protocols/sync.js +16 -103
  95. package/dist/cjs/node_modules/y-websocket/src/y-websocket.js +77 -219
  96. package/dist/cjs/node_modules/yjs/dist/yjs.js +2128 -4868
  97. package/dist/cjs/photo/FilterThumb.js +37 -25
  98. package/dist/cjs/photo/NiceAITools.js +679 -467
  99. package/dist/cjs/photo/PhotoEditor.js +34 -20
  100. package/dist/cjs/photo/PhotoEditor.module.css.js +296 -5
  101. package/dist/cjs/photo/PhotoEditorCanvas.js +250 -91
  102. package/dist/cjs/photo/PhotoEditorLeftPanel.js +1086 -224
  103. package/dist/cjs/photo/PhotoEditorToolbar.js +135 -19
  104. package/dist/cjs/photo/photoEditorActions.js +89 -72
  105. package/dist/cjs/photo/photoEditorTypes.js +29 -32
  106. package/dist/cjs/photo/photoFilters.js +959 -985
  107. package/dist/cjs/photo/photoOverlays.js +899 -945
  108. package/dist/cjs/photo/photoSelection.js +427 -499
  109. package/dist/cjs/photo/usePhotoEditor.js +739 -741
  110. package/dist/cjs/pixel/HSVPicker.js +191 -175
  111. package/dist/cjs/pixel/PixelEditor.js +159 -48
  112. package/dist/cjs/pixel/PixelEditor.module.css.js +209 -5
  113. package/dist/cjs/pixel/PixelEditorCanvas.js +29 -16
  114. package/dist/cjs/pixel/PixelEditorMenuBar.js +160 -162
  115. package/dist/cjs/pixel/PixelEditorRightPanel.js +377 -45
  116. package/dist/cjs/pixel/PixelEditorStatusBar.js +47 -20
  117. package/dist/cjs/pixel/PixelEditorTimeline.js +106 -23
  118. package/dist/cjs/pixel/PixelEditorToolbar.js +99 -21
  119. package/dist/cjs/pixel/SpriteGeneratorPanel.js +483 -303
  120. package/dist/cjs/pixel/animalGeneratorPresets.js +776 -601
  121. package/dist/cjs/pixel/asepriteFormat.js +511 -560
  122. package/dist/cjs/pixel/buildingGeneratorPresets.js +693 -520
  123. package/dist/cjs/pixel/characterGeneratorPresets.js +644 -544
  124. package/dist/cjs/pixel/pixel-pro.js +52 -63
  125. package/dist/cjs/pixel/pixelEditorExports.js +388 -428
  126. package/dist/cjs/pixel/pixelEditorTypes.js +91 -108
  127. package/dist/cjs/pixel/pixelEditorUtils.js +519 -561
  128. package/dist/cjs/pixel/spriteGeneratorCore.js +206 -257
  129. package/dist/cjs/pixel/usePixelEditor.js +1321 -1343
  130. package/dist/cjs/texture/Nice3DTexturePainter.js +707 -440
  131. package/dist/cjs/ui/NiceUIDesigner.js +954 -527
  132. package/dist/cjs/vector/NiceSvgToCode.js +586 -446
  133. package/dist/cjs/vector/VectorEditor.js +290 -117
  134. package/dist/cjs/vector/VectorEditor.module.css.js +86 -5
  135. package/dist/cjs/vector/VectorEditorMenuBar.js +333 -275
  136. package/dist/cjs/vector/VectorEditorRightPanel.js +1094 -371
  137. package/dist/cjs/vector/VectorEditorShapeRenderer.js +198 -60
  138. package/dist/cjs/vector/VectorEditorStatusBar.js +39 -13
  139. package/dist/cjs/vector/useVectorEditor.js +848 -889
  140. package/dist/cjs/vector/vectorAnimation.js +110 -137
  141. package/dist/cjs/vector/vectorBooleanOps.js +398 -485
  142. package/dist/cjs/vector/vectorEditorExport.js +201 -203
  143. package/dist/cjs/vector/vectorEditorImport.js +173 -189
  144. package/dist/cjs/vector/vectorEditorTypes.js +42 -49
  145. package/dist/cjs/vector/vectorGradients.js +151 -174
  146. package/dist/cjs/vector/vectorIconExport.js +52 -59
  147. package/dist/cjs/vector/vectorIconImport.js +169 -219
  148. package/dist/esm/animation/AnimatedPerson.js +470 -141
  149. package/dist/esm/animation/AnimationEditor.js +290 -100
  150. package/dist/esm/animation/Audience.js +83 -59
  151. package/dist/esm/animation/BodyRenderer.js +71 -25
  152. package/dist/esm/animation/animationHelper.js +284 -287
  153. package/dist/esm/animation/characterTypes.js +204 -202
  154. package/dist/esm/animation/choreoDSL.js +212 -218
  155. package/dist/esm/animation/choreography.js +8 -31
  156. package/dist/esm/animation/karaokeIntegration.js +74 -76
  157. package/dist/esm/animation/lottieExport.js +112 -113
  158. package/dist/esm/animation/motionPath.js +235 -247
  159. package/dist/esm/animation/physics.js +235 -253
  160. package/dist/esm/animation/rig/RigPlayer.js +53 -54
  161. package/dist/esm/animation/rig/RiggedBody.js +71 -24
  162. package/dist/esm/animation/rig/choreoRigBridge.js +74 -76
  163. package/dist/esm/animation/rig/ik.js +14 -17
  164. package/dist/esm/animation/rig/poseOps.js +37 -40
  165. package/dist/esm/animation/rig/presets.js +70 -71
  166. package/dist/esm/animation/rig/rigMath.js +28 -31
  167. package/dist/esm/animation/rig/rigTypes.js +62 -62
  168. package/dist/esm/animation/shapes/arms.js +32 -12
  169. package/dist/esm/animation/shapes/eyes.js +135 -46
  170. package/dist/esm/animation/shapes/hair.js +80 -44
  171. package/dist/esm/animation/shapes/heads.js +140 -56
  172. package/dist/esm/animation/shapes/headwear.js +54 -37
  173. package/dist/esm/animation/shapes/legs.js +32 -12
  174. package/dist/esm/animation/shapes/mouths.js +127 -43
  175. package/dist/esm/animation/shapes/noses.js +87 -24
  176. package/dist/esm/animation/shapes/outfits.js +106 -38
  177. package/dist/esm/animation/shapes/torsos.js +16 -10
  178. package/dist/esm/animation/spineExport.js +106 -120
  179. package/dist/esm/core/LocalUI.js +111 -42
  180. package/dist/esm/core/NiceBrushEngine.js +761 -551
  181. package/dist/esm/core/collaboration.js +255 -250
  182. package/dist/esm/core/colorBlindness.js +106 -114
  183. package/dist/esm/core/dragDrop.js +157 -157
  184. package/dist/esm/core/editorAsk.js +53 -40
  185. package/dist/esm/core/fixes.js +145 -170
  186. package/dist/esm/core/gridGuides.js +178 -200
  187. package/dist/esm/core/historyVisual.js +158 -134
  188. package/dist/esm/core/i18n.js +15 -13
  189. package/dist/esm/core/integrations.js +244 -248
  190. package/dist/esm/core/minimap.js +151 -150
  191. package/dist/esm/core/plugins.js +102 -112
  192. package/dist/esm/core/rtl.js +77 -82
  193. package/dist/esm/core/shortcuts.js +200 -224
  194. package/dist/esm/core/theme.js +150 -148
  195. package/dist/esm/core/yjsCollaboration.js +240 -292
  196. package/dist/esm/design/design-tools.js +13 -21
  197. package/dist/esm/font/NiceFontEditor.js +880 -315
  198. package/dist/esm/font/fontFormatUtils.js +394 -447
  199. package/dist/esm/game/GameAsset2dEditor.js +1202 -391
  200. package/dist/esm/game/GameAsset2dEditor.module.css.js +146 -3
  201. package/dist/esm/game/gameAssetTypes.js +8 -15
  202. package/dist/esm/game/gameAssetUtils.js +408 -412
  203. package/dist/esm/game/useGameAssetEditor.js +821 -762
  204. package/dist/esm/index.js +332 -69
  205. package/dist/esm/nice2dev-ui-graphics.css +1 -1
  206. package/dist/esm/node_modules/lib0/array.js +15 -69
  207. package/dist/esm/node_modules/lib0/binary.js +14 -19
  208. package/dist/esm/node_modules/lib0/broadcastchannel.js +27 -85
  209. package/dist/esm/node_modules/lib0/buffer.js +20 -80
  210. package/dist/esm/node_modules/lib0/conditions.js +4 -15
  211. package/dist/esm/node_modules/lib0/decoding.js +128 -286
  212. package/dist/esm/node_modules/lib0/dom.js +20 -43
  213. package/dist/esm/node_modules/lib0/encoding.js +90 -415
  214. package/dist/esm/node_modules/lib0/environment.js +33 -91
  215. package/dist/esm/node_modules/lib0/error.js +8 -28
  216. package/dist/esm/node_modules/lib0/function.js +31 -65
  217. package/dist/esm/node_modules/lib0/iterator.js +11 -32
  218. package/dist/esm/node_modules/lib0/logging.common.js +22 -21
  219. package/dist/esm/node_modules/lib0/logging.js +44 -70
  220. package/dist/esm/node_modules/lib0/map.js +21 -85
  221. package/dist/esm/node_modules/lib0/math.js +9 -31
  222. package/dist/esm/node_modules/lib0/number.js +7 -14
  223. package/dist/esm/node_modules/lib0/object.js +26 -87
  224. package/dist/esm/node_modules/lib0/observable.js +40 -77
  225. package/dist/esm/node_modules/lib0/pair.js +5 -19
  226. package/dist/esm/node_modules/lib0/prng.js +15 -76
  227. package/dist/esm/node_modules/lib0/promise.js +7 -29
  228. package/dist/esm/node_modules/lib0/random.js +10 -22
  229. package/dist/esm/node_modules/lib0/schema.js +367 -686
  230. package/dist/esm/node_modules/lib0/set.js +4 -9
  231. package/dist/esm/node_modules/lib0/storage.js +23 -54
  232. package/dist/esm/node_modules/lib0/string.js +26 -71
  233. package/dist/esm/node_modules/lib0/symbol.js +3 -11
  234. package/dist/esm/node_modules/lib0/time.js +3 -14
  235. package/dist/esm/node_modules/lib0/trait/equality.js +5 -27
  236. package/dist/esm/node_modules/lib0/url.js +5 -17
  237. package/dist/esm/node_modules/lib0/webcrypto.js +3 -4
  238. package/dist/esm/node_modules/y-protocols/auth.js +7 -18
  239. package/dist/esm/node_modules/y-protocols/awareness.js +58 -115
  240. package/dist/esm/node_modules/y-protocols/sync.js +26 -102
  241. package/dist/esm/node_modules/y-websocket/src/y-websocket.js +82 -218
  242. package/dist/esm/node_modules/yjs/dist/yjs.js +2263 -4899
  243. package/dist/esm/photo/FilterThumb.js +37 -23
  244. package/dist/esm/photo/NiceAITools.js +685 -466
  245. package/dist/esm/photo/PhotoEditor.js +34 -18
  246. package/dist/esm/photo/PhotoEditor.module.css.js +296 -3
  247. package/dist/esm/photo/PhotoEditorCanvas.js +250 -89
  248. package/dist/esm/photo/PhotoEditorLeftPanel.js +1086 -222
  249. package/dist/esm/photo/PhotoEditorToolbar.js +135 -17
  250. package/dist/esm/photo/photoEditorActions.js +93 -71
  251. package/dist/esm/photo/photoEditorTypes.js +32 -31
  252. package/dist/esm/photo/photoFilters.js +967 -984
  253. package/dist/esm/photo/photoOverlays.js +913 -944
  254. package/dist/esm/photo/photoSelection.js +438 -498
  255. package/dist/esm/photo/usePhotoEditor.js +740 -740
  256. package/dist/esm/pixel/HSVPicker.js +192 -174
  257. package/dist/esm/pixel/PixelEditor.js +160 -47
  258. package/dist/esm/pixel/PixelEditor.module.css.js +209 -3
  259. package/dist/esm/pixel/PixelEditorCanvas.js +29 -14
  260. package/dist/esm/pixel/PixelEditorMenuBar.js +160 -160
  261. package/dist/esm/pixel/PixelEditorRightPanel.js +377 -43
  262. package/dist/esm/pixel/PixelEditorStatusBar.js +47 -18
  263. package/dist/esm/pixel/PixelEditorTimeline.js +106 -21
  264. package/dist/esm/pixel/PixelEditorToolbar.js +99 -19
  265. package/dist/esm/pixel/SpriteGeneratorPanel.js +483 -301
  266. package/dist/esm/pixel/animalGeneratorPresets.js +782 -600
  267. package/dist/esm/pixel/asepriteFormat.js +517 -559
  268. package/dist/esm/pixel/buildingGeneratorPresets.js +699 -519
  269. package/dist/esm/pixel/characterGeneratorPresets.js +650 -543
  270. package/dist/esm/pixel/pixel-pro.js +53 -62
  271. package/dist/esm/pixel/pixelEditorExports.js +397 -427
  272. package/dist/esm/pixel/pixelEditorTypes.js +103 -107
  273. package/dist/esm/pixel/pixelEditorUtils.js +551 -560
  274. package/dist/esm/pixel/spriteGeneratorCore.js +223 -256
  275. package/dist/esm/pixel/usePixelEditor.js +1322 -1342
  276. package/dist/esm/texture/Nice3DTexturePainter.js +709 -439
  277. package/dist/esm/ui/NiceUIDesigner.js +957 -526
  278. package/dist/esm/vector/NiceSvgToCode.js +589 -445
  279. package/dist/esm/vector/VectorEditor.js +291 -116
  280. package/dist/esm/vector/VectorEditor.module.css.js +86 -3
  281. package/dist/esm/vector/VectorEditorMenuBar.js +333 -273
  282. package/dist/esm/vector/VectorEditorRightPanel.js +1094 -369
  283. package/dist/esm/vector/VectorEditorShapeRenderer.js +199 -59
  284. package/dist/esm/vector/VectorEditorStatusBar.js +39 -11
  285. package/dist/esm/vector/useVectorEditor.js +849 -888
  286. package/dist/esm/vector/vectorAnimation.js +115 -136
  287. package/dist/esm/vector/vectorBooleanOps.js +401 -484
  288. package/dist/esm/vector/vectorEditorExport.js +207 -202
  289. package/dist/esm/vector/vectorEditorImport.js +174 -188
  290. package/dist/esm/vector/vectorEditorTypes.js +50 -48
  291. package/dist/esm/vector/vectorGradients.js +158 -173
  292. package/dist/esm/vector/vectorIconExport.js +53 -58
  293. package/dist/esm/vector/vectorIconImport.js +171 -218
  294. package/package.json +9 -15
@@ -1,554 +1,985 @@
1
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
- import { NiceTutorialButton, resolveTutorial, NiceAppShell } from '@nice2dev/ui';
3
- import { NiceIcon, clickOnActivationKey } from '@nice2dev/ui-core';
4
- import React from 'react';
5
- import { useNiceTranslation } from '../core/i18n.js';
6
-
7
- /** Built-in guided tour (EN inline + i18n keys → PL and other locales). */
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { NiceTutorialButton, resolveTutorial, NiceAppShell } from "@nice2dev/ui";
3
+ import { NiceIcon, clickOnActivationKey } from "@nice2dev/ui-core";
4
+ import React from "react";
5
+ import { useNiceTranslation } from "../core/i18n.js";
8
6
  const UI_DESIGNER_TOUR = [
9
- {
10
- target: '.nice-ui-designer',
11
- titleKey: 'tutorial.uiDesigner.intro.title',
12
- title: 'UI designer',
13
- contentKey: 'tutorial.uiDesigner.intro.content',
14
- content: 'Drag components from the palette onto the canvas, edit their props in the panel, preview responsive breakpoints, and export to React/TSX.',
15
- placement: 'auto',
16
- },
7
+ {
8
+ target: ".nice-ui-designer",
9
+ titleKey: "tutorial.uiDesigner.intro.title",
10
+ title: "UI designer",
11
+ contentKey: "tutorial.uiDesigner.intro.content",
12
+ content: "Drag components from the palette onto the canvas, edit their props in the panel, preview responsive breakpoints, and export to React/TSX.",
13
+ placement: "auto"
14
+ }
17
15
  ];
18
- // ── Component Palette ───────────────────────────────────────────
19
16
  const COMPONENT_DEFS = [
20
- {
21
- type: 'Container',
22
- label: 'Container',
23
- icon: 'box',
24
- defaultProps: {},
25
- defaultStyle: { padding: 16, display: 'flex', flexDirection: 'column', gap: 8 },
26
- allowChildren: true,
27
- },
28
- {
29
- type: 'Row',
30
- label: 'Row',
31
- icon: 'columns',
32
- defaultProps: {},
33
- defaultStyle: { display: 'flex', flexDirection: 'row', gap: 8, alignItems: 'center' },
34
- allowChildren: true,
35
- },
36
- {
37
- type: 'Column',
38
- label: 'Column',
39
- icon: 'list',
40
- defaultProps: {},
41
- defaultStyle: { display: 'flex', flexDirection: 'column', gap: 8 },
42
- allowChildren: true,
43
- },
44
- {
45
- type: 'Text',
46
- label: 'Text',
47
- icon: 'edit',
48
- defaultProps: { text: 'Text content' },
49
- defaultStyle: { fontSize: 14 },
50
- allowChildren: false,
51
- },
52
- {
53
- type: 'Heading',
54
- label: 'Heading',
55
- icon: 'heading',
56
- defaultProps: { text: 'Heading', level: 2 },
57
- defaultStyle: { fontSize: 24, fontWeight: 'bold' },
58
- allowChildren: false,
59
- },
60
- {
61
- type: 'Button',
62
- label: 'Button',
63
- icon: 'button',
64
- defaultProps: { text: 'Click me', variant: 'primary' },
65
- defaultStyle: { padding: '8px 16px', borderRadius: 4, cursor: 'pointer' },
66
- allowChildren: false,
67
- },
68
- {
69
- type: 'TextInput',
70
- label: 'Input',
71
- icon: 'input',
72
- defaultProps: { placeholder: 'Enter text...' },
73
- defaultStyle: { padding: 8, border: '1px solid var(--nice-border, #ccc)', borderRadius: 4 },
74
- allowChildren: false,
75
- },
76
- {
77
- type: 'Image',
78
- label: 'Image',
79
- icon: 'image',
80
- defaultProps: { src: '', alt: 'Image' },
81
- defaultStyle: { width: 200, height: 150, objectFit: 'cover' },
82
- allowChildren: false,
83
- },
84
- {
85
- type: 'Spacer',
86
- label: 'Spacer',
87
- icon: 'square',
88
- defaultProps: {},
89
- defaultStyle: { height: 16 },
90
- allowChildren: false,
91
- },
92
- {
93
- type: 'Divider',
94
- label: 'Divider',
95
- icon: 'line',
96
- defaultProps: {},
97
- defaultStyle: { height: 1, background: 'var(--nice-border, #dee2e6)', width: '100%' },
98
- allowChildren: false,
99
- },
100
- {
101
- type: 'Card',
102
- label: 'Card',
103
- icon: 'card',
104
- defaultProps: {},
105
- defaultStyle: {
106
- padding: 16,
107
- border: '1px solid var(--nice-border, #dee2e6)',
108
- borderRadius: 8,
109
- background: 'var(--nice-bg, #fff)',
110
- },
111
- allowChildren: true,
112
- },
113
- {
114
- type: 'List',
115
- label: 'List',
116
- icon: 'list',
117
- defaultProps: { items: ['Item 1', 'Item 2', 'Item 3'] },
118
- defaultStyle: { listStyleType: 'disc', paddingLeft: 20 },
119
- allowChildren: false,
17
+ {
18
+ type: "Container",
19
+ label: "Container",
20
+ icon: "box",
21
+ defaultProps: {},
22
+ defaultStyle: { padding: 16, display: "flex", flexDirection: "column", gap: 8 },
23
+ allowChildren: true
24
+ },
25
+ {
26
+ type: "Row",
27
+ label: "Row",
28
+ icon: "columns",
29
+ defaultProps: {},
30
+ defaultStyle: { display: "flex", flexDirection: "row", gap: 8, alignItems: "center" },
31
+ allowChildren: true
32
+ },
33
+ {
34
+ type: "Column",
35
+ label: "Column",
36
+ icon: "list",
37
+ defaultProps: {},
38
+ defaultStyle: { display: "flex", flexDirection: "column", gap: 8 },
39
+ allowChildren: true
40
+ },
41
+ {
42
+ type: "Text",
43
+ label: "Text",
44
+ icon: "edit",
45
+ defaultProps: { text: "Text content" },
46
+ defaultStyle: { fontSize: 14 },
47
+ allowChildren: false
48
+ },
49
+ {
50
+ type: "Heading",
51
+ label: "Heading",
52
+ icon: "heading",
53
+ defaultProps: { text: "Heading", level: 2 },
54
+ defaultStyle: { fontSize: 24, fontWeight: "bold" },
55
+ allowChildren: false
56
+ },
57
+ {
58
+ type: "Button",
59
+ label: "Button",
60
+ icon: "button",
61
+ defaultProps: { text: "Click me", variant: "primary" },
62
+ defaultStyle: { padding: "8px 16px", borderRadius: 4, cursor: "pointer" },
63
+ allowChildren: false
64
+ },
65
+ {
66
+ type: "TextInput",
67
+ label: "Input",
68
+ icon: "input",
69
+ defaultProps: { placeholder: "Enter text..." },
70
+ defaultStyle: { padding: 8, border: "1px solid var(--nice-border, #ccc)", borderRadius: 4 },
71
+ allowChildren: false
72
+ },
73
+ {
74
+ type: "Image",
75
+ label: "Image",
76
+ icon: "image",
77
+ defaultProps: { src: "", alt: "Image" },
78
+ defaultStyle: { width: 200, height: 150, objectFit: "cover" },
79
+ allowChildren: false
80
+ },
81
+ {
82
+ type: "Spacer",
83
+ label: "Spacer",
84
+ icon: "square",
85
+ defaultProps: {},
86
+ defaultStyle: { height: 16 },
87
+ allowChildren: false
88
+ },
89
+ {
90
+ type: "Divider",
91
+ label: "Divider",
92
+ icon: "line",
93
+ defaultProps: {},
94
+ defaultStyle: { height: 1, background: "var(--nice-border, #dee2e6)", width: "100%" },
95
+ allowChildren: false
96
+ },
97
+ {
98
+ type: "Card",
99
+ label: "Card",
100
+ icon: "card",
101
+ defaultProps: {},
102
+ defaultStyle: {
103
+ padding: 16,
104
+ border: "1px solid var(--nice-border, #dee2e6)",
105
+ borderRadius: 8,
106
+ background: "var(--nice-bg, #fff)"
120
107
  },
108
+ allowChildren: true
109
+ },
110
+ {
111
+ type: "List",
112
+ label: "List",
113
+ icon: "list",
114
+ defaultProps: { items: ["Item 1", "Item 2", "Item 3"] },
115
+ defaultStyle: { listStyleType: "disc", paddingLeft: 20 },
116
+ allowChildren: false
117
+ }
121
118
  ];
122
- // ── Code Generation ─────────────────────────────────────────────
123
119
  function nodeToJsx(node, indent = 2) {
124
- var _a, _b, _c;
125
- const pad = ' '.repeat(indent);
126
- const styleStr = Object.entries(node.style)
127
- .map(([k, v]) => `${k}: ${typeof v === 'string' ? `"${v}"` : v}`)
128
- .join(', ');
129
- switch (node.type) {
130
- case 'Text':
131
- return `${pad}<p style={{ ${styleStr} }}>${node.props.text}</p>`;
132
- case 'Heading':
133
- return `${pad}<h${(_a = node.props.level) !== null && _a !== void 0 ? _a : 2} style={{ ${styleStr} }}>${node.props.text}</h${(_b = node.props.level) !== null && _b !== void 0 ? _b : 2}>`;
134
- case 'Button':
135
- return `${pad}<button style={{ ${styleStr} }}>${node.props.text}</button>`;
136
- case 'TextInput':
137
- return `${pad}<input placeholder="${node.props.placeholder}" style={{ ${styleStr} }} />`;
138
- case 'Image':
139
- return `${pad}<img src="${node.props.src}" alt="${node.props.alt}" style={{ ${styleStr} }} />`;
140
- case 'Spacer':
141
- return `${pad}<div style={{ ${styleStr} }} />`;
142
- case 'Divider':
143
- return `${pad}<hr style={{ ${styleStr} }} />`;
144
- case 'List': {
145
- const items = (_c = node.props.items) !== null && _c !== void 0 ? _c : [];
146
- return `${pad}<ul style={{ ${styleStr} }}>\n${items.map((i) => `${pad} <li>${i}</li>`).join('\n')}\n${pad}</ul>`;
147
- }
148
- default: {
149
- const Tag = node.type === 'Card' ? 'div' : 'div';
150
- if (node.children.length === 0) {
151
- return `${pad}<${Tag} style={{ ${styleStr} }} />`;
152
- }
153
- const kids = node.children.map((c) => nodeToJsx(c, indent + 2)).join('\n');
154
- return `${pad}<${Tag} style={{ ${styleStr} }}>\n${kids}\n${pad}</${Tag}>`;
155
- }
120
+ const pad = " ".repeat(indent);
121
+ const styleStr = Object.entries(node.style).map(([k, v]) => `${k}: ${typeof v === "string" ? `"${v}"` : v}`).join(", ");
122
+ switch (node.type) {
123
+ case "Text":
124
+ return `${pad}<p style={{ ${styleStr} }}>${node.props.text}</p>`;
125
+ case "Heading":
126
+ return `${pad}<h${node.props.level ?? 2} style={{ ${styleStr} }}>${node.props.text}</h${node.props.level ?? 2}>`;
127
+ case "Button":
128
+ return `${pad}<button style={{ ${styleStr} }}>${node.props.text}</button>`;
129
+ case "TextInput":
130
+ return `${pad}<input placeholder="${node.props.placeholder}" style={{ ${styleStr} }} />`;
131
+ case "Image":
132
+ return `${pad}<img src="${node.props.src}" alt="${node.props.alt}" style={{ ${styleStr} }} />`;
133
+ case "Spacer":
134
+ return `${pad}<div style={{ ${styleStr} }} />`;
135
+ case "Divider":
136
+ return `${pad}<hr style={{ ${styleStr} }} />`;
137
+ case "List": {
138
+ const items = node.props.items ?? [];
139
+ return `${pad}<ul style={{ ${styleStr} }}>
140
+ ${items.map((i) => `${pad} <li>${i}</li>`).join("\n")}
141
+ ${pad}</ul>`;
156
142
  }
143
+ default: {
144
+ const Tag = node.type === "Card" ? "div" : "div";
145
+ if (node.children.length === 0) {
146
+ return `${pad}<${Tag} style={{ ${styleStr} }} />`;
147
+ }
148
+ const kids = node.children.map((c) => nodeToJsx(c, indent + 2)).join("\n");
149
+ return `${pad}<${Tag} style={{ ${styleStr} }}>
150
+ ${kids}
151
+ ${pad}</${Tag}>`;
152
+ }
153
+ }
157
154
  }
158
- function exportToReact(tree, componentName = 'MyComponent') {
159
- const body = tree.map((n) => nodeToJsx(n, 4)).join('\n');
160
- return `import React from "react";\n\nexport const ${componentName}: React.FC = () => {\n return (\n <div>\n${body}\n </div>\n );\n};\n`;
155
+ function exportToReact(tree, componentName = "MyComponent") {
156
+ const body = tree.map((n) => nodeToJsx(n, 4)).join("\n");
157
+ return `import React from "react";
158
+
159
+ export const ${componentName}: React.FC = () => {
160
+ return (
161
+ <div>
162
+ ${body}
163
+ </div>
164
+ );
165
+ };
166
+ `;
161
167
  }
162
- // ── Hook ────────────────────────────────────────────────────────
163
168
  function useUIDesigner() {
164
- const [tree, setTree] = React.useState([]);
165
- const [selectedId, setSelectedId] = React.useState(null);
166
- const historyRef = React.useRef([[]]);
167
- const [historyIdx, setHistoryIdx] = React.useState(0);
168
- const pushHistory = React.useCallback((newTree) => {
169
- const next = historyRef.current.slice(0, historyIdx + 1);
170
- next.push(JSON.parse(JSON.stringify(newTree)));
171
- if (next.length > 40) {
172
- next.shift();
173
- }
174
- historyRef.current = next;
175
- setHistoryIdx(next.length - 1);
176
- }, [historyIdx]);
177
- const undo = React.useCallback(() => {
178
- if (historyIdx <= 0) {
179
- return;
180
- }
181
- const newIdx = historyIdx - 1;
182
- setHistoryIdx(newIdx);
183
- setTree(JSON.parse(JSON.stringify(historyRef.current[newIdx])));
184
- }, [historyIdx]);
185
- const redo = React.useCallback(() => {
186
- if (historyIdx >= historyRef.current.length - 1) {
187
- return;
188
- }
189
- const newIdx = historyIdx + 1;
190
- setHistoryIdx(newIdx);
191
- setTree(JSON.parse(JSON.stringify(historyRef.current[newIdx])));
192
- }, [historyIdx]);
193
- const addNode = React.useCallback((type, parentId) => {
194
- const def = COMPONENT_DEFS.find((d) => d.type === type);
195
- if (!def) {
196
- return;
197
- }
198
- const node = {
199
- id: `node-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
200
- type,
201
- props: { ...def.defaultProps },
202
- children: [],
203
- style: { ...def.defaultStyle },
204
- };
205
- let newTree;
206
- if (parentId) {
207
- newTree = addToParent(tree, parentId, node);
208
- }
209
- else {
210
- newTree = [...tree, node];
211
- }
212
- setTree(newTree);
213
- pushHistory(newTree);
214
- setSelectedId(node.id);
215
- }, [tree, pushHistory]);
216
- const removeNode = React.useCallback((id) => {
217
- const newTree = removeFromTree(tree, id);
218
- setTree(newTree);
219
- pushHistory(newTree);
220
- if (selectedId === id) {
221
- setSelectedId(null);
222
- }
223
- }, [tree, selectedId, pushHistory]);
224
- const updateNode = React.useCallback((id, updates) => {
225
- const newTree = updateInTree(tree, id, updates);
226
- setTree(newTree);
227
- pushHistory(newTree);
228
- }, [tree, pushHistory]);
229
- const moveNode = React.useCallback((id, newParentId, index) => {
230
- // Find the node, remove it from current position, insert at new position
231
- const node = findInTree(tree, id);
232
- if (!node) {
233
- return;
234
- }
235
- let newTree = removeFromTree(tree, id);
236
- if (newParentId) {
237
- newTree = addToParent(newTree, newParentId, node, index);
238
- }
239
- else {
240
- if (index !== undefined) {
241
- newTree = [...newTree.slice(0, index), node, ...newTree.slice(index)];
242
- }
243
- else {
244
- newTree = [...newTree, node];
245
- }
169
+ const [tree, setTree] = React.useState([]);
170
+ const [selectedId, setSelectedId] = React.useState(null);
171
+ const historyRef = React.useRef([[]]);
172
+ const [historyIdx, setHistoryIdx] = React.useState(0);
173
+ const pushHistory = React.useCallback(
174
+ (newTree) => {
175
+ const next = historyRef.current.slice(0, historyIdx + 1);
176
+ next.push(JSON.parse(JSON.stringify(newTree)));
177
+ if (next.length > 40) {
178
+ next.shift();
179
+ }
180
+ historyRef.current = next;
181
+ setHistoryIdx(next.length - 1);
182
+ },
183
+ [historyIdx]
184
+ );
185
+ const undo = React.useCallback(() => {
186
+ if (historyIdx <= 0) {
187
+ return;
188
+ }
189
+ const newIdx = historyIdx - 1;
190
+ setHistoryIdx(newIdx);
191
+ setTree(JSON.parse(JSON.stringify(historyRef.current[newIdx])));
192
+ }, [historyIdx]);
193
+ const redo = React.useCallback(() => {
194
+ if (historyIdx >= historyRef.current.length - 1) {
195
+ return;
196
+ }
197
+ const newIdx = historyIdx + 1;
198
+ setHistoryIdx(newIdx);
199
+ setTree(JSON.parse(JSON.stringify(historyRef.current[newIdx])));
200
+ }, [historyIdx]);
201
+ const addNode = React.useCallback(
202
+ (type, parentId) => {
203
+ const def = COMPONENT_DEFS.find((d) => d.type === type);
204
+ if (!def) {
205
+ return;
206
+ }
207
+ const node = {
208
+ id: `node-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
209
+ type,
210
+ props: { ...def.defaultProps },
211
+ children: [],
212
+ style: { ...def.defaultStyle }
213
+ };
214
+ let newTree;
215
+ if (parentId) {
216
+ newTree = addToParent(tree, parentId, node);
217
+ } else {
218
+ newTree = [...tree, node];
219
+ }
220
+ setTree(newTree);
221
+ pushHistory(newTree);
222
+ setSelectedId(node.id);
223
+ },
224
+ [tree, pushHistory]
225
+ );
226
+ const removeNode = React.useCallback(
227
+ (id) => {
228
+ const newTree = removeFromTree(tree, id);
229
+ setTree(newTree);
230
+ pushHistory(newTree);
231
+ if (selectedId === id) {
232
+ setSelectedId(null);
233
+ }
234
+ },
235
+ [tree, selectedId, pushHistory]
236
+ );
237
+ const updateNode = React.useCallback(
238
+ (id, updates) => {
239
+ const newTree = updateInTree(tree, id, updates);
240
+ setTree(newTree);
241
+ pushHistory(newTree);
242
+ },
243
+ [tree, pushHistory]
244
+ );
245
+ const moveNode = React.useCallback(
246
+ (id, newParentId, index) => {
247
+ const node = findInTree(tree, id);
248
+ if (!node) {
249
+ return;
250
+ }
251
+ let newTree = removeFromTree(tree, id);
252
+ if (newParentId) {
253
+ newTree = addToParent(newTree, newParentId, node, index);
254
+ } else {
255
+ if (index !== void 0) {
256
+ newTree = [...newTree.slice(0, index), node, ...newTree.slice(index)];
257
+ } else {
258
+ newTree = [...newTree, node];
246
259
  }
247
- setTree(newTree);
248
- pushHistory(newTree);
249
- }, [tree, pushHistory]);
250
- return {
251
- tree,
252
- setTree,
253
- selectedId,
254
- setSelectedId,
255
- addNode,
256
- removeNode,
257
- updateNode,
258
- moveNode,
259
- exportCode: () => exportToReact(tree),
260
- undo,
261
- redo,
262
- canUndo: historyIdx > 0,
263
- canRedo: historyIdx < historyRef.current.length - 1,
264
- };
260
+ }
261
+ setTree(newTree);
262
+ pushHistory(newTree);
263
+ },
264
+ [tree, pushHistory]
265
+ );
266
+ return {
267
+ tree,
268
+ setTree,
269
+ selectedId,
270
+ setSelectedId,
271
+ addNode,
272
+ removeNode,
273
+ updateNode,
274
+ moveNode,
275
+ exportCode: () => exportToReact(tree),
276
+ undo,
277
+ redo,
278
+ canUndo: historyIdx > 0,
279
+ canRedo: historyIdx < historyRef.current.length - 1
280
+ };
265
281
  }
266
282
  function addToParent(nodes, parentId, child, index) {
267
- return nodes.map((n) => {
268
- if (n.id === parentId) {
269
- const kids = [...n.children];
270
- if (index !== undefined) {
271
- kids.splice(index, 0, child);
272
- }
273
- else {
274
- kids.push(child);
275
- }
276
- return { ...n, children: kids };
277
- }
278
- return { ...n, children: addToParent(n.children, parentId, child, index) };
279
- });
283
+ return nodes.map((n) => {
284
+ if (n.id === parentId) {
285
+ const kids = [...n.children];
286
+ if (index !== void 0) {
287
+ kids.splice(index, 0, child);
288
+ } else {
289
+ kids.push(child);
290
+ }
291
+ return { ...n, children: kids };
292
+ }
293
+ return { ...n, children: addToParent(n.children, parentId, child, index) };
294
+ });
280
295
  }
281
296
  function removeFromTree(nodes, id) {
282
- return nodes
283
- .filter((n) => n.id !== id)
284
- .map((n) => ({ ...n, children: removeFromTree(n.children, id) }));
297
+ return nodes.filter((n) => n.id !== id).map((n) => ({ ...n, children: removeFromTree(n.children, id) }));
285
298
  }
286
299
  function findInTree(nodes, id) {
287
- for (const n of nodes) {
288
- if (n.id === id) {
289
- return n;
290
- }
291
- const found = findInTree(n.children, id);
292
- if (found) {
293
- return found;
294
- }
300
+ for (const n of nodes) {
301
+ if (n.id === id) {
302
+ return n;
303
+ }
304
+ const found = findInTree(n.children, id);
305
+ if (found) {
306
+ return found;
295
307
  }
296
- return null;
308
+ }
309
+ return null;
297
310
  }
298
311
  function updateInTree(nodes, id, updates) {
299
- return nodes.map((n) => {
300
- if (n.id === id) {
301
- return {
302
- ...n,
303
- props: updates.props ? { ...n.props, ...updates.props } : n.props,
304
- style: updates.style ? { ...n.style, ...updates.style } : n.style,
305
- };
306
- }
307
- return { ...n, children: updateInTree(n.children, id, updates) };
308
- });
312
+ return nodes.map((n) => {
313
+ if (n.id === id) {
314
+ return {
315
+ ...n,
316
+ props: updates.props ? { ...n.props, ...updates.props } : n.props,
317
+ style: updates.style ? { ...n.style, ...updates.style } : n.style
318
+ };
319
+ }
320
+ return { ...n, children: updateInTree(n.children, id, updates) };
321
+ });
309
322
  }
310
- // ── Component ───────────────────────────────────────────────────
311
- /** Visual drag & drop UI builder that generates React code. */
312
- const NiceUIDesigner = ({ onChange, onExport, className = '', tutorial, }) => {
313
- var _a, _b, _c, _d, _e;
314
- const { t } = useNiceTranslation();
315
- const designer = useUIDesigner();
316
- const [breakpoint, setBreakpoint] = React.useState('desktop');
317
- const [dragType, setDragType] = React.useState(null);
318
- const [showCode, setShowCode] = React.useState(false);
319
- React.useEffect(() => {
320
- onChange === null || onChange === void 0 ? void 0 : onChange(designer.tree);
321
- }, [designer.tree, onChange]);
322
- // Keyboard shortcuts
323
- React.useEffect(() => {
324
- const handler = (e) => {
325
- if (e.ctrlKey && e.key === 'z') {
326
- e.preventDefault();
327
- designer.undo();
323
+ const NiceUIDesigner = ({
324
+ onChange,
325
+ onExport,
326
+ className = "",
327
+ tutorial
328
+ }) => {
329
+ const { t } = useNiceTranslation();
330
+ const designer = useUIDesigner();
331
+ const [breakpoint, setBreakpoint] = React.useState("desktop");
332
+ const [dragType, setDragType] = React.useState(null);
333
+ const [showCode, setShowCode] = React.useState(false);
334
+ React.useEffect(() => {
335
+ onChange?.(designer.tree);
336
+ }, [designer.tree, onChange]);
337
+ React.useEffect(() => {
338
+ const handler = (e) => {
339
+ if (e.ctrlKey && e.key === "z") {
340
+ e.preventDefault();
341
+ designer.undo();
342
+ }
343
+ if (e.ctrlKey && e.key === "y") {
344
+ e.preventDefault();
345
+ designer.redo();
346
+ }
347
+ if (e.key === "Delete" && designer.selectedId) {
348
+ designer.removeNode(designer.selectedId);
349
+ }
350
+ };
351
+ window.addEventListener("keydown", handler);
352
+ return () => window.removeEventListener("keydown", handler);
353
+ }, [designer]);
354
+ const canvasWidth = breakpoint === "mobile" ? 375 : breakpoint === "tablet" ? 768 : "100%";
355
+ const selectedNode = designer.selectedId ? findInTree(designer.tree, designer.selectedId) : null;
356
+ const btnStyle = (active) => ({
357
+ padding: "4px 8px",
358
+ border: "none",
359
+ borderRadius: 3,
360
+ cursor: "pointer",
361
+ fontSize: 11,
362
+ background: active ? "var(--nice-info, #339af0)" : "var(--nice-bg-secondary, #2c2e33)",
363
+ color: active ? "var(--nice-color-white, #fff)" : "var(--nice-text, #c1c2c5)"
364
+ });
365
+ const fieldStyle = {
366
+ width: "100%",
367
+ padding: "2px 4px",
368
+ background: "var(--nice-bg-secondary, #2c2e33)",
369
+ color: "var(--nice-text, #c1c2c5)",
370
+ border: "1px solid var(--nice-border, #373a40)",
371
+ borderRadius: 3,
372
+ fontSize: 10
373
+ };
374
+ const handleDrop = (e, parentId) => {
375
+ e.preventDefault();
376
+ e.stopPropagation();
377
+ if (dragType) {
378
+ designer.addNode(dragType, parentId);
379
+ setDragType(null);
380
+ }
381
+ };
382
+ const handleDragOver = (e) => {
383
+ e.preventDefault();
384
+ e.stopPropagation();
385
+ };
386
+ const renderNode = (node, depth = 0) => {
387
+ const isSelected = designer.selectedId === node.id;
388
+ const def = COMPONENT_DEFS.find((d) => d.type === node.type);
389
+ return /* @__PURE__ */ jsxs(
390
+ "div",
391
+ {
392
+ role: "presentation",
393
+ onClick: (e) => {
394
+ e.stopPropagation();
395
+ designer.setSelectedId(node.id);
396
+ },
397
+ onDrop: (e) => def?.allowChildren ? handleDrop(e, node.id) : void 0,
398
+ onDragOver: def?.allowChildren ? handleDragOver : void 0,
399
+ style: {
400
+ ...node.style,
401
+ outline: isSelected ? "2px solid var(--nice-info, #339af0)" : "1px dashed var(--nice-overlay-10, rgba(0, 0, 0, 0.1))",
402
+ outlineOffset: 1,
403
+ minHeight: 24,
404
+ position: "relative",
405
+ cursor: "pointer"
406
+ },
407
+ children: [
408
+ node.type === "Text" || node.type === "Heading" ? String(node.props.text ?? "") : node.type === "Button" ? /* @__PURE__ */ jsx("button", { style: { pointerEvents: "none" }, children: String(node.props.text ?? "Button") }) : node.type === "TextInput" ? /* @__PURE__ */ jsx(
409
+ "input",
410
+ {
411
+ placeholder: String(node.props.placeholder ?? ""),
412
+ readOnly: true,
413
+ style: { pointerEvents: "none", ...node.style }
328
414
  }
329
- if (e.ctrlKey && e.key === 'y') {
330
- e.preventDefault();
331
- designer.redo();
415
+ ) : node.type === "Image" ? /* @__PURE__ */ jsxs(
416
+ "div",
417
+ {
418
+ style: {
419
+ width: "100%",
420
+ height: "100%",
421
+ background: "var(--nice-border, #e9ecef)",
422
+ display: "flex",
423
+ alignItems: "center",
424
+ justifyContent: "center",
425
+ color: "var(--nice-text-secondary, #868e96)",
426
+ fontSize: 11,
427
+ gap: 4
428
+ },
429
+ children: [
430
+ /* @__PURE__ */ jsx(NiceIcon, { name: "image", size: 14 }),
431
+ " ",
432
+ t("uiDesigner.image", "Image")
433
+ ]
332
434
  }
333
- if (e.key === 'Delete' && designer.selectedId) {
334
- designer.removeNode(designer.selectedId);
435
+ ) : node.type === "List" ? /* @__PURE__ */ jsx("ul", { style: { margin: 0, ...node.style }, children: (node.props.items ?? []).map((item, i) => /* @__PURE__ */ jsx("li", { children: item }, i)) }) : node.type === "Divider" ? /* @__PURE__ */ jsx(
436
+ "hr",
437
+ {
438
+ style: {
439
+ margin: 0,
440
+ border: "none",
441
+ borderTop: "1px solid var(--nice-border, #dee2e6)",
442
+ width: "100%"
443
+ }
335
444
  }
336
- };
337
- window.addEventListener('keydown', handler);
338
- return () => window.removeEventListener('keydown', handler);
339
- }, [designer]);
340
- const canvasWidth = breakpoint === 'mobile' ? 375 : breakpoint === 'tablet' ? 768 : '100%';
341
- const selectedNode = designer.selectedId ? findInTree(designer.tree, designer.selectedId) : null;
342
- const btnStyle = (active) => ({
343
- padding: '4px 8px',
344
- border: 'none',
345
- borderRadius: 3,
346
- cursor: 'pointer',
347
- fontSize: 11,
348
- background: active ? 'var(--nice-info, #339af0)' : 'var(--nice-bg-secondary, #2c2e33)',
349
- color: active ? 'var(--nice-color-white, #fff)' : 'var(--nice-text, #c1c2c5)',
350
- });
351
- const fieldStyle = {
352
- width: '100%',
353
- padding: '2px 4px',
354
- background: 'var(--nice-bg-secondary, #2c2e33)',
355
- color: 'var(--nice-text, #c1c2c5)',
356
- border: '1px solid var(--nice-border, #373a40)',
357
- borderRadius: 3,
358
- fontSize: 10,
359
- };
360
- const handleDrop = (e, parentId) => {
361
- e.preventDefault();
362
- e.stopPropagation();
363
- if (dragType) {
364
- designer.addNode(dragType, parentId);
365
- setDragType(null);
445
+ ) : node.children.map((c) => renderNode(c, depth + 1)),
446
+ isSelected && /* @__PURE__ */ jsx(
447
+ "div",
448
+ {
449
+ style: {
450
+ position: "absolute",
451
+ top: -12,
452
+ left: 0,
453
+ fontSize: 9,
454
+ background: "var(--nice-info, #339af0)",
455
+ color: "var(--nice-text-on-primary, #fff)",
456
+ padding: "0 4px",
457
+ borderRadius: "2px 2px 0 0"
458
+ },
459
+ children: node.type
460
+ }
461
+ )
462
+ ]
463
+ },
464
+ node.id
465
+ );
466
+ };
467
+ const renderTreeItem = (node, depth = 0) => {
468
+ const def = COMPONENT_DEFS.find((d) => d.type === node.type);
469
+ return /* @__PURE__ */ jsxs(React.Fragment, { children: [
470
+ /* @__PURE__ */ jsxs(
471
+ "div",
472
+ {
473
+ role: "button",
474
+ tabIndex: 0,
475
+ onKeyDown: clickOnActivationKey,
476
+ onClick: () => designer.setSelectedId(node.id),
477
+ style: {
478
+ padding: "2px 4px",
479
+ paddingLeft: 4 + depth * 12,
480
+ fontSize: 10,
481
+ cursor: "pointer",
482
+ display: "flex",
483
+ alignItems: "center",
484
+ gap: 4,
485
+ background: designer.selectedId === node.id ? "color-mix(in srgb, var(--nice-color-primary, #339af0) 20%, transparent)" : "transparent",
486
+ borderRadius: 2
487
+ },
488
+ children: [
489
+ def?.icon && /* @__PURE__ */ jsx(NiceIcon, { name: def.icon, size: 12 }),
490
+ /* @__PURE__ */ jsxs(
491
+ "span",
492
+ {
493
+ style: { flex: 1, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" },
494
+ children: [
495
+ node.type,
496
+ node.props.text ? `: ${String(node.props.text).slice(0, 15)}` : ""
497
+ ]
498
+ }
499
+ )
500
+ ]
366
501
  }
367
- };
368
- const handleDragOver = (e) => {
369
- e.preventDefault();
370
- e.stopPropagation();
371
- };
372
- const renderNode = (node, depth = 0) => {
373
- var _a, _b, _c, _d;
374
- const isSelected = designer.selectedId === node.id;
375
- const def = COMPONENT_DEFS.find((d) => d.type === node.type);
376
- return (jsxs("div", { role: "presentation", onClick: (e) => {
377
- e.stopPropagation();
378
- designer.setSelectedId(node.id);
379
- }, onDrop: (e) => ((def === null || def === void 0 ? void 0 : def.allowChildren) ? handleDrop(e, node.id) : undefined), onDragOver: (def === null || def === void 0 ? void 0 : def.allowChildren) ? handleDragOver : undefined, style: {
380
- ...node.style,
381
- outline: isSelected
382
- ? '2px solid var(--nice-info, #339af0)'
383
- : '1px dashed var(--nice-overlay-10, rgba(0, 0, 0, 0.1))',
384
- outlineOffset: 1,
385
- minHeight: 24,
386
- position: 'relative',
387
- cursor: 'pointer',
388
- }, children: [node.type === 'Text' || node.type === 'Heading' ? (String((_a = node.props.text) !== null && _a !== void 0 ? _a : '')) : node.type === 'Button' ? (jsx("button", { style: { pointerEvents: 'none' }, children: String((_b = node.props.text) !== null && _b !== void 0 ? _b : 'Button') })) : node.type === 'TextInput' ? (jsx("input", { placeholder: String((_c = node.props.placeholder) !== null && _c !== void 0 ? _c : ''), readOnly: true, style: { pointerEvents: 'none', ...node.style } })) : node.type === 'Image' ? (jsxs("div", { style: {
389
- width: '100%',
390
- height: '100%',
391
- background: 'var(--nice-border, #e9ecef)',
392
- display: 'flex',
393
- alignItems: 'center',
394
- justifyContent: 'center',
395
- color: 'var(--nice-text-secondary, #868e96)',
396
- fontSize: 11,
397
- gap: 4,
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: {
399
- margin: 0,
400
- border: 'none',
401
- borderTop: '1px solid var(--nice-border, #dee2e6)',
402
- width: '100%',
403
- } })) : (node.children.map((c) => renderNode(c, depth + 1))), isSelected && (jsx("div", { style: {
404
- position: 'absolute',
405
- top: -12,
406
- left: 0,
407
- fontSize: 9,
408
- background: 'var(--nice-info, #339af0)',
409
- color: 'var(--nice-text-on-primary, #fff)',
410
- padding: '0 4px',
411
- borderRadius: '2px 2px 0 0',
412
- }, children: node.type }))] }, node.id));
413
- };
414
- const renderTreeItem = (node, depth = 0) => {
415
- const def = COMPONENT_DEFS.find((d) => d.type === node.type);
416
- return (jsxs(React.Fragment, { children: [jsxs("div", { role: "button", tabIndex: 0, onKeyDown: clickOnActivationKey, onClick: () => designer.setSelectedId(node.id), style: {
417
- padding: '2px 4px',
418
- paddingLeft: 4 + depth * 12,
419
- fontSize: 10,
420
- cursor: 'pointer',
421
- display: 'flex',
422
- alignItems: 'center',
423
- gap: 4,
424
- background: designer.selectedId === node.id
425
- ? 'color-mix(in srgb, var(--nice-color-primary, #339af0) 20%, transparent)'
426
- : 'transparent',
427
- borderRadius: 2,
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));
429
- };
430
- const leftPanel = (jsxs("div", { style: {
431
- width: 160,
432
- display: 'flex',
433
- flexDirection: 'column',
434
- gap: 8,
435
- fontSize: 11,
436
- padding: 8,
437
- height: '100%',
438
- overflowY: 'auto',
439
- boxSizing: 'border-box',
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: {
441
- display: 'flex',
442
- alignItems: 'center',
443
- gap: 4,
444
- padding: '4px 6px',
445
- background: 'var(--nice-bg-secondary, #2c2e33)',
446
- border: 'none',
447
- borderRadius: 3,
448
- color: 'var(--nice-text, #c1c2c5)',
449
- cursor: 'grab',
450
- textAlign: 'left',
451
- fontSize: 11,
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: {
454
- padding: '4px 8px',
455
- background: 'var(--nice-primary, #228be6)',
456
- color: 'var(--nice-text-on-primary, #fff)',
457
- border: 'none',
458
- borderRadius: 3,
459
- cursor: 'pointer',
460
- fontSize: 11,
461
- }, children: t('uiDesigner.export', 'Export') })] }));
462
- const mainContent = (jsx("div", { style: {
502
+ ),
503
+ node.children.map((c) => renderTreeItem(c, depth + 1))
504
+ ] }, node.id);
505
+ };
506
+ const leftPanel = /* @__PURE__ */ jsxs(
507
+ "div",
508
+ {
509
+ style: {
510
+ width: 160,
511
+ display: "flex",
512
+ flexDirection: "column",
513
+ gap: 8,
514
+ fontSize: 11,
515
+ padding: 8,
516
+ height: "100%",
517
+ overflowY: "auto",
518
+ boxSizing: "border-box"
519
+ },
520
+ children: [
521
+ /* @__PURE__ */ jsxs("div", { children: [
522
+ /* @__PURE__ */ jsx("strong", { style: { fontSize: 12, display: "block", marginBottom: 4 }, children: t("uiDesigner.components", "Components") }),
523
+ /* @__PURE__ */ jsx("div", { style: { display: "flex", flexDirection: "column", gap: 2 }, children: COMPONENT_DEFS.map((def) => /* @__PURE__ */ jsxs(
524
+ "button",
525
+ {
526
+ draggable: true,
527
+ onDragStart: () => setDragType(def.type),
528
+ onDragEnd: () => setDragType(null),
529
+ onClick: () => designer.addNode(def.type, designer.selectedId ?? void 0),
530
+ style: {
531
+ display: "flex",
532
+ alignItems: "center",
533
+ gap: 4,
534
+ padding: "4px 6px",
535
+ background: "var(--nice-bg-secondary, #2c2e33)",
536
+ border: "none",
537
+ borderRadius: 3,
538
+ color: "var(--nice-text, #c1c2c5)",
539
+ cursor: "grab",
540
+ textAlign: "left",
541
+ fontSize: 11
542
+ },
543
+ children: [
544
+ /* @__PURE__ */ jsx(NiceIcon, { name: def.icon, size: 14 }),
545
+ " ",
546
+ def.label
547
+ ]
548
+ },
549
+ def.type
550
+ )) })
551
+ ] }),
552
+ /* @__PURE__ */ jsxs("div", { children: [
553
+ /* @__PURE__ */ jsx("strong", { style: { fontSize: 12, display: "block", marginBottom: 4 }, children: t("uiDesigner.tree", "Tree") }),
554
+ /* @__PURE__ */ jsx("div", { style: { maxHeight: 200, overflowY: "auto" }, children: designer.tree.length === 0 ? /* @__PURE__ */ jsx("div", { style: { color: "var(--nice-text-secondary, #5c5f66)", padding: 4 }, children: t("uiDesigner.empty", "Empty") }) : designer.tree.map((n) => renderTreeItem(n)) })
555
+ ] })
556
+ ]
557
+ }
558
+ );
559
+ const toolbarContent = /* @__PURE__ */ jsxs(
560
+ "div",
561
+ {
562
+ style: { display: "flex", gap: 4, alignItems: "center", fontSize: 11, padding: "4px 8px" },
563
+ children: [
564
+ /* @__PURE__ */ jsx(
565
+ "button",
566
+ {
567
+ onClick: () => designer.undo(),
568
+ disabled: !designer.canUndo,
569
+ style: { ...btnStyle(false), opacity: designer.canUndo ? 1 : 0.4 },
570
+ title: t("uiDesigner.undoCtrlZ", "Undo (Ctrl+Z)"),
571
+ "aria-label": t("uiDesigner.undo", "Undo"),
572
+ children: /* @__PURE__ */ jsx(NiceIcon, { name: "reply", size: 14 })
573
+ }
574
+ ),
575
+ /* @__PURE__ */ jsx(
576
+ "button",
577
+ {
578
+ onClick: () => designer.redo(),
579
+ disabled: !designer.canRedo,
580
+ style: { ...btnStyle(false), opacity: designer.canRedo ? 1 : 0.4 },
581
+ title: t("uiDesigner.redoCtrlY", "Redo (Ctrl+Y)"),
582
+ "aria-label": t("uiDesigner.redo", "Redo"),
583
+ children: /* @__PURE__ */ jsx(NiceIcon, { name: "forward", size: 14 })
584
+ }
585
+ ),
586
+ /* @__PURE__ */ jsx("div", { style: { width: 1, height: 16, background: "var(--nice-border, #373a40)" } }),
587
+ /* @__PURE__ */ jsxs("button", { onClick: () => setBreakpoint("desktop"), style: btnStyle(breakpoint === "desktop"), children: [
588
+ /* @__PURE__ */ jsx(NiceIcon, { name: "monitor", size: 14 }),
589
+ " ",
590
+ t("uiDesigner.desktop", "Desktop")
591
+ ] }),
592
+ /* @__PURE__ */ jsxs("button", { onClick: () => setBreakpoint("tablet"), style: btnStyle(breakpoint === "tablet"), children: [
593
+ /* @__PURE__ */ jsx(NiceIcon, { name: "window", size: 14 }),
594
+ " ",
595
+ t("uiDesigner.tablet", "Tablet")
596
+ ] }),
597
+ /* @__PURE__ */ jsxs("button", { onClick: () => setBreakpoint("mobile"), style: btnStyle(breakpoint === "mobile"), children: [
598
+ /* @__PURE__ */ jsx(NiceIcon, { name: "phone", size: 14 }),
599
+ " ",
600
+ t("uiDesigner.mobile", "Mobile")
601
+ ] }),
602
+ /* @__PURE__ */ jsx("div", { style: { flex: 1 } }),
603
+ designer.selectedId && /* @__PURE__ */ jsxs(
604
+ "button",
605
+ {
606
+ onClick: () => designer.removeNode(designer.selectedId),
607
+ style: { ...btnStyle(false), color: "var(--nice-danger, #ff6b6b)" },
608
+ children: [
609
+ /* @__PURE__ */ jsx(NiceIcon, { name: "trash", size: 14 }),
610
+ " ",
611
+ t("uiDesigner.delete", "Delete")
612
+ ]
613
+ }
614
+ ),
615
+ /* @__PURE__ */ jsxs("button", { onClick: () => setShowCode((v) => !v), style: btnStyle(showCode), children: [
616
+ "</>",
617
+ " ",
618
+ t("uiDesigner.code", "Code")
619
+ ] }),
620
+ /* @__PURE__ */ jsx(
621
+ "button",
622
+ {
623
+ onClick: () => onExport?.(designer.exportCode()),
624
+ style: {
625
+ padding: "4px 8px",
626
+ background: "var(--nice-primary, #228be6)",
627
+ color: "var(--nice-text-on-primary, #fff)",
628
+ border: "none",
629
+ borderRadius: 3,
630
+ cursor: "pointer",
631
+ fontSize: 11
632
+ },
633
+ children: t("uiDesigner.export", "Export")
634
+ }
635
+ )
636
+ ]
637
+ }
638
+ );
639
+ const mainContent = /* @__PURE__ */ jsx(
640
+ "div",
641
+ {
642
+ style: {
643
+ flex: 1,
644
+ display: "flex",
645
+ flexDirection: "column",
646
+ height: "100%",
647
+ padding: 8,
648
+ boxSizing: "border-box"
649
+ },
650
+ children: showCode ? /* @__PURE__ */ jsx(
651
+ "pre",
652
+ {
653
+ style: {
463
654
  flex: 1,
464
- display: 'flex',
465
- flexDirection: 'column',
466
- height: '100%',
467
- padding: 8,
468
- boxSizing: 'border-box',
469
- }, children: showCode ? (jsx("pre", { style: {
470
- flex: 1,
471
- background: 'var(--nice-bg, #141517)',
472
- borderRadius: 6,
473
- padding: 12,
474
- margin: 0,
475
- overflow: 'auto',
476
- fontSize: 11,
477
- color: 'var(--nice-color-success, #a6e3a1)',
478
- fontFamily: 'monospace',
479
- }, children: designer.exportCode() })) : (jsx("div", { style: {
480
- flex: 1,
481
- background: 'var(--nice-bg, #fff)',
482
- borderRadius: 6,
483
- padding: 16,
484
- overflow: 'auto',
485
- color: 'var(--nice-text, #212529)',
486
- maxWidth: canvasWidth,
487
- margin: breakpoint !== 'desktop' ? '0 auto' : undefined,
488
- border: breakpoint !== 'desktop' ? '1px solid var(--nice-border, #373a40)' : undefined,
489
- transition: 'max-width 0.2s',
490
- }, onDrop: (e) => handleDrop(e), onDragOver: handleDragOver, children: designer.tree.length === 0 ? (jsx("div", { style: {
491
- textAlign: 'center',
492
- padding: 40,
493
- color: 'var(--nice-text-secondary, #868e96)',
494
- }, children: t('uiDesigner.dragOrClickAComponent', 'Drag or click a component to add it') })) : (designer.tree.map((n) => renderNode(n))) })) }));
495
- const rightPanel = (jsxs("div", { style: {
496
- width: 200,
655
+ background: "var(--nice-bg, #141517)",
656
+ borderRadius: 6,
657
+ padding: 12,
658
+ margin: 0,
659
+ overflow: "auto",
497
660
  fontSize: 11,
498
- display: 'flex',
499
- flexDirection: 'column',
500
- gap: 4,
501
- height: '100%',
502
- overflowY: 'auto',
503
- padding: 8,
504
- boxSizing: 'border-box',
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: {
506
- color: 'var(--nice-text-secondary, #868e96)',
507
- display: 'flex',
508
- alignItems: 'center',
509
- gap: 4,
510
- }, children: [(() => {
511
- var _a;
512
- const di = (_a = COMPONENT_DEFS.find((d) => d.type === selectedNode.type)) === null || _a === void 0 ? void 0 : _a.icon;
513
- return di ? jsx(NiceIcon, { name: di, size: 14 }) : null;
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, {
515
- props: { level: Number(e.target.value) },
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: {
517
- border: 'none',
518
- borderTop: '1px solid var(--nice-border, #373a40)',
519
- margin: '4px 0',
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'
521
- ? selectedNode.style[prop]
522
- : 0, onChange: (e) => designer.updateNode(selectedNode.id, {
523
- style: { [prop]: Number(e.target.value) },
524
- }), style: { ...fieldStyle, width: 50 } })] }, prop))), jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: "fontSize" }), jsx("input", { type: "number", value: typeof selectedNode.style.fontSize === 'number' ? selectedNode.style.fontSize : 14, onChange: (e) => designer.updateNode(selectedNode.id, {
525
- style: { fontSize: Number(e.target.value) },
526
- }), style: { ...fieldStyle, width: 50 } })] }), jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: "color" }), jsx("input", { type: "color", value: typeof selectedNode.style.color === 'string' ? selectedNode.style.color : '#000000', onChange: (e) => designer.updateNode(selectedNode.id, { style: { color: e.target.value } }), style: { width: 24, height: 20, border: 'none', cursor: 'pointer' } })] }), jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: "bgColor" }), jsx("input", { type: "color", value: typeof selectedNode.style.background === 'string'
527
- ? selectedNode.style.background
528
- : '#ffffff', onChange: (e) => designer.updateNode(selectedNode.id, { style: { background: e.target.value } }), style: { width: 24, height: 20, border: 'none', cursor: 'pointer' } })] }), selectedNode.style.display === 'flex' && (jsxs(Fragment, { children: [jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: "direction" }), jsxs("select", { value: (_a = selectedNode.style.flexDirection) !== null && _a !== void 0 ? _a : 'column', onChange: (e) => designer.updateNode(selectedNode.id, {
529
- style: {
530
- flexDirection: e.target.value,
531
- },
532
- }), style: { ...fieldStyle, width: 80 }, children: [jsx("option", { value: "row", children: "row" }), jsx("option", { value: "column", children: "column" })] })] }), jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: "align" }), jsx("select", { value: (_b = selectedNode.style.alignItems) !== null && _b !== void 0 ? _b : 'stretch', onChange: (e) => designer.updateNode(selectedNode.id, {
533
- style: { alignItems: e.target.value },
534
- }), style: { ...fieldStyle, width: 80 }, children: ['stretch', 'center', 'flex-start', 'flex-end'].map((v) => (jsx("option", { value: v, children: v }, v))) })] }), jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: "justify" }), jsx("select", { value: (_c = selectedNode.style.justifyContent) !== null && _c !== void 0 ? _c : 'flex-start', onChange: (e) => designer.updateNode(selectedNode.id, {
535
- style: { justifyContent: e.target.value },
536
- }), style: { ...fieldStyle, width: 80 }, children: ['flex-start', 'center', 'flex-end', 'space-between', 'space-around'].map((v) => (jsx("option", { value: v, children: v }, v))) })] })] })), jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: "width" }), jsx("input", { value: (_d = selectedNode.style.width) !== null && _d !== void 0 ? _d : '', placeholder: "auto", onChange: (e) => {
537
- const v = e.target.value;
538
- designer.updateNode(selectedNode.id, {
539
- style: { width: isNaN(Number(v)) ? v : Number(v) },
540
- });
541
- }, style: { ...fieldStyle, width: 60 } })] }), jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 4 }, children: [jsx("label", { style: { minWidth: 60 }, children: "height" }), jsx("input", { value: (_e = selectedNode.style.height) !== null && _e !== void 0 ? _e : '', placeholder: "auto", onChange: (e) => {
542
- const v = e.target.value;
543
- designer.updateNode(selectedNode.id, {
544
- style: { height: isNaN(Number(v)) ? v : Number(v) },
545
- });
546
- }, style: { ...fieldStyle, width: 60 } })] })] })) : (jsx("div", { style: {
547
- color: 'var(--nice-text-secondary, #5c5f66)',
548
- padding: 8,
549
- textAlign: 'center',
550
- }, children: t('uiDesigner.selectAnElement', 'Select an element') }))] }));
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 })] }));
661
+ color: "var(--nice-color-success, #a6e3a1)",
662
+ fontFamily: "monospace"
663
+ },
664
+ children: designer.exportCode()
665
+ }
666
+ ) : /* @__PURE__ */ jsx(
667
+ "div",
668
+ {
669
+ style: {
670
+ flex: 1,
671
+ background: "var(--nice-bg, #fff)",
672
+ borderRadius: 6,
673
+ padding: 16,
674
+ overflow: "auto",
675
+ color: "var(--nice-text, #212529)",
676
+ maxWidth: canvasWidth,
677
+ margin: breakpoint !== "desktop" ? "0 auto" : void 0,
678
+ border: breakpoint !== "desktop" ? "1px solid var(--nice-border, #373a40)" : void 0,
679
+ transition: "max-width 0.2s"
680
+ },
681
+ onDrop: (e) => handleDrop(e),
682
+ onDragOver: handleDragOver,
683
+ children: designer.tree.length === 0 ? /* @__PURE__ */ jsx(
684
+ "div",
685
+ {
686
+ style: {
687
+ textAlign: "center",
688
+ padding: 40,
689
+ color: "var(--nice-text-secondary, #868e96)"
690
+ },
691
+ children: t("uiDesigner.dragOrClickAComponent", "Drag or click a component to add it")
692
+ }
693
+ ) : designer.tree.map((n) => renderNode(n))
694
+ }
695
+ )
696
+ }
697
+ );
698
+ const rightPanel = /* @__PURE__ */ jsxs(
699
+ "div",
700
+ {
701
+ style: {
702
+ width: 200,
703
+ fontSize: 11,
704
+ display: "flex",
705
+ flexDirection: "column",
706
+ gap: 4,
707
+ height: "100%",
708
+ overflowY: "auto",
709
+ padding: 8,
710
+ boxSizing: "border-box"
711
+ },
712
+ children: [
713
+ /* @__PURE__ */ jsx("strong", { style: { fontSize: 12 }, children: t("uiDesigner.properties", "Properties") }),
714
+ selectedNode ? /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: [
715
+ /* @__PURE__ */ jsxs(
716
+ "div",
717
+ {
718
+ style: {
719
+ color: "var(--nice-text-secondary, #868e96)",
720
+ display: "flex",
721
+ alignItems: "center",
722
+ gap: 4
723
+ },
724
+ children: [
725
+ (() => {
726
+ const di = COMPONENT_DEFS.find((d) => d.type === selectedNode.type)?.icon;
727
+ return di ? /* @__PURE__ */ jsx(NiceIcon, { name: di, size: 14 }) : null;
728
+ })(),
729
+ " ",
730
+ selectedNode.type
731
+ ]
732
+ }
733
+ ),
734
+ selectedNode.props.text !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
735
+ /* @__PURE__ */ jsx("label", { children: t("uiDesigner.text", "Text") }),
736
+ /* @__PURE__ */ jsx(
737
+ "input",
738
+ {
739
+ value: String(selectedNode.props.text),
740
+ onChange: (e) => designer.updateNode(selectedNode.id, { props: { text: e.target.value } }),
741
+ style: fieldStyle
742
+ }
743
+ )
744
+ ] }),
745
+ selectedNode.props.placeholder !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
746
+ /* @__PURE__ */ jsx("label", { children: t("uiDesigner.placeholder", "Placeholder") }),
747
+ /* @__PURE__ */ jsx(
748
+ "input",
749
+ {
750
+ value: String(selectedNode.props.placeholder),
751
+ onChange: (e) => designer.updateNode(selectedNode.id, { props: { placeholder: e.target.value } }),
752
+ style: fieldStyle
753
+ }
754
+ )
755
+ ] }),
756
+ selectedNode.props.level !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
757
+ /* @__PURE__ */ jsx("label", { children: t("uiDesigner.headingLevel", "Heading Level") }),
758
+ /* @__PURE__ */ jsx(
759
+ "select",
760
+ {
761
+ value: Number(selectedNode.props.level),
762
+ onChange: (e) => designer.updateNode(selectedNode.id, {
763
+ props: { level: Number(e.target.value) }
764
+ }),
765
+ style: fieldStyle,
766
+ children: [1, 2, 3, 4, 5, 6].map((v) => /* @__PURE__ */ jsxs("option", { value: v, children: [
767
+ "H",
768
+ v
769
+ ] }, v))
770
+ }
771
+ )
772
+ ] }),
773
+ selectedNode.props.variant !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
774
+ /* @__PURE__ */ jsx("label", { children: t("uiDesigner.variant", "Variant") }),
775
+ /* @__PURE__ */ jsx(
776
+ "select",
777
+ {
778
+ value: String(selectedNode.props.variant),
779
+ onChange: (e) => designer.updateNode(selectedNode.id, { props: { variant: e.target.value } }),
780
+ style: fieldStyle,
781
+ children: ["primary", "secondary", "outline", "ghost"].map((v) => /* @__PURE__ */ jsx("option", { value: v, children: v }, v))
782
+ }
783
+ )
784
+ ] }),
785
+ selectedNode.props.src !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
786
+ /* @__PURE__ */ jsx("label", { children: t("uiDesigner.imageUrl", "Image URL") }),
787
+ /* @__PURE__ */ jsx(
788
+ "input",
789
+ {
790
+ value: String(selectedNode.props.src),
791
+ onChange: (e) => designer.updateNode(selectedNode.id, { props: { src: e.target.value } }),
792
+ style: fieldStyle
793
+ }
794
+ )
795
+ ] }),
796
+ selectedNode.props.alt !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
797
+ /* @__PURE__ */ jsx("label", { children: t("uiDesigner.altText", "Alt Text") }),
798
+ /* @__PURE__ */ jsx(
799
+ "input",
800
+ {
801
+ value: String(selectedNode.props.alt),
802
+ onChange: (e) => designer.updateNode(selectedNode.id, { props: { alt: e.target.value } }),
803
+ style: fieldStyle
804
+ }
805
+ )
806
+ ] }),
807
+ /* @__PURE__ */ jsx(
808
+ "hr",
809
+ {
810
+ style: {
811
+ border: "none",
812
+ borderTop: "1px solid var(--nice-border, #373a40)",
813
+ margin: "4px 0"
814
+ }
815
+ }
816
+ ),
817
+ /* @__PURE__ */ jsx("strong", { style: { color: "var(--nice-text-secondary, #868e96)" }, children: t("uiDesigner.style", "Style") }),
818
+ ["padding", "margin", "gap", "borderRadius"].map((prop) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
819
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: prop }),
820
+ /* @__PURE__ */ jsx(
821
+ "input",
822
+ {
823
+ type: "number",
824
+ value: typeof selectedNode.style[prop] === "number" ? selectedNode.style[prop] : 0,
825
+ onChange: (e) => designer.updateNode(selectedNode.id, {
826
+ style: { [prop]: Number(e.target.value) }
827
+ }),
828
+ style: { ...fieldStyle, width: 50 }
829
+ }
830
+ )
831
+ ] }, prop)),
832
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
833
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: "fontSize" }),
834
+ /* @__PURE__ */ jsx(
835
+ "input",
836
+ {
837
+ type: "number",
838
+ value: typeof selectedNode.style.fontSize === "number" ? selectedNode.style.fontSize : 14,
839
+ onChange: (e) => designer.updateNode(selectedNode.id, {
840
+ style: { fontSize: Number(e.target.value) }
841
+ }),
842
+ style: { ...fieldStyle, width: 50 }
843
+ }
844
+ )
845
+ ] }),
846
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
847
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: "color" }),
848
+ /* @__PURE__ */ jsx(
849
+ "input",
850
+ {
851
+ type: "color",
852
+ value: typeof selectedNode.style.color === "string" ? selectedNode.style.color : "#000000",
853
+ onChange: (e) => designer.updateNode(selectedNode.id, { style: { color: e.target.value } }),
854
+ style: { width: 24, height: 20, border: "none", cursor: "pointer" }
855
+ }
856
+ )
857
+ ] }),
858
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
859
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: "bgColor" }),
860
+ /* @__PURE__ */ jsx(
861
+ "input",
862
+ {
863
+ type: "color",
864
+ value: typeof selectedNode.style.background === "string" ? selectedNode.style.background : "#ffffff",
865
+ onChange: (e) => designer.updateNode(selectedNode.id, { style: { background: e.target.value } }),
866
+ style: { width: 24, height: 20, border: "none", cursor: "pointer" }
867
+ }
868
+ )
869
+ ] }),
870
+ selectedNode.style.display === "flex" && /* @__PURE__ */ jsxs(Fragment, { children: [
871
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
872
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: "direction" }),
873
+ /* @__PURE__ */ jsxs(
874
+ "select",
875
+ {
876
+ value: selectedNode.style.flexDirection ?? "column",
877
+ onChange: (e) => designer.updateNode(selectedNode.id, {
878
+ style: {
879
+ flexDirection: e.target.value
880
+ }
881
+ }),
882
+ style: { ...fieldStyle, width: 80 },
883
+ children: [
884
+ /* @__PURE__ */ jsx("option", { value: "row", children: "row" }),
885
+ /* @__PURE__ */ jsx("option", { value: "column", children: "column" })
886
+ ]
887
+ }
888
+ )
889
+ ] }),
890
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
891
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: "align" }),
892
+ /* @__PURE__ */ jsx(
893
+ "select",
894
+ {
895
+ value: selectedNode.style.alignItems ?? "stretch",
896
+ onChange: (e) => designer.updateNode(selectedNode.id, {
897
+ style: { alignItems: e.target.value }
898
+ }),
899
+ style: { ...fieldStyle, width: 80 },
900
+ children: ["stretch", "center", "flex-start", "flex-end"].map((v) => /* @__PURE__ */ jsx("option", { value: v, children: v }, v))
901
+ }
902
+ )
903
+ ] }),
904
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
905
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: "justify" }),
906
+ /* @__PURE__ */ jsx(
907
+ "select",
908
+ {
909
+ value: selectedNode.style.justifyContent ?? "flex-start",
910
+ onChange: (e) => designer.updateNode(selectedNode.id, {
911
+ style: { justifyContent: e.target.value }
912
+ }),
913
+ style: { ...fieldStyle, width: 80 },
914
+ children: ["flex-start", "center", "flex-end", "space-between", "space-around"].map(
915
+ (v) => /* @__PURE__ */ jsx("option", { value: v, children: v }, v)
916
+ )
917
+ }
918
+ )
919
+ ] })
920
+ ] }),
921
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
922
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: "width" }),
923
+ /* @__PURE__ */ jsx(
924
+ "input",
925
+ {
926
+ value: selectedNode.style.width ?? "",
927
+ placeholder: "auto",
928
+ onChange: (e) => {
929
+ const v = e.target.value;
930
+ designer.updateNode(selectedNode.id, {
931
+ style: { width: isNaN(Number(v)) ? v : Number(v) }
932
+ });
933
+ },
934
+ style: { ...fieldStyle, width: 60 }
935
+ }
936
+ )
937
+ ] }),
938
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: 4 }, children: [
939
+ /* @__PURE__ */ jsx("label", { style: { minWidth: 60 }, children: "height" }),
940
+ /* @__PURE__ */ jsx(
941
+ "input",
942
+ {
943
+ value: selectedNode.style.height ?? "",
944
+ placeholder: "auto",
945
+ onChange: (e) => {
946
+ const v = e.target.value;
947
+ designer.updateNode(selectedNode.id, {
948
+ style: { height: isNaN(Number(v)) ? v : Number(v) }
949
+ });
950
+ },
951
+ style: { ...fieldStyle, width: 60 }
952
+ }
953
+ )
954
+ ] })
955
+ ] }) : /* @__PURE__ */ jsx(
956
+ "div",
957
+ {
958
+ style: {
959
+ color: "var(--nice-text-secondary, #5c5f66)",
960
+ padding: 8,
961
+ textAlign: "center"
962
+ },
963
+ children: t("uiDesigner.selectAnElement", "Select an element")
964
+ }
965
+ )
966
+ ]
967
+ }
968
+ );
969
+ return /* @__PURE__ */ jsxs(
970
+ "div",
971
+ {
972
+ className: `nice-ui-designer ${className}`,
973
+ style: { position: "relative", height: "100%" },
974
+ children: [
975
+ /* @__PURE__ */ jsx("span", { style: { position: "absolute", top: 6, right: 6, zIndex: 20 }, children: /* @__PURE__ */ jsx(NiceTutorialButton, { steps: resolveTutorial(tutorial, UI_DESIGNER_TOUR) }) }),
976
+ /* @__PURE__ */ jsx(NiceAppShell, { flush: true, toolbar: toolbarContent, sidebar: leftPanel, rightSidebar: rightPanel, children: mainContent })
977
+ ]
978
+ }
979
+ );
980
+ };
981
+ export {
982
+ NiceUIDesigner,
983
+ exportToReact,
984
+ useUIDesigner
552
985
  };
553
-
554
- export { NiceUIDesigner, exportToReact, useUIDesigner };