@j3m-quantum/ui 1.9.1 → 1.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -9418,36 +9418,41 @@ function getLeftStrokeStyles(state, hasRisk, isHovered) {
9418
9418
  stroke: "border-l-[3px] border-l-red-500",
9419
9419
  content: "text-foreground",
9420
9420
  progressBg: "bg-red-500",
9421
- iconColor: "text-red-600 dark:text-red-400"
9421
+ iconColor: "text-red-600 dark:text-red-400",
9422
+ cardBg: "bg-background"
9422
9423
  };
9423
9424
  }
9424
9425
  switch (state) {
9425
9426
  case "sent":
9426
9427
  return {
9427
- stroke: "border-l-[3px] border-l-green-500/50",
9428
- content: "text-muted-foreground/60",
9429
- progressBg: "bg-green-500",
9430
- iconColor: "text-green-600 dark:text-green-400"
9428
+ stroke: "border-l-[3px] border-l-green-500/40",
9429
+ content: "text-muted-foreground/50",
9430
+ progressBg: "bg-green-500/50",
9431
+ iconColor: "text-green-600/50 dark:text-green-400/50",
9432
+ cardBg: "bg-muted/30"
9431
9433
  };
9432
9434
  case "ready":
9433
9435
  return {
9434
9436
  stroke: "border-l-[3px] border-l-green-500",
9435
9437
  content: "text-foreground",
9436
9438
  progressBg: "bg-green-500",
9437
- iconColor: "text-green-600 dark:text-green-400"
9439
+ iconColor: "text-green-600 dark:text-green-400",
9440
+ cardBg: "bg-background"
9438
9441
  };
9439
9442
  default:
9440
9443
  return {
9441
9444
  stroke: isHovered ? "border-l-[3px] border-l-primary/50" : "border-l-[3px] border-l-border",
9442
9445
  content: "text-foreground",
9443
9446
  progressBg: "bg-primary",
9444
- iconColor: "text-muted-foreground"
9447
+ iconColor: "text-muted-foreground",
9448
+ cardBg: "bg-background"
9445
9449
  };
9446
9450
  }
9447
9451
  }
9448
9452
  function DeliveryBadge({
9449
9453
  delivery,
9450
9454
  onClick,
9455
+ onCommentClick,
9451
9456
  className
9452
9457
  }) {
9453
9458
  const [isHovered, setIsHovered] = React27__namespace.useState(false);
@@ -9510,70 +9515,125 @@ function DeliveryBadge({
9510
9515
  onClick?.();
9511
9516
  }
9512
9517
  };
9518
+ const handleCommentClick = (e) => {
9519
+ e.stopPropagation();
9520
+ onCommentClick?.();
9521
+ };
9522
+ const amountColorClass = React27__namespace.useMemo(() => {
9523
+ if (visualState === "sent") {
9524
+ return "text-muted-foreground/40";
9525
+ }
9526
+ if (delivery.isReadyToUnload) {
9527
+ return "text-green-600 dark:text-green-400";
9528
+ }
9529
+ if (delivery.hasProductionRisk) {
9530
+ return "text-red-600 dark:text-red-400";
9531
+ }
9532
+ return "text-muted-foreground";
9533
+ }, [visualState, delivery.isReadyToUnload, delivery.hasProductionRisk]);
9513
9534
  return /* @__PURE__ */ jsxRuntime.jsxs(
9514
- "button",
9535
+ "div",
9515
9536
  {
9516
- type: "button",
9517
- onClick: handleClick,
9518
- onKeyDown: handleKeyDown,
9519
- onMouseEnter: () => setIsHovered(true),
9520
- onMouseLeave: () => setIsHovered(false),
9521
9537
  className: cn(
9522
- // Position relative for comment dot
9538
+ // Position relative for comment button
9523
9539
  "relative",
9524
9540
  // Full-width in cell, 90° corners
9525
9541
  "w-full rounded-none",
9526
9542
  // Sizing using Quantum tokens:
9527
- // - h-[80px] card height
9528
- // - px-6 = 24px horizontal (j3m.spacing.l)
9529
- // - py-4 = 16px vertical (j3m.spacing.m)
9530
- "h-[80px] px-6 py-4",
9531
- // Layout
9532
- "flex items-center",
9533
- // Card base: white background, complete border
9534
- "bg-background border border-border",
9543
+ // - min-h-[100px] card min-height
9544
+ // - pt-4 pb-3 = vertical padding (j3m.spacing.m / j3m.spacing.s)
9545
+ // - pl-4 = left padding (j3m.spacing.m)
9546
+ // - pr-2 = minimal right padding (progress bar extends further)
9547
+ "min-h-[100px] pt-4 pb-3 pl-4 pr-2",
9548
+ // Card base: dynamic background based on state, complete border
9549
+ styles.cardBg,
9550
+ "border border-border",
9535
9551
  // Left stroke for status
9536
9552
  styles.stroke,
9537
- // Interactive states
9538
- "cursor-pointer transition-all duration-200 ease-out",
9539
- "hover:-translate-y-0.5 hover:shadow-[var(--j3m-shadow-md)]",
9540
- "active:translate-y-0 active:shadow-sm",
9541
- // Focus state
9542
- "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1",
9543
- // Greyed out for sent state
9544
- visualState === "sent" && "opacity-60",
9553
+ // Interactive states (reduced for sent state)
9554
+ "transition-all duration-200 ease-out",
9555
+ visualState !== "sent" && "hover:-translate-y-0.5 hover:shadow-[var(--j3m-shadow-md)]",
9545
9556
  className
9546
9557
  ),
9547
9558
  children: [
9548
- hasComments && /* @__PURE__ */ jsxRuntime.jsx(
9549
- "span",
9559
+ /* @__PURE__ */ jsxRuntime.jsx(
9560
+ Button,
9550
9561
  {
9551
- className: "absolute -top-1 -right-1 h-3 w-3 rounded-full bg-primary ring-2 ring-background",
9552
- "aria-label": "Has comments"
9562
+ type: "button",
9563
+ variant: "ghost",
9564
+ size: "icon",
9565
+ className: cn(
9566
+ "absolute top-2 right-2",
9567
+ // 44px touch target for accessibility
9568
+ "h-11 w-11",
9569
+ "rounded-full",
9570
+ hasComments && "text-primary"
9571
+ ),
9572
+ onClick: handleCommentClick,
9573
+ "aria-label": hasComments ? `${delivery.comments.length} comments` : "Add comment",
9574
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
9575
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-5 w-5" }),
9576
+ hasComments && /* @__PURE__ */ jsxRuntime.jsx(
9577
+ "span",
9578
+ {
9579
+ className: "absolute -top-1 -right-1 h-2.5 w-2.5 rounded-full bg-primary border-2 border-background",
9580
+ "aria-hidden": "true"
9581
+ }
9582
+ )
9583
+ ] })
9553
9584
  }
9554
9585
  ),
9555
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col justify-center gap-3 min-w-0 flex-1 overflow-hidden", children: [
9556
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 overflow-hidden", children: [
9557
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm font-semibold truncate", styles.content), children: prefixTitle }),
9558
- visualState === "sent" && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 text-green-600 dark:text-green-400 shrink-0" }),
9559
- delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-4 w-4 text-red-500 shrink-0" }),
9560
- delivery.supplierName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground truncate ml-auto", children: delivery.supplierName })
9561
- ] }),
9562
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
9563
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Factory, { className: cn("h-3.5 w-3.5 shrink-0", styles.iconColor) }),
9564
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 h-1.5 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
9565
- "div",
9566
- {
9567
- className: cn("h-full rounded-full transition-all", styles.progressBg),
9568
- style: { width: `${productionProgress}%` }
9569
- }
9570
- ) }),
9571
- productionDisplay && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9572
- "text-xs tabular-nums font-medium shrink-0",
9573
- delivery.isReadyToUnload ? "text-green-600 dark:text-green-400" : delivery.hasProductionRisk ? "text-red-600 dark:text-red-400" : "text-muted-foreground"
9574
- ), children: productionDisplay })
9575
- ] })
9576
- ] })
9586
+ /* @__PURE__ */ jsxRuntime.jsxs(
9587
+ "button",
9588
+ {
9589
+ type: "button",
9590
+ onClick: handleClick,
9591
+ onKeyDown: handleKeyDown,
9592
+ onMouseEnter: () => setIsHovered(true),
9593
+ onMouseLeave: () => setIsHovered(false),
9594
+ className: cn(
9595
+ // Full width, no background (inherits from parent)
9596
+ "w-full bg-transparent text-left",
9597
+ // Layout - vertical stack
9598
+ "flex flex-col gap-2",
9599
+ // Interactive states
9600
+ "cursor-pointer",
9601
+ "active:translate-y-0 active:shadow-sm",
9602
+ // Focus state
9603
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-1"
9604
+ ),
9605
+ children: [
9606
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 overflow-hidden pr-12", children: [
9607
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn("text-sm font-semibold truncate", styles.content), children: prefixTitle }),
9608
+ delivery.hasProductionRisk && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertTriangle, { className: "h-4 w-4 text-red-500 shrink-0" }),
9609
+ delivery.supplierName && /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9610
+ "text-xs truncate ml-auto",
9611
+ visualState === "sent" ? "text-muted-foreground/40" : "text-muted-foreground"
9612
+ ), children: delivery.supplierName })
9613
+ ] }),
9614
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pr-14", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 bg-black/10 dark:bg-white/10 rounded-full overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx(
9615
+ "div",
9616
+ {
9617
+ className: cn("h-full rounded-full transition-all", styles.progressBg),
9618
+ style: { width: `${productionProgress}%` }
9619
+ }
9620
+ ) }) }),
9621
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-2", children: [
9622
+ productionDisplay && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1.5", children: [
9623
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Factory, { className: cn("h-3 w-3 shrink-0", styles.iconColor) }),
9624
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9625
+ "text-[11px] tabular-nums font-medium",
9626
+ amountColorClass
9627
+ ), children: productionDisplay })
9628
+ ] }),
9629
+ visualState === "sent" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 ml-auto", children: [
9630
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3.5 w-3.5 text-green-600/60 dark:text-green-400/60 shrink-0" }),
9631
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-medium text-muted-foreground/50 uppercase tracking-wide", children: "Sent" })
9632
+ ] })
9633
+ ] })
9634
+ ]
9635
+ }
9636
+ )
9577
9637
  ]
9578
9638
  }
9579
9639
  );
@@ -9583,7 +9643,7 @@ function WeeklyLoadingView({
9583
9643
  deliveries,
9584
9644
  onDeliveryClick,
9585
9645
  onWeekChange,
9586
- onDayCommentClick,
9646
+ onDeliveryCommentClick,
9587
9647
  showNavigation = true,
9588
9648
  className
9589
9649
  }) {
@@ -9614,20 +9674,6 @@ function WeeklyLoadingView({
9614
9674
  }
9615
9675
  return grouped;
9616
9676
  }, [deliveries]);
9617
- const commentCountByDay = React27__namespace.useMemo(() => {
9618
- const counts = /* @__PURE__ */ new Map();
9619
- for (let i = 1; i <= 5; i++) {
9620
- counts.set(i, 0);
9621
- }
9622
- for (const delivery of deliveries) {
9623
- const dayOfWeek = delivery.date.getDay();
9624
- if (dayOfWeek >= 1 && dayOfWeek <= 5) {
9625
- const current = counts.get(dayOfWeek) ?? 0;
9626
- counts.set(dayOfWeek, current + delivery.comments.length);
9627
- }
9628
- }
9629
- return counts;
9630
- }, [deliveries]);
9631
9677
  const totalDeliveries = deliveries.length;
9632
9678
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("flex flex-col", className), children: [
9633
9679
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 border-b border-border p-4 lg:flex-row lg:items-center lg:justify-between", children: [
@@ -9692,54 +9738,27 @@ function WeeklyLoadingView({
9692
9738
  ] }),
9693
9739
  /* @__PURE__ */ jsxRuntime.jsxs(ScrollArea, { className: "flex-1", children: [
9694
9740
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "hidden sm:block", children: [
9695
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-5 border-b border-border bg-muted/30", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => {
9696
- const dayCommentCount = commentCountByDay.get(dayOfWeek) ?? 0;
9697
- return /* @__PURE__ */ jsxRuntime.jsxs(
9698
- "div",
9699
- {
9700
- className: cn(
9701
- // Relative for positioning comment button
9702
- "relative",
9703
- // Compact padding: py-2 px-3 (j3m.spacing.xs / j3m.spacing.s)
9704
- "flex items-center justify-center gap-2 py-2 px-3",
9705
- dayIsToday && "bg-primary/5"
9706
- ),
9707
- children: [
9708
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9709
- "text-xs font-medium uppercase tracking-wide",
9710
- dayIsToday ? "text-primary" : "text-muted-foreground"
9711
- ), children: getShortDayLabel(dayOfWeek) }),
9712
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9713
- "text-base font-semibold tabular-nums",
9714
- dayIsToday ? "text-primary" : "text-foreground"
9715
- ), children: date.getDate() }),
9716
- /* @__PURE__ */ jsxRuntime.jsxs(
9717
- Button,
9718
- {
9719
- variant: "ghost",
9720
- size: "icon",
9721
- className: cn(
9722
- "absolute top-1 right-1 h-7 w-7",
9723
- dayCommentCount > 0 && "text-primary"
9724
- ),
9725
- onClick: (e) => {
9726
- e.stopPropagation();
9727
- onDayCommentClick?.(dayOfWeek, date);
9728
- },
9729
- children: [
9730
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
9731
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4" }),
9732
- dayCommentCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" })
9733
- ] }),
9734
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: dayCommentCount > 0 ? `${dayCommentCount} comments on ${getShortDayLabel(dayOfWeek)}` : `Add comment for ${getShortDayLabel(dayOfWeek)}` })
9735
- ]
9736
- }
9737
- )
9738
- ]
9739
- },
9740
- dayOfWeek
9741
- );
9742
- }) }),
9741
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-5 border-b border-border bg-muted/30", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => /* @__PURE__ */ jsxRuntime.jsxs(
9742
+ "div",
9743
+ {
9744
+ className: cn(
9745
+ // Compact padding
9746
+ "flex flex-col items-center justify-center py-2 px-2",
9747
+ dayIsToday && "bg-primary/5"
9748
+ ),
9749
+ children: [
9750
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9751
+ "text-[11px] font-semibold uppercase tracking-wide leading-none",
9752
+ dayIsToday ? "text-primary" : "text-muted-foreground"
9753
+ ), children: getShortDayLabel(dayOfWeek) }),
9754
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9755
+ "text-lg font-medium tabular-nums leading-tight mt-0.5",
9756
+ dayIsToday ? "text-primary" : "text-foreground"
9757
+ ), children: date.getDate() })
9758
+ ]
9759
+ },
9760
+ dayOfWeek
9761
+ )) }),
9743
9762
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-5", children: weekDays.map(({ dayOfWeek, isToday: dayIsToday }) => {
9744
9763
  const dayDeliveries = deliveriesByDay.get(dayOfWeek) ?? [];
9745
9764
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -9754,7 +9773,8 @@ function WeeklyLoadingView({
9754
9773
  DeliveryBadge,
9755
9774
  {
9756
9775
  delivery,
9757
- onClick: () => onDeliveryClick?.(delivery)
9776
+ onClick: () => onDeliveryClick?.(delivery),
9777
+ onCommentClick: () => onDeliveryCommentClick?.(delivery)
9758
9778
  },
9759
9779
  delivery.id
9760
9780
  )) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-6 text-sm text-muted-foreground/40", children: "\u2014" }) })
@@ -9765,7 +9785,6 @@ function WeeklyLoadingView({
9765
9785
  ] }),
9766
9786
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:hidden divide-y divide-border", children: weekDays.map(({ date, dayOfWeek, isToday: dayIsToday }) => {
9767
9787
  const dayDeliveries = deliveriesByDay.get(dayOfWeek) ?? [];
9768
- const dayCommentCount = commentCountByDay.get(dayOfWeek) ?? 0;
9769
9788
  return /* @__PURE__ */ jsxRuntime.jsxs(
9770
9789
  "div",
9771
9790
  {
@@ -9774,52 +9793,31 @@ function WeeklyLoadingView({
9774
9793
  ),
9775
9794
  children: [
9776
9795
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between px-4 py-2", children: [
9777
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
9778
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9779
- "text-xs font-medium uppercase",
9780
- dayIsToday ? "text-primary" : "text-muted-foreground"
9781
- ), children: getShortDayLabel(dayOfWeek) }),
9782
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9783
- "text-base font-semibold tabular-nums",
9784
- dayIsToday ? "text-primary" : "text-foreground"
9785
- ), children: date.getDate() }),
9786
- dayIsToday && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-primary font-medium", children: "Today" })
9787
- ] }),
9788
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
9789
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
9790
- dayDeliveries.length,
9791
- " ",
9792
- dayDeliveries.length === 1 ? "delivery" : "deliveries"
9796
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
9797
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center min-w-[40px]", children: [
9798
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9799
+ "text-[11px] font-semibold uppercase tracking-wide leading-none",
9800
+ dayIsToday ? "text-primary" : "text-muted-foreground"
9801
+ ), children: getShortDayLabel(dayOfWeek) }),
9802
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: cn(
9803
+ "text-lg font-medium tabular-nums leading-tight mt-0.5",
9804
+ dayIsToday ? "text-primary" : "text-foreground"
9805
+ ), children: date.getDate() })
9793
9806
  ] }),
9794
- /* @__PURE__ */ jsxRuntime.jsxs(
9795
- Button,
9796
- {
9797
- variant: "ghost",
9798
- size: "icon",
9799
- className: cn(
9800
- "h-7 w-7",
9801
- dayCommentCount > 0 && "text-primary"
9802
- ),
9803
- onClick: (e) => {
9804
- e.stopPropagation();
9805
- onDayCommentClick?.(dayOfWeek, date);
9806
- },
9807
- children: [
9808
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
9809
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4" }),
9810
- dayCommentCount > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "absolute -top-1 -right-1 h-2 w-2 rounded-full bg-primary" })
9811
- ] }),
9812
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Comments" })
9813
- ]
9814
- }
9815
- )
9807
+ dayIsToday && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-primary font-medium bg-primary/10 px-2 py-0.5 rounded", children: "Today" })
9808
+ ] }),
9809
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground", children: [
9810
+ dayDeliveries.length,
9811
+ " ",
9812
+ dayDeliveries.length === 1 ? "delivery" : "deliveries"
9816
9813
  ] })
9817
9814
  ] }),
9818
9815
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-3 p-3 pt-0", children: dayDeliveries.length > 0 ? dayDeliveries.map((delivery) => /* @__PURE__ */ jsxRuntime.jsx(
9819
9816
  DeliveryBadge,
9820
9817
  {
9821
9818
  delivery,
9822
- onClick: () => onDeliveryClick?.(delivery)
9819
+ onClick: () => onDeliveryClick?.(delivery),
9820
+ onCommentClick: () => onDeliveryCommentClick?.(delivery)
9823
9821
  },
9824
9822
  delivery.id
9825
9823
  )) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-muted-foreground/40 py-4 text-center", children: "\u2014" }) })
@@ -9929,7 +9927,7 @@ function AddCommentDialog({
9929
9927
  }, [open]);
9930
9928
  return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-md", children: [
9931
9929
  /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
9932
- /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Add pre-unloading note" }),
9930
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Add pre-loading note" }),
9933
9931
  /* @__PURE__ */ jsxRuntime.jsxs(DialogDescription, { children: [
9934
9932
  "Add a note for ",
9935
9933
  /* @__PURE__ */ jsxRuntime.jsx("strong", { children: delivery.label }),
@@ -9945,7 +9943,7 @@ function AddCommentDialog({
9945
9943
  Textarea,
9946
9944
  {
9947
9945
  id: "comment-text",
9948
- placeholder: "Add a note before unloading...",
9946
+ placeholder: "Add a note before loading...",
9949
9947
  value: commentText,
9950
9948
  onChange: (e) => setCommentText(e.target.value),
9951
9949
  onKeyDown: handleKeyDown,
@@ -10000,7 +9998,7 @@ function CommentsSection({
10000
9998
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
10001
9999
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10002
10000
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { className: "h-4 w-4 text-muted-foreground" }),
10003
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Notes before unloading" }),
10001
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Notes before loading" }),
10004
10002
  comments.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "secondary", className: "text-[10px] h-5", children: comments.length })
10005
10003
  ] }),
10006
10004
  /* @__PURE__ */ jsxRuntime.jsxs(
@@ -10035,7 +10033,7 @@ function CommentsSection({
10035
10033
  ] }),
10036
10034
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm", children: comment.text })
10037
10035
  ] }, comment.id)) })
10038
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-dashed p-4 text-center text-sm text-muted-foreground", children: "No pre-unloading notes yet. Add notes before confirming the load." })
10036
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-dashed p-4 text-center text-sm text-muted-foreground", children: "No pre-loading notes yet. Add notes before confirming the load." })
10039
10037
  ] }),
10040
10038
  /* @__PURE__ */ jsxRuntime.jsx(
10041
10039
  AddCommentDialog,
@@ -10098,7 +10096,7 @@ function DeliveryDetailPage({
10098
10096
  const addons = delivery.elements.filter((e) => e.status === "addon");
10099
10097
  return { loaded, missing, moved, addons };
10100
10098
  }, [delivery.elements]);
10101
- const preUnloadingComments = delivery.comments.filter((c) => c.context === "pre_unloading");
10099
+ const preLoadingComments = delivery.comments.filter((c) => c.context === "pre_unloading");
10102
10100
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col h-full", children: [
10103
10101
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 px-4 py-3 border-b bg-background sticky top-0 z-10", children: /* @__PURE__ */ jsxRuntime.jsxs(
10104
10102
  Button,
@@ -10147,7 +10145,7 @@ function DeliveryDetailPage({
10147
10145
  {
10148
10146
  variant: "outline",
10149
10147
  className: "bg-green-100 dark:bg-green-900/50 border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",
10150
- children: "Ready to unload"
10148
+ children: "Ready to load"
10151
10149
  }
10152
10150
  )
10153
10151
  ] })
@@ -10238,13 +10236,13 @@ function DeliveryDetailPage({
10238
10236
  ] })
10239
10237
  ] })
10240
10238
  ] }),
10241
- delivery.elements.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
10239
+ (elementsByStatus.loaded.length > 0 || elementsByStatus.missing.length > 0 || elementsByStatus.moved.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
10242
10240
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10243
10241
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Package, { className: "h-4 w-4 text-muted-foreground" }),
10244
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Elements to Unload" }),
10242
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "What should be packed" }),
10245
10243
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground ml-auto", children: [
10246
- delivery.elements.length,
10247
- " total"
10244
+ elementsByStatus.loaded.length + elementsByStatus.missing.length + elementsByStatus.moved.length,
10245
+ " items"
10248
10246
  ] })
10249
10247
  ] }),
10250
10248
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
@@ -10255,7 +10253,7 @@ function DeliveryDetailPage({
10255
10253
  /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-right", children: "Size (m\xB2)" }),
10256
10254
  /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-center", children: "Status" })
10257
10255
  ] }) }),
10258
- /* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: delivery.elements.map((element) => /* @__PURE__ */ jsxRuntime.jsxs(
10256
+ /* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: [...elementsByStatus.loaded, ...elementsByStatus.missing, ...elementsByStatus.moved].map((element) => /* @__PURE__ */ jsxRuntime.jsxs(
10259
10257
  TableRow,
10260
10258
  {
10261
10259
  className: getElementRowBg(element.status),
@@ -10283,10 +10281,6 @@ function DeliveryDetailPage({
10283
10281
  element.status === "moved" && element.actualDeliveryLabel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[9px] text-blue-600 dark:text-blue-400", children: [
10284
10282
  "\u2192 ",
10285
10283
  element.actualDeliveryLabel
10286
- ] }),
10287
- element.status === "addon" && element.originalDeliveryLabel && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-[9px] text-purple-600 dark:text-purple-400", children: [
10288
- "from ",
10289
- element.originalDeliveryLabel
10290
10284
  ] })
10291
10285
  ] }) })
10292
10286
  ]
@@ -10295,10 +10289,48 @@ function DeliveryDetailPage({
10295
10289
  )) })
10296
10290
  ] }) })
10297
10291
  ] }),
10292
+ elementsByStatus.addons.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "space-y-3", children: [
10293
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
10294
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, { className: "h-4 w-4 text-purple-600 dark:text-purple-400" }),
10295
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm font-semibold", children: "Extra items (moved to this delivery)" }),
10296
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-xs text-muted-foreground ml-auto", children: [
10297
+ elementsByStatus.addons.length,
10298
+ " items"
10299
+ ] })
10300
+ ] }),
10301
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "These items were originally planned for other deliveries but have been moved to this one." }),
10302
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg border border-purple-200 dark:border-purple-800 overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsxs(Table, { children: [
10303
+ /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(TableRow, { className: "bg-purple-50/50 dark:bg-purple-950/30 hover:bg-purple-50/50 dark:hover:bg-purple-950/30", children: [
10304
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold", children: "Prefix" }),
10305
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold", children: "Type" }),
10306
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-right", children: "Weight" }),
10307
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold text-right", children: "Size (m\xB2)" }),
10308
+ /* @__PURE__ */ jsxRuntime.jsx(TableHead, { className: "font-semibold", children: "Moved from" })
10309
+ ] }) }),
10310
+ /* @__PURE__ */ jsxRuntime.jsx(TableBody, { children: elementsByStatus.addons.map((element) => /* @__PURE__ */ jsxRuntime.jsxs(
10311
+ TableRow,
10312
+ {
10313
+ className: "bg-purple-50/30 dark:bg-purple-950/10",
10314
+ children: [
10315
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "font-medium", children: element.prefix }),
10316
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: element.type }),
10317
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-right tabular-nums", children: element.weight ? /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
10318
+ element.weight,
10319
+ " ",
10320
+ element.weightUnit || "kg"
10321
+ ] }) : "\u2014" }),
10322
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { className: "text-right tabular-nums", children: element.sizeSqm ?? "\u2014" }),
10323
+ /* @__PURE__ */ jsxRuntime.jsx(TableCell, { children: element.originalDeliveryLabel ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-purple-600 dark:text-purple-400", children: element.originalDeliveryLabel }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: "\u2014" }) })
10324
+ ]
10325
+ },
10326
+ element.id
10327
+ )) })
10328
+ ] }) })
10329
+ ] }),
10298
10330
  /* @__PURE__ */ jsxRuntime.jsx(
10299
10331
  CommentsSection,
10300
10332
  {
10301
- comments: preUnloadingComments,
10333
+ comments: preLoadingComments,
10302
10334
  delivery,
10303
10335
  weekId: week.weekKey,
10304
10336
  onAddComment
@@ -10335,6 +10367,9 @@ function SupplierWeeklyLoading({
10335
10367
  }) {
10336
10368
  const [selectedDelivery, setSelectedDelivery] = React27__namespace.useState(null);
10337
10369
  const [sheetOpen, setSheetOpen] = React27__namespace.useState(false);
10370
+ const [commentDelivery, setCommentDelivery] = React27__namespace.useState(null);
10371
+ const [commentDialogOpen, setCommentDialogOpen] = React27__namespace.useState(false);
10372
+ const [commentText, setCommentText] = React27__namespace.useState("");
10338
10373
  const handleDeliveryClick = (delivery) => {
10339
10374
  setSelectedDelivery(delivery);
10340
10375
  setSheetOpen(true);
@@ -10345,6 +10380,38 @@ function SupplierWeeklyLoading({
10345
10380
  setTimeout(() => setSelectedDelivery(null), 200);
10346
10381
  onBack?.();
10347
10382
  };
10383
+ const handleDeliveryCommentClick = (delivery) => {
10384
+ setCommentDelivery(delivery);
10385
+ setCommentDialogOpen(true);
10386
+ };
10387
+ const handleCommentDialogClose = () => {
10388
+ setCommentDialogOpen(false);
10389
+ setCommentText("");
10390
+ setTimeout(() => setCommentDelivery(null), 200);
10391
+ };
10392
+ const handleCommentSubmit = () => {
10393
+ if (commentText.trim() && commentDelivery && onAddComment) {
10394
+ onAddComment({
10395
+ author: "Current User",
10396
+ // Would come from auth context in real app
10397
+ text: commentText.trim(),
10398
+ context: "pre_unloading",
10399
+ weekId: week.weekKey,
10400
+ deliveryId: commentDelivery.id,
10401
+ supplierId: commentDelivery.supplierId,
10402
+ supplierName: commentDelivery.supplierName,
10403
+ prefixId: commentDelivery.prefixScope,
10404
+ prefixName: commentDelivery.prefixScope
10405
+ });
10406
+ handleCommentDialogClose();
10407
+ }
10408
+ };
10409
+ const handleCommentKeyDown = (e) => {
10410
+ if (e.key === "Enter" && (e.metaKey || e.ctrlKey)) {
10411
+ e.preventDefault();
10412
+ handleCommentSubmit();
10413
+ }
10414
+ };
10348
10415
  const Wrapper = bordered ? Card : "div";
10349
10416
  const Content14 = bordered ? CardContent : "div";
10350
10417
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -10363,6 +10430,7 @@ function SupplierWeeklyLoading({
10363
10430
  week,
10364
10431
  deliveries,
10365
10432
  onDeliveryClick: handleDeliveryClick,
10433
+ onDeliveryCommentClick: handleDeliveryCommentClick,
10366
10434
  onWeekChange,
10367
10435
  showNavigation
10368
10436
  }
@@ -10391,7 +10459,58 @@ function SupplierWeeklyLoading({
10391
10459
  )
10392
10460
  ]
10393
10461
  }
10394
- ) })
10462
+ ) }),
10463
+ /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: commentDialogOpen, onOpenChange: (open) => !open && handleCommentDialogClose(), children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "sm:max-w-md", children: [
10464
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
10465
+ /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Add pre-loading note" }),
10466
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogDescription, { children: [
10467
+ "Add a note for ",
10468
+ /* @__PURE__ */ jsxRuntime.jsx("strong", { children: commentDelivery?.label }),
10469
+ " (",
10470
+ commentDelivery?.supplierName,
10471
+ commentDelivery?.prefixScope && ` \u2022 ${commentDelivery.prefixScope}`,
10472
+ ")."
10473
+ ] })
10474
+ ] }),
10475
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4 py-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
10476
+ /* @__PURE__ */ jsxRuntime.jsx(Label2, { htmlFor: "card-comment-text", className: "text-sm font-medium", children: "Note" }),
10477
+ /* @__PURE__ */ jsxRuntime.jsx(
10478
+ Textarea,
10479
+ {
10480
+ id: "card-comment-text",
10481
+ placeholder: "Add a note before loading...",
10482
+ value: commentText,
10483
+ onChange: (e) => setCommentText(e.target.value),
10484
+ onKeyDown: handleCommentKeyDown,
10485
+ className: "min-h-[120px] text-base resize-none",
10486
+ autoFocus: true
10487
+ }
10488
+ ),
10489
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: "\u2318+Enter to save" })
10490
+ ] }) }),
10491
+ /* @__PURE__ */ jsxRuntime.jsxs(DialogFooter, { className: "gap-2 sm:gap-0", children: [
10492
+ /* @__PURE__ */ jsxRuntime.jsx(
10493
+ Button,
10494
+ {
10495
+ variant: "ghost",
10496
+ onClick: handleCommentDialogClose,
10497
+ children: "Cancel"
10498
+ }
10499
+ ),
10500
+ /* @__PURE__ */ jsxRuntime.jsxs(
10501
+ Button,
10502
+ {
10503
+ onClick: handleCommentSubmit,
10504
+ disabled: !commentText.trim(),
10505
+ className: "gap-1.5",
10506
+ children: [
10507
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Send, { className: "h-4 w-4" }),
10508
+ "Save note"
10509
+ ]
10510
+ }
10511
+ )
10512
+ ] })
10513
+ ] }) })
10395
10514
  ] });
10396
10515
  }
10397
10516
  function getStatusBadgeVariant3(status) {