jac-client 0.2.3__py3-none-any.whl → 0.2.8__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/app.jac +494 -347
- jac_client/examples/all-in-one/assets/workers/worker.py +5 -0
- jac_client/examples/all-in-one/button.jac +1 -1
- jac_client/examples/all-in-one/components/CategoryFilter.jac +35 -0
- jac_client/examples/all-in-one/components/Header.jac +13 -0
- jac_client/examples/all-in-one/components/ProfitOverview.jac +50 -0
- jac_client/examples/all-in-one/components/Summary.jac +53 -0
- jac_client/examples/all-in-one/components/TransactionForm.jac +158 -0
- jac_client/examples/all-in-one/components/TransactionItem.jac +55 -0
- jac_client/examples/all-in-one/components/TransactionList.jac +37 -0
- jac_client/examples/all-in-one/components/button.jac +1 -1
- jac_client/examples/all-in-one/components/navigation.jac +132 -0
- jac_client/examples/all-in-one/constants/categories.jac +37 -0
- jac_client/examples/all-in-one/constants/clients.jac +13 -0
- jac_client/examples/all-in-one/context/BudgetContext.jac +28 -0
- jac_client/examples/all-in-one/hooks/useBudget.jac +116 -0
- jac_client/examples/all-in-one/hooks/useLocalStorage.jac +36 -0
- jac_client/examples/all-in-one/pages/BudgetPlanner.cl.jac +70 -0
- jac_client/examples/all-in-one/pages/BudgetPlanner.jac +126 -0
- jac_client/examples/all-in-one/pages/FeaturesTest.cl.jac +552 -0
- jac_client/examples/all-in-one/pages/FeaturesTest.jac +126 -0
- jac_client/examples/all-in-one/pages/LandingPage.jac +101 -0
- jac_client/examples/all-in-one/pages/loginPage.jac +132 -0
- jac_client/examples/all-in-one/pages/nestedDemo.jac +61 -0
- jac_client/examples/all-in-one/pages/notFound.jac +24 -0
- jac_client/examples/all-in-one/pages/signupPage.jac +133 -0
- jac_client/examples/all-in-one/utils/formatters.jac +52 -0
- jac_client/examples/asset-serving/css-with-image/{app.jac → src/app.jac} +4 -4
- jac_client/examples/asset-serving/image-asset/{app.jac → src/app.jac} +4 -4
- jac_client/examples/asset-serving/import-alias/{app.jac → src/app.jac} +5 -5
- jac_client/examples/basic/{app.jac → src/app.jac} +4 -4
- jac_client/examples/basic-auth/src/app.jac +371 -0
- jac_client/examples/basic-auth-with-router/{app.jac → src/app.jac} +28 -28
- jac_client/examples/basic-full-stack/{app.jac → src/app.jac} +166 -127
- jac_client/examples/css-styling/js-styling/{app.jac → src/app.jac} +7 -7
- jac_client/examples/css-styling/material-ui/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/pure-css/{app.jac → src/app.jac} +7 -7
- jac_client/examples/css-styling/sass-example/{app.jac → src/app.jac} +7 -7
- jac_client/examples/css-styling/styled-components/{app.jac → src/app.jac} +6 -6
- jac_client/examples/css-styling/tailwind-example/{app.jac → src/app.jac} +7 -7
- jac_client/examples/full-stack-with-auth/{app.jac → src/app.jac} +47 -47
- 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} +15 -15
- jac_client/plugin/cli.jac +504 -0
- jac_client/plugin/client.jac +45 -0
- jac_client/plugin/client_runtime.cl.jac +42 -0
- jac_client/plugin/impl/client.impl.jac +193 -0
- jac_client/plugin/impl/client_runtime.impl.jac +195 -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 +67 -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 +89 -0
- jac_client/plugin/src/impl/compiler.impl.jac +288 -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 +626 -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 +44 -0
- jac_client/plugin/vite_client_bundle.jac +31 -0
- jac_client/tests/conftest.py +283 -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 +15 -18
- jac_client/tests/fixtures/with-ts/app.jac +35 -0
- jac_client/tests/test_cli.py +811 -0
- jac_client/tests/test_it.py +592 -97
- {jac_client-0.2.3.dist-info → jac_client-0.2.8.dist-info}/METADATA +41 -34
- jac_client-0.2.8.dist-info/RECORD +97 -0
- {jac_client-0.2.3.dist-info → jac_client-0.2.8.dist-info}/WHEEL +2 -1
- jac_client-0.2.8.dist-info/entry_points.txt +4 -0
- jac_client-0.2.8.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/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.3.dist-info/RECORD +0 -171
- jac_client-0.2.3.dist-info/entry_points.txt +0 -4
|
@@ -1,67 +1,69 @@
|
|
|
1
1
|
# Todo App
|
|
2
|
-
cl import from react {
|
|
2
|
+
cl import from react { 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
|
+
has todos: list = [];
|
|
38
|
+
has inputValue: str = "";
|
|
39
|
+
has filter: str = "all";
|
|
36
40
|
|
|
37
|
-
useEffect(
|
|
38
|
-
async def loadTodos
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
useEffect(
|
|
42
|
+
lambda -> None{ async def loadTodos -> None {
|
|
43
|
+
result = root spawn read_todos();
|
|
44
|
+
todos = result.reports;
|
|
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
|
-
|
|
56
|
-
|
|
57
|
+
todos = newTodos;
|
|
58
|
+
inputValue = "";
|
|
57
59
|
}
|
|
58
60
|
|
|
59
61
|
# Toggle todo completion status
|
|
60
62
|
async def toggleTodo(id: any) -> None {
|
|
61
63
|
console.log("toggleTodo", id);
|
|
62
64
|
id spawn toggle_todo();
|
|
63
|
-
|
|
64
|
-
if todo._jac_id == id {
|
|
65
|
+
todos = todos.map(
|
|
66
|
+
lambda todo: any -> any{ if todo._jac_id == id {
|
|
65
67
|
updatedTodo = {
|
|
66
68
|
"_jac_id": todo._jac_id,
|
|
67
69
|
"text": todo.text,
|
|
@@ -69,70 +71,79 @@ cl {
|
|
|
69
71
|
"id": todo.id
|
|
70
72
|
};
|
|
71
73
|
return updatedTodo;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
}));
|
|
74
|
+
}return todo; }
|
|
75
|
+
);
|
|
75
76
|
}
|
|
76
77
|
|
|
77
78
|
# Delete a todo
|
|
78
79
|
def deleteTodo(id: any) -> None {
|
|
79
|
-
|
|
80
|
+
todos = todos.filter(lambda todo: any -> bool{ return todo.id != id; } );
|
|
80
81
|
}
|
|
81
82
|
|
|
82
83
|
# Clear all completed todos
|
|
83
|
-
def clearCompleted
|
|
84
|
-
|
|
84
|
+
def clearCompleted -> None {
|
|
85
|
+
todos = todos.filter(lambda todo: any -> bool{ return not todo.done; } );
|
|
85
86
|
}
|
|
86
87
|
|
|
87
88
|
# Filter todos based on current filter
|
|
88
|
-
def getFilteredTodos
|
|
89
|
+
def getFilteredTodos -> list {
|
|
89
90
|
if filter == "active" {
|
|
90
|
-
return todos.filter(
|
|
91
|
+
return todos.filter(
|
|
92
|
+
lambda todo: any -> bool{ return not todo.done; }
|
|
93
|
+
);
|
|
91
94
|
} elif filter == "completed" {
|
|
92
|
-
return todos.filter(lambda
|
|
95
|
+
return todos.filter(lambda todo: any -> bool{ return todo.done; } );
|
|
93
96
|
}
|
|
94
97
|
return todos;
|
|
95
98
|
}
|
|
96
99
|
|
|
97
100
|
# Count active todos
|
|
98
|
-
activeCount = todos.filter(
|
|
101
|
+
activeCount = todos.filter(
|
|
102
|
+
lambda todo: any -> bool{ return not todo.done; }
|
|
103
|
+
).length;
|
|
99
104
|
|
|
100
105
|
filteredTodos = getFilteredTodos();
|
|
101
106
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
return <div
|
|
108
|
+
style={{
|
|
109
|
+
"maxWidth": "600px",
|
|
110
|
+
"margin": "40px auto",
|
|
111
|
+
"padding": "24px",
|
|
112
|
+
"fontFamily": "system-ui, -apple-system, sans-serif",
|
|
113
|
+
"background": "#f9fafb",
|
|
114
|
+
"minHeight": "100vh"
|
|
115
|
+
}}
|
|
116
|
+
>
|
|
117
|
+
<h1
|
|
118
|
+
style={{
|
|
119
|
+
"textAlign": "center",
|
|
120
|
+
"color": "#1f2937",
|
|
121
|
+
"marginBottom": "32px",
|
|
122
|
+
"fontSize": "2.5rem",
|
|
123
|
+
"fontWeight": "700"
|
|
124
|
+
}}
|
|
125
|
+
>
|
|
126
|
+
📝 My Todo App
|
|
127
|
+
</h1>
|
|
119
128
|
# Add todo form
|
|
120
|
-
<div
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
<div
|
|
130
|
+
style={{
|
|
131
|
+
"display": "flex",
|
|
132
|
+
"gap": "8px",
|
|
133
|
+
"marginBottom": "24px",
|
|
134
|
+
"background": "#ffffff",
|
|
135
|
+
"padding": "16px",
|
|
136
|
+
"borderRadius": "12px",
|
|
137
|
+
"boxShadow": "0 1px 3px rgba(0,0,0,0.1)"
|
|
138
|
+
}}
|
|
139
|
+
>
|
|
129
140
|
<input
|
|
130
141
|
type="text"
|
|
131
142
|
value={inputValue}
|
|
132
|
-
onChange={lambda
|
|
133
|
-
onKeyPress={lambda
|
|
134
|
-
|
|
135
|
-
}}
|
|
143
|
+
onChange={lambda e: any -> None{ inputValue = e.target.value;} }
|
|
144
|
+
onKeyPress={lambda e: any -> None{ if e.key == "Enter" {
|
|
145
|
+
addTodo();
|
|
146
|
+
}} }
|
|
136
147
|
placeholder="What needs to be done?"
|
|
137
148
|
style={{
|
|
138
149
|
"flex": "1",
|
|
@@ -160,16 +171,17 @@ cl {
|
|
|
160
171
|
Add
|
|
161
172
|
</button>
|
|
162
173
|
</div>
|
|
163
|
-
|
|
164
174
|
# Filter buttons
|
|
165
|
-
<div
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
175
|
+
<div
|
|
176
|
+
style={{
|
|
177
|
+
"display": "flex",
|
|
178
|
+
"gap": "8px",
|
|
179
|
+
"marginBottom": "24px",
|
|
180
|
+
"justifyContent": "center"
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
171
183
|
<button
|
|
172
|
-
onClick={lambda
|
|
184
|
+
onClick={lambda -> None{ filter = "all";} }
|
|
173
185
|
style={{
|
|
174
186
|
"padding": "8px 16px",
|
|
175
187
|
"background": ("#3b82f6" if filter == "all" else "#ffffff"),
|
|
@@ -184,7 +196,7 @@ cl {
|
|
|
184
196
|
All
|
|
185
197
|
</button>
|
|
186
198
|
<button
|
|
187
|
-
onClick={lambda
|
|
199
|
+
onClick={lambda -> None{ filter = "active";} }
|
|
188
200
|
style={{
|
|
189
201
|
"padding": "8px 16px",
|
|
190
202
|
"background": ("#3b82f6" if filter == "active" else "#ffffff"),
|
|
@@ -199,10 +211,12 @@ cl {
|
|
|
199
211
|
Active
|
|
200
212
|
</button>
|
|
201
213
|
<button
|
|
202
|
-
onClick={lambda
|
|
214
|
+
onClick={lambda -> None{ filter = "completed";} }
|
|
203
215
|
style={{
|
|
204
216
|
"padding": "8px 16px",
|
|
205
|
-
"background": (
|
|
217
|
+
"background": (
|
|
218
|
+
"#3b82f6" if filter == "completed" else "#ffffff"
|
|
219
|
+
),
|
|
206
220
|
"color": ("#ffffff" if filter == "completed" else "#3b82f6"),
|
|
207
221
|
"border": "1px solid #3b82f6",
|
|
208
222
|
"borderRadius": "6px",
|
|
@@ -214,25 +228,38 @@ cl {
|
|
|
214
228
|
Completed
|
|
215
229
|
</button>
|
|
216
230
|
</div>
|
|
217
|
-
|
|
218
231
|
# Todo list
|
|
219
|
-
<div
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
232
|
+
<div
|
|
233
|
+
style={{
|
|
234
|
+
"background": "#ffffff",
|
|
235
|
+
"borderRadius": "12px",
|
|
236
|
+
"boxShadow": "0 1px 3px rgba(0,0,0,0.1)",
|
|
237
|
+
"overflow": "hidden"
|
|
238
|
+
}}
|
|
239
|
+
>
|
|
240
|
+
{(
|
|
241
|
+
<div
|
|
242
|
+
style={{
|
|
243
|
+
"padding": "40px",
|
|
244
|
+
"textAlign": "center",
|
|
245
|
+
"color": "#9ca3af"
|
|
246
|
+
}}
|
|
247
|
+
>
|
|
248
|
+
{(
|
|
249
|
+
"No todos yet. Add one above!"
|
|
250
|
+
if filter == "all"
|
|
251
|
+
else (
|
|
252
|
+
"No active todos!"
|
|
253
|
+
if filter == "active"
|
|
254
|
+
else "No completed todos!"
|
|
255
|
+
)
|
|
256
|
+
)}
|
|
257
|
+
</div>
|
|
258
|
+
)
|
|
259
|
+
if filteredTodos.length == 0
|
|
260
|
+
else (
|
|
261
|
+
filteredTodos.map(
|
|
262
|
+
lambda todo: any -> any{ return <div
|
|
236
263
|
key={todo._jac_id}
|
|
237
264
|
style={{
|
|
238
265
|
"display": "flex",
|
|
@@ -246,23 +273,27 @@ cl {
|
|
|
246
273
|
<input
|
|
247
274
|
type="checkbox"
|
|
248
275
|
checked={todo.done}
|
|
249
|
-
onChange={lambda
|
|
276
|
+
onChange={lambda -> None{ toggleTodo(todo._jac_id);} }
|
|
250
277
|
style={{
|
|
251
278
|
"width": "20px",
|
|
252
279
|
"height": "20px",
|
|
253
280
|
"cursor": "pointer"
|
|
254
281
|
}}
|
|
255
282
|
/>
|
|
256
|
-
<span
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
283
|
+
<span
|
|
284
|
+
style={{
|
|
285
|
+
"flex": "1",
|
|
286
|
+
"textDecoration": (
|
|
287
|
+
"line-through" if todo.done else "none"
|
|
288
|
+
),
|
|
289
|
+
"color": ("#9ca3af" if todo.done else "#1f2937"),
|
|
290
|
+
"fontSize": "16px"
|
|
291
|
+
}}
|
|
292
|
+
>
|
|
262
293
|
{todo.text}
|
|
263
294
|
</span>
|
|
264
295
|
<button
|
|
265
|
-
onClick={lambda
|
|
296
|
+
onClick={lambda -> None{ deleteTodo(todo.__jac_id);} }
|
|
266
297
|
style={{
|
|
267
298
|
"padding": "6px 12px",
|
|
268
299
|
"background": "#ef4444",
|
|
@@ -277,29 +308,31 @@ cl {
|
|
|
277
308
|
>
|
|
278
309
|
Delete
|
|
279
310
|
</button>
|
|
280
|
-
</div>;
|
|
281
|
-
|
|
311
|
+
</div>; }
|
|
312
|
+
)
|
|
282
313
|
)}
|
|
283
314
|
</div>
|
|
284
|
-
|
|
285
315
|
# Stats and clear completed button
|
|
286
|
-
{(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
316
|
+
{(
|
|
317
|
+
<div
|
|
318
|
+
style={{
|
|
319
|
+
"display": "flex",
|
|
320
|
+
"justifyContent": "space-between",
|
|
321
|
+
"alignItems": "center",
|
|
322
|
+
"marginTop": "24px",
|
|
323
|
+
"padding": "16px",
|
|
324
|
+
"background": "#ffffff",
|
|
325
|
+
"borderRadius": "12px",
|
|
326
|
+
"boxShadow": "0 1px 3px rgba(0,0,0,0.1)"
|
|
327
|
+
}}
|
|
328
|
+
>
|
|
329
|
+
<span
|
|
330
|
+
style={{"color": "#6b7280", "fontSize": "14px"}}
|
|
331
|
+
>
|
|
300
332
|
{activeCount} {"item" if activeCount == 1 else "items"} left
|
|
301
333
|
</span>
|
|
302
|
-
{(
|
|
334
|
+
{(
|
|
335
|
+
<button
|
|
303
336
|
onClick={clearCompleted}
|
|
304
337
|
style={{
|
|
305
338
|
"padding": "8px 16px",
|
|
@@ -313,8 +346,14 @@ cl {
|
|
|
313
346
|
}}
|
|
314
347
|
>
|
|
315
348
|
Clear Completed
|
|
316
|
-
</button>
|
|
317
|
-
|
|
349
|
+
</button>
|
|
350
|
+
)
|
|
351
|
+
if todos.some(lambda todo: any -> bool{ return todo.done; } )
|
|
352
|
+
else None}
|
|
353
|
+
</div>
|
|
354
|
+
)
|
|
355
|
+
if todos.length > 0
|
|
356
|
+
else None}
|
|
318
357
|
</div>;
|
|
319
358
|
}
|
|
320
359
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# Pages
|
|
2
|
-
cl import from react {
|
|
2
|
+
cl import from react { 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
|
+
has count: int = 0;
|
|
8
8
|
|
|
9
9
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
handleIncrement = lambda e: any -> None{ count = count + 1;} ;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
handleDecrement = lambda e: any -> None{ count = count - 1;} ;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
handleReset = lambda e: any -> None{ count = 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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
cl import from react {
|
|
1
|
+
cl import from react { useEffect }
|
|
2
2
|
cl import from '@mui/material/Button' { default as Button }
|
|
3
3
|
cl import from '@mui/material/Card' { default as Card }
|
|
4
4
|
cl import from '@mui/material/CardContent' { default as CardContent }
|
|
@@ -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
|
+
has count: int = 0;
|
|
17
17
|
|
|
18
18
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
handleIncrement = lambda e: any -> None{ count = count + 1;} ;
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
handleDecrement = lambda e: any -> None{ count = count - 1;} ;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
handleReset = lambda e: any -> None{ count = 0;} ;
|
|
25
25
|
|
|
26
26
|
return <Box
|
|
27
27
|
sx={{
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# Pages
|
|
2
|
-
cl import from react {
|
|
2
|
+
cl import from react { useEffect }
|
|
3
3
|
cl import ".styles.css";
|
|
4
4
|
|
|
5
5
|
cl {
|
|
6
|
-
def app
|
|
7
|
-
|
|
6
|
+
def:pub app -> any {
|
|
7
|
+
has count: int = 0;
|
|
8
8
|
|
|
9
9
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
handleIncrement = lambda e: any -> None{ count = count + 1;} ;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
handleDecrement = lambda e: any -> None{ count = count - 1;} ;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
handleReset = lambda e: any -> None{ count = 0;} ;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
countClass = "countDisplay " + (
|
|
18
18
|
"positive" if count > 0 else "negative" if count < 0 else "zero"
|
|
19
19
|
);
|
|
20
20
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# Pages
|
|
2
|
-
cl import from react {
|
|
2
|
+
cl import from react { useEffect }
|
|
3
3
|
cl import ".styles.scss";
|
|
4
4
|
|
|
5
5
|
cl {
|
|
6
|
-
def app
|
|
7
|
-
|
|
6
|
+
def:pub app -> any {
|
|
7
|
+
has count: int = 0;
|
|
8
8
|
|
|
9
9
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
handleIncrement = lambda e: any -> None{ count = count + 1;} ;
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
handleDecrement = lambda e: any -> None{ count = count - 1;} ;
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
handleReset = lambda e: any -> None{ count = 0;} ;
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
countClass = "countDisplay " + (
|
|
18
18
|
"positive" if count > 0 else "negative" if count < 0 else "zero"
|
|
19
19
|
);
|
|
20
20
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Pages
|
|
2
|
-
cl import from react {
|
|
2
|
+
cl import from react { useEffect }
|
|
3
3
|
cl import from .styled {
|
|
4
4
|
Container,
|
|
5
5
|
Card,
|
|
@@ -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
|
+
has count: int = 0;
|
|
19
19
|
|
|
20
20
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
handleIncrement = lambda e: any -> None{ count = count + 1;} ;
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
handleDecrement = lambda e: any -> None{ count = count - 1;} ;
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
handleReset = lambda e: any -> None{ count = 0;} ;
|
|
27
27
|
|
|
28
28
|
return <Container>
|
|
29
29
|
<Card>
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
# Pages
|
|
2
|
-
cl import from react {
|
|
2
|
+
cl import from react { useEffect }
|
|
3
3
|
cl import ".global.css";
|
|
4
4
|
cl {
|
|
5
|
-
def app
|
|
6
|
-
|
|
5
|
+
def:pub app -> any {
|
|
6
|
+
has count: int = 0;
|
|
7
7
|
|
|
8
8
|
useEffect(lambda -> None{ console.log("Count changed: ", count);} , [count]);
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
handleIncrement = lambda e: any -> None{ count = count + 1;} ;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
handleDecrement = lambda e: any -> None{ count = count - 1;} ;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
handleReset = lambda e: any -> None{ count = 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
|
|