@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.
- package/README.md +2 -2
- package/bundlers.d.ts +19 -0
- package/bundlers.js +75 -0
- package/client-5FqNUiuz.d.ts +309 -0
- package/client-By_MTZkm.js +1796 -0
- package/client.d.ts +1 -0
- package/client.js +3 -0
- package/constants.d.ts +50 -0
- package/constants.js +62 -0
- package/internal.d.ts +1 -0
- package/internal.js +3 -0
- package/package.json +9 -4
- package/transformer.d.ts +137 -0
- package/transformer.js +1253 -0
- package/bundlers/rollup.d.ts +0 -7
- package/bundlers/rollup.js +0 -23
- package/bundlers/vite.d.ts +0 -8
- package/bundlers/vite.js +0 -52
- package/client/decorators/bind.d.ts +0 -8
- package/client/decorators/bind.js +0 -21
- package/client/decorators/context.d.ts +0 -3
- package/client/decorators/context.js +0 -121
- package/client/decorators/direction.d.ts +0 -5
- package/client/decorators/direction.js +0 -8
- package/client/decorators/element.d.ts +0 -7
- package/client/decorators/element.js +0 -65
- package/client/decorators/event.d.ts +0 -35
- package/client/decorators/event.js +0 -53
- package/client/decorators/host.d.ts +0 -4
- package/client/decorators/host.js +0 -7
- package/client/decorators/index.d.ts +0 -15
- package/client/decorators/index.js +0 -15
- package/client/decorators/isRTL.d.ts +0 -4
- package/client/decorators/isRTL.js +0 -7
- package/client/decorators/listen.d.ts +0 -52
- package/client/decorators/listen.js +0 -37
- package/client/decorators/method.d.ts +0 -6
- package/client/decorators/method.js +0 -15
- package/client/decorators/property.d.ts +0 -25
- package/client/decorators/property.js +0 -94
- package/client/decorators/query.d.ts +0 -9
- package/client/decorators/query.js +0 -12
- package/client/decorators/queryAll.d.ts +0 -12
- package/client/decorators/queryAll.js +0 -15
- package/client/decorators/slots.d.ts +0 -4
- package/client/decorators/slots.js +0 -7
- package/client/decorators/state.d.ts +0 -6
- package/client/decorators/state.js +0 -23
- package/client/decorators/watch.d.ts +0 -11
- package/client/decorators/watch.js +0 -31
- package/client/index.d.ts +0 -2
- package/client/index.js +0 -2
- package/client/utils/appendToMethod.d.ts +0 -1
- package/client/utils/appendToMethod.js +0 -15
- package/client/utils/attributes.d.ts +0 -2
- package/client/utils/attributes.js +0 -33
- package/client/utils/call.d.ts +0 -1
- package/client/utils/call.js +0 -3
- package/client/utils/classes.d.ts +0 -4
- package/client/utils/classes.js +0 -45
- package/client/utils/config.d.ts +0 -39
- package/client/utils/config.js +0 -28
- package/client/utils/defineProperty.d.ts +0 -1
- package/client/utils/defineProperty.js +0 -1
- package/client/utils/direction.d.ts +0 -6
- package/client/utils/direction.js +0 -8
- package/client/utils/event.d.ts +0 -13
- package/client/utils/event.js +0 -48
- package/client/utils/getFramework.d.ts +0 -2
- package/client/utils/getFramework.js +0 -20
- package/client/utils/getStyles.d.ts +0 -2
- package/client/utils/getStyles.js +0 -4
- package/client/utils/getTag.d.ts +0 -2
- package/client/utils/getTag.js +0 -4
- package/client/utils/host.d.ts +0 -5
- package/client/utils/host.js +0 -12
- package/client/utils/index.d.ts +0 -32
- package/client/utils/index.js +0 -32
- package/client/utils/isCSSColor.d.ts +0 -5
- package/client/utils/isCSSColor.js +0 -9
- package/client/utils/isEvent.d.ts +0 -1
- package/client/utils/isEvent.js +0 -3
- package/client/utils/isRTL.d.ts +0 -5
- package/client/utils/isRTL.js +0 -5
- package/client/utils/isServer.d.ts +0 -4
- package/client/utils/isServer.js +0 -6
- package/client/utils/merge.d.ts +0 -1
- package/client/utils/merge.js +0 -22
- package/client/utils/query.d.ts +0 -5
- package/client/utils/query.js +0 -7
- package/client/utils/queryAll.d.ts +0 -5
- package/client/utils/queryAll.js +0 -7
- package/client/utils/request.d.ts +0 -9
- package/client/utils/request.js +0 -106
- package/client/utils/shadowRoot.d.ts +0 -2
- package/client/utils/shadowRoot.js +0 -4
- package/client/utils/slots.d.ts +0 -9
- package/client/utils/slots.js +0 -18
- package/client/utils/styles.d.ts +0 -4
- package/client/utils/styles.js +0 -10
- package/client/utils/task.d.ts +0 -6
- package/client/utils/task.js +0 -34
- package/client/utils/toBoolean.d.ts +0 -1
- package/client/utils/toBoolean.js +0 -3
- package/client/utils/toDecorator.d.ts +0 -2
- package/client/utils/toDecorator.js +0 -10
- package/client/utils/toEvent.d.ts +0 -1
- package/client/utils/toEvent.js +0 -3
- package/client/utils/toProperty.d.ts +0 -1
- package/client/utils/toProperty.js +0 -55
- package/client/utils/toUnit.d.ts +0 -4
- package/client/utils/toUnit.js +0 -10
- package/client/utils/typeOf.d.ts +0 -3
- package/client/utils/typeOf.js +0 -6
- package/client/utils/uhtml.d.ts +0 -22
- package/client/utils/uhtml.js +0 -703
- package/client/utils/updateAttribute.d.ts +0 -2
- package/client/utils/updateAttribute.js +0 -10
- package/constants/index.d.ts +0 -48
- package/constants/index.js +0 -60
- package/transformer/index.d.ts +0 -3
- package/transformer/index.js +0 -3
- package/transformer/plugins/assets.d.ts +0 -7
- package/transformer/plugins/assets.js +0 -26
- package/transformer/plugins/copy.d.ts +0 -9
- package/transformer/plugins/copy.js +0 -29
- package/transformer/plugins/customElement.d.ts +0 -7
- package/transformer/plugins/customElement.js +0 -392
- package/transformer/plugins/document.d.ts +0 -7
- package/transformer/plugins/document.js +0 -206
- package/transformer/plugins/extract.d.ts +0 -2
- package/transformer/plugins/extract.js +0 -22
- package/transformer/plugins/index.d.ts +0 -12
- package/transformer/plugins/index.js +0 -12
- package/transformer/plugins/parse.d.ts +0 -6
- package/transformer/plugins/parse.js +0 -13
- package/transformer/plugins/read.d.ts +0 -7
- package/transformer/plugins/read.js +0 -19
- package/transformer/plugins/readme.d.ts +0 -6
- package/transformer/plugins/readme.js +0 -24
- package/transformer/plugins/style.d.ts +0 -6
- package/transformer/plugins/style.js +0 -42
- package/transformer/plugins/validate.d.ts +0 -2
- package/transformer/plugins/validate.js +0 -40
- package/transformer/plugins/visualStudioCode.d.ts +0 -8
- package/transformer/plugins/visualStudioCode.js +0 -73
- package/transformer/plugins/webTypes.d.ts +0 -10
- package/transformer/plugins/webTypes.js +0 -74
- package/transformer/transformer.d.ts +0 -8
- package/transformer/transformer.js +0 -78
- package/transformer/transformer.types.d.ts +0 -52
- package/transformer/transformer.types.js +0 -1
- package/transformer/utils/addDependency.d.ts +0 -7
- package/transformer/utils/addDependency.js +0 -64
- package/transformer/utils/extractAttribute.d.ts +0 -2
- package/transformer/utils/extractAttribute.js +0 -10
- package/transformer/utils/extractFromComment.d.ts +0 -4
- package/transformer/utils/extractFromComment.js +0 -51
- package/transformer/utils/getInitializer.d.ts +0 -2
- package/transformer/utils/getInitializer.js +0 -3
- package/transformer/utils/getType.d.ts +0 -2
- package/transformer/utils/getType.js +0 -89
- package/transformer/utils/getTypeReference.d.ts +0 -2
- package/transformer/utils/getTypeReference.js +0 -33
- package/transformer/utils/hasDecorator.d.ts +0 -1
- package/transformer/utils/hasDecorator.js +0 -5
- package/transformer/utils/index.d.ts +0 -10
- package/transformer/utils/index.js +0 -10
- package/transformer/utils/print.d.ts +0 -2
- package/transformer/utils/print.js +0 -5
- package/transformer/utils/printType.d.ts +0 -1
- package/transformer/utils/printType.js +0 -69
- package/transformer/utils/visitor.d.ts +0 -2
- package/transformer/utils/visitor.js +0 -5
- package/types/index.d.ts +0 -2
- package/types/index.js +0 -1
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { kebabCase } from 'change-case';
|
|
2
|
-
import * as CONSTANTS from '../../constants/index.js';
|
|
3
|
-
import { appendToMethod, defineProperty, host, request, toProperty, updateAttribute } from '../utils/index.js';
|
|
4
|
-
/**
|
|
5
|
-
* Creates a reactive property, reflecting a corresponding attribute value,
|
|
6
|
-
* and updates the element when the property is set.
|
|
7
|
-
*/
|
|
8
|
-
export function Property(options) {
|
|
9
|
-
return function (target, key, descriptor) {
|
|
10
|
-
// Creates a unique symbol for the lock flag.
|
|
11
|
-
const locked = Symbol();
|
|
12
|
-
// Converts property name to string.
|
|
13
|
-
const name = String(key);
|
|
14
|
-
// Calculates attribute.
|
|
15
|
-
const attribute = options?.attribute || kebabCase(name);
|
|
16
|
-
// Registers an attribute that is intricately linked to the property.
|
|
17
|
-
(target.constructor['observedAttributes'] ||= []).push(attribute);
|
|
18
|
-
// TODO
|
|
19
|
-
if (attribute) {
|
|
20
|
-
// TODO
|
|
21
|
-
target.constructor[CONSTANTS.MAPPER] ||= {};
|
|
22
|
-
// TODO
|
|
23
|
-
target.constructor[CONSTANTS.MAPPER][attribute] = name;
|
|
24
|
-
}
|
|
25
|
-
// TODO: This feature is an experimental
|
|
26
|
-
// When the property is a getter function.
|
|
27
|
-
if (descriptor) {
|
|
28
|
-
// Checks the reflection.
|
|
29
|
-
if (options?.reflect) {
|
|
30
|
-
// Stores the original getter function.
|
|
31
|
-
const getter = descriptor.get;
|
|
32
|
-
// Defines a new getter function.
|
|
33
|
-
descriptor.get = function () {
|
|
34
|
-
const value = getter?.apply(this);
|
|
35
|
-
this[locked] = true;
|
|
36
|
-
updateAttribute(this, attribute, value);
|
|
37
|
-
this[locked] = false;
|
|
38
|
-
return value;
|
|
39
|
-
};
|
|
40
|
-
// TODO: Check the lifecycle
|
|
41
|
-
appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATED, function () {
|
|
42
|
-
// Calls the getter function to update the related attribute.
|
|
43
|
-
this[key];
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// When the property is normal.
|
|
48
|
-
else {
|
|
49
|
-
// Creates a unique symbol.
|
|
50
|
-
const symbol = Symbol();
|
|
51
|
-
// Defines a getter function to use in the target class.
|
|
52
|
-
function get() {
|
|
53
|
-
return this[symbol];
|
|
54
|
-
}
|
|
55
|
-
// Defines a setter function to use in the target class.
|
|
56
|
-
function set(next) {
|
|
57
|
-
const previous = this[symbol];
|
|
58
|
-
if (next === previous)
|
|
59
|
-
return;
|
|
60
|
-
this[symbol] = next;
|
|
61
|
-
request(this, name, previous, (skipped) => {
|
|
62
|
-
if (skipped)
|
|
63
|
-
return;
|
|
64
|
-
if (!options?.reflect)
|
|
65
|
-
return;
|
|
66
|
-
this[locked] = true;
|
|
67
|
-
updateAttribute(this, attribute, next);
|
|
68
|
-
this[locked] = false;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
// Attaches the getter and setter functions to the current property of the target class.
|
|
72
|
-
defineProperty(target, key, { get, set });
|
|
73
|
-
}
|
|
74
|
-
// TODO: Check the lifecycle
|
|
75
|
-
appendToMethod(target, CONSTANTS.LIFECYCLE_CONSTRUCTED, function () {
|
|
76
|
-
// Defines a getter function to use in the host element.
|
|
77
|
-
const get = () => {
|
|
78
|
-
return this[key];
|
|
79
|
-
};
|
|
80
|
-
// Defines a setter function to use in the host element.
|
|
81
|
-
const set = descriptor
|
|
82
|
-
? undefined
|
|
83
|
-
: (input) => {
|
|
84
|
-
if (this[locked]) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
this[key] = toProperty(input, options?.type);
|
|
88
|
-
};
|
|
89
|
-
// TODO: Check the configuration.
|
|
90
|
-
// Attaches the getter and setter functions to the current property of the host element.
|
|
91
|
-
defineProperty(host(this), key, { get, set, configurable: true });
|
|
92
|
-
});
|
|
93
|
-
};
|
|
94
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Selects the first element in the shadow dom that matches a specified CSS selector.
|
|
3
|
-
*
|
|
4
|
-
* @param selectors A string containing one or more selectors to match.
|
|
5
|
-
* This string must be a valid CSS selector string; if it isn't, a `SyntaxError` exception is thrown. See
|
|
6
|
-
* [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
|
|
7
|
-
* for more about selectors and how to manage them.
|
|
8
|
-
*/
|
|
9
|
-
export declare function Query(selectors: string): (target: import("../../types/index.js").HTMLPlusElement, key: PropertyKey) => void;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { query, toDecorator } from '../utils/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Selects the first element in the shadow dom that matches a specified CSS selector.
|
|
4
|
-
*
|
|
5
|
-
* @param selectors A string containing one or more selectors to match.
|
|
6
|
-
* This string must be a valid CSS selector string; if it isn't, a `SyntaxError` exception is thrown. See
|
|
7
|
-
* [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
|
|
8
|
-
* for more about selectors and how to manage them.
|
|
9
|
-
*/
|
|
10
|
-
export function Query(selectors) {
|
|
11
|
-
return toDecorator(query, selectors);
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Selects all elements in the shadow dom that match a specified CSS selector.
|
|
3
|
-
*
|
|
4
|
-
* @param selectors A string containing one or more selectors to match against.
|
|
5
|
-
* This string must be a valid
|
|
6
|
-
* [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors)
|
|
7
|
-
* string; if it's not, a `SyntaxError` exception is thrown. See
|
|
8
|
-
* [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
|
|
9
|
-
* for more information about using selectors to identify elements.
|
|
10
|
-
* Multiple selectors may be specified by separating them using commas.
|
|
11
|
-
*/
|
|
12
|
-
export declare function QueryAll(selectors: string): (target: import("../../types/index.js").HTMLPlusElement, key: PropertyKey) => void;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { queryAll, toDecorator } from '../utils/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Selects all elements in the shadow dom that match a specified CSS selector.
|
|
4
|
-
*
|
|
5
|
-
* @param selectors A string containing one or more selectors to match against.
|
|
6
|
-
* This string must be a valid
|
|
7
|
-
* [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_selectors)
|
|
8
|
-
* string; if it's not, a `SyntaxError` exception is thrown. See
|
|
9
|
-
* [Locating DOM elements using selectors](https://developer.mozilla.org/en-US/docs/Web/API/Document_object_model/Locating_DOM_elements_using_selectors)
|
|
10
|
-
* for more information about using selectors to identify elements.
|
|
11
|
-
* Multiple selectors may be specified by separating them using commas.
|
|
12
|
-
*/
|
|
13
|
-
export function QueryAll(selectors) {
|
|
14
|
-
return toDecorator(queryAll, selectors);
|
|
15
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { HTMLPlusElement } from '../../types/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Applying this decorator to any `class property` will trigger the
|
|
4
|
-
* element to re-render upon the desired property changes.
|
|
5
|
-
*/
|
|
6
|
-
export declare function State(): (target: HTMLPlusElement, key: PropertyKey) => void;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { defineProperty, request } from '../utils/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Applying this decorator to any `class property` will trigger the
|
|
4
|
-
* element to re-render upon the desired property changes.
|
|
5
|
-
*/
|
|
6
|
-
export function State() {
|
|
7
|
-
return function (target, key) {
|
|
8
|
-
const name = String(key);
|
|
9
|
-
const symbol = Symbol();
|
|
10
|
-
function get() {
|
|
11
|
-
return this[symbol];
|
|
12
|
-
}
|
|
13
|
-
function set(next) {
|
|
14
|
-
const previous = this[symbol];
|
|
15
|
-
if (next === previous)
|
|
16
|
-
return;
|
|
17
|
-
this[symbol] = next;
|
|
18
|
-
request(this, name, previous);
|
|
19
|
-
}
|
|
20
|
-
// TODO: configurable
|
|
21
|
-
defineProperty(target, key, { get, set, configurable: true });
|
|
22
|
-
};
|
|
23
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HTMLPlusElement } from '../../types/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* Monitors `@Property` and `@State` to detect changes.
|
|
4
|
-
* The decorated method will be called after any changes,
|
|
5
|
-
* with the `key`, `newValue`, and `oldValue` as parameters.
|
|
6
|
-
* If the `key` is not defined, all `@Property` and `@State` are considered.
|
|
7
|
-
*
|
|
8
|
-
* @param keys Collection of `@Property` and `@State` names.
|
|
9
|
-
* @param immediate Triggers the callback immediately after initialization.
|
|
10
|
-
*/
|
|
11
|
-
export declare function Watch(keys?: string | string[], immediate?: boolean): (target: HTMLPlusElement, key: PropertyKey) => void;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import * as CONSTANTS from '../../constants/index.js';
|
|
2
|
-
import { appendToMethod } from '../utils/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* Monitors `@Property` and `@State` to detect changes.
|
|
5
|
-
* The decorated method will be called after any changes,
|
|
6
|
-
* with the `key`, `newValue`, and `oldValue` as parameters.
|
|
7
|
-
* If the `key` is not defined, all `@Property` and `@State` are considered.
|
|
8
|
-
*
|
|
9
|
-
* @param keys Collection of `@Property` and `@State` names.
|
|
10
|
-
* @param immediate Triggers the callback immediately after initialization.
|
|
11
|
-
*/
|
|
12
|
-
export function Watch(keys, immediate) {
|
|
13
|
-
return function (target, key) {
|
|
14
|
-
// Gets all keys
|
|
15
|
-
const all = [keys].flat().filter((item) => item);
|
|
16
|
-
// Registers a lifecycle to detect changes.
|
|
17
|
-
appendToMethod(target, CONSTANTS.LIFECYCLE_UPDATED, function (states) {
|
|
18
|
-
// Skips the logic if 'immediate' wasn't passed.
|
|
19
|
-
if (!immediate && !this[CONSTANTS.API_RENDER_COMPLETED])
|
|
20
|
-
return;
|
|
21
|
-
// Loops the keys.
|
|
22
|
-
states.forEach((previous, item) => {
|
|
23
|
-
// Skips the current key.
|
|
24
|
-
if (all.length && !all.includes(item))
|
|
25
|
-
return;
|
|
26
|
-
// Invokes the method with parameters.
|
|
27
|
-
this[key](this[item], previous, item);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
};
|
|
31
|
-
}
|
package/client/index.d.ts
DELETED
package/client/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const appendToMethod: (target: Object, key: PropertyKey, handler: (this: any, ...parameters: Array<any>) => void) => void;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export const appendToMethod = (target, key, handler) => {
|
|
2
|
-
// Gets the previous function
|
|
3
|
-
const previous = target[key];
|
|
4
|
-
// Creates new function
|
|
5
|
-
function next(...parameters) {
|
|
6
|
-
// Calls the previous
|
|
7
|
-
const result = previous?.bind(this)(...parameters);
|
|
8
|
-
// Calls the appended
|
|
9
|
-
handler.bind(this)(...parameters);
|
|
10
|
-
// Returns the result
|
|
11
|
-
return result;
|
|
12
|
-
}
|
|
13
|
-
// Replaces the next with the previous one
|
|
14
|
-
target[key] = next;
|
|
15
|
-
};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { off, on } from './event.js';
|
|
2
|
-
import { host } from './host.js';
|
|
3
|
-
import { isEvent } from './isEvent.js';
|
|
4
|
-
import { toEvent } from './toEvent.js';
|
|
5
|
-
import { updateAttribute } from './updateAttribute.js';
|
|
6
|
-
const symbol = Symbol();
|
|
7
|
-
export const attributes = (target, attributes) => {
|
|
8
|
-
const element = host(target);
|
|
9
|
-
const prev = element[symbol] || {};
|
|
10
|
-
const next = Object.assign({}, ...attributes);
|
|
11
|
-
const prevClass = (prev.class || '').split(' ');
|
|
12
|
-
const nextClass = (next.class || '').split(' ');
|
|
13
|
-
const newClass = element.className
|
|
14
|
-
.split(' ')
|
|
15
|
-
.filter((key) => !prevClass.includes(key) && !nextClass.includes(key))
|
|
16
|
-
.concat(nextClass)
|
|
17
|
-
.filter((key) => key)
|
|
18
|
-
.join(' ');
|
|
19
|
-
updateAttribute(element, 'class', newClass || undefined);
|
|
20
|
-
if (prev.style || next.style)
|
|
21
|
-
element.setAttribute('style', next.style || '');
|
|
22
|
-
for (const key in prev)
|
|
23
|
-
isEvent(key) && off(element, toEvent(key), prev[key]);
|
|
24
|
-
for (const key in next) {
|
|
25
|
-
if (['class', 'style'].includes(key))
|
|
26
|
-
continue;
|
|
27
|
-
if (isEvent(key))
|
|
28
|
-
on(element, toEvent(key), next[key]);
|
|
29
|
-
else
|
|
30
|
-
updateAttribute(element, key, next[key]);
|
|
31
|
-
}
|
|
32
|
-
element[symbol] = { ...next };
|
|
33
|
-
};
|
package/client/utils/call.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const call: (target: Object, key: PropertyKey, ...parameters: Array<any>) => any;
|
package/client/utils/call.js
DELETED
package/client/utils/classes.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { kebabCase } from 'change-case';
|
|
2
|
-
import { typeOf } from './typeOf.js';
|
|
3
|
-
/**
|
|
4
|
-
* TODO
|
|
5
|
-
*/
|
|
6
|
-
export const classes = (input, smart) => {
|
|
7
|
-
const result = [];
|
|
8
|
-
switch (typeOf(input)) {
|
|
9
|
-
case 'array': {
|
|
10
|
-
for (const item of input) {
|
|
11
|
-
result.push(classes(item, smart));
|
|
12
|
-
}
|
|
13
|
-
break;
|
|
14
|
-
}
|
|
15
|
-
case 'object': {
|
|
16
|
-
const keys = Object.keys(input);
|
|
17
|
-
for (const key of keys) {
|
|
18
|
-
const value = input[key];
|
|
19
|
-
const name = kebabCase(key);
|
|
20
|
-
const type = typeOf(value);
|
|
21
|
-
if (!smart) {
|
|
22
|
-
value && result.push(name);
|
|
23
|
-
continue;
|
|
24
|
-
}
|
|
25
|
-
switch (type) {
|
|
26
|
-
case 'boolean': {
|
|
27
|
-
value && result.push(`${name}`);
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
case 'number':
|
|
31
|
-
case 'string': {
|
|
32
|
-
result.push(`${name}-${value}`);
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
case 'string': {
|
|
40
|
-
result.push(input);
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return result.filter((item) => item).join(' ');
|
|
45
|
-
};
|
package/client/utils/config.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* TODO
|
|
3
|
-
*/
|
|
4
|
-
export interface Config {
|
|
5
|
-
event?: {
|
|
6
|
-
resolver?: (parameters: any) => CustomEvent | undefined;
|
|
7
|
-
};
|
|
8
|
-
asset?: {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
};
|
|
11
|
-
element?: {
|
|
12
|
-
[key: string]: {
|
|
13
|
-
property?: {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* TODO
|
|
21
|
-
*/
|
|
22
|
-
export interface ConfigOptions {
|
|
23
|
-
/**
|
|
24
|
-
* TODO
|
|
25
|
-
*/
|
|
26
|
-
force?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* TODO
|
|
29
|
-
*/
|
|
30
|
-
override?: boolean;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* TODO
|
|
34
|
-
*/
|
|
35
|
-
export declare const getConfig: (...keys: string[]) => any;
|
|
36
|
-
/**
|
|
37
|
-
* TODO
|
|
38
|
-
*/
|
|
39
|
-
export declare const setConfig: (config: Config, options?: ConfigOptions) => void;
|
package/client/utils/config.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { isServer } from './isServer.js';
|
|
2
|
-
import { merge } from './merge.js';
|
|
3
|
-
const DEFAULTS = {
|
|
4
|
-
element: {}
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* TODO
|
|
8
|
-
*/
|
|
9
|
-
export const getConfig = (...keys) => {
|
|
10
|
-
if (isServer())
|
|
11
|
-
return;
|
|
12
|
-
let config = window[`$htmlplus$`];
|
|
13
|
-
for (const key of keys) {
|
|
14
|
-
if (!config)
|
|
15
|
-
break;
|
|
16
|
-
config = config[key];
|
|
17
|
-
}
|
|
18
|
-
return config;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* TODO
|
|
22
|
-
*/
|
|
23
|
-
export const setConfig = (config, options) => {
|
|
24
|
-
if (isServer())
|
|
25
|
-
return;
|
|
26
|
-
const previous = options?.override ? {} : window[`$htmlplus$`];
|
|
27
|
-
window[`$htmlplus$`] = merge({}, DEFAULTS, previous, config);
|
|
28
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const defineProperty: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const defineProperty = Object.defineProperty;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { HTMLPlusElement } from '../../types/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 declare const direction: (target: HTMLElement | HTMLPlusElement) => "ltr" | "rtl";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { host } from './host.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 const direction = (target) => {
|
|
7
|
-
return getComputedStyle(host(target)).getPropertyValue('direction');
|
|
8
|
-
};
|
package/client/utils/event.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { HTMLPlusElement } from '../../types/index.js';
|
|
2
|
-
/**
|
|
3
|
-
* TODO
|
|
4
|
-
*/
|
|
5
|
-
export declare const dispatch: <T = any>(target: HTMLElement | HTMLPlusElement, type: string, eventInitDict?: CustomEventInit<T>) => CustomEvent<T>;
|
|
6
|
-
/**
|
|
7
|
-
* TODO
|
|
8
|
-
*/
|
|
9
|
-
export declare const on: (target: Window | Document | HTMLElement | HTMLPlusElement, type: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
|
|
10
|
-
/**
|
|
11
|
-
* TODO
|
|
12
|
-
*/
|
|
13
|
-
export declare const off: (target: Window | Document | HTMLElement | HTMLPlusElement, type: string, handler: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions) => void;
|
package/client/utils/event.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { host } from './host.js';
|
|
2
|
-
const outsides = [];
|
|
3
|
-
/**
|
|
4
|
-
* TODO
|
|
5
|
-
*/
|
|
6
|
-
export const dispatch = (target, type, eventInitDict) => {
|
|
7
|
-
const event = new CustomEvent(type, eventInitDict);
|
|
8
|
-
host(target).dispatchEvent(event);
|
|
9
|
-
return event;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* TODO
|
|
13
|
-
*/
|
|
14
|
-
export const on = (target, type, handler, options) => {
|
|
15
|
-
const element = host(target);
|
|
16
|
-
if (type != 'outside') {
|
|
17
|
-
return element.addEventListener(type, handler, options);
|
|
18
|
-
}
|
|
19
|
-
const callback = (event) => {
|
|
20
|
-
!event.composedPath().some((item) => item == element) && handler(event);
|
|
21
|
-
};
|
|
22
|
-
type = 'ontouchstart' in window.document.documentElement ? 'touchstart' : 'click';
|
|
23
|
-
on(document, type, callback, options);
|
|
24
|
-
outsides.push({
|
|
25
|
-
callback,
|
|
26
|
-
element,
|
|
27
|
-
handler,
|
|
28
|
-
options,
|
|
29
|
-
type
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* TODO
|
|
34
|
-
*/
|
|
35
|
-
export const off = (target, type, handler, options) => {
|
|
36
|
-
const element = host(target);
|
|
37
|
-
if (type != 'outside') {
|
|
38
|
-
return element.removeEventListener(type, handler, options);
|
|
39
|
-
}
|
|
40
|
-
const index = outsides.findIndex((outside) => {
|
|
41
|
-
return outside.element == element && outside.handler == handler && outside.options == options;
|
|
42
|
-
});
|
|
43
|
-
const outside = outsides[index];
|
|
44
|
-
if (!outside)
|
|
45
|
-
return;
|
|
46
|
-
off(document, outside.type, outside.callback, outside.options);
|
|
47
|
-
outsides.splice(index, 1);
|
|
48
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { host } from './host.js';
|
|
2
|
-
export const getFramework = (target) => {
|
|
3
|
-
const element = host(target);
|
|
4
|
-
if ('_qc_' in element)
|
|
5
|
-
return 'qwik';
|
|
6
|
-
if ('_$owner' in element)
|
|
7
|
-
return 'solid';
|
|
8
|
-
if ('__svelte_meta' in element)
|
|
9
|
-
return 'svelte';
|
|
10
|
-
if ('__vnode' in element)
|
|
11
|
-
return 'vue';
|
|
12
|
-
const keys = Object.keys(element);
|
|
13
|
-
const has = (input) => keys.some((key) => key.startsWith(input));
|
|
14
|
-
if (has('_blazor'))
|
|
15
|
-
return 'blazor';
|
|
16
|
-
if (has('__react'))
|
|
17
|
-
return 'react';
|
|
18
|
-
if (has('__zone_symbol__'))
|
|
19
|
-
return 'angular';
|
|
20
|
-
};
|
package/client/utils/getTag.d.ts
DELETED
package/client/utils/getTag.js
DELETED
package/client/utils/host.d.ts
DELETED
package/client/utils/host.js
DELETED
package/client/utils/index.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export * from './appendToMethod.js';
|
|
2
|
-
export * from './attributes.js';
|
|
3
|
-
export * from './call.js';
|
|
4
|
-
export * from './classes.js';
|
|
5
|
-
export * from './config.js';
|
|
6
|
-
export * from './defineProperty.js';
|
|
7
|
-
export * from './direction.js';
|
|
8
|
-
export * from './event.js';
|
|
9
|
-
export * from './getFramework.js';
|
|
10
|
-
export * from './getStyles.js';
|
|
11
|
-
export * from './getTag.js';
|
|
12
|
-
export * from './host.js';
|
|
13
|
-
export * from './isCSSColor.js';
|
|
14
|
-
export * from './isEvent.js';
|
|
15
|
-
export * from './isRTL.js';
|
|
16
|
-
export * from './isServer.js';
|
|
17
|
-
export * from './merge.js';
|
|
18
|
-
export * from './query.js';
|
|
19
|
-
export * from './queryAll.js';
|
|
20
|
-
export * from './request.js';
|
|
21
|
-
export * from './shadowRoot.js';
|
|
22
|
-
export * from './slots.js';
|
|
23
|
-
export * from './styles.js';
|
|
24
|
-
export * from './task.js';
|
|
25
|
-
export * from './toBoolean.js';
|
|
26
|
-
export * from './toDecorator.js';
|
|
27
|
-
export * from './toEvent.js';
|
|
28
|
-
export * from './toProperty.js';
|
|
29
|
-
export * from './toUnit.js';
|
|
30
|
-
export * from './typeOf.js';
|
|
31
|
-
export * from './uhtml.js';
|
|
32
|
-
export * from './updateAttribute.js';
|