@gem-sdk/core 1.53.0-dev.121 → 1.53.0-dev.124
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.
|
@@ -35,7 +35,7 @@ const componentIconList = [
|
|
|
35
35
|
const componentUsingAdvanced = [
|
|
36
36
|
'IconList'
|
|
37
37
|
];
|
|
38
|
-
const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageContext, ...passProps })=>{
|
|
38
|
+
const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageContext, largeComponent = [], sizeLargeComponent = 50, ...passProps })=>{
|
|
39
39
|
const item = builder[uid];
|
|
40
40
|
const Component = components[item?.tag];
|
|
41
41
|
if (!Component) {
|
|
@@ -74,6 +74,8 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
74
74
|
advanced: item.advanced,
|
|
75
75
|
parentId: componentsRenderWithParentId.includes(item.tag) ? parentId : null,
|
|
76
76
|
pageContext,
|
|
77
|
+
largeComponent,
|
|
78
|
+
sizeLargeComponent,
|
|
77
79
|
...passProps,
|
|
78
80
|
builderAttrs: {
|
|
79
81
|
...passProps.builderAttrs
|
|
@@ -85,7 +87,9 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
85
87
|
builder,
|
|
86
88
|
components,
|
|
87
89
|
customProps,
|
|
88
|
-
pageContext
|
|
90
|
+
pageContext,
|
|
91
|
+
largeComponent,
|
|
92
|
+
sizeLargeComponent
|
|
89
93
|
};
|
|
90
94
|
}),
|
|
91
95
|
children: !constant.customRenderChildren.includes(item.tag) ? WrapRenderChildren({
|
|
@@ -97,11 +101,13 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
97
101
|
components,
|
|
98
102
|
customProps,
|
|
99
103
|
parentTag: item.tag,
|
|
100
|
-
pageContext
|
|
104
|
+
pageContext,
|
|
105
|
+
largeComponent,
|
|
106
|
+
sizeLargeComponent
|
|
101
107
|
}))) : ''
|
|
102
108
|
});
|
|
103
109
|
}, ()=>{
|
|
104
|
-
|
|
110
|
+
const liquid = Component({
|
|
105
111
|
builderProps: {
|
|
106
112
|
uid,
|
|
107
113
|
builderData: item
|
|
@@ -113,11 +119,17 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
113
119
|
isText: componentTexts.includes(item.tag) ? true : null,
|
|
114
120
|
parentId: componentsRenderWithParentId.includes(item.tag) ? parentId : null,
|
|
115
121
|
pageContext,
|
|
122
|
+
largeComponent,
|
|
123
|
+
sizeLargeComponent,
|
|
116
124
|
...passProps,
|
|
117
125
|
builderAttrs: {
|
|
118
126
|
...passProps.builderAttrs
|
|
119
127
|
}
|
|
120
128
|
});
|
|
129
|
+
if (isLimitSize(liquid, sizeLargeComponent)) {
|
|
130
|
+
largeComponent.push(item.uid);
|
|
131
|
+
}
|
|
132
|
+
return liquid;
|
|
121
133
|
});
|
|
122
134
|
} else {
|
|
123
135
|
liquid = render.template`<div gp-el-wrapper style="${!componentIconList.includes(item.tag) ? style : ''}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
|
|
@@ -134,6 +146,8 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
134
146
|
cssClass: item?.advanced?.cssClass
|
|
135
147
|
},
|
|
136
148
|
pageContext,
|
|
149
|
+
largeComponent,
|
|
150
|
+
sizeLargeComponent,
|
|
137
151
|
...passProps,
|
|
138
152
|
builderAttrs: {
|
|
139
153
|
...passProps.builderAttrs
|
|
@@ -145,7 +159,9 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
145
159
|
builder,
|
|
146
160
|
components,
|
|
147
161
|
customProps,
|
|
148
|
-
pageContext
|
|
162
|
+
pageContext,
|
|
163
|
+
largeComponent,
|
|
164
|
+
sizeLargeComponent
|
|
149
165
|
};
|
|
150
166
|
}),
|
|
151
167
|
children: !constant.customRenderChildren.includes(item.tag) ? WrapRenderChildren({
|
|
@@ -157,11 +173,13 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
157
173
|
components,
|
|
158
174
|
customProps,
|
|
159
175
|
parentTag: item.tag,
|
|
160
|
-
pageContext
|
|
176
|
+
pageContext,
|
|
177
|
+
largeComponent,
|
|
178
|
+
sizeLargeComponent
|
|
161
179
|
}))) : ''
|
|
162
180
|
});
|
|
163
181
|
}, ()=>{
|
|
164
|
-
|
|
182
|
+
const liquid = Component({
|
|
165
183
|
builderProps: {
|
|
166
184
|
uid,
|
|
167
185
|
builderData: item
|
|
@@ -179,6 +197,10 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
179
197
|
...passProps.builderAttrs
|
|
180
198
|
}
|
|
181
199
|
});
|
|
200
|
+
if (isLimitSize(liquid, sizeLargeComponent)) {
|
|
201
|
+
largeComponent.push(item.uid);
|
|
202
|
+
}
|
|
203
|
+
return liquid;
|
|
182
204
|
})}
|
|
183
205
|
</div>`;
|
|
184
206
|
}
|
|
@@ -303,6 +325,11 @@ const WrapRenderChildren = ({ uid, customProps }, codes)=>{
|
|
|
303
325
|
}
|
|
304
326
|
return liquid;
|
|
305
327
|
};
|
|
328
|
+
const isLimitSize = (liquid, size = 50)=>{
|
|
329
|
+
const textEncoder = new TextEncoder();
|
|
330
|
+
const byteSize = textEncoder.encode(liquid).length;
|
|
331
|
+
return byteSize >= size * 1024;
|
|
332
|
+
};
|
|
306
333
|
|
|
307
334
|
exports.RenderChildren = RenderChildren;
|
|
308
335
|
exports.WrapRenderChildren = WrapRenderChildren;
|
|
@@ -31,7 +31,7 @@ const componentIconList = [
|
|
|
31
31
|
const componentUsingAdvanced = [
|
|
32
32
|
'IconList'
|
|
33
33
|
];
|
|
34
|
-
const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageContext, ...passProps })=>{
|
|
34
|
+
const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageContext, largeComponent = [], sizeLargeComponent = 50, ...passProps })=>{
|
|
35
35
|
const item = builder[uid];
|
|
36
36
|
const Component = components[item?.tag];
|
|
37
37
|
if (!Component) {
|
|
@@ -70,6 +70,8 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
70
70
|
advanced: item.advanced,
|
|
71
71
|
parentId: componentsRenderWithParentId.includes(item.tag) ? parentId : null,
|
|
72
72
|
pageContext,
|
|
73
|
+
largeComponent,
|
|
74
|
+
sizeLargeComponent,
|
|
73
75
|
...passProps,
|
|
74
76
|
builderAttrs: {
|
|
75
77
|
...passProps.builderAttrs
|
|
@@ -81,7 +83,9 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
81
83
|
builder,
|
|
82
84
|
components,
|
|
83
85
|
customProps,
|
|
84
|
-
pageContext
|
|
86
|
+
pageContext,
|
|
87
|
+
largeComponent,
|
|
88
|
+
sizeLargeComponent
|
|
85
89
|
};
|
|
86
90
|
}),
|
|
87
91
|
children: !customRenderChildren.includes(item.tag) ? WrapRenderChildren({
|
|
@@ -93,11 +97,13 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
93
97
|
components,
|
|
94
98
|
customProps,
|
|
95
99
|
parentTag: item.tag,
|
|
96
|
-
pageContext
|
|
100
|
+
pageContext,
|
|
101
|
+
largeComponent,
|
|
102
|
+
sizeLargeComponent
|
|
97
103
|
}))) : ''
|
|
98
104
|
});
|
|
99
105
|
}, ()=>{
|
|
100
|
-
|
|
106
|
+
const liquid = Component({
|
|
101
107
|
builderProps: {
|
|
102
108
|
uid,
|
|
103
109
|
builderData: item
|
|
@@ -109,11 +115,17 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
109
115
|
isText: componentTexts.includes(item.tag) ? true : null,
|
|
110
116
|
parentId: componentsRenderWithParentId.includes(item.tag) ? parentId : null,
|
|
111
117
|
pageContext,
|
|
118
|
+
largeComponent,
|
|
119
|
+
sizeLargeComponent,
|
|
112
120
|
...passProps,
|
|
113
121
|
builderAttrs: {
|
|
114
122
|
...passProps.builderAttrs
|
|
115
123
|
}
|
|
116
124
|
});
|
|
125
|
+
if (isLimitSize(liquid, sizeLargeComponent)) {
|
|
126
|
+
largeComponent.push(item.uid);
|
|
127
|
+
}
|
|
128
|
+
return liquid;
|
|
117
129
|
});
|
|
118
130
|
} else {
|
|
119
131
|
liquid = template`<div gp-el-wrapper style="${!componentIconList.includes(item.tag) ? style : ''}" class="${item.uid} ${!item?.childrens?.length && item.tag === 'IconListItemHoz' ? 'hidden' : ''}">
|
|
@@ -130,6 +142,8 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
130
142
|
cssClass: item?.advanced?.cssClass
|
|
131
143
|
},
|
|
132
144
|
pageContext,
|
|
145
|
+
largeComponent,
|
|
146
|
+
sizeLargeComponent,
|
|
133
147
|
...passProps,
|
|
134
148
|
builderAttrs: {
|
|
135
149
|
...passProps.builderAttrs
|
|
@@ -141,7 +155,9 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
141
155
|
builder,
|
|
142
156
|
components,
|
|
143
157
|
customProps,
|
|
144
|
-
pageContext
|
|
158
|
+
pageContext,
|
|
159
|
+
largeComponent,
|
|
160
|
+
sizeLargeComponent
|
|
145
161
|
};
|
|
146
162
|
}),
|
|
147
163
|
children: !customRenderChildren.includes(item.tag) ? WrapRenderChildren({
|
|
@@ -153,11 +169,13 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
153
169
|
components,
|
|
154
170
|
customProps,
|
|
155
171
|
parentTag: item.tag,
|
|
156
|
-
pageContext
|
|
172
|
+
pageContext,
|
|
173
|
+
largeComponent,
|
|
174
|
+
sizeLargeComponent
|
|
157
175
|
}))) : ''
|
|
158
176
|
});
|
|
159
177
|
}, ()=>{
|
|
160
|
-
|
|
178
|
+
const liquid = Component({
|
|
161
179
|
builderProps: {
|
|
162
180
|
uid,
|
|
163
181
|
builderData: item
|
|
@@ -175,6 +193,10 @@ const Render = ({ uid, builder, components, parentId, extraFiles = {}, pageConte
|
|
|
175
193
|
...passProps.builderAttrs
|
|
176
194
|
}
|
|
177
195
|
});
|
|
196
|
+
if (isLimitSize(liquid, sizeLargeComponent)) {
|
|
197
|
+
largeComponent.push(item.uid);
|
|
198
|
+
}
|
|
199
|
+
return liquid;
|
|
178
200
|
})}
|
|
179
201
|
</div>`;
|
|
180
202
|
}
|
|
@@ -299,5 +321,10 @@ const WrapRenderChildren = ({ uid, customProps }, codes)=>{
|
|
|
299
321
|
}
|
|
300
322
|
return liquid;
|
|
301
323
|
};
|
|
324
|
+
const isLimitSize = (liquid, size = 50)=>{
|
|
325
|
+
const textEncoder = new TextEncoder();
|
|
326
|
+
const byteSize = textEncoder.encode(liquid).length;
|
|
327
|
+
return byteSize >= size * 1024;
|
|
328
|
+
};
|
|
302
329
|
|
|
303
330
|
export { RenderChildren, WrapRenderChildren, Render as default };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -31149,7 +31149,7 @@ type Props = {
|
|
|
31149
31149
|
pageContext?: PageContext;
|
|
31150
31150
|
[key: string]: any;
|
|
31151
31151
|
};
|
|
31152
|
-
declare const Render: ({ uid, builder, components, parentId, extraFiles, pageContext, ...passProps }: Props) => {
|
|
31152
|
+
declare const Render: ({ uid, builder, components, parentId, extraFiles, pageContext, largeComponent, sizeLargeComponent, ...passProps }: Props) => {
|
|
31153
31153
|
liquid: string;
|
|
31154
31154
|
extraFiles: ExtraFiles;
|
|
31155
31155
|
};
|