@epa-wg/custom-element 0.0.32 → 0.0.34

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.
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AgentMigrationStateService">
4
+ <option name="migrationStatus" value="COMPLETED" />
5
+ </component>
6
+ </project>
package/README.md CHANGED
@@ -47,7 +47,7 @@ This project is a POC( Proof of Concept ) targeting to become a base for native
47
47
 
48
48
  # use
49
49
 
50
- Use the [bootstrap project](https://github.com/EPA-WG/custom-element-bootstrap) with all pre-configured or
50
+ [//]: # (Use the [bootstrap project]&#40;https://github.com/EPA-WG/custom-element-bootstrap&#41; with all pre-configured or)
51
51
  ## install
52
52
  use via CDN
53
53
  ```html
@@ -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]: https://unpkg.com/@epa-wg/custom-element@0.0.32/demo/hex-grid-transform.png
344
+ [hex-grid-image]: https://unpkg.com/@epa-wg/custom-element@0.0.34/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.32/coverage/src/custom-element/coverage.svg
352
- [coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.32/coverage/src/custom-element/index.html
353
- [storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.32/storybook-static/index.html?path=/story/welcome--introduction
351
+ [coverage-image]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.34/coverage/src/custom-element/coverage.svg
352
+ [coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.34/coverage/src/custom-element/index.html
353
+ [storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.34/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
@@ -1,160 +1,160 @@
1
- /**
2
- * node xslDtd2Ide.cjs
3
- * would get xsl 1.0 schema and populate IntelliJ and VS Code IDE custom elements definitions
4
- *
5
- * This is one time use script as XSLT 1.0 schema is not changing.
6
- * DTD parsing here is not generic and cobers only particula XSLT 1.0 schema.
7
- */
8
- import { readFileSync, writeFileSync } from 'node:fs';
9
-
10
-
11
- const dtdText = await fetch( 'https://www.w3.org/1999/11/xslt10.dtd' )
12
- .then( ( response ) => response.text() )
13
- .then( ( body ) =>
14
- {
15
- return body;
16
- } );
17
- const matches = dtdText.match( /<([^>]*)>/g );
18
-
19
- const chopOff = ( s, begin = 1, end = 1 ) => s.substring( begin, s.length - end );
20
- const trim = s => s?.trim ? s.trim() : s;
21
-
22
- let lastComment = ''
23
- const dtdObj = { ENTITY: {}, ELEMENT: {} }
24
- for( const match of matches ){
25
- if( match.startsWith( '<!--' ) ) {
26
- lastComment = match;
27
- continue;
28
- }
29
- const body = chopOff( match, 2 );
30
- const arr = body.split( /\s/ );
31
- const name = arr[ 1 ].trim();
32
- const resolveRef = s => s ? ( s.startsWith ? ( s.startsWith( '%' ) ? dtdObj.ENTITY[ chopOff( s, 1, 0 ).replace( ';',
33
- '' ) ] : s ) : s ) : s;
34
- const attrObj = a =>
35
- {
36
- if( !a || Array.isArray( a ) || !a.trim )
37
- return a;
38
- const as = a.trim();
39
- if( 'CDATA,#PCDATA,NMTOKEN,NMTOKENS,'.includes( as + ',' ) )
40
- return as;
41
- const ar = as.split( ';' )
42
- const aa = ar[ 0 ].split( ' ' );
43
- // if( aa[0].includes('select')){debugger;}
44
- return { name: aa[ 0 ], type: resolveRef( aa[ 1 ] ), defValue: aa[ 1 ], required: (ar[1] || aa[ 2 ])?.trim() }
45
- };
46
- switch( arr[ 0 ] ){
47
- case 'ENTITY':{
48
- let key = arr[ 2 ];
49
- let val = body.substring( body.indexOf( key ) + key.length ).trim();
50
- let ss;
51
- if( val.startsWith( '"' ) || val.startsWith( "'" ) ) {
52
- val = chopOff( val );
53
- if( val.includes( '(#PCDATA' ) ) {
54
- val = val.replace( '(#PCDATA', '' ).replace( ')*', '' ).trim();
55
- ss = [ '#PCDATA', ...val.split( '\n' ).map( s => s.trim() ).map( resolveRef ).flat() ];
56
- } else
57
- ss = val.split( /[\n]/ ).map( s => s.replace( '|', '' ).trim() ).filter( s => s );
58
- } else
59
- ss = val.split( /[|\n]/ );
60
-
61
- const v = ss.map( trim ).filter( s => s ).map( resolveRef ).map( attrObj ).flat().filter( s => s );
62
- dtdObj.ENTITY[ key ] = !v.length ? '' : v.length === 1 ? v[ 0 ] : v;
63
- break;
64
- }
65
- case 'ELEMENT':
66
- dtdObj.ELEMENT[ name ] = { values: arr[ 2 ], attributes: [] };
67
- break;
68
- case 'ATTLIST':{
69
- const attrStr = body.split( name )[ 1 ].trim();
70
- const attrs = attrStr.split( '\n' ).map( s => s.trim() );
71
- const elementAttrs = dtdObj.ELEMENT[ name ].attributes;
72
- for( let a of attrs ){
73
- if( a.startsWith( '%' ) ) {
74
- const v = dtdObj.ENTITY[ chopOff( a.split( ';' )[ 0 ], 1, 0 ) ];
75
- if( !v ) {
76
- debugger;
77
- }
78
- Array.isArray( v )
79
- ? elementAttrs.push( ...v )
80
- : elementAttrs.push( v );
81
- } else
82
- elementAttrs.push( attrObj( a ) );
83
- }
84
-
85
- break;
86
- }
87
- }
88
- }
89
-
90
- // replace the tags list in custom-element.js
91
-
92
- const tagsCsv = Object.keys( dtdObj.ELEMENT ).map( s => s.replace( 'xsl:', '' ) ).join( ',' );
93
- const jsText = readFileSync( '../custom-element.js', 'utf8' )
94
- const updatedJs = jsText.replace( /^.*export const xslTags = .*$/mg,
95
- `export const xslTags = '${ tagsCsv }'.split(',');` );
96
- writeFileSync( '../custom-element.js', updatedJs );
97
-
98
- const vsCode = {
99
- "version": 1.1, tags: Object.keys( dtdObj.ELEMENT ).map( s => (
100
- { name : s.replace( 'xsl:', '' )
101
- , description : `${ s }`
102
- , attributes : dtdObj.ELEMENT[ s ].attributes.map( a => (
103
- { name : a.name
104
- , description: `${ JSON.stringify( a ) }`
105
- , type : "string"
106
- , required : a.required === '#REQUIRED'
107
- } ) )
108
- , references : [ { name: "MDN docs"
109
- , url : `https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/${s.replace( 'xsl:', '' )}`
110
- }]
111
- } ) )
112
- };
113
-
114
- writeFileSync( '.././ide/customData-xsl.json', JSON.stringify( vsCode, undefined, 4 ) );
115
-
116
- const intelliJ = {
117
- "$schema": "http://json.schemastore.org/web-types",
118
- "name": "@epa-wg/custom-element",
119
- "version": "0.0.32",
120
- "js-types-syntax": "typescript",
121
- "description-markup": "markdown",
122
- "contributions": {
123
- "html": {
124
- "elements": [
125
- ...Object.keys( dtdObj.ELEMENT ).map( s => (
126
- { name : s.replace( 'xsl:', '' )
127
- , description : `${ s }`
128
- , attributes : dtdObj.ELEMENT[ s ].attributes.map( a => (
129
- { name : a.name
130
- , description : `${ JSON.stringify( a ) }`
131
- , type : "string"
132
- , required : a.required === '#REQUIRED'
133
- } ) )
134
- , 'doc-url' : `https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/${s.replace( 'xsl:', '' )}`
135
- } ) ),
136
- {
137
- "name": "for-each",
138
- "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.",
139
- "doc-url": "https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/for-each",
140
- "attributes": [
141
- {
142
- "name": "select",
143
- "description": "Uses an XPath expression to select nodes to be processed.",
144
- "required": true,
145
- "doc-url": "https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/for-each#select",
146
- "value": {
147
- "type": "string"
148
- }
149
- }
150
- ]
151
- }
152
- ]
153
- }
154
- }
155
- };
156
-
157
-
158
- writeFileSync( '.././ide/web-types-xsl.json', JSON.stringify( intelliJ, undefined, 4 ) );
159
-
160
-
1
+ /**
2
+ * node xslDtd2Ide.cjs
3
+ * would get xsl 1.0 schema and populate IntelliJ and VS Code IDE custom elements definitions
4
+ *
5
+ * This is one time use script as XSLT 1.0 schema is not changing.
6
+ * DTD parsing here is not generic and cobers only particula XSLT 1.0 schema.
7
+ */
8
+ import { readFileSync, writeFileSync } from 'node:fs';
9
+
10
+
11
+ const dtdText = await fetch( 'https://www.w3.org/1999/11/xslt10.dtd' )
12
+ .then( ( response ) => response.text() )
13
+ .then( ( body ) =>
14
+ {
15
+ return body;
16
+ } );
17
+ const matches = dtdText.match( /<([^>]*)>/g );
18
+
19
+ const chopOff = ( s, begin = 1, end = 1 ) => s.substring( begin, s.length - end );
20
+ const trim = s => s?.trim ? s.trim() : s;
21
+
22
+ let lastComment = ''
23
+ const dtdObj = { ENTITY: {}, ELEMENT: {} }
24
+ for( const match of matches ){
25
+ if( match.startsWith( '<!--' ) ) {
26
+ lastComment = match;
27
+ continue;
28
+ }
29
+ const body = chopOff( match, 2 );
30
+ const arr = body.split( /\s/ );
31
+ const name = arr[ 1 ].trim();
32
+ const resolveRef = s => s ? ( s.startsWith ? ( s.startsWith( '%' ) ? dtdObj.ENTITY[ chopOff( s, 1, 0 ).replace( ';',
33
+ '' ) ] : s ) : s ) : s;
34
+ const attrObj = a =>
35
+ {
36
+ if( !a || Array.isArray( a ) || !a.trim )
37
+ return a;
38
+ const as = a.trim();
39
+ if( 'CDATA,#PCDATA,NMTOKEN,NMTOKENS,'.includes( as + ',' ) )
40
+ return as;
41
+ const ar = as.split( ';' )
42
+ const aa = ar[ 0 ].split( ' ' );
43
+ // if( aa[0].includes('select')){debugger;}
44
+ return { name: aa[ 0 ], type: resolveRef( aa[ 1 ] ), defValue: aa[ 1 ], required: (ar[1] || aa[ 2 ])?.trim() }
45
+ };
46
+ switch( arr[ 0 ] ){
47
+ case 'ENTITY':{
48
+ let key = arr[ 2 ];
49
+ let val = body.substring( body.indexOf( key ) + key.length ).trim();
50
+ let ss;
51
+ if( val.startsWith( '"' ) || val.startsWith( "'" ) ) {
52
+ val = chopOff( val );
53
+ if( val.includes( '(#PCDATA' ) ) {
54
+ val = val.replace( '(#PCDATA', '' ).replace( ')*', '' ).trim();
55
+ ss = [ '#PCDATA', ...val.split( '\n' ).map( s => s.trim() ).map( resolveRef ).flat() ];
56
+ } else
57
+ ss = val.split( /[\n]/ ).map( s => s.replace( '|', '' ).trim() ).filter( s => s );
58
+ } else
59
+ ss = val.split( /[|\n]/ );
60
+
61
+ const v = ss.map( trim ).filter( s => s ).map( resolveRef ).map( attrObj ).flat().filter( s => s );
62
+ dtdObj.ENTITY[ key ] = !v.length ? '' : v.length === 1 ? v[ 0 ] : v;
63
+ break;
64
+ }
65
+ case 'ELEMENT':
66
+ dtdObj.ELEMENT[ name ] = { values: arr[ 2 ], attributes: [] };
67
+ break;
68
+ case 'ATTLIST':{
69
+ const attrStr = body.split( name )[ 1 ].trim();
70
+ const attrs = attrStr.split( '\n' ).map( s => s.trim() );
71
+ const elementAttrs = dtdObj.ELEMENT[ name ].attributes;
72
+ for( let a of attrs ){
73
+ if( a.startsWith( '%' ) ) {
74
+ const v = dtdObj.ENTITY[ chopOff( a.split( ';' )[ 0 ], 1, 0 ) ];
75
+ if( !v ) {
76
+ debugger;
77
+ }
78
+ Array.isArray( v )
79
+ ? elementAttrs.push( ...v )
80
+ : elementAttrs.push( v );
81
+ } else
82
+ elementAttrs.push( attrObj( a ) );
83
+ }
84
+
85
+ break;
86
+ }
87
+ }
88
+ }
89
+
90
+ // replace the tags list in custom-element.js
91
+
92
+ const tagsCsv = Object.keys( dtdObj.ELEMENT ).map( s => s.replace( 'xsl:', '' ) ).join( ',' );
93
+ const jsText = readFileSync( '../custom-element.js', 'utf8' )
94
+ const updatedJs = jsText.replace( /^.*export const xslTags = .*$/mg,
95
+ `export const xslTags = '${ tagsCsv }'.split(',');` );
96
+ writeFileSync( '../custom-element.js', updatedJs );
97
+
98
+ const vsCode = {
99
+ "version": 1.1, tags: Object.keys( dtdObj.ELEMENT ).map( s => (
100
+ { name : s.replace( 'xsl:', '' )
101
+ , description : `${ s }`
102
+ , attributes : dtdObj.ELEMENT[ s ].attributes.map( a => (
103
+ { name : a.name
104
+ , description: `${ JSON.stringify( a ) }`
105
+ , type : "string"
106
+ , required : a.required === '#REQUIRED'
107
+ } ) )
108
+ , references : [ { name: "MDN docs"
109
+ , url : `https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/${s.replace( 'xsl:', '' )}`
110
+ }]
111
+ } ) )
112
+ };
113
+
114
+ writeFileSync( '.././ide/customData-xsl.json', JSON.stringify( vsCode, undefined, 4 ) );
115
+
116
+ const intelliJ = {
117
+ "$schema": "http://json.schemastore.org/web-types",
118
+ "name": "@epa-wg/custom-element",
119
+ "version": "0.0.34",
120
+ "js-types-syntax": "typescript",
121
+ "description-markup": "markdown",
122
+ "contributions": {
123
+ "html": {
124
+ "elements": [
125
+ ...Object.keys( dtdObj.ELEMENT ).map( s => (
126
+ { name : s.replace( 'xsl:', '' )
127
+ , description : `${ s }`
128
+ , attributes : dtdObj.ELEMENT[ s ].attributes.map( a => (
129
+ { name : a.name
130
+ , description : `${ JSON.stringify( a ) }`
131
+ , type : "string"
132
+ , required : a.required === '#REQUIRED'
133
+ } ) )
134
+ , 'doc-url' : `https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/${s.replace( 'xsl:', '' )}`
135
+ } ) ),
136
+ {
137
+ "name": "for-each",
138
+ "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.",
139
+ "doc-url": "https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/for-each",
140
+ "attributes": [
141
+ {
142
+ "name": "select",
143
+ "description": "Uses an XPath expression to select nodes to be processed.",
144
+ "required": true,
145
+ "doc-url": "https://developer.mozilla.org/en-US/docs/Web/XSLT/Element/for-each#select",
146
+ "value": {
147
+ "type": "string"
148
+ }
149
+ }
150
+ ]
151
+ }
152
+ ]
153
+ }
154
+ }
155
+ };
156
+
157
+
158
+ writeFileSync( '.././ide/web-types-xsl.json', JSON.stringify( intelliJ, undefined, 4 ) );
159
+
160
+
@@ -1,5 +1,9 @@
1
1
  export function log(x: any): void;
2
2
  export function deepEqual(a: any, b:any): boolean|0;
3
+ export function cloneAs(sourceNode: HTMLElement, tag:string): HTMLElement;
4
+ export function mix(objTo: any, objFrom:any): any;
5
+ export function mergeAttr(fromEl: HTMLElement, toEL:HTMLElement): void;
6
+
3
7
  export function xml2dom(xmlString:string): Document;
4
8
  export function xmlString(doc:Node|Document): string;
5
9
  export function obj2node(o:any, tag:string, doc:Document): HTMLElement;