@bizapps/design-system-testing 1.11.0 → 1.12.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/dist/main.cjs CHANGED
@@ -28,6 +28,7 @@ var reactHookForm = require('react-hook-form');
28
28
  var zod = require('@hookform/resolvers/zod');
29
29
  var confetti = require('canvas-confetti');
30
30
  var reactTable = require('@tanstack/react-table');
31
+ var reactDom = require('react-dom');
31
32
  var SignaturePadLib = require('signature_pad');
32
33
 
33
34
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -5430,10 +5431,11 @@ function SheetContent({
5430
5431
  children,
5431
5432
  side = "right",
5432
5433
  showCloseButton = true,
5434
+ overlayClassName,
5433
5435
  ...props
5434
5436
  }) {
5435
5437
  return /* @__PURE__ */ jsxRuntime.jsxs(SheetPortal, { children: [
5436
- /* @__PURE__ */ jsxRuntime.jsx(SheetOverlay, {}),
5438
+ /* @__PURE__ */ jsxRuntime.jsx(SheetOverlay, { className: overlayClassName }),
5437
5439
  /* @__PURE__ */ jsxRuntime.jsxs(
5438
5440
  radixUi.Dialog.Content,
5439
5441
  {
@@ -9207,6 +9209,7 @@ var DEFAULT_LABELS = {
9207
9209
  collapse: "Collapse menu",
9208
9210
  expand: "Expand menu",
9209
9211
  openMenu: "Open menu",
9212
+ closeMenu: "Close menu",
9210
9213
  currentPageSuffix: " (contains the current page)",
9211
9214
  searchPlaceholder: () => "Filter links\u2026",
9212
9215
  searchLabel: (moduleLabel) => `Filter links of ${moduleLabel}`,
@@ -9221,6 +9224,8 @@ var DEFAULT_LABELS = {
9221
9224
  var EASE = "cubic-bezier(.2,.8,.2,1)";
9222
9225
  var MOTION_MS = 240;
9223
9226
  var FADE_MS = MOTION_MS / 2;
9227
+ var MORPH_MS = 360;
9228
+ var MORPH_EASE = "cubic-bezier(.65,0,.35,1)";
9224
9229
  var BOUNCE_KEYFRAMES = [
9225
9230
  { transform: "translateY(0) scale(1)" },
9226
9231
  { transform: "translateY(-3px) scale(1.06)", offset: 0.35 },
@@ -9229,8 +9234,132 @@ var BOUNCE_KEYFRAMES = [
9229
9234
  ];
9230
9235
  var BOUNCE_MS = 420;
9231
9236
  var SUBTLE_SCROLLBAR = "[scrollbar-color:var(--floating-sidebar-scrollbar-thumb)_var(--floating-sidebar-scrollbar-track)]! [&::-webkit-scrollbar]:w-2.5! [&::-webkit-scrollbar-track]:bg-floating-sidebar-scrollbar-track! [&::-webkit-scrollbar-thumb]:rounded-full! [&::-webkit-scrollbar-thumb]:border-2! [&::-webkit-scrollbar-thumb]:border-solid! [&::-webkit-scrollbar-thumb]:border-floating-sidebar-scrollbar-track! [&::-webkit-scrollbar-thumb]:bg-floating-sidebar-scrollbar-thumb! [&::-webkit-scrollbar-thumb:hover]:bg-floating-sidebar-scrollbar-thumb-hover!";
9232
- var DEFAULT_WIDTH = 276;
9237
+ var MORPH_SETTLE_MS = 120;
9238
+ function morphBox(element) {
9239
+ const rect = element.getBoundingClientRect();
9240
+ const computed = getComputedStyle(element);
9241
+ const drawer = element.closest('[data-slot="sheet-content"]');
9242
+ const drawerRect = drawer?.getBoundingClientRect();
9243
+ const offsetX = drawer && drawerRect ? drawerRect.left - drawer.offsetLeft : 0;
9244
+ const offsetY = drawer && drawerRect ? drawerRect.top - drawer.offsetTop : 0;
9245
+ const borderWidth = parseFloat(computed.borderTopWidth) || 0;
9246
+ return {
9247
+ left: rect.left - offsetX,
9248
+ top: rect.top - offsetY,
9249
+ width: rect.width,
9250
+ height: rect.height,
9251
+ // `rounded-full` resolves to an enormous radius that would not interpolate visibly;
9252
+ // half the height draws the same pill.
9253
+ borderRadius: `${Math.min(parseFloat(computed.borderTopLeftRadius) || 0, rect.height / 2)}px`,
9254
+ borderWidth: `${borderWidth}px`,
9255
+ borderColor: borderWidth > 0 ? computed.borderTopColor : "transparent",
9256
+ backgroundColor: computed.backgroundColor,
9257
+ boxShadow: computed.boxShadow
9258
+ };
9259
+ }
9260
+ var morphStyle = (b) => ({
9261
+ left: `${b.left}px`,
9262
+ top: `${b.top}px`,
9263
+ width: `${b.width}px`,
9264
+ height: `${b.height}px`,
9265
+ borderRadius: b.borderRadius,
9266
+ borderWidth: b.borderWidth,
9267
+ borderColor: b.borderColor,
9268
+ backgroundColor: b.backgroundColor,
9269
+ boxShadow: b.boxShadow
9270
+ });
9271
+ var sameBox = (a, b) => Math.abs(a.left - b.left) < 0.5 && Math.abs(a.top - b.top) < 0.5 && Math.abs(a.width - b.width) < 0.5 && Math.abs(a.height - b.height) < 0.5;
9272
+ function MobileMorph({ morph, side, ghostRef, getTarget, onDone }) {
9273
+ const chevronsRef = react.useRef(null);
9274
+ const menuRef = react.useRef(null);
9275
+ const onDoneRef = react.useRef(onDone);
9276
+ react.useLayoutEffect(() => {
9277
+ onDoneRef.current = onDone;
9278
+ });
9279
+ react.useLayoutEffect(() => {
9280
+ const ghost = ghostRef.current;
9281
+ if (!ghost) return;
9282
+ let frame = 0;
9283
+ let tries = 0;
9284
+ const animations = [];
9285
+ const options = {
9286
+ duration: MORPH_MS,
9287
+ easing: MORPH_EASE,
9288
+ fill: "forwards"
9289
+ };
9290
+ const start = () => {
9291
+ const target = getTarget();
9292
+ if (!target) {
9293
+ if (tries++ < 10) frame = requestAnimationFrame(start);
9294
+ else onDoneRef.current();
9295
+ return;
9296
+ }
9297
+ const to = morphBox(target);
9298
+ const chevrons = morph.to === "open" ? 1 : 0;
9299
+ animations.push(
9300
+ ghost.animate([morphStyle(morph.from), morphStyle(to)], options),
9301
+ chevronsRef.current.animate(
9302
+ [{ opacity: morph.chevrons }, { opacity: chevrons }],
9303
+ options
9304
+ ),
9305
+ menuRef.current.animate(
9306
+ [{ opacity: 1 - morph.chevrons }, { opacity: 1 - chevrons }],
9307
+ options
9308
+ )
9309
+ );
9310
+ animations[0].onfinish = () => {
9311
+ const settled = getTarget();
9312
+ const end = settled && morphBox(settled);
9313
+ if (!end || sameBox(end, to)) return onDoneRef.current();
9314
+ const settle = ghost.animate([morphStyle(to), morphStyle(end)], {
9315
+ ...options,
9316
+ duration: MORPH_SETTLE_MS
9317
+ });
9318
+ animations.push(settle);
9319
+ settle.onfinish = () => onDoneRef.current();
9320
+ };
9321
+ };
9322
+ start();
9323
+ return () => {
9324
+ cancelAnimationFrame(frame);
9325
+ animations.forEach((animation2) => animation2.cancel());
9326
+ };
9327
+ }, [morph, getTarget, ghostRef]);
9328
+ return reactDom.createPortal(
9329
+ /* @__PURE__ */ jsxRuntime.jsxs(
9330
+ "div",
9331
+ {
9332
+ ref: ghostRef,
9333
+ "aria-hidden": "true",
9334
+ "data-slot": "floating-sidebar-morph",
9335
+ "data-state": morph.to,
9336
+ className: "text-primary pointer-events-none fixed z-[60] flex items-center justify-center overflow-hidden border-solid",
9337
+ style: morphStyle(morph.from),
9338
+ children: [
9339
+ /* @__PURE__ */ jsxRuntime.jsx(
9340
+ "span",
9341
+ {
9342
+ ref: chevronsRef,
9343
+ "data-slot": "floating-sidebar-morph-chevrons",
9344
+ className: "absolute flex",
9345
+ style: {
9346
+ opacity: morph.chevrons,
9347
+ // Same direction as the close button's chevrons in the drawer.
9348
+ transform: side === "right" ? "rotate(180deg)" : void 0
9349
+ },
9350
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronsLeft, { className: "size-5", strokeWidth: 1.5 })
9351
+ }
9352
+ ),
9353
+ /* @__PURE__ */ jsxRuntime.jsx("span", { ref: menuRef, className: "absolute flex", style: { opacity: 1 - morph.chevrons }, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Menu, { className: "size-5", strokeWidth: 1.5 }) })
9354
+ ]
9355
+ }
9356
+ ),
9357
+ document.body
9358
+ );
9359
+ }
9360
+ var DEFAULT_WIDTH = 305;
9233
9361
  var DEFAULT_COLLAPSED_WIDTH = 48;
9362
+ var TILE_ICON_SIZE = 22;
9234
9363
  var MIN_COLLAPSED_WIDTH = 40;
9235
9364
  var t = (prop, ms = 300, delay = 0) => `${prop} ${ms}ms ${EASE} ${delay}ms`;
9236
9365
  function transition2(reduced, ...parts) {
@@ -9262,31 +9391,29 @@ function isEditableTarget(target) {
9262
9391
  if (target.closest('[data-slot="floating-sidebar-search"]')) return false;
9263
9392
  return target.closest('[contenteditable]:not([contenteditable="false"])') !== null || target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.tagName === "SELECT";
9264
9393
  }
9394
+ var ICON_SIZES = {
9395
+ sm: "[&>svg]:size-[18px]",
9396
+ md: "[&>svg]:size-5",
9397
+ lg: "[&>svg]:size-[22px]"
9398
+ };
9265
9399
  function SidebarIcon({
9266
9400
  icon,
9267
9401
  resolveIcon,
9268
- small = false
9402
+ size = "md"
9269
9403
  }) {
9270
9404
  const resolved = typeof icon === "string" ? resolveIcon?.(icon) : icon;
9405
+ const sizeClass2 = cn(
9406
+ ICON_SIZES[size],
9407
+ "[&>svg]:transition-[width,height] [&>svg]:duration-240 [&>svg]:ease-[cubic-bezier(.2,.8,.2,1)] motion-reduce:[&>svg]:transition-none"
9408
+ );
9271
9409
  if (resolved === void 0 || resolved === null) {
9272
- return /* @__PURE__ */ jsxRuntime.jsx("span", { "data-slot": "floating-sidebar-fallback-icon", className: "flex", children: /* @__PURE__ */ jsxRuntime.jsx(
9273
- lucideReact.CircleDashed,
9274
- {
9275
- "aria-hidden": "true",
9276
- className: small ? "size-[18px]" : "size-5",
9277
- strokeWidth: 1.5
9278
- }
9279
- ) });
9410
+ return /* @__PURE__ */ jsxRuntime.jsx("span", { "data-slot": "floating-sidebar-fallback-icon", className: cn("flex", sizeClass2), children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleDashed, { "aria-hidden": "true", strokeWidth: 1.5 }) });
9280
9411
  }
9281
9412
  return /* @__PURE__ */ jsxRuntime.jsx(
9282
9413
  "span",
9283
9414
  {
9284
9415
  "data-slot": "floating-sidebar-icon",
9285
- className: cn(
9286
- "flex",
9287
- "[&>svg]:stroke-[1.5]",
9288
- small ? "[&>svg]:size-[18px]" : "[&>svg]:size-5"
9289
- ),
9416
+ className: cn("flex [&>svg]:stroke-[1.5]", sizeClass2),
9290
9417
  children: resolved
9291
9418
  }
9292
9419
  );
@@ -9303,7 +9430,7 @@ function FloatingSidebar({
9303
9430
  collapsedWidth = DEFAULT_COLLAPSED_WIDTH,
9304
9431
  type = "single",
9305
9432
  openModuleIds: openModulesProp,
9306
- defaultOpenModuleIds = [],
9433
+ defaultOpenModuleIds,
9307
9434
  onOpenModulesChange,
9308
9435
  hideEmptyModules = true,
9309
9436
  activeItemId: activeItemProp,
@@ -9332,9 +9459,16 @@ function FloatingSidebar({
9332
9459
  const isMobile = useIsMobile();
9333
9460
  const baseId = react.useId();
9334
9461
  const [open, setOpen] = useControllableState2(openProp, defaultOpen, onOpenChange);
9462
+ const moduleIdByItemId = react.useMemo(
9463
+ () => new Map(modules.flatMap((module) => module.items.map((item) => [item.id, module.id]))),
9464
+ [modules]
9465
+ );
9466
+ const moduleIdOf = (itemId) => itemId ? moduleIdByItemId.get(itemId) : void 0;
9467
+ const initialActiveModuleId = moduleIdOf(activeItemProp ?? defaultActiveItemId);
9335
9468
  const [rawOpenModuleIds, setOpenModuleIds] = useControllableState2(
9336
9469
  openModulesProp,
9337
- defaultOpenModuleIds,
9470
+ // Without an explicit default, the module of the current page starts open.
9471
+ defaultOpenModuleIds ?? (initialActiveModuleId ? [initialActiveModuleId] : []),
9338
9472
  onOpenModulesChange
9339
9473
  );
9340
9474
  const railWidth = Math.max(MIN_COLLAPSED_WIDTH, collapsedWidth);
@@ -9352,6 +9486,51 @@ function FloatingSidebar({
9352
9486
  defaultMobileOpen,
9353
9487
  onMobileOpenChange
9354
9488
  );
9489
+ const morphEnabled = isMobile && mobileOpenProp === void 0 && !reduced;
9490
+ const triggerRef = react.useRef(null);
9491
+ const toggleRef = react.useRef(null);
9492
+ const morphGhostRef = react.useRef(null);
9493
+ const deferredFocus = react.useRef(null);
9494
+ const [morph, setMorph] = react.useState(null);
9495
+ if (morph && !morphEnabled) setMorph(null);
9496
+ const prevMobileOpen = react.useRef(mobileOpen);
9497
+ react.useLayoutEffect(() => {
9498
+ if (prevMobileOpen.current === mobileOpen) return;
9499
+ prevMobileOpen.current = mobileOpen;
9500
+ const ghost = morphGhostRef.current;
9501
+ const source = ghost ?? (mobileOpen ? triggerRef.current : toggleRef.current);
9502
+ deferredFocus.current = null;
9503
+ if (!morphEnabled || !source || typeof source.animate !== "function") return;
9504
+ deferredFocus.current = mobileOpen ? "toggle" : "trigger";
9505
+ const chevrons = ghost?.querySelector(
9506
+ '[data-slot="floating-sidebar-morph-chevrons"]'
9507
+ );
9508
+ setMorph((current) => ({
9509
+ to: mobileOpen ? "open" : "closed",
9510
+ from: morphBox(source),
9511
+ chevrons: chevrons ? parseFloat(getComputedStyle(chevrons).opacity) : mobileOpen ? 0 : 1,
9512
+ key: (current?.key ?? 0) + 1
9513
+ }));
9514
+ }, [mobileOpen, morphEnabled]);
9515
+ const getMorphTarget = react.useCallback(
9516
+ () => morph?.to === "open" ? toggleRef.current : triggerRef.current,
9517
+ [morph?.to]
9518
+ );
9519
+ const endMorph = react.useCallback(() => setMorph(null), []);
9520
+ react.useLayoutEffect(() => {
9521
+ if (morph) return;
9522
+ const pending = deferredFocus.current;
9523
+ deferredFocus.current = null;
9524
+ const active = document.activeElement;
9525
+ if (pending === "toggle") {
9526
+ const toggle2 = toggleRef.current;
9527
+ if (toggle2 && active === toggle2.closest('[data-slot="sheet-content"]')) toggle2.focus();
9528
+ } else if (pending === "trigger" && (!active || active === document.body)) {
9529
+ triggerRef.current?.focus();
9530
+ }
9531
+ }, [morph]);
9532
+ const morphing = morphEnabled && morph !== null;
9533
+ const finePointer = useMediaQuery("(hover: hover) and (pointer: fine)");
9355
9534
  const [queries, setQueries] = react.useState({});
9356
9535
  const [flyoutId, setFlyoutId] = react.useState(null);
9357
9536
  const [hoverId, setHoverId] = react.useState(null);
@@ -9391,8 +9570,31 @@ function FloatingSidebar({
9391
9570
  document.addEventListener("keydown", onKeyDown);
9392
9571
  return () => document.removeEventListener("keydown", onKeyDown);
9393
9572
  }, [shortcut, toggle, isMobile, mobileOpen, setMobileOpen]);
9573
+ const openModule = (moduleId) => {
9574
+ const opened = rawOpenModuleIds.includes(moduleId);
9575
+ if (type === "multiple") {
9576
+ if (!opened) setOpenModuleIds([...rawOpenModuleIds, moduleId]);
9577
+ } else if (!opened || rawOpenModuleIds.length > 1) {
9578
+ setOpenModuleIds([moduleId]);
9579
+ }
9580
+ };
9581
+ const activeModuleId = moduleIdOf(activeItemId);
9582
+ const syncedActive = react.useRef(`${activeItemId}|${activeModuleId}`);
9583
+ react.useEffect(() => {
9584
+ const key = `${activeItemId}|${activeModuleId}`;
9585
+ if (syncedActive.current === key) return;
9586
+ syncedActive.current = key;
9587
+ if (activeModuleId) openModule(activeModuleId);
9588
+ });
9394
9589
  const selectItem = (item, module, navigates) => {
9395
- if (navigates) setActiveItemId(item.id);
9590
+ if (navigates) {
9591
+ setActiveItemId(item.id);
9592
+ openModule(module.id);
9593
+ if (activeItemProp === void 0) {
9594
+ syncedActive.current = `${item.id}|${moduleIdOf(item.id)}`;
9595
+ }
9596
+ if (queries[module.id]) setQueries((current) => ({ ...current, [module.id]: "" }));
9597
+ }
9396
9598
  setFlyoutId(null);
9397
9599
  if (isMobile) setMobileOpen(false);
9398
9600
  onItemSelect?.(item, module);
@@ -9409,7 +9611,7 @@ function FloatingSidebar({
9409
9611
  renderLink,
9410
9612
  onToggleFavorite: toggleFavorite
9411
9613
  };
9412
- const toggleLabel = collapsed ? labels.expand : labels.collapse;
9614
+ const toggleLabel = isMobile ? labels.closeMenu : collapsed ? labels.expand : labels.collapse;
9413
9615
  const ability = useOptionalAbility();
9414
9616
  const usesPermissions = modules.some(
9415
9617
  (module) => module.permission || module.items.some((item) => item.permission)
@@ -9496,20 +9698,25 @@ function FloatingSidebar({
9496
9698
  children: labels.title
9497
9699
  }
9498
9700
  ),
9499
- !isMobile && /* @__PURE__ */ jsxRuntime.jsx(
9701
+ /* @__PURE__ */ jsxRuntime.jsx(
9500
9702
  "button",
9501
9703
  {
9704
+ ref: toggleRef,
9502
9705
  type: "button",
9503
9706
  "data-slot": "floating-sidebar-toggle",
9504
9707
  "aria-label": toggleLabel,
9505
- "aria-expanded": !collapsed,
9506
- title: shortcut ? `${toggleLabel} (Ctrl/\u2318 + B)` : toggleLabel,
9507
- onClick: toggle,
9708
+ "aria-expanded": isMobile ? void 0 : !collapsed,
9709
+ title: shortcut && (!isMobile || finePointer) ? `${toggleLabel} (Ctrl/\u2318 + B)` : toggleLabel,
9710
+ onClick: isMobile ? () => setMobileOpen(false) : toggle,
9508
9711
  className: cn(
9509
9712
  "text-primary focus-visible:ring-primary bg-sidebar border-floating-sidebar-card-border hover:bg-floating-sidebar-toggle-hover flex size-8 shrink-0 cursor-pointer items-center justify-center rounded-full border shadow-[0_2px_6px_color-mix(in_srgb,var(--color-primary)_6%,transparent)] outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
9510
9713
  side === "right" ? "mr-auto" : "ml-auto"
9511
9714
  ),
9512
9715
  style: {
9716
+ // Hidden, and out of reach of a stray tap, while the mobile morph stands in
9717
+ // for it.
9718
+ opacity: morphing ? 0 : void 0,
9719
+ pointerEvents: morphing ? "none" : void 0,
9513
9720
  // The auto margin keeps the toggle on the edge while the width animates;
9514
9721
  // only the outer margin changes, to center it on the collapsed rail.
9515
9722
  // (`auto` cannot be interpolated, so animating it made the toggle jump.)
@@ -9595,36 +9802,65 @@ function FloatingSidebar({
9595
9802
  }
9596
9803
  );
9597
9804
  if (isMobile) {
9598
- return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: 300, children: /* @__PURE__ */ jsxRuntime.jsxs(Sheet, { open: mobileOpen, onOpenChange: setMobileOpen, children: [
9599
- mobileOpenProp === void 0 && /* @__PURE__ */ jsxRuntime.jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
9600
- "button",
9601
- {
9602
- type: "button",
9603
- "data-slot": "floating-sidebar-mobile-trigger",
9604
- "aria-label": labels.openMenu,
9605
- className: "text-primary focus-visible:ring-primary bg-sidebar hover:bg-sidebar-accent flex size-10 cursor-pointer items-center justify-center rounded-[10px] shadow-[0_8px_24px_color-mix(in_srgb,var(--color-primary)_8%,transparent)] outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
9606
- children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Menu, { "aria-hidden": "true", className: "size-5", strokeWidth: 1.5 })
9607
- }
9608
- ) }),
9609
- /* @__PURE__ */ jsxRuntime.jsxs(
9610
- SheetContent,
9805
+ return /* @__PURE__ */ jsxRuntime.jsxs(TooltipProvider, { delayDuration: 300, children: [
9806
+ /* @__PURE__ */ jsxRuntime.jsxs(Sheet, { open: mobileOpen, onOpenChange: setMobileOpen, children: [
9807
+ mobileOpenProp === void 0 && /* @__PURE__ */ jsxRuntime.jsx(SheetTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
9808
+ "button",
9809
+ {
9810
+ ref: triggerRef,
9811
+ type: "button",
9812
+ "data-slot": "floating-sidebar-mobile-trigger",
9813
+ "aria-label": labels.openMenu,
9814
+ style: {
9815
+ opacity: morphing ? 0 : void 0,
9816
+ pointerEvents: morphing ? "none" : void 0
9817
+ },
9818
+ className: "text-primary focus-visible:ring-primary bg-sidebar hover:bg-sidebar-accent flex size-10 cursor-pointer items-center justify-center rounded-[10px] shadow-[0_8px_24px_color-mix(in_srgb,var(--color-primary)_8%,transparent)] outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
9819
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Menu, { "aria-hidden": "true", className: "size-5", strokeWidth: 1.5 })
9820
+ }
9821
+ ) }),
9822
+ /* @__PURE__ */ jsxRuntime.jsxs(
9823
+ SheetContent,
9824
+ {
9825
+ side,
9826
+ "aria-describedby": void 0,
9827
+ showCloseButton: false,
9828
+ overlayClassName: "bg-primary/20",
9829
+ className: "bg-transparent p-3 pt-2 shadow-none data-[side=left]:border-r-0 data-[side=right]:border-l-0",
9830
+ style: { width: width + 24, maxWidth: "100%" },
9831
+ onOpenAutoFocus: (event) => {
9832
+ if (deferredFocus.current !== "toggle") return;
9833
+ event.preventDefault();
9834
+ event.currentTarget?.focus();
9835
+ },
9836
+ onCloseAutoFocus: (event) => {
9837
+ if (deferredFocus.current === "trigger") event.preventDefault();
9838
+ },
9839
+ onEscapeKeyDown: (event) => {
9840
+ const active = document.activeElement;
9841
+ if (active instanceof HTMLInputElement && active.value && active.closest('[data-slot="floating-sidebar-search"]')) {
9842
+ event.preventDefault();
9843
+ }
9844
+ },
9845
+ children: [
9846
+ /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { className: "sr-only", children: labels.title }),
9847
+ nav
9848
+ ]
9849
+ }
9850
+ )
9851
+ ] }),
9852
+ morphing && /* @__PURE__ */ jsxRuntime.jsx(
9853
+ MobileMorph,
9611
9854
  {
9855
+ morph,
9612
9856
  side,
9613
- "aria-describedby": void 0,
9614
- className: "p-4 pt-12",
9615
- onEscapeKeyDown: (event) => {
9616
- const active = document.activeElement;
9617
- if (active instanceof HTMLInputElement && active.value && active.closest('[data-slot="floating-sidebar-search"]')) {
9618
- event.preventDefault();
9619
- }
9620
- },
9621
- children: [
9622
- /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { className: "sr-only", children: labels.title }),
9623
- nav
9624
- ]
9625
- }
9857
+ ghostRef: morphGhostRef,
9858
+ getTarget: getMorphTarget,
9859
+ onDone: endMorph
9860
+ },
9861
+ morph.key
9626
9862
  )
9627
- ] }) });
9863
+ ] });
9628
9864
  }
9629
9865
  return /* @__PURE__ */ jsxRuntime.jsx(TooltipProvider, { delayDuration: 300, children: nav });
9630
9866
  }
@@ -9758,7 +9994,8 @@ function ModuleCard({
9758
9994
  const fillAfterCollapse = tileSelected && tileActive && settling && !reduced;
9759
9995
  const fillTransition = fillAfterCollapse ? `0ms linear ${MOTION_MS}ms` : `${FADE_MS}ms linear 0ms`;
9760
9996
  const iconFlipDelay = fillAfterCollapse ? MOTION_MS : FADE_MS / 2;
9761
- const tilePadding = (tileSize - 2 - 20) / 2;
9997
+ const tilePadding = (tileSize - 2 - TILE_ICON_SIZE) / 2;
9998
+ const iconHighlighted = collapsed ? tileSelected : open;
9762
9999
  const cardRef = react.useRef(null);
9763
10000
  const wasCollapsed = react.useRef(collapsed);
9764
10001
  react.useEffect(() => {
@@ -9798,7 +10035,7 @@ function ModuleCard({
9798
10035
  "border",
9799
10036
  collapsed ? "rounded-[14px]" : "rounded-2xl",
9800
10037
  tileSelected ? "border-primary bg-primary" : "bg-sidebar border-floating-sidebar-card-border",
9801
- open ? "shadow-[0_8px_24px_color-mix(in_srgb,var(--color-primary)_8%,transparent)]" : "shadow-[0_2px_8px_color-mix(in_srgb,var(--color-primary)_4%,transparent)]"
10038
+ open ? "shadow-[0_4px_14px_color-mix(in_srgb,var(--color-primary)_3%,transparent)]" : "shadow-[0_1px_4px_color-mix(in_srgb,var(--color-primary)_3%,transparent)]"
9802
10039
  ),
9803
10040
  style: {
9804
10041
  flex: open ? "0 1 auto" : "0 0 auto",
@@ -9866,8 +10103,24 @@ function ModuleCard({
9866
10103
  "span",
9867
10104
  {
9868
10105
  "data-slot": "floating-sidebar-module-icon",
9869
- className: "relative flex shrink-0 items-center justify-center",
9870
- children: /* @__PURE__ */ jsxRuntime.jsx(SidebarIcon, { icon: module.icon, resolveIcon })
10106
+ className: cn(
10107
+ "relative flex shrink-0 items-center justify-center",
10108
+ !iconHighlighted && "text-muted-foreground"
10109
+ ),
10110
+ style: {
10111
+ transition: transition2(
10112
+ reduced,
10113
+ `color 0ms linear ${iconFlipDelay}ms`
10114
+ )
10115
+ },
10116
+ children: /* @__PURE__ */ jsxRuntime.jsx(
10117
+ SidebarIcon,
10118
+ {
10119
+ icon: module.icon,
10120
+ resolveIcon,
10121
+ size: collapsed ? "lg" : "md"
10122
+ }
10123
+ )
9871
10124
  }
9872
10125
  ),
9873
10126
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -10055,7 +10308,9 @@ function ModuleCard({
10055
10308
  "data-slot": "floating-sidebar-flyout-list",
10056
10309
  "data-scroll": "muted",
10057
10310
  className: cn(
10058
- "max-h-[420px] min-h-0 overflow-y-auto",
10311
+ // Clip x: items nudge 2px right on hover, and a y-only scroller
10312
+ // would then scroll sideways.
10313
+ "max-h-[420px] min-h-0 overflow-x-hidden overflow-y-auto",
10059
10314
  SUBTLE_SCROLLBAR
10060
10315
  ),
10061
10316
  children: [
@@ -10120,7 +10375,7 @@ function ItemRow({ item, list, visible, staggerIndex, onSelect }) {
10120
10375
  "span",
10121
10376
  {
10122
10377
  className: cn("flex shrink-0", active ? "text-primary" : "text-muted-foreground"),
10123
- children: /* @__PURE__ */ jsxRuntime.jsx(SidebarIcon, { icon: item.icon, resolveIcon, small: true })
10378
+ children: /* @__PURE__ */ jsxRuntime.jsx(SidebarIcon, { icon: item.icon, resolveIcon, size: "sm" })
10124
10379
  }
10125
10380
  ),
10126
10381
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 [overflow-wrap:anywhere]", children: item.label })
@@ -10229,6 +10484,1111 @@ function ItemRow({ item, list, visible, staggerIndex, onSelect }) {
10229
10484
  }
10230
10485
  );
10231
10486
  }
10487
+ var AppHubContext = react.createContext(null);
10488
+ function useAppHubContext() {
10489
+ const context = react.use(AppHubContext);
10490
+ if (!context) throw new Error("AppHub parts must be rendered inside <AppHub>.");
10491
+ return context;
10492
+ }
10493
+
10494
+ // src/components/compounds/AppHub/app-hub.constants.ts
10495
+ var DEFAULT_APP_HUB_ID = "app-hub";
10496
+ var DEFAULT_STORAGE_KEY = "tcce-app-hub:open";
10497
+ var OPEN_CHANGE_EVENT = "tcce-app-hub:open-change";
10498
+ var ITEM_SELECTOR = "[data-app-hub-item]";
10499
+ var ENTRY_SELECTOR = "[data-app-hub-entry]";
10500
+ var FOCUS_RING = "outline-hidden focus-visible:outline-2 focus-visible:outline-solid focus-visible:outline-offset-3 focus-visible:outline-main-blue-primary";
10501
+ var TOOLTIP_CLASS = "rounded-lg px-2.75 py-1.75 text-[11px] leading-none font-semibold shadow-black-button motion-reduce:animate-none";
10502
+ var DEFAULT_APP_HUB_LABELS = {
10503
+ navigation: "Applications",
10504
+ allApps: "All applications",
10505
+ sheetTitle: "Applications",
10506
+ hideDock: "Hide dock",
10507
+ showDock: "show applications dock",
10508
+ tab: "Apps",
10509
+ fab: "Apps",
10510
+ pending: (count) => `${count} pending`,
10511
+ leaves: (appName) => `leaves ${appName}`,
10512
+ current: "Current",
10513
+ noAccess: "No access \xB7 ask your manager",
10514
+ searchLabel: "Search applications",
10515
+ searchPlaceholder: "Search apps",
10516
+ clearSearch: "Clear search",
10517
+ resultCount: (count) => count === 1 ? "1 application found" : `${count} applications found`,
10518
+ loading: "Loading applications",
10519
+ empty: "No applications found",
10520
+ noMatch: (query) => `No apps match \u201C${query}\u201D`,
10521
+ noMatchDescription: "Check the spelling or clear the search.",
10522
+ error: "Couldn\u2019t load applications",
10523
+ errorDescription: "The apps in the dock still work.",
10524
+ retry: "Try again",
10525
+ directory: "View all applications",
10526
+ close: "Close",
10527
+ dockHidden: "Applications dock hidden. Use the Apps tab on the right edge to show it again.",
10528
+ dockShown: "Applications dock shown"
10529
+ };
10530
+
10531
+ // src/components/compounds/AppHub/app-hub.utils.ts
10532
+ function mergeLabels(defaults, overrides = {}) {
10533
+ const defined = Object.entries(overrides).filter(([, value]) => value !== void 0);
10534
+ return { ...defaults, ...Object.fromEntries(defined) };
10535
+ }
10536
+ function areLabelsEqual(a, b) {
10537
+ const keys = Object.keys(a);
10538
+ return keys.every((key) => Object.is(a[key], b[key]));
10539
+ }
10540
+ function normalizePending(pending) {
10541
+ return typeof pending === "number" && Number.isFinite(pending) && pending >= 1 ? Math.floor(pending) : 0;
10542
+ }
10543
+ function formatPendingCount(count) {
10544
+ return count > 9 ? "9+" : String(count);
10545
+ }
10546
+ function sumPending(apps) {
10547
+ return apps.reduce((total, app) => total + (app.locked ? 0 : normalizePending(app.pending)), 0);
10548
+ }
10549
+ function getAppAccessibleName(app, labels, appName) {
10550
+ const pending = normalizePending(app.pending);
10551
+ return [
10552
+ app.label,
10553
+ pending > 0 && labels.pending(pending),
10554
+ app.external && labels.leaves(appName)
10555
+ ].filter(Boolean).join(", ");
10556
+ }
10557
+ function getEntryElement(container) {
10558
+ return container?.querySelector(ENTRY_SELECTOR) ?? container?.querySelector(ITEM_SELECTOR) ?? null;
10559
+ }
10560
+ function groupApps(apps) {
10561
+ const sections = /* @__PURE__ */ new Map([[void 0, []]]);
10562
+ for (const app of apps) {
10563
+ const key = app.group || void 0;
10564
+ sections.set(key, [...sections.get(key) ?? [], app]);
10565
+ }
10566
+ return [...sections].filter(([, items]) => items.length > 0).map(([heading, items]) => ({ heading, apps: items }));
10567
+ }
10568
+ function filterApps(apps, query) {
10569
+ const needle = query.trim().toLowerCase();
10570
+ if (!needle) return apps;
10571
+ return apps.filter(
10572
+ (app) => `${app.label} ${app.description ?? ""}`.toLowerCase().includes(needle)
10573
+ );
10574
+ }
10575
+ var appHubIconVariants = classVarianceAuthority.cva("relative flex shrink-0 items-center justify-center", {
10576
+ variants: {
10577
+ tone: {
10578
+ green: "bg-green-100 text-green-800",
10579
+ yellow: "bg-yellow-200 text-yellow-800",
10580
+ navy: "bg-main-blue-primary/10 text-main-blue-primary",
10581
+ orange: "bg-orange-100 text-orange-800",
10582
+ purple: "bg-purple-100 text-purple-600",
10583
+ grey: "bg-light-200 text-main-grey"
10584
+ },
10585
+ size: {
10586
+ tile: "size-12 rounded-2xl [&_svg]:size-5",
10587
+ row: "size-9 rounded-xl [&_svg]:size-4.5",
10588
+ sheet: "size-10 rounded-xl [&_svg]:size-5"
10589
+ },
10590
+ // Declared last so `cn()` keeps the current fill over the tone.
10591
+ current: { true: "bg-main-blue-primary text-main-white", false: "" }
10592
+ },
10593
+ defaultVariants: { tone: "grey", size: "tile", current: false }
10594
+ });
10595
+ function AppHubLink({
10596
+ app,
10597
+ afterNavigate,
10598
+ onClick,
10599
+ ...props
10600
+ }) {
10601
+ const { renderLink, onNavigate } = useAppHubContext();
10602
+ const linkProps = {
10603
+ ...props,
10604
+ href: app.href,
10605
+ onClick: (event) => {
10606
+ onClick?.(event);
10607
+ const modified = event.defaultPrevented || event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey;
10608
+ if (modified) return;
10609
+ onNavigate?.(app, event);
10610
+ afterNavigate?.();
10611
+ }
10612
+ };
10613
+ return renderLink ? renderLink(linkProps, app) : /* @__PURE__ */ jsxRuntime.jsx("a", { ...linkProps });
10614
+ }
10615
+ function AppHubCounter({ count, className }) {
10616
+ if (count <= 0) return null;
10617
+ return /* @__PURE__ */ jsxRuntime.jsx(
10618
+ "span",
10619
+ {
10620
+ "aria-hidden": "true",
10621
+ "data-slot": "app-hub-counter",
10622
+ className: cn(
10623
+ "bg-main-orange-primary text-background ring-background absolute -top-1 -right-1 flex h-4.5 min-w-4.5 items-center justify-center rounded-full px-1 text-[11px] font-bold ring-2",
10624
+ className
10625
+ ),
10626
+ children: formatPendingCount(count)
10627
+ }
10628
+ );
10629
+ }
10630
+ function AppHubTile({ app, current = false }) {
10631
+ const { labels, appName } = useAppHubContext();
10632
+ const name = getAppAccessibleName(app, labels, appName);
10633
+ const tone = app.tone ?? "grey";
10634
+ return /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
10635
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, "aria-describedby": void 0, children: /* @__PURE__ */ jsxRuntime.jsxs(
10636
+ AppHubLink,
10637
+ {
10638
+ app,
10639
+ "aria-label": name,
10640
+ "aria-current": current ? "page" : void 0,
10641
+ "data-slot": "app-hub-tile",
10642
+ "data-variant": tone,
10643
+ "data-current": current ? "" : void 0,
10644
+ "data-app-hub-item": "",
10645
+ "data-app-hub-entry": current ? "" : void 0,
10646
+ className: cn(
10647
+ appHubIconVariants({ tone, size: "tile", current }),
10648
+ "hover:shadow-black-button transition-[translate,box-shadow] hover:-translate-y-0.5 active:translate-y-px active:shadow-none motion-reduce:transition-none",
10649
+ "data-current:before:bg-main-orange-primary data-current:before:absolute data-current:before:-left-2.5 data-current:before:h-5 data-current:before:w-0.75 data-current:before:rounded-full",
10650
+ FOCUS_RING
10651
+ ),
10652
+ children: [
10653
+ /* @__PURE__ */ jsxRuntime.jsx("span", { "aria-hidden": "true", className: "contents", children: app.icon }),
10654
+ /* @__PURE__ */ jsxRuntime.jsx(AppHubCounter, { count: normalizePending(app.pending) })
10655
+ ]
10656
+ }
10657
+ ) }),
10658
+ /* @__PURE__ */ jsxRuntime.jsx(
10659
+ TooltipContent,
10660
+ {
10661
+ "aria-hidden": "true",
10662
+ side: "left",
10663
+ variant: "primary",
10664
+ size: "sm",
10665
+ className: TOOLTIP_CLASS,
10666
+ children: app.label
10667
+ }
10668
+ )
10669
+ ] });
10670
+ }
10671
+ var NAV_KEYS = /* @__PURE__ */ new Set(["ArrowDown", "ArrowUp", "Home", "End"]);
10672
+ function useArrowNavigation(containerRef) {
10673
+ return react.useCallback(
10674
+ (event) => {
10675
+ const container = containerRef.current;
10676
+ const target = event.target;
10677
+ if (event.defaultPrevented || !container || !NAV_KEYS.has(event.key)) return;
10678
+ if (!(target instanceof Element) || !container.contains(target)) return;
10679
+ const current = target.closest(ITEM_SELECTOR);
10680
+ if (!current) return;
10681
+ const items = Array.from(container.querySelectorAll(ITEM_SELECTOR)).filter(
10682
+ (item) => !item.closest("[inert]")
10683
+ );
10684
+ const index = items.indexOf(current);
10685
+ if (index === -1) return;
10686
+ event.preventDefault();
10687
+ const last = items.length - 1;
10688
+ const next = event.key === "Home" ? 0 : event.key === "End" ? last : event.key === "ArrowDown" ? (index + 1) % items.length : (index - 1 + items.length) % items.length;
10689
+ items[next]?.focus();
10690
+ },
10691
+ [containerRef]
10692
+ );
10693
+ }
10694
+ var SKELETON_ROWS = [
10695
+ ["w-[58%]", "w-[82%]"],
10696
+ ["w-[44%]", "w-[70%]"],
10697
+ ["w-[64%]", "w-[76%]"]
10698
+ ];
10699
+ function AppHubRow({
10700
+ app,
10701
+ current,
10702
+ variant,
10703
+ onActivate
10704
+ }) {
10705
+ const { labels, appName } = useAppHubContext();
10706
+ const descId = react.useId();
10707
+ const locked = app.locked === true;
10708
+ const pending = normalizePending(app.pending);
10709
+ const className = cn(
10710
+ "hover:bg-light-200 flex w-full items-center gap-3 rounded-xl p-2 text-left",
10711
+ variant === "panel" ? "min-h-13" : "min-h-14",
10712
+ current && "bg-light-200",
10713
+ FOCUS_RING
10714
+ );
10715
+ const body = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10716
+ /* @__PURE__ */ jsxRuntime.jsx(
10717
+ "span",
10718
+ {
10719
+ "aria-hidden": "true",
10720
+ className: appHubIconVariants({
10721
+ tone: locked ? "grey" : app.tone ?? "grey",
10722
+ size: variant === "panel" ? "row" : "sheet"
10723
+ }),
10724
+ children: app.icon
10725
+ }
10726
+ ),
10727
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex min-w-0 flex-1 flex-col", children: [
10728
+ /* @__PURE__ */ jsxRuntime.jsxs(
10729
+ "span",
10730
+ {
10731
+ className: cn(
10732
+ "text-light-1000 flex items-center gap-1.5 font-medium",
10733
+ variant === "panel" ? "text-sm" : "text-[15px]"
10734
+ ),
10735
+ children: [
10736
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: app.label }),
10737
+ app.external && /* @__PURE__ */ jsxRuntime.jsx(
10738
+ lucideReact.ArrowUpRight,
10739
+ {
10740
+ "aria-hidden": "true",
10741
+ className: "text-main-grey size-3.25 shrink-0"
10742
+ }
10743
+ )
10744
+ ]
10745
+ }
10746
+ ),
10747
+ locked ? /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-main-grey flex items-center gap-1 text-xs", children: [
10748
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Lock, { "aria-hidden": "true", className: "size-3" }),
10749
+ labels.noAccess
10750
+ ] }) : app.description && /* @__PURE__ */ jsxRuntime.jsx(
10751
+ "span",
10752
+ {
10753
+ id: descId,
10754
+ className: cn(
10755
+ "text-main-grey truncate",
10756
+ variant === "panel" ? "text-xs" : "text-[13px]"
10757
+ ),
10758
+ children: app.description
10759
+ }
10760
+ )
10761
+ ] }),
10762
+ current && /* @__PURE__ */ jsxRuntime.jsx(
10763
+ "span",
10764
+ {
10765
+ "aria-hidden": "true",
10766
+ className: "bg-main-blue-primary text-main-white shrink-0 rounded-full px-2 py-0.5 text-[11px] leading-tight font-semibold",
10767
+ children: labels.current
10768
+ }
10769
+ ),
10770
+ pending > 0 && !locked && /* @__PURE__ */ jsxRuntime.jsx(
10771
+ "span",
10772
+ {
10773
+ "aria-hidden": "true",
10774
+ "data-slot": "app-hub-row-counter",
10775
+ className: cn(
10776
+ "bg-main-orange-primary text-background flex shrink-0 items-center justify-center rounded-full font-bold",
10777
+ variant === "panel" ? "h-5 min-w-5 px-1.5 text-[11px]" : "h-5.5 min-w-5.5 px-1.75 text-xs"
10778
+ ),
10779
+ children: formatPendingCount(pending)
10780
+ }
10781
+ )
10782
+ ] });
10783
+ if (locked) {
10784
+ return /* @__PURE__ */ jsxRuntime.jsx(
10785
+ "button",
10786
+ {
10787
+ type: "button",
10788
+ "aria-disabled": "true",
10789
+ "data-slot": "app-hub-row",
10790
+ "data-app-hub-item": "",
10791
+ className: cn(className, "text-main-grey cursor-not-allowed"),
10792
+ children: body
10793
+ }
10794
+ );
10795
+ }
10796
+ return /* @__PURE__ */ jsxRuntime.jsx(
10797
+ AppHubLink,
10798
+ {
10799
+ app,
10800
+ afterNavigate: onActivate,
10801
+ "aria-label": getAppAccessibleName(app, labels, appName),
10802
+ "aria-current": current ? "page" : void 0,
10803
+ "aria-describedby": app.description ? descId : void 0,
10804
+ "data-slot": "app-hub-row",
10805
+ "data-app-hub-item": "",
10806
+ className,
10807
+ children: body
10808
+ }
10809
+ );
10810
+ }
10811
+ function AppHubCatalog({
10812
+ variant,
10813
+ apps,
10814
+ currentAppId,
10815
+ status,
10816
+ onRetry,
10817
+ directoryHref,
10818
+ searchThreshold,
10819
+ onActivate
10820
+ }) {
10821
+ const { labels, renderLink } = useAppHubContext();
10822
+ const rootRef = react.useRef(null);
10823
+ const onKeyDown = useArrowNavigation(rootRef);
10824
+ const searchId = react.useId();
10825
+ const searchRef = react.useRef(null);
10826
+ const [query, setQuery] = react.useState("");
10827
+ const directoryProps = {
10828
+ href: directoryHref ?? "",
10829
+ "data-slot": "app-hub-directory",
10830
+ "data-app-hub-item": "",
10831
+ onClick: () => onActivate?.(),
10832
+ className: cn(
10833
+ "text-main-blue-primary flex items-center gap-2 font-semibold",
10834
+ variant === "panel" ? "border-light-200 hover:bg-light-200 justify-between border-t px-4 py-3 text-[13px]" : "border-light-300 mx-4 mb-4 min-h-13 justify-center rounded-full border text-sm",
10835
+ FOCUS_RING
10836
+ ),
10837
+ children: /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10838
+ labels.directory,
10839
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRight, { "aria-hidden": "true", className: "size-4 shrink-0" })
10840
+ ] })
10841
+ };
10842
+ const ready = status === "ready";
10843
+ const searchVisible = variant === "panel" && ready && apps.length >= searchThreshold;
10844
+ if (!searchVisible && query) setQuery("");
10845
+ const activeQuery = searchVisible ? query : "";
10846
+ const filtered = filterApps(apps, activeQuery);
10847
+ const message = status === "loading" ? labels.loading : activeQuery && labels.resultCount(filtered.length);
10848
+ const [live, setLive] = react.useState("");
10849
+ react.useEffect(() => setLive(message), [message]);
10850
+ return /* @__PURE__ */ jsxRuntime.jsxs(
10851
+ "div",
10852
+ {
10853
+ ref: rootRef,
10854
+ "data-slot": "app-hub-catalog",
10855
+ "data-variant": variant,
10856
+ tabIndex: -1,
10857
+ onKeyDown,
10858
+ className: "flex min-h-0 flex-1 flex-col outline-none",
10859
+ children: [
10860
+ searchVisible && /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-slot": "app-hub-search", className: "relative shrink-0 px-3 pt-3", children: [
10861
+ /* @__PURE__ */ jsxRuntime.jsx("label", { htmlFor: searchId, className: "sr-only", children: labels.searchLabel }),
10862
+ /* @__PURE__ */ jsxRuntime.jsx(
10863
+ lucideReact.Search,
10864
+ {
10865
+ "aria-hidden": "true",
10866
+ className: "text-main-grey pointer-events-none absolute top-[calc(50%+6px)] left-6 size-4 -translate-y-1/2"
10867
+ }
10868
+ ),
10869
+ /* @__PURE__ */ jsxRuntime.jsx(
10870
+ Input,
10871
+ {
10872
+ ref: searchRef,
10873
+ id: searchId,
10874
+ type: "search",
10875
+ value: query,
10876
+ placeholder: labels.searchPlaceholder,
10877
+ onChange: (event) => setQuery(event.target.value),
10878
+ className: "border-main-grey/70 bg-background h-10 rounded-lg px-9 text-sm [&::-webkit-search-cancel-button]:appearance-none"
10879
+ }
10880
+ ),
10881
+ query && /* @__PURE__ */ jsxRuntime.jsx(
10882
+ "button",
10883
+ {
10884
+ type: "button",
10885
+ "aria-label": labels.clearSearch,
10886
+ onClick: () => {
10887
+ setQuery("");
10888
+ searchRef.current?.focus();
10889
+ },
10890
+ className: cn(
10891
+ "text-main-grey hover:bg-light-200 absolute top-[calc(50%+6px)] right-4 flex size-8 -translate-y-1/2 items-center justify-center rounded-lg [&_svg]:size-3.5",
10892
+ FOCUS_RING
10893
+ ),
10894
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": "true" })
10895
+ }
10896
+ )
10897
+ ] }),
10898
+ /* @__PURE__ */ jsxRuntime.jsxs(
10899
+ "div",
10900
+ {
10901
+ "data-slot": "app-hub-catalog-scroll",
10902
+ className: cn(
10903
+ "flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-2",
10904
+ variant === "panel" && "max-h-74"
10905
+ ),
10906
+ children: [
10907
+ /* @__PURE__ */ jsxRuntime.jsx("div", { role: "status", className: "sr-only", children: live }),
10908
+ status === "loading" && /* @__PURE__ */ jsxRuntime.jsx(
10909
+ "div",
10910
+ {
10911
+ "data-slot": "app-hub-loading",
10912
+ "aria-hidden": "true",
10913
+ className: "flex flex-col gap-1",
10914
+ children: SKELETON_ROWS.map(([first, second]) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 p-2", children: [
10915
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bg-light-200 size-9 shrink-0 rounded-xl" }),
10916
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-1 flex-col gap-1.5", children: [
10917
+ /* @__PURE__ */ jsxRuntime.jsx(
10918
+ "span",
10919
+ {
10920
+ className: cn("bg-light-200 h-2.5 rounded-[5px]", first)
10921
+ }
10922
+ ),
10923
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("bg-light-200 h-2 rounded-sm", second) })
10924
+ ] })
10925
+ ] }, first))
10926
+ }
10927
+ ),
10928
+ status === "error" && /* @__PURE__ */ jsxRuntime.jsxs(
10929
+ "div",
10930
+ {
10931
+ role: "alert",
10932
+ "data-slot": "app-hub-error",
10933
+ className: "flex flex-col items-start gap-2.5 px-2 pt-3 pb-2",
10934
+ children: [
10935
+ /* @__PURE__ */ jsxRuntime.jsx(
10936
+ "span",
10937
+ {
10938
+ "aria-hidden": "true",
10939
+ className: "flex size-9 items-center justify-center rounded-xl bg-red-100 text-red-800",
10940
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CircleAlert, { className: "size-4.5" })
10941
+ }
10942
+ ),
10943
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-col gap-1", children: [
10944
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-light-1000 text-sm font-semibold", children: labels.error }),
10945
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-main-grey text-[13px] leading-snug", children: labels.errorDescription })
10946
+ ] }),
10947
+ onRetry && /* @__PURE__ */ jsxRuntime.jsx(
10948
+ Button,
10949
+ {
10950
+ size: "sm",
10951
+ variant: "outline",
10952
+ "data-app-hub-item": "",
10953
+ onClick: () => {
10954
+ rootRef.current?.focus();
10955
+ onRetry();
10956
+ },
10957
+ children: labels.retry
10958
+ }
10959
+ )
10960
+ ]
10961
+ }
10962
+ ),
10963
+ ready && filtered.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs(
10964
+ "div",
10965
+ {
10966
+ "data-slot": "app-hub-empty",
10967
+ className: "flex flex-col items-start gap-1.5 px-2 pt-4 pb-2",
10968
+ children: [
10969
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-light-1000 text-sm font-semibold", children: activeQuery ? labels.noMatch(activeQuery) : labels.empty }),
10970
+ activeQuery && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10971
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-main-grey text-[13px] leading-snug", children: labels.noMatchDescription }),
10972
+ /* @__PURE__ */ jsxRuntime.jsx(
10973
+ "button",
10974
+ {
10975
+ type: "button",
10976
+ "data-app-hub-item": "",
10977
+ onClick: () => {
10978
+ setQuery("");
10979
+ searchRef.current?.focus();
10980
+ },
10981
+ className: cn(
10982
+ "text-main-blue-primary mt-1 rounded-sm py-1.5 text-[13px] font-semibold underline underline-offset-3",
10983
+ FOCUS_RING
10984
+ ),
10985
+ children: labels.clearSearch
10986
+ }
10987
+ )
10988
+ ] })
10989
+ ]
10990
+ }
10991
+ ),
10992
+ ready && groupApps(filtered).map((section) => /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "flex flex-col gap-1", children: [
10993
+ section.heading && /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-main-grey px-2 text-[11px] font-semibold uppercase", children: section.heading }),
10994
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { role: "list", className: "flex flex-col gap-1", children: section.apps.map((app) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(
10995
+ AppHubRow,
10996
+ {
10997
+ app,
10998
+ current: app.id === currentAppId,
10999
+ variant,
11000
+ onActivate
11001
+ }
11002
+ ) }, app.id)) })
11003
+ ] }, section.heading ?? ""))
11004
+ ]
11005
+ }
11006
+ ),
11007
+ directoryHref && /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderLink ? renderLink(directoryProps, void 0) : /* @__PURE__ */ jsxRuntime.jsx("a", { ...directoryProps }) })
11008
+ ]
11009
+ }
11010
+ );
11011
+ }
11012
+ function AppHubPanel({
11013
+ id,
11014
+ open,
11015
+ onOpenChange,
11016
+ onCloseAutoFocus,
11017
+ ...catalog
11018
+ }) {
11019
+ const { labels } = useAppHubContext();
11020
+ const titleId = react.useId();
11021
+ const contentRef = react.useRef(null);
11022
+ const [tooltipOpen, setTooltipOpen] = react.useState(false);
11023
+ if (open && tooltipOpen) setTooltipOpen(false);
11024
+ const quietRef = react.useRef(false);
11025
+ react.useEffect(() => {
11026
+ if (open) return () => void (quietRef.current = true);
11027
+ }, [open]);
11028
+ return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange, children: [
11029
+ /* @__PURE__ */ jsxRuntime.jsxs(
11030
+ Tooltip,
11031
+ {
11032
+ open: tooltipOpen,
11033
+ onOpenChange: (next) => setTooltipOpen(next && !open && !quietRef.current),
11034
+ children: [
11035
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, "aria-describedby": void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
11036
+ PopoverTrigger,
11037
+ {
11038
+ "aria-label": labels.allApps,
11039
+ "aria-controls": id,
11040
+ "data-slot": "app-hub-panel-trigger",
11041
+ onPointerEnter: () => void (quietRef.current = false),
11042
+ onBlur: () => void (quietRef.current = false),
11043
+ "data-app-hub-item": "",
11044
+ className: cn(
11045
+ appHubIconVariants({ tone: "grey", size: "tile" }),
11046
+ // Both triggers write `data-state` through `asChild` and the tooltip's value
11047
+ // wins, so the open tint keys off `aria-expanded` instead.
11048
+ "aria-expanded:bg-main-blue-primary/10 aria-expanded:text-main-blue-primary",
11049
+ FOCUS_RING
11050
+ ),
11051
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutGrid, { "aria-hidden": "true" })
11052
+ }
11053
+ ) }),
11054
+ /* @__PURE__ */ jsxRuntime.jsx(
11055
+ TooltipContent,
11056
+ {
11057
+ "aria-hidden": "true",
11058
+ side: "left",
11059
+ variant: "primary",
11060
+ size: "sm",
11061
+ className: TOOLTIP_CLASS,
11062
+ children: labels.allApps
11063
+ }
11064
+ )
11065
+ ]
11066
+ }
11067
+ ),
11068
+ /* @__PURE__ */ jsxRuntime.jsxs(
11069
+ PopoverContent,
11070
+ {
11071
+ ref: contentRef,
11072
+ id,
11073
+ side: "left",
11074
+ align: "center",
11075
+ sideOffset: 22,
11076
+ collisionPadding: 8,
11077
+ "aria-labelledby": titleId,
11078
+ "data-slot": "app-hub-panel",
11079
+ onCloseAutoFocus,
11080
+ onOpenAutoFocus: (event) => {
11081
+ event.preventDefault();
11082
+ const content = contentRef.current;
11083
+ (content?.querySelector('input[type="search"]') ?? content?.querySelector(ITEM_SELECTOR) ?? content)?.focus();
11084
+ },
11085
+ className: "border-light-300 shadow-black-card max-h-(--radix-popover-content-available-height) w-75 gap-0 rounded-2xl border p-0 motion-reduce:data-[state=closed]:animate-none motion-reduce:data-[state=open]:animate-none",
11086
+ children: [
11087
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 pt-3 pb-1", children: [
11088
+ /* @__PURE__ */ jsxRuntime.jsx(
11089
+ "h2",
11090
+ {
11091
+ id: titleId,
11092
+ className: "font-heading text-main-blue-primary text-base leading-tight font-bold",
11093
+ children: labels.allApps
11094
+ }
11095
+ ),
11096
+ /* @__PURE__ */ jsxRuntime.jsx(
11097
+ "button",
11098
+ {
11099
+ type: "button",
11100
+ "aria-label": labels.close,
11101
+ onClick: () => onOpenChange(false),
11102
+ className: cn(
11103
+ "text-main-grey hover:bg-light-200 flex size-8 items-center justify-center rounded-xl [&_svg]:size-4",
11104
+ FOCUS_RING
11105
+ ),
11106
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": "true" })
11107
+ }
11108
+ )
11109
+ ] }),
11110
+ /* @__PURE__ */ jsxRuntime.jsx(
11111
+ AppHubCatalog,
11112
+ {
11113
+ variant: "panel",
11114
+ onActivate: () => onOpenChange(false),
11115
+ ...catalog
11116
+ }
11117
+ )
11118
+ ]
11119
+ }
11120
+ )
11121
+ ] });
11122
+ }
11123
+ function AppHubRail({
11124
+ id,
11125
+ apps,
11126
+ currentAppId,
11127
+ open,
11128
+ onHide,
11129
+ railRef,
11130
+ panel
11131
+ }) {
11132
+ const { labels } = useAppHubContext();
11133
+ const onKeyDown = useArrowNavigation(railRef);
11134
+ return /* @__PURE__ */ jsxRuntime.jsxs(
11135
+ "div",
11136
+ {
11137
+ ref: railRef,
11138
+ id,
11139
+ "data-slot": "app-hub-rail",
11140
+ "data-state": open ? "open" : "closed",
11141
+ inert: !open,
11142
+ onKeyDown,
11143
+ className: cn(
11144
+ "pointer-events-auto flex flex-col items-center gap-2 px-2.5 py-3",
11145
+ "border-light-200 bg-background/95 shadow-black-card rounded-l-4xl border border-r-0",
11146
+ "transition-transform duration-300 data-[state=closed]:translate-x-[150%] motion-reduce:transition-none"
11147
+ ),
11148
+ children: [
11149
+ /* @__PURE__ */ jsxRuntime.jsx("ul", { role: "list", className: "flex flex-col items-center gap-2", children: apps.map((app) => /* @__PURE__ */ jsxRuntime.jsx("li", { children: /* @__PURE__ */ jsxRuntime.jsx(AppHubTile, { app, current: app.id === currentAppId }) }, app.id)) }),
11150
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", className: "bg-light-300 my-0.5 h-px w-6.5" }),
11151
+ panel,
11152
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "aria-hidden": "true", className: "bg-light-300 my-0.5 h-px w-6.5" }),
11153
+ /* @__PURE__ */ jsxRuntime.jsxs(Tooltip, { children: [
11154
+ /* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, "aria-describedby": void 0, children: /* @__PURE__ */ jsxRuntime.jsx(
11155
+ "button",
11156
+ {
11157
+ type: "button",
11158
+ "aria-label": labels.hideDock,
11159
+ "aria-expanded": "true",
11160
+ "aria-controls": id,
11161
+ "data-slot": "app-hub-hide",
11162
+ "data-app-hub-item": "",
11163
+ onClick: onHide,
11164
+ className: cn(
11165
+ "text-main-grey hover:bg-light-200 hover:text-main-blue-primary flex size-8 items-center justify-center rounded-xl [&_svg]:size-4",
11166
+ FOCUS_RING
11167
+ ),
11168
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.PanelRightClose, { "aria-hidden": "true" })
11169
+ }
11170
+ ) }),
11171
+ /* @__PURE__ */ jsxRuntime.jsx(
11172
+ TooltipContent,
11173
+ {
11174
+ "aria-hidden": "true",
11175
+ side: "left",
11176
+ variant: "primary",
11177
+ size: "sm",
11178
+ className: TOOLTIP_CLASS,
11179
+ children: labels.hideDock
11180
+ }
11181
+ )
11182
+ ] })
11183
+ ]
11184
+ }
11185
+ );
11186
+ }
11187
+ function AppHubTab({ railId, open, pending, onShow, tabRef }) {
11188
+ const { labels } = useAppHubContext();
11189
+ const name = [`${labels.tab}, ${labels.showDock}`, pending > 0 && labels.pending(pending)].filter(Boolean).join(", ");
11190
+ return /* @__PURE__ */ jsxRuntime.jsx(
11191
+ "div",
11192
+ {
11193
+ "data-slot": "app-hub-tab-wrapper",
11194
+ "data-state": open ? "open" : "closed",
11195
+ inert: open,
11196
+ className: "pointer-events-auto transition-transform duration-300 data-[state=open]:translate-x-[150%] motion-reduce:transition-none",
11197
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
11198
+ "button",
11199
+ {
11200
+ ref: tabRef,
11201
+ type: "button",
11202
+ "aria-label": name,
11203
+ "aria-expanded": "false",
11204
+ "aria-controls": railId,
11205
+ "data-slot": "app-hub-tab",
11206
+ "data-app-hub-entry": "",
11207
+ onClick: onShow,
11208
+ className: cn(
11209
+ "border-light-300 bg-background/95 text-main-blue-primary flex w-10 flex-col items-center gap-2 rounded-l-2xl border border-r-0 py-3.5",
11210
+ FOCUS_RING
11211
+ ),
11212
+ children: [
11213
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutGrid, { "aria-hidden": "true", className: "size-4.5" }),
11214
+ /* @__PURE__ */ jsxRuntime.jsx(
11215
+ "span",
11216
+ {
11217
+ "aria-hidden": "true",
11218
+ className: "text-main-grey text-[11px] leading-none font-semibold tracking-[0.12em] uppercase [writing-mode:vertical-rl]",
11219
+ children: labels.tab
11220
+ }
11221
+ ),
11222
+ pending > 0 && /* @__PURE__ */ jsxRuntime.jsx(
11223
+ "span",
11224
+ {
11225
+ "aria-hidden": "true",
11226
+ "data-slot": "app-hub-counter",
11227
+ className: "bg-main-orange-primary text-background flex h-4.5 min-w-4.5 items-center justify-center rounded-full px-1.25 text-[11px] leading-none font-bold",
11228
+ children: formatPendingCount(pending)
11229
+ }
11230
+ )
11231
+ ]
11232
+ }
11233
+ )
11234
+ }
11235
+ );
11236
+ }
11237
+ function AppHubSheet({ pending, ...catalog }) {
11238
+ const { labels } = useAppHubContext();
11239
+ const [open, setOpen] = react.useState(false);
11240
+ return /* @__PURE__ */ jsxRuntime.jsxs(Sheet, { open, onOpenChange: setOpen, children: [
11241
+ /* @__PURE__ */ jsxRuntime.jsxs(
11242
+ SheetTrigger,
11243
+ {
11244
+ "data-slot": "app-hub-fab",
11245
+ "data-app-hub-entry": "",
11246
+ className: cn(
11247
+ // Bottom-right, in the thumb zone and out of the reading area (the rail centers instead).
11248
+ "bg-main-blue-primary text-main-white shadow-black-button pointer-events-auto mr-4 mb-4 flex h-12 items-center gap-2 self-end rounded-full pr-4.5 pl-4 text-sm font-semibold",
11249
+ FOCUS_RING
11250
+ ),
11251
+ children: [
11252
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LayoutGrid, { "aria-hidden": "true", className: "size-4.5" }),
11253
+ labels.fab,
11254
+ pending > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "sr-only", children: [
11255
+ ", ",
11256
+ labels.pending(pending)
11257
+ ] }),
11258
+ pending > 0 && /* @__PURE__ */ jsxRuntime.jsx(
11259
+ "span",
11260
+ {
11261
+ "aria-hidden": "true",
11262
+ "data-slot": "app-hub-counter",
11263
+ className: "bg-main-orange-primary text-background flex h-5 min-w-5 items-center justify-center rounded-full px-1.5 text-[11px] leading-none font-bold",
11264
+ children: formatPendingCount(pending)
11265
+ }
11266
+ )
11267
+ ]
11268
+ }
11269
+ ),
11270
+ /* @__PURE__ */ jsxRuntime.jsxs(
11271
+ SheetContent,
11272
+ {
11273
+ side: "bottom",
11274
+ "aria-modal": "true",
11275
+ "aria-describedby": void 0,
11276
+ showCloseButton: false,
11277
+ onOpenAutoFocus: (event) => {
11278
+ event.preventDefault();
11279
+ event.currentTarget.querySelector('[data-slot="app-hub-sheet-close"]')?.focus();
11280
+ },
11281
+ className: "max-h-[85dvh] rounded-t-3xl motion-reduce:transition-none motion-reduce:data-closed:animate-none motion-reduce:data-open:animate-none",
11282
+ children: [
11283
+ /* @__PURE__ */ jsxRuntime.jsx(
11284
+ "div",
11285
+ {
11286
+ "aria-hidden": "true",
11287
+ className: "bg-light-300 mx-auto mt-2 h-1 w-10 rounded-full"
11288
+ }
11289
+ ),
11290
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 pt-2", children: [
11291
+ /* @__PURE__ */ jsxRuntime.jsx(SheetTitle, { className: "font-heading text-main-blue-primary text-xl leading-tight font-bold", children: labels.sheetTitle }),
11292
+ /* @__PURE__ */ jsxRuntime.jsx(
11293
+ SheetClose,
11294
+ {
11295
+ "data-slot": "app-hub-sheet-close",
11296
+ "aria-label": labels.close,
11297
+ className: cn(
11298
+ "text-main-grey hover:bg-light-200 flex size-11 items-center justify-center rounded-xl [&_svg]:size-5",
11299
+ FOCUS_RING
11300
+ ),
11301
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { "aria-hidden": "true" })
11302
+ }
11303
+ )
11304
+ ] }),
11305
+ /* @__PURE__ */ jsxRuntime.jsx(AppHubCatalog, { ...catalog, variant: "sheet", onActivate: () => setOpen(false) })
11306
+ ]
11307
+ }
11308
+ )
11309
+ ] });
11310
+ }
11311
+ var noopSubscribe = () => () => {
11312
+ };
11313
+ var nullSnapshot = () => null;
11314
+ function useAppHubOpen({
11315
+ open: controlledOpen,
11316
+ defaultOpen,
11317
+ onOpenChange,
11318
+ storageKey: storageKey2,
11319
+ layoutDefault
11320
+ }) {
11321
+ const controlled = controlledOpen !== void 0;
11322
+ const persistedKey = !controlled ? storageKey2 : null;
11323
+ const fallback = defaultOpen ?? layoutDefault;
11324
+ const [memoryOpen, setMemoryOpen] = react.useState(void 0);
11325
+ const [sessionOverride, setSessionOverride] = react.useState(void 0);
11326
+ const store = react.useMemo(() => {
11327
+ if (persistedKey === null) return { subscribe: noopSubscribe, getSnapshot: nullSnapshot };
11328
+ const subscribe2 = (notify) => {
11329
+ const onStorage = (event) => {
11330
+ if (event.key === null || event.key === persistedKey) notify();
11331
+ };
11332
+ const onChange = (event) => {
11333
+ if (event.detail?.key === persistedKey) notify();
11334
+ };
11335
+ window.addEventListener("storage", onStorage);
11336
+ window.addEventListener(OPEN_CHANGE_EVENT, onChange);
11337
+ return () => {
11338
+ window.removeEventListener("storage", onStorage);
11339
+ window.removeEventListener(OPEN_CHANGE_EVENT, onChange);
11340
+ };
11341
+ };
11342
+ const getSnapshot2 = () => {
11343
+ try {
11344
+ const value = window.localStorage.getItem(persistedKey);
11345
+ return value === "true" ? true : value === "false" ? false : null;
11346
+ } catch {
11347
+ return null;
11348
+ }
11349
+ };
11350
+ return { subscribe: subscribe2, getSnapshot: getSnapshot2 };
11351
+ }, [persistedKey]);
11352
+ const stored = react.useSyncExternalStore(store.subscribe, store.getSnapshot, nullSnapshot);
11353
+ const setOpen = react.useCallback(
11354
+ (next) => {
11355
+ onOpenChange?.(next);
11356
+ if (controlled) return;
11357
+ if (storageKey2 === null) {
11358
+ setMemoryOpen(next);
11359
+ return;
11360
+ }
11361
+ try {
11362
+ window.localStorage.setItem(storageKey2, String(next));
11363
+ setSessionOverride(void 0);
11364
+ } catch {
11365
+ setSessionOverride(next);
11366
+ }
11367
+ window.dispatchEvent(
11368
+ new CustomEvent(OPEN_CHANGE_EVENT, { detail: { key: storageKey2 } })
11369
+ );
11370
+ },
11371
+ [controlled, onOpenChange, storageKey2]
11372
+ );
11373
+ let open;
11374
+ if (controlled) open = controlledOpen;
11375
+ else if (storageKey2 === null) open = memoryOpen ?? fallback;
11376
+ else open = sessionOverride ?? stored ?? fallback;
11377
+ return { open, setOpen };
11378
+ }
11379
+ var DESKTOP_QUERY = "(min-width: 1024px)";
11380
+ var TABLET_QUERY = "(min-width: 768px)";
11381
+ function hasMatchMedia() {
11382
+ return typeof window !== "undefined" && typeof window.matchMedia === "function";
11383
+ }
11384
+ function subscribe(notify) {
11385
+ if (!hasMatchMedia()) return () => {
11386
+ };
11387
+ const lists = [DESKTOP_QUERY, TABLET_QUERY].map((query) => window.matchMedia(query));
11388
+ lists.forEach((list) => list.addEventListener("change", notify));
11389
+ return () => lists.forEach((list) => list.removeEventListener("change", notify));
11390
+ }
11391
+ function getSnapshot() {
11392
+ if (!hasMatchMedia()) return "desktop";
11393
+ if (window.matchMedia(DESKTOP_QUERY).matches) return "desktop";
11394
+ return window.matchMedia(TABLET_QUERY).matches ? "tablet" : "mobile";
11395
+ }
11396
+ var getServerSnapshot = () => "desktop";
11397
+ function useAppHubViewport() {
11398
+ return react.useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
11399
+ }
11400
+ function AppHub({
11401
+ apps,
11402
+ appName,
11403
+ currentAppId,
11404
+ catalogStatus = "ready",
11405
+ onRetry,
11406
+ directoryHref,
11407
+ layout = "auto",
11408
+ searchThreshold = 7,
11409
+ position = "fixed",
11410
+ open: openProp,
11411
+ defaultOpen,
11412
+ onOpenChange,
11413
+ storageKey: storageKey2 = DEFAULT_STORAGE_KEY,
11414
+ onNavigate,
11415
+ renderLink,
11416
+ labels: labelOverrides,
11417
+ id = DEFAULT_APP_HUB_ID,
11418
+ className
11419
+ }) {
11420
+ const merged = mergeLabels(DEFAULT_APP_HUB_LABELS, labelOverrides);
11421
+ const [stableLabels, setStableLabels] = react.useState(merged);
11422
+ const labels = areLabelsEqual(stableLabels, merged) ? stableLabels : merged;
11423
+ if (labels !== stableLabels) setStableLabels(labels);
11424
+ const viewport = useAppHubViewport();
11425
+ const family = layout === "auto" ? viewport === "mobile" ? "sheet" : "dock" : layout;
11426
+ const { open, setOpen } = useAppHubOpen({
11427
+ open: openProp,
11428
+ defaultOpen,
11429
+ onOpenChange,
11430
+ storageKey: storageKey2,
11431
+ // Tablet starts collapsed only when the layout follows the viewport.
11432
+ layoutDefault: !(layout === "auto" && viewport === "tablet")
11433
+ });
11434
+ const [panelOpen, setPanelOpen] = react.useState(false);
11435
+ if (!open && panelOpen) setPanelOpen(false);
11436
+ const [announcement, setAnnouncement] = react.useState("");
11437
+ const [, requestRender] = react.useReducer((count) => count + 1, 0);
11438
+ const previousOpenRef = react.useRef(open);
11439
+ const railRef = react.useRef(null);
11440
+ const tabRef = react.useRef(null);
11441
+ const focusIntentRef = react.useRef(null);
11442
+ const railId = `${id}-rail`;
11443
+ react.useLayoutEffect(() => {
11444
+ const intent = focusIntentRef.current;
11445
+ focusIntentRef.current = null;
11446
+ if (previousOpenRef.current === open) return;
11447
+ previousOpenRef.current = open;
11448
+ setAnnouncement(intent === open ? open ? labels.dockShown : labels.dockHidden : "");
11449
+ const entry = open ? getEntryElement(railRef.current) : tabRef.current;
11450
+ if (intent === open) {
11451
+ entry?.focus();
11452
+ return;
11453
+ }
11454
+ const active = document.activeElement;
11455
+ const stranded = open ? [tabRef.current] : [railRef.current, document.getElementById(`${id}-panel`)];
11456
+ if (active && stranded.some((element) => element?.contains(active))) entry?.focus();
11457
+ });
11458
+ function toggle(next) {
11459
+ focusIntentRef.current = next;
11460
+ setOpen(next);
11461
+ requestRender();
11462
+ }
11463
+ const context = react.useMemo(
11464
+ () => ({ labels, appName, renderLink, onNavigate }),
11465
+ [labels, appName, renderLink, onNavigate]
11466
+ );
11467
+ return /* @__PURE__ */ jsxRuntime.jsx(AppHubContext, { value: context, children: /* @__PURE__ */ jsxRuntime.jsxs(
11468
+ "nav",
11469
+ {
11470
+ id,
11471
+ "aria-label": labels.navigation,
11472
+ "data-slot": "app-hub",
11473
+ "data-layout": family,
11474
+ "data-state": open ? "open" : "closed",
11475
+ "data-position": position,
11476
+ className: cn(
11477
+ // `overflow-x-clip` keeps the slid-out form from creating scrollable overflow
11478
+ // (a scrollIntoView would otherwise shift the host); `pl-8` leaves room for the shadow.
11479
+ "pointer-events-none inset-y-0 right-0 z-40 grid items-center justify-items-end overflow-x-clip pl-8 *:col-start-1 *:row-start-1",
11480
+ position === "fixed" ? "fixed" : "absolute",
11481
+ className
11482
+ ),
11483
+ children: [
11484
+ family === "sheet" ? /* @__PURE__ */ jsxRuntime.jsx(
11485
+ AppHubSheet,
11486
+ {
11487
+ apps,
11488
+ currentAppId,
11489
+ status: catalogStatus,
11490
+ onRetry,
11491
+ directoryHref,
11492
+ searchThreshold,
11493
+ pending: sumPending(apps)
11494
+ }
11495
+ ) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11496
+ /* @__PURE__ */ jsxRuntime.jsx(
11497
+ AppHubRail,
11498
+ {
11499
+ id: railId,
11500
+ apps: apps.filter((app) => app.inRail && !app.locked),
11501
+ currentAppId,
11502
+ open,
11503
+ onHide: () => toggle(false),
11504
+ railRef,
11505
+ panel: /* @__PURE__ */ jsxRuntime.jsx(
11506
+ AppHubPanel,
11507
+ {
11508
+ id: `${id}-panel`,
11509
+ open: panelOpen,
11510
+ onOpenChange: setPanelOpen,
11511
+ onCloseAutoFocus: (event) => {
11512
+ if (open) return;
11513
+ event.preventDefault();
11514
+ const active = document.activeElement;
11515
+ if (!active || active === document.body)
11516
+ tabRef.current?.focus();
11517
+ },
11518
+ apps,
11519
+ currentAppId,
11520
+ status: catalogStatus,
11521
+ onRetry,
11522
+ directoryHref,
11523
+ searchThreshold
11524
+ }
11525
+ )
11526
+ }
11527
+ ),
11528
+ /* @__PURE__ */ jsxRuntime.jsx(
11529
+ AppHubTab,
11530
+ {
11531
+ railId,
11532
+ open,
11533
+ pending: sumPending(apps),
11534
+ onShow: () => toggle(true),
11535
+ tabRef
11536
+ }
11537
+ )
11538
+ ] }),
11539
+ /* @__PURE__ */ jsxRuntime.jsx(
11540
+ "div",
11541
+ {
11542
+ role: "status",
11543
+ "aria-live": "polite",
11544
+ "aria-atomic": "true",
11545
+ "data-slot": "app-hub-live",
11546
+ className: "sr-only",
11547
+ children: announcement
11548
+ }
11549
+ )
11550
+ ]
11551
+ }
11552
+ ) });
11553
+ }
11554
+ function getLiveEntry(root) {
11555
+ const live = [...root?.querySelectorAll("[data-slot]") ?? []].find(
11556
+ (region) => !region.closest("[inert]") && getEntryElement(region) !== null
11557
+ );
11558
+ return getEntryElement(live ?? root);
11559
+ }
11560
+ function AppHubSkipLink({
11561
+ targetId = DEFAULT_APP_HUB_ID,
11562
+ children = "Skip to applications",
11563
+ className,
11564
+ onClick,
11565
+ ...props
11566
+ }) {
11567
+ function handleClick(event) {
11568
+ onClick?.(event);
11569
+ if (event.defaultPrevented) return;
11570
+ const entry = getLiveEntry(document.getElementById(targetId));
11571
+ if (!entry) return;
11572
+ event.preventDefault();
11573
+ entry.focus();
11574
+ }
11575
+ return /* @__PURE__ */ jsxRuntime.jsx(
11576
+ "a",
11577
+ {
11578
+ ...props,
11579
+ href: `#${targetId}`,
11580
+ "data-slot": "app-hub-skip-link",
11581
+ onClick: handleClick,
11582
+ className: cn(
11583
+ "bg-main-blue-primary text-main-white sr-only rounded-md px-4 py-2 text-sm font-semibold",
11584
+ "focus:not-sr-only focus:fixed focus:top-2 focus:left-2 focus:z-50",
11585
+ "focus-visible:outline-main-orange-primary outline-hidden focus-visible:outline-2 focus-visible:outline-offset-2",
11586
+ className
11587
+ ),
11588
+ children
11589
+ }
11590
+ );
11591
+ }
10232
11592
  var DrawerContext = react.createContext({ isOpen: false, modal: true });
10233
11593
  function Drawer({ children, open, onOpenChange, modal = true, ...props }) {
10234
11594
  const [internalOpen, setInternalOpen] = react.useState(props.defaultOpen ?? false);
@@ -10689,6 +12049,8 @@ exports.AlertDialogPortal = AlertDialogPortal;
10689
12049
  exports.AlertDialogTitle = AlertDialogTitle;
10690
12050
  exports.AlertDialogTrigger = AlertDialogTrigger;
10691
12051
  exports.AlertTitle = AlertTitle;
12052
+ exports.AppHub = AppHub;
12053
+ exports.AppHubSkipLink = AppHubSkipLink;
10692
12054
  exports.AppShell = AppShell;
10693
12055
  exports.Avatar = Avatar;
10694
12056
  exports.AvatarBadge = AvatarBadge;