piral-litel 0.15.0-alpha.3809 → 0.15.0-alpha.3933
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 +1 -1
- package/esm/converter.js +20 -22
- package/esm/converter.js.map +1 -1
- package/lib/converter.js +20 -22
- package/lib/converter.js.map +1 -1
- package/package.json +4 -5
- package/src/converter.ts +25 -27
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
# [Piral LitEl](https://piral.io) · [](https://github.com/smapiot/piral/blob/main/LICENSE) [](https://www.npmjs.com/package/piral-litel) [](https://jestjs.io) [](https://gitter.im/piral-io/community)
|
|
4
4
|
|
|
5
|
-
This is a plugin that only has a peer dependency to `
|
|
5
|
+
This is a plugin that only has a peer dependency to `lit-element`. What `piral-litel` brings to the table is a set of Pilet API extensions that can be used with `piral` or `piral-core`.
|
|
6
6
|
|
|
7
7
|
The set includes a LitElement converter for any component registration, as well as a `fromLitEl` shortcut and a `LitElExtension` component.
|
|
8
8
|
|
package/esm/converter.js
CHANGED
|
@@ -2,30 +2,28 @@ import { createExtension } from './extension';
|
|
|
2
2
|
export function createConverter(config = {}) {
|
|
3
3
|
const { selector = 'litel-extension' } = config;
|
|
4
4
|
const Extension = createExtension(selector);
|
|
5
|
-
const convert = (elementName) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const convert = (elementName) => ({
|
|
6
|
+
mount(parent, data, ctx) {
|
|
7
|
+
const { piral } = data;
|
|
8
|
+
const el = parent.appendChild(document.createElement(elementName));
|
|
9
|
+
el.setAttribute('props', JSON.stringify(data));
|
|
10
|
+
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
11
|
+
el.shadowRoot.addEventListener('render-html', (ev) => {
|
|
12
|
+
ev.stopPropagation();
|
|
13
|
+
piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
|
|
14
|
+
}, false);
|
|
15
|
+
},
|
|
16
|
+
update(parent, data, ctx) {
|
|
17
|
+
const el = parent.querySelector(elementName);
|
|
18
|
+
if (el) {
|
|
10
19
|
el.setAttribute('props', JSON.stringify(data));
|
|
11
20
|
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const el = parent.querySelector(elementName);
|
|
19
|
-
if (el) {
|
|
20
|
-
el.setAttribute('props', JSON.stringify(data));
|
|
21
|
-
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
unmount(el) {
|
|
25
|
-
el.innerHTML = '';
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
};
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
unmount(el) {
|
|
24
|
+
el.innerHTML = '';
|
|
25
|
+
},
|
|
26
|
+
});
|
|
29
27
|
convert.Extension = Extension;
|
|
30
28
|
return convert;
|
|
31
29
|
}
|
package/esm/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAU9C,MAAM,UAAU,eAAe,CAAC,SAAgC,EAAE;IAChE,MAAM,EAAE,QAAQ,GAAG,iBAAiB,EAAE,GAAG,MAAM,CAAC;IAChD,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,WAAmB,EAA4B,EAAE
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAU9C,MAAM,UAAU,eAAe,CAAC,SAAgC,EAAE;IAChE,MAAM,EAAE,QAAQ,GAAG,iBAAiB,EAAE,GA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CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/lib/converter.js
CHANGED
|
@@ -5,30 +5,28 @@ const extension_1 = require("./extension");
|
|
|
5
5
|
function createConverter(config = {}) {
|
|
6
6
|
const { selector = 'litel-extension' } = config;
|
|
7
7
|
const Extension = (0, extension_1.createExtension)(selector);
|
|
8
|
-
const convert = (elementName) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
const convert = (elementName) => ({
|
|
9
|
+
mount(parent, data, ctx) {
|
|
10
|
+
const { piral } = data;
|
|
11
|
+
const el = parent.appendChild(document.createElement(elementName));
|
|
12
|
+
el.setAttribute('props', JSON.stringify(data));
|
|
13
|
+
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
14
|
+
el.shadowRoot.addEventListener('render-html', (ev) => {
|
|
15
|
+
ev.stopPropagation();
|
|
16
|
+
piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
|
|
17
|
+
}, false);
|
|
18
|
+
},
|
|
19
|
+
update(parent, data, ctx) {
|
|
20
|
+
const el = parent.querySelector(elementName);
|
|
21
|
+
if (el) {
|
|
13
22
|
el.setAttribute('props', JSON.stringify(data));
|
|
14
23
|
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const el = parent.querySelector(elementName);
|
|
22
|
-
if (el) {
|
|
23
|
-
el.setAttribute('props', JSON.stringify(data));
|
|
24
|
-
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
25
|
-
}
|
|
26
|
-
},
|
|
27
|
-
unmount(el) {
|
|
28
|
-
el.innerHTML = '';
|
|
29
|
-
},
|
|
30
|
-
};
|
|
31
|
-
};
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
unmount(el) {
|
|
27
|
+
el.innerHTML = '';
|
|
28
|
+
},
|
|
29
|
+
});
|
|
32
30
|
convert.Extension = Extension;
|
|
33
31
|
return convert;
|
|
34
32
|
}
|
package/lib/converter.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAU9C,SAAgB,eAAe,CAAC,SAAgC,EAAE;IAChE,MAAM,EAAE,QAAQ,GAAG,iBAAiB,EAAE,GAAG,MAAM,CAAC;IAChD,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,WAAmB,EAA4B,EAAE
|
|
1
|
+
{"version":3,"file":"converter.js","sourceRoot":"","sources":["../src/converter.ts"],"names":[],"mappings":";;;AACA,2CAA8C;AAU9C,SAAgB,eAAe,CAAC,SAAgC,EAAE;IAChE,MAAM,EAAE,QAAQ,GAAG,iBAAiB,EAAE,GAAG,MAAM,CAAC;IAChD,MAAM,SAAS,GAAG,IAAA,2BAAe,EAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,CAAoC,WAAmB,EAA4B,EAAE,CAAC,CAAC;QACrG,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG;YACrB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;YACvB,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,CAAC,QAAQ,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC;YACnE,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;YAC/C,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;YAC5C,EAAE,CAAC,UAAU,CAAC,gBAAgB,CAC5B,aAAa,EACb,CAAC,EAAe,EAAE,EAAE;gBAClB,EAAE,CAAC,eAAe,EAAE,CAAC;gBACrB,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/D,CAAC,EACD,KAAK,CACN,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG;YACtB,MAAM,EAAE,GAAG,MAAM,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAE7C,IAAI,EAAE,EAAE;gBACN,EAAE,CAAC,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC/C,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC;aAC7C;QACH,CAAC;QACD,OAAO,CAAC,EAAE;YACR,EAAE,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,CAAC;KACF,CAAC,CAAC;IACH,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC;IAC9B,OAAO,OAAO,CAAC;AACjB,CAAC;AAhCD,0CAgCC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-litel",
|
|
3
|
-
"version": "0.15.0-alpha.
|
|
3
|
+
"version": "0.15.0-alpha.3933",
|
|
4
4
|
"description": "Plugin for integrating Lit-Element components in Piral.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"piral",
|
|
@@ -46,11 +46,10 @@
|
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"lit-element": "^2.2.1",
|
|
49
|
-
"piral-core": "0.15.0-alpha.
|
|
49
|
+
"piral-core": "0.15.0-alpha.3933"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"lit-element": "^2.0.0"
|
|
53
|
-
"piral-core": "0.14.x"
|
|
52
|
+
"lit-element": "^2.0.0"
|
|
54
53
|
},
|
|
55
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "520a272d09f02543153f1d8b2ae23a3ae10acd6f"
|
|
56
55
|
}
|
package/src/converter.ts
CHANGED
|
@@ -12,35 +12,33 @@ export interface LitElConverterOptions {
|
|
|
12
12
|
export function createConverter(config: LitElConverterOptions = {}) {
|
|
13
13
|
const { selector = 'litel-extension' } = config;
|
|
14
14
|
const Extension = createExtension(selector);
|
|
15
|
-
const convert = <TProps extends BaseComponentProps>(elementName: string): ForeignComponent<TProps> => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
const convert = <TProps extends BaseComponentProps>(elementName: string): ForeignComponent<TProps> => ({
|
|
16
|
+
mount(parent, data, ctx) {
|
|
17
|
+
const { piral } = data;
|
|
18
|
+
const el = parent.appendChild(document.createElement(elementName));
|
|
19
|
+
el.setAttribute('props', JSON.stringify(data));
|
|
20
|
+
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
21
|
+
el.shadowRoot.addEventListener(
|
|
22
|
+
'render-html',
|
|
23
|
+
(ev: CustomEvent) => {
|
|
24
|
+
ev.stopPropagation();
|
|
25
|
+
piral.renderHtmlExtension(ev.detail.target, ev.detail.props);
|
|
26
|
+
},
|
|
27
|
+
false,
|
|
28
|
+
);
|
|
29
|
+
},
|
|
30
|
+
update(parent, data, ctx) {
|
|
31
|
+
const el = parent.querySelector(elementName);
|
|
32
|
+
|
|
33
|
+
if (el) {
|
|
20
34
|
el.setAttribute('props', JSON.stringify(data));
|
|
21
35
|
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
false,
|
|
29
|
-
);
|
|
30
|
-
},
|
|
31
|
-
update(parent, data, ctx) {
|
|
32
|
-
const el = parent.querySelector(elementName);
|
|
33
|
-
|
|
34
|
-
if (el) {
|
|
35
|
-
el.setAttribute('props', JSON.stringify(data));
|
|
36
|
-
el.setAttribute('ctx', JSON.stringify(ctx));
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
unmount(el) {
|
|
40
|
-
el.innerHTML = '';
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
};
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
unmount(el) {
|
|
39
|
+
el.innerHTML = '';
|
|
40
|
+
},
|
|
41
|
+
});
|
|
44
42
|
convert.Extension = Extension;
|
|
45
43
|
return convert;
|
|
46
44
|
}
|