@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.
- package/CHANGELOG.md +9 -0
- package/dist/cjs/animation/AnimatedPerson.js +470 -143
- package/dist/cjs/animation/AnimationEditor.js +289 -101
- package/dist/cjs/animation/Audience.js +83 -61
- package/dist/cjs/animation/BodyRenderer.js +69 -28
- package/dist/cjs/animation/animationHelper.js +281 -288
- package/dist/cjs/animation/characterTypes.js +200 -203
- package/dist/cjs/animation/choreoDSL.js +205 -219
- package/dist/cjs/animation/choreography.js +4 -32
- package/dist/cjs/animation/karaokeIntegration.js +68 -77
- package/dist/cjs/animation/lottieExport.js +108 -114
- package/dist/cjs/animation/motionPath.js +225 -248
- package/dist/cjs/animation/physics.js +227 -254
- package/dist/cjs/animation/rig/RigPlayer.js +53 -56
- package/dist/cjs/animation/rig/RiggedBody.js +71 -26
- package/dist/cjs/animation/rig/choreoRigBridge.js +72 -77
- package/dist/cjs/animation/rig/ik.js +13 -18
- package/dist/cjs/animation/rig/poseOps.js +34 -41
- package/dist/cjs/animation/rig/presets.js +64 -72
- package/dist/cjs/animation/rig/rigMath.js +25 -32
- package/dist/cjs/animation/rig/rigTypes.js +59 -63
- package/dist/cjs/animation/shapes/arms.js +31 -13
- package/dist/cjs/animation/shapes/eyes.js +129 -47
- package/dist/cjs/animation/shapes/hair.js +72 -45
- package/dist/cjs/animation/shapes/heads.js +131 -57
- package/dist/cjs/animation/shapes/headwear.js +47 -38
- package/dist/cjs/animation/shapes/legs.js +31 -13
- package/dist/cjs/animation/shapes/mouths.js +120 -44
- package/dist/cjs/animation/shapes/noses.js +80 -25
- package/dist/cjs/animation/shapes/outfits.js +101 -39
- package/dist/cjs/animation/shapes/torsos.js +15 -11
- package/dist/cjs/animation/spineExport.js +103 -121
- package/dist/cjs/core/LocalUI.js +108 -43
- package/dist/cjs/core/NiceBrushEngine.js +758 -552
- package/dist/cjs/core/collaboration.js +249 -251
- package/dist/cjs/core/colorBlindness.js +100 -115
- package/dist/cjs/core/dragDrop.js +155 -158
- package/dist/cjs/core/editorAsk.js +51 -41
- package/dist/cjs/core/fixes.js +140 -171
- package/dist/cjs/core/gridGuides.js +166 -201
- package/dist/cjs/core/historyVisual.js +156 -135
- package/dist/cjs/core/i18n.js +13 -14
- package/dist/cjs/core/integrations.js +238 -249
- package/dist/cjs/core/minimap.js +149 -151
- package/dist/cjs/core/plugins.js +98 -113
- package/dist/cjs/core/rtl.js +71 -83
- package/dist/cjs/core/shortcuts.js +196 -225
- package/dist/cjs/core/theme.js +142 -149
- package/dist/cjs/core/yjsCollaboration.js +232 -293
- package/dist/cjs/design/design-tools.js +12 -22
- package/dist/cjs/font/NiceFontEditor.js +877 -316
- package/dist/cjs/font/fontFormatUtils.js +388 -448
- package/dist/cjs/game/GameAsset2dEditor.js +1201 -392
- package/dist/cjs/game/GameAsset2dEditor.module.css.js +146 -5
- package/dist/cjs/game/gameAssetTypes.js +7 -16
- package/dist/cjs/game/gameAssetUtils.js +390 -413
- package/dist/cjs/game/useGameAssetEditor.js +820 -763
- package/dist/cjs/index.js +81 -84
- package/dist/cjs/nice2dev-ui-graphics.css +1 -1
- package/dist/cjs/node_modules/lib0/array.js +8 -70
- package/dist/cjs/node_modules/lib0/binary.js +3 -20
- package/dist/cjs/node_modules/lib0/broadcastchannel.js +24 -86
- package/dist/cjs/node_modules/lib0/buffer.js +15 -82
- package/dist/cjs/node_modules/lib0/conditions.js +3 -16
- package/dist/cjs/node_modules/lib0/decoding.js +108 -287
- package/dist/cjs/node_modules/lib0/dom.js +14 -44
- package/dist/cjs/node_modules/lib0/encoding.js +68 -418
- package/dist/cjs/node_modules/lib0/environment.js +26 -92
- package/dist/cjs/node_modules/lib0/error.js +5 -29
- package/dist/cjs/node_modules/lib0/function.js +27 -66
- package/dist/cjs/node_modules/lib0/iterator.js +8 -33
- package/dist/cjs/node_modules/lib0/logging.common.js +12 -22
- package/dist/cjs/node_modules/lib0/logging.js +32 -71
- package/dist/cjs/node_modules/lib0/map.js +16 -86
- package/dist/cjs/node_modules/lib0/math.js +3 -32
- package/dist/cjs/node_modules/lib0/number.js +4 -15
- package/dist/cjs/node_modules/lib0/object.js +14 -88
- package/dist/cjs/node_modules/lib0/observable.js +38 -78
- package/dist/cjs/node_modules/lib0/pair.js +3 -20
- package/dist/cjs/node_modules/lib0/prng.js +8 -77
- package/dist/cjs/node_modules/lib0/promise.js +6 -30
- package/dist/cjs/node_modules/lib0/random.js +8 -23
- package/dist/cjs/node_modules/lib0/schema.js +313 -687
- package/dist/cjs/node_modules/lib0/set.js +3 -10
- package/dist/cjs/node_modules/lib0/storage.js +20 -55
- package/dist/cjs/node_modules/lib0/string.js +17 -72
- package/dist/cjs/node_modules/lib0/symbol.js +2 -12
- package/dist/cjs/node_modules/lib0/time.js +2 -15
- package/dist/cjs/node_modules/lib0/trait/equality.js +3 -28
- package/dist/cjs/node_modules/lib0/url.js +4 -18
- package/dist/cjs/node_modules/lib0/webcrypto.js +2 -5
- package/dist/cjs/node_modules/y-protocols/auth.js +5 -19
- package/dist/cjs/node_modules/y-protocols/awareness.js +53 -116
- package/dist/cjs/node_modules/y-protocols/sync.js +16 -103
- package/dist/cjs/node_modules/y-websocket/src/y-websocket.js +77 -219
- package/dist/cjs/node_modules/yjs/dist/yjs.js +2128 -4868
- package/dist/cjs/photo/FilterThumb.js +37 -25
- package/dist/cjs/photo/NiceAITools.js +679 -467
- package/dist/cjs/photo/PhotoEditor.js +34 -20
- package/dist/cjs/photo/PhotoEditor.module.css.js +296 -5
- package/dist/cjs/photo/PhotoEditorCanvas.js +250 -91
- package/dist/cjs/photo/PhotoEditorLeftPanel.js +1086 -224
- package/dist/cjs/photo/PhotoEditorToolbar.js +135 -19
- package/dist/cjs/photo/photoEditorActions.js +89 -72
- package/dist/cjs/photo/photoEditorTypes.js +29 -32
- package/dist/cjs/photo/photoFilters.js +959 -985
- package/dist/cjs/photo/photoOverlays.js +899 -945
- package/dist/cjs/photo/photoSelection.js +427 -499
- package/dist/cjs/photo/usePhotoEditor.js +739 -741
- package/dist/cjs/pixel/HSVPicker.js +191 -175
- package/dist/cjs/pixel/PixelEditor.js +159 -48
- package/dist/cjs/pixel/PixelEditor.module.css.js +209 -5
- package/dist/cjs/pixel/PixelEditorCanvas.js +29 -16
- package/dist/cjs/pixel/PixelEditorMenuBar.js +160 -162
- package/dist/cjs/pixel/PixelEditorRightPanel.js +377 -45
- package/dist/cjs/pixel/PixelEditorStatusBar.js +47 -20
- package/dist/cjs/pixel/PixelEditorTimeline.js +106 -23
- package/dist/cjs/pixel/PixelEditorToolbar.js +99 -21
- package/dist/cjs/pixel/SpriteGeneratorPanel.js +483 -303
- package/dist/cjs/pixel/animalGeneratorPresets.js +776 -601
- package/dist/cjs/pixel/asepriteFormat.js +511 -560
- package/dist/cjs/pixel/buildingGeneratorPresets.js +693 -520
- package/dist/cjs/pixel/characterGeneratorPresets.js +644 -544
- package/dist/cjs/pixel/pixel-pro.js +52 -63
- package/dist/cjs/pixel/pixelEditorExports.js +388 -428
- package/dist/cjs/pixel/pixelEditorTypes.js +91 -108
- package/dist/cjs/pixel/pixelEditorUtils.js +519 -561
- package/dist/cjs/pixel/spriteGeneratorCore.js +206 -257
- package/dist/cjs/pixel/usePixelEditor.js +1321 -1343
- package/dist/cjs/texture/Nice3DTexturePainter.js +707 -440
- package/dist/cjs/ui/NiceUIDesigner.js +954 -527
- package/dist/cjs/vector/NiceSvgToCode.js +586 -446
- package/dist/cjs/vector/VectorEditor.js +290 -117
- package/dist/cjs/vector/VectorEditor.module.css.js +86 -5
- package/dist/cjs/vector/VectorEditorMenuBar.js +333 -275
- package/dist/cjs/vector/VectorEditorRightPanel.js +1094 -371
- package/dist/cjs/vector/VectorEditorShapeRenderer.js +198 -60
- package/dist/cjs/vector/VectorEditorStatusBar.js +39 -13
- package/dist/cjs/vector/useVectorEditor.js +848 -889
- package/dist/cjs/vector/vectorAnimation.js +110 -137
- package/dist/cjs/vector/vectorBooleanOps.js +398 -485
- package/dist/cjs/vector/vectorEditorExport.js +201 -203
- package/dist/cjs/vector/vectorEditorImport.js +173 -189
- package/dist/cjs/vector/vectorEditorTypes.js +42 -49
- package/dist/cjs/vector/vectorGradients.js +151 -174
- package/dist/cjs/vector/vectorIconExport.js +52 -59
- package/dist/cjs/vector/vectorIconImport.js +169 -219
- package/dist/esm/animation/AnimatedPerson.js +470 -141
- package/dist/esm/animation/AnimationEditor.js +290 -100
- package/dist/esm/animation/Audience.js +83 -59
- package/dist/esm/animation/BodyRenderer.js +71 -25
- package/dist/esm/animation/animationHelper.js +284 -287
- package/dist/esm/animation/characterTypes.js +204 -202
- package/dist/esm/animation/choreoDSL.js +212 -218
- package/dist/esm/animation/choreography.js +8 -31
- package/dist/esm/animation/karaokeIntegration.js +74 -76
- package/dist/esm/animation/lottieExport.js +112 -113
- package/dist/esm/animation/motionPath.js +235 -247
- package/dist/esm/animation/physics.js +235 -253
- package/dist/esm/animation/rig/RigPlayer.js +53 -54
- package/dist/esm/animation/rig/RiggedBody.js +71 -24
- package/dist/esm/animation/rig/choreoRigBridge.js +74 -76
- package/dist/esm/animation/rig/ik.js +14 -17
- package/dist/esm/animation/rig/poseOps.js +37 -40
- package/dist/esm/animation/rig/presets.js +70 -71
- package/dist/esm/animation/rig/rigMath.js +28 -31
- package/dist/esm/animation/rig/rigTypes.js +62 -62
- package/dist/esm/animation/shapes/arms.js +32 -12
- package/dist/esm/animation/shapes/eyes.js +135 -46
- package/dist/esm/animation/shapes/hair.js +80 -44
- package/dist/esm/animation/shapes/heads.js +140 -56
- package/dist/esm/animation/shapes/headwear.js +54 -37
- package/dist/esm/animation/shapes/legs.js +32 -12
- package/dist/esm/animation/shapes/mouths.js +127 -43
- package/dist/esm/animation/shapes/noses.js +87 -24
- package/dist/esm/animation/shapes/outfits.js +106 -38
- package/dist/esm/animation/shapes/torsos.js +16 -10
- package/dist/esm/animation/spineExport.js +106 -120
- package/dist/esm/core/LocalUI.js +111 -42
- package/dist/esm/core/NiceBrushEngine.js +761 -551
- package/dist/esm/core/collaboration.js +255 -250
- package/dist/esm/core/colorBlindness.js +106 -114
- package/dist/esm/core/dragDrop.js +157 -157
- package/dist/esm/core/editorAsk.js +53 -40
- package/dist/esm/core/fixes.js +145 -170
- package/dist/esm/core/gridGuides.js +178 -200
- package/dist/esm/core/historyVisual.js +158 -134
- package/dist/esm/core/i18n.js +15 -13
- package/dist/esm/core/integrations.js +244 -248
- package/dist/esm/core/minimap.js +151 -150
- package/dist/esm/core/plugins.js +102 -112
- package/dist/esm/core/rtl.js +77 -82
- package/dist/esm/core/shortcuts.js +200 -224
- package/dist/esm/core/theme.js +150 -148
- package/dist/esm/core/yjsCollaboration.js +240 -292
- package/dist/esm/design/design-tools.js +13 -21
- package/dist/esm/font/NiceFontEditor.js +880 -315
- package/dist/esm/font/fontFormatUtils.js +394 -447
- package/dist/esm/game/GameAsset2dEditor.js +1202 -391
- package/dist/esm/game/GameAsset2dEditor.module.css.js +146 -3
- package/dist/esm/game/gameAssetTypes.js +8 -15
- package/dist/esm/game/gameAssetUtils.js +408 -412
- package/dist/esm/game/useGameAssetEditor.js +821 -762
- package/dist/esm/index.js +332 -69
- package/dist/esm/nice2dev-ui-graphics.css +1 -1
- package/dist/esm/node_modules/lib0/array.js +15 -69
- package/dist/esm/node_modules/lib0/binary.js +14 -19
- package/dist/esm/node_modules/lib0/broadcastchannel.js +27 -85
- package/dist/esm/node_modules/lib0/buffer.js +20 -80
- package/dist/esm/node_modules/lib0/conditions.js +4 -15
- package/dist/esm/node_modules/lib0/decoding.js +128 -286
- package/dist/esm/node_modules/lib0/dom.js +20 -43
- package/dist/esm/node_modules/lib0/encoding.js +90 -415
- package/dist/esm/node_modules/lib0/environment.js +33 -91
- package/dist/esm/node_modules/lib0/error.js +8 -28
- package/dist/esm/node_modules/lib0/function.js +31 -65
- package/dist/esm/node_modules/lib0/iterator.js +11 -32
- package/dist/esm/node_modules/lib0/logging.common.js +22 -21
- package/dist/esm/node_modules/lib0/logging.js +44 -70
- package/dist/esm/node_modules/lib0/map.js +21 -85
- package/dist/esm/node_modules/lib0/math.js +9 -31
- package/dist/esm/node_modules/lib0/number.js +7 -14
- package/dist/esm/node_modules/lib0/object.js +26 -87
- package/dist/esm/node_modules/lib0/observable.js +40 -77
- package/dist/esm/node_modules/lib0/pair.js +5 -19
- package/dist/esm/node_modules/lib0/prng.js +15 -76
- package/dist/esm/node_modules/lib0/promise.js +7 -29
- package/dist/esm/node_modules/lib0/random.js +10 -22
- package/dist/esm/node_modules/lib0/schema.js +367 -686
- package/dist/esm/node_modules/lib0/set.js +4 -9
- package/dist/esm/node_modules/lib0/storage.js +23 -54
- package/dist/esm/node_modules/lib0/string.js +26 -71
- package/dist/esm/node_modules/lib0/symbol.js +3 -11
- package/dist/esm/node_modules/lib0/time.js +3 -14
- package/dist/esm/node_modules/lib0/trait/equality.js +5 -27
- package/dist/esm/node_modules/lib0/url.js +5 -17
- package/dist/esm/node_modules/lib0/webcrypto.js +3 -4
- package/dist/esm/node_modules/y-protocols/auth.js +7 -18
- package/dist/esm/node_modules/y-protocols/awareness.js +58 -115
- package/dist/esm/node_modules/y-protocols/sync.js +26 -102
- package/dist/esm/node_modules/y-websocket/src/y-websocket.js +82 -218
- package/dist/esm/node_modules/yjs/dist/yjs.js +2263 -4899
- package/dist/esm/photo/FilterThumb.js +37 -23
- package/dist/esm/photo/NiceAITools.js +685 -466
- package/dist/esm/photo/PhotoEditor.js +34 -18
- package/dist/esm/photo/PhotoEditor.module.css.js +296 -3
- package/dist/esm/photo/PhotoEditorCanvas.js +250 -89
- package/dist/esm/photo/PhotoEditorLeftPanel.js +1086 -222
- package/dist/esm/photo/PhotoEditorToolbar.js +135 -17
- package/dist/esm/photo/photoEditorActions.js +93 -71
- package/dist/esm/photo/photoEditorTypes.js +32 -31
- package/dist/esm/photo/photoFilters.js +967 -984
- package/dist/esm/photo/photoOverlays.js +913 -944
- package/dist/esm/photo/photoSelection.js +438 -498
- package/dist/esm/photo/usePhotoEditor.js +740 -740
- package/dist/esm/pixel/HSVPicker.js +192 -174
- package/dist/esm/pixel/PixelEditor.js +160 -47
- package/dist/esm/pixel/PixelEditor.module.css.js +209 -3
- package/dist/esm/pixel/PixelEditorCanvas.js +29 -14
- package/dist/esm/pixel/PixelEditorMenuBar.js +160 -160
- package/dist/esm/pixel/PixelEditorRightPanel.js +377 -43
- package/dist/esm/pixel/PixelEditorStatusBar.js +47 -18
- package/dist/esm/pixel/PixelEditorTimeline.js +106 -21
- package/dist/esm/pixel/PixelEditorToolbar.js +99 -19
- package/dist/esm/pixel/SpriteGeneratorPanel.js +483 -301
- package/dist/esm/pixel/animalGeneratorPresets.js +782 -600
- package/dist/esm/pixel/asepriteFormat.js +517 -559
- package/dist/esm/pixel/buildingGeneratorPresets.js +699 -519
- package/dist/esm/pixel/characterGeneratorPresets.js +650 -543
- package/dist/esm/pixel/pixel-pro.js +53 -62
- package/dist/esm/pixel/pixelEditorExports.js +397 -427
- package/dist/esm/pixel/pixelEditorTypes.js +103 -107
- package/dist/esm/pixel/pixelEditorUtils.js +551 -560
- package/dist/esm/pixel/spriteGeneratorCore.js +223 -256
- package/dist/esm/pixel/usePixelEditor.js +1322 -1342
- package/dist/esm/texture/Nice3DTexturePainter.js +709 -439
- package/dist/esm/ui/NiceUIDesigner.js +957 -526
- package/dist/esm/vector/NiceSvgToCode.js +589 -445
- package/dist/esm/vector/VectorEditor.js +291 -116
- package/dist/esm/vector/VectorEditor.module.css.js +86 -3
- package/dist/esm/vector/VectorEditorMenuBar.js +333 -273
- package/dist/esm/vector/VectorEditorRightPanel.js +1094 -369
- package/dist/esm/vector/VectorEditorShapeRenderer.js +199 -59
- package/dist/esm/vector/VectorEditorStatusBar.js +39 -11
- package/dist/esm/vector/useVectorEditor.js +849 -888
- package/dist/esm/vector/vectorAnimation.js +115 -136
- package/dist/esm/vector/vectorBooleanOps.js +401 -484
- package/dist/esm/vector/vectorEditorExport.js +207 -202
- package/dist/esm/vector/vectorEditorImport.js +174 -188
- package/dist/esm/vector/vectorEditorTypes.js +50 -48
- package/dist/esm/vector/vectorGradients.js +158 -173
- package/dist/esm/vector/vectorIconExport.js +53 -58
- package/dist/esm/vector/vectorIconImport.js +171 -218
- package/package.json +9 -15
|
@@ -1,558 +1,985 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
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 =
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
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
|
-
|
|
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
|
-
|
|
290
|
-
|
|
291
|
-
|
|
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
|
-
|
|
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
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
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
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
-
|
|
332
|
-
|
|
333
|
-
|
|
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
|
-
|
|
336
|
-
|
|
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
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
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
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
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
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
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
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
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;
|