cajoa 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -4
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -96,7 +96,7 @@ const [todos, setTodos] = createSignal([{ id: 1, text: "Learn Cajoa" }]);
|
|
|
96
96
|
|
|
97
97
|
## Forms, styles and events
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
````tsx
|
|
100
100
|
const [name, setName] = createSignal("");
|
|
101
101
|
const [agree, setAgree] = createSignal(false);
|
|
102
102
|
|
|
@@ -118,12 +118,29 @@ const [agree, setAgree] = createSignal(false);
|
|
|
118
118
|
Hello, {() => name() || "stranger"}!
|
|
119
119
|
</p>
|
|
120
120
|
</form>;
|
|
121
|
-
|
|
121
|
+
|
|
122
|
+
## Refs and SVG
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
function SearchBox() {
|
|
126
|
+
let input: HTMLInputElement | undefined;
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<div>
|
|
130
|
+
<input ref={(el: HTMLInputElement) => (input = el)} />
|
|
131
|
+
<button onClick={() => input?.focus()}>Focus</button>
|
|
132
|
+
</div>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
````
|
|
122
137
|
|
|
123
138
|
- `value`, `checked` and `selected` are set as DOM properties, so they stay in sync even after the user typed. Write `value` after `type`, `min` and `max`.
|
|
124
139
|
- `style` takes a string or an object (camelCase keys, kebab-case keys, or custom properties like `--accent`). Numbers are not converted to `px`, so write `"12px"`. For a reactive style, pass a function: `style={() => ({ color: color() })}`. An object with signals inside, like `style={{ color: color() }}`, is read once.
|
|
125
140
|
- Events are native DOM events. `onChange` fires when a field loses focus, so use `onInput` for every keystroke. `onDoubleClick` listens to `dblclick`.
|
|
126
141
|
- `className` and `htmlFor` work. Inline string handlers like `onclick="..."` are ignored.
|
|
142
|
+
- `ref` is a function that receives the element once it is created. Its props and children are ready, but it is not in the page yet, so use `onMount` if you need to measure it right away. Signals read inside `ref` are not tracked.
|
|
143
|
+
- SVG works: `<svg>`, `<path>`, `<circle>`, gradients, filters and the other SVG tags are created in the SVG namespace. Write attributes as `stroke-width="2"` or `strokeWidth="2"`.
|
|
127
144
|
|
|
128
145
|
```tsx
|
|
129
146
|
import { render, Router, Route, Link, useParams } from "cajoa";
|
|
@@ -233,12 +250,11 @@ Routes are matched in order, so put `path="*"` last.
|
|
|
233
250
|
- Router: pathname only (no query/hash handling), no nested routes, no `base` path.
|
|
234
251
|
- `<Show>` and `<Router>` return a function, so they must sit inside an element, not be the root returned by `render`.
|
|
235
252
|
- Single-page apps need a server fallback to `index.html` for unknown paths.
|
|
236
|
-
- SVG is not supported yet: `<svg>` is created as an HTML element, so it does not render.
|
|
237
|
-
- No `ref` prop yet.
|
|
238
253
|
- `<select value>` works only when the `<option>` elements are direct children of the `<select>`.
|
|
239
254
|
- `createMemo` can show a brief inconsistent state when memos depend on each other.
|
|
240
255
|
- `set` calls are not batched automatically inside event handlers. Wrap them in `batch()`.
|
|
241
256
|
- Types in the core use a loose `HostNode` type for now.
|
|
257
|
+
- Inside `<svg>`, the tags `<a>`, `<title>`, `<style>` and `<script>` are created as HTML elements (they share their names with HTML tags).
|
|
242
258
|
|
|
243
259
|
## Roadmap
|
|
244
260
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cajoa",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "A small, beginner-friendly frontend framework built on signals and JSX.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -56,8 +56,8 @@
|
|
|
56
56
|
],
|
|
57
57
|
"sideEffects": true,
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@cajoa/core": "^0.
|
|
60
|
-
"@cajoa/dom": "^0.
|
|
59
|
+
"@cajoa/core": "^0.9.0",
|
|
60
|
+
"@cajoa/dom": "^0.9.0"
|
|
61
61
|
},
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|