UNPKG

@devgateway/dvz-ui-react

Version:

A modular, embeddable React component library for data visualization and UI, built with TypeScript. Provides reusable components for charts, maps, dashboards, and more, with built-in support for internationalization and Redux integration.

2 lines (1 loc) 933 B
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react");function u(){const e=typeof window<"u"&&"screen"in window&&"orientation"in window.screen,r=()=>{if(e){const{type:n,angle:a}=window.screen.orientation;return{type:n,angle:a}}return{type:"portrait-primary",angle:0}},[o,i]=t.useState(r);t.useEffect(()=>{if(!e)return;const n=()=>i(r());return window.screen.orientation.addEventListener("change",n),n(),()=>{window.screen.orientation.removeEventListener("change",n)}},[e]);const c=t.useCallback((n="portrait")=>e&&window.screen.orientation.lock?window.screen.orientation.lock(n):Promise.reject(new Error("Screen Orientation lock unsupported")),[e]),s=t.useCallback(()=>e&&window.screen.orientation.unlock?window.screen.orientation.unlock():Promise.reject(new Error("Screen Orientation unlock unsupported")),[e]);return{orientation:o,lock:c,unlock:s}}exports.useScreenOrientation=u;