derive-dashboards 0.5.1 → 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/README.md +4 -2
- package/dist/body.mjs +2 -2
- package/dist/charts/data/buckets.d.mts +11 -0
- package/dist/charts/data/buckets.mjs +66 -0
- package/dist/charts/data/clean.mjs +55 -0
- package/dist/charts/data/format.d.mts +19 -0
- package/dist/charts/data/format.mjs +174 -0
- package/dist/charts/data/input-error.d.mts +5 -0
- package/dist/charts/data/input-error.mjs +11 -0
- package/dist/charts/data/range.mjs +14 -0
- package/dist/charts/data/rows.d.mts +13 -0
- package/dist/charts/data/rows.mjs +31 -0
- package/dist/charts/data/shares.mjs +55 -0
- package/dist/charts/data/types.d.mts +106 -0
- package/dist/charts/data/words.d.mts +44 -0
- package/dist/charts/data/words.mjs +31 -0
- package/dist/charts/describe.mjs +110 -0
- package/dist/charts/index.d.mts +34 -0
- package/dist/charts/index.mjs +24 -0
- package/dist/charts/kinds/area-marks.mjs +120 -0
- package/dist/charts/kinds/area.d.mts +23 -0
- package/dist/charts/kinds/area.mjs +71 -0
- package/dist/charts/kinds/bars-data.d.mts +11 -0
- package/dist/charts/kinds/bars-data.mjs +30 -0
- package/dist/charts/kinds/bars-layout.mjs +30 -0
- package/dist/charts/kinds/bars-marks.mjs +93 -0
- package/dist/charts/kinds/bars-words.mjs +56 -0
- package/dist/charts/kinds/bars.d.mts +17 -0
- package/dist/charts/kinds/bars.mjs +68 -0
- package/dist/charts/kinds/columns-data.mjs +116 -0
- package/dist/charts/kinds/columns-layout.mjs +29 -0
- package/dist/charts/kinds/columns-marks.mjs +200 -0
- package/dist/charts/kinds/columns-words.mjs +26 -0
- package/dist/charts/kinds/columns.d.mts +13 -0
- package/dist/charts/kinds/columns.mjs +80 -0
- package/dist/charts/kinds/dumbbell-data.d.mts +22 -0
- package/dist/charts/kinds/dumbbell-data.mjs +59 -0
- package/dist/charts/kinds/dumbbell-layout.mjs +113 -0
- package/dist/charts/kinds/dumbbell-marks.mjs +119 -0
- package/dist/charts/kinds/dumbbell-words.d.mts +7 -0
- package/dist/charts/kinds/dumbbell-words.mjs +94 -0
- package/dist/charts/kinds/dumbbell.d.mts +14 -0
- package/dist/charts/kinds/dumbbell.mjs +67 -0
- package/dist/charts/kinds/funnel-data.d.mts +11 -0
- package/dist/charts/kinds/funnel-data.mjs +70 -0
- package/dist/charts/kinds/funnel-layout.mjs +32 -0
- package/dist/charts/kinds/funnel-marks.mjs +204 -0
- package/dist/charts/kinds/funnel-words.mjs +77 -0
- package/dist/charts/kinds/funnel.d.mts +11 -0
- package/dist/charts/kinds/funnel.mjs +75 -0
- package/dist/charts/kinds/grid-data.d.mts +18 -0
- package/dist/charts/kinds/grid-data.mjs +35 -0
- package/dist/charts/kinds/grid-layout.mjs +77 -0
- package/dist/charts/kinds/grid-marks.mjs +140 -0
- package/dist/charts/kinds/grid-time.mjs +41 -0
- package/dist/charts/kinds/grid-words.mjs +86 -0
- package/dist/charts/kinds/grid.d.mts +22 -0
- package/dist/charts/kinds/grid.mjs +55 -0
- package/dist/charts/kinds/histogram-data.mjs +142 -0
- package/dist/charts/kinds/histogram-layout.mjs +144 -0
- package/dist/charts/kinds/histogram-marks.mjs +110 -0
- package/dist/charts/kinds/histogram-words.mjs +104 -0
- package/dist/charts/kinds/histogram.d.mts +15 -0
- package/dist/charts/kinds/histogram.mjs +47 -0
- package/dist/charts/kinds/line-marks.mjs +36 -0
- package/dist/charts/kinds/line.d.mts +17 -0
- package/dist/charts/kinds/line.mjs +52 -0
- package/dist/charts/kinds/multiples-grid.mjs +107 -0
- package/dist/charts/kinds/multiples-head.mjs +44 -0
- package/dist/charts/kinds/multiples-layout.mjs +159 -0
- package/dist/charts/kinds/multiples-marks.mjs +95 -0
- package/dist/charts/kinds/multiples-words.mjs +110 -0
- package/dist/charts/kinds/multiples.d.mts +26 -0
- package/dist/charts/kinds/multiples.mjs +42 -0
- package/dist/charts/kinds/row-chart.mjs +112 -0
- package/dist/charts/kinds/row-marks.mjs +121 -0
- package/dist/charts/kinds/scatter-data.d.mts +18 -0
- package/dist/charts/kinds/scatter-data.mjs +123 -0
- package/dist/charts/kinds/scatter-layout.mjs +189 -0
- package/dist/charts/kinds/scatter-marks.mjs +149 -0
- package/dist/charts/kinds/scatter-words.mjs +80 -0
- package/dist/charts/kinds/scatter.d.mts +21 -0
- package/dist/charts/kinds/scatter.mjs +72 -0
- package/dist/charts/kinds/stat-data.mjs +91 -0
- package/dist/charts/kinds/stat-layout.mjs +108 -0
- package/dist/charts/kinds/stat-marks.mjs +85 -0
- package/dist/charts/kinds/stat-words.mjs +57 -0
- package/dist/charts/kinds/stat.d.mts +28 -0
- package/dist/charts/kinds/stat.mjs +35 -0
- package/dist/charts/kinds/time-chart.mjs +74 -0
- package/dist/charts/kinds/time-frame.mjs +113 -0
- package/dist/charts/kinds/time-notes.mjs +36 -0
- package/dist/charts/kinds/time-plan.d.mts +8 -0
- package/dist/charts/kinds/time-plan.mjs +57 -0
- package/dist/charts/kinds/time-plot.mjs +56 -0
- package/dist/charts/kinds/time-stops.mjs +56 -0
- package/dist/charts/kinds/value-plot.mjs +33 -0
- package/dist/charts/kinds/waterfall-data.d.mts +7 -0
- package/dist/charts/kinds/waterfall-data.mjs +71 -0
- package/dist/charts/kinds/waterfall-layout.mjs +38 -0
- package/dist/charts/kinds/waterfall-marks.mjs +82 -0
- package/dist/charts/kinds/waterfall-words.mjs +118 -0
- package/dist/charts/kinds/waterfall.d.mts +17 -0
- package/dist/charts/kinds/waterfall.mjs +66 -0
- package/dist/charts/layout/boxes.mjs +28 -0
- package/dist/charts/layout/dodge.mjs +75 -0
- package/dist/charts/layout/extent.mjs +25 -0
- package/dist/charts/layout/frame.mjs +97 -0
- package/dist/charts/layout/place-labels.mjs +101 -0
- package/dist/charts/layout/stack.mjs +31 -0
- package/dist/charts/marks/axes.mjs +137 -0
- package/dist/charts/marks/dot.mjs +31 -0
- package/dist/charts/marks/end-labels.mjs +124 -0
- package/dist/charts/marks/legend.mjs +141 -0
- package/dist/charts/marks/lines.d.mts +2 -0
- package/dist/charts/marks/lines.mjs +38 -0
- package/dist/charts/marks/lit.d.mts +3 -0
- package/dist/charts/marks/lit.mjs +63 -0
- package/dist/charts/marks/more.mjs +18 -0
- package/dist/charts/marks/notes.mjs +253 -0
- package/dist/charts/marks/series-line.mjs +110 -0
- package/dist/charts/marks/thin.mjs +138 -0
- package/dist/charts/marks/x-axis.mjs +32 -0
- package/dist/charts/scale/calendar.mjs +174 -0
- package/dist/charts/scale/time-ticks.mjs +154 -0
- package/dist/charts/scale/time.mjs +33 -0
- package/dist/charts/scale/value.mjs +161 -0
- package/dist/charts/scene/defs.mjs +33 -0
- package/dist/charts/scene/markup.mjs +35 -0
- package/dist/charts/scene/nearest.d.mts +11 -0
- package/dist/charts/scene/nearest.mjs +49 -0
- package/dist/charts/scene/paint.d.mts +12 -0
- package/dist/charts/scene/paint.mjs +13 -0
- package/dist/charts/scene/svg.d.mts +18 -0
- package/dist/charts/scene/svg.mjs +185 -0
- package/dist/charts/scene/types.d.mts +177 -0
- package/dist/charts/text/measure.d.mts +9 -0
- package/dist/charts/text/measure.mjs +123 -0
- package/dist/charts/theme.d.mts +47 -0
- package/dist/charts/theme.mjs +239 -0
- package/dist/charts-react/Chart.d.mts +91 -0
- package/dist/charts-react/Chart.mjs +166 -0
- package/dist/charts-react/Overlay.mjs +171 -0
- package/dist/charts-react/Picture.mjs +22 -0
- package/dist/charts-react/Reader.mjs +147 -0
- package/dist/charts-react/bucket-names.mjs +29 -0
- package/dist/charts-react/chart-unlayered.css +1 -0
- package/dist/charts-react/chart-unlayered.css.d.ts +1 -0
- package/dist/charts-react/chart.css +1 -0
- package/dist/charts-react/chart.css.d.ts +1 -0
- package/dist/charts-react/events.mjs +72 -0
- package/dist/charts-react/exact-sum.mjs +24 -0
- package/dist/charts-react/from-answer.mjs +185 -0
- package/dist/charts-react/index.d.mts +3 -0
- package/dist/charts-react/index.mjs +4 -0
- package/dist/charts-react/keys.mjs +117 -0
- package/dist/charts-react/opens.mjs +28 -0
- package/dist/charts-react/plan-bars.mjs +95 -0
- package/dist/charts-react/plan-funnel.mjs +120 -0
- package/dist/charts-react/plan-grid.mjs +121 -0
- package/dist/charts-react/plan-parts.d.mts +2 -0
- package/dist/charts-react/plan-parts.mjs +30 -0
- package/dist/charts-react/plan-time.mjs +84 -0
- package/dist/charts-react/plan.d.mts +3 -0
- package/dist/charts-react/plan.mjs +37 -0
- package/dist/charts-react/point-keys.mjs +22 -0
- package/dist/charts-react/pointer.mjs +99 -0
- package/dist/charts-react/reader-page.d.mts +8 -0
- package/dist/charts-react/reader-page.mjs +116 -0
- package/dist/charts-react/tiles.d.mts +24 -0
- package/dist/charts-react/tiles.mjs +142 -0
- package/dist/charts-react/tip-place.mjs +107 -0
- package/dist/charts-react/tip-room.mjs +31 -0
- package/dist/charts-react/useClientLayoutEffect.mjs +8 -0
- package/dist/charts-react/useScene.mjs +76 -0
- package/dist/charts-react/useSize.mjs +44 -0
- package/dist/charts-react/useStop.mjs +68 -0
- package/dist/core/conformance/memory/aggregate.mjs +2 -1
- package/dist/core/conformance/memory/rows.mjs +1 -1
- package/dist/core/conformance/memory/source.mjs +3 -2
- package/dist/core/document/display-comparisons.mjs +49 -0
- package/dist/core/document/display-entries.mjs +2 -1
- 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 +27 -12
- package/dist/core/document/display.mjs +40 -49
- package/dist/core/document/view-layout.mjs +16 -0
- package/dist/core/engine/access.mjs +4 -2
- package/dist/core/engine/context.mjs +5 -7
- package/dist/core/engine/custom/cells.mjs +1 -1
- package/dist/core/engine/custom/records.mjs +2 -1
- 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/plan.d.mts +2 -0
- 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/exact/decimal.d.mts +1 -4
- package/dist/core/exact/decimal.mjs +1 -14
- package/dist/core/exact/text.d.mts +5 -0
- package/dist/core/exact/text.mjs +19 -0
- package/dist/core/index.d.mts +9 -6
- package/dist/core/index.mjs +11 -8
- package/dist/core/model/types.d.mts +2 -0
- package/dist/core/model/validate/fields.mjs +1 -1
- package/dist/core/model/validate/known-members.mjs +2 -0
- package/dist/core/model/validate/shape.mjs +5 -1
- package/dist/core/oracle/visibility.mjs +2 -2
- package/dist/core/policy/bind.mjs +29 -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 +2 -1
- package/dist/core/query/drill/types.d.mts +7 -0
- package/dist/core/query/drill/types.mjs +3 -1
- package/dist/core/result/number.mjs +2 -1
- package/dist/core/result/time-axis.mjs +2 -1
- package/dist/core/schema/answers.d.mts +1176 -362
- package/dist/core/schema/commands.mjs +2 -1
- package/dist/core/schema/document.mjs +27 -2
- 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/index.d.mts +2 -1
- package/dist/core/schema/index.mjs +2 -1
- package/dist/core/schema/null-ops.d.mts +6 -0
- package/dist/core/schema/null-ops.mjs +18 -0
- package/dist/core/schema/query.mjs +30 -4
- package/dist/core/schema/tools.mjs +13 -0
- package/dist/core/schema/union-error.mjs +38 -0
- package/dist/core/time/bucket.mjs +2 -1
- package/dist/core/time/index.d.mts +3 -2
- package/dist/core/time/instant.d.mts +1 -2
- package/dist/core/time/instant.mjs +2 -30
- package/dist/core/time/range.mjs +2 -1
- package/dist/core/time/stored.mjs +2 -1
- package/dist/core/time/text-time.d.mts +10 -0
- package/dist/core/time/text-time.mjs +80 -0
- 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/digits.mjs +1 -1
- 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 +20 -8
- package/dist/react/english.d.mts +4 -1
- package/dist/react/english.mjs +17 -2
- 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 +2 -1
- package/dist/react/format-time.mjs +42 -34
- package/dist/react/format.mjs +15 -3
- package/dist/react/index.d.mts +4 -3
- package/dist/react/index.mjs +4 -3
- package/dist/react/messages.d.mts +23 -2
- package/dist/react/renderers/entries.d.mts +11 -0
- 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/series.mjs +8 -3
- package/dist/react/theme-unlayered.css +1 -3144
- package/dist/react/theme.css +1 -3146
- package/dist/recharts/parts.mjs +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +10 -5
- package/dist/store/apply.mjs +2 -2
- package/dist/store/editor.mjs +2 -2
- package/dist/store/writer.mjs +2 -2
- package/package.json +27 -2
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { useDashboards } from "../context.mjs";
|
|
2
|
+
import { formatCell, groupText } from "../format.mjs";
|
|
3
|
+
import { formatPeriod } from "../format-time.mjs";
|
|
4
|
+
import { isTotal } from "../renderers/table-scale.mjs";
|
|
5
|
+
import { crumbText } from "./Header.mjs";
|
|
6
|
+
import { rowEntry } from "./state.mjs";
|
|
7
|
+
import { useDrill } from "./useDrill.mjs";
|
|
8
|
+
import { Fragment, useId, useState } from "react";
|
|
9
|
+
import { MAX_DRILL_STEPS, isMark } from "derive-dashboards/core";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
// src/drill/Comparison.tsx
|
|
12
|
+
function GroupName({ label }) {
|
|
13
|
+
return label.split(/(?<=[_-])/u).map((part, i) => /* @__PURE__ */ jsxs(Fragment, { children: [i > 0 && /* @__PURE__ */ jsx("wbr", {}), part] }, i));
|
|
14
|
+
}
|
|
15
|
+
function GroupRow({ view, row, toggle, child }) {
|
|
16
|
+
const format = useDashboards();
|
|
17
|
+
const [, ...metrics] = view.answer.columns;
|
|
18
|
+
const value = row[0] ?? null;
|
|
19
|
+
const label = groupLabel({
|
|
20
|
+
view,
|
|
21
|
+
row
|
|
22
|
+
}, format);
|
|
23
|
+
return /* @__PURE__ */ jsxs("tr", {
|
|
24
|
+
"data-child": child === void 0 ? void 0 : true,
|
|
25
|
+
"data-mark": isMark(value) ? value.mark : void 0,
|
|
26
|
+
children: [/* @__PURE__ */ jsxs("th", {
|
|
27
|
+
scope: "row",
|
|
28
|
+
children: [child !== void 0 && /* @__PURE__ */ jsxs("span", {
|
|
29
|
+
className: "dd-sr-only",
|
|
30
|
+
children: [child, " · "]
|
|
31
|
+
}), toggle ? /* @__PURE__ */ jsxs("button", {
|
|
32
|
+
type: "button",
|
|
33
|
+
"aria-label": toggle.label,
|
|
34
|
+
"aria-expanded": toggle.expanded,
|
|
35
|
+
"aria-controls": toggle.controls,
|
|
36
|
+
onClick: toggle.click,
|
|
37
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
38
|
+
className: "dd-disclosure dd-direction",
|
|
39
|
+
"aria-hidden": "true",
|
|
40
|
+
children: "›"
|
|
41
|
+
}), /* @__PURE__ */ jsx(GroupName, { label })]
|
|
42
|
+
}) : /* @__PURE__ */ jsx(GroupName, { label })]
|
|
43
|
+
}), metrics.map((column, i) => /* @__PURE__ */ jsx("td", { children: formatCell(row[i + 1] ?? null, column, format) }, column.id))]
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function InlineNote({ columns, children }) {
|
|
47
|
+
return /* @__PURE__ */ jsx("tr", {
|
|
48
|
+
"data-child": "true",
|
|
49
|
+
children: /* @__PURE__ */ jsx("td", {
|
|
50
|
+
colSpan: columns,
|
|
51
|
+
className: "dd-comparison-note",
|
|
52
|
+
"aria-live": "polite",
|
|
53
|
+
children
|
|
54
|
+
})
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** Fetch a group's children only while it is open. Keep every value under its parent column. */
|
|
58
|
+
function Children(props) {
|
|
59
|
+
const { messages } = useDashboards();
|
|
60
|
+
const [state, setState] = useState(props.state);
|
|
61
|
+
const d = useDrill({
|
|
62
|
+
state,
|
|
63
|
+
onStateChange: setState
|
|
64
|
+
});
|
|
65
|
+
if (d.status === "error") return /* @__PURE__ */ jsxs(InlineNote, {
|
|
66
|
+
columns: props.columns,
|
|
67
|
+
children: [
|
|
68
|
+
messages.drillFailed,
|
|
69
|
+
" ",
|
|
70
|
+
/* @__PURE__ */ jsx("button", {
|
|
71
|
+
type: "button",
|
|
72
|
+
onClick: d.retry,
|
|
73
|
+
children: messages.drillRetry
|
|
74
|
+
})
|
|
75
|
+
]
|
|
76
|
+
});
|
|
77
|
+
const view = d.shown;
|
|
78
|
+
if (view?.by !== "comparison") return /* @__PURE__ */ jsx(InlineNote, {
|
|
79
|
+
columns: props.columns,
|
|
80
|
+
children: messages.loading
|
|
81
|
+
});
|
|
82
|
+
if (view.answer.unreadable || view.omitted) return /* @__PURE__ */ jsx(InlineNote, {
|
|
83
|
+
columns: props.columns,
|
|
84
|
+
children: messages.noAccess
|
|
85
|
+
});
|
|
86
|
+
const rows = view.answer.rows.filter((row) => !isTotal(row));
|
|
87
|
+
if (rows.length === 0) return /* @__PURE__ */ jsx(InlineNote, {
|
|
88
|
+
columns: props.columns,
|
|
89
|
+
children: messages.drillNoGroups
|
|
90
|
+
});
|
|
91
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("tr", {
|
|
92
|
+
className: "dd-comparison-subhead",
|
|
93
|
+
children: /* @__PURE__ */ jsx("th", {
|
|
94
|
+
colSpan: props.columns,
|
|
95
|
+
children: props.label
|
|
96
|
+
})
|
|
97
|
+
}), rows.map((row) => /* @__PURE__ */ jsx(GroupRow, {
|
|
98
|
+
view,
|
|
99
|
+
row,
|
|
100
|
+
child: props.parent
|
|
101
|
+
}, JSON.stringify(row[0])))] });
|
|
102
|
+
}
|
|
103
|
+
function groupLabel(props, format) {
|
|
104
|
+
const value = props.row[0] ?? null;
|
|
105
|
+
const column = props.view.answer.columns[0];
|
|
106
|
+
return groupText(value, column, format);
|
|
107
|
+
}
|
|
108
|
+
function Group(props) {
|
|
109
|
+
const format = useDashboards();
|
|
110
|
+
const [expanded, setExpanded] = useState(false);
|
|
111
|
+
const childrenId = useId();
|
|
112
|
+
const { view, row, state } = props;
|
|
113
|
+
const field = view.thenBy;
|
|
114
|
+
const selection = rowEntry(view.drill, props.index);
|
|
115
|
+
const terminal = isMark(row[0] ?? null) || state.path.length >= MAX_DRILL_STEPS;
|
|
116
|
+
if (!field || selection === void 0 || terminal) return /* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx(GroupRow, { ...props }) });
|
|
117
|
+
const label = groupLabel(props, format);
|
|
118
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("tbody", { children: /* @__PURE__ */ jsx(GroupRow, {
|
|
119
|
+
...props,
|
|
120
|
+
toggle: {
|
|
121
|
+
controls: childrenId,
|
|
122
|
+
expanded,
|
|
123
|
+
label: `${label} · ${format.messages.drillBy} ${field.label}`,
|
|
124
|
+
click: () => {
|
|
125
|
+
setExpanded(!expanded);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}) }), /* @__PURE__ */ jsx("tbody", {
|
|
129
|
+
id: childrenId,
|
|
130
|
+
hidden: !expanded,
|
|
131
|
+
"aria-label": label,
|
|
132
|
+
children: expanded && /* @__PURE__ */ jsx(Children, {
|
|
133
|
+
state: {
|
|
134
|
+
...state,
|
|
135
|
+
path: [...state.path, selection],
|
|
136
|
+
view: {
|
|
137
|
+
by: "comparison",
|
|
138
|
+
member: field.id
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
columns: view.answer.columns.length,
|
|
142
|
+
parent: label,
|
|
143
|
+
label: field.label
|
|
144
|
+
}, selection)
|
|
145
|
+
})] });
|
|
146
|
+
}
|
|
147
|
+
function ComparisonTable({ label, view, state }) {
|
|
148
|
+
const { columns, rows } = view.answer;
|
|
149
|
+
return /* @__PURE__ */ jsx("div", {
|
|
150
|
+
className: "dd-comparison-scroll",
|
|
151
|
+
children: /* @__PURE__ */ jsxs("table", {
|
|
152
|
+
"aria-label": label,
|
|
153
|
+
style: { minWidth: `${17 + (columns.length - 1) * 10}ch` },
|
|
154
|
+
children: [/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: columns.map((c) => /* @__PURE__ */ jsx("th", {
|
|
155
|
+
scope: "col",
|
|
156
|
+
children: c.label
|
|
157
|
+
}, c.id)) }) }), rows.map((row, index) => /* @__PURE__ */ jsx(Group, {
|
|
158
|
+
row,
|
|
159
|
+
index,
|
|
160
|
+
view,
|
|
161
|
+
state
|
|
162
|
+
}, JSON.stringify(row[0])))]
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
function ComparisonHeading({ answer, label, by, receipt }) {
|
|
167
|
+
const format = useDashboards();
|
|
168
|
+
const last = answer.path.at(-1);
|
|
169
|
+
return /* @__PURE__ */ jsxs("header", { children: [/* @__PURE__ */ jsxs("h4", { children: [last?.kind === "group" && !last.parts && last.value !== null ? /* @__PURE__ */ jsxs("small", { children: [last.label, " "] }) : null, label] }), /* @__PURE__ */ jsxs("p", { children: [by, receipt.range && /* @__PURE__ */ jsxs(Fragment$1, { children: [" · ", formatPeriod(receipt.range, format, receipt.calendar.timezone)] })] })] });
|
|
170
|
+
}
|
|
171
|
+
function Comparison({ answer, view }) {
|
|
172
|
+
const format = useDashboards();
|
|
173
|
+
const { messages } = format;
|
|
174
|
+
const { columns, rows, receipt } = view.answer;
|
|
175
|
+
const last = answer.path.at(-1);
|
|
176
|
+
const label = last ? crumbText(last, format, receipt.calendar.timezone) : messages.total;
|
|
177
|
+
const field = columns[0]?.label ?? "";
|
|
178
|
+
const by = messages.drillGroupedBy?.(field) ?? field;
|
|
179
|
+
if (view.answer.unreadable) return /* @__PURE__ */ jsx("p", {
|
|
180
|
+
role: "status",
|
|
181
|
+
children: messages.noAccess
|
|
182
|
+
});
|
|
183
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
184
|
+
className: "dd-comparison",
|
|
185
|
+
children: [
|
|
186
|
+
/* @__PURE__ */ jsx(ComparisonHeading, {
|
|
187
|
+
answer,
|
|
188
|
+
label,
|
|
189
|
+
by,
|
|
190
|
+
receipt
|
|
191
|
+
}),
|
|
192
|
+
view.omitted && /* @__PURE__ */ jsx("p", {
|
|
193
|
+
role: "status",
|
|
194
|
+
children: messages.drillOmitted
|
|
195
|
+
}),
|
|
196
|
+
rows.length === 0 ? /* @__PURE__ */ jsx("p", { children: messages.drillNoGroups }) : /* @__PURE__ */ jsx(ComparisonTable, {
|
|
197
|
+
label: `${label} · ${by}`,
|
|
198
|
+
view,
|
|
199
|
+
state: answer.state
|
|
200
|
+
})
|
|
201
|
+
]
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
export { Comparison };
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
-
import { formatInstantAt } from "../format-time.mjs";
|
|
2
1
|
import { useDashboards } from "../context.mjs";
|
|
3
2
|
import { formatCell } from "../format.mjs";
|
|
3
|
+
import { TrendPeriod } from "./Notes.mjs";
|
|
4
4
|
import { useEffect, useState } from "react";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
6
|
// src/drill/Controls.tsx
|
|
7
7
|
/** Over time's range in words and its grain picker. */
|
|
8
8
|
function TrendControls({ d }) {
|
|
9
|
-
const
|
|
10
|
-
const { messages } = format;
|
|
9
|
+
const { messages } = useDashboards();
|
|
11
10
|
const shown = d.shown;
|
|
12
11
|
if (shown?.by !== "trend") return null;
|
|
13
|
-
const zone = d.summary?.receipt.calendar.timezone;
|
|
14
|
-
const range = shown.range;
|
|
15
|
-
const day = (text) => formatInstantAt(text, "day", format.locale, zone);
|
|
16
12
|
return /* @__PURE__ */ jsxs("div", {
|
|
17
13
|
className: "dd-drill-controls",
|
|
18
|
-
children: [
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
children: [/* @__PURE__ */ jsx(TrendPeriod, {
|
|
15
|
+
range: shown.range,
|
|
16
|
+
summary: d.summary
|
|
21
17
|
}), (shown.grains ?? []).length < 2 ? null : /* @__PURE__ */ jsxs("label", {
|
|
22
18
|
className: "dd-drill-by",
|
|
23
19
|
children: [/* @__PURE__ */ jsx("span", {
|
|
@@ -120,7 +116,7 @@ function OnlyToggle({ d }) {
|
|
|
120
116
|
if (numerator === void 0) return null;
|
|
121
117
|
const count = numerator.count === void 0 ? "" : formatCell(numerator.count, { type: "int" }, format);
|
|
122
118
|
const only = numerator.only === true;
|
|
123
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
119
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("button", {
|
|
124
120
|
type: "button",
|
|
125
121
|
className: "dd-drill-only",
|
|
126
122
|
"aria-pressed": only,
|
|
@@ -144,7 +140,7 @@ function Operands({ d }) {
|
|
|
144
140
|
return /* @__PURE__ */ jsxs("section", { children: [/* @__PURE__ */ jsx("h4", { children: format.messages.drillOperands }), /* @__PURE__ */ jsx("ul", {
|
|
145
141
|
className: "dd-drill-operands",
|
|
146
142
|
children: shown.operands.map((o) => {
|
|
147
|
-
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
143
|
+
const body = /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
148
144
|
/* @__PURE__ */ jsxs("span", { children: [
|
|
149
145
|
o.label,
|
|
150
146
|
" ",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { InDrillDrawer } from "./drawer-context.mjs";
|
|
2
|
+
import { useFocusReturn } from "./panel-focus.mjs";
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef } from "react";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/drill/DrillDrawer.tsx
|
|
6
|
+
const useLayout = typeof document === "undefined" ? useEffect : useLayoutEffect;
|
|
7
|
+
/** The built-in inspector owns focus while open. A host placing DrillPanel itself owns its surface. */
|
|
8
|
+
function DrillDrawer(props) {
|
|
9
|
+
const dialog = useRef(null);
|
|
10
|
+
const pressedOutside = useRef(false);
|
|
11
|
+
useFocusReturn(dialog, props.widgetId);
|
|
12
|
+
useLayout(() => {
|
|
13
|
+
const node = dialog.current;
|
|
14
|
+
node?.toggleAttribute("data-gutter", window.innerWidth > document.documentElement.clientWidth);
|
|
15
|
+
node?.showModal();
|
|
16
|
+
node?.querySelector(".dd-drill-head h3")?.focus({ preventScroll: true });
|
|
17
|
+
return () => node?.close();
|
|
18
|
+
}, []);
|
|
19
|
+
return /* @__PURE__ */ jsx("dialog", {
|
|
20
|
+
className: "dd-drill-drawer",
|
|
21
|
+
ref: dialog,
|
|
22
|
+
"aria-label": props.title,
|
|
23
|
+
onKeyDown: (event) => {
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
},
|
|
26
|
+
onCancel: (event) => {
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
props.close();
|
|
29
|
+
},
|
|
30
|
+
onPointerDown: (event) => {
|
|
31
|
+
pressedOutside.current = event.target === event.currentTarget;
|
|
32
|
+
},
|
|
33
|
+
onPointerUp: (event) => {
|
|
34
|
+
if (pressedOutside.current && event.target === event.currentTarget) props.close();
|
|
35
|
+
},
|
|
36
|
+
children: /* @__PURE__ */ jsx(InDrillDrawer.Provider, {
|
|
37
|
+
value: true,
|
|
38
|
+
children: props.children
|
|
39
|
+
})
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
export { DrillDrawer };
|
|
@@ -2,11 +2,12 @@ import { useDashboards } from "../context.mjs";
|
|
|
2
2
|
import { Tabs } from "./DrillTabs.mjs";
|
|
3
3
|
import { Crumbs, DrillHead, Value, crumbText } from "./Header.mjs";
|
|
4
4
|
import { Main } from "./PanelBody.mjs";
|
|
5
|
+
import { useFocusReturn, usePanelLandmark, usePeek } from "./panel-focus.mjs";
|
|
6
|
+
import { showsFields } from "./state.mjs";
|
|
5
7
|
import { SeeRows } from "./PanelStates.mjs";
|
|
6
|
-
import { useFocusReturn, usePeek } from "./panel-focus.mjs";
|
|
7
8
|
import { useDrill } from "./useDrill.mjs";
|
|
8
9
|
import { useRef } from "react";
|
|
9
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
11
|
// src/drill/DrillPanel.tsx
|
|
11
12
|
/** The panel over its own controller. */
|
|
12
13
|
function OwnController(props) {
|
|
@@ -22,6 +23,7 @@ function OwnController(props) {
|
|
|
22
23
|
/** Escape closes the drill; the dashboard's own Escape would close it again, so it stops here. */
|
|
23
24
|
function closeOnEscape(event, close) {
|
|
24
25
|
if (event.key !== "Escape") return;
|
|
26
|
+
event.preventDefault();
|
|
25
27
|
event.stopPropagation();
|
|
26
28
|
close();
|
|
27
29
|
}
|
|
@@ -32,58 +34,76 @@ function parentText(parent, title, named) {
|
|
|
32
34
|
}
|
|
33
35
|
/** The widget a dashboard's drill opened from: its tile is lit, and focus goes back to it. */
|
|
34
36
|
const widgetOf = (state) => state?.origin.kind === "dashboard" ? state.origin.widgetId : void 0;
|
|
37
|
+
function rootLink(d) {
|
|
38
|
+
if (d.path.every((c) => c.kind === "total")) return;
|
|
39
|
+
return () => {
|
|
40
|
+
d.goTo(0);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const isComparison = (d) => d.view?.by === "comparison";
|
|
44
|
+
const hasParent = (d) => showsFields(d.state) || (d.state?.path.length ?? 0) > 1;
|
|
45
|
+
function PanelHead({ d, title, close }) {
|
|
46
|
+
const format = useDashboards();
|
|
47
|
+
const comparison = isComparison(d);
|
|
48
|
+
const zone = d.summary?.receipt.calendar.timezone;
|
|
49
|
+
const parent = d.path.at(-2);
|
|
50
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(DrillHead, {
|
|
51
|
+
title,
|
|
52
|
+
step: JSON.stringify(d.state?.path),
|
|
53
|
+
onRoot: comparison ? void 0 : rootLink(d),
|
|
54
|
+
onBack: hasParent(d) ? d.back : void 0,
|
|
55
|
+
onClose: close,
|
|
56
|
+
children: comparison ? null : /* @__PURE__ */ jsx(Crumbs, {
|
|
57
|
+
path: d.path,
|
|
58
|
+
timeZone: zone,
|
|
59
|
+
onGoTo: d.goTo
|
|
60
|
+
})
|
|
61
|
+
}), d.summary === void 0 || comparison ? null : /* @__PURE__ */ jsx(Value, {
|
|
62
|
+
summary: d.summary,
|
|
63
|
+
parent: parentText(parent, title, (c) => crumbText(c, format, zone)),
|
|
64
|
+
onRefresh: d.retry
|
|
65
|
+
})] });
|
|
66
|
+
}
|
|
67
|
+
const explicitRecords = (d) => d.state?.view?.by === "items";
|
|
35
68
|
function Panel({ d, ...props }) {
|
|
36
69
|
const format = useDashboards();
|
|
70
|
+
const title = props.title ?? format.messages.drillTitle;
|
|
71
|
+
const landmark = usePanelLandmark(title);
|
|
37
72
|
const panel = useRef(null);
|
|
38
|
-
useFocusReturn(panel, widgetOf(d.state));
|
|
39
|
-
const
|
|
73
|
+
useFocusReturn(panel, widgetOf(d.state), landmark.role === "presentation");
|
|
74
|
+
const comparison = isComparison(d);
|
|
75
|
+
const wide = comparison || showsFields(d.state);
|
|
76
|
+
const [peek, expand] = usePeek(wide, explicitRecords(d));
|
|
40
77
|
if (d.state === void 0) return null;
|
|
41
|
-
const title = props.title ?? format.messages.drillTitle;
|
|
42
78
|
const close = props.onClose ?? d.close;
|
|
43
|
-
const zone = d.summary?.receipt.calendar.timezone;
|
|
44
|
-
const parent = d.path.at(-2);
|
|
45
79
|
return /* @__PURE__ */ jsxs("aside", {
|
|
46
80
|
ref: panel,
|
|
47
81
|
className: "dd-panel dd-drill",
|
|
48
|
-
|
|
82
|
+
...landmark,
|
|
49
83
|
"data-peek": peek,
|
|
84
|
+
"data-wide": wide || void 0,
|
|
50
85
|
onKeyDown: (event) => {
|
|
51
86
|
closeOnEscape(event, close);
|
|
52
87
|
},
|
|
53
|
-
children: [
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
timeZone: zone,
|
|
64
|
-
onGoTo: d.goTo
|
|
65
|
-
}),
|
|
66
|
-
d.summary === void 0 ? null : /* @__PURE__ */ jsx(Value, {
|
|
67
|
-
summary: d.summary,
|
|
68
|
-
parent: parentText(parent, title, (c) => crumbText(c, format, zone)),
|
|
69
|
-
onRefresh: d.retry
|
|
70
|
-
}),
|
|
71
|
-
peek ? /* @__PURE__ */ jsx(SeeRows, {
|
|
88
|
+
children: [/* @__PURE__ */ jsx(PanelHead, {
|
|
89
|
+
d,
|
|
90
|
+
title,
|
|
91
|
+
close
|
|
92
|
+
}), peek ? /* @__PURE__ */ jsx(SeeRows, {
|
|
93
|
+
d,
|
|
94
|
+
onExpand: expand
|
|
95
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
96
|
+
comparison ? null : /* @__PURE__ */ jsx(Tabs, { d }),
|
|
97
|
+
/* @__PURE__ */ jsx(Main, {
|
|
72
98
|
d,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
props.actions === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
82
|
-
className: "dd-panel-foot",
|
|
83
|
-
children: props.actions
|
|
84
|
-
})
|
|
85
|
-
] })
|
|
86
|
-
]
|
|
99
|
+
props,
|
|
100
|
+
close
|
|
101
|
+
}),
|
|
102
|
+
props.actions === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
103
|
+
className: "dd-panel-foot",
|
|
104
|
+
children: props.actions
|
|
105
|
+
})
|
|
106
|
+
] })]
|
|
87
107
|
});
|
|
88
108
|
}
|
|
89
109
|
/**
|
|
@@ -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. */
|