@eintrek/erp-shell 0.1.39 → 0.1.41

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.js CHANGED
@@ -459,10 +459,22 @@ function SidebarProvider({ children, defaultOpen = true, }) {
459
459
  localStorage.setItem("sidebar-open", String(open));
460
460
  }
461
461
  }, [open]);
462
- // Handle mobile detection
462
+ // Handle mobile detection.
463
+ //
464
+ // Crossing into a narrow viewport closes the sidebar. One `open` state
465
+ // serves both layouts, and on desktop it is remembered as true — so
466
+ // narrowing the window turned that into a drawer covering the whole page,
467
+ // which had to be dismissed before anything underneath could be reached.
468
+ // A remembered desktop preference is not a request to open a drawer.
463
469
  React.useEffect(() => {
470
+ let wasMobile = null;
464
471
  const checkMobile = () => {
465
- setIsMobile(window.innerWidth < 768);
472
+ const nowMobile = window.innerWidth < 768;
473
+ setIsMobile(nowMobile);
474
+ if (nowMobile && wasMobile === false) {
475
+ setOpenState(false);
476
+ }
477
+ wasMobile = nowMobile;
466
478
  };
467
479
  checkMobile();
468
480
  window.addEventListener("resize", checkMobile);
@@ -783,13 +795,27 @@ function AppBreadcrumb({ labels = {}, homeLabel = "แดชบอร์ด", ro
783
795
  if (segments.length === 0) {
784
796
  return jsxRuntime.jsx("h1", { className: "text-xl font-semibold", children: homeLabel });
785
797
  }
786
- return (jsxRuntime.jsx(erpTheme.Breadcrumb, { children: jsxRuntime.jsxs(erpTheme.BreadcrumbList, { children: [jsxRuntime.jsx(erpTheme.BreadcrumbItem, { className: "hidden md:block", children: jsxRuntime.jsx(erpTheme.BreadcrumbLink, { asChild: true, children: jsxRuntime.jsx(Link, { href: "/", className: "font-thai text-[14px] font-normal text-white/80 hover:text-white transition-colors", children: rootLabel }) }) }), segments.map((segment, index) => {
798
+ return (jsxRuntime.jsx(erpTheme.Breadcrumb, { children: jsxRuntime.jsxs(erpTheme.BreadcrumbList, { children: [jsxRuntime.jsx(erpTheme.BreadcrumbItem, { children: jsxRuntime.jsx(erpTheme.BreadcrumbLink, { asChild: true, children: jsxRuntime.jsx(Link, { href: "/", className: "font-thai text-[14px] font-normal text-white/80 hover:text-white transition-colors", children: rootLabel }) }) }), segments.map((segment, index) => {
787
799
  const href = "/" + segments.slice(0, index + 1).join("/");
788
800
  const isLast = index === segments.length - 1;
789
- const label = labels[segment] || segment;
790
- return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(erpTheme.BreadcrumbSeparator, { className: "hidden md:block text-white/80", children: jsxRuntime.jsx(lucideReact.ChevronRight, { strokeWidth: 2, className: "h-4 w-4" }) }), jsxRuntime.jsx(erpTheme.BreadcrumbItem, { children: isLast ? (jsxRuntime.jsx(erpTheme.BreadcrumbPage, { className: "font-thai text-[14px] font-normal text-white/95 leading-none", children: decodeURIComponent(label) })) : (jsxRuntime.jsx(erpTheme.BreadcrumbLink, { asChild: true, children: jsxRuntime.jsx(Link, { href: href, className: "font-thai text-[14px] font-normal text-white/80 hover:text-white transition-colors leading-none", children: decodeURIComponent(label) }) })) })] }, `${segment}-${index}`));
801
+ // A record id is not a place. Falling back to the raw segment put a
802
+ // 36-character uuid in the trail, which pushed everything before it
803
+ // off a phone and told the reader nothing they could use.
804
+ const label = labels[segment] ?? (isRecordID(segment) ? "รายละเอียด" : segment);
805
+ return (jsxRuntime.jsxs(React.Fragment, { children: [jsxRuntime.jsx(erpTheme.BreadcrumbSeparator, { className: "text-white/80", children: jsxRuntime.jsx(lucideReact.ChevronRight, { strokeWidth: 2, className: "h-4 w-4" }) }), jsxRuntime.jsx(erpTheme.BreadcrumbItem, { children: isLast ? (jsxRuntime.jsx(erpTheme.BreadcrumbPage, { className: "font-thai text-[14px] font-normal text-white/95 leading-none", children: decodeURIComponent(label) })) : (jsxRuntime.jsx(erpTheme.BreadcrumbLink, { asChild: true, children: jsxRuntime.jsx(Link, { href: href, className: "font-thai text-[14px] font-normal text-white/80 hover:text-white transition-colors leading-none", children: decodeURIComponent(label) }) })) })] }, `${segment}-${index}`));
791
806
  })] }) }));
792
807
  }
808
+ /**
809
+ * Whether a path segment is a record identifier rather than a page.
810
+ *
811
+ * Covers the uuid the APIs issue and the long opaque ids that show up in
812
+ * document routes. Deliberately narrow: a real page called "settings" must
813
+ * never be mistaken for one of these.
814
+ */
815
+ function isRecordID(segment) {
816
+ return (/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(segment) ||
817
+ /^[0-9a-f]{24,}$/i.test(segment));
818
+ }
793
819
 
794
820
  function isExternalHref(href) {
795
821
  return /^https?:\/\//i.test(href) || href.startsWith("//");