@htmlplus/element 0.7.2 → 0.7.3
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/client/decorators/index.d.ts +0 -1
- package/client/decorators/index.js +0 -1
- package/client/helpers/index.d.ts +1 -9
- package/client/helpers/index.js +1 -9
- package/client/utils/attributes.d.ts +1 -0
- package/client/utils/attributes.js +31 -0
- package/client/{helpers → utils}/classes.js +1 -1
- package/client/utils/config.d.ts +5 -3
- package/client/{helpers → utils}/direction.js +1 -1
- package/client/utils/index.d.ts +10 -1
- package/client/utils/index.js +10 -1
- package/client/{helpers → utils}/query.js +1 -1
- package/client/{helpers → utils}/queryAll.js +1 -1
- package/client/utils/request.js +3 -3
- package/client/{helpers → utils}/slots.js +1 -1
- package/client/{helpers → utils}/styles.js +1 -1
- package/client/utils/uhtml.d.ts +22 -0
- package/client/utils/uhtml.js +699 -0
- package/compiler/plugins/customElement.js +109 -45
- package/compiler/plugins/style.js +1 -2
- package/compiler/utils/addDependency.js +3 -0
- package/constants/index.d.ts +9 -3
- package/constants/index.js +9 -4
- package/package.json +1 -1
- package/client/decorators/attributes.d.ts +0 -2
- package/client/decorators/attributes.js +0 -12
- package/client/utils/syncAttributes.d.ts +0 -1
- package/client/utils/syncAttributes.js +0 -31
- /package/client/{helpers → utils}/classes.d.ts +0 -0
- /package/client/{helpers → utils}/direction.d.ts +0 -0
- /package/client/{helpers → utils}/isRTL.d.ts +0 -0
- /package/client/{helpers → utils}/isRTL.js +0 -0
- /package/client/{helpers → utils}/query.d.ts +0 -0
- /package/client/{helpers → utils}/queryAll.d.ts +0 -0
- /package/client/{helpers → utils}/slots.d.ts +0 -0
- /package/client/{helpers → utils}/styles.d.ts +0 -0
- /package/client/{helpers → utils}/toUnit.d.ts +0 -0
- /package/client/{helpers → utils}/toUnit.js +0 -0
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './direction.js';
|
|
3
|
-
export * from './isRTL.js';
|
|
4
|
-
export * from './query.js';
|
|
5
|
-
export * from './queryAll.js';
|
|
6
|
-
export * from './slots.js';
|
|
7
|
-
export * from './styles.js';
|
|
8
|
-
export * from './toUnit.js';
|
|
9
|
-
export { getConfig, host, isServer, on, off, setConfig } from '../utils/index.js';
|
|
1
|
+
export { classes, direction, getConfig, host, isRTL, isServer, on, off, query, queryAll, slots, styles, toUnit, setConfig } from '../utils/index.js';
|
package/client/helpers/index.js
CHANGED
|
@@ -1,9 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
export * from './direction.js';
|
|
3
|
-
export * from './isRTL.js';
|
|
4
|
-
export * from './query.js';
|
|
5
|
-
export * from './queryAll.js';
|
|
6
|
-
export * from './slots.js';
|
|
7
|
-
export * from './styles.js';
|
|
8
|
-
export * from './toUnit.js';
|
|
9
|
-
export { getConfig, host, isServer, on, off, setConfig } from '../utils/index.js';
|
|
1
|
+
export { classes, direction, getConfig, host, isRTL, isServer, on, off, query, queryAll, slots, styles, toUnit, setConfig } from '../utils/index.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const attributes: (element: HTMLElement, attributes: any[]) => void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { off, on } from './event.js';
|
|
2
|
+
import { isEvent } from './isEvent.js';
|
|
3
|
+
import { toEvent } from './toEvent.js';
|
|
4
|
+
import { updateAttribute } from './updateAttribute.js';
|
|
5
|
+
const symbol = Symbol();
|
|
6
|
+
export const attributes = (element, attributes) => {
|
|
7
|
+
const prev = element[symbol] || {};
|
|
8
|
+
const next = Object.assign({}, ...attributes);
|
|
9
|
+
const prevClass = (prev.class || '').split(' ');
|
|
10
|
+
const nextClass = (next.class || '').split(' ');
|
|
11
|
+
const newClass = element.className
|
|
12
|
+
.split(' ')
|
|
13
|
+
.filter((key) => !prevClass.includes(key) && !nextClass.includes(key))
|
|
14
|
+
.concat(nextClass)
|
|
15
|
+
.filter((key) => key)
|
|
16
|
+
.join(' ');
|
|
17
|
+
updateAttribute(element, 'class', newClass || undefined);
|
|
18
|
+
if (prev.style || next.style)
|
|
19
|
+
element.setAttribute('style', next.style || '');
|
|
20
|
+
for (const key in prev)
|
|
21
|
+
isEvent(key) && off(element, toEvent(key), prev[key]);
|
|
22
|
+
for (const key in next) {
|
|
23
|
+
if (['class', 'style'].includes(key))
|
|
24
|
+
continue;
|
|
25
|
+
if (isEvent(key))
|
|
26
|
+
on(element, toEvent(key), next[key]);
|
|
27
|
+
else
|
|
28
|
+
updateAttribute(element, key, next[key]);
|
|
29
|
+
}
|
|
30
|
+
element[symbol] = Object.assign({}, next);
|
|
31
|
+
};
|
package/client/utils/config.d.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
interface
|
|
1
|
+
export interface Config {
|
|
2
|
+
asset?: {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
};
|
|
2
5
|
component?: {
|
|
3
6
|
[key: string]: {
|
|
4
7
|
property?: {
|
|
@@ -8,5 +11,4 @@ interface Options {
|
|
|
8
11
|
};
|
|
9
12
|
}
|
|
10
13
|
export declare const getConfig: (namespace: string, ...parameters: string[]) => any;
|
|
11
|
-
export declare const setConfig: (namespace: string, config:
|
|
12
|
-
export {};
|
|
14
|
+
export declare const setConfig: (namespace: string, config: Config, override?: boolean) => void;
|
package/client/utils/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './addMember.js';
|
|
2
2
|
export * from './appendToMethod.js';
|
|
3
|
+
export * from './attributes.js';
|
|
3
4
|
export * from './call.js';
|
|
5
|
+
export * from './classes.js';
|
|
4
6
|
export * from './config.js';
|
|
5
7
|
export * from './defineProperty.js';
|
|
8
|
+
export * from './direction.js';
|
|
6
9
|
export * from './event.js';
|
|
7
10
|
export * from './fromAttribute.js';
|
|
8
11
|
export * from './getFramework.js';
|
|
@@ -12,13 +15,19 @@ export * from './getStyles.js';
|
|
|
12
15
|
export * from './getTag.js';
|
|
13
16
|
export * from './host.js';
|
|
14
17
|
export * from './isEvent.js';
|
|
18
|
+
export * from './isRTL.js';
|
|
15
19
|
export * from './isServer.js';
|
|
16
20
|
export * from './merge.js';
|
|
21
|
+
export * from './query.js';
|
|
22
|
+
export * from './queryAll.js';
|
|
17
23
|
export * from './request.js';
|
|
18
24
|
export * from './shadowRoot.js';
|
|
19
|
-
export * from './
|
|
25
|
+
export * from './slots.js';
|
|
26
|
+
export * from './styles.js';
|
|
20
27
|
export * from './task.js';
|
|
21
28
|
export * from './toBoolean.js';
|
|
22
29
|
export * from './toEvent.js';
|
|
30
|
+
export * from './toUnit.js';
|
|
23
31
|
export * from './typeOf.js';
|
|
32
|
+
export * from './uhtml.js';
|
|
24
33
|
export * from './updateAttribute.js';
|
package/client/utils/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './addMember.js';
|
|
2
2
|
export * from './appendToMethod.js';
|
|
3
|
+
export * from './attributes.js';
|
|
3
4
|
export * from './call.js';
|
|
5
|
+
export * from './classes.js';
|
|
4
6
|
export * from './config.js';
|
|
5
7
|
export * from './defineProperty.js';
|
|
8
|
+
export * from './direction.js';
|
|
6
9
|
export * from './event.js';
|
|
7
10
|
export * from './fromAttribute.js';
|
|
8
11
|
export * from './getFramework.js';
|
|
@@ -12,13 +15,19 @@ export * from './getStyles.js';
|
|
|
12
15
|
export * from './getTag.js';
|
|
13
16
|
export * from './host.js';
|
|
14
17
|
export * from './isEvent.js';
|
|
18
|
+
export * from './isRTL.js';
|
|
15
19
|
export * from './isServer.js';
|
|
16
20
|
export * from './merge.js';
|
|
21
|
+
export * from './query.js';
|
|
22
|
+
export * from './queryAll.js';
|
|
17
23
|
export * from './request.js';
|
|
18
24
|
export * from './shadowRoot.js';
|
|
19
|
-
export * from './
|
|
25
|
+
export * from './slots.js';
|
|
26
|
+
export * from './styles.js';
|
|
20
27
|
export * from './task.js';
|
|
21
28
|
export * from './toBoolean.js';
|
|
22
29
|
export * from './toEvent.js';
|
|
30
|
+
export * from './toUnit.js';
|
|
23
31
|
export * from './typeOf.js';
|
|
32
|
+
export * from './uhtml.js';
|
|
24
33
|
export * from './updateAttribute.js';
|
package/client/utils/request.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as CONSTANTS from '../../constants/index.js';
|
|
2
|
-
import { call } from '
|
|
3
|
-
import { task } from '../utils/task.js';
|
|
4
|
-
import { html, render } from '../vendors/uhtml.js';
|
|
2
|
+
import { call } from './call.js';
|
|
5
3
|
import { getStyles } from './getStyles.js';
|
|
6
4
|
import { shadowRoot } from './shadowRoot.js';
|
|
5
|
+
import { task } from './task.js';
|
|
6
|
+
import { html, render } from './uhtml.js';
|
|
7
7
|
/**
|
|
8
8
|
* Updates the DOM with a scheduled task.
|
|
9
9
|
* @param target The component instance.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Holds all details wrappers needed to render the content further on.
|
|
3
|
+
* @constructor
|
|
4
|
+
* @param {string} type The hole type, either `html` or `svg`.
|
|
5
|
+
* @param {string[]} template The template literals used to the define the content.
|
|
6
|
+
* @param {Array} values Zero, one, or more interpolated values to render.
|
|
7
|
+
*/
|
|
8
|
+
export class Hole {
|
|
9
|
+
constructor(type: any, template: any, values: any);
|
|
10
|
+
type: any;
|
|
11
|
+
template: any;
|
|
12
|
+
values: any;
|
|
13
|
+
}
|
|
14
|
+
export const html: ((template: any, ...values: any[]) => Hole) & {
|
|
15
|
+
for(ref: any, id: any): any;
|
|
16
|
+
node: (template: any, ...values: any[]) => any;
|
|
17
|
+
};
|
|
18
|
+
export function render(where: any, what: any): any;
|
|
19
|
+
export const svg: ((template: any, ...values: any[]) => Hole) & {
|
|
20
|
+
for(ref: any, id: any): any;
|
|
21
|
+
node: (template: any, ...values: any[]) => any;
|
|
22
|
+
};
|