@prismicio/slice-simulator-react
Advanced tools
Comparing version 0.2.2 to 0.2.3-alpha.0
import { SliceSimulatorState, SliceSimulatorProps as SliceSimulatorProps$1 } from '@prismicio/slice-simulator-core'; | ||
declare type SliceSimulatorProps = { | ||
type SliceSimulatorProps = { | ||
className?: string; | ||
@@ -5,0 +5,0 @@ sliceZone: (props: { |
@@ -6,22 +6,44 @@ import * as React from 'react'; | ||
const SliceSimulator = (props) => { | ||
var _a, _b; | ||
const defaultProps = getDefaultProps(); | ||
const [managedState, setManagedState] = React.useState(getDefaultManagedState()); | ||
const [managedState, setManagedState] = React.useState( | ||
getDefaultManagedState() | ||
); | ||
const [slices, setSlices] = React.useState(getDefaultSlices()); | ||
const [message, setMessage] = React.useState(getDefaultMessage()); | ||
React.useEffect(() => { | ||
coreManager.stateManager.on(StateManagerEventType.ManagedState, (_managedState) => { | ||
setManagedState(_managedState); | ||
}, "simulator-managed-state"); | ||
coreManager.stateManager.on(StateManagerEventType.Slices, (_slices) => { | ||
setSlices(_slices); | ||
}, "simulator-slices"); | ||
coreManager.stateManager.on(StateManagerEventType.Message, (_message) => { | ||
setMessage(_message); | ||
}, "simulator-message"); | ||
coreManager.stateManager.on( | ||
StateManagerEventType.ManagedState, | ||
(_managedState) => { | ||
setManagedState(_managedState); | ||
}, | ||
"simulator-managed-state" | ||
); | ||
coreManager.stateManager.on( | ||
StateManagerEventType.Slices, | ||
(_slices) => { | ||
setSlices(_slices); | ||
}, | ||
"simulator-slices" | ||
); | ||
coreManager.stateManager.on( | ||
StateManagerEventType.Message, | ||
(_message) => { | ||
setMessage(_message); | ||
}, | ||
"simulator-message" | ||
); | ||
coreManager.init(props.state); | ||
return () => { | ||
coreManager.stateManager.off(StateManagerEventType.ManagedState, "simulator-managed-state"); | ||
coreManager.stateManager.off(StateManagerEventType.Slices, "simulator-slices"); | ||
coreManager.stateManager.off(StateManagerEventType.Message, "simulator-message"); | ||
coreManager.stateManager.off( | ||
StateManagerEventType.ManagedState, | ||
"simulator-managed-state" | ||
); | ||
coreManager.stateManager.off( | ||
StateManagerEventType.Slices, | ||
"simulator-slices" | ||
); | ||
coreManager.stateManager.off( | ||
StateManagerEventType.Message, | ||
"simulator-message" | ||
); | ||
}; | ||
@@ -40,3 +62,3 @@ }, []); | ||
style: { | ||
zIndex: typeof props.zIndex === "undefined" ? defaultProps.zIndex : (_a = props.zIndex) != null ? _a : void 0, | ||
zIndex: typeof props.zIndex === "undefined" ? defaultProps.zIndex : props.zIndex, | ||
position: "fixed", | ||
@@ -48,3 +70,3 @@ top: 0, | ||
overflow: "auto", | ||
background: typeof props.background === "undefined" ? defaultProps.background : (_b = props.background) != null ? _b : void 0 | ||
background: typeof props.background === "undefined" ? defaultProps.background : props.background | ||
} | ||
@@ -51,0 +73,0 @@ }, message ? /* @__PURE__ */ React.createElement("article", { |
{ | ||
"name": "@prismicio/slice-simulator-react", | ||
"version": "0.2.2", | ||
"version": "0.2.3-alpha.0", | ||
"description": "Preview and develop Prismic slices fast with minimal configuration", | ||
@@ -35,20 +35,20 @@ "keywords": [ | ||
"release": "npm run test && standard-version && git push --follow-tags && npm run build && npm publish", | ||
"release:alpha": "npm run test && standard-version --release-as major --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha", | ||
"release:alpha:dry": "standard-version --release-as major --prerelease alpha --dry-run", | ||
"release:alpha": "npm run test && standard-version --release-as patch --prerelease alpha && git push --follow-tags && npm run build && npm publish --tag alpha", | ||
"release:alpha:dry": "standard-version --release-as patch --prerelease alpha --dry-run", | ||
"release:dry": "standard-version --dry-run", | ||
"test": "npm run unit && npm run build", | ||
"unit": "nyc --reporter=lcovonly --reporter=text --exclude-after-remap=false ava" | ||
"unit": "vitest run --coverage", | ||
"unit:watch": "vitest watch" | ||
}, | ||
"dependencies": { | ||
"@prismicio/slice-simulator-core": "^0.2.1" | ||
"@prismicio/slice-simulator-core": "^0.2.7-alpha.0" | ||
}, | ||
"devDependencies": { | ||
"@types/react": "^18.0.2", | ||
"ava": "^3.15.0", | ||
"nyc": "^15.1.0", | ||
"react": "^18.0.0", | ||
"@types/react": "^18.0.25", | ||
"@vitest/coverage-c8": "^0.25.3", | ||
"react": "^18.2.0", | ||
"siroc": "^0.16.0", | ||
"standard-version": "^9.3.2", | ||
"ts-eager": "^2.0.2", | ||
"typescript": "^4.6.3" | ||
"standard-version": "^9.5.0", | ||
"typescript": "^4.9.3", | ||
"vitest": "^0.25.3" | ||
}, | ||
@@ -59,3 +59,3 @@ "peerDependencies": { | ||
"engines": { | ||
"node": ">=12.7.0" | ||
"node": ">=14.15.0" | ||
}, | ||
@@ -62,0 +62,0 @@ "publishConfig": { |
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
Sorry, the diff of this file is not supported yet
42793
7
308