@bottom-sheet/react-hooks
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -15,5 +15,11 @@ var $dYZEH$react = require("react"); | ||
function $882b6d93070905b3$var$createStore() { | ||
function $882b6d93070905b3$var$createStore({ initialHeight: initialHeight = (0, $dYZEH$bottomsheetstatemachine.defaultInitialHeight) , snapPoints: snapPoints = (0, $dYZEH$bottomsheetstatemachine.defaultSnapPoints) } = {}) { | ||
console.debug("createStore"); | ||
const service = (0, $dYZEH$xstate.interpret)((0, $dYZEH$bottomsheetstatemachine.BottomSheetMachine)); | ||
const service = (0, $dYZEH$xstate.interpret)((0, $dYZEH$bottomsheetstatemachine.BottomSheetMachine).withConfig({ | ||
actions: { | ||
setInitialHeight: (0, $dYZEH$bottomsheetstatemachine.assignInitialHeight)(initialHeight), | ||
setSnapPoints: (0, $dYZEH$bottomsheetstatemachine.assignSnapPoints)(snapPoints) | ||
} | ||
})); | ||
let snapshot = service.initialState; | ||
@@ -52,4 +58,4 @@ // transient is updated more frequently than the snapshot, outside of react render cycles | ||
} | ||
function $882b6d93070905b3$export$a93bae334d1de14f() { | ||
const [store] = (0, $dYZEH$react.useState)(()=>$882b6d93070905b3$var$createStore()); | ||
function $882b6d93070905b3$export$a93bae334d1de14f(props = {}) { | ||
const [store] = (0, $dYZEH$react.useState)(()=>$882b6d93070905b3$var$createStore(props)); | ||
/* | ||
@@ -56,0 +62,0 @@ // useState lets us create the store exactly once, which is a guarantee that useMemo doesn't provide |
import { BottomSheetEvent } from "@bottom-sheet/state-machine"; | ||
export function useBottomSheetMachine(): { | ||
import { GetInitialHeight, GetSnapPoints } from "@bottom-sheet/types"; | ||
export interface BottomSheetMachineProps { | ||
initialHeight?: GetInitialHeight; | ||
snapPoints?: GetSnapPoints; | ||
} | ||
export function useBottomSheetMachine(props?: BottomSheetMachineProps): { | ||
state: import("xstate").State<import("@bottom-sheet/state-machine").BottomSheetContext, BottomSheetEvent, any, { | ||
@@ -4,0 +9,0 @@ value: any; |
import {useState as $26Zo0$useState, useMemo as $26Zo0$useMemo} from "react"; | ||
import {interpret as $26Zo0$interpret} from "xstate"; | ||
import {useSyncExternalStore as $26Zo0$useSyncExternalStore} from "use-sync-external-store/shim"; | ||
import {BottomSheetMachine as $26Zo0$BottomSheetMachine} from "@bottom-sheet/state-machine"; | ||
import {defaultInitialHeight as $26Zo0$defaultInitialHeight, defaultSnapPoints as $26Zo0$defaultSnapPoints, BottomSheetMachine as $26Zo0$BottomSheetMachine, assignInitialHeight as $26Zo0$assignInitialHeight, assignSnapPoints as $26Zo0$assignSnapPoints} from "@bottom-sheet/state-machine"; | ||
@@ -10,5 +10,11 @@ | ||
function $149c1bd638913645$var$createStore() { | ||
function $149c1bd638913645$var$createStore({ initialHeight: initialHeight = (0, $26Zo0$defaultInitialHeight) , snapPoints: snapPoints = (0, $26Zo0$defaultSnapPoints) } = {}) { | ||
console.debug("createStore"); | ||
const service = (0, $26Zo0$interpret)((0, $26Zo0$BottomSheetMachine)); | ||
const service = (0, $26Zo0$interpret)((0, $26Zo0$BottomSheetMachine).withConfig({ | ||
actions: { | ||
setInitialHeight: (0, $26Zo0$assignInitialHeight)(initialHeight), | ||
setSnapPoints: (0, $26Zo0$assignSnapPoints)(snapPoints) | ||
} | ||
})); | ||
let snapshot = service.initialState; | ||
@@ -47,4 +53,4 @@ // transient is updated more frequently than the snapshot, outside of react render cycles | ||
} | ||
function $149c1bd638913645$export$a93bae334d1de14f() { | ||
const [store] = (0, $26Zo0$useState)(()=>$149c1bd638913645$var$createStore()); | ||
function $149c1bd638913645$export$a93bae334d1de14f(props = {}) { | ||
const [store] = (0, $26Zo0$useState)(()=>$149c1bd638913645$var$createStore(props)); | ||
/* | ||
@@ -51,0 +57,0 @@ // useState lets us create the store exactly once, which is a guarantee that useMemo doesn't provide |
{ | ||
"name": "@bottom-sheet/react-hooks", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "The hooks that power `@bottom-sheet/react-spring`", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
32315
220