derive-dashboards 0.6.0 → 0.7.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/charts/kinds/area-marks.mjs +2 -1
- package/dist/charts/kinds/funnel-words.mjs +1 -1
- package/dist/charts/kinds/grid-marks.mjs +9 -4
- package/dist/charts/theme.d.mts +13 -13
- package/dist/charts/theme.mjs +17 -14
- package/dist/charts-react/Overlay.mjs +1 -0
- package/dist/charts-react/chart-unlayered.css +1 -107
- package/dist/charts-react/chart.css +1 -121
- package/dist/charts-react/tip-place.mjs +30 -15
- package/dist/core/document/display-comparisons.mjs +49 -0
- package/dist/core/document/display-validation.d.mts +12 -0
- package/dist/core/document/display-validation.mjs +56 -0
- package/dist/core/document/display.d.mts +6 -12
- package/dist/core/document/display.mjs +23 -48
- package/dist/core/engine/dialect.d.mts +2 -0
- package/dist/core/engine/index.mjs +1 -1
- package/dist/core/engine/levels.mjs +33 -1
- package/dist/core/engine/postgres.mjs +1 -0
- package/dist/core/engine/rank.mjs +1 -1
- package/dist/core/engine/reader.d.mts +4 -0
- package/dist/core/engine/sql-partition.mjs +45 -0
- package/dist/core/engine/sql-reads.mjs +4 -1
- package/dist/core/engine/statement.mjs +4 -4
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +1 -1
- package/dist/core/error/codes.mjs +1 -1
- package/dist/core/index.d.mts +6 -5
- package/dist/core/index.mjs +8 -7
- package/dist/core/model/validate/fields.mjs +1 -1
- package/dist/core/query/drill/compose.d.mts +2 -0
- package/dist/core/query/drill/compose.mjs +1 -1
- package/dist/core/query/drill/synthetic.mjs +1 -1
- package/dist/core/query/drill/types.d.mts +7 -0
- package/dist/core/query/drill/types.mjs +3 -1
- package/dist/core/schema/answers.d.mts +1176 -362
- package/dist/core/schema/drill-answers.mjs +19 -1
- package/dist/core/schema/drill.d.mts +21 -6
- package/dist/core/schema/drill.mjs +7 -1
- package/dist/core/schema/tools.mjs +13 -0
- package/dist/core/time/index.d.mts +2 -2
- package/dist/core/time/text-time.d.mts +9 -2
- package/dist/core/time/text-time.mjs +18 -3
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +22 -2
- package/dist/dashboard-documents.d.mts +8 -0
- package/dist/dashboard-documents.mjs +52 -0
- package/dist/drill-access.mjs +40 -3
- package/dist/drill-comparison.mjs +71 -0
- package/dist/drill-crumbs.mjs +21 -2
- package/dist/drill-group-seal.mjs +13 -0
- package/dist/drill-open.mjs +7 -1
- package/dist/drill-seal.mjs +4 -6
- package/dist/drill-views.mjs +5 -13
- package/dist/drill.mjs +28 -58
- package/dist/editing.mjs +1 -1
- package/dist/endpoints/drill.mjs +2 -3
- package/dist/endpoints/index.d.mts +20 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +6 -27
- package/dist/llms.txt +1 -1
- package/dist/react/Cell.mjs +2 -2
- package/dist/react/DashboardList.mjs +3 -3
- package/dist/react/Editing.mjs +3 -3
- package/dist/react/Header.mjs +2 -2
- package/dist/react/History.mjs +3 -3
- package/dist/react/Parts.mjs +2 -2
- package/dist/react/RowBody.d.mts +2 -4
- package/dist/react/RowBody.mjs +14 -39
- package/dist/react/Tile.mjs +4 -5
- package/dist/react/builder/FilterEditor.mjs +2 -2
- package/dist/react/builder/Picker.mjs +3 -3
- package/dist/react/builder/RangeEditor.mjs +3 -3
- package/dist/react/builder/Time.mjs +3 -3
- package/dist/react/builder/Values.mjs +2 -2
- package/dist/react/builder/WidgetBuilder.mjs +2 -2
- package/dist/react/drill/Bars.mjs +34 -38
- package/dist/react/drill/Comparison.mjs +204 -0
- package/dist/react/drill/Controls.mjs +8 -12
- package/dist/react/drill/DrillDrawer.mjs +42 -0
- package/dist/react/drill/DrillPanel.mjs +61 -41
- package/dist/react/drill/Header.mjs +65 -35
- package/dist/react/drill/ItemLink.mjs +40 -0
- package/dist/react/drill/Items.d.mts +2 -1
- package/dist/react/drill/Items.mjs +126 -99
- package/dist/react/drill/ItemsBody.mjs +38 -0
- package/dist/react/drill/ItemsFoot.mjs +24 -19
- package/dist/react/drill/Notes.mjs +23 -13
- package/dist/react/drill/PanelBody.mjs +7 -25
- package/dist/react/drill/RecordRow.mjs +47 -0
- package/dist/react/drill/Trend.mjs +186 -0
- package/dist/react/drill/board.mjs +21 -11
- package/dist/react/drill/drawer-context.mjs +5 -0
- package/dist/react/drill/item-parts.mjs +53 -35
- package/dist/react/drill/item-type.d.mts +2 -2
- package/dist/react/drill/lazy.d.mts +1 -4
- package/dist/react/drill/lazy.mjs +29 -11
- package/dist/react/drill/panel-focus.mjs +18 -7
- package/dist/react/drill/props.d.mts +7 -1
- package/dist/react/drill/props.mjs +39 -8
- package/dist/react/drill/record-page.mjs +61 -0
- package/dist/react/drill/state.mjs +17 -2
- package/dist/react/drill/trend-touch.mjs +33 -0
- package/dist/react/drill/useDrill.d.mts +3 -3
- package/dist/react/drill/useDrill.mjs +35 -15
- package/dist/react/drill/words.d.mts +14 -0
- package/dist/react/drill/words.mjs +19 -7
- package/dist/react/english.d.mts +1 -0
- package/dist/react/english.mjs +1 -0
- package/dist/react/filters/chip.mjs +2 -2
- package/dist/react/filters/menu-search.mjs +5 -5
- package/dist/react/filters/menu.mjs +2 -2
- package/dist/react/filters/number.mjs +2 -2
- package/dist/react/filters/operator.mjs +2 -2
- package/dist/react/filters/phone.mjs +2 -2
- package/dist/react/filters/values.mjs +4 -4
- package/dist/react/format-time.d.mts +1 -0
- package/dist/react/format-time.mjs +39 -33
- package/dist/react/format.mjs +10 -1
- package/dist/react/renderers/list.mjs +8 -10
- package/dist/react/renderers/table-cells.mjs +38 -9
- package/dist/react/renderers/table-measure.mjs +2 -0
- package/dist/react/renderers/table-row.mjs +64 -7
- package/dist/react/renderers/table-sort.mjs +2 -8
- package/dist/react/renderers/table.mjs +16 -15
- package/dist/react/theme-unlayered.css +1 -3148
- package/dist/react/theme.css +1 -3150
- package/dist/recharts/parts.mjs +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +4 -2
- package/dist/store/apply.mjs +2 -2
- package/dist/store/editor.mjs +2 -2
- package/dist/store/writer.mjs +2 -2
- package/package.json +1 -1
|
@@ -22,34 +22,57 @@ function nounOnly(summary, format) {
|
|
|
22
22
|
if (summary.noun === void 0) return format.messages.drillNoun(n);
|
|
23
23
|
return n === 1 ? summary.noun.one : summary.noun.other;
|
|
24
24
|
}
|
|
25
|
-
|
|
26
|
-
function DrillHead(props) {
|
|
25
|
+
function FocusTitle(props) {
|
|
27
26
|
const { messages } = useDashboards();
|
|
28
27
|
const heading = useRef(null);
|
|
29
28
|
const { step } = props;
|
|
30
29
|
useEffect(() => {
|
|
31
30
|
if (step !== "") heading.current?.focus({ preventScroll: true });
|
|
32
31
|
}, [step]);
|
|
32
|
+
return /* @__PURE__ */ jsx("h3", {
|
|
33
|
+
ref: heading,
|
|
34
|
+
tabIndex: -1,
|
|
35
|
+
children: props.onRoot === void 0 ? props.title : /* @__PURE__ */ jsx("button", {
|
|
36
|
+
type: "button",
|
|
37
|
+
className: "dd-drill-root",
|
|
38
|
+
onClick: props.onRoot,
|
|
39
|
+
children: messages.drillRoot(props.title)
|
|
40
|
+
})
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** The panel's head: Back, its title, Close. The title takes focus whenever the step changes. */
|
|
44
|
+
function DrillHead(props) {
|
|
45
|
+
const { messages } = useDashboards();
|
|
33
46
|
return /* @__PURE__ */ jsxs("header", {
|
|
34
47
|
className: "dd-panel-head dd-drill-head",
|
|
35
48
|
children: [
|
|
36
|
-
/* @__PURE__ */
|
|
49
|
+
props.onBack === void 0 ? null : /* @__PURE__ */ jsx("button", {
|
|
37
50
|
type: "button",
|
|
38
|
-
className: "dd-
|
|
51
|
+
className: "dd-drill-icon",
|
|
52
|
+
"aria-label": messages.drillBack,
|
|
53
|
+
title: messages.drillBack,
|
|
39
54
|
onClick: props.onBack,
|
|
40
|
-
children:
|
|
55
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
56
|
+
className: "dd-direction",
|
|
57
|
+
"aria-hidden": "true",
|
|
58
|
+
children: "‹"
|
|
59
|
+
})
|
|
41
60
|
}),
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
children: props.title
|
|
61
|
+
/* @__PURE__ */ jsxs("div", {
|
|
62
|
+
className: "dd-drill-trail",
|
|
63
|
+
children: [/* @__PURE__ */ jsx(FocusTitle, { ...props }), props.children]
|
|
46
64
|
}),
|
|
47
65
|
/* @__PURE__ */ jsx("button", {
|
|
48
66
|
type: "button",
|
|
49
|
-
className: "dd-
|
|
67
|
+
className: "dd-drill-icon dd-drill-close",
|
|
68
|
+
"aria-label": messages.close,
|
|
69
|
+
title: messages.close,
|
|
50
70
|
"aria-keyshortcuts": "Escape",
|
|
51
71
|
onClick: props.onClose,
|
|
52
|
-
children:
|
|
72
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
73
|
+
"aria-hidden": "true",
|
|
74
|
+
children: "×"
|
|
75
|
+
})
|
|
53
76
|
})
|
|
54
77
|
]
|
|
55
78
|
});
|
|
@@ -76,25 +99,23 @@ function crumbText(c, format, timeZone) {
|
|
|
76
99
|
/** The path as breadcrumbs: the tile, then each step, each going back to it. */
|
|
77
100
|
function Crumbs(props) {
|
|
78
101
|
const format = useDashboards();
|
|
102
|
+
if (props.path.every((c) => c.kind === "total")) return null;
|
|
79
103
|
return /* @__PURE__ */ jsx("nav", {
|
|
80
104
|
className: "dd-drill-crumbs",
|
|
81
105
|
"aria-label": format.messages.drillTitle,
|
|
82
|
-
children: /* @__PURE__ */
|
|
83
|
-
type: "button",
|
|
84
|
-
onClick: () => {
|
|
85
|
-
props.onGoTo(0);
|
|
86
|
-
},
|
|
87
|
-
children: format.messages.drillRoot(props.root)
|
|
88
|
-
}) }), props.path.map((c, i) => c.kind === "total" ? null : /* @__PURE__ */ jsx("li", {
|
|
106
|
+
children: /* @__PURE__ */ jsx("ol", { children: props.path.map((c, i) => c.kind === "total" ? null : /* @__PURE__ */ jsx("li", {
|
|
89
107
|
"aria-current": i === props.path.length - 1 ? "step" : void 0,
|
|
90
|
-
children: i === props.path.length - 1 ? /* @__PURE__ */
|
|
108
|
+
children: i === props.path.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [c.kind === "group" && !c.parts && c.value !== null ? /* @__PURE__ */ jsxs("small", {
|
|
109
|
+
className: "dd-sr-only",
|
|
110
|
+
children: [c.label, " "]
|
|
111
|
+
}) : null, crumbText(c, format, props.timeZone)] }) : /* @__PURE__ */ jsx("button", {
|
|
91
112
|
type: "button",
|
|
92
113
|
onClick: () => {
|
|
93
114
|
props.onGoTo(i + 1);
|
|
94
115
|
},
|
|
95
116
|
children: crumbText(c, format, props.timeZone)
|
|
96
117
|
})
|
|
97
|
-
}, `${c.label}-${String(i)}`))
|
|
118
|
+
}, `${c.label}-${String(i)}`)) })
|
|
98
119
|
});
|
|
99
120
|
}
|
|
100
121
|
/** "396 tasks with Hours (57 without)", or the rows alone. */
|
|
@@ -105,28 +126,37 @@ function rowsLine(summary, format) {
|
|
|
105
126
|
const missing = without === void 0 || without <= 0 ? void 0 : formatCell(without, { type: "int" }, format);
|
|
106
127
|
return format.messages.drillWith(rows, summary.operand, missing);
|
|
107
128
|
}
|
|
129
|
+
function shareText(summary, parent, format) {
|
|
130
|
+
const share = summary.share;
|
|
131
|
+
if (share === void 0) return null;
|
|
132
|
+
const percent = new Intl.NumberFormat(format.locale, { style: "percent" }).format(share.value);
|
|
133
|
+
const metric = summary.column?.label;
|
|
134
|
+
const tile = metric === void 0 ? void 0 : format.messages.drillMetricTotal?.(metric);
|
|
135
|
+
return format.messages.drillShare(percent, share.of === "parent" ? parent : tile);
|
|
136
|
+
}
|
|
108
137
|
/** The value, the rows behind it when they differ, its share, and what the viewer should know about it. */
|
|
109
138
|
function Value({ summary, parent, onRefresh }) {
|
|
110
139
|
const format = useDashboards();
|
|
111
140
|
const value = formatCell(summary.value, valueColumn(summary), format);
|
|
112
141
|
const rows = rowsLine(summary, format);
|
|
113
|
-
const share = summary
|
|
142
|
+
const share = shareText(summary, parent, format);
|
|
143
|
+
const counted = sameCount(summary);
|
|
144
|
+
const label = summary.column?.label ?? (counted ? nounOnly(summary, format) : void 0);
|
|
114
145
|
return /* @__PURE__ */ jsxs("div", {
|
|
115
146
|
className: "dd-drill-value",
|
|
116
|
-
children: [
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
})]
|
|
147
|
+
children: [
|
|
148
|
+
/* @__PURE__ */ jsxs("p", {
|
|
149
|
+
className: "dd-drill-stat",
|
|
150
|
+
children: [/* @__PURE__ */ jsx("strong", { children: value }), label === void 0 ? null : /* @__PURE__ */ jsx("span", { children: label })]
|
|
151
|
+
}),
|
|
152
|
+
rows !== void 0 && !counted ? /* @__PURE__ */ jsx("p", { children: rows }) : null,
|
|
153
|
+
share === null ? null : /* @__PURE__ */ jsx("p", { children: share }),
|
|
154
|
+
/* @__PURE__ */ jsx(Notes, {
|
|
155
|
+
summary,
|
|
156
|
+
value,
|
|
157
|
+
onRefresh
|
|
158
|
+
})
|
|
159
|
+
]
|
|
130
160
|
});
|
|
131
161
|
}
|
|
132
162
|
export { Crumbs, DrillHead, Value, crumbText };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { useDashboards } from "../context.mjs";
|
|
2
|
+
import { asItem } from "./item-type.mjs";
|
|
3
|
+
import { itemLink } from "derive-dashboards/core";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/drill/ItemLink.tsx
|
|
6
|
+
const plainClick = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
|
|
7
|
+
/**
|
|
8
|
+
* An item's link: the host's `itemHref` when it gives one (its `undefined` turns the link off),
|
|
9
|
+
* else its source's `itemLinks` template, else the server's. A hidden key never has one.
|
|
10
|
+
*/
|
|
11
|
+
const hrefOf = (options, item) => options.itemHref === void 0 ? itemLink(options.itemLinks, item) ?? item.link : options.itemHref(asItem(item));
|
|
12
|
+
/** How an item opens: as a link, a button, or not at all. */
|
|
13
|
+
function Opener(props) {
|
|
14
|
+
const { link: Link = "a" } = useDashboards();
|
|
15
|
+
const { item, options } = props;
|
|
16
|
+
const href = hrefOf(options, item);
|
|
17
|
+
const onItem = options.onItem;
|
|
18
|
+
if (href === void 0 && onItem === void 0) return /* @__PURE__ */ jsx("div", {
|
|
19
|
+
className: props.className,
|
|
20
|
+
children: props.children
|
|
21
|
+
});
|
|
22
|
+
if (href === void 0) return /* @__PURE__ */ jsx("button", {
|
|
23
|
+
type: "button",
|
|
24
|
+
className: props.className,
|
|
25
|
+
onClick: (event) => onItem?.(asItem(item), { event }),
|
|
26
|
+
children: props.children
|
|
27
|
+
});
|
|
28
|
+
const onClick = (event) => {
|
|
29
|
+
if (onItem === void 0 || !plainClick(event)) return;
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
onItem(asItem(item), { event });
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ jsx(Link, {
|
|
34
|
+
href,
|
|
35
|
+
className: props.className,
|
|
36
|
+
onClick,
|
|
37
|
+
children: props.children
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
export { Opener, hrefOf };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Item } from "../index.mjs";
|
|
2
1
|
import { ItemParts } from "./item-parts.mjs";
|
|
2
|
+
import "./item-type.mjs";
|
|
3
|
+
import { Item } from "../index.mjs";
|
|
3
4
|
import { ComponentType, MouseEvent, ReactNode } from "react";
|
|
4
5
|
import { DrillItem, DrillItemsView, ItemLinks } from "derive-dashboards/core";
|
|
5
6
|
/** What a host's own item row is given: the item's link and parts, and how to open it. */
|
|
@@ -1,47 +1,14 @@
|
|
|
1
1
|
import { isNumberType } from "../columns.mjs";
|
|
2
2
|
import { useDashboards } from "../context.mjs";
|
|
3
3
|
import { formatCell } from "../format.mjs";
|
|
4
|
-
import {
|
|
5
|
-
import { columnShape, itemParts,
|
|
4
|
+
import { Opener, hrefOf } from "./ItemLink.mjs";
|
|
5
|
+
import { columnShape, itemParts, itemTitle, recordField, recordParts, sortDate } from "./item-parts.mjs";
|
|
6
6
|
import { asItem } from "./item-type.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { RecordHeading, RecordRow } from "./RecordRow.mjs";
|
|
8
|
+
import { RecordPager, useRecordPage } from "./record-page.mjs";
|
|
9
|
+
import { useEffect, useRef } from "react";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
// src/drill/Items.tsx
|
|
11
|
-
const plainClick = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
|
|
12
|
-
/**
|
|
13
|
-
* An item's link: the host's `itemHref` when it gives one (its `undefined` turns the link off),
|
|
14
|
-
* else its source's `itemLinks` template, else the server's. A hidden key never has one.
|
|
15
|
-
*/
|
|
16
|
-
const hrefOf = (options, item) => options.itemHref === void 0 ? itemLink(options.itemLinks, item) ?? item.link : options.itemHref(asItem(item));
|
|
17
|
-
/** How an item opens: as a link, a button, or not at all. */
|
|
18
|
-
function Opener(props) {
|
|
19
|
-
const { link: Link = "a" } = useDashboards();
|
|
20
|
-
const { item, options } = props;
|
|
21
|
-
const href = hrefOf(options, item);
|
|
22
|
-
const onItem = options.onItem;
|
|
23
|
-
if (href === void 0 && onItem === void 0) return /* @__PURE__ */ jsx("div", {
|
|
24
|
-
className: props.className,
|
|
25
|
-
children: props.children
|
|
26
|
-
});
|
|
27
|
-
if (href === void 0) return /* @__PURE__ */ jsx("button", {
|
|
28
|
-
type: "button",
|
|
29
|
-
className: props.className,
|
|
30
|
-
onClick: (event) => onItem?.(asItem(item), { event }),
|
|
31
|
-
children: props.children
|
|
32
|
-
});
|
|
33
|
-
const onClick = (event) => {
|
|
34
|
-
if (onItem === void 0 || !plainClick(event)) return;
|
|
35
|
-
event.preventDefault();
|
|
36
|
-
onItem(asItem(item), { event });
|
|
37
|
-
};
|
|
38
|
-
return /* @__PURE__ */ jsx(Link, {
|
|
39
|
-
href,
|
|
40
|
-
className: props.className,
|
|
41
|
-
onClick,
|
|
42
|
-
children: props.children
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
12
|
/** A noun as a column heading: "task" reads "Task". */
|
|
46
13
|
const headOf = (noun) => noun === void 0 ? void 0 : `${noun.charAt(0).toLocaleUpperCase()}${noun.slice(1)}`;
|
|
47
14
|
/**
|
|
@@ -52,14 +19,18 @@ const headOf = (noun) => noun === void 0 ? void 0 : `${noun.charAt(0).toLocaleUp
|
|
|
52
19
|
function Table(props) {
|
|
53
20
|
const format = useDashboards();
|
|
54
21
|
const { view } = props;
|
|
22
|
+
const body = useAppendedRow(props);
|
|
55
23
|
const cell = {
|
|
56
24
|
...format,
|
|
57
25
|
timeZone: props.timeZone
|
|
58
26
|
};
|
|
59
|
-
const
|
|
27
|
+
const priority = (member) => member === view.sorted?.member ? 0 : view.fixed?.includes(member) === true ? 2 : 1;
|
|
28
|
+
const rest = view.columns.filter((c) => c.member !== view.title).toSorted((a, b) => priority(a.member) - priority(b.member));
|
|
60
29
|
const named = view.columns.find((c) => c.member === view.title);
|
|
61
|
-
return /* @__PURE__ */ jsx("
|
|
30
|
+
return /* @__PURE__ */ jsx("section", {
|
|
62
31
|
className: "dd-records-scroll",
|
|
32
|
+
tabIndex: 0,
|
|
33
|
+
"aria-label": format.messages.drillViews.items,
|
|
63
34
|
children: /* @__PURE__ */ jsxs("table", {
|
|
64
35
|
className: "dd-table",
|
|
65
36
|
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
@@ -69,21 +40,28 @@ function Table(props) {
|
|
|
69
40
|
scope: "col",
|
|
70
41
|
"data-numeric": isNumberType(c.type),
|
|
71
42
|
children: c.label
|
|
72
|
-
}, c.member))] }) }), /* @__PURE__ */ jsx("tbody", {
|
|
73
|
-
|
|
74
|
-
children: /* @__PURE__ */
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
43
|
+
}, c.member))] }) }), /* @__PURE__ */ jsx("tbody", {
|
|
44
|
+
ref: body,
|
|
45
|
+
children: props.items.map((item, i) => /* @__PURE__ */ jsxs("tr", {
|
|
46
|
+
tabIndex: -1,
|
|
47
|
+
children: [/* @__PURE__ */ jsx("th", {
|
|
48
|
+
scope: "row",
|
|
49
|
+
children: /* @__PURE__ */ jsx(Opener, {
|
|
50
|
+
item,
|
|
51
|
+
options: props.options,
|
|
52
|
+
className: "dd-item-cell",
|
|
53
|
+
children: itemTitle(named, item, {
|
|
54
|
+
n: props.start + i + 1,
|
|
55
|
+
noun: props.noun
|
|
56
|
+
}, cell)
|
|
57
|
+
})
|
|
58
|
+
}), rest.map((c) => /* @__PURE__ */ jsx("td", {
|
|
59
|
+
"data-numeric": isNumberType(c.type),
|
|
60
|
+
"data-type": c.type,
|
|
61
|
+
children: formatCell(item.values[c.member] ?? null, columnShape(c), cell)
|
|
62
|
+
}, c.member))]
|
|
63
|
+
}, item.id))
|
|
64
|
+
})]
|
|
87
65
|
})
|
|
88
66
|
});
|
|
89
67
|
}
|
|
@@ -99,71 +77,120 @@ function helpersOf(options, item, base) {
|
|
|
99
77
|
} }
|
|
100
78
|
};
|
|
101
79
|
}
|
|
102
|
-
/**
|
|
103
|
-
function
|
|
104
|
-
const format = useDashboards();
|
|
105
|
-
const { view, options } = props;
|
|
80
|
+
/** Reveal the first new record for keyboard and pointer users, including read-only records. */
|
|
81
|
+
function useAppendedRow({ loaded, start }) {
|
|
106
82
|
const list = useRef(null);
|
|
107
|
-
const seen = useRef(
|
|
83
|
+
const seen = useRef(loaded);
|
|
108
84
|
useEffect(() => {
|
|
109
85
|
const before = seen.current;
|
|
110
|
-
seen.current =
|
|
111
|
-
if (
|
|
112
|
-
list.current?.children[before
|
|
113
|
-
|
|
86
|
+
seen.current = loaded;
|
|
87
|
+
if (loaded <= before || before === 0 || before < start) return;
|
|
88
|
+
const row = list.current?.children[before - start];
|
|
89
|
+
if (!(row instanceof HTMLElement)) return;
|
|
90
|
+
const target = row.querySelector("a[href], button:not(:disabled), [tabindex]") ?? row;
|
|
91
|
+
target.focus({ preventScroll: true });
|
|
92
|
+
target.scrollIntoView({
|
|
93
|
+
block: "nearest",
|
|
94
|
+
inline: "nearest"
|
|
95
|
+
});
|
|
96
|
+
}, [loaded, start]);
|
|
97
|
+
return list;
|
|
98
|
+
}
|
|
99
|
+
function List(props) {
|
|
100
|
+
const format = useDashboards();
|
|
101
|
+
const { view, options } = props;
|
|
102
|
+
const list = useAppendedRow(props);
|
|
114
103
|
const cell = {
|
|
115
104
|
...format,
|
|
116
105
|
timeZone: props.timeZone
|
|
117
106
|
};
|
|
107
|
+
const field = recordField(view);
|
|
108
|
+
const sorted = sortDate(view);
|
|
118
109
|
return /* @__PURE__ */ jsx("ul", {
|
|
119
110
|
className: "dd-items",
|
|
120
111
|
ref: list,
|
|
121
112
|
children: props.items.map((item, i) => {
|
|
122
|
-
const parts = itemParts(view, item, {
|
|
123
|
-
n: i + 1,
|
|
124
|
-
noun: props.noun
|
|
125
|
-
}, cell);
|
|
126
113
|
const render = options.renderItem;
|
|
114
|
+
const row = {
|
|
115
|
+
n: props.start + i + 1,
|
|
116
|
+
noun: props.noun
|
|
117
|
+
};
|
|
127
118
|
const opens = hrefOf(options, item) !== void 0 || options.onItem !== void 0;
|
|
128
|
-
return /* @__PURE__ */ jsx("li", {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
119
|
+
return /* @__PURE__ */ jsx("li", {
|
|
120
|
+
tabIndex: -1,
|
|
121
|
+
children: render === void 0 ? /* @__PURE__ */ jsx(Opener, {
|
|
122
|
+
item,
|
|
123
|
+
options,
|
|
124
|
+
className: "dd-item",
|
|
125
|
+
children: /* @__PURE__ */ jsx(RecordRow, {
|
|
126
|
+
parts: recordParts(view, item, {
|
|
127
|
+
...row,
|
|
128
|
+
date: sorted?.member
|
|
129
|
+
}, cell),
|
|
130
|
+
opens,
|
|
131
|
+
date: sorted?.label,
|
|
132
|
+
field,
|
|
133
|
+
value: field && formatCell(item.values[field.member] ?? null, columnShape(field), cell)
|
|
134
|
+
})
|
|
135
|
+
}) : render(asItem(item), helpersOf(options, item, {
|
|
136
|
+
...itemParts(view, item, row, cell),
|
|
137
|
+
view
|
|
138
|
+
}))
|
|
139
|
+
}, item.id);
|
|
143
140
|
})
|
|
144
141
|
});
|
|
145
142
|
}
|
|
146
|
-
/** The
|
|
143
|
+
/** The toggle survives both layouts and takes focus back when the wide table closes. */
|
|
144
|
+
function useReturnToSummary(fields) {
|
|
145
|
+
const toggle = useRef(null);
|
|
146
|
+
const previous = useRef(fields);
|
|
147
|
+
useEffect(() => {
|
|
148
|
+
if (previous.current && !fields) toggle.current?.focus({ preventScroll: true });
|
|
149
|
+
previous.current = fields;
|
|
150
|
+
}, [fields]);
|
|
151
|
+
return toggle;
|
|
152
|
+
}
|
|
153
|
+
/** The same page of records as a summary list or a full table. */
|
|
147
154
|
function Items(props) {
|
|
148
155
|
const format = useDashboards();
|
|
149
156
|
const { view, Empty } = props;
|
|
150
|
-
const
|
|
157
|
+
const toggle = useReturnToSummary(props.fields);
|
|
158
|
+
const page = useRecordPage(props.items);
|
|
159
|
+
const visible = {
|
|
160
|
+
...props,
|
|
161
|
+
start: page.start,
|
|
162
|
+
items: page.items,
|
|
163
|
+
loaded: props.items.length
|
|
164
|
+
};
|
|
151
165
|
if (props.items.length === 0) return Empty === void 0 ? /* @__PURE__ */ jsx("p", {
|
|
152
166
|
className: "dd-tile-state",
|
|
153
167
|
children: format.messages.drillNoItems
|
|
154
168
|
}) : /* @__PURE__ */ jsx(Empty, {});
|
|
155
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
169
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
170
|
+
/* @__PURE__ */ jsxs("div", {
|
|
171
|
+
className: "dd-drill-records-head",
|
|
172
|
+
children: [props.count(page.paged ? {
|
|
173
|
+
first: page.start + 1,
|
|
174
|
+
last: page.end
|
|
175
|
+
} : void 0), /* @__PURE__ */ jsx("button", {
|
|
176
|
+
className: "dd-records-switch",
|
|
177
|
+
ref: toggle,
|
|
178
|
+
type: "button",
|
|
179
|
+
onClick: props.switchMode,
|
|
180
|
+
"aria-expanded": props.fields,
|
|
181
|
+
children: props.fields ? format.messages.drillList : format.messages.drillTable
|
|
182
|
+
})]
|
|
183
|
+
}),
|
|
184
|
+
page.paged && /* @__PURE__ */ jsx(RecordPager, {
|
|
185
|
+
page,
|
|
186
|
+
loaded: props.items.length
|
|
187
|
+
}),
|
|
188
|
+
!props.fields && props.options.renderItem === void 0 ? /* @__PURE__ */ jsx(RecordHeading, {
|
|
189
|
+
view,
|
|
190
|
+
noun: props.noun,
|
|
191
|
+
field: recordField(view)
|
|
192
|
+
}) : null,
|
|
193
|
+
props.fields ? /* @__PURE__ */ jsx(Table, { ...visible }) : /* @__PURE__ */ jsx(List, { ...visible })
|
|
194
|
+
] });
|
|
168
195
|
}
|
|
169
196
|
export { Items };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useDashboards } from "../context.mjs";
|
|
2
|
+
import { formatCell } from "../format.mjs";
|
|
3
|
+
import { OnlyToggle } from "./Controls.mjs";
|
|
4
|
+
import { Items } from "./Items.mjs";
|
|
5
|
+
import { RecordCount } from "./ItemsFoot.mjs";
|
|
6
|
+
import { itemFields, showsFields } from "./state.mjs";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/drill/ItemsBody.tsx
|
|
9
|
+
/** Items: the Only filter, a percentile's marker row, then the rows. */
|
|
10
|
+
function ItemsBody(a) {
|
|
11
|
+
const format = useDashboards();
|
|
12
|
+
const { d, view, props } = a;
|
|
13
|
+
const p = view.percentile;
|
|
14
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
15
|
+
/* @__PURE__ */ jsx(OnlyToggle, { d }),
|
|
16
|
+
p === void 0 || d.summary === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
17
|
+
className: "dd-drill-marker",
|
|
18
|
+
children: format.messages.drillPercentile(p, formatCell(d.summary.value, d.summary.column, format))
|
|
19
|
+
}),
|
|
20
|
+
/* @__PURE__ */ jsx(Items, {
|
|
21
|
+
count: (range) => /* @__PURE__ */ jsx(RecordCount, {
|
|
22
|
+
d,
|
|
23
|
+
range
|
|
24
|
+
}),
|
|
25
|
+
fields: showsFields(d.state),
|
|
26
|
+
switchMode: () => {
|
|
27
|
+
if (d.state) d.setView(itemFields(d.state, !showsFields(d.state)).view, "push");
|
|
28
|
+
},
|
|
29
|
+
view,
|
|
30
|
+
items: d.items.items,
|
|
31
|
+
options: props,
|
|
32
|
+
noun: d.summary?.noun?.one,
|
|
33
|
+
timeZone: d.summary?.receipt.calendar.timezone,
|
|
34
|
+
Empty: props.components?.Empty
|
|
35
|
+
})
|
|
36
|
+
] });
|
|
37
|
+
}
|
|
38
|
+
export { ItemsBody };
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { useDashboards } from "../context.mjs";
|
|
2
|
+
import { formatCell } from "../format.mjs";
|
|
2
3
|
import { countText } from "./counts.mjs";
|
|
4
|
+
import { RECORD_PAGES } from "./words.mjs";
|
|
3
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
6
|
// src/drill/ItemsFoot.tsx
|
|
5
7
|
/**
|
|
@@ -11,7 +13,7 @@ function listCount(view, summary) {
|
|
|
11
13
|
return summary.semantics === "distinct" ? summary.value : summary.itemCount;
|
|
12
14
|
}
|
|
13
15
|
/** Items' count and sort, then Show more while there are more, with a retry when a page fails. */
|
|
14
|
-
function
|
|
16
|
+
function RecordCount({ d, range }) {
|
|
15
17
|
const format = useDashboards();
|
|
16
18
|
const { messages } = format;
|
|
17
19
|
const view = d.items.view;
|
|
@@ -19,23 +21,26 @@ function ItemsFoot({ d }) {
|
|
|
19
21
|
const count = listCount(view, d.summary);
|
|
20
22
|
const total = count === void 0 ? void 0 : countText(count, format);
|
|
21
23
|
const sort = sortText(view, messages);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
24
|
+
const number = (n) => formatCell(n, { type: "int" }, format);
|
|
25
|
+
return /* @__PURE__ */ jsxs("p", {
|
|
26
|
+
className: "dd-records-count",
|
|
27
|
+
"aria-live": "polite",
|
|
28
|
+
children: [
|
|
29
|
+
range === void 0 ? messages.drillShowing(d.items.items.length, total) : (messages.drillRecordPages ?? RECORD_PAGES).range(number(range.first), number(range.last), number(d.items.items.length), total),
|
|
30
|
+
" ",
|
|
31
|
+
"· ",
|
|
32
|
+
sort
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function ItemsFoot({ d }) {
|
|
37
|
+
const { messages } = useDashboards();
|
|
38
|
+
if (d.items.view === void 0) return null;
|
|
39
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [d.items.moreError === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
40
|
+
className: "dd-tile-error",
|
|
41
|
+
role: "alert",
|
|
42
|
+
children: messages.drillFailed
|
|
43
|
+
}), d.items.hasMore ? /* @__PURE__ */ jsx(More, { d }) : null] });
|
|
39
44
|
}
|
|
40
45
|
/** How the Items are sorted, in words: the declared order, or by the value. */
|
|
41
46
|
function sortText(view, messages) {
|
|
@@ -57,4 +62,4 @@ function More({ d }) {
|
|
|
57
62
|
children: label
|
|
58
63
|
});
|
|
59
64
|
}
|
|
60
|
-
export { ItemsFoot };
|
|
65
|
+
export { ItemsFoot, RecordCount };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { formatInstantAt } from "../format-time.mjs";
|
|
2
1
|
import { useDashboards } from "../context.mjs";
|
|
3
2
|
import { formatCell } from "../format.mjs";
|
|
3
|
+
import { formatPeriod } from "../format-time.mjs";
|
|
4
|
+
import { trendWindowLabel } from "./words.mjs";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
// src/drill/Notes.tsx
|
|
6
7
|
/** The value as the line reads it: a ratio as a percent when its column says so. */
|
|
@@ -10,17 +11,26 @@ const valueColumn = (summary) => summary.semantics === "ratio" && summary.column
|
|
|
10
11
|
fraction: true,
|
|
11
12
|
type: "float"
|
|
12
13
|
} : summary.column;
|
|
13
|
-
/**
|
|
14
|
-
function
|
|
14
|
+
/** Show a trend's window separately only when it differs from the selection. */
|
|
15
|
+
function TrendPeriod({ range, summary }) {
|
|
16
|
+
const format = useDashboards();
|
|
17
|
+
const selected = summary?.range;
|
|
18
|
+
if (range === void 0 || range.from === selected?.from && range.to === selected.to) return null;
|
|
19
|
+
const period = formatPeriod(range, format, summary?.receipt.calendar.timezone);
|
|
20
|
+
const window = format.messages.drillTrendWindow ?? trendWindowLabel;
|
|
21
|
+
return /* @__PURE__ */ jsx("span", {
|
|
22
|
+
className: "dd-drill-range",
|
|
23
|
+
children: summary && !selected ? window(period) : period
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function Period({ summary }) {
|
|
15
27
|
const format = useDashboards();
|
|
16
28
|
const { messages } = format;
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const zone = summary.receipt.calendar.timezone;
|
|
20
|
-
const day = (at) => formatInstantAt(at, "day", format.locale, zone);
|
|
29
|
+
if (summary.range === void 0) return null;
|
|
30
|
+
const period = formatPeriod(summary.range, format, summary.receipt.calendar.timezone);
|
|
21
31
|
return /* @__PURE__ */ jsx("p", {
|
|
22
32
|
className: "dd-drill-period",
|
|
23
|
-
children: messages.drillEarlier(
|
|
33
|
+
children: summary.previous === true ? messages.drillEarlier(period) : period
|
|
24
34
|
});
|
|
25
35
|
}
|
|
26
36
|
/** The notes under the value: the period before, a moved value (the viewer's own link only), a shared link's limits. */
|
|
@@ -28,14 +38,14 @@ function Notes({ summary, value, onRefresh }) {
|
|
|
28
38
|
const format = useDashboards();
|
|
29
39
|
const { messages } = format;
|
|
30
40
|
const clicked = summary.clicked;
|
|
31
|
-
const
|
|
41
|
+
const previous = clicked === void 0 || summary.foreign === true ? void 0 : formatCell(clicked, valueColumn(summary), format);
|
|
32
42
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
33
|
-
/* @__PURE__ */ jsx(
|
|
34
|
-
|
|
43
|
+
/* @__PURE__ */ jsx(Period, { summary }),
|
|
44
|
+
previous !== void 0 && previous !== value ? /* @__PURE__ */ jsxs("p", {
|
|
35
45
|
className: "dd-tile-note",
|
|
36
46
|
role: "status",
|
|
37
47
|
children: [
|
|
38
|
-
messages.drillMoved(value,
|
|
48
|
+
messages.drillMoved(value, previous),
|
|
39
49
|
" ",
|
|
40
50
|
/* @__PURE__ */ jsx("button", {
|
|
41
51
|
type: "button",
|
|
@@ -56,4 +66,4 @@ function Notes({ summary, value, onRefresh }) {
|
|
|
56
66
|
}) : null
|
|
57
67
|
] });
|
|
58
68
|
}
|
|
59
|
-
export { Notes, valueColumn };
|
|
69
|
+
export { Notes, TrendPeriod, valueColumn };
|