@ai-matrx/records-ui 0.116.10 → 0.116.12
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/CHANGELOG.md +26 -1
- package/dist/index.cjs +90 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +93 -33
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -5353,6 +5353,21 @@ interface ChartBlockProps {
|
|
|
5353
5353
|
className?: string | undefined;
|
|
5354
5354
|
/** A donut draws its total in the middle (the first measure added up over its groups). */
|
|
5355
5355
|
centerValue?: boolean | undefined;
|
|
5356
|
+
/**
|
|
5357
|
+
* The number a `centerValue` donut draws in its middle when the host knows the whole answer: the
|
|
5358
|
+
* total over EVERY record (a cut of 200 groups still counts all of them), or an average / min / max
|
|
5359
|
+
* over every record, which adding the groups up would get wrong. `null` = the store had no total
|
|
5360
|
+
* ("–"). Absent: the drawn groups added up.
|
|
5361
|
+
*/
|
|
5362
|
+
centerTotal?: number | null | undefined;
|
|
5363
|
+
/** `false` draws no legend beside a donut and no value list under bars or a line. Default `true`. */
|
|
5364
|
+
legend?: boolean | undefined;
|
|
5365
|
+
/**
|
|
5366
|
+
* The colour each group is drawn in, keyed by its stored value as text ("" for no value) — a
|
|
5367
|
+
* choice column's own option colours. A group not named here takes the palette's next colour.
|
|
5368
|
+
* Single-group blocks only; a compared block keeps its two series tones.
|
|
5369
|
+
*/
|
|
5370
|
+
groupColors?: Readonly<Record<string, string>> | undefined;
|
|
5356
5371
|
/**
|
|
5357
5372
|
* `bare` — the drawing alone, for a block a page already titles: no figure border, no padding,
|
|
5358
5373
|
* no caption row. Default `card`.
|
|
@@ -5368,7 +5383,7 @@ interface ChartBlockProps {
|
|
|
5368
5383
|
token: string;
|
|
5369
5384
|
} | undefined;
|
|
5370
5385
|
}
|
|
5371
|
-
declare function ChartBlock({ block, subject, tableName, className, centerValue, variant, source }: ChartBlockProps): react.JSX.Element;
|
|
5386
|
+
declare function ChartBlock({ block, subject, tableName, className, centerValue, centerTotal, legend, groupColors, variant, source }: ChartBlockProps): react.JSX.Element;
|
|
5372
5387
|
|
|
5373
5388
|
type ChartLayoutKind = "bar" | "line" | "donut";
|
|
5374
5389
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -5353,6 +5353,21 @@ interface ChartBlockProps {
|
|
|
5353
5353
|
className?: string | undefined;
|
|
5354
5354
|
/** A donut draws its total in the middle (the first measure added up over its groups). */
|
|
5355
5355
|
centerValue?: boolean | undefined;
|
|
5356
|
+
/**
|
|
5357
|
+
* The number a `centerValue` donut draws in its middle when the host knows the whole answer: the
|
|
5358
|
+
* total over EVERY record (a cut of 200 groups still counts all of them), or an average / min / max
|
|
5359
|
+
* over every record, which adding the groups up would get wrong. `null` = the store had no total
|
|
5360
|
+
* ("–"). Absent: the drawn groups added up.
|
|
5361
|
+
*/
|
|
5362
|
+
centerTotal?: number | null | undefined;
|
|
5363
|
+
/** `false` draws no legend beside a donut and no value list under bars or a line. Default `true`. */
|
|
5364
|
+
legend?: boolean | undefined;
|
|
5365
|
+
/**
|
|
5366
|
+
* The colour each group is drawn in, keyed by its stored value as text ("" for no value) — a
|
|
5367
|
+
* choice column's own option colours. A group not named here takes the palette's next colour.
|
|
5368
|
+
* Single-group blocks only; a compared block keeps its two series tones.
|
|
5369
|
+
*/
|
|
5370
|
+
groupColors?: Readonly<Record<string, string>> | undefined;
|
|
5356
5371
|
/**
|
|
5357
5372
|
* `bare` — the drawing alone, for a block a page already titles: no figure border, no padding,
|
|
5358
5373
|
* no caption row. Default `card`.
|
|
@@ -5368,7 +5383,7 @@ interface ChartBlockProps {
|
|
|
5368
5383
|
token: string;
|
|
5369
5384
|
} | undefined;
|
|
5370
5385
|
}
|
|
5371
|
-
declare function ChartBlock({ block, subject, tableName, className, centerValue, variant, source }: ChartBlockProps): react.JSX.Element;
|
|
5386
|
+
declare function ChartBlock({ block, subject, tableName, className, centerValue, centerTotal, legend, groupColors, variant, source }: ChartBlockProps): react.JSX.Element;
|
|
5372
5387
|
|
|
5373
5388
|
type ChartLayoutKind = "bar" | "line" | "donut";
|
|
5374
5389
|
/**
|
package/dist/index.js
CHANGED
|
@@ -20217,7 +20217,7 @@ function structuredWordsFor(field, value) {
|
|
|
20217
20217
|
}
|
|
20218
20218
|
|
|
20219
20219
|
// src/CalendarView.tsx
|
|
20220
|
-
import { useEffect as useEffect58, useMemo as useMemo43, useRef as useRef31, useState as useState66 } from "react";
|
|
20220
|
+
import { useEffect as useEffect58, useLayoutEffect as useLayoutEffect3, useMemo as useMemo43, useRef as useRef31, useState as useState66 } from "react";
|
|
20221
20221
|
import { mayDrag as mayDrag2 } from "@ai-matrx/records/react";
|
|
20222
20222
|
import { Button as Button55, Select as Select5, SelectContent as SelectContent3, SelectItem as SelectItem3, SelectTrigger as SelectTrigger3, SelectValue as SelectValue3, cn as cn30 } from "@ai-matrx/design-system";
|
|
20223
20223
|
import { CHOICE_CHIP_CLASS } from "@ai-matrx/design-system/data-table";
|
|
@@ -20490,6 +20490,25 @@ function useNarrow() {
|
|
|
20490
20490
|
}, []);
|
|
20491
20491
|
return narrow;
|
|
20492
20492
|
}
|
|
20493
|
+
var READABLE_CELL_PX = 72;
|
|
20494
|
+
function useGridWidth(grid, mode) {
|
|
20495
|
+
const [width, setWidth] = useState66(null);
|
|
20496
|
+
const useIsoLayoutEffect2 = typeof window === "undefined" ? useEffect58 : useLayoutEffect3;
|
|
20497
|
+
useIsoLayoutEffect2(() => {
|
|
20498
|
+
const el = grid.current;
|
|
20499
|
+
if (!el) {
|
|
20500
|
+
setWidth(null);
|
|
20501
|
+
return;
|
|
20502
|
+
}
|
|
20503
|
+
const read = () => setWidth(el.clientWidth);
|
|
20504
|
+
read();
|
|
20505
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
20506
|
+
const watcher = new ResizeObserver(read);
|
|
20507
|
+
watcher.observe(el);
|
|
20508
|
+
return () => watcher.disconnect();
|
|
20509
|
+
}, [grid, mode]);
|
|
20510
|
+
return width;
|
|
20511
|
+
}
|
|
20493
20512
|
function byTime(a, b) {
|
|
20494
20513
|
const allDayOn = (p) => !p.at || p.lastDay > p.firstDay;
|
|
20495
20514
|
return Number(!allDayOn(a)) - Number(!allDayOn(b)) || (a.at && b.at && !allDayOn(a) && !allDayOn(b) ? a.at.getTime() - b.at.getTime() : 0) || a.firstDay.localeCompare(b.firstDay);
|
|
@@ -20582,6 +20601,11 @@ function CalendarView({
|
|
|
20582
20601
|
const titleOf = (row) => cardWords(row, titleField, labels).text;
|
|
20583
20602
|
const rowById = (id) => rows.find((r) => r.id === id);
|
|
20584
20603
|
const frame = useRef31(null);
|
|
20604
|
+
const grid = useRef31(null);
|
|
20605
|
+
const gridWidth = useGridWidth(grid, mode);
|
|
20606
|
+
const cellColumns = mode === "month" ? 7 : mode === "week" ? 7 : 1;
|
|
20607
|
+
const cellReserve = mode === "month" ? 0 : 44;
|
|
20608
|
+
const tightCells = (mode === "month" || mode === "week") && gridWidth !== null && gridWidth > 0 && (gridWidth - cellReserve) / cellColumns < READABLE_CELL_PX;
|
|
20585
20609
|
const [focusOn, setFocusOn] = useState66(null);
|
|
20586
20610
|
useEffect58(() => {
|
|
20587
20611
|
if (!focusOn) return;
|
|
@@ -20802,7 +20826,7 @@ function CalendarView({
|
|
|
20802
20826
|
window.addEventListener("pointermove", onMove);
|
|
20803
20827
|
window.addEventListener("pointerup", onUp);
|
|
20804
20828
|
};
|
|
20805
|
-
const cardFace = (row, extra, className2) => {
|
|
20829
|
+
const cardFace = (row, extra, className2, compact = false) => {
|
|
20806
20830
|
const may = canMove(row);
|
|
20807
20831
|
const lockWords = mayDrag2(row.level) ? WORKED_OUT_DATE_LOCK : "View only";
|
|
20808
20832
|
const color = colorOf(row);
|
|
@@ -20816,17 +20840,19 @@ function CalendarView({
|
|
|
20816
20840
|
// The chip palette, not the faint row tint: a calendar is read by its colours at a glance.
|
|
20817
20841
|
color ? CHOICE_CHIP_CLASS[color] : "bg-background",
|
|
20818
20842
|
may ? "cursor-grab active:cursor-grabbing" : "cursor-default",
|
|
20843
|
+
compact ? "min-h-3 px-0" : "",
|
|
20819
20844
|
className2
|
|
20820
20845
|
),
|
|
20821
20846
|
onClick: () => onOpenRecord?.(row.id),
|
|
20847
|
+
...compact ? { "aria-label": title, "data-calendar-compact": "" } : {},
|
|
20822
20848
|
title: may ? `${title} \xB7 drag to another day, or Alt + arrow keys` : `${title} \xB7 ${lockWords}`,
|
|
20823
20849
|
...color ? { "data-calendar-color": color } : {},
|
|
20824
20850
|
...may ? { "aria-keyshortcuts": "Alt+ArrowLeft Alt+ArrowRight Alt+ArrowUp Alt+ArrowDown" } : { "data-calendar-locked": "" },
|
|
20825
20851
|
children: [
|
|
20826
|
-
may ? null : /* @__PURE__ */ jsx72("span", { title: lockWords, "aria-label": lockWords, className: "inline-flex", ...mayDrag2(row.level) ? { "data-calendar-worked-out": "" } : {}, children: /* @__PURE__ */ jsx72(LockIcon, {}) }),
|
|
20827
|
-
extra,
|
|
20828
|
-
/* @__PURE__ */ jsx72("span", { className: "min-w-0 max-w-full shrink-0 truncate", "data-calendar-card-title": "", children: title }),
|
|
20829
|
-
/* @__PURE__ */ jsx72(CardFieldsInline, { row, fields: cardFields })
|
|
20852
|
+
compact ? null : may ? null : /* @__PURE__ */ jsx72("span", { title: lockWords, "aria-label": lockWords, className: "inline-flex", ...mayDrag2(row.level) ? { "data-calendar-worked-out": "" } : {}, children: /* @__PURE__ */ jsx72(LockIcon, {}) }),
|
|
20853
|
+
compact ? null : extra,
|
|
20854
|
+
compact ? null : /* @__PURE__ */ jsx72("span", { className: "min-w-0 max-w-full shrink-0 truncate", "data-calendar-card-title": "", children: title }),
|
|
20855
|
+
compact ? null : /* @__PURE__ */ jsx72(CardFieldsInline, { row, fields: cardFields })
|
|
20830
20856
|
]
|
|
20831
20857
|
}
|
|
20832
20858
|
);
|
|
@@ -20836,8 +20862,8 @@ function CalendarView({
|
|
|
20836
20862
|
const words2 = timeOfDayWords(startOf(row));
|
|
20837
20863
|
return words2 ? /* @__PURE__ */ jsx72("span", { className: "hidden shrink-0 tabular-nums text-[10px] opacity-75 @[8rem]:inline", "data-calendar-time": "", children: words2 }) : null;
|
|
20838
20864
|
};
|
|
20839
|
-
const listCard = (p, key) => /* @__PURE__ */ jsxs66("li", { ...dragSource(p.row), children: [
|
|
20840
|
-
cardFace(p.row, timeOn(p.row)),
|
|
20865
|
+
const listCard = (p, key, compact = false) => /* @__PURE__ */ jsxs66("li", { ...dragSource(p.row), children: [
|
|
20866
|
+
cardFace(p.row, timeOn(p.row), void 0, compact),
|
|
20841
20867
|
refusalOn(p.row)
|
|
20842
20868
|
] }, key);
|
|
20843
20869
|
const today = dayKey(personWallNow());
|
|
@@ -20895,7 +20921,7 @@ function CalendarView({
|
|
|
20895
20921
|
if (mode === "month") {
|
|
20896
20922
|
const first = startOfWeek(dayKey(new Date(anchorDate.getFullYear(), anchorDate.getMonth(), 1)), firstDay);
|
|
20897
20923
|
const weeks = Array.from({ length: 6 }, (_, w) => addDays2(first, w * 7));
|
|
20898
|
-
body = /* @__PURE__ */ jsx72("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs66("div", { className: "w-full min-w-0 border-l border-t", role: "grid", "aria-label": heading, "data-calendar-month": "", children: [
|
|
20924
|
+
body = /* @__PURE__ */ jsx72("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs66("div", { ref: grid, className: "w-full min-w-0 border-l border-t", role: "grid", "aria-label": heading, "data-calendar-month": "", ...tightCells ? { "data-calendar-tight": "" } : {}, children: [
|
|
20899
20925
|
/* @__PURE__ */ jsx72("div", { className: "grid grid-cols-7", role: "row", children: Array.from({ length: 7 }, (_, i) => addDays2(first, i)).map((d) => /* @__PURE__ */ jsx72("div", { role: "columnheader", className: "border-b border-r px-1 py-0.5 text-center text-xs text-muted-foreground", children: dayDate(d).toLocaleDateString(void 0, { weekday: "short" }) }, `h${d}`)) }),
|
|
20900
20926
|
weeks.map((ws) => /* @__PURE__ */ jsx72(
|
|
20901
20927
|
MonthWeek,
|
|
@@ -20911,6 +20937,11 @@ function CalendarView({
|
|
|
20911
20937
|
barDrop,
|
|
20912
20938
|
canCreate: creates,
|
|
20913
20939
|
onCreate: (d) => void createAt(rescheduledValue(null, d, null, moments), null, calendarDayLabel(d)),
|
|
20940
|
+
tight: tightCells,
|
|
20941
|
+
dotClass: (row) => {
|
|
20942
|
+
const c = colorOf(row);
|
|
20943
|
+
return c ? CHOICE_CHIP_CLASS[c] : "bg-muted-foreground/40";
|
|
20944
|
+
},
|
|
20914
20945
|
card: (p, key) => listCard(p, key),
|
|
20915
20946
|
bar: (p, key) => /* @__PURE__ */ jsxs66("div", { ...dragSource(p.row), className: "relative h-full", children: [
|
|
20916
20947
|
cardFace(p.row, null, "h-full"),
|
|
@@ -20936,12 +20967,12 @@ function CalendarView({
|
|
|
20936
20967
|
})
|
|
20937
20968
|
);
|
|
20938
20969
|
const columns = `2.75rem repeat(${days.length}, minmax(0, 1fr))`;
|
|
20939
|
-
body = /* @__PURE__ */ jsx72("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs66("div", { className: "w-full min-w-0 border-l border-t", "data-calendar-week": "", "data-calendar-days": days.length, children: [
|
|
20970
|
+
body = /* @__PURE__ */ jsx72("div", { className: "min-w-0 flex-1 overflow-x-auto", children: /* @__PURE__ */ jsxs66("div", { ref: grid, className: "w-full min-w-0 border-l border-t", "data-calendar-week": "", "data-calendar-days": days.length, ...tightCells ? { "data-calendar-tight": "" } : {}, children: [
|
|
20940
20971
|
/* @__PURE__ */ jsxs66("div", { className: "grid", style: { gridTemplateColumns: columns }, children: [
|
|
20941
20972
|
/* @__PURE__ */ jsx72("div", { className: "border-b border-r" }),
|
|
20942
20973
|
days.map((d) => /* @__PURE__ */ jsx72("div", { className: cn30("border-b border-r px-1 py-0.5 text-center text-xs", d === today ? "font-semibold text-primary" : "text-muted-foreground"), children: dayDate(d).toLocaleDateString(void 0, { weekday: "short", day: "numeric" }) }, `h${d}`)),
|
|
20943
20974
|
/* @__PURE__ */ jsx72("div", { className: "border-b border-r px-1 py-0.5 text-[10px] text-muted-foreground", children: "All day" }),
|
|
20944
|
-
days.map((d) => /* @__PURE__ */ jsx72("div", { "data-calendar-day": d, className: cn30("min-h-8 border-b border-r p-0.5", ghost?.day === d && ghost.minute === null ? "bg-primary/10" : void 0), ...dayDrop(d), children: /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: allDay(d).map((p) => listCard(p, `${p.row.id}:${d}
|
|
20975
|
+
days.map((d) => /* @__PURE__ */ jsx72("div", { "data-calendar-day": d, className: cn30("min-h-8 border-b border-r p-0.5", ghost?.day === d && ghost.minute === null ? "bg-primary/10" : void 0), ...dayDrop(d), children: /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: allDay(d).map((p) => listCard(p, `${p.row.id}:${d}`, tightCells)) }) }, `a${d}`))
|
|
20945
20976
|
] }),
|
|
20946
20977
|
/* @__PURE__ */ jsx72(
|
|
20947
20978
|
WeekHours,
|
|
@@ -20987,7 +21018,8 @@ function CalendarView({
|
|
|
20987
21018
|
p.row,
|
|
20988
21019
|
tight ? null : /* @__PURE__ */ jsx72("span", { className: "hidden shrink-0 tabular-nums text-[10px] opacity-75 @[8rem]:inline", "data-calendar-time": "", children: timeLabel(start) }),
|
|
20989
21020
|
// Taller blocks sharing the width stack the time over the name.
|
|
20990
|
-
cn30("h-full items-start", !tight && end - start >= 45 && cols > 1 ? "flex-col gap-0" : void 0)
|
|
21021
|
+
cn30("h-full items-start", !tight && end - start >= 45 && cols > 1 ? "flex-col gap-0" : void 0),
|
|
21022
|
+
tightCells
|
|
20991
21023
|
),
|
|
20992
21024
|
endField && !endWorkedOut && canMove(p.row) ? /* @__PURE__ */ jsx72(
|
|
20993
21025
|
"div",
|
|
@@ -21056,7 +21088,9 @@ function MonthWeek({
|
|
|
21056
21088
|
onCreate,
|
|
21057
21089
|
card,
|
|
21058
21090
|
bar,
|
|
21059
|
-
refusalOn
|
|
21091
|
+
refusalOn,
|
|
21092
|
+
tight,
|
|
21093
|
+
dotClass
|
|
21060
21094
|
}) {
|
|
21061
21095
|
const weekEnd = addDays2(weekStart, 6);
|
|
21062
21096
|
const days = Array.from({ length: 7 }, (_, i) => addDays2(weekStart, i));
|
|
@@ -21068,7 +21102,7 @@ function MonthWeek({
|
|
|
21068
21102
|
laneEnds[lane] = s.to;
|
|
21069
21103
|
return { ...s, lane };
|
|
21070
21104
|
});
|
|
21071
|
-
const lanesShown = Math.min(laneEnds.length, MONTH_ROWS - 1);
|
|
21105
|
+
const lanesShown = tight ? 0 : Math.min(laneEnds.length, MONTH_ROWS - 1);
|
|
21072
21106
|
const singlesFit = MONTH_ROWS - lanesShown;
|
|
21073
21107
|
return /* @__PURE__ */ jsxs66("div", { className: "relative grid grid-cols-7", role: "row", "data-calendar-week-row": weekStart, children: [
|
|
21074
21108
|
days.map((d) => {
|
|
@@ -21080,7 +21114,8 @@ function MonthWeek({
|
|
|
21080
21114
|
const everything = placed.filter((p) => p.firstDay <= d && p.lastDay >= d).sort(byTime);
|
|
21081
21115
|
const create = (e) => {
|
|
21082
21116
|
if (e.target.closest("button, [data-calendar-card], [role=dialog]")) return;
|
|
21083
|
-
|
|
21117
|
+
if (tight && everything.length > 0) onOpenDay(d);
|
|
21118
|
+
else onCreate(d);
|
|
21084
21119
|
};
|
|
21085
21120
|
return /* @__PURE__ */ jsxs66(
|
|
21086
21121
|
"div",
|
|
@@ -21089,7 +21124,8 @@ function MonthWeek({
|
|
|
21089
21124
|
"aria-label": calendarDayLabel(d),
|
|
21090
21125
|
"data-calendar-day": d,
|
|
21091
21126
|
className: cn30(
|
|
21092
|
-
"group relative flex min-
|
|
21127
|
+
"group relative flex min-w-0 flex-col gap-0.5 border-b border-r p-0.5",
|
|
21128
|
+
tight ? "min-h-14" : "min-h-24",
|
|
21093
21129
|
inMonth ? "" : "bg-muted/40",
|
|
21094
21130
|
ghostDay === d ? "bg-primary/10 ring-2 ring-inset ring-primary" : "",
|
|
21095
21131
|
canCreate ? "cursor-cell" : ""
|
|
@@ -21123,8 +21159,18 @@ function MonthWeek({
|
|
|
21123
21159
|
)
|
|
21124
21160
|
] }),
|
|
21125
21161
|
/* @__PURE__ */ jsx72("div", { style: { height: lanesShown * BAR_PX }, "aria-hidden": "true" }),
|
|
21126
|
-
|
|
21127
|
-
|
|
21162
|
+
tight ? everything.length > 0 ? /* @__PURE__ */ jsx72(
|
|
21163
|
+
"button",
|
|
21164
|
+
{
|
|
21165
|
+
type: "button",
|
|
21166
|
+
className: "flex min-w-0 flex-wrap items-center justify-center gap-0.5 self-stretch px-0.5 py-0.5",
|
|
21167
|
+
"aria-label": `${everything.length} ${everything.length === 1 ? "record" : "records"} on ${calendarDayLabel(d)}`,
|
|
21168
|
+
"data-calendar-marks": d,
|
|
21169
|
+
onClick: () => onOpenDay(d),
|
|
21170
|
+
children: everything.length <= 3 ? everything.map((p) => /* @__PURE__ */ jsx72("span", { "aria-hidden": "true", "data-calendar-dot": "", className: cn30("h-1.5 w-1.5 rounded-full border", dotClass(p.row)) }, p.row.id)) : /* @__PURE__ */ jsx72("span", { className: "rounded-full bg-muted px-1 text-[10px] tabular-nums leading-4", "data-calendar-count": "", children: everything.length })
|
|
21171
|
+
}
|
|
21172
|
+
) : null : /* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: shown4.map((p) => card(p, `${p.row.id}:${d}`)) }),
|
|
21173
|
+
more > 0 && !tight ? /* @__PURE__ */ jsxs66("button", { type: "button", className: "self-start px-1 text-xs text-muted-foreground hover:text-foreground", "data-calendar-more": d, onClick: () => onOpenDay(d), children: [
|
|
21128
21174
|
"+",
|
|
21129
21175
|
more,
|
|
21130
21176
|
" more"
|
|
@@ -21135,7 +21181,11 @@ function MonthWeek({
|
|
|
21135
21181
|
role: "dialog",
|
|
21136
21182
|
"aria-label": calendarDayLabel(d),
|
|
21137
21183
|
"data-calendar-day-open": d,
|
|
21138
|
-
className:
|
|
21184
|
+
className: cn30(
|
|
21185
|
+
"z-20 flex flex-col gap-1 rounded-md border bg-popover p-2 shadow-lg",
|
|
21186
|
+
// A narrow cell cannot hold a panel: the day's list opens as a sheet over the page's foot.
|
|
21187
|
+
tight ? "fixed inset-x-3 bottom-3 z-50 max-h-[60vh] overflow-y-auto" : "absolute left-0 top-0 w-56"
|
|
21188
|
+
),
|
|
21139
21189
|
onKeyDown: (e) => {
|
|
21140
21190
|
if (e.key === "Escape") onOpenDay(null);
|
|
21141
21191
|
},
|
|
@@ -21144,7 +21194,8 @@ function MonthWeek({
|
|
|
21144
21194
|
/* @__PURE__ */ jsx72("span", { className: "text-xs font-medium", children: calendarDayLabel(d) }),
|
|
21145
21195
|
/* @__PURE__ */ jsx72(Button55, { size: "sm", variant: "ghost", className: "ml-auto h-6", "aria-label": "Close", onClick: () => onOpenDay(null), children: "\xD7" })
|
|
21146
21196
|
] }),
|
|
21147
|
-
/* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: everything.map((p) => card(p, `open:${p.row.id}:${d}`)) })
|
|
21197
|
+
/* @__PURE__ */ jsx72("ul", { className: "flex flex-col gap-0.5", children: everything.map((p) => card(p, `open:${p.row.id}:${d}`)) }),
|
|
21198
|
+
tight && canCreate ? /* @__PURE__ */ jsx72(Button55, { size: "sm", variant: "outline", className: "h-7 self-start", "data-calendar-add-in-sheet": d, onClick: () => onCreate(d), children: "Add a record" }) : null
|
|
21148
21199
|
]
|
|
21149
21200
|
}
|
|
21150
21201
|
) : null
|
|
@@ -23420,8 +23471,15 @@ function asRefusal2(block) {
|
|
|
23420
23471
|
"dashboard_run"
|
|
23421
23472
|
);
|
|
23422
23473
|
}
|
|
23474
|
+
function colorOfGroup(groups, colors) {
|
|
23475
|
+
if (!colors) return null;
|
|
23476
|
+
const values = Object.values(groups);
|
|
23477
|
+
if (values.length > 1) return null;
|
|
23478
|
+
const raw = values[0];
|
|
23479
|
+
return colors[raw === null || raw === void 0 ? "" : String(raw)] ?? null;
|
|
23480
|
+
}
|
|
23423
23481
|
var NO_GROUPS = { title: "", kind: "bar", group_by: [], rows: [] };
|
|
23424
|
-
function ChartBlock({ block, subject, tableName: tableName2, className, centerValue, variant = "card", source }) {
|
|
23482
|
+
function ChartBlock({ block, subject, tableName: tableName2, className, centerValue, centerTotal, legend = true, groupColors, variant = "card", source }) {
|
|
23425
23483
|
const bare = variant === "bare";
|
|
23426
23484
|
const host = useRecordsUi();
|
|
23427
23485
|
const kind2 = block.kind;
|
|
@@ -23472,10 +23530,10 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
23472
23530
|
};
|
|
23473
23531
|
}
|
|
23474
23532
|
points.forEach((point, index) => {
|
|
23475
|
-
out[point.label] ??= { label: point.label, color: SERIES_COLORS[index % SERIES_COLORS.length] };
|
|
23533
|
+
out[point.label] ??= { label: point.label, color: (!windows ? colorOfGroup(point.groups, groupColors) : null) ?? SERIES_COLORS[index % SERIES_COLORS.length] };
|
|
23476
23534
|
});
|
|
23477
23535
|
return out;
|
|
23478
|
-
}, [primary, measureName, windows, points]);
|
|
23536
|
+
}, [primary, measureName, windows, points, groupColors]);
|
|
23479
23537
|
const goal = target && typeof target.value === "number" ? {
|
|
23480
23538
|
value: typeof target.pace === "number" ? target.pace : block.bucket ? null : target.value,
|
|
23481
23539
|
label: typeof target.pace === "number" && target.per !== "bucket" ? `${target.label} pace` : target.label
|
|
@@ -23534,10 +23592,11 @@ function ChartBlock({ block, subject, tableName: tableName2, className, centerVa
|
|
|
23534
23592
|
config,
|
|
23535
23593
|
onDrill: drill,
|
|
23536
23594
|
goal,
|
|
23537
|
-
...centerValue ? { center: points.reduce((sum, p) => sum + (p.values[primary] ?? 0), 0) } : {}
|
|
23595
|
+
...centerValue ? { center: centerTotal !== void 0 ? centerTotal : points.reduce((sum, p) => sum + (p.values[primary] ?? 0), 0) } : {},
|
|
23596
|
+
showLegend: legend
|
|
23538
23597
|
}
|
|
23539
23598
|
),
|
|
23540
|
-
kind2 === "donut" ? null : /* @__PURE__ */ jsx79(Values, { points, measure: primary, config, onDrill: drill, compared, aimingUp: !!target })
|
|
23599
|
+
kind2 === "donut" || !legend ? null : /* @__PURE__ */ jsx79(Values, { points, measure: primary, config, onDrill: drill, compared, aimingUp: !!target })
|
|
23541
23600
|
] }) })
|
|
23542
23601
|
]
|
|
23543
23602
|
}
|
|
@@ -23744,7 +23803,8 @@ function Drawing({
|
|
|
23744
23803
|
config,
|
|
23745
23804
|
onDrill,
|
|
23746
23805
|
goal,
|
|
23747
|
-
center
|
|
23806
|
+
center,
|
|
23807
|
+
showLegend = true
|
|
23748
23808
|
}) {
|
|
23749
23809
|
const compared = series.length > 1;
|
|
23750
23810
|
const drawOrder = compared ? [series[1], series[0]] : series;
|
|
@@ -23801,15 +23861,15 @@ function Drawing({
|
|
|
23801
23861
|
{
|
|
23802
23862
|
className: "pointer-events-none absolute inset-0 flex items-center justify-center px-6 font-semibold tabular-nums",
|
|
23803
23863
|
"data-records-chart-center": "",
|
|
23804
|
-
title: pretty(center),
|
|
23805
|
-
style: { fontSize: pretty(center).length > 6 ? 13 : 16 },
|
|
23806
|
-
children: pretty(center).length > 7 ? compactTick(center) : pretty(center)
|
|
23864
|
+
title: center === null ? void 0 : pretty(center),
|
|
23865
|
+
style: { fontSize: center !== null && pretty(center).length > 6 ? 13 : 16 },
|
|
23866
|
+
children: center === null ? "\u2013" : pretty(center).length > 7 ? compactTick(center) : pretty(center)
|
|
23807
23867
|
}
|
|
23808
23868
|
)
|
|
23809
23869
|
] });
|
|
23810
23870
|
return /* @__PURE__ */ jsxs72("div", { className: "flex min-w-0 flex-wrap items-center gap-x-4 gap-y-2", "data-records-donut": "", children: [
|
|
23811
23871
|
ringWithCenter,
|
|
23812
|
-
/* @__PURE__ */ jsx79("ul", { className: "flex min-w-[8rem] max-w-md flex-1 basis-40 flex-col gap-0.5 overflow-y-auto overscroll-contain", style: { maxHeight: DONUT_LEGEND_MAX_PX }, "data-records-donut-legend": "", children: points.map((point, at) => {
|
|
23872
|
+
showLegend ? /* @__PURE__ */ jsx79("ul", { className: "flex min-w-[8rem] max-w-md flex-1 basis-40 flex-col gap-0.5 overflow-y-auto overscroll-contain", style: { maxHeight: DONUT_LEGEND_MAX_PX }, "data-records-donut-legend": "", children: points.map((point, at) => {
|
|
23813
23873
|
const value = point.values[series[0]] ?? 0;
|
|
23814
23874
|
const share = total > 0 ? Math.round(value / total * 1e3) / 10 : 0;
|
|
23815
23875
|
const row = /* @__PURE__ */ jsxs72(Fragment34, { children: [
|
|
@@ -23819,7 +23879,7 @@ function Drawing({
|
|
|
23819
23879
|
/* @__PURE__ */ jsx79("span", { className: "w-10 shrink-0 text-right tabular-nums text-muted-foreground", "data-records-donut-share": "", children: `${share}%` })
|
|
23820
23880
|
] });
|
|
23821
23881
|
return /* @__PURE__ */ jsx79("li", { className: "min-w-0 text-xs", children: onDrill ? /* @__PURE__ */ jsx79("button", { type: "button", className: "flex w-full min-w-0 items-center gap-2 rounded px-1 py-0.5 text-left hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", onClick: () => onDrill(point), children: row }) : /* @__PURE__ */ jsx79("span", { className: "flex w-full min-w-0 items-center gap-2 px-1 py-0.5", children: row }) }, `${at}:${point.label}`);
|
|
23822
|
-
}) })
|
|
23882
|
+
}) }) : null
|
|
23823
23883
|
] });
|
|
23824
23884
|
}
|
|
23825
23885
|
if (kind2 === "line") {
|
|
@@ -38826,7 +38886,7 @@ function TablePresence({ tableId }) {
|
|
|
38826
38886
|
}
|
|
38827
38887
|
|
|
38828
38888
|
// src/toolbarFit.ts
|
|
38829
|
-
import { useEffect as useEffect102, useLayoutEffect as
|
|
38889
|
+
import { useEffect as useEffect102, useLayoutEffect as useLayoutEffect4, useState as useState116 } from "react";
|
|
38830
38890
|
import { flushSync } from "react-dom";
|
|
38831
38891
|
function widthAtFold(piece, fold) {
|
|
38832
38892
|
for (let f = Math.min(fold, (piece.byFold?.length ?? 0) - 1); f >= 0; f -= 1) {
|
|
@@ -38918,7 +38978,7 @@ function createFitMemory() {
|
|
|
38918
38978
|
}
|
|
38919
38979
|
};
|
|
38920
38980
|
}
|
|
38921
|
-
var useIsoLayoutEffect = typeof window === "undefined" ? useEffect102 :
|
|
38981
|
+
var useIsoLayoutEffect = typeof window === "undefined" ? useEffect102 : useLayoutEffect4;
|
|
38922
38982
|
function useToolbarFit(row) {
|
|
38923
38983
|
const [fold, setFold] = useState116(0);
|
|
38924
38984
|
useIsoLayoutEffect(() => {
|