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