@mediaradar/design-components 0.33.0 → 0.35.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 +120 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +75 -16
- package/dist/index.d.ts +75 -16
- package/dist/index.js +145 -90
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -645,7 +645,7 @@ var import_lucide_react5 = require("lucide-react");
|
|
|
645
645
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
646
646
|
function boxClass(on, disabled) {
|
|
647
647
|
return cn(
|
|
648
|
-
"flex
|
|
648
|
+
"flex size-4.5 shrink-0 items-center justify-center rounded-small border transition-colors",
|
|
649
649
|
on ? "border-transparent bg-brand-primaryAction text-brand-onprimary" : "border-border-interactive bg-input",
|
|
650
650
|
disabled && "cursor-not-allowed opacity-50"
|
|
651
651
|
);
|
|
@@ -727,6 +727,7 @@ var CREATIVE_INTEL_SHORTCUTS = [
|
|
|
727
727
|
"All available history",
|
|
728
728
|
"Custom"
|
|
729
729
|
];
|
|
730
|
+
var HIDDEN_SHORTCUTS = ["Last 30 days"];
|
|
730
731
|
var WEEKDAYS = ["Mo", "Tu", "We", "Th", "Fr", "Sa", "Su"];
|
|
731
732
|
var MONTHS = [
|
|
732
733
|
"January",
|
|
@@ -757,6 +758,20 @@ var fmt = (d) => `${MONTHS[d.getMonth()].slice(0, 3)} ${d.getDate()}, ${d.getFul
|
|
|
757
758
|
var fmtFull = (d) => `${MONTHS[d.getMonth()]} ${d.getDate()}, ${d.getFullYear()}`;
|
|
758
759
|
var fullRangeLabel = (s, e) => `${fmtFull(s)} - ${fmtFull(e)}`;
|
|
759
760
|
var presetLabel = (sc) => sc === "Custom" ? "Custom range" : sc;
|
|
761
|
+
var MON = (d) => MONTHS[d.getMonth()].slice(0, 3);
|
|
762
|
+
function spanLabel(s, e) {
|
|
763
|
+
if (s.getFullYear() !== e.getFullYear()) return `${fmt(s)} \u2013 ${fmt(e)}`;
|
|
764
|
+
if (s.getMonth() !== e.getMonth()) return `${MON(s)} ${s.getDate()} \u2013 ${MON(e)} ${e.getDate()}, ${e.getFullYear()}`;
|
|
765
|
+
return s.getDate() === e.getDate() ? fmt(s) : `${MON(s)} ${s.getDate()} \u2013 ${e.getDate()}, ${e.getFullYear()}`;
|
|
766
|
+
}
|
|
767
|
+
function compareSpan(s, e, mode) {
|
|
768
|
+
if (mode === "year") {
|
|
769
|
+
const back = (d) => new Date(d.getFullYear() - 1, d.getMonth(), d.getDate());
|
|
770
|
+
return [back(s), back(e)];
|
|
771
|
+
}
|
|
772
|
+
const days = Math.round((startOfDay(e).getTime() - startOfDay(s).getTime()) / 864e5) + 1;
|
|
773
|
+
return [addDays(s, -days), addDays(s, -1)];
|
|
774
|
+
}
|
|
760
775
|
function presetRange(key, today) {
|
|
761
776
|
const t = startOfDay(today);
|
|
762
777
|
const qMonth = Math.floor(t.getMonth() / 3) * 3;
|
|
@@ -793,6 +808,8 @@ function presetRange(key, today) {
|
|
|
793
808
|
return [addDays(t, -6), t];
|
|
794
809
|
case "Last 14 days":
|
|
795
810
|
return [addDays(t, -13), t];
|
|
811
|
+
case "Last 30 days":
|
|
812
|
+
return [addDays(t, -29), t];
|
|
796
813
|
case "Last month": {
|
|
797
814
|
const s = new Date(t.getFullYear(), t.getMonth() - 1, 1);
|
|
798
815
|
const e = new Date(t.getFullYear(), t.getMonth(), 0);
|
|
@@ -814,7 +831,7 @@ function monthGrid(year, month) {
|
|
|
814
831
|
}
|
|
815
832
|
function matchShortcut(shortcuts, label) {
|
|
816
833
|
if (!label) return "Rolling 12 months";
|
|
817
|
-
const hit = shortcuts.find((s) => s.toLowerCase() === label.toLowerCase());
|
|
834
|
+
const hit = [...shortcuts, ...HIDDEN_SHORTCUTS].find((s) => s.toLowerCase() === label.toLowerCase());
|
|
818
835
|
return hit || "Custom";
|
|
819
836
|
}
|
|
820
837
|
function slug2(value) {
|
|
@@ -833,23 +850,43 @@ function DateRangeFilter({
|
|
|
833
850
|
shortDates = false,
|
|
834
851
|
icon,
|
|
835
852
|
presetSet = "default",
|
|
853
|
+
excludePresets = [],
|
|
854
|
+
emptyLabel,
|
|
855
|
+
today: todayProp,
|
|
856
|
+
initialRange,
|
|
857
|
+
compare,
|
|
858
|
+
onApply,
|
|
836
859
|
testIdPrefix,
|
|
837
860
|
granularity = "day"
|
|
838
861
|
}) {
|
|
839
862
|
const monthly = granularity === "month";
|
|
840
863
|
const snap = (s, e) => monthly ? [firstOfMonth(s), lastOfMonth(e)] : [s, e];
|
|
841
864
|
const controlled = controlledValue !== void 0 && controlledRange !== void 0;
|
|
842
|
-
const
|
|
843
|
-
const
|
|
865
|
+
const startsEmpty = !controlled && !!emptyLabel;
|
|
866
|
+
const SHORTCUTS = (presetSet === "creativeIntel" ? CREATIVE_INTEL_SHORTCUTS : DEFAULT_SHORTCUTS).filter(
|
|
867
|
+
(s) => !excludePresets.includes(s)
|
|
868
|
+
);
|
|
869
|
+
const today = (0, import_react3.useMemo)(() => todayProp ?? /* @__PURE__ */ new Date(), []);
|
|
844
870
|
const initShortcut = matchShortcut(SHORTCUTS, controlled ? controlledValue : defaultValue);
|
|
845
|
-
const initRange = controlled ? controlledRange : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today));
|
|
871
|
+
const initRange = controlled ? controlledRange : initShortcut === "Custom" && initialRange ? snap(...initialRange) : snap(...presetRange(initShortcut === "Custom" ? "Rolling 12 months" : initShortcut, today));
|
|
872
|
+
const compareLabel = (id) => compare?.options.find((o) => o.id === id)?.label;
|
|
846
873
|
const dateLine = (s, e) => monthly ? `${fmtMonth(s)} \u2013 ${fmtMonth(e)}` : shortDates ? `${fmt(s)} \u2013 ${fmt(e)}` : fullRangeLabel(s, e);
|
|
847
874
|
const [open, setOpen] = (0, import_react3.useState)(false);
|
|
848
875
|
const [uncontrolledValue, setUncontrolledValue] = (0, import_react3.useState)(
|
|
849
|
-
showDates ? presetLabel(initShortcut) : defaultValue || "Last 7 days"
|
|
876
|
+
startsEmpty ? emptyLabel : showDates ? presetLabel(initShortcut) : defaultValue || "Last 7 days"
|
|
877
|
+
);
|
|
878
|
+
const [uncontrolledDatesLine, setUncontrolledDatesLine] = (0, import_react3.useState)(
|
|
879
|
+
startsEmpty ? null : dateLine(initRange[0], initRange[1])
|
|
850
880
|
);
|
|
851
|
-
const
|
|
852
|
-
const
|
|
881
|
+
const committed = (0, import_react3.useRef)({ shortcut: initShortcut, start: initRange[0], end: initRange[1], set: !startsEmpty });
|
|
882
|
+
const [cmp, setCmp] = (0, import_react3.useState)(compare?.value);
|
|
883
|
+
const committedCmp = (0, import_react3.useRef)(compare?.value);
|
|
884
|
+
const [appliedCmp, setAppliedCmp] = (0, import_react3.useState)(compare?.value);
|
|
885
|
+
(0, import_react3.useEffect)(() => {
|
|
886
|
+
committedCmp.current = compare?.value;
|
|
887
|
+
setAppliedCmp(compare?.value);
|
|
888
|
+
}, [compare?.value]);
|
|
889
|
+
const compareName = `${(0, import_react3.useId)()}-compare`;
|
|
853
890
|
const displayValue = controlled ? showDates ? presetLabel(initShortcut) : controlledValue : uncontrolledValue;
|
|
854
891
|
const displayDatesLine = controlled ? dateLine(initRange[0], initRange[1]) : uncontrolledDatesLine;
|
|
855
892
|
const [shortcut, setShortcut] = (0, import_react3.useState)(initShortcut);
|
|
@@ -858,7 +895,7 @@ function DateRangeFilter({
|
|
|
858
895
|
const [leftMonth, setLeftMonth] = (0, import_react3.useState)(new Date(initRange[0].getFullYear(), initRange[0].getMonth(), 1));
|
|
859
896
|
const ref = (0, import_react3.useRef)(null);
|
|
860
897
|
(0, import_react3.useEffect)(() => {
|
|
861
|
-
if (controlled) return;
|
|
898
|
+
if (controlled || startsEmpty) return;
|
|
862
899
|
onRangeChange?.(committed.current.start, committed.current.end);
|
|
863
900
|
}, []);
|
|
864
901
|
(0, import_react3.useEffect)(() => {
|
|
@@ -866,10 +903,12 @@ function DateRangeFilter({
|
|
|
866
903
|
const committedShortcut = controlled ? initShortcut : committed.current.shortcut;
|
|
867
904
|
const committedStart = controlled ? initRange[0] : committed.current.start;
|
|
868
905
|
const committedEnd = controlled ? initRange[1] : committed.current.end;
|
|
906
|
+
const hasRange = controlled || committed.current.set;
|
|
869
907
|
setShortcut(committedShortcut);
|
|
870
|
-
setStart(committedStart);
|
|
871
|
-
setEnd(committedEnd);
|
|
872
|
-
setLeftMonth(new Date(committedStart.getFullYear(), committedStart.getMonth(), 1));
|
|
908
|
+
setStart(hasRange ? committedStart : null);
|
|
909
|
+
setEnd(hasRange ? committedEnd : null);
|
|
910
|
+
setLeftMonth(hasRange ? new Date(committedStart.getFullYear(), committedStart.getMonth(), 1) : addMonths(today, -1));
|
|
911
|
+
setCmp(committedCmp.current);
|
|
873
912
|
const onKey = (e) => e.key === "Escape" && setOpen(false);
|
|
874
913
|
const onClick = (e) => {
|
|
875
914
|
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
@@ -903,17 +942,22 @@ function DateRangeFilter({
|
|
|
903
942
|
setEnd(e);
|
|
904
943
|
} else setEnd(monthly ? lastOfMonth(d) : d);
|
|
905
944
|
};
|
|
945
|
+
const canApply = !!start || controlled || committed.current.set;
|
|
906
946
|
const apply = () => {
|
|
947
|
+
if (!canApply) return;
|
|
907
948
|
const [s, e] = snap(start || initRange[0], end || start || initRange[0]);
|
|
908
949
|
const custom = monthly ? `${fmtMonth(s)} \u2014 ${fmtMonth(e)}` : `${fmt(s)} \u2014 ${fmt(e)}`;
|
|
909
950
|
const v = showDates ? presetLabel(shortcut) : shortcut === "Custom" ? custom : shortcut;
|
|
910
951
|
if (!controlled) {
|
|
911
|
-
committed.current = { shortcut, start: s, end: e };
|
|
952
|
+
committed.current = { shortcut, start: s, end: e, set: true };
|
|
912
953
|
setUncontrolledValue(v);
|
|
913
954
|
setUncontrolledDatesLine(dateLine(s, e));
|
|
914
955
|
}
|
|
956
|
+
committedCmp.current = cmp;
|
|
957
|
+
setAppliedCmp(cmp);
|
|
915
958
|
onChange?.(v);
|
|
916
959
|
onRangeChange?.(s, e);
|
|
960
|
+
onApply?.(shortcut === "Custom" ? `${fmt(s)} \u2013 ${fmt(e)}` : shortcut, s, e, cmp);
|
|
917
961
|
setOpen(false);
|
|
918
962
|
};
|
|
919
963
|
const popRef = (0, import_react3.useRef)(null);
|
|
@@ -935,8 +979,14 @@ function DateRangeFilter({
|
|
|
935
979
|
children: [
|
|
936
980
|
icon && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "shrink-0 text-text-tertiary", children: icon }),
|
|
937
981
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
|
|
938
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: showDates ? "text-[11px] text-text-tertiary" : "text-control-caption uppercase tracking-wide text-text-tertiary", children: showDates ? displayDatesLine : caption }),
|
|
939
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.
|
|
982
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: showDates && displayDatesLine ? "text-[11px] text-text-tertiary" : "text-control-caption uppercase tracking-wide text-text-tertiary", children: showDates && displayDatesLine ? displayDatesLine : caption }),
|
|
983
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "text-[12px] font-medium text-text-primary", children: [
|
|
984
|
+
displayValue,
|
|
985
|
+
compareLabel(appliedCmp) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("span", { className: "font-normal text-text-secondary", children: [
|
|
986
|
+
" \xB7 vs ",
|
|
987
|
+
compareLabel(appliedCmp).toLowerCase()
|
|
988
|
+
] })
|
|
989
|
+
] })
|
|
940
990
|
] }),
|
|
941
991
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_lucide_react6.ChevronDown, { size: 14, "aria-hidden": "true", className: `shrink-0 text-text-secondary transition-transform ${open ? "rotate-180" : ""}` })
|
|
942
992
|
]
|
|
@@ -1012,10 +1062,39 @@ function DateRangeFilter({
|
|
|
1012
1062
|
] })
|
|
1013
1063
|
] }, offset);
|
|
1014
1064
|
}) }),
|
|
1065
|
+
compare && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("fieldset", { className: "mt-4 border-t border-border-default pt-4", children: [
|
|
1066
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("legend", { className: "float-left mb-2 w-full text-xs font-medium text-text-secondary", children: "Compare to" }),
|
|
1067
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "clear-left flex flex-col gap-1", children: compare.options.map((o) => {
|
|
1068
|
+
const on = (cmp ?? compare.value) === o.id;
|
|
1069
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
1070
|
+
"label",
|
|
1071
|
+
{
|
|
1072
|
+
className: `flex cursor-pointer items-center gap-2.5 rounded-control px-2 py-1.5 text-dense transition-colors ${on ? "bg-subtle" : "hover:bg-subtle"}`,
|
|
1073
|
+
children: [
|
|
1074
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1075
|
+
"input",
|
|
1076
|
+
{
|
|
1077
|
+
type: "radio",
|
|
1078
|
+
name: compareName,
|
|
1079
|
+
value: o.id,
|
|
1080
|
+
checked: on,
|
|
1081
|
+
onChange: () => setCmp(o.id),
|
|
1082
|
+
"data-testid": testIdPrefix && `${testIdPrefix}-compare-${slug2(o.id)}`,
|
|
1083
|
+
className: "h-4 w-4 accent-brand-primaryAction"
|
|
1084
|
+
}
|
|
1085
|
+
),
|
|
1086
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: `w-44 shrink-0 ${on ? "font-semibold text-text-primary" : "text-text-secondary"}`, children: o.label }),
|
|
1087
|
+
start && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "tabular-nums text-text-tertiary", children: spanLabel(...compareSpan(start, end ?? start, o.id)) })
|
|
1088
|
+
]
|
|
1089
|
+
},
|
|
1090
|
+
o.id
|
|
1091
|
+
);
|
|
1092
|
+
}) })
|
|
1093
|
+
] }),
|
|
1015
1094
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "mt-4 flex items-center justify-end gap-2", children: [
|
|
1016
1095
|
monthly && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "mr-auto text-xs text-text-tertiary", children: "Data is monthly, so ranges cover whole months." }),
|
|
1017
1096
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-cancel`, onClick: () => setOpen(false), className: "rounded-control border border-border-default bg-surface px-5 py-2 text-[13px] font-semibold text-text-primary transition-colors hover:bg-subtle", children: "Cancel" }),
|
|
1018
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-apply`, onClick: apply, className: "rounded-control bg-brand-primaryAction px-5 py-2 text-[13px] font-semibold text-brand-onprimary transition-[filter] hover:brightness-110", children: "Apply" })
|
|
1097
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("button", { type: "button", "data-testid": testIdPrefix && `${testIdPrefix}-apply`, onClick: apply, disabled: !canApply, className: "rounded-control bg-brand-primaryAction px-5 py-2 text-[13px] font-semibold text-brand-onprimary transition-[filter] hover:brightness-110 disabled:cursor-not-allowed disabled:opacity-50", children: "Apply" })
|
|
1019
1098
|
] })
|
|
1020
1099
|
] })
|
|
1021
1100
|
]
|
|
@@ -1374,7 +1453,7 @@ function SectionRail({
|
|
|
1374
1453
|
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1375
1454
|
"h2",
|
|
1376
1455
|
{
|
|
1377
|
-
className: titleSerif ? "font-serif text-
|
|
1456
|
+
className: titleSerif ? "font-serif text-xl font-normal tracking-tight text-text-primary" : "text-xl font-medium tracking-tight text-text-primary",
|
|
1378
1457
|
children: title
|
|
1379
1458
|
}
|
|
1380
1459
|
),
|
|
@@ -1418,7 +1497,7 @@ function SectionRail({
|
|
|
1418
1497
|
"div",
|
|
1419
1498
|
{
|
|
1420
1499
|
ref: scrollRef,
|
|
1421
|
-
className: "flex gap-4 overflow-x-auto scroll-smooth pb-2 snap-x snap-mandatory scrollbar-none [&::-webkit-scrollbar]:hidden -mx-4 px-4 sm:mx-0 sm:px-0 *:w-
|
|
1500
|
+
className: "flex gap-4 overflow-x-auto scroll-smooth pb-2 snap-x snap-mandatory scrollbar-none [&::-webkit-scrollbar]:hidden -mx-4 px-4 sm:mx-0 sm:px-0 *:w-67 *:shrink-0 *:snap-start lg:grid lg:grid-cols-[repeat(4,minmax(0,320px))] lg:gap-5 lg:overflow-visible lg:justify-start lg:*:w-auto lg:*:shrink lg:*:snap-none",
|
|
1422
1501
|
children
|
|
1423
1502
|
}
|
|
1424
1503
|
)
|
|
@@ -1836,12 +1915,12 @@ function SummaryGroupItem({
|
|
|
1836
1915
|
className: cx5("shrink-0 text-text-secondary transition-transform", !open && "-rotate-90")
|
|
1837
1916
|
}
|
|
1838
1917
|
),
|
|
1839
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: cx5("truncate font-semibold text-text-primary", nested ? "text-
|
|
1840
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "shrink-0 rounded-full bg-subtle px-1.5 py-0.5 text-
|
|
1918
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: cx5("truncate font-semibold text-text-primary", nested ? "text-xs" : "text-dense"), children: group.label }),
|
|
1919
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "shrink-0 rounded-full bg-subtle px-1.5 py-0.5 text-micro font-semibold text-text-secondary", children: ownCount })
|
|
1841
1920
|
]
|
|
1842
1921
|
}
|
|
1843
1922
|
),
|
|
1844
|
-
open && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "pt-2.5", children: ownCount === 0 && subCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-
|
|
1923
|
+
open && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "pt-2.5", children: ownCount === 0 && subCount === 0 ? /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-xs text-text-secondary", children: "Nothing selected." }) : /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-2.5", children: [
|
|
1845
1924
|
ownCount > 0 && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col gap-1.5", children: [
|
|
1846
1925
|
group.items.map((item) => /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
1847
1926
|
"div",
|
|
@@ -1849,8 +1928,8 @@ function SummaryGroupItem({
|
|
|
1849
1928
|
className: "flex items-center justify-between gap-2 rounded-control border border-border-default bg-canvas px-2 py-1",
|
|
1850
1929
|
children: [
|
|
1851
1930
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("span", { className: "min-w-0 flex-1", children: [
|
|
1852
|
-
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "block truncate text-
|
|
1853
|
-
item.meta && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "block truncate text-
|
|
1931
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "block truncate text-xs text-text-primary", children: item.name }),
|
|
1932
|
+
item.meta && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("span", { className: "block truncate text-micro text-text-secondary", children: item.meta })
|
|
1854
1933
|
] }),
|
|
1855
1934
|
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1856
1935
|
"button",
|
|
@@ -1872,7 +1951,7 @@ function SummaryGroupItem({
|
|
|
1872
1951
|
type: "button",
|
|
1873
1952
|
onClick: group.onRemoveAll,
|
|
1874
1953
|
"data-testid": testIdPrefix && `${testIdPrefix}-remove-all-${group.id}`,
|
|
1875
|
-
className: "mt-0.5 self-start text-
|
|
1954
|
+
className: "mt-0.5 self-start text-micro font-medium text-text-link hover:underline",
|
|
1876
1955
|
children: "Remove all"
|
|
1877
1956
|
}
|
|
1878
1957
|
)
|
|
@@ -1953,7 +2032,7 @@ function BlankLegend({ rows, reverse = false }) {
|
|
|
1953
2032
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1954
2033
|
var BAR_PROFILE = [92, 86, 76, 65, 57, 40, 30, 24, 18, 13];
|
|
1955
2034
|
function BarChartPlaceholder({ height = 220 }) {
|
|
1956
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AxisFrame, { height, xTicks: BAR_PROFILE.length, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex h-full w-full items-end gap-2", children: BAR_PROFILE.map((pct, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1 rounded-t-
|
|
2035
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AxisFrame, { height, xTicks: BAR_PROFILE.length, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex h-full w-full items-end gap-2", children: BAR_PROFILE.map((pct, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1 rounded-t-small bg-subtle", style: { height: `${pct}%` } }, i)) }) });
|
|
1957
2036
|
}
|
|
1958
2037
|
|
|
1959
2038
|
// src/LineChartPlaceholder.tsx
|
|
@@ -3415,11 +3494,12 @@ function workspaceInitials(name) {
|
|
|
3415
3494
|
}
|
|
3416
3495
|
var SIZES = {
|
|
3417
3496
|
/** Matches a 15px lucide icon exactly, so a workspace name in a menu row
|
|
3418
|
-
* left-aligns with labels in icon-led rows above and below it.
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3497
|
+
* left-aligns with labels in icon-led rows above and below it. Shows one
|
|
3498
|
+
* initial: two at the smallest type step (10px) don't fit in 15px. */
|
|
3499
|
+
xs: "size-3.75 rounded-small text-badge",
|
|
3500
|
+
/** text-badge (10px), not text-control-caption: that step is for dropdown
|
|
3501
|
+
* captions. Two initials need to sit inside the 24px tile, a step below md. */
|
|
3502
|
+
sm: "h-6 w-6 text-badge",
|
|
3423
3503
|
md: "h-7 w-7 text-micro",
|
|
3424
3504
|
lg: "h-11 w-11 text-panel-title"
|
|
3425
3505
|
};
|
|
@@ -3432,7 +3512,7 @@ function WorkspaceAvatar({ name, size = "md" }) {
|
|
|
3432
3512
|
"flex shrink-0 items-center justify-center rounded-control bg-subtle font-semibold leading-none text-text-secondary",
|
|
3433
3513
|
SIZES[size]
|
|
3434
3514
|
),
|
|
3435
|
-
children: workspaceInitials(name ?? "All data")
|
|
3515
|
+
children: size === "xs" ? workspaceInitials(name ?? "All data").slice(0, 1) : workspaceInitials(name ?? "All data")
|
|
3436
3516
|
}
|
|
3437
3517
|
);
|
|
3438
3518
|
}
|
|
@@ -3535,10 +3615,10 @@ function TablePagination({
|
|
|
3535
3615
|
const current = Math.min(page, totalPages);
|
|
3536
3616
|
const rangeStart = totalItems === 0 ? 0 : (current - 1) * perPage + 1;
|
|
3537
3617
|
const rangeEnd = Math.min(current * perPage, totalItems);
|
|
3538
|
-
const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-
|
|
3618
|
+
const btn = "flex h-8 min-w-8 items-center justify-center rounded-control px-2 text-dense transition-colors";
|
|
3539
3619
|
const off = "disabled:pointer-events-none disabled:opacity-30";
|
|
3540
3620
|
const stepBtn = cn(btn, "text-text-secondary hover:bg-subtle hover:text-text-primary", off);
|
|
3541
|
-
const range = /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("span", { className: "text-
|
|
3621
|
+
const range = /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("span", { className: "text-dense text-text-tertiary tabular-nums", children: [
|
|
3542
3622
|
rangeStart.toLocaleString(),
|
|
3543
3623
|
" \u2013 ",
|
|
3544
3624
|
rangeEnd.toLocaleString(),
|
|
@@ -3551,7 +3631,7 @@ function TablePagination({
|
|
|
3551
3631
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
|
|
3552
3632
|
"div",
|
|
3553
3633
|
{
|
|
3554
|
-
className: cn("flex items-center gap-2 text-
|
|
3634
|
+
className: cn("flex items-center gap-2 text-dense text-text-secondary", !onPerPageChange && "invisible"),
|
|
3555
3635
|
children: [
|
|
3556
3636
|
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3557
3637
|
SelectFilter,
|
|
@@ -3595,7 +3675,7 @@ function TablePagination({
|
|
|
3595
3675
|
}
|
|
3596
3676
|
),
|
|
3597
3677
|
pageWindow(current, totalPages).map(
|
|
3598
|
-
(p) => typeof p === "string" ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "px-1 text-
|
|
3678
|
+
(p) => typeof p === "string" ? /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "px-1 text-dense text-text-tertiary", children: "\u2026" }, p) : /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3599
3679
|
"button",
|
|
3600
3680
|
{
|
|
3601
3681
|
type: "button",
|
|
@@ -3676,7 +3756,7 @@ function resolveRange(label, today = startOfToday()) {
|
|
|
3676
3756
|
}
|
|
3677
3757
|
return [new Date(end.getFullYear(), end.getMonth() - 6, 1), end];
|
|
3678
3758
|
}
|
|
3679
|
-
function
|
|
3759
|
+
function spanLabel2(label, today) {
|
|
3680
3760
|
const [s, e] = resolveRange(label, today);
|
|
3681
3761
|
return `${fmtDate(s)} \u2013 ${fmtDate(e)}`;
|
|
3682
3762
|
}
|
|
@@ -3762,7 +3842,7 @@ function DateRangePicker({
|
|
|
3762
3842
|
className: chipTriggerClass(),
|
|
3763
3843
|
children: [
|
|
3764
3844
|
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("span", { className: "flex flex-col gap-1 text-left leading-none", children: [
|
|
3765
|
-
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-control-caption text-text-tertiary", children:
|
|
3845
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-control-caption text-text-tertiary", children: spanLabel2(value, end) }),
|
|
3766
3846
|
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("span", { className: "text-[12px] font-medium text-text-primary", children: value })
|
|
3767
3847
|
] }),
|
|
3768
3848
|
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_lucide_react22.ChevronDown, { size: 14, "aria-hidden": "true", className: cn("shrink-0 text-text-secondary transition-transform", open && "rotate-180") })
|
|
@@ -3970,7 +4050,7 @@ function MultiSelectFilter({
|
|
|
3970
4050
|
onClick: () => toggleGroup(g),
|
|
3971
4051
|
className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
|
|
3972
4052
|
children: [
|
|
3973
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4053
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CheckBoxBox, { checked: state === "all", indeterminate: state === "some" }),
|
|
3974
4054
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: cn("flex-1 text-[14px] text-text-primary", !plainParent && "font-semibold"), children: g.label }),
|
|
3975
4055
|
counts && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OptionCount, { n: countFor(g.id) })
|
|
3976
4056
|
]
|
|
@@ -3985,7 +4065,7 @@ function MultiSelectFilter({
|
|
|
3985
4065
|
onClick: () => toggle(c.id),
|
|
3986
4066
|
className: "flex w-full items-center gap-2.5 rounded-control py-2 pl-9 pr-2 text-left transition-colors hover:bg-subtle",
|
|
3987
4067
|
children: [
|
|
3988
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4068
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CheckBoxBox, { checked }),
|
|
3989
4069
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "flex-1 text-[14px] text-text-primary", children: c.label }),
|
|
3990
4070
|
counts && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OptionCount, { n: countFor(c.id) })
|
|
3991
4071
|
]
|
|
@@ -4003,16 +4083,7 @@ function MultiSelectFilter({
|
|
|
4003
4083
|
onClick: () => toggle(o.id),
|
|
4004
4084
|
className: "flex w-full items-center gap-2.5 rounded-control px-2 py-2 text-left transition-colors hover:bg-subtle",
|
|
4005
4085
|
children: [
|
|
4006
|
-
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
4007
|
-
"span",
|
|
4008
|
-
{
|
|
4009
|
-
className: cn(
|
|
4010
|
-
"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-[5px] border transition-colors",
|
|
4011
|
-
checked ? "border-transparent bg-brand-primaryAction text-brand-onprimary" : "border-border-interactive bg-input"
|
|
4012
|
-
),
|
|
4013
|
-
children: checked && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react23.Check, { size: 13, strokeWidth: 3 })
|
|
4014
|
-
}
|
|
4015
|
-
),
|
|
4086
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)(CheckBoxBox, { checked }),
|
|
4016
4087
|
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { className: "flex-1 text-[14px] text-text-primary", children: o.label }),
|
|
4017
4088
|
counts && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(OptionCount, { n: countFor(o.id) })
|
|
4018
4089
|
]
|
|
@@ -4039,22 +4110,6 @@ function MultiSelectFilter({
|
|
|
4039
4110
|
)
|
|
4040
4111
|
] });
|
|
4041
4112
|
}
|
|
4042
|
-
function TriCheck({ state }) {
|
|
4043
|
-
const filled = state !== "none";
|
|
4044
|
-
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)(
|
|
4045
|
-
"span",
|
|
4046
|
-
{
|
|
4047
|
-
className: cn(
|
|
4048
|
-
"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-[5px] border transition-colors",
|
|
4049
|
-
filled ? "border-transparent bg-brand-primaryAction text-brand-onprimary" : "border-border-interactive bg-input"
|
|
4050
|
-
),
|
|
4051
|
-
children: [
|
|
4052
|
-
state === "all" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react23.Check, { size: 13, strokeWidth: 3 }),
|
|
4053
|
-
state === "some" && /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_lucide_react23.Minus, { size: 13, strokeWidth: 3 })
|
|
4054
|
-
]
|
|
4055
|
-
}
|
|
4056
|
-
);
|
|
4057
|
-
}
|
|
4058
4113
|
function OptionCount({ n }) {
|
|
4059
4114
|
return /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("span", { className: "shrink-0 text-[12px] tabular-nums text-text-tertiary", children: [
|
|
4060
4115
|
"(",
|