@epa-wg/custom-element 0.0.27 → 0.0.29

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 CHANGED
@@ -341,16 +341,16 @@ within template
341
341
  [css-demo-url]: https://unpkg.com/@epa-wg/custom-element@0.0/demo/scoped-css.html
342
342
  [slice-demo-url]: https://unpkg.com/@epa-wg/custom-element@0.0/demo/data-slices.html
343
343
  [hex-grid-url]: https://unpkg.com/@epa-wg/custom-element@0.0/demo/hex-grid.html
344
- [hex-grid-image]: demo/hex-grid-transform.png
344
+ [hex-grid-image]: https://unpkg.com/@epa-wg/custom-element@0.0.29/demo/hex-grid-transform.png
345
345
  [local-storage-demo]: https://unpkg.com/@epa-wg/custom-element@0.0/demo/local-storage.html
346
346
  [http-request-demo]: https://unpkg.com/@epa-wg/custom-element@0.0/demo/http-request.html
347
347
  [location-demo]: https://unpkg.com/@epa-wg/custom-element@0.0/demo/location.html
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.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
351
+ [coverage-image]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.29/coverage/src/custom-element/coverage.svg
352
+ [coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.29/coverage/src/custom-element/index.html
353
+ [storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.29/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
@@ -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.27",
119
+ "version": "0.0.29",
120
120
  "js-types-syntax": "typescript",
121
121
  "description-markup": "markdown",
122
122
  "contributions": {
package/custom-element.js CHANGED
@@ -72,6 +72,12 @@ assureSlot( e )
72
72
  }
73
73
  return e;
74
74
  }
75
+ function
76
+ keepAttributes(e, aNames)
77
+ { e.getAttributeNames().forEach( n=> aNames.includes(n) || e.removeAttribute(n) ); }
78
+
79
+ export const
80
+ sanitizeBlankText = payload=> [...payload].filter(e=>!(e.nodeType===3 && e.data.trim() ==='' ));
75
81
 
76
82
  export function
77
83
  obj2node( o, tag, doc )
@@ -181,17 +187,26 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
181
187
  </dce-text>
182
188
  </xsl:template>
183
189
  <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>
190
+ <xsl:copy>
191
+ <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
192
+ </xsl:copy>
189
193
  </xsl:template>
190
194
  <xsl:template mode="sanitize" match="xhtml:*">
191
195
  <xsl:element name="{local-name()}">
192
196
  <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
193
197
  </xsl:element>
194
198
  </xsl:template>
199
+ <xsl:template mode="sanitize" match="xhtml:input">
200
+ <xsl:element name="{local-name()}">
201
+ <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
202
+ </xsl:element>
203
+ <xsl:for-each select="*">
204
+ <xsl:copy>
205
+ <xsl:attribute name="for" >^</xsl:attribute>
206
+ <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
207
+ </xsl:copy>
208
+ </xsl:for-each>
209
+ </xsl:template>
195
210
  </xsl:stylesheet>`)
196
211
  const sanitizeProcessor = new XSLTProcessor()
197
212
  , tc = (n =>
@@ -273,9 +288,11 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
273
288
  const params = [];
274
289
  [...fr.querySelectorAll('dce-root>attribute')].forEach( a=>
275
290
  {
291
+ keepAttributes(a,'namespace,name,select');
276
292
  const p = cloneAs(a,'xsl:param')
277
293
  , name = attr(a,'name');
278
294
  payload.append(p);
295
+ keepAttributes(p,'select,name');
279
296
  let select = attr(p,'select')?.split('??')
280
297
  if( !select)
281
298
  { select = ['//'+name, `'${p.textContent}'`];
@@ -283,8 +300,8 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
283
300
  p.setAttribute('name',name);
284
301
  }
285
302
  let val;
286
- if( select?.length>1 ){
287
- p.removeAttribute('select');
303
+ if( select?.length>1 )
304
+ { p.removeAttribute('select');
288
305
  const c = $( xslDom, 'template[match="ignore"]>choose').cloneNode(true);
289
306
  emptyNode(c.firstElementChild).append( createText(c,'{'+select[0]+'}'));
290
307
  emptyNode(c.lastElementChild ).append( createText(c,'{'+select[1]+'}'));
@@ -317,7 +334,7 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
317
334
  for( let c of s.childNodes)
318
335
  v.lastElementChild.append(c)
319
336
  return v
320
- }
337
+ };
321
338
 
322
339
  forEach$( payload,'slot', s => s.parentNode.replaceChild( slot2xsl(s), s ) )
323
340
 
@@ -466,7 +483,8 @@ const loadTemplateRoots = async ( src, dce )=>
466
483
  if( hash )
467
484
  { const ret = dom.querySelectorAll('#'+hash);
468
485
  if( ret.length )
469
- return [...ret]
486
+ return [...ret];
487
+ console.error('template not found',src+'#'+hash);
470
488
  return [dce]
471
489
  }
472
490
  return [dom]
@@ -609,6 +627,8 @@ CustomElement extends HTMLElement
609
627
  static observedAttributes = ['src','tag','hidden'];
610
628
  async connectedCallback()
611
629
  {
630
+ if(this.firstElementChild && this.firstElementChild.localName !== 'template')
631
+ console.warn('custom-element used without template wrapping content\n', this.outerHTML);
612
632
  const templateRoots = await loadTemplateRoots( attr( this, 'src' ), this )
613
633
  , tag = attr( this, 'tag' )
614
634
  , tagName = tag ? tag : 'dce-'+crypto.randomUUID();
@@ -644,16 +664,16 @@ CustomElement extends HTMLElement
644
664
  static get observedAttributes(){ return declaredAttributes.map( a=>attr(a,'name')); }
645
665
  #inTransform = 0;
646
666
  connectedCallback()
647
- { let payload = this.childNodes;
667
+ { let payload = sanitizeBlankText(this.childNodes);
648
668
  if( this.firstElementChild?.tagName === 'TEMPLATE' )
649
669
  {
650
670
  if( this.firstElementChild !== this.lastElementChild )
651
671
  { console.error('payload should have TEMPLATE as only child', this.outerHTML ) }
652
672
  const t = this.firstElementChild;
653
673
  t.remove();
654
- payload = t.content.childNodes;
674
+ payload = sanitizeBlankText(t.content.childNodes);
655
675
 
656
- for( const n of [...t.content.childNodes] )
676
+ for( const n of payload )
657
677
  if( n.localName === 'style' ){
658
678
  const id = assureUID(this,'data-dce-style')
659
679
  n.innerHTML= `${tagName}[data-dce-style="${id}"]{${n.innerHTML}}`;
@@ -728,18 +748,39 @@ CustomElement extends HTMLElement
728
748
  }
729
749
  })
730
750
 
751
+ function getSliceTarget(el)
752
+ { let r = el;
753
+ if( el.localName === 'slice')
754
+ { const ref= attr(el,'for');
755
+ if( !ref )
756
+ r = el.parentElement;
757
+ if( '^' === ref )
758
+ { do r = r.previousElementSibling;
759
+ while( r.localName === 'slice' )
760
+ } else
761
+ r = this.querySelector(ref)
762
+
763
+ if( !r )
764
+ return console.warn(`can not find selector in "slice for=${ref}" `, el.outerHTML);
765
+ attr(el,'slice') || el.setAttribute('slice', attr(el,'name'))
766
+ }
767
+ return r;
768
+ }
731
769
  forEach$( this,'[slice],[slice-event]', el =>
732
- { if( !el.dceInitialized )
770
+ { let evs = attr(el,'slice-event');
771
+ const sVal = el.hasAttribute('slice-value') || el.hasAttribute('value') || el.value;
772
+ const tgt = getSliceTarget(el);
773
+ if( !el.dceInitialized )
733
774
  { el.dceInitialized = 1;
734
- let evs = attr(el,'slice-event');
735
- if( el.hasAttribute('custom-validity') )
775
+ if( tgt.hasAttribute('custom-validity') )
736
776
  evs += ' change submit';
737
777
 
738
778
  [...new Set((evs || 'change') .split(' '))]
739
- .forEach( t=> (el.localName==='slice'? el.parentElement : el)
740
- .addEventListener( t, ev=>
779
+ .forEach( t=>
780
+ tgt.addEventListener( t, ev=>
741
781
  { ev.sliceElement = el;
742
782
  ev.sliceEventSource = ev.currentTarget || ev.target;
783
+ ev.sliceProcessed = 0;
743
784
  const slices = event2slice( sliceRoot, attr( ev.sliceElement, 'slice'), ev, this );
744
785
 
745
786
  forEach$(this,'[custom-validity]',el =>
@@ -752,7 +793,7 @@ CustomElement extends HTMLElement
752
793
  }catch(err)
753
794
  { console.error(err, 'xPath', x) }
754
795
  })
755
- const x = attr(el,'custom-validity')
796
+ const x = attr(tgt,'custom-validity')
756
797
  , v = x && xPath( x, attrsRoot )
757
798
  , msg = v === true? '' : v;
758
799
 
@@ -778,8 +819,8 @@ CustomElement extends HTMLElement
778
819
  this.onSlice(ev);
779
820
  } ));
780
821
  if( !evs || evs.includes('init') )
781
- { if( el.hasAttribute('slice-value') || el.hasAttribute('value') || el.value )
782
- this.onSlice({type:'init', target: el, sliceElement:el, sliceEventSource:el })
822
+ { if( sVal )
823
+ this.onSlice({type:'init', target: tgt, sliceElement:el, sliceEventSource:tgt })
783
824
  else
784
825
  el.value = sliceXPath( attr(el,'slice') )
785
826
  }
package/demo/demo.css CHANGED
@@ -14,9 +14,6 @@ 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
- }
20
17
 
21
18
  html-demo-element h3
22
19
  { text-shadow: 0 0 0.25em white;
package/demo/s.xml CHANGED
@@ -1,3 +1,18 @@
1
- <body xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><h4>embed-1.html</h4>
2
- <custom-element><template>🖖</template></custom-element>
3
- </body>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <datadom>
3
+ <payload xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
4
+ <a xmlns="http://www.w3.org/1999/xhtml" href="#" data-dce-id="4" slot="">link 1</a>
5
+ <a xmlns="http://www.w3.org/1999/xhtml" href="#" data-dce-id="5" slot="">link 2</a>
6
+ <a xmlns="http://www.w3.org/1999/xhtml" href="#" data-dce-id="6" slot="">link 3</a>
7
+ </payload>
8
+ <attributes>
9
+ <xmlns/>
10
+ <justify>end</justify>
11
+ <data-dce-id>2</data-dce-id>
12
+ <direction>row</direction>
13
+ </attributes>
14
+ <dataset>
15
+ <dceId>2</dceId>
16
+ </dataset>
17
+ <slice/>
18
+ </datadom>
package/demo/s.xslt CHANGED
@@ -1,56 +1,39 @@
1
- <?xml version='1.0' encoding='UTF-8'?>
2
- <xsl:stylesheet version="1.0"
3
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4
- xmlns:xhtml="http://www.w3.org/1999/xhtml"
5
- >
6
- <xsl:output method="xml"/>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <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
+ <xsl:template match="ignore">
4
+ <xsl:choose>
5
+ <xsl:when test="//attr"><xsl:value-of select="//attr"/></xsl:when>
6
+ <xsl:otherwise><xsl:value-of select="def"/></xsl:otherwise>
7
+ </xsl:choose><xsl:value-of select="."/></xsl:template>
8
+ <xsl:template mode="payload" match="attributes"><xsl:param name="direction"><xsl:choose>
9
+ <xsl:when test="//direction"><xsl:value-of select="//direction"/></xsl:when>
10
+ <xsl:otherwise><xsl:value-of select="'row'"/></xsl:otherwise>
11
+ </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 name="direction"><xsl:choose>
12
+ <xsl:when test="//direction"><xsl:value-of select="//direction"/></xsl:when>
13
+ <xsl:otherwise><xsl:value-of select="'row'"/></xsl:otherwise>
14
+ </xsl:choose></xsl:attribute><xsl:call-template name="slot">
15
+ <xsl:with-param name="slotname" select="''"/>
16
+ <xsl:with-param name="defaultvalue"/>
17
+ </xsl:call-template></dce-root></xsl:template>
7
18
  <xsl:template match="/">
8
- <dce-root >
9
- <xsl:apply-templates select="*"/>
10
- </dce-root>
11
- </xsl:template>
12
- <xsl:template match="*[name()='template']">
13
- <xsl:apply-templates mode="sanitize" select="*|text()"/>
14
- </xsl:template>
15
- <xsl:template match="*">
16
- <xsl:apply-templates mode="sanitize" select="*|text()"/>
17
- </xsl:template>
18
- <xsl:template match="*[name()='svg']|*[name()='math']">
19
- <xsl:apply-templates mode="sanitize" select="."/>
20
- </xsl:template>
21
- <xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]">
22
- <xsl:copy>
23
- <xsl:apply-templates mode="sanitize" select="@*"/>
24
- <xsl:value-of select="text()"></xsl:value-of>
25
- </xsl:copy>
26
- </xsl:template>
27
- <xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]">
28
- <xsl:element name="{local-name()}">
29
- <xsl:apply-templates mode="sanitize" select="@*"/>
30
- <xsl:value-of select="text()"></xsl:value-of>
31
- </xsl:element>
32
- </xsl:template>
33
- <xsl:template mode="sanitize" match="*|@*">
34
- <xsl:copy>
35
- <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
36
- </xsl:copy>
37
- </xsl:template>
38
- <xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
39
- <xsl:template mode="sanitize" match="text()">
40
- <dce-text>
41
- <xsl:copy/>
42
- </dce-text>
43
- </xsl:template>
44
- <xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']">
45
- <dce-text>
46
- <xsl:copy>
47
- <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
48
- </xsl:copy>
49
- </dce-text>
50
- </xsl:template>
51
- <xsl:template mode="sanitize" match="xhtml:*">
52
- <xsl:element name="{local-name()}">
53
- <xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
54
- </xsl:element>
55
- </xsl:template>
19
+ <xsl:apply-templates mode="payload" select="/datadom/attributes"/>
20
+ </xsl:template>
21
+ <xsl:template name="slot">
22
+ <xsl:param name="slotname"/>
23
+ <xsl:param name="defaultvalue"/>
24
+ <xsl:choose>
25
+ <xsl:when test="//payload/*[@slot=$slotname]">
26
+ <xsl:copy-of select="//payload/*[@slot=$slotname]"/>
27
+ </xsl:when>
28
+ <xsl:otherwise>
29
+ <xsl:copy-of select="$defaultvalue"/>
30
+ </xsl:otherwise>
31
+ </xsl:choose>
32
+ </xsl:template>
33
+ <xsl:variable name="js-injected-body">
34
+ <xsl:call-template name="slot">
35
+ <xsl:with-param name="slotname" select="''"/>
36
+ <xsl:with-param name="defaultvalue"/>
37
+ </xsl:call-template>
38
+ </xsl:variable>
56
39
  </xsl:stylesheet>
package/demo/ss.html CHANGED
@@ -1,57 +1,24 @@
1
- <dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:dce="urn:schemas-epa-wg:dce" data-dce-id="1"><http-request xmlns="" url="/reflect" slice="page" data-dce-id="2"></http-request><p xmlns="" data-dce-id="3">Pokemon Count: 6</p>
2
- <ul xmlns="" data-dce-id="6">
3
- <var data-testid="request-section" data-dce-id="7"><dce-text data-dce-id="8">request</dce-text></var><div data-dce-id="9">
4
- <var data-dce-id="10">@url</var><dce-text data-dce-id="11">
5
- =
6
- </dce-text><code data-testid="attr-url" data-dce-id="12">/reflect</code>
7
- </div>
8
- <div data-dce-id="9-1">
9
- <var data-dce-id="10">@data-dce-id</var><dce-text data-dce-id="11">
10
- =
11
- </dce-text><code data-testid="attr-data-dce-id" data-dce-id="12">2</code>
12
- </div>
13
- </ul>
14
- <ul xmlns="" data-dce-id="6-1">
15
- <var data-testid="request-section" data-dce-id="7"><dce-text data-dce-id="8">response</dce-text></var><div data-dce-id="9">
16
- <var data-dce-id="10">@ok</var><dce-text data-dce-id="11">
17
- =
18
- </dce-text><code data-testid="attr-ok" data-dce-id="12">true</code>
19
- </div>
20
- <div data-dce-id="9-1">
21
- <var data-dce-id="10">@status</var><dce-text data-dce-id="11">
22
- =
23
- </dce-text><code data-testid="attr-status" data-dce-id="12">200</code>
24
- </div>
25
- <div data-dce-id="9-2">
26
- <var data-dce-id="10">@statusText</var><dce-text data-dce-id="11">
27
- =
28
- </dce-text><code data-testid="attr-statusText" data-dce-id="12">OK</code>
29
- </div>
30
- <div data-dce-id="9-3">
31
- <var data-dce-id="10">@type</var><dce-text data-dce-id="11">
32
- =
33
- </dce-text><code data-testid="attr-type" data-dce-id="12">basic</code>
34
- </div>
35
- <div data-dce-id="9-4">
36
- <var data-dce-id="10">@url</var><dce-text data-dce-id="11">
37
- =
38
- </dce-text><code data-testid="attr-url" data-dce-id="12">http://localhost:5173/reflect</code>
39
- </div>
40
- <div data-dce-id="9-5">
41
- <var data-dce-id="10">@redirected</var><dce-text data-dce-id="11">
42
- =
43
- </dce-text><code data-testid="attr-redirected" data-dce-id="12">false</code>
44
- </div>
45
- </ul><button xmlns="" data-dce-id="5">bulbasaur</button><button xmlns="" data-dce-id="5-1">ivysaur</button><button xmlns="" data-dce-id="5-2">venusaur</button><button xmlns="" data-dce-id="5-3">charmander</button><button xmlns="" data-dce-id="5-4">charmeleon</button><button xmlns="" data-dce-id="5-5">charizard</button>
46
- <ul xmlns="" data-dce-id="6-2">
47
- <var data-testid="request-section" data-dce-id="7"><dce-text data-dce-id="8">data</dce-text></var><div data-dce-id="9">
48
- <var data-dce-id="10">@count</var><dce-text data-dce-id="11">
49
- =
50
- </dce-text><code data-testid="attr-count" data-dce-id="12">1279</code>
51
- </div>
52
- <div data-dce-id="9-1">
53
- <var data-dce-id="10">@next</var><dce-text data-dce-id="11">
54
- =
55
- </dce-text><code data-testid="attr-next" data-dce-id="12">https://pokeapi.co/api/v2/pokemon?offset=6&amp;limit=6</code>
56
- </div>
57
- </ul></dce-root>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <dce-root data-dce-id="1" label="Number" name="" placeholder="Enter the numeric value" type="text" value=""
3
+ xmlns="http://www.w3.org/1999/xhtml" xmlns:dce="urn:schemas-epa-wg:dce"
4
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"><pre data-dce-id="2" xmlns=""> //focused
5
+ //suggest
6
+ //selected
7
+ $selected-value </pre>
8
+ <label data-dce-id="3">
9
+ <dce-text data-dce-id="4">Number</dce-text>
10
+ <input data-dce-id="5" name="" placeholder="Enter the numeric value" type="text" value="">
11
+ <slice data-dce-id="6" name="focused" slice-event="focus" slice-value="1"/>
12
+ <slice data-dce-id="7" name="selected" slice-event="input"/>
13
+ </input></label>
14
+ <fieldset data-dce-id="8" form="cem-autocomplete-form" xmlns=""><label data-dce-id="9" value="one"><input
15
+ data-dce-id="10" name="cem-autocomplete" slice="suggest" slice-event="input" type="radio" value="one"/>
16
+ <dce-text data-dce-id="11">One</dce-text>
17
+ </label><label data-dce-id="9" value="two"><input data-dce-id="10" name="cem-autocomplete" slice="suggest" slice-event="input"
18
+ type="radio" value="two"/>
19
+ <dce-text data-dce-id="11">Two</dce-text>
20
+ </label><label data-dce-id="9" value="three"><input data-dce-id="10" name="cem-autocomplete" slice="suggest"
21
+ slice-event="input" type="radio" value="three"/>
22
+ <dce-text data-dce-id="11">Three</dce-text>
23
+ </label></fieldset>
24
+ </dce-root>
@@ -0,0 +1,7 @@
1
+ # transformation lifecycle
2
+
3
+ # embedded CE rendering
4
+
5
+ * render outer CE
6
+ * render inner CE
7
+ *
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/web-types",
3
3
  "name": "@epa-wg/custom-element",
4
- "version": "0.0.27",
4
+ "version": "0.0.29",
5
5
  "js-types-syntax": "typescript",
6
6
  "description-markup": "markdown",
7
7
  "contributions": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "http://json.schemastore.org/web-types",
3
3
  "name": "@epa-wg/custom-element",
4
- "version": "0.0.27",
4
+ "version": "0.0.29",
5
5
  "js-types-syntax": "typescript",
6
6
  "description-markup": "markdown",
7
7
  "contributions": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@epa-wg/custom-element",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
4
  "description": "Declarative Custom Element as W3C proposal PoC with native(XSLT) based templating",
5
5
  "browser": "custom-element.js",
6
6
  "module": "custom-element.js",
package/demo/a.html DELETED
@@ -1,60 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
- <title>Data slices - Declarative Custom Element implementation demo</title>
6
- <link rel="icon" href="./wc-square.svg"/>
7
-
8
- <script type="module" src="../http-request.js"></script>
9
- <script type="module" src="../custom-element.js"></script>
10
- <style>
11
- @import "./demo.css";
12
-
13
- label {
14
- display: flex;
15
- }
16
-
17
- label:has(input[type="text"],input[type="password"],input:not([type]) ) {
18
- flex-direction: column;
19
- }
20
-
21
- nav {
22
- max-width: 32em;
23
- }
24
- </style>
25
- <!-- https://github.com/mdn/learning-area/blob/main/html/forms/form-validation/custom-error-message.html
26
- todo: apply setCustomValidity( warningStr )
27
- -->
28
-
29
- </head>
30
- <body>
31
-
32
- <fieldset>
33
- <legend><b style="color:green">green</b> in instance style can be overridden in payload as <i
34
- style="color:red">red</i> in 1st instance
35
- </legend>
36
- <custom-element tag="dce-3">
37
- <template>
38
- <u>
39
- <slot>is green</slot>
40
- </u>
41
- </template>
42
- <style>dce-3 {
43
- color: green
44
- }</style>
45
- </custom-element>
46
- <u>should be</u> <i style="color:red">red</i>:
47
- <dce-3 id="dce32">
48
- <template>
49
- <style> color:red; </style>
50
- <u>red</u>
51
- </template>
52
- </dce-3> <br/>
53
- should be GREEN:
54
- <dce-3 id="dce31">green</dce-3>
55
- </fieldset>
56
-
57
- <script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
58
-
59
- </body>
60
- </html>
package/demo/a.svg DELETED
@@ -1,27 +0,0 @@
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/b.html DELETED
@@ -1,13 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <dce-root data-dce-id="1" xmlns="http://www.w3.org/1999/xhtml" xmlns:dce="urn:schemas-epa-wg:dce"
3
- xmlns:xhtml="http://www.w3.org/1999/xhtml"><u data-dce-id="2" xmlns="">
4
- <dce-text data-dce-id="3">
5
- <xhtml:span xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot=""/>
6
- <xhtml:style xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot="" title="ABC">
7
- dce-3[data-dce-style="54f96d52-ce70-435d-83c4-b421357d9a17"]{ color:red; }
8
- </xhtml:style>
9
- <xhtml:span xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot=""/>
10
- <xhtml:u xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot="">red</xhtml:u>
11
- <xhtml:span xmlns:xsl="http://www.w3.org/1999/XSL/Transform" slot=""/>
12
- </dce-text>
13
- </u></dce-root>
Binary file
Binary file
package/demo/s1.xslt DELETED
@@ -1,60 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml"
3
- xmlns:dce="urn:schemas-epa-wg:dce" xmlns:exsl="http://exslt.org/common" version="1.0"
4
- exclude-result-prefixes="exsl">
5
- <xsl:template match="ignore">
6
- <xsl:choose>
7
- <xsl:when test="//attr">
8
- <xsl:value-of select="//attr"/>
9
- </xsl:when>
10
- <xsl:otherwise>
11
- <xsl:value-of select="def"/>
12
- </xsl:otherwise>
13
- </xsl:choose>
14
- <xsl:value-of select="."/>
15
- </xsl:template>
16
- <xsl:template mode="payload" match="attributes">
17
- <dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" data-dce-id="1">
18
- <u xmlns="" data-dce-id="2">
19
- <dce-text data-dce-id="3">
20
- <xsl:call-template name="slot">
21
- <xsl:with-param name="slotname" select="''"/>
22
- <xsl:with-param name="defaultvalue">
23
- <dce-text xmlns="" data-dce-id="4">is green</dce-text>
24
- </xsl:with-param>
25
- </xsl:call-template>
26
- </dce-text>
27
- </u>
28
- </dce-root>
29
- </xsl:template>
30
- <xsl:template match="/">
31
- <xsl:apply-templates mode="payload" select="/datadom/attributes"/>
32
- </xsl:template>
33
-
34
- <xsl:template match="@*|node()" mode="copy-html">
35
- <xsl:copy><xsl:apply-templates select="@*|node()" mode="copy-html"/></xsl:copy>
36
- </xsl:template>
37
- <xsl:template match="node()[starts-with(name(),'xhtml:')]" mode="copy-html">
38
- <xsl:element name="{local-name()}"><xsl:apply-templates select="@*|node()" mode="copy-html"/></xsl:element>
39
- </xsl:template>
40
-
41
-
42
- <xsl:template name="slot">
43
- <xsl:param name="slotname"/>
44
- <xsl:param name="defaultvalue"/>
45
- <xsl:choose>
46
- <xsl:when test="//payload/*[@slot=$slotname]">
47
- <xsl:apply-templates mode="copy-html" select="//payload/*[@slot=$slotname]"/>
48
- </xsl:when>
49
- <xsl:otherwise>
50
- <xsl:apply-templates mode="copy-html" select="$defaultvalue"/>
51
- </xsl:otherwise>
52
- </xsl:choose>
53
- </xsl:template>
54
- <xsl:variable name="js-injected-body">
55
- <xsl:call-template name="slot">
56
- <xsl:with-param name="slotname" select="''"/>
57
- <xsl:with-param name="defaultvalue"/>
58
- </xsl:call-template>
59
- </xsl:variable>
60
- </xsl:stylesheet>
package/demo/z.html DELETED
@@ -1,33 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
- <title>DOM merge - Declarative Custom Element implementation demo</title>
6
- <link rel="icon" href="./wc-square.svg"/>
7
- <script type="importmap">
8
- {
9
- "imports": {
10
- "@epa-wg/custom-element/": "../",
11
- "@epa-wg/custom-element-dist/": "../"
12
- }
13
- }
14
- </script>
15
- <script type="module" src="../http-request.js"></script>
16
- <script type="module" src="../location-element.js"></script>
17
- <script type="module" src="../custom-element.js"></script>
18
- <style>
19
- @import "./demo.css";
20
- dt{ font-weight: bold}
21
- dd{ padding: 0;}
22
- h1,h3{ margin: 0;}
23
- nav{ gap:0; }
24
- </style>
25
- </head>
26
- <body>
27
-
28
- <custom-element src="./html-template.html#dwc-logo">
29
- <template><i>loading SVG from templates file ...</i></template>
30
- </custom-element>
31
-
32
- </body>
33
- </html>
package/demo/z.js DELETED
@@ -1,9 +0,0 @@
1
- import circle from "circle";
2
- import circle2 from "lib-root/circle.js";
3
- console.log(circle())
4
- try{
5
-
6
- console.log(import.meta.resolve('lib-root/a.js'))
7
- }catch( err ){
8
- console.error(err.message)
9
- }
package/demo/z.xml DELETED
@@ -1,60 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <dce-root data-dce-id="1" xmlns:dce="urn:schemas-epa-wg:dce" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
- <location-element slice="window-url" data-dce-id="2"/>
4
- <table data-dce-id="3">
5
- <tr data-dce-id="4">
6
- <th data-dce-id="5">
7
- <u data-dce-id="6">URL properties</u>
8
- </th>
9
- </tr>
10
- <tr data-dce-id="7">
11
- <th data-dce-id="8">href</th>
12
- <td data-dce-id="9">http://localhost:63342/custom-element/demo/a.html?_ijt=qca6trk5kne6eo4s4tomq4egmm&amp;_ij_reload=RELOAD_ON_SAVE</td>
13
- </tr>
14
- <tr data-dce-id="7">
15
- <th data-dce-id="8">origin</th>
16
- <td data-dce-id="9">http://localhost:63342</td>
17
- </tr>
18
- <tr data-dce-id="7">
19
- <th data-dce-id="8">protocol</th>
20
- <td data-dce-id="9">http:</td>
21
- </tr>
22
- <tr data-dce-id="7">
23
- <th data-dce-id="8">host</th>
24
- <td data-dce-id="9">localhost:63342</td>
25
- </tr>
26
- <tr data-dce-id="7">
27
- <th data-dce-id="8">hostname</th>
28
- <td data-dce-id="9">localhost</td>
29
- </tr>
30
- <tr data-dce-id="7">
31
- <th data-dce-id="8">port</th>
32
- <td data-dce-id="9">63342</td>
33
- </tr>
34
- <tr data-dce-id="7">
35
- <th data-dce-id="8">pathname</th>
36
- <td data-dce-id="9">/custom-element/demo/a.html</td>
37
- </tr>
38
- <tr data-dce-id="7">
39
- <th data-dce-id="8">search</th>
40
- <td data-dce-id="9">?_ijt=qca6trk5kne6eo4s4tomq4egmm&amp;_ij_reload=RELOAD_ON_SAVE</td>
41
- </tr>
42
- <tr data-dce-id="7">
43
- <th data-dce-id="8">hash</th>
44
- <td data-dce-id="9"/>
45
- </tr>
46
- <tr data-dce-id="10">
47
- <th data-dce-id="11">
48
- <u data-dce-id="12">URL parameters</u>
49
- </th>
50
- </tr>
51
- <tr data-dce-id="13">
52
- <th data-dce-id="14">_ijt</th>
53
- <td data-dce-id="15">qca6trk5kne6eo4s4tomq4egmm</td>
54
- </tr>
55
- <tr data-dce-id="13">
56
- <th data-dce-id="14">_ij_reload</th>
57
- <td data-dce-id="15">RELOAD_ON_SAVE</td>
58
- </tr>
59
- </table>
60
- </dce-root>
package/demo/z1.html DELETED
@@ -1,34 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
- <title>DOM merge - Declarative Custom Element implementation demo</title>
6
- <link rel="icon" href="./wc-square.svg"/>
7
- <script type="importmap">
8
- {
9
- "imports": {
10
- "@epa-wg/custom-element/": "../",
11
- "@epa-wg/custom-element-dist/": "../"
12
- }
13
- }
14
- </script>
15
- <script type="module" src="../http-request.js"></script>
16
- <script type="module" src="../location-element.js"></script>
17
- <script type="module" src="../custom-element.js"></script>
18
- <style>
19
- @import "./demo.css";
20
- dt{ font-weight: bold}
21
- dd{ padding: 0;}
22
- h1,h3{ margin: 0;}
23
- nav{ gap:0; }
24
- </style>
25
- </head>
26
- <body>
27
- <button onclick="window.location.hash = `#@epa-wg/custom-element-dist@0.0.27/storybook-static/index.html`">set in page URL</button>
28
-
29
- <custom-element src="@epa-wg/custom-element-dist/demo/npm-versions.html#npm-version"
30
- package-name="@epa-wg/custom-element-dist"
31
- ></custom-element>
32
-
33
- </body>
34
- </html>