@epa-wg/custom-element 0.0.16 → 0.0.18
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/.idea/codeStyles/codeStyleConfig.xml +5 -0
- package/.vscode/settings.json +25 -0
- package/README.md +32 -17
- package/bin/xslDtd2Ide.mjs +160 -0
- package/custom-element.d.ts +31 -0
- package/custom-element.js +38 -5
- package/demo/a.html +6 -11
- package/demo/hex-grid-dce.html +13 -13
- package/demo/http-request.html +13 -13
- package/demo/local-storage.html +2 -2
- package/demo/location-element.html +12 -12
- package/demo/parameters.html +4 -4
- package/demo/s.xslt +4 -6
- package/demo/z.html +3 -5
- package/ide/IDE.md +31 -0
- package/ide/customData-dce.json +89 -0
- package/ide/customData-xsl.json +1018 -0
- package/ide/web-types-dce.json +98 -0
- package/ide/web-types-xsl.json +867 -0
- package/index.html +5 -4
- package/package.json +6 -3
- package/request.html +2 -2
|
@@ -52,18 +52,18 @@
|
|
|
52
52
|
|
|
53
53
|
<xhtml:table>
|
|
54
54
|
<tr><th><h3> URL properties </h3></th></tr>
|
|
55
|
-
<
|
|
55
|
+
<apply-templates mode="attrs" select="//slice/window-url/@*"></apply-templates>
|
|
56
56
|
</xhtml:table>
|
|
57
57
|
<xhtml:table>
|
|
58
58
|
<tr><th><h3> URL parameters </h3></th></tr>
|
|
59
|
-
<
|
|
59
|
+
<apply-templates mode="attrs" select="//slice/window-url/params/*"></apply-templates>
|
|
60
60
|
</xhtml:table>
|
|
61
|
-
<
|
|
61
|
+
<template mode="attrs" match="*|@*">
|
|
62
62
|
<xhtml:tr>
|
|
63
63
|
<xhtml:th>{name()}</xhtml:th>
|
|
64
64
|
<xhtml:td>{.}</xhtml:td>
|
|
65
65
|
</xhtml:tr>
|
|
66
|
-
</
|
|
66
|
+
</template>
|
|
67
67
|
</template>
|
|
68
68
|
</custom-element>
|
|
69
69
|
<dce-2>?</dce-2>
|
|
@@ -84,21 +84,21 @@
|
|
|
84
84
|
<xhtml:table>
|
|
85
85
|
<xhtml:tbody>
|
|
86
86
|
<xhtml:tr><xhtml:th><h3>URL properties</h3></xhtml:th></xhtml:tr>
|
|
87
|
-
<
|
|
87
|
+
<for-each select="//slice/window-url/@*">
|
|
88
88
|
<xhtml:tr>
|
|
89
89
|
<xhtml:th>{name()}</xhtml:th>
|
|
90
90
|
<xhtml:td>{.}</xhtml:td>
|
|
91
91
|
</xhtml:tr>
|
|
92
|
-
</
|
|
92
|
+
</for-each>
|
|
93
93
|
</xhtml:tbody>
|
|
94
94
|
<xhtml:tbody>
|
|
95
95
|
<xhtml:tr><xhtml:th><h3>URL parameters</h3></xhtml:th></xhtml:tr>
|
|
96
|
-
<
|
|
96
|
+
<for-each select="//slice/window-url/params/*">
|
|
97
97
|
<xhtml:tr>
|
|
98
98
|
<xhtml:th>{name()}</xhtml:th>
|
|
99
99
|
<xhtml:td>{.}</xhtml:td>
|
|
100
100
|
</xhtml:tr>
|
|
101
|
-
</
|
|
101
|
+
</for-each>
|
|
102
102
|
</xhtml:tbody>
|
|
103
103
|
</xhtml:table>
|
|
104
104
|
</template>
|
|
@@ -121,21 +121,21 @@
|
|
|
121
121
|
<xhtml:table>
|
|
122
122
|
<xhtml:tbody>
|
|
123
123
|
<xhtml:tr><xhtml:th><h3>URL properties</h3></xhtml:th></xhtml:tr>
|
|
124
|
-
<
|
|
124
|
+
<for-each select="//slice/src-url/@*">
|
|
125
125
|
<xhtml:tr>
|
|
126
126
|
<xhtml:th>{name()}</xhtml:th>
|
|
127
127
|
<xhtml:td>{.}</xhtml:td>
|
|
128
128
|
</xhtml:tr>
|
|
129
|
-
</
|
|
129
|
+
</for-each>
|
|
130
130
|
</xhtml:tbody>
|
|
131
131
|
<xhtml:tbody>
|
|
132
132
|
<xhtml:tr><xhtml:th><h3>URL parameters</h3></xhtml:th></xhtml:tr>
|
|
133
|
-
<
|
|
133
|
+
<for-each select="//slice/src-url/params/*">
|
|
134
134
|
<xhtml:tr>
|
|
135
135
|
<xhtml:th>{name()}</xhtml:th>
|
|
136
136
|
<xhtml:td>{.}</xhtml:td>
|
|
137
137
|
</xhtml:tr>
|
|
138
|
-
</
|
|
138
|
+
</for-each>
|
|
139
139
|
</xhtml:tbody>
|
|
140
140
|
</xhtml:table>
|
|
141
141
|
</template>
|
package/demo/parameters.html
CHANGED
|
@@ -27,12 +27,12 @@ params needed to declare DCE attributes and track the attributes changes. It als
|
|
|
27
27
|
">
|
|
28
28
|
<template>
|
|
29
29
|
<custom-element tag="dce-link" hidden>
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
<
|
|
30
|
+
<attribute name="p1" >default_P1 </attribute>
|
|
31
|
+
<attribute name="p2" select="'always_p2'" ></attribute>
|
|
32
|
+
<attribute name="p3" select="//p3 ?? 'def_P3' " ></attribute>
|
|
33
33
|
p1:{$p1} <br/> p2: {$p2} <br/> p3: {$p3}
|
|
34
34
|
</custom-element>
|
|
35
|
-
<dce-link id="dce1"></dce-link>
|
|
35
|
+
<dce-link id="dce1" ></dce-link>
|
|
36
36
|
<section>
|
|
37
37
|
<dce-link id="dce2" p1="123" p2="override ignored as select is defined"></dce-link> <br/>
|
|
38
38
|
<div><input id="i1" value="p1" /> <button onclick="dce2.setAttribute('p1',i1.value)"> set p1</button> </div>
|
package/demo/s.xslt
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
1
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dce="urn:schemas-epa-wg:dce" xmlns:exsl="http://exslt.org/common" version="1.0" exclude-result-prefixes="exsl">
|
|
3
2
|
<xsl:template match="ignore">
|
|
4
3
|
<xsl:choose>
|
|
@@ -10,11 +9,10 @@
|
|
|
10
9
|
<xsl:when test="//p1 "><xsl:value-of select="//p1 "/></xsl:when>
|
|
11
10
|
<xsl:otherwise><xsl:value-of select=" 'def_p1' "/></xsl:otherwise>
|
|
12
11
|
</xsl:choose></xsl:param><xsl:param xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="p2" select="'always_p2'"/><xsl:param xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="p3"><xsl:choose>
|
|
13
|
-
<xsl:when test="p3"><xsl:value-of select="p3"/></xsl:when>
|
|
14
|
-
<xsl:otherwise><xsl:value-of select="default_P3"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
</dce-text></dce-root></xsl:template>
|
|
12
|
+
<xsl:when test="//p3"><xsl:value-of select="//p3"/></xsl:when>
|
|
13
|
+
<xsl:otherwise><xsl:value-of select="'default_P3 p1:{$p1"/> p2:<xsl:value-of select="$p2"/> p3:<xsl:value-of select="$p3"/>
|
|
14
|
+
'}</xsl:otherwise>
|
|
15
|
+
</xsl:choose></xsl:param><dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" data-dce-id="1"><xsl:attribute xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="p1" select="//p1 ?? 'def_p1' "/><xsl:attribute xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="p2" select="'always_p2'"/><xsl:attribute xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="p3"/></dce-root></xsl:template>
|
|
18
16
|
<xsl:template match="/">
|
|
19
17
|
<xsl:apply-templates mode="payload" select="/datadom/attributes"/>
|
|
20
18
|
</xsl:template>
|
package/demo/z.html
CHANGED
|
@@ -39,12 +39,10 @@
|
|
|
39
39
|
</head>
|
|
40
40
|
<body>
|
|
41
41
|
|
|
42
|
-
<custom-element src="
|
|
43
|
-
|
|
42
|
+
<custom-element src="embed-1.html">
|
|
43
|
+
loading from embed-1.html ...
|
|
44
44
|
</custom-element>
|
|
45
|
-
|
|
46
|
-
<!-- <template><i>element with id=none is missing in template</i></template>-->
|
|
47
|
-
<!--</custom-element>-->
|
|
45
|
+
|
|
48
46
|
|
|
49
47
|
</body>
|
|
50
48
|
</html>
|
package/ide/IDE.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Ide setup for DCE
|
|
2
|
+
<details>
|
|
3
|
+
<summary> VS Code </summary>
|
|
4
|
+
Copy into `.vscode/settings.json`
|
|
5
|
+
|
|
6
|
+
{
|
|
7
|
+
"html.customData": [
|
|
8
|
+
"./node_modules/@epa-wg/custom-element/ide/customData-dce.json",
|
|
9
|
+
"./node_modules/@epa-wg/custom-element/ide/customData-xsl.json",
|
|
10
|
+
"./customData.json"
|
|
11
|
+
],
|
|
12
|
+
}
|
|
13
|
+
After editing the DCE in the HTML sources, update `./customData.json` with project' custom tags and attributes.
|
|
14
|
+
</details>
|
|
15
|
+
|
|
16
|
+
<details>
|
|
17
|
+
<summary> IntelliJ </summary>
|
|
18
|
+
Append into `package.json`
|
|
19
|
+
|
|
20
|
+
{
|
|
21
|
+
"web-types":[ "./node_modules/@epa-wg/custom-element/ide/web-types-dce.json",
|
|
22
|
+
"./node_modules/@epa-wg/custom-element/ide/web-types-xsl.json",
|
|
23
|
+
"./web_types.json"
|
|
24
|
+
],
|
|
25
|
+
}
|
|
26
|
+
After editing the DCE in the HTML, update `./web-types.json` with project' custom tags and attributes.
|
|
27
|
+
</details>
|
|
28
|
+
|
|
29
|
+
# Publishing your components
|
|
30
|
+
When preparing your package for publishing, make sure the instructions on IDE support with your package and DCE package
|
|
31
|
+
tags covered in IntelliJ and VS Code format.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1.1,
|
|
3
|
+
"globalAttributes": [
|
|
4
|
+
{
|
|
5
|
+
"name": "slice",
|
|
6
|
+
"description": {
|
|
7
|
+
"kind": "markdown",
|
|
8
|
+
"value": "Defines the name of data slice in DCE where the data from `value` will be propagated on `change` or by `slice-update` event\n\nOn: any component with `value` and associated change event"
|
|
9
|
+
},
|
|
10
|
+
"references": [
|
|
11
|
+
{
|
|
12
|
+
"name": "Demo",
|
|
13
|
+
"url": "https://unpkg.com/@epa-wg/custom-element/demo/dom-merge.html"
|
|
14
|
+
}
|
|
15
|
+
]
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"name": "slice-update",
|
|
19
|
+
"description": {
|
|
20
|
+
"kind": "markdown",
|
|
21
|
+
"value": "Defines the event name on which `value` would be synchronized with DCE slice\n\nOn: any component with `value` and associated change event"
|
|
22
|
+
},
|
|
23
|
+
"references": [
|
|
24
|
+
{
|
|
25
|
+
"name": "Demo",
|
|
26
|
+
"url": "https://unpkg.com/@epa-wg/custom-element/demo/dom-merge.html"
|
|
27
|
+
}
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
"tags": [
|
|
32
|
+
{
|
|
33
|
+
"name": "custom-element",
|
|
34
|
+
"description": "Declarative Cuestom ELement(DCE). `<custom-element tag='my-element'></custom-element>`.",
|
|
35
|
+
"attributes": [
|
|
36
|
+
{
|
|
37
|
+
"name": "hidden",
|
|
38
|
+
"description": "hides DCE definition to prevent visual appearance of content. Wrap the payload into template tag to prevent applying the inline CSS in global scope.",
|
|
39
|
+
"type": "boolean"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "tag",
|
|
43
|
+
"description": "HTML tag for Custom Element. Used for window.customElements.define(). If not set, would be generated and DCE instance rendered inline.",
|
|
44
|
+
"type": "string"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "src",
|
|
48
|
+
"description": "full, relative, or hash URL to DCE template",
|
|
49
|
+
"type": "string",
|
|
50
|
+
"references": [
|
|
51
|
+
{
|
|
52
|
+
"name": "example",
|
|
53
|
+
"url": "https://unpkg.com/@epa-wg/custom-element/demo/external-template.html"
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"references": [
|
|
59
|
+
{
|
|
60
|
+
"name": "custom-element",
|
|
61
|
+
"url": "https://github.com/EPA-WG/custom-element"
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "for-each",
|
|
67
|
+
"description": "The <xsl:for-each> element selects a set of nodes and processes each of them in the same way. It is often used to iterate through a set of nodes or to change the current node. If one or more <xsl:sort> elements appear as the children of this element, sorting occurs before processing. Otherwise, nodes are processed in document order.",
|
|
68
|
+
"attributes": [
|
|
69
|
+
{
|
|
70
|
+
"name": "select",
|
|
71
|
+
"description": "Uses an XPath expression to select nodes to be processed.",
|
|
72
|
+
"type": "string",
|
|
73
|
+
"references": [
|
|
74
|
+
{
|
|
75
|
+
"name": "MDN docs",
|
|
76
|
+
"url": "https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/for-each#select"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
],
|
|
81
|
+
"references": [
|
|
82
|
+
{
|
|
83
|
+
"name": "for-each",
|
|
84
|
+
"url": "https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/for-each"
|
|
85
|
+
}
|
|
86
|
+
]
|
|
87
|
+
}
|
|
88
|
+
]
|
|
89
|
+
}
|