@lingxia/vue 0.9.0 → 0.11.1
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/LxPicker.vue +3 -5
- package/dist/hook.d.ts +14 -0
- package/dist/hook.js +24 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +1 -3
- package/dist/types.d.ts +0 -59
- package/package.json +5 -5
- package/dist/LxInput.vue +0 -92
- package/dist/LxTextarea.vue +0 -90
package/dist/LxPicker.vue
CHANGED
|
@@ -21,7 +21,7 @@ const emit = defineEmits<{
|
|
|
21
21
|
'update:modelValue': [value: string | string[]];
|
|
22
22
|
confirm: [value: string | string[]];
|
|
23
23
|
cancel: [];
|
|
24
|
-
|
|
24
|
+
columnChange: [value: string | string[]];
|
|
25
25
|
}>();
|
|
26
26
|
|
|
27
27
|
if (typeof window !== 'undefined') {
|
|
@@ -45,7 +45,6 @@ const pickerEventListeners: Record<string, EventListenerObject> = {
|
|
|
45
45
|
const displayText = computed(() => getPickerDisplayText(props.modelValue, props.fields));
|
|
46
46
|
|
|
47
47
|
function handleChange(e: Event) {
|
|
48
|
-
props.onChange?.(e);
|
|
49
48
|
const detail = getCustomEventDetail<{
|
|
50
49
|
confirmed?: boolean;
|
|
51
50
|
cancelled?: boolean;
|
|
@@ -70,15 +69,14 @@ function handleChange(e: Event) {
|
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
function handleScroll(e: Event) {
|
|
73
|
-
props.onNativeScroll?.(e);
|
|
74
72
|
const detail = getCustomEventDetail<{
|
|
75
73
|
value?: string | string[];
|
|
76
74
|
index?: number | number[];
|
|
77
75
|
}>(e);
|
|
78
76
|
if (detail.value !== undefined) {
|
|
79
|
-
emit('
|
|
77
|
+
emit('columnChange', detail.value);
|
|
80
78
|
} else if (detail.index !== undefined) {
|
|
81
|
-
emit('
|
|
79
|
+
emit('columnChange', getPickerValueFromIndex(props.columns, detail.index));
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
|
package/dist/hook.d.ts
CHANGED
|
@@ -40,4 +40,18 @@ export interface LxChannelState<TData, TOut = TData> {
|
|
|
40
40
|
export declare function useLxChannel<TMethod extends (...args: any[]) => Promise<LxChannel<any, any>>>(method: MethodSource<TMethod>, options?: LxChannelOptions & {
|
|
41
41
|
params?: ParamsSource<MethodParams<TMethod>>;
|
|
42
42
|
}): LxChannelState<ChannelIn<TMethod>, ChannelOut<TMethod>>;
|
|
43
|
+
export interface LxPlatform {
|
|
44
|
+
os: string;
|
|
45
|
+
isIOS: boolean;
|
|
46
|
+
isMacOS: boolean;
|
|
47
|
+
isApple: boolean;
|
|
48
|
+
isAndroid: boolean;
|
|
49
|
+
isHarmony: boolean;
|
|
50
|
+
isWindows: boolean;
|
|
51
|
+
isDesktop: boolean;
|
|
52
|
+
isRunner: boolean;
|
|
53
|
+
}
|
|
54
|
+
export declare function usePlatform(): LxPlatform;
|
|
55
|
+
/** Effective product language selected by the host. */
|
|
56
|
+
export declare function useDisplayLanguage(): string;
|
|
43
57
|
export {};
|
package/dist/hook.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { onUnmounted, reactive, ref, unref, watch, } from "vue";
|
|
2
|
+
import { getDisplayLanguage } from "@lingxia/bridge";
|
|
2
3
|
import { getMethodKey, invokeMethod, resolveParams, stableParamKey, toBridgeError, } from "@lingxia/bridge/invocation";
|
|
3
4
|
import { ensurePageBridgeSubscription, getPageActions, subscribePageData, } from "@lingxia/page-runtime";
|
|
4
5
|
function resolveMethod(source) {
|
|
@@ -191,3 +192,26 @@ export function useLxChannel(method, options) {
|
|
|
191
192
|
});
|
|
192
193
|
return { last, error, connecting, connected, send, close, reopen };
|
|
193
194
|
}
|
|
195
|
+
function readPlatform() {
|
|
196
|
+
const p = window.LingXiaBridge?.platform;
|
|
197
|
+
return {
|
|
198
|
+
os: p?.getOS() ?? "unknown",
|
|
199
|
+
isIOS: p?.isIOS() ?? false,
|
|
200
|
+
isMacOS: p?.isMacOS() ?? false,
|
|
201
|
+
isApple: p?.isApple() ?? false,
|
|
202
|
+
isAndroid: p?.isAndroid() ?? false,
|
|
203
|
+
isHarmony: p?.isHarmony() ?? false,
|
|
204
|
+
isWindows: p?.isWindows() ?? false,
|
|
205
|
+
isDesktop: p?.isDesktop() ?? false,
|
|
206
|
+
isRunner: p?.isRunner() ?? false,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
// Typed platform detection for pages, so they never reach for the window global
|
|
210
|
+
// or hand-roll an OS check. Fixed for the session, so it resolves once.
|
|
211
|
+
export function usePlatform() {
|
|
212
|
+
return readPlatform();
|
|
213
|
+
}
|
|
214
|
+
/** Effective product language selected by the host. */
|
|
215
|
+
export function useDisplayLanguage() {
|
|
216
|
+
return getDisplayLanguage();
|
|
217
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
export { useLxPage, useLxStream, useLxChannel, type LxStreamOptions, type LxStreamState, type LxChannelOptions, type LxChannelState, } from "./hook.js";
|
|
1
|
+
export { useLxPage, useLxStream, useLxChannel, usePlatform, useDisplayLanguage, type LxStreamOptions, type LxStreamState, type LxChannelOptions, type LxChannelState, type LxPlatform, } from "./hook.js";
|
|
2
2
|
export { default as LxVideo } from "./LxVideo.vue";
|
|
3
3
|
export { default as LxMediaSwiper } from "./LxMediaSwiper.vue";
|
|
4
4
|
export { default as LxPicker } from "./LxPicker.vue";
|
|
5
5
|
export { default as LxNavigator } from "./LxNavigator.vue";
|
|
6
|
-
export {
|
|
7
|
-
export { default as LxTextarea } from "./LxTextarea.vue";
|
|
8
|
-
export type { LxVideoProps, LxMediaSwiperProps, LxPickerProps, LxNavigatorProps, LxNavigatorEvent, LxInputProps, LxTextareaProps, } from "./types.js";
|
|
6
|
+
export type { LxVideoProps, LxMediaSwiperProps, LxPickerProps, LxNavigatorProps, LxNavigatorEvent, } from "./types.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
export { useLxPage, useLxStream, useLxChannel, } from "./hook.js";
|
|
1
|
+
export { useLxPage, useLxStream, useLxChannel, usePlatform, useDisplayLanguage, } from "./hook.js";
|
|
2
2
|
export { default as LxVideo } from "./LxVideo.vue";
|
|
3
3
|
export { default as LxMediaSwiper } from "./LxMediaSwiper.vue";
|
|
4
4
|
export { default as LxPicker } from "./LxPicker.vue";
|
|
5
5
|
export { default as LxNavigator } from "./LxNavigator.vue";
|
|
6
|
-
export { default as LxInput } from "./LxInput.vue";
|
|
7
|
-
export { default as LxTextarea } from "./LxTextarea.vue";
|
package/dist/types.d.ts
CHANGED
|
@@ -26,8 +26,6 @@ export interface LxPickerProps {
|
|
|
26
26
|
confirmText?: string;
|
|
27
27
|
confirmTextColor?: string;
|
|
28
28
|
confirmButtonColor?: string;
|
|
29
|
-
onChange?: (event: Event) => void;
|
|
30
|
-
onNativeScroll?: (event: Event) => void;
|
|
31
29
|
pageBindings?: Record<string, string>;
|
|
32
30
|
}
|
|
33
31
|
export interface LxNavigatorProps {
|
|
@@ -49,61 +47,4 @@ export interface LxNavigatorProps {
|
|
|
49
47
|
class?: string;
|
|
50
48
|
style?: CSSProperties;
|
|
51
49
|
}
|
|
52
|
-
export interface LxInputProps {
|
|
53
|
-
id?: string;
|
|
54
|
-
modelValue?: string;
|
|
55
|
-
value?: string;
|
|
56
|
-
defaultValue?: string;
|
|
57
|
-
type?: 'text' | 'number' | 'password' | 'digit';
|
|
58
|
-
password?: boolean;
|
|
59
|
-
placeholder?: string;
|
|
60
|
-
placeholderStyle?: string;
|
|
61
|
-
placeholderClass?: string;
|
|
62
|
-
maxlength?: number;
|
|
63
|
-
cursorSpacing?: number;
|
|
64
|
-
autoFocus?: boolean;
|
|
65
|
-
disabled?: boolean;
|
|
66
|
-
focus?: boolean;
|
|
67
|
-
confirmType?: 'send' | 'search' | 'next' | 'go' | 'done';
|
|
68
|
-
alwaysEmbed?: boolean;
|
|
69
|
-
confirmHold?: boolean;
|
|
70
|
-
cursor?: number;
|
|
71
|
-
cursorColor?: string;
|
|
72
|
-
selectionStart?: number;
|
|
73
|
-
selectionEnd?: number;
|
|
74
|
-
adjustPosition?: boolean;
|
|
75
|
-
holdKeyboard?: boolean;
|
|
76
|
-
class?: string;
|
|
77
|
-
style?: CSSProperties;
|
|
78
|
-
pageBindings?: Record<string, string>;
|
|
79
|
-
}
|
|
80
|
-
export interface LxTextareaProps {
|
|
81
|
-
id?: string;
|
|
82
|
-
modelValue?: string;
|
|
83
|
-
value?: string;
|
|
84
|
-
defaultValue?: string;
|
|
85
|
-
placeholder?: string;
|
|
86
|
-
placeholderStyle?: string;
|
|
87
|
-
placeholderClass?: string;
|
|
88
|
-
maxlength?: number;
|
|
89
|
-
disabled?: boolean;
|
|
90
|
-
autoFocus?: boolean;
|
|
91
|
-
focus?: boolean;
|
|
92
|
-
autoHeight?: boolean;
|
|
93
|
-
cursorSpacing?: number;
|
|
94
|
-
showConfirmBar?: boolean;
|
|
95
|
-
adjustPosition?: boolean;
|
|
96
|
-
holdKeyboard?: boolean;
|
|
97
|
-
disableDefaultPadding?: boolean;
|
|
98
|
-
confirmType?: 'send' | 'search' | 'next' | 'go' | 'done' | 'return';
|
|
99
|
-
confirmHold?: boolean;
|
|
100
|
-
fixed?: boolean;
|
|
101
|
-
adjustKeyboardTo?: 'cursor' | 'bottom';
|
|
102
|
-
cursor?: number;
|
|
103
|
-
selectionStart?: number;
|
|
104
|
-
selectionEnd?: number;
|
|
105
|
-
class?: string;
|
|
106
|
-
style?: CSSProperties;
|
|
107
|
-
pageBindings?: Record<string, string>;
|
|
108
|
-
}
|
|
109
50
|
export type { LxNavigatorEvent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lingxia/vue",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "LingXia Vue runtime and components for lxapp pages",
|
|
6
6
|
"type": "module",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"./package.json": "./package.json"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "npm run clean && npm --prefix ../lingxia-elements run build && npm --prefix ../lingxia-page-runtime run build && tsc -p tsconfig.json &&
|
|
17
|
+
"build": "npm run clean && npm --prefix ../lingxia-elements run build && npm --prefix ../lingxia-page-runtime run build && tsc -p tsconfig.json && node scripts/copy-sfc-assets.mjs",
|
|
18
18
|
"clean": "rm -rf dist",
|
|
19
19
|
"prepublishOnly": "npm run build"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@lingxia/bridge": "0.
|
|
23
|
-
"@lingxia/elements": "0.
|
|
24
|
-
"@lingxia/page-runtime": "0.
|
|
22
|
+
"@lingxia/bridge": "^0.11.1",
|
|
23
|
+
"@lingxia/elements": "^0.11.1",
|
|
24
|
+
"@lingxia/page-runtime": "^0.11.1"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"vue": ">=3.5.0"
|
package/dist/LxInput.vue
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, h, onBeforeUnmount, ref, useAttrs, watch } from 'vue';
|
|
3
|
-
import { registerInputComponent } from '@lingxia/elements';
|
|
4
|
-
import { buildInputNativeAttrs } from '@lingxia/elements';
|
|
5
|
-
import type { LxInputProps } from './types.js';
|
|
6
|
-
import {
|
|
7
|
-
bindElementEvents,
|
|
8
|
-
getCustomEventDetail,
|
|
9
|
-
unbindElementEvents,
|
|
10
|
-
} from './text_component_shared.js';
|
|
11
|
-
|
|
12
|
-
const props = withDefaults(defineProps<LxInputProps>(), {
|
|
13
|
-
type: 'text',
|
|
14
|
-
disabled: false,
|
|
15
|
-
confirmType: 'done',
|
|
16
|
-
});
|
|
17
|
-
const attrs = useAttrs();
|
|
18
|
-
|
|
19
|
-
const emit = defineEmits<{
|
|
20
|
-
'update:modelValue': [value: string];
|
|
21
|
-
input: [detail: Record<string, unknown>];
|
|
22
|
-
change: [detail: Record<string, unknown>];
|
|
23
|
-
focus: [detail: Record<string, unknown>];
|
|
24
|
-
blur: [detail: Record<string, unknown>];
|
|
25
|
-
confirm: [detail: Record<string, unknown>];
|
|
26
|
-
keyboardHeightChange: [detail: Record<string, unknown>];
|
|
27
|
-
nicknameReview: [detail: Record<string, unknown>];
|
|
28
|
-
}>();
|
|
29
|
-
|
|
30
|
-
if (typeof window !== 'undefined') {
|
|
31
|
-
registerInputComponent();
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const elementRef = ref<HTMLElement | null>(null);
|
|
35
|
-
let boundElement: HTMLElement | null = null;
|
|
36
|
-
|
|
37
|
-
const inputEventListeners: Record<string, EventListenerObject> = {
|
|
38
|
-
input: {
|
|
39
|
-
handleEvent: (event: Event) => {
|
|
40
|
-
const detail = getCustomEventDetail<Record<string, unknown>>(event);
|
|
41
|
-
if (typeof detail.value === 'string') {
|
|
42
|
-
emit('update:modelValue', detail.value);
|
|
43
|
-
}
|
|
44
|
-
emit('input', detail);
|
|
45
|
-
},
|
|
46
|
-
},
|
|
47
|
-
change: {
|
|
48
|
-
handleEvent: (event: Event) => emit('change', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
49
|
-
},
|
|
50
|
-
focus: {
|
|
51
|
-
handleEvent: (event: Event) => emit('focus', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
52
|
-
},
|
|
53
|
-
blur: {
|
|
54
|
-
handleEvent: (event: Event) => emit('blur', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
55
|
-
},
|
|
56
|
-
confirm: {
|
|
57
|
-
handleEvent: (event: Event) => emit('confirm', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
58
|
-
},
|
|
59
|
-
keyboardheightchange: {
|
|
60
|
-
handleEvent: (event: Event) => emit('keyboardHeightChange', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
61
|
-
},
|
|
62
|
-
nicknamereview: {
|
|
63
|
-
handleEvent: (event: Event) => emit('nicknameReview', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
watch(elementRef, (element) => {
|
|
68
|
-
boundElement = bindElementEvents(boundElement, element, inputEventListeners);
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
onBeforeUnmount(() => {
|
|
72
|
-
unbindElementEvents(boundElement, inputEventListeners);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
const inputProps = computed<Record<string, unknown>>(() => {
|
|
76
|
-
const result: Record<string, unknown> = buildInputNativeAttrs({
|
|
77
|
-
...props,
|
|
78
|
-
id: props.id ?? (typeof attrs.id === 'string' ? attrs.id : undefined),
|
|
79
|
-
}, attrs as Record<string, unknown>, elementRef.value !== null);
|
|
80
|
-
result.class = props.class ?? attrs.class;
|
|
81
|
-
result.style = props.style ?? attrs.style;
|
|
82
|
-
return result;
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
defineExpose({ el: elementRef });
|
|
86
|
-
|
|
87
|
-
const renderInput = () => h('lx-input', { ref: elementRef, ...inputProps.value });
|
|
88
|
-
</script>
|
|
89
|
-
|
|
90
|
-
<template>
|
|
91
|
-
<renderInput />
|
|
92
|
-
</template>
|
package/dist/LxTextarea.vue
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { computed, h, onBeforeUnmount, ref, useAttrs, watch } from 'vue';
|
|
3
|
-
import { registerTextareaComponent } from '@lingxia/elements';
|
|
4
|
-
import { buildTextareaNativeAttrs } from '@lingxia/elements';
|
|
5
|
-
import type { LxTextareaProps } from './types.js';
|
|
6
|
-
import {
|
|
7
|
-
bindElementEvents,
|
|
8
|
-
getCustomEventDetail,
|
|
9
|
-
unbindElementEvents,
|
|
10
|
-
} from './text_component_shared.js';
|
|
11
|
-
|
|
12
|
-
const props = withDefaults(defineProps<LxTextareaProps>(), {
|
|
13
|
-
disabled: false,
|
|
14
|
-
});
|
|
15
|
-
const attrs = useAttrs();
|
|
16
|
-
|
|
17
|
-
const emit = defineEmits<{
|
|
18
|
-
'update:modelValue': [value: string];
|
|
19
|
-
input: [detail: Record<string, unknown>];
|
|
20
|
-
change: [detail: Record<string, unknown>];
|
|
21
|
-
focus: [detail: Record<string, unknown>];
|
|
22
|
-
blur: [detail: Record<string, unknown>];
|
|
23
|
-
confirm: [detail: Record<string, unknown>];
|
|
24
|
-
lineChange: [detail: Record<string, unknown>];
|
|
25
|
-
keyboardHeightChange: [detail: Record<string, unknown>];
|
|
26
|
-
}>();
|
|
27
|
-
|
|
28
|
-
if (typeof window !== 'undefined') {
|
|
29
|
-
registerTextareaComponent();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const elementRef = ref<HTMLElement | null>(null);
|
|
33
|
-
let boundElement: HTMLElement | null = null;
|
|
34
|
-
|
|
35
|
-
const textareaEventListeners: Record<string, EventListenerObject> = {
|
|
36
|
-
input: {
|
|
37
|
-
handleEvent: (event: Event) => {
|
|
38
|
-
const detail = getCustomEventDetail<Record<string, unknown>>(event);
|
|
39
|
-
if (typeof detail.value === 'string') {
|
|
40
|
-
emit('update:modelValue', detail.value);
|
|
41
|
-
}
|
|
42
|
-
emit('input', detail);
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
change: {
|
|
46
|
-
handleEvent: (event: Event) => emit('change', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
47
|
-
},
|
|
48
|
-
focus: {
|
|
49
|
-
handleEvent: (event: Event) => emit('focus', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
50
|
-
},
|
|
51
|
-
blur: {
|
|
52
|
-
handleEvent: (event: Event) => emit('blur', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
53
|
-
},
|
|
54
|
-
confirm: {
|
|
55
|
-
handleEvent: (event: Event) => emit('confirm', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
56
|
-
},
|
|
57
|
-
linechange: {
|
|
58
|
-
handleEvent: (event: Event) => emit('lineChange', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
59
|
-
},
|
|
60
|
-
keyboardheightchange: {
|
|
61
|
-
handleEvent: (event: Event) => emit('keyboardHeightChange', getCustomEventDetail<Record<string, unknown>>(event)),
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
watch(elementRef, (element) => {
|
|
66
|
-
boundElement = bindElementEvents(boundElement, element, textareaEventListeners);
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
onBeforeUnmount(() => {
|
|
70
|
-
unbindElementEvents(boundElement, textareaEventListeners);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
const textareaProps = computed<Record<string, unknown>>(() => {
|
|
74
|
-
const result: Record<string, unknown> = buildTextareaNativeAttrs({
|
|
75
|
-
...props,
|
|
76
|
-
id: props.id ?? (typeof attrs.id === 'string' ? attrs.id : undefined),
|
|
77
|
-
}, attrs as Record<string, unknown>, elementRef.value !== null);
|
|
78
|
-
result.class = props.class ?? attrs.class;
|
|
79
|
-
result.style = props.style ?? attrs.style;
|
|
80
|
-
return result;
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
defineExpose({ el: elementRef });
|
|
84
|
-
|
|
85
|
-
const renderTextarea = () => h('lx-textarea', { ref: elementRef, ...textareaProps.value });
|
|
86
|
-
</script>
|
|
87
|
-
|
|
88
|
-
<template>
|
|
89
|
-
<renderTextarea />
|
|
90
|
-
</template>
|