@lingxia/vue 0.6.0 → 0.6.5

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.
@@ -0,0 +1,96 @@
1
+ <script setup lang="ts">
2
+ import { computed, h, onBeforeUnmount, ref, useAttrs, useId, watch } from 'vue';
3
+ import {
4
+ buildMediaSwiperNativeAttrs,
5
+ MEDIA_SWIPER_DOM_EVENT_MAP,
6
+ registerMediaSwiperComponent,
7
+ } from '@lingxia/elements';
8
+ import { bindElementEvents, unbindElementEvents } from './text_component_shared.js';
9
+ import type { LxMediaSwiperProps } from './types.js';
10
+
11
+ const props = withDefaults(defineProps<LxMediaSwiperProps>(), {
12
+ loop: false,
13
+ autoplay: false,
14
+ interval: 5000,
15
+ animation: 'slide',
16
+ direction: 'horizontal',
17
+ objectFit: 'cover',
18
+ controls: false,
19
+ muted: true,
20
+ dots: false,
21
+ swipeEnabled: true,
22
+ });
23
+ const attrs = useAttrs();
24
+
25
+ const emit = defineEmits<{
26
+ change: [e: Event];
27
+ transitionEnd: [e: Event];
28
+ endReached: [e: Event];
29
+ tap: [e: Event];
30
+ videoEnded: [e: Event];
31
+ error: [e: Event];
32
+ }>();
33
+
34
+ if (typeof window !== 'undefined') {
35
+ registerMediaSwiperComponent();
36
+ }
37
+
38
+ const elementRef = ref<HTMLElement | null>(null);
39
+ const vueId = useId();
40
+ let boundElement: HTMLElement | null = null;
41
+
42
+ const resolvedId = computed(() => props.id || `lx-media-swiper-${vueId.replace(/[:]/g, '')}`);
43
+
44
+ const eventListeners: Record<string, EventListenerObject> = {
45
+ [MEDIA_SWIPER_DOM_EVENT_MAP.onChange]: { handleEvent: (event: Event) => emit('change', event) },
46
+ [MEDIA_SWIPER_DOM_EVENT_MAP.onTransitionEnd]: { handleEvent: (event: Event) => emit('transitionEnd', event) },
47
+ [MEDIA_SWIPER_DOM_EVENT_MAP.onEndReached]: { handleEvent: (event: Event) => emit('endReached', event) },
48
+ [MEDIA_SWIPER_DOM_EVENT_MAP.onTap]: { handleEvent: (event: Event) => emit('tap', event) },
49
+ [MEDIA_SWIPER_DOM_EVENT_MAP.onVideoEnded]: { handleEvent: (event: Event) => emit('videoEnded', event) },
50
+ [MEDIA_SWIPER_DOM_EVENT_MAP.onError]: { handleEvent: (event: Event) => emit('error', event) },
51
+ };
52
+
53
+ watch(elementRef, (element) => {
54
+ boundElement = bindElementEvents(boundElement, element, eventListeners);
55
+ });
56
+
57
+ onBeforeUnmount(() => {
58
+ unbindElementEvents(boundElement, eventListeners);
59
+ });
60
+
61
+ watch(
62
+ [elementRef, () => props.pageBindings],
63
+ () => {
64
+ const el = elementRef.value as any;
65
+ if (el) {
66
+ el.pageBindings = props.pageBindings ?? {};
67
+ }
68
+ },
69
+ { immediate: true }
70
+ );
71
+
72
+ const domProps = computed(() => {
73
+ const result = buildMediaSwiperNativeAttrs({
74
+ ...props,
75
+ id: resolvedId.value,
76
+ }, attrs as Record<string, unknown>);
77
+ return {
78
+ ...result,
79
+ class: props.class ?? attrs.class,
80
+ style: props.style ?? attrs.style,
81
+ };
82
+ });
83
+
84
+ defineExpose({
85
+ el: elementRef,
86
+ next: () => (elementRef.value as any)?.next?.(),
87
+ previous: () => (elementRef.value as any)?.previous?.(),
88
+ goToIndex: (index: number) => (elementRef.value as any)?.goToIndex?.(index),
89
+ });
90
+
91
+ const render = () => h('lx-media-swiper', { ref: elementRef, ...domProps.value });
92
+ </script>
93
+
94
+ <template>
95
+ <render />
96
+ </template>
package/dist/LxVideo.vue CHANGED
@@ -69,15 +69,15 @@ onBeforeUnmount(() => {
69
69
  });
70
70
 
71
71
  watch(
72
- [elementRef, () => props.rotate, () => props.objectFit],
72
+ [elementRef, () => props.contentRotate, () => props.objectFit],
73
73
  () => {
74
74
  const el = elementRef.value;
75
75
  if (!el) return;
76
- const rotate = props.rotate;
77
- if (rotate === undefined || rotate === null || rotate === '') {
78
- el.removeAttribute('rotate');
76
+ const contentRotate = props.contentRotate;
77
+ if (contentRotate === undefined || contentRotate === null || contentRotate === '') {
78
+ el.removeAttribute('content-rotate');
79
79
  } else {
80
- el.setAttribute('rotate', String(rotate).trim());
80
+ el.setAttribute('content-rotate', String(contentRotate).trim());
81
81
  }
82
82
  const objectFit = props.objectFit;
83
83
  if (objectFit === undefined || objectFit === null || objectFit === '') {
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  export { useLxPage, useLxStream, useLxChannel, type LxStreamOptions, type LxStreamState, type LxChannelOptions, type LxChannelState, } from "./hook.js";
2
2
  export { default as LxVideo } from "./LxVideo.vue";
3
+ export { default as LxMediaSwiper } from "./LxMediaSwiper.vue";
3
4
  export { default as LxPicker } from "./LxPicker.vue";
4
5
  export { default as LxNavigator } from "./LxNavigator.vue";
5
6
  export { default as LxInput } from "./LxInput.vue";
6
7
  export { default as LxTextarea } from "./LxTextarea.vue";
7
- export type { LxVideoProps, LxPickerProps, LxNavigatorProps, LxNavigatorEvent, LxInputProps, LxTextareaProps, } from "./types.js";
8
+ export type { LxVideoProps, LxMediaSwiperProps, LxPickerProps, LxNavigatorProps, LxNavigatorEvent, LxInputProps, LxTextareaProps, } from "./types.js";
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  export { useLxPage, useLxStream, useLxChannel, } from "./hook.js";
2
2
  export { default as LxVideo } from "./LxVideo.vue";
3
+ export { default as LxMediaSwiper } from "./LxMediaSwiper.vue";
3
4
  export { default as LxPicker } from "./LxPicker.vue";
4
5
  export { default as LxNavigator } from "./LxNavigator.vue";
5
6
  export { default as LxInput } from "./LxInput.vue";
package/dist/types.d.ts CHANGED
@@ -1,10 +1,14 @@
1
1
  import type { CSSProperties } from 'vue';
2
- import type { LxVideoAttributes } from '@lingxia/elements';
2
+ import type { LxMediaSwiperAttributes, LxVideoAttributes } from '@lingxia/elements';
3
3
  import type { LxNavigatorEvent, NavigatorEnvVersion, NavigatorOpenType, NavigatorQuery, NavigatorTarget } from '@lingxia/elements';
4
4
  export interface LxVideoProps extends Omit<LxVideoAttributes, 'ref' | 'className' | 'style'> {
5
5
  class?: string;
6
6
  style?: CSSProperties;
7
7
  }
8
+ export interface LxMediaSwiperProps extends Omit<LxMediaSwiperAttributes, 'ref' | 'className' | 'style'> {
9
+ class?: string;
10
+ style?: CSSProperties;
11
+ }
8
12
  export interface LxPickerProps {
9
13
  columns?: string[][] | [string[], Record<string, string[]>];
10
14
  mode?: 'date' | 'time';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxia/vue",
3
- "version": "0.6.0",
3
+ "version": "0.6.5",
4
4
  "private": false,
5
5
  "description": "LingXia Vue runtime and components for lxapp pages",
6
6
  "type": "module",
@@ -19,9 +19,9 @@
19
19
  "prepublishOnly": "npm run build"
20
20
  },
21
21
  "dependencies": {
22
- "@lingxia/bridge": "0.6.0",
23
- "@lingxia/elements": "0.6.0",
24
- "@lingxia/page-runtime": "0.6.0"
22
+ "@lingxia/bridge": "0.6.5",
23
+ "@lingxia/elements": "0.6.5",
24
+ "@lingxia/page-runtime": "0.6.5"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "vue": ">=3.5.0"