jac-client 0.2.2__py3-none-any.whl → 0.2.6__py3-none-any.whl
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.
- jac_client/examples/all-in-one/assets/workers/worker.py +5 -0
- jac_client/examples/all-in-one/src/app.jac +841 -0
- jac_client/examples/all-in-one/{button.jac → src/button.jac} +1 -1
- jac_client/examples/all-in-one/{components → src/components}/button.jac +1 -1
- jac_client/examples/asset-serving/css-with-image/{app.jac → src/app.jac} +2 -2
- jac_client/examples/asset-serving/image-asset/{app.jac → src/app.jac} +2 -2
- jac_client/examples/asset-serving/import-alias/{app.jac → src/app.jac} +7 -7
- jac_client/examples/basic/{app.jac → src/app.jac} +2 -2
- jac_client/examples/basic-auth/src/app.jac +377 -0
- jac_client/examples/basic-auth-with-router/{app.jac → src/app.jac} +18 -18
- jac_client/examples/basic-full-stack/{app.jac → src/app.jac} +175 -130
- jac_client/examples/css-styling/js-styling/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/material-ui/{app.jac → src/app.jac} +5 -5
- jac_client/examples/css-styling/pure-css/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/sass-example/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/styled-components/{app.jac → src/app.jac} +5 -5
- jac_client/examples/css-styling/tailwind-example/{app.jac → src/app.jac} +6 -6
- jac_client/examples/full-stack-with-auth/{app.jac → src/app.jac} +37 -37
- jac_client/examples/little-x/{app.jac → src/app.jac} +27 -32
- jac_client/examples/little-x/src/submit-button.jac +16 -0
- jac_client/examples/nested-folders/nested-advance/{ButtonRoot.jac → src/ButtonRoot.jac} +1 -1
- jac_client/examples/nested-folders/nested-advance/{app.jac → src/app.jac} +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/ButtonSecondL.jac +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/Card.jac +1 -1
- jac_client/examples/nested-folders/nested-advance/{level1 → src/level1}/level2/ButtonThirdL.jac +1 -1
- jac_client/examples/nested-folders/nested-basic/{app.jac → src/app.jac} +2 -2
- jac_client/examples/nested-folders/nested-basic/{button.jac → src/button.jac} +1 -1
- jac_client/examples/nested-folders/nested-basic/{components → src/components}/button.jac +1 -1
- jac_client/examples/ts-support/src/app.jac +35 -0
- jac_client/examples/with-router/{app.jac → src/app.jac} +11 -11
- jac_client/plugin/cli.jac +547 -0
- jac_client/plugin/client.jac +52 -0
- jac_client/plugin/client_runtime.cl.jac +38 -0
- jac_client/plugin/impl/client.impl.jac +134 -0
- jac_client/plugin/impl/client_runtime.impl.jac +177 -0
- jac_client/plugin/impl/vite_client_bundle.impl.jac +72 -0
- jac_client/plugin/plugin_config.jac +195 -0
- jac_client/plugin/src/__init__.jac +20 -0
- jac_client/plugin/src/asset_processor.jac +33 -0
- jac_client/plugin/src/babel_processor.jac +18 -0
- jac_client/plugin/src/compiler.jac +66 -0
- jac_client/plugin/src/config_loader.jac +32 -0
- jac_client/plugin/src/impl/asset_processor.impl.jac +127 -0
- jac_client/plugin/src/impl/babel_processor.impl.jac +84 -0
- jac_client/plugin/src/impl/compiler.impl.jac +251 -0
- jac_client/plugin/src/impl/config_loader.impl.jac +119 -0
- jac_client/plugin/src/impl/import_processor.impl.jac +33 -0
- jac_client/plugin/src/impl/jac_to_js.impl.jac +41 -0
- jac_client/plugin/src/impl/package_installer.impl.jac +105 -0
- jac_client/plugin/src/impl/vite_bundler.impl.jac +513 -0
- jac_client/plugin/src/import_processor.jac +19 -0
- jac_client/plugin/src/jac_to_js.jac +35 -0
- jac_client/plugin/src/package_installer.jac +26 -0
- jac_client/plugin/src/vite_bundler.jac +36 -0
- jac_client/plugin/vite_client_bundle.jac +31 -0
- jac_client/tests/conftest.py +281 -0
- jac_client/tests/fixtures/basic-app/app.jac +2 -2
- jac_client/tests/fixtures/cl_file/app.cl.jac +2 -2
- jac_client/tests/fixtures/client_app_with_antd/app.jac +1 -1
- jac_client/tests/fixtures/js_import/app.jac +5 -5
- jac_client/tests/fixtures/spawn_test/app.jac +7 -7
- jac_client/tests/fixtures/with-ts/app.jac +35 -0
- jac_client/tests/test_cli.py +755 -0
- jac_client/tests/test_it.py +347 -67
- {jac_client-0.2.2.dist-info → jac_client-0.2.6.dist-info}/METADATA +30 -24
- jac_client-0.2.6.dist-info/RECORD +74 -0
- {jac_client-0.2.2.dist-info → jac_client-0.2.6.dist-info}/WHEEL +2 -1
- jac_client-0.2.6.dist-info/entry_points.txt +4 -0
- jac_client-0.2.6.dist-info/top_level.txt +1 -0
- jac_client/docs/README.md +0 -689
- jac_client/docs/advanced-state.md +0 -1265
- jac_client/docs/asset-serving/intro.md +0 -209
- jac_client/docs/assets/pipe_line-v2.svg +0 -32
- jac_client/docs/assets/pipe_line.png +0 -0
- jac_client/docs/file-system/app.jac.md +0 -121
- jac_client/docs/file-system/backend-frontend.md +0 -217
- jac_client/docs/file-system/intro.md +0 -72
- jac_client/docs/file-system/nested-imports.md +0 -348
- jac_client/docs/guide-example/intro.md +0 -115
- jac_client/docs/guide-example/step-01-setup.md +0 -270
- jac_client/docs/guide-example/step-02-components.md +0 -416
- jac_client/docs/guide-example/step-03-styling.md +0 -478
- jac_client/docs/guide-example/step-04-todo-ui.md +0 -477
- jac_client/docs/guide-example/step-05-local-state.md +0 -530
- jac_client/docs/guide-example/step-06-events.md +0 -749
- jac_client/docs/guide-example/step-07-effects.md +0 -468
- jac_client/docs/guide-example/step-08-walkers.md +0 -534
- jac_client/docs/guide-example/step-09-authentication.md +0 -586
- jac_client/docs/guide-example/step-10-routing.md +0 -539
- jac_client/docs/guide-example/step-11-final.md +0 -963
- jac_client/docs/imports.md +0 -1141
- jac_client/docs/lifecycle-hooks.md +0 -773
- jac_client/docs/routing.md +0 -659
- jac_client/docs/styling/intro.md +0 -249
- jac_client/docs/styling/js-styling.md +0 -367
- jac_client/docs/styling/material-ui.md +0 -341
- jac_client/docs/styling/pure-css.md +0 -299
- jac_client/docs/styling/sass.md +0 -403
- jac_client/docs/styling/styled-components.md +0 -395
- jac_client/docs/styling/tailwind.md +0 -298
- jac_client/examples/all-in-one/.babelrc +0 -9
- jac_client/examples/all-in-one/README.md +0 -16
- jac_client/examples/all-in-one/app.jac +0 -426
- jac_client/examples/all-in-one/assets/burger.png +0 -0
- jac_client/examples/all-in-one/package.json +0 -29
- jac_client/examples/all-in-one/styles.css +0 -26
- jac_client/examples/all-in-one/vite.config.js +0 -28
- jac_client/examples/asset-serving/css-with-image/.babelrc +0 -9
- jac_client/examples/asset-serving/css-with-image/README.md +0 -91
- jac_client/examples/asset-serving/css-with-image/assets/burger.png +0 -0
- jac_client/examples/asset-serving/css-with-image/package.json +0 -28
- jac_client/examples/asset-serving/css-with-image/styles.css +0 -26
- jac_client/examples/asset-serving/css-with-image/vite.config.js +0 -28
- jac_client/examples/asset-serving/image-asset/.babelrc +0 -9
- jac_client/examples/asset-serving/image-asset/README.md +0 -119
- jac_client/examples/asset-serving/image-asset/assets/burger.png +0 -0
- jac_client/examples/asset-serving/image-asset/package.json +0 -28
- jac_client/examples/asset-serving/image-asset/styles.css +0 -26
- jac_client/examples/asset-serving/image-asset/vite.config.js +0 -28
- jac_client/examples/asset-serving/import-alias/.babelrc +0 -9
- jac_client/examples/asset-serving/import-alias/README.md +0 -83
- jac_client/examples/asset-serving/import-alias/assets/burger.png +0 -0
- jac_client/examples/asset-serving/import-alias/package.json +0 -28
- jac_client/examples/asset-serving/import-alias/vite.config.js +0 -28
- jac_client/examples/basic/.babelrc +0 -9
- jac_client/examples/basic/README.md +0 -16
- jac_client/examples/basic/package.json +0 -27
- jac_client/examples/basic/vite.config.js +0 -27
- jac_client/examples/basic-auth/.babelrc +0 -9
- jac_client/examples/basic-auth/README.md +0 -16
- jac_client/examples/basic-auth/app.jac +0 -308
- jac_client/examples/basic-auth/package.json +0 -27
- jac_client/examples/basic-auth/vite.config.js +0 -27
- jac_client/examples/basic-auth-with-router/.babelrc +0 -9
- jac_client/examples/basic-auth-with-router/README.md +0 -60
- jac_client/examples/basic-auth-with-router/package.json +0 -28
- jac_client/examples/basic-auth-with-router/vite.config.js +0 -27
- jac_client/examples/basic-full-stack/.babelrc +0 -9
- jac_client/examples/basic-full-stack/README.md +0 -18
- jac_client/examples/basic-full-stack/package.json +0 -28
- jac_client/examples/basic-full-stack/vite.config.js +0 -27
- jac_client/examples/css-styling/js-styling/.babelrc +0 -9
- jac_client/examples/css-styling/js-styling/README.md +0 -183
- jac_client/examples/css-styling/js-styling/package.json +0 -28
- jac_client/examples/css-styling/js-styling/styles.js +0 -100
- jac_client/examples/css-styling/js-styling/vite.config.js +0 -27
- jac_client/examples/css-styling/material-ui/.babelrc +0 -9
- jac_client/examples/css-styling/material-ui/README.md +0 -16
- jac_client/examples/css-styling/material-ui/package.json +0 -32
- jac_client/examples/css-styling/material-ui/vite.config.js +0 -27
- jac_client/examples/css-styling/pure-css/.babelrc +0 -9
- jac_client/examples/css-styling/pure-css/README.md +0 -16
- jac_client/examples/css-styling/pure-css/package.json +0 -28
- jac_client/examples/css-styling/pure-css/styles.css +0 -111
- jac_client/examples/css-styling/pure-css/vite.config.js +0 -27
- jac_client/examples/css-styling/sass-example/.babelrc +0 -9
- jac_client/examples/css-styling/sass-example/README.md +0 -16
- jac_client/examples/css-styling/sass-example/package.json +0 -29
- jac_client/examples/css-styling/sass-example/styles.scss +0 -153
- jac_client/examples/css-styling/sass-example/vite.config.js +0 -27
- jac_client/examples/css-styling/styled-components/.babelrc +0 -9
- jac_client/examples/css-styling/styled-components/README.md +0 -16
- jac_client/examples/css-styling/styled-components/package.json +0 -29
- jac_client/examples/css-styling/styled-components/styled.js +0 -90
- jac_client/examples/css-styling/styled-components/vite.config.js +0 -27
- jac_client/examples/css-styling/tailwind-example/.babelrc +0 -9
- jac_client/examples/css-styling/tailwind-example/README.md +0 -16
- jac_client/examples/css-styling/tailwind-example/global.css +0 -1
- jac_client/examples/css-styling/tailwind-example/package.json +0 -30
- jac_client/examples/css-styling/tailwind-example/vite.config.js +0 -29
- jac_client/examples/full-stack-with-auth/.babelrc +0 -9
- jac_client/examples/full-stack-with-auth/README.md +0 -16
- jac_client/examples/full-stack-with-auth/package.json +0 -28
- jac_client/examples/full-stack-with-auth/vite.config.js +0 -29
- jac_client/examples/little-x/package.json +0 -23
- jac_client/examples/little-x/submit-button.jac +0 -8
- jac_client/examples/nested-folders/nested-advance/.babelrc +0 -9
- jac_client/examples/nested-folders/nested-advance/README.md +0 -77
- jac_client/examples/nested-folders/nested-advance/package.json +0 -29
- jac_client/examples/nested-folders/nested-advance/vite.config.js +0 -28
- jac_client/examples/nested-folders/nested-basic/.babelrc +0 -9
- jac_client/examples/nested-folders/nested-basic/README.md +0 -183
- jac_client/examples/nested-folders/nested-basic/app.js +0 -7
- jac_client/examples/nested-folders/nested-basic/package.json +0 -28
- jac_client/examples/nested-folders/nested-basic/vite.config.js +0 -27
- jac_client/examples/with-router/.babelrc +0 -9
- jac_client/examples/with-router/README.md +0 -17
- jac_client/examples/with-router/package.json +0 -28
- jac_client/examples/with-router/vite.config.js +0 -27
- jac_client/plugin/cli.py +0 -244
- jac_client/plugin/client.py +0 -152
- jac_client/plugin/client_runtime.jac +0 -234
- jac_client/plugin/vite_client_bundle.py +0 -503
- jac_client/tests/fixtures/js_import/utils.js +0 -21
- jac_client/tests/fixtures/package-lock.json +0 -329
- jac_client/tests/fixtures/package.json +0 -11
- jac_client/tests/test_asset_examples.py +0 -322
- jac_client/tests/test_cl.py +0 -530
- jac_client/tests/test_create_jac_app.py +0 -131
- jac_client/tests/test_nested_file.py +0 -374
- jac_client-0.2.2.dist-info/RECORD +0 -171
- jac_client-0.2.2.dist-info/entry_points.txt +0 -4
|
@@ -1,55 +1,57 @@
|
|
|
1
1
|
# Todo App
|
|
2
|
-
cl import from react {useState, useEffect}
|
|
2
|
+
cl import from react { useState, useEffect }
|
|
3
3
|
|
|
4
4
|
node Todo {
|
|
5
|
-
has text: str
|
|
6
|
-
|
|
5
|
+
has text: str,
|
|
6
|
+
done: bool = False;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
walker create_todo {
|
|
10
|
-
has text:str;
|
|
10
|
+
has text: str;
|
|
11
|
+
|
|
11
12
|
can create with `root entry {
|
|
12
|
-
new_todo = here ++> Todo(text=
|
|
13
|
-
report new_todo;
|
|
13
|
+
new_todo = here ++> Todo(text=self.text);
|
|
14
|
+
report new_todo ;
|
|
14
15
|
}
|
|
15
16
|
}
|
|
17
|
+
|
|
16
18
|
walker toggle_todo {
|
|
17
19
|
can toggle with Todo entry {
|
|
18
20
|
here.done = not here.done;
|
|
19
|
-
report here;
|
|
21
|
+
report here ;
|
|
20
22
|
}
|
|
21
23
|
}
|
|
24
|
+
|
|
22
25
|
walker read_todos {
|
|
23
26
|
can read with `root entry {
|
|
24
27
|
visit [-->(`?Todo)];
|
|
25
28
|
}
|
|
29
|
+
|
|
26
30
|
can report_todos with exit {
|
|
27
|
-
report here;
|
|
31
|
+
report here ;
|
|
28
32
|
}
|
|
29
33
|
}
|
|
30
34
|
|
|
31
35
|
cl {
|
|
32
|
-
def app
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
+
def:pub app -> any {
|
|
37
|
+
[todos, setTodos] = useState([]);
|
|
38
|
+
[inputValue, setInputValue] = useState("");
|
|
39
|
+
[filter, setFilter] = useState("all");
|
|
36
40
|
|
|
37
|
-
useEffect(
|
|
38
|
-
async def loadTodos
|
|
41
|
+
useEffect(
|
|
42
|
+
lambda -> None{ async def loadTodos -> None {
|
|
39
43
|
todos = root spawn read_todos();
|
|
40
44
|
setTodos(todos.reports);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
} loadTodos();} ,
|
|
46
|
+
[]
|
|
47
|
+
);
|
|
44
48
|
|
|
45
49
|
# Add a new todo
|
|
46
|
-
async def addTodo
|
|
47
|
-
if not inputValue.trim() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
"done": False
|
|
52
|
-
};
|
|
50
|
+
async def addTodo -> None {
|
|
51
|
+
if not inputValue.trim() {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
newTodo = {"id": Date.now(), "text": inputValue.trim(), "done": False};
|
|
53
55
|
response = root spawn create_todo(text=inputValue.trim());
|
|
54
56
|
newTodos = todos.concat([response.reports[0][0]]);
|
|
55
57
|
setTodos(newTodos);
|
|
@@ -60,79 +62,94 @@ cl {
|
|
|
60
62
|
async def toggleTodo(id: any) -> None {
|
|
61
63
|
console.log("toggleTodo", id);
|
|
62
64
|
id spawn toggle_todo();
|
|
63
|
-
setTodos(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
65
|
+
setTodos(
|
|
66
|
+
todos.map(
|
|
67
|
+
lambda todo: any -> any{ if todo._jac_id == id {
|
|
68
|
+
updatedTodo = {
|
|
69
|
+
"_jac_id": todo._jac_id,
|
|
70
|
+
"text": todo.text,
|
|
71
|
+
"done": not todo.done,
|
|
72
|
+
"id": todo.id
|
|
73
|
+
};
|
|
74
|
+
return updatedTodo;
|
|
75
|
+
}return todo; }
|
|
76
|
+
)
|
|
77
|
+
);
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
# Delete a todo
|
|
78
81
|
def deleteTodo(id: any) -> None {
|
|
79
|
-
setTodos(
|
|
82
|
+
setTodos(
|
|
83
|
+
todos.filter(lambda todo: any -> bool{ return todo.id != id; } )
|
|
84
|
+
);
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
# Clear all completed todos
|
|
83
|
-
def clearCompleted
|
|
84
|
-
setTodos(
|
|
88
|
+
def clearCompleted -> None {
|
|
89
|
+
setTodos(
|
|
90
|
+
todos.filter(lambda todo: any -> bool{ return not todo.done; } )
|
|
91
|
+
);
|
|
85
92
|
}
|
|
86
93
|
|
|
87
94
|
# Filter todos based on current filter
|
|
88
|
-
def getFilteredTodos
|
|
95
|
+
def getFilteredTodos -> list {
|
|
89
96
|
if filter == "active" {
|
|
90
|
-
return todos.filter(
|
|
97
|
+
return todos.filter(
|
|
98
|
+
lambda todo: any -> bool{ return not todo.done; }
|
|
99
|
+
);
|
|
91
100
|
} elif filter == "completed" {
|
|
92
|
-
return todos.filter(lambda
|
|
101
|
+
return todos.filter(lambda todo: any -> bool{ return todo.done; } );
|
|
93
102
|
}
|
|
94
103
|
return todos;
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
# Count active todos
|
|
98
|
-
activeCount = todos.filter(
|
|
107
|
+
activeCount = todos.filter(
|
|
108
|
+
lambda todo: any -> bool{ return not todo.done; }
|
|
109
|
+
).length;
|
|
99
110
|
|
|
100
111
|
filteredTodos = getFilteredTodos();
|
|
101
112
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
113
|
+
return <div
|
|
114
|
+
style={{
|
|
115
|
+
"maxWidth": "600px",
|
|
116
|
+
"margin": "40px auto",
|
|
117
|
+
"padding": "24px",
|
|
118
|
+
"fontFamily": "system-ui, -apple-system, sans-serif",
|
|
119
|
+
"background": "#f9fafb",
|
|
120
|
+
"minHeight": "100vh"
|
|
121
|
+
}}
|
|
122
|
+
>
|
|
123
|
+
<h1
|
|
124
|
+
style={{
|
|
125
|
+
"textAlign": "center",
|
|
126
|
+
"color": "#1f2937",
|
|
127
|
+
"marginBottom": "32px",
|
|
128
|
+
"fontSize": "2.5rem",
|
|
129
|
+
"fontWeight": "700"
|
|
130
|
+
}}
|
|
131
|
+
>
|
|
132
|
+
📝 My Todo App
|
|
133
|
+
</h1>
|
|
119
134
|
# Add todo form
|
|
120
|
-
<div
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
135
|
+
<div
|
|
136
|
+
style={{
|
|
137
|
+
"display": "flex",
|
|
138
|
+
"gap": "8px",
|
|
139
|
+
"marginBottom": "24px",
|
|
140
|
+
"background": "#ffffff",
|
|
141
|
+
"padding": "16px",
|
|
142
|
+
"borderRadius": "12px",
|
|
143
|
+
"boxShadow": "0 1px 3px rgba(0,0,0,0.1)"
|
|
144
|
+
}}
|
|
145
|
+
>
|
|
129
146
|
<input
|
|
130
147
|
type="text"
|
|
131
148
|
value={inputValue}
|
|
132
|
-
onChange={lambda
|
|
133
|
-
onKeyPress={lambda
|
|
134
|
-
|
|
135
|
-
}}
|
|
149
|
+
onChange={lambda e: any -> None{ setInputValue(e.target.value);} }
|
|
150
|
+
onKeyPress={lambda e: any -> None{ if e.key == "Enter" {
|
|
151
|
+
addTodo();
|
|
152
|
+
}} }
|
|
136
153
|
placeholder="What needs to be done?"
|
|
137
154
|
style={{
|
|
138
155
|
"flex": "1",
|
|
@@ -160,16 +177,17 @@ cl {
|
|
|
160
177
|
Add
|
|
161
178
|
</button>
|
|
162
179
|
</div>
|
|
163
|
-
|
|
164
180
|
# Filter buttons
|
|
165
|
-
<div
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
181
|
+
<div
|
|
182
|
+
style={{
|
|
183
|
+
"display": "flex",
|
|
184
|
+
"gap": "8px",
|
|
185
|
+
"marginBottom": "24px",
|
|
186
|
+
"justifyContent": "center"
|
|
187
|
+
}}
|
|
188
|
+
>
|
|
171
189
|
<button
|
|
172
|
-
onClick={lambda
|
|
190
|
+
onClick={lambda -> None{ setFilter("all");} }
|
|
173
191
|
style={{
|
|
174
192
|
"padding": "8px 16px",
|
|
175
193
|
"background": ("#3b82f6" if filter == "all" else "#ffffff"),
|
|
@@ -184,7 +202,7 @@ cl {
|
|
|
184
202
|
All
|
|
185
203
|
</button>
|
|
186
204
|
<button
|
|
187
|
-
onClick={lambda
|
|
205
|
+
onClick={lambda -> None{ setFilter("active");} }
|
|
188
206
|
style={{
|
|
189
207
|
"padding": "8px 16px",
|
|
190
208
|
"background": ("#3b82f6" if filter == "active" else "#ffffff"),
|
|
@@ -199,10 +217,12 @@ cl {
|
|
|
199
217
|
Active
|
|
200
218
|
</button>
|
|
201
219
|
<button
|
|
202
|
-
onClick={lambda
|
|
220
|
+
onClick={lambda -> None{ setFilter("completed");} }
|
|
203
221
|
style={{
|
|
204
222
|
"padding": "8px 16px",
|
|
205
|
-
"background": (
|
|
223
|
+
"background": (
|
|
224
|
+
"#3b82f6" if filter == "completed" else "#ffffff"
|
|
225
|
+
),
|
|
206
226
|
"color": ("#ffffff" if filter == "completed" else "#3b82f6"),
|
|
207
227
|
"border": "1px solid #3b82f6",
|
|
208
228
|
"borderRadius": "6px",
|
|
@@ -214,25 +234,38 @@ cl {
|
|
|
214
234
|
Completed
|
|
215
235
|
</button>
|
|
216
236
|
</div>
|
|
217
|
-
|
|
218
237
|
# Todo list
|
|
219
|
-
<div
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
238
|
+
<div
|
|
239
|
+
style={{
|
|
240
|
+
"background": "#ffffff",
|
|
241
|
+
"borderRadius": "12px",
|
|
242
|
+
"boxShadow": "0 1px 3px rgba(0,0,0,0.1)",
|
|
243
|
+
"overflow": "hidden"
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
{(
|
|
247
|
+
<div
|
|
248
|
+
style={{
|
|
249
|
+
"padding": "40px",
|
|
250
|
+
"textAlign": "center",
|
|
251
|
+
"color": "#9ca3af"
|
|
252
|
+
}}
|
|
253
|
+
>
|
|
254
|
+
{(
|
|
255
|
+
"No todos yet. Add one above!"
|
|
256
|
+
if filter == "all"
|
|
257
|
+
else (
|
|
258
|
+
"No active todos!"
|
|
259
|
+
if filter == "active"
|
|
260
|
+
else "No completed todos!"
|
|
261
|
+
)
|
|
262
|
+
)}
|
|
263
|
+
</div>
|
|
264
|
+
)
|
|
265
|
+
if filteredTodos.length == 0
|
|
266
|
+
else (
|
|
267
|
+
filteredTodos.map(
|
|
268
|
+
lambda todo: any -> any{ return <div
|
|
236
269
|
key={todo._jac_id}
|
|
237
270
|
style={{
|
|
238
271
|
"display": "flex",
|
|
@@ -246,23 +279,27 @@ cl {
|
|
|
246
279
|
<input
|
|
247
280
|
type="checkbox"
|
|
248
281
|
checked={todo.done}
|
|
249
|
-
onChange={lambda
|
|
282
|
+
onChange={lambda -> None{ toggleTodo(todo._jac_id);} }
|
|
250
283
|
style={{
|
|
251
284
|
"width": "20px",
|
|
252
285
|
"height": "20px",
|
|
253
286
|
"cursor": "pointer"
|
|
254
287
|
}}
|
|
255
288
|
/>
|
|
256
|
-
<span
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
289
|
+
<span
|
|
290
|
+
style={{
|
|
291
|
+
"flex": "1",
|
|
292
|
+
"textDecoration": (
|
|
293
|
+
"line-through" if todo.done else "none"
|
|
294
|
+
),
|
|
295
|
+
"color": ("#9ca3af" if todo.done else "#1f2937"),
|
|
296
|
+
"fontSize": "16px"
|
|
297
|
+
}}
|
|
298
|
+
>
|
|
262
299
|
{todo.text}
|
|
263
300
|
</span>
|
|
264
301
|
<button
|
|
265
|
-
onClick={lambda
|
|
302
|
+
onClick={lambda -> None{ deleteTodo(todo.__jac_id);} }
|
|
266
303
|
style={{
|
|
267
304
|
"padding": "6px 12px",
|
|
268
305
|
"background": "#ef4444",
|
|
@@ -277,29 +314,31 @@ cl {
|
|
|
277
314
|
>
|
|
278
315
|
Delete
|
|
279
316
|
</button>
|
|
280
|
-
</div>;
|
|
281
|
-
|
|
317
|
+
</div>; }
|
|
318
|
+
)
|
|
282
319
|
)}
|
|
283
320
|
</div>
|
|
284
|
-
|
|
285
321
|
# Stats and clear completed button
|
|
286
|
-
{(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
322
|
+
{(
|
|
323
|
+
<div
|
|
324
|
+
style={{
|
|
325
|
+
"display": "flex",
|
|
326
|
+
"justifyContent": "space-between",
|
|
327
|
+
"alignItems": "center",
|
|
328
|
+
"marginTop": "24px",
|
|
329
|
+
"padding": "16px",
|
|
330
|
+
"background": "#ffffff",
|
|
331
|
+
"borderRadius": "12px",
|
|
332
|
+
"boxShadow": "0 1px 3px rgba(0,0,0,0.1)"
|
|
333
|
+
}}
|
|
334
|
+
>
|
|
335
|
+
<span
|
|
336
|
+
style={{"color": "#6b7280", "fontSize": "14px"}}
|
|
337
|
+
>
|
|
300
338
|
{activeCount} {"item" if activeCount == 1 else "items"} left
|
|
301
339
|
</span>
|
|
302
|
-
{(
|
|
340
|
+
{(
|
|
341
|
+
<button
|
|
303
342
|
onClick={clearCompleted}
|
|
304
343
|
style={{
|
|
305
344
|
"padding": "8px 16px",
|
|
@@ -313,8 +352,14 @@ cl {
|
|
|
313
352
|
}}
|
|
314
353
|
>
|
|
315
354
|
Clear Completed
|
|
316
|
-
</button>
|
|
317
|
-
|
|
355
|
+
</button>
|
|
356
|
+
)
|
|
357
|
+
if todos.some(lambda todo: any -> bool{ return todo.done; } )
|
|
358
|
+
else None}
|
|
359
|
+
</div>
|
|
360
|
+
)
|
|
361
|
+
if todos.length > 0
|
|
362
|
+
else None}
|
|
318
363
|
</div>;
|
|
319
364
|
}
|
|
320
365
|
}
|
|
@@ -3,18 +3,18 @@ cl import from react { useState, useEffect }
|
|
|
3
3
|
cl import from .styles { default as styles }
|
|
4
4
|
|
|
5
5
|
cl {
|
|
6
|
-
def app
|
|
7
|
-
|
|
6
|
+
def:pub app -> any {
|
|
7
|
+
[count, setCount] = useState(0);
|
|
8
8
|
|
|
9
9
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
handleIncrement = lambda e: any -> None{ setCount(count + 1);} ;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
handleDecrement = lambda e: any -> None{ setCount(count - 1);} ;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
handleReset = lambda e: any -> None{ setCount(0);} ;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
countStyle = styles.countDisplayZero
|
|
18
18
|
if count == 0
|
|
19
19
|
else (
|
|
20
20
|
styles.countDisplayPositive if count > 0 else styles.countDisplayNegative
|
|
@@ -12,16 +12,16 @@ cl import from '@mui/icons-material/Remove' { default as RemoveIcon }
|
|
|
12
12
|
cl import from '@mui/icons-material/Refresh' { default as RefreshIcon }
|
|
13
13
|
|
|
14
14
|
cl {
|
|
15
|
-
def app
|
|
16
|
-
|
|
15
|
+
def:pub app -> any {
|
|
16
|
+
[count, setCount] = useState(0);
|
|
17
17
|
|
|
18
18
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
handleIncrement = lambda e: any -> None{ setCount(count + 1);} ;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
handleDecrement = lambda e: any -> None{ setCount(count - 1);} ;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
handleReset = lambda e: any -> None{ setCount(0);} ;
|
|
25
25
|
|
|
26
26
|
return <Box
|
|
27
27
|
sx={{
|
|
@@ -3,18 +3,18 @@ cl import from react { useState, useEffect }
|
|
|
3
3
|
cl import ".styles.css";
|
|
4
4
|
|
|
5
5
|
cl {
|
|
6
|
-
def app
|
|
7
|
-
|
|
6
|
+
def:pub app -> any {
|
|
7
|
+
[count, setCount] = useState(0);
|
|
8
8
|
|
|
9
9
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
handleIncrement = lambda e: any -> None{ setCount(count + 1);} ;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
handleDecrement = lambda e: any -> None{ setCount(count - 1);} ;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
handleReset = lambda e: any -> None{ setCount(0);} ;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
countClass = "countDisplay " + (
|
|
18
18
|
"positive" if count > 0 else "negative" if count < 0 else "zero"
|
|
19
19
|
);
|
|
20
20
|
|
|
@@ -3,18 +3,18 @@ cl import from react { useState, useEffect }
|
|
|
3
3
|
cl import ".styles.scss";
|
|
4
4
|
|
|
5
5
|
cl {
|
|
6
|
-
def app
|
|
7
|
-
|
|
6
|
+
def:pub app -> any {
|
|
7
|
+
[count, setCount] = useState(0);
|
|
8
8
|
|
|
9
9
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
handleIncrement = lambda e: any -> None{ setCount(count + 1);} ;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
handleDecrement = lambda e: any -> None{ setCount(count - 1);} ;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
handleReset = lambda e: any -> None{ setCount(0);} ;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
countClass = "countDisplay " + (
|
|
18
18
|
"positive" if count > 0 else "negative" if count < 0 else "zero"
|
|
19
19
|
);
|
|
20
20
|
|
|
@@ -14,16 +14,16 @@ cl import from .styled {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
cl {
|
|
17
|
-
def app
|
|
18
|
-
|
|
17
|
+
def:pub app -> any {
|
|
18
|
+
[count, setCount] = useState(0);
|
|
19
19
|
|
|
20
20
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
handleIncrement = lambda e: any -> None{ setCount(count + 1);} ;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
handleDecrement = lambda e: any -> None{ setCount(count - 1);} ;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
handleReset = lambda e: any -> None{ setCount(0);} ;
|
|
27
27
|
|
|
28
28
|
return <Container>
|
|
29
29
|
<Card>
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
cl import from react { useState, useEffect }
|
|
3
3
|
cl import ".global.css";
|
|
4
4
|
cl {
|
|
5
|
-
def app
|
|
6
|
-
|
|
5
|
+
def:pub app -> any {
|
|
6
|
+
[count, setCount] = useState(0);
|
|
7
7
|
|
|
8
8
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
handleIncrement = lambda e: any -> None{ setCount(count + 1);} ;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
handleDecrement = lambda e: any -> None{ setCount(count - 1);} ;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
handleReset = lambda e: any -> None{ setCount(0);} ;
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
countColorClass = "text-gray-800"
|
|
17
17
|
if count == 0
|
|
18
18
|
else ("text-green-600" if count > 0 else "text-red-600");
|
|
19
19
|
|