@eintrek/erp-shell 0.1.25 → 0.1.26
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/auth/access-denied.d.ts +22 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +25 -4
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +24 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1170,6 +1170,27 @@ function cx(...parts) {
|
|
|
1170
1170
|
return parts.filter(Boolean).join(" ");
|
|
1171
1171
|
}
|
|
1172
1172
|
|
|
1173
|
+
/**
|
|
1174
|
+
* Central "no access" screen shared by every policy check (route-level
|
|
1175
|
+
* PermissionProvider and page-level PermissionGateShell). One look everywhere:
|
|
1176
|
+
* an illustration, a 403 headline, the page-specific reason, and recovery
|
|
1177
|
+
* actions.
|
|
1178
|
+
*/
|
|
1179
|
+
function AccessDenied({ title = "ขออภัย, คุณไม่มีสิทธิ์เข้าถึงหน้านี้ (403)", message = "คุณไม่มีสิทธิ์เข้าถึงหน้านี้ ขออภัยในความไม่สะดวก", homeHref = "/", homeLabel = "กลับไปหน้าหลัก", supportHref, supportLabel = "ติดต่อฝ่ายสนับสนุน", fullScreen = true, className, }) {
|
|
1180
|
+
const go = (href) => {
|
|
1181
|
+
if (typeof window !== "undefined")
|
|
1182
|
+
window.location.href = href;
|
|
1183
|
+
};
|
|
1184
|
+
const wrapperClass = [
|
|
1185
|
+
"flex min-w-0 flex-1 items-center justify-center p-4",
|
|
1186
|
+
fullScreen ? "min-h-[70vh]" : "",
|
|
1187
|
+
className ?? "",
|
|
1188
|
+
]
|
|
1189
|
+
.filter(Boolean)
|
|
1190
|
+
.join(" ");
|
|
1191
|
+
return (jsxRuntime.jsx("div", { className: wrapperClass, children: jsxRuntime.jsxs("div", { className: "relative w-full max-w-3xl overflow-hidden rounded-2xl border border-border/60 bg-card/60 p-8 shadow-sm backdrop-blur sm:p-10", children: [jsxRuntime.jsx(lucideReact.Sparkles, { className: "pointer-events-none absolute right-6 top-6 h-5 w-5 text-primary/40" }), jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-8 text-center sm:flex-row sm:text-left", children: [jsxRuntime.jsxs("div", { className: "relative shrink-0", children: [jsxRuntime.jsx("div", { className: "absolute inset-0 rounded-full bg-destructive/20 blur-2xl" }), jsxRuntime.jsx("div", { className: "relative flex h-28 w-28 items-center justify-center rounded-3xl border border-border/60 bg-gradient-to-br from-muted/40 to-background shadow-inner", children: jsxRuntime.jsx("div", { className: "flex h-16 w-16 items-center justify-center rounded-full border border-destructive/40 bg-destructive/10", children: jsxRuntime.jsx(lucideReact.Ban, { className: "h-8 w-8 text-destructive", strokeWidth: 2.5 }) }) })] }), jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [jsxRuntime.jsx("h1", { className: "text-xl font-bold text-foreground sm:text-2xl", children: title }), message ? (jsxRuntime.jsx("p", { className: "mt-3 whitespace-pre-line text-sm leading-relaxed text-muted-foreground sm:text-base", children: message })) : null, jsxRuntime.jsxs("div", { className: "mt-6 flex flex-col gap-3 sm:flex-row", children: [jsxRuntime.jsxs(erpTheme.Button, { type: "button", onClick: () => go(homeHref), className: "w-full sm:w-auto", children: [jsxRuntime.jsx(lucideReact.Home, { className: "mr-2 h-4 w-4" }), homeLabel] }), supportHref ? (jsxRuntime.jsxs(erpTheme.Button, { type: "button", variant: "outline", onClick: () => go(supportHref), className: "w-full sm:w-auto", children: [jsxRuntime.jsx(lucideReact.Headset, { className: "mr-2 h-4 w-4" }), supportLabel] })) : null] })] })] })] }) }));
|
|
1192
|
+
}
|
|
1193
|
+
|
|
1173
1194
|
const shellClassName = "flex min-w-0 flex-1 flex-col gap-6 overflow-x-hidden";
|
|
1174
1195
|
/**
|
|
1175
1196
|
* Shared layout for “กำลังตรวจสอบสิทธิ์” (skeleton) and “ไม่มีสิทธิ์” (message).
|
|
@@ -1180,7 +1201,7 @@ function PermissionGateShell({ policyLoading, hasPolicyAccess, deniedMessage, ch
|
|
|
1180
1201
|
return (jsxRuntime.jsx("div", { className: shellClassName, children: jsxRuntime.jsx("div", { className: skeletonGridClassName, children: Array.from({ length: skeletonCount }).map((_, i) => (jsxRuntime.jsx(erpTheme.Card, { children: skeletonVariant === "kpi" ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(erpTheme.CardHeader, { className: "flex flex-row items-center justify-between pb-2", children: [jsxRuntime.jsx(erpTheme.Skeleton, { className: "h-4 w-24" }), jsxRuntime.jsx(erpTheme.Skeleton, { className: "h-4 w-4 rounded" })] }), jsxRuntime.jsxs(erpTheme.CardContent, { children: [jsxRuntime.jsx(erpTheme.Skeleton, { className: "h-8 w-32 mb-2" }), jsxRuntime.jsx(erpTheme.Skeleton, { className: "h-3 w-20" })] })] })) : (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(erpTheme.CardHeader, { className: "pb-2", children: jsxRuntime.jsx(erpTheme.Skeleton, { className: "h-4 w-24" }) }), jsxRuntime.jsx(erpTheme.CardContent, { children: jsxRuntime.jsx(erpTheme.Skeleton, { className: "h-8 w-16" }) })] })) }, i))) }) }));
|
|
1181
1202
|
}
|
|
1182
1203
|
if (!hasPolicyAccess) {
|
|
1183
|
-
return (jsxRuntime.jsx("div", { className: shellClassName, children: jsxRuntime.jsx(
|
|
1204
|
+
return (jsxRuntime.jsx("div", { className: shellClassName, children: jsxRuntime.jsx(AccessDenied, { message: deniedMessage }) }));
|
|
1184
1205
|
}
|
|
1185
1206
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
1186
1207
|
}
|
|
@@ -1316,7 +1337,7 @@ function getRequiredChildGroups(pathname, rulesMap) {
|
|
|
1316
1337
|
}
|
|
1317
1338
|
|
|
1318
1339
|
function DeniedCard() {
|
|
1319
|
-
return (jsxRuntime.jsx(
|
|
1340
|
+
return (jsxRuntime.jsx(AccessDenied, { message: "\u0E04\u0E38\u0E13\u0E44\u0E21\u0E48\u0E21\u0E35\u0E2A\u0E34\u0E17\u0E18\u0E34\u0E4C\u0E40\u0E02\u0E49\u0E32\u0E16\u0E36\u0E07\u0E2B\u0E19\u0E49\u0E32\u0E19\u0E35\u0E49 \u0E2B\u0E32\u0E01\u0E04\u0E34\u0E14\u0E27\u0E48\u0E32\u0E04\u0E27\u0E23\u0E40\u0E02\u0E49\u0E32\u0E16\u0E36\u0E07\u0E44\u0E14\u0E49 \u0E01\u0E23\u0E38\u0E13\u0E32\u0E15\u0E34\u0E14\u0E15\u0E48\u0E2D\u0E1C\u0E39\u0E49\u0E14\u0E39\u0E41\u0E25\u0E23\u0E30\u0E1A\u0E1A\u0E02\u0E2D\u0E07\u0E2D\u0E07\u0E04\u0E4C\u0E01\u0E23" }));
|
|
1320
1341
|
}
|
|
1321
1342
|
/**
|
|
1322
1343
|
* Permission gate for a page subtree. Looks up the current pathname in the
|
|
@@ -1860,6 +1881,7 @@ Object.defineProperty(exports, "isAxiosError", {
|
|
|
1860
1881
|
enumerable: true,
|
|
1861
1882
|
get: function () { return axios.isAxiosError; }
|
|
1862
1883
|
});
|
|
1884
|
+
exports.AccessDenied = AccessDenied;
|
|
1863
1885
|
exports.ApiError = ApiError;
|
|
1864
1886
|
exports.AppBreadcrumb = AppBreadcrumb;
|
|
1865
1887
|
exports.AppLayoutShell = AppLayoutShell;
|