foldkit-mixins-surface 0.3.1 → 0.4.1

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.
Files changed (2) hide show
  1. package/README.md +9 -6
  2. package/package.json +13 -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.NullOr(Schema.String),
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 | null
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
- input.selectedId === null ? [] : [h.OnClick(Message.ArchivedTodo({ id: input.selectedId }))],
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 === null)]),
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.1",
3
+ "version": "0.4.1",
4
4
  "description": "Bridge foldkit-surface's projected Model and Message subset to foldkit-mixins SlotViews.",
5
5
  "keywords": [
6
6
  "foldkit",
@@ -27,6 +27,7 @@
27
27
  "sideEffects": false,
28
28
  "exports": {
29
29
  ".": {
30
+ "foldkit-plus:source": "./src/index.ts",
30
31
  "types": "./dist/index.d.mts",
31
32
  "import": "./dist/index.mjs"
32
33
  }
@@ -37,20 +38,21 @@
37
38
  "LICENSE"
38
39
  ],
39
40
  "peerDependencies": {
40
- "effect": "^4.0.0-rc.112",
41
- "foldkit": "^0.158.2",
42
- "foldkit-mixins": "^0.3.0",
43
- "foldkit-surface": "^0.4.0"
41
+ "effect": ">=4.0.0-rc.116 <4.0.0-rc.118",
42
+ "foldkit": "^0.163.0",
43
+ "foldkit-mixins": "^0.5.0",
44
+ "foldkit-surface": "^0.5.1"
44
45
  },
45
46
  "devDependencies": {
46
- "@foldkit/ui": "0.158.2",
47
- "effect": "4.0.0-rc.112",
48
- "foldkit": "0.158.2",
47
+ "@effect/platform-browser": "4.0.0-rc.116",
48
+ "@foldkit/ui": "0.163.0",
49
+ "effect": "4.0.0-rc.116",
50
+ "foldkit": "0.163.0",
49
51
  "tsdown": "^0.23.0",
50
52
  "typescript": "5.9.3",
51
- "foldkit-mixins": "0.3.0",
52
- "foldkit-mixins-ui": "0.3.0",
53
- "foldkit-surface": "0.4.0"
53
+ "foldkit-mixins": "0.5.0",
54
+ "foldkit-mixins-ui": "0.5.0",
55
+ "foldkit-surface": "0.5.1"
54
56
  },
55
57
  "scripts": {
56
58
  "build": "tsdown",