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,116 @@
|
|
|
1
|
+
import { useId, useState } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/reader-page.tsx
|
|
4
|
+
const ENGLISH = {
|
|
5
|
+
previous: "Previous page",
|
|
6
|
+
next: "Next page",
|
|
7
|
+
range: (first, last, total, axis) => `${axis === "rows" ? "Rows" : "Columns"} ${String(first)}–${String(last)} of ${String(total)}`
|
|
8
|
+
};
|
|
9
|
+
/** Bound the mounted cells in both directions. Each page is a rectangle of the original table. */
|
|
10
|
+
const CELLS = 512;
|
|
11
|
+
const WIDE = 32;
|
|
12
|
+
const TALL = 100;
|
|
13
|
+
function windowOf(data, chosen) {
|
|
14
|
+
const width = Math.max(1, Math.min(WIDE, data.columns.length));
|
|
15
|
+
const height = Math.min(TALL, Math.floor(CELLS / width));
|
|
16
|
+
const across = Math.max(1, Math.ceil(data.columns.length / width));
|
|
17
|
+
const pages = across * Math.ceil(data.rows.length / height);
|
|
18
|
+
const page = Math.max(0, Math.min(chosen, pages - 1));
|
|
19
|
+
const left = page % across * width;
|
|
20
|
+
const top = Math.floor(page / across) * height;
|
|
21
|
+
return {
|
|
22
|
+
page,
|
|
23
|
+
pages,
|
|
24
|
+
left,
|
|
25
|
+
top,
|
|
26
|
+
across,
|
|
27
|
+
rows: data.rows.slice(top, top + height),
|
|
28
|
+
columns: data.columns.slice(left, left + width)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
function Grid({ view, caption, noValue, id, heading }) {
|
|
32
|
+
return /* @__PURE__ */ jsxs("table", {
|
|
33
|
+
id,
|
|
34
|
+
children: [
|
|
35
|
+
caption === void 0 ? null : /* @__PURE__ */ jsx("caption", { children: caption }),
|
|
36
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("td", { children: heading }), view.columns.map((column) => /* @__PURE__ */ jsx("th", {
|
|
37
|
+
scope: "col",
|
|
38
|
+
children: column.label
|
|
39
|
+
}, column.key))] }) }),
|
|
40
|
+
/* @__PURE__ */ jsx("tbody", { children: view.rows.map((row) => /* @__PURE__ */ jsxs("tr", { children: [/* @__PURE__ */ jsx("th", {
|
|
41
|
+
scope: "row",
|
|
42
|
+
children: row.label
|
|
43
|
+
}), view.columns.map((column, i) => /* @__PURE__ */ jsx("td", { children: row.cells[view.left + i] ?? noValue }, column.key))] }, row.key)) })
|
|
44
|
+
]
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function pageLabel(view, data, words) {
|
|
48
|
+
return [words.range(view.top + 1, view.top + view.rows.length, data.rows.length, "rows"), ...view.across === 1 ? [] : [words.range(view.left + 1, view.left + view.columns.length, data.columns.length, "columns")]].join(". ");
|
|
49
|
+
}
|
|
50
|
+
function PageControls({ view, data, words, choose, focus, id }) {
|
|
51
|
+
if (view.pages <= 1) return null;
|
|
52
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
53
|
+
/* @__PURE__ */ jsx("span", {
|
|
54
|
+
"aria-live": "polite",
|
|
55
|
+
children: pageLabel(view, data, words)
|
|
56
|
+
}),
|
|
57
|
+
" ",
|
|
58
|
+
[[-1, words.previous], [1, words.next]].map(([step, text]) => {
|
|
59
|
+
const target = view.page + step;
|
|
60
|
+
const disabled = target < 0 || target >= view.pages;
|
|
61
|
+
return /* @__PURE__ */ jsx("button", {
|
|
62
|
+
type: "button",
|
|
63
|
+
"aria-controls": id,
|
|
64
|
+
"aria-disabled": disabled,
|
|
65
|
+
onFocus: () => {
|
|
66
|
+
focus(true);
|
|
67
|
+
},
|
|
68
|
+
onBlur: () => {
|
|
69
|
+
focus(false);
|
|
70
|
+
},
|
|
71
|
+
onKeyDown: (event) => {
|
|
72
|
+
event.stopPropagation();
|
|
73
|
+
},
|
|
74
|
+
onClick: () => {
|
|
75
|
+
if (!disabled) choose(target);
|
|
76
|
+
},
|
|
77
|
+
children: text
|
|
78
|
+
}, step);
|
|
79
|
+
})
|
|
80
|
+
] });
|
|
81
|
+
}
|
|
82
|
+
function ReaderPage({ data, caption, noValue, words = ENGLISH, hidden }) {
|
|
83
|
+
const [chosen, choose] = useState(0);
|
|
84
|
+
const [focused, focus] = useState(false);
|
|
85
|
+
const id = useId();
|
|
86
|
+
const view = windowOf(data, chosen);
|
|
87
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
88
|
+
className: focused ? "dd-c-reader-open" : "dd-sr-only",
|
|
89
|
+
style: focused ? openStyle : hidden,
|
|
90
|
+
children: [/* @__PURE__ */ jsx(PageControls, {
|
|
91
|
+
view,
|
|
92
|
+
data,
|
|
93
|
+
words,
|
|
94
|
+
choose,
|
|
95
|
+
focus,
|
|
96
|
+
id
|
|
97
|
+
}), /* @__PURE__ */ jsx(Grid, {
|
|
98
|
+
view,
|
|
99
|
+
caption,
|
|
100
|
+
noValue,
|
|
101
|
+
heading: data.heading,
|
|
102
|
+
id
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/** Keyboard focus reveals the same controls and cells to a sighted reader, even without theme.css. */
|
|
107
|
+
const openStyle = {
|
|
108
|
+
position: "absolute",
|
|
109
|
+
inset: 0,
|
|
110
|
+
zIndex: 2,
|
|
111
|
+
overflow: "auto",
|
|
112
|
+
padding: 8,
|
|
113
|
+
background: "var(--dd-surface, Canvas)",
|
|
114
|
+
color: "var(--dd-ink, CanvasText)"
|
|
115
|
+
};
|
|
116
|
+
export { ReaderPage };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import "./plan.mjs";
|
|
2
|
+
import { HoverItem, HoverStop, Words } from "derive-dashboards/charts";
|
|
3
|
+
import { TileRendererProps } from "derive-dashboards/react";
|
|
4
|
+
/** Values over time as lines; by category, bars in the answer's order. */
|
|
5
|
+
export declare const LineTile: (props: TileRendererProps) => import("react").JSX.Element;
|
|
6
|
+
/** Values over time as columns; by category, ranked bars, each with a tick where the widget names what it is read against. */
|
|
7
|
+
export declare const BarTile: (props: TileRendererProps) => import("react").JSX.Element;
|
|
8
|
+
/** Values over time as a stacked area where they add up, lines where they do not; by category, bars. */
|
|
9
|
+
export declare const AreaTile: (props: TileRendererProps) => import("react").JSX.Element;
|
|
10
|
+
/** A small chart for each series over time, on one scale; by category, bars. */
|
|
11
|
+
export declare const MultiplesTile: (props: TileRendererProps) => import("react").JSX.Element;
|
|
12
|
+
/** One value by two fields, each cell shaded by its value. */
|
|
13
|
+
export declare const HeatmapTile: (props: TileRendererProps) => import("react").JSX.Element;
|
|
14
|
+
/** Steps in order, each read against the first and the one before it. */
|
|
15
|
+
export declare const FunnelTile: (props: TileRendererProps) => import("react").JSX.Element;
|
|
16
|
+
/** The tiles drawn by the charts package: `<DashboardsProvider renderers={CHARTS_RENDERERS}>`. */
|
|
17
|
+
export declare const CHARTS_RENDERERS: {
|
|
18
|
+
line: (props: TileRendererProps) => import("react").JSX.Element;
|
|
19
|
+
bar: (props: TileRendererProps) => import("react").JSX.Element;
|
|
20
|
+
area: (props: TileRendererProps) => import("react").JSX.Element;
|
|
21
|
+
multiples: (props: TileRendererProps) => import("react").JSX.Element;
|
|
22
|
+
heatmap: (props: TileRendererProps) => import("react").JSX.Element;
|
|
23
|
+
funnel: (props: TileRendererProps) => import("react").JSX.Element;
|
|
24
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Chart } from "./Chart.mjs";
|
|
2
|
+
import { planOf, rowOf } from "./plan.mjs";
|
|
3
|
+
import { itemText } from "./Reader.mjs";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
import { ENGLISH } from "derive-dashboards/charts";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { sharedDisplay } from "derive-dashboards/core";
|
|
8
|
+
import { ENGLISH as ENGLISH$1 } from "derive-dashboards/react";
|
|
9
|
+
// src/tiles.tsx
|
|
10
|
+
/**
|
|
11
|
+
* A click or Enter opens the row behind the value chosen, when values stand for rows and the
|
|
12
|
+
* drill opens that row (`drill.props` says only whether it does). A screen reader hears a value
|
|
13
|
+
* that opens in the chart's own words, as the tooltip and the table say it, wrapped in the
|
|
14
|
+
* dashboards' word for a mark that opens (`drillMark`): "Tasks 6. Open what is behind it." Not
|
|
15
|
+
* the drill mark's own name, which the dashboards build from the row's raw cells (an hour as
|
|
16
|
+
* its instant). The stop's title is not in it: the live region says the title when a key moves
|
|
17
|
+
* to the stop, and a key that moves between a stop's values says the value alone, whether or
|
|
18
|
+
* not it opens.
|
|
19
|
+
*/
|
|
20
|
+
function selectOf(props, plan) {
|
|
21
|
+
const { drill, messages } = props;
|
|
22
|
+
if (drill === void 0 || plan.seriesOf === void 0) return {};
|
|
23
|
+
const opened = (stop, item) => {
|
|
24
|
+
const at = rowOf(plan, stop, item);
|
|
25
|
+
const entry = at?.series.column.id;
|
|
26
|
+
const mark = at === void 0 ? void 0 : drill.props(at.row, entry);
|
|
27
|
+
return at === void 0 || mark === void 0 ? void 0 : {
|
|
28
|
+
row: at.row,
|
|
29
|
+
entry
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
hint: messages.drillHint,
|
|
34
|
+
instruction: messages.chartPoints,
|
|
35
|
+
selectable: (stop, item) => opened(stop, item) !== void 0,
|
|
36
|
+
spoken: (stop, item) => opened(stop, item) === void 0 ? void 0 : messages.drillMark(itemText(item)),
|
|
37
|
+
onSelect: (stop, item) => {
|
|
38
|
+
const at = opened(stop, item);
|
|
39
|
+
if (at !== void 0) drill.open(at.row, at.entry);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** Wording for marks and tooltips. Hosts can translate notes about partial and merged periods. */
|
|
44
|
+
const chartWords = (messages) => ({
|
|
45
|
+
soFar: messages.soFar,
|
|
46
|
+
before: ENGLISH.before,
|
|
47
|
+
versus: ENGLISH.versus,
|
|
48
|
+
partial: messages.chartPartial ?? ENGLISH.partial,
|
|
49
|
+
averaged: messages.chartAveraged ?? ENGLISH.averaged,
|
|
50
|
+
merged: messages.chartMerged ?? ENGLISH.merged,
|
|
51
|
+
more: messages.moreRows,
|
|
52
|
+
funnel: messages.chartFunnel ?? ENGLISH.funnel,
|
|
53
|
+
waterfall: ENGLISH.waterfall,
|
|
54
|
+
histogram: ENGLISH.histogram
|
|
55
|
+
});
|
|
56
|
+
/**
|
|
57
|
+
* A tile's chart, filling its box, with what it does not draw named under the picture, inside
|
|
58
|
+
* the chart's box. The chart lays the picture over the note inline, so it holds without any
|
|
59
|
+
* stylesheet; its look (the tooltip, the focus ring) is in `chart.css`, and its reader table stays out of layout even without the theme.
|
|
60
|
+
*/
|
|
61
|
+
function Tile({ props, kind }) {
|
|
62
|
+
const { answer, slots, locale, messages, widget } = props;
|
|
63
|
+
const plan = useMemo(() => planOf({
|
|
64
|
+
answer,
|
|
65
|
+
messages,
|
|
66
|
+
widget,
|
|
67
|
+
...slots === void 0 ? {} : { slots },
|
|
68
|
+
...locale === void 0 ? {} : { locale }
|
|
69
|
+
}, kind), [
|
|
70
|
+
answer,
|
|
71
|
+
slots,
|
|
72
|
+
locale,
|
|
73
|
+
messages,
|
|
74
|
+
widget,
|
|
75
|
+
kind
|
|
76
|
+
]);
|
|
77
|
+
const words = useMemo(() => chartWords(messages), [messages]);
|
|
78
|
+
const note = plan === void 0 || plan.notDrawn.length === 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
79
|
+
className: "dd-chart-note",
|
|
80
|
+
children: messages.notDrawn(plan.notDrawn)
|
|
81
|
+
});
|
|
82
|
+
if (plan === void 0 || plan.empty) return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
|
|
83
|
+
className: "dd-tile-state",
|
|
84
|
+
children: sharedDisplay(widget.display).empty ?? messages.noData
|
|
85
|
+
}), note] });
|
|
86
|
+
return /* @__PURE__ */ jsx(Chart, {
|
|
87
|
+
draw: plan.draw,
|
|
88
|
+
markKeys: false,
|
|
89
|
+
...messages.chartTablePages === void 0 ? {} : { tablePages: messages.chartTablePages },
|
|
90
|
+
noPlot: messages.chartTooSmall ?? ENGLISH$1.chartTooSmall,
|
|
91
|
+
words,
|
|
92
|
+
caption: messages.chartTable({
|
|
93
|
+
title: widget.title,
|
|
94
|
+
kind: plan.drew,
|
|
95
|
+
points: plan.points
|
|
96
|
+
}),
|
|
97
|
+
noValue: messages.noValue,
|
|
98
|
+
...locale === void 0 ? {} : { locale },
|
|
99
|
+
...selectOf(props, plan),
|
|
100
|
+
children: note
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/** Values over time as lines; by category, bars in the answer's order. */
|
|
104
|
+
const LineTile = (props) => /* @__PURE__ */ jsx(Tile, {
|
|
105
|
+
props,
|
|
106
|
+
kind: "line"
|
|
107
|
+
});
|
|
108
|
+
/** Values over time as columns; by category, ranked bars, each with a tick where the widget names what it is read against. */
|
|
109
|
+
const BarTile = (props) => /* @__PURE__ */ jsx(Tile, {
|
|
110
|
+
props,
|
|
111
|
+
kind: "bar"
|
|
112
|
+
});
|
|
113
|
+
/** Values over time as a stacked area where they add up, lines where they do not; by category, bars. */
|
|
114
|
+
const AreaTile = (props) => /* @__PURE__ */ jsx(Tile, {
|
|
115
|
+
props,
|
|
116
|
+
kind: "area"
|
|
117
|
+
});
|
|
118
|
+
/** A small chart for each series over time, on one scale; by category, bars. */
|
|
119
|
+
const MultiplesTile = (props) => /* @__PURE__ */ jsx(Tile, {
|
|
120
|
+
props,
|
|
121
|
+
kind: "multiples"
|
|
122
|
+
});
|
|
123
|
+
/** One value by two fields, each cell shaded by its value. */
|
|
124
|
+
const HeatmapTile = (props) => /* @__PURE__ */ jsx(Tile, {
|
|
125
|
+
props,
|
|
126
|
+
kind: "heatmap"
|
|
127
|
+
});
|
|
128
|
+
/** Steps in order, each read against the first and the one before it. */
|
|
129
|
+
const FunnelTile = (props) => /* @__PURE__ */ jsx(Tile, {
|
|
130
|
+
props,
|
|
131
|
+
kind: "funnel"
|
|
132
|
+
});
|
|
133
|
+
/** The tiles drawn by the charts package: `<DashboardsProvider renderers={CHARTS_RENDERERS}>`. */
|
|
134
|
+
const CHARTS_RENDERERS = {
|
|
135
|
+
line: LineTile,
|
|
136
|
+
bar: BarTile,
|
|
137
|
+
area: AreaTile,
|
|
138
|
+
multiples: MultiplesTile,
|
|
139
|
+
heatmap: HeatmapTile,
|
|
140
|
+
funnel: FunnelTile
|
|
141
|
+
};
|
|
142
|
+
export { AreaTile, BarTile, CHARTS_RENDERERS, FunnelTile, HeatmapTile, LineTile, MultiplesTile, chartWords, selectOf };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/tip-place.ts
|
|
2
|
+
/** Each row's band and reach, as the scene's stops carry them. */
|
|
3
|
+
const rowReaches = (hover) => hover.stops.flatMap(({ band, end }) => band === void 0 || end === void 0 ? [] : [{
|
|
4
|
+
top: band.y,
|
|
5
|
+
bottom: band.y + band.height,
|
|
6
|
+
end
|
|
7
|
+
}]);
|
|
8
|
+
/**
|
|
9
|
+
* Where a stop's tooltip is anchored. A ranked bar's is at the pointer on its row (past the
|
|
10
|
+
* row's reach for the keyboard), placed clear of every row's reach; any other beside the stop,
|
|
11
|
+
* level with its dots.
|
|
12
|
+
*/
|
|
13
|
+
function anchorOf(hover, stop, pointer) {
|
|
14
|
+
const ys = stop.items.map((item) => item.y);
|
|
15
|
+
const y = ys.length === 0 ? stop.y : (Math.min(...ys) + Math.max(...ys)) / 2;
|
|
16
|
+
if (hover.snap !== "y" || stop.band === void 0) return {
|
|
17
|
+
x: stop.x,
|
|
18
|
+
y
|
|
19
|
+
};
|
|
20
|
+
const { band } = stop;
|
|
21
|
+
return {
|
|
22
|
+
x: pointer?.x ?? stop.end ?? stop.x,
|
|
23
|
+
y,
|
|
24
|
+
row: {
|
|
25
|
+
top: band.y,
|
|
26
|
+
bottom: band.y + band.height
|
|
27
|
+
},
|
|
28
|
+
rows: rowReaches(hover)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** The room between a stop and its tooltip, in pixels. */
|
|
32
|
+
const GAP = 20;
|
|
33
|
+
/** The room between a row and the tooltip over or under it. */
|
|
34
|
+
const UNDER = 10;
|
|
35
|
+
/** A number kept between two ends; the low end wins when they cross. */
|
|
36
|
+
const within = (value, low, high) => Math.max(low, Math.min(value, high));
|
|
37
|
+
/** Beside the anchor: to its right, or to its left when it would cross the right edge. */
|
|
38
|
+
function beside(anchor, tip, box) {
|
|
39
|
+
const top = anchor.y - tip.height / 2;
|
|
40
|
+
const right = anchor.x + GAP;
|
|
41
|
+
if (right + tip.width <= box.width) return {
|
|
42
|
+
left: right,
|
|
43
|
+
top
|
|
44
|
+
};
|
|
45
|
+
const left = anchor.x - tip.width - GAP;
|
|
46
|
+
if (left >= 0) return {
|
|
47
|
+
left,
|
|
48
|
+
top
|
|
49
|
+
};
|
|
50
|
+
const above = anchor.y - tip.height - UNDER;
|
|
51
|
+
return {
|
|
52
|
+
left: anchor.x - tip.width / 2,
|
|
53
|
+
top: above >= 0 ? above : anchor.y + UNDER
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/** The tops a tooltip on a row's line may take: centred on it, hanging from it, standing on it. */
|
|
57
|
+
const linesOf = (anchor, row, tip) => [
|
|
58
|
+
anchor.y - tip.height / 2,
|
|
59
|
+
row.top,
|
|
60
|
+
row.bottom - tip.height
|
|
61
|
+
];
|
|
62
|
+
/**
|
|
63
|
+
* On the row's own line, clear of the pointer and the reach of every row it lies over;
|
|
64
|
+
* null when the box has no room there. Centred on the row first; else hanging down from
|
|
65
|
+
* it or standing up on it, whichever passes the shorter bars beside it.
|
|
66
|
+
*/
|
|
67
|
+
function onLine(anchor, row, tip, box) {
|
|
68
|
+
const rows = anchor.rows ?? [{
|
|
69
|
+
...row,
|
|
70
|
+
end: anchor.x
|
|
71
|
+
}];
|
|
72
|
+
const high = box.width - tip.width;
|
|
73
|
+
for (const wanted of linesOf(anchor, row, tip)) {
|
|
74
|
+
const top = within(wanted, 0, box.height - tip.height);
|
|
75
|
+
const over = rows.filter((r) => r.bottom > top && r.top < top + tip.height);
|
|
76
|
+
const low = Math.max(0, ...over.map((r) => r.end)) + GAP;
|
|
77
|
+
const right = Math.max(low, anchor.x + GAP);
|
|
78
|
+
if (right <= high) return {
|
|
79
|
+
left: right,
|
|
80
|
+
top
|
|
81
|
+
};
|
|
82
|
+
const left = Math.min(high, anchor.x - GAP - tip.width);
|
|
83
|
+
if (left >= low) return {
|
|
84
|
+
left,
|
|
85
|
+
top
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
/** Over the row, or under it when there is no room over it; centred on the anchor. */
|
|
91
|
+
function offRow(row, anchor, tip) {
|
|
92
|
+
const over = row.top - UNDER - tip.height;
|
|
93
|
+
return {
|
|
94
|
+
left: anchor.x - tip.width / 2,
|
|
95
|
+
top: over >= 0 ? over : row.bottom + UNDER
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/** The tooltip's top-left corner, beside its stop or off its row, never outside the chart's box. */
|
|
99
|
+
function tipPlace(anchor, tip, box) {
|
|
100
|
+
const { row } = anchor;
|
|
101
|
+
const wanted = row === void 0 ? beside(anchor, tip, box) : onLine(anchor, row, tip, box) ?? offRow(row, anchor, tip);
|
|
102
|
+
return {
|
|
103
|
+
left: within(wanted.left, 0, box.width - tip.width),
|
|
104
|
+
top: within(wanted.top, 0, box.height - tip.height)
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
export { anchorOf, tipPlace };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/tip-room.ts
|
|
2
|
+
/**
|
|
3
|
+
* The run of a stop's `count` values a tooltip with room for `rows` of them holds: the chosen
|
|
4
|
+
* one in its middle, as far as the ends allow.
|
|
5
|
+
*/
|
|
6
|
+
function heldOf(count, rows, chosen = 0) {
|
|
7
|
+
const size = Math.min(count, rows);
|
|
8
|
+
const from = Math.max(0, Math.min(chosen - Math.floor(size / 2), count - size));
|
|
9
|
+
return {
|
|
10
|
+
from,
|
|
11
|
+
to: from + size
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* How many values a tooltip drawn taller than its box has room for: fewer than it holds by the
|
|
16
|
+
* lines it is over, and by one more for the line that counts the values left out, when it has
|
|
17
|
+
* none yet. Never fewer than one. Undefined for a tooltip that fits, or one with no second
|
|
18
|
+
* value to give up.
|
|
19
|
+
*/
|
|
20
|
+
function roomFor(tip, height) {
|
|
21
|
+
const labels = [...tip.querySelectorAll(".dd-c-tip-label")];
|
|
22
|
+
const [first] = labels;
|
|
23
|
+
const last = labels.at(-1);
|
|
24
|
+
const over = Math.max(tip.offsetHeight, tip.scrollHeight + tip.offsetHeight - tip.clientHeight) - height;
|
|
25
|
+
if (over <= 0 || first === void 0 || last === void 0 || labels.length < 2) return void 0;
|
|
26
|
+
const pitch = (last.offsetTop - first.offsetTop) / (labels.length - 1);
|
|
27
|
+
if (pitch <= 0) return void 0;
|
|
28
|
+
const counting = tip.querySelector(".dd-c-tip-more") === null ? 1 : 0;
|
|
29
|
+
return Math.max(1, labels.length - Math.ceil(over / pitch) - counting);
|
|
30
|
+
}
|
|
31
|
+
export { heldOf, roomFor };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useEffect, useLayoutEffect } from "react";
|
|
2
|
+
// src/useClientLayoutEffect.ts
|
|
3
|
+
/**
|
|
4
|
+
* A layout effect in a browser, a plain effect on a server: a server runs neither, but React 18
|
|
5
|
+
* warns of a layout effect there. Chosen once, as a page is either one or the other.
|
|
6
|
+
*/
|
|
7
|
+
const useClientLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
|
|
8
|
+
export { useClientLayoutEffect };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { useId, useMemo, useState, useSyncExternalStore } from "react";
|
|
2
|
+
import { renderSvg, tableMeasure } from "derive-dashboards/charts";
|
|
3
|
+
// src/useScene.ts
|
|
4
|
+
/** The scene for a size, none for no size; made again only when the size, `draw` or how text is read changes. */
|
|
5
|
+
function useDrawn(props, size) {
|
|
6
|
+
const { draw, measure = tableMeasure, locale, words } = props;
|
|
7
|
+
const width = size?.width;
|
|
8
|
+
const height = size?.height;
|
|
9
|
+
return useMemo(() => width === void 0 || height === void 0 ? void 0 : draw({
|
|
10
|
+
width,
|
|
11
|
+
height,
|
|
12
|
+
measure,
|
|
13
|
+
...locale === void 0 ? {} : { locale },
|
|
14
|
+
...words === void 0 ? {} : { words }
|
|
15
|
+
}), [
|
|
16
|
+
draw,
|
|
17
|
+
width,
|
|
18
|
+
height,
|
|
19
|
+
measure,
|
|
20
|
+
locale,
|
|
21
|
+
words
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
/** The room a chart's words are written for where its box is not measured yet: a usual tile's. */
|
|
25
|
+
const USUAL = {
|
|
26
|
+
width: 640,
|
|
27
|
+
height: 360
|
|
28
|
+
};
|
|
29
|
+
/** Nothing to listen to, and so nothing to stop listening to: where a chart was first rendered never changes. */
|
|
30
|
+
const unheard = () => {};
|
|
31
|
+
const never = () => unheard;
|
|
32
|
+
const inBrowser = () => false;
|
|
33
|
+
const onServer = () => true;
|
|
34
|
+
/**
|
|
35
|
+
* Whether this chart was first rendered on a server, or in a browser over a server's markup,
|
|
36
|
+
* which must match it. React says so by which snapshot it reads; kept as it was first read.
|
|
37
|
+
*/
|
|
38
|
+
function useServerMarkup() {
|
|
39
|
+
const now = useSyncExternalStore(never, inBrowser, onServer);
|
|
40
|
+
const [first] = useState(now);
|
|
41
|
+
return first;
|
|
42
|
+
}
|
|
43
|
+
const positiveOr = (value, fallback) => value !== void 0 && value > 0 ? value : fallback;
|
|
44
|
+
/**
|
|
45
|
+
* A chart's scene for its size, and the scene whose words it says: its own, or before its box
|
|
46
|
+
* is measured, on a server and over a server's markup, one laid out only to be read.
|
|
47
|
+
*/
|
|
48
|
+
function useScenes(props, size) {
|
|
49
|
+
const collapsed = size !== void 0 && (size.width <= 0 || size.height <= 0);
|
|
50
|
+
const scene = useDrawn(props, collapsed ? void 0 : size);
|
|
51
|
+
const served = useServerMarkup();
|
|
52
|
+
const unread = scene === void 0 && (served || collapsed);
|
|
53
|
+
const width = positiveOr(props.width, USUAL.width);
|
|
54
|
+
const height = positiveOr(props.height, USUAL.height);
|
|
55
|
+
const read = useDrawn(props, unread ? {
|
|
56
|
+
width,
|
|
57
|
+
height
|
|
58
|
+
} : void 0);
|
|
59
|
+
return {
|
|
60
|
+
scene,
|
|
61
|
+
said: scene ?? read
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
/** The picture as SVG text, its ids named under this chart's own, so two never share one. */
|
|
65
|
+
function usePicture(scene, markKeys) {
|
|
66
|
+
const id = `dd${useId().replaceAll(/[^\w-]/gu, "")}`;
|
|
67
|
+
return useMemo(() => scene === void 0 ? "" : renderSvg(scene, {
|
|
68
|
+
id,
|
|
69
|
+
markKeys
|
|
70
|
+
}), [
|
|
71
|
+
scene,
|
|
72
|
+
id,
|
|
73
|
+
markKeys
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
76
|
+
export { usePicture, useScenes };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useClientLayoutEffect } from "./useClientLayoutEffect.mjs";
|
|
2
|
+
import { startTransition, useState } from "react";
|
|
3
|
+
// src/useSize.ts
|
|
4
|
+
const SETTLE_MS = 120;
|
|
5
|
+
/** A box's size: as given, else as measured, rounded down to whole pixels. */
|
|
6
|
+
function useSize(ref, given) {
|
|
7
|
+
const [measured, setMeasured] = useState({});
|
|
8
|
+
const fixed = given.width !== void 0 && given.height !== void 0;
|
|
9
|
+
useClientLayoutEffect(() => {
|
|
10
|
+
const element = ref.current;
|
|
11
|
+
if (fixed || element === null || typeof ResizeObserver === "undefined") return;
|
|
12
|
+
let timer;
|
|
13
|
+
let last;
|
|
14
|
+
const observer = new ResizeObserver(([entry]) => {
|
|
15
|
+
if (entry === void 0) return;
|
|
16
|
+
const { width, height } = entry.contentRect;
|
|
17
|
+
const size = {
|
|
18
|
+
width: Math.floor(width),
|
|
19
|
+
height: Math.floor(height)
|
|
20
|
+
};
|
|
21
|
+
if (last?.width === size.width && last.height === size.height) return;
|
|
22
|
+
clearTimeout(timer);
|
|
23
|
+
if (last === void 0 || Math.min(last.width, last.height, size.width, size.height) <= 0) setMeasured(size);
|
|
24
|
+
else timer = setTimeout(() => {
|
|
25
|
+
startTransition(() => {
|
|
26
|
+
setMeasured(size);
|
|
27
|
+
});
|
|
28
|
+
}, SETTLE_MS);
|
|
29
|
+
last = size;
|
|
30
|
+
});
|
|
31
|
+
observer.observe(element);
|
|
32
|
+
return () => {
|
|
33
|
+
observer.disconnect();
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
};
|
|
36
|
+
}, [ref, fixed]);
|
|
37
|
+
const width = given.width ?? measured.width;
|
|
38
|
+
const height = given.height ?? measured.height;
|
|
39
|
+
return width === void 0 || height === void 0 ? void 0 : {
|
|
40
|
+
width,
|
|
41
|
+
height
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export { useSize };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
// src/useStop.ts
|
|
3
|
+
const same = (a, b) => a !== void 0 && a.scene === b.scene && a.index === b.index && a.via === b.via && a.item === b.item && a.moved === b.moved && a.at?.x === b.at?.x;
|
|
4
|
+
/** Whether `onHover` was last told this place on this scene, or nothing when nothing is lit. */
|
|
5
|
+
const toldOf = (was, index, scene) => was === void 0 ? index === void 0 : was.index === index && was.scene === scene;
|
|
6
|
+
/** The stop a chart has lit, how to light one, choose an item in it and clear it. */
|
|
7
|
+
function useStop(scene, onHover) {
|
|
8
|
+
const [held, setHeld] = useState();
|
|
9
|
+
const last = useRef(void 0);
|
|
10
|
+
const tell = (index) => {
|
|
11
|
+
if (toldOf(last.current, index, scene)) return;
|
|
12
|
+
onHover?.(index === void 0 ? void 0 : scene?.hover?.stops[index]);
|
|
13
|
+
};
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const was = last.current;
|
|
16
|
+
if (was === void 0 || was.scene === scene) return;
|
|
17
|
+
last.current = void 0;
|
|
18
|
+
setHeld(void 0);
|
|
19
|
+
onHover?.(void 0);
|
|
20
|
+
}, [scene, onHover]);
|
|
21
|
+
const hold = (next) => {
|
|
22
|
+
if (same(last.current, next)) return;
|
|
23
|
+
last.current = next;
|
|
24
|
+
setHeld(next);
|
|
25
|
+
};
|
|
26
|
+
const light = (index, via, near = {}) => {
|
|
27
|
+
tell(index);
|
|
28
|
+
hold({
|
|
29
|
+
index,
|
|
30
|
+
via,
|
|
31
|
+
at: near.at,
|
|
32
|
+
item: near.item ?? 0,
|
|
33
|
+
moved: "stop",
|
|
34
|
+
scene
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
const choose = (item) => {
|
|
38
|
+
const was = last.current;
|
|
39
|
+
if (was !== void 0 && was.scene === scene) hold({
|
|
40
|
+
index: was.index,
|
|
41
|
+
via: "key",
|
|
42
|
+
item,
|
|
43
|
+
moved: "item",
|
|
44
|
+
scene
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
const clear = () => {
|
|
48
|
+
tell();
|
|
49
|
+
if (last.current === void 0) return;
|
|
50
|
+
last.current = void 0;
|
|
51
|
+
setHeld(void 0);
|
|
52
|
+
};
|
|
53
|
+
const lit = held?.scene === scene ? held : void 0;
|
|
54
|
+
const stop = lit === void 0 ? void 0 : scene?.hover?.stops[lit.index];
|
|
55
|
+
const current = () => {
|
|
56
|
+
const was = last.current;
|
|
57
|
+
return was?.scene === scene ? was : void 0;
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
lit: stop === void 0 ? void 0 : lit,
|
|
61
|
+
stop,
|
|
62
|
+
light,
|
|
63
|
+
choose,
|
|
64
|
+
clear,
|
|
65
|
+
current
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export { useStop };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { storedExact } from "../../exact/decimal.mjs";
|
|
2
|
+
import { formatExact } from "../../exact/text.mjs";
|
|
2
3
|
import { canonical } from "../../value/canonical.mjs";
|
|
3
4
|
import { evalExpr, holds } from "./rows.mjs";
|
|
4
5
|
// src/conformance/memory/aggregate.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { datePart } from "../../oracle/expr.mjs";
|
|
2
2
|
import { evaluateLeaf } from "../../oracle/filter.mjs";
|
|
3
|
-
import { parseTextTime } from "../../time/
|
|
3
|
+
import { parseTextTime } from "../../time/text-time.mjs";
|
|
4
4
|
import { timeValue } from "../../time/stored.mjs";
|
|
5
5
|
import { fold } from "../../value/casefold.mjs";
|
|
6
6
|
// src/conformance/memory/rows.ts
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { parseExact } from "../../exact/
|
|
1
|
+
import { parseExact } from "../../exact/text.mjs";
|
|
2
2
|
import { bucketLabel } from "../../time/bucket.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { parseTextTime } from "../../time/text-time.mjs";
|
|
4
|
+
import { formatTextTime } from "../../time/instant.mjs";
|
|
4
5
|
import { canonical } from "../../value/canonical.mjs";
|
|
5
6
|
import { fold } from "../../value/casefold.mjs";
|
|
6
7
|
import { compareValues } from "../../value/compare.mjs";
|