@talex-touch/tuffex-wc 0.0.0-stage → 0.1.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 (43) hide show
  1. package/LICENSE +373 -0
  2. package/README.md +47 -2
  3. package/dist/chunks/TxImageGeneration.js +28478 -0
  4. package/dist/chunks/base-a.js +1223 -0
  5. package/dist/chunks/base-b.js +1648 -0
  6. package/dist/chunks/core.esm.js +2327 -0
  7. package/dist/chunks/glyphs-ai-1.js +33 -0
  8. package/dist/chunks/glyphs-ai-2.js +55 -0
  9. package/dist/chunks/glyphs-brand-1.js +23 -0
  10. package/dist/chunks/glyphs-brand-2.js +33 -0
  11. package/dist/chunks/glyphs-brand-3.js +40 -0
  12. package/dist/chunks/glyphs-icon-1.js +144 -0
  13. package/dist/chunks/glyphs-icon-2.js +124 -0
  14. package/dist/chunks/pinyin.js +4 -0
  15. package/dist/chunks/pull-down.esm.js +336 -0
  16. package/dist/chunks/pull-up.esm.js +234 -0
  17. package/dist/chunks/scroll-bar.esm.js +768 -0
  18. package/dist/chunks/tier-a.js +426 -0
  19. package/dist/chunks/tier-b.js +897 -0
  20. package/dist/chunks/tier-c.js +72 -0
  21. package/dist/chunks/tuffex-data.js +9757 -0
  22. package/dist/chunks/tuffex-extras.js +11692 -0
  23. package/dist/chunks/tuffex-media.js +13475 -0
  24. package/dist/chunks/tuffex-shared.js +17671 -0
  25. package/dist/chunks/vue-export-helper.js +10 -0
  26. package/dist/chunks/wc-runtime.js +922 -0
  27. package/dist/elements/base-a.d.ts +145 -0
  28. package/dist/elements/base-b.d.ts +129 -0
  29. package/dist/elements/index.d.ts +22 -0
  30. package/dist/elements/tier-a.d.ts +55 -0
  31. package/dist/elements/tier-b.d.ts +58 -0
  32. package/dist/elements/tier-c.d.ts +7 -0
  33. package/dist/index.d.ts +12 -0
  34. package/dist/index.js +320 -0
  35. package/dist/manifest.d.ts +19 -0
  36. package/dist/manifest.js +1377 -0
  37. package/dist/runtime/coerce.d.ts +38 -0
  38. package/dist/runtime/events.d.ts +17 -0
  39. package/dist/runtime/factory.d.ts +129 -0
  40. package/dist/runtime/styles.d.ts +20 -0
  41. package/dist/style.css +1 -0
  42. package/dist/types.d.ts +1861 -0
  43. package/package.json +75 -3
@@ -0,0 +1,922 @@
1
+ import { defineComponent, useHost, getCurrentInstance, ref, computed, watch, onBeforeUnmount, h, defineCustomElement } from "vue";
2
+ const NUMERIC_STRING_RE = /^-?\d+(?:\.\d+)?$/;
3
+ function coerceBoolean(raw) {
4
+ if (raw === void 0 || raw === null)
5
+ return void 0;
6
+ if (typeof raw === "boolean")
7
+ return raw;
8
+ if (typeof raw === "number")
9
+ return raw !== 0;
10
+ if (typeof raw === "string") {
11
+ const normalized = raw.trim().toLowerCase();
12
+ if (normalized === "false" || normalized === "0")
13
+ return false;
14
+ return true;
15
+ }
16
+ return Boolean(raw);
17
+ }
18
+ function coerceNumber(raw) {
19
+ if (raw === void 0 || raw === null)
20
+ return void 0;
21
+ if (typeof raw === "number")
22
+ return Number.isFinite(raw) ? raw : void 0;
23
+ if (typeof raw === "string") {
24
+ const trimmed = raw.trim();
25
+ if (!trimmed)
26
+ return void 0;
27
+ const parsed = Number(trimmed);
28
+ return Number.isFinite(parsed) ? parsed : void 0;
29
+ }
30
+ return void 0;
31
+ }
32
+ function coerceStringOrNumber(raw) {
33
+ if (raw === void 0 || raw === null)
34
+ return void 0;
35
+ if (typeof raw === "number")
36
+ return Number.isFinite(raw) ? raw : void 0;
37
+ if (typeof raw === "string") {
38
+ const trimmed = raw.trim();
39
+ if (trimmed && NUMERIC_STRING_RE.test(trimmed)) {
40
+ const parsed = Number(trimmed);
41
+ if (Number.isFinite(parsed))
42
+ return parsed;
43
+ }
44
+ return raw;
45
+ }
46
+ return String(raw);
47
+ }
48
+ function coerceBooleanOrString(raw) {
49
+ if (raw === void 0 || raw === null)
50
+ return void 0;
51
+ if (typeof raw === "boolean")
52
+ return raw;
53
+ if (typeof raw === "string") {
54
+ const normalized = raw.trim().toLowerCase();
55
+ if (normalized === "" || normalized === "true")
56
+ return true;
57
+ if (normalized === "false")
58
+ return false;
59
+ return raw;
60
+ }
61
+ return String(raw);
62
+ }
63
+ function coerceJson(raw) {
64
+ if (raw === void 0 || raw === null)
65
+ return void 0;
66
+ if (typeof raw !== "string")
67
+ return raw;
68
+ const trimmed = raw.trim();
69
+ if (!trimmed)
70
+ return void 0;
71
+ try {
72
+ return JSON.parse(trimmed);
73
+ } catch {
74
+ return void 0;
75
+ }
76
+ }
77
+ function coerceStringOrJson(raw) {
78
+ if (raw === void 0 || raw === null)
79
+ return void 0;
80
+ if (typeof raw !== "string")
81
+ return raw;
82
+ const trimmed = raw.trim();
83
+ if (trimmed.startsWith("[") && trimmed.endsWith("]") || trimmed.startsWith("{") && trimmed.endsWith("}")) {
84
+ try {
85
+ return JSON.parse(trimmed);
86
+ } catch {
87
+ return raw;
88
+ }
89
+ }
90
+ return raw;
91
+ }
92
+ function coerceBooleanOrJson(raw) {
93
+ if (raw === void 0 || raw === null)
94
+ return void 0;
95
+ if (typeof raw === "boolean")
96
+ return raw;
97
+ if (typeof raw !== "string")
98
+ return raw;
99
+ const trimmed = raw.trim();
100
+ const lower = trimmed.toLowerCase();
101
+ if (lower === "" || lower === "true" || lower === "1")
102
+ return true;
103
+ if (lower === "false" || lower === "0")
104
+ return false;
105
+ if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) {
106
+ try {
107
+ return JSON.parse(trimmed);
108
+ } catch {
109
+ return void 0;
110
+ }
111
+ }
112
+ return coerceBoolean(raw);
113
+ }
114
+ function coercePropValue(kind, raw) {
115
+ if (raw === void 0)
116
+ return void 0;
117
+ if (typeof kind === "function")
118
+ return kind(raw);
119
+ switch (kind) {
120
+ case "boolean":
121
+ return coerceBoolean(raw);
122
+ case "number":
123
+ return coerceNumber(raw);
124
+ case "string":
125
+ return raw === null ? void 0 : String(raw);
126
+ case "string-or-number":
127
+ return coerceStringOrNumber(raw);
128
+ case "boolean-or-string":
129
+ return coerceBooleanOrString(raw);
130
+ case "boolean-or-json":
131
+ return coerceBooleanOrJson(raw);
132
+ case "json":
133
+ return coerceJson(raw);
134
+ case "string-or-json":
135
+ return coerceStringOrJson(raw);
136
+ case "any":
137
+ default:
138
+ return raw;
139
+ }
140
+ }
141
+ function coercePropsBySchema(rawProps, schema) {
142
+ const result = {};
143
+ for (const [key, kind] of Object.entries(schema)) {
144
+ const raw = rawProps[key];
145
+ if (raw === void 0)
146
+ continue;
147
+ const coerced = coercePropValue(kind, raw);
148
+ if (coerced !== void 0)
149
+ result[key] = coerced;
150
+ }
151
+ return result;
152
+ }
153
+ const CAMEL_TO_KEBAB_RE = /([a-z0-9])([A-Z])/g;
154
+ function toDomEventName(eventName) {
155
+ return eventName.replace(CAMEL_TO_KEBAB_RE, "$1-$2").toLowerCase();
156
+ }
157
+ function toVueListenerProp(eventName) {
158
+ if (!eventName)
159
+ return "on";
160
+ return `on${eventName[0].toUpperCase()}${eventName.slice(1)}`;
161
+ }
162
+ function dispatchHostEvent(host, eventName, detail, options = {}) {
163
+ if (!host || typeof CustomEvent === "undefined")
164
+ return false;
165
+ const domName = toDomEventName(eventName);
166
+ const event = new CustomEvent(domName, {
167
+ detail,
168
+ bubbles: options.bubbles ?? true,
169
+ composed: options.composed ?? true,
170
+ cancelable: options.cancelable ?? false
171
+ });
172
+ return host.dispatchEvent(event);
173
+ }
174
+ const sharedShadowStyles = [];
175
+ const DEFAULT_SHADOW_HOST_CSS = `:host {
176
+ box-sizing: border-box;
177
+ }
178
+ :host([hidden]) {
179
+ display: none !important;
180
+ }`;
181
+ function registerTuffexShadowStyles(cssText) {
182
+ const trimmed = cssText.trim();
183
+ if (!trimmed || sharedShadowStyles.includes(trimmed))
184
+ return;
185
+ sharedShadowStyles.push(trimmed);
186
+ }
187
+ function setTuffexShadowStyles(styles) {
188
+ sharedShadowStyles.length = 0;
189
+ for (const style of styles)
190
+ registerTuffexShadowStyles(style);
191
+ }
192
+ function getTuffexShadowStyles(extraStyles) {
193
+ const combined = [DEFAULT_SHADOW_HOST_CSS, ...sharedShadowStyles, ...extraStyles ?? []];
194
+ return Array.from(new Set(combined.map((s) => s.trim()).filter(Boolean)));
195
+ }
196
+ function injectShadowStyles(shadowRoot, styles) {
197
+ const normalized = styles.map((s) => s.trim()).filter(Boolean);
198
+ if (!normalized.length)
199
+ return;
200
+ if (typeof CSSStyleSheet !== "undefined" && "adoptedStyleSheets" in shadowRoot && typeof CSSStyleSheet.prototype.replaceSync === "function") {
201
+ const sheets = normalized.map((css) => {
202
+ const sheet = new CSSStyleSheet();
203
+ sheet.replaceSync(css);
204
+ return sheet;
205
+ });
206
+ shadowRoot.adoptedStyleSheets = [...shadowRoot.adoptedStyleSheets, ...sheets];
207
+ return;
208
+ }
209
+ for (const css of normalized) {
210
+ const styleEl = document.createElement("style");
211
+ styleEl.textContent = css;
212
+ shadowRoot.appendChild(styleEl);
213
+ }
214
+ }
215
+ function hasHostSlotContent(host, slotName) {
216
+ if (!host)
217
+ return false;
218
+ const internal = host;
219
+ if (internal._slots) {
220
+ const nodes = internal._slots[slotName];
221
+ if (!nodes || nodes.length === 0)
222
+ return false;
223
+ if (slotName === "default")
224
+ return nodes.some(isMeaningfulSlotNode);
225
+ return true;
226
+ }
227
+ const childNodes = Array.from(host.childNodes);
228
+ if (slotName === "default") {
229
+ return childNodes.some((node) => {
230
+ if (node.nodeType === 1 && node.getAttribute("slot"))
231
+ return false;
232
+ return isMeaningfulSlotNode(node);
233
+ });
234
+ }
235
+ return childNodes.some(
236
+ (node) => node.nodeType === 1 && node.getAttribute("slot") === slotName
237
+ );
238
+ }
239
+ function isMeaningfulSlotNode(node) {
240
+ if (node.nodeType === 8)
241
+ return false;
242
+ if (node.nodeType === 3)
243
+ return Boolean(node.textContent && node.textContent.trim().length > 0);
244
+ return true;
245
+ }
246
+ function getHostSlotNodes(host, slotName = "default") {
247
+ if (!host)
248
+ return [];
249
+ const internal = host;
250
+ if (internal._slots)
251
+ return [...internal._slots[slotName] ?? []];
252
+ const childNodes = Array.from(host.childNodes);
253
+ if (slotName === "default") {
254
+ return childNodes.filter(
255
+ (node) => !(node.nodeType === 1 && node.getAttribute("slot"))
256
+ );
257
+ }
258
+ return childNodes.filter(
259
+ (node) => node.nodeType === 1 && node.getAttribute("slot") === slotName
260
+ );
261
+ }
262
+ function promoteChildProvides(wrapperInstance, childInstance) {
263
+ if (!wrapperInstance || !childInstance)
264
+ return;
265
+ const childProvides = childInstance.provides;
266
+ const wrapperProvides = wrapperInstance.provides;
267
+ if (!childProvides || !wrapperProvides || childProvides === wrapperProvides)
268
+ return;
269
+ for (const key of Reflect.ownKeys(childProvides)) {
270
+ wrapperProvides[key] = childProvides[key];
271
+ }
272
+ }
273
+ const NATIVE_ELEMENT_PROP_KEYS = /* @__PURE__ */ new Set([
274
+ // Node constants
275
+ "ATTRIBUTE_NODE",
276
+ "CDATA_SECTION_NODE",
277
+ "COMMENT_NODE",
278
+ "DOCUMENT_FRAGMENT_NODE",
279
+ "DOCUMENT_NODE",
280
+ "DOCUMENT_POSITION_CONTAINED_BY",
281
+ "DOCUMENT_POSITION_CONTAINS",
282
+ "DOCUMENT_POSITION_DISCONNECTED",
283
+ "DOCUMENT_POSITION_FOLLOWING",
284
+ "DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC",
285
+ "DOCUMENT_POSITION_PRECEDING",
286
+ "DOCUMENT_TYPE_NODE",
287
+ "ELEMENT_NODE",
288
+ "ENTITY_NODE",
289
+ "ENTITY_REFERENCE_NODE",
290
+ "NOTATION_NODE",
291
+ "PROCESSING_INSTRUCTION_NODE",
292
+ "TEXT_NODE",
293
+ // HTMLElement & HTMLOrForeignElement & ElementContentEditable & ElementCSSInlineStyle
294
+ "accessKey",
295
+ "accessKeyLabel",
296
+ "attachInternals",
297
+ "attributeStyleMap",
298
+ "autocapitalize",
299
+ "autocorrect",
300
+ "autofocus",
301
+ "blur",
302
+ "click",
303
+ "contentEditable",
304
+ "dataset",
305
+ "dir",
306
+ "draggable",
307
+ "editContext",
308
+ "enterKeyHint",
309
+ "focus",
310
+ "hidden",
311
+ "hidePopover",
312
+ "inert",
313
+ "innerText",
314
+ "inputMode",
315
+ "isContentEditable",
316
+ "lang",
317
+ "nonce",
318
+ "offsetHeight",
319
+ "offsetLeft",
320
+ "offsetParent",
321
+ "offsetTop",
322
+ "offsetWidth",
323
+ "outerText",
324
+ "popover",
325
+ "showPopover",
326
+ "spellcheck",
327
+ "style",
328
+ "tabIndex",
329
+ "title",
330
+ "togglePopover",
331
+ "translate",
332
+ "virtualKeyboardPolicy",
333
+ "writingSuggestions",
334
+ // ARIAMixin
335
+ "ariaActiveDescendantElement",
336
+ "ariaAtomic",
337
+ "ariaAutoComplete",
338
+ "ariaBrailleLabel",
339
+ "ariaBrailleRoleDescription",
340
+ "ariaBusy",
341
+ "ariaChecked",
342
+ "ariaColCount",
343
+ "ariaColIndex",
344
+ "ariaColIndexText",
345
+ "ariaColSpan",
346
+ "ariaControlsElements",
347
+ "ariaCurrent",
348
+ "ariaDescribedByElements",
349
+ "ariaDescription",
350
+ "ariaDetailsElements",
351
+ "ariaDisabled",
352
+ "ariaErrorMessageElements",
353
+ "ariaExpanded",
354
+ "ariaFlowToElements",
355
+ "ariaHasPopup",
356
+ "ariaHidden",
357
+ "ariaInvalid",
358
+ "ariaKeyShortcuts",
359
+ "ariaLabel",
360
+ "ariaLabelledByElements",
361
+ "ariaLabelledby",
362
+ "ariaLevel",
363
+ "ariaLive",
364
+ "ariaModal",
365
+ "ariaMultiLine",
366
+ "ariaMultiSelectable",
367
+ "ariaOrientation",
368
+ "ariaOwnsElements",
369
+ "ariaPlaceholder",
370
+ "ariaPosInSet",
371
+ "ariaPressed",
372
+ "ariaReadOnly",
373
+ "ariaRelevant",
374
+ "ariaRequired",
375
+ "ariaRoleDescription",
376
+ "ariaRowCount",
377
+ "ariaRowIndex",
378
+ "ariaRowIndexText",
379
+ "ariaRowSpan",
380
+ "ariaSelected",
381
+ "ariaSetSize",
382
+ "ariaSort",
383
+ "ariaValueMax",
384
+ "ariaValueMin",
385
+ "ariaValueNow",
386
+ "ariaValueText",
387
+ "role",
388
+ // Element & Animatable & CSSOM View & Shadow DOM & Fullscreen & Pointer Events
389
+ "after",
390
+ "animate",
391
+ "assignedSlot",
392
+ "attachShadow",
393
+ "attributes",
394
+ "before",
395
+ "checkVisibility",
396
+ "childElementCount",
397
+ "children",
398
+ "classList",
399
+ "className",
400
+ "clientHeight",
401
+ "clientLeft",
402
+ "clientTop",
403
+ "clientWidth",
404
+ "closest",
405
+ "computedStyleMap",
406
+ "currentCSSZoom",
407
+ "elementTiming",
408
+ "firstElementChild",
409
+ "getAnimations",
410
+ "getAttribute",
411
+ "getAttributeNS",
412
+ "getAttributeNames",
413
+ "getAttributeNode",
414
+ "getAttributeNodeNS",
415
+ "getBoundingClientRect",
416
+ "getClientRects",
417
+ "getElementsByClassName",
418
+ "getElementsByTagName",
419
+ "getElementsByTagNameNS",
420
+ "getHTML",
421
+ "hasAttribute",
422
+ "hasAttributeNS",
423
+ "hasAttributes",
424
+ "hasPointerCapture",
425
+ "id",
426
+ "innerHTML",
427
+ "insertAdjacentElement",
428
+ "insertAdjacentHTML",
429
+ "insertAdjacentText",
430
+ "lastElementChild",
431
+ "localName",
432
+ "matches",
433
+ "moveBefore",
434
+ "namespaceURI",
435
+ "nextElementSibling",
436
+ "outerHTML",
437
+ "part",
438
+ "prefix",
439
+ "prepend",
440
+ "previousElementSibling",
441
+ "querySelector",
442
+ "querySelectorAll",
443
+ "releasePointerCapture",
444
+ "remove",
445
+ "removeAttribute",
446
+ "removeAttributeNS",
447
+ "removeAttributeNode",
448
+ "replaceChildren",
449
+ "replaceWith",
450
+ "requestFullscreen",
451
+ "requestPointerLock",
452
+ "scroll",
453
+ "scrollBy",
454
+ "scrollHeight",
455
+ "scrollIntoView",
456
+ "scrollIntoViewIfNeeded",
457
+ "scrollLeft",
458
+ "scrollTo",
459
+ "scrollTop",
460
+ "scrollWidth",
461
+ "setAttribute",
462
+ "setAttributeNS",
463
+ "setAttributeNode",
464
+ "setAttributeNodeNS",
465
+ "setHTMLUnsafe",
466
+ "setPointerCapture",
467
+ "shadowRoot",
468
+ "slot",
469
+ "tagName",
470
+ "toggleAttribute",
471
+ "webkitMatchesSelector",
472
+ "webkitRequestFullScreen",
473
+ "webkitRequestFullscreen",
474
+ // Node & EventTarget
475
+ "addEventListener",
476
+ "append",
477
+ "appendChild",
478
+ "baseURI",
479
+ "childNodes",
480
+ "cloneNode",
481
+ "compareDocumentPosition",
482
+ "constructor",
483
+ "contains",
484
+ "dispatchEvent",
485
+ "firstChild",
486
+ "getRootNode",
487
+ "hasChildNodes",
488
+ "insertBefore",
489
+ "isConnected",
490
+ "isDefaultNamespace",
491
+ "isEqualNode",
492
+ "isSameNode",
493
+ "lastChild",
494
+ "lookupNamespaceURI",
495
+ "lookupPrefix",
496
+ "nextSibling",
497
+ "nodeName",
498
+ "nodeType",
499
+ "nodeValue",
500
+ "normalize",
501
+ "ownerDocument",
502
+ "parentElement",
503
+ "parentNode",
504
+ "previousSibling",
505
+ "removeChild",
506
+ "removeEventListener",
507
+ "replaceChild",
508
+ "textContent",
509
+ "when",
510
+ // GlobalEventHandlers
511
+ "onabort",
512
+ "onanimationcancel",
513
+ "onanimationend",
514
+ "onanimationiteration",
515
+ "onanimationstart",
516
+ "onauxclick",
517
+ "onbeforeinput",
518
+ "onbeforematch",
519
+ "onbeforetoggle",
520
+ "onbeforexrselect",
521
+ "onblur",
522
+ "oncancel",
523
+ "oncanplay",
524
+ "oncanplaythrough",
525
+ "onchange",
526
+ "onclick",
527
+ "onclose",
528
+ "oncommand",
529
+ "oncontentvisibilityautostatechange",
530
+ "oncontextlost",
531
+ "oncontextmenu",
532
+ "oncontextrestored",
533
+ "oncopy",
534
+ "oncuechange",
535
+ "oncut",
536
+ "ondblclick",
537
+ "ondrag",
538
+ "ondragend",
539
+ "ondragenter",
540
+ "ondragleave",
541
+ "ondragover",
542
+ "ondragstart",
543
+ "ondrop",
544
+ "ondurationchange",
545
+ "onemptied",
546
+ "onended",
547
+ "onerror",
548
+ "onfocus",
549
+ "onformdata",
550
+ "onfullscreenchange",
551
+ "onfullscreenerror",
552
+ "ongotpointercapture",
553
+ "oninput",
554
+ "oninvalid",
555
+ "onkeydown",
556
+ "onkeypress",
557
+ "onkeyup",
558
+ "onload",
559
+ "onloadeddata",
560
+ "onloadedmetadata",
561
+ "onloadstart",
562
+ "onlostpointercapture",
563
+ "onmousedown",
564
+ "onmouseenter",
565
+ "onmouseleave",
566
+ "onmousemove",
567
+ "onmouseout",
568
+ "onmouseover",
569
+ "onmouseup",
570
+ "onmousewheel",
571
+ "onpaste",
572
+ "onpause",
573
+ "onplay",
574
+ "onplaying",
575
+ "onpointercancel",
576
+ "onpointerdown",
577
+ "onpointerenter",
578
+ "onpointerleave",
579
+ "onpointermove",
580
+ "onpointerout",
581
+ "onpointerover",
582
+ "onpointerrawupdate",
583
+ "onpointerup",
584
+ "onprogress",
585
+ "onratechange",
586
+ "onreset",
587
+ "onresize",
588
+ "onscroll",
589
+ "onscrollend",
590
+ "onscrollsnapchange",
591
+ "onscrollsnapchanging",
592
+ "onsearch",
593
+ "onsecuritypolicyviolation",
594
+ "onseeked",
595
+ "onseeking",
596
+ "onselect",
597
+ "onselectionchange",
598
+ "onselectstart",
599
+ "onslotchange",
600
+ "onstalled",
601
+ "onsubmit",
602
+ "onsuspend",
603
+ "ontimeupdate",
604
+ "ontoggle",
605
+ "ontouchcancel",
606
+ "ontouchend",
607
+ "ontouchmove",
608
+ "ontouchstart",
609
+ "ontransitioncancel",
610
+ "ontransitionend",
611
+ "ontransitionrun",
612
+ "ontransitionstart",
613
+ "onvolumechange",
614
+ "onwaiting",
615
+ "onwebkitanimationend",
616
+ "onwebkitanimationiteration",
617
+ "onwebkitanimationstart",
618
+ "onwebkittransitionend",
619
+ "onwheel"
620
+ ]);
621
+ function isNativeElementPropKey(key) {
622
+ if (NATIVE_ELEMENT_PROP_KEYS.has(key))
623
+ return true;
624
+ if (typeof HTMLElement !== "undefined" && key in HTMLElement.prototype)
625
+ return true;
626
+ return false;
627
+ }
628
+ const CAMEL_TO_ATTR_RE = /([a-z0-9])([A-Z])/g;
629
+ function propKeyToAttrName(key) {
630
+ return key.replace(CAMEL_TO_ATTR_RE, "$1-$2").toLowerCase();
631
+ }
632
+ function createSlotVNode(host, slotName, teleportSafe = false) {
633
+ const isLightDom = Boolean(host && !host.shadowRoot);
634
+ if (teleportSafe && isLightDom && host) {
635
+ return h("span", {
636
+ "class": "tx-wc-slot-outlet",
637
+ "data-tx-slot": slotName,
638
+ "style": "display:contents",
639
+ "ref": (el) => {
640
+ if (!(el instanceof HTMLElement))
641
+ return;
642
+ const nodes = host._slots?.[slotName];
643
+ if (!nodes || nodes.length === 0)
644
+ return;
645
+ for (const node of nodes) {
646
+ if (node.parentNode !== el && !node.contains(el))
647
+ el.appendChild(node);
648
+ }
649
+ }
650
+ });
651
+ }
652
+ return h("slot", slotName === "default" ? void 0 : { name: slotName });
653
+ }
654
+ function useNativeAttrProps(host, schema) {
655
+ const nativeEntries = Object.entries(schema).filter(([key]) => isNativeElementPropKey(key));
656
+ const state = ref({});
657
+ if (!host || nativeEntries.length === 0) {
658
+ return {
659
+ get nativeValues() {
660
+ return state.value;
661
+ },
662
+ cleanup: () => {
663
+ }
664
+ };
665
+ }
666
+ const attrToKey = /* @__PURE__ */ new Map();
667
+ for (const [key, kind] of nativeEntries) {
668
+ attrToKey.set(propKeyToAttrName(key), [key, kind]);
669
+ }
670
+ const readAll = () => {
671
+ const next = {};
672
+ for (const [attrName, [key, kind]] of attrToKey.entries()) {
673
+ if (host.hasAttribute(attrName)) {
674
+ const coerced = coercePropValue(kind, host.getAttribute(attrName));
675
+ if (coerced !== void 0)
676
+ next[key] = coerced;
677
+ }
678
+ }
679
+ state.value = next;
680
+ };
681
+ readAll();
682
+ let observer = null;
683
+ if (typeof MutationObserver !== "undefined") {
684
+ observer = new MutationObserver(() => readAll());
685
+ observer.observe(host, {
686
+ attributes: true,
687
+ attributeFilter: Array.from(attrToKey.keys())
688
+ });
689
+ }
690
+ return {
691
+ get nativeValues() {
692
+ return state.value;
693
+ },
694
+ cleanup: () => {
695
+ observer?.disconnect();
696
+ observer = null;
697
+ }
698
+ };
699
+ }
700
+ function buildRawVueProps(schema) {
701
+ const defs = {};
702
+ for (const key of Object.keys(schema)) {
703
+ if (isNativeElementPropKey(key))
704
+ continue;
705
+ defs[key] = { default: void 0 };
706
+ }
707
+ return defs;
708
+ }
709
+ function createTxWrapperComponent(config) {
710
+ const propSchema = { ...config.props };
711
+ if (config.model?.aliasProp && !(config.model.aliasProp in propSchema)) {
712
+ propSchema[config.model.aliasProp] = propSchema[config.model.prop] ?? "any";
713
+ }
714
+ return defineComponent({
715
+ name: `Wc_${config.tag}`,
716
+ props: buildRawVueProps(propSchema),
717
+ setup(rawProps, { expose }) {
718
+ const host = useHost();
719
+ const wrapperInstance = getCurrentInstance();
720
+ const innerRef = ref(null);
721
+ const suppressedCleanup = [];
722
+ const nativeAttrs = useNativeAttrProps(host, propSchema);
723
+ const coercedProps = computed(() => {
724
+ const base = {
725
+ ...nativeAttrs.nativeValues,
726
+ ...coercePropsBySchema(rawProps, propSchema)
727
+ };
728
+ return config.transformProps ? config.transformProps(base, { host }) : base;
729
+ });
730
+ const modelConfig = config.model;
731
+ const hasLocalModel = ref(false);
732
+ const localModel = ref(void 0);
733
+ if (modelConfig) {
734
+ watch(
735
+ () => {
736
+ const primary = coercedProps.value[modelConfig.prop];
737
+ if (primary !== void 0)
738
+ return primary;
739
+ if (modelConfig.aliasProp)
740
+ return coercedProps.value[modelConfig.aliasProp];
741
+ return void 0;
742
+ },
743
+ (next) => {
744
+ if (next !== void 0) {
745
+ hasLocalModel.value = true;
746
+ localModel.value = next;
747
+ }
748
+ },
749
+ { immediate: true }
750
+ );
751
+ }
752
+ function syncHostModel(nextValue) {
753
+ if (!modelConfig)
754
+ return;
755
+ hasLocalModel.value = true;
756
+ localModel.value = nextValue;
757
+ if (modelConfig.reflectToHost !== false && host) {
758
+ const hostObj = host;
759
+ if (hostObj[modelConfig.prop] !== nextValue)
760
+ hostObj[modelConfig.prop] = nextValue;
761
+ }
762
+ }
763
+ const eventListeners = {};
764
+ const declaredEmits = new Set(config.emits ?? []);
765
+ if (modelConfig)
766
+ declaredEmits.add(modelConfig.event);
767
+ for (const emitName of declaredEmits) {
768
+ const listenerKey = toVueListenerProp(emitName);
769
+ eventListeners[listenerKey] = (...args) => {
770
+ const payload = args.length <= 1 ? args[0] : args;
771
+ if (emitName === "click" && typeof Event !== "undefined" && args[0] instanceof Event) {
772
+ args[0].stopPropagation();
773
+ }
774
+ if (modelConfig && emitName === modelConfig.event) {
775
+ syncHostModel(args[0]);
776
+ dispatchHostEvent(host, emitName, args[0]);
777
+ for (const extra of modelConfig.extraDomEvents ?? [])
778
+ dispatchHostEvent(host, extra, args[0]);
779
+ return;
780
+ }
781
+ dispatchHostEvent(host, emitName, payload);
782
+ };
783
+ }
784
+ if (config.exposeMethods?.length) {
785
+ const exposedObj = {};
786
+ for (const methodName of config.exposeMethods) {
787
+ exposedObj[methodName] = (...args) => {
788
+ const target = innerRef.value?.[methodName];
789
+ if (typeof target === "function")
790
+ return target(...args);
791
+ return target;
792
+ };
793
+ }
794
+ expose(exposedObj);
795
+ }
796
+ function attachNativeSuppressors(el) {
797
+ while (suppressedCleanup.length)
798
+ suppressedCleanup.pop()?.();
799
+ if (!config.suppressNativeEvents?.length || !(el instanceof EventTarget))
800
+ return;
801
+ for (const nativeEvent of config.suppressNativeEvents) {
802
+ const handler = (event) => {
803
+ if (!(event instanceof CustomEvent))
804
+ event.stopPropagation();
805
+ };
806
+ el.addEventListener(nativeEvent, handler);
807
+ suppressedCleanup.push(() => el.removeEventListener(nativeEvent, handler));
808
+ }
809
+ }
810
+ onBeforeUnmount(() => {
811
+ nativeAttrs.cleanup();
812
+ while (suppressedCleanup.length)
813
+ suppressedCleanup.pop()?.();
814
+ });
815
+ return () => {
816
+ const forwardedProps = { ...coercedProps.value };
817
+ if (modelConfig) {
818
+ if (modelConfig.aliasProp)
819
+ delete forwardedProps[modelConfig.aliasProp];
820
+ if (hasLocalModel.value)
821
+ forwardedProps[modelConfig.prop] = localModel.value;
822
+ }
823
+ const vnodeProps = {
824
+ ...forwardedProps,
825
+ ...eventListeners,
826
+ ref: innerRef,
827
+ onVnodeBeforeMount: (vnode) => {
828
+ if (config.promoteProvides)
829
+ promoteChildProvides(wrapperInstance, vnode.component);
830
+ },
831
+ onVnodeMounted: (vnode) => {
832
+ if (config.promoteProvides)
833
+ promoteChildProvides(wrapperInstance, vnode.component);
834
+ attachNativeSuppressors(vnode.el);
835
+ },
836
+ onVnodeUpdated: (vnode) => {
837
+ if (config.promoteProvides)
838
+ promoteChildProvides(wrapperInstance, vnode.component);
839
+ attachNativeSuppressors(vnode.el);
840
+ }
841
+ };
842
+ const slotMap = {};
843
+ for (const slotName of config.slots ?? []) {
844
+ if (hasHostSlotContent(host, slotName)) {
845
+ slotMap[slotName] = () => createSlotVNode(host, slotName, Boolean(config.teleportSlots));
846
+ }
847
+ }
848
+ return h(
849
+ config.component,
850
+ vnodeProps,
851
+ Object.keys(slotMap).length > 0 ? slotMap : void 0
852
+ );
853
+ };
854
+ }
855
+ });
856
+ }
857
+ function createTxCustomElement(config) {
858
+ const wrapperComponent = createTxWrapperComponent(config);
859
+ return createTxCustomElementFromComponent(config.tag, wrapperComponent);
860
+ }
861
+ function createTxCustomElementFromComponent(defaultTag, wrapperComponent) {
862
+ const createClass = (options) => {
863
+ const useShadow = options?.shadowRoot === true;
864
+ if (useShadow) {
865
+ return defineCustomElement(wrapperComponent, {
866
+ shadowRoot: true,
867
+ styles: getTuffexShadowStyles(options?.styles)
868
+ });
869
+ }
870
+ return defineCustomElement(wrapperComponent, {
871
+ shadowRoot: false
872
+ });
873
+ };
874
+ const ElementClass = createClass({ shadowRoot: false });
875
+ const define = (options) => {
876
+ const tagName = options?.tagName ?? defaultTag;
877
+ const registry = options?.registry ?? (typeof customElements !== "undefined" ? customElements : void 0);
878
+ if (!registry)
879
+ return options?.shadowRoot ? createClass(options) : ElementClass;
880
+ const existing = registry.get(tagName);
881
+ if (existing)
882
+ return existing;
883
+ const ctor = tagName !== defaultTag || options?.shadowRoot || options?.styles?.length ? createClass(options) : ElementClass;
884
+ registry.define(tagName, ctor);
885
+ return ctor;
886
+ };
887
+ return {
888
+ tag: defaultTag,
889
+ ElementClass,
890
+ createClass,
891
+ define
892
+ };
893
+ }
894
+ export {
895
+ DEFAULT_SHADOW_HOST_CSS as D,
896
+ NATIVE_ELEMENT_PROP_KEYS as N,
897
+ createTxCustomElementFromComponent as a,
898
+ coercePropsBySchema as b,
899
+ createTxCustomElement as c,
900
+ dispatchHostEvent as d,
901
+ buildRawVueProps as e,
902
+ createSlotVNode as f,
903
+ getHostSlotNodes as g,
904
+ hasHostSlotContent as h,
905
+ coerceStringOrJson as i,
906
+ coerceStringOrNumber as j,
907
+ coerceBoolean as k,
908
+ coerceBooleanOrJson as l,
909
+ coerceBooleanOrString as m,
910
+ coerceJson as n,
911
+ coerceNumber as o,
912
+ promoteChildProvides as p,
913
+ coercePropValue as q,
914
+ getTuffexShadowStyles as r,
915
+ injectShadowStyles as s,
916
+ isNativeElementPropKey as t,
917
+ useNativeAttrProps as u,
918
+ registerTuffexShadowStyles as v,
919
+ setTuffexShadowStyles as w,
920
+ toDomEventName as x,
921
+ toVueListenerProp as y
922
+ };