@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.
- package/LICENSE +373 -0
- package/README.md +47 -2
- package/dist/chunks/TxImageGeneration.js +28478 -0
- package/dist/chunks/base-a.js +1223 -0
- package/dist/chunks/base-b.js +1648 -0
- package/dist/chunks/core.esm.js +2327 -0
- package/dist/chunks/glyphs-ai-1.js +33 -0
- package/dist/chunks/glyphs-ai-2.js +55 -0
- package/dist/chunks/glyphs-brand-1.js +23 -0
- package/dist/chunks/glyphs-brand-2.js +33 -0
- package/dist/chunks/glyphs-brand-3.js +40 -0
- package/dist/chunks/glyphs-icon-1.js +144 -0
- package/dist/chunks/glyphs-icon-2.js +124 -0
- package/dist/chunks/pinyin.js +4 -0
- package/dist/chunks/pull-down.esm.js +336 -0
- package/dist/chunks/pull-up.esm.js +234 -0
- package/dist/chunks/scroll-bar.esm.js +768 -0
- package/dist/chunks/tier-a.js +426 -0
- package/dist/chunks/tier-b.js +897 -0
- package/dist/chunks/tier-c.js +72 -0
- package/dist/chunks/tuffex-data.js +9757 -0
- package/dist/chunks/tuffex-extras.js +11692 -0
- package/dist/chunks/tuffex-media.js +13475 -0
- package/dist/chunks/tuffex-shared.js +17671 -0
- package/dist/chunks/vue-export-helper.js +10 -0
- package/dist/chunks/wc-runtime.js +922 -0
- package/dist/elements/base-a.d.ts +145 -0
- package/dist/elements/base-b.d.ts +129 -0
- package/dist/elements/index.d.ts +22 -0
- package/dist/elements/tier-a.d.ts +55 -0
- package/dist/elements/tier-b.d.ts +58 -0
- package/dist/elements/tier-c.d.ts +7 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +320 -0
- package/dist/manifest.d.ts +19 -0
- package/dist/manifest.js +1377 -0
- package/dist/runtime/coerce.d.ts +38 -0
- package/dist/runtime/events.d.ts +17 -0
- package/dist/runtime/factory.d.ts +129 -0
- package/dist/runtime/styles.d.ts +20 -0
- package/dist/style.css +1 -0
- package/dist/types.d.ts +1861 -0
- package/package.json +75 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export type PropCoerceKind = 'string' | 'boolean' | 'number' | 'string-or-number' | 'boolean-or-string' | 'boolean-or-json' | 'json' | 'string-or-json' | 'any' | ((raw: unknown) => unknown);
|
|
2
|
+
export type PropSchema = Record<string, PropCoerceKind>;
|
|
3
|
+
/**
|
|
4
|
+
* Coerce HTML attribute / JS property values into strict boolean.
|
|
5
|
+
* - `""`, `"true"`, `"1"`, or matching attr name -> `true`
|
|
6
|
+
* - `"false"`, `"0"` -> `false`
|
|
7
|
+
* - `undefined` / `null` -> `undefined` (lets wrapped component default apply)
|
|
8
|
+
*/
|
|
9
|
+
export declare function coerceBoolean(raw: unknown): boolean | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Coerce HTML attribute / JS property values into finite number.
|
|
12
|
+
*/
|
|
13
|
+
export declare function coerceNumber(raw: unknown): number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Coerce string or numeric value (keeps non-numeric strings like `'100%'` or `'medium'`).
|
|
16
|
+
*/
|
|
17
|
+
export declare function coerceStringOrNumber(raw: unknown): string | number | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* Coerce boolean or string unions (e.g. `DividerGradient = boolean | 'start' | 'end' | 'both'`).
|
|
20
|
+
*/
|
|
21
|
+
export declare function coerceBooleanOrString(raw: unknown): boolean | string | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Coerce JSON-serialized HTML attributes into objects or arrays.
|
|
24
|
+
* Passes existing non-string JS values through unchanged.
|
|
25
|
+
*/
|
|
26
|
+
export declare function coerceJson<T = unknown>(raw: unknown): T | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Coerce values that may be either a plain string or a JSON array/object
|
|
29
|
+
* (e.g. `TxCollapse` `modelValue: string | string[]`, `TxStreamText` `content: string | StreamInline[]`).
|
|
30
|
+
*/
|
|
31
|
+
export declare function coerceStringOrJson(raw: unknown): unknown;
|
|
32
|
+
/**
|
|
33
|
+
* Coerce values that may be either a boolean flag or a JSON object/array
|
|
34
|
+
* (e.g. `TxForm` `persist: boolean | FormPersistOptions`, `TxScroll` `pullDownRefresh: boolean | object`).
|
|
35
|
+
*/
|
|
36
|
+
export declare function coerceBooleanOrJson(raw: unknown): unknown;
|
|
37
|
+
export declare function coercePropValue(kind: PropCoerceKind, raw: unknown): unknown;
|
|
38
|
+
export declare function coercePropsBySchema(rawProps: Record<string, unknown>, schema: PropSchema): Record<string, unknown>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert Vue event names (e.g. `update:modelValue`) to canonical DOM kebab-case (`update:model-value`).
|
|
3
|
+
*/
|
|
4
|
+
export declare function toDomEventName(eventName: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Convert a Vue emit name into a Vue listener prop key (`'update:modelValue'` -> `'onUpdate:modelValue'`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function toVueListenerProp(eventName: string): string;
|
|
9
|
+
export interface HostEventOptions {
|
|
10
|
+
bubbles?: boolean;
|
|
11
|
+
composed?: boolean;
|
|
12
|
+
cancelable?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Dispatch a bubbling, Shadow-DOM-crossing CustomEvent on a custom element host.
|
|
16
|
+
*/
|
|
17
|
+
export declare function dispatchHostEvent<T = unknown>(host: HTMLElement | null | undefined, eventName: string, detail?: T, options?: HostEventOptions): boolean;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { Component, ComponentInternalInstance, ComponentOptions, VNode } from 'vue';
|
|
2
|
+
import { PropSchema } from './coerce';
|
|
3
|
+
export interface DefineTxElementOptions {
|
|
4
|
+
/** Override the canonical `tx-*` custom element tag name. */
|
|
5
|
+
tagName?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Use Shadow DOM instead of Light DOM.
|
|
8
|
+
* Defaults to `false` so global `--tx-*` design tokens, `.dark` / high-contrast
|
|
9
|
+
* themes, and TuffEx BEM styles work seamlessly without FOUC or selector breaks.
|
|
10
|
+
*/
|
|
11
|
+
shadowRoot?: boolean;
|
|
12
|
+
/** Additional CSS text strings to inject when `shadowRoot: true`. */
|
|
13
|
+
styles?: string[];
|
|
14
|
+
/** Optional CustomElementRegistry (defaults to `globalThis.customElements`). */
|
|
15
|
+
registry?: CustomElementRegistry;
|
|
16
|
+
}
|
|
17
|
+
export interface TxCustomElementConstructor extends CustomElementConstructor {
|
|
18
|
+
readonly def?: ComponentOptions;
|
|
19
|
+
}
|
|
20
|
+
export interface ModelSyncConfig {
|
|
21
|
+
/** Inner Vue component prop name (e.g. `'modelValue'` or `'visible'`). */
|
|
22
|
+
prop: string;
|
|
23
|
+
/** Inner Vue component update event name (e.g. `'update:modelValue'` or `'update:visible'`). */
|
|
24
|
+
event: string;
|
|
25
|
+
/** Optional alias prop accepted on the WC host (e.g. `'modelValue'` aliasing `'visible'`). */
|
|
26
|
+
aliasProp?: string;
|
|
27
|
+
/** Additional DOM event names to emit alongside the primary update event. */
|
|
28
|
+
extraDomEvents?: string[];
|
|
29
|
+
/** Whether to mirror internal updates back onto the host element property. Defaults to `true`. */
|
|
30
|
+
reflectToHost?: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface TxWrapperConfig {
|
|
33
|
+
/** Custom element tag name, e.g. `'tx-button'`. */
|
|
34
|
+
tag: string;
|
|
35
|
+
/** Wrapped TuffEx Vue component. */
|
|
36
|
+
component: Component;
|
|
37
|
+
/** Prop coercion schema matching the wrapped component's truthful props. */
|
|
38
|
+
props: PropSchema;
|
|
39
|
+
/** Vue event names emitted by the wrapped component that should re-dispatch as bubbling, composed CustomEvents. */
|
|
40
|
+
emits?: string[];
|
|
41
|
+
/** Slot names supported by the wrapped component (`'default'`, `'header'`, etc.). */
|
|
42
|
+
slots?: string[];
|
|
43
|
+
/** Controlled + uncontrolled two-way model binding configuration. */
|
|
44
|
+
model?: ModelSyncConfig;
|
|
45
|
+
/**
|
|
46
|
+
* Native DOM event names to stop at the inner component root so the host
|
|
47
|
+
* dispatches a single clean CustomEvent instead of firing both native + custom.
|
|
48
|
+
*/
|
|
49
|
+
suppressNativeEvents?: string[];
|
|
50
|
+
/** Method / property names exposed by the inner component to forward onto the custom element host. */
|
|
51
|
+
exposeMethods?: string[];
|
|
52
|
+
/** Promote `provide()` keys from the wrapped child component onto the CE root instance for nested custom elements. */
|
|
53
|
+
promoteProvides?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Use imperative Light DOM slot outlets (`display:contents` ref containers) instead of
|
|
56
|
+
* `<slot>` tags so slots rendered inside child `<Teleport>` / `<Transition>` / `v-if`
|
|
57
|
+
* subtrees (e.g. Dialog, Drawer, Tooltip, Popover) project reliably on every open/close cycle.
|
|
58
|
+
*/
|
|
59
|
+
teleportSlots?: boolean;
|
|
60
|
+
/** Optional transform hook to adjust props before passing them to the wrapped component. */
|
|
61
|
+
transformProps?: (coerced: Record<string, unknown>, ctx: {
|
|
62
|
+
host: HTMLElement | null;
|
|
63
|
+
}) => Record<string, unknown>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Determine whether the host element actually has user-supplied content for a given slot name.
|
|
67
|
+
* Checking this before passing slot functions preserves wrapped components' fallback content
|
|
68
|
+
* (e.g. `TxTag`'s `label`, `TxBadge`'s `value`, `TxAvatar`'s `name`, `TxCard`'s optional header/footer).
|
|
69
|
+
*/
|
|
70
|
+
export declare function hasHostSlotContent(host: HTMLElement | null, slotName: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Read raw slot nodes from a custom element host (works for both Light DOM and Shadow DOM).
|
|
73
|
+
*/
|
|
74
|
+
export declare function getHostSlotNodes(host: HTMLElement | null, slotName?: string): Node[];
|
|
75
|
+
/**
|
|
76
|
+
* Copy own `provides` (both string and symbol keys) from a child Vue component instance
|
|
77
|
+
* onto the wrapper CE root instance so nested Vue custom elements inherit them via
|
|
78
|
+
* Vue 3.5's `_inheritParentContext()`.
|
|
79
|
+
*/
|
|
80
|
+
export declare function promoteChildProvides(wrapperInstance: ComponentInternalInstance | null, childInstance: ComponentInternalInstance | null | undefined): void;
|
|
81
|
+
/**
|
|
82
|
+
* Complete static guard set covering standard Chromium/Firefox/Safari `HTMLElement.prototype`
|
|
83
|
+
* properties (HTMLElement, HTMLOrForeignElement, ElementContentEditable, ElementCSSInlineStyle,
|
|
84
|
+
* Animatable, Element, ARIAMixin, GlobalEventHandlers, Node, EventTarget).
|
|
85
|
+
* Combined with a runtime `key in HTMLElement.prototype` check in `isNativeElementPropKey()`,
|
|
86
|
+
* this ensures zero Vue 3.5 `defineCustomElement` dev prop-collision warnings across all browsers,
|
|
87
|
+
* jsdom, and SSR environments.
|
|
88
|
+
*/
|
|
89
|
+
export declare const NATIVE_ELEMENT_PROP_KEYS: ReadonlySet<string>;
|
|
90
|
+
export declare function isNativeElementPropKey(key: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Create a slot VNode for the wrapped component.
|
|
93
|
+
* - For standard Light DOM & Shadow DOM slots, returns a native `<slot>` VNode handled by
|
|
94
|
+
* Vue 3.5's `VueElement._renderSlots` / native Shadow DOM.
|
|
95
|
+
* - When `teleportSafe` is `true` in Light DOM (`shadowRoot: false`), returns a zero-box
|
|
96
|
+
* `display:contents` outlet whose `ref` mounts `host._slots[slotName]` cleanly inside any
|
|
97
|
+
* `<Teleport>` / `<Transition>` / `v-if` subtree without colliding with `_renderSlots`.
|
|
98
|
+
*/
|
|
99
|
+
export declare function createSlotVNode(host: HTMLElement | null, slotName: string, teleportSafe?: boolean): VNode;
|
|
100
|
+
/**
|
|
101
|
+
* Observe HTML attributes for schema keys that collide with built-in HTMLElement properties
|
|
102
|
+
* (e.g. `title`, `ariaLabel`, `role`, `blur`, `autofocus`) so Vue CE does not overwrite native
|
|
103
|
+
* properties or emit dev warnings while attributes remain fully reactive.
|
|
104
|
+
*/
|
|
105
|
+
export declare function useNativeAttrProps(host: HTMLElement | null, schema: PropSchema): {
|
|
106
|
+
nativeValues: Record<string, unknown>;
|
|
107
|
+
cleanup: () => void;
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* Build Vue prop declarations with no implicit Vue Boolean/Number casting so our
|
|
111
|
+
* explicit schema coercer handles `attr="false"`, `attr=""`, JSON, and defaults accurately.
|
|
112
|
+
* Excludes keys that collide with built-in HTMLElement properties (handled via `useNativeAttrProps`).
|
|
113
|
+
*/
|
|
114
|
+
export declare function buildRawVueProps(schema: PropSchema): Record<string, {
|
|
115
|
+
default: undefined;
|
|
116
|
+
}>;
|
|
117
|
+
export declare function createTxWrapperComponent(config: TxWrapperConfig): ComponentOptions;
|
|
118
|
+
export interface TxElementBundle {
|
|
119
|
+
readonly tag: string;
|
|
120
|
+
readonly ElementClass: TxCustomElementConstructor;
|
|
121
|
+
readonly createClass: (options?: Pick<DefineTxElementOptions, 'shadowRoot' | 'styles'>) => TxCustomElementConstructor;
|
|
122
|
+
readonly define: (options?: DefineTxElementOptions) => TxCustomElementConstructor;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Create a TuffEx custom element class + idempotent `define*()` helper powered by
|
|
126
|
+
* Vue 3.5 `defineCustomElement` (`shadowRoot: false` by default, with optional `shadowRoot: true`).
|
|
127
|
+
*/
|
|
128
|
+
export declare function createTxCustomElement(config: TxWrapperConfig): TxElementBundle;
|
|
129
|
+
export declare function createTxCustomElementFromComponent(defaultTag: string, wrapperComponent: ComponentOptions): TxElementBundle;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal host-level styles always included when an element is created with `shadowRoot: true`.
|
|
3
|
+
*/
|
|
4
|
+
export declare const DEFAULT_SHADOW_HOST_CSS = ":host {\n box-sizing: border-box;\n}\n:host([hidden]) {\n display: none !important;\n}";
|
|
5
|
+
/**
|
|
6
|
+
* Append CSS text to the global stylesheet list applied to newly created `shadowRoot: true` elements.
|
|
7
|
+
*/
|
|
8
|
+
export declare function registerTuffexShadowStyles(cssText: string): void;
|
|
9
|
+
/**
|
|
10
|
+
* Replace the global stylesheet list for `shadowRoot: true` elements.
|
|
11
|
+
*/
|
|
12
|
+
export declare function setTuffexShadowStyles(styles: string[]): void;
|
|
13
|
+
/**
|
|
14
|
+
* Read the stylesheets that will be injected into `shadowRoot: true` elements.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getTuffexShadowStyles(extraStyles?: string[]): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Adopt CSS into a ShadowRoot (using `adoptedStyleSheets` when available, falling back to `<style>`).
|
|
19
|
+
*/
|
|
20
|
+
export declare function injectShadowStyles(shadowRoot: ShadowRoot, styles: string[]): void;
|