@pinnacle0/web-ui 0.6.36 → 0.6.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pinnacle0/web-ui",
3
- "version": "0.6.36",
3
+ "version": "0.6.37",
4
4
  "author": "Pinnacle",
5
5
  "license": "MIT",
6
6
  "sideEffects": [
@@ -9,6 +9,7 @@
9
9
  *
10
10
  * For iOS 26.0+ PWA, it does not dispatch any event when the orientation changes,
11
11
  * For iOS,
12
+ * Only support iOS 14+
12
13
  * Use media queries to check the orientation of the screen for iOS.
13
14
  *
14
15
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/orientation
@@ -16,7 +17,7 @@
16
17
  */
17
18
  export type OrientationType = "portrait" | "landscape";
18
19
  export type Subscriber = (orientation: OrientationType) => void;
19
- declare function subscribe(subscriber: Subscriber): () => void;
20
+ declare function subscribe(subscriber: Subscriber): (() => void) | undefined;
20
21
  declare function current(): OrientationType;
21
22
  export declare const OrientationUtil: Readonly<{
22
23
  subscribe: typeof subscribe;
@@ -9,6 +9,7 @@
9
9
  *
10
10
  * For iOS 26.0+ PWA, it does not dispatch any event when the orientation changes,
11
11
  * For iOS,
12
+ * Only support iOS 14+
12
13
  * Use media queries to check the orientation of the screen for iOS.
13
14
  *
14
15
  * @see https://developer.mozilla.org/en-US/docs/Web/CSS/@media/orientation
@@ -19,8 +20,11 @@ const supportScreenOrientationAPI = typeof window.screen.orientation !== "undefi
19
20
  function subscribe(subscriber) {
20
21
  const handler = () => subscriber(current());
21
22
  if (BrowserUtil.os() === "ios") {
22
- window.matchMedia("(orientation: portrait)").addEventListener("change", handler);
23
- return () => window.matchMedia("(orientation: portrait)").removeEventListener("change", handler);
23
+ const mediaQuery = window.matchMedia("(orientation: portrait)");
24
+ if (mediaQuery instanceof EventTarget) {
25
+ mediaQuery.addEventListener("change", handler);
26
+ return () => mediaQuery.removeEventListener("change", handler);
27
+ }
24
28
  }
25
29
  else if (supportScreenOrientationAPI) {
26
30
  window.screen.orientation.addEventListener("change", handler);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/OrientationUtil/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAE3C,MAAM,2BAA2B,GAAG,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,KAAK,WAAW,CAAC;AAMrF,SAAS,SAAS,CAAC,UAAsB;IACrC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5C,IAAI,WAAW,CAAC,EAAE,EAAE,KAAK,KAAK,EAAE,CAAC;QAC7B,MAAM,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACjF,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,yBAAyB,CAAC,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrG,CAAC;SAAM,IAAI,2BAA2B,EAAE,CAAC;QACrC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9D,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;QACtD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,mBAAmB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;IACjF,CAAC;AACL,CAAC;AAED,SAAS,OAAO;IACZ,IAAI,CAAC;QACD,IAAI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AC;IACzC,SAAS;IACT,OAAO;CACV,CAAC,CAAC"}
@@ -1,11 +0,0 @@
1
- import React from "react";
2
- export type Orientation = "portrait" | "landscape";
3
- interface OrientationContext {
4
- orientation: Orientation;
5
- }
6
- export interface Props {
7
- children: React.ReactNode;
8
- }
9
- export declare const OrientationContext: React.Context<OrientationContext>;
10
- export declare const OrientationContextProvider: ({ children }: Props) => React.JSX.Element;
11
- export {};
@@ -1,10 +0,0 @@
1
- import React from "react";
2
- import { ReactUtil } from "../../util/ReactUtil";
3
- import { OrientationUtil } from "../../util/OrientationUtil";
4
- export const OrientationContext = React.createContext({});
5
- export const OrientationContextProvider = ReactUtil.memo("OrientationContextProvider", ({ children }) => {
6
- const [currentOrientation, setCurrentOrientation] = React.useState(OrientationUtil.current());
7
- React.useEffect(() => OrientationUtil.subscribe(setCurrentOrientation), []);
8
- return React.createElement(OrientationContext.Provider, { value: { orientation: currentOrientation } }, children);
9
- });
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/OrientationContext/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAC,SAAS,EAAC,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAC,eAAe,EAAC,MAAM,4BAA4B,CAAC;AAY3D,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,aAAa,CAAC,EAAwB,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,0BAA0B,GAAG,SAAS,CAAC,IAAI,CAAC,4BAA4B,EAAE,CAAC,EAAC,QAAQ,EAAQ,EAAE,EAAE;IACzG,MAAM,CAAC,kBAAkB,EAAE,qBAAqB,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,CAAC;IAE9F,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,qBAAqB,CAAC,EAAE,EAAE,CAAC,CAAC;IAE5E,OAAO,oBAAC,kBAAkB,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAC,WAAW,EAAE,kBAAkB,EAAC,IAAG,QAAQ,CAA+B,CAAC;AAC3H,CAAC,CAAC,CAAC"}