@builder.io/mitosis 0.0.50-3 → 0.0.50-5
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/dist/src/generators/qwik/component.d.ts +3 -1
- package/dist/src/generators/qwik/component.js +44 -43
- package/dist/src/generators/qwik/handlers.js +4 -1
- package/dist/src/generators/qwik/jsx.js +5 -3
- package/dist/src/generators/qwik/src-generator.d.ts +2 -1
- package/dist/src/generators/qwik/src-generator.js +3 -3
- package/dist/src/generators/qwik.js +10 -23
- package/dist/test/.DS_Store +0 -0
- package/dist/test/.history/qwik/Accordion/low_20211113070910.jsx +24 -0
- package/dist/test/.history/qwik/Accordion/low_20211113070955.jsx +171 -0
- package/dist/test/qwik/.DS_Store +0 -0
- package/dist/test/qwik/.history/Image/med_20220125204036.js +10 -0
- package/dist/test/qwik/.history/Image/med_20220125204101.js +50 -0
- package/dist/test/qwik/.history/Image/med_20220125205805.js +55 -0
- package/dist/test/qwik/.history/Todo_20211022172235.tsx +9 -0
- package/dist/test/qwik/.history/Todo_20211022172244.tsx +6 -0
- package/dist/test/qwik/{qwik/hello_world/stylesheet/low.jsx → .history/hello_world/stylesheet/low_20220225135433.jsx} +9 -5
- package/dist/test/qwik/.history/hello_world/stylesheet/low_20220225135453.jsx +28 -0
- package/dist/test/qwik/{Todos/Todo.tsx/med.tsx → .history/hello_world/stylesheet/med_20220225135950.jsx} +8 -6
- package/dist/test/qwik/.history/hello_world/stylesheet/med_20220225140507.jsx +28 -0
- package/dist/test/qwik/.history/high_20211027155242.js +9 -0
- package/dist/test/qwik/.history/high_20211028144450.js +18 -0
- package/dist/test/qwik/.history/med_20211026163134.tsx +31 -0
- package/dist/test/qwik/.history/med_20211026163335.tsx +35 -0
- package/dist/test/qwik/.history/med_20211027110239.tsx +34 -0
- package/dist/test/qwik/.history/med_20211027120330.js +1 -0
- package/dist/test/qwik/.history/med_20211027120346.js +33 -0
- package/dist/test/qwik/.history/med_20211027120726.js +33 -0
- package/dist/test/qwik/.history/med_20211027120821.js +33 -0
- package/dist/test/qwik/.history/med_20211027120822.js +33 -0
- package/dist/test/qwik/.history/med_20211027122120.cjs +40 -0
- package/dist/test/qwik/.history/med_20211027122143.cjs +42 -0
- package/dist/test/qwik/.history/med_20211027123718.cjs +46 -0
- package/dist/test/qwik/.history/med_20211027123722.cjs +46 -0
- package/dist/test/qwik/.history/med_20211027123726.cjs +46 -0
- package/dist/test/qwik/.history/med_20211027123734.cjs +50 -0
- package/dist/test/qwik/.history/med_20211027123737.cjs +50 -0
- package/dist/test/qwik/.history/med_20211027124327.cjs +58 -0
- package/dist/test/qwik/.history/med_20211027125455.cjs +58 -0
- package/dist/test/qwik/.history/med_20211027131549.cjs +58 -0
- package/dist/test/qwik/.history/med_20211027131625.cjs +58 -0
- package/dist/test/qwik/.history/med_20211027132228.cjs +58 -0
- package/dist/test/qwik/.history/med_20211027133829.js +42 -0
- package/dist/test/qwik/.history/med_20211027133933.js +42 -0
- package/dist/test/qwik/.history/med_20211027134959.js +42 -0
- package/dist/test/qwik/{qwik/page-with-symbol/low.js → .history/qwik/page-with-symbol/low_20211029141031.js} +8 -10
- package/dist/test/qwik/.history/qwik/page-with-symbol/low_20211029141206.js +44 -0
- package/dist/test/qwik/Accordion/low.jsx +7 -4
- package/dist/test/qwik/Accordion/med.jsx +9 -8
- package/dist/test/qwik/{qwik/Image.slow → For}/high.js +0 -0
- package/dist/test/qwik/For/low.js +70 -0
- package/dist/test/qwik/For/low.jsx +7 -4
- package/dist/test/qwik/{qwik/Image.slow → For}/med.js +0 -0
- package/dist/test/qwik/For/med.jsx +9 -8
- package/dist/test/qwik/Image/low.js +7 -6
- package/dist/test/qwik/Image/med.js +9 -8
- package/dist/test/qwik/Image.slow/low.js +7 -6
- package/dist/test/qwik/Image.slow/med.js +9 -8
- package/dist/test/qwik/button/high.js +10 -3
- package/dist/test/qwik/button/low.js +8 -7
- package/dist/test/qwik/button/med.js +9 -8
- package/dist/test/qwik/component/bindings/low.jsx +12 -8
- package/dist/test/qwik/component/bindings/med.jsx +15 -18
- package/dist/test/qwik/hello_world/stylesheet/low.jsx +7 -4
- package/dist/test/qwik/hello_world/stylesheet/med.jsx +9 -8
- package/dist/test/qwik/page-with-symbol/low.js +7 -6
- package/dist/test/qwik/page-with-symbol/med.js +9 -8
- package/dist/test/qwik/svg/low.js +7 -4
- package/dist/test/qwik/svg/med.js +9 -8
- package/dist/test/qwik/todo/Todo.cjs/high.cjs +58 -0
- package/dist/test/qwik/{Todo → todo}/Todo.cjs/low.cjs +0 -0
- package/dist/test/qwik/todo/Todo.cjs/med.cjs +71 -0
- package/dist/test/qwik/todo/Todo.js/high.js +5 -0
- package/dist/test/qwik/{Todo → todo}/Todo.js/low.js +0 -0
- package/dist/test/qwik/todo/Todo.js/med.js +1 -0
- package/dist/test/qwik/todo/Todo.tsx/high.tsx +57 -0
- package/dist/test/qwik/{Todo → todo}/Todo.tsx/low.tsx +0 -0
- package/dist/test/qwik/todo/Todo.tsx/med.tsx +44 -0
- package/dist/test/qwik/todos/Todo.tsx/high.tsx +19 -0
- package/dist/test/qwik/{Todos → todos}/Todo.tsx/low.tsx +8 -7
- package/dist/test/qwik/todos/Todo.tsx/med.tsx +11 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +0 -11
- package/dist/src/__tests__/data/blocks/tabs.raw.jsx +0 -24
- package/dist/src/__tests__/qoot.test.d.ts +0 -1
- package/dist/src/__tests__/qoot.test.js +0 -115
- package/dist/src/generators/jsx-lite.d.ts +0 -10
- package/dist/src/generators/jsx-lite.js +0 -176
- package/dist/src/generators/qoot.d.ts +0 -21
- package/dist/src/generators/qoot.js +0 -442
- package/dist/src/helpers/create-jsx-lite-component.d.ts +0 -2
- package/dist/src/helpers/create-jsx-lite-component.js +0 -16
- package/dist/src/helpers/create-jsx-lite-context.d.ts +0 -4
- package/dist/src/helpers/create-jsx-lite-context.js +0 -18
- package/dist/src/helpers/create-jsx-lite-node.d.ts +0 -2
- package/dist/src/helpers/create-jsx-lite-node.js +0 -16
- package/dist/src/helpers/is-jsx-lite-node.d.ts +0 -2
- package/dist/src/helpers/is-jsx-lite-node.js +0 -7
- package/dist/src/types/jsx-lite-component.d.ts +0 -63
- package/dist/src/types/jsx-lite-component.js +0 -2
- package/dist/src/types/jsx-lite-context.d.ts +0 -6
- package/dist/src/types/jsx-lite-context.js +0 -2
- package/dist/src/types/jsx-lite-node.d.ts +0 -13
- package/dist/src/types/jsx-lite-node.js +0 -2
- package/dist/src/types/jsx-lite-styles.d.ts +0 -1
- package/dist/src/types/jsx-lite-styles.js +0 -2
- package/dist/test/qoot/Todo/bundle.js +0 -88
- package/dist/test/qoot/Todo/component.ts +0 -17
- package/dist/test/qoot/Todo/onButtonClick.ts +0 -13
- package/dist/test/qoot/Todo/onInput2Blur.ts +0 -11
- package/dist/test/qoot/Todo/onInput2KeyUp.ts +0 -10
- package/dist/test/qoot/Todo/onInputClick.ts +0 -10
- package/dist/test/qoot/Todo/onLabelDblClick.ts +0 -11
- package/dist/test/qoot/Todo/public.ts +0 -4
- package/dist/test/qoot/Todo/template.tsx +0 -46
- package/dist/test/qoot/Todos/component.ts +0 -9
- package/dist/test/qoot/Todos/onInputClick.ts +0 -14
- package/dist/test/qoot/Todos/public.ts +0 -3
- package/dist/test/qoot/Todos/template.tsx +0 -30
- package/dist/test/qwik/Todo/Todo.cjs/high.cjs +0 -31
- package/dist/test/qwik/Todo/Todo.cjs/med.cjs +0 -64
- package/dist/test/qwik/Todo/Todo.js/high.js +0 -5
- package/dist/test/qwik/Todo/Todo.js/med.js +0 -1
- package/dist/test/qwik/Todo/Todo.tsx/high.tsx +0 -30
- package/dist/test/qwik/Todo/Todo.tsx/med.tsx +0 -39
- package/dist/test/qwik/Todo/bundle.js +0 -46
- package/dist/test/qwik/Todo/component.ts +0 -17
- package/dist/test/qwik/Todo/onButtonClick.ts +0 -10
- package/dist/test/qwik/Todo/onInput2Blur.ts +0 -14
- package/dist/test/qwik/Todo/onInput2KeyUp.ts +0 -10
- package/dist/test/qwik/Todo/onInputClick.ts +0 -13
- package/dist/test/qwik/Todo/onLabelDblClick.ts +0 -11
- package/dist/test/qwik/Todo/public.ts +0 -3
- package/dist/test/qwik/Todo/template.tsx +0 -46
- package/dist/test/qwik/Todo.ts +0 -4
- package/dist/test/qwik/Todo_component.ts +0 -17
- package/dist/test/qwik/Todo_onButtonClick.ts +0 -13
- package/dist/test/qwik/Todo_onInput2Blur.ts +0 -14
- package/dist/test/qwik/Todo_onInput2KeyUp.ts +0 -10
- package/dist/test/qwik/Todo_onInputClick.ts +0 -13
- package/dist/test/qwik/Todo_onLabelDblClick.ts +0 -14
- package/dist/test/qwik/Todo_template.tsx +0 -46
- package/dist/test/qwik/Todos/Todo.tsx/high.tsx +0 -12
- package/dist/test/qwik/Todos/component.ts +0 -9
- package/dist/test/qwik/Todos/onInputClick.ts +0 -14
- package/dist/test/qwik/Todos/public.ts +0 -3
- package/dist/test/qwik/Todos/template.tsx +0 -30
- package/dist/test/qwik/Todos.ts +0 -3
- package/dist/test/qwik/Todos_component.ts +0 -9
- package/dist/test/qwik/Todos_onInputClick.ts +0 -14
- package/dist/test/qwik/Todos_template.tsx +0 -30
- package/dist/test/qwik/qwik/Image/high.js +0 -1
- package/dist/test/qwik/qwik/Image/low.js +0 -75
- package/dist/test/qwik/qwik/Image/med.js +0 -9
- package/dist/test/qwik/qwik/Image.slow/low.js +0 -75
- package/dist/test/qwik/qwik/button/high.js +0 -8
- package/dist/test/qwik/qwik/button/low.js +0 -34
- package/dist/test/qwik/qwik/button/med.js +0 -9
- package/dist/test/qwik/qwik/hello_world/stylesheet/high.jsx +0 -1
- package/dist/test/qwik/qwik/hello_world/stylesheet/med.jsx +0 -9
- package/dist/test/qwik/qwik/page-with-symbol/high.js +0 -1
- package/dist/test/qwik/qwik/page-with-symbol/med.js +0 -9
- package/dist/test/qwik/qwik/svg/high.js +0 -1
- package/dist/test/qwik/qwik/svg/low.js +0 -30
- package/dist/test/qwik/qwik/svg/med.js +0 -9
- package/dist/test/qwik/qwik/todo/Todo.cjs/high.cjs +0 -31
- package/dist/test/qwik/qwik/todo/Todo.cjs/low.cjs +0 -1
- package/dist/test/qwik/qwik/todo/Todo.cjs/med.cjs +0 -59
- package/dist/test/qwik/qwik/todo/Todo.js/high.js +0 -5
- package/dist/test/qwik/qwik/todo/Todo.js/low.js +0 -0
- package/dist/test/qwik/qwik/todo/Todo.js/med.js +0 -1
- package/dist/test/qwik/qwik/todo/Todo.tsx/high.tsx +0 -30
- package/dist/test/qwik/qwik/todo/Todo.tsx/low.tsx +0 -1
- package/dist/test/qwik/qwik/todo/Todo.tsx/med.tsx +0 -34
- package/dist/test/qwik/qwik/todos/Todo.tsx/high.tsx +0 -12
- package/dist/test/qwik/qwik/todos/Todo.tsx/low.tsx +0 -24
- package/dist/test/qwik/qwik/todos/Todo.tsx/med.tsx +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MitosisComponent } from '../../types/mitosis-component';
|
|
2
|
-
import { File } from './src-generator';
|
|
2
|
+
import { File, SrcBuilder } from './src-generator';
|
|
3
3
|
export declare type QwikOptions = {
|
|
4
4
|
qwikLib?: string;
|
|
5
5
|
qrlPrefix?: string;
|
|
@@ -17,4 +17,6 @@ export declare function addComponent(fileSet: FileSet, component: MitosisCompone
|
|
|
17
17
|
isRoot?: boolean;
|
|
18
18
|
shareStyles?: boolean;
|
|
19
19
|
}): void;
|
|
20
|
+
export declare function renderStateConst(file: File, isMount?: boolean): any;
|
|
21
|
+
export declare function renderUseLexicalScope(file: File): (this: SrcBuilder) => SrcBuilder;
|
|
20
22
|
export declare function addCommonStyles(fileSet: FileSet): void;
|
|
@@ -15,7 +15,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
15
15
|
return __assign.apply(this, arguments);
|
|
16
16
|
};
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.addCommonStyles = exports.addComponent = exports.createFileSet = void 0;
|
|
18
|
+
exports.addCommonStyles = exports.renderUseLexicalScope = exports.renderStateConst = exports.addComponent = exports.createFileSet = void 0;
|
|
19
19
|
var compile_away_builder_components_1 = require("../../plugins/compile-away-builder-components");
|
|
20
20
|
var minify_1 = require("../minify");
|
|
21
21
|
var handlers_1 = require("./handlers");
|
|
@@ -49,7 +49,6 @@ function getCommonStyles(fileSet) {
|
|
|
49
49
|
return fileSet['_commonStyles'];
|
|
50
50
|
}
|
|
51
51
|
function addComponent(fileSet, component, opts) {
|
|
52
|
-
var _a, _b;
|
|
53
52
|
if (opts === void 0) { opts = {}; }
|
|
54
53
|
var _opts = __assign({ isRoot: false, shareStyles: false }, opts);
|
|
55
54
|
(0, compile_away_builder_components_1.compileAwayBuilderComponentsFromTree)(component, __assign(__assign({}, compile_away_builder_components_1.components), { Image: undefined, CoreButton: undefined }));
|
|
@@ -61,52 +60,34 @@ function addComponent(fileSet, component, opts) {
|
|
|
61
60
|
var isStatic = Array.from(handlers.keys()).reduce(function (p, v) { return p && v.indexOf('state') == -1; }, true);
|
|
62
61
|
var onRenderFile = isStatic ? fileSet.low : fileSet.med;
|
|
63
62
|
var componentFile = fileSet.med;
|
|
64
|
-
if (!componentFile.exports.get('onMountCreateEmptyState')) {
|
|
65
|
-
componentFile.exportConst('onMountCreateEmptyState', function () {
|
|
66
|
-
this.emit((0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qHook'), [(0, src_generator_1.arrowFnValue)([], ['({})'])], ['any', 'any']));
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
if ((_a = component.hooks.onMount) === null || _a === void 0 ? void 0 : _a.code) {
|
|
70
|
-
addComponentOnMount(componentFile, componentName, component);
|
|
71
|
-
}
|
|
72
63
|
var styles = _opts.shareStyles
|
|
73
64
|
? getCommonStyles(fileSet).styles
|
|
74
65
|
: new Map();
|
|
75
66
|
(0, styles_1.collectStyles)(component.children, styles);
|
|
76
|
-
var
|
|
77
|
-
// tagName: string(componentName.toLowerCase()),
|
|
78
|
-
onMount: (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qHook'), [
|
|
79
|
-
componentFile.toQrl(((_b = component.hooks.onMount) === null || _b === void 0 ? void 0 : _b.code)
|
|
80
|
-
? componentName + '_onMount'
|
|
81
|
-
: 'onMountCreateEmptyState'),
|
|
82
|
-
]),
|
|
83
|
-
onRender: (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qHook'), [
|
|
84
|
-
onRenderFile.toQrl(componentName + '_onRender'),
|
|
85
|
-
]),
|
|
86
|
-
};
|
|
67
|
+
var withStyles = function () { return null; };
|
|
87
68
|
if (_opts.shareStyles) {
|
|
88
69
|
if (_opts.isRoot) {
|
|
89
|
-
var
|
|
90
|
-
getCommonStyles(fileSet).symbolName =
|
|
91
|
-
|
|
70
|
+
var symbolName_1 = componentName + '_styles';
|
|
71
|
+
getCommonStyles(fileSet).symbolName = symbolName_1;
|
|
72
|
+
withStyles = generateStyles(componentFile, onRenderFile, symbolName_1, false);
|
|
92
73
|
}
|
|
93
74
|
}
|
|
94
75
|
else {
|
|
95
76
|
if (styles.size) {
|
|
96
|
-
|
|
97
|
-
onRenderFile.exportConst(
|
|
77
|
+
var symbolName_2 = componentName + '_styles';
|
|
78
|
+
onRenderFile.exportConst(symbolName_2, (0, styles_1.renderStyles)(styles));
|
|
79
|
+
withStyles = generateStyles(componentFile, onRenderFile, symbolName_2, true);
|
|
98
80
|
}
|
|
99
81
|
}
|
|
100
|
-
|
|
82
|
+
addComponentOnMount(componentFile, onRenderFile, componentName, component, withStyles);
|
|
83
|
+
componentFile.exportConst(componentName, (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'component'), [generateQrl(componentFile, componentName + '_onMount')], ['any', 'any']));
|
|
101
84
|
onRenderFile.src.emit(src_generator_1.NL);
|
|
102
85
|
var directives = new Map();
|
|
103
|
-
onRenderFile.exportConst(componentName + '_onRender', (0, src_generator_1.
|
|
104
|
-
(
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
},
|
|
109
|
-
]),
|
|
86
|
+
onRenderFile.exportConst(componentName + '_onRender', (0, src_generator_1.arrowFnBlock)([], [
|
|
87
|
+
renderUseLexicalScope(onRenderFile),
|
|
88
|
+
function () {
|
|
89
|
+
return this.emit('return ', (0, jsx_1.renderJSXNodes)(onRenderFile, directives, handlers, component.children, styles, {}), ';');
|
|
90
|
+
},
|
|
110
91
|
]));
|
|
111
92
|
directives.forEach(function (code, name) {
|
|
112
93
|
fileSet.med.import(fileSet.med.qwikModule, 'h');
|
|
@@ -114,14 +95,26 @@ function addComponent(fileSet, component, opts) {
|
|
|
114
95
|
});
|
|
115
96
|
}
|
|
116
97
|
exports.addComponent = addComponent;
|
|
98
|
+
function generateStyles(componentFile, styleFile, symbol, scoped) {
|
|
99
|
+
return function () {
|
|
100
|
+
this.emit((0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, scoped ? 'withScopedSty' : 'withStyles'), [generateQrl(styleFile, symbol)]));
|
|
101
|
+
};
|
|
102
|
+
}
|
|
117
103
|
function renderStateConst(file, isMount) {
|
|
118
104
|
if (isMount === void 0) { isMount = false; }
|
|
119
105
|
return function () {
|
|
120
106
|
return this.emit('const state', src_generator_1.WS, '=', src_generator_1.WS, file.module == 'med'
|
|
121
107
|
? file.exports.get('__merge')
|
|
122
|
-
: file.import('./med', '__merge').name, '(__state__,', src_generator_1.WS, '__props__', isMount ? ',true);' : ');', src_generator_1.NL);
|
|
108
|
+
: file.import('./med.js', '__merge').name, '(__state__,', src_generator_1.WS, '__props__', isMount ? ',true);' : ');', src_generator_1.NL);
|
|
123
109
|
};
|
|
124
110
|
}
|
|
111
|
+
exports.renderStateConst = renderStateConst;
|
|
112
|
+
function renderUseLexicalScope(file) {
|
|
113
|
+
return function () {
|
|
114
|
+
return this.emit('const __scope__', src_generator_1.WS, '=', src_generator_1.WS, file.import(file.qwikModule, 'useLexicalScope').name, '();', src_generator_1.NL, 'const __props__', src_generator_1.WS, '=', src_generator_1.WS, '__scope__[0];', src_generator_1.NL, 'const __state__', src_generator_1.WS, '=', src_generator_1.WS, '__scope__[1];', src_generator_1.NL, renderStateConst(file, false));
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
exports.renderUseLexicalScope = renderUseLexicalScope;
|
|
125
118
|
function addCommonStyles(fileSet) {
|
|
126
119
|
var _a = getCommonStyles(fileSet), styles = _a.styles, symbolName = _a.symbolName;
|
|
127
120
|
var onRenderFile = fileSet.low;
|
|
@@ -130,15 +123,16 @@ function addCommonStyles(fileSet) {
|
|
|
130
123
|
}
|
|
131
124
|
}
|
|
132
125
|
exports.addCommonStyles = addCommonStyles;
|
|
133
|
-
function addComponentOnMount(componentFile, componentName, component) {
|
|
126
|
+
function addComponentOnMount(componentFile, onRenderFile, componentName, component, withStyles) {
|
|
134
127
|
componentFile.exportConst(componentName + '_onMount', function () {
|
|
135
128
|
var _this = this;
|
|
136
|
-
this.emit((0, src_generator_1.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
129
|
+
this.emit((0, src_generator_1.arrowFnValue)(['__props__'], function () {
|
|
130
|
+
var _a;
|
|
131
|
+
return _this.emit('{', src_generator_1.NL, src_generator_1.INDENT, 'const __state__', src_generator_1.WS, '=', src_generator_1.WS, componentFile.import(componentFile.qwikModule, 'createStore').name, '({});', src_generator_1.NL, renderStateConst(componentFile, true), (0, src_generator_1.iif)((_a = component.hooks.onMount) === null || _a === void 0 ? void 0 : _a.code), withStyles, src_generator_1.NL, 'return ', generateQrl(onRenderFile, componentName + '_onRender', [
|
|
132
|
+
'__props__',
|
|
133
|
+
'__state__',
|
|
134
|
+
]), ';', src_generator_1.UNINDENT, src_generator_1.NL, '}');
|
|
135
|
+
}));
|
|
142
136
|
});
|
|
143
137
|
}
|
|
144
138
|
function __merge(state, props, create) {
|
|
@@ -151,9 +145,16 @@ function __merge(state, props, create) {
|
|
|
151
145
|
}
|
|
152
146
|
}
|
|
153
147
|
if (create && typeof __STATE__ == 'object' && props.serverStateId) {
|
|
154
|
-
debugger;
|
|
155
148
|
Object.assign(state, __STATE__[props.serverStateId]);
|
|
156
149
|
}
|
|
157
150
|
return state;
|
|
158
151
|
}
|
|
152
|
+
function generateQrl(componentFile, componentName, capture) {
|
|
153
|
+
if (capture === void 0) { capture = []; }
|
|
154
|
+
return (0, src_generator_1.invoke)(componentFile.import(componentFile.qwikModule, 'qrl'), [
|
|
155
|
+
componentFile.toQrlChunk(),
|
|
156
|
+
(0, src_generator_1.quote)(componentName),
|
|
157
|
+
"[".concat(capture.join(','), "]"),
|
|
158
|
+
]);
|
|
159
|
+
}
|
|
159
160
|
var templateObject_1;
|
|
@@ -10,6 +10,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.renderHandlers = exports.extractJSBlock = void 0;
|
|
13
|
+
var component_1 = require("./component");
|
|
13
14
|
var src_generator_1 = require("./src-generator");
|
|
14
15
|
var IIF_START = '(() => {';
|
|
15
16
|
var IIF_END = '})()';
|
|
@@ -55,7 +56,9 @@ function renderHandlers(file, componentName, children) {
|
|
|
55
56
|
exports.renderHandlers = renderHandlers;
|
|
56
57
|
function renderHandler(file, symbol, code) {
|
|
57
58
|
file.exportConst(symbol, function () {
|
|
58
|
-
this.emit(
|
|
59
|
+
this.emit([
|
|
60
|
+
(0, src_generator_1.arrowFnBlock)([], [(0, component_1.renderUseLexicalScope)(file), wrapWithUse(file, code)]),
|
|
61
|
+
]);
|
|
59
62
|
});
|
|
60
63
|
file.src.emit(src_generator_1.NL);
|
|
61
64
|
}
|
|
@@ -131,9 +131,11 @@ function rewriteHandlers(file, handlers, bindings, symbolBindings) {
|
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
133
|
else if ((handlerBlock = handlers.get(binding))) {
|
|
134
|
-
key = "on:".concat(key.
|
|
135
|
-
binding = (0, src_generator_1.invoke)(file.import(file.qwikModule, '
|
|
136
|
-
(0, src_generator_1.quote)(file.qrlPrefix + 'high
|
|
134
|
+
key = "on:".concat(key.substring(2).toLowerCase());
|
|
135
|
+
binding = (0, src_generator_1.invoke)(file.import(file.qwikModule, 'qrl'), [
|
|
136
|
+
(0, src_generator_1.quote)(file.qrlPrefix + 'high.js'),
|
|
137
|
+
(0, src_generator_1.quote)(handlerBlock),
|
|
138
|
+
'[__props__, __state__]',
|
|
137
139
|
]);
|
|
138
140
|
}
|
|
139
141
|
else if (symbolBindings && key.startsWith('symbol.data.')) {
|
|
@@ -9,6 +9,7 @@ export interface SrcBuilderOptions {
|
|
|
9
9
|
isModule: boolean;
|
|
10
10
|
isJSX: boolean;
|
|
11
11
|
}
|
|
12
|
+
export declare type EmitFn = (this: SrcBuilder) => void;
|
|
12
13
|
export declare class File {
|
|
13
14
|
filename: string;
|
|
14
15
|
imports: Imports;
|
|
@@ -22,7 +23,7 @@ export declare class File {
|
|
|
22
23
|
get contents(): string;
|
|
23
24
|
constructor(filename: string, options: SrcBuilderOptions, qwikModule: string, qrlPrefix: string);
|
|
24
25
|
import(module: string, symbol: string): Symbol;
|
|
25
|
-
|
|
26
|
+
toQrlChunk(): string;
|
|
26
27
|
exportConst(name: string, value?: any): void;
|
|
27
28
|
toString(): string;
|
|
28
29
|
}
|
|
@@ -40,8 +40,8 @@ var File = /** @class */ (function () {
|
|
|
40
40
|
File.prototype.import = function (module, symbol) {
|
|
41
41
|
return this.imports.get(module, symbol);
|
|
42
42
|
};
|
|
43
|
-
File.prototype.
|
|
44
|
-
return quote(this.qrlPrefix + this.module + '
|
|
43
|
+
File.prototype.toQrlChunk = function () {
|
|
44
|
+
return quote(this.qrlPrefix + this.module + '.js');
|
|
45
45
|
};
|
|
46
46
|
File.prototype.exportConst = function (name, value) {
|
|
47
47
|
if (this.exports.has(name))
|
|
@@ -395,7 +395,7 @@ function arrowFnValue(args, expression) {
|
|
|
395
395
|
exports.arrowFnValue = arrowFnValue;
|
|
396
396
|
function iif(code) {
|
|
397
397
|
return function () {
|
|
398
|
-
this.emit('(()', exports.WS, '=>', exports.WS, '{', exports.WS, exports.NL, code, exports.NL, '}', ')()');
|
|
398
|
+
code && this.emit('(()', exports.WS, '=>', exports.WS, '{', exports.WS, exports.NL, code, exports.NL, '}', ')()');
|
|
399
399
|
};
|
|
400
400
|
}
|
|
401
401
|
exports.iif = iif;
|
|
@@ -153,7 +153,7 @@ var NODE_MAPPERS = {
|
|
|
153
153
|
.join('\n') + "</>";
|
|
154
154
|
},
|
|
155
155
|
For: function (json, options) {
|
|
156
|
-
return "{" + processBinding(json.bindings.each, options) + "
|
|
156
|
+
return "{" + processBinding(json.bindings.each, options) + ".map(" + json.properties._forName + " => (\n <>" + json.children
|
|
157
157
|
.filter(filter_empty_text_nodes_1.filterEmptyTextNodes)
|
|
158
158
|
.map(function (item) { return blockToQwik(item, options); })
|
|
159
159
|
.join('\n') + "</>\n ))}";
|
|
@@ -167,10 +167,10 @@ var NODE_MAPPERS = {
|
|
|
167
167
|
};
|
|
168
168
|
var getId = function (json, options) {
|
|
169
169
|
var name = json.properties.$name
|
|
170
|
-
? camelCase(json.properties.$name)
|
|
170
|
+
? lodash_1.camelCase(json.properties.$name)
|
|
171
171
|
: /^h\d$/.test(json.name || '') // don't dashcase h1 into h-1
|
|
172
172
|
? json.name
|
|
173
|
-
: camelCase(json.name || 'div');
|
|
173
|
+
: lodash_1.camelCase(json.name || 'div');
|
|
174
174
|
var newNameNum = (options.namesMap[name] || 0) + 1;
|
|
175
175
|
options.namesMap[name] = newNameNum;
|
|
176
176
|
return capitalize_1.capitalize("" + name + (newNameNum === 1 ? '' : "" + newNameNum));
|
|
@@ -248,7 +248,7 @@ var blockToQwik = function (json, options) {
|
|
|
248
248
|
return str;
|
|
249
249
|
};
|
|
250
250
|
var getComponentName = function (json, options) {
|
|
251
|
-
return capitalize_1.capitalize(camelCase(json.name || 'my-component'));
|
|
251
|
+
return capitalize_1.capitalize(lodash_1.camelCase(json.name || 'my-component'));
|
|
252
252
|
};
|
|
253
253
|
// TODO
|
|
254
254
|
var getProvidersString = function (componentJson, options) {
|
|
@@ -320,9 +320,9 @@ var componentToQwik = function (componentJson, toQwikOptions) {
|
|
|
320
320
|
if (options.plugins) {
|
|
321
321
|
json = plugins_1.runPostJsonPlugins(json, options.plugins);
|
|
322
322
|
}
|
|
323
|
-
componentName = capitalize_1.capitalize(camelCase(componentJson.name || 'my-component'));
|
|
323
|
+
componentName = capitalize_1.capitalize(lodash_1.camelCase(componentJson.name || 'my-component'));
|
|
324
324
|
strip_meta_properties_1.stripMetaProperties(json);
|
|
325
|
-
str = dedent_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { injectMethod, QRL,
|
|
325
|
+
str = dedent_1.default(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n import { injectMethod, QRL, jsxFactory } from '", "';\n import { ", "Component } from './", "_component.js'\n ", "\n\n export ", " injectMethod(", "Component, function (this: ", "Component) {\n return (", "\n ", "\n ", "\n ", ")\n })\n "], ["\n import { injectMethod, QRL, jsxFactory } from '", "';\n import { ", "Component } from './", "_component.js'\n ",
|
|
326
326
|
"\n\n export ",
|
|
327
327
|
" injectMethod(", "Component, function (this: ", "Component) {\n return (", "\n ",
|
|
328
328
|
"\n ", "\n ", ")\n })\n "])), qwikImport(options), componentName, componentName, render_imports_1.renderPreComponent(__assign(__assign({}, json), { imports: json.imports.map(function (item) {
|
|
@@ -333,7 +333,7 @@ var componentToQwik = function (componentJson, toQwikOptions) {
|
|
|
333
333
|
// Get the -1 index of array
|
|
334
334
|
.slice(-2, -1)
|
|
335
335
|
.pop();
|
|
336
|
-
var pascalName = capitalize_1.capitalize(camelCase(name_1));
|
|
336
|
+
var pascalName = capitalize_1.capitalize(lodash_1.camelCase(name_1));
|
|
337
337
|
clone.path = "../" + pascalName + "/public.js";
|
|
338
338
|
for (var key in clone.imports) {
|
|
339
339
|
var value = clone.imports[key];
|
|
@@ -400,14 +400,14 @@ var componentToQwik = function (componentJson, toQwikOptions) {
|
|
|
400
400
|
jsx: 'react',
|
|
401
401
|
isTSX: true,
|
|
402
402
|
allExtensions: true,
|
|
403
|
-
jsxFactory: '
|
|
404
|
-
jsxPragma: '
|
|
403
|
+
jsxFactory: 'jsxFactory',
|
|
404
|
+
jsxPragma: 'jsxFactory',
|
|
405
405
|
},
|
|
406
406
|
],
|
|
407
407
|
[
|
|
408
408
|
require('@babel/plugin-transform-react-jsx'),
|
|
409
409
|
{
|
|
410
|
-
pragma: '
|
|
410
|
+
pragma: 'jsxFactory',
|
|
411
411
|
pragmaFrag: 'null',
|
|
412
412
|
throwIfNamespace: false,
|
|
413
413
|
},
|
|
@@ -442,17 +442,4 @@ var componentToQwik = function (componentJson, toQwikOptions) {
|
|
|
442
442
|
});
|
|
443
443
|
};
|
|
444
444
|
exports.componentToQwik = componentToQwik;
|
|
445
|
-
/**
|
|
446
|
-
* This is a function similar to loadash `camelCase`, but it does not mess with capitalization.
|
|
447
|
-
*
|
|
448
|
-
* loadash: `camelCase('A-BC')` => "ABc"
|
|
449
|
-
* this fn: `camelCase('A-BC')` => "ABC"
|
|
450
|
-
*
|
|
451
|
-
*/
|
|
452
|
-
function camelCase(text) {
|
|
453
|
-
if (text === void 0) { text = ''; }
|
|
454
|
-
var parts = text.split('-');
|
|
455
|
-
var first = parts.shift();
|
|
456
|
-
return first + parts.map(capitalize_1.capitalize).join('');
|
|
457
|
-
}
|
|
458
445
|
var templateObject_1;
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { h, qHook } from "@builder.io/qwik";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const MyComponent_styles = `
|
|
5
|
+
.csw5022{
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
position: relative;
|
|
9
|
+
flex-shrink: 0;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
margin-top: 20px;
|
|
12
|
+
align-items: stretch;
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
export const MyComponent_onRender = qHook((props, state) => (
|
|
17
|
+
<div gridRowWidth="25%"
|
|
18
|
+
class="csw5022"
|
|
19
|
+
items={[{title:[{'@type':'@builder.io/sdk:Element','@version':2,layerName:'Accordion item title',id:'builder-5fed2723c1cc4fb39e9d22b9c54ef179',children:[{'@type':'@builder.io/sdk:Element','@version':2,id:'builder-2cad86b387ec405d82917895d7af0a12',component:{name:'Text',options:{text:'<p>Item 1</p>'}},responsiveStyles:{large:{textAlign:'left',display:'flex',flexDirection:'column'}}}],responsiveStyles:{large:{marginTop:'10px',position:'relative',display:'flex',alignItems:'stretch',flexDirection:'column',paddingBottom:'10px'}}}],detail:[{'@type':'@builder.io/sdk:Element','@version':2,layerName:'Accordion item detail',id:'builder-18279a99b32240f19aa21d3f4b015cc9',children:[{'@type':'@builder.io/sdk:Element','@version':2,id:'builder-2dbfa56b8988461c8566bbe759580e9b',component:{name:'Text',options:{text:'<p>Item 1 content</p>'}},responsiveStyles:{large:{paddingTop:'50px',textAlign:'left',display:'flex',flexDirection:'column',paddingBottom:'50px'}}}],responsiveStyles:{large:{position:'relative',display:'flex',alignItems:'stretch',flexDirection:'column',marginTop:'10px',paddingBottom:'10px'}}}]},{title:[{'@type':'@builder.io/sdk:Element','@version':2,layerName:'Accordion item title',id:'builder-2a93def22a354cf7aa193c20d1ad6def',children:[{'@type':'@builder.io/sdk:Element','@version':2,id:'builder-1365fc457ece45db82ad90dbe9819e7c',component:{name:'Text',options:{text:'<p>Item 2</p>'}},responsiveStyles:{large:{textAlign:'left',display:'flex',flexDirection:'column'}}}],responsiveStyles:{large:{marginTop:'10px',position:'relative',display:'flex',alignItems:'stretch',flexDirection:'column',paddingBottom:'10px'}}}],detail:[{'@type':'@builder.io/sdk:Element','@version':2,layerName:'Accordion item detail',id:'builder-fd6ef41da6d040328fbd8b0801611fe5',children:[{'@type':'@builder.io/sdk:Element','@version':2,id:'builder-7362f9fd64c647c5a400d9e75c74473f',component:{name:'Text',options:{text:'<p>Item 2 content</p>'}},responsiveStyles:{large:{paddingTop:'50px',textAlign:'left',display:'flex',flexDirection:'column',paddingBottom:'50px'}}}],responsiveStyles:{large:{position:'relative',display:'flex',alignItems:'stretch',flexDirection:'column',marginTop:'10px',paddingBottom:'10px'}}}]}]}
|
|
20
|
+
animate={true}>
|
|
21
|
+
<div innerHTML="">
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
));
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { h, qHook } from '@builder.io/qwik';
|
|
2
|
+
|
|
3
|
+
export const MyComponent_styles = `
|
|
4
|
+
.csw5022{
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
position: relative;
|
|
8
|
+
flex-shrink: 0;
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
margin-top: 20px;
|
|
11
|
+
align-items: stretch;
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const MyComponent_onRender = qHook((props, state) => (
|
|
16
|
+
<div
|
|
17
|
+
gridRowWidth="25%"
|
|
18
|
+
class="csw5022"
|
|
19
|
+
items={[
|
|
20
|
+
{
|
|
21
|
+
title: [
|
|
22
|
+
{
|
|
23
|
+
'@type': '@builder.io/sdk:Element',
|
|
24
|
+
'@version': 2,
|
|
25
|
+
layerName: 'Accordion item title',
|
|
26
|
+
id: 'builder-5fed2723c1cc4fb39e9d22b9c54ef179',
|
|
27
|
+
children: [
|
|
28
|
+
{
|
|
29
|
+
'@type': '@builder.io/sdk:Element',
|
|
30
|
+
'@version': 2,
|
|
31
|
+
id: 'builder-2cad86b387ec405d82917895d7af0a12',
|
|
32
|
+
component: { name: 'Text', options: { text: '<p>Item 1</p>' } },
|
|
33
|
+
responsiveStyles: {
|
|
34
|
+
large: {
|
|
35
|
+
textAlign: 'left',
|
|
36
|
+
display: 'flex',
|
|
37
|
+
flexDirection: 'column',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
responsiveStyles: {
|
|
43
|
+
large: {
|
|
44
|
+
marginTop: '10px',
|
|
45
|
+
position: 'relative',
|
|
46
|
+
display: 'flex',
|
|
47
|
+
alignItems: 'stretch',
|
|
48
|
+
flexDirection: 'column',
|
|
49
|
+
paddingBottom: '10px',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
detail: [
|
|
55
|
+
{
|
|
56
|
+
'@type': '@builder.io/sdk:Element',
|
|
57
|
+
'@version': 2,
|
|
58
|
+
layerName: 'Accordion item detail',
|
|
59
|
+
id: 'builder-18279a99b32240f19aa21d3f4b015cc9',
|
|
60
|
+
children: [
|
|
61
|
+
{
|
|
62
|
+
'@type': '@builder.io/sdk:Element',
|
|
63
|
+
'@version': 2,
|
|
64
|
+
id: 'builder-2dbfa56b8988461c8566bbe759580e9b',
|
|
65
|
+
component: {
|
|
66
|
+
name: 'Text',
|
|
67
|
+
options: { text: '<p>Item 1 content</p>' },
|
|
68
|
+
},
|
|
69
|
+
responsiveStyles: {
|
|
70
|
+
large: {
|
|
71
|
+
paddingTop: '50px',
|
|
72
|
+
textAlign: 'left',
|
|
73
|
+
display: 'flex',
|
|
74
|
+
flexDirection: 'column',
|
|
75
|
+
paddingBottom: '50px',
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
],
|
|
80
|
+
responsiveStyles: {
|
|
81
|
+
large: {
|
|
82
|
+
position: 'relative',
|
|
83
|
+
display: 'flex',
|
|
84
|
+
alignItems: 'stretch',
|
|
85
|
+
flexDirection: 'column',
|
|
86
|
+
marginTop: '10px',
|
|
87
|
+
paddingBottom: '10px',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
title: [
|
|
95
|
+
{
|
|
96
|
+
'@type': '@builder.io/sdk:Element',
|
|
97
|
+
'@version': 2,
|
|
98
|
+
layerName: 'Accordion item title',
|
|
99
|
+
id: 'builder-2a93def22a354cf7aa193c20d1ad6def',
|
|
100
|
+
children: [
|
|
101
|
+
{
|
|
102
|
+
'@type': '@builder.io/sdk:Element',
|
|
103
|
+
'@version': 2,
|
|
104
|
+
id: 'builder-1365fc457ece45db82ad90dbe9819e7c',
|
|
105
|
+
component: { name: 'Text', options: { text: '<p>Item 2</p>' } },
|
|
106
|
+
responsiveStyles: {
|
|
107
|
+
large: {
|
|
108
|
+
textAlign: 'left',
|
|
109
|
+
display: 'flex',
|
|
110
|
+
flexDirection: 'column',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
responsiveStyles: {
|
|
116
|
+
large: {
|
|
117
|
+
marginTop: '10px',
|
|
118
|
+
position: 'relative',
|
|
119
|
+
display: 'flex',
|
|
120
|
+
alignItems: 'stretch',
|
|
121
|
+
flexDirection: 'column',
|
|
122
|
+
paddingBottom: '10px',
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
detail: [
|
|
128
|
+
{
|
|
129
|
+
'@type': '@builder.io/sdk:Element',
|
|
130
|
+
'@version': 2,
|
|
131
|
+
layerName: 'Accordion item detail',
|
|
132
|
+
id: 'builder-fd6ef41da6d040328fbd8b0801611fe5',
|
|
133
|
+
children: [
|
|
134
|
+
{
|
|
135
|
+
'@type': '@builder.io/sdk:Element',
|
|
136
|
+
'@version': 2,
|
|
137
|
+
id: 'builder-7362f9fd64c647c5a400d9e75c74473f',
|
|
138
|
+
component: {
|
|
139
|
+
name: 'Text',
|
|
140
|
+
options: { text: '<p>Item 2 content</p>' },
|
|
141
|
+
},
|
|
142
|
+
responsiveStyles: {
|
|
143
|
+
large: {
|
|
144
|
+
paddingTop: '50px',
|
|
145
|
+
textAlign: 'left',
|
|
146
|
+
display: 'flex',
|
|
147
|
+
flexDirection: 'column',
|
|
148
|
+
paddingBottom: '50px',
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
responsiveStyles: {
|
|
154
|
+
large: {
|
|
155
|
+
position: 'relative',
|
|
156
|
+
display: 'flex',
|
|
157
|
+
alignItems: 'stretch',
|
|
158
|
+
flexDirection: 'column',
|
|
159
|
+
marginTop: '10px',
|
|
160
|
+
paddingBottom: '10px',
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
],
|
|
165
|
+
},
|
|
166
|
+
]}
|
|
167
|
+
animate={true}
|
|
168
|
+
>
|
|
169
|
+
<div innerHTML=""></div>
|
|
170
|
+
</div>
|
|
171
|
+
));
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { h, qComponent, qHook } from "@builder.io/qwik";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const onMountCreateEmptyState = qHook(() => ({}));
|
|
5
|
+
export const MyComponent = qComponent({
|
|
6
|
+
onMount: qHook("./med#onMountCreateEmptyState"),
|
|
7
|
+
onRender: qHook("./low#MyComponent_onRender"),
|
|
8
|
+
styles: "./low#MyComponent_styles"
|
|
9
|
+
});
|
|
10
|
+
export function Image(props){var jsx = props.children || [];var image = props.image;if(image){var isBuilderIoImage = !!(image || '').match(/builder\.io/);var imgProps ={src:props.image,backgroundSize:props.backgroundSize,backgroundPosition:props.backgroundPosition,altText:props.altText,fitContent:props.fitContent,aspectRatio:props.aspectRatio,class:props.class,lazy:props.lazy ? 'lazy':null,srcset:null,};var img = h('img',imgProps,jsx);if(isBuilderIoImage){var url_1 = new URL(image);var srcset = [100,200,400,800,1200,1600,2000] .map(function(size){url_1.searchParams.set('width',String(size));return "".concat(url_1," ").concat(size,"w");}).concat([image]).join(',');imgProps.srcset = srcset;jsx = jsx = [ h('picture',{},[ h('source',{type:'image/webp',srcset:srcset}),img,]),];}else{jsx = [img];}}if(props.href){jsx = [h('a',{href:props.href},jsx)];}return jsx;}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { h, qComponent, qHook } from '@builder.io/qwik';
|
|
2
|
+
|
|
3
|
+
export const onMountCreateEmptyState = qHook(() => ({}));
|
|
4
|
+
export const MyComponent = qComponent({
|
|
5
|
+
onMount: qHook('./med#onMountCreateEmptyState'),
|
|
6
|
+
onRender: qHook('./low#MyComponent_onRender'),
|
|
7
|
+
styles: './low#MyComponent_styles',
|
|
8
|
+
});
|
|
9
|
+
export function Image(props) {
|
|
10
|
+
var jsx = props.children || [];
|
|
11
|
+
var image = props.image;
|
|
12
|
+
if (image) {
|
|
13
|
+
var isBuilderIoImage = !!(image || '').match(/builder\.io/);
|
|
14
|
+
var imgProps = {
|
|
15
|
+
src: props.image,
|
|
16
|
+
backgroundSize: props.backgroundSize,
|
|
17
|
+
backgroundPosition: props.backgroundPosition,
|
|
18
|
+
altText: props.altText,
|
|
19
|
+
fitContent: props.fitContent,
|
|
20
|
+
aspectRatio: props.aspectRatio,
|
|
21
|
+
class: props.class,
|
|
22
|
+
lazy: props.lazy ? 'lazy' : null,
|
|
23
|
+
srcset: null,
|
|
24
|
+
};
|
|
25
|
+
var img = h('img', imgProps, jsx);
|
|
26
|
+
if (isBuilderIoImage) {
|
|
27
|
+
var url_1 = new URL(image);
|
|
28
|
+
var srcset = [100, 200, 400, 800, 1200, 1600, 2000]
|
|
29
|
+
.map(function (size) {
|
|
30
|
+
url_1.searchParams.set('width', String(size));
|
|
31
|
+
return ''.concat(url_1, ' ').concat(size, 'w');
|
|
32
|
+
})
|
|
33
|
+
.concat([image])
|
|
34
|
+
.join(',');
|
|
35
|
+
imgProps.srcset = srcset;
|
|
36
|
+
jsx = jsx = [
|
|
37
|
+
h('picture', {}, [
|
|
38
|
+
h('source', { type: 'image/webp', srcset: srcset }),
|
|
39
|
+
img,
|
|
40
|
+
]),
|
|
41
|
+
];
|
|
42
|
+
} else {
|
|
43
|
+
jsx = [img];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
if (props.href) {
|
|
47
|
+
jsx = [h('a', { href: props.href }, jsx)];
|
|
48
|
+
}
|
|
49
|
+
return jsx;
|
|
50
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { h, qComponent, qHook } from '@builder.io/qwik';
|
|
2
|
+
|
|
3
|
+
export const onMountCreateEmptyState = qHook(() => ({}));
|
|
4
|
+
export const MyComponent = qComponent({
|
|
5
|
+
onMount: qHook('./med#onMountCreateEmptyState'),
|
|
6
|
+
onRender: qHook('./low#MyComponent_onRender'),
|
|
7
|
+
styles: './low#MyComponent_styles',
|
|
8
|
+
});
|
|
9
|
+
export const Image = function Image(props) {
|
|
10
|
+
var jsx = props.children || [];
|
|
11
|
+
var image = props.image;
|
|
12
|
+
if (image) {
|
|
13
|
+
var isBuilderIoImage = !!(image || '').match(/builder\.io/);
|
|
14
|
+
var imgProps = {
|
|
15
|
+
src: props.image,
|
|
16
|
+
sizes: props.sizes,
|
|
17
|
+
alt: props.altText,
|
|
18
|
+
class: props.class,
|
|
19
|
+
lazy: props.lazy ? 'lazy' : undefined,
|
|
20
|
+
srcset: undefined,
|
|
21
|
+
};
|
|
22
|
+
if (isBuilderIoImage) {
|
|
23
|
+
var url_1 = new URL(image);
|
|
24
|
+
var srcset = [100, 200, 400, 800, 1200, 1600, 2000]
|
|
25
|
+
.map(function (size) {
|
|
26
|
+
url_1.searchParams.set('width', String(size));
|
|
27
|
+
return ''.concat(url_1, ' ').concat(size, 'w');
|
|
28
|
+
})
|
|
29
|
+
.concat([image])
|
|
30
|
+
.join(',');
|
|
31
|
+
imgProps.srcset = srcset;
|
|
32
|
+
jsx = jsx = [
|
|
33
|
+
h('picture', {}, [
|
|
34
|
+
h('source', { type: 'image/webp', srcset: srcset }),
|
|
35
|
+
h('img', imgProps, jsx),
|
|
36
|
+
h('div', {
|
|
37
|
+
class: 'builder-image-sizer',
|
|
38
|
+
styles: {
|
|
39
|
+
width: '100%',
|
|
40
|
+
paddingTop: (props.aspectRatio || 1) * 100 + '%',
|
|
41
|
+
pointerEvents: 'none',
|
|
42
|
+
fontSize: '0',
|
|
43
|
+
},
|
|
44
|
+
}),
|
|
45
|
+
]),
|
|
46
|
+
];
|
|
47
|
+
} else {
|
|
48
|
+
jsx = [h('img', imgProps, jsx)];
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
if (props.href) {
|
|
52
|
+
jsx = [h('a', { href: props.href }, jsx)];
|
|
53
|
+
}
|
|
54
|
+
return jsx;
|
|
55
|
+
};
|