functype-react 1.0.1 → 1.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # functype-react
2
2
 
3
- React bindings for the [functype](../functype) functional programming library — ADT-aware hooks and exhaustive pattern matching components.
3
+ React bindings for the [functype](https://github.com/jordanburke/functype) functional programming library — ADT-aware hooks and exhaustive pattern matching components.
4
4
 
5
5
  ## Thesis
6
6
 
@@ -27,4 +27,4 @@ declare const tagEq: Eq<unknown>;
27
27
  declare const structuralEq: Eq<unknown>;
28
28
  //#endregion
29
29
  export { tagEq as i, referenceEq as n, structuralEq as r, Eq as t };
30
- //# sourceMappingURL=eq-DRsa9bDd.d.ts.map
30
+ //# sourceMappingURL=eq-CK6oQqWG.d.ts.map
@@ -1,2 +1,2 @@
1
- import { i as tagEq, n as referenceEq, r as structuralEq, t as Eq } from "../eq-DRsa9bDd.js";
1
+ import { i as tagEq, n as referenceEq, r as structuralEq, t as Eq } from "../eq-CK6oQqWG.js";
2
2
  export { Eq, referenceEq, structuralEq, tagEq };
@@ -1,10 +1,10 @@
1
- import { i as tagEq, n as referenceEq, r as structuralEq, t as Eq } from "../eq-DRsa9bDd.js";
2
- import { t as useEither } from "../useEither-CNHDdbY0.js";
3
- import { t as useList } from "../useList-DDjSWoK3.js";
4
- import { t as useOption } from "../useOption-zK_MCd_z.js";
5
- import { t as useStableCallback } from "../useStableCallback-C4--2sM1.js";
6
- import { t as useStableEffect } from "../useStableEffect-DrXoz7gH.js";
7
- import { t as useStableMemo } from "../useStableMemo-2dH3cBpb.js";
8
- import { t as useStableState } from "../useStableState-yar7Urk-.js";
9
- import { t as useTry } from "../useTry-CQb5RL6r.js";
1
+ import { i as tagEq, n as referenceEq, r as structuralEq, t as Eq } from "../eq-CK6oQqWG.js";
2
+ import { t as useEither } from "../useEither-BtjexxmJ.js";
3
+ import { t as useList } from "../useList-DuZ4s_ax.js";
4
+ import { t as useOption } from "../useOption-7xTC5RY_.js";
5
+ import { t as useStableCallback } from "../useStableCallback-BK2Li2tM.js";
6
+ import { t as useStableEffect } from "../useStableEffect-sr_ERDtZ.js";
7
+ import { t as useStableMemo } from "../useStableMemo-INplGjSx.js";
8
+ import { t as useStableState } from "../useStableState-DyW-KdNX.js";
9
+ import { t as useTry } from "../useTry-lTpoF5Qy.js";
10
10
  export { type Eq, referenceEq, structuralEq, tagEq, useEither, useList, useOption, useStableCallback, useStableEffect, useStableMemo, useStableState, useTry };
@@ -1,2 +1,2 @@
1
- import { t as useEither } from "../useEither-CNHDdbY0.js";
1
+ import { t as useEither } from "../useEither-BtjexxmJ.js";
2
2
  export { useEither };
@@ -1,2 +1,2 @@
1
- import { t as useList } from "../useList-DDjSWoK3.js";
1
+ import { t as useList } from "../useList-DuZ4s_ax.js";
2
2
  export { useList };
@@ -1,2 +1,2 @@
1
- import { t as useOption } from "../useOption-zK_MCd_z.js";
1
+ import { t as useOption } from "../useOption-7xTC5RY_.js";
2
2
  export { useOption };
@@ -1,2 +1,2 @@
1
- import { t as useStableCallback } from "../useStableCallback-C4--2sM1.js";
1
+ import { t as useStableCallback } from "../useStableCallback-BK2Li2tM.js";
2
2
  export { useStableCallback };
@@ -1,2 +1,2 @@
1
- import { t as useStableEffect } from "../useStableEffect-DrXoz7gH.js";
1
+ import { t as useStableEffect } from "../useStableEffect-sr_ERDtZ.js";
2
2
  export { useStableEffect };
@@ -1,2 +1,2 @@
1
- import { t as useStableMemo } from "../useStableMemo-2dH3cBpb.js";
1
+ import { t as useStableMemo } from "../useStableMemo-INplGjSx.js";
2
2
  export { useStableMemo };
@@ -1,2 +1,2 @@
1
- import { t as useStableState } from "../useStableState-yar7Urk-.js";
1
+ import { t as useStableState } from "../useStableState-DyW-KdNX.js";
2
2
  export { useStableState };
@@ -1,2 +1,2 @@
1
- import { t as useTry } from "../useTry-CQb5RL6r.js";
1
+ import { t as useTry } from "../useTry-lTpoF5Qy.js";
2
2
  export { useTry };
@@ -70,4 +70,4 @@ declare function MatchTry<A>(props: {
70
70
  }): ReactElement;
71
71
  //#endregion
72
72
  export { MatchCases as a, Match as i, MatchOption as n, MatchEither as r, MatchTry as t };
73
- //# sourceMappingURL=index-zHf9iM1m.d.ts.map
73
+ //# sourceMappingURL=index-B1wI3pNy.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- import { i as tagEq, n as referenceEq, r as structuralEq, t as Eq } from "./eq-DRsa9bDd.js";
2
- import { t as useEither } from "./useEither-CNHDdbY0.js";
3
- import { t as useList } from "./useList-DDjSWoK3.js";
4
- import { t as useOption } from "./useOption-zK_MCd_z.js";
5
- import { t as useStableCallback } from "./useStableCallback-C4--2sM1.js";
6
- import { t as useStableEffect } from "./useStableEffect-DrXoz7gH.js";
7
- import { t as useStableMemo } from "./useStableMemo-2dH3cBpb.js";
8
- import { t as useStableState } from "./useStableState-yar7Urk-.js";
9
- import { t as useTry } from "./useTry-CQb5RL6r.js";
10
- import { a as MatchCases, i as Match, n as MatchOption, r as MatchEither, t as MatchTry } from "./index-zHf9iM1m.js";
1
+ import { i as tagEq, n as referenceEq, r as structuralEq, t as Eq } from "./eq-CK6oQqWG.js";
2
+ import { t as useEither } from "./useEither-BtjexxmJ.js";
3
+ import { t as useList } from "./useList-DuZ4s_ax.js";
4
+ import { t as useOption } from "./useOption-7xTC5RY_.js";
5
+ import { t as useStableCallback } from "./useStableCallback-BK2Li2tM.js";
6
+ import { t as useStableEffect } from "./useStableEffect-sr_ERDtZ.js";
7
+ import { t as useStableMemo } from "./useStableMemo-INplGjSx.js";
8
+ import { t as useStableState } from "./useStableState-DyW-KdNX.js";
9
+ import { t as useTry } from "./useTry-lTpoF5Qy.js";
10
+ import { a as MatchCases, i as Match, n as MatchOption, r as MatchEither, t as MatchTry } from "./index-B1wI3pNy.js";
11
11
  export { type Eq, Match, type MatchCases, MatchEither, MatchOption, MatchTry, referenceEq, structuralEq, tagEq, useEither, useList, useOption, useStableCallback, useStableEffect, useStableMemo, useStableState, useTry };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{referenceEq as e,structuralEq as t,tagEq as n}from"./hooks/eq.js";import{useEither as r}from"./hooks/useEither.js";import{useList as i}from"./hooks/useList.js";import{useOption as a}from"./hooks/useOption.js";import{useStableCallback as o}from"./hooks/useStableCallback.js";import{useStableEffect as s}from"./hooks/useStableEffect.js";import{useStableMemo as c}from"./hooks/useStableMemo.js";import{useStableState as l}from"./hooks/useStableState.js";import{useTry as u}from"./hooks/useTry.js";import"./hooks/index.js";import{i as d,n as f,r as p,t as m}from"./match-imuIisms.js";export{d as Match,p as MatchEither,f as MatchOption,m as MatchTry,e as referenceEq,t as structuralEq,n as tagEq,r as useEither,i as useList,a as useOption,o as useStableCallback,s as useStableEffect,c as useStableMemo,l as useStableState,u as useTry};
1
+ import{referenceEq as e,structuralEq as t,tagEq as n}from"./hooks/eq.js";import{useEither as r}from"./hooks/useEither.js";import{useList as i}from"./hooks/useList.js";import{useOption as a}from"./hooks/useOption.js";import{useStableCallback as o}from"./hooks/useStableCallback.js";import{useStableEffect as s}from"./hooks/useStableEffect.js";import{useStableMemo as c}from"./hooks/useStableMemo.js";import{useStableState as l}from"./hooks/useStableState.js";import{useTry as u}from"./hooks/useTry.js";import"./hooks/index.js";import{i as d,n as f,r as p,t as m}from"./match-4aBdbQyD.js";export{d as Match,p as MatchEither,f as MatchOption,m as MatchTry,e as referenceEq,t as structuralEq,n as tagEq,r as useEither,i as useList,a as useOption,o as useStableCallback,s as useStableEffect,c as useStableMemo,l as useStableState,u as useTry};
@@ -1,2 +1,2 @@
1
- import { a as MatchCases, i as Match, n as MatchOption, r as MatchEither, t as MatchTry } from "../index-zHf9iM1m.js";
1
+ import { a as MatchCases, i as Match, n as MatchOption, r as MatchEither, t as MatchTry } from "../index-B1wI3pNy.js";
2
2
  export { Match, type MatchCases, MatchEither, MatchOption, MatchTry };
@@ -1 +1 @@
1
- import{i as e,n as t,r as n,t as r}from"../match-imuIisms.js";export{e as Match,n as MatchEither,t as MatchOption,r as MatchTry};
1
+ import{i as e,n as t,r as n,t as r}from"../match-4aBdbQyD.js";export{e as Match,n as MatchEither,t as MatchOption,r as MatchTry};
@@ -1,2 +1,2 @@
1
1
  import{Fragment as e,jsx as t}from"react/jsx-runtime";function n(n){let r=n.children[n.value._tag];return t(e,{children:r(n.value)})}function r(n){return t(e,{children:n.value.fold(n.Left,n.Right)})}function i(n){return t(e,{children:n.value.fold(n.None,n.Some)})}function a(n){return t(e,{children:n.value.fold(n.Failure,n.Success)})}export{n as i,i as n,r,a as t};
2
- //# sourceMappingURL=match-imuIisms.js.map
2
+ //# sourceMappingURL=match-4aBdbQyD.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"match-imuIisms.js","names":[],"sources":["../src/match/Match.tsx","../src/match/MatchEither.tsx","../src/match/MatchOption.tsx","../src/match/MatchTry.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from \"react\"\n\n/**\n * Maps each `_tag` literal to a handler that receives the narrowed variant.\n *\n * TypeScript enforces exhaustiveness: omitting a case from `children` is a\n * compile error.\n */\nexport type MatchCases<U extends { _tag: string }> = {\n readonly [K in U[\"_tag\"]]: (value: Extract<U, { readonly _tag: K }>) => ReactNode\n}\n\n/**\n * Generic discriminated-union matcher for ADTs that follow functype's `_tag`\n * convention. Pass a value and a record of handlers keyed on each tag; the\n * matching handler is invoked with the narrowed variant.\n *\n * ```tsx\n * <Match value={state}>\n * {{\n * Loading: () => <Spinner />,\n * Success: ({ data }) => <Result data={data} />,\n * Failure: ({ error }) => <Err err={error} />,\n * }}\n * </Match>\n * ```\n */\nexport function Match<U extends { _tag: string }>(props: {\n readonly value: U\n readonly children: MatchCases<U>\n}): ReactElement {\n const handler = props.children[props.value._tag as U[\"_tag\"]] as (value: U) => ReactNode\n return <>{handler(props.value)}</>\n}\n","import type { Either } from \"functype/either\"\nimport type { ReactElement, ReactNode } from \"react\"\n\n/**\n * Tag-narrowed sugar over `Match` for `Either<L, R>`.\n */\nexport function MatchEither<L, R>(props: {\n readonly value: Either<L, R>\n readonly Left: (l: L) => ReactNode\n readonly Right: (r: R) => ReactNode\n}): ReactElement {\n return <>{props.value.fold(props.Left, props.Right)}</>\n}\n","import type { Option } from \"functype/option\"\nimport type { ReactElement, ReactNode } from \"react\"\n\n/**\n * Tag-narrowed sugar over `Match` for `Option<A>`. Renders `Some(a)` to the\n * `Some` handler and `None` to the `None` handler.\n */\nexport function MatchOption<A>(props: {\n readonly value: Option<A>\n readonly Some: (a: A) => ReactNode\n readonly None: () => ReactNode\n}): ReactElement {\n return <>{props.value.fold(props.None, props.Some)}</>\n}\n","import type { Try } from \"functype/try\"\nimport type { ReactElement, ReactNode } from \"react\"\n\n/**\n * Tag-narrowed sugar over `Match` for `Try<A>`. `Failure` receives the\n * underlying `Error`; `Success` receives the value.\n */\nexport function MatchTry<A>(props: {\n readonly value: Try<A>\n readonly Success: (a: A) => ReactNode\n readonly Failure: (e: Error) => ReactNode\n}): ReactElement {\n return <>{props.value.fold(props.Failure, props.Success)}</>\n}\n"],"mappings":"sDA2BA,SAAgB,EAAkC,EAGjC,CACf,IAAM,EAAU,EAAM,SAAS,EAAM,MAAM,MAC3C,OAAO,EAAA,EAAA,CAAA,SAAG,EAAQ,EAAM,KAAK,CAAI,CAAA,CACnC,CC3BA,SAAgB,EAAkB,EAIjB,CACf,OAAO,EAAA,EAAA,CAAA,SAAG,EAAM,MAAM,KAAK,EAAM,KAAM,EAAM,KAAK,CAAI,CAAA,CACxD,CCLA,SAAgB,EAAe,EAId,CACf,OAAO,EAAA,EAAA,CAAA,SAAG,EAAM,MAAM,KAAK,EAAM,KAAM,EAAM,IAAI,CAAI,CAAA,CACvD,CCNA,SAAgB,EAAY,EAIX,CACf,OAAO,EAAA,EAAA,CAAA,SAAG,EAAM,MAAM,KAAK,EAAM,QAAS,EAAM,OAAO,CAAI,CAAA,CAC7D"}
1
+ {"version":3,"file":"match-4aBdbQyD.js","names":[],"sources":["../src/match/Match.tsx","../src/match/MatchEither.tsx","../src/match/MatchOption.tsx","../src/match/MatchTry.tsx"],"sourcesContent":["import type { ReactElement, ReactNode } from \"react\"\n\n/**\n * Maps each `_tag` literal to a handler that receives the narrowed variant.\n *\n * TypeScript enforces exhaustiveness: omitting a case from `children` is a\n * compile error.\n */\nexport type MatchCases<U extends { _tag: string }> = {\n readonly [K in U[\"_tag\"]]: (value: Extract<U, { readonly _tag: K }>) => ReactNode\n}\n\n/**\n * Generic discriminated-union matcher for ADTs that follow functype's `_tag`\n * convention. Pass a value and a record of handlers keyed on each tag; the\n * matching handler is invoked with the narrowed variant.\n *\n * ```tsx\n * <Match value={state}>\n * {{\n * Loading: () => <Spinner />,\n * Success: ({ data }) => <Result data={data} />,\n * Failure: ({ error }) => <Err err={error} />,\n * }}\n * </Match>\n * ```\n */\nexport function Match<U extends { _tag: string }>(props: {\n readonly value: U\n readonly children: MatchCases<U>\n}): ReactElement {\n const handler = props.children[props.value._tag as U[\"_tag\"]] as (value: U) => ReactNode\n return <>{handler(props.value)}</>\n}\n","import type { Either } from \"functype/either\"\nimport type { ReactElement, ReactNode } from \"react\"\n\n/**\n * Tag-narrowed sugar over `Match` for `Either<L, R>`.\n */\nexport function MatchEither<L, R>(props: {\n readonly value: Either<L, R>\n readonly Left: (l: L) => ReactNode\n readonly Right: (r: R) => ReactNode\n}): ReactElement {\n return <>{props.value.fold(props.Left, props.Right)}</>\n}\n","import type { Option } from \"functype/option\"\nimport type { ReactElement, ReactNode } from \"react\"\n\n/**\n * Tag-narrowed sugar over `Match` for `Option<A>`. Renders `Some(a)` to the\n * `Some` handler and `None` to the `None` handler.\n */\nexport function MatchOption<A>(props: {\n readonly value: Option<A>\n readonly Some: (a: A) => ReactNode\n readonly None: () => ReactNode\n}): ReactElement {\n return <>{props.value.fold(props.None, props.Some)}</>\n}\n","import type { Try } from \"functype/try\"\nimport type { ReactElement, ReactNode } from \"react\"\n\n/**\n * Tag-narrowed sugar over `Match` for `Try<A>`. `Failure` receives the\n * underlying `Error`; `Success` receives the value.\n */\nexport function MatchTry<A>(props: {\n readonly value: Try<A>\n readonly Success: (a: A) => ReactNode\n readonly Failure: (e: Error) => ReactNode\n}): ReactElement {\n return <>{props.value.fold(props.Failure, props.Success)}</>\n}\n"],"mappings":"sDA2BA,SAAgB,EAAkC,EAGjC,CACf,IAAM,EAAU,EAAM,SAAS,EAAM,MAAM,MAC3C,OAAO,EAAA,EAAA,CAAA,SAAG,EAAQ,EAAM,KAAK,CAAI,CAAA,CACnC,CC3BA,SAAgB,EAAkB,EAIjB,CACf,OAAO,EAAA,EAAA,CAAA,SAAG,EAAM,MAAM,KAAK,EAAM,KAAM,EAAM,KAAK,CAAI,CAAA,CACxD,CCLA,SAAgB,EAAe,EAId,CACf,OAAO,EAAA,EAAA,CAAA,SAAG,EAAM,MAAM,KAAK,EAAM,KAAM,EAAM,IAAI,CAAI,CAAA,CACvD,CCNA,SAAgB,EAAY,EAIX,CACf,OAAO,EAAA,EAAA,CAAA,SAAG,EAAM,MAAM,KAAK,EAAM,QAAS,EAAM,OAAO,CAAI,CAAA,CAC7D"}
@@ -12,4 +12,4 @@ declare function useEither<E, A>(initial?: Either<E, A>): {
12
12
  };
13
13
  //#endregion
14
14
  export { useEither as t };
15
- //# sourceMappingURL=useEither-CNHDdbY0.d.ts.map
15
+ //# sourceMappingURL=useEither-BtjexxmJ.d.ts.map
@@ -15,4 +15,4 @@ declare function useList<A>(initial?: readonly A[]): {
15
15
  };
16
16
  //#endregion
17
17
  export { useList as t };
18
- //# sourceMappingURL=useList-DDjSWoK3.d.ts.map
18
+ //# sourceMappingURL=useList-DuZ4s_ax.d.ts.map
@@ -13,4 +13,4 @@ declare function useOption<A>(initial?: A): {
13
13
  };
14
14
  //#endregion
15
15
  export { useOption as t };
16
- //# sourceMappingURL=useOption-zK_MCd_z.d.ts.map
16
+ //# sourceMappingURL=useOption-7xTC5RY_.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as Eq } from "./eq-DRsa9bDd.js";
1
+ import { t as Eq } from "./eq-CK6oQqWG.js";
2
2
  import { DependencyList } from "react";
3
3
 
4
4
  //#region src/hooks/useStableCallback.d.ts
@@ -9,4 +9,4 @@ import { DependencyList } from "react";
9
9
  declare function useStableCallback<F extends (...args: never[]) => unknown>(callback: F, deps: DependencyList, eqs?: ReadonlyArray<Eq<unknown> | undefined>): F;
10
10
  //#endregion
11
11
  export { useStableCallback as t };
12
- //# sourceMappingURL=useStableCallback-C4--2sM1.d.ts.map
12
+ //# sourceMappingURL=useStableCallback-BK2Li2tM.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as Eq } from "./eq-DRsa9bDd.js";
1
+ import { t as Eq } from "./eq-CK6oQqWG.js";
2
2
  import { DependencyList, EffectCallback } from "react";
3
3
 
4
4
  //#region src/hooks/useStableEffect.d.ts
@@ -13,4 +13,4 @@ import { DependencyList, EffectCallback } from "react";
13
13
  declare function useStableEffect(effect: EffectCallback, deps: DependencyList, eqs?: ReadonlyArray<Eq<unknown> | undefined>): void;
14
14
  //#endregion
15
15
  export { useStableEffect as t };
16
- //# sourceMappingURL=useStableEffect-DrXoz7gH.d.ts.map
16
+ //# sourceMappingURL=useStableEffect-sr_ERDtZ.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as Eq } from "./eq-DRsa9bDd.js";
1
+ import { t as Eq } from "./eq-CK6oQqWG.js";
2
2
  import { DependencyList } from "react";
3
3
 
4
4
  //#region src/hooks/useStableMemo.d.ts
@@ -10,4 +10,4 @@ import { DependencyList } from "react";
10
10
  declare function useStableMemo<A>(factory: () => A, deps: DependencyList, eqs?: ReadonlyArray<Eq<unknown> | undefined>): A;
11
11
  //#endregion
12
12
  export { useStableMemo as t };
13
- //# sourceMappingURL=useStableMemo-2dH3cBpb.d.ts.map
13
+ //# sourceMappingURL=useStableMemo-INplGjSx.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as Eq } from "./eq-DRsa9bDd.js";
1
+ import { t as Eq } from "./eq-CK6oQqWG.js";
2
2
 
3
3
  //#region src/hooks/useStableState.d.ts
4
4
  /**
@@ -12,4 +12,4 @@ import { t as Eq } from "./eq-DRsa9bDd.js";
12
12
  declare function useStableState<A>(initial: A | (() => A), eq?: Eq<A>): readonly [A, (next: A | ((prev: A) => A)) => void];
13
13
  //#endregion
14
14
  export { useStableState as t };
15
- //# sourceMappingURL=useStableState-yar7Urk-.d.ts.map
15
+ //# sourceMappingURL=useStableState-DyW-KdNX.d.ts.map
@@ -12,4 +12,4 @@ declare function useTry<A>(initial?: Try<A>): {
12
12
  };
13
13
  //#endregion
14
14
  export { useTry as t };
15
- //# sourceMappingURL=useTry-CQb5RL6r.d.ts.map
15
+ //# sourceMappingURL=useTry-lTpoF5Qy.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functype-react",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "React bindings for functype — ADT-aware hooks and exhaustive pattern matching components",
5
5
  "keywords": [
6
6
  "functype",
@@ -17,6 +17,9 @@
17
17
  "author": "jordan.burke@gmail.com",
18
18
  "license": "MIT",
19
19
  "homepage": "https://github.com/jordanburke/functype/tree/main/packages/functype-react",
20
+ "bugs": {
21
+ "url": "https://github.com/jordanburke/functype/issues"
22
+ },
20
23
  "repository": {
21
24
  "type": "git",
22
25
  "url": "https://github.com/jordanburke/functype",
@@ -44,8 +47,8 @@
44
47
  "react": "^19.2.6",
45
48
  "react-dom": "^19.2.6",
46
49
  "ts-builds": "^2.8.1",
47
- "tsdown": "^0.22.0",
48
- "functype": "^1.0.1"
50
+ "tsdown": "^0.22.1",
51
+ "functype": "^1.2.0"
49
52
  },
50
53
  "type": "module",
51
54
  "main": "./dist/index.js",