@builder.io/sdk-qwik 0.0.7 → 0.0.8
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/lib/index.97024df8.js +80165 -0
- package/lib/index.d8c1e37f.cjs +80165 -0
- package/lib/index.qwik.cjs +2424 -0
- package/lib/index.qwik.mjs +2424 -0
- package/package.json +1 -1
- package/src/blocks/button/button.jsx +0 -197
- package/src/blocks/button/component-info.js +0 -41
- package/src/blocks/columns/columns.jsx +0 -267
- package/src/blocks/columns/component-info.js +0 -242
- package/src/blocks/custom-code/component-info.js +0 -31
- package/src/blocks/custom-code/custom-code.jsx +0 -130
- package/src/blocks/embed/component-info.js +0 -44
- package/src/blocks/embed/embed.jsx +0 -130
- package/src/blocks/embed/helpers.js +0 -9
- package/src/blocks/form/builder-blocks.jsx +0 -86
- package/src/blocks/form/component-info.js +0 -262
- package/src/blocks/form/form.jsx +0 -782
- package/src/blocks/fragment/component-info.js +0 -11
- package/src/blocks/fragment/fragment.jsx +0 -59
- package/src/blocks/image/component-info.js +0 -151
- package/src/blocks/image/image.helpers.js +0 -48
- package/src/blocks/image/image.jsx +0 -554
- package/src/blocks/img/component-info.js +0 -20
- package/src/blocks/img/img.jsx +0 -76
- package/src/blocks/input/component-info.js +0 -74
- package/src/blocks/input/input.jsx +0 -87
- package/src/blocks/raw-text/component-info.js +0 -16
- package/src/blocks/raw-text/raw-text.jsx +0 -53
- package/src/blocks/section/component-info.js +0 -49
- package/src/blocks/section/section.jsx +0 -97
- package/src/blocks/select/component-info.js +0 -59
- package/src/blocks/select/select.jsx +0 -149
- package/src/blocks/submit-button/component-info.js +0 -28
- package/src/blocks/submit-button/submit-button.jsx +0 -87
- package/src/blocks/symbol/component-info.js +0 -43
- package/src/blocks/symbol/symbol.jsx +0 -211
- package/src/blocks/text/component-info.js +0 -24
- package/src/blocks/text/text.jsx +0 -46
- package/src/blocks/textarea/component-info.js +0 -47
- package/src/blocks/textarea/textarea.jsx +0 -65
- package/src/blocks/util.js +0 -7
- package/src/blocks/video/component-info.js +0 -106
- package/src/blocks/video/video.jsx +0 -103
- package/src/components/render-block/block-styles.jsx +0 -174
- package/src/components/render-block/render-block.helpers.js +0 -23
- package/src/components/render-block/render-block.jsx +0 -733
- package/src/components/render-block/render-component.jsx +0 -245
- package/src/components/render-block/render-repeated-block.jsx +0 -104
- package/src/components/render-block/types.js +0 -0
- package/src/components/render-blocks.jsx +0 -387
- package/src/components/render-content/components/render-styles.jsx +0 -126
- package/src/components/render-content/index.js +0 -4
- package/src/components/render-content/render-content.jsx +0 -629
- package/src/components/render-inlined-styles.jsx +0 -141
- package/src/constants/builder-registered-components.js +0 -48
- package/src/constants/device-sizes.js +0 -21
- package/src/constants/target.js +0 -4
- package/src/context/builder.context.js +0 -5
- package/src/functions/camel-to-kebab-case.js +0 -4
- package/src/functions/convert-style-object.js +0 -6
- package/src/functions/evaluate.js +0 -28
- package/src/functions/event-handler-name.js +0 -7
- package/src/functions/get-block-actions.js +0 -23
- package/src/functions/get-block-component-options.js +0 -28
- package/src/functions/get-block-properties.js +0 -29
- package/src/functions/get-block-styles.js +0 -34
- package/src/functions/get-block-tag.js +0 -6
- package/src/functions/get-builder-search-params/fn.test.js +0 -13
- package/src/functions/get-builder-search-params/index.js +0 -33
- package/src/functions/get-content/ab-testing.js +0 -38
- package/src/functions/get-content/fn.test.js +0 -31
- package/src/functions/get-content/index.js +0 -96
- package/src/functions/get-content/types.js +0 -0
- package/src/functions/get-fetch.js +0 -34
- package/src/functions/get-global-this.js +0 -18
- package/src/functions/get-processed-block.js +0 -53
- package/src/functions/get-processed-block.test.js +0 -32
- package/src/functions/if-target.js +0 -15
- package/src/functions/is-browser.js +0 -6
- package/src/functions/is-editing.js +0 -7
- package/src/functions/is-iframe.js +0 -7
- package/src/functions/is-previewing.js +0 -14
- package/src/functions/on-change.js +0 -27
- package/src/functions/on-change.test.js +0 -19
- package/src/functions/register-component.js +0 -72
- package/src/functions/register.js +0 -29
- package/src/functions/sanitize-styles.js +0 -5
- package/src/functions/set-editor-settings.js +0 -15
- package/src/functions/set.js +0 -11
- package/src/functions/set.test.js +0 -16
- package/src/functions/track.js +0 -22
- package/src/functions/transform-block.js +0 -6
- package/src/helpers/css.js +0 -12
- package/src/helpers/flatten.js +0 -34
- package/src/index-helpers/blocks-exports.js +0 -22
- package/src/index-helpers/top-of-file.js +0 -4
- package/src/index.js +0 -10
- package/src/scripts/init-editing.js +0 -80
- package/src/types/builder-block.js +0 -0
- package/src/types/builder-content.js +0 -0
- package/src/types/components.js +0 -0
- package/src/types/deep-partial.js +0 -0
- package/src/types/element.js +0 -0
- package/src/types/targets.js +0 -0
- package/src/types/typescript.js +0 -0
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
// GENERATED BY MITOSIS
|
|
2
|
-
|
|
3
|
-
import BuilderContext from "../context/builder.context";
|
|
4
|
-
import { isEditing } from "../functions/is-editing.js";
|
|
5
|
-
import BlockStyles from "./render-block/block-styles";
|
|
6
|
-
import RenderBlock from "./render-block/render-block";
|
|
7
|
-
import {
|
|
8
|
-
Fragment,
|
|
9
|
-
Host,
|
|
10
|
-
component$,
|
|
11
|
-
h,
|
|
12
|
-
useContext,
|
|
13
|
-
useStylesScoped$,
|
|
14
|
-
} from "@builder.io/qwik";
|
|
15
|
-
export const className = function className(props, state, builderContext) {
|
|
16
|
-
return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
|
|
17
|
-
};
|
|
18
|
-
export const onClick = function onClick(props, state, builderContext) {
|
|
19
|
-
if (isEditing() && !props.blocks?.length) {
|
|
20
|
-
window.parent?.postMessage(
|
|
21
|
-
{
|
|
22
|
-
type: "builder.clickEmptyBlocks",
|
|
23
|
-
data: {
|
|
24
|
-
parentElementId: props.parent,
|
|
25
|
-
dataPath: props.path,
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
"*"
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
export const onMouseEnter = function onMouseEnter(
|
|
33
|
-
props,
|
|
34
|
-
state,
|
|
35
|
-
builderContext
|
|
36
|
-
) {
|
|
37
|
-
if (isEditing() && !props.blocks?.length) {
|
|
38
|
-
window.parent?.postMessage(
|
|
39
|
-
{
|
|
40
|
-
type: "builder.hoverEmptyBlocks",
|
|
41
|
-
data: {
|
|
42
|
-
parentElementId: props.parent,
|
|
43
|
-
dataPath: props.path,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
"*"
|
|
47
|
-
);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
export const RenderBlocks = component$(
|
|
51
|
-
(props) => {
|
|
52
|
-
useStylesScoped$(STYLES);
|
|
53
|
-
const builderContext = useContext(BuilderContext);
|
|
54
|
-
const state = {};
|
|
55
|
-
return (
|
|
56
|
-
<Host
|
|
57
|
-
class={className(props, state, builderContext) + " div-RenderBlocks"}
|
|
58
|
-
builder-path={props.path}
|
|
59
|
-
builder-parent-id={props.parent}
|
|
60
|
-
dataSet={{
|
|
61
|
-
class: className(props, state, builderContext),
|
|
62
|
-
}}
|
|
63
|
-
onClick$={(event) => onClick(props, state, builderContext)}
|
|
64
|
-
onMouseEnter$={(event) => onMouseEnter(props, state, builderContext)}
|
|
65
|
-
>
|
|
66
|
-
<>
|
|
67
|
-
{props.blocks
|
|
68
|
-
? (props.blocks || []).map((block) => {
|
|
69
|
-
return (
|
|
70
|
-
<RenderBlock
|
|
71
|
-
key={"render-block-" + block.id}
|
|
72
|
-
block={block}
|
|
73
|
-
context={builderContext}
|
|
74
|
-
></RenderBlock>
|
|
75
|
-
);
|
|
76
|
-
})
|
|
77
|
-
: null}
|
|
78
|
-
{props.blocks
|
|
79
|
-
? (props.blocks || []).map((block) => {
|
|
80
|
-
return (
|
|
81
|
-
<BlockStyles
|
|
82
|
-
key={"block-style-" + block.id}
|
|
83
|
-
block={block}
|
|
84
|
-
context={builderContext}
|
|
85
|
-
></BlockStyles>
|
|
86
|
-
);
|
|
87
|
-
})
|
|
88
|
-
: null}
|
|
89
|
-
</>
|
|
90
|
-
</Host>
|
|
91
|
-
);
|
|
92
|
-
},
|
|
93
|
-
{ tagName: "div" }
|
|
94
|
-
);
|
|
95
|
-
export default RenderBlocks;
|
|
96
|
-
export const STYLES = `.div-RenderBlocks {
|
|
97
|
-
display: flex;
|
|
98
|
-
flex-direction: column;
|
|
99
|
-
align-items: stretch; }`;
|
|
100
|
-
export const COMPONENT = {
|
|
101
|
-
"@type": "@builder.io/mitosis/component",
|
|
102
|
-
imports: [
|
|
103
|
-
{
|
|
104
|
-
imports: {
|
|
105
|
-
BuilderContext: "default",
|
|
106
|
-
},
|
|
107
|
-
path: "../context/builder.context.lite",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
imports: {
|
|
111
|
-
isEditing: "isEditing",
|
|
112
|
-
},
|
|
113
|
-
path: "../functions/is-editing.js",
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
imports: {
|
|
117
|
-
BlockStyles: "default",
|
|
118
|
-
},
|
|
119
|
-
path: "./render-block/block-styles.lite",
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
imports: {
|
|
123
|
-
RenderBlock: "default",
|
|
124
|
-
},
|
|
125
|
-
path: "./render-block/render-block.lite",
|
|
126
|
-
},
|
|
127
|
-
],
|
|
128
|
-
exports: {},
|
|
129
|
-
inputs: [],
|
|
130
|
-
meta: {
|
|
131
|
-
useMetadata: {
|
|
132
|
-
qwik: {
|
|
133
|
-
component: {
|
|
134
|
-
isLight: false,
|
|
135
|
-
},
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
refs: {},
|
|
140
|
-
state: {
|
|
141
|
-
className:
|
|
142
|
-
"@builder.io/mitosis/method:get className() {\n return 'builder-blocks' + (!props.blocks?.length ? ' no-blocks' : '');\n}",
|
|
143
|
-
onClick:
|
|
144
|
-
"@builder.io/mitosis/method:onClick() {\n if (isEditing() && !props.blocks?.length) {\n window.parent?.postMessage({\n type: 'builder.clickEmptyBlocks',\n data: {\n parentElementId: props.parent,\n dataPath: props.path\n }\n }, '*');\n }\n}",
|
|
145
|
-
onMouseEnter:
|
|
146
|
-
"@builder.io/mitosis/method:onMouseEnter() {\n if (isEditing() && !props.blocks?.length) {\n window.parent?.postMessage({\n type: 'builder.hoverEmptyBlocks',\n data: {\n parentElementId: props.parent,\n dataPath: props.path\n }\n }, '*');\n }\n}",
|
|
147
|
-
},
|
|
148
|
-
children: [
|
|
149
|
-
{
|
|
150
|
-
"@type": "@builder.io/mitosis/node",
|
|
151
|
-
name: "Host",
|
|
152
|
-
meta: {},
|
|
153
|
-
scope: {},
|
|
154
|
-
properties: {},
|
|
155
|
-
bindings: {
|
|
156
|
-
class: {
|
|
157
|
-
code: "className(props,state,builderContext) + ' div-RenderBlocks'",
|
|
158
|
-
},
|
|
159
|
-
"builder-path": {
|
|
160
|
-
code: "props.path",
|
|
161
|
-
},
|
|
162
|
-
"builder-parent-id": {
|
|
163
|
-
code: "props.parent",
|
|
164
|
-
},
|
|
165
|
-
dataSet: {
|
|
166
|
-
code: "{\n class: className(props,state,builderContext)\n}",
|
|
167
|
-
},
|
|
168
|
-
onClick: {
|
|
169
|
-
code: "onClick(props,state,builderContext,)",
|
|
170
|
-
arguments: ["event"],
|
|
171
|
-
},
|
|
172
|
-
onMouseEnter: {
|
|
173
|
-
code: "onMouseEnter(props,state,builderContext,)",
|
|
174
|
-
arguments: ["event"],
|
|
175
|
-
},
|
|
176
|
-
},
|
|
177
|
-
children: [
|
|
178
|
-
{
|
|
179
|
-
"@type": "@builder.io/mitosis/node",
|
|
180
|
-
name: "div",
|
|
181
|
-
meta: {},
|
|
182
|
-
scope: {},
|
|
183
|
-
properties: {
|
|
184
|
-
_text: "\n ",
|
|
185
|
-
},
|
|
186
|
-
bindings: {},
|
|
187
|
-
children: [],
|
|
188
|
-
},
|
|
189
|
-
{
|
|
190
|
-
"@type": "@builder.io/mitosis/node",
|
|
191
|
-
name: "div",
|
|
192
|
-
meta: {},
|
|
193
|
-
scope: {},
|
|
194
|
-
properties: {
|
|
195
|
-
_text: "\n ",
|
|
196
|
-
},
|
|
197
|
-
bindings: {},
|
|
198
|
-
children: [],
|
|
199
|
-
},
|
|
200
|
-
{
|
|
201
|
-
"@type": "@builder.io/mitosis/node",
|
|
202
|
-
name: "Show",
|
|
203
|
-
meta: {},
|
|
204
|
-
scope: {},
|
|
205
|
-
properties: {},
|
|
206
|
-
bindings: {
|
|
207
|
-
when: {
|
|
208
|
-
code: "props.blocks",
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
children: [
|
|
212
|
-
{
|
|
213
|
-
"@type": "@builder.io/mitosis/node",
|
|
214
|
-
name: "div",
|
|
215
|
-
meta: {},
|
|
216
|
-
scope: {},
|
|
217
|
-
properties: {
|
|
218
|
-
_text: "\n ",
|
|
219
|
-
},
|
|
220
|
-
bindings: {},
|
|
221
|
-
children: [],
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
"@type": "@builder.io/mitosis/node",
|
|
225
|
-
name: "For",
|
|
226
|
-
meta: {},
|
|
227
|
-
scope: {
|
|
228
|
-
For: ["block"],
|
|
229
|
-
},
|
|
230
|
-
properties: {
|
|
231
|
-
_forName: "block",
|
|
232
|
-
},
|
|
233
|
-
bindings: {
|
|
234
|
-
each: {
|
|
235
|
-
code: "props.blocks",
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
children: [
|
|
239
|
-
{
|
|
240
|
-
"@type": "@builder.io/mitosis/node",
|
|
241
|
-
name: "RenderBlock",
|
|
242
|
-
meta: {},
|
|
243
|
-
scope: {},
|
|
244
|
-
properties: {},
|
|
245
|
-
bindings: {
|
|
246
|
-
key: {
|
|
247
|
-
code: "'render-block-' + block.id",
|
|
248
|
-
},
|
|
249
|
-
block: {
|
|
250
|
-
code: "block",
|
|
251
|
-
},
|
|
252
|
-
context: {
|
|
253
|
-
code: "builderContext",
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
children: [],
|
|
257
|
-
},
|
|
258
|
-
],
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
"@type": "@builder.io/mitosis/node",
|
|
262
|
-
name: "div",
|
|
263
|
-
meta: {},
|
|
264
|
-
scope: {},
|
|
265
|
-
properties: {
|
|
266
|
-
_text: "\n ",
|
|
267
|
-
},
|
|
268
|
-
bindings: {},
|
|
269
|
-
children: [],
|
|
270
|
-
},
|
|
271
|
-
],
|
|
272
|
-
},
|
|
273
|
-
{
|
|
274
|
-
"@type": "@builder.io/mitosis/node",
|
|
275
|
-
name: "div",
|
|
276
|
-
meta: {},
|
|
277
|
-
scope: {},
|
|
278
|
-
properties: {
|
|
279
|
-
_text: "\n ",
|
|
280
|
-
},
|
|
281
|
-
bindings: {},
|
|
282
|
-
children: [],
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
"@type": "@builder.io/mitosis/node",
|
|
286
|
-
name: "Show",
|
|
287
|
-
meta: {},
|
|
288
|
-
scope: {},
|
|
289
|
-
properties: {},
|
|
290
|
-
bindings: {
|
|
291
|
-
when: {
|
|
292
|
-
code: "props.blocks",
|
|
293
|
-
},
|
|
294
|
-
},
|
|
295
|
-
children: [
|
|
296
|
-
{
|
|
297
|
-
"@type": "@builder.io/mitosis/node",
|
|
298
|
-
name: "div",
|
|
299
|
-
meta: {},
|
|
300
|
-
scope: {},
|
|
301
|
-
properties: {
|
|
302
|
-
_text: "\n ",
|
|
303
|
-
},
|
|
304
|
-
bindings: {},
|
|
305
|
-
children: [],
|
|
306
|
-
},
|
|
307
|
-
{
|
|
308
|
-
"@type": "@builder.io/mitosis/node",
|
|
309
|
-
name: "For",
|
|
310
|
-
meta: {},
|
|
311
|
-
scope: {
|
|
312
|
-
For: ["block"],
|
|
313
|
-
},
|
|
314
|
-
properties: {
|
|
315
|
-
_forName: "block",
|
|
316
|
-
},
|
|
317
|
-
bindings: {
|
|
318
|
-
each: {
|
|
319
|
-
code: "props.blocks",
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
children: [
|
|
323
|
-
{
|
|
324
|
-
"@type": "@builder.io/mitosis/node",
|
|
325
|
-
name: "BlockStyles",
|
|
326
|
-
meta: {},
|
|
327
|
-
scope: {},
|
|
328
|
-
properties: {},
|
|
329
|
-
bindings: {
|
|
330
|
-
key: {
|
|
331
|
-
code: "'block-style-' + block.id",
|
|
332
|
-
},
|
|
333
|
-
block: {
|
|
334
|
-
code: "block",
|
|
335
|
-
},
|
|
336
|
-
context: {
|
|
337
|
-
code: "builderContext",
|
|
338
|
-
},
|
|
339
|
-
},
|
|
340
|
-
children: [],
|
|
341
|
-
},
|
|
342
|
-
],
|
|
343
|
-
},
|
|
344
|
-
{
|
|
345
|
-
"@type": "@builder.io/mitosis/node",
|
|
346
|
-
name: "div",
|
|
347
|
-
meta: {},
|
|
348
|
-
scope: {},
|
|
349
|
-
properties: {
|
|
350
|
-
_text: "\n ",
|
|
351
|
-
},
|
|
352
|
-
bindings: {},
|
|
353
|
-
children: [],
|
|
354
|
-
},
|
|
355
|
-
],
|
|
356
|
-
},
|
|
357
|
-
{
|
|
358
|
-
"@type": "@builder.io/mitosis/node",
|
|
359
|
-
name: "div",
|
|
360
|
-
meta: {},
|
|
361
|
-
scope: {},
|
|
362
|
-
properties: {
|
|
363
|
-
_text: "\n ",
|
|
364
|
-
},
|
|
365
|
-
bindings: {},
|
|
366
|
-
children: [],
|
|
367
|
-
},
|
|
368
|
-
],
|
|
369
|
-
},
|
|
370
|
-
],
|
|
371
|
-
hooks: {},
|
|
372
|
-
context: {
|
|
373
|
-
get: {
|
|
374
|
-
builderContext: {
|
|
375
|
-
name: "BuilderContext",
|
|
376
|
-
path: "../context/builder.context.lite:default",
|
|
377
|
-
},
|
|
378
|
-
},
|
|
379
|
-
set: {},
|
|
380
|
-
},
|
|
381
|
-
name: "RenderBlocks",
|
|
382
|
-
subComponents: [],
|
|
383
|
-
types: [
|
|
384
|
-
"export type RenderBlockProps = {\n blocks?: BuilderBlock[];\n parent?: string;\n path?: string;\n};",
|
|
385
|
-
],
|
|
386
|
-
propsTypeRef: "RenderBlockProps",
|
|
387
|
-
};
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
// GENERATED BY MITOSIS
|
|
2
|
-
|
|
3
|
-
import RenderInlinedStyles from "../../render-inlined-styles";
|
|
4
|
-
import { Fragment, component$, h } from "@builder.io/qwik";
|
|
5
|
-
export const getCssFromFont = function getCssFromFont(props, state, font) {
|
|
6
|
-
// TODO: compute what font sizes are used and only load those.......
|
|
7
|
-
const family =
|
|
8
|
-
font.family +
|
|
9
|
-
(font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
|
|
10
|
-
const name = family.split(",")[0];
|
|
11
|
-
const url = font.fileUrl ?? font?.files?.regular;
|
|
12
|
-
let str = "";
|
|
13
|
-
|
|
14
|
-
if (url && family && name) {
|
|
15
|
-
str += `
|
|
16
|
-
@font-face {
|
|
17
|
-
font-family: "${family}";
|
|
18
|
-
src: local("${name}"), url('${url}') format('woff2');
|
|
19
|
-
font-display: fallback;
|
|
20
|
-
font-weight: 400;
|
|
21
|
-
}
|
|
22
|
-
`.trim();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (font.files) {
|
|
26
|
-
for (const weight in font.files) {
|
|
27
|
-
const isNumber = String(Number(weight)) === weight;
|
|
28
|
-
|
|
29
|
-
if (!isNumber) {
|
|
30
|
-
continue;
|
|
31
|
-
} // TODO: maybe limit number loaded
|
|
32
|
-
|
|
33
|
-
const weightUrl = font.files[weight];
|
|
34
|
-
|
|
35
|
-
if (weightUrl && weightUrl !== url) {
|
|
36
|
-
str += `
|
|
37
|
-
@font-face {
|
|
38
|
-
font-family: "${family}";
|
|
39
|
-
src: url('${weightUrl}') format('woff2');
|
|
40
|
-
font-display: fallback;
|
|
41
|
-
font-weight: ${weight};
|
|
42
|
-
}
|
|
43
|
-
`.trim();
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return str;
|
|
49
|
-
};
|
|
50
|
-
export const getFontCss = function getFontCss(props, state, { customFonts }) {
|
|
51
|
-
// TODO: flag for this
|
|
52
|
-
// if (!this.builder.allowCustomFonts) {
|
|
53
|
-
// return '';
|
|
54
|
-
// }
|
|
55
|
-
// TODO: separate internal data from external
|
|
56
|
-
return (
|
|
57
|
-
customFonts?.map((font) => getCssFromFont(props, state, font))?.join(" ") ||
|
|
58
|
-
""
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
export const injectedStyles = function injectedStyles(props, state) {
|
|
62
|
-
return `
|
|
63
|
-
${props.cssCode || ""}
|
|
64
|
-
${getFontCss(props, state, {
|
|
65
|
-
customFonts: props.customFonts,
|
|
66
|
-
})}`;
|
|
67
|
-
};
|
|
68
|
-
export const RenderContentStyles = component$((props) => {
|
|
69
|
-
const state = {};
|
|
70
|
-
return (
|
|
71
|
-
<RenderInlinedStyles
|
|
72
|
-
styles={injectedStyles(props, state)}
|
|
73
|
-
></RenderInlinedStyles>
|
|
74
|
-
);
|
|
75
|
-
});
|
|
76
|
-
export default RenderContentStyles;
|
|
77
|
-
export const COMPONENT = {
|
|
78
|
-
"@type": "@builder.io/mitosis/component",
|
|
79
|
-
imports: [
|
|
80
|
-
{
|
|
81
|
-
imports: {
|
|
82
|
-
RenderInlinedStyles: "default",
|
|
83
|
-
},
|
|
84
|
-
path: "../../render-inlined-styles.lite",
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
exports: {},
|
|
88
|
-
inputs: [],
|
|
89
|
-
meta: {},
|
|
90
|
-
refs: {},
|
|
91
|
-
state: {
|
|
92
|
-
getCssFromFont:
|
|
93
|
-
"@builder.io/mitosis/method:getCssFromFont(font: CustomFont) {\n // TODO: compute what font sizes are used and only load those.......\n const family = font.family + (font.kind && !font.kind.includes('#') ? ', ' + font.kind : '');\n const name = family.split(',')[0];\n const url = font.fileUrl ?? font?.files?.regular;\n let str = '';\n\n if (url && family && name) {\n str += `\n @font-face {\n font-family: \"${family}\";\n src: local(\"${name}\"), url('${url}') format('woff2');\n font-display: fallback;\n font-weight: 400;\n }\n `.trim();\n }\n\n if (font.files) {\n for (const weight in font.files) {\n const isNumber = String(Number(weight)) === weight;\n\n if (!isNumber) {\n continue;\n } // TODO: maybe limit number loaded\n\n\n const weightUrl = font.files[weight];\n\n if (weightUrl && weightUrl !== url) {\n str += `\n @font-face {\n font-family: \"${family}\";\n src: url('${weightUrl}') format('woff2');\n font-display: fallback;\n font-weight: ${weight};\n }\n `.trim();\n }\n }\n }\n\n return str;\n}",
|
|
94
|
-
getFontCss:
|
|
95
|
-
"@builder.io/mitosis/method:getFontCss({\n customFonts\n}: {\n customFonts?: CustomFont[];\n}) {\n // TODO: flag for this\n // if (!this.builder.allowCustomFonts) {\n // return '';\n // }\n // TODO: separate internal data from external\n return customFonts?.map(font => getCssFromFont(props,state,font))?.join(' ') || '';\n}",
|
|
96
|
-
injectedStyles:
|
|
97
|
-
"@builder.io/mitosis/method:get injectedStyles() {\n return `\n${props.cssCode || ''}\n${getFontCss(props,state,{\n customFonts: props.customFonts\n })}`;\n}",
|
|
98
|
-
},
|
|
99
|
-
children: [
|
|
100
|
-
{
|
|
101
|
-
"@type": "@builder.io/mitosis/node",
|
|
102
|
-
name: "RenderInlinedStyles",
|
|
103
|
-
meta: {},
|
|
104
|
-
scope: {},
|
|
105
|
-
properties: {},
|
|
106
|
-
bindings: {
|
|
107
|
-
styles: {
|
|
108
|
-
code: "injectedStyles(props,state)",
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
children: [],
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
hooks: {},
|
|
115
|
-
context: {
|
|
116
|
-
get: {},
|
|
117
|
-
set: {},
|
|
118
|
-
},
|
|
119
|
-
name: "RenderContentStyles",
|
|
120
|
-
subComponents: [],
|
|
121
|
-
interfaces: [
|
|
122
|
-
"interface CustomFont {\n family?: string;\n kind?: string;\n fileUrl?: string;\n files?: {\n [key: string]: string;\n };\n}",
|
|
123
|
-
"interface Props {\n cssCode?: string;\n customFonts?: CustomFont[];\n}",
|
|
124
|
-
],
|
|
125
|
-
propsTypeRef: "Props",
|
|
126
|
-
};
|