@lingxia/elements 0.5.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/component.d.ts +50 -0
- package/dist/component.js +139 -0
- package/dist/dom.d.ts +10 -0
- package/dist/dom.js +70 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/input.d.ts +117 -0
- package/dist/input.js +699 -0
- package/dist/native_component_wrapper_shared.d.ts +74 -0
- package/dist/native_component_wrapper_shared.js +193 -0
- package/dist/nativecomponent.d.ts +6 -0
- package/dist/nativecomponent.js +82 -0
- package/dist/navigator.d.ts +83 -0
- package/dist/navigator.js +388 -0
- package/dist/picker-web.d.ts +2 -0
- package/dist/picker-web.js +727 -0
- package/dist/picker.d.ts +77 -0
- package/dist/picker.js +342 -0
- package/dist/platform.d.ts +6 -0
- package/dist/platform.js +24 -0
- package/dist/text_component_native_attrs.d.ts +53 -0
- package/dist/text_component_native_attrs.js +111 -0
- package/dist/text_component_shared.d.ts +7 -0
- package/dist/text_component_shared.js +148 -0
- package/dist/textarea.d.ts +129 -0
- package/dist/textarea.js +841 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.js +1 -0
- package/dist/video.d.ts +134 -0
- package/dist/video.js +741 -0
- package/package.json +39 -0
- package/src/component.ts +164 -0
- package/src/dom.ts +83 -0
- package/src/index.ts +69 -0
- package/src/input.ts +799 -0
- package/src/native_component_wrapper_shared.ts +243 -0
- package/src/nativecomponent.ts +97 -0
- package/src/navigator.ts +533 -0
- package/src/picker-web.ts +719 -0
- package/src/picker.ts +418 -0
- package/src/platform.ts +25 -0
- package/src/text_component_native_attrs.ts +137 -0
- package/src/text_component_shared.ts +147 -0
- package/src/textarea.ts +959 -0
- package/src/types.ts +20 -0
- package/src/video.ts +855 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { NavigatorOpenType, NavigatorTarget } from "./navigator.js";
|
|
2
|
+
import type { LxVideoQuality } from "./video.js";
|
|
3
|
+
export declare function appendDataAttrs(attrs: Record<string, unknown>, target: Record<string, string>): void;
|
|
4
|
+
export declare function appendPassthroughAttrs(attrs: Record<string, unknown>, target: Record<string, string>): void;
|
|
5
|
+
export interface NavigatorNativeAttrOptions {
|
|
6
|
+
url?: string;
|
|
7
|
+
openType?: NavigatorOpenType;
|
|
8
|
+
target?: NavigatorTarget;
|
|
9
|
+
delta?: number;
|
|
10
|
+
appId?: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
phoneNumber?: string;
|
|
13
|
+
hoverClass?: string;
|
|
14
|
+
hoverStopPropagation?: boolean;
|
|
15
|
+
hoverStartTime?: number;
|
|
16
|
+
hoverStayTime?: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function buildNavigatorNativeAttrs(options: NavigatorNativeAttrOptions, extraAttrs?: Record<string, unknown>): Record<string, string>;
|
|
19
|
+
export type PickerColumns = string[][] | [string[], Record<string, string[]>];
|
|
20
|
+
export type PickerValue = string | string[] | undefined;
|
|
21
|
+
export type PickerFields = "year" | "month" | "day" | "range";
|
|
22
|
+
export interface PickerNativeAttrOptions {
|
|
23
|
+
id?: string;
|
|
24
|
+
columns?: PickerColumns;
|
|
25
|
+
mode?: "date" | "time";
|
|
26
|
+
start?: string;
|
|
27
|
+
end?: string;
|
|
28
|
+
fields?: PickerFields;
|
|
29
|
+
modelValue?: string | string[];
|
|
30
|
+
value?: string | string[];
|
|
31
|
+
cancelText?: string;
|
|
32
|
+
cancelTextColor?: string;
|
|
33
|
+
cancelButtonColor?: string;
|
|
34
|
+
confirmText?: string;
|
|
35
|
+
confirmTextColor?: string;
|
|
36
|
+
confirmButtonColor?: string;
|
|
37
|
+
}
|
|
38
|
+
export declare function isPickerDateMode(mode?: "date" | "time"): boolean;
|
|
39
|
+
export declare function isPickerCascading(columns?: PickerColumns): columns is [string[], Record<string, string[]>];
|
|
40
|
+
export declare function isPickerSingle(columns?: PickerColumns): boolean;
|
|
41
|
+
export declare function getPickerIndexFromValue(columns: PickerColumns | undefined, value: PickerValue): number | number[];
|
|
42
|
+
export declare function getPickerValueFromIndex(columns: PickerColumns | undefined, index: number | number[]): string | string[];
|
|
43
|
+
export declare function getPickerDisplayText(value: PickerValue, fields?: PickerFields): string;
|
|
44
|
+
export declare function buildPickerNativeAttrs(options: PickerNativeAttrOptions, extraAttrs?: Record<string, unknown>): Record<string, string>;
|
|
45
|
+
export declare const VIDEO_DOM_EVENT_MAP: {
|
|
46
|
+
readonly onPlayRequest: "playrequest";
|
|
47
|
+
readonly onPlay: "play";
|
|
48
|
+
readonly onPlaying: "playing";
|
|
49
|
+
readonly onPause: "pause";
|
|
50
|
+
readonly onStop: "stop";
|
|
51
|
+
readonly onEnded: "ended";
|
|
52
|
+
readonly onTimeUpdate: "timeupdate";
|
|
53
|
+
readonly onError: "error";
|
|
54
|
+
readonly onLoadedMetadata: "loadedmetadata";
|
|
55
|
+
readonly onFullscreenChange: "fullscreenchange";
|
|
56
|
+
readonly onWaiting: "waiting";
|
|
57
|
+
readonly onQualityChange: "qualitychange";
|
|
58
|
+
readonly onRateChange: "ratechange";
|
|
59
|
+
};
|
|
60
|
+
export interface VideoNativeAttrOptions {
|
|
61
|
+
id?: string;
|
|
62
|
+
src?: string;
|
|
63
|
+
poster?: string;
|
|
64
|
+
autoplay?: boolean;
|
|
65
|
+
loop?: boolean;
|
|
66
|
+
muted?: boolean;
|
|
67
|
+
controls?: boolean;
|
|
68
|
+
progressBar?: boolean;
|
|
69
|
+
live?: boolean;
|
|
70
|
+
volume?: string | number;
|
|
71
|
+
qualities?: LxVideoQuality[];
|
|
72
|
+
playbackRates?: number[];
|
|
73
|
+
}
|
|
74
|
+
export declare function buildVideoNativeAttrs(options: VideoNativeAttrOptions, extraAttrs?: Record<string, unknown>): Record<string, string | number>;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
export function appendDataAttrs(attrs, target) {
|
|
2
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
3
|
+
if (value === undefined || value === null)
|
|
4
|
+
continue;
|
|
5
|
+
if (!key.startsWith("data-"))
|
|
6
|
+
continue;
|
|
7
|
+
target[key] = String(value);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
export function appendPassthroughAttrs(attrs, target) {
|
|
11
|
+
for (const [key, value] of Object.entries(attrs)) {
|
|
12
|
+
if (value === undefined || value === null)
|
|
13
|
+
continue;
|
|
14
|
+
if (key in target)
|
|
15
|
+
continue;
|
|
16
|
+
if (key === "class" || key === "className" || key === "style" || key === "children" || key === "ref") {
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (key.startsWith("on"))
|
|
20
|
+
continue;
|
|
21
|
+
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
22
|
+
target[key] = String(value);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function buildNavigatorNativeAttrs(options, extraAttrs = {}) {
|
|
27
|
+
var _a, _b, _c, _d, _e, _f;
|
|
28
|
+
const result = {
|
|
29
|
+
"open-type": (_a = options.openType) !== null && _a !== void 0 ? _a : "navigate",
|
|
30
|
+
delta: String((_b = options.delta) !== null && _b !== void 0 ? _b : 1),
|
|
31
|
+
"hover-class": (_c = options.hoverClass) !== null && _c !== void 0 ? _c : "navigator-hover",
|
|
32
|
+
"hover-stop-propagation": String((_d = options.hoverStopPropagation) !== null && _d !== void 0 ? _d : false),
|
|
33
|
+
"hover-start-time": String((_e = options.hoverStartTime) !== null && _e !== void 0 ? _e : 20),
|
|
34
|
+
"hover-stay-time": String((_f = options.hoverStayTime) !== null && _f !== void 0 ? _f : 70),
|
|
35
|
+
};
|
|
36
|
+
if (options.url)
|
|
37
|
+
result.url = options.url;
|
|
38
|
+
if (options.target)
|
|
39
|
+
result.target = options.target;
|
|
40
|
+
if (options.appId)
|
|
41
|
+
result["app-id"] = options.appId;
|
|
42
|
+
if (options.path)
|
|
43
|
+
result.path = options.path;
|
|
44
|
+
if (options.phoneNumber)
|
|
45
|
+
result["phone-number"] = options.phoneNumber;
|
|
46
|
+
appendPassthroughAttrs(extraAttrs, result);
|
|
47
|
+
return result;
|
|
48
|
+
}
|
|
49
|
+
export function isPickerDateMode(mode) {
|
|
50
|
+
return mode === "date" || mode === "time";
|
|
51
|
+
}
|
|
52
|
+
export function isPickerCascading(columns) {
|
|
53
|
+
return !!columns && columns.length === 2 && typeof columns[1] === "object" && !Array.isArray(columns[1]);
|
|
54
|
+
}
|
|
55
|
+
export function isPickerSingle(columns) {
|
|
56
|
+
return !!columns && columns.length === 1;
|
|
57
|
+
}
|
|
58
|
+
export function getPickerIndexFromValue(columns, value) {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
if (!columns)
|
|
61
|
+
return 0;
|
|
62
|
+
if (isPickerSingle(columns)) {
|
|
63
|
+
if (typeof value !== "string")
|
|
64
|
+
return 0;
|
|
65
|
+
const idx = columns[0].indexOf(value);
|
|
66
|
+
return idx >= 0 ? idx : 0;
|
|
67
|
+
}
|
|
68
|
+
if (!Array.isArray(value)) {
|
|
69
|
+
return Array.from({ length: columns.length }, () => 0);
|
|
70
|
+
}
|
|
71
|
+
if (isPickerCascading(columns)) {
|
|
72
|
+
const [keys, map] = columns;
|
|
73
|
+
const keyIdx = Math.max(0, keys.indexOf(value[0]));
|
|
74
|
+
const valIdx = Math.max(0, (_b = (_a = map[keys[keyIdx]]) === null || _a === void 0 ? void 0 : _a.indexOf(value[1])) !== null && _b !== void 0 ? _b : 0);
|
|
75
|
+
return [keyIdx, valIdx];
|
|
76
|
+
}
|
|
77
|
+
const indexes = value.map((item, index) => { var _a, _b; return Math.max(0, (_b = (_a = columns[index]) === null || _a === void 0 ? void 0 : _a.indexOf(item)) !== null && _b !== void 0 ? _b : 0); });
|
|
78
|
+
while (indexes.length < columns.length)
|
|
79
|
+
indexes.push(0);
|
|
80
|
+
return indexes;
|
|
81
|
+
}
|
|
82
|
+
export function getPickerValueFromIndex(columns, index) {
|
|
83
|
+
var _a, _b, _c, _d, _e;
|
|
84
|
+
if (!columns)
|
|
85
|
+
return "";
|
|
86
|
+
if (typeof index === "number") {
|
|
87
|
+
return (_b = (_a = columns[0]) === null || _a === void 0 ? void 0 : _a[index]) !== null && _b !== void 0 ? _b : "";
|
|
88
|
+
}
|
|
89
|
+
if (isPickerCascading(columns)) {
|
|
90
|
+
const [keys, map] = columns;
|
|
91
|
+
const key = (_c = keys[index[0]]) !== null && _c !== void 0 ? _c : "";
|
|
92
|
+
return [key, (_e = (_d = map[key]) === null || _d === void 0 ? void 0 : _d[index[1]]) !== null && _e !== void 0 ? _e : ""];
|
|
93
|
+
}
|
|
94
|
+
return index.map((item, column) => { var _a, _b; return (_b = (_a = columns[column]) === null || _a === void 0 ? void 0 : _a[item]) !== null && _b !== void 0 ? _b : ""; });
|
|
95
|
+
}
|
|
96
|
+
export function getPickerDisplayText(value, fields) {
|
|
97
|
+
if (!value)
|
|
98
|
+
return "";
|
|
99
|
+
if (fields === "range" && Array.isArray(value)) {
|
|
100
|
+
return `${value[0]} ~ ${value[1]}`;
|
|
101
|
+
}
|
|
102
|
+
return typeof value === "string" ? value : value.join(" - ");
|
|
103
|
+
}
|
|
104
|
+
export function buildPickerNativeAttrs(options, extraAttrs = {}) {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
const result = {};
|
|
107
|
+
const explicitId = typeof options.id === "string" ? options.id.trim() : "";
|
|
108
|
+
const nextValue = (_a = options.modelValue) !== null && _a !== void 0 ? _a : options.value;
|
|
109
|
+
if (explicitId.length > 0)
|
|
110
|
+
result.id = explicitId;
|
|
111
|
+
if (isPickerDateMode(options.mode)) {
|
|
112
|
+
result.mode = options.mode;
|
|
113
|
+
if (options.fields)
|
|
114
|
+
result.fields = options.fields;
|
|
115
|
+
if (nextValue) {
|
|
116
|
+
result.value = typeof nextValue === "string" ? nextValue : JSON.stringify(nextValue);
|
|
117
|
+
}
|
|
118
|
+
if (options.start)
|
|
119
|
+
result.start = options.start;
|
|
120
|
+
if (options.end)
|
|
121
|
+
result.end = options.end;
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
result.mode = isPickerCascading(options.columns)
|
|
125
|
+
? "cascading"
|
|
126
|
+
: isPickerSingle(options.columns)
|
|
127
|
+
? "selector"
|
|
128
|
+
: "multiSelector";
|
|
129
|
+
result.columns = JSON.stringify((_b = options.columns) !== null && _b !== void 0 ? _b : []);
|
|
130
|
+
result["default-index"] = JSON.stringify(getPickerIndexFromValue(options.columns, nextValue));
|
|
131
|
+
}
|
|
132
|
+
if (options.cancelText)
|
|
133
|
+
result["cancel-text"] = options.cancelText;
|
|
134
|
+
if (options.cancelTextColor)
|
|
135
|
+
result["cancel-text-color"] = options.cancelTextColor;
|
|
136
|
+
if (options.cancelButtonColor)
|
|
137
|
+
result["cancel-button-color"] = options.cancelButtonColor;
|
|
138
|
+
if (options.confirmText)
|
|
139
|
+
result["confirm-text"] = options.confirmText;
|
|
140
|
+
if (options.confirmTextColor)
|
|
141
|
+
result["confirm-text-color"] = options.confirmTextColor;
|
|
142
|
+
if (options.confirmButtonColor)
|
|
143
|
+
result["confirm-button-color"] = options.confirmButtonColor;
|
|
144
|
+
appendPassthroughAttrs(extraAttrs, result);
|
|
145
|
+
return result;
|
|
146
|
+
}
|
|
147
|
+
export const VIDEO_DOM_EVENT_MAP = {
|
|
148
|
+
onPlayRequest: "playrequest",
|
|
149
|
+
onPlay: "play",
|
|
150
|
+
onPlaying: "playing",
|
|
151
|
+
onPause: "pause",
|
|
152
|
+
onStop: "stop",
|
|
153
|
+
onEnded: "ended",
|
|
154
|
+
onTimeUpdate: "timeupdate",
|
|
155
|
+
onError: "error",
|
|
156
|
+
onLoadedMetadata: "loadedmetadata",
|
|
157
|
+
onFullscreenChange: "fullscreenchange",
|
|
158
|
+
onWaiting: "waiting",
|
|
159
|
+
onQualityChange: "qualitychange",
|
|
160
|
+
onRateChange: "ratechange",
|
|
161
|
+
};
|
|
162
|
+
export function buildVideoNativeAttrs(options, extraAttrs = {}) {
|
|
163
|
+
var _a, _b;
|
|
164
|
+
const result = {};
|
|
165
|
+
const explicitId = typeof options.id === "string" ? options.id.trim() : "";
|
|
166
|
+
if (explicitId.length > 0)
|
|
167
|
+
result.id = explicitId;
|
|
168
|
+
if (options.src)
|
|
169
|
+
result.src = options.src;
|
|
170
|
+
if (options.poster)
|
|
171
|
+
result.poster = options.poster;
|
|
172
|
+
if (options.autoplay)
|
|
173
|
+
result.autoplay = "";
|
|
174
|
+
if (options.loop)
|
|
175
|
+
result.loop = "";
|
|
176
|
+
if (options.muted)
|
|
177
|
+
result.muted = "";
|
|
178
|
+
if (options.controls)
|
|
179
|
+
result.controls = "";
|
|
180
|
+
if (options.progressBar === false)
|
|
181
|
+
result["progress-bar"] = "false";
|
|
182
|
+
if (options.live)
|
|
183
|
+
result.live = "";
|
|
184
|
+
if (options.volume !== undefined)
|
|
185
|
+
result.volume = options.volume;
|
|
186
|
+
if ((_a = options.qualities) === null || _a === void 0 ? void 0 : _a.length)
|
|
187
|
+
result.qualities = JSON.stringify(options.qualities);
|
|
188
|
+
if ((_b = options.playbackRates) === null || _b === void 0 ? void 0 : _b.length)
|
|
189
|
+
result["playback-rates"] = JSON.stringify(options.playbackRates);
|
|
190
|
+
const extraNativeAttrs = {};
|
|
191
|
+
appendPassthroughAttrs(extraAttrs, extraNativeAttrs);
|
|
192
|
+
return { ...result, ...extraNativeAttrs };
|
|
193
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { NativeComponentMessage } from './types.js';
|
|
2
|
+
export type { NativeComponentMessage } from './types.js';
|
|
3
|
+
export declare function sendNativeComponentMessage(message: NativeComponentMessage): void;
|
|
4
|
+
export declare function registerNativeComponentHandler(id: string, handler: (msg: NativeComponentMessage) => void): () => void;
|
|
5
|
+
export declare function invalidateNativeComponentLayout(delays?: number[]): void;
|
|
6
|
+
export declare function addNativeComponentLayoutInvalidationListener(listener: EventListenerOrEventListenerObject): () => void;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
let warnedNoHandler = false;
|
|
2
|
+
const NATIVE_COMPONENT_LAYOUT_INVALIDATED_EVENT = "lingxia:native-component-layout-invalidated";
|
|
3
|
+
let pendingLayoutInvalidationFrame = null;
|
|
4
|
+
const pendingLayoutInvalidationTimers = new Map();
|
|
5
|
+
export function sendNativeComponentMessage(message) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const sender = typeof window !== "undefined"
|
|
8
|
+
? (_b = (_a = window.LingXiaBridge) === null || _a === void 0 ? void 0 : _a.nativeComponents) === null || _b === void 0 ? void 0 : _b.send
|
|
9
|
+
: undefined;
|
|
10
|
+
if (typeof sender !== "function") {
|
|
11
|
+
if (!warnedNoHandler) {
|
|
12
|
+
warnedNoHandler = true;
|
|
13
|
+
console.warn("[LingXia NativeComponent] message handler not available");
|
|
14
|
+
}
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
sender(message);
|
|
18
|
+
}
|
|
19
|
+
export function registerNativeComponentHandler(id, handler) {
|
|
20
|
+
var _a, _b, _c, _d, _e;
|
|
21
|
+
const nativeComponents = typeof window !== "undefined"
|
|
22
|
+
? (_a = window.LingXiaBridge) === null || _a === void 0 ? void 0 : _a.nativeComponents
|
|
23
|
+
: undefined;
|
|
24
|
+
const registerFn = nativeComponents === null || nativeComponents === void 0 ? void 0 : nativeComponents.register;
|
|
25
|
+
if (typeof registerFn === "function") {
|
|
26
|
+
const unregister = registerFn(id, handler);
|
|
27
|
+
const platform = (_b = window.LingXiaBridge) === null || _b === void 0 ? void 0 : _b.platform;
|
|
28
|
+
const requiresReadyHandshake = !!(((_c = platform === null || platform === void 0 ? void 0 : platform.isIOS) === null || _c === void 0 ? void 0 : _c.call(platform)) ||
|
|
29
|
+
((_d = platform === null || platform === void 0 ? void 0 : platform.isAndroid) === null || _d === void 0 ? void 0 : _d.call(platform)) ||
|
|
30
|
+
((_e = platform === null || platform === void 0 ? void 0 : platform.isMacOS) === null || _e === void 0 ? void 0 : _e.call(platform)));
|
|
31
|
+
const hasHandler = nativeComponents === null || nativeComponents === void 0 ? void 0 : nativeComponents.hasHandler;
|
|
32
|
+
const send = nativeComponents === null || nativeComponents === void 0 ? void 0 : nativeComponents.send;
|
|
33
|
+
if (typeof send === "function") {
|
|
34
|
+
const nativeReady = typeof hasHandler === "function" ? hasHandler() : true;
|
|
35
|
+
if (requiresReadyHandshake || nativeReady) {
|
|
36
|
+
send({ action: "component.ready", id });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return unregister;
|
|
40
|
+
}
|
|
41
|
+
if (!warnedNoHandler) {
|
|
42
|
+
warnedNoHandler = true;
|
|
43
|
+
console.warn("[LingXia NativeComponent] message handler not available");
|
|
44
|
+
}
|
|
45
|
+
return () => { };
|
|
46
|
+
}
|
|
47
|
+
function dispatchNativeComponentLayoutInvalidated() {
|
|
48
|
+
if (typeof window === "undefined")
|
|
49
|
+
return;
|
|
50
|
+
window.dispatchEvent(new CustomEvent(NATIVE_COMPONENT_LAYOUT_INVALIDATED_EVENT));
|
|
51
|
+
}
|
|
52
|
+
export function invalidateNativeComponentLayout(delays = [32, 96]) {
|
|
53
|
+
if (typeof window === "undefined")
|
|
54
|
+
return;
|
|
55
|
+
if (pendingLayoutInvalidationFrame === null) {
|
|
56
|
+
pendingLayoutInvalidationFrame = window.requestAnimationFrame(() => {
|
|
57
|
+
pendingLayoutInvalidationFrame = null;
|
|
58
|
+
dispatchNativeComponentLayoutInvalidated();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
const uniqueDelays = new Set(delays
|
|
62
|
+
.map((delay) => Math.round(delay))
|
|
63
|
+
.filter((delay) => delay > 0));
|
|
64
|
+
uniqueDelays.forEach((delay) => {
|
|
65
|
+
if (pendingLayoutInvalidationTimers.has(delay)) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const timer = window.setTimeout(() => {
|
|
69
|
+
pendingLayoutInvalidationTimers.delete(delay);
|
|
70
|
+
dispatchNativeComponentLayoutInvalidated();
|
|
71
|
+
}, delay);
|
|
72
|
+
pendingLayoutInvalidationTimers.set(delay, timer);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export function addNativeComponentLayoutInvalidationListener(listener) {
|
|
76
|
+
if (typeof window === "undefined")
|
|
77
|
+
return () => { };
|
|
78
|
+
window.addEventListener(NATIVE_COMPONENT_LAYOUT_INVALIDATED_EVENT, listener);
|
|
79
|
+
return () => {
|
|
80
|
+
window.removeEventListener(NATIVE_COMPONENT_LAYOUT_INVALIDATED_EVENT, listener);
|
|
81
|
+
};
|
|
82
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export type NavigatorOpenType = 'navigate' | 'redirect' | 'navigateBack' | 'reLaunch' | 'switchTab' | 'exit' | 'openUrl' | 'tel';
|
|
2
|
+
export type NavigatorTarget = 'self' | 'lxapp' | 'browser';
|
|
3
|
+
export interface LxNavigatorEventDetail {
|
|
4
|
+
success?: boolean;
|
|
5
|
+
errMsg?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface LxNavigatorEvent extends CustomEvent<LxNavigatorEventDetail> {
|
|
8
|
+
detail: LxNavigatorEventDetail;
|
|
9
|
+
}
|
|
10
|
+
export type LxNavigatorAttributes = {
|
|
11
|
+
url?: string;
|
|
12
|
+
'open-type'?: NavigatorOpenType;
|
|
13
|
+
target?: NavigatorTarget;
|
|
14
|
+
delta?: number;
|
|
15
|
+
'app-id'?: string;
|
|
16
|
+
path?: string;
|
|
17
|
+
'phone-number'?: string;
|
|
18
|
+
'hover-class'?: string;
|
|
19
|
+
'hover-stop-propagation'?: boolean;
|
|
20
|
+
'hover-start-time'?: number;
|
|
21
|
+
'hover-stay-time'?: number;
|
|
22
|
+
className?: string;
|
|
23
|
+
style?: any;
|
|
24
|
+
onSuccess?: (e: LxNavigatorEvent) => void;
|
|
25
|
+
onFail?: (e: LxNavigatorEvent) => void;
|
|
26
|
+
onComplete?: (e: LxNavigatorEvent) => void;
|
|
27
|
+
ref?: any;
|
|
28
|
+
children?: any;
|
|
29
|
+
};
|
|
30
|
+
declare global {
|
|
31
|
+
namespace JSX {
|
|
32
|
+
interface IntrinsicElements {
|
|
33
|
+
"lx-navigator": LxNavigatorAttributes;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
export declare class LxNavigatorElement extends HTMLElement {
|
|
38
|
+
static get observedAttributes(): string[];
|
|
39
|
+
private hoverClass;
|
|
40
|
+
private hoverStopPropagation;
|
|
41
|
+
private hoverStartTime;
|
|
42
|
+
private hoverStayTime;
|
|
43
|
+
private hoverTimer;
|
|
44
|
+
private isHovering;
|
|
45
|
+
private readonly onClick;
|
|
46
|
+
private readonly onTouchStart;
|
|
47
|
+
private readonly onTouchEnd;
|
|
48
|
+
private readonly onTouchCancel;
|
|
49
|
+
private readonly onMouseEnter;
|
|
50
|
+
private readonly onMouseLeave;
|
|
51
|
+
private readonly clickListener;
|
|
52
|
+
private readonly touchStartListener;
|
|
53
|
+
private readonly touchEndListener;
|
|
54
|
+
private readonly touchCancelListener;
|
|
55
|
+
private readonly mouseEnterListener;
|
|
56
|
+
private readonly mouseLeaveListener;
|
|
57
|
+
connectedCallback(): void;
|
|
58
|
+
disconnectedCallback(): void;
|
|
59
|
+
attributeChangedCallback(name: string, oldValue: string | null, newValue: string | null): void;
|
|
60
|
+
private applyDefaultStyles;
|
|
61
|
+
private setupHoverEffect;
|
|
62
|
+
private setupClickHandler;
|
|
63
|
+
private handleTouchStart;
|
|
64
|
+
private handleTouchEnd;
|
|
65
|
+
private handleTouchCancel;
|
|
66
|
+
private handleMouseEnter;
|
|
67
|
+
private handleMouseLeave;
|
|
68
|
+
private addHoverClass;
|
|
69
|
+
private removeHoverClass;
|
|
70
|
+
private clearHoverTimer;
|
|
71
|
+
private handleClick;
|
|
72
|
+
/**
|
|
73
|
+
* Auto-infer navigation target based on context
|
|
74
|
+
* Priority: explicit target > appId > HTTPS URL > default (self)
|
|
75
|
+
*/
|
|
76
|
+
private inferTarget;
|
|
77
|
+
private navigate;
|
|
78
|
+
private dispatchSuccess;
|
|
79
|
+
private resolveErrorMessage;
|
|
80
|
+
private dispatchFail;
|
|
81
|
+
private getHostApi;
|
|
82
|
+
private performNavigation;
|
|
83
|
+
}
|