@figspec/react
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -0,1 +1,2 @@ | ||
"use strict"; | ||
var __rest = (this && this.__rest) || function (s, e) { | ||
@@ -12,5 +13,7 @@ var t = {}; | ||
}; | ||
import { jsx as _jsx } from "react/jsx-runtime.js"; | ||
import "@figspec/components"; | ||
import { forwardRef, useCallback, useEffect, useImperativeHandle, useState, } from "react"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FigspecFileViewer = exports.FigspecFrameViewer = void 0; | ||
const jsx_runtime_js_1 = require("react/jsx-runtime.js"); | ||
require("@figspec/components"); | ||
const react_1 = require("react"); | ||
const bindEvent = (element, event, cb) => { | ||
@@ -23,7 +26,7 @@ const listener = ((ev) => { | ||
}; | ||
export const FigspecFrameViewer = forwardRef((_a, ref) => { | ||
exports.FigspecFrameViewer = react_1.forwardRef((_a, ref) => { | ||
var { nodes, renderedImage, className, panSpeed, zoomMargin, zoomSpeed, onNodeSelect, onPositionChange, onScaleChange } = _a, rest = __rest(_a, ["nodes", "renderedImage", "className", "panSpeed", "zoomMargin", "zoomSpeed", "onNodeSelect", "onPositionChange", "onScaleChange"]); | ||
const [refNode, setNode] = useState(null); | ||
useImperativeHandle(ref, () => refNode, [refNode]); | ||
const refCb = useCallback((node) => { | ||
const [refNode, setNode] = react_1.useState(null); | ||
react_1.useImperativeHandle(ref, () => refNode, [refNode]); | ||
const refCb = react_1.useCallback((node) => { | ||
if (node) { | ||
@@ -35,3 +38,3 @@ setNode(node); | ||
}, []); | ||
useEffect(() => { | ||
react_1.useEffect(() => { | ||
if (!refNode) | ||
@@ -42,3 +45,3 @@ return; | ||
}, [refNode, nodes, renderedImage]); | ||
useEffect(() => { | ||
react_1.useEffect(() => { | ||
if (!refNode || !onNodeSelect) | ||
@@ -48,3 +51,3 @@ return; | ||
}, [refNode, onNodeSelect]); | ||
useEffect(() => { | ||
react_1.useEffect(() => { | ||
if (!refNode || !onPositionChange) | ||
@@ -54,3 +57,3 @@ return; | ||
}, [refNode, onPositionChange]); | ||
useEffect(() => { | ||
react_1.useEffect(() => { | ||
if (!refNode || !onScaleChange) | ||
@@ -60,9 +63,9 @@ return; | ||
}, [refNode, onScaleChange]); | ||
return (_jsx("figspec-frame-viewer", Object.assign({ ref: refCb, class: className, "pan-speed": panSpeed, "zoom-margin": zoomMargin, "zoom-speed": zoomSpeed }, rest), void 0)); | ||
return (jsx_runtime_js_1.jsx("figspec-frame-viewer", Object.assign({ ref: refCb, class: className, "pan-speed": panSpeed, "zoom-margin": zoomMargin, "zoom-speed": zoomSpeed }, rest), void 0)); | ||
}); | ||
export const FigspecFileViewer = forwardRef((_a, ref) => { | ||
exports.FigspecFileViewer = react_1.forwardRef((_a, ref) => { | ||
var { documentNode, renderedImages, className, panSpeed, zoomMargin, zoomSpeed, onNodeSelect, onPositionChange, onScaleChange } = _a, rest = __rest(_a, ["documentNode", "renderedImages", "className", "panSpeed", "zoomMargin", "zoomSpeed", "onNodeSelect", "onPositionChange", "onScaleChange"]); | ||
const [refNode, setNode] = useState(null); | ||
useImperativeHandle(ref, () => refNode, [refNode]); | ||
const refCb = useCallback((node) => { | ||
const [refNode, setNode] = react_1.useState(null); | ||
react_1.useImperativeHandle(ref, () => refNode, [refNode]); | ||
const refCb = react_1.useCallback((node) => { | ||
if (node) { | ||
@@ -74,3 +77,3 @@ setNode(node); | ||
}, []); | ||
useEffect(() => { | ||
react_1.useEffect(() => { | ||
if (!refNode) | ||
@@ -81,3 +84,3 @@ return; | ||
}, [refNode, documentNode, renderedImages]); | ||
useEffect(() => { | ||
react_1.useEffect(() => { | ||
if (!refNode || !onNodeSelect) | ||
@@ -87,3 +90,3 @@ return; | ||
}, [refNode, onNodeSelect]); | ||
useEffect(() => { | ||
react_1.useEffect(() => { | ||
if (!refNode || !onPositionChange) | ||
@@ -93,3 +96,3 @@ return; | ||
}, [refNode, onPositionChange]); | ||
useEffect(() => { | ||
react_1.useEffect(() => { | ||
if (!refNode || !onScaleChange) | ||
@@ -99,3 +102,3 @@ return; | ||
}, [refNode, onScaleChange]); | ||
return (_jsx("figspec-file-viewer", Object.assign({ ref: refCb, class: className, "pan-speed": panSpeed, "zoom-margin": zoomMargin, "zoom-speed": zoomSpeed }, rest), void 0)); | ||
return (jsx_runtime_js_1.jsx("figspec-file-viewer", Object.assign({ ref: refCb, class: className, "pan-speed": panSpeed, "zoom-margin": zoomMargin, "zoom-speed": zoomSpeed }, rest), void 0)); | ||
}); |
@@ -8,3 +8,3 @@ { | ||
], | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"contributors": [ | ||
@@ -48,3 +48,3 @@ { | ||
"build:esm": "tsc --outDir esm/es2015", | ||
"build:cjs": "tsc --outDir cjs/es2016 --target es2016", | ||
"build:cjs": "tsc --outDir cjs/es2016 --target es2016 --module CommonJS", | ||
"build:default": "yarn build:esm && yarn build:cjs", | ||
@@ -51,0 +51,0 @@ "build": "yarn build:default", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
14791
247