@nice2dev/ui-graphics 1.3.15 → 1.3.16

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