@lingxia/elements 0.6.3 → 0.7.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/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  export { registerVideoComponent, LxVideoElement, type LxVideoAttributes, } from "./video.js";
2
+ export { registerMediaSwiperComponent, LxMediaSwiperElement, type LxMediaSwiperAttributes, type LxMediaSwiperItem, type LxMediaSwiperChangeEvent, type LxMediaSwiperChangeEventDetail, type LxMediaSwiperTransitionEndEvent, type LxMediaSwiperTransitionEndEventDetail, type LxMediaSwiperItemEvent, type LxMediaSwiperEventDetail, type LxMediaSwiperEndReachedEvent, type LxMediaSwiperEndReachedEventDetail, type LxMediaSwiperErrorEvent, type LxMediaSwiperErrorEventDetail, type LxMediaSwiperChangeSource, type LxMediaSwiperErrorCode, } from "./media_swiper.js";
2
3
  export { registerPickerComponent, LxPickerElement, type LxPickerAttributes, type LxPickerColumn, type LxPickerCascadingColumns, type LxPickerEvent, type LxPickerEventDetail, } from "./picker.js";
3
4
  export { registerInputComponent, LxInputElement, type LxInputAttributes, type LxInputEvent, type LxInputEventDetail, } from "./input.js";
4
5
  export { registerTextareaComponent, LxTextareaElement, type LxTextareaAttributes, type LxTextareaEvent, type LxTextareaEventDetail, } from "./textarea.js";
5
6
  export { LxNavigatorElement, type LxNavigatorAttributes, type LxNavigatorEvent, type NavigatorEnvVersion, type NavigatorOpenType, type NavigatorQuery, type NavigatorQueryValue, type NavigatorTarget, } from "./navigator.js";
6
- export { buildVideoNativeAttrs, buildNavigatorNativeAttrs, buildPickerNativeAttrs, getPickerDisplayText, getPickerValueFromIndex, VIDEO_DOM_EVENT_MAP, } from "./native_component_wrapper_shared.js";
7
+ export { buildVideoNativeAttrs, buildMediaSwiperNativeAttrs, buildNavigatorNativeAttrs, buildPickerNativeAttrs, getPickerDisplayText, getPickerValueFromIndex, VIDEO_DOM_EVENT_MAP, MEDIA_SWIPER_DOM_EVENT_MAP, } from "./native_component_wrapper_shared.js";
7
8
  export { buildInputNativeAttrs, buildTextareaNativeAttrs, } from "./text_component_native_attrs.js";
8
9
  export { isHarmony, isIOS, isAndroid, isMacOS, isDesktop, getOS, } from "./platform.js";
9
10
  export { ensureComponentId, rectEquals, NativeComponentUpdateState, type Rect, } from "./component.js";
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
1
  export { registerVideoComponent, LxVideoElement, } from "./video.js";
2
+ export { registerMediaSwiperComponent, LxMediaSwiperElement, } from "./media_swiper.js";
2
3
  export { registerPickerComponent, LxPickerElement, } from "./picker.js";
3
4
  export { registerInputComponent, LxInputElement, } from "./input.js";
4
5
  export { registerTextareaComponent, LxTextareaElement, } from "./textarea.js";
5
6
  export { LxNavigatorElement, } from "./navigator.js";
6
- export { buildVideoNativeAttrs, buildNavigatorNativeAttrs, buildPickerNativeAttrs, getPickerDisplayText, getPickerValueFromIndex, VIDEO_DOM_EVENT_MAP, } from "./native_component_wrapper_shared.js";
7
+ export { buildVideoNativeAttrs, buildMediaSwiperNativeAttrs, buildNavigatorNativeAttrs, buildPickerNativeAttrs, getPickerDisplayText, getPickerValueFromIndex, VIDEO_DOM_EVENT_MAP, MEDIA_SWIPER_DOM_EVENT_MAP, } from "./native_component_wrapper_shared.js";
7
8
  export { buildInputNativeAttrs, buildTextareaNativeAttrs, } from "./text_component_native_attrs.js";
8
9
  export { isHarmony, isIOS, isAndroid, isMacOS, isDesktop, getOS, } from "./platform.js";
9
10
  export { ensureComponentId, rectEquals, NativeComponentUpdateState, } from "./component.js";
@@ -0,0 +1,182 @@
1
+ type LxMediaSwiperEventHandler = (e: Event) => void;
2
+ export type LxMediaSwiperItem = {
3
+ id?: string;
4
+ type: "image";
5
+ src: string;
6
+ } | {
7
+ id?: string;
8
+ type: "video";
9
+ src: string;
10
+ poster?: string;
11
+ controls?: boolean;
12
+ muted?: boolean;
13
+ };
14
+ export type LxMediaSwiperChangeSource = "touch" | "autoplay" | "api" | "video";
15
+ export type LxMediaSwiperErrorCode = "not_found" | "network" | "decode" | "unsupported_format" | "permission_denied" | "unknown";
16
+ export type LxMediaSwiperEventDetail = {
17
+ index: number;
18
+ item: LxMediaSwiperItem;
19
+ };
20
+ export type LxMediaSwiperChangeEventDetail = {
21
+ index: number;
22
+ previousIndex: number;
23
+ item: LxMediaSwiperItem;
24
+ source: LxMediaSwiperChangeSource;
25
+ };
26
+ export type LxMediaSwiperTransitionEndEventDetail = LxMediaSwiperChangeEventDetail;
27
+ export type LxMediaSwiperEndReachedEventDetail = {
28
+ index: number;
29
+ item: LxMediaSwiperItem;
30
+ source: LxMediaSwiperChangeSource;
31
+ };
32
+ export type LxMediaSwiperErrorEventDetail = {
33
+ index: number;
34
+ item?: LxMediaSwiperItem;
35
+ code: LxMediaSwiperErrorCode;
36
+ message: string;
37
+ };
38
+ export type LxMediaSwiperChangeEvent = CustomEvent<LxMediaSwiperChangeEventDetail>;
39
+ export type LxMediaSwiperTransitionEndEvent = CustomEvent<LxMediaSwiperTransitionEndEventDetail>;
40
+ export type LxMediaSwiperItemEvent = CustomEvent<LxMediaSwiperEventDetail>;
41
+ export type LxMediaSwiperEndReachedEvent = CustomEvent<LxMediaSwiperEndReachedEventDetail>;
42
+ export type LxMediaSwiperErrorEvent = CustomEvent<LxMediaSwiperErrorEventDetail>;
43
+ /**
44
+ * Peek leaves part of the previous and next pages visible alongside the current
45
+ * page so users get a hint that more content exists. A single `number` applies
46
+ * symmetric peek on both edges; an object lets the two sides differ.
47
+ *
48
+ * For `direction="vertical"`, `previous` peeks the top edge and `next` peeks
49
+ * the bottom edge.
50
+ *
51
+ * Values are CSS pixels (DIPs). `0` (default) disables peek and behaves
52
+ * identically to v1: each page fills the swiper bounds.
53
+ */
54
+ export type LxMediaSwiperPeek = number | {
55
+ previous?: number;
56
+ next?: number;
57
+ };
58
+ export type LxMediaSwiperAttributes = {
59
+ id?: string;
60
+ items?: LxMediaSwiperItem[];
61
+ index?: number;
62
+ initialIndex?: number;
63
+ loop?: boolean;
64
+ autoplay?: boolean;
65
+ interval?: number;
66
+ animation?: "slide" | "none";
67
+ animationDuration?: number;
68
+ direction?: "horizontal" | "vertical";
69
+ contentRotate?: 0 | 90 | 180 | 270;
70
+ objectFit?: "cover" | "contain" | "fill" | "fit";
71
+ controls?: boolean;
72
+ muted?: boolean;
73
+ dots?: boolean | {
74
+ color?: string;
75
+ activeColor?: string;
76
+ };
77
+ swipeEnabled?: boolean;
78
+ peek?: LxMediaSwiperPeek;
79
+ className?: string;
80
+ style?: any;
81
+ ref?: any;
82
+ onChange?: LxMediaSwiperEventHandler;
83
+ onTransitionEnd?: LxMediaSwiperEventHandler;
84
+ onEndReached?: LxMediaSwiperEventHandler;
85
+ onTap?: LxMediaSwiperEventHandler;
86
+ onVideoEnded?: LxMediaSwiperEventHandler;
87
+ onError?: LxMediaSwiperEventHandler;
88
+ pageBindings?: Record<string, string>;
89
+ };
90
+ declare global {
91
+ namespace JSX {
92
+ interface IntrinsicElements {
93
+ "lx-media-swiper": LxMediaSwiperAttributes;
94
+ }
95
+ }
96
+ }
97
+ export declare class LxMediaSwiperElement extends HTMLElement {
98
+ static get observedAttributes(): string[];
99
+ private componentId;
100
+ private mounted;
101
+ private updateState;
102
+ private unregister?;
103
+ private resizeObserver?;
104
+ private pendingLayoutFrame;
105
+ private boundUpdatePosition;
106
+ private removeLayoutInvalidationListener?;
107
+ private iOSHelper?;
108
+ private rawHandlers;
109
+ private handlers;
110
+ private _pageBindings;
111
+ private harmonyCommandSeq;
112
+ private harmonyPendingCommand;
113
+ private pendingHarmonyProps?;
114
+ private pendingHarmonyRetryTimer;
115
+ private pendingHarmonyRetryCount;
116
+ private harmonyEmbed?;
117
+ private lastHarmonyProps?;
118
+ set items(value: LxMediaSwiperItem[] | string | null | undefined);
119
+ get items(): LxMediaSwiperItem[];
120
+ set index(value: number | null | undefined);
121
+ get index(): number | undefined;
122
+ set initialIndex(value: number | null | undefined);
123
+ get initialIndex(): number | undefined;
124
+ set contentRotate(value: unknown);
125
+ get contentRotate(): 0 | 90 | 180 | 270 | undefined;
126
+ set pageBindings(bindings: Record<string, string>);
127
+ get pageBindings(): Record<string, string>;
128
+ set pageFuncBindings(bindings: Record<string, string>);
129
+ setPageBindings(bindings: Record<string, string>): void;
130
+ next(): void;
131
+ previous(): void;
132
+ goToIndex(index: number): void;
133
+ connectedCallback(): void;
134
+ disconnectedCallback(): void;
135
+ attributeChangedCallback(name: string): void;
136
+ set onchange(cb: EventListener);
137
+ get onchange(): EventListener;
138
+ set ontransitionend(cb: EventListener);
139
+ get ontransitionend(): EventListener;
140
+ set onendreached(cb: EventListener);
141
+ get onendreached(): EventListener;
142
+ set ontap(cb: EventListener);
143
+ get ontap(): EventListener;
144
+ set onvideoended(cb: EventListener);
145
+ get onvideoended(): EventListener;
146
+ private sendCommand;
147
+ private collectProps;
148
+ private mountOrUpdate;
149
+ private mountOrUpdateHarmony;
150
+ private ensureHarmonyEmbed;
151
+ private encodeHarmonyProps;
152
+ private pushHarmonyPropsUpdate;
153
+ private scheduleHarmonyPropsRetry;
154
+ private flushHarmonyCommandIfPending;
155
+ private updatePosition;
156
+ private startTracking;
157
+ private stopTracking;
158
+ private startSizeObserver;
159
+ private stopSizeObserver;
160
+ private scheduleMountRetry;
161
+ private ensurePlaceholderStyle;
162
+ private upgradeProperty;
163
+ private isEventListener;
164
+ private setEventHandler;
165
+ private getEventHandler;
166
+ private parseItems;
167
+ private parseDots;
168
+ private parseIntegerAttr;
169
+ private parseRotate;
170
+ private parseObjectFit;
171
+ private parseAnimation;
172
+ private parseDirection;
173
+ /**
174
+ * Parse the `peek` attribute into a normalised `{ previous, next }` shape.
175
+ * Returns `undefined` when no peek is configured so native sides can fall back
176
+ * to the zero-peek (full-width page) layout.
177
+ */
178
+ private parsePeek;
179
+ private collectDataset;
180
+ }
181
+ export declare function registerMediaSwiperComponent(): void;
182
+ export {};