@htmlplus/element 0.4.1 → 0.4.2
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/event.js +2 -1
- package/client/decorators/property.js +1 -1
- package/client/utils/config.d.ts +10 -0
- package/client/utils/config.js +8 -0
- package/client/utils/event.js +3 -1
- package/client/utils/index.d.ts +1 -0
- package/client/utils/index.js +1 -0
- package/compiler/plugins/customElementReact/customElementReact.js +1 -1
- package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs +1 -1
- package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.ts.hbs +1 -1
- package/compiler/plugins/extract.js +11 -1
- package/package.json +1 -1
- package/types/context.d.ts +1 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { paramCase } from 'change-case';
|
|
1
2
|
import { defineProperty, dispatch, host } from '../utils/index.js';
|
|
2
3
|
export function Event(options = {}) {
|
|
3
4
|
return function (target, propertyKey) {
|
|
@@ -6,7 +7,7 @@ export function Event(options = {}) {
|
|
|
6
7
|
return (detail) => {
|
|
7
8
|
var _a;
|
|
8
9
|
(_a = options.bubbles) !== null && _a !== void 0 ? _a : (options.bubbles = false);
|
|
9
|
-
const name = options.name || String(propertyKey);
|
|
10
|
+
const name = paramCase(options.name || String(propertyKey));
|
|
10
11
|
const event = new CustomEvent(name, Object.assign(Object.assign({}, options), { detail }));
|
|
11
12
|
dispatch(host(this), event);
|
|
12
13
|
return event;
|
|
@@ -5,7 +5,7 @@ export function Property(options) {
|
|
|
5
5
|
return function (target, propertyKey) {
|
|
6
6
|
const name = String(propertyKey);
|
|
7
7
|
const attribute = paramCase(name);
|
|
8
|
-
const type = getMembers(target)[name]
|
|
8
|
+
const type = getMembers(target)[name][0];
|
|
9
9
|
const values = new Map();
|
|
10
10
|
function get() {
|
|
11
11
|
return values.get(this);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
event?: OptionsEvent;
|
|
3
|
+
}
|
|
4
|
+
interface OptionsEvent {
|
|
5
|
+
dispatch?: (target: OptionsEventTarget, event: Event) => boolean;
|
|
6
|
+
}
|
|
7
|
+
declare type OptionsEventTarget = Window | Document | Element;
|
|
8
|
+
export declare const getConfig: () => Options;
|
|
9
|
+
export declare const setConfig: (config: Options) => void;
|
|
10
|
+
export {};
|
package/client/utils/event.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { getConfig } from './config.js';
|
|
1
2
|
export const dispatch = (target, event) => {
|
|
2
|
-
|
|
3
|
+
var _a, _b;
|
|
4
|
+
return ((_b = (_a = getConfig().event) === null || _a === void 0 ? void 0 : _a.dispatch) === null || _b === void 0 ? void 0 : _b.call(_a, target, event)) || target.dispatchEvent(event);
|
|
3
5
|
};
|
|
4
6
|
export const on = (target, type, handler, options) => {
|
|
5
7
|
target.addEventListener(type, handler, options);
|
package/client/utils/index.d.ts
CHANGED
package/client/utils/index.js
CHANGED
package/compiler/plugins/customElementReact/templates/src/components/{{fileName}}.compact.ts.hbs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
import { {{componentClassNamePrune}} } from './{{fileName}}';
|
|
10
10
|
{{/each}}
|
|
11
11
|
|
|
12
|
-
const All =
|
|
12
|
+
const All = Object.assign({{root.componentClassNamePrune}}, {
|
|
13
13
|
{{#each filterd}}
|
|
14
14
|
{{componentClassNameInCategory}}: {{componentClassNamePrune}},
|
|
15
15
|
{{/each}}
|
|
@@ -19,7 +19,7 @@ type Renamed = Rename<{{importerComponentType.variable}}, {
|
|
|
19
19
|
{{/each}}
|
|
20
20
|
}>
|
|
21
21
|
|
|
22
|
-
export const {{componentClassNamePrune}} =
|
|
22
|
+
export const {{componentClassNamePrune}} = proxy<{{componentInterfaceName}}, Renamed>(
|
|
23
23
|
'{{componentTag}}',
|
|
24
24
|
[{{#each classProperties}}'{{key.name}}', {{/each}}],
|
|
25
25
|
[{{#each classEvents}}'{{key.name}}', {{/each}}],
|
|
@@ -35,7 +35,17 @@ export const extract = (options) => {
|
|
|
35
35
|
])));
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
|
-
}
|
|
38
|
+
},
|
|
39
|
+
JSXElement(path) {
|
|
40
|
+
var _a;
|
|
41
|
+
const { openingElement } = path.node;
|
|
42
|
+
const name = openingElement.name.name;
|
|
43
|
+
if (!/-/g.test(name))
|
|
44
|
+
return;
|
|
45
|
+
(_a = context.customElementNames) !== null && _a !== void 0 ? _a : (context.customElementNames = []);
|
|
46
|
+
context.customElementNames.push(name);
|
|
47
|
+
context.customElementNames = context.customElementNames.filter((item, index, items) => items.indexOf(item) === index).sort();
|
|
48
|
+
},
|
|
39
49
|
});
|
|
40
50
|
context.directoryPath = path.dirname(context.filePath);
|
|
41
51
|
context.directoryName = path.basename(context.directoryPath);
|
package/package.json
CHANGED
package/types/context.d.ts
CHANGED