@myriadcodelabs/uiflow 0.2.1 → 0.2.2

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.
@@ -168,31 +168,37 @@ type Props = {
168
168
  ```ts
169
169
  import { defineFlow } from "@myriadcodelabs/uiflow";
170
170
 
171
- type Data = {
171
+ type DomainData = {
172
172
  deckId: string;
173
+ };
174
+
175
+ type InternalData = {
173
176
  cards: CardState[];
174
177
  activeCardId: string | null;
175
178
  };
176
179
 
177
- export const flow = defineFlow<Data>(
180
+ export const flow = defineFlow<DomainData, InternalData>(
178
181
  {
179
182
  fetchCards: {
180
- input: (data) => ({ deckId: data.deckId }),
181
- action: async ({ deckId }, data) => {
183
+ input: (domain) => ({ deckId: domain.deckId }),
184
+ action: async ({ deckId }, _domain, internal) => {
182
185
  const cards = await fetchCardsAction(deckId);
183
- data.cards = cards ?? [];
184
- data.activeCardId = null;
186
+ internal.cards = cards ?? [];
187
+ internal.activeCardId = null;
185
188
  return { ok: true };
186
189
  },
187
190
  onOutput: () => "study",
188
191
  },
189
192
 
190
193
  study: {
191
- input: (data) => ({ cards: data.cards, activeCardId: data.activeCardId }),
194
+ input: (_domain, internal) => ({
195
+ cards: internal.cards,
196
+ activeCardId: internal.activeCardId,
197
+ }),
192
198
  view: StudyView,
193
- onOutput: (data, output, events) => {
199
+ onOutput: (_domain, internal, output, events) => {
194
200
  if (output.action === "flip") {
195
- data.activeCardId = output.cardId;
201
+ internal.activeCardId = output.cardId;
196
202
  return "study";
197
203
  }
198
204
  if (output.action === "next") {
@@ -202,7 +208,13 @@ export const flow = defineFlow<Data>(
202
208
  },
203
209
  },
204
210
  },
205
- { start: "fetchCards" }
211
+ {
212
+ start: "fetchCards",
213
+ createInternalData: () => ({
214
+ cards: [],
215
+ activeCardId: null,
216
+ }),
217
+ }
206
218
  );
207
219
  ```
208
220
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myriadcodelabs/uiflow",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Explicit, code-first UI flow orchestration for React.",
5
5
  "bin": {
6
6
  "uiflow": "./scripts/uiflow-cli.cjs"