@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.
Files changed (46) hide show
  1. package/dist/component.d.ts +50 -0
  2. package/dist/component.js +139 -0
  3. package/dist/dom.d.ts +10 -0
  4. package/dist/dom.js +70 -0
  5. package/dist/index.d.ts +9 -0
  6. package/dist/index.js +9 -0
  7. package/dist/input.d.ts +117 -0
  8. package/dist/input.js +699 -0
  9. package/dist/native_component_wrapper_shared.d.ts +74 -0
  10. package/dist/native_component_wrapper_shared.js +193 -0
  11. package/dist/nativecomponent.d.ts +6 -0
  12. package/dist/nativecomponent.js +82 -0
  13. package/dist/navigator.d.ts +83 -0
  14. package/dist/navigator.js +388 -0
  15. package/dist/picker-web.d.ts +2 -0
  16. package/dist/picker-web.js +727 -0
  17. package/dist/picker.d.ts +77 -0
  18. package/dist/picker.js +342 -0
  19. package/dist/platform.d.ts +6 -0
  20. package/dist/platform.js +24 -0
  21. package/dist/text_component_native_attrs.d.ts +53 -0
  22. package/dist/text_component_native_attrs.js +111 -0
  23. package/dist/text_component_shared.d.ts +7 -0
  24. package/dist/text_component_shared.js +148 -0
  25. package/dist/textarea.d.ts +129 -0
  26. package/dist/textarea.js +841 -0
  27. package/dist/types.d.ts +21 -0
  28. package/dist/types.js +1 -0
  29. package/dist/video.d.ts +134 -0
  30. package/dist/video.js +741 -0
  31. package/package.json +39 -0
  32. package/src/component.ts +164 -0
  33. package/src/dom.ts +83 -0
  34. package/src/index.ts +69 -0
  35. package/src/input.ts +799 -0
  36. package/src/native_component_wrapper_shared.ts +243 -0
  37. package/src/nativecomponent.ts +97 -0
  38. package/src/navigator.ts +533 -0
  39. package/src/picker-web.ts +719 -0
  40. package/src/picker.ts +418 -0
  41. package/src/platform.ts +25 -0
  42. package/src/text_component_native_attrs.ts +137 -0
  43. package/src/text_component_shared.ts +147 -0
  44. package/src/textarea.ts +959 -0
  45. package/src/types.ts +20 -0
  46. package/src/video.ts +855 -0
@@ -0,0 +1,77 @@
1
+ export type LxPickerColumn = string[];
2
+ export type LxPickerCascadingColumns = [string[], Record<string, string[]>];
3
+ type LxPickerViewEventHandler = (e: LxPickerEvent) => void;
4
+ export interface LxPickerEventDetail {
5
+ index?: number | number[];
6
+ value?: string | string[];
7
+ confirmed?: boolean;
8
+ cancelled?: boolean;
9
+ }
10
+ export interface LxPickerEvent extends CustomEvent<LxPickerEventDetail> {
11
+ detail: LxPickerEventDetail;
12
+ }
13
+ export type LxPickerAttributes = {
14
+ id?: string;
15
+ mode?: 'selector' | 'multiSelector' | 'cascading' | 'date' | 'time';
16
+ columns?: LxPickerColumn[] | LxPickerCascadingColumns;
17
+ defaultIndex?: number | number[];
18
+ value?: string;
19
+ start?: string;
20
+ end?: string;
21
+ fields?: 'year' | 'month' | 'day' | 'range';
22
+ cancelText?: string;
23
+ confirmText?: string;
24
+ cancelButtonColor?: string;
25
+ confirmButtonColor?: string;
26
+ cancelTextColor?: string;
27
+ confirmTextColor?: string;
28
+ className?: string;
29
+ style?: any;
30
+ ref?: any;
31
+ onChange?: LxPickerViewEventHandler;
32
+ onScroll?: LxPickerViewEventHandler;
33
+ pageBindings?: Record<string, string>;
34
+ };
35
+ declare global {
36
+ namespace JSX {
37
+ interface IntrinsicElements {
38
+ "lx-picker": LxPickerAttributes;
39
+ }
40
+ }
41
+ }
42
+ export declare class LxPickerElement extends HTMLElement {
43
+ static get observedAttributes(): string[];
44
+ private componentId;
45
+ private mounted;
46
+ private unregister?;
47
+ private _handlers;
48
+ private rawHandlers;
49
+ private _pageBindings;
50
+ private harmonyEmbed?;
51
+ private lastHarmonyProps?;
52
+ private webCleanup?;
53
+ private attrObserver?;
54
+ private removeLayoutInvalidationListener?;
55
+ private readonly layoutInvalidationListener;
56
+ private upgradeProperty;
57
+ set pageBindings(bindings: Record<string, string>);
58
+ get pageBindings(): Record<string, string>;
59
+ connectedCallback(): void;
60
+ disconnectedCallback(): void;
61
+ attributeChangedCallback(name: string): void;
62
+ private getAttr;
63
+ private getJsonAttr;
64
+ private collectProps;
65
+ private shouldRefreshForAttribute;
66
+ private startAttrObserver;
67
+ private stopAttrObserver;
68
+ private dataAttrToDatasetKey;
69
+ private collectDataset;
70
+ private mountPicker;
71
+ set onchange(cb: EventListener | null);
72
+ get onchange(): EventListener | null;
73
+ private ensureHarmonyEmbed;
74
+ private encodeHarmonyProps;
75
+ }
76
+ export declare function registerPickerComponent(): void;
77
+ export {};
package/dist/picker.js ADDED
@@ -0,0 +1,342 @@
1
+ import { sendNativeComponentMessage, registerNativeComponentHandler, addNativeComponentLayoutInvalidationListener } from "./nativecomponent.js";
2
+ import { ensureComponentId } from "./component.js";
3
+ import { measureElement } from "./dom.js";
4
+ import { isAndroid, isHarmony, isDesktop } from "./platform.js";
5
+ const HARMONY_PROPS_PREFIX = "data:application/json,";
6
+ // Component implementation
7
+ export class LxPickerElement extends HTMLElement {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.componentId = null;
11
+ this.mounted = false;
12
+ this._handlers = {};
13
+ this.rawHandlers = {};
14
+ this._pageBindings = {};
15
+ this.layoutInvalidationListener = {
16
+ handleEvent: () => {
17
+ if (!this.isConnected || isHarmony() || isDesktop())
18
+ return;
19
+ void this.mountPicker();
20
+ }
21
+ };
22
+ }
23
+ static get observedAttributes() {
24
+ return [
25
+ "id",
26
+ "mode",
27
+ "columns",
28
+ "default-index",
29
+ "value",
30
+ "start",
31
+ "end",
32
+ "fields",
33
+ "cancel-text",
34
+ "confirm-text",
35
+ "cancel-button-color",
36
+ "confirm-button-color",
37
+ "cancel-text-color",
38
+ "confirm-text-color"
39
+ ];
40
+ }
41
+ upgradeProperty(propName) {
42
+ const self = this;
43
+ if (!Object.prototype.hasOwnProperty.call(self, propName))
44
+ return;
45
+ const value = self[propName];
46
+ delete self[propName];
47
+ self[propName] = value;
48
+ }
49
+ set pageBindings(bindings) {
50
+ this._pageBindings = bindings !== null && bindings !== void 0 ? bindings : {};
51
+ if (this.isConnected) {
52
+ this.mountPicker();
53
+ }
54
+ }
55
+ get pageBindings() {
56
+ return this._pageBindings;
57
+ }
58
+ connectedCallback() {
59
+ this.upgradeProperty("pageBindings");
60
+ this.upgradeProperty("onchange");
61
+ this.componentId = ensureComponentId(this, "lx-picker", this.componentId);
62
+ if (!this.componentId)
63
+ return;
64
+ this.unregister = registerNativeComponentHandler(this.componentId, (message) => {
65
+ var _a;
66
+ if (typeof message.event === "string") {
67
+ this.dispatchEvent(new CustomEvent(message.event, { detail: (_a = message.detail) !== null && _a !== void 0 ? _a : {}, bubbles: true }));
68
+ }
69
+ });
70
+ this.startAttrObserver();
71
+ if (isAndroid()) {
72
+ this.removeLayoutInvalidationListener = addNativeComponentLayoutInvalidationListener(this.layoutInvalidationListener);
73
+ }
74
+ this.mountPicker();
75
+ queueMicrotask(() => {
76
+ if (!this.isConnected)
77
+ return;
78
+ this.mountPicker();
79
+ });
80
+ }
81
+ disconnectedCallback() {
82
+ var _a;
83
+ if (this.webCleanup) {
84
+ this.webCleanup();
85
+ this.webCleanup = undefined;
86
+ }
87
+ (_a = this.removeLayoutInvalidationListener) === null || _a === void 0 ? void 0 : _a.call(this);
88
+ this.removeLayoutInvalidationListener = undefined;
89
+ if (this.componentId && !isHarmony() && !isDesktop()) {
90
+ sendNativeComponentMessage({
91
+ action: "component.unmount",
92
+ id: this.componentId
93
+ });
94
+ }
95
+ if (this.unregister) {
96
+ this.unregister();
97
+ this.unregister = undefined;
98
+ }
99
+ if (this.harmonyEmbed && this.contains(this.harmonyEmbed)) {
100
+ this.removeChild(this.harmonyEmbed);
101
+ }
102
+ this.harmonyEmbed = undefined;
103
+ this.lastHarmonyProps = undefined;
104
+ this.mounted = false;
105
+ this.stopAttrObserver();
106
+ Object.keys(this._handlers).forEach(name => {
107
+ this.removeEventListener(name, this._handlers[name]);
108
+ });
109
+ this._handlers = {};
110
+ this.rawHandlers = {};
111
+ }
112
+ attributeChangedCallback(name) {
113
+ if (name === "id") {
114
+ const prev = this.componentId;
115
+ this.componentId = ensureComponentId(this, "lx-picker", this.componentId);
116
+ if (prev && this.componentId !== prev) {
117
+ this.mounted = false;
118
+ }
119
+ }
120
+ if (!this.isConnected)
121
+ return;
122
+ this.mountPicker();
123
+ }
124
+ getAttr(name, fallback = "") {
125
+ return this.getAttribute(name) || fallback;
126
+ }
127
+ getJsonAttr(name) {
128
+ const raw = this.getAttribute(name);
129
+ if (!raw)
130
+ return undefined;
131
+ try {
132
+ return JSON.parse(raw);
133
+ }
134
+ catch {
135
+ return undefined;
136
+ }
137
+ }
138
+ collectProps() {
139
+ const mode = this.getAttr("mode", "selector");
140
+ const isDateMode = mode === "date" || mode === "time";
141
+ const fields = this.getAttr("fields");
142
+ const props = {
143
+ mode,
144
+ cancelText: this.getAttr("cancel-text", ""),
145
+ confirmText: this.getAttr("confirm-text", ""),
146
+ cancelButtonColor: this.getAttr("cancel-button-color"),
147
+ confirmButtonColor: this.getAttr("confirm-button-color"),
148
+ cancelTextColor: this.getAttr("cancel-text-color"),
149
+ confirmTextColor: this.getAttr("confirm-text-color")
150
+ };
151
+ if (isDateMode) {
152
+ if (fields)
153
+ props.fields = fields;
154
+ const value = this.getAttr("value");
155
+ if (value) {
156
+ props.value = fields === "range" ? this.getJsonAttr("value") : value;
157
+ }
158
+ const start = this.getAttr("start");
159
+ if (start)
160
+ props.start = start;
161
+ const end = this.getAttr("end");
162
+ if (end)
163
+ props.end = end;
164
+ }
165
+ else {
166
+ props.columns = this.getJsonAttr("columns");
167
+ props.defaultIndex = this.getJsonAttr("default-index");
168
+ }
169
+ return props;
170
+ }
171
+ shouldRefreshForAttribute(name) {
172
+ const normalized = name.trim().toLowerCase();
173
+ return normalized.startsWith("data-");
174
+ }
175
+ startAttrObserver() {
176
+ if (typeof MutationObserver === "undefined" || this.attrObserver) {
177
+ return;
178
+ }
179
+ this.attrObserver = new MutationObserver((mutations) => {
180
+ for (const mutation of mutations) {
181
+ const attrName = mutation.attributeName;
182
+ if (!attrName || !this.shouldRefreshForAttribute(attrName)) {
183
+ continue;
184
+ }
185
+ this.mountPicker();
186
+ break;
187
+ }
188
+ });
189
+ this.attrObserver.observe(this, { attributes: true });
190
+ }
191
+ stopAttrObserver() {
192
+ if (!this.attrObserver) {
193
+ return;
194
+ }
195
+ this.attrObserver.disconnect();
196
+ this.attrObserver = undefined;
197
+ }
198
+ dataAttrToDatasetKey(attr) {
199
+ const raw = attr.slice(5).trim();
200
+ if (!raw)
201
+ return "";
202
+ const parts = raw.split("-").filter(Boolean);
203
+ if (parts.length === 0)
204
+ return "";
205
+ return parts
206
+ .map((segment, index) => {
207
+ if (index === 0)
208
+ return segment.toLowerCase();
209
+ return segment.charAt(0).toUpperCase() + segment.slice(1);
210
+ })
211
+ .join("");
212
+ }
213
+ collectDataset() {
214
+ const dataset = {};
215
+ const attrs = this.getAttributeNames();
216
+ for (const attr of attrs) {
217
+ if (!attr.startsWith("data-"))
218
+ continue;
219
+ const key = this.dataAttrToDatasetKey(attr);
220
+ if (!key)
221
+ continue;
222
+ const value = this.getAttribute(attr);
223
+ if (value == null)
224
+ continue;
225
+ dataset[key] = value;
226
+ }
227
+ return dataset;
228
+ }
229
+ async mountPicker() {
230
+ if (!this.componentId)
231
+ return;
232
+ const props = this.collectProps();
233
+ const dataset = this.collectDataset();
234
+ props.dataset = dataset;
235
+ props.datasetJson = JSON.stringify(dataset);
236
+ props.pageFuncBindings = this._pageBindings;
237
+ props.pageFuncBindingsJson = JSON.stringify(this._pageBindings);
238
+ const { rect, cornerRadius } = measureElement(this);
239
+ if (isHarmony()) {
240
+ this.ensureHarmonyEmbed(rect, props, cornerRadius);
241
+ this.mounted = true;
242
+ return;
243
+ }
244
+ if (isDesktop()) {
245
+ if (this.webCleanup)
246
+ return;
247
+ const { renderWebPicker } = await import('./picker-web.js');
248
+ if (!this.isConnected || !this.componentId || this.webCleanup)
249
+ return;
250
+ this.webCleanup = renderWebPicker(this, props, (detail) => {
251
+ this.dispatchEvent(new CustomEvent('change', { detail, bubbles: true }));
252
+ });
253
+ this.mounted = true;
254
+ return;
255
+ }
256
+ const payload = {
257
+ action: this.mounted ? "component.update" : "component.mount",
258
+ id: this.componentId,
259
+ type: "picker.native",
260
+ rect,
261
+ zIndex: 9999,
262
+ props: props
263
+ };
264
+ if (cornerRadius !== undefined) {
265
+ payload.cornerRadius = cornerRadius;
266
+ }
267
+ sendNativeComponentMessage(payload);
268
+ this.mounted = true;
269
+ }
270
+ // Event handler getter/setter for 'change' event
271
+ set onchange(cb) {
272
+ const raw = cb;
273
+ const current = this._handlers['change'];
274
+ if (current)
275
+ this.removeEventListener('change', current);
276
+ if (typeof raw === "function" ||
277
+ (!!raw && typeof raw === "object" && typeof raw.handleEvent === "function")) {
278
+ const listener = typeof raw === "function"
279
+ ? { handleEvent: raw }
280
+ : raw;
281
+ this._handlers['change'] = listener;
282
+ this.rawHandlers['change'] = raw;
283
+ this.addEventListener('change', listener);
284
+ }
285
+ else {
286
+ delete this._handlers['change'];
287
+ delete this.rawHandlers['change'];
288
+ }
289
+ }
290
+ get onchange() { return this.rawHandlers['change'] || null; }
291
+ ensureHarmonyEmbed(rect, props, cornerRadius) {
292
+ // Create embed element only once
293
+ if (!this.harmonyEmbed) {
294
+ const embed = document.createElement("embed");
295
+ embed.setAttribute("type", "native/picker");
296
+ embed.setAttribute("width", `${rect.width}`);
297
+ embed.setAttribute("height", `${rect.height}`);
298
+ embed.setAttribute("id", this.componentId);
299
+ embed.setAttribute("data-lx-component-id", this.componentId);
300
+ embed.style.display = "block";
301
+ embed.style.width = "100%";
302
+ embed.style.height = "100%";
303
+ embed.style.border = "none";
304
+ if (cornerRadius !== undefined) {
305
+ embed.style.borderRadius = `${cornerRadius}px`;
306
+ embed.style.overflow = "hidden";
307
+ }
308
+ const encodedProps = this.encodeHarmonyProps(props);
309
+ embed.setAttribute("src", encodedProps);
310
+ this.lastHarmonyProps = encodedProps;
311
+ this.appendChild(embed);
312
+ this.harmonyEmbed = embed;
313
+ return;
314
+ }
315
+ // Only update props via src if they actually changed
316
+ const encodedProps = this.encodeHarmonyProps(props);
317
+ if (encodedProps !== this.lastHarmonyProps) {
318
+ this.harmonyEmbed.setAttribute("src", encodedProps);
319
+ this.lastHarmonyProps = encodedProps;
320
+ }
321
+ // Ensure embed element matches latest corner radius for clipping
322
+ if (cornerRadius !== undefined && this.harmonyEmbed.style.borderRadius !== `${cornerRadius}px`) {
323
+ this.harmonyEmbed.style.borderRadius = `${cornerRadius}px`;
324
+ this.harmonyEmbed.style.overflow = "hidden";
325
+ }
326
+ }
327
+ encodeHarmonyProps(props) {
328
+ try {
329
+ const payload = { componentId: this.componentId, ...props };
330
+ return `${HARMONY_PROPS_PREFIX}${encodeURIComponent(JSON.stringify(payload))}`;
331
+ }
332
+ catch (_e) {
333
+ return `${HARMONY_PROPS_PREFIX}%7B%7D`;
334
+ }
335
+ }
336
+ }
337
+ // Register the custom element
338
+ export function registerPickerComponent() {
339
+ if (typeof window !== "undefined" && !customElements.get("lx-picker")) {
340
+ customElements.define("lx-picker", LxPickerElement);
341
+ }
342
+ }
@@ -0,0 +1,6 @@
1
+ export declare function isHarmony(): boolean;
2
+ export declare function isIOS(): boolean;
3
+ export declare function isAndroid(): boolean;
4
+ export declare function isMacOS(): boolean;
5
+ export declare function isDesktop(): boolean;
6
+ export declare function getOS(): string;
@@ -0,0 +1,24 @@
1
+ export function isHarmony() {
2
+ var _a, _b, _c;
3
+ return ((_c = (_b = (_a = window.LingXiaBridge) === null || _a === void 0 ? void 0 : _a.platform) === null || _b === void 0 ? void 0 : _b.isHarmony) === null || _c === void 0 ? void 0 : _c.call(_b)) === true;
4
+ }
5
+ export function isIOS() {
6
+ var _a, _b, _c;
7
+ return ((_c = (_b = (_a = window.LingXiaBridge) === null || _a === void 0 ? void 0 : _a.platform) === null || _b === void 0 ? void 0 : _b.isIOS) === null || _c === void 0 ? void 0 : _c.call(_b)) === true;
8
+ }
9
+ export function isAndroid() {
10
+ var _a, _b, _c;
11
+ return ((_c = (_b = (_a = window.LingXiaBridge) === null || _a === void 0 ? void 0 : _a.platform) === null || _b === void 0 ? void 0 : _b.isAndroid) === null || _c === void 0 ? void 0 : _c.call(_b)) === true;
12
+ }
13
+ export function isMacOS() {
14
+ var _a, _b, _c;
15
+ return ((_c = (_b = (_a = window.LingXiaBridge) === null || _a === void 0 ? void 0 : _a.platform) === null || _b === void 0 ? void 0 : _b.isMacOS) === null || _c === void 0 ? void 0 : _c.call(_b)) === true;
16
+ }
17
+ export function isDesktop() {
18
+ var _a, _b, _c;
19
+ return ((_c = (_b = (_a = window.LingXiaBridge) === null || _a === void 0 ? void 0 : _a.platform) === null || _b === void 0 ? void 0 : _b.isDesktop) === null || _c === void 0 ? void 0 : _c.call(_b)) === true;
20
+ }
21
+ export function getOS() {
22
+ var _a, _b, _c, _d;
23
+ return (_d = (_c = (_b = (_a = window.LingXiaBridge) === null || _a === void 0 ? void 0 : _a.platform) === null || _b === void 0 ? void 0 : _b.getOS) === null || _c === void 0 ? void 0 : _c.call(_b)) !== null && _d !== void 0 ? _d : "unknown";
24
+ }
@@ -0,0 +1,53 @@
1
+ export interface InputNativeAttrOptions {
2
+ id?: string;
3
+ modelValue?: string;
4
+ value?: string;
5
+ defaultValue?: string;
6
+ type?: "text" | "number" | "password" | "digit";
7
+ password?: boolean;
8
+ placeholder?: string;
9
+ placeholderStyle?: string;
10
+ placeholderClass?: string;
11
+ maxlength?: number;
12
+ cursorSpacing?: number;
13
+ autoFocus?: boolean;
14
+ disabled?: boolean;
15
+ focus?: boolean;
16
+ confirmType?: "send" | "search" | "next" | "go" | "done";
17
+ alwaysEmbed?: boolean;
18
+ confirmHold?: boolean;
19
+ cursor?: number;
20
+ cursorColor?: string;
21
+ selectionStart?: number;
22
+ selectionEnd?: number;
23
+ adjustPosition?: boolean;
24
+ holdKeyboard?: boolean;
25
+ }
26
+ export interface TextareaNativeAttrOptions {
27
+ id?: string;
28
+ modelValue?: string;
29
+ value?: string;
30
+ defaultValue?: string;
31
+ placeholder?: string;
32
+ placeholderStyle?: string;
33
+ placeholderClass?: string;
34
+ maxlength?: number;
35
+ disabled?: boolean;
36
+ autoFocus?: boolean;
37
+ focus?: boolean;
38
+ autoHeight?: boolean;
39
+ cursorSpacing?: number;
40
+ showConfirmBar?: boolean;
41
+ adjustPosition?: boolean;
42
+ holdKeyboard?: boolean;
43
+ disableDefaultPadding?: boolean;
44
+ confirmType?: "send" | "search" | "next" | "go" | "done" | "return";
45
+ confirmHold?: boolean;
46
+ fixed?: boolean;
47
+ adjustKeyboardTo?: "cursor" | "bottom";
48
+ cursor?: number;
49
+ selectionStart?: number;
50
+ selectionEnd?: number;
51
+ }
52
+ export declare function buildInputNativeAttrs(options: InputNativeAttrOptions, extraAttrs?: Record<string, unknown>, mounted?: boolean): Record<string, string>;
53
+ export declare function buildTextareaNativeAttrs(options: TextareaNativeAttrOptions, extraAttrs?: Record<string, unknown>, mounted?: boolean): Record<string, string>;
@@ -0,0 +1,111 @@
1
+ import { appendDataAttrs } from "./native_component_wrapper_shared.js";
2
+ export function buildInputNativeAttrs(options, extraAttrs = {}, mounted = false) {
3
+ var _a;
4
+ const result = {};
5
+ const explicitId = typeof options.id === "string" ? options.id.trim() : "";
6
+ if (explicitId.length > 0)
7
+ result.id = explicitId;
8
+ const nextValue = (_a = options.modelValue) !== null && _a !== void 0 ? _a : options.value;
9
+ if (nextValue !== undefined) {
10
+ result.value = nextValue;
11
+ }
12
+ else if (!mounted && options.defaultValue !== undefined) {
13
+ result.value = options.defaultValue;
14
+ }
15
+ if (options.type)
16
+ result.type = options.type;
17
+ if (options.password)
18
+ result.password = "true";
19
+ if (options.placeholder)
20
+ result.placeholder = options.placeholder;
21
+ if (options.placeholderStyle)
22
+ result["placeholder-style"] = options.placeholderStyle;
23
+ if (options.placeholderClass)
24
+ result["placeholder-class"] = options.placeholderClass;
25
+ if (options.maxlength !== undefined)
26
+ result.maxlength = String(options.maxlength);
27
+ if (options.cursorSpacing !== undefined)
28
+ result["cursor-spacing"] = String(options.cursorSpacing);
29
+ if (options.autoFocus)
30
+ result["auto-focus"] = "true";
31
+ if (options.disabled)
32
+ result.disabled = "true";
33
+ if (options.focus !== undefined)
34
+ result.focus = options.focus ? "true" : "false";
35
+ if (options.confirmType)
36
+ result["confirm-type"] = options.confirmType;
37
+ if (options.alwaysEmbed)
38
+ result["always-embed"] = "true";
39
+ if (options.confirmHold)
40
+ result["confirm-hold"] = "true";
41
+ if (options.cursor !== undefined)
42
+ result.cursor = String(options.cursor);
43
+ if (options.cursorColor)
44
+ result["cursor-color"] = options.cursorColor;
45
+ if (options.selectionStart !== undefined)
46
+ result["selection-start"] = String(options.selectionStart);
47
+ if (options.selectionEnd !== undefined)
48
+ result["selection-end"] = String(options.selectionEnd);
49
+ if (options.adjustPosition === false)
50
+ result["adjust-position"] = "false";
51
+ if (options.holdKeyboard)
52
+ result["hold-keyboard"] = "true";
53
+ appendDataAttrs(extraAttrs, result);
54
+ return result;
55
+ }
56
+ export function buildTextareaNativeAttrs(options, extraAttrs = {}, mounted = false) {
57
+ var _a;
58
+ const result = {};
59
+ const explicitId = typeof options.id === "string" ? options.id.trim() : "";
60
+ if (explicitId.length > 0)
61
+ result.id = explicitId;
62
+ const nextValue = (_a = options.modelValue) !== null && _a !== void 0 ? _a : options.value;
63
+ if (nextValue !== undefined) {
64
+ result.value = nextValue;
65
+ }
66
+ else if (!mounted && options.defaultValue !== undefined) {
67
+ result.value = options.defaultValue;
68
+ }
69
+ if (options.placeholder)
70
+ result.placeholder = options.placeholder;
71
+ if (options.placeholderStyle)
72
+ result["placeholder-style"] = options.placeholderStyle;
73
+ if (options.placeholderClass)
74
+ result["placeholder-class"] = options.placeholderClass;
75
+ if (options.maxlength !== undefined)
76
+ result.maxlength = String(options.maxlength);
77
+ if (options.disabled)
78
+ result.disabled = "true";
79
+ if (options.autoFocus)
80
+ result["auto-focus"] = "true";
81
+ if (options.focus !== undefined)
82
+ result.focus = options.focus ? "true" : "false";
83
+ if (options.autoHeight)
84
+ result["auto-height"] = "true";
85
+ if (options.cursorSpacing !== undefined)
86
+ result["cursor-spacing"] = String(options.cursorSpacing);
87
+ if (options.showConfirmBar === false)
88
+ result["show-confirm-bar"] = "false";
89
+ if (options.adjustPosition === false)
90
+ result["adjust-position"] = "false";
91
+ if (options.holdKeyboard)
92
+ result["hold-keyboard"] = "true";
93
+ if (options.disableDefaultPadding)
94
+ result["disable-default-padding"] = "true";
95
+ if (options.confirmType)
96
+ result["confirm-type"] = options.confirmType;
97
+ if (options.confirmHold)
98
+ result["confirm-hold"] = "true";
99
+ if (options.fixed)
100
+ result.fixed = "true";
101
+ if (options.adjustKeyboardTo)
102
+ result["adjust-keyboard-to"] = options.adjustKeyboardTo;
103
+ if (options.cursor !== undefined)
104
+ result.cursor = String(options.cursor);
105
+ if (options.selectionStart !== undefined)
106
+ result["selection-start"] = String(options.selectionStart);
107
+ if (options.selectionEnd !== undefined)
108
+ result["selection-end"] = String(options.selectionEnd);
109
+ appendDataAttrs(extraAttrs, result);
110
+ return result;
111
+ }
@@ -0,0 +1,7 @@
1
+ export declare function getPropOrAttr(el: HTMLElement, name: string): unknown;
2
+ export declare function parseNumberLike(value: unknown): number | undefined;
3
+ export declare function getBoolAttr(el: HTMLElement, name: string): boolean;
4
+ export declare function getNumAttr(el: HTMLElement, name: string): number | undefined;
5
+ export declare function shouldRefreshForDataAttribute(name: string): boolean;
6
+ export declare function collectDataset(el: HTMLElement): Record<string, string>;
7
+ export declare function ensureElementVisibleForKeyboard(el: HTMLElement, explicitKeyboardHeight?: number, forceCenter?: boolean, extraDelays?: number[]): void;