element-vir 12.2.0 → 12.3.1
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/dist/built-in-lit-types.d.ts +2 -0
- package/dist/built-in-lit-types.js +1 -0
- package/dist/declarative-element/utilities/template-string.d.ts +5 -0
- package/dist/declarative-element/utilities/template-string.js +39 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { svg, unsafeCSS } from 'lit';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TemplateResult } from 'lit';
|
|
2
|
+
import type { unsafeHTML, unsafeSVG } from '../../built-in-lit-directives';
|
|
3
|
+
export declare function templateToString(template: TemplateResult | ReturnType<typeof unsafeSVG> | ReturnType<typeof unsafeHTML> | {
|
|
4
|
+
templateString: string;
|
|
5
|
+
}): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { collapseWhiteSpace } from '@augment-vir/common';
|
|
2
|
+
export function templateToString(template) {
|
|
3
|
+
if ('templateString' in template) {
|
|
4
|
+
return template.templateString;
|
|
5
|
+
}
|
|
6
|
+
const { strings, values } = template;
|
|
7
|
+
if ((!strings || !strings?.length) && (!values || !values.length)) {
|
|
8
|
+
return '';
|
|
9
|
+
}
|
|
10
|
+
const valueList = [
|
|
11
|
+
...(values || []),
|
|
12
|
+
'', // this last empty string is so it's easier to deal with indexes
|
|
13
|
+
];
|
|
14
|
+
const stringsList = strings ?? [''];
|
|
15
|
+
const all = stringsList.map((stringValue, index) => {
|
|
16
|
+
const value = extractValue(stringValue, valueList[index]);
|
|
17
|
+
return `${stringValue}${value}`;
|
|
18
|
+
});
|
|
19
|
+
return collapseWhiteSpace(all.join(''));
|
|
20
|
+
}
|
|
21
|
+
function extractValue(previousString, value) {
|
|
22
|
+
if (value._$litType$ != undefined || value._$litDirective$ != undefined) {
|
|
23
|
+
// nested templates
|
|
24
|
+
return templateToString(value);
|
|
25
|
+
}
|
|
26
|
+
else if (Array.isArray(value)) {
|
|
27
|
+
// array of strings or templates.
|
|
28
|
+
const values = value.map((innerValue) => templateToString(innerValue));
|
|
29
|
+
return values.join('');
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
if (previousString.endsWith('=')) {
|
|
33
|
+
return `"${value}"`;
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './built-in-lit-directives';
|
|
2
|
+
export * from './built-in-lit-types';
|
|
2
3
|
export * from './declarative-element/declarative-element';
|
|
3
4
|
export * from './declarative-element/declarative-element-init';
|
|
4
5
|
export * from './declarative-element/define-element';
|
|
@@ -21,6 +22,7 @@ export * from './declarative-element/properties/host-classes';
|
|
|
21
22
|
export * from './declarative-element/properties/styles';
|
|
22
23
|
export * from './declarative-element/properties/tag-name';
|
|
23
24
|
export * from './declarative-element/render-callback';
|
|
25
|
+
export * from './declarative-element/utilities/template-string';
|
|
24
26
|
export * from './declarative-element/wrap-define-element';
|
|
25
27
|
export { requireAllCustomElementsToBeDeclarativeElements } from './require-declarative-element';
|
|
26
28
|
export * from './template-transforms/vir-css/vir-css';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './built-in-lit-directives';
|
|
2
|
+
export * from './built-in-lit-types';
|
|
2
3
|
export * from './declarative-element/declarative-element';
|
|
3
4
|
export * from './declarative-element/declarative-element-init';
|
|
4
5
|
export * from './declarative-element/define-element';
|
|
@@ -20,6 +21,7 @@ export * from './declarative-element/properties/host-classes';
|
|
|
20
21
|
export * from './declarative-element/properties/styles';
|
|
21
22
|
export * from './declarative-element/properties/tag-name';
|
|
22
23
|
export * from './declarative-element/render-callback';
|
|
24
|
+
export * from './declarative-element/utilities/template-string';
|
|
23
25
|
export * from './declarative-element/wrap-define-element';
|
|
24
26
|
export { requireAllCustomElementsToBeDeclarativeElements } from './require-declarative-element';
|
|
25
27
|
export * from './template-transforms/vir-css/vir-css';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "element-vir",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.1",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"custom",
|
|
6
6
|
"web",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"ts-node": "^10.9.1",
|
|
74
74
|
"type-fest": "^3.9.0",
|
|
75
75
|
"typescript": "^5.0.4",
|
|
76
|
-
"virmator": "^6.
|
|
77
|
-
"vite": "^4.3.
|
|
76
|
+
"virmator": "^6.5.0",
|
|
77
|
+
"vite": "^4.3.3",
|
|
78
78
|
"vite-tsconfig-paths": "^4.2.0"
|
|
79
79
|
}
|
|
80
80
|
}
|