@public-ui/theme-bwst 2.2.10-rc.1 → 2.2.11-d5dad25b9084a461f833a47372b0ec3c24bc5d73.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/dist/index.mjs CHANGED
@@ -1,6 +1,67 @@
1
1
  /*!
2
2
  * KoliBri - The accessible HTML-Standard
3
3
  */
4
+ let DEV_MODE = false;
5
+ const getDevMode = () => DEV_MODE === true;
6
+ const LOG_STYLE = 'color: white; background: #666; font-weight: bold; padding: .25em .5em; border-radius: 3px; border: 1px solid #000';
7
+ const mapToArray = (msg) => {
8
+ return Array.isArray(msg) ? msg : [msg];
9
+ };
10
+ const getLogLabel = (label) => {
11
+ return `%c${label}`;
12
+ };
13
+ const handleClassifier = (label, classifier) => {
14
+ if (typeof classifier === 'string' && classifier.length > 0) {
15
+ return `${getLogLabel(label)} | ${classifier}`;
16
+ }
17
+ else {
18
+ return getLogLabel(label);
19
+ }
20
+ };
21
+ const getShield = (label, options) => {
22
+ return [handleClassifier(label, options === null || options === void 0 ? void 0 : options.classifier), `${LOG_STYLE};${(options === null || options === void 0 ? void 0 : options.overwriteStyle) || ''}`];
23
+ };
24
+ const isDevModeOrForceLog = (devMode, forceLog) => devMode() || forceLog === true;
25
+ class Logger {
26
+ constructor(label, devMode) {
27
+ this.label = label;
28
+ this.devMode = devMode;
29
+ }
30
+ debug(msg, options) {
31
+ if (isDevModeOrForceLog(this.devMode, options === null || options === void 0 ? void 0 : options.forceLog)) {
32
+ console.debug(...getShield(this.label, options), ...mapToArray(msg));
33
+ }
34
+ }
35
+ info(msg, options) {
36
+ if (isDevModeOrForceLog(this.devMode, options === null || options === void 0 ? void 0 : options.forceLog)) {
37
+ console.info(...getShield(this.label, options), ...mapToArray(msg));
38
+ }
39
+ }
40
+ trace(msg, options) {
41
+ if (isDevModeOrForceLog(this.devMode, options === null || options === void 0 ? void 0 : options.forceLog)) {
42
+ console.trace(...getShield(this.label, options), ...mapToArray(msg));
43
+ }
44
+ }
45
+ warn(msg, options) {
46
+ if (isDevModeOrForceLog(this.devMode, options === null || options === void 0 ? void 0 : options.forceLog)) {
47
+ console.warn(...getShield(this.label, options), ...mapToArray(msg));
48
+ }
49
+ }
50
+ error(msg, options) {
51
+ console.error(...getShield(this.label, options), ...mapToArray(msg));
52
+ }
53
+ throw(msg, options) {
54
+ if (isDevModeOrForceLog(this.devMode, options === null || options === void 0 ? void 0 : options.forceLog)) {
55
+ throw new Error(...getShield(this.label, options), ...mapToArray(msg));
56
+ }
57
+ }
58
+ }
59
+ const Log = new Logger('KoliBri', getDevMode);
60
+
61
+ /*!
62
+ * KoliBri - The accessible HTML-Standard
63
+ */
64
+
4
65
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5
66
 
6
67
  var loglevel = {exports: {}};
@@ -362,7 +423,245 @@ var loglevel = {exports: {}};
362
423
  }));
363
424
  }(loglevel));
364
425
 
365
- const j=(t,e)=>s=>s(t,e),H=(t,e)=>s=>s(t,e,{append:false}),M=new Map,Y=[],$=new Map,o={A11yUi:{CSS_STYLE_CACHE:M,HYDRATED_HISTORY:Y,STYLING_TASK_QUEUE:$,Themes:{}}};const C=new Set,F=/--[^;]+/g,V=/:/,q=(t,e)=>{let s=e.match(F);if(Array.isArray(s)){s=s.filter(r=>V.test(r));const a=document.createElement("style");a.innerHTML=`.${t} {${s.join(";")}}`,document.querySelector("head")?.appendChild(a);}C.add(t);},f=(t,e)=>typeof o.A11yUi=="object"&&o.A11yUi!==null&&typeof o.A11yUi.Themes=="object"&&o.A11yUi.Themes!==null&&typeof o.A11yUi.Themes[t]=="object"&&o.A11yUi.Themes[t]!==null&&typeof o.A11yUi.Themes[t][e]=="string"?o.A11yUi.Themes[t][e].replace(/\r?\n/g,""):"",J=t=>{for(const e of Array.from(t.childNodes))if(e instanceof HTMLStyleElement&&e.tagName==="STYLE"&&e.dataset.themingFallback===void 0)t.removeChild(e);else break},W=(t,e)=>{try{if(o.A11yUi.Theme?.mode==="ssr")throw new Error("SSR");const s=[];e.forEach(a=>{const r=new CSSStyleSheet;r.replaceSync(a),s.push(r);}),t.adoptedStyleSheets=s;}catch{[...e].reverse().forEach((a,r)=>{if(typeof a!="string"||a.length===0)return;const n=document.createElement("style");switch(n.dataset.themingFallback="",r){case 4:n.dataset.themingBaseA11y="";break;case 3:n.dataset.themingBaseGlobal="";break;case 2:n.dataset.themingBaseComponent="";break;case 1:n.dataset.themingCustomGlobal="";break;case 0:n.dataset.themingCustomComponent="";break;default:n.dataset.themingUnknown="";break}n.innerHTML=a,t.insertBefore(n,t.firstChild);});}},X=(t,e,s)=>{if(s!==false){const a=[...Array.from(t.childNodes).filter(n=>n instanceof HTMLStyleElement&&n.tagName==="STYLE")];let r;try{r=[...Array.from(t.adoptedStyleSheets)];}catch{r=[];}s?.mode==="before"?(a.reverse().forEach(n=>e.unshift(n.innerHTML)),r.reverse().forEach(n=>e.unshift(Array.from(n.cssRules).map(i=>i.cssText).join("")))):s?.mode==="after"&&(a.forEach(n=>e.push(n.innerHTML)),r.forEach(n=>e.push(Array.from(n.cssRules).map(i=>i.cssText).join(""))));}},w=(t,e,s)=>{const a=e.name||"default";let r;try{if(t.shadowRoot===null)throw new Error("ShadowRoot is null");r=t.shadowRoot;}catch{r=t;}if(o.A11yUi.CSS_STYLE_CACHE.get(a)?.has(t.tagName))L(t,r,o.A11yUi.CSS_STYLE_CACHE.get(a)?.get(t.tagName),s);else {const n=f(a,"PROPERTIES"),i=f(a,"GLOBAL"),c=f(a,t.tagName);C.has(a)===false&&q(a,i);const m=[n,i,c];X(r,m,e.encroachCss),e.loglevel==="debug"&&console.log(t.tagName,m),e.cache===true&&(o.A11yUi.CSS_STYLE_CACHE.has(a)===false&&o.A11yUi.CSS_STYLE_CACHE.set(a,new Map),o.A11yUi.CSS_STYLE_CACHE.get(a)?.set(t.tagName,m)),L(t,r,m,s);}},L=(t,e,s,a)=>{J(e),W(e,s),t.style.visibility=a;},v=t=>{t.loglevel==="debug"&&o.A11yUi.HYDRATED_HISTORY.push({timestamp:Date.now(),numberOfTasks:o.A11yUi.STYLING_TASK_QUEUE.size});},te=t=>{o.A11yUi.STYLING_TASK_QUEUE.delete(t);},_=(t,e)=>{te(t),v(e);},se=t=>{for(const e of t)if(o.A11yUi.STYLING_TASK_QUEUE.has(e.target)&&e.target.classList.contains("hydrated")){const{styleVisibility:s,themeDetails:a}=o.A11yUi.STYLING_TASK_QUEUE.get(e.target);w(e.target,a,s),_(e.target,a);}};let d;try{d=new MutationObserver(se);}catch{d=null;}class ne{Prefix;Key;Tag;createTheme=(e,s)=>H(e,s);createTranslation=(e,s)=>j(e,s);constructor(e,s,a){this.Prefix=e,this.Key=Object.getOwnPropertyNames(s),this.Tag=Object.getOwnPropertyNames(a);}}
426
+ const j=(t,e)=>s=>s(t,e),H=(t,e)=>s=>s(t,e,{append:false}),M=new Map,Y=[],$=new Map,o$1={A11yUi:{CSS_STYLE_CACHE:M,HYDRATED_HISTORY:Y,STYLING_TASK_QUEUE:$,Themes:{}}};const C=new Set,F=/--[^;]+/g,V=/:/,q=(t,e)=>{let s=e.match(F);if(Array.isArray(s)){s=s.filter(r=>V.test(r));const a=document.createElement("style");a.innerHTML=`.${t} {${s.join(";")}}`,document.querySelector("head")?.appendChild(a);}C.add(t);},f$1=(t,e)=>typeof o$1.A11yUi=="object"&&o$1.A11yUi!==null&&typeof o$1.A11yUi.Themes=="object"&&o$1.A11yUi.Themes!==null&&typeof o$1.A11yUi.Themes[t]=="object"&&o$1.A11yUi.Themes[t]!==null&&typeof o$1.A11yUi.Themes[t][e]=="string"?o$1.A11yUi.Themes[t][e].replace(/\r?\n/g,""):"",J=t=>{for(const e of Array.from(t.childNodes))if(e instanceof HTMLStyleElement&&e.tagName==="STYLE"&&e.dataset.themingFallback===void 0)t.removeChild(e);else break},W=(t,e)=>{try{if(o$1.A11yUi.Theme?.mode==="ssr")throw new Error("SSR");const s=[];e.forEach(a=>{const r=new CSSStyleSheet;r.replaceSync(a),s.push(r);}),t.adoptedStyleSheets=s;}catch{[...e].reverse().forEach((a,r)=>{if(typeof a!="string"||a.length===0)return;const n=document.createElement("style");switch(n.dataset.themingFallback="",r){case 4:n.dataset.themingBaseA11y="";break;case 3:n.dataset.themingBaseGlobal="";break;case 2:n.dataset.themingBaseComponent="";break;case 1:n.dataset.themingCustomGlobal="";break;case 0:n.dataset.themingCustomComponent="";break;default:n.dataset.themingUnknown="";break}n.innerHTML=a,t.insertBefore(n,t.firstChild);});}},X=(t,e,s)=>{if(s!==false){const a=[...Array.from(t.childNodes).filter(n=>n instanceof HTMLStyleElement&&n.tagName==="STYLE")];let r;try{r=[...Array.from(t.adoptedStyleSheets)];}catch{r=[];}s?.mode==="before"?(a.reverse().forEach(n=>e.unshift(n.innerHTML)),r.reverse().forEach(n=>e.unshift(Array.from(n.cssRules).map(i=>i.cssText).join("")))):s?.mode==="after"&&(a.forEach(n=>e.push(n.innerHTML)),r.forEach(n=>e.push(Array.from(n.cssRules).map(i=>i.cssText).join(""))));}},w=(t,e,s)=>{const a=e.name||"default";let r;try{if(t.shadowRoot===null)throw new Error("ShadowRoot is null");r=t.shadowRoot;}catch{r=t;}if(o$1.A11yUi.CSS_STYLE_CACHE.get(a)?.has(t.tagName))L(t,r,o$1.A11yUi.CSS_STYLE_CACHE.get(a)?.get(t.tagName),s);else {const n=f$1(a,"PROPERTIES"),i=f$1(a,"GLOBAL"),c=f$1(a,t.tagName);C.has(a)===false&&q(a,i);const m=[n,i,c];X(r,m,e.encroachCss),e.loglevel==="debug"&&console.log(t.tagName,m),e.cache===true&&(o$1.A11yUi.CSS_STYLE_CACHE.has(a)===false&&o$1.A11yUi.CSS_STYLE_CACHE.set(a,new Map),o$1.A11yUi.CSS_STYLE_CACHE.get(a)?.set(t.tagName,m)),L(t,r,m,s);}},L=(t,e,s,a)=>{J(e),W(e,s),t.style.visibility=a;},v=t=>{t.loglevel==="debug"&&o$1.A11yUi.HYDRATED_HISTORY.push({timestamp:Date.now(),numberOfTasks:o$1.A11yUi.STYLING_TASK_QUEUE.size});},te=t=>{o$1.A11yUi.STYLING_TASK_QUEUE.delete(t);},_=(t,e)=>{te(t),v(e);},se=t=>{for(const e of t)if(o$1.A11yUi.STYLING_TASK_QUEUE.has(e.target)&&e.target.classList.contains("hydrated")){const{styleVisibility:s,themeDetails:a}=o$1.A11yUi.STYLING_TASK_QUEUE.get(e.target);w(e.target,a,s),_(e.target,a);}};try{new MutationObserver(se);}catch{}class ne{Prefix;Key;Tag;createTheme=(e,s)=>H(e,s);createTranslation=(e,s)=>j(e,s);constructor(e,s,a){this.Prefix=e,this.Key=Object.getOwnPropertyNames(s),this.Tag=Object.getOwnPropertyNames(a);}}
427
+ const devCache = new Set();
428
+ const devHint = (msg, options) => {
429
+ if (devCache.has(msg) === false || false) {
430
+ devCache.add(msg);
431
+ Log.debug([msg].concat([]), {
432
+ classifier: `💻 dev`,
433
+ forceLog: false,
434
+ overwriteStyle: '; background-color: #f09',
435
+ });
436
+ }
437
+ };
438
+ devHint(`We appreciate any feedback, comments, screenshots, or demo links of an application based on KoliBri (kolibri@itzbund.de). Thank you!`);
439
+
440
+ var rgbaConvert = {exports: {}};
441
+
442
+ rgbaConvert.exports = arr;
443
+ rgbaConvert.exports.arr = arr;
444
+ rgbaConvert.exports.obj = obj;
445
+ rgbaConvert.exports.css = css;
446
+ rgbaConvert.exports.hex = hex;
447
+ rgbaConvert.exports.num = num;
448
+
449
+ function arr(data) {
450
+ var a = parse(data);
451
+ if (a.length == 3) {
452
+ return a.concat(255)
453
+ } else {
454
+ a[3] = Math.round(a[3]);
455
+ return a
456
+ }
457
+ }
458
+
459
+ function obj(data) {
460
+ var a = parse(data);
461
+ return {
462
+ r: a[0],
463
+ g: a[1],
464
+ b: a[2],
465
+ a: a.length == 3
466
+ ? 255
467
+ : Math.round(a[3])
468
+ }
469
+ }
470
+
471
+ function css(data) {
472
+ var a = parse(data);
473
+ if (a.length == 3) a.push(255);
474
+
475
+ return a[3] == 255
476
+ ? 'rgb(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')'
477
+ : a[3] == 0
478
+ ? 'rgba(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', 0)'
479
+ : 'rgba(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + String(a[3] / 255).substr(1) + ')'
480
+ }
481
+
482
+ function hex(data) {
483
+ var a = parse(data);
484
+ if (a.length == 3) a.push(255);
485
+ var opaque = a[3] == 255;
486
+ var r = num2hex(a[0]);
487
+ var g = num2hex(a[1]);
488
+ var b = num2hex(a[2]);
489
+ var a = num2hex(Math.round(a[3]));
490
+ var is = isshort(r, g, b, a);
491
+ if (opaque) {
492
+ return is
493
+ ? '#' + r.charAt(0) + g.charAt(0) + b.charAt(0)
494
+ : '#' + r + g + b
495
+ }
496
+ return is
497
+ ? '#' + r.charAt(0) + g.charAt(0) + b.charAt(0) + a.charAt(0)
498
+ : '#' + r + g + b + a
499
+ }
500
+
501
+ function num(data) {
502
+ var a = parse(data);
503
+ if (a.length == 3) a.push(255);
504
+ else a[3] = Math.round(a[3]);
505
+ return ((a[3] << 24) >>> 0 | a[0] << 16 | a[1] << 8 | a[2]) >>> 0
506
+ }
507
+
508
+ function parse(data) {
509
+ if (typeof data == 'string') {
510
+ data = data.toLowerCase();
511
+ return name(data)
512
+ || hex3(data)
513
+ || hex6(data)
514
+ || rgb(data)
515
+ || rgba(data)
516
+ || [0, 0, 0, 255]
517
+ }
518
+ return object(data)
519
+ || array(data)
520
+ || number(data)
521
+ || [0, 0, 0, 255]
522
+ }
523
+
524
+ function num2hex(num) {
525
+ var s = num.toString(16);
526
+ return s.length == 1
527
+ ? '0' + s
528
+ : s
529
+ }
530
+
531
+ function isshort(r, g, b, a) {
532
+ var h = ['ff', '00', '11', '22', '33', '44', '55', '66',
533
+ '77', '88', '99', 'aa', 'bb', 'cc', 'dd', 'ee'];
534
+ return h.indexOf(r) != -1
535
+ && h.indexOf(g) != -1
536
+ && h.indexOf(b) != -1
537
+ && h.indexOf(a) != -1
538
+ }
539
+
540
+ function name(str) {
541
+ if (str == 'red') return [255, 0, 0]
542
+ if (str == 'green') return [0, 255, 0]
543
+ if (str == 'blue') return [0, 0, 255]
544
+ if (str == 'black') return [0, 0, 0]
545
+ if (str == 'white') return [255, 255, 255]
546
+ if (str == 'cyan') return [0, 255, 255]
547
+ if (str == 'gray') return [128, 128, 128]
548
+ if (str == 'grey') return [128, 128, 128]
549
+ if (str == 'magenta') return [255, 0, 255]
550
+ // ok, not the real css `pink` but my personal `magenta` alias
551
+ // `pink` is simpler than `fuchsia`, whatever...
552
+ if (str == 'pink') return [255, 0, 255]
553
+ if (str == 'yellow') return [255, 255, 0]
554
+ }
555
+
556
+ function hex2num(str) {
557
+ return str.length == 1
558
+ ? parseInt(str + str, 16)
559
+ : parseInt(str, 16)
560
+ }
561
+
562
+ function hex3(str) {
563
+ var s = str.replace(/^#/,'');
564
+ var l = s.length;
565
+ if (l == 3 || l == 4) {
566
+ var r = hex2num(s[0]);
567
+ var g = hex2num(s[1]);
568
+ var b = hex2num(s[2]);
569
+ var a = l == 3
570
+ ? 255
571
+ : hex2num(s[3]);
572
+
573
+ if (isNaN(r) || isNaN(g) || isNaN(b) || isNaN(a)) return
574
+
575
+ return [r, g, b, a]
576
+ }
577
+ }
578
+
579
+ function hex6(str) {
580
+ var s = str.replace(/^#/,'');
581
+ var l = s.length;
582
+ if (l == 6 || l == 8) {
583
+ var r = hex2num(s.slice(0, 2));
584
+ var g = hex2num(s.slice(2, 4));
585
+ var b = hex2num(s.slice(4, 6));
586
+ var a = l == 6
587
+ ? 255
588
+ : hex2num(s.slice(6, 8));
589
+
590
+ if (isNaN(r) || isNaN(g) || isNaN(b) || isNaN(a)) return
591
+
592
+ return [r, g, b, a]
593
+ }
594
+ }
595
+
596
+ function getnum(val, integer) {
597
+ if (typeof val != 'number') return -1
598
+ if (integer === true && Math.floor(val) !== val) return -1
599
+ return val >= 0 && val <= 255
600
+ ? val
601
+ : -1
602
+ }
603
+
604
+ function object(obj) {
605
+ if (Object.prototype.toString.call(obj) === '[object Object]'
606
+ && Object.getPrototypeOf(obj) === Object.getPrototypeOf({})) {
607
+ var r = getnum(obj.r != undefined ? obj.r : obj.red != undefined ? obj.red : 0, true);
608
+ var g = getnum(obj.g != undefined ? obj.g : obj.green != undefined ? obj.green : 0, true);
609
+ var b = getnum(obj.b != undefined ? obj.b : obj.blue != undefined ? obj.blue : 0, true);
610
+ var a = getnum(obj.a != undefined ? obj.a : obj.alpha != undefined ? obj.alpha : 255, true);
611
+ if (r != -1 && g != -1 && b != -1 && a != -1) {
612
+ return [r, g, b, a]
613
+ }
614
+ }
615
+ }
616
+
617
+ function array(arr) {
618
+ if (Array.isArray(arr) && (arr.length == 3 || arr.length == 4)) {
619
+ var r = getnum(arr[0], true);
620
+ var g = getnum(arr[1], true);
621
+ var b = getnum(arr[2], true);
622
+ var a = getnum(arr[3] != undefined ? arr[3] : 255, true);
623
+ if (r != -1 && g != -1 && b != -1 && a != -1) {
624
+ return [r, g, b, a]
625
+ }
626
+ }
627
+ }
628
+
629
+ function number(num) {
630
+ if (typeof num == 'number' && Math.floor(num) == num && num <= 4294967295 && num >= 0) {
631
+ var a = num >> 24 & 255;
632
+ var r = num >> 16 & 255;
633
+ var g = num >> 8 & 255;
634
+ var b = num & 255;
635
+ return [r, g, b, a]
636
+ }
637
+ }
638
+
639
+ function rgb(str) {
640
+ if (str.substr(0, 4) == 'rgb(') {
641
+ str = str.match(/^rgb\(([^)]+)\)/)[1];
642
+ var t = str.split(/ *, */).map(Number);
643
+ var r = getnum(t[0], true);
644
+ var g = getnum(t[1], true);
645
+ var b = getnum(t[2], true);
646
+ if (r != -1 && g != -1 && b != -1) {
647
+ return [r, g, b, 255]
648
+ }
649
+ }
650
+ }
651
+
652
+ function rgba(str) {
653
+ if (str.substr(0, 5) == 'rgba(') {
654
+ str = str.match(/^rgba\(([^)]+)\)/)[1];
655
+ var t = str.split(/ *, */).map(Number);
656
+ var r = getnum(t[0], true);
657
+ var g = getnum(t[1], true);
658
+ var b = getnum(t[2], true);
659
+ var a = getnum(t[3] * 255);
660
+ if (r != -1 && g != -1 && b != -1 && a != -1) {
661
+ return [r, g, b, a]
662
+ }
663
+ }
664
+ }
366
665
 
367
666
  /*!
368
667
  * KoliBri - The accessible HTML-Standard