foldkit-mixins-surface 0.3.1 → 0.4.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 +9 -6
- package/package.json +12 -11
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ dependencies.
|
|
|
43
43
|
## Usage
|
|
44
44
|
|
|
45
45
|
```ts
|
|
46
|
-
import { Schema } from 'effect'
|
|
46
|
+
import { Option, Schema } from 'effect'
|
|
47
47
|
import { defineMessageUnion } from 'foldkit/message'
|
|
48
48
|
import { Behavior, Capability, Event, Slot, Slots, Style } from 'foldkit-mixins'
|
|
49
49
|
import { SurfaceView } from 'foldkit-mixins-surface'
|
|
@@ -51,7 +51,7 @@ import { Surface } from 'foldkit-surface'
|
|
|
51
51
|
|
|
52
52
|
const Model = Schema.Struct({
|
|
53
53
|
todos: Schema.Array(Schema.Struct({ id: Schema.String, title: Schema.String })),
|
|
54
|
-
selectedId: Schema.
|
|
54
|
+
selectedId: Schema.Option(Schema.String),
|
|
55
55
|
secret: Schema.String,
|
|
56
56
|
})
|
|
57
57
|
|
|
@@ -79,7 +79,7 @@ const TodoStyle = Style.forSlots(TodoSlots)({ root: Style.class('todo-list') })
|
|
|
79
79
|
/** What the Surface projects — the input every attachment sees. */
|
|
80
80
|
type ProjectedTodos = {
|
|
81
81
|
readonly todos: ReadonlyArray<{ readonly id: string; readonly title: string }>
|
|
82
|
-
readonly selectedId: string
|
|
82
|
+
readonly selectedId: Option.Option<string>
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
// `input` is the projection, so `input.secret` does not type-check; `h` builds
|
|
@@ -91,7 +91,10 @@ const TodoBehavior = Behavior.forSlots(TodoSlots)<
|
|
|
91
91
|
archive: Behavior.slot({
|
|
92
92
|
requires: { events: [Event.Click] },
|
|
93
93
|
attributes: ({ input, h }) =>
|
|
94
|
-
|
|
94
|
+
Option.match(input.selectedId, {
|
|
95
|
+
onNone: () => [],
|
|
96
|
+
onSome: id => [h.OnClick(Message.ArchivedTodo({ id }))],
|
|
97
|
+
}),
|
|
95
98
|
}),
|
|
96
99
|
})
|
|
97
100
|
|
|
@@ -99,7 +102,7 @@ const TodoListView = SurfaceView.define(TodoList, TodoSlots, (model, slots, h) =
|
|
|
99
102
|
h.section(slots.root.attrs(), [
|
|
100
103
|
h.ul([], model.todos.map(todo => h.li([], [todo.title]))),
|
|
101
104
|
h.button(
|
|
102
|
-
slots.archive.attrs([h.Disabled(model.selectedId
|
|
105
|
+
slots.archive.attrs([h.Disabled(Option.isNone(model.selectedId))]),
|
|
103
106
|
['Archive selected'],
|
|
104
107
|
),
|
|
105
108
|
]),
|
|
@@ -164,7 +167,7 @@ dispatched. It is for tests, demos, and static output, not a replacement for
|
|
|
164
167
|
```ts
|
|
165
168
|
const html = SurfaceView.render(TodoListView, TodoList, undefined, {
|
|
166
169
|
todos: [{ id: 't1', title: 'Write docs' }],
|
|
167
|
-
selectedId: 't1',
|
|
170
|
+
selectedId: Option.some('t1'),
|
|
168
171
|
secret: 'not projected',
|
|
169
172
|
})
|
|
170
173
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "foldkit-mixins-surface",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Bridge foldkit-surface's projected Model and Message subset to foldkit-mixins SlotViews.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"foldkit",
|
|
@@ -37,20 +37,21 @@
|
|
|
37
37
|
"LICENSE"
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"effect": "^4.0.0-rc.
|
|
41
|
-
"foldkit": "^0.
|
|
42
|
-
"foldkit-mixins": "^0.
|
|
43
|
-
"foldkit-surface": "^0.
|
|
40
|
+
"effect": "^4.0.0-rc.116",
|
|
41
|
+
"foldkit": "^0.163.0",
|
|
42
|
+
"foldkit-mixins": "^0.4.0",
|
|
43
|
+
"foldkit-surface": "^0.5.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"
|
|
48
|
-
"
|
|
46
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
47
|
+
"@foldkit/ui": "0.163.0",
|
|
48
|
+
"effect": "4.0.0-rc.116",
|
|
49
|
+
"foldkit": "0.163.0",
|
|
49
50
|
"tsdown": "^0.23.0",
|
|
50
51
|
"typescript": "5.9.3",
|
|
51
|
-
"foldkit-mixins": "0.
|
|
52
|
-
"foldkit-
|
|
53
|
-
"foldkit-
|
|
52
|
+
"foldkit-mixins": "0.4.0",
|
|
53
|
+
"foldkit-surface": "0.5.0",
|
|
54
|
+
"foldkit-mixins-ui": "0.4.0"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|
|
56
57
|
"build": "tsdown",
|