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