@htmlplus/element 2.12.0 → 2.13.1

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 (176) hide show
  1. package/README.md +2 -2
  2. package/bundlers.d.ts +19 -0
  3. package/bundlers.js +75 -0
  4. package/client-5FqNUiuz.d.ts +309 -0
  5. package/client-By_MTZkm.js +1796 -0
  6. package/client.d.ts +1 -0
  7. package/client.js +3 -0
  8. package/constants.d.ts +50 -0
  9. package/constants.js +62 -0
  10. package/internal.d.ts +1 -0
  11. package/internal.js +3 -0
  12. package/package.json +9 -4
  13. package/transformer.d.ts +137 -0
  14. package/transformer.js +1253 -0
  15. package/bundlers/rollup.d.ts +0 -7
  16. package/bundlers/rollup.js +0 -23
  17. package/bundlers/vite.d.ts +0 -8
  18. package/bundlers/vite.js +0 -52
  19. package/client/decorators/bind.d.ts +0 -8
  20. package/client/decorators/bind.js +0 -21
  21. package/client/decorators/context.d.ts +0 -3
  22. package/client/decorators/context.js +0 -121
  23. package/client/decorators/direction.d.ts +0 -5
  24. package/client/decorators/direction.js +0 -8
  25. package/client/decorators/element.d.ts +0 -7
  26. package/client/decorators/element.js +0 -65
  27. package/client/decorators/event.d.ts +0 -35
  28. package/client/decorators/event.js +0 -53
  29. package/client/decorators/host.d.ts +0 -4
  30. package/client/decorators/host.js +0 -7
  31. package/client/decorators/index.d.ts +0 -15
  32. package/client/decorators/index.js +0 -15
  33. package/client/decorators/isRTL.d.ts +0 -4
  34. package/client/decorators/isRTL.js +0 -7
  35. package/client/decorators/listen.d.ts +0 -52
  36. package/client/decorators/listen.js +0 -37
  37. package/client/decorators/method.d.ts +0 -6
  38. package/client/decorators/method.js +0 -15
  39. package/client/decorators/property.d.ts +0 -25
  40. package/client/decorators/property.js +0 -94
  41. package/client/decorators/query.d.ts +0 -9
  42. package/client/decorators/query.js +0 -12
  43. package/client/decorators/queryAll.d.ts +0 -12
  44. package/client/decorators/queryAll.js +0 -15
  45. package/client/decorators/slots.d.ts +0 -4
  46. package/client/decorators/slots.js +0 -7
  47. package/client/decorators/state.d.ts +0 -6
  48. package/client/decorators/state.js +0 -23
  49. package/client/decorators/watch.d.ts +0 -11
  50. package/client/decorators/watch.js +0 -31
  51. package/client/index.d.ts +0 -2
  52. package/client/index.js +0 -2
  53. package/client/utils/appendToMethod.d.ts +0 -1
  54. package/client/utils/appendToMethod.js +0 -15
  55. package/client/utils/attributes.d.ts +0 -2
  56. package/client/utils/attributes.js +0 -33
  57. package/client/utils/call.d.ts +0 -1
  58. package/client/utils/call.js +0 -3
  59. package/client/utils/classes.d.ts +0 -4
  60. package/client/utils/classes.js +0 -45
  61. package/client/utils/config.d.ts +0 -39
  62. package/client/utils/config.js +0 -28
  63. package/client/utils/defineProperty.d.ts +0 -1
  64. package/client/utils/defineProperty.js +0 -1
  65. package/client/utils/direction.d.ts +0 -6
  66. package/client/utils/direction.js +0 -8
  67. package/client/utils/event.d.ts +0 -13
  68. package/client/utils/event.js +0 -48
  69. package/client/utils/getFramework.d.ts +0 -2
  70. package/client/utils/getFramework.js +0 -20
  71. package/client/utils/getStyles.d.ts +0 -2
  72. package/client/utils/getStyles.js +0 -4
  73. package/client/utils/getTag.d.ts +0 -2
  74. package/client/utils/getTag.js +0 -4
  75. package/client/utils/host.d.ts +0 -5
  76. package/client/utils/host.js +0 -12
  77. package/client/utils/index.d.ts +0 -32
  78. package/client/utils/index.js +0 -32
  79. package/client/utils/isCSSColor.d.ts +0 -5
  80. package/client/utils/isCSSColor.js +0 -9
  81. package/client/utils/isEvent.d.ts +0 -1
  82. package/client/utils/isEvent.js +0 -3
  83. package/client/utils/isRTL.d.ts +0 -5
  84. package/client/utils/isRTL.js +0 -5
  85. package/client/utils/isServer.d.ts +0 -4
  86. package/client/utils/isServer.js +0 -6
  87. package/client/utils/merge.d.ts +0 -1
  88. package/client/utils/merge.js +0 -22
  89. package/client/utils/query.d.ts +0 -5
  90. package/client/utils/query.js +0 -7
  91. package/client/utils/queryAll.d.ts +0 -5
  92. package/client/utils/queryAll.js +0 -7
  93. package/client/utils/request.d.ts +0 -9
  94. package/client/utils/request.js +0 -106
  95. package/client/utils/shadowRoot.d.ts +0 -2
  96. package/client/utils/shadowRoot.js +0 -4
  97. package/client/utils/slots.d.ts +0 -9
  98. package/client/utils/slots.js +0 -18
  99. package/client/utils/styles.d.ts +0 -4
  100. package/client/utils/styles.js +0 -10
  101. package/client/utils/task.d.ts +0 -6
  102. package/client/utils/task.js +0 -34
  103. package/client/utils/toBoolean.d.ts +0 -1
  104. package/client/utils/toBoolean.js +0 -3
  105. package/client/utils/toDecorator.d.ts +0 -2
  106. package/client/utils/toDecorator.js +0 -10
  107. package/client/utils/toEvent.d.ts +0 -1
  108. package/client/utils/toEvent.js +0 -3
  109. package/client/utils/toProperty.d.ts +0 -1
  110. package/client/utils/toProperty.js +0 -55
  111. package/client/utils/toUnit.d.ts +0 -4
  112. package/client/utils/toUnit.js +0 -10
  113. package/client/utils/typeOf.d.ts +0 -3
  114. package/client/utils/typeOf.js +0 -6
  115. package/client/utils/uhtml.d.ts +0 -22
  116. package/client/utils/uhtml.js +0 -703
  117. package/client/utils/updateAttribute.d.ts +0 -2
  118. package/client/utils/updateAttribute.js +0 -10
  119. package/constants/index.d.ts +0 -48
  120. package/constants/index.js +0 -60
  121. package/transformer/index.d.ts +0 -3
  122. package/transformer/index.js +0 -3
  123. package/transformer/plugins/assets.d.ts +0 -7
  124. package/transformer/plugins/assets.js +0 -26
  125. package/transformer/plugins/copy.d.ts +0 -9
  126. package/transformer/plugins/copy.js +0 -29
  127. package/transformer/plugins/customElement.d.ts +0 -7
  128. package/transformer/plugins/customElement.js +0 -392
  129. package/transformer/plugins/document.d.ts +0 -7
  130. package/transformer/plugins/document.js +0 -206
  131. package/transformer/plugins/extract.d.ts +0 -2
  132. package/transformer/plugins/extract.js +0 -22
  133. package/transformer/plugins/index.d.ts +0 -12
  134. package/transformer/plugins/index.js +0 -12
  135. package/transformer/plugins/parse.d.ts +0 -6
  136. package/transformer/plugins/parse.js +0 -13
  137. package/transformer/plugins/read.d.ts +0 -7
  138. package/transformer/plugins/read.js +0 -19
  139. package/transformer/plugins/readme.d.ts +0 -6
  140. package/transformer/plugins/readme.js +0 -24
  141. package/transformer/plugins/style.d.ts +0 -6
  142. package/transformer/plugins/style.js +0 -42
  143. package/transformer/plugins/validate.d.ts +0 -2
  144. package/transformer/plugins/validate.js +0 -40
  145. package/transformer/plugins/visualStudioCode.d.ts +0 -8
  146. package/transformer/plugins/visualStudioCode.js +0 -73
  147. package/transformer/plugins/webTypes.d.ts +0 -10
  148. package/transformer/plugins/webTypes.js +0 -74
  149. package/transformer/transformer.d.ts +0 -8
  150. package/transformer/transformer.js +0 -78
  151. package/transformer/transformer.types.d.ts +0 -52
  152. package/transformer/transformer.types.js +0 -1
  153. package/transformer/utils/addDependency.d.ts +0 -7
  154. package/transformer/utils/addDependency.js +0 -64
  155. package/transformer/utils/extractAttribute.d.ts +0 -2
  156. package/transformer/utils/extractAttribute.js +0 -10
  157. package/transformer/utils/extractFromComment.d.ts +0 -4
  158. package/transformer/utils/extractFromComment.js +0 -51
  159. package/transformer/utils/getInitializer.d.ts +0 -2
  160. package/transformer/utils/getInitializer.js +0 -3
  161. package/transformer/utils/getType.d.ts +0 -2
  162. package/transformer/utils/getType.js +0 -89
  163. package/transformer/utils/getTypeReference.d.ts +0 -2
  164. package/transformer/utils/getTypeReference.js +0 -33
  165. package/transformer/utils/hasDecorator.d.ts +0 -1
  166. package/transformer/utils/hasDecorator.js +0 -5
  167. package/transformer/utils/index.d.ts +0 -10
  168. package/transformer/utils/index.js +0 -10
  169. package/transformer/utils/print.d.ts +0 -2
  170. package/transformer/utils/print.js +0 -5
  171. package/transformer/utils/printType.d.ts +0 -1
  172. package/transformer/utils/printType.js +0 -69
  173. package/transformer/utils/visitor.d.ts +0 -2
  174. package/transformer/utils/visitor.js +0 -5
  175. package/types/index.d.ts +0 -2
  176. package/types/index.js +0 -1
@@ -1,7 +0,0 @@
1
- import { TransformerPlugin } from '../transformer/index.js';
2
- export declare const htmlplus: (...plugins: Array<TransformerPlugin>) => {
3
- name: string;
4
- buildStart(): Promise<void>;
5
- load(id: any): Promise<string | undefined>;
6
- buildEnd(error?: Error): Promise<void>;
7
- };
@@ -1,23 +0,0 @@
1
- import { transformer } from '../transformer/index.js';
2
- export const htmlplus = (...plugins) => {
3
- const { start, run, finish } = transformer(...plugins);
4
- return {
5
- name: 'htmlplus',
6
- async buildStart() {
7
- await start();
8
- },
9
- async load(id) {
10
- if (!id.endsWith('.tsx'))
11
- return;
12
- const { script, skipped } = await run(id);
13
- if (skipped)
14
- return;
15
- return script;
16
- },
17
- async buildEnd(error) {
18
- if (error)
19
- throw error;
20
- await finish();
21
- }
22
- };
23
- };
@@ -1,8 +0,0 @@
1
- import { TransformerPlugin } from '../transformer/index.js';
2
- export declare const htmlplus: (...plugins: Array<TransformerPlugin>) => {
3
- name: string;
4
- buildStart(): Promise<void>;
5
- load(id: any): Promise<string | undefined>;
6
- buildEnd(): Promise<void>;
7
- writeBundle(options: any, bundles: any): Promise<void>;
8
- };
package/bundlers/vite.js DELETED
@@ -1,52 +0,0 @@
1
- import path from 'path';
2
- import { transformer } from '../transformer/index.js';
3
- export const htmlplus = (...plugins) => {
4
- const { global, start, run, finish, write } = transformer(...plugins);
5
- return {
6
- name: 'htmlplus',
7
- async buildStart() {
8
- await start();
9
- },
10
- async load(id) {
11
- if (!id.endsWith('.tsx'))
12
- return;
13
- let { script, skipped, stylePath } = await run(id);
14
- if (skipped)
15
- return;
16
- if (script && stylePath) {
17
- script = script.replace(path.basename(stylePath), `${path.basename(stylePath)}?inline`);
18
- }
19
- return script;
20
- },
21
- async buildEnd() {
22
- await finish();
23
- },
24
- async writeBundle(options, bundles) {
25
- // TODO
26
- try {
27
- for (const context of global.contexts) {
28
- for (const key in bundles) {
29
- if (!Object.hasOwnProperty.call(bundles, key))
30
- continue;
31
- const bundle = bundles[key];
32
- if (!bundle.facadeModuleId.startsWith(context.filePath))
33
- continue;
34
- const modules = bundle['modules'];
35
- for (const key in modules) {
36
- if (!Object.hasOwnProperty.call(modules, key))
37
- continue;
38
- const module = modules[key];
39
- if (!key.startsWith(context.stylePath || ''))
40
- continue;
41
- context.styleContentTransformed = module.code;
42
- break;
43
- }
44
- break;
45
- }
46
- }
47
- }
48
- catch { }
49
- await write();
50
- }
51
- };
52
- };
@@ -1,8 +0,0 @@
1
- /**
2
- * Used to bind a method of a class to the current context,
3
- * making it easier to reference `this` within the method.
4
- */
5
- export declare function Bind(): (target: Object, key: PropertyKey, descriptor: PropertyDescriptor) => {
6
- configurable: boolean;
7
- get(): any;
8
- };
@@ -1,21 +0,0 @@
1
- import { defineProperty } from '../utils/index.js';
2
- /**
3
- * Used to bind a method of a class to the current context,
4
- * making it easier to reference `this` within the method.
5
- */
6
- export function Bind() {
7
- return function (target, key, descriptor) {
8
- return {
9
- configurable: true,
10
- get() {
11
- const value = descriptor?.value.bind(this);
12
- defineProperty(this, key, {
13
- value,
14
- configurable: true,
15
- writable: true
16
- });
17
- return value;
18
- }
19
- };
20
- };
21
- }
@@ -1,3 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- export declare function Provider(namespace: string): (target: HTMLPlusElement, key: PropertyKey, descriptor: PropertyDescriptor) => void;
3
- export declare function Consumer(namespace: string): (target: HTMLPlusElement, key: PropertyKey) => void;
@@ -1,121 +0,0 @@
1
- import * as CONSTANTS from '../../constants/index.js';
2
- import { appendToMethod, dispatch, off, on } from '../utils/index.js';
3
- export function Provider(namespace) {
4
- return function (target, key, descriptor) {
5
- const symbol = Symbol();
6
- const [MAIN, SUB] = namespace.split('.');
7
- const prefix = `htmlplus:${MAIN}`;
8
- const cleanups = (instance) => {
9
- return (instance[symbol] ||= new Map());
10
- };
11
- const update = (instance) => {
12
- const options = {};
13
- options.detail = descriptor.get.call(instance);
14
- dispatch(instance, `${prefix}:update`, options);
15
- if (!SUB)
16
- return;
17
- options.bubbles = true;
18
- dispatch(instance, `${prefix}:${instance[SUB]}:update`, options);
19
- };
20
- // TODO
21
- appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
22
- const cleanup = () => {
23
- off(this, `${prefix}:presence`, onPresence);
24
- cleanups(this).delete(prefix);
25
- };
26
- const onPresence = (event) => {
27
- event.stopPropagation();
28
- event.detail(this, descriptor.get.call(this));
29
- };
30
- on(this, `${prefix}:presence`, onPresence);
31
- cleanups(this).set(prefix, cleanup);
32
- });
33
- appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATE, function (states) {
34
- update(this);
35
- if (cleanups(this).size && !states.has(SUB))
36
- return;
37
- cleanups(this).get(`${prefix}:${states.get(SUB)}`)?.();
38
- const type = `${prefix}:${this[SUB]}`;
39
- const cleanup = () => {
40
- off(window, `${type}:presence`, onPresence);
41
- cleanups(this).delete(type);
42
- dispatch(window, `${type}:disconnect`);
43
- };
44
- const onPresence = () => {
45
- update(this);
46
- };
47
- on(window, `${type}:presence`, onPresence);
48
- cleanups(this).set(type, cleanup);
49
- });
50
- appendToMethod(target, CONSTANTS.LIFECYCLE_DISCONNECTED, function () {
51
- cleanups(this).forEach((cleanup) => cleanup());
52
- });
53
- };
54
- }
55
- export function Consumer(namespace) {
56
- return function (target, key) {
57
- const symbol = Symbol();
58
- const [MAIN, SUB] = namespace.split('.');
59
- const prefix = `htmlplus:${MAIN}`;
60
- const cleanups = (instance) => {
61
- return (instance[symbol] ||= new Map());
62
- };
63
- const update = (instance, state) => {
64
- instance[key] = state;
65
- };
66
- // TODO
67
- appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
68
- // TODO
69
- if (SUB && this[SUB])
70
- return;
71
- // TODO
72
- let connected;
73
- const options = {
74
- bubbles: true
75
- };
76
- options.detail = (parent, state) => {
77
- // TODO
78
- connected = true;
79
- update(this, state);
80
- const cleanup = () => {
81
- off(parent, `${prefix}:update`, onUpdate);
82
- cleanups(this).delete(prefix);
83
- update(this, undefined);
84
- };
85
- const onUpdate = (event) => {
86
- update(this, event.detail);
87
- };
88
- on(parent, `${prefix}:update`, onUpdate);
89
- cleanups(this).set(prefix, cleanup);
90
- };
91
- dispatch(this, `${prefix}:presence`, options);
92
- // TODO: When the `Provider` element is activated after the `Consumer` element.
93
- !connected && setTimeout(() => dispatch(this, `${prefix}:presence`, options));
94
- });
95
- appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATE, function (states) {
96
- if (cleanups(this).size && !states.has(SUB))
97
- return;
98
- cleanups(this).get(`${prefix}:${states.get(SUB)}`)?.();
99
- const type = `${prefix}:${this[SUB]}`;
100
- const cleanup = () => {
101
- off(window, `${type}:disconnect`, onDisconnect);
102
- off(window, `${type}:update`, onUpdate);
103
- cleanups(this).delete(type);
104
- update(this, undefined);
105
- };
106
- const onDisconnect = () => {
107
- update(this, undefined);
108
- };
109
- const onUpdate = (event) => {
110
- update(this, event.detail);
111
- };
112
- on(window, `${type}:disconnect`, onDisconnect);
113
- on(window, `${type}:update`, onUpdate);
114
- cleanups(this).set(type, cleanup);
115
- dispatch(window, `${type}:presence`);
116
- });
117
- appendToMethod(target, CONSTANTS.LIFECYCLE_DISCONNECTED, function () {
118
- cleanups(this).forEach((cleanup) => cleanup());
119
- });
120
- };
121
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Indicates whether the [Direction](https://mdn.io/css-direction)
3
- * of the element is `Right-To-Left` or `Left-To-Right`.
4
- */
5
- export declare function Direction(): (target: import("../../types/index.js").HTMLPlusElement, key: PropertyKey) => void;
@@ -1,8 +0,0 @@
1
- import { direction, toDecorator } from '../utils/index.js';
2
- /**
3
- * Indicates whether the [Direction](https://mdn.io/css-direction)
4
- * of the element is `Right-To-Left` or `Left-To-Right`.
5
- */
6
- export function Direction() {
7
- return toDecorator(direction);
8
- }
@@ -1,7 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * The class marked with this decorator is considered a
4
- * [Custom Element](https://mdn.io/using-custom-elements),
5
- * and its name, in kebab-case, serves as the element name.
6
- */
7
- export declare function Element(): (constructor: HTMLPlusElement) => void;
@@ -1,65 +0,0 @@
1
- import { camelCase } from 'change-case';
2
- import * as CONSTANTS from '../../constants/index.js';
3
- import { call, getConfig, getTag, isServer, request } from '../utils/index.js';
4
- /**
5
- * The class marked with this decorator is considered a
6
- * [Custom Element](https://mdn.io/using-custom-elements),
7
- * and its name, in kebab-case, serves as the element name.
8
- */
9
- export function Element() {
10
- return function (constructor) {
11
- if (isServer())
12
- return;
13
- const tag = getTag(constructor);
14
- if (customElements.get(tag))
15
- return;
16
- customElements.define(tag, proxy(constructor));
17
- };
18
- }
19
- const proxy = (constructor) => {
20
- return class Plus extends HTMLElement {
21
- static formAssociated = constructor['formAssociated'];
22
- static observedAttributes = constructor['observedAttributes'];
23
- constructor() {
24
- super();
25
- this.attachShadow({
26
- mode: 'open',
27
- delegatesFocus: constructor['delegatesFocus'],
28
- slotAssignment: constructor['slotAssignment']
29
- });
30
- const instance = (this[CONSTANTS.API_INSTANCE] = new constructor());
31
- instance[CONSTANTS.API_HOST] = () => this;
32
- call(instance, CONSTANTS.LIFECYCLE_CONSTRUCTED);
33
- }
34
- adoptedCallback() {
35
- call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_ADOPTED);
36
- }
37
- attributeChangedCallback(key, prev, next) {
38
- // Ensures the integrity of readonly properties to prevent potential errors.
39
- try {
40
- const attribute = constructor[CONSTANTS.MAPPER]?.[key];
41
- const property = attribute || camelCase(key);
42
- this[property] = next;
43
- }
44
- catch { }
45
- }
46
- connectedCallback() {
47
- const instance = this[CONSTANTS.API_INSTANCE];
48
- // TODO: experimental for global config
49
- Object.assign(instance, getConfig('element', getTag(instance), 'property'));
50
- instance[CONSTANTS.API_CONNECTED] = true;
51
- const connect = () => {
52
- request(instance, undefined, undefined, () => {
53
- call(instance, CONSTANTS.LIFECYCLE_LOADED);
54
- });
55
- };
56
- const callback = call(instance, CONSTANTS.LIFECYCLE_CONNECTED);
57
- if (!callback?.then)
58
- return connect();
59
- callback.then(() => connect());
60
- }
61
- disconnectedCallback() {
62
- call(this[CONSTANTS.API_INSTANCE], CONSTANTS.LIFECYCLE_DISCONNECTED);
63
- }
64
- };
65
- };
@@ -1,35 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * A function type that generates a `CustomEvent`.
4
- */
5
- export type EventEmitter<T = any> = (data?: T) => CustomEvent<T>;
6
- /**
7
- * An object that configures
8
- * [options](https://developer.mozilla.org/docs/Web/API/Event/EventEvent#options)
9
- * for the event dispatcher.
10
- */
11
- export interface EventOptions {
12
- /**
13
- * A boolean value indicating whether the event bubbles.
14
- * The default is `false`.
15
- */
16
- bubbles?: boolean;
17
- /**
18
- * A boolean value indicating whether the event can be cancelled.
19
- * The default is `false`.
20
- */
21
- cancelable?: boolean;
22
- /**
23
- * A boolean value indicating whether the event will trigger listeners outside of a shadow root
24
- * (see [Event.composed](https://mdn.io/event-composed) for more details).
25
- * The default is `false`.
26
- */
27
- composed?: boolean;
28
- }
29
- /**
30
- * Provides the capability to dispatch a [CustomEvent](https://mdn.io/custom-event)
31
- * from an element.
32
- *
33
- * @param options An object that configures options for the event dispatcher.
34
- */
35
- export declare function Event<T = any>(options?: EventOptions): (target: HTMLPlusElement, key: PropertyKey) => void;
@@ -1,53 +0,0 @@
1
- import { kebabCase, pascalCase } from 'change-case';
2
- import { defineProperty, dispatch, getConfig, getFramework, host } from '../utils/index.js';
3
- /**
4
- * Provides the capability to dispatch a [CustomEvent](https://mdn.io/custom-event)
5
- * from an element.
6
- *
7
- * @param options An object that configures options for the event dispatcher.
8
- */
9
- export function Event(options = {}) {
10
- return function (target, key) {
11
- defineProperty(target, key, {
12
- get() {
13
- return (detail) => {
14
- const element = host(this);
15
- const framework = getFramework(this);
16
- options.bubbles ??= false;
17
- let type = String(key);
18
- switch (framework) {
19
- // TODO: Experimental
20
- case 'blazor':
21
- options.bubbles = true;
22
- type = pascalCase(type);
23
- try {
24
- window['Blazor'].registerCustomEventType(type, {
25
- createEventArgs: (event) => ({
26
- detail: event.detail
27
- })
28
- });
29
- }
30
- catch { }
31
- break;
32
- case 'qwik':
33
- case 'solid':
34
- type = pascalCase(type).toLowerCase();
35
- break;
36
- case 'react':
37
- case 'preact':
38
- type = pascalCase(type);
39
- break;
40
- default:
41
- type = kebabCase(type);
42
- break;
43
- }
44
- let event;
45
- event ||= getConfig('event', 'resolver')?.({ detail, element, framework, options, type });
46
- event && element.dispatchEvent(event);
47
- event ||= dispatch(this, type, { ...options, detail });
48
- return event;
49
- };
50
- }
51
- });
52
- };
53
- }
@@ -1,4 +0,0 @@
1
- /**
2
- * Indicates the host of the element.
3
- */
4
- export declare function Host(): (target: import("../../types/index.js").HTMLPlusElement, key: PropertyKey) => void;
@@ -1,7 +0,0 @@
1
- import { host, toDecorator } from '../utils/index.js';
2
- /**
3
- * Indicates the host of the element.
4
- */
5
- export function Host() {
6
- return toDecorator(host);
7
- }
@@ -1,15 +0,0 @@
1
- export * from './bind.js';
2
- export * from './context.js';
3
- export * from './direction.js';
4
- export * from './element.js';
5
- export * from './event.js';
6
- export * from './host.js';
7
- export * from './isRTL.js';
8
- export * from './listen.js';
9
- export * from './method.js';
10
- export * from './property.js';
11
- export * from './query.js';
12
- export * from './queryAll.js';
13
- export * from './slots.js';
14
- export * from './state.js';
15
- export * from './watch.js';
@@ -1,15 +0,0 @@
1
- export * from './bind.js';
2
- export * from './context.js';
3
- export * from './direction.js';
4
- export * from './element.js';
5
- export * from './event.js';
6
- export * from './host.js';
7
- export * from './isRTL.js';
8
- export * from './listen.js';
9
- export * from './method.js';
10
- export * from './property.js';
11
- export * from './query.js';
12
- export * from './queryAll.js';
13
- export * from './slots.js';
14
- export * from './state.js';
15
- export * from './watch.js';
@@ -1,4 +0,0 @@
1
- /**
2
- * Indicates whether the direction of the element is `Right-To-Left` or not.
3
- */
4
- export declare function IsRTL(): (target: import("../../types/index.js").HTMLPlusElement, key: PropertyKey) => void;
@@ -1,7 +0,0 @@
1
- import { isRTL, toDecorator } from '../utils/index.js';
2
- /**
3
- * Indicates whether the direction of the element is `Right-To-Left` or not.
4
- */
5
- export function IsRTL() {
6
- return toDecorator(isRTL);
7
- }
@@ -1,52 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * An object that configures
4
- * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
5
- * for the event listener.
6
- */
7
- export interface ListenOptions {
8
- /**
9
- * A boolean value indicating that events of this type will be dispatched to the registered
10
- * `listener` before being dispatched to any `EventTarget` beneath it in the DOM tree.
11
- * If not specified, defaults to `false`.
12
- */
13
- capture?: boolean;
14
- /**
15
- * A boolean value indicating that the `listener` should be invoked at most once after being added.
16
- * If `true`, the `listener` would be automatically removed when invoked.
17
- * If not specified, defaults to `false`.
18
- */
19
- once?: boolean;
20
- /**
21
- * A boolean value that, if `true`,
22
- * indicates that the function specified by `listener` will never call
23
- * [preventDefault()](https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault).
24
- * If a passive listener does call `preventDefault()`,
25
- * the user agent will do nothing other than generate a console warning.
26
- */
27
- passive?: boolean;
28
- /**
29
- * An [AbortSignal](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal).
30
- * The listener will be removed when the given `AbortSignal` object's
31
- * [abort()](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort) method is called.
32
- * If not specified, no `AbortSignal` is associated with the listener.
33
- */
34
- signal?: AbortSignal;
35
- /**
36
- * The target element, defaults to `host`.
37
- */
38
- target?: 'host' | 'body' | 'document' | 'window';
39
- }
40
- /**
41
- * Will be called whenever the specified event is delivered to the target
42
- * [More](https://mdn.io/add-event-listener).
43
- *
44
- * @param type A case-sensitive string representing the [Event Type](https://mdn.io/events) to listen for.
45
- * @param options An object that configures
46
- * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
47
- * for the event listener.
48
- */
49
- export declare function Listen(type: string, options?: ListenOptions): (target: HTMLPlusElement, key: PropertyKey, descriptor: PropertyDescriptor) => {
50
- configurable: boolean;
51
- get(): any;
52
- };
@@ -1,37 +0,0 @@
1
- import * as CONSTANTS from '../../constants/index.js';
2
- import { appendToMethod, on, off } from '../utils/index.js';
3
- import { Bind } from './bind.js';
4
- /**
5
- * Will be called whenever the specified event is delivered to the target
6
- * [More](https://mdn.io/add-event-listener).
7
- *
8
- * @param type A case-sensitive string representing the [Event Type](https://mdn.io/events) to listen for.
9
- * @param options An object that configures
10
- * [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
11
- * for the event listener.
12
- */
13
- export function Listen(type, options) {
14
- return function (target, key, descriptor) {
15
- const element = (instance) => {
16
- switch (options?.target) {
17
- case 'body':
18
- return window.document.body;
19
- case 'document':
20
- return window.document;
21
- case 'window':
22
- return window;
23
- case 'host':
24
- return instance;
25
- default:
26
- return instance;
27
- }
28
- };
29
- appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
30
- on(element(this), type, this[key], options);
31
- });
32
- appendToMethod(target, CONSTANTS.LIFECYCLE_DISCONNECTED, function () {
33
- off(element(this), type, this[key], options);
34
- });
35
- return Bind()(target, key, descriptor);
36
- };
37
- }
@@ -1,6 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * Provides a way to encapsulate functionality within an element
4
- * and invoke it as needed, both internally and externally.
5
- */
6
- export declare function Method(): (target: HTMLPlusElement, key: PropertyKey) => void;
@@ -1,15 +0,0 @@
1
- import * as CONSTANTS from '../../constants/index.js';
2
- import { appendToMethod, defineProperty, host } from '../utils/index.js';
3
- /**
4
- * Provides a way to encapsulate functionality within an element
5
- * and invoke it as needed, both internally and externally.
6
- */
7
- export function Method() {
8
- return function (target, key) {
9
- appendToMethod(target, CONSTANTS.LIFECYCLE_CONSTRUCTED, function () {
10
- defineProperty(host(this), key, {
11
- get: () => this[key].bind(this)
12
- });
13
- });
14
- };
15
- }
@@ -1,25 +0,0 @@
1
- import { HTMLPlusElement } from '../../types/index.js';
2
- /**
3
- * The configuration for property decorator.
4
- */
5
- export interface PropertyOptions {
6
- /**
7
- * Specifies the name of the attribute related to the property.
8
- */
9
- attribute?: string;
10
- /**
11
- * Whether property value is reflected back to the associated attribute. default is `false`.
12
- */
13
- reflect?: boolean;
14
- /**
15
- * Specifies the property `type` and supports
16
- * [data types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures).
17
- * If this value is not set, it will be set automatically during transforming.
18
- */
19
- type?: any;
20
- }
21
- /**
22
- * Creates a reactive property, reflecting a corresponding attribute value,
23
- * and updates the element when the property is set.
24
- */
25
- export declare function Property(options?: PropertyOptions): (target: HTMLPlusElement, key: PropertyKey, descriptor?: PropertyDescriptor) => void;