@rip-lang/ui 0.3.9 → 0.3.10
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 +49 -0
- package/dist/rip-ui.min.js +61 -61
- package/dist/rip-ui.min.js.br +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -75,6 +75,55 @@ export About = component
|
|
|
75
75
|
Reactive props via `:=` signal passthrough. Readonly props via `=!`.
|
|
76
76
|
Children blocks passed as DOM nodes via `@children`.
|
|
77
77
|
|
|
78
|
+
## Props — The `@` Contract
|
|
79
|
+
|
|
80
|
+
The `@` prefix on a member declaration marks it as a **public prop** — settable
|
|
81
|
+
by a parent component. Members without `@` are **private state** and ignore
|
|
82
|
+
any value a parent tries to pass in.
|
|
83
|
+
|
|
84
|
+
```coffee
|
|
85
|
+
export Drawer = component
|
|
86
|
+
@open := false # public — parent can pass `open: true`
|
|
87
|
+
@breakpoint := 480 # public — parent can pass `breakpoint: 768`
|
|
88
|
+
isRight := false # private — always starts as false
|
|
89
|
+
closing := false # private — always starts as false
|
|
90
|
+
|
|
91
|
+
render
|
|
92
|
+
if open
|
|
93
|
+
div "Drawer is open"
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The compiler enforces the boundary:
|
|
97
|
+
|
|
98
|
+
```javascript
|
|
99
|
+
// @open := false → accepts parent value
|
|
100
|
+
this.open = __state(props.open ?? false);
|
|
101
|
+
|
|
102
|
+
// isRight := false → ignores parent, always uses default
|
|
103
|
+
this.isRight = __state(false);
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
This works for all member types:
|
|
107
|
+
|
|
108
|
+
| Declaration | Visibility | Meaning |
|
|
109
|
+
|-------------|-----------|---------|
|
|
110
|
+
| `@title := 'Hello'` | Public | Reactive state, settable by parent |
|
|
111
|
+
| `@label =! 'Default'` | Public | Readonly prop, settable by parent |
|
|
112
|
+
| `count := 0` | Private | Reactive state, internal only |
|
|
113
|
+
| `cache =! null` | Private | Readonly, internal only |
|
|
114
|
+
| `total ~= items.length` | — | Computed (always derived, never a prop) |
|
|
115
|
+
|
|
116
|
+
A parent passes props as key-value pairs when using a component:
|
|
117
|
+
|
|
118
|
+
```coffee
|
|
119
|
+
Drawer open: showDrawer, breakpoint: 768
|
|
120
|
+
div "Content here"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
The `@` declarations at the top of a component are its public API. Everything
|
|
124
|
+
else is an implementation detail. No separate type files, no prop validation
|
|
125
|
+
boilerplate — one character that says "this is settable from outside."
|
|
126
|
+
|
|
78
127
|
## Render Block Syntax
|
|
79
128
|
|
|
80
129
|
Inside a `render` block, elements are declared by tag name. Classes, attributes,
|