@public-ui/theme-default 2.0.5 → 2.0.6

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
@@ -611,57 +611,63 @@ var TagEnum = /* @__PURE__ */ ((TagEnum2) => {
611
611
  TagEnum2[TagEnum2["tree-item"] = 49] = "tree-item";
612
612
  return TagEnum2;
613
613
  })(TagEnum || {});
614
-
615
- const _Log = class {
616
- static mapToArray(msg) {
617
- return Array.isArray(msg) ? msg : [msg];
618
- }
619
- static handleClassifier(classifier) {
620
- if (typeof classifier === "string" && classifier.length > 0) {
621
- return `${_Log.shield.label} | ${classifier}`;
622
- } else {
623
- return _Log.shield.label;
624
- }
614
+ let DEV_MODE = null;
615
+ const getDevMode = () => DEV_MODE === true;
616
+ const LOG_STYLE = "color: white; background: #666; font-weight: bold; padding: .25em .5em; border-radius: 3px; border: 1px solid #000";
617
+ const mapToArray = (msg) => {
618
+ return Array.isArray(msg) ? msg : [msg];
619
+ };
620
+ const getLogLabel = (label) => {
621
+ return `%c${label}`;
622
+ };
623
+ const handleClassifier = (label, classifier) => {
624
+ if (typeof classifier === "string" && classifier.length > 0) {
625
+ return `${getLogLabel(label)} | ${classifier}`;
626
+ } else {
627
+ return getLogLabel(label);
625
628
  }
626
- static getShield(options) {
627
- return [_Log.handleClassifier(options?.classifier), `${_Log.shield.style};${options?.overwriteStyle || ""}`];
629
+ };
630
+ const getShield = (label, options) => {
631
+ return [handleClassifier(label, options?.classifier), `${LOG_STYLE};${options?.overwriteStyle || ""}`];
632
+ };
633
+ const isDevModeOrForceLog = (devMode, forceLog) => devMode() || forceLog === true;
634
+ class Logger {
635
+ constructor(label, devMode) {
636
+ this.label = label;
637
+ this.devMode = devMode;
628
638
  }
629
- static debug(msg, options) {
630
- if (options?.forceLog === true) {
631
- console.debug(..._Log.getShield(options), ..._Log.mapToArray(msg));
639
+ debug(msg, options) {
640
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
641
+ console.debug(...getShield(this.label, options), ...mapToArray(msg));
632
642
  }
633
643
  }
634
- static info(msg, options) {
635
- if (options?.forceLog === true) {
636
- console.info(..._Log.getShield(options), ..._Log.mapToArray(msg));
644
+ info(msg, options) {
645
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
646
+ console.info(...getShield(this.label, options), ...mapToArray(msg));
637
647
  }
638
648
  }
639
- static trace(msg, options) {
640
- if (options?.forceLog === true) {
641
- console.trace(..._Log.getShield(options), ..._Log.mapToArray(msg));
649
+ trace(msg, options) {
650
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
651
+ console.trace(...getShield(this.label, options), ...mapToArray(msg));
642
652
  }
643
653
  }
644
- static warn(msg, options) {
645
- if (options?.forceLog === true) {
646
- console.warn(..._Log.getShield(options), ..._Log.mapToArray(msg));
654
+ warn(msg, options) {
655
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
656
+ console.warn(...getShield(this.label, options), ...mapToArray(msg));
647
657
  }
648
658
  }
649
- static error(msg, options) {
650
- if (options?.forceLog === true) {
651
- console.error(..._Log.getShield(options), ..._Log.mapToArray(msg));
659
+ error(msg, options) {
660
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
661
+ console.error(...getShield(this.label, options), ...mapToArray(msg));
652
662
  }
653
663
  }
654
- static throw(msg, options) {
655
- if (options?.forceLog === true) {
656
- throw new Error(..._Log.getShield(options), ..._Log.mapToArray(msg));
664
+ throw(msg, options) {
665
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
666
+ throw new Error(...getShield(this.label, options), ...mapToArray(msg));
657
667
  }
658
668
  }
659
- };
660
- let Log = _Log;
661
- Log.shield = {
662
- label: "%cKoliBri",
663
- style: "color: white; background: #666; font-weight: bold; padding: .25em .5em; border-radius: 3px; border: 1px solid #000"
664
- };
669
+ }
670
+ const Log = new Logger("KoliBri", getDevMode);
665
671
  const devCache = /* @__PURE__ */ new Set();
666
672
  const devHint = (msg, options) => {
667
673
  if (devCache.has(msg) === false || !!options?.force) {
package/dist/index.mjs CHANGED
@@ -609,57 +609,63 @@ var TagEnum = /* @__PURE__ */ ((TagEnum2) => {
609
609
  TagEnum2[TagEnum2["tree-item"] = 49] = "tree-item";
610
610
  return TagEnum2;
611
611
  })(TagEnum || {});
612
-
613
- const _Log = class {
614
- static mapToArray(msg) {
615
- return Array.isArray(msg) ? msg : [msg];
616
- }
617
- static handleClassifier(classifier) {
618
- if (typeof classifier === "string" && classifier.length > 0) {
619
- return `${_Log.shield.label} | ${classifier}`;
620
- } else {
621
- return _Log.shield.label;
622
- }
612
+ let DEV_MODE = null;
613
+ const getDevMode = () => DEV_MODE === true;
614
+ const LOG_STYLE = "color: white; background: #666; font-weight: bold; padding: .25em .5em; border-radius: 3px; border: 1px solid #000";
615
+ const mapToArray = (msg) => {
616
+ return Array.isArray(msg) ? msg : [msg];
617
+ };
618
+ const getLogLabel = (label) => {
619
+ return `%c${label}`;
620
+ };
621
+ const handleClassifier = (label, classifier) => {
622
+ if (typeof classifier === "string" && classifier.length > 0) {
623
+ return `${getLogLabel(label)} | ${classifier}`;
624
+ } else {
625
+ return getLogLabel(label);
623
626
  }
624
- static getShield(options) {
625
- return [_Log.handleClassifier(options?.classifier), `${_Log.shield.style};${options?.overwriteStyle || ""}`];
627
+ };
628
+ const getShield = (label, options) => {
629
+ return [handleClassifier(label, options?.classifier), `${LOG_STYLE};${options?.overwriteStyle || ""}`];
630
+ };
631
+ const isDevModeOrForceLog = (devMode, forceLog) => devMode() || forceLog === true;
632
+ class Logger {
633
+ constructor(label, devMode) {
634
+ this.label = label;
635
+ this.devMode = devMode;
626
636
  }
627
- static debug(msg, options) {
628
- if (options?.forceLog === true) {
629
- console.debug(..._Log.getShield(options), ..._Log.mapToArray(msg));
637
+ debug(msg, options) {
638
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
639
+ console.debug(...getShield(this.label, options), ...mapToArray(msg));
630
640
  }
631
641
  }
632
- static info(msg, options) {
633
- if (options?.forceLog === true) {
634
- console.info(..._Log.getShield(options), ..._Log.mapToArray(msg));
642
+ info(msg, options) {
643
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
644
+ console.info(...getShield(this.label, options), ...mapToArray(msg));
635
645
  }
636
646
  }
637
- static trace(msg, options) {
638
- if (options?.forceLog === true) {
639
- console.trace(..._Log.getShield(options), ..._Log.mapToArray(msg));
647
+ trace(msg, options) {
648
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
649
+ console.trace(...getShield(this.label, options), ...mapToArray(msg));
640
650
  }
641
651
  }
642
- static warn(msg, options) {
643
- if (options?.forceLog === true) {
644
- console.warn(..._Log.getShield(options), ..._Log.mapToArray(msg));
652
+ warn(msg, options) {
653
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
654
+ console.warn(...getShield(this.label, options), ...mapToArray(msg));
645
655
  }
646
656
  }
647
- static error(msg, options) {
648
- if (options?.forceLog === true) {
649
- console.error(..._Log.getShield(options), ..._Log.mapToArray(msg));
657
+ error(msg, options) {
658
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
659
+ console.error(...getShield(this.label, options), ...mapToArray(msg));
650
660
  }
651
661
  }
652
- static throw(msg, options) {
653
- if (options?.forceLog === true) {
654
- throw new Error(..._Log.getShield(options), ..._Log.mapToArray(msg));
662
+ throw(msg, options) {
663
+ if (isDevModeOrForceLog(this.devMode, options?.forceLog)) {
664
+ throw new Error(...getShield(this.label, options), ...mapToArray(msg));
655
665
  }
656
666
  }
657
- };
658
- let Log = _Log;
659
- Log.shield = {
660
- label: "%cKoliBri",
661
- style: "color: white; background: #666; font-weight: bold; padding: .25em .5em; border-radius: 3px; border: 1px solid #000"
662
- };
667
+ }
668
+ const Log = new Logger("KoliBri", getDevMode);
663
669
  const devCache = /* @__PURE__ */ new Set();
664
670
  const devHint = (msg, options) => {
665
671
  if (devCache.has(msg) === false || !!options?.force) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@public-ui/theme-default",
3
- "version": "2.0.5",
3
+ "version": "2.0.6",
4
4
  "license": "EUPL-1.2",
5
5
  "homepage": "https://public-ui.github.io",
6
6
  "repository": "https://github.com/public-ui/kolibri",
@@ -38,8 +38,8 @@
38
38
  "wcag"
39
39
  ],
40
40
  "devDependencies": {
41
- "@public-ui/schema": "2.0.5",
42
- "@public-ui/visual-tests": "2.0.5",
41
+ "@public-ui/schema": "2.0.6",
42
+ "@public-ui/visual-tests": "2.0.6",
43
43
  "@types/node": "ts5.3",
44
44
  "@typescript-eslint/eslint-plugin": "7.0.1",
45
45
  "@typescript-eslint/parser": "7.0.1",
@@ -50,7 +50,7 @@
50
50
  "unbuild": "1.2.1"
51
51
  },
52
52
  "peerDependencies": {
53
- "@public-ui/components": "2.0.5"
53
+ "@public-ui/components": "2.0.6"
54
54
  },
55
55
  "sideEffects": false,
56
56
  "type": "module",