@lingxia/elements 0.13.0 → 0.15.0

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/dist/picker.js CHANGED
@@ -1,7 +1,15 @@
1
1
  import { sendNativeComponentMessage, registerNativeComponentHandler, addNativeComponentLayoutInvalidationListener } from "./nativecomponent.js";
2
2
  import { ensureComponentId } from "./component.js";
3
3
  import { measureElement } from "./dom.js";
4
- import { isAndroid, isHarmony, isDesktop } from "./platform.js";
4
+ import { isAndroid, isHarmony, isIOS } from "./platform.js";
5
+ // Which hosts register a `picker.native` component. A capability question, not
6
+ // a form-factor one: macOS and Windows have no picker factory, so they draw the
7
+ // web picker even in the Runner's phone frame, where the host class is mobile
8
+ // but the machine underneath is still a Mac or a PC. Harmony has its own embed
9
+ // path and never reaches either branch.
10
+ function hasNativePicker() {
11
+ return isIOS() || isAndroid();
12
+ }
5
13
  const HARMONY_PROPS_PREFIX = "data:application/json,";
6
14
  // Component implementation
7
15
  export class LxPickerElement extends HTMLElement {
@@ -14,7 +22,7 @@ export class LxPickerElement extends HTMLElement {
14
22
  this._pageBindings = {};
15
23
  this.layoutInvalidationListener = {
16
24
  handleEvent: () => {
17
- if (!this.isConnected || isHarmony() || isDesktop())
25
+ if (!this.isConnected || isHarmony() || !hasNativePicker())
18
26
  return;
19
27
  void this.mountPicker();
20
28
  }
@@ -86,7 +94,7 @@ export class LxPickerElement extends HTMLElement {
86
94
  }
87
95
  (_a = this.removeLayoutInvalidationListener) === null || _a === void 0 ? void 0 : _a.call(this);
88
96
  this.removeLayoutInvalidationListener = undefined;
89
- if (this.componentId && !isHarmony() && !isDesktop()) {
97
+ if (this.componentId && !isHarmony() && hasNativePicker()) {
90
98
  sendNativeComponentMessage({
91
99
  action: "component.unmount",
92
100
  id: this.componentId
@@ -241,7 +249,7 @@ export class LxPickerElement extends HTMLElement {
241
249
  this.mounted = true;
242
250
  return;
243
251
  }
244
- if (isDesktop()) {
252
+ if (!hasNativePicker()) {
245
253
  if (this.webCleanup)
246
254
  return;
247
255
  const { renderWebPicker } = await import('./picker-web.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxia/elements",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "private": false,
5
5
  "description": "LingXia custom elements — native-backed web components for LxApp pages",
6
6
  "type": "module",
package/src/picker.ts CHANGED
@@ -5,7 +5,16 @@ import {
5
5
  } from "./nativecomponent.js";
6
6
  import { ensureComponentId } from "./component.js";
7
7
  import { measureElement } from "./dom.js";
8
- import { isAndroid, isHarmony, isDesktop } from "./platform.js";
8
+ import { isAndroid, isHarmony, isIOS } from "./platform.js";
9
+
10
+ // Which hosts register a `picker.native` component. A capability question, not
11
+ // a form-factor one: macOS and Windows have no picker factory, so they draw the
12
+ // web picker even in the Runner's phone frame, where the host class is mobile
13
+ // but the machine underneath is still a Mac or a PC. Harmony has its own embed
14
+ // path and never reaches either branch.
15
+ function hasNativePicker(): boolean {
16
+ return isIOS() || isAndroid();
17
+ }
9
18
 
10
19
  const HARMONY_PROPS_PREFIX = "data:application/json,";
11
20
 
@@ -90,7 +99,7 @@ export class LxPickerElement extends HTMLElement {
90
99
  private removeLayoutInvalidationListener?: () => void;
91
100
  private readonly layoutInvalidationListener: EventListenerObject = {
92
101
  handleEvent: () => {
93
- if (!this.isConnected || isHarmony() || isDesktop()) return;
102
+ if (!this.isConnected || isHarmony() || !hasNativePicker()) return;
94
103
  void this.mountPicker();
95
104
  }
96
105
  };
@@ -146,7 +155,7 @@ export class LxPickerElement extends HTMLElement {
146
155
  this.removeLayoutInvalidationListener?.();
147
156
  this.removeLayoutInvalidationListener = undefined;
148
157
 
149
- if (this.componentId && !isHarmony() && !isDesktop()) {
158
+ if (this.componentId && !isHarmony() && hasNativePicker()) {
150
159
  sendNativeComponentMessage({
151
160
  action: "component.unmount",
152
161
  id: this.componentId
@@ -301,7 +310,7 @@ export class LxPickerElement extends HTMLElement {
301
310
  return;
302
311
  }
303
312
 
304
- if (isDesktop()) {
313
+ if (!hasNativePicker()) {
305
314
  if (this.webCleanup) return;
306
315
  const { renderWebPicker } = await import('./picker-web.js');
307
316
  if (!this.isConnected || !this.componentId || this.webCleanup) return;