@crystaltech/hsms-shared-ui 0.6.7 → 0.6.8

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.es2.js CHANGED
@@ -1,26 +1,27 @@
1
- function u(t, e) {
1
+ import { p as g } from "./logo-CDcm1S1N.js";
2
+ function w(t, e) {
2
3
  try {
3
4
  let a = t.replace("#", "");
4
- a.length === 3 && (a = a.split("").map((s) => s + s).join(""));
5
- const r = (s) => Math.min(255, Math.max(0, s)), n = r(parseInt(a.slice(0, 2), 16) + e), i = r(parseInt(a.slice(2, 4), 16) + e), p = r(parseInt(a.slice(4, 6), 16) + e), o = (s) => {
6
- const l = s.toString(16);
7
- return (l.length === 1 ? "0" : "") + l;
5
+ a.length === 3 && (a = a.split("").map((i) => i + i).join(""));
6
+ const r = (i) => Math.min(255, Math.max(0, i)), n = r(parseInt(a.slice(0, 2), 16) + e), o = r(parseInt(a.slice(2, 4), 16) + e), d = r(parseInt(a.slice(4, 6), 16) + e), s = (i) => {
7
+ const m = i.toString(16);
8
+ return (m.length === 1 ? "0" : "") + m;
8
9
  };
9
- return "#" + o(n) + o(i) + o(p);
10
+ return "#" + s(n) + s(o) + s(d);
10
11
  } catch {
11
12
  return t;
12
13
  }
13
14
  }
14
- function g() {
15
+ function E() {
15
16
  try {
16
- const t = localStorage.getItem("theme"), e = t ? JSON.parse(t) : null, a = e && e.mode || "light", r = e && e.themeColor || "#2c5282", n = u(r, 24), i = a === "light" ? "#ffffff" : "#121212", p = a === "light" ? "#0f172a" : "#e5e7eb", o = document.documentElement;
17
- o.style.setProperty("--app-bg", i), o.style.setProperty("--app-fg", p), o.style.setProperty("--app-primary", r), o.style.setProperty("--app-primary-2", n);
17
+ const t = localStorage.getItem("theme"), e = t ? JSON.parse(t) : null, a = e && e.mode || "light", r = e && e.themeColor || "#2563eb", n = w(r, 36), o = a === "light" ? "#ffffff" : "#121212", d = a === "light" ? "#0f172a" : "#e5e7eb", s = document.documentElement;
18
+ s.style.setProperty("--app-bg", o), s.style.setProperty("--app-fg", d), s.style.setProperty("--app-primary", r), s.style.setProperty("--app-primary-2", n);
18
19
  } catch {
19
20
  const e = document.documentElement;
20
- e.style.setProperty("--app-bg", "#ffffff"), e.style.setProperty("--app-fg", "#0f172a"), e.style.setProperty("--app-primary", "#2c5282"), e.style.setProperty("--app-primary-2", "#3b82f6");
21
+ e.style.setProperty("--app-bg", "#ffffff"), e.style.setProperty("--app-fg", "#0f172a"), e.style.setProperty("--app-primary", "#2563eb"), e.style.setProperty("--app-primary-2", "#60a5fa");
21
22
  }
22
23
  }
23
- function y() {
24
+ function u() {
24
25
  try {
25
26
  const t = localStorage.getItem("organization_name") || "", e = localStorage.getItem("organization_logo_full_url") || "";
26
27
  return { orgName: t, orgLogo: e };
@@ -28,7 +29,7 @@ function y() {
28
29
  return { orgName: "", orgLogo: "" };
29
30
  }
30
31
  }
31
- function f() {
32
+ function x() {
32
33
  if (document.getElementById("hsms-pre-splash-style")) return;
33
34
  const t = document.createElement("style");
34
35
  t.id = "hsms-pre-splash-style", t.textContent = `
@@ -73,14 +74,14 @@ function f() {
73
74
  @keyframes hsms-spin { to { transform: rotate(360deg); } }
74
75
  `, document.head.appendChild(t);
75
76
  }
76
- function v(t) {
77
+ function L(t) {
77
78
  if (t != null && t.rootId) {
78
79
  const e = document.getElementById(t.rootId);
79
80
  if (e) return e;
80
81
  }
81
82
  return document.getElementById("app") || document.getElementById("root") || document.body;
82
83
  }
83
- function d(t) {
84
+ function c(t) {
84
85
  try {
85
86
  const e = document.getElementById("hsms-pre-splash");
86
87
  if (!e) return;
@@ -102,63 +103,85 @@ function d(t) {
102
103
  } catch {
103
104
  }
104
105
  }
105
- function c(t) {
106
+ function y(t) {
106
107
  try {
107
108
  if (document.getElementById("hsms-pre-splash")) return;
108
109
  try {
109
110
  document.documentElement.classList.add("app-loading"), document.documentElement.classList.remove("app-ready"), window.__APP_READY__ = !1;
110
111
  } catch {
111
112
  }
112
- g(), f();
113
- const { orgName: e, orgLogo: a } = y(), r = v(t), n = document.createElement("div");
113
+ E(), x();
114
+ const { orgName: e, orgLogo: a } = u(), r = L(t), n = document.createElement("div");
114
115
  n.id = "hsms-pre-splash", n.className = "app-splash", n.setAttribute("role", "status"), n.setAttribute("aria-live", "polite"), n.innerHTML = `
115
116
  <div class="brand">
116
- <img id="hsms-splash-logo" src="/logo.png" alt="Organization Logo"
117
+ <img id="hsms-splash-logo" src="${g}" alt="Organization Logo"
117
118
  style="height:40px;width:auto;border-radius:6px" />
118
119
  <div id="hsms-splash-name" class="splash-title">Loading HSMS UI…</div>
119
120
  </div>
120
121
  <div class="splash-spinner" aria-hidden="true"></div>
121
122
  `, r.firstChild ? r.insertBefore(n, r.firstChild) : r.appendChild(n);
122
- const i = n.querySelector("#hsms-splash-logo"), p = n.querySelector("#hsms-splash-name");
123
- i && a && (i.src = a), p && e && (p.textContent = e);
124
- const o = new MutationObserver(() => {
125
- d(r), document.getElementById("hsms-pre-splash") || o.disconnect();
123
+ const o = n.querySelector("#hsms-splash-logo"), d = n.querySelector("#hsms-splash-name");
124
+ if (o && a && (o.src = a), d && e && (d.textContent = e), o) {
125
+ const l = g, p = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(
126
+ `<svg xmlns="http://www.w3.org/2000/svg" width="80" height="40">
127
+ <rect width="100%" height="100%" rx="6" fill="rgba(255,255,255,0.18)"/>
128
+ <text x="50%" y="50%" dominant-baseline="middle" text-anchor="middle" fill="white" font-family="sans-serif" font-size="12">HSMS</text>
129
+ </svg>`
130
+ );
131
+ o.addEventListener("error", () => {
132
+ try {
133
+ const h = o.getAttribute("src") || "";
134
+ h !== l ? o.src = l : h !== p && (o.src = p);
135
+ } catch {
136
+ }
137
+ });
138
+ }
139
+ const s = () => {
140
+ try {
141
+ const { orgName: l, orgLogo: p } = u();
142
+ o && p && (o.src = p), d && l && (d.textContent = l);
143
+ } catch {
144
+ }
145
+ };
146
+ window.addEventListener("hsms-organization-updated", s);
147
+ const i = new MutationObserver(() => {
148
+ c(r), document.getElementById("hsms-pre-splash") || i.disconnect();
126
149
  });
127
- o.observe(r, { childList: !0, subtree: !1 });
128
- const s = () => d(r);
129
- window.addEventListener("load", s, { once: !0 });
130
- const l = () => d(r);
131
- window.addEventListener("hsms-app-mounted", l);
132
- const m = () => d(r);
133
- document.addEventListener("DOMContentLoaded", m, { once: !0 });
134
- const h = () => d(r);
135
- window.addEventListener("app-ready", h);
150
+ i.observe(r, { childList: !0, subtree: !1 });
151
+ const m = () => c(r);
152
+ window.addEventListener("load", m, { once: !0 });
153
+ const f = () => c(r);
154
+ window.addEventListener("hsms-app-mounted", f);
155
+ const v = () => c(r);
156
+ document.addEventListener("DOMContentLoaded", v, { once: !0 });
157
+ const b = () => c(r);
158
+ window.addEventListener("app-ready", b);
136
159
  } catch {
137
160
  }
138
161
  }
139
- function E() {
140
- d();
162
+ function I() {
163
+ c();
141
164
  }
142
- function b() {
165
+ function S() {
143
166
  try {
144
167
  window.__APP_READY__ = !0, window.dispatchEvent(new Event("app-ready"));
145
168
  } catch {
146
169
  }
147
170
  }
148
171
  try {
149
- c();
172
+ y();
150
173
  } catch {
151
174
  }
152
175
  try {
153
176
  window.HSMSPreMountSplash = {
154
- initPreMountSplash: c,
155
- hidePreMountSplash: E,
156
- markAppReady: b
177
+ initPreMountSplash: y,
178
+ hidePreMountSplash: I,
179
+ markAppReady: S
157
180
  };
158
181
  } catch {
159
182
  }
160
183
  export {
161
- E as hidePreMountSplash,
162
- c as initPreMountSplash,
163
- b as markAppReady
184
+ I as hidePreMountSplash,
185
+ y as initPreMountSplash,
186
+ S as markAppReady
164
187
  };