jqx-es 1.2.7 → 1.2.9
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/Bundle/jqx.browser.min.js +14 -14
- package/Bundle/jqx.min.js +14 -14
- package/Resource/Common/DOM.js +2 -5
- package/Resource/Common/DOMCleanup.js +1 -2
- package/Resource/Common/Popup.js +21 -4
- package/Resource/Common/Utilities.js +196 -2
- package/Resource/Common/WebComponentFactory.min.js +11 -0
- package/Resource/Common/cright.css +40 -0
- package/Resource/Common/css.min.js +31 -0
- package/Resource/Common/highlight.min.js +418 -0
- package/Resource/Common/javascript.min.js +81 -0
- package/Resource/Common/rainbow.min.css +1 -0
- package/Resource/Common/xml.min.js +29 -0
- package/package.json +1 -1
- package/src/JQxConstructorFactory.js +2 -2
- package/src/JQxCreatorFactory.js +4 -7
- package/src/JQxInstanceMethods.js +8 -11
- package/src/JQxUtilities.js +11 -191
package/Resource/Common/Popup.js
CHANGED
|
@@ -8,10 +8,18 @@ export default function($) {
|
|
|
8
8
|
const [popupContent, popupNode] = [$(`#jqxPopupContent`), $.node(`#jqxPopup`)];
|
|
9
9
|
let currentProps = {};
|
|
10
10
|
$.handle( { type: `click, keydown`, handlers: genericPopupCloseHandler, capture: true } );
|
|
11
|
-
return Object.freeze({show: initPopup, removeModal});
|
|
11
|
+
return Object.freeze({show: initPopup, remove: initHidePopup, removeModal});
|
|
12
12
|
|
|
13
13
|
function initPopup(props) {
|
|
14
|
-
if (popupNode.open) {
|
|
14
|
+
if (popupNode.open) {
|
|
15
|
+
switch(true) {
|
|
16
|
+
case isCurrent(props): return;
|
|
17
|
+
default:
|
|
18
|
+
initHidePopup();
|
|
19
|
+
return setTimeout(() => initPopup(props), 200);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
15
23
|
currentProps = {...props};
|
|
16
24
|
let {content} = currentProps;
|
|
17
25
|
return !($.IS(content, String, HTMLElement) || content?.isJQx) ? true : showPopup();
|
|
@@ -19,11 +27,18 @@ export default function($) {
|
|
|
19
27
|
|
|
20
28
|
function initHidePopup() {
|
|
21
29
|
if (currentProps.modal) {
|
|
22
|
-
return failModalClose(currentProps.warnMessage)
|
|
30
|
+
return failModalClose(currentProps.warnMessage);
|
|
23
31
|
}
|
|
24
32
|
|
|
25
33
|
return hidePopup();
|
|
26
34
|
}
|
|
35
|
+
|
|
36
|
+
function isCurrent(props) {
|
|
37
|
+
for (const [key, value] of Object.entries(currentProps)) {
|
|
38
|
+
if (value !== props[key]) { return false; }
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
27
42
|
|
|
28
43
|
function showPopup() {
|
|
29
44
|
popupContent.clear();
|
|
@@ -37,7 +52,9 @@ export default function($) {
|
|
|
37
52
|
|
|
38
53
|
function hidePopup() {
|
|
39
54
|
popupNode.close(currentProps.returnValue);
|
|
40
|
-
if ($.IS(currentProps.callback, Function)) {
|
|
55
|
+
if ($.IS(currentProps.callback, Function)) {
|
|
56
|
+
return setTimeout(() => currentProps.callback(currentProps.returnValue), 200);
|
|
57
|
+
}
|
|
41
58
|
currentProps = {};
|
|
42
59
|
}
|
|
43
60
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
import { default as IS, maybe } from "./TypeofAnything.js";
|
|
2
|
+
import {ATTRS} from "./EmbedResources.js";
|
|
3
|
+
import {default as tagFNFactory} from "./tinyDOM.js";
|
|
4
|
+
import styleFactory from "./LifeCSS.js";
|
|
5
|
+
import {createElementFromHtmlString, inject2DOMTree, cleanupHtml} from "./DOM.js";
|
|
6
|
+
import PopupFactory from "./Popup.js";
|
|
7
|
+
import { listeners, default as HandleFactory } from "./HandlerFactory.js";
|
|
8
|
+
import tagLib from "./HTMLTags.js";
|
|
2
9
|
|
|
3
10
|
const systemLog = systemLogFactory();
|
|
4
11
|
const insertPositions = Object.freeze(new Proxy({
|
|
@@ -8,9 +15,40 @@ const insertPositions = Object.freeze(new Proxy({
|
|
|
8
15
|
after: "afterend", afterend: "afterend" }, {
|
|
9
16
|
get(obj, key) { return obj[String(key).toLowerCase()] ?? obj[key]; }
|
|
10
17
|
}));
|
|
18
|
+
const characters4RandomString = [...Array(26)]
|
|
19
|
+
.map((x, i) => String.fromCharCode(i + 65))
|
|
20
|
+
.concat([...Array(26)].map((x, i) => String.fromCharCode(i + 97)))
|
|
21
|
+
.concat([...Array(10)].map((x, i) => `${i}`));
|
|
22
|
+
const datasetKeyProxy = Object.freeze({
|
|
23
|
+
get(obj, key) { return obj[toCamelcase(key)] || obj[key]; },
|
|
24
|
+
enumerable: false,
|
|
25
|
+
configurable: false
|
|
26
|
+
});
|
|
11
27
|
|
|
12
|
-
export {
|
|
13
|
-
|
|
28
|
+
export {
|
|
29
|
+
after, applyStyle, assignAttrValues, ATTRS, before, checkProp, cleanupHtml, cloneAndDestroy,
|
|
30
|
+
createElementFromHtmlString, datasetKeyProxy, inject2DOMTree, ElemArray2HtmlString, emptyElement,
|
|
31
|
+
escHtml, findParentScrollDistance, HandleFactory, input2Collection, insertPositions, IS, isArrayOfHtmlElements,
|
|
32
|
+
isArrayOfHtmlStrings, isComment, isCommentOrTextNode, isHtmlString, isModal, isNode, isNonEmptyString,
|
|
33
|
+
isText, isVisible, isWritable, listeners, logTime, maybe, pad0, PopupFactory, randomNr, randomString,
|
|
34
|
+
resolveEventTypeParameter, setData, styleFactory, systemLog, tagFNFactory, tagLib, toCamelcase,
|
|
35
|
+
toDashedNotation, truncate2SingleStr, truncateHtmlStr, ucFirst,
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function checkProp(prop) {
|
|
39
|
+
return prop.startsWith(`data`) || ATTRS.html.find(attr => prop.toLowerCase() === attr);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function emptyElement(el) {
|
|
43
|
+
return el && (el.textContent = "");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function findParentScrollDistance(node, distance = 0, top = true) {
|
|
47
|
+
node = node?.parentElement;
|
|
48
|
+
const what = top ? `scrollTop` : `scrollLeft`;
|
|
49
|
+
distance += node ? node[what] : 0;
|
|
50
|
+
return !node ? distance : findParentScrollDistance(node, distance, top);
|
|
51
|
+
}
|
|
14
52
|
|
|
15
53
|
function isNonEmptyString(str, minlen = 1) {
|
|
16
54
|
minlen = IS(minlen, Number) && minlen || 1;
|
|
@@ -86,11 +124,167 @@ function logTime() {
|
|
|
86
124
|
pad0(d.getSeconds())}.${pad0(d.getMilliseconds(), 3)}]`)(new Date());
|
|
87
125
|
}
|
|
88
126
|
|
|
127
|
+
function assignAttrValues(el, keyValuePairs) {
|
|
128
|
+
if (el) {
|
|
129
|
+
for (let [key, value] of Object.entries(keyValuePairs)) {
|
|
130
|
+
key = toDashedNotation(key);
|
|
131
|
+
if (key.startsWith(`data`)) {
|
|
132
|
+
return setData(el, value);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
if (IS(value, String) && checkProp(key)) {
|
|
136
|
+
el.setAttribute(key, value.split(/[, ]/)?.join(` `));
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function setData(el, keyValuePairs) {
|
|
143
|
+
if (el && IS(keyValuePairs, Object)) {
|
|
144
|
+
for (const [key, value] of Object.entries(keyValuePairs)) {
|
|
145
|
+
el.setAttribute(`data-${toDashedNotation(key)}`, value);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function input2Collection(input) {
|
|
151
|
+
return !input ? []
|
|
152
|
+
: IS(input, Proxy) ? [input.EL]
|
|
153
|
+
: IS(input, NodeList) ? [...input]
|
|
154
|
+
: isNode(input) ? [input]
|
|
155
|
+
: isArrayOfHtmlElements(input) ? input
|
|
156
|
+
: input.isJQx ? input.collection : undefined;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function after(instance, elem2AddAfter) {
|
|
160
|
+
return instance.andThen(elem2AddAfter);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function before (instance, elem2AddBefore) {
|
|
164
|
+
return instance.andThen(elem2AddBefore, true);
|
|
165
|
+
}
|
|
166
|
+
|
|
89
167
|
function isNode(input) {
|
|
90
168
|
return IS(input, Text, HTMLElement, Comment)
|
|
91
169
|
}
|
|
92
170
|
|
|
171
|
+
function applyStyle(el, rules) {
|
|
172
|
+
if (IS(rules, Object)) {
|
|
173
|
+
for (let [key, value] of Object.entries(rules)) {
|
|
174
|
+
let priority;
|
|
175
|
+
if (/!important/i.test(value)) {
|
|
176
|
+
value = value.slice(0, value.indexOf(`!`)).trim();
|
|
177
|
+
priority = 'important';
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
el.style.setProperty(toDashedNotation(key), value, priority)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
function cloneAndDestroy(elem) {
|
|
186
|
+
const cloned = elem.cloneNode(true)
|
|
187
|
+
cloned.removeAttribute && cloned.removeAttribute(`id`);
|
|
188
|
+
elem.isConnected ? elem.remove() : elem = null;
|
|
189
|
+
return cloned;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
function isVisible(el) {
|
|
194
|
+
if (!el) { return undefined; }
|
|
195
|
+
const elStyle = el.style;
|
|
196
|
+
const computedStyle = getComputedStyle(el);
|
|
197
|
+
const invisible = [elStyle.visibility, computedStyle.visibility].includes("hidden");
|
|
198
|
+
const noDisplay = [elStyle.display, computedStyle.display].includes("none");
|
|
199
|
+
const offscreen = el.offsetTop < 0 || (el.offsetLeft + el.offsetWidth) < 0
|
|
200
|
+
|| el.offsetLeft > document.body.offsetWidth;
|
|
201
|
+
const noOpacity = +computedStyle.opacity === 0 || +(elStyle.opacity || 1) === 0;
|
|
202
|
+
return !(offscreen || noOpacity || noDisplay || invisible);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function isWritable(elem) {
|
|
206
|
+
return [...elem.parentNode.querySelectorAll(`:is(:read-write)`)]?.find(el => el === elem) ?? false;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function ElemArray2HtmlString(elems) {
|
|
210
|
+
return elems?.filter(el => el).reduce((acc, el) =>
|
|
211
|
+
acc.concat(isComment(el) ? `<!--${el.data}-->`
|
|
212
|
+
: isCommentOrTextNode(el) ? el.textContent
|
|
213
|
+
: el.outerHTML), ``);
|
|
214
|
+
}
|
|
215
|
+
|
|
93
216
|
/* private */
|
|
94
217
|
function pad0(nr, n=2) {
|
|
95
218
|
return `${nr}`.padStart(n, `0`);
|
|
96
219
|
}
|
|
220
|
+
|
|
221
|
+
function randomNr(max, min = 0) {
|
|
222
|
+
[max, min] = [Math.floor(max), Math.ceil(min)];
|
|
223
|
+
return Math.floor( ([...crypto.getRandomValues(new Uint32Array(1))].shift() / 2 ** 32 ) * (max - min + 1) + min );
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
function randomString() {
|
|
227
|
+
return `_${shuffle(characters4RandomString).slice(0, 8).join(``)}`;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function resolveEventTypeParameter (maybeTypes) {
|
|
231
|
+
maybeTypes = IS(maybeTypes, String) && /,/.test(maybeTypes) ? maybeTypes.split(`,`) : maybeTypes;
|
|
232
|
+
return IS(maybeTypes, Array)
|
|
233
|
+
? maybeTypes.filter(t => isNonEmptyString(t)).map(t => t.trim().toLowerCase())
|
|
234
|
+
: IS(maybeTypes, String) && maybeTypes?.trim().toLowerCase() || ``;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function isModal(elem) {
|
|
238
|
+
return [...elem.parentNode.querySelectorAll(`:is(:modal)`)]?.find(el => el === elem) ?? false;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/* private */
|
|
242
|
+
function shuffle(array) {
|
|
243
|
+
let i = array.length;
|
|
244
|
+
while (i--) {
|
|
245
|
+
const ri = randomNr(i);
|
|
246
|
+
[array[i], array[ri]] = [array[ri], array[i]];
|
|
247
|
+
}
|
|
248
|
+
return array;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function toCamelcase(str2Convert) {
|
|
252
|
+
return IS(str2Convert, String)
|
|
253
|
+
? str2Convert.toLowerCase()
|
|
254
|
+
.split(`-`)
|
|
255
|
+
.map( (str, i) => i && `${ucFirst(str)}` || str)
|
|
256
|
+
.join(``)
|
|
257
|
+
: str2Convert;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
function toDashedNotation(str2Convert) {
|
|
261
|
+
return str2Convert.replace(/[A-Z]/g, a => `-${a.toLowerCase()}`).replace(/^-|-$/, ``);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
function ucFirst([first, ...theRest]) {
|
|
265
|
+
return `${first.toUpperCase()}${theRest.join(``)}`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function isCommentOrTextNode(node) {
|
|
269
|
+
return IS(node, Comment, Text);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function isComment(input) {
|
|
273
|
+
IS(input, Comment);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
function isText(input) {
|
|
277
|
+
return IS(input, Text);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
function isHtmlString(input) {
|
|
281
|
+
return IS(input, String) && /^<|>$/.test(`${input}`.trim());
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function isArrayOfHtmlElements(input) {
|
|
285
|
+
return IS(input, Array) && !input?.find(el => !isNode(el));
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
function isArrayOfHtmlStrings(input) {
|
|
289
|
+
return IS(input, Array) && !input?.find(s => !isHtmlString(s));
|
|
290
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function d(t,...e){let n=typeof t=="symbol"?Symbol("any"):t;return e.length>1?L(n,...e):P(n,...e)}function P(t,...e){let{compareWith:n,inputIsNothing:o,shouldBeIsNothing:r,inputCTOR:a,is_NAN:c}=j(t,...e);return c&&n?(n=S({trial:l=>String(n),whenError:l=>""}),n===String(t)||e===Number):o||r?r?String(t)===String(n):n?!1:`${t}`:a===Boolean?n?a===n:"Boolean":M(t,n,I(t,a))}function I(t,e){return t===0?Number:t===""?String:t?e:{name:String(t)}}function j(t,...e){let n=e.length>0,o=n&&e.shift(),r=_(t),a=n&&_(o),c=!r&&Object.getPrototypeOf(t)?.constructor,l=S({trial:i=>String(t),whenError:i=>""})==="NaN";return{compareWith:o,inputIsNothing:r,shouldBeIsNothing:a,inputCTOR:c,is_NAN:l}}function M(t,e,n){return S({trial:o=>String(e),whenError:o=>"-"})==="NaN"?String(t)==="NaN":e?S({trial:o=>t instanceof e,whenError:o=>!1})||e===n||e===Object.getPrototypeOf(n)||`${e?.name}`===n?.name:n?.name}function L(t,...e){for(let n of e)if(d(t,n))return!0;return!1}function _(t){return S({trial:e=>/^(undefined|null)$/.test(String(t)),whenError:e=>!1})}function S({trial:t,whenError:e=n=>console.log(n)}={}){if(!t||!(t instanceof Function))return console.info("TypeofAnything {maybe}: trial parameter not a Function or Lambda"),!1;try{return t()}catch(n){return e(n)}}function H({IS:t,tryJSON:e,contractsPrefix:n}={}){return n=n&&`${n}
|
|
2
|
+
`||"",{EN:{unknownOrNa:"unknown or n/a",unknown:"unknown",nameOkExpected:"The contract to add needs a name (String)",isMethodExpected:"The contract to add needs a method (Function)",expectedOkExpected:"The contract to add needs an expected value method (String|Function)",addContracts_Contract_Expected:"the parameter for [addContracts] should be at least { [contractName]: { method: Function, expected: String|Function } }",addContract_Contract_Expected:`addContract parameters should at least be {name, method, expected}
|
|
3
|
+
(when method is a named function, the name was derived from that)`,report_sorry:(o,r)=>`\u2718 ${n}Contract violation for contract [${o}], input ${r}`,report_forValue:o=>`${o}`,report_Expected:o=>`
|
|
4
|
+
${o}`,report_defaultValue:(o,r)=>o?"":`
|
|
5
|
+
Using the contract default value (${t(r,Function)?r.toString():t(r,String)?`"${r}"`:e(r)}) instead`},NL:{unknownOrNa:"onbekend of nvt",unknown:"onbekend",nameOkExpected:"Het contract moet een naam hebben (eigenschap name: String)",isMethodExpected:"Het contract moet kunnen worden uitgevoerd (eigenschap method: Function)",expectedOkExpected:"Het contract moet aangeven wat er wordt verwacht (eigenschap expected: String|Function)",addContracts_Contract_Expected:"De parameter for [addContracts] moet tenminste { [contractName]: { method: Function, expected: String|Function } } zijn",addContract_Contract_Expected:`De invoer vooor [addContract] moet tenminste {name, method, expected} zijn
|
|
6
|
+
(wanneer de eigenschap [method] een functie met naam was wordt [name] daarvan afgeleid)`,report_sorry:(o,r)=>`\u2718 ${n} Contractbreuk voor contract [${o}], input ${r}`,report_forValue:o=>`${o}`,report_Expected:o=>`
|
|
7
|
+
${o}`,report_defaultValue:(o,r)=>o?"":`
|
|
8
|
+
In plaats daarvan wordt de voor dit contract toegekende standaardwaarde (${t(r,Function)?r.toString():t(r,String)?`"${r}"`:e(r)}) gebruikt`}}}var s,F=z,v=q(),A=J();function z(t){l(t);let{reporter:e,logViolations:n,alwaysThrow:o,language:r,contractsPrefix:a}=t;s=H({IS:d,tryJSON:N,contractsPrefix:a})[r];let c={addContract:b,addContracts:i};return U(c),Object.freeze({contracts:c,IS:d,tryJSON:N});function l(u){u.reporter=u.reporter||E,u.logViolations=u.logViolations||!1,u.alwaysThrow=u.alwaysThrow||!1,u.language=u.language||"EN"}function i(u){if(!c.addContracts_Contract(u))return;let m=Object.entries(u);for(let[p,h]of m)b({...h,paramsChecked:!0,name:p})}function b(u=v.addContract){let{name:m,method:p,expected:h,defaultValue:y,customReport:g,reportFn:O,shouldThrow:V,reportViolationsByDefault:w,paramsChecked:x}=u;m=m||p?.name;let B=c.addContract_Contract||A.checkSingleContractParameters;if(!x&&!B({name:m,method:p,expected:h}))return;let D=W({name:m,method:p,expected:h,defaultValue:y,reporter:e,reportFn:O,customReport:g,reportViolationsByDefault:w,logViolations:n,shouldThrow:V,alwaysThrow:o});return Object.defineProperty(c,m,{value:D,enumerable:!0})}}function W(t=v.createContract){let{name:e,method:n,expected:o,defaultValue:r,customReport:a,reportFn:c,reporter:l,logViolations:i,shouldThrow:b,reportViolationsByDefault:u,alwaysThrow:m}=t;return function(p,...h){let y=n(p,...h),g=d(h[0],Object)&&{...h[0],value:p}||{value:p};if(c=c??l??E,d(a,Function)&&a(g),$(y)){let O=d(o,Function)?o(g):o;y=!$(g.defaultValue)||r?g.defaultValue||r:y;let[V,w]=[g.reportViolation??u,g.shouldThrow??b];if(V||w||i){let x=K({inputValue:p,defaultValue:y,shouldBe:O,fnName:e||n.name});if(w||m)throw new TypeError(x);l(x)}}return y}}function q(){let[t,e,n,o,r,a,c]=[...Array(7)];return{get reportViolations(){return{inputValue:c,defaultValue:o,shouldBe:s.unknowOrNa,fnName:s.unknown}},get createContract(){return{name:t,method:e,expected:n,defaultValue:o,customReport:r,reportFn:a,reporter:E,logViolations:!1,shouldThrow:!1,alwaysThrow:!1,reportViolationsByDefault:!1}},get addContract(){return{name:t,method:e,expected:n,defaultValue:o,customReport:r,reportFn:a,reporter:E,shouldThrow:!1,reportViolationsByDefault:!1,paramsChecked:!1}}}}function J(){let t=o=>d(o,String)&&o.trim().length,e=o=>d(o,String)&&o.length||d(o,Function),n=o=>d(o,Function);return{nameOk:t,expectedOk:e,isMethod:n,checkSingleContractParameters:({name:o,method:r,expected:a}={})=>o&&t(o)&&r&&n(r)&&a&&e(a)}}function U(t){let{nameOk:e,expectedOk:n,isMethod:o,checkSingleContractParameters:r}=A;t.addContract({method:e,expected:s.nameOkExpected,reportViolationsByDefault:!0}),t.addContract({method:o,expected:s.isMethodExpected,reportViolationsByDefault:!0}),t.addContract({method:n,expected:s.expectedOkExpected,reportViolationsByDefault:!0}),t.addContract({name:"addContracts_Contract",method:a=>d(a,Object)&&[...Object.entries(a)].filter(([,c])=>c.method&&o(c.method)&&c.expected&&n(c.expected)).length>0?a:void 0,expected:s.addContracts_Contract_Expected,reportViolationsByDefault:!0}),t.addContract({name:"addContract_Contract",method:r,expected:s.addContract_Contract_Expected,reportViolationsByDefault:!0})}function K(t=v.reportViolations){let{inputValue:e,defaultValue:n,shouldBe:o,fnName:r}=t,a=s.report_sorry(r,G(e)),c=s.report_forValue(a),l=s.report_Expected(o),i=s.report_defaultValue($(n),n);return Q(`${c}${l}${i}`)}function Q(t,e=3){return t.replace(/\n/g,`
|
|
9
|
+
${" ".repeat(e)}`)}function $(t){return d(t,void 0,null,NaN)}function N(t){return X(()=>{let e=JSON.stringify(t);return/Infinity|NaN/.test(e)?e.replace(/"/g,""):e},t)}function G(t){let e=n=>d(n,String)?`"${n}"`:d(n,Object)?N(n):String(n);return d(t,String)?`"${t}"`:d(t,Object)?N(t):/Array\(/.test(t?.constructor.toString())?`[${[...t].map(e)}]`:String(t)}function E(t){console.info(t)}function X(t,e){try{return t()}catch(n){return console.error({isOk:n.name===expected,message:n.message,type:n.name}),e}}var{contracts:k,IS:f,tryJSON:Y}=F({contractsPrefix:"[Web Component creator module]"});Z();function Z(){k.addContracts({componentName:{method:tt,reportViolationsByDefault:!0,expected({customElementName:e}={}){return[`createComponent componentName: '${e??"*no name given*"}' is not a valid custom element name!`,"See https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name"].join(`
|
|
10
|
+
`)}},attrChange:{method:t,defaultValue:{attributes:[],method:function(){}},expected:"onAttrChange expected {attributes: Array, method: Function}"}});function t(e){let n=f(e,Object)&&r(e?.attributes)&&f(e?.method,Function);return e&&!n&&o(),n?e:void 0;function o(){let a=f(e?.method,Function)?"Function ok":"nothing or not a Function";console.log(["\u2718 [Web Component creator module]","createComponent onAttrChange: contract for parameters violated",`Input: { attributes: ${Y(e?.attributes)}, method: ${a} }`,"Input expected: nothing or { attributes: Array[string], method: Function({input}) {...} }","Will use default: { attributes: [], method: () => {} }"].join(`
|
|
11
|
+
`))}function r(a){return f(a,Array)&&a.filter(c=>f(c,String)&&!/\s/g.test(c)).length===a.length&&a||void 0}}}function tt(t){let e=["annotation-xml","color-profile","font-face","font-face-src","font-face-uri","font-face-format","font-face-name","missing-glyph"];return f(t,String)&&/\-{1,}/.test(t)&&t.toLowerCase()===t&&!e.find(n=>n===t)&&t||void 0}var T={};["a","area","audio","br","base","body","button","canvas","dl","data","datalist","div","em","fieldset","font","footer","form","hr","head","header","output","iframe","frameset","img","input","li","label","legend","link","map","mark","menu","media","meta","nav","meter","ol","object","optgroup","option","p","param","picture","pre","progress","quote","script","select","source","span","style","caption","td","col","table","tr","template","textarea","time","title","track","details","ul","video","del","ins","slot","blockquote","svg","dialog","summary","main","address","colgroup","tbody","tfoot","thead","th","dd","dt","figcaption","figure","i","b","code","h1","h2","h3","h4","abbr","bdo","dfn","kbd","q","rb","rp","rt","ruby","s","strike","samp","small","strong","sup","sub","u","var","wbr","nobr","tt","noscript"].forEach(t=>{Object.defineProperty(T,t,{get(){if(!t)return;let e=document.createElement(t)?.constructor;return e!==HTMLUnknownElement?e:void 0}})});var R=Object.freeze(T);var C=ut();function ht(t){t=rt(t);let{componentName:e}=t;if(k.componentName(e)&&!customElements.get(e)){let n=t.extends?.toLowerCase()?.trim(),o=R[n]??HTMLElement,r=et({forElem:o});ot(r,t),!C.clientOnly&&C.report(`[factory] Registered component "${e}"`),customElements.define(e,r,{extends:n})}}function et({forElem:t}={}){let e=t;return function n(){return n.prototype=e.prototype,nt(n),Reflect.construct(e,[],n)}}function nt(t){if(!t.prototype.setComponentState){let e={},n=o=>o.hasAttribute("is")||/-/.test(o.tagName);Object.defineProperties(t.prototype,{myName:{get:function(){return it(this)}},state:{get:function(){return n(this)&&e[this.myName]||{}}},nth:{value:function(o){return f(o,Number,void 0)&&at(this,o)||void 0}},instanceNr:{get(){return n(this)&&getInstancePositionInDom(this)}},setComponentState:{value:function(o){if(n(this)){let r=this.myName;Object.entries(o).forEach(([a,c])=>{e[r]=e[r]??{component:this.myName},e[r][a]=c})}}}})}}function ot(t,e){let{onConnect:n,onDisconnect:o,onAdopted:r,onAttrChange:a}=e,[c,l]=[a.attributes,a.method];t.observedAttributes=c,t.prototype={connectedCallback:function(){let i=this;return!C.clientOnly&&C.report(`[factory] (Re)connected an instance of <${i.myName}>`),i.shadowRoot?.isConnected?!0:n(i)},disconnectedCallback(){let i=this;!C.clientOnly&&C.report(`[factory] Removed an instance of <${i.myName}>`),o(i)},adoptedCallback(){return r(this)},attributeChangedCallback(i,b,u){if(c.length)return c.find(m=>m===i)&&l(this,i,b,u),!0}}}function rt(t){t.onAttrChange=k.attrChange(t.onAttrChange);let e=function(){};return t.onConnect=t.onConnect??e,t.onDisconnect=t.onDisconnect??e,t.onAdopted=t.onAdopted??e,t}function at(t,e=1){return[...t.getRootNode().querySelectorAll(t.myName)].find((n,o)=>e===o+1)}function ct(){let t=new Date;return[t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()].reduce((e,n,o)=>`${e}${o<3?":":"."}${`${n}`.padStart(o<3?2:3,"0")}`,"").slice(1)}function it(t){let e=t.getAttribute("is");return`${t.tagName.toLowerCase()}${e?`[is='${e}']`:""}`}function gt(t,e={mode:"open"}){let n=t.shadowRoot;return n||t.attachShadow(e)}function yt(t,e){if(t.state.styling)return t.state.styling;e=e.startsWith("#")?document.querySelector(e).content.querySelector("style").textContent:e,C.report(`[client] Storing embedded style for <${t.myName}>`);let n=new CSSStyleSheet;return n.replaceSync(e),t.setComponentState({styling:n}),t.state.styling}function ut(){let t={"<":"<",">":">"},e=!1,n=function(c){console.info(`\u2714 ${c.replaceAll(/<|>/g,l=>t[l])}`)},o=n,r=function(){},a=!1;return{on(){e=!0},off(){e=!1},get now(){return ct},set clientOnly(c){a=f(c,Boolean)&&c||!1},get clientOnly(){return a},set report(c){o=c||n},get report(){return e&&o||r}}}export{gt as createOrRetrieveShadowRoot,ht as default,C as reporter,yt as setComponentStyleFor};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
color: #555;
|
|
3
|
+
display: inline-block;
|
|
4
|
+
position: fixed;
|
|
5
|
+
background-color: #fff;
|
|
6
|
+
top: 0;
|
|
7
|
+
left: 50%;
|
|
8
|
+
transform: translateX(-50%);
|
|
9
|
+
z-index: 2;
|
|
10
|
+
border-radius: 4px;
|
|
11
|
+
padding: 2px 0;
|
|
12
|
+
width: 100vw;
|
|
13
|
+
text-align: center;
|
|
14
|
+
box-shadow: 0 2px 14px #999;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
::slotted(span.yr) {
|
|
18
|
+
font-weight: bold;
|
|
19
|
+
color: green;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
::slotted(a[target]) {
|
|
23
|
+
text-decoration: none;
|
|
24
|
+
font-weight: bold;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
::slotted(a[target]):before {
|
|
28
|
+
color: rgba(0, 0, 238, 0.7);
|
|
29
|
+
font-size: 1.1rem;
|
|
30
|
+
padding-right: 2px;
|
|
31
|
+
vertical-align: baseline;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
::slotted(a[target]):after {
|
|
35
|
+
content: ' | ';
|
|
36
|
+
color: #000;
|
|
37
|
+
font-weight: normal;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
::slotted(a[target]:last-child):after { content: ''; margin-right: 2rem; }
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*! `css` grammar compiled for Highlight.js 11.11.1 */
|
|
2
|
+
(()=>{var e=(()=>{"use strict"
|
|
3
|
+
;const e=["a","abbr","address","article","aside","audio","b","blockquote","body","button","canvas","caption","cite","code","dd","del","details","dfn","div","dl","dt","em","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","html","i","iframe","img","input","ins","kbd","label","legend","li","main","mark","menu","nav","object","ol","optgroup","option","p","picture","q","quote","samp","section","select","source","span","strong","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","ul","var","video","defs","g","marker","mask","pattern","svg","switch","symbol","feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feFlood","feGaussianBlur","feImage","feMerge","feMorphology","feOffset","feSpecularLighting","feTile","feTurbulence","linearGradient","radialGradient","stop","circle","ellipse","image","line","path","polygon","polyline","rect","text","use","textPath","tspan","foreignObject","clipPath"],i=["any-hover","any-pointer","aspect-ratio","color","color-gamut","color-index","device-aspect-ratio","device-height","device-width","display-mode","forced-colors","grid","height","hover","inverted-colors","monochrome","orientation","overflow-block","overflow-inline","pointer","prefers-color-scheme","prefers-contrast","prefers-reduced-motion","prefers-reduced-transparency","resolution","scan","scripting","update","width","min-width","max-width","min-height","max-height"].sort().reverse(),t=["active","any-link","blank","checked","current","default","defined","dir","disabled","drop","empty","enabled","first","first-child","first-of-type","fullscreen","future","focus","focus-visible","focus-within","has","host","host-context","hover","indeterminate","in-range","invalid","is","lang","last-child","last-of-type","left","link","local-link","not","nth-child","nth-col","nth-last-child","nth-last-col","nth-last-of-type","nth-of-type","only-child","only-of-type","optional","out-of-range","past","placeholder-shown","read-only","read-write","required","right","root","scope","target","target-within","user-invalid","valid","visited","where"].sort().reverse(),o=["after","backdrop","before","cue","cue-region","first-letter","first-line","grammar-error","marker","part","placeholder","selection","slotted","spelling-error"].sort().reverse(),r=["accent-color","align-content","align-items","align-self","alignment-baseline","all","anchor-name","animation","animation-composition","animation-delay","animation-direction","animation-duration","animation-fill-mode","animation-iteration-count","animation-name","animation-play-state","animation-range","animation-range-end","animation-range-start","animation-timeline","animation-timing-function","appearance","aspect-ratio","backdrop-filter","backface-visibility","background","background-attachment","background-blend-mode","background-clip","background-color","background-image","background-origin","background-position","background-position-x","background-position-y","background-repeat","background-size","baseline-shift","block-size","border","border-block","border-block-color","border-block-end","border-block-end-color","border-block-end-style","border-block-end-width","border-block-start","border-block-start-color","border-block-start-style","border-block-start-width","border-block-style","border-block-width","border-bottom","border-bottom-color","border-bottom-left-radius","border-bottom-right-radius","border-bottom-style","border-bottom-width","border-collapse","border-color","border-end-end-radius","border-end-start-radius","border-image","border-image-outset","border-image-repeat","border-image-slice","border-image-source","border-image-width","border-inline","border-inline-color","border-inline-end","border-inline-end-color","border-inline-end-style","border-inline-end-width","border-inline-start","border-inline-start-color","border-inline-start-style","border-inline-start-width","border-inline-style","border-inline-width","border-left","border-left-color","border-left-style","border-left-width","border-radius","border-right","border-right-color","border-right-style","border-right-width","border-spacing","border-start-end-radius","border-start-start-radius","border-style","border-top","border-top-color","border-top-left-radius","border-top-right-radius","border-top-style","border-top-width","border-width","bottom","box-align","box-decoration-break","box-direction","box-flex","box-flex-group","box-lines","box-ordinal-group","box-orient","box-pack","box-shadow","box-sizing","break-after","break-before","break-inside","caption-side","caret-color","clear","clip","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","color-scheme","column-count","column-fill","column-gap","column-rule","column-rule-color","column-rule-style","column-rule-width","column-span","column-width","columns","contain","contain-intrinsic-block-size","contain-intrinsic-height","contain-intrinsic-inline-size","contain-intrinsic-size","contain-intrinsic-width","container","container-name","container-type","content","content-visibility","counter-increment","counter-reset","counter-set","cue","cue-after","cue-before","cursor","cx","cy","direction","display","dominant-baseline","empty-cells","enable-background","field-sizing","fill","fill-opacity","fill-rule","filter","flex","flex-basis","flex-direction","flex-flow","flex-grow","flex-shrink","flex-wrap","float","flood-color","flood-opacity","flow","font","font-display","font-family","font-feature-settings","font-kerning","font-language-override","font-optical-sizing","font-palette","font-size","font-size-adjust","font-smooth","font-smoothing","font-stretch","font-style","font-synthesis","font-synthesis-position","font-synthesis-small-caps","font-synthesis-style","font-synthesis-weight","font-variant","font-variant-alternates","font-variant-caps","font-variant-east-asian","font-variant-emoji","font-variant-ligatures","font-variant-numeric","font-variant-position","font-variation-settings","font-weight","forced-color-adjust","gap","glyph-orientation-horizontal","glyph-orientation-vertical","grid","grid-area","grid-auto-columns","grid-auto-flow","grid-auto-rows","grid-column","grid-column-end","grid-column-start","grid-gap","grid-row","grid-row-end","grid-row-start","grid-template","grid-template-areas","grid-template-columns","grid-template-rows","hanging-punctuation","height","hyphenate-character","hyphenate-limit-chars","hyphens","icon","image-orientation","image-rendering","image-resolution","ime-mode","initial-letter","initial-letter-align","inline-size","inset","inset-area","inset-block","inset-block-end","inset-block-start","inset-inline","inset-inline-end","inset-inline-start","isolation","justify-content","justify-items","justify-self","kerning","left","letter-spacing","lighting-color","line-break","line-height","line-height-step","list-style","list-style-image","list-style-position","list-style-type","margin","margin-block","margin-block-end","margin-block-start","margin-bottom","margin-inline","margin-inline-end","margin-inline-start","margin-left","margin-right","margin-top","margin-trim","marker","marker-end","marker-mid","marker-start","marks","mask","mask-border","mask-border-mode","mask-border-outset","mask-border-repeat","mask-border-slice","mask-border-source","mask-border-width","mask-clip","mask-composite","mask-image","mask-mode","mask-origin","mask-position","mask-repeat","mask-size","mask-type","masonry-auto-flow","math-depth","math-shift","math-style","max-block-size","max-height","max-inline-size","max-width","min-block-size","min-height","min-inline-size","min-width","mix-blend-mode","nav-down","nav-index","nav-left","nav-right","nav-up","none","normal","object-fit","object-position","offset","offset-anchor","offset-distance","offset-path","offset-position","offset-rotate","opacity","order","orphans","outline","outline-color","outline-offset","outline-style","outline-width","overflow","overflow-anchor","overflow-block","overflow-clip-margin","overflow-inline","overflow-wrap","overflow-x","overflow-y","overlay","overscroll-behavior","overscroll-behavior-block","overscroll-behavior-inline","overscroll-behavior-x","overscroll-behavior-y","padding","padding-block","padding-block-end","padding-block-start","padding-bottom","padding-inline","padding-inline-end","padding-inline-start","padding-left","padding-right","padding-top","page","page-break-after","page-break-before","page-break-inside","paint-order","pause","pause-after","pause-before","perspective","perspective-origin","place-content","place-items","place-self","pointer-events","position","position-anchor","position-visibility","print-color-adjust","quotes","r","resize","rest","rest-after","rest-before","right","rotate","row-gap","ruby-align","ruby-position","scale","scroll-behavior","scroll-margin","scroll-margin-block","scroll-margin-block-end","scroll-margin-block-start","scroll-margin-bottom","scroll-margin-inline","scroll-margin-inline-end","scroll-margin-inline-start","scroll-margin-left","scroll-margin-right","scroll-margin-top","scroll-padding","scroll-padding-block","scroll-padding-block-end","scroll-padding-block-start","scroll-padding-bottom","scroll-padding-inline","scroll-padding-inline-end","scroll-padding-inline-start","scroll-padding-left","scroll-padding-right","scroll-padding-top","scroll-snap-align","scroll-snap-stop","scroll-snap-type","scroll-timeline","scroll-timeline-axis","scroll-timeline-name","scrollbar-color","scrollbar-gutter","scrollbar-width","shape-image-threshold","shape-margin","shape-outside","shape-rendering","speak","speak-as","src","stop-color","stop-opacity","stroke","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke-width","tab-size","table-layout","text-align","text-align-all","text-align-last","text-anchor","text-combine-upright","text-decoration","text-decoration-color","text-decoration-line","text-decoration-skip","text-decoration-skip-ink","text-decoration-style","text-decoration-thickness","text-emphasis","text-emphasis-color","text-emphasis-position","text-emphasis-style","text-indent","text-justify","text-orientation","text-overflow","text-rendering","text-shadow","text-size-adjust","text-transform","text-underline-offset","text-underline-position","text-wrap","text-wrap-mode","text-wrap-style","timeline-scope","top","touch-action","transform","transform-box","transform-origin","transform-style","transition","transition-behavior","transition-delay","transition-duration","transition-property","transition-timing-function","translate","unicode-bidi","user-modify","user-select","vector-effect","vertical-align","view-timeline","view-timeline-axis","view-timeline-inset","view-timeline-name","view-transition-name","visibility","voice-balance","voice-duration","voice-family","voice-pitch","voice-range","voice-rate","voice-stress","voice-volume","white-space","white-space-collapse","widows","width","will-change","word-break","word-spacing","word-wrap","writing-mode","x","y","z-index","zoom"].sort().reverse()
|
|
4
|
+
;return n=>{const a=n.regex,l=(e=>({IMPORTANT:{scope:"meta",begin:"!important"},
|
|
5
|
+
BLOCK_COMMENT:e.C_BLOCK_COMMENT_MODE,HEXCOLOR:{scope:"number",
|
|
6
|
+
begin:/#(([0-9a-fA-F]{3,4})|(([0-9a-fA-F]{2}){3,4}))\b/},FUNCTION_DISPATCH:{
|
|
7
|
+
className:"built_in",begin:/[\w-]+(?=\()/},ATTRIBUTE_SELECTOR_MODE:{
|
|
8
|
+
scope:"selector-attr",begin:/\[/,end:/\]/,illegal:"$",
|
|
9
|
+
contains:[e.APOS_STRING_MODE,e.QUOTE_STRING_MODE]},CSS_NUMBER_MODE:{
|
|
10
|
+
scope:"number",
|
|
11
|
+
begin:e.NUMBER_RE+"(%|em|ex|ch|rem|vw|vh|vmin|vmax|cm|mm|in|pt|pc|px|deg|grad|rad|turn|s|ms|Hz|kHz|dpi|dpcm|dppx)?",
|
|
12
|
+
relevance:0},CSS_VARIABLE:{className:"attr",begin:/--[A-Za-z_][A-Za-z0-9_-]*/}
|
|
13
|
+
}))(n),s=[n.APOS_STRING_MODE,n.QUOTE_STRING_MODE];return{name:"CSS",
|
|
14
|
+
case_insensitive:!0,illegal:/[=|'\$]/,keywords:{keyframePosition:"from to"},
|
|
15
|
+
classNameAliases:{keyframePosition:"selector-tag"},contains:[l.BLOCK_COMMENT,{
|
|
16
|
+
begin:/-(webkit|moz|ms|o)-(?=[a-z])/},l.CSS_NUMBER_MODE,{
|
|
17
|
+
className:"selector-id",begin:/#[A-Za-z0-9_-]+/,relevance:0},{
|
|
18
|
+
className:"selector-class",begin:"\\.[a-zA-Z-][a-zA-Z0-9_-]*",relevance:0
|
|
19
|
+
},l.ATTRIBUTE_SELECTOR_MODE,{className:"selector-pseudo",variants:[{
|
|
20
|
+
begin:":("+t.join("|")+")"},{begin:":(:)?("+o.join("|")+")"}]},l.CSS_VARIABLE,{
|
|
21
|
+
className:"attribute",begin:"\\b("+r.join("|")+")\\b"},{begin:/:/,end:/[;}{]/,
|
|
22
|
+
contains:[l.BLOCK_COMMENT,l.HEXCOLOR,l.IMPORTANT,l.CSS_NUMBER_MODE,...s,{
|
|
23
|
+
begin:/(url|data-uri)\(/,end:/\)/,relevance:0,keywords:{built_in:"url data-uri"
|
|
24
|
+
},contains:[...s,{className:"string",begin:/[^)]/,endsWithParent:!0,
|
|
25
|
+
excludeEnd:!0}]},l.FUNCTION_DISPATCH]},{begin:a.lookahead(/@/),end:"[{;]",
|
|
26
|
+
relevance:0,illegal:/:/,contains:[{className:"keyword",begin:/@-?\w[\w]*(-\w+)*/
|
|
27
|
+
},{begin:/\s/,endsWithParent:!0,excludeEnd:!0,relevance:0,keywords:{
|
|
28
|
+
$pattern:/[a-z-]+/,keyword:"and or not only",attribute:i.join(" ")},contains:[{
|
|
29
|
+
begin:/[a-z-]+(?=:)/,className:"attribute"},...s,l.CSS_NUMBER_MODE]}]},{
|
|
30
|
+
className:"selector-tag",begin:"\\b("+e.join("|")+")\\b"}]}}})()
|
|
31
|
+
;hljs.registerLanguage("css",e)})();
|