@duongthiu/onex-core 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -65
- package/THEME_API.md +36 -33
- package/dist/api.js +14 -0
- package/dist/api.js.map +1 -0
- package/dist/api.mjs +5 -0
- package/dist/api.mjs.map +1 -0
- package/dist/auth.js +23 -0
- package/dist/auth.js.map +1 -0
- package/dist/auth.mjs +6 -0
- package/dist/auth.mjs.map +1 -0
- package/dist/blog.js +22 -0
- package/dist/blog.js.map +1 -0
- package/dist/blog.mjs +5 -0
- package/dist/blog.mjs.map +1 -0
- package/dist/cart.js +27 -0
- package/dist/cart.js.map +1 -0
- package/dist/cart.mjs +6 -0
- package/dist/cart.mjs.map +1 -0
- package/dist/chunk-2CSWHI3L.js +210 -0
- package/dist/chunk-2CSWHI3L.js.map +1 -0
- package/dist/chunk-2FGHIDUV.js +99 -0
- package/dist/chunk-2FGHIDUV.js.map +1 -0
- package/dist/chunk-2NMEKWO5.js +40 -0
- package/dist/chunk-2NMEKWO5.js.map +1 -0
- package/dist/chunk-43BVHGDT.mjs +131 -0
- package/dist/chunk-43BVHGDT.mjs.map +1 -0
- package/dist/chunk-4JVQJI3I.mjs +290 -0
- package/dist/chunk-4JVQJI3I.mjs.map +1 -0
- package/dist/chunk-5N2EKK5O.js +9550 -0
- package/dist/chunk-5N2EKK5O.js.map +1 -0
- package/dist/chunk-5T6NDVSN.js +76 -0
- package/dist/chunk-5T6NDVSN.js.map +1 -0
- package/dist/chunk-73AINNCI.mjs +201 -0
- package/dist/chunk-73AINNCI.mjs.map +1 -0
- package/dist/chunk-AIXBDAVP.mjs +61 -0
- package/dist/chunk-AIXBDAVP.mjs.map +1 -0
- package/dist/chunk-ALYN5HAC.js +210 -0
- package/dist/chunk-ALYN5HAC.js.map +1 -0
- package/dist/chunk-AREMJR3Q.js +36 -0
- package/dist/chunk-AREMJR3Q.js.map +1 -0
- package/dist/chunk-DXAI6XOI.mjs +33 -0
- package/dist/chunk-DXAI6XOI.mjs.map +1 -0
- package/dist/chunk-F5TFNWFJ.mjs +257 -0
- package/dist/chunk-F5TFNWFJ.mjs.map +1 -0
- package/dist/chunk-FQ7FWUZN.js +265 -0
- package/dist/chunk-FQ7FWUZN.js.map +1 -0
- package/dist/{chunk-3SZX6LHT.js → chunk-J27VGXJH.js} +2 -24
- package/dist/chunk-J27VGXJH.js.map +1 -0
- package/dist/chunk-JZ46LLTZ.js +121 -0
- package/dist/chunk-JZ46LLTZ.js.map +1 -0
- package/dist/chunk-K24UHN6G.mjs +76 -0
- package/dist/chunk-K24UHN6G.mjs.map +1 -0
- package/dist/chunk-KCQGGU5R.mjs +344 -0
- package/dist/chunk-KCQGGU5R.mjs.map +1 -0
- package/dist/chunk-MT22NYKT.mjs +117 -0
- package/dist/chunk-MT22NYKT.mjs.map +1 -0
- package/dist/chunk-NDD472IZ.js +85 -0
- package/dist/chunk-NDD472IZ.js.map +1 -0
- package/dist/chunk-NHOIGGYU.mjs +833 -0
- package/dist/chunk-NHOIGGYU.mjs.map +1 -0
- package/dist/chunk-O3XR7TW3.mjs +12 -0
- package/dist/chunk-O3XR7TW3.mjs.map +1 -0
- package/dist/chunk-OAPYSC2X.mjs +206 -0
- package/dist/chunk-OAPYSC2X.mjs.map +1 -0
- package/dist/{chunk-XE4EOKS4.mjs → chunk-ONJREDYY.mjs} +3 -23
- package/dist/chunk-ONJREDYY.mjs.map +1 -0
- package/dist/chunk-OVT2LUAM.js +197 -0
- package/dist/chunk-OVT2LUAM.js.map +1 -0
- package/dist/chunk-OWNGNGKL.js +331 -0
- package/dist/chunk-OWNGNGKL.js.map +1 -0
- package/dist/chunk-P7SXNZSV.js +298 -0
- package/dist/chunk-P7SXNZSV.js.map +1 -0
- package/dist/chunk-PFJOL3HI.mjs +71 -0
- package/dist/chunk-PFJOL3HI.mjs.map +1 -0
- package/dist/chunk-PPULMWJ6.js +295 -0
- package/dist/chunk-PPULMWJ6.js.map +1 -0
- package/dist/chunk-RGIVKACG.js +359 -0
- package/dist/chunk-RGIVKACG.js.map +1 -0
- package/dist/chunk-RPP5K2LP.js +870 -0
- package/dist/chunk-RPP5K2LP.js.map +1 -0
- package/dist/{chunk-7EON6Q4L.mjs → chunk-RUCHWUD7.mjs} +7651 -6370
- package/dist/chunk-RUCHWUD7.mjs.map +1 -0
- package/dist/chunk-SEVUIX4H.js +137 -0
- package/dist/chunk-SEVUIX4H.js.map +1 -0
- package/dist/chunk-SK2FSHFM.mjs +208 -0
- package/dist/chunk-SK2FSHFM.mjs.map +1 -0
- package/dist/chunk-T6EJ2GAV.mjs +294 -0
- package/dist/chunk-T6EJ2GAV.mjs.map +1 -0
- package/dist/chunk-ULBDOFZI.mjs +302 -0
- package/dist/chunk-ULBDOFZI.mjs.map +1 -0
- package/dist/chunk-V3JIELNV.js +241 -0
- package/dist/chunk-V3JIELNV.js.map +1 -0
- package/dist/chunk-V5E2KWMA.mjs +238 -0
- package/dist/chunk-V5E2KWMA.mjs.map +1 -0
- package/dist/chunk-VJA3ER6A.js +14 -0
- package/dist/chunk-VJA3ER6A.js.map +1 -0
- package/dist/chunk-VLI7ULX5.js +66 -0
- package/dist/chunk-VLI7ULX5.js.map +1 -0
- package/dist/chunk-WFGS5OFH.mjs +189 -0
- package/dist/chunk-WFGS5OFH.mjs.map +1 -0
- package/dist/chunk-WVC5GP24.mjs +96 -0
- package/dist/chunk-WVC5GP24.mjs.map +1 -0
- package/dist/chunk-YOSPWY5K.mjs +36 -0
- package/dist/chunk-YOSPWY5K.mjs.map +1 -0
- package/dist/chunk-ZFFXXLX7.js +205 -0
- package/dist/chunk-ZFFXXLX7.js.map +1 -0
- package/dist/client.js +512 -249
- package/dist/client.mjs +21 -2
- package/dist/components.js +393 -0
- package/dist/components.js.map +1 -0
- package/dist/components.mjs +8 -0
- package/dist/components.mjs.map +1 -0
- package/dist/config.js +17 -0
- package/dist/config.js.map +1 -0
- package/dist/config.mjs +4 -0
- package/dist/config.mjs.map +1 -0
- package/dist/contact.js +22 -0
- package/dist/contact.js.map +1 -0
- package/dist/contact.mjs +5 -0
- package/dist/contact.mjs.map +1 -0
- package/dist/contexts.js +51 -0
- package/dist/contexts.js.map +1 -0
- package/dist/contexts.mjs +6 -0
- package/dist/contexts.mjs.map +1 -0
- package/dist/finance.js +26 -0
- package/dist/finance.js.map +1 -0
- package/dist/finance.mjs +5 -0
- package/dist/finance.mjs.map +1 -0
- package/dist/icons.js +15 -0
- package/dist/icons.js.map +1 -0
- package/dist/icons.mjs +4 -0
- package/dist/icons.mjs.map +1 -0
- package/dist/index.js +512 -249
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +21 -2
- package/dist/index.mjs.map +1 -1
- package/dist/internal.js +1437 -0
- package/dist/internal.js.map +1 -0
- package/dist/internal.mjs +1404 -0
- package/dist/internal.mjs.map +1 -0
- package/dist/motion.js +51 -0
- package/dist/motion.js.map +1 -0
- package/dist/motion.mjs +38 -0
- package/dist/motion.mjs.map +1 -0
- package/dist/orders.js +22 -0
- package/dist/orders.js.map +1 -0
- package/dist/orders.mjs +5 -0
- package/dist/orders.mjs.map +1 -0
- package/dist/products.js +27 -0
- package/dist/products.js.map +1 -0
- package/dist/products.mjs +6 -0
- package/dist/products.mjs.map +1 -0
- package/dist/registry.js +44 -0
- package/dist/registry.js.map +1 -0
- package/dist/registry.mjs +7 -0
- package/dist/registry.mjs.map +1 -0
- package/dist/renderers.js +51 -0
- package/dist/renderers.js.map +1 -0
- package/dist/renderers.mjs +6 -0
- package/dist/renderers.mjs.map +1 -0
- package/dist/server.js +11 -189
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +3 -186
- package/dist/server.mjs.map +1 -1
- package/dist/types.js +37 -0
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +4 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils.js +160 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +7 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/wrappers.js +104 -0
- package/dist/wrappers.js.map +1 -0
- package/dist/wrappers.mjs +96 -0
- package/dist/wrappers.mjs.map +1 -0
- package/package.json +112 -9
- package/dist/api-vuL1Eg5L.d.mts +0 -2961
- package/dist/api-vuL1Eg5L.d.ts +0 -2961
- package/dist/chunk-3SZX6LHT.js.map +0 -1
- package/dist/chunk-7EON6Q4L.mjs.map +0 -1
- package/dist/chunk-WDY773GJ.js +0 -8308
- package/dist/chunk-WDY773GJ.js.map +0 -1
- package/dist/chunk-XE4EOKS4.mjs.map +0 -1
- package/dist/client.d.mts +0 -1461
- package/dist/client.d.ts +0 -1461
- package/dist/index.d.mts +0 -125
- package/dist/index.d.ts +0 -125
- package/dist/server.d.mts +0 -70
- package/dist/server.d.ts +0 -70
|
@@ -0,0 +1,833 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { DEFAULT_INSPECTOR_CONFIG, FIELD_TYPES } from './chunk-F5TFNWFJ.mjs';
|
|
3
|
+
import { __spreadProps, __spreadValues } from './chunk-YOSPWY5K.mjs';
|
|
4
|
+
|
|
5
|
+
// src/utils/generate-id.ts
|
|
6
|
+
function generatePageId(prefix = "page") {
|
|
7
|
+
return `${prefix}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
8
|
+
}
|
|
9
|
+
function generateSectionId(sectionType) {
|
|
10
|
+
return `${sectionType}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
11
|
+
}
|
|
12
|
+
function generateBlockId(blockType) {
|
|
13
|
+
return `${blockType}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
14
|
+
}
|
|
15
|
+
function generateHandle(title) {
|
|
16
|
+
return title.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
17
|
+
}
|
|
18
|
+
function generateThemeId(name) {
|
|
19
|
+
const handle = generateHandle(name);
|
|
20
|
+
return `${handle}-${Date.now()}`;
|
|
21
|
+
}
|
|
22
|
+
function generateId(prefix = "id") {
|
|
23
|
+
return `${prefix}-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// src/utils/block-finder.ts
|
|
27
|
+
function findBlockInSection(section, blockId) {
|
|
28
|
+
if (!(section == null ? void 0 : section.blocks)) return void 0;
|
|
29
|
+
for (const block of section.blocks) {
|
|
30
|
+
if (block.id === blockId) {
|
|
31
|
+
return block;
|
|
32
|
+
}
|
|
33
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
34
|
+
const found = findBlockInBlocks(block.blocks, blockId);
|
|
35
|
+
if (found) return found;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
function findBlockInBlocks(blocks, blockId) {
|
|
41
|
+
for (const block of blocks) {
|
|
42
|
+
if (block.id === blockId) {
|
|
43
|
+
return block;
|
|
44
|
+
}
|
|
45
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
46
|
+
const found = findBlockInBlocks(block.blocks, blockId);
|
|
47
|
+
if (found) return found;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return void 0;
|
|
51
|
+
}
|
|
52
|
+
function updateNestedBlock(section, blockId, updates) {
|
|
53
|
+
if (!section.blocks) return section;
|
|
54
|
+
return __spreadProps(__spreadValues({}, section), {
|
|
55
|
+
blocks: updateBlockInArray(section.blocks, blockId, updates)
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function updateBlockInArray(blocks, blockId, updates) {
|
|
59
|
+
return blocks.map((block) => {
|
|
60
|
+
if (block.id === blockId) {
|
|
61
|
+
return __spreadValues(__spreadValues({}, block), updates);
|
|
62
|
+
}
|
|
63
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
64
|
+
return __spreadProps(__spreadValues({}, block), {
|
|
65
|
+
blocks: updateBlockInArray(block.blocks, blockId, updates)
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return block;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
function removeNestedBlock(section, blockId) {
|
|
72
|
+
if (!section.blocks) return section;
|
|
73
|
+
return __spreadProps(__spreadValues({}, section), {
|
|
74
|
+
blocks: removeBlockFromArray(section.blocks, blockId)
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
function removeBlockFromArray(blocks, blockId) {
|
|
78
|
+
return blocks.filter((block) => block.id !== blockId).map((block) => {
|
|
79
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
80
|
+
return __spreadProps(__spreadValues({}, block), {
|
|
81
|
+
blocks: removeBlockFromArray(block.blocks, blockId)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
return block;
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function getBlockPath(section, blockId) {
|
|
88
|
+
if (!(section == null ? void 0 : section.blocks)) return [];
|
|
89
|
+
for (const block of section.blocks) {
|
|
90
|
+
if (block.id === blockId) {
|
|
91
|
+
return [block.id];
|
|
92
|
+
}
|
|
93
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
94
|
+
const path = getBlockPathInBlocks(block.blocks, blockId);
|
|
95
|
+
if (path.length > 0) {
|
|
96
|
+
return [block.id, ...path];
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
function getBlockPathInBlocks(blocks, blockId) {
|
|
103
|
+
for (const block of blocks) {
|
|
104
|
+
if (block.id === blockId) {
|
|
105
|
+
return [block.id];
|
|
106
|
+
}
|
|
107
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
108
|
+
const path = getBlockPathInBlocks(block.blocks, blockId);
|
|
109
|
+
if (path.length > 0) {
|
|
110
|
+
return [block.id, ...path];
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// src/utils/component-finder.ts
|
|
118
|
+
function findComponentInSection(section, componentId) {
|
|
119
|
+
if (!section) return null;
|
|
120
|
+
if (section.components) {
|
|
121
|
+
const directComponent = section.components.find(
|
|
122
|
+
(c) => c.id === componentId
|
|
123
|
+
);
|
|
124
|
+
if (directComponent) {
|
|
125
|
+
return directComponent;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
if (section.blocks && section.blocks.length > 0) {
|
|
129
|
+
const found = findComponentInBlocks(section.blocks, componentId);
|
|
130
|
+
if (found) return found;
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
function findComponentInBlocks(blocks, componentId) {
|
|
135
|
+
for (const block of blocks) {
|
|
136
|
+
if (block.components) {
|
|
137
|
+
const component = block.components.find((c) => c.id === componentId);
|
|
138
|
+
if (component) {
|
|
139
|
+
return component;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
143
|
+
const found = findComponentInBlocks(block.blocks, componentId);
|
|
144
|
+
if (found) return found;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
function getComponentPath(section, componentId) {
|
|
150
|
+
if (!section) return null;
|
|
151
|
+
if (section.components) {
|
|
152
|
+
const directComponent = section.components.find(
|
|
153
|
+
(c) => c.id === componentId
|
|
154
|
+
);
|
|
155
|
+
if (directComponent) {
|
|
156
|
+
return {
|
|
157
|
+
sectionId: section.id,
|
|
158
|
+
blockPath: [],
|
|
159
|
+
componentId
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (section.blocks && section.blocks.length > 0) {
|
|
164
|
+
const blockPath = getComponentPathInBlocks(section.blocks, componentId);
|
|
165
|
+
if (blockPath.length > 0) {
|
|
166
|
+
return {
|
|
167
|
+
sectionId: section.id,
|
|
168
|
+
blockPath,
|
|
169
|
+
componentId
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
function getComponentPathInBlocks(blocks, componentId) {
|
|
176
|
+
for (const block of blocks) {
|
|
177
|
+
if (block.components) {
|
|
178
|
+
const component = block.components.find((c) => c.id === componentId);
|
|
179
|
+
if (component) {
|
|
180
|
+
return [block.id];
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
184
|
+
const path = getComponentPathInBlocks(block.blocks, componentId);
|
|
185
|
+
if (path.length > 0) {
|
|
186
|
+
return [block.id, ...path];
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// src/utils/component-updater.ts
|
|
194
|
+
function updateNestedComponent(section, componentId, updates) {
|
|
195
|
+
let updatedComponents = section.components;
|
|
196
|
+
if (updatedComponents && updatedComponents.length > 0) {
|
|
197
|
+
updatedComponents = updatedComponents.map((component) => {
|
|
198
|
+
var _a, _b;
|
|
199
|
+
if (component.id === componentId) {
|
|
200
|
+
return __spreadProps(__spreadValues(__spreadValues({}, component), updates), {
|
|
201
|
+
// Deep merge content and style if provided
|
|
202
|
+
content: updates.content ? __spreadValues(__spreadValues({}, (_a = component.content) != null ? _a : {}), updates.content) : component.content,
|
|
203
|
+
style: updates.style ? __spreadValues(__spreadValues({}, (_b = component.style) != null ? _b : {}), updates.style) : component.style
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
return component;
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
let updatedBlocks = section.blocks;
|
|
210
|
+
if (updatedBlocks && updatedBlocks.length > 0) {
|
|
211
|
+
updatedBlocks = updateComponentInBlocks(
|
|
212
|
+
updatedBlocks,
|
|
213
|
+
componentId,
|
|
214
|
+
updates
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
return __spreadProps(__spreadValues({}, section), {
|
|
218
|
+
components: updatedComponents,
|
|
219
|
+
blocks: updatedBlocks
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
function updateComponentInBlocks(blocks, componentId, updates) {
|
|
223
|
+
return blocks.map((block) => {
|
|
224
|
+
const updatedBlock = __spreadValues({}, block);
|
|
225
|
+
if (block.components && block.components.length > 0) {
|
|
226
|
+
updatedBlock.components = block.components.map((component) => {
|
|
227
|
+
var _a, _b;
|
|
228
|
+
if (component.id === componentId) {
|
|
229
|
+
return __spreadProps(__spreadValues(__spreadValues({}, component), updates), {
|
|
230
|
+
type: component.type,
|
|
231
|
+
// Deep merge content and style if provided
|
|
232
|
+
content: updates.content ? __spreadValues(__spreadValues({}, (_a = component.content) != null ? _a : {}), updates.content) : component.content,
|
|
233
|
+
style: updates.style ? __spreadValues(__spreadValues({}, (_b = component.style) != null ? _b : {}), updates.style) : component.style
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return component;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
if (block.blocks && block.blocks.length > 0) {
|
|
240
|
+
updatedBlock.blocks = updateComponentInBlocks(
|
|
241
|
+
block.blocks,
|
|
242
|
+
componentId,
|
|
243
|
+
updates
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
return updatedBlock;
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// src/utils/section-helpers.ts
|
|
251
|
+
function sortComponents(components) {
|
|
252
|
+
return [...components].sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
253
|
+
}
|
|
254
|
+
function filterEnabledComponents(components) {
|
|
255
|
+
return components.filter((component) => component.enabled !== false);
|
|
256
|
+
}
|
|
257
|
+
function getActiveComponents(components) {
|
|
258
|
+
return sortComponents(filterEnabledComponents(components));
|
|
259
|
+
}
|
|
260
|
+
function groupBySlot(components, slotConfig) {
|
|
261
|
+
const slots = {};
|
|
262
|
+
const ungrouped = [];
|
|
263
|
+
for (const slotName in slotConfig) {
|
|
264
|
+
slots[slotName] = [];
|
|
265
|
+
}
|
|
266
|
+
const typeToSlot = {};
|
|
267
|
+
for (const [slotName, types] of Object.entries(slotConfig)) {
|
|
268
|
+
for (const type of types) {
|
|
269
|
+
typeToSlot[type] = slotName;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
for (const component of components) {
|
|
273
|
+
if (component.enabled === false) continue;
|
|
274
|
+
const slotName = typeToSlot[component.type];
|
|
275
|
+
if (slotName) {
|
|
276
|
+
slots[slotName].push(component);
|
|
277
|
+
} else {
|
|
278
|
+
ungrouped.push(component);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
for (const slotName in slots) {
|
|
282
|
+
slots[slotName] = sortComponents(slots[slotName]);
|
|
283
|
+
}
|
|
284
|
+
ungrouped.sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
285
|
+
return { slots, ungrouped };
|
|
286
|
+
}
|
|
287
|
+
function getComponentsByType(components, types) {
|
|
288
|
+
const typeArray = Array.isArray(types) ? types : [types];
|
|
289
|
+
return components.filter(
|
|
290
|
+
(component) => component.enabled !== false && typeArray.includes(component.type)
|
|
291
|
+
).sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
292
|
+
}
|
|
293
|
+
function getFirstComponentByType(components, types) {
|
|
294
|
+
const typeArray = Array.isArray(types) ? types : [types];
|
|
295
|
+
return components.find(
|
|
296
|
+
(component) => component.enabled !== false && typeArray.includes(component.type)
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
function hasComponentType(components, types) {
|
|
300
|
+
const typeArray = Array.isArray(types) ? types : [types];
|
|
301
|
+
return components.some(
|
|
302
|
+
(component) => component.enabled !== false && typeArray.includes(component.type)
|
|
303
|
+
);
|
|
304
|
+
}
|
|
305
|
+
function sortBlocks(blocks) {
|
|
306
|
+
return [...blocks].sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
307
|
+
}
|
|
308
|
+
function filterEnabledBlocks(blocks) {
|
|
309
|
+
return blocks.filter((block) => block.enabled !== false);
|
|
310
|
+
}
|
|
311
|
+
function getActiveBlocks(blocks) {
|
|
312
|
+
return sortBlocks(filterEnabledBlocks(blocks));
|
|
313
|
+
}
|
|
314
|
+
function countEnabledItems(items) {
|
|
315
|
+
return items.filter((item) => item.enabled !== false).length;
|
|
316
|
+
}
|
|
317
|
+
function hasEnabledItems(items) {
|
|
318
|
+
return !!items && countEnabledItems(items) > 0;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
// src/utils/inspector-utils.ts
|
|
322
|
+
function getElementLabel(result) {
|
|
323
|
+
switch (result.type) {
|
|
324
|
+
case "component":
|
|
325
|
+
return result.componentType || "Component";
|
|
326
|
+
case "block": {
|
|
327
|
+
const blockElement = result.element || document.querySelector(`[data-block-id="${result.blockId}"]`);
|
|
328
|
+
const blockType = blockElement == null ? void 0 : blockElement.getAttribute("data-block-type");
|
|
329
|
+
if (blockType) {
|
|
330
|
+
return blockType.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
331
|
+
}
|
|
332
|
+
return "Block";
|
|
333
|
+
}
|
|
334
|
+
case "section": {
|
|
335
|
+
const element = result.element || document.querySelector(`[data-section-id="${result.sectionId}"]`);
|
|
336
|
+
const sectionName = element == null ? void 0 : element.getAttribute("data-section-name");
|
|
337
|
+
if (sectionName) {
|
|
338
|
+
return sectionName;
|
|
339
|
+
}
|
|
340
|
+
const sectionType = element == null ? void 0 : element.getAttribute("data-section-type");
|
|
341
|
+
if (sectionType) {
|
|
342
|
+
return sectionType.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
343
|
+
}
|
|
344
|
+
return "Section";
|
|
345
|
+
}
|
|
346
|
+
default:
|
|
347
|
+
return "Unknown";
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function getSelectionColor(type) {
|
|
351
|
+
return DEFAULT_INSPECTOR_CONFIG.outlineColors[type] || "#999999";
|
|
352
|
+
}
|
|
353
|
+
function formatBlockName(name) {
|
|
354
|
+
return name.split("-").map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// src/utils/adapters.ts
|
|
358
|
+
function toComponentInstance(component) {
|
|
359
|
+
var _a, _b, _c;
|
|
360
|
+
const content = (_b = (_a = component.content) != null ? _a : component.settings) != null ? _b : {};
|
|
361
|
+
const style = (_c = component.style) != null ? _c : {};
|
|
362
|
+
return {
|
|
363
|
+
id: component.id,
|
|
364
|
+
type: component.type,
|
|
365
|
+
content,
|
|
366
|
+
style,
|
|
367
|
+
responsiveStyle: void 0,
|
|
368
|
+
styleMode: "basic",
|
|
369
|
+
order: component.order,
|
|
370
|
+
enabled: component.enabled,
|
|
371
|
+
createdAt: component.createdAt,
|
|
372
|
+
updatedAt: component.updatedAt
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// src/utils/section/validation.ts
|
|
377
|
+
function validateFieldValue(fieldDef, value) {
|
|
378
|
+
if (fieldDef.required && (value === void 0 || value === null)) {
|
|
379
|
+
return {
|
|
380
|
+
field: fieldDef.id,
|
|
381
|
+
value,
|
|
382
|
+
message: `Field '${fieldDef.id}' is required but was not provided`
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
if (value === void 0 || value === null) {
|
|
386
|
+
return null;
|
|
387
|
+
}
|
|
388
|
+
switch (fieldDef.type) {
|
|
389
|
+
case FIELD_TYPES.SELECT:
|
|
390
|
+
case FIELD_TYPES.RADIO: {
|
|
391
|
+
const options = fieldDef.options || [];
|
|
392
|
+
const allowedValues = options.map((opt) => opt.value);
|
|
393
|
+
if (!allowedValues.includes(value)) {
|
|
394
|
+
return {
|
|
395
|
+
field: fieldDef.id,
|
|
396
|
+
value,
|
|
397
|
+
message: `Value '${value}' for field '${fieldDef.id}' is not in allowed options`,
|
|
398
|
+
allowedValues
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
break;
|
|
402
|
+
}
|
|
403
|
+
case FIELD_TYPES.NUMBER:
|
|
404
|
+
case FIELD_TYPES.RANGE: {
|
|
405
|
+
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
406
|
+
return {
|
|
407
|
+
field: fieldDef.id,
|
|
408
|
+
value,
|
|
409
|
+
message: `Field '${fieldDef.id}' must be a number, got '${typeof value}'`
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
if (fieldDef.min !== void 0 && value < fieldDef.min) {
|
|
413
|
+
return {
|
|
414
|
+
field: fieldDef.id,
|
|
415
|
+
value,
|
|
416
|
+
message: `Value ${value} for field '${fieldDef.id}' is below minimum ${fieldDef.min}`
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
if (fieldDef.max !== void 0 && value > fieldDef.max) {
|
|
420
|
+
return {
|
|
421
|
+
field: fieldDef.id,
|
|
422
|
+
value,
|
|
423
|
+
message: `Value ${value} for field '${fieldDef.id}' is above maximum ${fieldDef.max}`
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
break;
|
|
427
|
+
}
|
|
428
|
+
case FIELD_TYPES.TEXT:
|
|
429
|
+
case FIELD_TYPES.TEXTAREA: {
|
|
430
|
+
const strValue = String(value);
|
|
431
|
+
if (fieldDef.maxLength && strValue.length > fieldDef.maxLength) {
|
|
432
|
+
return {
|
|
433
|
+
field: fieldDef.id,
|
|
434
|
+
value,
|
|
435
|
+
message: `Field '${fieldDef.id}' exceeds maximum length of ${fieldDef.maxLength}`
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
440
|
+
case FIELD_TYPES.URL: {
|
|
441
|
+
const urlValue = String(value);
|
|
442
|
+
if (!urlValue.startsWith("/") && !urlValue.startsWith("http://") && !urlValue.startsWith("https://") && !urlValue.startsWith("#")) {
|
|
443
|
+
return {
|
|
444
|
+
field: fieldDef.id,
|
|
445
|
+
value,
|
|
446
|
+
message: `Field '${fieldDef.id}' with value '${urlValue}' is not a valid URL`
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
break;
|
|
450
|
+
}
|
|
451
|
+
case FIELD_TYPES.BOOLEAN:
|
|
452
|
+
case FIELD_TYPES.CHECKBOX: {
|
|
453
|
+
if (typeof value !== "boolean") {
|
|
454
|
+
return {
|
|
455
|
+
field: fieldDef.id,
|
|
456
|
+
value,
|
|
457
|
+
message: `Field '${fieldDef.id}' must be a boolean, got '${typeof value}'`
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
return null;
|
|
464
|
+
}
|
|
465
|
+
function validateSettings(section, schema) {
|
|
466
|
+
var _a;
|
|
467
|
+
const errors = [];
|
|
468
|
+
for (const fieldDef of schema.settings) {
|
|
469
|
+
const value = (_a = section.settings) == null ? void 0 : _a[fieldDef.id];
|
|
470
|
+
const error = validateFieldValue(fieldDef, value);
|
|
471
|
+
if (error) {
|
|
472
|
+
errors.push(error);
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
return {
|
|
476
|
+
valid: errors.length === 0,
|
|
477
|
+
errors
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
function validateSection(section, schema) {
|
|
481
|
+
return validateSettings(section, schema);
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// src/utils/section/extraction.ts
|
|
485
|
+
function extractSettings(section, schema) {
|
|
486
|
+
var _a, _b, _c;
|
|
487
|
+
const result = {};
|
|
488
|
+
for (const fieldDef of schema.settings) {
|
|
489
|
+
const fieldId = fieldDef.id;
|
|
490
|
+
const runtimeValue = (_a = section.settings) == null ? void 0 : _a[fieldId];
|
|
491
|
+
const defaultValue = (_c = (_b = schema.defaults[fieldId]) != null ? _b : fieldDef.default) != null ? _c : void 0;
|
|
492
|
+
if (runtimeValue !== void 0 && runtimeValue !== null) {
|
|
493
|
+
const error = validateFieldValue(fieldDef, runtimeValue);
|
|
494
|
+
if (error) {
|
|
495
|
+
if (process.env.NODE_ENV === "development") {
|
|
496
|
+
console.warn(
|
|
497
|
+
`[Section Validation] ${error.message}. Using default: "${defaultValue}"`
|
|
498
|
+
);
|
|
499
|
+
}
|
|
500
|
+
result[fieldId] = defaultValue;
|
|
501
|
+
} else {
|
|
502
|
+
result[fieldId] = runtimeValue;
|
|
503
|
+
}
|
|
504
|
+
} else {
|
|
505
|
+
result[fieldId] = defaultValue;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
return result;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// src/utils/section/conversion.ts
|
|
512
|
+
function autoConvertValue(fieldDef, value) {
|
|
513
|
+
if (value == null) return value;
|
|
514
|
+
switch (fieldDef.type) {
|
|
515
|
+
// String types
|
|
516
|
+
case FIELD_TYPES.TEXT:
|
|
517
|
+
case FIELD_TYPES.TEXTAREA:
|
|
518
|
+
case FIELD_TYPES.URL:
|
|
519
|
+
case FIELD_TYPES.COLOR:
|
|
520
|
+
case FIELD_TYPES.SELECT:
|
|
521
|
+
case FIELD_TYPES.RADIO:
|
|
522
|
+
case FIELD_TYPES.RICHTEXT:
|
|
523
|
+
case FIELD_TYPES.IMAGE:
|
|
524
|
+
case FIELD_TYPES.VIDEO:
|
|
525
|
+
case FIELD_TYPES.FONT:
|
|
526
|
+
return String(value);
|
|
527
|
+
// Number types
|
|
528
|
+
case FIELD_TYPES.NUMBER:
|
|
529
|
+
case FIELD_TYPES.RANGE:
|
|
530
|
+
return Number(value);
|
|
531
|
+
// Boolean types
|
|
532
|
+
case FIELD_TYPES.BOOLEAN:
|
|
533
|
+
case FIELD_TYPES.CHECKBOX:
|
|
534
|
+
return Boolean(value);
|
|
535
|
+
// Array types
|
|
536
|
+
case FIELD_TYPES.ARRAY:
|
|
537
|
+
case FIELD_TYPES.REPEATER:
|
|
538
|
+
return Array.isArray(value) ? value : [];
|
|
539
|
+
// Complex types (return as-is)
|
|
540
|
+
case FIELD_TYPES.COLLECTION:
|
|
541
|
+
case FIELD_TYPES.PRODUCT:
|
|
542
|
+
case FIELD_TYPES.BLOG:
|
|
543
|
+
case FIELD_TYPES.ARTICLE:
|
|
544
|
+
case FIELD_TYPES.PAGE:
|
|
545
|
+
return value;
|
|
546
|
+
default:
|
|
547
|
+
return value;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
function createValueProxy(values, definitions) {
|
|
551
|
+
return new Proxy(values, {
|
|
552
|
+
get(target, prop) {
|
|
553
|
+
const value = target[prop];
|
|
554
|
+
const fieldDef = definitions.find((f) => f.id === prop);
|
|
555
|
+
if (!fieldDef) {
|
|
556
|
+
return value;
|
|
557
|
+
}
|
|
558
|
+
return autoConvertValue(fieldDef, value);
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// src/utils/section/index.ts
|
|
564
|
+
function getSectionValues(section, schema) {
|
|
565
|
+
const settingsValues = extractSettings(section, schema);
|
|
566
|
+
const validation = validateSection(section, schema);
|
|
567
|
+
return {
|
|
568
|
+
settings: createValueProxy(settingsValues, schema.settings),
|
|
569
|
+
isValid: validation.valid,
|
|
570
|
+
errors: validation.errors
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
|
|
574
|
+
// src/utils/component/validation.ts
|
|
575
|
+
function validateFieldValue2(fieldDef, value) {
|
|
576
|
+
if (value === void 0 || value === null) {
|
|
577
|
+
if (fieldDef.required) {
|
|
578
|
+
return {
|
|
579
|
+
field: fieldDef.id,
|
|
580
|
+
value,
|
|
581
|
+
message: `Field "${fieldDef.label}" is required`
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
return null;
|
|
585
|
+
}
|
|
586
|
+
switch (fieldDef.type) {
|
|
587
|
+
case FIELD_TYPES.SELECT:
|
|
588
|
+
case FIELD_TYPES.RADIO: {
|
|
589
|
+
const selectDef = fieldDef;
|
|
590
|
+
const allowedValues = selectDef.options.map((opt) => opt.value);
|
|
591
|
+
if (!allowedValues.includes(String(value))) {
|
|
592
|
+
return {
|
|
593
|
+
field: fieldDef.id,
|
|
594
|
+
value,
|
|
595
|
+
message: `Value "${value}" is not in allowed options for field "${fieldDef.label}"`,
|
|
596
|
+
allowedValues
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
case FIELD_TYPES.NUMBER:
|
|
602
|
+
case FIELD_TYPES.RANGE: {
|
|
603
|
+
const numberDef = fieldDef;
|
|
604
|
+
const numValue = Number(value);
|
|
605
|
+
if (isNaN(numValue)) {
|
|
606
|
+
return {
|
|
607
|
+
field: fieldDef.id,
|
|
608
|
+
value,
|
|
609
|
+
message: `Value "${value}" for field "${fieldDef.label}" must be a number`
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
if (numberDef.min !== void 0 && numValue < numberDef.min) {
|
|
613
|
+
return {
|
|
614
|
+
field: fieldDef.id,
|
|
615
|
+
value,
|
|
616
|
+
message: `Value ${numValue} for field "${fieldDef.label}" is below minimum ${numberDef.min}`
|
|
617
|
+
};
|
|
618
|
+
}
|
|
619
|
+
if (numberDef.max !== void 0 && numValue > numberDef.max) {
|
|
620
|
+
return {
|
|
621
|
+
field: fieldDef.id,
|
|
622
|
+
value,
|
|
623
|
+
message: `Value ${numValue} for field "${fieldDef.label}" is above maximum ${numberDef.max}`
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
break;
|
|
627
|
+
}
|
|
628
|
+
case FIELD_TYPES.TEXT:
|
|
629
|
+
case FIELD_TYPES.TEXTAREA: {
|
|
630
|
+
const textDef = fieldDef;
|
|
631
|
+
const strValue = String(value);
|
|
632
|
+
if (textDef.maxLength && strValue.length > textDef.maxLength) {
|
|
633
|
+
return {
|
|
634
|
+
field: fieldDef.id,
|
|
635
|
+
value,
|
|
636
|
+
message: `Text for field "${fieldDef.label}" exceeds maximum length of ${textDef.maxLength}`
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
case FIELD_TYPES.BOOLEAN:
|
|
642
|
+
case FIELD_TYPES.CHECKBOX: {
|
|
643
|
+
if (typeof value !== "boolean") {
|
|
644
|
+
return {
|
|
645
|
+
field: fieldDef.id,
|
|
646
|
+
value,
|
|
647
|
+
message: `Value "${value}" for field "${fieldDef.label}" must be a boolean`
|
|
648
|
+
};
|
|
649
|
+
}
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
case FIELD_TYPES.URL: {
|
|
653
|
+
const strValue = String(value);
|
|
654
|
+
if (!strValue.startsWith("#") && !strValue.startsWith("/") && !strValue.startsWith("http")) {
|
|
655
|
+
return {
|
|
656
|
+
field: fieldDef.id,
|
|
657
|
+
value,
|
|
658
|
+
message: `Value "${value}" for field "${fieldDef.label}" is not a valid URL`
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
break;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
return null;
|
|
665
|
+
}
|
|
666
|
+
function validateContent(component, definition) {
|
|
667
|
+
const errors = [];
|
|
668
|
+
for (const fieldDef of definition.contentSettings) {
|
|
669
|
+
const value = component.content[fieldDef.id];
|
|
670
|
+
const error = validateFieldValue2(fieldDef, value);
|
|
671
|
+
if (error) {
|
|
672
|
+
errors.push(error);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
return {
|
|
676
|
+
valid: errors.length === 0,
|
|
677
|
+
errors
|
|
678
|
+
};
|
|
679
|
+
}
|
|
680
|
+
function validateStyle(component, definition) {
|
|
681
|
+
const errors = [];
|
|
682
|
+
const allStyleSettings = [
|
|
683
|
+
...definition.basicStyleSettings,
|
|
684
|
+
...definition.advancedStyleSettings
|
|
685
|
+
];
|
|
686
|
+
for (const fieldDef of allStyleSettings) {
|
|
687
|
+
const value = component.style[fieldDef.id];
|
|
688
|
+
const error = validateFieldValue2(fieldDef, value);
|
|
689
|
+
if (error) {
|
|
690
|
+
errors.push(error);
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
return {
|
|
694
|
+
valid: errors.length === 0,
|
|
695
|
+
errors
|
|
696
|
+
};
|
|
697
|
+
}
|
|
698
|
+
function validateComponent(component, definition) {
|
|
699
|
+
const contentValidation = validateContent(component, definition);
|
|
700
|
+
const styleValidation = validateStyle(component, definition);
|
|
701
|
+
return {
|
|
702
|
+
valid: contentValidation.valid && styleValidation.valid,
|
|
703
|
+
errors: [...contentValidation.errors, ...styleValidation.errors]
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
// src/utils/component/extraction.ts
|
|
708
|
+
function extractContent(component, definition) {
|
|
709
|
+
var _a, _b;
|
|
710
|
+
const result = {};
|
|
711
|
+
for (const fieldDef of definition.contentSettings) {
|
|
712
|
+
const fieldId = fieldDef.id;
|
|
713
|
+
const runtimeValue = component.content[fieldId];
|
|
714
|
+
const defaultValue = (_b = (_a = definition.contentDefaults[fieldId]) != null ? _a : fieldDef.default) != null ? _b : void 0;
|
|
715
|
+
if (runtimeValue !== void 0 && runtimeValue !== null) {
|
|
716
|
+
const error = validateFieldValue2(fieldDef, runtimeValue);
|
|
717
|
+
if (error) {
|
|
718
|
+
if (process.env.NODE_ENV === "development") {
|
|
719
|
+
console.warn(
|
|
720
|
+
`[Component Validation] ${error.message}. Using default: "${defaultValue}"`
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
result[fieldId] = defaultValue;
|
|
724
|
+
} else {
|
|
725
|
+
result[fieldId] = runtimeValue;
|
|
726
|
+
}
|
|
727
|
+
} else {
|
|
728
|
+
result[fieldId] = defaultValue;
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
return result;
|
|
732
|
+
}
|
|
733
|
+
function extractStyle(component, definition) {
|
|
734
|
+
var _a, _b;
|
|
735
|
+
const result = {};
|
|
736
|
+
const allStyleSettings = [
|
|
737
|
+
...definition.basicStyleSettings,
|
|
738
|
+
...definition.advancedStyleSettings
|
|
739
|
+
];
|
|
740
|
+
for (const fieldDef of allStyleSettings) {
|
|
741
|
+
const fieldId = fieldDef.id;
|
|
742
|
+
const runtimeValue = component.style[fieldId];
|
|
743
|
+
const defaultValue = (_b = (_a = definition.styleDefaults[fieldId]) != null ? _a : fieldDef.default) != null ? _b : void 0;
|
|
744
|
+
if (runtimeValue !== void 0 && runtimeValue !== null) {
|
|
745
|
+
const error = validateFieldValue2(fieldDef, runtimeValue);
|
|
746
|
+
if (error) {
|
|
747
|
+
if (process.env.NODE_ENV === "development") {
|
|
748
|
+
console.warn(
|
|
749
|
+
`[Component Validation] ${error.message}. Using default: "${defaultValue}"`
|
|
750
|
+
);
|
|
751
|
+
}
|
|
752
|
+
result[fieldId] = defaultValue;
|
|
753
|
+
} else {
|
|
754
|
+
result[fieldId] = runtimeValue;
|
|
755
|
+
}
|
|
756
|
+
} else {
|
|
757
|
+
result[fieldId] = defaultValue;
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
return result;
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
// src/utils/component/conversion.ts
|
|
764
|
+
function autoConvertValue2(fieldDef, value) {
|
|
765
|
+
if (value == null) return value;
|
|
766
|
+
switch (fieldDef.type) {
|
|
767
|
+
// String types
|
|
768
|
+
case FIELD_TYPES.TEXT:
|
|
769
|
+
case FIELD_TYPES.TEXTAREA:
|
|
770
|
+
case FIELD_TYPES.URL:
|
|
771
|
+
case FIELD_TYPES.COLOR:
|
|
772
|
+
case FIELD_TYPES.SELECT:
|
|
773
|
+
case FIELD_TYPES.RADIO:
|
|
774
|
+
case FIELD_TYPES.RICHTEXT:
|
|
775
|
+
case FIELD_TYPES.IMAGE:
|
|
776
|
+
case FIELD_TYPES.VIDEO:
|
|
777
|
+
case FIELD_TYPES.FONT:
|
|
778
|
+
return String(value);
|
|
779
|
+
// Number types
|
|
780
|
+
case FIELD_TYPES.NUMBER:
|
|
781
|
+
case FIELD_TYPES.RANGE:
|
|
782
|
+
return Number(value);
|
|
783
|
+
// Boolean types
|
|
784
|
+
case FIELD_TYPES.BOOLEAN:
|
|
785
|
+
case FIELD_TYPES.CHECKBOX:
|
|
786
|
+
return Boolean(value);
|
|
787
|
+
// Array types
|
|
788
|
+
case FIELD_TYPES.ARRAY:
|
|
789
|
+
case FIELD_TYPES.REPEATER:
|
|
790
|
+
return Array.isArray(value) ? value : [];
|
|
791
|
+
// Complex types (return as-is)
|
|
792
|
+
case FIELD_TYPES.COLLECTION:
|
|
793
|
+
case FIELD_TYPES.PRODUCT:
|
|
794
|
+
case FIELD_TYPES.BLOG:
|
|
795
|
+
case FIELD_TYPES.ARTICLE:
|
|
796
|
+
case FIELD_TYPES.PAGE:
|
|
797
|
+
return value;
|
|
798
|
+
default:
|
|
799
|
+
return value;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
function createValueProxy2(values, definitions) {
|
|
803
|
+
return new Proxy(values, {
|
|
804
|
+
get(target, prop) {
|
|
805
|
+
const value = target[prop];
|
|
806
|
+
const fieldDef = definitions.find((f) => f.id === prop);
|
|
807
|
+
if (!fieldDef) {
|
|
808
|
+
return value;
|
|
809
|
+
}
|
|
810
|
+
return autoConvertValue2(fieldDef, value);
|
|
811
|
+
}
|
|
812
|
+
});
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
// src/utils/component/index.ts
|
|
816
|
+
function getComponentValues(component, definition) {
|
|
817
|
+
const contentValues = extractContent(component, definition);
|
|
818
|
+
const styleValues = extractStyle(component, definition);
|
|
819
|
+
const validation = validateComponent(component, definition);
|
|
820
|
+
return {
|
|
821
|
+
content: createValueProxy2(contentValues, definition.contentSettings),
|
|
822
|
+
style: createValueProxy2(styleValues, [
|
|
823
|
+
...definition.basicStyleSettings,
|
|
824
|
+
...definition.advancedStyleSettings
|
|
825
|
+
]),
|
|
826
|
+
isValid: validation.valid,
|
|
827
|
+
errors: validation.errors
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
export { countEnabledItems, filterEnabledBlocks, filterEnabledComponents, findBlockInSection, findComponentInSection, formatBlockName, generateBlockId, generateHandle, generateId, generatePageId, generateSectionId, generateThemeId, getActiveBlocks, getActiveComponents, getBlockPath, getComponentPath, getComponentValues, getComponentsByType, getElementLabel, getFirstComponentByType, getSectionValues, getSelectionColor, groupBySlot, hasComponentType, hasEnabledItems, removeNestedBlock, sortBlocks, sortComponents, toComponentInstance, updateNestedBlock, updateNestedComponent, validateComponent, validateContent, validateSection, validateSettings, validateStyle };
|
|
832
|
+
//# sourceMappingURL=chunk-NHOIGGYU.mjs.map
|
|
833
|
+
//# sourceMappingURL=chunk-NHOIGGYU.mjs.map
|