@htmlplus/element 1.0.0 → 1.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 +616 -534
- package/bundlers/rollup.d.ts +2 -2
- package/bundlers/rollup.js +5 -5
- package/bundlers/vite.d.ts +2 -2
- package/bundlers/vite.js +5 -5
- package/client/decorators/bind.d.ts +4 -0
- package/client/decorators/bind.js +4 -0
- package/client/decorators/direction.d.ts +5 -0
- package/client/decorators/direction.js +8 -0
- package/client/decorators/element.d.ts +5 -0
- package/client/decorators/element.js +7 -2
- package/client/decorators/event.d.ts +21 -7
- package/client/decorators/event.js +7 -2
- package/client/decorators/host.d.ts +4 -2
- package/client/decorators/host.js +5 -8
- package/client/decorators/index.d.ts +3 -0
- package/client/decorators/index.js +3 -0
- package/client/decorators/isRTL.d.ts +4 -0
- package/client/decorators/isRTL.js +7 -0
- package/client/decorators/listen.d.ts +38 -8
- package/client/decorators/listen.js +9 -12
- package/client/decorators/method.d.ts +4 -0
- package/client/decorators/method.js +4 -0
- package/client/decorators/property.d.ts +8 -1
- package/client/decorators/property.js +4 -0
- package/client/decorators/query.d.ts +9 -2
- package/client/decorators/query.js +10 -9
- package/client/decorators/queryAll.d.ts +12 -2
- package/client/decorators/queryAll.js +13 -9
- package/client/decorators/slots.d.ts +4 -0
- package/client/decorators/slots.js +7 -0
- package/client/decorators/state.d.ts +4 -0
- package/client/decorators/state.js +4 -0
- package/client/decorators/watch.d.ts +5 -4
- package/client/decorators/watch.js +5 -4
- package/client/index.d.ts +1 -3
- package/client/index.js +1 -3
- package/client/utils/classes.d.ts +3 -0
- package/client/utils/classes.js +11 -28
- package/client/utils/config.d.ts +25 -3
- package/client/utils/config.js +18 -10
- package/client/utils/direction.d.ts +5 -2
- package/client/utils/direction.js +5 -1
- package/client/utils/event.d.ts +6 -0
- package/client/utils/event.js +6 -0
- package/client/utils/host.d.ts +3 -0
- package/client/utils/host.js +3 -0
- package/client/utils/index.d.ts +4 -1
- package/client/utils/index.js +4 -1
- package/client/utils/isCSSColor.d.ts +5 -0
- package/client/utils/isCSSColor.js +9 -0
- package/client/utils/isRTL.d.ts +3 -0
- package/client/utils/isRTL.js +3 -0
- package/client/utils/isServer.d.ts +3 -0
- package/client/utils/isServer.js +3 -0
- package/client/utils/query.d.ts +5 -0
- package/client/utils/query.js +8 -0
- package/client/utils/queryAll.d.ts +5 -0
- package/client/utils/queryAll.js +8 -0
- package/client/utils/request.d.ts +1 -1
- package/client/utils/request.js +1 -1
- package/client/utils/slots.d.ts +3 -0
- package/client/utils/slots.js +6 -1
- package/client/utils/styles.d.ts +3 -0
- package/client/utils/styles.js +3 -0
- package/client/utils/toDecorator.d.ts +2 -0
- package/client/utils/toDecorator.js +10 -0
- package/client/utils/toUnit.d.ts +4 -1
- package/client/utils/toUnit.js +6 -3
- package/constants/index.d.ts +1 -0
- package/constants/index.js +2 -0
- package/package.json +3 -3
- package/transformer/index.d.ts +3 -0
- package/transformer/index.js +3 -0
- package/transformer/plugins/assets.d.ts +8 -0
- package/transformer/plugins/assets.js +29 -0
- package/{compiler → transformer}/plugins/copy.d.ts +2 -2
- package/{compiler → transformer}/plugins/customElement.d.ts +2 -2
- package/{compiler → transformer}/plugins/customElement.js +13 -12
- package/{compiler → transformer}/plugins/customElementReact/customElementReact.d.ts +4 -4
- package/{compiler → transformer}/plugins/customElementReact/customElementReact.js +18 -18
- package/{compiler → transformer}/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +1 -1
- package/{compiler → transformer}/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +3 -3
- package/transformer/plugins/customElementReact/templates/src/index.ts.hbs +1 -0
- package/transformer/plugins/document.d.ts +7 -0
- package/{compiler → transformer}/plugins/document.js +18 -18
- package/transformer/plugins/extract.d.ts +2 -0
- package/{compiler → transformer}/plugins/extract.js +1 -18
- package/transformer/plugins/parse.d.ts +6 -0
- package/{compiler → transformer}/plugins/parse.js +1 -1
- package/transformer/plugins/read.d.ts +8 -0
- package/transformer/plugins/read.js +20 -0
- package/transformer/plugins/readme.d.ts +6 -0
- package/{compiler → transformer}/plugins/readme.js +3 -2
- package/transformer/plugins/style.d.ts +6 -0
- package/{compiler → transformer}/plugins/style.js +4 -2
- package/transformer/plugins/validate.d.ts +2 -0
- package/transformer/plugins/validate.js +41 -0
- package/transformer/plugins/visualStudioCode.d.ts +8 -0
- package/{compiler → transformer}/plugins/visualStudioCode.js +10 -8
- package/transformer/plugins/webTypes.d.ts +10 -0
- package/{compiler → transformer}/plugins/webTypes.js +11 -7
- package/transformer/transformer.d.ts +6 -0
- package/{compiler/compiler.js → transformer/transformer.js} +17 -17
- package/transformer/transformer.types.d.ts +50 -0
- package/{compiler → transformer}/utils/printType.js +2 -2
- package/{compiler → transformer}/utils/renderTemplate.js +2 -0
- package/types/index.d.ts +2 -4
- package/types/index.js +1 -4
- package/CHANGELOG.md +0 -7
- package/bundlers/index.d.ts +0 -2
- package/bundlers/index.js +0 -2
- package/client/helpers/index.d.ts +0 -1
- package/client/helpers/index.js +0 -1
- package/client/services/index.d.ts +0 -1
- package/client/services/index.js +0 -1
- package/client/services/link.d.ts +0 -4
- package/client/services/link.js +0 -196
- package/client/utils/getNamespace.d.ts +0 -2
- package/client/utils/getNamespace.js +0 -4
- package/client/vendors/uhtml.d.ts +0 -29
- package/client/vendors/uhtml.js +0 -700
- package/compiler/compiler.d.ts +0 -6
- package/compiler/index.d.ts +0 -2
- package/compiler/index.js +0 -2
- package/compiler/plugins/assets.d.ts +0 -8
- package/compiler/plugins/assets.js +0 -33
- package/compiler/plugins/customElementReact/templates/src/index.ts.hbs +0 -1
- package/compiler/plugins/document.d.ts +0 -7
- package/compiler/plugins/extract.d.ts +0 -2
- package/compiler/plugins/parse.d.ts +0 -5
- package/compiler/plugins/read.d.ts +0 -8
- package/compiler/plugins/read.js +0 -13
- package/compiler/plugins/readme.d.ts +0 -6
- package/compiler/plugins/style.d.ts +0 -6
- package/compiler/plugins/validate.d.ts +0 -2
- package/compiler/plugins/validate.js +0 -37
- package/compiler/plugins/visualStudioCode.d.ts +0 -8
- package/compiler/plugins/webTypes.d.ts +0 -10
- package/types/context.d.ts +0 -31
- package/types/global.d.ts +0 -4
- package/types/global.js +0 -1
- package/types/plugin.d.ts +0 -10
- package/types/plugin.js +0 -1
- package/types/plusElement.d.ts +0 -2
- package/types/plusElement.js +0 -1
- /package/{compiler → transformer}/plugins/copy.js +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/index.d.ts +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/index.js +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/templates/README.md.hbs +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/templates/_.gitignore.hbs +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/templates/package.json.hbs +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/templates/rollup.config.js.hbs +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/templates/src/components/index.ts.hbs +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/templates/src/proxy.ts.hbs +0 -0
- /package/{compiler → transformer}/plugins/customElementReact/templates/tsconfig.json.hbs +0 -0
- /package/{compiler → transformer}/plugins/index.d.ts +0 -0
- /package/{compiler → transformer}/plugins/index.js +0 -0
- /package/{types/context.js → transformer/transformer.types.js} +0 -0
- /package/{compiler → transformer}/utils/__dirname.d.ts +0 -0
- /package/{compiler → transformer}/utils/__dirname.js +0 -0
- /package/{compiler → transformer}/utils/addDependency.d.ts +0 -0
- /package/{compiler → transformer}/utils/addDependency.js +0 -0
- /package/{compiler → transformer}/utils/getInitializer.d.ts +0 -0
- /package/{compiler → transformer}/utils/getInitializer.js +0 -0
- /package/{compiler → transformer}/utils/getType.d.ts +0 -0
- /package/{compiler → transformer}/utils/getType.js +0 -0
- /package/{compiler → transformer}/utils/getTypeReference.d.ts +0 -0
- /package/{compiler → transformer}/utils/getTypeReference.js +0 -0
- /package/{compiler → transformer}/utils/hasDecorator.d.ts +0 -0
- /package/{compiler → transformer}/utils/hasDecorator.js +0 -0
- /package/{compiler → transformer}/utils/index.d.ts +0 -0
- /package/{compiler → transformer}/utils/index.js +0 -0
- /package/{compiler → transformer}/utils/isDirectoryEmpty.d.ts +0 -0
- /package/{compiler → transformer}/utils/isDirectoryEmpty.js +0 -0
- /package/{compiler → transformer}/utils/print.d.ts +0 -0
- /package/{compiler → transformer}/utils/print.js +0 -0
- /package/{compiler → transformer}/utils/printType.d.ts +0 -0
- /package/{compiler → transformer}/utils/removeUnusedImport.d.ts +0 -0
- /package/{compiler → transformer}/utils/removeUnusedImport.js +0 -0
- /package/{compiler → transformer}/utils/renderTemplate.d.ts +0 -0
- /package/{compiler → transformer}/utils/tags.d.ts +0 -0
- /package/{compiler → transformer}/utils/tags.js +0 -0
- /package/{compiler → transformer}/utils/visitor.d.ts +0 -0
- /package/{compiler → transformer}/utils/visitor.js +0 -0
package/bundlers/rollup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
1
|
+
import { TransformerPlugin } from '../transformer/index.js';
|
|
2
|
+
export declare const htmlplus: (...plugins: Array<TransformerPlugin>) => {
|
|
3
3
|
name: string;
|
|
4
4
|
buildStart(): Promise<void>;
|
|
5
5
|
load(id: any): Promise<string | undefined>;
|
package/bundlers/rollup.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export const
|
|
3
|
-
const { start, run, finish } =
|
|
1
|
+
import { transformer } from '../transformer/index.js';
|
|
2
|
+
export const htmlplus = (...plugins) => {
|
|
3
|
+
const { start, run, finish } = transformer(...plugins);
|
|
4
4
|
return {
|
|
5
5
|
name: 'htmlplus',
|
|
6
6
|
async buildStart() {
|
|
@@ -9,8 +9,8 @@ export const rollup = (...plugins) => {
|
|
|
9
9
|
async load(id) {
|
|
10
10
|
if (!id.endsWith('.tsx'))
|
|
11
11
|
return;
|
|
12
|
-
const {
|
|
13
|
-
if (
|
|
12
|
+
const { script, skipped } = await run(id);
|
|
13
|
+
if (skipped)
|
|
14
14
|
return;
|
|
15
15
|
return script;
|
|
16
16
|
},
|
package/bundlers/vite.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const
|
|
1
|
+
import { TransformerPlugin } from '../transformer/index.js';
|
|
2
|
+
export declare const htmlplus: (...plugins: Array<TransformerPlugin>) => {
|
|
3
3
|
name: string;
|
|
4
4
|
buildStart(): Promise<void>;
|
|
5
5
|
load(id: any): Promise<string | undefined>;
|
package/bundlers/vite.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
|
-
import {
|
|
3
|
-
export const
|
|
4
|
-
const { start, run, finish } =
|
|
2
|
+
import { transformer } from '../transformer/index.js';
|
|
3
|
+
export const htmlplus = (...plugins) => {
|
|
4
|
+
const { start, run, finish } = transformer(...plugins);
|
|
5
5
|
return {
|
|
6
6
|
name: 'htmlplus',
|
|
7
7
|
async buildStart() {
|
|
@@ -10,8 +10,8 @@ export const vite = (...plugins) => {
|
|
|
10
10
|
async load(id) {
|
|
11
11
|
if (!id.endsWith('.tsx'))
|
|
12
12
|
return;
|
|
13
|
-
let {
|
|
14
|
-
if (
|
|
13
|
+
let { script, skipped, stylePath } = await run(id);
|
|
14
|
+
if (skipped)
|
|
15
15
|
return;
|
|
16
16
|
if (script && stylePath) {
|
|
17
17
|
script = script.replace(path.basename(stylePath), `${path.basename(stylePath)}?inline`);
|
|
@@ -1,3 +1,7 @@
|
|
|
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
|
+
*/
|
|
1
5
|
export declare function Bind(): (target: Object, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => {
|
|
2
6
|
configurable: boolean;
|
|
3
7
|
get(): any;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
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
|
+
*/
|
|
2
6
|
export function Bind() {
|
|
3
7
|
return function (target, propertyKey, descriptor) {
|
|
4
8
|
return {
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
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
|
+
*/
|
|
2
7
|
export declare function Element(): (constructor: PlusElement) => void;
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { camelCase, kebabCase } from 'change-case';
|
|
2
2
|
import * as CONSTANTS from '../../constants/index.js';
|
|
3
|
-
import { call, getConfig, getMembers,
|
|
3
|
+
import { call, getConfig, getMembers, getTag, isServer, request, toProperty } 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
|
+
*/
|
|
4
9
|
export function Element() {
|
|
5
10
|
return function (constructor) {
|
|
6
11
|
if (isServer())
|
|
@@ -46,7 +51,7 @@ export function Element() {
|
|
|
46
51
|
connectedCallback() {
|
|
47
52
|
const instance = this[CONSTANTS.API_INSTANCE];
|
|
48
53
|
// TODO: experimental for global config
|
|
49
|
-
Object.assign(instance, getConfig(
|
|
54
|
+
Object.assign(instance, getConfig('element', getTag(instance), 'property'));
|
|
50
55
|
const connect = () => {
|
|
51
56
|
instance[CONSTANTS.API_CONNECTED] = true;
|
|
52
57
|
call(instance, CONSTANTS.LIFECYCLE_CONNECTED);
|
|
@@ -1,21 +1,35 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A function type that generates a `CustomEvent`.
|
|
4
|
+
*/
|
|
2
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
|
+
*/
|
|
3
11
|
export interface EventOptions {
|
|
4
12
|
/**
|
|
5
|
-
* A
|
|
6
|
-
|
|
7
|
-
name?: string;
|
|
8
|
-
/**
|
|
9
|
-
* A Boolean indicating whether the event bubbles up through the DOM or not. default is `false`.
|
|
13
|
+
* A boolean value indicating whether the event bubbles.
|
|
14
|
+
* The default is `false`.
|
|
10
15
|
*/
|
|
11
16
|
bubbles?: boolean;
|
|
12
17
|
/**
|
|
13
|
-
* A
|
|
18
|
+
* A boolean value indicating whether the event can be cancelled.
|
|
19
|
+
* The default is `false`.
|
|
14
20
|
*/
|
|
15
21
|
cancelable?: boolean;
|
|
16
22
|
/**
|
|
17
|
-
* A
|
|
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`.
|
|
18
26
|
*/
|
|
19
27
|
composed?: boolean;
|
|
20
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
|
+
*/
|
|
21
35
|
export declare function Event<T = any>(options?: EventOptions): (target: PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { kebabCase, pascalCase } from 'change-case';
|
|
2
2
|
import { defineProperty, 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
|
+
*/
|
|
3
9
|
export function Event(options = {}) {
|
|
4
10
|
return function (target, propertyKey) {
|
|
5
11
|
defineProperty(target, propertyKey, {
|
|
@@ -9,14 +15,13 @@ export function Event(options = {}) {
|
|
|
9
15
|
const element = host(this);
|
|
10
16
|
const framework = getFramework(element);
|
|
11
17
|
(_a = options.bubbles) !== null && _a !== void 0 ? _a : (options.bubbles = false);
|
|
12
|
-
let name =
|
|
18
|
+
let name = String(propertyKey);
|
|
13
19
|
switch (framework) {
|
|
14
20
|
case 'qwik':
|
|
15
21
|
case 'solid':
|
|
16
22
|
name = pascalCase(name).toLowerCase();
|
|
17
23
|
break;
|
|
18
24
|
case 'preact':
|
|
19
|
-
case 'react':
|
|
20
25
|
name = pascalCase(name);
|
|
21
26
|
break;
|
|
22
27
|
default:
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Indicates the host of the element.
|
|
3
|
+
*/
|
|
4
|
+
export declare function Host(): (target: import("../../types/index.js").PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { host, toDecorator } from '../utils/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Indicates the host of the element.
|
|
4
|
+
*/
|
|
2
5
|
export function Host() {
|
|
3
|
-
return
|
|
4
|
-
defineProperty(target, propertyKey, {
|
|
5
|
-
get() {
|
|
6
|
-
return host(this);
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
};
|
|
6
|
+
return toDecorator(host);
|
|
10
7
|
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export * from './bind.js';
|
|
2
|
+
export * from './direction.js';
|
|
2
3
|
export * from './element.js';
|
|
3
4
|
export * from './event.js';
|
|
4
5
|
export * from './host.js';
|
|
6
|
+
export * from './isRTL.js';
|
|
5
7
|
export * from './listen.js';
|
|
6
8
|
export * from './method.js';
|
|
7
9
|
export * from './property.js';
|
|
8
10
|
export * from './query.js';
|
|
9
11
|
export * from './queryAll.js';
|
|
12
|
+
export * from './slots.js';
|
|
10
13
|
export * from './state.js';
|
|
11
14
|
export * from './watch.js';
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export * from './bind.js';
|
|
2
|
+
export * from './direction.js';
|
|
2
3
|
export * from './element.js';
|
|
3
4
|
export * from './event.js';
|
|
4
5
|
export * from './host.js';
|
|
6
|
+
export * from './isRTL.js';
|
|
5
7
|
export * from './listen.js';
|
|
6
8
|
export * from './method.js';
|
|
7
9
|
export * from './property.js';
|
|
8
10
|
export * from './query.js';
|
|
9
11
|
export * from './queryAll.js';
|
|
12
|
+
export * from './slots.js';
|
|
10
13
|
export * from './state.js';
|
|
11
14
|
export * from './watch.js';
|
|
@@ -1,20 +1,50 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* An object that configures
|
|
4
|
+
* [options](https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener#options)
|
|
5
|
+
* for the event listener.
|
|
6
|
+
*/
|
|
2
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
|
+
*/
|
|
3
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
|
+
*/
|
|
4
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
|
+
*/
|
|
5
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
|
+
*/
|
|
6
34
|
signal?: AbortSignal;
|
|
35
|
+
/**
|
|
36
|
+
* The target element, defaults to `host`.
|
|
37
|
+
*/
|
|
7
38
|
target?: 'host' | 'body' | 'document' | 'window';
|
|
8
39
|
}
|
|
9
40
|
/**
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*
|
|
15
|
-
* [
|
|
16
|
-
*
|
|
17
|
-
* @param options An object that specifies characteristics about the event listener.
|
|
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.
|
|
18
48
|
*/
|
|
19
49
|
export declare function Listen(type: string, options?: ListenOptions): (target: PlusElement, propertyKey: PropertyKey, descriptor: PropertyDescriptor) => {
|
|
20
50
|
configurable: boolean;
|
|
@@ -2,22 +2,19 @@ import * as CONSTANTS from '../../constants/index.js';
|
|
|
2
2
|
import { appendToMethod, host, on, off } from '../utils/index.js';
|
|
3
3
|
import { Bind } from './bind.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*
|
|
12
|
-
* [More](https://mdn.io/addEventListener).
|
|
13
|
-
* @param type A case-sensitive string representing the [event type](https://mdn.io/events) to listen for.
|
|
14
|
-
* @param options An object that specifies characteristics about the event listener.
|
|
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.
|
|
15
12
|
*/
|
|
16
13
|
export function Listen(type, options) {
|
|
17
14
|
return function (target, propertyKey, descriptor) {
|
|
18
|
-
options = Object.assign({},
|
|
15
|
+
options = Object.assign({ target: 'host' }, options);
|
|
19
16
|
const element = (instance) => {
|
|
20
|
-
switch (options
|
|
17
|
+
switch (options.target) {
|
|
21
18
|
case 'body':
|
|
22
19
|
return window.document.body;
|
|
23
20
|
case 'document':
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Provides a way to encapsulate functionality within an element
|
|
4
|
+
* and invoke it as needed, both internally and externally.
|
|
5
|
+
*/
|
|
2
6
|
export declare function Method(): (target: PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as CONSTANTS from '../../constants/index.js';
|
|
2
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
|
+
*/
|
|
3
7
|
export function Method() {
|
|
4
8
|
return function (target, propertyKey) {
|
|
5
9
|
appendToMethod(target, CONSTANTS.LIFECYCLE_CONNECTED, function () {
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* The configuration for property decorator.
|
|
4
|
+
*/
|
|
2
5
|
export interface PropertyOptions {
|
|
3
6
|
/**
|
|
4
7
|
* Whether property value is reflected back to the associated attribute. default is `false`.
|
|
5
8
|
*/
|
|
6
9
|
reflect?: boolean;
|
|
7
10
|
/**
|
|
8
|
-
*
|
|
11
|
+
* Do not set the value to this property. This value is automatically set during transpiling.
|
|
9
12
|
*/
|
|
10
13
|
type?: number;
|
|
11
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a reactive property, reflecting a corresponding attribute value,
|
|
17
|
+
* and updates the element when the property is set.
|
|
18
|
+
*/
|
|
12
19
|
export declare function Property(options?: PropertyOptions): (target: PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import * as CONSTANTS from '../../constants/index.js';
|
|
2
2
|
import { addMember, appendToMethod, defineProperty, host, request, toProperty, updateAttribute } from '../utils/index.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a reactive property, reflecting a corresponding attribute value,
|
|
5
|
+
* and updates the element when the property is set.
|
|
6
|
+
*/
|
|
3
7
|
export function Property(options) {
|
|
4
8
|
return function (target, propertyKey) {
|
|
5
9
|
const name = String(propertyKey);
|
|
@@ -1,2 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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").PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
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
|
+
*/
|
|
2
10
|
export function Query(selectors) {
|
|
3
|
-
return
|
|
4
|
-
defineProperty(target, propertyKey, {
|
|
5
|
-
get() {
|
|
6
|
-
var _a;
|
|
7
|
-
return (_a = shadowRoot(this)) === null || _a === void 0 ? void 0 : _a.querySelector(selectors);
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
+
return toDecorator(query, selectors);
|
|
11
12
|
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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").PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
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
|
+
*/
|
|
2
13
|
export function QueryAll(selectors) {
|
|
3
|
-
return
|
|
4
|
-
defineProperty(target, propertyKey, {
|
|
5
|
-
get() {
|
|
6
|
-
var _a;
|
|
7
|
-
return (_a = shadowRoot(this)) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selectors);
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
};
|
|
14
|
+
return toDecorator(queryAll, selectors);
|
|
11
15
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* Applying this decorator to any `class property` will trigger the
|
|
4
|
+
* element to re-render upon the desired property changes.
|
|
5
|
+
*/
|
|
2
6
|
export declare function State(): (target: PlusElement, propertyKey: PropertyKey) => void;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
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
|
+
*/
|
|
2
6
|
export function State() {
|
|
3
7
|
return function (target, propertyKey) {
|
|
4
8
|
const name = String(propertyKey);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
2
2
|
/**
|
|
3
|
-
* Monitors `@Property` and `@State` to
|
|
4
|
-
* The decorated method will be
|
|
5
|
-
*
|
|
6
|
-
* If the
|
|
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
|
+
*
|
|
7
8
|
* @param keys Collection of `@Property` and `@State` names.
|
|
8
9
|
* @param immediate Triggers the callback immediately after initialization.
|
|
9
10
|
*/
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as CONSTANTS from '../../constants/index.js';
|
|
2
2
|
import { appendToMethod } from '../utils/index.js';
|
|
3
3
|
/**
|
|
4
|
-
* Monitors `@Property` and `@State` to
|
|
5
|
-
* The decorated method will be
|
|
6
|
-
*
|
|
7
|
-
* If the
|
|
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
|
+
*
|
|
8
9
|
* @param keys Collection of `@Property` and `@State` names.
|
|
9
10
|
* @param immediate Triggers the callback immediately after initialization.
|
|
10
11
|
*/
|
package/client/index.d.ts
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export * from './decorators/index.js';
|
|
2
|
-
export
|
|
3
|
-
export * from './services/index.js';
|
|
4
|
-
export { getConfig, setConfig } from './utils/config.js';
|
|
2
|
+
export { classes, direction, getConfig, host, isCSSColor, isRTL, query, queryAll, on, off, slots, styles, toUnit, setConfig, type Config, type ConfigOptions } from './utils/index.js';
|
package/client/index.js
CHANGED
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
export * from './decorators/index.js';
|
|
2
|
-
export
|
|
3
|
-
export * from './services/index.js';
|
|
4
|
-
export { getConfig, setConfig } from './utils/config.js';
|
|
2
|
+
export { classes, direction, getConfig, host, isCSSColor, isRTL, query, queryAll, on, off, slots, styles, toUnit, setConfig } from './utils/index.js';
|