-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8abb49
commit f0539a5
Showing
13 changed files
with
325 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { IMachine } from './core' | ||
|
||
export function isDisabled<Event, State, Message, Transformed, SubState, Final>( | ||
machine: IMachine<Event, State, Message, Transformed, SubState, Final>, | ||
transformed: Transformed, | ||
event: Event, | ||
) { | ||
let touched = false | ||
const res = machine.reducer(event, transformed, () => { | ||
touched = true | ||
}) | ||
return !touched && res === undefined | ||
} | ||
|
||
export function nextState<Event, State, Message, Transformed, SubState, Final>( | ||
machine: IMachine<Event, State, Message, Transformed, SubState, Final>, | ||
transformed: Transformed, | ||
event: Event, | ||
) { | ||
const nextState = machine.reducer(event, transformed, () => {}) | ||
if (nextState === undefined) return transformed | ||
return machine.transform(nextState) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"name": "@constellar/react", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/prncss-xyz/constellar.git" | ||
}, | ||
"keywords": [ | ||
"react", | ||
"optics", | ||
"state" | ||
], | ||
"private": false, | ||
"type": "module", | ||
"version": "2.2.4", | ||
"description": "", | ||
"main": "dist/index.cjs", | ||
"module": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"scripts": { | ||
"dev:test": "vitest watch", | ||
"build": "tsc -p ./tsconfig.json && vite build", | ||
"test:unit": "vitest run", | ||
"test:coverage": "vitest run --coverage", | ||
"test:lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix", | ||
"test:types": "tsc --noEmit", | ||
"format": "prettier --write ./src" | ||
}, | ||
"author": "Juliette Lamarche", | ||
"license": "MIT", | ||
"peerDependencies": { | ||
"@constellar/core": "workspace:^", | ||
"react": ">=18.0.0" | ||
}, | ||
"devDependencies": { | ||
"@testing-library/dom": "^10.4.0", | ||
"@testing-library/react": "^16.0.0", | ||
"@types/node": "^22.2.0", | ||
"@types/react": "^18.3.3", | ||
"@vitest/coverage-v8": "^2.0.5", | ||
"jsdom": "^24.1.1", | ||
"react": "18", | ||
"react-dom": "18", | ||
"vite": "^5.4.0", | ||
"vite-plugin-dts": "^4.0.2", | ||
"vitest": "^2.0.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './machine' | ||
export * from './optics' |
Oops, something went wrong.