@builder.io/mitosis 0.0.48 → 0.0.49

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.
Files changed (152) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/dist/src/__tests__/angular.test.d.ts +1 -0
  3. package/dist/src/__tests__/angular.test.js +12 -0
  4. package/dist/src/__tests__/data/blocks/onUpdate.raw.d.ts +1 -0
  5. package/dist/src/__tests__/data/blocks/onUpdate.raw.jsx +10 -0
  6. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.d.ts +1 -0
  7. package/dist/src/__tests__/data/blocks/onUpdateWithDeps.raw.jsx +11 -0
  8. package/dist/src/__tests__/data/blocks/tabs.raw.d.ts +11 -0
  9. package/dist/src/__tests__/data/blocks/tabs.raw.jsx +24 -0
  10. package/dist/src/__tests__/qoot.test.d.ts +1 -0
  11. package/dist/src/__tests__/qoot.test.js +115 -0
  12. package/dist/src/__tests__/qwik.test.js +38 -10
  13. package/dist/src/__tests__/react.test.js +12 -0
  14. package/dist/src/__tests__/svelte.test.d.ts +1 -0
  15. package/dist/src/__tests__/svelte.test.js +12 -0
  16. package/dist/src/__tests__/vue.test.js +6 -0
  17. package/dist/src/generators/angular.js +7 -3
  18. package/dist/src/generators/builder.js +7 -7
  19. package/dist/src/generators/html.js +16 -7
  20. package/dist/src/generators/jsx-lite.d.ts +10 -0
  21. package/dist/src/generators/jsx-lite.js +176 -0
  22. package/dist/src/generators/minify.d.ts +1 -0
  23. package/dist/src/generators/minify.js +24 -0
  24. package/dist/src/generators/mitosis.js +5 -2
  25. package/dist/src/generators/qoot.d.ts +21 -0
  26. package/dist/src/generators/qoot.js +442 -0
  27. package/dist/src/generators/qwik/component.js +48 -6
  28. package/dist/src/generators/qwik/directives.d.ts +21 -1
  29. package/dist/src/generators/qwik/directives.js +80 -3
  30. package/dist/src/generators/qwik/jsx.d.ts +1 -1
  31. package/dist/src/generators/qwik/jsx.js +28 -5
  32. package/dist/src/generators/qwik/src-generator.d.ts +3 -1
  33. package/dist/src/generators/qwik/src-generator.js +34 -10
  34. package/dist/src/generators/qwik.d.ts +21 -0
  35. package/dist/src/generators/qwik.js +458 -0
  36. package/dist/src/generators/react.js +13 -7
  37. package/dist/src/generators/solid.js +5 -2
  38. package/dist/src/generators/svelte.js +10 -5
  39. package/dist/src/generators/vue.js +7 -5
  40. package/dist/src/helpers/create-jsx-lite-component.d.ts +2 -0
  41. package/dist/src/helpers/create-jsx-lite-component.js +16 -0
  42. package/dist/src/helpers/create-jsx-lite-context.d.ts +4 -0
  43. package/dist/src/helpers/create-jsx-lite-context.js +18 -0
  44. package/dist/src/helpers/create-jsx-lite-node.d.ts +2 -0
  45. package/dist/src/helpers/create-jsx-lite-node.js +16 -0
  46. package/dist/src/helpers/is-jsx-lite-node.d.ts +2 -0
  47. package/dist/src/helpers/is-jsx-lite-node.js +7 -0
  48. package/dist/src/helpers/map-refs.js +7 -6
  49. package/dist/src/helpers/process-http-requests.js +3 -3
  50. package/dist/src/helpers/process-tag-references.js +4 -3
  51. package/dist/src/index.d.ts +2 -1
  52. package/dist/src/index.js +4 -3
  53. package/dist/src/parsers/builder.d.ts +50 -10
  54. package/dist/src/parsers/builder.js +37 -7
  55. package/dist/src/parsers/jsx.js +43 -3
  56. package/dist/src/parsers/liquid.js +4 -4
  57. package/dist/src/plugins/compile-away-builder-components.js +40 -20
  58. package/dist/src/symbols/symbol-processor.d.ts +18 -0
  59. package/dist/src/symbols/symbol-processor.js +177 -0
  60. package/dist/src/types/jsx-lite-component.d.ts +63 -0
  61. package/dist/src/types/jsx-lite-component.js +2 -0
  62. package/dist/src/types/jsx-lite-context.d.ts +6 -0
  63. package/dist/src/types/jsx-lite-context.js +2 -0
  64. package/dist/src/types/jsx-lite-node.d.ts +13 -0
  65. package/dist/src/types/jsx-lite-node.js +2 -0
  66. package/dist/src/types/jsx-lite-styles.d.ts +1 -0
  67. package/dist/src/types/jsx-lite-styles.js +2 -0
  68. package/dist/src/types/mitosis-component.d.ts +10 -5
  69. package/dist/test/qoot/Todo/bundle.js +88 -0
  70. package/dist/test/qoot/Todo/component.ts +17 -0
  71. package/dist/test/qoot/Todo/onButtonClick.ts +13 -0
  72. package/dist/test/qoot/Todo/onInput2Blur.ts +11 -0
  73. package/dist/test/qoot/Todo/onInput2KeyUp.ts +10 -0
  74. package/dist/test/qoot/Todo/onInputClick.ts +10 -0
  75. package/dist/test/qoot/Todo/onLabelDblClick.ts +11 -0
  76. package/dist/test/qoot/Todo/public.ts +4 -0
  77. package/dist/test/qoot/Todo/template.tsx +46 -0
  78. package/dist/test/qoot/Todos/component.ts +9 -0
  79. package/dist/test/qoot/Todos/onInputClick.ts +14 -0
  80. package/dist/test/qoot/Todos/public.ts +3 -0
  81. package/dist/test/qoot/Todos/template.tsx +30 -0
  82. package/dist/test/qwik/{todo → Todo}/Todo.cjs/high.cjs +0 -0
  83. package/dist/test/qwik/{todo → Todo}/Todo.cjs/low.cjs +0 -0
  84. package/dist/test/qwik/{todo → Todo}/Todo.cjs/med.cjs +0 -0
  85. package/dist/test/qwik/{todo → Todo}/Todo.js/high.js +0 -0
  86. package/dist/test/qwik/{todo → Todo}/Todo.js/low.js +0 -0
  87. package/dist/test/qwik/{todo → Todo}/Todo.js/med.js +0 -0
  88. package/dist/test/qwik/{todo → Todo}/Todo.tsx/high.tsx +0 -0
  89. package/dist/test/qwik/{todo → Todo}/Todo.tsx/low.tsx +0 -0
  90. package/dist/test/qwik/{todo → Todo}/Todo.tsx/med.tsx +0 -0
  91. package/dist/test/qwik/Todo/bundle.js +46 -0
  92. package/dist/test/qwik/Todo/component.ts +17 -0
  93. package/dist/test/qwik/Todo/onButtonClick.ts +10 -0
  94. package/dist/test/qwik/Todo/onInput2Blur.ts +14 -0
  95. package/dist/test/qwik/Todo/onInput2KeyUp.ts +10 -0
  96. package/dist/test/qwik/Todo/onInputClick.ts +13 -0
  97. package/dist/test/qwik/Todo/onLabelDblClick.ts +11 -0
  98. package/dist/test/qwik/Todo/public.ts +3 -0
  99. package/dist/test/qwik/Todo/template.tsx +46 -0
  100. package/dist/test/qwik/Todo.ts +4 -0
  101. package/dist/test/qwik/Todo_component.ts +17 -0
  102. package/dist/test/qwik/Todo_onButtonClick.ts +13 -0
  103. package/dist/test/qwik/Todo_onInput2Blur.ts +14 -0
  104. package/dist/test/qwik/Todo_onInput2KeyUp.ts +10 -0
  105. package/dist/test/qwik/Todo_onInputClick.ts +13 -0
  106. package/dist/test/qwik/Todo_onLabelDblClick.ts +14 -0
  107. package/dist/test/qwik/Todo_template.tsx +46 -0
  108. package/dist/test/qwik/{todos → Todos}/Todo.tsx/high.tsx +0 -0
  109. package/dist/test/qwik/{todos → Todos}/Todo.tsx/low.tsx +3 -4
  110. package/dist/test/qwik/{todos → Todos}/Todo.tsx/med.tsx +0 -0
  111. package/dist/test/qwik/Todos/component.ts +9 -0
  112. package/dist/test/qwik/Todos/onInputClick.ts +14 -0
  113. package/dist/test/qwik/Todos/public.ts +3 -0
  114. package/dist/test/qwik/Todos/template.tsx +30 -0
  115. package/dist/test/qwik/Todos.ts +3 -0
  116. package/dist/test/qwik/Todos_component.ts +9 -0
  117. package/dist/test/qwik/Todos_onInputClick.ts +14 -0
  118. package/dist/test/qwik/Todos_template.tsx +30 -0
  119. package/dist/test/qwik/qwik/Image/high.js +1 -0
  120. package/dist/test/qwik/qwik/Image/low.js +75 -0
  121. package/dist/test/qwik/qwik/Image/med.js +9 -0
  122. package/dist/test/qwik/{For/high.jsx → qwik/Image.slow/high.js} +0 -0
  123. package/dist/test/qwik/qwik/Image.slow/low.js +75 -0
  124. package/dist/test/qwik/{For/med.jsx → qwik/Image.slow/med.js} +0 -0
  125. package/dist/test/qwik/qwik/button/high.js +8 -0
  126. package/dist/test/qwik/qwik/button/low.js +34 -0
  127. package/dist/test/qwik/qwik/button/med.js +9 -0
  128. package/dist/test/qwik/qwik/hello_world/stylesheet/high.jsx +1 -0
  129. package/dist/test/qwik/qwik/hello_world/stylesheet/low.jsx +24 -0
  130. package/dist/test/qwik/qwik/hello_world/stylesheet/med.jsx +9 -0
  131. package/dist/test/qwik/qwik/page-with-symbol/high.js +1 -0
  132. package/dist/test/qwik/qwik/page-with-symbol/low.js +49 -0
  133. package/dist/test/qwik/qwik/page-with-symbol/med.js +9 -0
  134. package/dist/test/qwik/qwik/svg/high.js +1 -0
  135. package/dist/test/qwik/qwik/svg/low.js +30 -0
  136. package/dist/test/qwik/qwik/svg/med.js +9 -0
  137. package/dist/test/qwik/qwik/todo/Todo.cjs/high.cjs +31 -0
  138. package/dist/test/qwik/qwik/todo/Todo.cjs/low.cjs +1 -0
  139. package/dist/test/qwik/qwik/todo/Todo.cjs/med.cjs +59 -0
  140. package/dist/test/qwik/qwik/todo/Todo.js/high.js +5 -0
  141. package/dist/{src/types/generators.d.ts → test/qwik/qwik/todo/Todo.js/low.js} +0 -0
  142. package/dist/test/qwik/qwik/todo/Todo.js/med.js +1 -0
  143. package/dist/test/qwik/qwik/todo/Todo.tsx/high.tsx +30 -0
  144. package/dist/test/qwik/qwik/todo/Todo.tsx/low.tsx +1 -0
  145. package/dist/test/qwik/qwik/todo/Todo.tsx/med.tsx +34 -0
  146. package/dist/test/qwik/qwik/todos/Todo.tsx/high.tsx +12 -0
  147. package/dist/test/qwik/qwik/todos/Todo.tsx/low.tsx +24 -0
  148. package/dist/test/qwik/qwik/todos/Todo.tsx/med.tsx +8 -0
  149. package/dist/tsconfig.tsbuildinfo +1 -1
  150. package/package.json +1 -1
  151. package/dist/src/types/generators.js +0 -1
  152. package/dist/test/qwik/For/low.jsx +0 -55
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
3
+ if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
4
+ return cooked;
5
+ };
6
+ var __assign = (this && this.__assign) || function () {
7
+ __assign = Object.assign || function(t) {
8
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
9
+ s = arguments[i];
10
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
11
+ t[p] = s[p];
12
+ }
13
+ return t;
14
+ };
15
+ return __assign.apply(this, arguments);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ exports.getJsxSymbolComponentName = exports.convertBuilderElementToMitosisComponent = exports.convertBuilderContentToSymbolHierarchy = exports.ensureAllSymbolsHaveIds = void 0;
19
+ var traverse_1 = require("traverse");
20
+ var builder_1 = require("../parsers/builder");
21
+ var minify_1 = require("../generators/minify");
22
+ /**
23
+ * Ensure every symbol in a BuilderContent tree has a unique ID.
24
+ * Mutates the data tree directly.
25
+ */
26
+ function ensureAllSymbolsHaveIds(content) {
27
+ var ids = new Set();
28
+ (0, traverse_1.forEach)(content, function (el) {
29
+ var _a, _b, _c;
30
+ if (this.key === 'jsCode' &&
31
+ isString(el) &&
32
+ el.endsWith('return _virtual_index')) {
33
+ // Sometimes rollup adds a final `return _virtual_index` but that causes VM evaluation to fail.
34
+ // Instead of a return on the last line, it needs a plain expression on the last line. Luckily
35
+ // because the rollup compile behavior is consistent this works pretty reliably
36
+ el = el.replace(/return _virtual_index$/, '_virtual_index');
37
+ this.parent && (this.parent.node.jsCode = el);
38
+ }
39
+ if ((0, builder_1.isBuilderElement)(el)) {
40
+ if (((_a = el === null || el === void 0 ? void 0 : el.component) === null || _a === void 0 ? void 0 : _a.name) === 'Symbol') {
41
+ var id = getIdFromSymbol(el);
42
+ if (id) {
43
+ if (ids.has(id)) {
44
+ if ((_c = (_b = el.component) === null || _b === void 0 ? void 0 : _b.options) === null || _c === void 0 ? void 0 : _c.symbol) {
45
+ var id_1 = generateId();
46
+ el.component.options.symbol.entry = id_1;
47
+ if (el.component.options.symbol.content) {
48
+ el.component.options.symbol.content.id = id_1;
49
+ }
50
+ ids.add(id_1);
51
+ }
52
+ }
53
+ else {
54
+ ids.add(id);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ });
60
+ }
61
+ exports.ensureAllSymbolsHaveIds = ensureAllSymbolsHaveIds;
62
+ //TODO(misko): needs test
63
+ function convertBuilderContentToSymbolHierarchy(content, _a) {
64
+ var _b;
65
+ var _c = _a === void 0 ? {} : _a, collectComponentStyles = _c.collectComponentStyles, collectComponentState = _c.collectComponentState;
66
+ var path = [-1, content.id];
67
+ var hierarchy = (_b = {
68
+ depthFirstSymbols: []
69
+ },
70
+ _b[content.id] = [],
71
+ _b);
72
+ (0, traverse_1.forEach)(content, function (el) {
73
+ var _a, _b, _c;
74
+ var cssCode = el === null || el === void 0 ? void 0 : el.cssCode;
75
+ if (cssCode) {
76
+ collectComponentStyles && collectComponentStyles.push((0, minify_1.minify)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", ""], ["", ""])), cssCode));
77
+ }
78
+ while (path[0 /* DEPTH */] >= this.path.length) {
79
+ path.shift();
80
+ path.shift();
81
+ }
82
+ if ((0, builder_1.isBuilderElement)(el)) {
83
+ if (((_a = el === null || el === void 0 ? void 0 : el.component) === null || _a === void 0 ? void 0 : _a.name) === 'Symbol') {
84
+ if (collectComponentState) {
85
+ var symbol = el.component.options.symbol;
86
+ var props = symbol.data;
87
+ var state = (_c = (_b = symbol.content) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c.state;
88
+ if (state) {
89
+ var id = toHash(state);
90
+ props['serverStateId'] = id;
91
+ collectComponentState[id] = state;
92
+ }
93
+ }
94
+ if (path[0 /* DEPTH */] < this.path.length) {
95
+ var id = getIdFromSymbol(el);
96
+ hierarchy[id] = [];
97
+ addIfMissing(hierarchy[path[1 /* ID */]], id);
98
+ path.unshift(this.path.length, id);
99
+ }
100
+ // TODO(misko): This should be `el.content` not `el`
101
+ // Because we don't wante to take the `<Symbol>` with us.
102
+ // TODO(misko): Do we really want to add ALL symbols? Even duplicates?
103
+ hierarchy.depthFirstSymbols.unshift(el);
104
+ }
105
+ }
106
+ });
107
+ return hierarchy;
108
+ }
109
+ exports.convertBuilderContentToSymbolHierarchy = convertBuilderContentToSymbolHierarchy;
110
+ function convertBuilderElementToMitosisComponent(element) {
111
+ var _a, _b;
112
+ var symbolValue = (_b = (_a = element.component) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.symbol;
113
+ var elContent = symbolValue === null || symbolValue === void 0 ? void 0 : symbolValue.content;
114
+ if (!elContent) {
115
+ console.warn('Symbol missing content', element.id);
116
+ delete element.component; // TODO(misko): Should this be assign `undefined` for perf?
117
+ element.children = [];
118
+ return null;
119
+ }
120
+ var id = getIdFromSymbol(element);
121
+ var componentName = getJsxSymbolComponentName(id);
122
+ delete element.component; // TODO(misko): Should this be assign `undefined` for perf?
123
+ element.children = [
124
+ (0, builder_1.createBuilderElement)({
125
+ component: {
126
+ name: componentName,
127
+ options: symbolValue.data,
128
+ },
129
+ }),
130
+ ];
131
+ var mitosisComponent = __assign(__assign({}, (0, builder_1.builderContentToMitosisComponent)(elContent, {
132
+ includeBuilderExtras: true,
133
+ preserveTextBlocks: true,
134
+ })), { name: componentName });
135
+ mitosisComponent.meta.builderElId = element.id;
136
+ return mitosisComponent;
137
+ }
138
+ exports.convertBuilderElementToMitosisComponent = convertBuilderElementToMitosisComponent;
139
+ function getJsxSymbolComponentName(id) {
140
+ return 'Component' + id.toUpperCase().replace(/-/g, '');
141
+ }
142
+ exports.getJsxSymbolComponentName = getJsxSymbolComponentName;
143
+ function getIdFromSymbol(el) {
144
+ var _a, _b, _c;
145
+ // TODO(misko): Don't use entry us el.id???
146
+ return (_c = (_b = (_a = el.component) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.symbol) === null || _c === void 0 ? void 0 : _c.entry;
147
+ }
148
+ function addIfMissing(array, value) {
149
+ if (array.indexOf(value) == -1) {
150
+ array.push(value);
151
+ }
152
+ }
153
+ function isString(value) {
154
+ return typeof value == 'string';
155
+ }
156
+ function generateId() {
157
+ return (
158
+ // TODO(misko): For now I have removed the data as I think it is overkill
159
+ // and makes the output unnecessarily big.
160
+ // new Date().getTime().toString(36) +
161
+ Math.round(Math.random() * Number.MAX_SAFE_INTEGER).toString(36));
162
+ }
163
+ function toHash(obj) {
164
+ return hashCode(JSON.stringify(obj));
165
+ }
166
+ function hashCode(text) {
167
+ var hash = 0, i, chr;
168
+ if (text.length === 0)
169
+ return String(hash);
170
+ for (i = 0; i < text.length; i++) {
171
+ chr = text.charCodeAt(i);
172
+ hash = (hash << 5) - hash + chr;
173
+ hash |= 0; // Convert to 32bit integer
174
+ }
175
+ return Number(Math.abs(hash)).toString(36);
176
+ }
177
+ var templateObject_1;
@@ -0,0 +1,63 @@
1
+ import { JSONObject } from './json';
2
+ import { JSXLiteNode } from './jsx-lite-node';
3
+ /**
4
+ * @example
5
+ * // import core, { useState, someThing as someAlias } from '@jsx-lite/core'
6
+ * {
7
+ * path: '@jsx-lite/core',
8
+ * imports: {
9
+ * useState: 'useState',
10
+ * someAlias: 'someThing',
11
+ * core: 'default',
12
+ * }
13
+ * }
14
+ *
15
+ * @example
16
+ * // import * as core from '@jsx-lite/core'
17
+ * {
18
+ * path: '@jsx-lite/core',
19
+ * imports: {
20
+ * core: '*',
21
+ * }
22
+ * }
23
+ */
24
+ export interface JSXLiteImport {
25
+ path: string;
26
+ imports: {
27
+ [key: string]: string | undefined;
28
+ };
29
+ }
30
+ declare type ContextInfo = {
31
+ name: string;
32
+ path: string;
33
+ };
34
+ export declare type JSXLiteComponent = {
35
+ '@type': '@jsx-lite/component';
36
+ name: string;
37
+ imports: JSXLiteImport[];
38
+ meta: JSONObject & {
39
+ metadataHook?: JSONObject;
40
+ };
41
+ state: JSONObject;
42
+ context: {
43
+ get: {
44
+ [key: string]: ContextInfo;
45
+ };
46
+ set: {
47
+ [key: string]: {
48
+ name: string;
49
+ value?: JSONObject;
50
+ };
51
+ };
52
+ };
53
+ hooks: {
54
+ init?: string;
55
+ onMount?: string;
56
+ onUnMount?: string;
57
+ preComponent?: string;
58
+ postComponent?: string;
59
+ };
60
+ children: JSXLiteNode[];
61
+ subComponents: JSXLiteComponent[];
62
+ };
63
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { JSONObject } from '../types/json';
2
+ export declare type JSXLiteContext = {
3
+ '@type': '@jsx-lite/context';
4
+ name: string;
5
+ value: JSONObject;
6
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { JSONObject } from './json';
2
+ export declare type JSXLiteNode = {
3
+ '@type': '@jsx-lite/node';
4
+ name: string;
5
+ meta: JSONObject;
6
+ properties: {
7
+ [key: string]: string | undefined;
8
+ };
9
+ bindings: {
10
+ [key: string]: string | undefined;
11
+ };
12
+ children: JSXLiteNode[];
13
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export declare type JSXLiteStyles = Omit<Partial<CSSStyleDeclaration>, 'length' | 'getPropertyPriority' | 'getPropertyValue' | 'item' | 'removeProperty' | 'setProperty'>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -31,6 +31,10 @@ declare type ContextInfo = {
31
31
  name: string;
32
32
  path: string;
33
33
  };
34
+ declare type extendedHook = {
35
+ code: string;
36
+ deps?: string;
37
+ };
34
38
  export declare type MitosisComponent = {
35
39
  '@type': '@builder.io/mitosis/component';
36
40
  name: string;
@@ -51,11 +55,12 @@ export declare type MitosisComponent = {
51
55
  };
52
56
  };
53
57
  hooks: {
54
- init?: string;
55
- onMount?: string;
56
- onUnMount?: string;
57
- preComponent?: string;
58
- postComponent?: string;
58
+ init?: extendedHook;
59
+ onMount?: extendedHook;
60
+ onUnMount?: extendedHook;
61
+ preComponent?: extendedHook;
62
+ postComponent?: extendedHook;
63
+ onUpdate?: extendedHook;
59
64
  };
60
65
  children: MitosisNode[];
61
66
  subComponents: MitosisComponent[];
@@ -0,0 +1,88 @@
1
+ import { Component, injectMethod, jsxFactory, QRL, injectEventHandler, provideEvent, markDirty } from '@builder.io/qwik';
2
+
3
+ function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ class TodoComponent$1 extends Component {
5
+ constructor(...args) {
6
+ super(...args);
7
+
8
+ _defineProperty$1(this, "editing", false);
9
+ }
10
+
11
+ toggle() {
12
+ this.todo.completed = !this.todo.completed;
13
+ }
14
+
15
+ $newState() {
16
+ return {}; // TODO
17
+ }
18
+
19
+ }
20
+
21
+ _defineProperty$1(TodoComponent$1, "$templateQRL", "ui:/Todo/bundle.template");
22
+
23
+ const template = injectMethod(TodoComponent$1, function () {
24
+ return jsxFactory("li", {
25
+ class: `${this.todo.completed ? "completed" : ""} ${this.editing ? "editing" : ""}`
26
+ }, jsxFactory("div", {
27
+ class: "view"
28
+ }, jsxFactory("input", {
29
+ class: "toggle",
30
+ type: "checkbox",
31
+ checked: this.todo.completed,
32
+ "on:click": QRL`ui:/Todo/bundle.onInputClick`
33
+ }), jsxFactory("label", {
34
+ "on:dblclick": QRL`ui:/Todo/bundle.onLabelDblClick`
35
+ }, this.todo.text), jsxFactory("button", {
36
+ class: "destroy",
37
+ "on:click": QRL`ui:/Todo/bundle.onButtonClick`
38
+ })), this.editing ? jsxFactory(null, null, jsxFactory("input", {
39
+ class: "edit",
40
+ value: this.todo.text,
41
+ "on:blur": QRL`ui:/Todo/bundle.onInput2Blur`,
42
+ "on:keyup": QRL`ui:/Todo/bundle.onInput2KeyUp`
43
+ })) : undefined);
44
+ });
45
+
46
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
47
+ class TodoComponent extends Component {
48
+ constructor(...args) {
49
+ super(...args);
50
+
51
+ _defineProperty(this, "editing", false);
52
+ }
53
+
54
+ toggle() {
55
+ this.todo.completed = !this.todo.completed;
56
+ }
57
+
58
+ $newState() {
59
+ return {}; // TODO
60
+ }
61
+
62
+ }
63
+
64
+ _defineProperty(TodoComponent, "$templateQRL", "ui:/Todo/bundle.template");
65
+
66
+ const onInputClick = injectEventHandler(TodoComponent$1, provideEvent(), async function (event) {
67
+ this.toggle();
68
+ });
69
+
70
+ const onLabelDblClick = injectEventHandler(TodoComponent$1, provideEvent(), async function (event) {
71
+ this.editing = true;
72
+ markDirty(this);
73
+ });
74
+
75
+ const onButtonClick = injectEventHandler(TodoComponent$1, provideEvent(), async function (event) {
76
+ todosState.todos.splice(todosState.todos.indexOf(this.todo));
77
+ });
78
+
79
+ const onInput2Blur = injectEventHandler(TodoComponent$1, provideEvent(), async function (event) {
80
+ this.editing = false;
81
+ markDirty(this);
82
+ });
83
+
84
+ const onInput2KeyUp = injectEventHandler(TodoComponent$1, provideEvent(), async function (event) {
85
+ this.todo.text = event.target.value;
86
+ });
87
+
88
+ export { TodoComponent, onButtonClick, onInput2Blur, onInput2KeyUp, onInputClick, onLabelDblClick, template };
@@ -0,0 +1,17 @@
1
+ import { Component, QRL } from "@builder.io/qwik";
2
+
3
+ export class TodoComponent extends Component<any, any> {
4
+ static $templateQRL = "ui:/Todo/template";
5
+
6
+ editing = false;
7
+ toggle() {
8
+ this.todo.completed = !this.todo.completed;
9
+ }
10
+
11
+ $newState() {
12
+ return {}; // TODO
13
+ }
14
+ }
15
+
16
+ }
17
+ }
@@ -0,0 +1,13 @@
1
+ import { injectEventHandler, provideEvent, markDirty } from "@builder.io/qwik";
2
+ import { TodoComponent } from "./component.js";
3
+
4
+ export default injectEventHandler(
5
+ TodoComponent,
6
+ provideEvent(),
7
+ async function (this: TodoComponent, event: Event) {
8
+ todosState.todos.splice(todosState.todos.indexOf(this.todo));
9
+ }
10
+ );
11
+ odo));
12
+ }
13
+ );
@@ -0,0 +1,11 @@
1
+ import { injectEventHandler, provideEvent, markDirty } from "@builder.io/qwik";
2
+ import { TodoComponent } from "./component.js";
3
+
4
+ export const onInput2Blur = injectEventHandler(
5
+ TodoComponent,
6
+ provideEvent(),
7
+ async function (this: TodoComponent, event: Event) {
8
+ this.editing = false;
9
+ markDirty(this);
10
+ }
11
+ );
@@ -0,0 +1,10 @@
1
+ import { injectEventHandler, provideEvent, markDirty } from "@builder.io/qwik";
2
+ import { TodoComponent } from "./component.js";
3
+
4
+ export const onInput2KeyUp = injectEventHandler(
5
+ TodoComponent,
6
+ provideEvent(),
7
+ async function (this: TodoComponent, event: Event) {
8
+ this.todo.text = event.target.value;
9
+ }
10
+ );
@@ -0,0 +1,10 @@
1
+ import { injectEventHandler, provideEvent, markDirty } from "@builder.io/qwik";
2
+ import { TodoComponent } from "./component.js";
3
+
4
+ export const onInputClick = injectEventHandler(
5
+ TodoComponent,
6
+ provideEvent(),
7
+ async function (this: TodoComponent, event: Event) {
8
+ this.toggle();
9
+ }
10
+ );
@@ -0,0 +1,11 @@
1
+ import { injectEventHandler, provideEvent, markDirty } from "@builder.io/qwik";
2
+ import { TodoComponent } from "./component.js";
3
+
4
+ export const onLabelDblClick = injectEventHandler(
5
+ TodoComponent,
6
+ provideEvent(),
7
+ async function (this: TodoComponent, event: Event) {
8
+ this.editing = true;
9
+ markDirty(this);
10
+ }
11
+ );
@@ -0,0 +1,4 @@
1
+ import { jsxDeclareComponent, QRL } from "@builder.io/qwik";
2
+
3
+ export const Todo = jsxDeclareComponent(QRL`ui:/Todo/template`, "todo");
4
+ odo");
@@ -0,0 +1,46 @@
1
+ import { injectMethod, QRL, jsxFactory } from "@builder.io/qwik";
2
+ import { TodoComponent } from "./component.js";
3
+
4
+ import { TodosState as todosState } from "../TodosState/public.js";
5
+
6
+ export const template = injectMethod(
7
+ TodoComponent,
8
+ function (this: TodoComponent) {
9
+ return (
10
+ <li
11
+ class={`${this.todo.completed ? "completed" : ""} ${
12
+ this.editing ? "editing" : ""
13
+ }`}
14
+ >
15
+ <div class="view">
16
+ <input
17
+ class="toggle"
18
+ type="checkbox"
19
+ checked={this.todo.completed}
20
+ on:click={QRL`ui:/Todo/bundle.onInputClick`}
21
+ />
22
+
23
+ <label on:dblclick={QRL`ui:/Todo/bundle.onLabelDblClick`}>
24
+ {this.todo.text}
25
+ </label>
26
+
27
+ <button
28
+ class="destroy"
29
+ on:click={QRL`ui:/Todo/bundle.onButtonClick`}
30
+ ></button>
31
+ </div>
32
+
33
+ {this.editing ? (
34
+ <>
35
+ <input
36
+ class="edit"
37
+ value={this.todo.text}
38
+ on:blur={QRL`ui:/Todo/bundle.onInput2Blur`}
39
+ on:keyup={QRL`ui:/Todo/bundle.onInput2KeyUp`}
40
+ />
41
+ </>
42
+ ) : undefined}
43
+ </li>
44
+ );
45
+ }
46
+ );
@@ -0,0 +1,9 @@
1
+ import { Component, QRL } from "@builder.io/qwik";
2
+
3
+ export class TodosComponent extends Component<any, any> {
4
+ static $templateQRL = "ui:/Todos/template";
5
+
6
+ $newState() {
7
+ return {}; // TODO
8
+ }
9
+ }
@@ -0,0 +1,14 @@
1
+ import { injectEventHandler, provideEvent, markDirty } from "@builder.io/qwik";
2
+ import { TodosComponent } from "./component.js";
3
+
4
+ export default injectEventHandler(
5
+ TodosComponent,
6
+ provideEvent(),
7
+ async function (this: TodosComponent, event: Event) {
8
+ const newValue = !todosState.allCompleted;
9
+
10
+ for (const todoItem of todosState.todos) {
11
+ todoItem.completed = newValue;
12
+ }
13
+ }
14
+ );
@@ -0,0 +1,3 @@
1
+ import { jsxDeclareComponent, QRL } from "@builder.io/qwik";
2
+
3
+ export const Todos = jsxDeclareComponent(QRL`ui:/Todos/template`, "todos");
@@ -0,0 +1,30 @@
1
+ import { injectMethod, QRL, jsxFactory } from "@builder.io/qwik";
2
+ import { TodosComponent } from "./component.js";
3
+
4
+ import { TodosState as todosState } from "../TodosState/public.js";
5
+ import { Todo } from "../Todo/public.js";
6
+
7
+ export default injectMethod(TodosComponent, function (this: TodosComponent) {
8
+ return (
9
+ <section class="main">
10
+ {todosState.todos.length ? (
11
+ <>
12
+ <input
13
+ class="toggle-all"
14
+ type="checkbox"
15
+ checked={todosState.allCompleted}
16
+ on:click={QRL`ui:/Todos/onInputClick`}
17
+ />
18
+ </>
19
+ ) : undefined}
20
+
21
+ <ul class="todo-list">
22
+ {todosState.todos.map((todo) => (
23
+ <>
24
+ <Todo todo={todo}></Todo>
25
+ </>
26
+ ))}
27
+ </ul>
28
+ </section>
29
+ );
30
+ });
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,46 @@
1
+ import { Component, injectMethod, h, QRL } from '@builder.io/qwik';
2
+
3
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
4
+ class TodoComponent extends Component {
5
+ constructor(...args) {
6
+ super(...args);
7
+
8
+ _defineProperty(this, "editing", false);
9
+ }
10
+
11
+ toggle() {
12
+ this.todo.completed = !this.todo.completed;
13
+ }
14
+
15
+ $newState() {
16
+ return {}; // TODO
17
+ }
18
+
19
+ }
20
+
21
+ _defineProperty(TodoComponent, "$templateQRL", "ui:/Todo/bundle.template");
22
+
23
+ const template = injectMethod(TodoComponent, function () {
24
+ return h("li", {
25
+ class: `${this.todo.completed ? "completed" : ""} ${this.editing ? "editing" : ""}`
26
+ }, h("div", {
27
+ class: "view"
28
+ }, h("input", {
29
+ type: "checkbox",
30
+ class: "toggle",
31
+ checked: this.todo.completed,
32
+ "on:click": QRL`ui:/Todo/bundle.onInputClick`
33
+ }), h("label", {
34
+ "on:dblclick": QRL`ui:/Todo/bundle.onLabelDblClick`
35
+ }, this.todo.text), h("button", {
36
+ class: "destroy",
37
+ "on:click": QRL`ui:/Todo/bundle.onButtonClick`
38
+ })), this.editing ? h(null, null, h("input", {
39
+ class: "edit",
40
+ value: this.todo.text,
41
+ "on:blur": QRL`ui:/Todo/bundle.onInput2Blur`,
42
+ "on:keyup": QRL`ui:/Todo/bundle.onInput2KeyUp`
43
+ })) : undefined);
44
+ });
45
+
46
+ export { template };