@techexp/webitem 0.5.3 → 0.6.0
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-dev.md +2 -2
- package/README.md +2 -2
- package/dist/webitem-esm.js +10 -19
- package/dist/webitem-script-min.js +4 -4
- package/dist/webitem-script.js +55 -97
- package/eslint.config.js +95 -0
- package/package.json +12 -11
- package/.eslintrc.js +0 -92
package/README-dev.md
CHANGED
|
@@ -5,13 +5,13 @@ This file contains info to help the developer of the library.
|
|
|
5
5
|
|
|
6
6
|
## Project Directory Structure
|
|
7
7
|
|
|
8
|
-
1. The root of the project
|
|
8
|
+
1. The root of the project contains these files
|
|
9
9
|
1. `.ackrc`: Config for [Ack](https://beyondgrep.com/) grep tool
|
|
10
10
|
2. `.editorconfig`: Config for [EditorConfig](https://editorconfig.org/)
|
|
11
11
|
3. `.eslintrc`: ES Lint customized rules
|
|
12
12
|
4. `.gitignore`: List of files to be ignored by git
|
|
13
13
|
5. `.npmrc`: Configuration for npm.
|
|
14
|
-
6. `LICENSE`: License file,
|
|
14
|
+
6. `LICENSE`: License file, using Apache v 2.0
|
|
15
15
|
7. `package.json`, `package-lock.json`: NPM package definition.
|
|
16
16
|
8. `README.md`: Info about using the library.
|
|
17
17
|
9. `README-dev.md`: This file.
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ A library to simplify creating HTML5 Web Components (Custom Elements).
|
|
|
4
4
|
## Introduction
|
|
5
5
|
In modern HTML, you can create web components using
|
|
6
6
|
[customElements.define()](https://developer.mozilla.org/en-US/docs/Web/Web_Components).
|
|
7
|
-
This API is
|
|
7
|
+
This API is powerful, but can be verbose and complicated. The _webitem.js_ library provides a wrapper
|
|
8
8
|
around that API in an attempt to make it simple for the application's programmer.
|
|
9
9
|
|
|
10
10
|
## Install
|
|
@@ -125,7 +125,7 @@ CSS applied to a web component (_through shadow DOM_) is scoped to the component
|
|
|
125
125
|
with CSS outside the component.
|
|
126
126
|
|
|
127
127
|
If you need to use a common CSS file within the component, a possible solution is to use
|
|
128
|
-
the `<link>`
|
|
128
|
+
the `<link>` tagDef in the component's html, for exmaple, add the next line at the top of your component's html:
|
|
129
129
|
|
|
130
130
|
```html
|
|
131
131
|
<link rel="stylesheet" href="css/common.css">
|
package/dist/webitem-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// webitem.js Library to simplify creating HTML5 Custom Elements
|
|
2
2
|
// https://github.com/ahabra/webitem
|
|
3
|
-
// Copyright 2021 (C) Abdul Habra. Version 0.
|
|
3
|
+
// Copyright 2021 (C) Abdul Habra. Version 0.6.0.
|
|
4
4
|
// Apache License Version 2.0
|
|
5
5
|
|
|
6
6
|
|
|
@@ -17,8 +17,7 @@ function defineElement({
|
|
|
17
17
|
actionList,
|
|
18
18
|
eventHandlerList
|
|
19
19
|
}) {
|
|
20
|
-
if (customElements.get(nameWithDash))
|
|
21
|
-
return false;
|
|
20
|
+
if (customElements.get(nameWithDash)) return false;
|
|
22
21
|
const el = class extends HTMLElement {
|
|
23
22
|
constructor() {
|
|
24
23
|
super();
|
|
@@ -41,8 +40,7 @@ function defineElement({
|
|
|
41
40
|
}
|
|
42
41
|
function bindProperties(root, propertyList) {
|
|
43
42
|
const result = {};
|
|
44
|
-
if (!validatePropertyList(propertyList))
|
|
45
|
-
return result;
|
|
43
|
+
if (!validatePropertyList(propertyList)) return result;
|
|
46
44
|
propertyList.forEach((p) => addProperty(result, p, root));
|
|
47
45
|
return result;
|
|
48
46
|
}
|
|
@@ -54,13 +52,11 @@ function addProperty(obj, prop, root) {
|
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
54
|
function createOnChange(prop, root) {
|
|
57
|
-
if (!prop.onChange)
|
|
58
|
-
return void 0;
|
|
55
|
+
if (!prop.onChange) return void 0;
|
|
59
56
|
return (oldValue, newValue) => prop.onChange(root, oldValue, newValue);
|
|
60
57
|
}
|
|
61
58
|
function validatePropertyList(propertyList) {
|
|
62
|
-
if (!propertyList)
|
|
63
|
-
return false;
|
|
59
|
+
if (!propertyList) return false;
|
|
64
60
|
if (!Array.isArray(propertyList)) {
|
|
65
61
|
throw "propertyList must be an array of {name, value, [sel], [attr]} objects";
|
|
66
62
|
}
|
|
@@ -68,21 +64,18 @@ function validatePropertyList(propertyList) {
|
|
|
68
64
|
}
|
|
69
65
|
function defineActions(root, actionList) {
|
|
70
66
|
const actions = {};
|
|
71
|
-
if (!actionList)
|
|
72
|
-
return actions;
|
|
67
|
+
if (!actionList) return actions;
|
|
73
68
|
actionList.forEach((pair) => {
|
|
74
69
|
addAction(root, actions, pair.name, pair.action);
|
|
75
70
|
});
|
|
76
71
|
return actions;
|
|
77
72
|
}
|
|
78
73
|
function addAction(root, actions, name, action) {
|
|
79
|
-
if (!Objecter.isString(name) || !Objecter.isFunction(action))
|
|
80
|
-
return;
|
|
74
|
+
if (!Objecter.isString(name) || !Objecter.isFunction(action)) return;
|
|
81
75
|
actions[name] = action.bind(root);
|
|
82
76
|
}
|
|
83
77
|
function addEventListeners(root, eventHandlerList) {
|
|
84
|
-
if (!eventHandlerList)
|
|
85
|
-
return;
|
|
78
|
+
if (!eventHandlerList) return;
|
|
86
79
|
if (!Array.isArray(eventHandlerList)) {
|
|
87
80
|
throw "eventHandlerList must be an array of {sel, eventName, listener} objects";
|
|
88
81
|
}
|
|
@@ -110,8 +103,7 @@ function getCss(css, display) {
|
|
|
110
103
|
}
|
|
111
104
|
function buildCss(css) {
|
|
112
105
|
css = Stringer.trim(css);
|
|
113
|
-
if (css.length === 0)
|
|
114
|
-
return "";
|
|
106
|
+
if (css.length === 0) return "";
|
|
115
107
|
if (!Stringer.startsWith(css, "<style>", false)) {
|
|
116
108
|
css = Domer.tag("style", {}, css);
|
|
117
109
|
}
|
|
@@ -119,8 +111,7 @@ function buildCss(css) {
|
|
|
119
111
|
}
|
|
120
112
|
function displayStyle(display) {
|
|
121
113
|
display = Stringer.trim(display);
|
|
122
|
-
if (display.length === 0)
|
|
123
|
-
return "";
|
|
114
|
+
if (display.length === 0) return "";
|
|
124
115
|
return `
|
|
125
116
|
<style>
|
|
126
117
|
:host { display: ${display};}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// webitem.js Library to simplify creating HTML5 Custom Elements
|
|
2
2
|
// https://github.com/ahabra/webitem
|
|
3
|
-
// Copyright 2021 (C) Abdul Habra. Version 0.
|
|
3
|
+
// Copyright 2021 (C) Abdul Habra. Version 0.6.0.
|
|
4
4
|
// Apache License Version 2.0
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
var webitem=(()=>{var v=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var ue=(e,t)=>{for(var n in t)v(e,n,{get:t[n],enumerable:!0})},oe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of re(t))!ie.call(e,i)&&i!==n&&v(e,i,{get:()=>t[i],enumerable:!(r=ne(t,i))||r.enumerable});return e};var fe=e=>oe(v({},"__esModule",{value:!0}),e);var
|
|
7
|
+
var webitem=(()=>{var v=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var re=Object.getOwnPropertyNames;var ie=Object.prototype.hasOwnProperty;var ue=(e,t)=>{for(var n in t)v(e,n,{get:t[n],enumerable:!0})},oe=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of re(t))!ie.call(e,i)&&i!==n&&v(e,i,{get:()=>t[i],enumerable:!(r=ne(t,i))||r.enumerable});return e};var fe=e=>oe(v({},"__esModule",{value:!0}),e);var at={};ue(at,{defineElement:()=>Ye});var se=Object.defineProperty,g=(e,t)=>{for(var n in t)se(e,n,{get:t[n],enumerable:!0})},l={};g(l,{add:()=>xe,all:()=>F,classPresentIf:()=>$e,createElement:()=>Ae,createElements:()=>M,first:()=>be,getAttributes:()=>Se,id:()=>Ee,removeElements:()=>Te,setContent:()=>Ne,tag:()=>_});var d={};g(d,{equals:()=>q,forEachEntry:()=>L,has:()=>le,isDate:()=>S,isFunction:()=>P,isInteger:()=>ce,isNil:()=>ae,isNumber:()=>R,isRegExp:()=>j,isString:()=>p});function ae(e){return e==null}function p(e){return m(e,"String")}function P(e){return m(e,"Function")}function S(e){return m(e,"Date")}function R(e){return m(e,"Number")?Number.isNaN(e)?!1:Number.isFinite(e):!p(e)||(e=e.trim(),e==="")?!1:!isNaN(e)}function ce(e){return R(e)?Number.isInteger(Number.parseFloat(e)):!1}function j(e){return m(e,"RegExp")}function m(e,t){return Object.prototype.toString.call(e)===`[object ${t}]`}function L(e,t){if(!(!e||!t)){if(Array.isArray(e)){e.forEach((n,r)=>{t(r,n)});return}Object.entries(e).forEach(n=>t(n[0],n[1]))}}function le(e,t){return!e||!t?!1:Object.prototype.hasOwnProperty.call(e,t)}function q(e,t){return e===t?!0:e===void 0||t===void 0?!1:de(e,t)}function de(e,t){return N(e)||N(t)?e===t:he(e,t)}var me=new Set(["boolean","number","bigint","string","symbol"]);function N(e){return me.has(typeof e)}function he(e,t){return ge(e,t)?pe(e,t)?!0:ye(e,t):!1}function ge(e,t){return T(e)===T(t)}function T(e){return Object.prototype.toString.call(e)}function pe(e,t){return S(e)&&S(t)?e.getTime()===t.getTime():!1}function ye(e,t){let n=Object.keys(e);return n.length!==Object.keys(t).length?!1:n.every(r=>q(e[r],t[r]))}function Ee(e,t=document){return O(t)&&(t=t.shadowRoot),t.getElementById(e)}function F(e,t=document){return O(t)&&(t=t.shadowRoot),Array.from(t.querySelectorAll(e))}function be(e,t=document){return O(t)&&(t=t.shadowRoot),e.includes("/")?we(e,t):t.querySelector(e)}function we(e,t){let n=e.split("/").map(r=>r.trim()).filter(r=>r.length>0);for(let r of n)if(t=ve(r,t),t===null)break;return t}function ve(e,t){return e==="shadowRoot"||e==="shadow-root"?t.shadowRoot:t.querySelector(e)}function O(e){return e&&e.shadowRoot&&e.tagName.includes("-")}function Se(e){let t={},n=e.attributes;if(!n||n.length===0)return t;for(let r=0;r<n.length;r++){let i=n[r];t[i.name]=i.value}return t}function M(e=""){if(e=e.trim(),!e)return[];let t=document.createElement("template");return t.innerHTML=e,Array.from(t.content.childNodes)}function Ae(e,t={},n=""){let r=_(e,t,n),i=M(r);return i.length===0?null:i[0]}function _(e,t={},n=""){if(!e)return"";let r=Le(t);return`<${e}${r}>${n}</${e}>`}function Le(e){let t=[];return L(e,(r,i)=>{t.push(`${r}="${i}"`)}),(t.length>0?" ":"")+t.join(" ")}var Oe=new Set(["beforebegin","afterbegin","beforeend","afterend"]);function xe(e,t,n="beforeend"){return n=n.toLowerCase(),Oe.has(n)?(p(t)?e.insertAdjacentHTML(n,t):Ce(e,t,n),!0):!1}function Ce(e,t,n){Array.isArray(t)?t.forEach(r=>e.insertAdjacentElement(n,r)):e.insertAdjacentElement(n,t)}function Ne(e,...t){e.innerHTML="",e.append(...t)}function Te(e,t=document){F(e,t).forEach(r=>{r.parentNode.removeChild(r)})}function $e(e,t,n){if(!e)return;let r=n?"add":"remove";e.classList[r](t)}var h={};g(h,{endsWith:()=>D,indexOf:()=>x,indexOfFirstMatch:()=>Pe,indexOfLastMatch:()=>Re,isEmpty:()=>y,removePrefix:()=>H,removeSuffix:()=>I,removeSurrounding:()=>je,replaceAll:()=>V,replaceTemplate:()=>Me,startsWith:()=>W,strip:()=>De,stripEnd:()=>We,stripStart:()=>_e,substringAfter:()=>qe,substringBefore:()=>Fe,trim:()=>A});function x(e,t,n=0,r=!1){return e?r?e.toLowerCase().indexOf(t.toLowerCase(),n):e.indexOf(t,n):-1}function Pe(e,t){return!t||!e?-1:e.split("").findIndex(t)}function Re(e,t){if(!t||!e)return-1;let n=e.split("");for(let r=n.length;r>=0;--r)if(t(n[r],r))return r;return-1}function W(e="",t=void 0,n=!1){if(n){let r=e.substring(0,t.length).toLowerCase();return t.toLowerCase()===r}return e.startsWith(t)}function D(e,t,n=!1){return n?e.toLowerCase().endsWith(t.toLowerCase()):e.endsWith(t)}function H(e,t,n=!1){return W(e,t,n)&&(e=e.substring(t.length)),e}function I(e,t,n=!1){return D(e,t,n)&&(e=e.substring(0,e.length-t.length)),e}function je(e,t,n,r=!1){return I(H(e,t,r),n,r)}function qe(e,t,n=!1){if(!t)return e;let r=x(e,t,0,n);return r<0?"":e.substring(r+t.length)}function Fe(e,t,n=!1){if(!t)return"";let r=x(e,t,0,n);return r<0?e:e.substring(0,r)}function A(e){return y(e)?"":(p(e)||(e=String(e)),e.trim(e))}function y(e){return e==null||e===""}function V(e,t,n){if(P(String.prototype.replaceAll))return e.replaceAll(t,n);if(j(t))return e.replace(t,n);let r=new RegExp(t,"g");return e.replace(r,n)}function Me(e="",t={},n="${",r="}"){return L(t,(i,u)=>{u!==void 0&&(i=n+i+r,e=V(e,i,u))}),e}function _e(e,t=""){return y(e)?"":t?k(e,new Set(Array.from(t))):e}function k(e,t){for(let n=0;n<e.length;n++)if(!t.has(e.charAt(n)))return e.substring(n);return""}function We(e,t=""){return y(e)?"":t?B(e,new Set(Array.from(t))):e}function B(e,t){for(let n=e.length-1;n>=0;n--)if(!t.has(e.charAt(n)))return e.substring(0,n+1);return""}function De(e,t=""){if(e===void 0||e==="")return"";if(!t)return e;let n=new Set(Array.from(t));return e=k(e,n),e?B(e,n):""}var He={};g(He,{compareLines:()=>Ie});function Ie(e,t,{trim:n=!0,skipEmpty:r=!0,caseSensitive:i=!0}={trim:!0,skipEmpty:!0,caseSensitive:!0}){return e=$(e,{trim:n,skipEmpty:r}),t=$(t,{trim:n,skipEmpty:r}),e.length!==t.length?`t1 has ${e.length} lines(s) while t2 has ${t.length} line(s).`:Ve(e,t,i)}function Ve(e,t,n){for(let r=0;r<e.length;r++){let i=ke(e[r],t[r],r,n);if(i.length>0)return i}return""}function ke(e,t,n,r){let i=r?e:e.toLowerCase(),u=r?t:t.toLowerCase();return i!==u?`Line #${n+1} mismatch.
|
|
8
8
|
${e}
|
|
9
9
|
${t}`:""}function $(e,{trim:t,skipEmpty:n}){return t&&(e=A(e)),e=e.split(`
|
|
10
|
-
`),t&&(e=e.map(r=>A(r))),n&&(e=e.filter(r=>!!r)),e}function C({obj:e={},prop:t,sel:n,attr:r,root:i=document,getter:u,setter:o,onChange:f}){
|
|
10
|
+
`),t&&(e=e.map(r=>A(r))),n&&(e=e.filter(r=>!!r)),e}function C({obj:e={},prop:t,sel:n,attr:r,root:i=document,getter:u,setter:o,onChange:f}){Xe(t),ze(e,t);let s={};return u||(u=()=>Ge({prop:t,sel:n,attr:r,root:i,objNotBound:s})),o||(o=a=>Je({prop:t,value:a,root:i,sel:n,attr:r,objNotBound:s})),Be({obj:e,prop:t,getter:u,setter:o,onChange:f})}function Be({obj:e,prop:t,getter:n,setter:r,onChange:i}){return Object.defineProperty(e,t,{get:()=>n(),set:o=>{if(i){let f=n(t);f!==o&&i(f,o)}r(o)},configurable:!0,enumerable:!0}),e}var E=e=>e.type==="checkbox",b=e=>e.type==="radio",G=e=>e.nodeName.toLowerCase()==="select",J=e=>e.nodeName.toLowerCase()==="input-field",K=e=>"value"in e,z=e=>new Set(Array.isArray(e)?e:[e]);function ze(e,t){let n=e[t];return n!==void 0&&(console.info(`Property '${t}' already exists in object. Will override previous definition but retain old value of ${n}.`),e[t]=n),n}function Ge({prop:e,root:t,sel:n,attr:r,objNotBound:i}){return n?Ke(t,n,r):i[e]}function Je({prop:e,value:t,root:n,sel:r,attr:i,objNotBound:u}){if(r){Qe(n,r,t,i);return}u[e]=t}function Ke(e,t,n){let r=Q(e,t);if(r.length===0)return null;let i=r[0];if(n)return i.getAttribute(n);if(!K(i))return i.innerHTML;if(E(i))return r.filter(u=>E(u)&&u.checked).map(u=>u.value==="on"?u.name:u.value);if(G(i))return[...i.querySelectorAll("option")].filter(o=>o.selected).map(o=>o.value);if(!(b(i)&&(i=r.filter(b).find(u=>u.checked),!i)))return J(i)?i.getAttribute("value"):i.value}function Qe(e,t,n,r){let i=Q(e,t);if(i.length===0)return;let u=i[0];if(E(u)){let o=z(n);i.filter(E).forEach(f=>f.checked=o.has(f.value)||o.has(f.name));return}if(G(u)){let o=z(n);u.querySelectorAll("option").forEach(f=>f.selected=o.has(f.value));return}if(b(u)){i.filter(b).forEach(o=>o.checked=o.value===n);return}i.forEach(o=>Ue(o,n,r))}function Ue(e,t,n){n?e.setAttribute(n,t):K(e)?e.value=t:J(e)?e.setAttribute("value",t):e.innerHTML=t}function Q(e,t){let n=e.querySelectorAll(t);return n.length===0&&console.warn(`No elements found matching selector ${t}`),[...n]}function Xe(e){if(typeof e!="string"||e.length===0)throw"'prop' argument must be a String defining the name a property."}function Ye({nameWithDash:e,html:t,css:n,display:r,propertyList:i,actionList:u,eventHandlerList:o}){if(customElements.get(e))return!1;let f=class extends HTMLElement{constructor(){super();let s=this;it(this,t,n,r),this.wi={},this.wi.properties=Ze(this,i),this.wi.actions=nt(this,u),rt(this,o),this.wi.addProperty=function(a,c,w,Z,ee){let te={name:a,value:c,sel:w,attr:Z,onChange:ee};U(s.wi.properties,te,s)},this.wi.addAction=(a,c)=>X(s,s.wi.actions,a,c),this.wi.addEventListener=(a,c,w)=>Y(s,{sel:a,eventName:c,listener:w})}};return customElements.define(e,f),!0}function Ze(e,t){let n={};return tt(t)&&t.forEach(r=>U(n,r,e)),n}function U(e,t,n){let r=et(t,n);C({obj:e,prop:t.name,sel:t.sel,attr:t.attr,root:n.shadowRoot,onChange:r}),t.value!==void 0&&(e[t.name]=t.value)}function et(e,t){if(e.onChange)return(n,r)=>e.onChange(t,n,r)}function tt(e){if(!e)return!1;if(!Array.isArray(e))throw"propertyList must be an array of {name, value, [sel], [attr]} objects";return!0}function nt(e,t){let n={};return t&&t.forEach(r=>{X(e,n,r.name,r.action)}),n}function X(e,t,n,r){!d.isString(n)||!d.isFunction(r)||(t[n]=r.bind(e))}function rt(e,t){if(t){if(!Array.isArray(t))throw"eventHandlerList must be an array of {sel, eventName, listener} objects";t.forEach(n=>Y(e,n))}}function Y(e,{sel:t,eventName:n,listener:r}){l.all(t,e.shadowRoot).forEach(u=>{u.addEventListener(n,o=>{r(o,e)})})}function it(e,t,n,r){t=ut(e,t);let i=e.attachShadow({mode:"open"}),u=l.createElements(ot(n,r)+t);i.append(...u)}function ut(e,t){return d.isFunction(t)?t(e):t}function ot(e,t){return st(t)+ft(e)}function ft(e){return e=h.trim(e),e.length===0?"":(h.startsWith(e,"<style>",!1)||(e=l.tag("style",{},e)),e)}function st(e){return e=h.trim(e),e.length===0?"":`
|
|
11
11
|
<style>
|
|
12
12
|
:host { display: ${e};}
|
|
13
13
|
:host([hidden]) {display: none;}
|
|
14
14
|
</style>
|
|
15
|
-
`}return fe(
|
|
15
|
+
`}return fe(at);})();
|
package/dist/webitem-script.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// webitem.js Library to simplify creating HTML5 Custom Elements
|
|
2
2
|
// https://github.com/ahabra/webitem
|
|
3
|
-
// Copyright 2021 (C) Abdul Habra. Version 0.
|
|
3
|
+
// Copyright 2021 (C) Abdul Habra. Version 0.6.0.
|
|
4
4
|
// Apache License Version 2.0
|
|
5
5
|
|
|
6
6
|
|
|
@@ -76,20 +76,16 @@ var webitem = (() => {
|
|
|
76
76
|
}
|
|
77
77
|
function isNumber(n) {
|
|
78
78
|
if (isType(n, "Number")) {
|
|
79
|
-
if (Number.isNaN(n))
|
|
80
|
-
return false;
|
|
79
|
+
if (Number.isNaN(n)) return false;
|
|
81
80
|
return Number.isFinite(n);
|
|
82
81
|
}
|
|
83
|
-
if (!isString(n))
|
|
84
|
-
return false;
|
|
82
|
+
if (!isString(n)) return false;
|
|
85
83
|
n = n.trim();
|
|
86
|
-
if (n === "")
|
|
87
|
-
return false;
|
|
84
|
+
if (n === "") return false;
|
|
88
85
|
return !isNaN(n);
|
|
89
86
|
}
|
|
90
87
|
function isInteger(n) {
|
|
91
|
-
if (!isNumber(n))
|
|
92
|
-
return false;
|
|
88
|
+
if (!isNumber(n)) return false;
|
|
93
89
|
return Number.isInteger(Number.parseFloat(n));
|
|
94
90
|
}
|
|
95
91
|
function isRegExp(re) {
|
|
@@ -99,8 +95,7 @@ var webitem = (() => {
|
|
|
99
95
|
return Object.prototype.toString.call(v) === `[object ${type}]`;
|
|
100
96
|
}
|
|
101
97
|
function forEachEntry(object, func) {
|
|
102
|
-
if (!object || !func)
|
|
103
|
-
return;
|
|
98
|
+
if (!object || !func) return;
|
|
104
99
|
if (Array.isArray(object)) {
|
|
105
100
|
object.forEach((v, index) => {
|
|
106
101
|
func(index, v);
|
|
@@ -110,20 +105,16 @@ var webitem = (() => {
|
|
|
110
105
|
Object.entries(object).forEach((p) => func(p[0], p[1]));
|
|
111
106
|
}
|
|
112
107
|
function has(object, propName) {
|
|
113
|
-
if (!object || !propName)
|
|
114
|
-
return false;
|
|
108
|
+
if (!object || !propName) return false;
|
|
115
109
|
return Object.prototype.hasOwnProperty.call(object, propName);
|
|
116
110
|
}
|
|
117
111
|
function equals(a, b) {
|
|
118
|
-
if (a === b)
|
|
119
|
-
|
|
120
|
-
if (a === void 0 || b === void 0)
|
|
121
|
-
return false;
|
|
112
|
+
if (a === b) return true;
|
|
113
|
+
if (a === void 0 || b === void 0) return false;
|
|
122
114
|
return isEqual(a, b);
|
|
123
115
|
}
|
|
124
116
|
function isEqual(a, b) {
|
|
125
|
-
if (isSimpleType(a) || isSimpleType(b))
|
|
126
|
-
return a === b;
|
|
117
|
+
if (isSimpleType(a) || isSimpleType(b)) return a === b;
|
|
127
118
|
return isEqualCompoundType(a, b);
|
|
128
119
|
}
|
|
129
120
|
var simpleTypes = /* @__PURE__ */ new Set(["boolean", "number", "bigint", "string", "symbol"]);
|
|
@@ -131,10 +122,8 @@ var webitem = (() => {
|
|
|
131
122
|
return simpleTypes.has(typeof v);
|
|
132
123
|
}
|
|
133
124
|
function isEqualCompoundType(a, b) {
|
|
134
|
-
if (!isEqualType(a, b))
|
|
135
|
-
|
|
136
|
-
if (isEqualDates(a, b))
|
|
137
|
-
return true;
|
|
125
|
+
if (!isEqualType(a, b)) return false;
|
|
126
|
+
if (isEqualDates(a, b)) return true;
|
|
138
127
|
return isEqualObjects(a, b);
|
|
139
128
|
}
|
|
140
129
|
function isEqualType(a, b) {
|
|
@@ -151,8 +140,7 @@ var webitem = (() => {
|
|
|
151
140
|
}
|
|
152
141
|
function isEqualObjects(a, b) {
|
|
153
142
|
const akeys = Object.keys(a);
|
|
154
|
-
if (akeys.length !== Object.keys(b).length)
|
|
155
|
-
return false;
|
|
143
|
+
if (akeys.length !== Object.keys(b).length) return false;
|
|
156
144
|
return akeys.every((k) => equals(a[k], b[k]));
|
|
157
145
|
}
|
|
158
146
|
function id(elementId, root = document) {
|
|
@@ -174,11 +162,13 @@ var webitem = (() => {
|
|
|
174
162
|
if (!selector.includes("/")) {
|
|
175
163
|
return root.querySelector(selector);
|
|
176
164
|
}
|
|
165
|
+
return traverseSelectorPath(selector, root);
|
|
166
|
+
}
|
|
167
|
+
function traverseSelectorPath(selector, root) {
|
|
177
168
|
const path = selector.split("/").map((p) => p.trim()).filter((p) => p.length > 0);
|
|
178
169
|
for (const p of path) {
|
|
179
170
|
root = nextChild(p, root);
|
|
180
|
-
if (root === null)
|
|
181
|
-
break;
|
|
171
|
+
if (root === null) break;
|
|
182
172
|
}
|
|
183
173
|
return root;
|
|
184
174
|
}
|
|
@@ -192,8 +182,7 @@ var webitem = (() => {
|
|
|
192
182
|
function getAttributes(el) {
|
|
193
183
|
const result = {};
|
|
194
184
|
const atts = el.attributes;
|
|
195
|
-
if (!atts || atts.length === 0)
|
|
196
|
-
return result;
|
|
185
|
+
if (!atts || atts.length === 0) return result;
|
|
197
186
|
for (let i = 0; i < atts.length; i++) {
|
|
198
187
|
const a = atts[i];
|
|
199
188
|
result[a.name] = a.value;
|
|
@@ -202,8 +191,7 @@ var webitem = (() => {
|
|
|
202
191
|
}
|
|
203
192
|
function createElements(html = "") {
|
|
204
193
|
html = html.trim();
|
|
205
|
-
if (!html)
|
|
206
|
-
return [];
|
|
194
|
+
if (!html) return [];
|
|
207
195
|
const temp = document.createElement("template");
|
|
208
196
|
temp.innerHTML = html;
|
|
209
197
|
return Array.from(temp.content.childNodes);
|
|
@@ -211,13 +199,11 @@ var webitem = (() => {
|
|
|
211
199
|
function createElement(name, attributes = {}, content = "") {
|
|
212
200
|
const html = tag(name, attributes, content);
|
|
213
201
|
const elements = createElements(html);
|
|
214
|
-
if (elements.length === 0)
|
|
215
|
-
return null;
|
|
202
|
+
if (elements.length === 0) return null;
|
|
216
203
|
return elements[0];
|
|
217
204
|
}
|
|
218
205
|
function tag(name, attributes = {}, content = "") {
|
|
219
|
-
if (!name)
|
|
220
|
-
return "";
|
|
206
|
+
if (!name) return "";
|
|
221
207
|
const atts = attsToString(attributes);
|
|
222
208
|
return `<${name}${atts}>${content}</${name}>`;
|
|
223
209
|
}
|
|
@@ -232,8 +218,7 @@ var webitem = (() => {
|
|
|
232
218
|
var LOCATIONS = /* @__PURE__ */ new Set(["beforebegin", "afterbegin", "beforeend", "afterend"]);
|
|
233
219
|
function add(target, tobeAdded, location = "beforeend") {
|
|
234
220
|
location = location.toLowerCase();
|
|
235
|
-
if (!LOCATIONS.has(location))
|
|
236
|
-
return false;
|
|
221
|
+
if (!LOCATIONS.has(location)) return false;
|
|
237
222
|
if (isString(tobeAdded)) {
|
|
238
223
|
target.insertAdjacentHTML(location, tobeAdded);
|
|
239
224
|
} else {
|
|
@@ -259,8 +244,7 @@ var webitem = (() => {
|
|
|
259
244
|
});
|
|
260
245
|
}
|
|
261
246
|
function classPresentIf(el, cssClass, condition) {
|
|
262
|
-
if (!el)
|
|
263
|
-
return;
|
|
247
|
+
if (!el) return;
|
|
264
248
|
const func = condition ? "add" : "remove";
|
|
265
249
|
el.classList[func](cssClass);
|
|
266
250
|
}
|
|
@@ -285,25 +269,21 @@ var webitem = (() => {
|
|
|
285
269
|
trim: () => trim
|
|
286
270
|
});
|
|
287
271
|
function indexOf(st, search, fromIndex = 0, ignoreCase = false) {
|
|
288
|
-
if (!st)
|
|
289
|
-
return -1;
|
|
272
|
+
if (!st) return -1;
|
|
290
273
|
if (ignoreCase) {
|
|
291
274
|
return st.toLowerCase().indexOf(search.toLowerCase(), fromIndex);
|
|
292
275
|
}
|
|
293
276
|
return st.indexOf(search, fromIndex);
|
|
294
277
|
}
|
|
295
278
|
function indexOfFirstMatch(st, callback) {
|
|
296
|
-
if (!callback || !st)
|
|
297
|
-
return -1;
|
|
279
|
+
if (!callback || !st) return -1;
|
|
298
280
|
return st.split("").findIndex(callback);
|
|
299
281
|
}
|
|
300
282
|
function indexOfLastMatch(st, callback) {
|
|
301
|
-
if (!callback || !st)
|
|
302
|
-
return -1;
|
|
283
|
+
if (!callback || !st) return -1;
|
|
303
284
|
const chars = st.split("");
|
|
304
285
|
for (let i = chars.length; i >= 0; --i) {
|
|
305
|
-
if (callback(chars[i], i))
|
|
306
|
-
return i;
|
|
286
|
+
if (callback(chars[i], i)) return i;
|
|
307
287
|
}
|
|
308
288
|
return -1;
|
|
309
289
|
}
|
|
@@ -340,8 +320,7 @@ var webitem = (() => {
|
|
|
340
320
|
return st;
|
|
341
321
|
}
|
|
342
322
|
const i = indexOf(st, search, 0, ignoreCase);
|
|
343
|
-
if (i < 0)
|
|
344
|
-
return "";
|
|
323
|
+
if (i < 0) return "";
|
|
345
324
|
return st.substring(i + search.length);
|
|
346
325
|
}
|
|
347
326
|
function substringBefore(st, search, ignoreCase = false) {
|
|
@@ -349,13 +328,11 @@ var webitem = (() => {
|
|
|
349
328
|
return "";
|
|
350
329
|
}
|
|
351
330
|
const i = indexOf(st, search, 0, ignoreCase);
|
|
352
|
-
if (i < 0)
|
|
353
|
-
return st;
|
|
331
|
+
if (i < 0) return st;
|
|
354
332
|
return st.substring(0, i);
|
|
355
333
|
}
|
|
356
334
|
function trim(s) {
|
|
357
|
-
if (isEmpty(s))
|
|
358
|
-
return "";
|
|
335
|
+
if (isEmpty(s)) return "";
|
|
359
336
|
if (!isString(s)) {
|
|
360
337
|
s = String(s);
|
|
361
338
|
}
|
|
@@ -384,10 +361,8 @@ var webitem = (() => {
|
|
|
384
361
|
return text;
|
|
385
362
|
}
|
|
386
363
|
function stripStart(s, stripChars = "") {
|
|
387
|
-
if (isEmpty(s))
|
|
388
|
-
|
|
389
|
-
if (!stripChars)
|
|
390
|
-
return s;
|
|
364
|
+
if (isEmpty(s)) return "";
|
|
365
|
+
if (!stripChars) return s;
|
|
391
366
|
return stripStart_(s, new Set(Array.from(stripChars)));
|
|
392
367
|
}
|
|
393
368
|
function stripStart_(s, stripSet) {
|
|
@@ -399,10 +374,8 @@ var webitem = (() => {
|
|
|
399
374
|
return "";
|
|
400
375
|
}
|
|
401
376
|
function stripEnd(s, stripChars = "") {
|
|
402
|
-
if (isEmpty(s))
|
|
403
|
-
|
|
404
|
-
if (!stripChars)
|
|
405
|
-
return s;
|
|
377
|
+
if (isEmpty(s)) return "";
|
|
378
|
+
if (!stripChars) return s;
|
|
406
379
|
return stripEnd_(s, new Set(Array.from(stripChars)));
|
|
407
380
|
}
|
|
408
381
|
function stripEnd_(s, stripSet) {
|
|
@@ -414,14 +387,11 @@ var webitem = (() => {
|
|
|
414
387
|
return "";
|
|
415
388
|
}
|
|
416
389
|
function strip(s, stripChars = "") {
|
|
417
|
-
if (s === void 0 || s === "")
|
|
418
|
-
|
|
419
|
-
if (!stripChars)
|
|
420
|
-
return s;
|
|
390
|
+
if (s === void 0 || s === "") return "";
|
|
391
|
+
if (!stripChars) return s;
|
|
421
392
|
const stripSet = new Set(Array.from(stripChars));
|
|
422
393
|
s = stripStart_(s, stripSet);
|
|
423
|
-
if (!s)
|
|
424
|
-
return "";
|
|
394
|
+
if (!s) return "";
|
|
425
395
|
return stripEnd_(s, stripSet);
|
|
426
396
|
}
|
|
427
397
|
var LineCompare_exports = {};
|
|
@@ -434,6 +404,9 @@ var webitem = (() => {
|
|
|
434
404
|
if (t1.length !== t2.length) {
|
|
435
405
|
return `t1 has ${t1.length} lines(s) while t2 has ${t2.length} line(s).`;
|
|
436
406
|
}
|
|
407
|
+
return compareArraysOfLines(t1, t2, caseSensitive);
|
|
408
|
+
}
|
|
409
|
+
function compareArraysOfLines(t1, t2, caseSensitive) {
|
|
437
410
|
for (let i = 0; i < t1.length; i++) {
|
|
438
411
|
const result = compareTwoLines(t1[i], t2[i], i, caseSensitive);
|
|
439
412
|
if (result.length > 0) {
|
|
@@ -521,8 +494,7 @@ ${t2}`;
|
|
|
521
494
|
return oldValue;
|
|
522
495
|
}
|
|
523
496
|
function getValue({ prop, root, sel, attr, objNotBound }) {
|
|
524
|
-
if (sel)
|
|
525
|
-
return getDomVal(root, sel, attr);
|
|
497
|
+
if (sel) return getDomVal(root, sel, attr);
|
|
526
498
|
return objNotBound[prop];
|
|
527
499
|
}
|
|
528
500
|
function setValue({ prop, value, root, sel, attr, objNotBound }) {
|
|
@@ -534,13 +506,10 @@ ${t2}`;
|
|
|
534
506
|
}
|
|
535
507
|
function getDomVal(root, sel, attr) {
|
|
536
508
|
const elements = findElements(root, sel);
|
|
537
|
-
if (elements.length === 0)
|
|
538
|
-
return null;
|
|
509
|
+
if (elements.length === 0) return null;
|
|
539
510
|
let el = elements[0];
|
|
540
|
-
if (attr)
|
|
541
|
-
|
|
542
|
-
if (!isInput(el))
|
|
543
|
-
return el.innerHTML;
|
|
511
|
+
if (attr) return el.getAttribute(attr);
|
|
512
|
+
if (!isInput(el)) return el.innerHTML;
|
|
544
513
|
if (isCheckbox(el)) {
|
|
545
514
|
return elements.filter((e) => isCheckbox(e) && e.checked).map((e) => e.value === "on" ? e.name : e.value);
|
|
546
515
|
}
|
|
@@ -550,8 +519,7 @@ ${t2}`;
|
|
|
550
519
|
}
|
|
551
520
|
if (isRadio(el)) {
|
|
552
521
|
el = elements.filter(isRadio).find((e) => e.checked);
|
|
553
|
-
if (!el)
|
|
554
|
-
return void 0;
|
|
522
|
+
if (!el) return void 0;
|
|
555
523
|
}
|
|
556
524
|
if (isInputField(el)) {
|
|
557
525
|
return el.getAttribute("value");
|
|
@@ -560,8 +528,7 @@ ${t2}`;
|
|
|
560
528
|
}
|
|
561
529
|
function setDomVal(root, sel, val, attr) {
|
|
562
530
|
const elements = findElements(root, sel);
|
|
563
|
-
if (elements.length === 0)
|
|
564
|
-
return;
|
|
531
|
+
if (elements.length === 0) return;
|
|
565
532
|
const el = elements[0];
|
|
566
533
|
if (isCheckbox(el)) {
|
|
567
534
|
const v = toSet(val);
|
|
@@ -613,8 +580,7 @@ ${t2}`;
|
|
|
613
580
|
actionList,
|
|
614
581
|
eventHandlerList
|
|
615
582
|
}) {
|
|
616
|
-
if (customElements.get(nameWithDash))
|
|
617
|
-
return false;
|
|
583
|
+
if (customElements.get(nameWithDash)) return false;
|
|
618
584
|
const el = class extends HTMLElement {
|
|
619
585
|
constructor() {
|
|
620
586
|
super();
|
|
@@ -637,8 +603,7 @@ ${t2}`;
|
|
|
637
603
|
}
|
|
638
604
|
function bindProperties(root, propertyList) {
|
|
639
605
|
const result = {};
|
|
640
|
-
if (!validatePropertyList(propertyList))
|
|
641
|
-
return result;
|
|
606
|
+
if (!validatePropertyList(propertyList)) return result;
|
|
642
607
|
propertyList.forEach((p) => addProperty(result, p, root));
|
|
643
608
|
return result;
|
|
644
609
|
}
|
|
@@ -650,13 +615,11 @@ ${t2}`;
|
|
|
650
615
|
}
|
|
651
616
|
}
|
|
652
617
|
function createOnChange(prop, root) {
|
|
653
|
-
if (!prop.onChange)
|
|
654
|
-
return void 0;
|
|
618
|
+
if (!prop.onChange) return void 0;
|
|
655
619
|
return (oldValue, newValue) => prop.onChange(root, oldValue, newValue);
|
|
656
620
|
}
|
|
657
621
|
function validatePropertyList(propertyList) {
|
|
658
|
-
if (!propertyList)
|
|
659
|
-
return false;
|
|
622
|
+
if (!propertyList) return false;
|
|
660
623
|
if (!Array.isArray(propertyList)) {
|
|
661
624
|
throw "propertyList must be an array of {name, value, [sel], [attr]} objects";
|
|
662
625
|
}
|
|
@@ -664,21 +627,18 @@ ${t2}`;
|
|
|
664
627
|
}
|
|
665
628
|
function defineActions(root, actionList) {
|
|
666
629
|
const actions = {};
|
|
667
|
-
if (!actionList)
|
|
668
|
-
return actions;
|
|
630
|
+
if (!actionList) return actions;
|
|
669
631
|
actionList.forEach((pair) => {
|
|
670
632
|
addAction(root, actions, pair.name, pair.action);
|
|
671
633
|
});
|
|
672
634
|
return actions;
|
|
673
635
|
}
|
|
674
636
|
function addAction(root, actions, name, action) {
|
|
675
|
-
if (!Objecter_exports.isString(name) || !Objecter_exports.isFunction(action))
|
|
676
|
-
return;
|
|
637
|
+
if (!Objecter_exports.isString(name) || !Objecter_exports.isFunction(action)) return;
|
|
677
638
|
actions[name] = action.bind(root);
|
|
678
639
|
}
|
|
679
640
|
function addEventListeners(root, eventHandlerList) {
|
|
680
|
-
if (!eventHandlerList)
|
|
681
|
-
return;
|
|
641
|
+
if (!eventHandlerList) return;
|
|
682
642
|
if (!Array.isArray(eventHandlerList)) {
|
|
683
643
|
throw "eventHandlerList must be an array of {sel, eventName, listener} objects";
|
|
684
644
|
}
|
|
@@ -706,8 +666,7 @@ ${t2}`;
|
|
|
706
666
|
}
|
|
707
667
|
function buildCss(css) {
|
|
708
668
|
css = Stringer_exports.trim(css);
|
|
709
|
-
if (css.length === 0)
|
|
710
|
-
return "";
|
|
669
|
+
if (css.length === 0) return "";
|
|
711
670
|
if (!Stringer_exports.startsWith(css, "<style>", false)) {
|
|
712
671
|
css = Domer_exports.tag("style", {}, css);
|
|
713
672
|
}
|
|
@@ -715,8 +674,7 @@ ${t2}`;
|
|
|
715
674
|
}
|
|
716
675
|
function displayStyle(display) {
|
|
717
676
|
display = Stringer_exports.trim(display);
|
|
718
|
-
if (display.length === 0)
|
|
719
|
-
return "";
|
|
677
|
+
if (display.length === 0) return "";
|
|
720
678
|
return `
|
|
721
679
|
<style>
|
|
722
680
|
:host { display: ${display};}
|
package/eslint.config.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import js from '@eslint/js'
|
|
2
|
+
import globals from "globals"
|
|
3
|
+
import { defineConfig } from 'eslint/config'
|
|
4
|
+
|
|
5
|
+
const error = 'error'
|
|
6
|
+
const readonly = 'readonly'
|
|
7
|
+
const always = 'always'
|
|
8
|
+
const never = 'never'
|
|
9
|
+
|
|
10
|
+
export default defineConfig([
|
|
11
|
+
{
|
|
12
|
+
files: ['**/*.js'],
|
|
13
|
+
plugins: { js },
|
|
14
|
+
extends: ['js/recommended'],
|
|
15
|
+
|
|
16
|
+
languageOptions: {
|
|
17
|
+
ecmaVersion: 'latest',
|
|
18
|
+
sourceType: 'module',
|
|
19
|
+
|
|
20
|
+
globals: {
|
|
21
|
+
...globals.browser,
|
|
22
|
+
describe: readonly,
|
|
23
|
+
it: readonly,
|
|
24
|
+
beforeEach: readonly,
|
|
25
|
+
afterEach: readonly
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
rules: {
|
|
30
|
+
indent: [error, 2],
|
|
31
|
+
'linebreak-style': [error, 'unix'],
|
|
32
|
+
quotes: [error, 'single'],
|
|
33
|
+
semi: [error, never],
|
|
34
|
+
|
|
35
|
+
'block-scoped-var': [error],
|
|
36
|
+
complexity: [error, 6],
|
|
37
|
+
'dot-location': [error, 'object'],
|
|
38
|
+
eqeqeq: [error, always],
|
|
39
|
+
'no-else-return': [error],
|
|
40
|
+
'no-multi-spaces': [error, { ignoreEOLComments: true }],
|
|
41
|
+
'no-octal': [error],
|
|
42
|
+
'no-octal-escape': [error],
|
|
43
|
+
'no-return-assign': [error, always],
|
|
44
|
+
'no-sequences': [error],
|
|
45
|
+
'no-useless-concat': [error],
|
|
46
|
+
'no-useless-return': [error],
|
|
47
|
+
radix: [error],
|
|
48
|
+
yoda: [error],
|
|
49
|
+
|
|
50
|
+
'no-label-var': [error],
|
|
51
|
+
'brace-style': [error, '1tbs', {allowSingleLine: true}],
|
|
52
|
+
'comma-spacing': [error, {before: false, after: true}],
|
|
53
|
+
'comma-style': [error, 'last'],
|
|
54
|
+
'func-call-spacing': [error, never],
|
|
55
|
+
'key-spacing': [error, {beforeColon: false, afterColon:true}],
|
|
56
|
+
'keyword-spacing': [error],
|
|
57
|
+
'max-depth': [error, 4],
|
|
58
|
+
'max-len': [error, {code: 120, comments: 100, ignoreUrls: true}],
|
|
59
|
+
'max-lines': [error, {max: 300, skipBlankLines: true, skipComments: false}],
|
|
60
|
+
'max-lines-per-function': [error, {max: 200, skipBlankLines: true, skipComments: true, IIFEs: false}],
|
|
61
|
+
'max-nested-callbacks': [error, 4],
|
|
62
|
+
'max-params': [error, 5],
|
|
63
|
+
'max-statements': [error, 10],
|
|
64
|
+
'max-statements-per-line': [error, {max: 2}],
|
|
65
|
+
'new-cap': [error],
|
|
66
|
+
'new-parens': [error, always],
|
|
67
|
+
'no-array-constructor': [error],
|
|
68
|
+
'no-bitwise': [error],
|
|
69
|
+
'no-lonely-if': [error],
|
|
70
|
+
'no-multi-assign': [error],
|
|
71
|
+
'no-multiple-empty-lines': [error, {max: 3, maxBOF: 1, maxEOF: 1}],
|
|
72
|
+
'no-nested-ternary': [error],
|
|
73
|
+
'no-new-object': [error],
|
|
74
|
+
'no-tabs': [error],
|
|
75
|
+
'no-trailing-spaces': [error],
|
|
76
|
+
'no-unneeded-ternary': [error],
|
|
77
|
+
'no-whitespace-before-property': [error],
|
|
78
|
+
'nonblock-statement-body-position': [error, 'beside'],
|
|
79
|
+
'prefer-exponentiation-operator': [error],
|
|
80
|
+
'quote-props': [error, 'as-needed'],
|
|
81
|
+
'semi-spacing': [error],
|
|
82
|
+
'semi-style': [error],
|
|
83
|
+
'space-before-function-paren': [error, never],
|
|
84
|
+
'space-infix-ops': [error],
|
|
85
|
+
'spaced-comment': [error, always],
|
|
86
|
+
'switch-colon-spacing': [error],
|
|
87
|
+
'no-duplicate-imports': [error],
|
|
88
|
+
'no-useless-computed-key': [error],
|
|
89
|
+
'no-useless-constructor': [error],
|
|
90
|
+
'no-var': [error],
|
|
91
|
+
'prefer-const': [error],
|
|
92
|
+
'prefer-rest-params': [error]
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
]);
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@techexp/webitem",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Library to simplify creating Web Components/Custom Elements",
|
|
5
5
|
"author": "Abdul Habra",
|
|
6
6
|
"license": "Apache",
|
|
7
7
|
"repository": "ahabra/webitem",
|
|
8
8
|
"main": "dist/webitem-esm.js",
|
|
9
|
+
"type": "module",
|
|
9
10
|
"keywords": [
|
|
10
11
|
"web component",
|
|
11
12
|
"custom element"
|
|
@@ -29,18 +30,18 @@
|
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@esm-bundle/chai": "^4.3.4",
|
|
32
|
-
"@web/test-runner": "^0.
|
|
33
|
+
"@web/test-runner": "^0.20.2",
|
|
33
34
|
"@web/test-runner-commands": "^0.9.0",
|
|
34
|
-
"@web/test-runner-puppeteer": "^0.
|
|
35
|
-
"chalk": "^5.
|
|
36
|
-
"esbuild": "^0.
|
|
37
|
-
"eslint": "^
|
|
38
|
-
"fs-extra": "^11.
|
|
39
|
-
"npm-check-updates": "^
|
|
40
|
-
"serve": "^14.2.
|
|
35
|
+
"@web/test-runner-puppeteer": "^0.18.0",
|
|
36
|
+
"chalk": "^5.4.1",
|
|
37
|
+
"esbuild": "^0.25.4",
|
|
38
|
+
"eslint": "^9.27.0",
|
|
39
|
+
"fs-extra": "^11.3.0",
|
|
40
|
+
"npm-check-updates": "^18.0.1",
|
|
41
|
+
"serve": "^14.2.4"
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
|
-
"@techexp/data-bind": "^0.9.
|
|
44
|
-
"@techexp/jshelper": "^0.
|
|
44
|
+
"@techexp/data-bind": "^0.9.4",
|
|
45
|
+
"@techexp/jshelper": "^0.7.0"
|
|
45
46
|
}
|
|
46
47
|
}
|
package/.eslintrc.js
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
const error = 'error'
|
|
2
|
-
const readonly = 'readonly'
|
|
3
|
-
const always = 'always'
|
|
4
|
-
const never = 'never'
|
|
5
|
-
|
|
6
|
-
module.exports = {
|
|
7
|
-
extends: 'eslint:recommended',
|
|
8
|
-
|
|
9
|
-
env: {
|
|
10
|
-
browser: true,
|
|
11
|
-
es2021: true
|
|
12
|
-
},
|
|
13
|
-
|
|
14
|
-
parserOptions: {
|
|
15
|
-
ecmaVersion: 12,
|
|
16
|
-
sourceType: 'module'
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
globals: {
|
|
20
|
-
describe: readonly,
|
|
21
|
-
it: readonly,
|
|
22
|
-
beforeEach: readonly,
|
|
23
|
-
afterEach: readonly
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
rules: {
|
|
27
|
-
indent: [error, 2],
|
|
28
|
-
'linebreak-style': [error, 'unix'],
|
|
29
|
-
quotes: [error, 'single'],
|
|
30
|
-
semi: [error, never],
|
|
31
|
-
|
|
32
|
-
'block-scoped-var': [error],
|
|
33
|
-
complexity: [error, 4],
|
|
34
|
-
'dot-location': [error, 'object'],
|
|
35
|
-
eqeqeq: [error, always],
|
|
36
|
-
'no-else-return': [error],
|
|
37
|
-
'no-multi-spaces': [error, { ignoreEOLComments: true }],
|
|
38
|
-
'no-octal': [error],
|
|
39
|
-
'no-octal-escape': [error],
|
|
40
|
-
'no-return-assign': [error, always],
|
|
41
|
-
'no-sequences': [error],
|
|
42
|
-
'no-useless-concat': [error],
|
|
43
|
-
'no-useless-return': [error],
|
|
44
|
-
radix: [error],
|
|
45
|
-
yoda: [error],
|
|
46
|
-
|
|
47
|
-
'no-label-var': [error],
|
|
48
|
-
'brace-style': [error, '1tbs', {allowSingleLine: true}],
|
|
49
|
-
'comma-spacing': [error, {before: false, after: true}],
|
|
50
|
-
'comma-style': [error, 'last'],
|
|
51
|
-
'func-call-spacing': [error, never],
|
|
52
|
-
'key-spacing': [error, {beforeColon: false, afterColon:true}],
|
|
53
|
-
'keyword-spacing': [error],
|
|
54
|
-
'max-depth': [error, 4],
|
|
55
|
-
'max-len': [error, {code: 120, comments: 100, ignoreUrls: true}],
|
|
56
|
-
'max-lines': [error, {max: 250, skipBlankLines: true, skipComments: false}],
|
|
57
|
-
'max-lines-per-function': [error, {max: 200, skipBlankLines: true, skipComments: true, IIFEs: false}],
|
|
58
|
-
'max-nested-callbacks': [error, 4],
|
|
59
|
-
'max-params': [error, 5],
|
|
60
|
-
'max-statements': [error, 10],
|
|
61
|
-
'max-statements-per-line': [error, {max: 2}],
|
|
62
|
-
'new-cap': [error],
|
|
63
|
-
'new-parens': [error, always],
|
|
64
|
-
'no-array-constructor': [error],
|
|
65
|
-
'no-bitwise': [error],
|
|
66
|
-
'no-lonely-if': [error],
|
|
67
|
-
'no-multi-assign': [error],
|
|
68
|
-
'no-multiple-empty-lines': [error, {max: 3, maxBOF: 1, maxEOF: 1}],
|
|
69
|
-
'no-nested-ternary': [error],
|
|
70
|
-
'no-new-object': [error],
|
|
71
|
-
'no-tabs': [error],
|
|
72
|
-
'no-trailing-spaces': [error],
|
|
73
|
-
'no-unneeded-ternary': [error],
|
|
74
|
-
'no-whitespace-before-property': [error],
|
|
75
|
-
'nonblock-statement-body-position': [error, 'beside'],
|
|
76
|
-
'prefer-exponentiation-operator': [error],
|
|
77
|
-
'quote-props': [error, 'as-needed'],
|
|
78
|
-
'semi-spacing': [error],
|
|
79
|
-
'semi-style': [error],
|
|
80
|
-
'space-before-function-paren': [error, never],
|
|
81
|
-
'space-infix-ops': [error],
|
|
82
|
-
'spaced-comment': [error, always],
|
|
83
|
-
'switch-colon-spacing': [error],
|
|
84
|
-
'no-duplicate-imports': [error],
|
|
85
|
-
'no-useless-computed-key': [error],
|
|
86
|
-
'no-useless-constructor': [error],
|
|
87
|
-
'no-var': [error],
|
|
88
|
-
'prefer-const': [error],
|
|
89
|
-
'prefer-rest-params': [error]
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}
|