@apotech-os/support-kit 3.3.0 → 3.4.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/ui/index.cjs CHANGED
@@ -457,13 +457,40 @@ var POINTS_FORMAT = new Intl.NumberFormat("fr-FR", {
457
457
  maximumFractionDigits: 1,
458
458
  signDisplay: "exceptZero"
459
459
  });
460
+ var DELTA_FORMAT = new Intl.NumberFormat("fr-FR", {
461
+ style: "percent",
462
+ maximumFractionDigits: 1,
463
+ signDisplay: "exceptZero"
464
+ });
465
+ function HeroSide({ label, value, compareValue, lowerIsBetter = false, formatValue }) {
466
+ const delta = uiSdk.relativeDelta(value, compareValue);
467
+ const improved = delta === null ? null : delta > 0 !== lowerIsBetter;
468
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
469
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground", children: label }),
470
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xl font-semibold tabular-nums text-foreground", children: formatValue(value) }),
471
+ delta !== null && /* @__PURE__ */ jsxRuntime.jsxs(
472
+ "p",
473
+ {
474
+ className: `text-xs font-medium tabular-nums ${improved ? "text-status-success" : "text-status-blocked"}`,
475
+ children: [
476
+ DELTA_FORMAT.format(delta),
477
+ compareValue !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "ml-1 font-normal text-muted-foreground", children: [
478
+ "vs ",
479
+ formatValue(compareValue)
480
+ ] })
481
+ ]
482
+ }
483
+ )
484
+ ] });
485
+ }
460
486
  function formatRate(value) {
461
487
  return Number.isNaN(value) ? "\u2014" : `${Math.round(value * 100)} %`;
462
488
  }
463
489
  function AutonomyHero({
464
490
  rate,
465
491
  compareRate,
466
- caption
492
+ caption,
493
+ sides = []
467
494
  }) {
468
495
  const points = ratePoints(rate, compareRate);
469
496
  return /* @__PURE__ */ jsxRuntime.jsx(uiSdk.Card, { className: "border-primary/25 bg-gradient-to-br from-primary/10 via-card to-card", children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardContent, { className: "space-y-1 p-4", children: [
@@ -488,7 +515,8 @@ function AutonomyHero({
488
515
  ]
489
516
  }
490
517
  ),
491
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pt-1 text-xs text-muted-foreground", children: caption })
518
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "pt-1 text-xs text-muted-foreground", children: caption }),
519
+ sides.length > 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-2 gap-4 border-t border-border/60 pt-3 sm:max-w-md", children: sides.map((side) => /* @__PURE__ */ jsxRuntime.jsx(HeroSide, { ...side }, side.label)) })
492
520
  ] }) });
493
521
  }
494
522
  var DASHBOARD_PRESETS = [
@@ -548,22 +576,28 @@ function StackedRow({
548
576
  formatCount: formatCount2
549
577
  }) {
550
578
  const width = scale > 0 ? total / scale * 100 : 0;
551
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-[minmax(6rem,9rem)_1fr_auto] items-center gap-3 text-xs", children: [
552
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate text-muted-foreground", title: label, children: label }),
553
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 w-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full overflow-hidden rounded-sm", style: { width: `${width}%` }, children: segments.filter((segment) => segment.value > 0).map((segment) => /* @__PURE__ */ jsxRuntime.jsx(
554
- "div",
555
- {
556
- role: "presentation",
557
- title: `${segment.label} : ${formatCount2(segment.value)}${sharePercent(segment.value, total) === null ? "" : ` (${sharePercent(segment.value, total)})`}`,
558
- style: {
559
- width: `${segment.value / total * 100}%`,
560
- backgroundColor: segment.color
561
- }
562
- },
563
- segment.key
564
- )) }) }),
565
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "tabular-nums text-muted-foreground", children: formatCount2(total) })
566
- ] });
579
+ return (
580
+ // Utilitaires standards seulement : une colonne en valeur arbitraire
581
+ // (`grid-cols-[minmax(6rem,9rem)_1fr_auto]`) n'est pas générée par le
582
+ // Tailwind de l'instance, qui ne scanne pas le dist du kit pour ça — la
583
+ // ligne retombait alors en trois blocs empilés.
584
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 text-xs", children: [
585
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-36 shrink-0 truncate text-muted-foreground", title: label, children: label }),
586
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-4 flex-1", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-full overflow-hidden rounded-sm", style: { width: `${width}%` }, children: segments.filter((segment) => segment.value > 0).map((segment) => /* @__PURE__ */ jsxRuntime.jsx(
587
+ "div",
588
+ {
589
+ role: "presentation",
590
+ title: `${segment.label} : ${formatCount2(segment.value)}${sharePercent(segment.value, total) === null ? "" : ` (${sharePercent(segment.value, total)})`}`,
591
+ style: {
592
+ width: `${segment.value / total * 100}%`,
593
+ backgroundColor: segment.color
594
+ }
595
+ },
596
+ segment.key
597
+ )) }) }),
598
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "w-14 shrink-0 text-right tabular-nums text-muted-foreground", children: formatCount2(total) })
599
+ ] })
600
+ );
567
601
  }
568
602
  function StackedLegend({ segments }) {
569
603
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground", children: segments.map((segment) => /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex items-center gap-1.5", children: [
@@ -683,66 +717,35 @@ function DashboardPage() {
683
717
  ] })
684
718
  }
685
719
  ),
686
- /* @__PURE__ */ jsxRuntime.jsxs(
687
- "div",
720
+ /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "dashboard-kpis", children: /* @__PURE__ */ jsxRuntime.jsx(
721
+ AutonomyHero,
688
722
  {
689
- "data-testid": "dashboard-kpis",
690
- className: "grid grid-cols-1 gap-4 sm:grid-cols-[1.3fr_1fr_1fr]",
691
- children: [
692
- /* @__PURE__ */ jsxRuntime.jsx(
693
- AutonomyHero,
694
- {
695
- rate: loading ? Number.NaN : rate,
696
- compareRate,
697
- caption: loading ? "Calcul en cours\u2026" : `${formatCount(totals.auto)} r\xE9gl\xE9es par l\u2019IA sur ${formatCount(settled)} demandes r\xE9gl\xE9es.`
698
- }
699
- ),
700
- /* @__PURE__ */ jsxRuntime.jsx(
701
- uiSdk.KpiCard,
702
- {
703
- label: "R\xE9ponse automatis\xE9e par l\u2019agent",
704
- value: loading ? Number.NaN : totals.auto,
705
- ...compareTotals === null ? {} : { compareValue: compareTotals.auto },
706
- formatValue: formatCount
707
- }
708
- ),
709
- /* @__PURE__ */ jsxRuntime.jsx(
710
- uiSdk.KpiCard,
711
- {
712
- label: "Repris par un humain",
713
- value: loading ? Number.NaN : totals.human,
714
- ...compareTotals === null ? {} : { compareValue: compareTotals.human },
715
- formatValue: formatCount,
716
- lowerIsBetter: true
717
- }
718
- )
723
+ rate: loading ? Number.NaN : rate,
724
+ compareRate,
725
+ caption: loading ? "Calcul en cours\u2026" : `${formatCount(settled)} demandes r\xE9gl\xE9es sur la p\xE9riode.`,
726
+ sides: loading ? [] : [
727
+ {
728
+ label: "R\xE9ponse automatis\xE9e par l\u2019agent",
729
+ value: totals.auto,
730
+ formatValue: formatCount,
731
+ ...compareTotals === null ? {} : { compareValue: compareTotals.auto }
732
+ },
733
+ {
734
+ label: "Repris par un humain",
735
+ value: totals.human,
736
+ formatValue: formatCount,
737
+ lowerIsBetter: true,
738
+ ...compareTotals === null ? {} : { compareValue: compareTotals.human }
739
+ }
719
740
  ]
720
741
  }
721
- ),
722
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [
723
- /* @__PURE__ */ jsxRuntime.jsx(
724
- uiSdk.KpiCard,
725
- {
726
- label: "Encore en cours",
727
- value: loading ? Number.NaN : totals.inProgress,
728
- formatValue: formatCount
729
- }
730
- ),
731
- /* @__PURE__ */ jsxRuntime.jsx(
732
- uiSdk.KpiCard,
733
- {
734
- label: "Sans r\xE9ponse n\xE9cessaire",
735
- value: loading ? Number.NaN : totals.noReplyNeeded,
736
- formatValue: formatCount
737
- }
738
- )
739
- ] }),
742
+ ) }),
740
743
  /* @__PURE__ */ jsxRuntime.jsxs("details", { className: "text-xs leading-relaxed text-muted-foreground", children: [
741
744
  /* @__PURE__ */ jsxRuntime.jsx("summary", { className: "cursor-pointer select-none font-medium", children: "Comment le taux d\u2019autonomie est calcul\xE9" }),
742
745
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-2", children: "Le taux d\u2019autonomie rapporte les r\xE9ponses envoy\xE9es par l\u2019IA \xE0 ces m\xEAmes r\xE9ponses plus celles qu\u2019un humain a reprises \u2014 bloqu\xE9es, escalad\xE9es, invalid\xE9es parce qu\u2019un agent avait d\xE9j\xE0 r\xE9pondu, ou expir\xE9es. \xB7 Une escalade est compt\xE9e UNE fois, du c\xF4t\xE9 humain : c\u2019est un motif de blocage, pas un camp de plus. \xB7 Les demandes encore en cours, celles sans r\xE9ponse n\xE9cessaire et les \xE9checs techniques sont hors du taux \u2014 les compter d\u2019un c\xF4t\xE9 ou de l\u2019autre le fausserait dans les deux sens. \xB7 Le d\xE9nominateur ne couvre que les demandes mises en file : un ticket escalad\xE9 avant toute g\xE9n\xE9ration n\u2019y figure pas." })
743
746
  ] }),
744
747
  dailyError !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-destructive", children: "Erreur lors du calcul des chiffres cl\xE9s." }),
745
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 lg:grid-cols-2", children: [
748
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4", children: [
746
749
  /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.Card, { children: [
747
750
  /* @__PURE__ */ jsxRuntime.jsx(uiSdk.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsxs(uiSdk.CardTitle, { className: "text-sm", children: [
748
751
  "Automatique ou humain, ",