@fieldtripjs/react 0.1.0 → 0.2.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.
@@ -14,6 +14,7 @@ export interface FlowController<FL extends AnyFlow> {
14
14
  readonly state: FlowState<FL>;
15
15
  readonly step: StepName<FL>;
16
16
  readonly path: readonly StepName<FL>[];
17
+ readonly forecast: readonly StepName<FL>[];
17
18
  readonly values: FlowValues<FL>;
18
19
  readonly inputs: Readonly<Record<string, unknown>>;
19
20
  readonly issues: FieldIssues;
package/dist/use-flow.js CHANGED
@@ -1,4 +1,4 @@
1
- import { back as backState, next as nextState, path as pathOf, result, setInputs, start, visibleFields as visibleFieldsOf, } from "@fieldtripjs/core";
1
+ import { back as backState, forecast as forecastOf, next as nextState, path as pathOf, result, setInputs, start, visibleFields as visibleFieldsOf, } from "@fieldtripjs/core";
2
2
  import { useCallback, useEffect, useMemo, useRef, useState } from "react";
3
3
  export function useFlow(flow, options = {}) {
4
4
  const [state, setState] = useState(() => options.initialState ?? start(flow));
@@ -48,6 +48,7 @@ export function useFlow(flow, options = {}) {
48
48
  }, [flow, commit]);
49
49
  const inputs = state.inputs[state.current] ?? {};
50
50
  const visibleFields = useMemo(() => visibleFieldsOf(flow, state), [flow, state]);
51
+ const forecast = useMemo(() => forecastOf(flow, state), [flow, state]);
51
52
  const field = useCallback((name) => ({
52
53
  name,
53
54
  value: inputs[name],
@@ -59,6 +60,7 @@ export function useFlow(flow, options = {}) {
59
60
  state,
60
61
  step: state.current,
61
62
  path: pathOf(state),
63
+ forecast,
62
64
  values: result(flow, state),
63
65
  inputs,
64
66
  issues,
@@ -71,5 +73,5 @@ export function useFlow(flow, options = {}) {
71
73
  next,
72
74
  back,
73
75
  reset,
74
- }), [flow, state, inputs, issues, visibleFields, isPending, setInput, field, next, back, reset]);
76
+ }), [flow, state, forecast, inputs, issues, visibleFields, isPending, setInput, field, next, back, reset]);
75
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fieldtripjs/react",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Headless React bindings for @fieldtripjs/core.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -25,7 +25,7 @@
25
25
  "react": ">=18"
26
26
  },
27
27
  "dependencies": {
28
- "@fieldtripjs/core": "0.1.0"
28
+ "@fieldtripjs/core": "0.2.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@testing-library/react": "^16.3.3",