Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bottom-sheet/react-hooks

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bottom-sheet/react-hooks - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

102

dist/cjs/index.js

@@ -0,23 +1,97 @@

var $dYZEH$react = require("react");
var $dYZEH$xstate = require("xstate");
var $dYZEH$usesyncexternalstoreshim = require("use-sync-external-store/shim");
var $dYZEH$bottomsheetstatemachine = require("@bottom-sheet/state-machine");
function $parcel$exportWildcard(dest, source) {
Object.keys(source).forEach(function(key) {
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) {
return;
}
function $parcel$export(e, n, v, s) {
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
}
Object.defineProperty(dest, key, {
enumerable: true,
get: function get() {
return source[key];
}
});
});
$parcel$export(module.exports, "useBottomSheetMachine", () => $882b6d93070905b3$export$a93bae334d1de14f);
return dest;
function $882b6d93070905b3$var$createStore() {
const service = $dYZEH$xstate.interpret($dYZEH$bottomsheetstatemachine.BottomSheetMachine);
const matches = (parentStateValue)=>service.initialized ? service.state.matches(parentStateValue) : service.initialState.matches(parentStateValue)
;
return {
subscribe: (onStoreChange)=>{
console.log('subscribe called!');
service.onTransition((state)=>{
// @TODO: flesh out the logic for when to notify react of state changes or not (as state updates can be expensive and we should be transient when possible)
if (state.changed) onStoreChange();
});
service.start();
return ()=>void service.stop()
;
},
getInitialized () {
return service.initialized;
},
getSnapshot: ()=>service.initialized ? service.state : service.initialState
,
matches: matches,
dispatch (event) {
return service.send(event);
}
};
}
const $882b6d93070905b3$var$store = $882b6d93070905b3$var$createStore();
function $882b6d93070905b3$export$a93bae334d1de14f() {
/*
// useState lets us create the store exactly once, which is a guarantee that useMemo doesn't provide
const [store] = useState(() => {
const service = interpret(BottomSheetMachine)
const matches: typeof service.state.matches = (parentStateValue) =>
service.initialized
? service.state.matches(parentStateValue)
: service.initialState.matches(parentStateValue)
$parcel$exportWildcard(module.exports, $dYZEH$bottomsheetstatemachine);
return {
subscribe: (onStoreChange: () => void) => {
console.log('subscribe called!')
service.onTransition((state) => {
// @TODO: flesh out the logic for when to notify react of state changes or not (as state updates can be expensive and we should be transient when possible)
if (state.changed) {
onStoreChange()
}
})
service.start()
return () => void service.stop()
},
getInitialized() {
return service.initialized
},
getSnapshot: () =>
service.initialized ? service.state : service.initialState,
matches,
dispatch(event: BottomSheetEvent) {
return service.send(event)
},
}
})
// */ const state = $dYZEH$usesyncexternalstoreshim.useSyncExternalStore($882b6d93070905b3$var$store.subscribe, $882b6d93070905b3$var$store.getSnapshot);
/*
const [inc, tick] = useState(0)
useEffect(() => {
const unsubscribe = store.subscribe(() => tick((inc) => ++inc))
return () => unsubscribe()
}, [])
// */ return $dYZEH$react.useMemo(()=>({
context: state.context,
getSnapshot: $882b6d93070905b3$var$store.getSnapshot,
dispatch: $882b6d93070905b3$var$store.dispatch,
matches: $882b6d93070905b3$var$store.matches,
get initialized () {
return $882b6d93070905b3$var$store.getInitialized();
}
})
, [
state.context
]);
}
//# sourceMappingURL=index.js.map

@@ -1,3 +0,28 @@

export * from '@bottom-sheet/state-machine';
import { BottomSheetEvent } from "@bottom-sheet/state-machine";
export function useBottomSheetMachine(): {
context: import("@bottom-sheet/state-machine").BottomSheetContext;
getSnapshot: () => import("xstate").State<import("@bottom-sheet/state-machine").BottomSheetContext, BottomSheetEvent, any, {
value: any;
context: import("@bottom-sheet/state-machine").BottomSheetContext;
}, import("xstate").ResolveTypegenMeta<import("@bottom-sheet/state-machine/dist/dts/index.typegen").Typegen0, BottomSheetEvent, import("xstate").BaseActionObject, import("xstate").ServiceMap>>;
dispatch: (event: BottomSheetEvent) => import("xstate").State<import("@bottom-sheet/state-machine").BottomSheetContext, BottomSheetEvent, any, {
value: any;
context: import("@bottom-sheet/state-machine").BottomSheetContext;
}, import("xstate").ResolveTypegenMeta<import("@bottom-sheet/state-machine/dist/dts/index.typegen").Typegen0, BottomSheetEvent, import("xstate").BaseActionObject, import("xstate").ServiceMap>>;
matches: {
<TSV extends "closed" | "open" | "open.initially" | "open.opening" | "open.opening.waiting" | "open.opening.autofocusing" | "open.opening.animating" | "open.resting" | "open.dragging" | "open.resizing" | "open.snapping" | "open.closing" | {
open?: "initially" | "opening" | "resting" | "dragging" | "resizing" | "snapping" | "closing" | {
opening?: "waiting" | "autofocusing" | "animating";
};
}>(parentStateValue: TSV): boolean;
<TSV_1 extends never>(parentStateValue: TSV_1): this is import("xstate").State<import("@bottom-sheet/state-machine").BottomSheetContext, BottomSheetEvent, any, {
value: any;
context: import("@bottom-sheet/state-machine").BottomSheetContext;
}, import("xstate").ResolveTypegenMeta<import("@bottom-sheet/state-machine/dist/dts/index.typegen").Typegen0, BottomSheetEvent, import("xstate").BaseActionObject, import("xstate").ServiceMap>> & {
value: TSV_1;
};
};
readonly initialized: boolean;
};
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,5 @@

import * as $26Zo0$bottomsheetstatemachine from "@bottom-sheet/state-machine";
import {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";

@@ -6,2 +9,86 @@

function $149c1bd638913645$var$createStore() {
const service = $26Zo0$interpret($26Zo0$BottomSheetMachine);
const matches = (parentStateValue)=>service.initialized ? service.state.matches(parentStateValue) : service.initialState.matches(parentStateValue)
;
return {
subscribe: (onStoreChange)=>{
console.log('subscribe called!');
service.onTransition((state)=>{
// @TODO: flesh out the logic for when to notify react of state changes or not (as state updates can be expensive and we should be transient when possible)
if (state.changed) onStoreChange();
});
service.start();
return ()=>void service.stop()
;
},
getInitialized () {
return service.initialized;
},
getSnapshot: ()=>service.initialized ? service.state : service.initialState
,
matches: matches,
dispatch (event) {
return service.send(event);
}
};
}
const $149c1bd638913645$var$store = $149c1bd638913645$var$createStore();
function $149c1bd638913645$export$a93bae334d1de14f() {
/*
// useState lets us create the store exactly once, which is a guarantee that useMemo doesn't provide
const [store] = useState(() => {
const service = interpret(BottomSheetMachine)
const matches: typeof service.state.matches = (parentStateValue) =>
service.initialized
? service.state.matches(parentStateValue)
: service.initialState.matches(parentStateValue)
return {
subscribe: (onStoreChange: () => void) => {
console.log('subscribe called!')
service.onTransition((state) => {
// @TODO: flesh out the logic for when to notify react of state changes or not (as state updates can be expensive and we should be transient when possible)
if (state.changed) {
onStoreChange()
}
})
service.start()
return () => void service.stop()
},
getInitialized() {
return service.initialized
},
getSnapshot: () =>
service.initialized ? service.state : service.initialState,
matches,
dispatch(event: BottomSheetEvent) {
return service.send(event)
},
}
})
// */ const state = $26Zo0$useSyncExternalStore($149c1bd638913645$var$store.subscribe, $149c1bd638913645$var$store.getSnapshot);
/*
const [inc, tick] = useState(0)
useEffect(() => {
const unsubscribe = store.subscribe(() => tick((inc) => ++inc))
return () => unsubscribe()
}, [])
// */ return $26Zo0$useMemo(()=>({
context: state.context,
getSnapshot: $149c1bd638913645$var$store.getSnapshot,
dispatch: $149c1bd638913645$var$store.dispatch,
matches: $149c1bd638913645$var$store.matches,
get initialized () {
return $149c1bd638913645$var$store.getInitialized();
}
})
, [
state.context
]);
}
export {$149c1bd638913645$export$a93bae334d1de14f as useBottomSheetMachine};
//# sourceMappingURL=index.js.map
{
"name": "@bottom-sheet/react-hooks",
"version": "1.0.0",
"version": "1.0.1",
"description": "The hooks that power `@bottom-sheet/react-spring`",

@@ -48,5 +48,17 @@ "keywords": [

},
"jest": {
"rootDir": ".",
"testEnvironment": "jsdom",
"transform": {
"^.+\\.(t|j)sx?$": [
"@swc/jest"
]
}
},
"dependencies": {
"@bottom-sheet/state-machine": "^1.0.4",
"@bottom-sheet/types": "^1.0.3"
"@bottom-sheet/types": "^1.0.3",
"@types/use-sync-external-store": "^0.0.3",
"use-sync-external-store": "^1.1.0",
"xstate": "^4.32.1"
},

@@ -60,4 +72,11 @@ "devDependencies": {

"@skypack/package-check": "^0.2.2",
"@swc/core": "^1.2.185",
"@swc/jest": "^0.2.21",
"@testing-library/react": "^13.2.0",
"@types/jest": "^27.5.1",
"@types/node": "^17.0.33",
"@types/react": "^18.0.9",
"@types/react-dom": "^18.0.4",
"@typescript-eslint/eslint-plugin": "^5.23.0",
"@typescript-eslint/parser": "^5.23.0",
"@xstate/cli": "^0.1.7",

@@ -70,6 +89,11 @@ "eslint": "^8.15.0",

"eslint-plugin-react": "^7.29.4",
"eslint-plugin-react-hooks": "^4.5.0",
"jest": "^28.1.0",
"jest-environment-jsdom": "^28.1.0",
"parcel": "^2.5.0",
"prettier": "^2.6.2",
"prettier-plugin-packagejson": "^2.2.18",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-test-renderer": "^18.1.0",
"rimraf": "^3.0.2",

@@ -80,2 +104,5 @@ "semantic-release": "^19.0.2",

},
"peerDependencies": {
"react": "17 || 18"
},
"publishConfig": {

@@ -82,0 +109,0 @@ "access": "public"

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc