@crystaltech/hsms-shared-ui 0.6.6 → 0.6.7-alpha-1
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/README.md +134 -0
- package/dist/components/ui/SideDrawer.d.ts +78 -0
- package/dist/hooks/useLogout.d.ts +1 -0
- package/dist/hooks/useSyncedLocalStorage.d.ts +5 -0
- package/dist/index.es.js +8318 -8185
- package/dist/index.es2.js +164 -0
- package/dist/index.js +86 -86
- package/dist/index2.js +48 -0
- package/dist/logo.png +0 -0
- package/dist/preMountSplash.iife.js +48 -0
- package/dist/splash/preMountSplash.d.ts +28 -0
- package/package.json +7 -2
package/dist/index2.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
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;
|
package/dist/logo.png
ADDED
|
Binary file
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
var HSMSPreMountSplash=function(d){"use strict";function g(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),p=r(parseInt(a.slice(2,4),16)+e),l=r(parseInt(a.slice(4,6),16)+e),o=s=>{const c=s.toString(16);return(c.length===1?"0":"")+c};return"#"+o(n)+o(p)+o(l)}catch{return t}}function y(){try{const t=localStorage.getItem("theme"),e=t?JSON.parse(t):null,a=e&&e.mode||"light",r=e&&e.themeColor||"#2c5282",n=g(r,24),p=a==="light"?"#ffffff":"#121212",l=a==="light"?"#0f172a":"#e5e7eb",o=document.documentElement;o.style.setProperty("--app-bg",p),o.style.setProperty("--app-fg",l),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 f(){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 b(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 i(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 m(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{}y(),v();const{orgName:e,orgLogo:a}=f(),r=b(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 p=n.querySelector("#hsms-splash-logo"),l=n.querySelector("#hsms-splash-name");p&&a&&(p.src=a),l&&e&&(l.textContent=e);const o=new MutationObserver(()=>{i(r),document.getElementById("hsms-pre-splash")||o.disconnect()});o.observe(r,{childList:!0,subtree:!1});const s=()=>i(r);window.addEventListener("load",s,{once:!0});const c=()=>i(r);window.addEventListener("hsms-app-mounted",c);const E=()=>i(r);document.addEventListener("DOMContentLoaded",E,{once:!0});const w=()=>i(r);window.addEventListener("app-ready",w)}catch{}}function h(){i()}function u(){try{window.__APP_READY__=!0,window.dispatchEvent(new Event("app-ready"))}catch{}}try{m()}catch{}try{window.HSMSPreMountSplash={initPreMountSplash:m,hidePreMountSplash:h,markAppReady:u}}catch{}return d.hidePreMountSplash=h,d.initPreMountSplash=m,d.markAppReady=u,Object.defineProperty(d,Symbol.toStringTag,{value:"Module"}),d}({});
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
export type PreMountSplashOptions = {
|
|
15
|
+
rootId?: string;
|
|
16
|
+
};
|
|
17
|
+
export declare function initPreMountSplash(options?: PreMountSplashOptions): void;
|
|
18
|
+
export declare function hidePreMountSplash(): void;
|
|
19
|
+
export declare function markAppReady(): void;
|
|
20
|
+
declare global {
|
|
21
|
+
interface Window {
|
|
22
|
+
HSMSPreMountSplash?: {
|
|
23
|
+
initPreMountSplash: (options?: PreMountSplashOptions) => void;
|
|
24
|
+
hidePreMountSplash: () => void;
|
|
25
|
+
markAppReady: () => void;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
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.
|
|
4
|
+
"version": "0.6.7-alpha-1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
7
7
|
"module": "dist/index.mjs",
|
|
@@ -21,6 +21,11 @@
|
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"import": "./dist/index.es.js",
|
|
23
23
|
"require": "./dist/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./preMountSplash": {
|
|
26
|
+
"types": "./dist/splash/preMountSplash.d.ts",
|
|
27
|
+
"import": "./dist/preMountSplash.es.js",
|
|
28
|
+
"require": "./dist/preMountSplash.js"
|
|
24
29
|
}
|
|
25
30
|
},
|
|
26
31
|
"peerDependencies": {
|
|
@@ -78,7 +83,7 @@
|
|
|
78
83
|
},
|
|
79
84
|
"scripts": {
|
|
80
85
|
"dev": "vite",
|
|
81
|
-
"build": "tsc && vite build",
|
|
86
|
+
"build": "tsc && vite build && vite build -c vite.iife.config.ts",
|
|
82
87
|
"lint": "eslint ."
|
|
83
88
|
}
|
|
84
89
|
}
|