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 +1 -1
- package/dist/{eq-DRsa9bDd.d.ts → eq-CK6oQqWG.d.ts} +1 -1
- package/dist/hooks/eq.d.ts +1 -1
- package/dist/hooks/index.d.ts +9 -9
- package/dist/hooks/useEither.d.ts +1 -1
- package/dist/hooks/useList.d.ts +1 -1
- package/dist/hooks/useOption.d.ts +1 -1
- package/dist/hooks/useStableCallback.d.ts +1 -1
- package/dist/hooks/useStableEffect.d.ts +1 -1
- package/dist/hooks/useStableMemo.d.ts +1 -1
- package/dist/hooks/useStableState.d.ts +1 -1
- package/dist/hooks/useTry.d.ts +1 -1
- package/dist/{index-zHf9iM1m.d.ts → index-B1wI3pNy.d.ts} +1 -1
- package/dist/index.d.ts +10 -10
- package/dist/index.js +1 -1
- package/dist/match/index.d.ts +1 -1
- package/dist/match/index.js +1 -1
- package/dist/{match-imuIisms.js → match-4aBdbQyD.js} +1 -1
- package/dist/{match-imuIisms.js.map → match-4aBdbQyD.js.map} +1 -1
- package/dist/{useEither-CNHDdbY0.d.ts → useEither-BtjexxmJ.d.ts} +1 -1
- package/dist/{useList-DDjSWoK3.d.ts → useList-DuZ4s_ax.d.ts} +1 -1
- package/dist/{useOption-zK_MCd_z.d.ts → useOption-7xTC5RY_.d.ts} +1 -1
- package/dist/{useStableCallback-C4--2sM1.d.ts → useStableCallback-BK2Li2tM.d.ts} +2 -2
- package/dist/{useStableEffect-DrXoz7gH.d.ts → useStableEffect-sr_ERDtZ.d.ts} +2 -2
- package/dist/{useStableMemo-2dH3cBpb.d.ts → useStableMemo-INplGjSx.d.ts} +2 -2
- package/dist/{useStableState-yar7Urk-.d.ts → useStableState-DyW-KdNX.d.ts} +2 -2
- package/dist/{useTry-CQb5RL6r.d.ts → useTry-lTpoF5Qy.d.ts} +1 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# functype-react
|
|
2
2
|
|
|
3
|
-
React bindings for the [functype](
|
|
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
|
|
package/dist/hooks/eq.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as tagEq, n as referenceEq, r as structuralEq, t as Eq } from "../eq-
|
|
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 };
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { i as tagEq, n as referenceEq, r as structuralEq, t as Eq } from "../eq-
|
|
2
|
-
import { t as useEither } from "../useEither-
|
|
3
|
-
import { t as useList } from "../useList-
|
|
4
|
-
import { t as useOption } from "../useOption-
|
|
5
|
-
import { t as useStableCallback } from "../useStableCallback-
|
|
6
|
-
import { t as useStableEffect } from "../useStableEffect-
|
|
7
|
-
import { t as useStableMemo } from "../useStableMemo-
|
|
8
|
-
import { t as useStableState } from "../useStableState-
|
|
9
|
-
import { t as useTry } from "../useTry-
|
|
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-
|
|
1
|
+
import { t as useEither } from "../useEither-BtjexxmJ.js";
|
|
2
2
|
export { useEither };
|
package/dist/hooks/useList.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as useList } from "../useList-
|
|
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-
|
|
1
|
+
import { t as useOption } from "../useOption-7xTC5RY_.js";
|
|
2
2
|
export { useOption };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as useStableCallback } from "../useStableCallback-
|
|
1
|
+
import { t as useStableCallback } from "../useStableCallback-BK2Li2tM.js";
|
|
2
2
|
export { useStableCallback };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as useStableEffect } from "../useStableEffect-
|
|
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-
|
|
1
|
+
import { t as useStableMemo } from "../useStableMemo-INplGjSx.js";
|
|
2
2
|
export { useStableMemo };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as useStableState } from "../useStableState-
|
|
1
|
+
import { t as useStableState } from "../useStableState-DyW-KdNX.js";
|
|
2
2
|
export { useStableState };
|
package/dist/hooks/useTry.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as useTry } from "../useTry-
|
|
1
|
+
import { t as useTry } from "../useTry-lTpoF5Qy.js";
|
|
2
2
|
export { useTry };
|
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-
|
|
2
|
-
import { t as useEither } from "./useEither-
|
|
3
|
-
import { t as useList } from "./useList-
|
|
4
|
-
import { t as useOption } from "./useOption-
|
|
5
|
-
import { t as useStableCallback } from "./useStableCallback-
|
|
6
|
-
import { t as useStableEffect } from "./useStableEffect-
|
|
7
|
-
import { t as useStableMemo } from "./useStableMemo-
|
|
8
|
-
import { t as useStableState } from "./useStableState-
|
|
9
|
-
import { t as useTry } from "./useTry-
|
|
10
|
-
import { a as MatchCases, i as Match, n as MatchOption, r as MatchEither, t as MatchTry } from "./index-
|
|
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-
|
|
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};
|
package/dist/match/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as MatchCases, i as Match, n as MatchOption, r as MatchEither, t as MatchTry } from "../index-
|
|
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 };
|
package/dist/match/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e,n as t,r as n,t as r}from"../match-
|
|
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-
|
|
2
|
+
//# sourceMappingURL=match-4aBdbQyD.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"match-
|
|
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"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Eq } from "./eq-
|
|
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-
|
|
12
|
+
//# sourceMappingURL=useStableCallback-BK2Li2tM.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Eq } from "./eq-
|
|
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-
|
|
16
|
+
//# sourceMappingURL=useStableEffect-sr_ERDtZ.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Eq } from "./eq-
|
|
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-
|
|
13
|
+
//# sourceMappingURL=useStableMemo-INplGjSx.d.ts.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as Eq } from "./eq-
|
|
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-
|
|
15
|
+
//# sourceMappingURL=useStableState-DyW-KdNX.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functype-react",
|
|
3
|
-
"version": "1.0
|
|
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.
|
|
48
|
-
"functype": "^1.0
|
|
50
|
+
"tsdown": "^0.22.1",
|
|
51
|
+
"functype": "^1.2.0"
|
|
49
52
|
},
|
|
50
53
|
"type": "module",
|
|
51
54
|
"main": "./dist/index.js",
|