@epa-wg/custom-element 0.0.25 → 0.0.27
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 +3 -3
- package/bin/xslDtd2Ide.mjs +1 -1
- package/custom-element.js +103 -33
- package/demo/a.svg +27 -0
- package/demo/confused.svg +1 -0
- package/demo/demo.css +11 -8
- package/demo/embed-1.html +1 -2
- package/demo/external-template.html +122 -62
- package/demo/lib-dir/Smiley.svg +24 -0
- package/demo/lib-dir/embed-lib.html +34 -0
- package/demo/module-url.html +215 -0
- package/demo/npm-versions-demo.html +118 -0
- package/demo/npm-versions.html +94 -0
- package/demo/s.xml +3 -36
- package/demo/s.xslt +55 -96
- package/demo/set-url.html +1 -1
- package/demo/z.html +32 -61
- package/demo/z.js +9 -0
- package/demo/z1.html +34 -0
- package/ide/customData-dce.json +215 -181
- package/ide/web-types-dce.json +184 -159
- package/ide/web-types-xsl.json +1 -1
- package/index.html +21 -3
- package/local-storage.js +19 -14
- package/module-url.js +34 -0
- package/package.json +1 -1
- package/request.html +0 -53
package/README.md
CHANGED
|
@@ -348,9 +348,9 @@ within template
|
|
|
348
348
|
[github-image]: https://cdnjs.cloudflare.com/ajax/libs/octicons/8.5.0/svg/mark-github.svg
|
|
349
349
|
[npm-image]: https://img.shields.io/npm/v/@epa-wg/custom-element.svg
|
|
350
350
|
[npm-url]: https://npmjs.org/package/@epa-wg/custom-element
|
|
351
|
-
[coverage-image]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.
|
|
352
|
-
[coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.
|
|
353
|
-
[storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.
|
|
351
|
+
[coverage-image]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.27/coverage/src/custom-element/coverage.svg
|
|
352
|
+
[coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.27/coverage/src/custom-element/index.html
|
|
353
|
+
[storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.27/storybook-static/index.html?path=/story/welcome--introduction
|
|
354
354
|
[sandbox-url]: https://stackblitz.com/github/EPA-WG/custom-element?file=index.html
|
|
355
355
|
[webcomponents-url]: https://www.webcomponents.org/element/@epa-wg/custom-element
|
|
356
356
|
[webcomponents-img]: https://img.shields.io/badge/webcomponents.org-published-blue.svg
|
package/bin/xslDtd2Ide.mjs
CHANGED
|
@@ -116,7 +116,7 @@ writeFileSync( '.././ide/customData-xsl.json', JSON.stringify( vsCode, undefined
|
|
|
116
116
|
const intelliJ = {
|
|
117
117
|
"$schema": "http://json.schemastore.org/web-types",
|
|
118
118
|
"name": "@epa-wg/custom-element",
|
|
119
|
-
"version": "0.0.
|
|
119
|
+
"version": "0.0.27",
|
|
120
120
|
"js-types-syntax": "typescript",
|
|
121
121
|
"description-markup": "markdown",
|
|
122
122
|
"contributions": {
|
package/custom-element.js
CHANGED
|
@@ -47,6 +47,7 @@ xml2dom( xmlString )
|
|
|
47
47
|
}
|
|
48
48
|
export function
|
|
49
49
|
xmlString(doc){ return new XMLSerializer().serializeToString( doc ) }
|
|
50
|
+
function x(doc) { return xmlString(doc) }
|
|
50
51
|
|
|
51
52
|
function
|
|
52
53
|
injectData( root, sectionName, arr, cb )
|
|
@@ -145,22 +146,63 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
|
|
|
145
146
|
if( templateNode.tagName === S || templateNode.documentElement?.tagName === S )
|
|
146
147
|
return tagUid(templateNode)
|
|
147
148
|
const sanitizeXsl = xml2dom(`<xsl:stylesheet version="1.0" xmlns:xsl="${ XSL_NS_URL }" xmlns:xhtml="${ HTML_NS_URL }" xmlns:exsl="${EXSL_NS_URL}" exclude-result-prefixes="exsl" >
|
|
148
|
-
|
|
149
|
-
<xsl:template match="/"><dce-root xmlns="${ HTML_NS_URL }"><xsl:apply-templates select="*"/></dce-root></xsl:template>
|
|
150
|
-
|
|
151
|
-
<xsl:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
<xsl:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
<xsl:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
149
|
+
<xsl:output method="xml"/>
|
|
150
|
+
<xsl:template match="/"><dce-root xmlns="${ HTML_NS_URL }"><xsl:apply-templates select="*" /></dce-root></xsl:template>
|
|
151
|
+
<xsl:template match="*[name()='template']">
|
|
152
|
+
<xsl:apply-templates mode="sanitize" select="*|text()"/>
|
|
153
|
+
</xsl:template>
|
|
154
|
+
<xsl:template match="*">
|
|
155
|
+
<xsl:apply-templates mode="sanitize" select="*|text()"/>
|
|
156
|
+
</xsl:template>
|
|
157
|
+
<xsl:template match="*[name()='svg']|*[name()='math']">
|
|
158
|
+
<xsl:apply-templates mode="sanitize" select="."/>
|
|
159
|
+
</xsl:template>
|
|
160
|
+
<xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]">
|
|
161
|
+
<xsl:copy>
|
|
162
|
+
<xsl:apply-templates mode="sanitize" select="@*"/>
|
|
163
|
+
<xsl:value-of select="text()"></xsl:value-of>
|
|
164
|
+
</xsl:copy>
|
|
165
|
+
</xsl:template>
|
|
166
|
+
<xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]">
|
|
167
|
+
<xsl:element name="{local-name()}">
|
|
168
|
+
<xsl:apply-templates mode="sanitize" select="@*"/>
|
|
169
|
+
<xsl:value-of select="text()"></xsl:value-of>
|
|
170
|
+
</xsl:element>
|
|
171
|
+
</xsl:template>
|
|
172
|
+
<xsl:template mode="sanitize" match="*|@*">
|
|
173
|
+
<xsl:copy>
|
|
174
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
175
|
+
</xsl:copy>
|
|
176
|
+
</xsl:template>
|
|
177
|
+
<xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
|
|
178
|
+
<xsl:template mode="sanitize" match="text()">
|
|
179
|
+
<dce-text>
|
|
180
|
+
<xsl:copy/>
|
|
181
|
+
</dce-text>
|
|
182
|
+
</xsl:template>
|
|
183
|
+
<xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']">
|
|
184
|
+
<dce-text>
|
|
185
|
+
<xsl:copy>
|
|
186
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
187
|
+
</xsl:copy>
|
|
188
|
+
</dce-text>
|
|
189
|
+
</xsl:template>
|
|
190
|
+
<xsl:template mode="sanitize" match="xhtml:*">
|
|
191
|
+
<xsl:element name="{local-name()}">
|
|
192
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
193
|
+
</xsl:element>
|
|
194
|
+
</xsl:template>
|
|
195
|
+
</xsl:stylesheet>`)
|
|
161
196
|
const sanitizeProcessor = new XSLTProcessor()
|
|
162
197
|
, tc = (n =>
|
|
163
198
|
{
|
|
199
|
+
forEach$(n,'custom-element', ce=>{
|
|
200
|
+
if( 'template' === ce.firstElementChild.localName )
|
|
201
|
+
{
|
|
202
|
+
[...ce.firstElementChild.content.childNodes].forEach(n=>ce.append(n));
|
|
203
|
+
ce.firstElementChild.remove();
|
|
204
|
+
}
|
|
205
|
+
})
|
|
164
206
|
forEach$(n,'script', s=> s.remove() );
|
|
165
207
|
const xslRoot = n.content ?? n.firstElementChild?.content ?? n.body ?? n;
|
|
166
208
|
xslTags.forEach( tag => forEach$( xslRoot, tag, el=>toXsl(el,xslRoot) ) );
|
|
@@ -223,6 +265,11 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
|
|
|
223
265
|
, payload = $( xslDom, 'template[mode="payload"]');
|
|
224
266
|
if( !fr )
|
|
225
267
|
return console.error("transformation error",{ xml:tc.outerHTML, xsl: xmlString( sanitizeXsl ) });
|
|
268
|
+
if( 'dce-root'!==fr.firstElementChild.localName )
|
|
269
|
+
{ const r = fr.ownerDocument.createElement('dce-root');
|
|
270
|
+
[...fr.childNodes].forEach(n=>r.append(n));
|
|
271
|
+
fr.append(r)
|
|
272
|
+
}
|
|
226
273
|
const params = [];
|
|
227
274
|
[...fr.querySelectorAll('dce-root>attribute')].forEach( a=>
|
|
228
275
|
{
|
|
@@ -259,7 +306,7 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
|
|
|
259
306
|
for( const c of fr.childNodes )
|
|
260
307
|
payload.append(xslDom.importNode(c,true))
|
|
261
308
|
|
|
262
|
-
const embeddedTemplates = [...payload.
|
|
309
|
+
const embeddedTemplates = [...payload.getElementsByTagName('xsl:template')];
|
|
263
310
|
embeddedTemplates.forEach(t=>payload.ownerDocument.documentElement.append(t));
|
|
264
311
|
|
|
265
312
|
const slotCall = $(xslDom,'call-template[name="slot"]')
|
|
@@ -288,8 +335,9 @@ xhrTemplate(src)
|
|
|
288
335
|
// xhr.overrideMimeType("text/xml");
|
|
289
336
|
xhr.onload = () =>
|
|
290
337
|
{ if( xhr.readyState === xhr.DONE && xhr.status === 200 )
|
|
291
|
-
resolve( xhr.responseXML || create('div', xhr.responseText ) )
|
|
292
|
-
|
|
338
|
+
resolve( xhr.responseXML?.body || xhr.responseXML || create('div', xhr.responseText ) )
|
|
339
|
+
else
|
|
340
|
+
reject(`${xhr.statusText} - ${src}`)
|
|
293
341
|
};
|
|
294
342
|
xhr.addEventListener("error", ev=>reject(ev) );
|
|
295
343
|
|
|
@@ -372,7 +420,7 @@ event2slice( x, sliceNames, ev, dce )
|
|
|
372
420
|
s.append( obj2node(new FormData(el),'value', s.ownerDocument) )
|
|
373
421
|
return s
|
|
374
422
|
}
|
|
375
|
-
const v = el.value ?? attr(
|
|
423
|
+
const v = el.value ?? attr( el, 'value' ) ;
|
|
376
424
|
cleanSliceValue();
|
|
377
425
|
if( v === null || v === undefined )
|
|
378
426
|
[...s.childNodes].filter(n=>n.localName!=='event').map(n=>n.remove());
|
|
@@ -396,19 +444,27 @@ const loadTemplateRoots = async ( src, dce )=>
|
|
|
396
444
|
return [dce]
|
|
397
445
|
if( src.startsWith('#') )
|
|
398
446
|
return ( n =>
|
|
399
|
-
{
|
|
400
|
-
|
|
401
|
-
if( a.length )
|
|
402
|
-
return [...a]
|
|
403
|
-
const r = n.getRootNode();
|
|
404
|
-
return r===n ? []: getByHashId(r)
|
|
447
|
+
{ const a = n.querySelectorAll(src)
|
|
448
|
+
return [...( a.length ? a : n.getRootNode().querySelectorAll(src) )]
|
|
405
449
|
})(dce.parentElement)
|
|
406
450
|
try
|
|
407
|
-
{
|
|
408
|
-
|
|
409
|
-
|
|
451
|
+
{ const [path, hash] = src.split('#');
|
|
452
|
+
if( '.' === src.charAt(0))
|
|
453
|
+
src = new URL(path, dce.closest('[base]')?.getAttribute('base') || location ).href;
|
|
454
|
+
else
|
|
455
|
+
try
|
|
456
|
+
{ src = import.meta.resolve( path );
|
|
457
|
+
if(hash)
|
|
458
|
+
src +='#'+hash;
|
|
459
|
+
}
|
|
460
|
+
catch( e )
|
|
461
|
+
{ console.error(e.message) }
|
|
462
|
+
// todo cache
|
|
463
|
+
const dom = await xhrTemplate(src);
|
|
464
|
+
dce.setAttributeNS('xml', 'base', src );
|
|
465
|
+
|
|
410
466
|
if( hash )
|
|
411
|
-
{ const ret = dom.querySelectorAll(hash);
|
|
467
|
+
{ const ret = dom.querySelectorAll('#'+hash);
|
|
412
468
|
if( ret.length )
|
|
413
469
|
return [...ret]
|
|
414
470
|
return [dce]
|
|
@@ -454,8 +510,11 @@ export function appendByDceId(parent,e,k)
|
|
|
454
510
|
}
|
|
455
511
|
export function merge( parent, fromArr )
|
|
456
512
|
{
|
|
457
|
-
if(
|
|
458
|
-
return
|
|
513
|
+
if( 'dce-root' === parent.firstElementChild?.localName && 'dce-root' !== fromArr[0].localName)
|
|
514
|
+
return;
|
|
515
|
+
if( !fromArr.length )
|
|
516
|
+
return 'dce-root' !== parent.firstElementChild?.localName && removeChildren(parent);
|
|
517
|
+
|
|
459
518
|
const id2old = {};
|
|
460
519
|
for( let c of parent.childNodes)
|
|
461
520
|
{ ASSERT( !id2old[c.dceId] );
|
|
@@ -482,7 +541,8 @@ export function merge( parent, fromArr )
|
|
|
482
541
|
appendByDceId(parent,e,k)
|
|
483
542
|
}
|
|
484
543
|
for( let v of Object.values(id2old) )
|
|
485
|
-
v.
|
|
544
|
+
if( v.localName !== 'dce-root')
|
|
545
|
+
v.remove();
|
|
486
546
|
}
|
|
487
547
|
export function assureUID(n,attr)
|
|
488
548
|
{ if( !n.hasAttribute(attr) )
|
|
@@ -523,7 +583,7 @@ export const xPath = (x,root)=>
|
|
|
523
583
|
ret += n.textContent;
|
|
524
584
|
return ret
|
|
525
585
|
}
|
|
526
|
-
export const xslTags = 'stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,
|
|
586
|
+
export const xslTags = 'stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback'.split(',');
|
|
527
587
|
export const toXsl = (el, defParent) => {
|
|
528
588
|
const x = create('xsl:'+el.localName);
|
|
529
589
|
for( let a of el.attributes )
|
|
@@ -561,7 +621,13 @@ CustomElement extends HTMLElement
|
|
|
561
621
|
this.append(s);
|
|
562
622
|
})
|
|
563
623
|
const templateDocs = templateRoots.map( n => createXsltFromDom( n ) )
|
|
564
|
-
, xp = templateDocs.map( (td, p) =>
|
|
624
|
+
, xp = templateDocs.map( (td, p) =>
|
|
625
|
+
{ p = new XSLTProcessor();
|
|
626
|
+
try{ p.importStylesheet( td ) }
|
|
627
|
+
catch( e )
|
|
628
|
+
{ console.error(e, xmlString(td)) }
|
|
629
|
+
return p
|
|
630
|
+
})
|
|
565
631
|
|
|
566
632
|
Object.defineProperty( this, "xsltString", { get: ()=>templateDocs.map( td => xmlString(td) ).join('\n') });
|
|
567
633
|
|
|
@@ -725,13 +791,17 @@ CustomElement extends HTMLElement
|
|
|
725
791
|
applySlices();
|
|
726
792
|
}
|
|
727
793
|
#applyAttribute(name, newValue)
|
|
728
|
-
{
|
|
794
|
+
{ if( 'value' === name )
|
|
795
|
+
this.value = newValue;
|
|
796
|
+
let a = this.xml.querySelector(`attributes>${name}`);
|
|
729
797
|
if( a )
|
|
730
798
|
emptyNode(a).append( createText(a,newValue) );
|
|
731
799
|
else
|
|
732
800
|
{ a = create( name, newValue, this.xml );
|
|
733
801
|
this.xml.querySelector('attributes').append( a );
|
|
734
802
|
}
|
|
803
|
+
|
|
804
|
+
this.dispatchEvent(new CustomEvent('change', { bubbles: true,detail: { [name]: newValue }}))
|
|
735
805
|
}
|
|
736
806
|
attributeChangedCallback(name, oldValue, newValue)
|
|
737
807
|
{ if( !this.xml || this.#inTransform )
|
package/demo/a.svg
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<svg id="dwc-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216 209.18" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
2
|
+
<defs>
|
|
3
|
+
|
|
4
|
+
</defs>
|
|
5
|
+
<polygon class="cls-3" points="0 82.47 0 126.71 34.84 146.83 34.84 187.06 73.16 209.18 108 189.07 142.84 209.18 181.16 187.06 181.16 146.83 216 126.71 216 82.47 181.16 62.35 181.16 22.12 142.84 0 108 20.12 73.16 0 34.84 22.12 34.84 62.35 0 82.47"/>
|
|
6
|
+
<path class="cls-2" d="m114.33,56.69l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
7
|
+
<path class="cls-2" d="m98.19,62.71h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
8
|
+
<path class="cls-1" d="m48.12,66.01l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97Z"/>
|
|
9
|
+
<path class="cls-2" d="m46.18,24.66l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0s20.64-11.92,20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06Z"/>
|
|
10
|
+
<path class="cls-2" d="m115.87,24.66l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0s20.64-11.92,20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06Z"/>
|
|
11
|
+
<path class="cls-2" d="m152.65,42.59c-4.44,2.56-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0Z"/>
|
|
12
|
+
<path class="cls-2" d="m77.55,158.4l20.65-11.92h0c4.44-2.57,6.33-5.84,6.33-10.97v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92c-4.44,2.57-6.33,5.84-6.33,10.97h0s0,23.84,0,23.84c0,.54.45.8.92.54Z"/>
|
|
13
|
+
<path class="cls-4" d="m146.31,134.03v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0s0-23.84,0-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97Z"/>
|
|
14
|
+
<path class="cls-4" d="m63.35,123.06h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
15
|
+
<path class="cls-4" d="m103.61,151.37l-20.64,11.92c-4.44,2.57-6.33,5.84-6.33,10.97h0s0,23.84,0,23.84c0,.54.45.8.92.54l20.65-11.92h0c4.44-2.57,6.33-5.84,6.33-10.97v-23.84c0-.54-.45-.8-.92-.53Z"/>
|
|
16
|
+
<path class="cls-4" d="m63.35,163.29h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
17
|
+
<path class="cls-4" d="m28.51,102.94h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
18
|
+
<path class="cls-4" d="m133.04,163.29l-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84c0,5.13,1.89,8.4,6.33,10.97h0s20.65,11.92,20.65,11.92c.47.27.92,0,.92-.54v-23.84s0,0,0,0c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
19
|
+
<path class="cls-4" d="m173.29,151.37l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0s0-23.84,0-23.84c0-.54-.45-.8-.92-.53Z"/>
|
|
20
|
+
<path class="cls-4" d="m209.06,91.55c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84Z"/>
|
|
21
|
+
<path class="cls-2" d="m149.18,117.04l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
22
|
+
<path class="cls-1" d="m112.39,98.05l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54Z"/>
|
|
23
|
+
<path class="cls-1" d="m100.13,105.12c.47-.27.47-.79,0-1.06l-20.65-11.92c-4.44-2.57-8.22-2.57-12.67,0h0s-20.65,11.92-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92h0c4.44,2.57,8.22,2.57,12.67,0l20.64-11.92Z"/>
|
|
24
|
+
<path class="cls-2" d="m65.29,85.01c.47-.27.47-.79,0-1.06l-20.65-11.92c-4.44-2.57-8.22-2.57-12.67,0h0s-20.65,11.92-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92h0c4.44,2.57,8.22,2.57,12.67,0l20.64-11.92Z"/>
|
|
25
|
+
<path class="cls-1" d="m133.04,123.06l-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84c0,5.13,1.89,8.4,6.33,10.97h0s20.65,11.92,20.65,11.92c.47.27.92,0,.92-.54v-23.84s0,0,0,0c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
26
|
+
<path class="cls-1" d="m184.02,96.93l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
27
|
+
</svg>
|
package/demo/confused.svg
CHANGED
package/demo/demo.css
CHANGED
|
@@ -4,16 +4,19 @@ html
|
|
|
4
4
|
}
|
|
5
5
|
body,nav{ display: flex; flex-wrap: wrap; align-content: stretch; gap: 1rem; }
|
|
6
6
|
body>*{flex: auto;}
|
|
7
|
-
nav
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
{
|
|
7
|
+
nav
|
|
8
|
+
{ flex-direction: column;
|
|
9
|
+
dce-root{ box-shadow:none; padding: 0;}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
html-demo-element *:has(>dce-root){ box-shadow: 0 0 0.5rem lime; padding: 1rem; flex:1; display: block; }
|
|
13
|
+
script{ display:none !important; }
|
|
14
14
|
dd{ padding: 1rem;}
|
|
15
15
|
p{ margin: 0;}
|
|
16
|
-
|
|
16
|
+
code{ font-weight: bold; color: green; text-wrap: nowrap; }
|
|
17
|
+
*{
|
|
18
|
+
gap: 1rem;
|
|
19
|
+
}
|
|
17
20
|
|
|
18
21
|
html-demo-element h3
|
|
19
22
|
{ text-shadow: 0 0 0.25em white;
|
package/demo/embed-1.html
CHANGED
|
@@ -3,26 +3,61 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
5
|
<title>http-request Declarative Custom Element implementation demo</title>
|
|
6
|
-
|
|
6
|
+
<link rel="icon" href="./wc-square.svg"/>
|
|
7
7
|
|
|
8
8
|
<script type="module" src="../http-request.js"></script>
|
|
9
9
|
<script type="module" src="../custom-element.js"></script>
|
|
10
10
|
<style>
|
|
11
11
|
@import "./demo.css";
|
|
12
12
|
|
|
13
|
-
button
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
button {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
align-items: center;
|
|
17
|
+
flex: auto;
|
|
18
|
+
box-shadow: inset silver 0 0 1rem;
|
|
19
|
+
min-width: 12rem;
|
|
20
|
+
padding: 1rem;
|
|
21
|
+
color: coral;
|
|
22
|
+
text-shadow: 1px 1px silver;
|
|
23
|
+
font-weight: bolder;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
button img {
|
|
27
|
+
max-height: 10vw;
|
|
28
|
+
min-height: 4rem;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
table {
|
|
32
|
+
min-width: 16rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
td {
|
|
36
|
+
border-bottom: 1px solid silver;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
tfoot td {
|
|
40
|
+
border-bottom: none;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
td, th {
|
|
44
|
+
text-align: right;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
caption {
|
|
48
|
+
padding: 1rem;
|
|
49
|
+
font-weight: bolder;
|
|
50
|
+
font-family: sans-serif;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
code {
|
|
54
|
+
text-align: right;
|
|
55
|
+
min-width: 3rem;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
svg {
|
|
59
|
+
max-height: 3rem;
|
|
17
60
|
}
|
|
18
|
-
button img{ max-height: 10vw; min-height: 4rem;}
|
|
19
|
-
table{ min-width: 16rem; }
|
|
20
|
-
td{ border-bottom: 1px solid silver; }
|
|
21
|
-
tfoot td{ border-bottom: none; }
|
|
22
|
-
td,th{text-align: right; }
|
|
23
|
-
caption{ padding: 1rem; font-weight: bolder; font-family: sans-serif; }
|
|
24
|
-
code{ text-align: right; min-width: 3rem;}
|
|
25
|
-
svg{ max-height: 3rem;}
|
|
26
61
|
</style>
|
|
27
62
|
</head>
|
|
28
63
|
<body>
|
|
@@ -35,15 +70,16 @@
|
|
|
35
70
|
<html-demo-element legend="1. reference the template in page DOM"
|
|
36
71
|
description="should render hand wave with '👋 World!' and 'Hello World!'">
|
|
37
72
|
<template>
|
|
38
|
-
<template id="template1">
|
|
39
|
-
|
|
40
|
-
|
|
73
|
+
<template id="template1">
|
|
74
|
+
<slot> Hello</slot>
|
|
75
|
+
World!
|
|
76
|
+
</template>
|
|
41
77
|
|
|
42
|
-
<custom-element tag="dce-internal" src="#template1"></custom-element>
|
|
43
|
-
<!-- no need for loading fallback as the template exists -->
|
|
78
|
+
<custom-element tag="dce-internal" src="#template1"></custom-element>
|
|
79
|
+
<!-- no need for loading fallback as the template exists -->
|
|
44
80
|
|
|
45
|
-
<dce-internal>👋</dce-internal>
|
|
46
|
-
<dce-internal></dce-internal>
|
|
81
|
+
<dce-internal>👋</dce-internal>
|
|
82
|
+
<dce-internal></dce-internal>
|
|
47
83
|
</template>
|
|
48
84
|
</html-demo-element>
|
|
49
85
|
|
|
@@ -51,67 +87,67 @@
|
|
|
51
87
|
<html-demo-element legend="2. without TAG, inline instantiation"
|
|
52
88
|
description="hash value in SRC references template by ID. Should output 'construction' 2 times">
|
|
53
89
|
<template>
|
|
54
|
-
<template id="template2">
|
|
55
|
-
|
|
56
|
-
</template>
|
|
90
|
+
<template id="template2">
|
|
91
|
+
🏗️ construction
|
|
92
|
+
</template>
|
|
57
93
|
|
|
58
|
-
<custom-element src="#template2"></custom-element>
|
|
59
|
-
<custom-element src="#template2"></custom-element>
|
|
94
|
+
<custom-element src="#template2"></custom-element>
|
|
95
|
+
<custom-element src="#template2"></custom-element>
|
|
60
96
|
</template>
|
|
61
97
|
</html-demo-element>
|
|
62
98
|
|
|
63
|
-
<html-demo-element legend="3. external SVG file"
|
|
99
|
+
<html-demo-element legend="3. external SVG file">
|
|
64
100
|
<template>
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
101
|
+
<custom-element tag="dce-external" src="confused.svg">
|
|
102
|
+
<template><i>loading from SVG ...</i></template>
|
|
103
|
+
</custom-element>
|
|
104
|
+
<dce-external></dce-external>
|
|
105
|
+
<custom-element src="confused.svg">
|
|
106
|
+
<i>inline DCE loading from SVG ...</i>
|
|
107
|
+
</custom-element>
|
|
108
|
+
<custom-element src="no.svg">
|
|
109
|
+
<i>fallback for missing image</i>
|
|
110
|
+
</custom-element>
|
|
75
111
|
</template>
|
|
76
112
|
</html-demo-element>
|
|
77
113
|
|
|
78
114
|
<html-demo-element legend="4. external XSLT file"
|
|
79
115
|
description="This external templates generated the tree for DCE data set"
|
|
80
|
-
|
|
116
|
+
>
|
|
81
117
|
<a href="tree.xsl">tree.xsl</a>
|
|
82
118
|
<template>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
119
|
+
<custom-element tag="dce-external-4" src="tree.xsl">
|
|
120
|
+
<template><i>loading from XSLT ...</i></template>
|
|
121
|
+
</custom-element>
|
|
122
|
+
<dce-external-4 title="DCE with external XSLT template" data-fruit="🍌">Hi</dce-external-4>
|
|
123
|
+
<custom-element src="tree.xsl" data-smile="👼" data-basket="🍒">
|
|
124
|
+
<i>inline DCE loading from XSLT ...</i>
|
|
125
|
+
</custom-element>
|
|
90
126
|
</template>
|
|
91
127
|
</html-demo-element>
|
|
92
128
|
|
|
93
129
|
<html-demo-element legend="5. external HTML template" description="Should render 👋👌, svg, formula">
|
|
94
130
|
<template>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
131
|
+
<custom-element tag="dce-external-5" src="html-template.html">
|
|
132
|
+
<template><i>loading from HTML file ...</i></template>
|
|
133
|
+
</custom-element>
|
|
134
|
+
<dce-external-5 title="DCE with external XSLT template" data-fruit="🍌">Hi</dce-external-5>
|
|
135
|
+
<custom-element src="html-template.html" data-smile="👼" data-basket="🍒">
|
|
136
|
+
<i>inline DCE loading from HTML file ...</i>
|
|
137
|
+
</custom-element>
|
|
102
138
|
</template>
|
|
103
139
|
</html-demo-element>
|
|
104
140
|
|
|
105
141
|
<html-demo-element legend="6. HTML, SVG by ID within external file" description="Should render 👋, svg, formula">
|
|
106
142
|
<a href="html-template.html">html-template.html</a>
|
|
107
143
|
<template>
|
|
108
|
-
<custom-element src="html-template.html#wave"
|
|
144
|
+
<custom-element src="./html-template.html#wave">
|
|
109
145
|
<template><i>loading HTML from templates file ...</i></template>
|
|
110
146
|
</custom-element>
|
|
111
|
-
<custom-element src="html-template.html#dwc-logo"
|
|
112
|
-
<template><i>loading
|
|
147
|
+
<custom-element src="./html-template.html#dwc-logo">
|
|
148
|
+
<template><i>loading SVG from templates file ...</i></template>
|
|
113
149
|
</custom-element>
|
|
114
|
-
<custom-element src="html-template.html#sophomores-dream"
|
|
150
|
+
<custom-element src="./html-template.html#sophomores-dream">
|
|
115
151
|
<template><i>loading MathML from HTML file ...</i></template>
|
|
116
152
|
</custom-element>
|
|
117
153
|
</template>
|
|
@@ -119,10 +155,10 @@
|
|
|
119
155
|
<html-demo-element legend="7. XSLT by ID within external file" description="Should render tree, and fallback">
|
|
120
156
|
<a href="html-template.html">html-template.html</a>
|
|
121
157
|
<template>
|
|
122
|
-
<custom-element src="html-template.xhtml#embedded-xsl"
|
|
123
|
-
<template>whole XSLT is
|
|
158
|
+
<custom-element src="html-template.xhtml#embedded-xsl">
|
|
159
|
+
<template>whole XSLT is embedded into HTML body</template>
|
|
124
160
|
</custom-element>
|
|
125
|
-
|
|
161
|
+
<custom-element src="html-template.html#none">
|
|
126
162
|
<template><i>element with id=none is missing in template</i></template>
|
|
127
163
|
</custom-element>
|
|
128
164
|
</template>
|
|
@@ -132,13 +168,37 @@
|
|
|
132
168
|
description="Should render Vulcan Salute 🖖"
|
|
133
169
|
>
|
|
134
170
|
<template>
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
171
|
+
<custom-element src="embed-1.html">
|
|
172
|
+
loading from embed-1.html ...
|
|
173
|
+
</custom-element>
|
|
174
|
+
</template>
|
|
175
|
+
</html-demo-element>
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
<html-demo-element legend="9. external file with invoking of relative template as hash by enclosed custom-element"
|
|
179
|
+
description="Should render Vulcan Salute 🖖"
|
|
180
|
+
>
|
|
181
|
+
<template>
|
|
182
|
+
<custom-element src="./lib-dir/embed-lib.html#embed-relative-hash">
|
|
183
|
+
loading from embed-1.html ...
|
|
184
|
+
</custom-element>
|
|
138
185
|
</template>
|
|
139
186
|
</html-demo-element>
|
|
140
|
-
|
|
187
|
+
|
|
188
|
+
<html-demo-element
|
|
189
|
+
legend="10. external file with invoking of template in another relative path file by enclosed custom-element"
|
|
190
|
+
description="Should render Vulcan Salute 🖖"
|
|
191
|
+
>
|
|
192
|
+
<template>
|
|
193
|
+
<custom-element src="./lib-dir/embed-lib.html#embed-relative-file">
|
|
194
|
+
loading from ./lib-dir/embed-lib.html ...
|
|
195
|
+
</custom-element>
|
|
196
|
+
</template>
|
|
141
197
|
</html-demo-element>
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
<html-demo-element legend="embed-1.html external file" src="embed-1.html"></html-demo-element>
|
|
201
|
+
<html-demo-element legend="embed-lib.html with multiple templates" src="embed-lib.html"></html-demo-element>
|
|
142
202
|
<!--
|
|
143
203
|
<html-demo-element legend="9. deep external files, complex rendering" >
|
|
144
204
|
<template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
|
2
|
+
<!DOCTYPE svg>
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" baseProfile="full" viewBox="-21 -21 42 42">
|
|
4
|
+
<defs>
|
|
5
|
+
<radialGradient id="b" cx=".2" cy=".2" r=".5" fx=".2" fy=".2">
|
|
6
|
+
<stop offset="0" stop-color="#fff" stop-opacity=".7"/>
|
|
7
|
+
<stop offset="1" stop-color="#fff" stop-opacity="0"/>
|
|
8
|
+
</radialGradient>
|
|
9
|
+
<radialGradient id="a" cx=".5" cy=".5" r=".5">
|
|
10
|
+
<stop offset="0" stop-color="#ff0"/>
|
|
11
|
+
<stop offset=".75" stop-color="#ff0"/>
|
|
12
|
+
<stop offset=".95" stop-color="#ee0"/>
|
|
13
|
+
<stop offset="1" stop-color="#e8e800"/>
|
|
14
|
+
</radialGradient>
|
|
15
|
+
</defs>
|
|
16
|
+
<circle r="20" fill="url(#a)" stroke="#000" stroke-width=".15"/>
|
|
17
|
+
<circle r="20" fill="url(#b)"/>
|
|
18
|
+
<g id="c">
|
|
19
|
+
<ellipse cx="-6" cy="-7" rx="2.5" ry="4"/>
|
|
20
|
+
<path fill="none" stroke="#000" stroke-linecap="round" stroke-width=".5" d="M10.6 2.7a4 4 0 0 0 4 3"/>
|
|
21
|
+
</g>
|
|
22
|
+
<use xlink:href="#c" transform="scale(-1 1)"/>
|
|
23
|
+
<path fill="none" stroke="#000" stroke-width=".75" d="M-12 5a13.5 13.5 0 0 0 24 0 13 13 0 0 1-24 0"/>
|
|
24
|
+
</svg>
|