@lingxia/page-runtime 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.
Files changed (54) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/react/LxInput.d.ts +47 -0
  4. package/dist/react/LxInput.js +128 -0
  5. package/dist/react/LxNavigator.d.ts +23 -0
  6. package/dist/react/LxNavigator.js +61 -0
  7. package/dist/react/LxPicker.d.ts +27 -0
  8. package/dist/react/LxPicker.js +113 -0
  9. package/dist/react/LxTextarea.d.ts +47 -0
  10. package/dist/react/LxTextarea.js +118 -0
  11. package/dist/react/LxVideo.d.ts +5 -0
  12. package/dist/react/LxVideo.js +113 -0
  13. package/dist/react/hook.d.ts +39 -0
  14. package/dist/react/hook.js +212 -0
  15. package/dist/react/index.d.ts +6 -0
  16. package/dist/react/index.js +6 -0
  17. package/dist/react/text_component_shared.d.ts +5 -0
  18. package/dist/react/text_component_shared.js +33 -0
  19. package/dist/shared/runtime.d.ts +21 -0
  20. package/dist/shared/runtime.js +142 -0
  21. package/dist/vue/LxInput.vue +92 -0
  22. package/dist/vue/LxNavigator.vue +79 -0
  23. package/dist/vue/LxPicker.vue +144 -0
  24. package/dist/vue/LxTextarea.vue +90 -0
  25. package/dist/vue/LxVideo.vue +111 -0
  26. package/dist/vue/hook.d.ts +42 -0
  27. package/dist/vue/hook.js +194 -0
  28. package/dist/vue/index.d.ts +7 -0
  29. package/dist/vue/index.js +6 -0
  30. package/dist/vue/text_component_shared.d.ts +3 -0
  31. package/dist/vue/text_component_shared.js +26 -0
  32. package/dist/vue/types.d.ts +101 -0
  33. package/dist/vue/types.js +1 -0
  34. package/package.json +67 -0
  35. package/src/index.ts +21 -0
  36. package/src/react/LxInput.tsx +224 -0
  37. package/src/react/LxNavigator.tsx +132 -0
  38. package/src/react/LxPicker.tsx +205 -0
  39. package/src/react/LxTextarea.tsx +216 -0
  40. package/src/react/LxVideo.tsx +166 -0
  41. package/src/react/hook.ts +317 -0
  42. package/src/react/index.ts +14 -0
  43. package/src/react/text_component_shared.ts +43 -0
  44. package/src/shared/runtime.ts +186 -0
  45. package/src/vue/LxInput.vue +92 -0
  46. package/src/vue/LxNavigator.vue +79 -0
  47. package/src/vue/LxPicker.vue +144 -0
  48. package/src/vue/LxTextarea.vue +90 -0
  49. package/src/vue/LxVideo.vue +111 -0
  50. package/src/vue/hook.ts +313 -0
  51. package/src/vue/index.ts +22 -0
  52. package/src/vue/shims-vue.d.ts +5 -0
  53. package/src/vue/text_component_shared.ts +33 -0
  54. package/src/vue/types.ts +107 -0
@@ -0,0 +1 @@
1
+ export { ensurePageBridgeSubscription, getPageActions, getPageSnapshot, getPageStateInfo, subscribePageData, subscribePageSnapshot, toBridgeError, resolveParams, stableParamKey, invokeMethod, getMethodKey, type ActionMap, type Snapshot, type ParamsSource, type MethodParams, type StreamData, type StreamResult, type ChannelIn, type ChannelOut, } from "./shared/runtime.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export { ensurePageBridgeSubscription, getPageActions, getPageSnapshot, getPageStateInfo, subscribePageData, subscribePageSnapshot, toBridgeError, resolveParams, stableParamKey, invokeMethod, getMethodKey, } from "./shared/runtime.js";
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ export interface LxInputEventDetail {
3
+ value?: string;
4
+ cursor?: number;
5
+ keyCode?: number;
6
+ height?: number;
7
+ duration?: number;
8
+ encryptedValue?: string;
9
+ encryptError?: string;
10
+ pass?: boolean;
11
+ timeout?: boolean;
12
+ }
13
+ export interface LxInputProps {
14
+ id?: string;
15
+ value?: string;
16
+ defaultValue?: string;
17
+ type?: "text" | "number" | "password" | "digit";
18
+ password?: boolean;
19
+ placeholder?: string;
20
+ placeholderStyle?: string;
21
+ placeholderClass?: string;
22
+ maxlength?: number;
23
+ cursorSpacing?: number;
24
+ autoFocus?: boolean;
25
+ disabled?: boolean;
26
+ focus?: boolean;
27
+ confirmType?: "send" | "search" | "next" | "go" | "done";
28
+ alwaysEmbed?: boolean;
29
+ confirmHold?: boolean;
30
+ cursor?: number;
31
+ cursorColor?: string;
32
+ selectionStart?: number;
33
+ selectionEnd?: number;
34
+ adjustPosition?: boolean;
35
+ holdKeyboard?: boolean;
36
+ onInput?: (detail: LxInputEventDetail) => void;
37
+ onChange?: (detail: LxInputEventDetail) => void;
38
+ onFocus?: (detail: LxInputEventDetail) => void;
39
+ onBlur?: (detail: LxInputEventDetail) => void;
40
+ onConfirm?: (detail: LxInputEventDetail) => void;
41
+ onKeyboardHeightChange?: (detail: LxInputEventDetail) => void;
42
+ onNicknameReview?: (detail: LxInputEventDetail) => void;
43
+ pageBindings?: Record<string, string>;
44
+ className?: string;
45
+ style?: React.CSSProperties;
46
+ }
47
+ export declare const LxInput: React.ForwardRefExoticComponent<LxInputProps & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,128 @@
1
+ import React, { forwardRef, useCallback, useEffect, useRef } from "react";
2
+ import { registerInputComponent } from "@lingxia/elements";
3
+ import { buildInputNativeAttrs } from "@lingxia/elements";
4
+ import { assignForwardedRef, bindElementEvents, getCustomEventDetail, unbindElementEvents, } from "./text_component_shared.js";
5
+ if (typeof window !== "undefined") {
6
+ registerInputComponent();
7
+ }
8
+ export const LxInput = forwardRef(({ value, defaultValue, type, password, placeholder, placeholderStyle, placeholderClass, maxlength, cursorSpacing, autoFocus, disabled, focus, confirmType, alwaysEmbed, confirmHold, cursor, cursorColor, selectionStart, selectionEnd, adjustPosition, holdKeyboard, onInput, onChange, onFocus, onBlur, onConfirm, onKeyboardHeightChange, onNicknameReview, pageBindings, className, style, id, ...rest }, ref) => {
9
+ const elementRef = useRef(null);
10
+ const boundElementRef = useRef(null);
11
+ const handlerRef = useRef({
12
+ onInput,
13
+ onChange,
14
+ onFocus,
15
+ onBlur,
16
+ onConfirm,
17
+ onKeyboardHeightChange,
18
+ onNicknameReview,
19
+ });
20
+ handlerRef.current = {
21
+ onInput,
22
+ onChange,
23
+ onFocus,
24
+ onBlur,
25
+ onConfirm,
26
+ onKeyboardHeightChange,
27
+ onNicknameReview,
28
+ };
29
+ const listenerMapRef = useRef({
30
+ input: {
31
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
32
+ },
33
+ change: {
34
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
35
+ },
36
+ focus: {
37
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
38
+ },
39
+ blur: {
40
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
41
+ },
42
+ confirm: {
43
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onConfirm) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
44
+ },
45
+ keyboardheightchange: {
46
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onKeyboardHeightChange) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
47
+ },
48
+ nicknamereview: {
49
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onNicknameReview) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
50
+ },
51
+ });
52
+ const elementRefCallback = useCallback((element) => {
53
+ boundElementRef.current = bindElementEvents(boundElementRef.current, element, listenerMapRef.current);
54
+ elementRef.current = element;
55
+ assignForwardedRef(ref, element);
56
+ }, [ref]);
57
+ useEffect(() => () => {
58
+ unbindElementEvents(boundElementRef.current, listenerMapRef.current);
59
+ boundElementRef.current = null;
60
+ elementRef.current = null;
61
+ }, []);
62
+ useEffect(() => {
63
+ const el = elementRef.current;
64
+ if (!el)
65
+ return;
66
+ const setAttr = (name, next) => {
67
+ if (next === null) {
68
+ el.removeAttribute(name);
69
+ return;
70
+ }
71
+ el.setAttribute(name, next);
72
+ };
73
+ if (type && String(type).trim().length > 0) {
74
+ el.setAttribute("type", String(type).trim().toLowerCase());
75
+ }
76
+ else {
77
+ el.removeAttribute("type");
78
+ }
79
+ if (password) {
80
+ el.setAttribute("password", "true");
81
+ }
82
+ else {
83
+ el.removeAttribute("password");
84
+ }
85
+ setAttr("value", value !== undefined ? String(value) : null);
86
+ setAttr("focus", focus !== undefined ? (focus ? "true" : "false") : null);
87
+ setAttr("maxlength", maxlength !== undefined ? String(maxlength) : null);
88
+ setAttr("placeholder-style", placeholderStyle ? String(placeholderStyle) : null);
89
+ }, [type, password, value, focus, maxlength, placeholderStyle]);
90
+ // Set pageBindings property on custom element
91
+ useEffect(() => {
92
+ const el = elementRef.current;
93
+ if (el && pageBindings) {
94
+ el.pageBindings = pageBindings;
95
+ }
96
+ }, [pageBindings]);
97
+ const inputProps = buildInputNativeAttrs({
98
+ id,
99
+ value,
100
+ defaultValue,
101
+ type,
102
+ password,
103
+ placeholder,
104
+ placeholderStyle,
105
+ placeholderClass,
106
+ maxlength,
107
+ cursorSpacing,
108
+ autoFocus,
109
+ disabled,
110
+ focus,
111
+ confirmType,
112
+ alwaysEmbed,
113
+ confirmHold,
114
+ cursor,
115
+ cursorColor,
116
+ selectionStart,
117
+ selectionEnd,
118
+ adjustPosition,
119
+ holdKeyboard,
120
+ }, rest, boundElementRef.current !== null);
121
+ return React.createElement("lx-input", {
122
+ ref: elementRefCallback,
123
+ className,
124
+ style,
125
+ ...inputProps,
126
+ });
127
+ });
128
+ LxInput.displayName = "LxInput";
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import type { LxNavigatorAttributes, LxNavigatorEvent, NavigatorOpenType, NavigatorTarget } from '@lingxia/elements';
3
+ import '@lingxia/elements';
4
+ export interface LxNavigatorProps extends Omit<LxNavigatorAttributes, 'onSuccess' | 'onFail' | 'onComplete'> {
5
+ url?: string;
6
+ openType?: NavigatorOpenType;
7
+ target?: NavigatorTarget;
8
+ delta?: number;
9
+ appId?: string;
10
+ path?: string;
11
+ phoneNumber?: string;
12
+ hoverClass?: string;
13
+ hoverStopPropagation?: boolean;
14
+ hoverStartTime?: number;
15
+ hoverStayTime?: number;
16
+ className?: string;
17
+ style?: React.CSSProperties;
18
+ onSuccess?: (e: LxNavigatorEvent) => void;
19
+ onFail?: (e: LxNavigatorEvent) => void;
20
+ onComplete?: (e: LxNavigatorEvent) => void;
21
+ children?: React.ReactNode;
22
+ }
23
+ export declare const LxNavigator: React.ForwardRefExoticComponent<Omit<LxNavigatorProps, "ref"> & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,61 @@
1
+ import React from 'react';
2
+ import { buildNavigatorNativeAttrs } from '@lingxia/elements';
3
+ // Import to ensure custom element is registered
4
+ import '@lingxia/elements';
5
+ export const LxNavigator = React.forwardRef((props, ref) => {
6
+ const { url, openType = 'navigate', target, // Auto-inferred, no default
7
+ delta = 1, appId, path, phoneNumber, hoverClass = 'navigator-hover', hoverStopPropagation = false, hoverStartTime = 20, hoverStayTime = 70, className, style, onSuccess, onFail, onComplete, children, ...rest } = props;
8
+ const elementRef = React.useRef(null);
9
+ React.useImperativeHandle(ref, () => elementRef.current);
10
+ React.useEffect(() => {
11
+ const element = elementRef.current;
12
+ if (!element)
13
+ return;
14
+ const handleSuccess = (e) => {
15
+ if (onSuccess) {
16
+ onSuccess(e);
17
+ }
18
+ };
19
+ const handleFail = (e) => {
20
+ if (onFail) {
21
+ onFail(e);
22
+ }
23
+ };
24
+ const handleComplete = (e) => {
25
+ if (onComplete) {
26
+ onComplete(e);
27
+ }
28
+ };
29
+ const successListener = { handleEvent: handleSuccess };
30
+ const failListener = { handleEvent: handleFail };
31
+ const completeListener = { handleEvent: handleComplete };
32
+ element.addEventListener('success', successListener);
33
+ element.addEventListener('fail', failListener);
34
+ element.addEventListener('complete', completeListener);
35
+ return () => {
36
+ element.removeEventListener('success', successListener);
37
+ element.removeEventListener('fail', failListener);
38
+ element.removeEventListener('complete', completeListener);
39
+ };
40
+ }, [onSuccess, onFail, onComplete]);
41
+ const navigatorProps = buildNavigatorNativeAttrs({
42
+ url,
43
+ openType,
44
+ target,
45
+ delta,
46
+ appId,
47
+ path,
48
+ phoneNumber,
49
+ hoverClass,
50
+ hoverStopPropagation,
51
+ hoverStartTime,
52
+ hoverStayTime,
53
+ }, rest);
54
+ return React.createElement('lx-navigator', {
55
+ ref: elementRef,
56
+ className,
57
+ style,
58
+ ...navigatorProps
59
+ }, children);
60
+ });
61
+ LxNavigator.displayName = 'LxNavigator';
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+ export interface LxPickerProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange' | 'onScroll'> {
3
+ columns?: string[][] | [string[], Record<string, string[]>];
4
+ mode?: 'date' | 'time';
5
+ start?: string;
6
+ end?: string;
7
+ fields?: 'year' | 'month' | 'day' | 'range';
8
+ value?: string | string[];
9
+ onConfirm?: (value: string | string[]) => void;
10
+ onCancel?: () => void;
11
+ onScroll?: (value: string | string[]) => void;
12
+ onChange?: (event: CustomEvent) => void;
13
+ onNativeScroll?: (event: CustomEvent) => void;
14
+ pageBindings?: Record<string, string>;
15
+ placeholder?: string;
16
+ className?: string;
17
+ style?: React.CSSProperties;
18
+ disabled?: boolean;
19
+ cancelText?: string;
20
+ cancelTextColor?: string;
21
+ cancelButtonColor?: string;
22
+ confirmText?: string;
23
+ confirmTextColor?: string;
24
+ confirmButtonColor?: string;
25
+ children?: React.ReactNode;
26
+ }
27
+ export declare const LxPicker: React.ForwardRefExoticComponent<LxPickerProps & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,113 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import React, { forwardRef, useCallback, useId, useRef, useState } from 'react';
3
+ import { registerPickerComponent } from '@lingxia/elements';
4
+ import { buildPickerNativeAttrs, getPickerDisplayText, getPickerValueFromIndex, } from '@lingxia/elements';
5
+ import { assignForwardedRef, bindElementEvents, getCustomEventDetail, unbindElementEvents, } from './text_component_shared.js';
6
+ if (typeof window !== "undefined") {
7
+ registerPickerComponent();
8
+ }
9
+ export const LxPicker = forwardRef(({ id, columns, mode, start, end, fields, value, onConfirm, onCancel, onScroll, placeholder = 'Please select', onChange, onNativeScroll, pageBindings, className, style, disabled, cancelText, cancelTextColor, cancelButtonColor, confirmText, confirmTextColor, confirmButtonColor, children, ...rest }, ref) => {
10
+ const [visible, setVisible] = useState(false);
11
+ const reactId = useId();
12
+ const pickerId = id !== null && id !== void 0 ? id : `lx-picker-${reactId.replace(/[:]/g, "")}`;
13
+ const elementRef = useRef(null);
14
+ const boundElementRef = useRef(null);
15
+ const handlerRef = useRef({
16
+ columns,
17
+ mode,
18
+ onConfirm,
19
+ onCancel,
20
+ onScroll,
21
+ onChange,
22
+ onNativeScroll,
23
+ });
24
+ handlerRef.current = {
25
+ columns,
26
+ mode,
27
+ onConfirm,
28
+ onCancel,
29
+ onScroll,
30
+ onChange,
31
+ onNativeScroll,
32
+ };
33
+ const listenerMapRef = useRef({
34
+ change: {
35
+ handleEvent: (event) => {
36
+ var _a, _b, _c, _d, _e, _f, _g;
37
+ const detail = getCustomEventDetail(event);
38
+ (_b = (_a = handlerRef.current).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, event);
39
+ if (detail.confirmed) {
40
+ const nextValue = handlerRef.current.mode === 'date' || handlerRef.current.mode === 'time'
41
+ ? ((_c = detail.value) !== null && _c !== void 0 ? _c : '')
42
+ : detail.index !== undefined
43
+ ? getPickerValueFromIndex(handlerRef.current.columns, detail.index)
44
+ : '';
45
+ (_e = (_d = handlerRef.current).onConfirm) === null || _e === void 0 ? void 0 : _e.call(_d, nextValue);
46
+ setVisible(false);
47
+ return;
48
+ }
49
+ if (detail.cancelled) {
50
+ (_g = (_f = handlerRef.current).onCancel) === null || _g === void 0 ? void 0 : _g.call(_f);
51
+ setVisible(false);
52
+ }
53
+ },
54
+ },
55
+ scroll: {
56
+ handleEvent: (event) => {
57
+ var _a, _b, _c, _d, _e, _f;
58
+ const detail = getCustomEventDetail(event);
59
+ (_b = (_a = handlerRef.current).onNativeScroll) === null || _b === void 0 ? void 0 : _b.call(_a, event);
60
+ if (detail.value !== undefined) {
61
+ (_d = (_c = handlerRef.current).onScroll) === null || _d === void 0 ? void 0 : _d.call(_c, detail.value);
62
+ return;
63
+ }
64
+ if (detail.index !== undefined) {
65
+ (_f = (_e = handlerRef.current).onScroll) === null || _f === void 0 ? void 0 : _f.call(_e, getPickerValueFromIndex(handlerRef.current.columns, detail.index));
66
+ }
67
+ },
68
+ },
69
+ });
70
+ const elementRefCallback = useCallback((element) => {
71
+ boundElementRef.current = bindElementEvents(boundElementRef.current, element, listenerMapRef.current);
72
+ elementRef.current = element;
73
+ assignForwardedRef(ref, element);
74
+ // Set pageBindings on custom element
75
+ if (element && pageBindings) {
76
+ element.pageBindings = pageBindings;
77
+ }
78
+ }, [ref, pageBindings]);
79
+ React.useEffect(() => () => {
80
+ unbindElementEvents(boundElementRef.current, listenerMapRef.current);
81
+ boundElementRef.current = null;
82
+ elementRef.current = null;
83
+ }, []);
84
+ const handleClick = () => !disabled && setVisible(true);
85
+ const pickerProps = buildPickerNativeAttrs({
86
+ id: pickerId,
87
+ columns,
88
+ mode,
89
+ start,
90
+ end,
91
+ fields,
92
+ value,
93
+ cancelText,
94
+ cancelTextColor,
95
+ cancelButtonColor,
96
+ confirmText,
97
+ confirmTextColor,
98
+ confirmButtonColor,
99
+ }, rest);
100
+ const displayText = getPickerDisplayText(value, fields);
101
+ return (_jsxs(_Fragment, { children: [children ? (_jsx("div", { onClick: handleClick, className: className, style: {
102
+ cursor: disabled ? 'not-allowed' : 'pointer',
103
+ opacity: disabled ? 0.5 : 1,
104
+ ...style,
105
+ }, children: children })) : (_jsxs("div", { onClick: handleClick, className: className, style: {
106
+ display: 'flex', alignItems: 'center', justifyContent: 'space-between',
107
+ padding: '12px 14px', backgroundColor: '#fff', border: '1px solid #e5e7eb',
108
+ borderRadius: '8px', cursor: disabled ? 'not-allowed' : 'pointer',
109
+ opacity: disabled ? 0.5 : 1, width: '100%', boxSizing: 'border-box',
110
+ ...style,
111
+ }, children: [_jsx("span", { style: { color: value ? '#111' : '#9ca3af' }, children: displayText || placeholder }), _jsx("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", children: _jsx("path", { d: "M6 9l6 6 6-6" }) })] })), visible && React.createElement('lx-picker', { ref: elementRefCallback, ...pickerProps })] }));
112
+ });
113
+ LxPicker.displayName = 'LxPicker';
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ export interface LxTextareaEventDetail {
3
+ value?: string;
4
+ cursor?: number;
5
+ lineCount?: number;
6
+ height?: number;
7
+ duration?: number;
8
+ selectionStart?: number;
9
+ selectionEnd?: number;
10
+ heightRpx?: number;
11
+ }
12
+ export interface LxTextareaProps {
13
+ id?: string;
14
+ value?: string;
15
+ defaultValue?: string;
16
+ placeholder?: string;
17
+ placeholderStyle?: string;
18
+ placeholderClass?: string;
19
+ maxlength?: number;
20
+ disabled?: boolean;
21
+ autoFocus?: boolean;
22
+ focus?: boolean;
23
+ autoHeight?: boolean;
24
+ cursorSpacing?: number;
25
+ showConfirmBar?: boolean;
26
+ adjustPosition?: boolean;
27
+ holdKeyboard?: boolean;
28
+ disableDefaultPadding?: boolean;
29
+ confirmType?: "send" | "search" | "next" | "go" | "done" | "return";
30
+ confirmHold?: boolean;
31
+ fixed?: boolean;
32
+ adjustKeyboardTo?: "cursor" | "bottom";
33
+ cursor?: number;
34
+ selectionStart?: number;
35
+ selectionEnd?: number;
36
+ onInput?: (detail: LxTextareaEventDetail) => void;
37
+ onChange?: (detail: LxTextareaEventDetail) => void;
38
+ onFocus?: (detail: LxTextareaEventDetail) => void;
39
+ onBlur?: (detail: LxTextareaEventDetail) => void;
40
+ onConfirm?: (detail: LxTextareaEventDetail) => void;
41
+ onLineChange?: (detail: LxTextareaEventDetail) => void;
42
+ onKeyboardHeightChange?: (detail: LxTextareaEventDetail) => void;
43
+ pageBindings?: Record<string, string>;
44
+ className?: string;
45
+ style?: React.CSSProperties;
46
+ }
47
+ export declare const LxTextarea: React.ForwardRefExoticComponent<LxTextareaProps & React.RefAttributes<HTMLElement>>;
@@ -0,0 +1,118 @@
1
+ import React, { forwardRef, useCallback, useEffect, useRef } from "react";
2
+ import { registerTextareaComponent } from "@lingxia/elements";
3
+ import { buildTextareaNativeAttrs } from "@lingxia/elements";
4
+ import { assignForwardedRef, bindElementEvents, getCustomEventDetail, unbindElementEvents, } from "./text_component_shared.js";
5
+ if (typeof window !== "undefined") {
6
+ registerTextareaComponent();
7
+ }
8
+ export const LxTextarea = forwardRef(({ value, defaultValue, placeholder, placeholderStyle, placeholderClass, maxlength, disabled, autoFocus, focus, autoHeight, cursorSpacing, showConfirmBar, adjustPosition, holdKeyboard, disableDefaultPadding, confirmType, confirmHold, fixed, adjustKeyboardTo, cursor, selectionStart, selectionEnd, onInput, onChange, onFocus, onBlur, onConfirm, onLineChange, onKeyboardHeightChange, pageBindings, className, style, id, ...rest }, ref) => {
9
+ const elementRef = useRef(null);
10
+ const boundElementRef = useRef(null);
11
+ const handlerRef = useRef({
12
+ onInput,
13
+ onChange,
14
+ onFocus,
15
+ onBlur,
16
+ onConfirm,
17
+ onLineChange,
18
+ onKeyboardHeightChange,
19
+ });
20
+ handlerRef.current = {
21
+ onInput,
22
+ onChange,
23
+ onFocus,
24
+ onBlur,
25
+ onConfirm,
26
+ onLineChange,
27
+ onKeyboardHeightChange,
28
+ };
29
+ const listenerMapRef = useRef({
30
+ input: {
31
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onInput) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
32
+ },
33
+ change: {
34
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onChange) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
35
+ },
36
+ focus: {
37
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onFocus) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
38
+ },
39
+ blur: {
40
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onBlur) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
41
+ },
42
+ confirm: {
43
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onConfirm) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
44
+ },
45
+ linechange: {
46
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onLineChange) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
47
+ },
48
+ keyboardheightchange: {
49
+ handleEvent: (event) => { var _a, _b; return (_b = (_a = handlerRef.current).onKeyboardHeightChange) === null || _b === void 0 ? void 0 : _b.call(_a, getCustomEventDetail(event)); },
50
+ },
51
+ });
52
+ const elementRefCallback = useCallback((element) => {
53
+ boundElementRef.current = bindElementEvents(boundElementRef.current, element, listenerMapRef.current);
54
+ elementRef.current = element;
55
+ assignForwardedRef(ref, element);
56
+ }, [ref]);
57
+ useEffect(() => () => {
58
+ unbindElementEvents(boundElementRef.current, listenerMapRef.current);
59
+ boundElementRef.current = null;
60
+ elementRef.current = null;
61
+ }, []);
62
+ React.useEffect(() => {
63
+ const el = elementRef.current;
64
+ if (!el)
65
+ return;
66
+ const setAttr = (name, next) => {
67
+ if (next === null) {
68
+ el.removeAttribute(name);
69
+ return;
70
+ }
71
+ el.setAttribute(name, next);
72
+ };
73
+ setAttr("value", value !== undefined ? String(value) : null);
74
+ setAttr("focus", focus !== undefined ? (focus ? "true" : "false") : null);
75
+ setAttr("maxlength", maxlength !== undefined ? String(maxlength) : null);
76
+ setAttr("placeholder-style", placeholderStyle ? String(placeholderStyle) : null);
77
+ setAttr("auto-height", autoHeight ? "true" : null);
78
+ }, [value, focus, maxlength, placeholderStyle, autoHeight]);
79
+ // Set pageBindings property on custom element
80
+ useEffect(() => {
81
+ const el = elementRef.current;
82
+ if (el && pageBindings) {
83
+ el.pageBindings = pageBindings;
84
+ }
85
+ }, [pageBindings]);
86
+ const textareaProps = buildTextareaNativeAttrs({
87
+ id,
88
+ value,
89
+ defaultValue,
90
+ placeholder,
91
+ placeholderStyle,
92
+ placeholderClass,
93
+ maxlength,
94
+ disabled,
95
+ autoFocus,
96
+ focus,
97
+ autoHeight,
98
+ cursorSpacing,
99
+ showConfirmBar,
100
+ adjustPosition,
101
+ holdKeyboard,
102
+ disableDefaultPadding,
103
+ confirmType,
104
+ confirmHold,
105
+ fixed,
106
+ adjustKeyboardTo,
107
+ cursor,
108
+ selectionStart,
109
+ selectionEnd,
110
+ }, rest, boundElementRef.current !== null);
111
+ return React.createElement("lx-textarea", {
112
+ ref: elementRefCallback,
113
+ className,
114
+ style,
115
+ ...textareaProps,
116
+ });
117
+ });
118
+ LxTextarea.displayName = "LxTextarea";
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ import { type LxVideoAttributes } from '@lingxia/elements';
3
+ export interface LxVideoProps extends LxVideoAttributes, Omit<React.HTMLAttributes<HTMLElement>, keyof LxVideoAttributes | "children" | "dangerouslySetInnerHTML" | "ref" | "onPlaying"> {
4
+ }
5
+ export declare const LxVideo: React.ForwardRefExoticComponent<Omit<LxVideoProps, "ref"> & React.RefAttributes<HTMLElement>>;