create-qwik 0.0.8 → 0.0.12

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 (56) hide show
  1. package/README.md +20 -0
  2. package/create-qwik +106 -0
  3. package/index.js +2 -101
  4. package/package.json +5 -4
  5. package/starters/apps/starter/index.html +1 -0
  6. package/starters/apps/starter/package.json +7 -10
  7. package/starters/apps/starter/public/favicon.ico +0 -0
  8. package/starters/apps/starter/src/{index.server.tsx → entry.server.tsx} +4 -5
  9. package/starters/apps/starter/src/root.css +3 -0
  10. package/starters/apps/starter/src/root.tsx +62 -0
  11. package/starters/apps/starter/tsconfig.json +3 -3
  12. package/starters/apps/starter/vite.config.js +34 -0
  13. package/starters/apps/starter-builder/index.html +1 -0
  14. package/starters/apps/starter-builder/package.json +7 -10
  15. package/starters/apps/starter-builder/public/favicon.ico +0 -0
  16. package/starters/apps/starter-builder/src/{index.server.tsx → entry.server.tsx} +4 -8
  17. package/starters/apps/starter-builder/src/root.css +3 -0
  18. package/starters/apps/starter-builder/src/root.tsx +41 -0
  19. package/starters/apps/starter-builder/tsconfig.json +3 -3
  20. package/starters/apps/starter-builder/vite.config.js +34 -0
  21. package/starters/apps/starter-partytown/index.html +1 -0
  22. package/starters/apps/starter-partytown/package.json +8 -11
  23. package/starters/apps/starter-partytown/src/{index.server.tsx → entry.server.tsx} +6 -7
  24. package/starters/apps/starter-partytown/src/root.css +3 -0
  25. package/starters/apps/starter-partytown/src/{my-app.tsx → root.tsx} +12 -18
  26. package/starters/apps/starter-partytown/tsconfig.json +3 -3
  27. package/starters/apps/starter-partytown/vite.config.js +34 -0
  28. package/starters/apps/todo/index.html +1 -0
  29. package/starters/apps/todo/package.json +7 -11
  30. package/starters/apps/todo/public/favicon.ico +0 -0
  31. package/starters/apps/todo/src/{index.server.tsx → entry.server.tsx} +3 -4
  32. package/starters/apps/todo/src/root.css +3 -0
  33. package/starters/apps/todo/src/root.tsx +232 -0
  34. package/starters/apps/todo/src/state.ts +5 -7
  35. package/starters/apps/todo/tsconfig.json +2 -3
  36. package/starters/apps/todo/vite.config.js +34 -0
  37. package/starters/features/prettier/.prettierignore +29 -0
  38. package/starters/features/prettier/package.json +12 -0
  39. package/starters/features/tailwindcss/package.json +10 -0
  40. package/starters/features/tailwindcss/postcss.config.js +6 -0
  41. package/starters/features/tailwindcss/src/root.css +3 -0
  42. package/starters/features/tailwindcss/tailwind.config.js +7 -0
  43. package/starters/servers/cloudflare/package.json +7 -9
  44. package/starters/servers/cloudflare/{workers-site → server}/package.json +1 -1
  45. package/starters/servers/cloudflare/src/{index.cloudflare.tsx → entry.cloudflare.tsx} +11 -4
  46. package/starters/servers/cloudflare/wrangler.toml +2 -2
  47. package/starters/servers/express/package.json +1 -1
  48. package/starters/servers/express/server/index.js +4 -4
  49. package/starters/apps/starter/rollup.config.js +0 -37
  50. package/starters/apps/starter/src/my-app.tsx +0 -63
  51. package/starters/apps/starter-builder/rollup.config.js +0 -37
  52. package/starters/apps/starter-builder/src/my-app.tsx +0 -34
  53. package/starters/apps/starter-partytown/rollup.config.js +0 -37
  54. package/starters/apps/todo/rollup.config.js +0 -39
  55. package/starters/apps/todo/src/components.tsx +0 -225
  56. package/starters/servers/cloudflare/rollup.config.server.js +0 -29
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Write here your global css styles
3
+ */
@@ -0,0 +1,41 @@
1
+ import { component$, onRender$, withStyles$ } from '@builder.io/qwik';
2
+ import styles from './root.css';
3
+
4
+ export const Root = component$(() => {
5
+ withStyles$(styles);
6
+ return onRender$(() => (
7
+ <>
8
+ <Header />
9
+ <div id="my-content"></div>
10
+ <Footer />
11
+ </>
12
+ ));
13
+ });
14
+
15
+ export const Header = component$(() => {
16
+ return onRender$(() => (
17
+ <p style={{ 'text-align': 'center' }}>
18
+ <a href="https://github.com/builderio/qwik">
19
+ <img
20
+ alt="Qwik Logo"
21
+ width={400}
22
+ src="https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F667ab6c2283d4c4d878fb9083aacc10f"
23
+ />
24
+ </a>
25
+ </p>
26
+ ));
27
+ });
28
+
29
+ export const Footer = component$(() => {
30
+ return onRender$(() => (
31
+ <>
32
+ <hr />
33
+ <p style={{ 'text-align': 'center' }}>
34
+ Made with ❤️ by{' '}
35
+ <a target="_blank" href="https://www.builder.io/">
36
+ Builder.io
37
+ </a>
38
+ </p>
39
+ </>
40
+ ));
41
+ });
@@ -3,10 +3,10 @@
3
3
  "target": "ES2017",
4
4
  "module": "ES2020",
5
5
  "lib": ["es2020", "DOM"],
6
- "jsx": "react",
7
- "jsxFactory": "h",
8
- "jsxFragmentFactory": "Fragment",
6
+ "jsx": "react-jsx",
7
+ "jsxImportSource": "@builder.io/qwik",
9
8
  "strict": true,
9
+ "resolveJsonModule": true,
10
10
  "moduleResolution": "node",
11
11
  "esModuleInterop": true,
12
12
  "skipLibCheck": true,
@@ -0,0 +1,34 @@
1
+ import { defineConfig } from 'vite';
2
+ import { qwikRollup } from '@builder.io/qwik/optimizer';
3
+ import { writeFile, mkdir } from 'fs/promises';
4
+ import { dirname, resolve } from 'path';
5
+
6
+ export default defineConfig({
7
+ build: {
8
+ rollupOptions: {
9
+ output: {
10
+ chunkFileNames: 'q-[hash].js',
11
+ assetFileNames: 'q-[hash].[ext]',
12
+ },
13
+ },
14
+ },
15
+ ssr: {
16
+ noExternal: true,
17
+ },
18
+ plugins: [
19
+ qwikRollup({
20
+ srcDir: resolve('./src'),
21
+ entryStrategy: {
22
+ type: 'single',
23
+ },
24
+ symbolsOutput: (data) => {
25
+ outputJSON('./server/q-symbols.json', data);
26
+ },
27
+ }),
28
+ ],
29
+ });
30
+
31
+ async function outputJSON(path, data) {
32
+ await mkdir(dirname(path), { recursive: true });
33
+ await writeFile(path, JSON.stringify(data, null, 2));
34
+ }
@@ -0,0 +1 @@
1
+ <script type="module" src="/src/root.tsx"></script>
@@ -3,19 +3,16 @@
3
3
  "version": "0.0.1",
4
4
  "description": "Blank starter app with Partytown",
5
5
  "scripts": {
6
- "build": "npm run clean && rollup -c",
7
- "clean": "rimraf */build/",
8
- "start": "npm run clean && concurrently -c blue,green \"rollup -c --configDev --watch\" \"wait-on public/build && npm run serve\"",
9
- "serve": "echo \"server not setup\""
6
+ "build": "npm run build.client && npm run build.server",
7
+ "build.client": "vite build",
8
+ "build.server": "vite build --outDir server/build --ssr src/entry.server.tsx",
9
+ "start": "npm run dev",
10
+ "dev": "vite"
10
11
  },
11
12
  "devDependencies": {
12
- "@builder.io/qwik": "0.0.16-1",
13
- "@rollup/plugin-node-resolve": "^13.0.6",
14
- "concurrently": "^6.4.0",
15
- "rimraf": "^3.0.2",
16
- "rollup": "^2.59.0",
17
- "typescript": "^4.5.2",
18
- "wait-on": "^6.0.0"
13
+ "@builder.io/qwik": "0.0.16-8",
14
+ "typescript": "4.5.2",
15
+ "vite": "2.7.13"
19
16
  },
20
17
  "author": "Builder.io Team",
21
18
  "license": "MIT",
@@ -6,28 +6,27 @@
6
6
  * found in the LICENSE file at https://github.com/BuilderIO/qwik/blob/main/LICENSE
7
7
  */
8
8
 
9
- import { h } from '@builder.io/qwik';
10
9
  import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
11
- import { MyApp } from './my-app';
10
+ import { Root } from './root';
12
11
 
13
12
  /**
14
13
  * Entry point for server-side pre-rendering.
15
14
  *
16
15
  * @returns a promise when all of the rendering is completed.
17
16
  */
18
- export function renderApp(opts: RenderToStringOptions) {
17
+ export function render(opts: RenderToStringOptions) {
19
18
  return renderToString(
20
19
  <html>
21
20
  <head>
22
21
  <title>Qwik + Partytown Blank App</title>
23
- <script defer async src="~partytown/debug/partytown.js"></script>
22
+ <script defer async src="/~partytown/debug/partytown.js"></script>
24
23
  </head>
25
24
  <body q:base="/build/">
26
- <MyApp />
25
+ <Root />
27
26
  <script type="text/partytown">
28
27
  ({partyTownExampleWhichBlocksMainThreadForOneSecond.toString()})()
29
28
  </script>
30
- <QwikLoader debug={opts.debug} events={['click', 'keyup', 'expensive-computation-done']} />
29
+ <QwikLoader debug={opts.debug} events={['click', 'keyup', 'expensiveComputationDone']} />
31
30
  </body>
32
31
  </html>,
33
32
  opts
@@ -45,5 +44,5 @@ function partyTownExampleWhichBlocksMainThreadForOneSecond() {
45
44
  }
46
45
  // eslint-disable-next-line no-console
47
46
  console.log('Expensive computation ended at:', end);
48
- document.dispatchEvent(new Event('expensive-computation-done', { bubbles: true }));
47
+ document.dispatchEvent(new Event('expensiveComputationDone', { bubbles: true }));
49
48
  }
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Write here your global css styles
3
+ */
@@ -1,21 +1,15 @@
1
- import { h, qEvent } from '@builder.io/qwik';
2
- import { qComponent, qHook, useEvent } from '@builder.io/qwik';
1
+ import { component$, onRender$, useEvent, createStore, withStyles$ } from '@builder.io/qwik';
2
+ import styles from './root.css';
3
3
 
4
- export const expensiveComputationDone = qEvent('document:expensiveComputationDone');
4
+ export const Root = component$(() => {
5
+ withStyles$(styles);
5
6
 
6
- export const MyApp = qComponent<{}, { name: string; running: boolean }>({
7
- tagName: 'my-app', // optional
8
- onMount: qHook(() => ({ name: 'World', running: true })),
9
- onRender: qHook((props, state) => {
7
+ const state = createStore({ name: 'World', running: true });
8
+ return onRender$(() => {
10
9
  // eslint-disable-next-line no-console
11
10
  console.log('Qwik: MyApp component is rendering...');
12
11
  return (
13
- <div
14
- id="my-app"
15
- {...expensiveComputationDone(
16
- qHook<typeof MyApp>((props, state) => (state.running = false))
17
- )}
18
- >
12
+ <div id="my-app" on$:expensiveComputationDone={() => (state.running = false)}>
19
13
  <p style={{ 'text-align': 'center' }}>
20
14
  <a href="https://github.com/builderio/qwik">
21
15
  <img
@@ -25,7 +19,7 @@ export const MyApp = qComponent<{}, { name: string; running: boolean }>({
25
19
  />
26
20
  </a>
27
21
  </p>
28
- <p>
22
+ <p class="congrats">
29
23
  Congratulations <a href="https://github.com/builderio/qwik">Qwik</a> with{' '}
30
24
  <a href="https://github.com/BuilderIO/partytown">Partytown</a> is working!
31
25
  </p>
@@ -60,7 +54,7 @@ export const MyApp = qComponent<{}, { name: string; running: boolean }>({
60
54
  </li>
61
55
  <li>
62
56
  Once the expensive operation is finished it dispatches custom event (
63
- <code>expensivecomputationdone</code>) that this component listens on. It is only at
57
+ <code>expensiveComputationDone</code>) that this component listens on. It is only at
64
58
  that time that Qwik lazy-loads the component render function and updates the UI. (See
65
59
  network tab.)
66
60
  </li>
@@ -68,11 +62,11 @@ export const MyApp = qComponent<{}, { name: string; running: boolean }>({
68
62
  Try interacting with this component by changing{' '}
69
63
  <input
70
64
  value={state.name}
71
- on:keyup={qHook<typeof MyApp>((props, state) => {
65
+ on$:keyup={() => {
72
66
  const event = useEvent<KeyboardEvent>();
73
67
  const input = event.target as HTMLInputElement;
74
68
  state.name = input.value;
75
- })}
69
+ }}
76
70
  ></input>
77
71
  .
78
72
  </li>
@@ -99,5 +93,5 @@ export const MyApp = qComponent<{}, { name: string; running: boolean }>({
99
93
  </p>
100
94
  </div>
101
95
  );
102
- }),
96
+ });
103
97
  });
@@ -3,10 +3,10 @@
3
3
  "target": "ES2017",
4
4
  "module": "ES2020",
5
5
  "lib": ["es2020", "DOM"],
6
- "jsx": "react",
7
- "jsxFactory": "h",
8
- "jsxFragmentFactory": "Fragment",
6
+ "jsx": "react-jsx",
7
+ "jsxImportSource": "@builder.io/qwik",
9
8
  "strict": true,
9
+ "resolveJsonModule": true,
10
10
  "moduleResolution": "node",
11
11
  "esModuleInterop": true,
12
12
  "skipLibCheck": true,
@@ -0,0 +1,34 @@
1
+ import { defineConfig } from 'vite';
2
+ import { qwikRollup } from '@builder.io/qwik/optimizer';
3
+ import { writeFile, mkdir } from 'fs/promises';
4
+ import { dirname, resolve } from 'path';
5
+
6
+ export default defineConfig({
7
+ build: {
8
+ rollupOptions: {
9
+ output: {
10
+ chunkFileNames: 'q-[hash].js',
11
+ assetFileNames: 'q-[hash].[ext]',
12
+ },
13
+ },
14
+ },
15
+ ssr: {
16
+ noExternal: true,
17
+ },
18
+ plugins: [
19
+ qwikRollup({
20
+ srcDir: resolve('./src'),
21
+ entryStrategy: {
22
+ type: 'single',
23
+ },
24
+ symbolsOutput: (data) => {
25
+ outputJSON('./server/q-symbols.json', data);
26
+ },
27
+ }),
28
+ ],
29
+ });
30
+
31
+ async function outputJSON(path, data) {
32
+ await mkdir(dirname(path), { recursive: true });
33
+ await writeFile(path, JSON.stringify(data, null, 2));
34
+ }
@@ -0,0 +1 @@
1
+ <script type="module" src="/src/root.tsx"></script>
@@ -3,20 +3,16 @@
3
3
  "version": "0.0.1",
4
4
  "description": "Classic Todo MVC app",
5
5
  "scripts": {
6
- "build": "npm run clean && rollup -c",
7
- "clean": "rimraf */build/",
8
- "serve": "echo 'missing server'",
9
- "start": "npm run clean && concurrently -c blue,green \"rollup -c --configDev --watch\" \"wait-on public/build && npm run serve\""
6
+ "build": "npm run build.client && npm run build.server",
7
+ "build.client": "vite build",
8
+ "build.server": "vite build --outDir server/build --ssr src/entry.server.tsx",
9
+ "start": "npm run dev",
10
+ "dev": "vite"
10
11
  },
11
12
  "devDependencies": {
12
- "@builder.io/qwik": "0.0.16-1",
13
- "@rollup/plugin-node-resolve": "^13.0.6",
14
- "concurrently": "^6.4.0",
15
- "rimraf": "^3.0.2",
16
- "rollup": "^2.59.0",
17
- "rollup-plugin-terser": "^7.0.2",
13
+ "@builder.io/qwik": "0.0.16-8",
18
14
  "typescript": "^4.5.2",
19
- "wait-on": "^6.0.0"
15
+ "vite": "2.7.13"
20
16
  },
21
17
  "author": "Builder.io Team",
22
18
  "license": "MIT",
@@ -6,9 +6,8 @@
6
6
  * found in the LICENSE file at https://github.com/BuilderIO/qwik/blob/main/LICENSE
7
7
  */
8
8
 
9
- import { h } from '@builder.io/qwik';
10
9
  import { renderToString, RenderToStringOptions, QwikLoader } from '@builder.io/qwik/server';
11
- import { ToDoApp } from './components';
10
+ import { Root } from './root';
12
11
  import type { Todos } from './state';
13
12
 
14
13
  /**
@@ -16,7 +15,7 @@ import type { Todos } from './state';
16
15
  *
17
16
  * @returns a promise when all of the rendering is completed.
18
17
  */
19
- export function renderApp(opts: RenderToStringOptions) {
18
+ export function render(opts: RenderToStringOptions) {
20
19
  const todos: Todos = {
21
20
  filter: 'all',
22
21
  items: [
@@ -34,7 +33,7 @@ export function renderApp(opts: RenderToStringOptions) {
34
33
  <link rel="stylesheet" href="/index.css" />
35
34
  </head>
36
35
  <body q:base="/build/">
37
- <ToDoApp todos={todos} />
36
+ <Root todos={todos} />
38
37
  <QwikLoader debug={opts.debug} />
39
38
  </body>
40
39
  </html>,
@@ -0,0 +1,3 @@
1
+ /**
2
+ * Write here your global css styles
3
+ */
@@ -0,0 +1,232 @@
1
+ import {
2
+ Host,
3
+ component,
4
+ onRender$,
5
+ createStore,
6
+ useHostElement,
7
+ useEvent,
8
+ notifyRender,
9
+ $,
10
+ withStyles$,
11
+ } from '@builder.io/qwik';
12
+ import {
13
+ addItem,
14
+ clearCompleted,
15
+ FilterStates,
16
+ getFilteredCount,
17
+ getFilteredItems,
18
+ removeItem,
19
+ TodoItem,
20
+ Todos,
21
+ toggleItem,
22
+ updateFilter,
23
+ } from './state';
24
+
25
+ import styles from './root.css';
26
+
27
+ /* eslint no-console: ["off"] */
28
+
29
+ // TODO(misko): APIs for better debugger experience: getProps
30
+ // TODO(misko): APIs for better debugger experience: dehydrate
31
+ // TODO(misko): APIs to have a global way of notifying which events are being fired, so we can console out render events in the demo applications
32
+ // TODO(misko): Place breakpoint in DOM modification and notice that too many writes are happening.
33
+ // TODO(misko): <item> renders twice on toggle. 1) Due to state change, 2) due to <main> somehow triggering render.
34
+
35
+ ////////////////////////////////////////////////////////////////////////////////////////
36
+ ////////////////////////////////////////////////////////////////////////////////////////
37
+ ////////////////////////////////////////////////////////////////////////////////////////
38
+ ////////////////////////////////////////////////////////////////////////////////////////
39
+
40
+ /**
41
+ * Overall application component.
42
+ *
43
+ * This component is static (meaning it will never change). Because of this
44
+ * Qwik knows that it should never need to be rerendered, and its code will never
45
+ * download to the client.
46
+ */
47
+ export const Root = component(
48
+ 'todo',
49
+ $((props: { todos: Todos }) => {
50
+ withStyles$(styles);
51
+ return onRender$(() => {
52
+ console.log('on:qRender => <ToDoApp/>');
53
+ return (
54
+ <section class="todoapp">
55
+ <Header todos={props.todos} />
56
+ <Main todos={props.todos} />
57
+ <Footer todos={props.todos} />
58
+ </section>
59
+ );
60
+ });
61
+ })
62
+ );
63
+
64
+ /**
65
+ * Header component which is responsible for providing UI to ender new todo item.
66
+ *
67
+ * This component only rerenders if the user interacts with it through the input.
68
+ */
69
+ export const Header = component(
70
+ 'header',
71
+ $((props: { todos: Todos }) => {
72
+ const state = createStore({ text: '' });
73
+ return onRender$(() => {
74
+ console.log('on:qRender => <Header/>');
75
+ return (
76
+ <>
77
+ <h1>todos</h1>
78
+ <input
79
+ class="new-todo"
80
+ placeholder="What needs to be done?"
81
+ autoFocus
82
+ value={state.text}
83
+ on$:keyup={() => {
84
+ const event = useEvent<KeyboardEvent>();
85
+ const inputValue = (event.target as HTMLInputElement).value;
86
+ state.text = inputValue;
87
+ if (event.key === 'Enter' && inputValue) {
88
+ addItem(props.todos, state.text);
89
+ state.text = '';
90
+ }
91
+ }}
92
+ />
93
+ </>
94
+ );
95
+ });
96
+ })
97
+ );
98
+
99
+ /**
100
+ * Main body of the application which contains the list of todo items.
101
+ *
102
+ * This component only rerenders/hydrates/downloads if the list of todos changes.
103
+ */
104
+ export const Main = component(
105
+ 'main',
106
+ $((props: { todos: Todos }) => {
107
+ return onRender$(() => {
108
+ console.log('on:qRender => <Main/>');
109
+ return (
110
+ <Host class="main">
111
+ <ul class="todo-list">
112
+ {getFilteredItems(props.todos).map((key) => (
113
+ <Item item={key} todos={props.todos} />
114
+ ))}
115
+ </ul>
116
+ </Host>
117
+ );
118
+ });
119
+ })
120
+ );
121
+
122
+ /**
123
+ * Individual items of the component.
124
+ *
125
+ * It only rerenders if the user infarcts with it or if the item itself changes.
126
+ */
127
+ export const Item = component(
128
+ 'li',
129
+ $((props: { item: TodoItem; todos: Todos }) => {
130
+ const state = createStore({ editing: false });
131
+ return onRender$(() => {
132
+ console.log(
133
+ 'on:qRender => <Item item="' +
134
+ JSON.stringify(props.item, (key, value) => (key.startsWith('__') ? undefined : value)) +
135
+ '"/>'
136
+ );
137
+ return (
138
+ <Host class={{ completed: props.item.completed, editing: state.editing }}>
139
+ <div class="view">
140
+ <input
141
+ class="toggle"
142
+ type="checkbox"
143
+ checked={props.item.completed}
144
+ on$:click={() => toggleItem(props.todos, props.item)}
145
+ />
146
+ <label
147
+ on$:dblclick={async () => {
148
+ state.editing = true;
149
+ const hostElement = useHostElement()!;
150
+ await notifyRender(hostElement);
151
+ const inputEl = hostElement.querySelector('input.edit') as HTMLInputElement;
152
+ inputEl.focus();
153
+ inputEl.selectionStart = inputEl.selectionEnd = inputEl.value.length;
154
+ }}
155
+ >
156
+ {props.item.title}
157
+ </label>
158
+ <button class="destroy" on$:click={() => removeItem(props.todos, props.item)}></button>
159
+ </div>
160
+ {state.editing ? (
161
+ <input
162
+ class="edit"
163
+ value={props.item.title}
164
+ on$:blur={() => (state.editing = false)}
165
+ on$:keyup={() => {
166
+ const event = useEvent<KeyboardEvent>();
167
+ const inputValue = (event.target as HTMLInputElement).value;
168
+ props.item.title = inputValue;
169
+ if (event.key === 'Enter') {
170
+ state.editing = false;
171
+ }
172
+ }}
173
+ />
174
+ ) : null}
175
+ </Host>
176
+ );
177
+ });
178
+ })
179
+ );
180
+
181
+ /**
182
+ * Footer showing items remaining and filtering options
183
+ *
184
+ * It only rerenders if the todos count changes or filters are reset.
185
+ */
186
+ export const Footer = component(
187
+ 'footer',
188
+ $((props: { todos: Todos }) => {
189
+ return onRender$(() => {
190
+ console.log('on:qRender => <Footer/>');
191
+ /**
192
+ * Example of lite-component (it will always be included with the parent component)
193
+ */
194
+ function Filter({ filter }: { filter: FilterStates }) {
195
+ const lMode = filter.toLowerCase();
196
+ return (
197
+ <li>
198
+ <a
199
+ class={{ selected: props.todos.filter == lMode }}
200
+ on$:click={() => updateFilter(props.todos, filter)}
201
+ >
202
+ {filter[0].toUpperCase() + filter.substr(1)}
203
+ </a>
204
+ </li>
205
+ );
206
+ }
207
+ const remaining = getFilteredCount(props.todos);
208
+ return (
209
+ <Host class="footer">
210
+ {props.todos.items.length > 0 ? (
211
+ <>
212
+ <span class="todo-count">
213
+ <strong>{remaining}</strong>
214
+ {remaining == 1 ? ' item' : ' items'} left
215
+ </span>
216
+ <ul class="filters">
217
+ {FilterStates.map((f) => (
218
+ <Filter filter={f} />
219
+ ))}
220
+ </ul>
221
+ {remaining > 0 ? (
222
+ <button class="clear-completed" on$:click={() => clearCompleted(props.todos)}>
223
+ Clear completed
224
+ </button>
225
+ ) : null}
226
+ </>
227
+ ) : null}
228
+ </Host>
229
+ );
230
+ });
231
+ })
232
+ );
@@ -1,5 +1,3 @@
1
- import { qObject } from '@builder.io/qwik';
2
-
3
1
  ////////////////////////////////////////////////////////////////////////
4
2
  // Todo Application State Interfaces
5
3
  ////////////////////////////////////////////////////////////////////////
@@ -19,16 +17,16 @@ export interface Todos {
19
17
  ////////////////////////////////////////////////////////////////////////
20
18
 
21
19
  export function addItem(todos: Todos, text: string) {
22
- todos.items.push(qObject({ completed: false, title: text }));
20
+ todos.items.push({ completed: false, title: text });
23
21
  updateFilter(todos);
24
22
  }
25
23
 
26
- export function removeItem(todos: Todos, TodoItem: TodoItem) {
27
- todos.items = todos.items.filter((i) => i != TodoItem);
24
+ export function removeItem(todos: Todos, todoItem: TodoItem) {
25
+ todos.items = todos.items.filter((i) => i != todoItem);
28
26
  updateFilter(todos);
29
27
  }
30
- export function toggleItem(todos: Todos, TodoItem: TodoItem) {
31
- TodoItem.completed = !TodoItem.completed;
28
+ export function toggleItem(todos: Todos, todoItem: TodoItem) {
29
+ todoItem.completed = !todoItem.completed;
32
30
  updateFilter(todos);
33
31
  }
34
32
 
@@ -3,9 +3,8 @@
3
3
  "target": "ES2017",
4
4
  "module": "ES2020",
5
5
  "lib": ["es2020", "DOM"],
6
- "jsx": "react",
7
- "jsxFactory": "h",
8
- "jsxFragmentFactory": "Fragment",
6
+ "jsx": "react-jsx",
7
+ "jsxImportSource": "@builder.io/qwik",
9
8
  "strict": true,
10
9
  "resolveJsonModule": true,
11
10
  "moduleResolution": "node",