UNPKG

@nwebui/react-niagara-px

Version:
33 lines 1.34 kB
import React, { useCallback } from "react"; import { usePxView } from "../PxViewContext"; import useWidgetChanged from "./useWidgetChanged"; import { imageUrl } from "./utils"; import { Widget } from "./Widget"; const Picture = function ({ nativeWidget, children }) { const { popup } = usePxView(); useWidgetChanged(nativeWidget); const image = nativeWidget.gets("image"); const style = { width: "100%", height: "100%", userSelect: "none", // @ts-ignore WebkitUserDrag: "none", // @ts-ignore userDrag: "none", }; const bindings = Array.from(nativeWidget.childComponents((c) => c.is("kitPx:PopupBinding"))); const hasPopup = bindings.length > 0; const handleClick = useCallback(() => { const binding = Array.from(nativeWidget.childComponents((c) => c.is("kitPx:PopupBinding")))[0]; if (binding) { const ord = binding.gets("ord"); popup(ord); } }, [popup]); return (React.createElement(Widget, { nativeWidget: nativeWidget, onClick: handleClick, style: { cursor: hasPopup ? "pointer" : undefined } }, image && React.createElement("img", { src: imageUrl(image), style: style }), children)); }; export default Picture; //# sourceMappingURL=Picture.js.map