directix 1.11.0 → 2.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/README.md +60 -6
- package/dist/index.cjs +186 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +210 -2
- package/dist/index.iife.js +186 -20
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +3 -3
- package/dist/index.mjs +187 -21
- package/dist/index.mjs.map +1 -1
- package/dist/nuxt/index.cjs +16 -16
- package/dist/nuxt/index.cjs.map +3 -3
- package/dist/nuxt/index.d.ts +2 -2
- package/dist/nuxt/index.mjs +16 -16
- package/dist/nuxt/index.mjs.map +3 -3
- package/dist/nuxt/runtime/plugin.mjs +16 -16
- package/dist/nuxt/runtime/plugin.mjs.map +3 -3
- package/package.json +15 -15
package/dist/index.d.ts
CHANGED
|
@@ -102,6 +102,23 @@ export declare interface AnnounceOptions {
|
|
|
102
102
|
*/
|
|
103
103
|
export declare function applyAriaAttributes(el: HTMLElement, config: ARIAConfig): void;
|
|
104
104
|
|
|
105
|
+
/**
|
|
106
|
+
* Apply a Vue directive to a custom element
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { vLazy } from 'directix'
|
|
111
|
+
* import { applyDirectiveToCustomElement } from 'directix/web-components'
|
|
112
|
+
*
|
|
113
|
+
* const myElement = document.querySelector('my-component')
|
|
114
|
+
* applyDirectiveToCustomElement(myElement, vLazy, { threshold: 0.5 })
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
export declare function applyDirectiveToCustomElement<T = any>(el: Element, directive: Directive, value?: T, options?: {
|
|
118
|
+
arg?: string;
|
|
119
|
+
modifiers?: Record<string, boolean>;
|
|
120
|
+
}): () => void;
|
|
121
|
+
|
|
105
122
|
/**
|
|
106
123
|
* ARIA attribute configuration
|
|
107
124
|
*/
|
|
@@ -1008,6 +1025,19 @@ export declare function createDirectiveBenchmark(directiveName: string, setup: (
|
|
|
1008
1025
|
measureFullCycle: () => Promise<BenchmarkResult>;
|
|
1009
1026
|
};
|
|
1010
1027
|
|
|
1028
|
+
/**
|
|
1029
|
+
* Create a directive element wrapper
|
|
1030
|
+
*
|
|
1031
|
+
* @example
|
|
1032
|
+
* ```ts
|
|
1033
|
+
* import { createDirectiveElement, vLazy } from 'directix'
|
|
1034
|
+
*
|
|
1035
|
+
* const LazyImage = createDirectiveElement('lazy-image', vLazy)
|
|
1036
|
+
* customElements.define('lazy-image', LazyImage)
|
|
1037
|
+
* ```
|
|
1038
|
+
*/
|
|
1039
|
+
export declare function createDirectiveElement(_name: string, directive: Directive, options?: Omit<CustomElementDirectiveOptions, 'name' | 'directive'>): CustomElementConstructor;
|
|
1040
|
+
|
|
1011
1041
|
/**
|
|
1012
1042
|
* Create a directive from a template
|
|
1013
1043
|
*
|
|
@@ -1195,6 +1225,34 @@ export declare function createSafeDirectiveWrapper<T>(directiveName: string, ope
|
|
|
1195
1225
|
validateBinding?: (binding: any) => boolean;
|
|
1196
1226
|
}): (el: HTMLElement, binding: any, vnode: any) => Promise<T | undefined>;
|
|
1197
1227
|
|
|
1228
|
+
/**
|
|
1229
|
+
* Create SSR-safe custom element with declarative shadow DOM support
|
|
1230
|
+
*
|
|
1231
|
+
* @param name - Element name
|
|
1232
|
+
* @param directive - Vue directive
|
|
1233
|
+
* @param options - Element options
|
|
1234
|
+
* @returns SSR-safe custom element definition
|
|
1235
|
+
*
|
|
1236
|
+
* @example
|
|
1237
|
+
* ```ts
|
|
1238
|
+
* import { createSSRSafeCustomElement, vLazy } from 'directix'
|
|
1239
|
+
*
|
|
1240
|
+
* const LazyImage = createSSRSafeCustomElement('lazy-image', vLazy, {
|
|
1241
|
+
* shadow: true,
|
|
1242
|
+
* styles: ':host { display: block; }',
|
|
1243
|
+
* })
|
|
1244
|
+
*
|
|
1245
|
+
* // SSR render
|
|
1246
|
+
* const html = LazyImage.ssrRender({ src: 'image.jpg' })
|
|
1247
|
+
*
|
|
1248
|
+
* // Register in browser
|
|
1249
|
+
* if (typeof window !== 'undefined') {
|
|
1250
|
+
* customElements.define('lazy-image', LazyImage.elementClass)
|
|
1251
|
+
* }
|
|
1252
|
+
* ```
|
|
1253
|
+
*/
|
|
1254
|
+
export declare function createSSRSafeCustomElement(name: string, directive: Directive, options?: Omit<CustomElementDirectiveOptions, 'name' | 'directive'>): SSRSafeCustomElement;
|
|
1255
|
+
|
|
1198
1256
|
/**
|
|
1199
1257
|
* Create a style-based directive template
|
|
1200
1258
|
*
|
|
@@ -1264,8 +1322,9 @@ export declare function createUppercaser(first?: boolean): (text: string) => str
|
|
|
1264
1322
|
export declare function createVue2Directive<T, B extends Element>(hooks: DirectiveHooks<T, B>): Record<string, any>;
|
|
1265
1323
|
|
|
1266
1324
|
/**
|
|
1267
|
-
* Vue 3 directive
|
|
1268
|
-
*
|
|
1325
|
+
* Create Vue 3 directive with optimizations
|
|
1326
|
+
* Uses markRaw for DOM elements and shallowReactive for state
|
|
1327
|
+
* @returns Vue 3 directive object
|
|
1269
1328
|
*/
|
|
1270
1329
|
export declare function createVue3Directive<T, B extends Element>(hooks: DirectiveHooks<T, B>): Record<string, any>;
|
|
1271
1330
|
|
|
@@ -1311,6 +1370,44 @@ export declare interface CSPConfig {
|
|
|
1311
1370
|
nonce?: string;
|
|
1312
1371
|
}
|
|
1313
1372
|
|
|
1373
|
+
/**
|
|
1374
|
+
* Options for creating a custom element directive
|
|
1375
|
+
*/
|
|
1376
|
+
export declare interface CustomElementDirectiveOptions {
|
|
1377
|
+
/** The element name (must contain a hyphen) */
|
|
1378
|
+
name: string;
|
|
1379
|
+
/** The Vue directive to apply */
|
|
1380
|
+
directive: Directive;
|
|
1381
|
+
/** Default binding value */
|
|
1382
|
+
defaultValue?: any;
|
|
1383
|
+
/** Whether to use shadow DOM */
|
|
1384
|
+
shadow?: boolean;
|
|
1385
|
+
/** Shadow DOM mode */
|
|
1386
|
+
shadowMode?: 'open' | 'closed';
|
|
1387
|
+
/** CSS styles to inject into shadow DOM (v2.1.0) */
|
|
1388
|
+
styles?: string | string[];
|
|
1389
|
+
/** Attributes to observe for changes (v2.1.0) */
|
|
1390
|
+
observedAttributes?: string[];
|
|
1391
|
+
/** Lifecycle hooks (v2.1.0) */
|
|
1392
|
+
lifecycle?: CustomElementLifecycleHooks;
|
|
1393
|
+
/** Enable slot content projection (v2.1.0) */
|
|
1394
|
+
slots?: boolean;
|
|
1395
|
+
}
|
|
1396
|
+
|
|
1397
|
+
/**
|
|
1398
|
+
* Lifecycle hooks for custom element
|
|
1399
|
+
*/
|
|
1400
|
+
export declare interface CustomElementLifecycleHooks {
|
|
1401
|
+
/** Called when element is connected to DOM */
|
|
1402
|
+
onConnect?: (el: HTMLElement) => void;
|
|
1403
|
+
/** Called when element is disconnected from DOM */
|
|
1404
|
+
onDisconnect?: (el: HTMLElement) => void;
|
|
1405
|
+
/** Called when element is adopted to a new document */
|
|
1406
|
+
onAdopt?: (el: HTMLElement) => void;
|
|
1407
|
+
/** Called when an attribute changes */
|
|
1408
|
+
onAttributeChange?: (el: HTMLElement, name: string, oldValue: string | null, newValue: string | null) => void;
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1314
1411
|
declare interface CustomIntegration {
|
|
1315
1412
|
enabled: boolean;
|
|
1316
1413
|
pushMetrics: (metrics: Metric[]) => Promise<void>;
|
|
@@ -1418,6 +1515,23 @@ export declare interface DeferredTask {
|
|
|
1418
1515
|
*/
|
|
1419
1516
|
export declare function deferTask(id: string, execute: () => void | Promise<void>, priority?: 'critical' | 'high' | 'medium' | 'low'): void;
|
|
1420
1517
|
|
|
1518
|
+
/**
|
|
1519
|
+
* Define a custom element that wraps a Vue directive
|
|
1520
|
+
*
|
|
1521
|
+
* @example
|
|
1522
|
+
* ```ts
|
|
1523
|
+
* import { vClickOutside, defineCustomElementDirective } from 'directix'
|
|
1524
|
+
*
|
|
1525
|
+
* defineCustomElementDirective({
|
|
1526
|
+
* name: 'click-outside',
|
|
1527
|
+
* directive: vClickOutside,
|
|
1528
|
+
* })
|
|
1529
|
+
*
|
|
1530
|
+
* // Now you can use: <click-outside></click-outside>
|
|
1531
|
+
* ```
|
|
1532
|
+
*/
|
|
1533
|
+
export declare function defineCustomElementDirective(options: CustomElementDirectiveOptions): void;
|
|
1534
|
+
|
|
1421
1535
|
/**
|
|
1422
1536
|
* Define a cross-version compatible directive
|
|
1423
1537
|
* @param definition The directive definition
|
|
@@ -2630,6 +2744,21 @@ export declare function getPolyfillStatus(): Record<string, {
|
|
|
2630
2744
|
required: boolean;
|
|
2631
2745
|
}>;
|
|
2632
2746
|
|
|
2747
|
+
/**
|
|
2748
|
+
* Get all registered custom element names
|
|
2749
|
+
*
|
|
2750
|
+
* @returns Array of custom element names
|
|
2751
|
+
*
|
|
2752
|
+
* @example
|
|
2753
|
+
* ```ts
|
|
2754
|
+
* import { getRegisteredCustomElements } from 'directix'
|
|
2755
|
+
*
|
|
2756
|
+
* const elements = getRegisteredCustomElements()
|
|
2757
|
+
* console.log('Registered:', elements)
|
|
2758
|
+
* ```
|
|
2759
|
+
*/
|
|
2760
|
+
export declare function getRegisteredCustomElements(): string[];
|
|
2761
|
+
|
|
2633
2762
|
/**
|
|
2634
2763
|
* Get slowest directives
|
|
2635
2764
|
*/
|
|
@@ -2730,6 +2859,24 @@ export declare interface HotkeyDefinition {
|
|
|
2730
2859
|
disabled?: boolean | Ref<boolean>;
|
|
2731
2860
|
}
|
|
2732
2861
|
|
|
2862
|
+
/**
|
|
2863
|
+
* Hydrate custom elements on the client (SSR support)
|
|
2864
|
+
*
|
|
2865
|
+
* @param root - Root element to hydrate
|
|
2866
|
+
*
|
|
2867
|
+
* @example
|
|
2868
|
+
* ```ts
|
|
2869
|
+
* import { hydrateCustomElements, registerDirectiveElements } from 'directix'
|
|
2870
|
+
*
|
|
2871
|
+
* // Register directives first
|
|
2872
|
+
* registerDirectiveElements({ 'lazy-img': vLazy })
|
|
2873
|
+
*
|
|
2874
|
+
* // Then hydrate
|
|
2875
|
+
* hydrateCustomElements(document.body)
|
|
2876
|
+
* ```
|
|
2877
|
+
*/
|
|
2878
|
+
export declare function hydrateCustomElements(root?: Element): void;
|
|
2879
|
+
|
|
2733
2880
|
/**
|
|
2734
2881
|
* i18n instance type
|
|
2735
2882
|
*/
|
|
@@ -2833,6 +2980,28 @@ export declare const isBrowser: () => boolean;
|
|
|
2833
2980
|
*/
|
|
2834
2981
|
export declare function isBrowserSupported(browserName: string, version: number): boolean;
|
|
2835
2982
|
|
|
2983
|
+
/**
|
|
2984
|
+
* Check if an element is a custom element
|
|
2985
|
+
*/
|
|
2986
|
+
export declare function isCustomElement(el: Element): boolean;
|
|
2987
|
+
|
|
2988
|
+
/**
|
|
2989
|
+
* Check if custom element is defined
|
|
2990
|
+
*
|
|
2991
|
+
* @param name - Element name
|
|
2992
|
+
* @returns True if element is defined
|
|
2993
|
+
*
|
|
2994
|
+
* @example
|
|
2995
|
+
* ```ts
|
|
2996
|
+
* import { isCustomElementDefined } from 'directix'
|
|
2997
|
+
*
|
|
2998
|
+
* if (!isCustomElementDefined('lazy-img')) {
|
|
2999
|
+
* customElements.define('lazy-img', LazyImage)
|
|
3000
|
+
* }
|
|
3001
|
+
* ```
|
|
3002
|
+
*/
|
|
3003
|
+
export declare function isCustomElementDefined(name: string): boolean;
|
|
3004
|
+
|
|
2836
3005
|
/**
|
|
2837
3006
|
* Check if DevTools is available
|
|
2838
3007
|
*/
|
|
@@ -4013,6 +4182,21 @@ export declare function quickPrint(target: string | HTMLElement, options?: UsePr
|
|
|
4013
4182
|
*/
|
|
4014
4183
|
export declare function recordHistogram(name: string, value: number, labels?: Record<string, string>): void;
|
|
4015
4184
|
|
|
4185
|
+
/**
|
|
4186
|
+
* Register multiple directives as custom elements
|
|
4187
|
+
*
|
|
4188
|
+
* @example
|
|
4189
|
+
* ```ts
|
|
4190
|
+
* import { registerDirectiveElements, vLazy, vClickOutside } from 'directix'
|
|
4191
|
+
*
|
|
4192
|
+
* registerDirectiveElements({
|
|
4193
|
+
* 'lazy-img': vLazy,
|
|
4194
|
+
* 'click-outside': vClickOutside,
|
|
4195
|
+
* })
|
|
4196
|
+
* ```
|
|
4197
|
+
*/
|
|
4198
|
+
export declare function registerDirectiveElements(elements: Record<string, Directive>): void;
|
|
4199
|
+
|
|
4016
4200
|
/**
|
|
4017
4201
|
* Register a polyfill
|
|
4018
4202
|
*/
|
|
@@ -4318,6 +4502,14 @@ export declare function setWarningLevel(level: LogLevel): void;
|
|
|
4318
4502
|
*/
|
|
4319
4503
|
export declare type SkeletonAnimation = 'wave' | 'pulse' | 'none';
|
|
4320
4504
|
|
|
4505
|
+
/**
|
|
4506
|
+
* SSR-safe custom element result (v2.1.0)
|
|
4507
|
+
*/
|
|
4508
|
+
export declare interface SSRSafeCustomElement {
|
|
4509
|
+
elementClass: CustomElementConstructor;
|
|
4510
|
+
ssrRender: (attrs?: Record<string, string>) => string;
|
|
4511
|
+
}
|
|
4512
|
+
|
|
4321
4513
|
/**
|
|
4322
4514
|
* Start a performance measurement
|
|
4323
4515
|
*/
|
|
@@ -10445,6 +10637,22 @@ export declare class WeakCache<K extends object, V> {
|
|
|
10445
10637
|
size(): number;
|
|
10446
10638
|
}
|
|
10447
10639
|
|
|
10640
|
+
/**
|
|
10641
|
+
* Wait for custom element to be defined
|
|
10642
|
+
*
|
|
10643
|
+
* @param name - Element name
|
|
10644
|
+
* @returns Promise that resolves when element is defined
|
|
10645
|
+
*
|
|
10646
|
+
* @example
|
|
10647
|
+
* ```ts
|
|
10648
|
+
* import { whenCustomElementDefined } from 'directix'
|
|
10649
|
+
*
|
|
10650
|
+
* await whenCustomElementDefined('lazy-img')
|
|
10651
|
+
* // Element is now ready to use
|
|
10652
|
+
* ```
|
|
10653
|
+
*/
|
|
10654
|
+
export declare function whenCustomElementDefined(name: string): Promise<void>;
|
|
10655
|
+
|
|
10448
10656
|
/**
|
|
10449
10657
|
* Measure and log performance
|
|
10450
10658
|
*/
|
package/dist/index.iife.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* directix
|
|
3
|
-
* A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3
|
|
2
|
+
* directix v2.1.0
|
|
3
|
+
* A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3, with Web Components support
|
|
4
4
|
* (c) 2021-present saqqdy <https://github.com/saqqdy>
|
|
5
5
|
* Released under the MIT License.
|
|
6
6
|
*/
|
|
@@ -58,8 +58,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
58
58
|
});
|
|
59
59
|
};
|
|
60
60
|
/*!
|
|
61
|
-
* directix
|
|
62
|
-
* A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3
|
|
61
|
+
* directix v2.1.0
|
|
62
|
+
* A comprehensive, easy-to-use, and high-performance Vue custom directives library supporting both Vue 2 and Vue 3, with Web Components support
|
|
63
63
|
* (c) 2021-present saqqdy <https://github.com/saqqdy>
|
|
64
64
|
* Released under the MIT License.
|
|
65
65
|
*/
|
|
@@ -78,7 +78,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
78
78
|
},
|
|
79
79
|
inserted(el, binding, vnode) {
|
|
80
80
|
if (hooks.mounted) {
|
|
81
|
-
hooks.mounted(el, normalizeBinding$
|
|
81
|
+
hooks.mounted(el, normalizeBinding$2(binding), vnode);
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
84
|
update(el, binding, vnode, oldVnode) {
|
|
@@ -86,9 +86,9 @@ var __async = (__this, __arguments, generator) => {
|
|
|
86
86
|
if (hooks.updated) {
|
|
87
87
|
hooks.updated(
|
|
88
88
|
el,
|
|
89
|
-
normalizeBinding$
|
|
89
|
+
normalizeBinding$2(binding),
|
|
90
90
|
vnode,
|
|
91
|
-
normalizeBinding$
|
|
91
|
+
normalizeBinding$2(__spreadProps(__spreadValues({}, binding), { value: binding.oldValue })),
|
|
92
92
|
oldVnode
|
|
93
93
|
);
|
|
94
94
|
}
|
|
@@ -101,7 +101,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
101
101
|
},
|
|
102
102
|
unbind(el, binding, vnode) {
|
|
103
103
|
if (hooks.unmounted) {
|
|
104
|
-
hooks.unmounted(el, normalizeBinding$
|
|
104
|
+
hooks.unmounted(el, normalizeBinding$2(binding), vnode);
|
|
105
105
|
}
|
|
106
106
|
const state2 = el.__directix_state__;
|
|
107
107
|
if (state2 == null ? void 0 : state2.cleanup) {
|
|
@@ -112,7 +112,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
112
112
|
};
|
|
113
113
|
return directive;
|
|
114
114
|
}
|
|
115
|
-
function normalizeBinding$
|
|
115
|
+
function normalizeBinding$2(binding) {
|
|
116
116
|
var _a2;
|
|
117
117
|
return {
|
|
118
118
|
value: binding.value,
|
|
@@ -129,20 +129,20 @@ var __async = (__this, __arguments, generator) => {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
function createVue3Directive(hooks) {
|
|
132
|
-
|
|
132
|
+
return {
|
|
133
133
|
created(el, binding, vnode) {
|
|
134
|
-
const state2 = {
|
|
135
|
-
value: binding.value,
|
|
134
|
+
const state2 = vue.shallowReactive({
|
|
135
|
+
value: binding.value != null ? vue.markRaw(binding.value) : binding.value,
|
|
136
136
|
vnode,
|
|
137
137
|
cleanup: []
|
|
138
|
-
};
|
|
138
|
+
});
|
|
139
139
|
el.__directix_state__ = state2;
|
|
140
140
|
},
|
|
141
141
|
beforeMount(_el, _binding, _vnode) {
|
|
142
142
|
},
|
|
143
143
|
mounted(el, binding, vnode) {
|
|
144
144
|
if (hooks.mounted) {
|
|
145
|
-
hooks.mounted(el,
|
|
145
|
+
hooks.mounted(el, normalizeBinding$1(binding), vnode);
|
|
146
146
|
}
|
|
147
147
|
},
|
|
148
148
|
beforeUpdate(_el, _binding, _vnode, _prevVnode) {
|
|
@@ -152,14 +152,14 @@ var __async = (__this, __arguments, generator) => {
|
|
|
152
152
|
if (hooks.updated) {
|
|
153
153
|
hooks.updated(
|
|
154
154
|
el,
|
|
155
|
-
|
|
155
|
+
normalizeBinding$1(binding),
|
|
156
156
|
vnode,
|
|
157
|
-
|
|
157
|
+
normalizeBinding$1(__spreadProps(__spreadValues({}, binding), { value: binding.oldValue })),
|
|
158
158
|
prevVnode
|
|
159
159
|
);
|
|
160
160
|
}
|
|
161
161
|
if (state2) {
|
|
162
|
-
state2.value = binding.value;
|
|
162
|
+
state2.value = binding.value != null ? vue.markRaw(binding.value) : binding.value;
|
|
163
163
|
state2.vnode = vnode;
|
|
164
164
|
}
|
|
165
165
|
},
|
|
@@ -167,7 +167,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
167
167
|
},
|
|
168
168
|
unmounted(el, binding, vnode) {
|
|
169
169
|
if (hooks.unmounted) {
|
|
170
|
-
hooks.unmounted(el,
|
|
170
|
+
hooks.unmounted(el, normalizeBinding$1(binding), vnode);
|
|
171
171
|
}
|
|
172
172
|
const state2 = el.__directix_state__;
|
|
173
173
|
if (state2 == null ? void 0 : state2.cleanup) {
|
|
@@ -176,9 +176,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
176
176
|
delete el.__directix_state__;
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
|
-
return directive;
|
|
180
179
|
}
|
|
181
|
-
function
|
|
180
|
+
function normalizeBinding$1(binding) {
|
|
182
181
|
var _a2;
|
|
183
182
|
return {
|
|
184
183
|
value: binding.value,
|
|
@@ -21952,6 +21951,163 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
21952
21951
|
}
|
|
21953
21952
|
};
|
|
21954
21953
|
}
|
|
21954
|
+
function isCustomElement(el) {
|
|
21955
|
+
return el.tagName.includes("-") || customElements.get(el.tagName.toLowerCase()) !== void 0;
|
|
21956
|
+
}
|
|
21957
|
+
function applyDirectiveToCustomElement(el, directive, value, options) {
|
|
21958
|
+
const binding = {
|
|
21959
|
+
value,
|
|
21960
|
+
oldValue: null,
|
|
21961
|
+
arg: options == null ? void 0 : options.arg,
|
|
21962
|
+
modifiers: (options == null ? void 0 : options.modifiers) || {},
|
|
21963
|
+
instance: null
|
|
21964
|
+
};
|
|
21965
|
+
const vnode = { el };
|
|
21966
|
+
const mountedHook = directive.mounted;
|
|
21967
|
+
if (mountedHook) {
|
|
21968
|
+
mountedHook(el, binding, vnode, null);
|
|
21969
|
+
}
|
|
21970
|
+
return () => {
|
|
21971
|
+
const unmountedHook = directive.unmounted;
|
|
21972
|
+
if (unmountedHook) {
|
|
21973
|
+
unmountedHook(el, binding, vnode, null);
|
|
21974
|
+
}
|
|
21975
|
+
};
|
|
21976
|
+
}
|
|
21977
|
+
function defineCustomElementDirective(options) {
|
|
21978
|
+
const { name, directive, defaultValue, shadow = false, shadowMode = "open" } = options;
|
|
21979
|
+
class DirectiveCustomElement extends HTMLElement {
|
|
21980
|
+
constructor() {
|
|
21981
|
+
super();
|
|
21982
|
+
__publicField(this, "cleanup");
|
|
21983
|
+
__publicField(this, "currentValue", defaultValue);
|
|
21984
|
+
if (shadow) {
|
|
21985
|
+
this.attachShadow({ mode: shadowMode });
|
|
21986
|
+
}
|
|
21987
|
+
}
|
|
21988
|
+
connectedCallback() {
|
|
21989
|
+
this.cleanup = applyDirectiveToCustomElement(
|
|
21990
|
+
this,
|
|
21991
|
+
directive,
|
|
21992
|
+
this.currentValue
|
|
21993
|
+
);
|
|
21994
|
+
}
|
|
21995
|
+
disconnectedCallback() {
|
|
21996
|
+
if (this.cleanup) {
|
|
21997
|
+
this.cleanup();
|
|
21998
|
+
this.cleanup = void 0;
|
|
21999
|
+
}
|
|
22000
|
+
}
|
|
22001
|
+
// Allow setting value via attribute
|
|
22002
|
+
static get observedAttributes() {
|
|
22003
|
+
return ["value"];
|
|
22004
|
+
}
|
|
22005
|
+
attributeChangedCallback(attrName, oldValue, newValue) {
|
|
22006
|
+
if (attrName === "value" && oldValue !== newValue) {
|
|
22007
|
+
this.currentValue = newValue;
|
|
22008
|
+
if (this.cleanup) {
|
|
22009
|
+
this.cleanup();
|
|
22010
|
+
}
|
|
22011
|
+
this.cleanup = applyDirectiveToCustomElement(
|
|
22012
|
+
this,
|
|
22013
|
+
directive,
|
|
22014
|
+
this.currentValue
|
|
22015
|
+
);
|
|
22016
|
+
}
|
|
22017
|
+
}
|
|
22018
|
+
}
|
|
22019
|
+
customElements.define(name, DirectiveCustomElement);
|
|
22020
|
+
}
|
|
22021
|
+
function createDirectiveElement(_name, directive, options) {
|
|
22022
|
+
const { defaultValue, shadow = false, shadowMode = "open" } = options || {};
|
|
22023
|
+
return class extends HTMLElement {
|
|
22024
|
+
constructor() {
|
|
22025
|
+
super();
|
|
22026
|
+
__publicField(this, "cleanup");
|
|
22027
|
+
__publicField(this, "currentValue", defaultValue);
|
|
22028
|
+
if (shadow) {
|
|
22029
|
+
this.attachShadow({ mode: shadowMode });
|
|
22030
|
+
}
|
|
22031
|
+
}
|
|
22032
|
+
connectedCallback() {
|
|
22033
|
+
this.cleanup = applyDirectiveToCustomElement(
|
|
22034
|
+
this,
|
|
22035
|
+
directive,
|
|
22036
|
+
this.currentValue
|
|
22037
|
+
);
|
|
22038
|
+
}
|
|
22039
|
+
disconnectedCallback() {
|
|
22040
|
+
if (this.cleanup) {
|
|
22041
|
+
this.cleanup();
|
|
22042
|
+
this.cleanup = void 0;
|
|
22043
|
+
}
|
|
22044
|
+
}
|
|
22045
|
+
static get observedAttributes() {
|
|
22046
|
+
return ["value"];
|
|
22047
|
+
}
|
|
22048
|
+
attributeChangedCallback(_attrName, oldValue, newValue) {
|
|
22049
|
+
if (oldValue !== newValue) {
|
|
22050
|
+
this.currentValue = newValue;
|
|
22051
|
+
if (this.cleanup) {
|
|
22052
|
+
this.cleanup();
|
|
22053
|
+
}
|
|
22054
|
+
this.cleanup = applyDirectiveToCustomElement(
|
|
22055
|
+
this,
|
|
22056
|
+
directive,
|
|
22057
|
+
this.currentValue
|
|
22058
|
+
);
|
|
22059
|
+
}
|
|
22060
|
+
}
|
|
22061
|
+
};
|
|
22062
|
+
}
|
|
22063
|
+
function registerDirectiveElements(elements) {
|
|
22064
|
+
Object.entries(elements).forEach(([elementName, elementDirective]) => {
|
|
22065
|
+
const elementClass = createDirectiveElement(elementName, elementDirective);
|
|
22066
|
+
customElements.define(elementName, elementClass);
|
|
22067
|
+
});
|
|
22068
|
+
}
|
|
22069
|
+
function isCustomElementDefined(name) {
|
|
22070
|
+
return customElements.get(name) !== void 0;
|
|
22071
|
+
}
|
|
22072
|
+
function whenCustomElementDefined(name) {
|
|
22073
|
+
return __async(this, null, function* () {
|
|
22074
|
+
yield customElements.whenDefined(name);
|
|
22075
|
+
});
|
|
22076
|
+
}
|
|
22077
|
+
function getRegisteredCustomElements() {
|
|
22078
|
+
const registry = customElements.__registry;
|
|
22079
|
+
if (registry && typeof registry.keys === "function") {
|
|
22080
|
+
return Array.from(registry.keys());
|
|
22081
|
+
}
|
|
22082
|
+
return [];
|
|
22083
|
+
}
|
|
22084
|
+
function hydrateCustomElements(root = document.body) {
|
|
22085
|
+
const customElementsList = root.querySelectorAll("*");
|
|
22086
|
+
customElementsList.forEach((el) => {
|
|
22087
|
+
var _a2;
|
|
22088
|
+
if (isCustomElement(el)) {
|
|
22089
|
+
const clone = el.cloneNode(true);
|
|
22090
|
+
(_a2 = el.parentNode) == null ? void 0 : _a2.replaceChild(clone, el);
|
|
22091
|
+
}
|
|
22092
|
+
});
|
|
22093
|
+
}
|
|
22094
|
+
function createSSRSafeCustomElement(name, directive, options) {
|
|
22095
|
+
const { styles, shadow = false } = options || {};
|
|
22096
|
+
const ssrRender = (attrs = {}) => {
|
|
22097
|
+
const attrString = Object.entries(attrs).map(([key, value]) => `${key}="${value}"`).join(" ");
|
|
22098
|
+
if (shadow) {
|
|
22099
|
+
const stylesString = styles ? `<style>${Array.isArray(styles) ? styles.join("") : styles}</style>` : "";
|
|
22100
|
+
return `<${name} ${attrString}><template shadowroot="open">${stylesString}<slot></slot></template></${name}>`;
|
|
22101
|
+
}
|
|
22102
|
+
return `<${name} ${attrString}></${name}>`;
|
|
22103
|
+
};
|
|
22104
|
+
const elementClass = typeof window === "undefined" ? class extends HTMLElement {
|
|
22105
|
+
} : createDirectiveElement(name, directive, options);
|
|
22106
|
+
return {
|
|
22107
|
+
elementClass,
|
|
22108
|
+
ssrRender
|
|
22109
|
+
};
|
|
22110
|
+
}
|
|
21955
22111
|
const zhCN = {
|
|
21956
22112
|
directives: {
|
|
21957
22113
|
debounce: {
|
|
@@ -24066,6 +24222,7 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24066
24222
|
exports.addPassiveListener = addPassiveListener;
|
|
24067
24223
|
exports.announce = announce;
|
|
24068
24224
|
exports.applyAriaAttributes = applyAriaAttributes;
|
|
24225
|
+
exports.applyDirectiveToCustomElement = applyDirectiveToCustomElement;
|
|
24069
24226
|
exports.assert = assert;
|
|
24070
24227
|
exports.assertPositive = assertPositive;
|
|
24071
24228
|
exports.assertRange = assertRange;
|
|
@@ -24113,6 +24270,7 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24113
24270
|
exports.createDelayedClick = createDelayedClick;
|
|
24114
24271
|
exports.createDeprecationWarning = createDeprecationWarning;
|
|
24115
24272
|
exports.createDirectiveBenchmark = createDirectiveBenchmark;
|
|
24273
|
+
exports.createDirectiveElement = createDirectiveElement;
|
|
24116
24274
|
exports.createDirectiveTemplate = createDirectiveTemplate;
|
|
24117
24275
|
exports.createEventDirective = createEventDirective;
|
|
24118
24276
|
exports.createI18n = createI18n;
|
|
@@ -24123,6 +24281,7 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24123
24281
|
exports.createPerformanceBudget = createPerformanceBudget;
|
|
24124
24282
|
exports.createPermissionCheck = createPermissionCheck;
|
|
24125
24283
|
exports.createPermissionChecker = createPermissionChecker;
|
|
24284
|
+
exports.createSSRSafeCustomElement = createSSRSafeCustomElement;
|
|
24126
24285
|
exports.createSafeContentHandler = createSafeContentHandler;
|
|
24127
24286
|
exports.createSafeDirectiveWrapper = createSafeDirectiveWrapper;
|
|
24128
24287
|
exports.createStyleDirective = createStyleDirective;
|
|
@@ -24137,6 +24296,7 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24137
24296
|
exports.deepMerge = deepMerge;
|
|
24138
24297
|
exports.deferNonCriticalDirective = deferNonCriticalDirective;
|
|
24139
24298
|
exports.deferTask = deferTask;
|
|
24299
|
+
exports.defineCustomElementDirective = defineCustomElementDirective;
|
|
24140
24300
|
exports.defineDirective = defineDirective;
|
|
24141
24301
|
exports.defineDirectiveGroup = defineDirectiveGroup;
|
|
24142
24302
|
exports.definePlugin = definePlugin;
|
|
@@ -24242,6 +24402,7 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24242
24402
|
exports.getPluginManager = getPluginManager;
|
|
24243
24403
|
exports.getPluginRegistry = getPluginRegistry;
|
|
24244
24404
|
exports.getPolyfillStatus = getPolyfillStatus;
|
|
24405
|
+
exports.getRegisteredCustomElements = getRegisteredCustomElements;
|
|
24245
24406
|
exports.getSlowestDirectives = getSlowestDirectives;
|
|
24246
24407
|
exports.getSupportedRegions = getSupportedRegions;
|
|
24247
24408
|
exports.getTimezoneInfo = getTimezoneInfo;
|
|
@@ -24252,6 +24413,7 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24252
24413
|
exports.handleTouchConflict = handleTouchConflict;
|
|
24253
24414
|
exports.hasPermission = hasPermission$2;
|
|
24254
24415
|
exports.hasPermissionSync = hasPermissionSync;
|
|
24416
|
+
exports.hydrateCustomElements = hydrateCustomElements;
|
|
24255
24417
|
exports.importConfig = importConfig;
|
|
24256
24418
|
exports.incrementCounter = incrementCounter;
|
|
24257
24419
|
exports.info = info;
|
|
@@ -24265,6 +24427,8 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24265
24427
|
exports.isBoolean = isBoolean;
|
|
24266
24428
|
exports.isBrowser = isBrowser;
|
|
24267
24429
|
exports.isBrowserSupported = isBrowserSupported;
|
|
24430
|
+
exports.isCustomElement = isCustomElement;
|
|
24431
|
+
exports.isCustomElementDefined = isCustomElementDefined;
|
|
24268
24432
|
exports.isDOMReady = isDOMReady;
|
|
24269
24433
|
exports.isDevtoolsAvailable = isDevtoolsAvailable;
|
|
24270
24434
|
exports.isEmpty = isEmpty;
|
|
@@ -24314,6 +24478,7 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24314
24478
|
exports.preloadModule = preloadModule;
|
|
24315
24479
|
exports.quickPrint = quickPrint;
|
|
24316
24480
|
exports.recordHistogram = recordHistogram;
|
|
24481
|
+
exports.registerDirectiveElements = registerDirectiveElements;
|
|
24317
24482
|
exports.registerPolyfill = registerPolyfill;
|
|
24318
24483
|
exports.removeHealthCheck = removeHealthCheck;
|
|
24319
24484
|
exports.requestIdleCallback = requestIdleCallback;
|
|
@@ -24501,6 +24666,7 @@ ${(_a2 = new Error("Stack trace").stack) == null ? void 0 : _a2.split("\n").slic
|
|
|
24501
24666
|
exports.warnUnsupportedFeatures = warnUnsupportedFeatures;
|
|
24502
24667
|
exports.watchConfig = watchConfig;
|
|
24503
24668
|
exports.watchEffectBinding = watchEffectBinding;
|
|
24669
|
+
exports.whenCustomElementDefined = whenCustomElementDefined;
|
|
24504
24670
|
exports.withAuditLog = withAuditLog;
|
|
24505
24671
|
exports.withErrorRecovery = withErrorRecovery;
|
|
24506
24672
|
exports.withPerformanceMonitoring = withPerformanceMonitoring;
|