@pinnacle0/web-ui 0.6.28 → 0.6.30

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.28",
3
+ "version": "0.6.30",
4
4
  "author": "Pinnacle",
5
5
  "license": "MIT",
6
6
  "sideEffects": [
@@ -47,7 +47,7 @@
47
47
  "react-dom": "19.2.0",
48
48
  "react-router-dom": "5.3.0",
49
49
  "@pinnacle0/devtool-util": "1.3.6",
50
- "@pinnacle0/webpack-util": "0.8.17"
50
+ "@pinnacle0/webpack-util": "0.8.18"
51
51
  },
52
52
  "exports": {
53
53
  "./core/*": {
@@ -1,12 +1,11 @@
1
1
  /**
2
- * 1)
3
- * This util only works on mobile devices.
4
- * 2)
5
- * For Safari Mobile & Iphone Mobile,
6
- * ScreenOrientation API is not supported, and screen.availHeight & screen.availWidth will not produce a good result.
7
- * So use old APIs: window.eventListener, 'orientationchange'.
2
+ * Orientation detection utility for mobile and desktop devices.
8
3
  *
9
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/orientationchange_event
4
+ * Uses the matchMedia API with orientation media queries, which provides
5
+ * reliable cross-platform support including iOS 26+ where the legacy
6
+ * window.orientation API has been removed since iOS 26+ PWA is not supported.
7
+ *
8
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Testing_media_queries
10
9
  */
11
10
  export type OrientationType = "portrait" | "landscape";
12
11
  export type Subscriber = (orientation: OrientationType) => void;
@@ -1,35 +1,36 @@
1
1
  /**
2
- * 1)
3
- * This util only works on mobile devices.
4
- * 2)
5
- * For Safari Mobile & Iphone Mobile,
6
- * ScreenOrientation API is not supported, and screen.availHeight & screen.availWidth will not produce a good result.
7
- * So use old APIs: window.eventListener, 'orientationchange'.
2
+ * Orientation detection utility for mobile and desktop devices.
8
3
  *
9
- * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/orientationchange_event
4
+ * Uses the matchMedia API with orientation media queries, which provides
5
+ * reliable cross-platform support including iOS 26+ where the legacy
6
+ * window.orientation API has been removed since iOS 26+ PWA is not supported.
7
+ *
8
+ * @see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Testing_media_queries
10
9
  */
11
- const supportScreenOrientationAPI = typeof window.screen.orientation !== "undefined";
12
10
  function subscribe(subscriber) {
13
11
  const handler = () => subscriber(current());
14
- if (supportScreenOrientationAPI) {
15
- window.screen.orientation.addEventListener("change", handler);
16
- return () => window.screen.orientation.removeEventListener("change", handler);
12
+ // Use matchMedia for iOS 26+ and other browsers
13
+ const portraitQuery = window.matchMedia("(orientation: portrait)");
14
+ const mediaHandler = () => handler();
15
+ // Use addEventListener for modern browsers, addListener for older ones
16
+ if (portraitQuery.addEventListener) {
17
+ portraitQuery.addEventListener("change", mediaHandler);
18
+ return () => portraitQuery.removeEventListener("change", mediaHandler);
17
19
  }
18
20
  else {
19
- window.addEventListener("orientationchange", handler);
20
- return () => window.removeEventListener("orientationchange", handler, false);
21
+ // Fallback for very old browsers
22
+ portraitQuery.addListener(mediaHandler);
23
+ return () => portraitQuery.removeListener(mediaHandler);
21
24
  }
22
25
  }
23
26
  function current() {
24
27
  try {
25
- if (supportScreenOrientationAPI) {
26
- return window.screen.orientation.angle === 0 ? "portrait" : "landscape";
27
- }
28
- else {
29
- return window.orientation === 0 ? "portrait" : "landscape";
30
- }
28
+ // Use matchMedia API for iOS 26+ and other browsers
29
+ const isPortrait = window.matchMedia("(orientation: portrait)").matches;
30
+ return isPortrait ? "portrait" : "landscape";
31
31
  }
32
32
  catch {
33
+ // Do not use window.innerHeight/window.innerWidth comparison, because it is incorrect if keyboard is popped up
33
34
  return "portrait";
34
35
  }
35
36
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/OrientationUtil/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,M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