@crystaltech/hsms-shared-ui 0.6.7 → 0.6.9-alpha-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,16 +1,3 @@
1
- /**
2
- * HSMS Pre-Mount Splash Injector
3
- *
4
- * Side-effect module that:
5
- * - Applies theme CSS variables early from localStorage
6
- * - Reads organization branding (name/logo) from localStorage
7
- * - Injects a minimal splash UI inside the app root so React replaces it on mount
8
- *
9
- * Usage:
10
- * import '@crystaltech/hsms-shared-ui/preMountSplash';
11
- * // or via script tag (ESM):
12
- * // <script type="module" src="/node_modules/@crystaltech/hsms-shared-ui/dist/preMountSplash.es.js"></script>
13
- */
14
1
  export type PreMountSplashOptions = {
15
2
  rootId?: string;
16
3
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@crystaltech/hsms-shared-ui",
3
3
  "private": false,
4
- "version": "0.6.7",
4
+ "version": "0.6.9-alpha-0",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.mjs",
package/dist/index.es2.js DELETED
@@ -1,164 +0,0 @@
1
- function u(t, e) {
2
- try {
3
- 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;
8
- };
9
- return "#" + o(n) + o(i) + o(p);
10
- } catch {
11
- return t;
12
- }
13
- }
14
- function g() {
15
- 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);
18
- } catch {
19
- 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
- }
22
- }
23
- function y() {
24
- try {
25
- const t = localStorage.getItem("organization_name") || "", e = localStorage.getItem("organization_logo_full_url") || "";
26
- return { orgName: t, orgLogo: e };
27
- } catch {
28
- return { orgName: "", orgLogo: "" };
29
- }
30
- }
31
- function f() {
32
- if (document.getElementById("hsms-pre-splash-style")) return;
33
- const t = document.createElement("style");
34
- t.id = "hsms-pre-splash-style", t.textContent = `
35
- html, body { height: 100%; }
36
- body { margin: 0; background: var(--app-bg); color: var(--app-fg); }
37
- .app-splash {
38
- height: 100%;
39
- display: flex;
40
- align-items: center;
41
- justify-content: center;
42
- flex-direction: column;
43
- gap: 12px;
44
- background-image:
45
- radial-gradient(circle at 10% 10%, rgba(255,255,255,0.06), transparent 40%),
46
- linear-gradient(135deg, var(--app-primary), var(--app-primary-2));
47
- color: white;
48
- opacity: 1;
49
- transform: translateY(0);
50
- transition: opacity 280ms ease-out, transform 280ms ease-out;
51
- }
52
- .app-splash.app-splash-hide {
53
- opacity: 0;
54
- transform: translateY(6px);
55
- pointer-events: none;
56
- }
57
- .app-splash .brand {
58
- display: flex;
59
- align-items: center;
60
- gap: 10px;
61
- background: rgba(255,255,255,0.12);
62
- border: 1px solid rgba(255,255,255,0.2);
63
- padding: 10px 14px;
64
- border-radius: 12px;
65
- }
66
- .splash-title { font-weight: 600; letter-spacing: .2px; }
67
- .splash-spinner {
68
- width: 28px; height: 28px; border-radius: 50%;
69
- border: 3px solid rgba(0,0,0,0.1);
70
- border-top-color: var(--app-primary);
71
- animation: hsms-spin 1s linear infinite;
72
- }
73
- @keyframes hsms-spin { to { transform: rotate(360deg); } }
74
- `, document.head.appendChild(t);
75
- }
76
- function v(t) {
77
- if (t != null && t.rootId) {
78
- const e = document.getElementById(t.rootId);
79
- if (e) return e;
80
- }
81
- return document.getElementById("app") || document.getElementById("root") || document.body;
82
- }
83
- function d(t) {
84
- try {
85
- const e = document.getElementById("hsms-pre-splash");
86
- if (!e) return;
87
- const a = t || e.parentElement || document.body;
88
- if (a && Array.from(a.children).some((n) => n !== e) || document.readyState === "complete")
89
- try {
90
- e.classList.add("app-splash-hide");
91
- const n = () => {
92
- e.removeEventListener("transitionend", n), e && e.parentElement && e.remove();
93
- try {
94
- document.documentElement.classList.remove("app-loading"), document.documentElement.classList.add("app-ready"), window.__APP_READY__ = !0, window.dispatchEvent(new Event("app-ready"));
95
- } catch {
96
- }
97
- };
98
- e.addEventListener("transitionend", n), setTimeout(n, 340);
99
- } catch {
100
- e.remove();
101
- }
102
- } catch {
103
- }
104
- }
105
- function c(t) {
106
- try {
107
- if (document.getElementById("hsms-pre-splash")) return;
108
- try {
109
- document.documentElement.classList.add("app-loading"), document.documentElement.classList.remove("app-ready"), window.__APP_READY__ = !1;
110
- } catch {
111
- }
112
- g(), f();
113
- const { orgName: e, orgLogo: a } = y(), r = v(t), n = document.createElement("div");
114
- n.id = "hsms-pre-splash", n.className = "app-splash", n.setAttribute("role", "status"), n.setAttribute("aria-live", "polite"), n.innerHTML = `
115
- <div class="brand">
116
- <img id="hsms-splash-logo" src="/logo.png" alt="Organization Logo"
117
- style="height:40px;width:auto;border-radius:6px" />
118
- <div id="hsms-splash-name" class="splash-title">Loading HSMS UI…</div>
119
- </div>
120
- <div class="splash-spinner" aria-hidden="true"></div>
121
- `, 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();
126
- });
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);
136
- } catch {
137
- }
138
- }
139
- function E() {
140
- d();
141
- }
142
- function b() {
143
- try {
144
- window.__APP_READY__ = !0, window.dispatchEvent(new Event("app-ready"));
145
- } catch {
146
- }
147
- }
148
- try {
149
- c();
150
- } catch {
151
- }
152
- try {
153
- window.HSMSPreMountSplash = {
154
- initPreMountSplash: c,
155
- hidePreMountSplash: E,
156
- markAppReady: b
157
- };
158
- } catch {
159
- }
160
- export {
161
- E as hidePreMountSplash,
162
- c as initPreMountSplash,
163
- b as markAppReady
164
- };
package/dist/index2.js DELETED
@@ -1,48 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function y(t,e){try{let a=t.replace("#","");a.length===3&&(a=a.split("").map(s=>s+s).join(""));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=>{const d=s.toString(16);return(d.length===1?"0":"")+d};return"#"+o(n)+o(i)+o(p)}catch{return t}}function f(){try{const t=localStorage.getItem("theme"),e=t?JSON.parse(t):null,a=e&&e.mode||"light",r=e&&e.themeColor||"#2c5282",n=y(r,24),i=a==="light"?"#ffffff":"#121212",p=a==="light"?"#0f172a":"#e5e7eb",o=document.documentElement;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)}catch{const e=document.documentElement;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")}}function b(){try{const t=localStorage.getItem("organization_name")||"",e=localStorage.getItem("organization_logo_full_url")||"";return{orgName:t,orgLogo:e}}catch{return{orgName:"",orgLogo:""}}}function v(){if(document.getElementById("hsms-pre-splash-style"))return;const t=document.createElement("style");t.id="hsms-pre-splash-style",t.textContent=`
2
- html, body { height: 100%; }
3
- body { margin: 0; background: var(--app-bg); color: var(--app-fg); }
4
- .app-splash {
5
- height: 100%;
6
- display: flex;
7
- align-items: center;
8
- justify-content: center;
9
- flex-direction: column;
10
- gap: 12px;
11
- background-image:
12
- radial-gradient(circle at 10% 10%, rgba(255,255,255,0.06), transparent 40%),
13
- linear-gradient(135deg, var(--app-primary), var(--app-primary-2));
14
- color: white;
15
- opacity: 1;
16
- transform: translateY(0);
17
- transition: opacity 280ms ease-out, transform 280ms ease-out;
18
- }
19
- .app-splash.app-splash-hide {
20
- opacity: 0;
21
- transform: translateY(6px);
22
- pointer-events: none;
23
- }
24
- .app-splash .brand {
25
- display: flex;
26
- align-items: center;
27
- gap: 10px;
28
- background: rgba(255,255,255,0.12);
29
- border: 1px solid rgba(255,255,255,0.2);
30
- padding: 10px 14px;
31
- border-radius: 12px;
32
- }
33
- .splash-title { font-weight: 600; letter-spacing: .2px; }
34
- .splash-spinner {
35
- width: 28px; height: 28px; border-radius: 50%;
36
- border: 3px solid rgba(0,0,0,0.1);
37
- border-top-color: var(--app-primary);
38
- animation: hsms-spin 1s linear infinite;
39
- }
40
- @keyframes hsms-spin { to { transform: rotate(360deg); } }
41
- `,document.head.appendChild(t)}function E(t){if(t!=null&&t.rootId){const e=document.getElementById(t.rootId);if(e)return e}return document.getElementById("app")||document.getElementById("root")||document.body}function l(t){try{const e=document.getElementById("hsms-pre-splash");if(!e)return;const a=t||e.parentElement||document.body;if(a&&Array.from(a.children).some(n=>n!==e)||document.readyState==="complete")try{e.classList.add("app-splash-hide");const n=()=>{e.removeEventListener("transitionend",n),e&&e.parentElement&&e.remove();try{document.documentElement.classList.remove("app-loading"),document.documentElement.classList.add("app-ready"),window.__APP_READY__=!0,window.dispatchEvent(new Event("app-ready"))}catch{}};e.addEventListener("transitionend",n),setTimeout(n,340)}catch{e.remove()}}catch{}}function c(t){try{if(document.getElementById("hsms-pre-splash"))return;try{document.documentElement.classList.add("app-loading"),document.documentElement.classList.remove("app-ready"),window.__APP_READY__=!1}catch{}f(),v();const{orgName:e,orgLogo:a}=b(),r=E(t),n=document.createElement("div");n.id="hsms-pre-splash",n.className="app-splash",n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),n.innerHTML=`
42
- <div class="brand">
43
- <img id="hsms-splash-logo" src="/logo.png" alt="Organization Logo"
44
- style="height:40px;width:auto;border-radius:6px" />
45
- <div id="hsms-splash-name" class="splash-title">Loading HSMS UI…</div>
46
- </div>
47
- <div class="splash-spinner" aria-hidden="true"></div>
48
- `,r.firstChild?r.insertBefore(n,r.firstChild):r.appendChild(n);const i=n.querySelector("#hsms-splash-logo"),p=n.querySelector("#hsms-splash-name");i&&a&&(i.src=a),p&&e&&(p.textContent=e);const o=new MutationObserver(()=>{l(r),document.getElementById("hsms-pre-splash")||o.disconnect()});o.observe(r,{childList:!0,subtree:!1});const s=()=>l(r);window.addEventListener("load",s,{once:!0});const d=()=>l(r);window.addEventListener("hsms-app-mounted",d);const u=()=>l(r);document.addEventListener("DOMContentLoaded",u,{once:!0});const g=()=>l(r);window.addEventListener("app-ready",g)}catch{}}function m(){l()}function h(){try{window.__APP_READY__=!0,window.dispatchEvent(new Event("app-ready"))}catch{}}try{c()}catch{}try{window.HSMSPreMountSplash={initPreMountSplash:c,hidePreMountSplash:m,markAppReady:h}}catch{}exports.hidePreMountSplash=m;exports.initPreMountSplash=c;exports.markAppReady=h;