blue-web 1.36.2 → 1.37.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.
@@ -1,132 +1,133 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
+ // src/js/odometer.ts
4
2
  /**
5
- * Odometer web component for animated number display
6
- *
7
- * @element bl-odometer
8
- * @attr {number} value - Current value to display
9
- * @attr {number} max - Maximum value before showing "+"
10
- * @fires change - Fired when value changes
11
- * @cssprop --bl-odometer-duration - Transition duration for number animation (default: 0.4s)
12
- */
13
- class Odometer extends HTMLElement {
14
- static get observedAttributes() {
15
- return ["value", "max"];
16
- }
17
- constructor() {
18
- super();
19
- _defineProperty(this, "_initialized", false);
20
- _defineProperty(this, "_resetTimer", null);
21
- this.attachShadow({
22
- mode: "open"
23
- });
24
- }
25
- connectedCallback() {
26
- if (!this._initialized) {
27
- this.setup();
28
- this._initialized = true;
29
- // Initialen Wert anwenden (Markup-Attribut oder default)
30
- this.updateValue(this.value);
31
- }
32
- }
33
- setup() {
34
- const style = document.createElement("style");
35
- style.textContent = /* CSS */"\n :host {\n display: inline-flex;\n min-width: 1em;\n height: 1em;\n text-align: center;\n overflow: hidden;\n line-height: 1em;\n }\n .numbers {\n display: flex;\n flex-direction: column;\n transition: transform var(--bl-odometer-duration, 0.4s) cubic-bezier(0.34, 1.56, 0.64, 1);\n }\n .numbers span {\n display: flex;\n align-items: center;\n justify-content: center;\n height: 1em;\n }";
36
- const wrapper = document.createElement("span");
37
- wrapper.classList.add("numbers");
38
- wrapper.setAttribute("aria-hidden", "true");
39
- this.shadowRoot.append(style, wrapper);
40
- this.wrapper = wrapper;
41
- this.rebuildNumbers();
42
- }
43
- rebuildNumbers() {
44
- this.wrapper.innerHTML = "";
45
- const max = this.max;
46
- for (let i = 0; i <= max; i++) {
47
- const s = document.createElement("span");
48
- s.textContent = String(i);
49
- this.wrapper.appendChild(s);
50
- }
51
- const plus = document.createElement("span");
52
- plus.textContent = "".concat(max, "+");
53
- this.wrapper.appendChild(plus);
54
-
55
- // Aktuellen Wert neu anwenden
56
- if (this._initialized) {
57
- this.updateValue(this.value);
58
- }
59
- }
60
- attributeChangedCallback(name, oldValue, newValue) {
61
- if (newValue !== oldValue && this._initialized) {
62
- if (name === "value") {
63
- const prev = parseInt(oldValue !== null && oldValue !== void 0 ? oldValue : "0", 10) || 0;
64
- const next = parseInt(newValue !== null && newValue !== void 0 ? newValue : "0", 10) || 0;
65
- this.applyChangeState(prev, next);
66
- this.updateValue(next);
67
- } else if (name === "max") {
68
- this.rebuildNumbers();
69
- }
70
- }
71
- }
72
- updateValue(value) {
73
- const max = this.max;
74
- const index = value > max ? max + 1 : Math.max(0, value);
75
- const height = this.wrapper.getBoundingClientRect().height || 16;
76
- this.wrapper.style.transform = "translateY(-".concat(index * height, "px)");
77
- const displayValue = value > max ? "".concat(max, "+") : "".concat(value);
78
- this.setAttribute("aria-label", displayValue);
79
- }
80
- clearResetTimer() {
81
- if (this._resetTimer !== null) {
82
- clearTimeout(this._resetTimer);
83
- this._resetTimer = null;
84
- }
85
- }
86
- scheduleResetChange() {
87
- this.clearResetTimer();
88
- const delay = 3000;
89
- this._resetTimer = window.setTimeout(() => {
90
- this.removeAttribute("data-change");
91
- this._resetTimer = null;
92
- }, delay);
93
- }
94
- applyChangeState(previous, next) {
95
- if (next > previous) {
96
- this.setAttribute("data-change", "up");
97
- this.scheduleResetChange();
98
- } else if (next < previous) {
99
- this.setAttribute("data-change", "down");
100
- this.scheduleResetChange();
101
- }
102
- }
103
- set value(value) {
104
- const current = this.value;
105
- if (current !== value) {
106
- this.setAttribute("value", String(value));
107
- if (this._initialized) {
108
- this.dispatchEvent(new CustomEvent("change", {
109
- detail: {
110
- value
111
- },
112
- bubbles: true,
113
- composed: true
114
- }));
115
- }
116
- }
117
- }
118
- get value() {
119
- return parseInt(this.getAttribute("value") || "0", 10) || 0;
120
- }
121
- set max(value) {
122
- this.setAttribute("max", String(value));
123
- }
124
- get max() {
125
- return parseInt(this.getAttribute("max") || "9", 10) || 9;
126
- }
127
- }
128
- if (!customElements.get("bl-odometer")) {
129
- customElements.define("bl-odometer", Odometer);
130
- }
131
- export { Odometer };
132
- export default Odometer;
3
+ * Odometer web component for animated number display
4
+ *
5
+ * @element bl-odometer
6
+ * @attr {number} value - Current value to display
7
+ * @attr {number} max - Maximum value before showing "+"
8
+ * @fires change - Fired when value changes
9
+ * @cssprop --bl-odometer-duration - Transition duration for number animation (default: 0.4s)
10
+ */
11
+ var Odometer = class extends HTMLElement {
12
+ wrapper;
13
+ _initialized = false;
14
+ _resetTimer = null;
15
+ static get observedAttributes() {
16
+ return ["value", "max"];
17
+ }
18
+ constructor() {
19
+ super();
20
+ this.attachShadow({ mode: "open" });
21
+ }
22
+ connectedCallback() {
23
+ if (!this._initialized) {
24
+ this.setup();
25
+ this._initialized = true;
26
+ this.updateValue(this.value);
27
+ }
28
+ }
29
+ setup() {
30
+ const style = document.createElement("style");
31
+ style.textContent = `
32
+ :host {
33
+ display: inline-flex;
34
+ min-width: 1em;
35
+ height: 1em;
36
+ text-align: center;
37
+ overflow: hidden;
38
+ line-height: 1em;
39
+ }
40
+ .numbers {
41
+ display: flex;
42
+ flex-direction: column;
43
+ transition: transform var(--bl-odometer-duration, 0.4s) cubic-bezier(0.34, 1.56, 0.64, 1);
44
+ }
45
+ .numbers span {
46
+ display: flex;
47
+ align-items: center;
48
+ justify-content: center;
49
+ height: 1em;
50
+ }`;
51
+ const wrapper = document.createElement("span");
52
+ wrapper.classList.add("numbers");
53
+ wrapper.setAttribute("aria-hidden", "true");
54
+ this.shadowRoot.append(style, wrapper);
55
+ this.wrapper = wrapper;
56
+ this.rebuildNumbers();
57
+ }
58
+ rebuildNumbers() {
59
+ this.wrapper.innerHTML = "";
60
+ const max = this.max;
61
+ for (let i = 0; i <= max; i++) {
62
+ const s = document.createElement("span");
63
+ s.textContent = String(i);
64
+ this.wrapper.appendChild(s);
65
+ }
66
+ const plus = document.createElement("span");
67
+ plus.textContent = `${max}+`;
68
+ this.wrapper.appendChild(plus);
69
+ if (this._initialized) this.updateValue(this.value);
70
+ }
71
+ attributeChangedCallback(name, oldValue, newValue) {
72
+ if (newValue !== oldValue && this._initialized) {
73
+ if (name === "value") {
74
+ const prev = parseInt(oldValue ?? "0", 10) || 0;
75
+ const next = parseInt(newValue ?? "0", 10) || 0;
76
+ this.applyChangeState(prev, next);
77
+ this.updateValue(next);
78
+ } else if (name === "max") this.rebuildNumbers();
79
+ }
80
+ }
81
+ updateValue(value) {
82
+ const max = this.max;
83
+ const index = value > max ? max + 1 : Math.max(0, value);
84
+ const height = this.wrapper.getBoundingClientRect().height || 16;
85
+ this.wrapper.style.transform = `translateY(-${index * height}px)`;
86
+ const displayValue = value > max ? `${max}+` : `${value}`;
87
+ this.setAttribute("aria-label", displayValue);
88
+ }
89
+ clearResetTimer() {
90
+ if (this._resetTimer !== null) {
91
+ clearTimeout(this._resetTimer);
92
+ this._resetTimer = null;
93
+ }
94
+ }
95
+ scheduleResetChange() {
96
+ this.clearResetTimer();
97
+ const delay = 3e3;
98
+ this._resetTimer = window.setTimeout(() => {
99
+ this.removeAttribute("data-change");
100
+ this._resetTimer = null;
101
+ }, delay);
102
+ }
103
+ applyChangeState(previous, next) {
104
+ if (next > previous) {
105
+ this.setAttribute("data-change", "up");
106
+ this.scheduleResetChange();
107
+ } else if (next < previous) {
108
+ this.setAttribute("data-change", "down");
109
+ this.scheduleResetChange();
110
+ }
111
+ }
112
+ set value(value) {
113
+ if (this.value !== value) {
114
+ this.setAttribute("value", String(value));
115
+ if (this._initialized) this.dispatchEvent(new CustomEvent("change", {
116
+ detail: { value },
117
+ bubbles: true,
118
+ composed: true
119
+ }));
120
+ }
121
+ }
122
+ get value() {
123
+ return parseInt(this.getAttribute("value") || "0", 10) || 0;
124
+ }
125
+ set max(value) {
126
+ this.setAttribute("max", String(value));
127
+ }
128
+ get max() {
129
+ return parseInt(this.getAttribute("max") || "9", 10) || 9;
130
+ }
131
+ };
132
+ if (!customElements.get("bl-odometer")) customElements.define("bl-odometer", Odometer);
133
+ export { Odometer, Odometer as default };
@@ -1,65 +1,54 @@
1
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
2
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
3
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
4
- export class OverflowDetector {
5
- constructor() {
6
- _defineProperty(this, "resizeObserver", null);
7
- _defineProperty(this, "entries", new Map());
8
- if ("ResizeObserver" in window) {
9
- this.resizeObserver = new ResizeObserver(resizeEntries => {
10
- for (const resizeEntry of resizeEntries) {
11
- const element = resizeEntry.target;
12
- const entry = this.entries.get(element);
13
- if (entry) {
14
- this.check(entry);
15
- }
16
- }
17
- });
18
- }
19
- }
20
- check(entry) {
21
- const isOverflowing = entry.element.scrollWidth > entry.element.clientWidth + 1;
22
- if (isOverflowing !== entry.wasOverflowing) {
23
- entry.wasOverflowing = isOverflowing;
24
- entry.onChange(isOverflowing, entry.element);
25
- }
26
- }
27
- observe(options) {
28
- var _this$resizeObserver;
29
- const element = options.element,
30
- onChange = options.onChange;
31
- if (this.entries.has(element)) {
32
- this.unobserve(element);
33
- }
34
- const entry = {
35
- element,
36
- onChange,
37
- wasOverflowing: false
38
- };
39
- this.entries.set(element, entry);
40
- (_this$resizeObserver = this.resizeObserver) === null || _this$resizeObserver === void 0 || _this$resizeObserver.observe(element);
41
- this.check(entry);
42
- }
43
- unobserve(element) {
44
- var _this$resizeObserver2;
45
- (_this$resizeObserver2 = this.resizeObserver) === null || _this$resizeObserver2 === void 0 || _this$resizeObserver2.unobserve(element);
46
- this.entries.delete(element);
47
- }
48
- checkAll() {
49
- this.entries.forEach(entry => {
50
- this.check(entry);
51
- });
52
- }
53
- destroy() {
54
- var _this$resizeObserver3;
55
- (_this$resizeObserver3 = this.resizeObserver) === null || _this$resizeObserver3 === void 0 || _this$resizeObserver3.disconnect();
56
- this.resizeObserver = null;
57
- this.entries.clear();
58
- }
59
- }
60
- export function isOverflowing(element) {
61
- return element.scrollWidth > element.clientWidth + 1;
1
+ // src/js/overflow-detector.ts
2
+ var OverflowDetector = class {
3
+ resizeObserver = null;
4
+ entries = /* @__PURE__ */ new Map();
5
+ constructor() {
6
+ if ("ResizeObserver" in window) this.resizeObserver = new ResizeObserver((resizeEntries) => {
7
+ for (const resizeEntry of resizeEntries) {
8
+ const element = resizeEntry.target;
9
+ const entry = this.entries.get(element);
10
+ if (entry) this.check(entry);
11
+ }
12
+ });
13
+ }
14
+ check(entry) {
15
+ const isOverflowing = entry.element.scrollWidth > entry.element.clientWidth + 1;
16
+ if (isOverflowing !== entry.wasOverflowing) {
17
+ entry.wasOverflowing = isOverflowing;
18
+ entry.onChange(isOverflowing, entry.element);
19
+ }
20
+ }
21
+ observe(options) {
22
+ const { element, onChange } = options;
23
+ if (this.entries.has(element)) this.unobserve(element);
24
+ const entry = {
25
+ element,
26
+ onChange,
27
+ wasOverflowing: false
28
+ };
29
+ this.entries.set(element, entry);
30
+ this.resizeObserver?.observe(element);
31
+ this.check(entry);
32
+ }
33
+ unobserve(element) {
34
+ this.resizeObserver?.unobserve(element);
35
+ this.entries.delete(element);
36
+ }
37
+ checkAll() {
38
+ this.entries.forEach((entry) => {
39
+ this.check(entry);
40
+ });
41
+ }
42
+ destroy() {
43
+ this.resizeObserver?.disconnect();
44
+ this.resizeObserver = null;
45
+ this.entries.clear();
46
+ }
47
+ };
48
+ function isOverflowing(element) {
49
+ return element.scrollWidth > element.clientWidth + 1;
62
50
  }
63
51
  window.blueWeb = window.blueWeb || {};
64
52
  window.blueWeb.OverflowDetector = OverflowDetector;
65
- window.blueWeb.isOverflowing = isOverflowing;
53
+ window.blueWeb.isOverflowing = isOverflowing;
54
+ export { OverflowDetector, isOverflowing };
@@ -1,62 +1,44 @@
1
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
2
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
3
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
4
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
5
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
+ // src/js/progress.ts
6
2
  window.blueWeb = window.blueWeb || {};
3
+ window.blueWeb.progress = { instances: /* @__PURE__ */ new Map([]) };
7
4
  window.blueWeb.progress = {
8
- instances: new Map([])
5
+ ...window.blueWeb.progress,
6
+ start: (id = "blueWebProgress", parent = document.body, ariaLabel = "Loading data", positionClass = "fixed-top") => {
7
+ const parentEl = typeof parent === "string" || parent instanceof String ? document.querySelector(parent.toString()) : parent;
8
+ let progressEl = document.getElementById(id);
9
+ if (!progressEl) {
10
+ progressEl = document.createElement("div");
11
+ progressEl.id = id;
12
+ progressEl.className = `progress ${positionClass} rounded-0`;
13
+ progressEl.setAttribute("style", "--bs-progress-height: 0.25rem");
14
+ progressEl.setAttribute("role", "progressbar");
15
+ progressEl.setAttribute("aria-label", ariaLabel);
16
+ progressEl.setAttribute("aria-valuemin", "0");
17
+ progressEl.setAttribute("aria-valuemax", "100");
18
+ progressEl.innerHTML = `<div class="progress-bar progress-bar-striped progress-bar-animated" style="width: 0%"></div>`;
19
+ parentEl.appendChild(progressEl);
20
+ }
21
+ const progressBar = progressEl.querySelector(".progress-bar");
22
+ if (!progressBar) return;
23
+ window.blueWeb.progress.instances.set(id, 0);
24
+ var interval = setInterval(function() {
25
+ let progress = window.blueWeb.progress.instances.get(id);
26
+ var increment = Math.random() * (progress < 90 ? 5 : .1);
27
+ progress += increment;
28
+ progress = Math.min(progress, 99);
29
+ window.blueWeb.progress.instances.set(id, progress);
30
+ progressBar.style.width = progress + "%";
31
+ progressEl?.setAttribute("aria-valuenow", Math.round(progress).toString());
32
+ if (progress >= 100) clearInterval(interval);
33
+ }, 200);
34
+ },
35
+ stop: (id = "blueWebProgress") => {
36
+ const progressEl = document.getElementById(id);
37
+ if (!progressEl) return;
38
+ window.blueWeb.progress.instances.set(id, 100);
39
+ setTimeout(() => {
40
+ progressEl.remove();
41
+ }, 500);
42
+ }
9
43
  };
10
- window.blueWeb.progress = _objectSpread(_objectSpread({}, window.blueWeb.progress), {}, {
11
- start: function () {
12
- let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "blueWebProgress";
13
- let parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document.body;
14
- let ariaLabel = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "Loading data";
15
- let positionClass = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "fixed-top";
16
- const parentEl = typeof parent === "string" || parent instanceof String ? document.querySelector(parent.toString()) : parent;
17
- let progressEl = document.getElementById(id);
18
- if (!progressEl) {
19
- progressEl = document.createElement("div");
20
- progressEl.id = id;
21
- progressEl.className = "progress ".concat(positionClass, " rounded-0");
22
- progressEl.setAttribute("style", "--bs-progress-height: 0.25rem");
23
- progressEl.setAttribute("role", "progressbar");
24
- progressEl.setAttribute("aria-label", ariaLabel);
25
- progressEl.setAttribute("aria-valuemin", "0");
26
- progressEl.setAttribute("aria-valuemax", "100");
27
- progressEl.innerHTML = /*html*/"<div class=\"progress-bar progress-bar-striped progress-bar-animated\" style=\"width: 0%\"></div>";
28
- parentEl.appendChild(progressEl);
29
- }
30
- const progressBar = progressEl.querySelector(".progress-bar");
31
- if (!progressBar) return;
32
- window.blueWeb.progress.instances.set(id, 0);
33
- var interval = setInterval(function () {
34
- var _progressEl;
35
- let progress = window.blueWeb.progress.instances.get(id);
36
- // Simuliere einen natürlichen Anstieg
37
- var increment = Math.random() * (progress < 90 ? 5 : 0.1); // Zufälliger Anstieg zwischen 0 und 5
38
- progress += increment;
39
- progress = Math.min(progress, 99); // Fortschritt darf nicht über 100% gehen
40
- window.blueWeb.progress.instances.set(id, progress);
41
-
42
- // Aktualisiere die Progressbar
43
- progressBar.style.width = progress + "%";
44
- (_progressEl = progressEl) === null || _progressEl === void 0 || _progressEl.setAttribute("aria-valuenow", Math.round(progress).toString());
45
-
46
- // Stoppe das Intervall, wenn 100% erreicht sind
47
- if (progress >= 100) {
48
- clearInterval(interval);
49
- }
50
- }, 200); // Update alle 200ms
51
- },
52
- stop: function () {
53
- let id = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "blueWebProgress";
54
- const progressEl = document.getElementById(id);
55
- if (!progressEl) return;
56
- window.blueWeb.progress.instances.set(id, 100);
57
- setTimeout(() => {
58
- progressEl.remove();
59
- }, 500);
60
- }
61
- });
62
- export default window.blueWeb.progress;
44
+ window.blueWeb.progress;