@htmlplus/element 1.0.0 → 2.0.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/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/{compiler → transformer}/plugins/index.d.ts +0 -1
- package/{compiler → transformer}/plugins/index.js +0 -1
- 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/customElementReact.d.ts +0 -16
- package/compiler/plugins/customElementReact/customElementReact.js +0 -97
- package/compiler/plugins/customElementReact/index.d.ts +0 -1
- package/compiler/plugins/customElementReact/index.js +0 -1
- package/compiler/plugins/customElementReact/templates/README.md.hbs +0 -1
- package/compiler/plugins/customElementReact/templates/_.gitignore.hbs +0 -2
- package/compiler/plugins/customElementReact/templates/package.json.hbs +0 -37
- package/compiler/plugins/customElementReact/templates/rollup.config.js.hbs +0 -21
- package/compiler/plugins/customElementReact/templates/src/components/index.ts.hbs +0 -17
- package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +0 -18
- package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +0 -23
- package/compiler/plugins/customElementReact/templates/src/index.ts.hbs +0 -1
- package/compiler/plugins/customElementReact/templates/src/proxy.ts.hbs +0 -269
- package/compiler/plugins/customElementReact/templates/tsconfig.json.hbs +0 -17
- 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/{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/client/utils/classes.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { kebabCase } from 'change-case';
|
|
2
2
|
import { typeOf } from './typeOf.js';
|
|
3
|
+
/**
|
|
4
|
+
* TODO
|
|
5
|
+
*/
|
|
3
6
|
export const classes = (input, smart) => {
|
|
4
7
|
const result = [];
|
|
5
8
|
switch (typeOf(input)) {
|
|
6
9
|
case 'array': {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return;
|
|
11
|
-
result.push(value);
|
|
12
|
-
});
|
|
10
|
+
for (const item of input) {
|
|
11
|
+
result.push(classes(item, smart));
|
|
12
|
+
}
|
|
13
13
|
break;
|
|
14
14
|
}
|
|
15
15
|
case 'object': {
|
|
@@ -19,34 +19,17 @@ export const classes = (input, smart) => {
|
|
|
19
19
|
const name = kebabCase(key);
|
|
20
20
|
const type = typeOf(value);
|
|
21
21
|
if (!smart) {
|
|
22
|
-
|
|
23
|
-
continue;
|
|
24
|
-
result.push(name);
|
|
22
|
+
value && result.push(name);
|
|
25
23
|
continue;
|
|
26
24
|
}
|
|
27
25
|
switch (type) {
|
|
28
26
|
case 'boolean': {
|
|
29
|
-
|
|
30
|
-
continue;
|
|
31
|
-
result.push(`${name}`);
|
|
32
|
-
break;
|
|
33
|
-
}
|
|
34
|
-
case 'number': {
|
|
35
|
-
result.push(`${name}-${value}`);
|
|
27
|
+
value && result.push(`${name}`);
|
|
36
28
|
break;
|
|
37
29
|
}
|
|
30
|
+
case 'number':
|
|
38
31
|
case 'string': {
|
|
39
|
-
|
|
40
|
-
case '':
|
|
41
|
-
case 'true':
|
|
42
|
-
result.push(`${name}`);
|
|
43
|
-
break;
|
|
44
|
-
case 'false':
|
|
45
|
-
break;
|
|
46
|
-
default:
|
|
47
|
-
result.push(`${name}-${value}`);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
32
|
+
result.push(`${name}-${value}`);
|
|
50
33
|
break;
|
|
51
34
|
}
|
|
52
35
|
}
|
|
@@ -58,5 +41,5 @@ export const classes = (input, smart) => {
|
|
|
58
41
|
break;
|
|
59
42
|
}
|
|
60
43
|
}
|
|
61
|
-
return result.join(' ');
|
|
44
|
+
return result.filter((item) => item).join(' ');
|
|
62
45
|
};
|
package/client/utils/config.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TODO
|
|
3
|
+
*/
|
|
1
4
|
export interface Config {
|
|
2
5
|
asset?: {
|
|
3
6
|
[key: string]: any;
|
|
4
7
|
};
|
|
5
|
-
|
|
8
|
+
element?: {
|
|
6
9
|
[key: string]: {
|
|
7
10
|
property?: {
|
|
8
11
|
[key: string]: any;
|
|
@@ -10,5 +13,24 @@ export interface Config {
|
|
|
10
13
|
};
|
|
11
14
|
};
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* TODO
|
|
18
|
+
*/
|
|
19
|
+
export interface ConfigOptions {
|
|
20
|
+
/**
|
|
21
|
+
* TODO
|
|
22
|
+
*/
|
|
23
|
+
force?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* TODO
|
|
26
|
+
*/
|
|
27
|
+
override?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* TODO
|
|
31
|
+
*/
|
|
32
|
+
export declare const getConfig: (...keys: string[]) => any;
|
|
33
|
+
/**
|
|
34
|
+
* TODO
|
|
35
|
+
*/
|
|
36
|
+
export declare const setConfig: (config: Config, options?: ConfigOptions) => void;
|
package/client/utils/config.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
+
import { isServer } from './isServer.js';
|
|
1
2
|
import { merge } from './merge.js';
|
|
2
|
-
|
|
3
|
-
|
|
3
|
+
const DEFAULTS = {
|
|
4
|
+
element: {}
|
|
4
5
|
};
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* TODO
|
|
8
|
+
*/
|
|
9
|
+
export const getConfig = (...keys) => {
|
|
10
|
+
if (isServer())
|
|
7
11
|
return;
|
|
8
|
-
let config = window[
|
|
9
|
-
for (const
|
|
12
|
+
let config = window[`$htmlplus$`];
|
|
13
|
+
for (const key of keys) {
|
|
10
14
|
if (!config)
|
|
11
15
|
break;
|
|
12
|
-
config = config[
|
|
16
|
+
config = config[key];
|
|
13
17
|
}
|
|
14
18
|
return config;
|
|
15
19
|
};
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
/**
|
|
21
|
+
* TODO
|
|
22
|
+
*/
|
|
23
|
+
export const setConfig = (config, options) => {
|
|
24
|
+
if (isServer())
|
|
18
25
|
return;
|
|
19
|
-
|
|
26
|
+
const previous = (options === null || options === void 0 ? void 0 : options.override) ? {} : window[`$htmlplus$`];
|
|
27
|
+
window[`$htmlplus$`] = merge({}, DEFAULTS, previous, config);
|
|
20
28
|
};
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
2
|
-
|
|
3
|
-
|
|
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: PlusElement) => 'ltr' | 'rtl';
|
|
@@ -1,4 +1,8 @@
|
|
|
1
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
|
+
*/
|
|
2
6
|
export const direction = (target) => {
|
|
3
|
-
return getComputedStyle(host(target)).getPropertyValue('direction')
|
|
7
|
+
return getComputedStyle(host(target)).getPropertyValue('direction');
|
|
4
8
|
};
|
package/client/utils/event.d.ts
CHANGED
|
@@ -3,6 +3,12 @@ type EventType = 'outside' | (string & {});
|
|
|
3
3
|
type EventHandler = EventListenerOrEventListenerObject;
|
|
4
4
|
type EventOptions = boolean | AddEventListenerOptions;
|
|
5
5
|
type EventListener = (target: EventTarget, type: EventType, handler: EventHandler, options?: EventOptions) => void;
|
|
6
|
+
/**
|
|
7
|
+
* TODO
|
|
8
|
+
*/
|
|
6
9
|
export declare const off: EventListener;
|
|
10
|
+
/**
|
|
11
|
+
* TODO
|
|
12
|
+
*/
|
|
7
13
|
export declare const on: EventListener;
|
|
8
14
|
export {};
|
package/client/utils/event.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
const outsides = [];
|
|
2
|
+
/**
|
|
3
|
+
* TODO
|
|
4
|
+
*/
|
|
2
5
|
export const off = (target, type, handler, options) => {
|
|
3
6
|
if (type != 'outside')
|
|
4
7
|
return target.removeEventListener(type, handler, options);
|
|
@@ -9,6 +12,9 @@ export const off = (target, type, handler, options) => {
|
|
|
9
12
|
off(document, outside.type, outside.callback, outside.options);
|
|
10
13
|
outsides.splice(index, 1);
|
|
11
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* TODO
|
|
17
|
+
*/
|
|
12
18
|
export const on = (target, type, handler, options) => {
|
|
13
19
|
if (type != 'outside')
|
|
14
20
|
return target.addEventListener(type, handler, options);
|
package/client/utils/host.d.ts
CHANGED
package/client/utils/host.js
CHANGED
package/client/utils/index.d.ts
CHANGED
|
@@ -9,20 +9,23 @@ export * from './direction.js';
|
|
|
9
9
|
export * from './event.js';
|
|
10
10
|
export * from './getFramework.js';
|
|
11
11
|
export * from './getMembers.js';
|
|
12
|
-
export * from './getNamespace.js';
|
|
13
12
|
export * from './getStyles.js';
|
|
14
13
|
export * from './getTag.js';
|
|
15
14
|
export * from './host.js';
|
|
15
|
+
export * from './isCSSColor.js';
|
|
16
16
|
export * from './isEvent.js';
|
|
17
17
|
export * from './isRTL.js';
|
|
18
18
|
export * from './isServer.js';
|
|
19
19
|
export * from './merge.js';
|
|
20
|
+
export * from './query.js';
|
|
21
|
+
export * from './queryAll.js';
|
|
20
22
|
export * from './request.js';
|
|
21
23
|
export * from './shadowRoot.js';
|
|
22
24
|
export * from './slots.js';
|
|
23
25
|
export * from './styles.js';
|
|
24
26
|
export * from './task.js';
|
|
25
27
|
export * from './toBoolean.js';
|
|
28
|
+
export * from './toDecorator.js';
|
|
26
29
|
export * from './toEvent.js';
|
|
27
30
|
export * from './toProperty.js';
|
|
28
31
|
export * from './toUnit.js';
|
package/client/utils/index.js
CHANGED
|
@@ -9,20 +9,23 @@ export * from './direction.js';
|
|
|
9
9
|
export * from './event.js';
|
|
10
10
|
export * from './getFramework.js';
|
|
11
11
|
export * from './getMembers.js';
|
|
12
|
-
export * from './getNamespace.js';
|
|
13
12
|
export * from './getStyles.js';
|
|
14
13
|
export * from './getTag.js';
|
|
15
14
|
export * from './host.js';
|
|
15
|
+
export * from './isCSSColor.js';
|
|
16
16
|
export * from './isEvent.js';
|
|
17
17
|
export * from './isRTL.js';
|
|
18
18
|
export * from './isServer.js';
|
|
19
19
|
export * from './merge.js';
|
|
20
|
+
export * from './query.js';
|
|
21
|
+
export * from './queryAll.js';
|
|
20
22
|
export * from './request.js';
|
|
21
23
|
export * from './shadowRoot.js';
|
|
22
24
|
export * from './slots.js';
|
|
23
25
|
export * from './styles.js';
|
|
24
26
|
export * from './task.js';
|
|
25
27
|
export * from './toBoolean.js';
|
|
28
|
+
export * from './toDecorator.js';
|
|
26
29
|
export * from './toEvent.js';
|
|
27
30
|
export * from './toProperty.js';
|
|
28
31
|
export * from './toUnit.js';
|
package/client/utils/isRTL.d.ts
CHANGED
package/client/utils/isRTL.js
CHANGED
package/client/utils/isServer.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { shadowRoot } from './shadowRoot.js';
|
|
2
|
+
/**
|
|
3
|
+
* Selects the first element in the shadow dom that matches a specified CSS selector.
|
|
4
|
+
*/
|
|
5
|
+
export function query(target, selectors) {
|
|
6
|
+
var _a;
|
|
7
|
+
return (_a = shadowRoot(target)) === null || _a === void 0 ? void 0 : _a.querySelector(selectors);
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { shadowRoot } from './shadowRoot.js';
|
|
2
|
+
/**
|
|
3
|
+
* Selects all elements in the shadow dom that match a specified CSS selector.
|
|
4
|
+
*/
|
|
5
|
+
export function queryAll(target, selectors) {
|
|
6
|
+
var _a;
|
|
7
|
+
return (_a = shadowRoot(target)) === null || _a === void 0 ? void 0 : _a.querySelectorAll(selectors);
|
|
8
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { PlusElement } from '../../types';
|
|
2
2
|
/**
|
|
3
3
|
* Updates the DOM with a scheduled task.
|
|
4
|
-
* @param target The
|
|
4
|
+
* @param target The element instance.
|
|
5
5
|
* @param name Property/State name.
|
|
6
6
|
* @param previous The previous value of Property/State.
|
|
7
7
|
* @param callback Invoked when the rendering phase is completed.
|
package/client/utils/request.js
CHANGED
|
@@ -6,7 +6,7 @@ import { task } from './task.js';
|
|
|
6
6
|
import { html, render } from './uhtml.js';
|
|
7
7
|
/**
|
|
8
8
|
* Updates the DOM with a scheduled task.
|
|
9
|
-
* @param target The
|
|
9
|
+
* @param target The element instance.
|
|
10
10
|
* @param name Property/State name.
|
|
11
11
|
* @param previous The previous value of Property/State.
|
|
12
12
|
* @param callback Invoked when the rendering phase is completed.
|
package/client/utils/slots.d.ts
CHANGED
package/client/utils/slots.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { host } from './host.js';
|
|
2
|
+
/**
|
|
3
|
+
* Returns the slots name.
|
|
4
|
+
*/
|
|
2
5
|
export const slots = (target) => {
|
|
3
6
|
var _a;
|
|
4
7
|
const slots = {};
|
|
5
8
|
const children = Array.from(host(target).childNodes);
|
|
6
9
|
for (const child of children) {
|
|
7
|
-
|
|
10
|
+
if (child.nodeName == '#comment')
|
|
11
|
+
continue;
|
|
12
|
+
const name = child['slot'] || (((_a = child.nodeValue) === null || _a === void 0 ? void 0 : _a.trim()) && 'default') || ('slot' in child && 'default');
|
|
8
13
|
if (!name)
|
|
9
14
|
continue;
|
|
10
15
|
slots[name] = true;
|
package/client/utils/styles.d.ts
CHANGED
package/client/utils/styles.js
CHANGED
package/client/utils/toUnit.d.ts
CHANGED
package/client/utils/toUnit.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a value to a unit.
|
|
3
|
+
*/
|
|
1
4
|
export const toUnit = (input, unit = 'px') => {
|
|
2
|
-
if (input
|
|
3
|
-
return
|
|
5
|
+
if (input === null || input === undefined || input === '')
|
|
6
|
+
return input;
|
|
4
7
|
if (isNaN(+input))
|
|
5
8
|
return String(input);
|
|
6
|
-
return
|
|
9
|
+
return Number(input) + unit;
|
|
7
10
|
};
|
package/constants/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const API_RENDER_COMPLETED: unique symbol;
|
|
|
8
8
|
export declare const API_STACKS: unique symbol;
|
|
9
9
|
export declare const COMMENT_AUTO_ADDED_DEPENDENCY = " THIS DEPENDENCY IS AUTO-ADDED, DO NOT EDIT MANUALY";
|
|
10
10
|
export declare const COMMENT_AUTO_ADDED_PROPERTY = " THIS PROPERTY IS AUTO-ADDED, DO NOT EDIT MANUALY";
|
|
11
|
+
export declare const CSS_DECORATOR_PROPERTY = "@Property()";
|
|
11
12
|
export declare const DECORATOR_ELEMENT = "Element";
|
|
12
13
|
export declare const DECORATOR_EVENT = "Event";
|
|
13
14
|
export declare const DECORATOR_PROPERTY = "Property";
|
package/constants/index.js
CHANGED
|
@@ -10,6 +10,8 @@ export const API_STACKS = Symbol();
|
|
|
10
10
|
// comments
|
|
11
11
|
export const COMMENT_AUTO_ADDED_DEPENDENCY = ' THIS DEPENDENCY IS AUTO-ADDED, DO NOT EDIT MANUALY';
|
|
12
12
|
export const COMMENT_AUTO_ADDED_PROPERTY = ' THIS PROPERTY IS AUTO-ADDED, DO NOT EDIT MANUALY';
|
|
13
|
+
// CSS decorators
|
|
14
|
+
export const CSS_DECORATOR_PROPERTY = '@Property()';
|
|
13
15
|
// decorators
|
|
14
16
|
export const DECORATOR_ELEMENT = 'Element';
|
|
15
17
|
export const DECORATOR_EVENT = 'Event';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@htmlplus/element",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"author": "Masood Abdolian <m.abdolian@gmail.com>",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"directory": "dist"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
|
-
"node": ">=
|
|
18
|
+
"node": ">= 20.10.0"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"components",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"prettier": "^2.8.0",
|
|
58
58
|
"rimraf": "^3.0.2",
|
|
59
59
|
"semantic-release": "^22.0.8",
|
|
60
|
-
"
|
|
60
|
+
"tsx": "^4.6.2",
|
|
61
61
|
"vite": "^3.2.4"
|
|
62
62
|
}
|
|
63
63
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TransformerPlugin, TransformerPluginContext } from '../transformer.types';
|
|
2
|
+
export declare const ASSETS_OPTIONS: Partial<AssetsOptions>;
|
|
3
|
+
export interface AssetsOptions {
|
|
4
|
+
once?: boolean;
|
|
5
|
+
destination?: (context: TransformerPluginContext) => string;
|
|
6
|
+
source?: (context: TransformerPluginContext) => string;
|
|
7
|
+
}
|
|
8
|
+
export declare const assets: (options?: AssetsOptions) => TransformerPlugin;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
export const ASSETS_OPTIONS = {
|
|
4
|
+
once: true,
|
|
5
|
+
destination(context) {
|
|
6
|
+
return path.join('dist', 'assets', context.fileName);
|
|
7
|
+
},
|
|
8
|
+
source(context) {
|
|
9
|
+
return path.join(context.directoryPath, 'assets');
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const assets = (options) => {
|
|
13
|
+
const name = 'assets';
|
|
14
|
+
options = Object.assign({}, ASSETS_OPTIONS, options);
|
|
15
|
+
const sources = new Set();
|
|
16
|
+
const run = (context) => {
|
|
17
|
+
context.assetsDestination = options.destination(context);
|
|
18
|
+
context.assetsSource = options.source(context);
|
|
19
|
+
if (!context.assetsSource)
|
|
20
|
+
return;
|
|
21
|
+
if (!fs.existsSync(context.assetsSource))
|
|
22
|
+
return;
|
|
23
|
+
if (options.once && sources.has(context.assetsSource))
|
|
24
|
+
return;
|
|
25
|
+
sources.add(context.assetsSource);
|
|
26
|
+
fs.copySync(context.assetsSource, context.assetsDestination);
|
|
27
|
+
};
|
|
28
|
+
return { name, run };
|
|
29
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransformerPlugin } from '../transformer.types';
|
|
2
2
|
export declare const COPY_OPTIONS: Partial<CopyOptions>;
|
|
3
3
|
export interface CopyOptions {
|
|
4
4
|
at?: 'start' | 'run' | 'finish';
|
|
@@ -6,4 +6,4 @@ export interface CopyOptions {
|
|
|
6
6
|
source: string;
|
|
7
7
|
transformer?: (content: string) => string;
|
|
8
8
|
}
|
|
9
|
-
export declare const copy: (options: CopyOptions) =>
|
|
9
|
+
export declare const copy: (options: CopyOptions) => TransformerPlugin;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { TransformerPlugin } from '../transformer.types';
|
|
2
2
|
export declare const CUSTOM_ELEMENT_OPTIONS: Partial<CustomElementOptions>;
|
|
3
3
|
export interface CustomElementOptions {
|
|
4
4
|
prefix?: string;
|
|
5
5
|
typings?: boolean;
|
|
6
6
|
}
|
|
7
|
-
export declare const customElement: (options?: CustomElementOptions) =>
|
|
7
|
+
export declare const customElement: (options?: CustomElementOptions) => TransformerPlugin;
|