derive-dashboards 0.8.0 → 0.10.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/CHANGELOG.md +534 -0
- package/README.md +8 -2
- package/dist/adapter/statement.mjs +9 -7
- package/dist/authorize.mjs +27 -6
- package/dist/body.mjs +28 -25
- package/dist/cache.d.mts +2 -2
- package/dist/charts/data/buckets.d.mts +25 -7
- package/dist/charts/data/buckets.mjs +92 -15
- package/dist/charts/data/clean.mjs +254 -12
- package/dist/charts/data/format.d.mts +7 -2
- package/dist/charts/data/format.mjs +68 -70
- package/dist/charts/data/input-error.d.mts +2 -0
- package/dist/charts/data/input-error.mjs +2 -0
- package/dist/charts/data/rows.d.mts +3 -1
- package/dist/charts/data/rows.mjs +4 -2
- package/dist/charts/data/types.d.mts +50 -7
- package/dist/charts/data/words.d.mts +13 -0
- package/dist/charts/data/words.mjs +8 -1
- package/dist/charts/describe.mjs +6 -6
- package/dist/charts/index.d.mts +14 -14
- package/dist/charts/index.mjs +4 -1
- package/dist/charts/kinds/area-marks.mjs +67 -26
- package/dist/charts/kinds/area.d.mts +3 -3
- package/dist/charts/kinds/area.mjs +32 -11
- package/dist/charts/kinds/bars-data.d.mts +3 -3
- package/dist/charts/kinds/bars-data.mjs +12 -6
- package/dist/charts/kinds/bars-layout.mjs +60 -6
- package/dist/charts/kinds/bars-marks.mjs +6 -6
- package/dist/charts/kinds/bars.d.mts +5 -3
- package/dist/charts/kinds/bars.mjs +39 -6
- package/dist/charts/kinds/columns-data.mjs +14 -5
- package/dist/charts/kinds/columns-marks.mjs +52 -23
- package/dist/charts/kinds/columns.d.mts +2 -2
- package/dist/charts/kinds/columns.mjs +36 -10
- package/dist/charts/kinds/course-data.mjs +44 -0
- package/dist/charts/kinds/course-layout.mjs +77 -0
- package/dist/charts/kinds/course-marks.mjs +52 -0
- package/dist/charts/kinds/course-words.mjs +64 -0
- package/dist/charts/kinds/course.d.mts +10 -0
- package/dist/charts/kinds/course.mjs +55 -0
- package/dist/charts/kinds/dumbbell-data.d.mts +4 -4
- package/dist/charts/kinds/dumbbell-data.mjs +3 -3
- package/dist/charts/kinds/dumbbell-layout.mjs +17 -8
- package/dist/charts/kinds/dumbbell.d.mts +5 -3
- package/dist/charts/kinds/dumbbell.mjs +35 -4
- package/dist/charts/kinds/funnel-data.d.mts +3 -3
- package/dist/charts/kinds/funnel-data.mjs +11 -16
- package/dist/charts/kinds/funnel-layout.mjs +7 -6
- package/dist/charts/kinds/funnel.d.mts +5 -4
- package/dist/charts/kinds/funnel.mjs +33 -6
- package/dist/charts/kinds/grid-data.d.mts +3 -3
- package/dist/charts/kinds/grid-data.mjs +55 -13
- package/dist/charts/kinds/grid-layout.mjs +88 -13
- package/dist/charts/kinds/grid-legend.mjs +60 -0
- package/dist/charts/kinds/grid-marks.mjs +81 -30
- package/dist/charts/kinds/grid-time.mjs +19 -5
- package/dist/charts/kinds/grid-words.mjs +57 -35
- package/dist/charts/kinds/grid.d.mts +7 -4
- package/dist/charts/kinds/grid.mjs +49 -8
- package/dist/charts/kinds/histogram-data.mjs +68 -26
- package/dist/charts/kinds/histogram-layout.mjs +4 -3
- package/dist/charts/kinds/histogram-words.mjs +2 -3
- package/dist/charts/kinds/histogram.d.mts +2 -2
- package/dist/charts/kinds/histogram.mjs +17 -1
- package/dist/charts/kinds/line-marks.mjs +19 -11
- package/dist/charts/kinds/line.d.mts +2 -2
- package/dist/charts/kinds/line.mjs +21 -3
- package/dist/charts/kinds/multiples-grid.mjs +57 -27
- package/dist/charts/kinds/multiples-head.mjs +52 -22
- package/dist/charts/kinds/multiples-layout.mjs +106 -52
- package/dist/charts/kinds/multiples-marks.mjs +6 -5
- package/dist/charts/kinds/multiples-words.mjs +53 -38
- package/dist/charts/kinds/multiples.d.mts +2 -2
- package/dist/charts/kinds/multiples.mjs +35 -7
- package/dist/charts/kinds/row-chart.d.mts +7 -0
- package/dist/charts/kinds/row-chart.mjs +47 -10
- package/dist/charts/kinds/row-marks.mjs +5 -5
- package/dist/charts/kinds/scatter-data.d.mts +5 -5
- package/dist/charts/kinds/scatter-data.mjs +6 -6
- package/dist/charts/kinds/scatter-marks.mjs +46 -19
- package/dist/charts/kinds/scatter-words.mjs +8 -8
- package/dist/charts/kinds/scatter.d.mts +5 -3
- package/dist/charts/kinds/scatter.mjs +18 -0
- package/dist/charts/kinds/stat-data.mjs +7 -7
- package/dist/charts/kinds/stat-marks.mjs +2 -2
- package/dist/charts/kinds/stat.d.mts +4 -4
- package/dist/charts/kinds/stat.mjs +19 -0
- package/dist/charts/kinds/time-chart.mjs +13 -4
- package/dist/charts/kinds/time-frame.mjs +50 -19
- package/dist/charts/kinds/time-plan.mjs +29 -2
- package/dist/charts/kinds/time-plot.mjs +1 -1
- package/dist/charts/kinds/time-stops.mjs +58 -29
- package/dist/charts/kinds/waterfall-data.d.mts +3 -3
- package/dist/charts/kinds/waterfall-data.mjs +2 -2
- package/dist/charts/kinds/waterfall.d.mts +5 -4
- package/dist/charts/kinds/waterfall.mjs +29 -2
- package/dist/charts/layout/frame.mjs +5 -3
- package/dist/charts/layout/stack.mjs +43 -22
- package/dist/charts/marks/axes.mjs +10 -5
- package/dist/charts/marks/budget.mjs +14 -0
- package/dist/charts/marks/end-labels.mjs +24 -10
- package/dist/charts/marks/legend.mjs +19 -8
- package/dist/charts/marks/lines.mjs +3 -3
- package/dist/charts/marks/more.mjs +79 -13
- package/dist/charts/marks/notes.mjs +12 -6
- package/dist/charts/marks/series-line.mjs +14 -10
- package/dist/charts/marks/thin.mjs +16 -33
- package/dist/charts/scale/calendar.mjs +41 -26
- package/dist/charts/scale/linear.mjs +58 -0
- package/dist/charts/scale/value.d.mts +21 -0
- package/dist/charts/scale/value.mjs +67 -9
- package/dist/charts/scene/lazy.mjs +27 -0
- package/dist/charts/scene/markup.mjs +2 -1
- package/dist/charts/scene/svg.mjs +20 -8
- package/dist/charts/scene/types.d.mts +34 -0
- package/dist/charts/text/measure.mjs +33 -3
- package/dist/charts/theme.mjs +13 -4
- package/dist/charts-react/Chart.d.mts +20 -0
- package/dist/charts-react/Chart.mjs +9 -67
- package/dist/charts-react/Reader.mjs +50 -96
- package/dist/charts-react/box.mjs +106 -0
- package/dist/charts-react/bucket-names.mjs +9 -24
- package/dist/charts-react/columns-picture.mjs +12 -0
- package/dist/charts-react/exact-sum.mjs +4 -7
- package/dist/charts-react/from-answer.mjs +9 -4
- package/dist/charts-react/index.d.mts +9 -2
- package/dist/charts-react/index.mjs +9 -2
- package/dist/charts-react/kinds/area.d.mts +4 -0
- package/dist/charts-react/kinds/area.mjs +38 -0
- package/dist/charts-react/kinds/bar.d.mts +4 -0
- package/dist/charts-react/kinds/bar.mjs +15 -0
- package/dist/charts-react/kinds/funnel.d.mts +4 -0
- package/dist/charts-react/kinds/funnel.mjs +13 -0
- package/dist/charts-react/kinds/heatmap.d.mts +4 -0
- package/dist/charts-react/kinds/heatmap.mjs +13 -0
- package/dist/charts-react/kinds/line.d.mts +4 -0
- package/dist/charts-react/kinds/line.mjs +20 -0
- package/dist/charts-react/kinds/multiples.d.mts +4 -0
- package/dist/charts-react/kinds/multiples.mjs +33 -0
- package/dist/charts-react/kinds/number.d.mts +5 -0
- package/dist/charts-react/kinds/number.mjs +86 -0
- package/dist/charts-react/plan-bars.mjs +15 -8
- package/dist/charts-react/plan-funnel.mjs +3 -1
- package/dist/charts-react/plan-grid.mjs +14 -5
- package/dist/charts-react/plan-of.mjs +17 -0
- package/dist/charts-react/plan-parts.mjs +16 -5
- package/dist/charts-react/plan-time.mjs +4 -53
- package/dist/charts-react/reader-page.d.mts +1 -1
- package/dist/charts-react/reader-page.mjs +19 -9
- package/dist/charts-react/renderers.d.mts +14 -0
- package/dist/charts-react/renderers.mjs +22 -0
- package/dist/charts-react/table.d.mts +1 -0
- package/dist/charts-react/table.mjs +108 -0
- package/dist/charts-react/tiles.mjs +21 -49
- package/dist/charts-react/useScene.mjs +45 -17
- package/dist/charts-react/words.mjs +19 -0
- package/dist/checks.mjs +97 -19
- package/dist/cli/add.mjs +4 -3
- package/dist/cli/doctor.mjs +2 -2
- package/dist/core/conformance/index.d.mts +5 -2
- package/dist/core/conformance/index.mjs +5 -2
- package/dist/core/conformance/memory/aggregate.mjs +11 -6
- package/dist/core/conformance/memory/rows.d.mts +7 -3
- package/dist/core/conformance/memory/rows.mjs +19 -13
- package/dist/core/conformance/memory/source.mjs +4 -4
- package/dist/core/document/control-fields.d.mts +20 -0
- package/dist/core/document/control-fields.mjs +117 -0
- package/dist/core/document/display-comparisons.d.mts +17 -0
- package/dist/core/document/display-comparisons.mjs +15 -4
- package/dist/core/document/display-entries.d.mts +14 -0
- package/dist/core/document/display-entries.mjs +25 -9
- package/dist/core/document/display-validation.d.mts +5 -1
- package/dist/core/document/display-validation.mjs +14 -7
- package/dist/core/document/display.d.mts +12 -10
- package/dist/core/document/display.mjs +32 -6
- package/dist/core/document/layout.d.mts +8 -9
- package/dist/core/document/layout.mjs +23 -6
- package/dist/core/document/stacked.d.mts +0 -7
- package/dist/core/document/types.mjs +8 -6
- package/dist/core/document/upgrade.d.mts +1 -0
- package/dist/core/document/upgrade.mjs +4 -2
- package/dist/core/engine/access.mjs +3 -3
- package/dist/core/engine/assert.mjs +4 -2
- package/dist/core/engine/bucket.mjs +2 -2
- package/dist/core/engine/checks.mjs +6 -7
- package/dist/core/engine/custom/ask.mjs +22 -2
- package/dist/core/engine/custom/cells.mjs +22 -22
- package/dist/core/engine/custom/level.mjs +12 -13
- package/dist/core/engine/custom/measures.mjs +12 -9
- package/dist/core/engine/custom/reader.mjs +3 -1
- package/dist/core/engine/custom/records.mjs +8 -7
- package/dist/core/engine/custom/unread.mjs +78 -0
- package/dist/core/engine/custom/where.mjs +15 -10
- package/dist/core/engine/index.d.mts +2 -13
- package/dist/core/engine/index.mjs +2 -12
- package/dist/core/engine/measure.mjs +1 -0
- package/dist/core/engine/members.mjs +7 -3
- package/dist/core/engine/nan.mjs +10 -1
- package/dist/core/engine/native.mjs +2 -20
- package/dist/core/engine/numbers.mjs +26 -14
- package/dist/core/engine/postgres.mjs +9 -5
- package/dist/core/engine/prepare.mjs +4 -4
- package/dist/core/engine/rank-sets.mjs +1 -1
- package/dist/core/engine/read.mjs +5 -4
- package/dist/core/engine/reader.d.mts +6 -0
- package/dist/core/engine/record-layout.mjs +3 -3
- package/dist/core/engine/run.mjs +77 -20
- package/dist/core/engine/segmented.d.mts +2 -1
- package/dist/core/engine/segmented.mjs +19 -12
- package/dist/core/engine/series.mjs +1 -1
- package/dist/core/engine/shape.mjs +8 -8
- package/dist/core/engine/sql-partition.mjs +2 -2
- package/dist/core/engine/sql-pass.mjs +3 -2
- package/dist/core/engine/sql-reader.mjs +13 -5
- package/dist/core/engine/sql-reads.mjs +2 -1
- package/dist/core/engine/sql-records.mjs +2 -2
- package/dist/core/engine/sql-split.mjs +1 -1
- package/dist/core/engine/sql-unread.mjs +70 -0
- package/dist/core/engine/time.mjs +2 -1
- package/dist/core/engine/types.d.mts +17 -0
- package/dist/core/engine/version.d.mts +1 -1
- package/dist/core/engine/version.mjs +1 -1
- package/dist/core/error/codes.d.mts +24 -1
- package/dist/core/error/codes.mjs +23 -3
- package/dist/core/error/refusal.d.mts +8 -3
- package/dist/core/error/refusal.mjs +6 -1
- package/dist/core/exact/decimal.d.mts +1 -14
- package/dist/core/exact/decimal.mjs +9 -19
- package/dist/core/exact/stored.d.mts +9 -0
- package/dist/core/exact/stored.mjs +38 -0
- package/dist/core/exact/text.d.mts +16 -1
- package/dist/core/exact/text.mjs +50 -1
- package/dist/core/format/digits.mjs +55 -0
- package/dist/core/format/index.d.mts +16 -0
- package/dist/core/format/index.mjs +27 -0
- package/dist/core/format/number.d.mts +27 -0
- package/dist/core/format/number.mjs +158 -0
- package/dist/core/format/write.d.mts +6 -0
- package/dist/core/format/write.mjs +57 -0
- package/dist/core/index.d.mts +43 -33
- package/dist/core/index.mjs +31 -28
- package/dist/core/model/defaults.d.mts +18 -1
- package/dist/core/model/defaults.mjs +19 -1
- package/dist/core/model/define.d.mts +17 -8
- package/dist/core/model/define.mjs +2 -0
- package/dist/core/model/member.d.mts +5 -3
- package/dist/core/model/member.mjs +33 -6
- package/dist/core/model/storage.mjs +40 -12
- package/dist/core/model/types.d.mts +17 -1
- package/dist/core/model/types.mjs +5 -0
- package/dist/core/model/validate/expr.d.mts +1 -7
- package/dist/core/model/validate/fields.d.mts +2 -0
- package/dist/core/model/validate/fields.mjs +14 -7
- package/dist/core/model/validate/issues.mjs +5 -1
- package/dist/core/model/validate/known-members.mjs +6 -5
- package/dist/core/model/validate/shape.mjs +36 -3
- package/dist/core/model/validate/source.mjs +2 -2
- package/dist/core/oracle/data.d.mts +4 -2
- package/dist/core/oracle/evaluate.d.mts +19 -1
- package/dist/core/oracle/evaluate.mjs +56 -10
- package/dist/core/oracle/expr.mjs +1 -1
- package/dist/core/oracle/facts.mjs +12 -5
- package/dist/core/oracle/measure.mjs +1 -1
- package/dist/core/oracle/request.mjs +39 -4
- package/dist/core/oracle/segmented.d.mts +3 -1
- package/dist/core/oracle/segmented.mjs +19 -13
- package/dist/core/oracle/unread.mjs +32 -0
- package/dist/core/oracle/visibility.mjs +4 -3
- package/dist/core/policy/bind.d.mts +2 -11
- package/dist/core/policy/bind.mjs +1 -1
- package/dist/core/policy/match.mjs +1 -1
- package/dist/core/query/closure.d.mts +7 -2
- package/dist/core/query/closure.mjs +29 -12
- package/dist/core/query/compose-tile.d.mts +3 -2
- package/dist/core/query/compose-tile.mjs +32 -13
- package/dist/core/query/compose.d.mts +0 -5
- package/dist/core/query/drill/internal.d.mts +5 -5
- package/dist/core/query/drill/internal.mjs +11 -0
- package/dist/core/query/drill/links.d.mts +2 -3
- package/dist/core/query/drill/links.mjs +31 -5
- package/dist/core/query/drill/selection.d.mts +8 -2
- package/dist/core/query/drill/selection.mjs +14 -3
- package/dist/core/query/drill/synthetic.mjs +1 -1
- package/dist/core/query/drill/time.mjs +11 -10
- package/dist/core/query/filter.d.mts +1 -6
- package/dist/core/query/filter.mjs +1 -4
- package/dist/core/query/fold.mjs +23 -0
- package/dist/core/query/segments.mjs +42 -3
- package/dist/core/query/to-wire.d.mts +7 -0
- package/dist/core/query/to-wire.mjs +14 -2
- package/dist/core/query/types.d.mts +30 -13
- package/dist/core/result/columns.mjs +23 -13
- package/dist/core/result/number.mjs +3 -3
- package/dist/core/result/status.d.mts +13 -0
- package/dist/core/result/status.mjs +18 -0
- package/dist/core/result/time-axis.d.mts +14 -13
- package/dist/core/result/time-axis.mjs +20 -2
- package/dist/core/result/types.d.mts +33 -3
- package/dist/core/result/whole.d.mts +23 -0
- package/dist/core/result/whole.mjs +27 -0
- package/dist/core/schema/agent-query.d.mts +89 -0
- package/dist/core/schema/agent-query.mjs +115 -0
- package/dist/core/schema/aliases.mjs +1 -52
- package/dist/core/schema/answer-parts.mjs +17 -13
- package/dist/core/schema/answers.d.mts +787 -319
- package/dist/core/schema/commands.d.mts +33 -23
- package/dist/core/schema/commands.mjs +26 -18
- package/dist/core/schema/custom.mjs +46 -45
- package/dist/core/schema/document.d.mts +32 -27
- package/dist/core/schema/document.mjs +61 -81
- package/dist/core/schema/drill-answers.mjs +4 -1
- package/dist/core/schema/drill.d.mts +14 -9
- package/dist/core/schema/drill.mjs +23 -22
- package/dist/core/schema/index.d.mts +5 -3
- package/dist/core/schema/index.mjs +5 -3
- package/dist/core/schema/options.d.mts +92 -0
- package/dist/core/schema/options.mjs +104 -0
- package/dist/core/schema/picks.d.mts +2 -2
- package/dist/core/schema/picks.mjs +7 -6
- package/dist/core/schema/query.d.mts +9 -83
- package/dist/core/schema/query.mjs +49 -73
- package/dist/core/schema/strict.d.mts +3 -0
- package/dist/core/schema/strict.mjs +91 -0
- package/dist/core/schema/tools.mjs +4 -0
- package/dist/core/schema/union-error.mjs +30 -7
- package/dist/core/schema/view.d.mts +4 -3
- package/dist/core/schema/view.mjs +16 -11
- package/dist/core/store/ddl.d.mts +0 -2
- package/dist/core/store/ddl.mjs +1 -5
- package/dist/core/time/bucket.d.mts +1 -19
- package/dist/core/time/bucket.mjs +6 -6
- package/dist/core/time/compare.mjs +3 -2
- package/dist/core/time/index.d.mts +7 -8
- package/dist/core/time/instant.d.mts +15 -9
- package/dist/core/time/instant.mjs +23 -9
- package/dist/core/time/range.d.mts +3 -15
- package/dist/core/time/range.mjs +17 -7
- package/dist/core/time/stored.d.mts +8 -5
- package/dist/core/time/stored.mjs +51 -15
- package/dist/core/time/temporal.d.mts +1 -5
- package/dist/core/time/temporal.mjs +9 -4
- package/dist/core/time/text-time.d.mts +31 -2
- package/dist/core/time/text-time.mjs +139 -22
- package/dist/core/time/zone.mjs +2 -2
- package/dist/core/types/api.d.mts +1 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/dashboard.d.mts +185 -0
- package/dist/core/types/dashboard.mjs +26 -0
- package/dist/core/types/drill-api.d.mts +14 -2
- package/dist/core/types/infer.d.mts +0 -4
- package/dist/core/types/options-check.d.mts +42 -0
- package/dist/core/types/options-check.mjs +90 -0
- package/dist/core/types/options.d.mts +14 -8
- package/dist/core/value/casefold.d.mts +1 -3
- package/dist/core/value/stored.d.mts +26 -0
- package/dist/core/value/stored.mjs +28 -0
- package/dist/cursor-seal.mjs +37 -9
- package/dist/dashboard-documents.d.mts +14 -6
- package/dist/dashboard-documents.mjs +32 -12
- package/dist/dashboards.mjs +10 -9
- package/dist/drill-access.mjs +6 -6
- package/dist/drill-change.mjs +18 -20
- package/dist/drill-comparison.mjs +2 -1
- package/dist/drill-crumbs.mjs +63 -28
- package/dist/drill-distinct.mjs +2 -1
- package/dist/drill-explain.mjs +1 -1
- package/dist/drill-items.mjs +1 -1
- package/dist/drill-open.mjs +39 -23
- package/dist/drill-seal.mjs +41 -13
- package/dist/drill-share.mjs +1 -1
- package/dist/drill-summary.mjs +2 -1
- package/dist/drill-targets.mjs +4 -4
- package/dist/drill-views.mjs +4 -3
- package/dist/drill.mjs +1 -1
- package/dist/editing.mjs +5 -3
- package/dist/endpoints/index.d.mts +29 -8
- package/dist/endpoints/index.mjs +4 -1
- package/dist/endpoints/meta.mjs +4 -3
- package/dist/endpoints/query.mjs +5 -2
- package/dist/endpoints/read.mjs +7 -6
- package/dist/endpoints/versions.mjs +2 -1
- package/dist/execute.d.mts +3 -0
- package/dist/execute.mjs +23 -12
- package/dist/grant.d.mts +9 -0
- package/dist/grant.mjs +43 -0
- package/dist/handler.mjs +8 -13
- package/dist/http.d.mts +6 -2
- package/dist/http.mjs +6 -2
- package/dist/index.d.mts +25 -4
- package/dist/index.mjs +91 -40
- package/dist/llms.txt +3 -3
- package/dist/mcp/api.mjs +2 -1
- package/dist/mcp/query.mjs +3 -8
- package/dist/mcp/resolve.mjs +9 -2
- package/dist/node/index.d.mts +36 -0
- package/dist/node/index.mjs +89 -0
- package/dist/node/request.d.mts +12 -0
- package/dist/node/request.mjs +119 -0
- package/dist/node/response.mjs +58 -0
- package/dist/principal.mjs +15 -7
- package/dist/react/Canvas.mjs +88 -67
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +11 -4
- package/dist/react/Dashboard.mjs +42 -42
- package/dist/react/DashboardList.mjs +9 -4
- package/dist/react/Editing.d.mts +9 -0
- package/dist/react/Editing.mjs +8 -3
- package/dist/react/Grid.mjs +1 -1
- package/dist/react/Header.mjs +4 -35
- package/dist/react/History.mjs +3 -2
- package/dist/react/LoadFailed.mjs +59 -0
- package/dist/react/Panel.d.mts +1 -1
- package/dist/react/Panel.mjs +1 -1
- package/dist/react/Parts.d.mts +34 -0
- package/dist/react/Parts.mjs +9 -6
- package/dist/react/ReviewPanel.mjs +1 -1
- package/dist/react/RowBody.d.mts +2 -0
- package/dist/react/RowBody.mjs +5 -1
- package/dist/react/Share.mjs +153 -0
- package/dist/react/TabStrip.mjs +37 -0
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +89 -92
- package/dist/react/TileState.mjs +117 -0
- package/dist/react/ago.mjs +45 -0
- package/dist/react/arrange-steps.mjs +99 -11
- package/dist/react/arrange.mjs +11 -4
- package/dist/react/board.mjs +2 -2
- package/dist/react/bucket-name.d.mts +8 -0
- package/dist/react/bucket-name.mjs +13 -0
- package/dist/react/builder/DisplayOptions.mjs +219 -0
- package/dist/react/builder/Preview.mjs +13 -13
- package/dist/react/builder/RangeEditor.mjs +4 -3
- package/dist/react/builder/WidgetBuilder.d.mts +1 -7
- package/dist/react/builder/WidgetBuilder.mjs +12 -3
- package/dist/react/builder/base.d.mts +13 -2
- package/dist/react/builder/base.mjs +70 -12
- package/dist/react/builder/display.d.mts +3 -0
- package/dist/react/builder/display.mjs +257 -0
- package/dist/react/builder/labels.mjs +19 -5
- package/dist/react/builder/options.mjs +11 -6
- package/dist/react/builder/state.mjs +25 -3
- package/dist/react/builder/useBuilder.d.mts +7 -1
- package/dist/react/builder/useBuilder.mjs +6 -9
- package/dist/react/builder/usePreview.mjs +3 -2
- package/dist/react/builder/words.d.mts +16 -1
- package/dist/react/builder/words.mjs +41 -1
- package/dist/react/change-text.mjs +149 -0
- package/dist/react/client.d.mts +9 -0
- package/dist/react/client.mjs +105 -14
- package/dist/react/context.d.mts +24 -3
- package/dist/react/context.mjs +23 -7
- package/dist/react/dates-shown.mjs +76 -0
- package/dist/react/draft.mjs +3 -2
- package/dist/react/drill/Bars.mjs +12 -16
- package/dist/react/drill/Comparison.mjs +1 -1
- package/dist/react/drill/DrillPanel.d.mts +1 -1
- package/dist/react/drill/DrillPanel.mjs +2 -1
- package/dist/react/drill/Header.mjs +65 -12
- package/dist/react/drill/Items.d.mts +1 -1
- package/dist/react/drill/Notes.mjs +10 -7
- package/dist/react/drill/PanelStates.mjs +8 -1
- package/dist/react/drill/Trend.mjs +10 -5
- package/dist/react/drill/board.d.mts +1 -1
- package/dist/react/drill/host.mjs +4 -1
- package/dist/react/drill/lazy.mjs +2 -27
- package/dist/react/drill/props.d.mts +17 -7
- package/dist/react/drill/props.mjs +55 -14
- package/dist/react/drill/state.d.mts +15 -5
- package/dist/react/drill/state.mjs +12 -3
- package/dist/react/drill/words.d.mts +46 -3
- package/dist/react/drill/words.mjs +30 -5
- package/dist/react/english.mjs +33 -8
- package/dist/react/export/ExportButton.mjs +4 -1
- package/dist/react/export/csv.d.mts +7 -2
- package/dist/react/export/csv.mjs +24 -7
- package/dist/react/failure-words.mjs +60 -0
- package/dist/react/filters/bar.d.mts +1 -1
- package/dist/react/filters/bar.mjs +4 -1
- package/dist/react/filters/calendar.mjs +23 -8
- package/dist/react/filters/chip.mjs +7 -3
- package/dist/react/filters/context.d.mts +13 -1
- package/dist/react/filters/context.mjs +1 -1
- package/dist/react/filters/dates-said.mjs +57 -0
- package/dist/react/filters/days.d.mts +3 -4
- package/dist/react/filters/days.mjs +10 -17
- package/dist/react/filters/hooks.d.mts +11 -0
- package/dist/react/filters/hooks.mjs +10 -6
- package/dist/react/filters/menu-search.mjs +17 -9
- package/dist/react/filters/menu.mjs +10 -8
- package/dist/react/filters/phone.mjs +41 -16
- package/dist/react/filters/place.mjs +40 -0
- package/dist/react/filters/popover.mjs +18 -13
- package/dist/react/filters/rules.d.mts +4 -3
- package/dist/react/filters/rules.mjs +3 -3
- package/dist/react/filters/sheet.mjs +7 -3
- package/dist/react/filters/state.mjs +6 -1
- package/dist/react/filters/values.mjs +24 -7
- package/dist/react/filters/words.d.mts +13 -0
- package/dist/react/filters/words.mjs +5 -0
- package/dist/react/format-time.d.mts +17 -6
- package/dist/react/format-time.mjs +152 -33
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +27 -133
- package/dist/react/headline.d.mts +6 -3
- package/dist/react/headline.mjs +81 -25
- package/dist/react/index.d.mts +19 -17
- package/dist/react/index.mjs +12 -10
- package/dist/react/lazy.mjs +38 -0
- package/dist/react/messages.d.mts +78 -2
- package/dist/react/now.mjs +38 -0
- package/dist/react/read.d.mts +1 -0
- package/dist/react/read.mjs +140 -9
- package/dist/react/renderers/exact.mjs +31 -59
- package/dist/react/renderers/index.d.mts +27 -6
- package/dist/react/renderers/index.mjs +141 -102
- package/dist/react/renderers/list-parts.mjs +24 -0
- package/dist/react/renderers/list.d.mts +1 -0
- package/dist/react/renderers/list.mjs +99 -43
- package/dist/react/renderers/more-rows.mjs +75 -0
- package/dist/react/renderers/number-before.mjs +320 -0
- package/dist/react/renderers/number-period.mjs +54 -0
- package/dist/react/renderers/number-whole.mjs +29 -0
- package/dist/react/renderers/props.d.mts +24 -1
- package/dist/react/renderers/props.mjs +8 -0
- package/dist/react/renderers/table-cells.mjs +137 -31
- package/dist/react/renderers/table-fit.mjs +55 -10
- package/dist/react/renderers/table-measure.mjs +29 -9
- package/dist/react/renderers/table-row.mjs +14 -9
- package/dist/react/renderers/table-scale.mjs +2 -3
- package/dist/react/renderers/table-sort.mjs +3 -2
- package/dist/react/renderers/table-whole.mjs +37 -0
- package/dist/react/renderers/table.mjs +73 -53
- package/dist/react/review.d.mts +7 -0
- package/dist/react/review.mjs +35 -8
- package/dist/react/roving.d.mts +6 -0
- package/dist/react/roving.mjs +123 -0
- package/dist/react/says-dates.d.mts +7 -0
- package/dist/react/says-dates.mjs +51 -0
- package/dist/react/series.mjs +5 -6
- package/dist/react/stable.mjs +1 -1
- package/dist/react/tabs/EditTabs.mjs +125 -0
- package/dist/react/tabs/NameField.mjs +72 -0
- package/dist/react/tabs/TabMenu.mjs +175 -0
- package/dist/react/tabs/actions.mjs +37 -0
- package/dist/react/tabs/commands.mjs +76 -0
- package/dist/react/tabs/focus.mjs +22 -0
- package/dist/react/tabs/keys.mjs +28 -0
- package/dist/react/theme-unlayered.css +1 -1
- package/dist/react/theme.css +1 -1
- package/dist/react/tile-store.d.mts +4 -0
- package/dist/react/tile-store.mjs +93 -13
- package/dist/react/touch.d.mts +16 -0
- package/dist/react/touch.mjs +39 -0
- package/dist/react/useBoard.d.mts +6 -0
- package/dist/react/useBoard.mjs +1 -0
- package/dist/react/useDashboard.d.mts +2 -0
- package/dist/react/useDashboard.mjs +5 -2
- package/dist/react/useTiles.d.mts +3 -0
- package/dist/react/useTiles.mjs +73 -17
- package/dist/react/view-grid.mjs +2 -2
- package/dist/react/view.mjs +1 -1
- package/dist/recharts/axes.mjs +1 -1
- package/dist/recharts/axis.mjs +23 -73
- package/dist/recharts/bar.d.mts +2 -1
- package/dist/recharts/bar.mjs +140 -64
- package/dist/recharts/fit.mjs +33 -0
- package/dist/recharts/line.mjs +21 -15
- package/dist/recharts/marks.mjs +2 -1
- package/dist/recharts/parts.mjs +16 -13
- package/dist/recharts/table.mjs +8 -3
- package/dist/refusal.mjs +46 -0
- package/dist/registry/filter-bar.json +1 -1
- package/dist/skills/derive-dashboards/SKILL.md +23 -8
- package/dist/tile-doc.mjs +1 -1
- package/package.json +21 -6
- package/dist/charts-react/plan.d.mts +0 -3
- package/dist/charts-react/plan.mjs +0 -37
- package/dist/charts-react/tiles.d.mts +0 -24
- package/dist/core/policy/match.d.mts +0 -16
- package/dist/core/schema/aliases.d.mts +0 -7
- package/dist/core/time/compare.d.mts +0 -30
- package/dist/react/EditBar.d.mts +0 -16
- package/dist/react/History.d.mts +0 -30
- package/dist/react/ReviewPanel.d.mts +0 -15
- package/dist/react/digits.mjs +0 -46
- package/dist/react/drill/trend-touch.mjs +0 -33
- package/dist/react/renderers/exact.d.mts +0 -6
package/dist/react/client.d.mts
CHANGED
|
@@ -63,6 +63,15 @@ export type ClientOptions = {
|
|
|
63
63
|
* checked either way.
|
|
64
64
|
*/
|
|
65
65
|
schemas?: ClientSchemas;
|
|
66
|
+
/**
|
|
67
|
+
* Called when a request finds the viewer signed out: the handler's own 401 (your `viewer`
|
|
68
|
+
* found no one), or something in front of the handler turning them away (a sign-in layer's
|
|
69
|
+
* redirect, its 401 or 403). Once, until a request is answered again, however many were
|
|
70
|
+
* turned away; never for a request that was stopped, nor for the handler's own 403. Send the
|
|
71
|
+
* viewer to sign in here: the client asks with `redirect: "manual"`, so a `fetch` of the
|
|
72
|
+
* host's own never sees a sign-in layer's redirect as a 401.
|
|
73
|
+
*/
|
|
74
|
+
onSignedOut?: () => void;
|
|
66
75
|
};
|
|
67
76
|
/** What a typed client reads from the server: pass `typeof dashboards` (what `deriveDashboards` returned). */
|
|
68
77
|
export type DashboardsServer = {
|
package/dist/react/client.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DashboardsError } from "./errors.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { signedOut } from "./failure-words.mjs";
|
|
3
|
+
import { checkContract, methodLost, readerOf, redirectedAway, unfollowed } from "./read.mjs";
|
|
3
4
|
// src/client.ts
|
|
4
5
|
function isApiError(value) {
|
|
5
6
|
return typeof value === "object" && value !== null && "error" in value;
|
|
@@ -39,6 +40,86 @@ async function* tileLines(request, reader, body, signal) {
|
|
|
39
40
|
message: "The answer was cut off."
|
|
40
41
|
});
|
|
41
42
|
}
|
|
43
|
+
/** Whether a request failed because it was stopped, which is never a failure to tell anyone of. */
|
|
44
|
+
const stopped = (error, init) => init.signal?.aborted === true || error instanceof Error && error.name === "AbortError";
|
|
45
|
+
/**
|
|
46
|
+
* Follows a redirect once, to see whose answer is behind it. Once the first answer was a
|
|
47
|
+
* redirect, any failure of this second ask, a real network drop included, reads as a redirect
|
|
48
|
+
* somewhere this page may not read: a browser rejects a cross-origin redirect it will not let
|
|
49
|
+
* the page read exactly as it rejects a dropped connection, so the two cannot be told apart.
|
|
50
|
+
*/
|
|
51
|
+
async function follow(doFetch, url, init) {
|
|
52
|
+
try {
|
|
53
|
+
return await doFetch(url, {
|
|
54
|
+
...init,
|
|
55
|
+
redirect: "follow"
|
|
56
|
+
});
|
|
57
|
+
} catch (error) {
|
|
58
|
+
throw stopped(error, init) ? error : redirectedAway(url);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** The site a URL is on; a path alone is on the page's own, where there is a page. */
|
|
62
|
+
function originOf(url) {
|
|
63
|
+
const page = globalThis.location?.href;
|
|
64
|
+
return URL.canParse(url, page) ? new URL(url, page).origin : void 0;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Where to ask next time, when a followed answer is the handler's own (it has the fingerprint)
|
|
68
|
+
* at another address of the same site. Never another site, though a redirect led there: the
|
|
69
|
+
* request is asked for where its host wrote it, with the credentials of that site.
|
|
70
|
+
*/
|
|
71
|
+
function ledTo(asked, followed) {
|
|
72
|
+
if (!followed.redirected || followed.headers.get("dd-contract") === null) return void 0;
|
|
73
|
+
const [from, to] = [originOf(asked), originOf(followed.url)];
|
|
74
|
+
return from !== void 0 && from === to ? followed.url : void 0;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Asks without following a redirect, since the handler never sends one. A browser that follows
|
|
78
|
+
* a sign-in layer's redirect to a page on another origin fails CORS, and fetch rejects as if the
|
|
79
|
+
* server were down. A redirect is followed once (`follow`): the handler's answer behind it (a
|
|
80
|
+
* trailing slash, say) is read, and where it led is asked directly from then on (`led`), unless
|
|
81
|
+
* the redirect turned a POST into a GET (`methodLost`); a page the browser will not let this
|
|
82
|
+
* page read is a sign-in page on another site, a viewer turned away.
|
|
83
|
+
*/
|
|
84
|
+
async function ask(doFetch, url, init, led) {
|
|
85
|
+
const first = await doFetch(led.get(url) ?? url, {
|
|
86
|
+
...init,
|
|
87
|
+
redirect: "manual"
|
|
88
|
+
});
|
|
89
|
+
if (!unfollowed(first)) return first;
|
|
90
|
+
led.delete(url);
|
|
91
|
+
const followed = await follow(doFetch, url, init);
|
|
92
|
+
const lost = await methodLost(first, followed, {
|
|
93
|
+
url,
|
|
94
|
+
method: init.method
|
|
95
|
+
});
|
|
96
|
+
if (lost !== void 0) throw lost;
|
|
97
|
+
const to = ledTo(url, followed);
|
|
98
|
+
if (to !== void 0) led.set(url, to);
|
|
99
|
+
return followed;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Tells the host, once a spell, that the viewer is signed out (`onSignedOut`): a spell ends
|
|
103
|
+
* when a request is answered. A host's mistake in the callback is the host's to see on
|
|
104
|
+
* the console; it never takes the place of the request's own failure.
|
|
105
|
+
*/
|
|
106
|
+
function signedOutOnce(onSignedOut) {
|
|
107
|
+
let away = false;
|
|
108
|
+
return {
|
|
109
|
+
answered: () => {
|
|
110
|
+
away = false;
|
|
111
|
+
},
|
|
112
|
+
signedOut: () => {
|
|
113
|
+
if (away || onSignedOut === void 0) return;
|
|
114
|
+
away = true;
|
|
115
|
+
try {
|
|
116
|
+
onSignedOut();
|
|
117
|
+
} catch (mistake) {
|
|
118
|
+
console.error("derive-dashboards: onSignedOut threw", mistake);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
42
123
|
/**
|
|
43
124
|
* The client for the handler's endpoints. Its named methods are what the components use;
|
|
44
125
|
* `call` reaches any endpoint by path. Give it the server's type,
|
|
@@ -49,26 +130,36 @@ function createDashboardsClient(options = {}) {
|
|
|
49
130
|
const base = options.baseURL ?? "/api/dashboards";
|
|
50
131
|
const doFetch = options.fetch ?? globalThis.fetch.bind(globalThis);
|
|
51
132
|
const reader = readerOf(options.schemas);
|
|
133
|
+
const spell = signedOutOnce(options.onSignedOut);
|
|
134
|
+
const led = /* @__PURE__ */ new Map();
|
|
52
135
|
const request = async (path, body, signal) => {
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
136
|
+
const url = `${base}${path}`;
|
|
137
|
+
try {
|
|
138
|
+
const response = await ask(doFetch, url, {
|
|
139
|
+
method: body === void 0 ? "GET" : "POST",
|
|
140
|
+
credentials: "same-origin",
|
|
141
|
+
headers: {
|
|
142
|
+
"content-type": "application/json",
|
|
143
|
+
...options.headers?.()
|
|
144
|
+
},
|
|
145
|
+
...body === void 0 ? {} : { body: JSON.stringify(body) },
|
|
146
|
+
...signal === void 0 ? {} : { signal }
|
|
147
|
+
}, led);
|
|
148
|
+
checkContract(response, options.schemas, url);
|
|
149
|
+
if (response.status === 401) spell.signedOut();
|
|
150
|
+
else spell.answered();
|
|
151
|
+
return response;
|
|
152
|
+
} catch (error) {
|
|
153
|
+
if (signal?.aborted !== true && signedOut(error)) spell.signedOut();
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
65
156
|
};
|
|
66
157
|
async function fetchJson(path, body, signal) {
|
|
67
158
|
const response = await request(path, body, signal);
|
|
68
159
|
if (!response.ok) throw await failure(response);
|
|
69
160
|
return response.json();
|
|
70
161
|
}
|
|
71
|
-
const typed = (path, body, signal) => fetchJson(path, body, signal);
|
|
162
|
+
const typed = async (path, body, signal) => reader.any(path, await fetchJson(path, body, signal));
|
|
72
163
|
/** One of the library's endpoints, its body from the contract, its answer read by `reader`. */
|
|
73
164
|
const core = async (path, ...args) => reader.answer(path, await fetchJson(path, ...args));
|
|
74
165
|
return {
|
package/dist/react/context.d.mts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { DashboardsClient } from "./client.mjs";
|
|
2
|
-
import { FilterBarProps } from "./filters/hooks.mjs";
|
|
3
2
|
import "./FilterBar.mjs";
|
|
3
|
+
import { FilterBarOptions } from "./filters/context.mjs";
|
|
4
|
+
import { FilterBarProps } from "./filters/hooks.mjs";
|
|
4
5
|
import { Messages } from "./messages.mjs";
|
|
5
6
|
import { TileRenderer } from "./renderers/props.mjs";
|
|
6
7
|
import "./renderers/index.mjs";
|
|
8
|
+
import { Author, TileResult } from "derive-dashboards/core";
|
|
7
9
|
import { ComponentType, MouseEvent, ReactNode } from "react";
|
|
8
|
-
import { Author } from "derive-dashboards/core";
|
|
9
10
|
/** The props every link the library draws passes: a router's link component takes them. */
|
|
10
11
|
export type LinkProps = {
|
|
11
12
|
href: string;
|
|
@@ -27,7 +28,11 @@ type Value = {
|
|
|
27
28
|
authorName?: (author: Author) => string | undefined;
|
|
28
29
|
/** Who answers and for whom: the viewer's key and the client, so no cache serves another viewer. */
|
|
29
30
|
cacheScope: string;
|
|
31
|
+
/** Tile answers already read, by dashboard id: drawn at once, and not asked for again. */
|
|
32
|
+
served?: ServedTiles;
|
|
30
33
|
};
|
|
34
|
+
/** Tile answers already read, by dashboard id, each list as the tiles endpoint answers. */
|
|
35
|
+
export type ServedTiles = Readonly<Record<string, readonly TileResult[]>>;
|
|
31
36
|
export type DashboardsProviderProps = {
|
|
32
37
|
client: DashboardsClient;
|
|
33
38
|
/** Renderers by widget kind, added to the built-in "number" and "table". */
|
|
@@ -56,11 +61,27 @@ export type DashboardsProviderProps = {
|
|
|
56
61
|
* (`npx shadcn@latest add ./node_modules/derive-dashboards/dist/registry/filter-bar.json`).
|
|
57
62
|
*/
|
|
58
63
|
components?: Partial<Components>;
|
|
64
|
+
/**
|
|
65
|
+
* Dashboards already read, by id (`api.getDashboard` on the server, say): each is drawn as
|
|
66
|
+
* its layout at once, its tiles loading, on the server too, and read again in the browser.
|
|
67
|
+
* Without one, a dashboard says it is loading until its document arrives.
|
|
68
|
+
*/
|
|
69
|
+
dashboards?: Readonly<Record<string, DashboardRead>>;
|
|
70
|
+
/**
|
|
71
|
+
* Tile answers already read, by dashboard id (`api.tile` for each tile of the tab it opens
|
|
72
|
+
* on, on the server, say), for the view the page opens with: the published dashboard, its
|
|
73
|
+
* first tab, no picks. Given with its dashboard, each tile is drawn with its answer at once,
|
|
74
|
+
* on the server too, and the browser takes them over without asking for them again.
|
|
75
|
+
*/
|
|
76
|
+
tiles?: ServedTiles;
|
|
59
77
|
children: ReactNode;
|
|
60
78
|
};
|
|
79
|
+
/** A dashboard as `client.getDashboard` reads it. */
|
|
80
|
+
export type DashboardRead = Awaited<ReturnType<DashboardsClient["getDashboard"]>>;
|
|
61
81
|
/** The parts a host may draw itself. Each defaults to the library's own. */
|
|
82
|
+
/** The filter bar is handed the dashboard's `filterBar` options beside its own props. */
|
|
62
83
|
export type Components = {
|
|
63
|
-
FilterBar: ComponentType<FilterBarProps>;
|
|
84
|
+
FilterBar: ComponentType<FilterBarProps & FilterBarOptions>;
|
|
64
85
|
};
|
|
65
86
|
export declare function DashboardsProvider(props: DashboardsProviderProps): import("react").JSX.Element;
|
|
66
87
|
export declare function useDashboards(): Value;
|
package/dist/react/context.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { FilterBar } from "./filters/bar.mjs";
|
|
|
2
2
|
import { ENGLISH } from "./english.mjs";
|
|
3
3
|
import { BUILTIN_RENDERERS } from "./renderers/index.mjs";
|
|
4
4
|
import { createContext, useContext, useMemo } from "react";
|
|
5
|
-
import { SWRConfig } from "swr";
|
|
5
|
+
import { SWRConfig, unstable_serialize } from "swr";
|
|
6
6
|
import { jsx } from "react/jsx-runtime";
|
|
7
7
|
// src/context.tsx
|
|
8
8
|
/** A stable number per client, so a new client starts its own caches. */
|
|
@@ -16,11 +16,25 @@ function clientId(client) {
|
|
|
16
16
|
return counted.clients;
|
|
17
17
|
}
|
|
18
18
|
const Context = createContext(null);
|
|
19
|
+
/** The key a dashboard is cached by, which `useDashboard` reads it with. */
|
|
20
|
+
const dashboardKey = (id) => ["dd-dashboard", id];
|
|
21
|
+
/** The provider's cache settings: a cache of its own, and the dashboards given as already read. */
|
|
22
|
+
function useCacheConfig(dashboards) {
|
|
23
|
+
return useMemo(() => {
|
|
24
|
+
const read = Object.entries(dashboards ?? {});
|
|
25
|
+
const fallback = Object.fromEntries(read.map(([id, d]) => [unstable_serialize(dashboardKey(id)), d]));
|
|
26
|
+
return {
|
|
27
|
+
...ownCache,
|
|
28
|
+
fallback
|
|
29
|
+
};
|
|
30
|
+
}, [dashboards]);
|
|
31
|
+
}
|
|
19
32
|
/** A cache of the provider's own, so answers never mix with the host's or another viewer's. */
|
|
20
33
|
const ownCache = { provider: () => /* @__PURE__ */ new Map() };
|
|
21
34
|
function DashboardsProvider(props) {
|
|
22
|
-
const { client, renderers, locale, messages, viewerKey, authorName, link, components,
|
|
35
|
+
const { client, renderers, locale, messages, viewerKey, authorName, link, components, tiles } = props;
|
|
23
36
|
const csv = props.csv !== false;
|
|
37
|
+
const cache = useCacheConfig(props.dashboards);
|
|
24
38
|
const cacheScope = `${viewerKey ?? ""}:${String(clientId(client))}`;
|
|
25
39
|
const value = useMemo(() => ({
|
|
26
40
|
client,
|
|
@@ -40,7 +54,8 @@ function DashboardsProvider(props) {
|
|
|
40
54
|
components: {
|
|
41
55
|
FilterBar,
|
|
42
56
|
...components
|
|
43
|
-
}
|
|
57
|
+
},
|
|
58
|
+
...tiles === void 0 ? {} : { served: tiles }
|
|
44
59
|
}), [
|
|
45
60
|
client,
|
|
46
61
|
cacheScope,
|
|
@@ -50,13 +65,14 @@ function DashboardsProvider(props) {
|
|
|
50
65
|
csv,
|
|
51
66
|
authorName,
|
|
52
67
|
link,
|
|
53
|
-
components
|
|
68
|
+
components,
|
|
69
|
+
tiles
|
|
54
70
|
]);
|
|
55
71
|
return /* @__PURE__ */ jsx(SWRConfig, {
|
|
56
|
-
value:
|
|
72
|
+
value: cache,
|
|
57
73
|
children: /* @__PURE__ */ jsx(Context.Provider, {
|
|
58
74
|
value,
|
|
59
|
-
children
|
|
75
|
+
children: props.children
|
|
60
76
|
})
|
|
61
77
|
}, cacheScope);
|
|
62
78
|
}
|
|
@@ -65,4 +81,4 @@ function useDashboards() {
|
|
|
65
81
|
if (value === null) throw new Error("Wrap the dashboard in <DashboardsProvider client={…}>.");
|
|
66
82
|
return value;
|
|
67
83
|
}
|
|
68
|
-
export { DashboardsProvider, useDashboards };
|
|
84
|
+
export { DashboardsProvider, dashboardKey, useDashboards };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { formatPeriod } from "./format-time.mjs";
|
|
2
|
+
import { isDateRange } from "derive-dashboards/core";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
// src/dates-shown.ts
|
|
5
|
+
/** Whether a tile's answer was read: not refused, and not one the viewer may not see. */
|
|
6
|
+
const wasRead = (result) => !("error" in result) && result.unreadable !== true;
|
|
7
|
+
/** The time a tile's answer covers, as a key two tiles share when they cover the same days. */
|
|
8
|
+
const spanKey = (result) => {
|
|
9
|
+
if (result === void 0 || "error" in result) return void 0;
|
|
10
|
+
const range = result.receipt.range;
|
|
11
|
+
return range === void 0 ? void 0 : `${range.from}|${range.to}`;
|
|
12
|
+
};
|
|
13
|
+
/** What most tiles cover when most read every date: lifetime figures, which cover no range. */
|
|
14
|
+
const EVERY_DATE = "every date";
|
|
15
|
+
/**
|
|
16
|
+
* The span most of the tiles cover: more than half of the tiles that read their data. The
|
|
17
|
+
* dashboard says it once and the tiles that cover it leave it out. It is a range's key
|
|
18
|
+
* (`spanKey`), or `EVERY_DATE` when most read every date: a page of lifetime figures shows all
|
|
19
|
+
* time, and says so. None when the tiles disagree. Tiles still `waiting` for their answer count
|
|
20
|
+
* against it, since any of them may cover other dates: a span is most tiles' only once it would
|
|
21
|
+
* stay so whatever they answer.
|
|
22
|
+
*/
|
|
23
|
+
function sharedSpan(results, waiting = 0) {
|
|
24
|
+
const counts = /* @__PURE__ */ new Map();
|
|
25
|
+
let read = waiting;
|
|
26
|
+
for (const result of results.values()) {
|
|
27
|
+
if (!wasRead(result)) continue;
|
|
28
|
+
read += 1;
|
|
29
|
+
const key = spanKey(result) ?? "every date";
|
|
30
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
31
|
+
}
|
|
32
|
+
const [top] = [...counts].toSorted((a, b) => b[1] - a[1]);
|
|
33
|
+
return top !== void 0 && top[1] * 2 > read ? top[0] : void 0;
|
|
34
|
+
}
|
|
35
|
+
/** The answer of a tile that covers the span most tiles do; none when the tiles share none. */
|
|
36
|
+
function sharedAnswer(results, waiting = 0) {
|
|
37
|
+
const shared = sharedSpan(results, waiting);
|
|
38
|
+
return [...results.values()].flatMap((result) => wasRead(result) ? [result] : []).find((result) => (spanKey(result) ?? "every date") === shared);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The dates most tiles cover, as the date control says them ("Aug 23 to Nov 20", or "All time"
|
|
42
|
+
* where most read every date). A tile still
|
|
43
|
+
* waiting holds its last answer, which is of the picks before, so only the tiles that have
|
|
44
|
+
* answered say, and they say once they are most of the tiles whatever the rest answer: the
|
|
45
|
+
* first tile to answer does not speak for a dashboard of five. Undefined when the tiles share
|
|
46
|
+
* none. Null while a tile that could say is still waiting: the control then says neither the
|
|
47
|
+
* dates of the picks before nor that there are none.
|
|
48
|
+
*/
|
|
49
|
+
function datesShown(tiles, format) {
|
|
50
|
+
const one = sharedAnswer(new Map([...tiles.results].filter(([widget]) => !tiles.pending.has(widget))), tiles.pending.size);
|
|
51
|
+
if (one === void 0) return tiles.pending.size > 0 ? null : void 0;
|
|
52
|
+
const range = one.receipt.range;
|
|
53
|
+
if (range === void 0) return format.messages.tileAllTime;
|
|
54
|
+
return formatPeriod(range, format, one.receipt.calendar.timezone);
|
|
55
|
+
}
|
|
56
|
+
/** What the dates shown are the dates of: the tab, and the dates the viewer picked. */
|
|
57
|
+
const datesKey = (tab, picks) => JSON.stringify([tab, Object.entries(picks).filter(([, pick]) => isDateRange(pick))]);
|
|
58
|
+
/**
|
|
59
|
+
* The dates shown, kept while the tiles wait for the answer to a pick that does not change
|
|
60
|
+
* them. A filter's pick sends every tile for a new answer, of the same dates: the control goes
|
|
61
|
+
* on saying them. Another tab, or other dates picked, is another question (`key`): its dates
|
|
62
|
+
* are not known until its tiles answer.
|
|
63
|
+
*/
|
|
64
|
+
function useDatesKept(dates, key) {
|
|
65
|
+
const [kept, setKept] = useState({
|
|
66
|
+
key,
|
|
67
|
+
dates
|
|
68
|
+
});
|
|
69
|
+
if (dates === null) return kept.key === key ? kept.dates : null;
|
|
70
|
+
if (kept.key !== key || kept.dates !== dates) setKept({
|
|
71
|
+
key,
|
|
72
|
+
dates
|
|
73
|
+
});
|
|
74
|
+
return dates;
|
|
75
|
+
}
|
|
76
|
+
export { EVERY_DATE, datesKey, datesShown, sharedSpan, spanKey, useDatesKept, wasRead };
|
package/dist/react/draft.mjs
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { DashboardsError } from "./errors.mjs";
|
|
2
2
|
import { useDashboards } from "./context.mjs";
|
|
3
|
+
import { failureWords } from "./failure-words.mjs";
|
|
3
4
|
import { isShifted } from "./marks.mjs";
|
|
4
5
|
import { useRef, useState } from "react";
|
|
5
6
|
// src/draft.ts
|
|
6
7
|
/** What to tell the editor when a draft request is refused: the common cases in their words. */
|
|
7
8
|
function failureText(failure, messages) {
|
|
8
9
|
if (failure instanceof TypeError) return messages.unreachable;
|
|
9
|
-
if (!(failure instanceof DashboardsError)) return failure
|
|
10
|
+
if (!(failure instanceof DashboardsError)) return failureWords(failure, messages);
|
|
10
11
|
if (failure.code === "DRAFT_CONFLICT") return messages.draftChanged;
|
|
11
12
|
if (failure.code === "DRAFT_CLOSED") return messages.draftClosed;
|
|
12
13
|
if (failure.code === "REPLAY_REFUSED") return messages.replayRefused(failure.message);
|
|
13
|
-
return failure
|
|
14
|
+
return failureWords(failure, messages);
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* State that requests read when they run, not when they were asked for: a value for drawing,
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { signedChange } from "../change-text.mjs";
|
|
1
2
|
import { useDashboards } from "../context.mjs";
|
|
2
|
-
import { formatBucket } from "../format-time.mjs";
|
|
3
3
|
import { ENGLISH } from "../english.mjs";
|
|
4
4
|
import { formatCell, plotValue } from "../format.mjs";
|
|
5
|
+
import { formatFull } from "../headline.mjs";
|
|
5
6
|
import { rowEntry } from "./state.mjs";
|
|
6
7
|
import { Columns } from "./Trend.mjs";
|
|
7
8
|
import { MAX_DRILL_ROWS, isMark, parseTextTime, roleOf } from "derive-dashboards/core";
|
|
@@ -11,25 +12,21 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
11
12
|
function rowName(view, row, format) {
|
|
12
13
|
const [cell = null] = row;
|
|
13
14
|
const [column] = view.answer.columns;
|
|
14
|
-
return isMark(cell) || cell === null || cell === "" ? markName(cell, column?.label ?? "", format) :
|
|
15
|
+
return isMark(cell) || cell === null || cell === "" ? markName(cell, column?.label ?? "", format) : formatCell(cell, column, {
|
|
16
|
+
...format,
|
|
17
|
+
timeZone: view.answer.receipt.calendar.timezone
|
|
18
|
+
});
|
|
15
19
|
}
|
|
16
20
|
/** Other, Total, or "No assignee" for a group with no value. */
|
|
17
21
|
const markName = (cell, label, format) => isMark(cell) ? cell.mark === "other" ? format.messages.other : format.messages.total : format.messages.drillNone(label);
|
|
18
|
-
/** A group's value as the tile names it: a time bucket at its grain, else the formatted value. */
|
|
19
|
-
function valueName(cell, column, format) {
|
|
20
|
-
if (column?.grain !== void 0 && typeof cell === "string") return formatBucket(cell, column.grain, format.locale);
|
|
21
|
-
return formatCell(cell, column, format);
|
|
22
|
-
}
|
|
23
22
|
/** The line's column: the one named, else the first value column. */
|
|
24
23
|
const lineAt = (view, entry) => {
|
|
25
24
|
const named = view.answer.columns.findIndex((c) => c.id === entry);
|
|
26
25
|
return named >= 0 ? named : view.answer.columns.findIndex((c) => roleOf(c) === "measure");
|
|
27
26
|
};
|
|
28
|
-
/** A change with its sign: "+6" when it went up. */
|
|
29
|
-
const signed = (text, size) => size > 0 && !text.startsWith("+") ? `+${text}` : text;
|
|
30
27
|
const isAll = (row) => row.some((c) => isMark(c) && c.mark === "all");
|
|
31
28
|
/** Use the reporting instant, so a clipped historical month has a different label from this month. */
|
|
32
|
-
function isRunning(bucket, now) {
|
|
29
|
+
function isRunning$1(bucket, now) {
|
|
33
30
|
const from = parseTextTime(bucket.from);
|
|
34
31
|
const to = parseTextTime(bucket.to);
|
|
35
32
|
return bucket.partial !== "start" && now !== void 0 && from !== void 0 && to !== void 0 && from <= now && now < to;
|
|
@@ -46,7 +43,7 @@ function runningAt(view) {
|
|
|
46
43
|
function partialNotes(view, { messages }) {
|
|
47
44
|
const notes = /* @__PURE__ */ new Map();
|
|
48
45
|
const now = runningAt(view);
|
|
49
|
-
for (const bucket of view.answer.time?.buckets ?? []) if (bucket.partial) notes.set(bucket.label, isRunning(bucket, now) ? messages.soFar : messages.chartPartial ?? ENGLISH.chartPartial);
|
|
46
|
+
for (const bucket of view.answer.time?.buckets ?? []) if (bucket.partial) notes.set(bucket.label, isRunning$1(bucket, now) ? messages.soFar : messages.chartPartial ?? ENGLISH.chartPartial);
|
|
50
47
|
return notes;
|
|
51
48
|
}
|
|
52
49
|
/**
|
|
@@ -65,7 +62,7 @@ function barsOf(view, entry, format) {
|
|
|
65
62
|
const compared = view.change === true && rows.some(({ row }) => (row[change] ?? null) !== null);
|
|
66
63
|
const sized = compared ? change : at;
|
|
67
64
|
const max = Math.max(0, ...rows.map(({ row }) => Math.abs(plotValue(row[sized] ?? null) ?? 0)));
|
|
68
|
-
const text = (row, i) =>
|
|
65
|
+
const text = (row, i) => formatFull(row[i] ?? null, columns[i], format);
|
|
69
66
|
const notes = partialNotes(view, format);
|
|
70
67
|
return rows.map(({ row, selection }) => {
|
|
71
68
|
const size = plotValue(row[sized] ?? null) ?? 0;
|
|
@@ -75,7 +72,7 @@ function barsOf(view, entry, format) {
|
|
|
75
72
|
note: typeof row[0] === "string" ? notes.get(row[0]) : void 0,
|
|
76
73
|
width: max === 0 ? 0 : Math.abs(size) / max * 100,
|
|
77
74
|
negative: size < 0,
|
|
78
|
-
text: compared && (row[before] ?? null) !== null ? format.messages.drillChange(text(row, at),
|
|
75
|
+
text: compared && (row[before] ?? null) !== null ? format.messages.drillChange(text(row, at), formatFull(row[before] ?? null, columns[at], format), signedChange(row[change] ?? null, columns[at], format)) : text(row, at)
|
|
79
76
|
},
|
|
80
77
|
selection
|
|
81
78
|
};
|
|
@@ -131,15 +128,14 @@ function comparedTotal(view) {
|
|
|
131
128
|
change
|
|
132
129
|
};
|
|
133
130
|
}
|
|
134
|
-
/** The whole change in a Breakdown of the change: "vs 169, +33", from its total row. */
|
|
131
|
+
/** The whole change in a Breakdown of the change: "vs 169, +33", from its total row, written as the line is (`signedChange`). */
|
|
135
132
|
function changeLine(view, entry, format) {
|
|
136
133
|
const compared = comparedTotal(view);
|
|
137
134
|
if (compared === void 0) return void 0;
|
|
138
135
|
const { total, before, change } = compared;
|
|
139
136
|
const { columns } = view.answer;
|
|
140
137
|
const at = lineAt(view, entry);
|
|
141
|
-
|
|
142
|
-
return format.messages.drillVersus(formatCell(total[before] ?? null, columns[at], format), signed(formatCell(total[change] ?? null, columns[change], format), size));
|
|
138
|
+
return format.messages.drillVersus(formatFull(total[before] ?? null, columns[at], format), signedChange(total[change] ?? null, columns[at], format));
|
|
143
139
|
}
|
|
144
140
|
/** A breakdown shows groups and their changes. A trend shows the same values in time order. */
|
|
145
141
|
function Bars(props) {
|
|
@@ -5,8 +5,8 @@ import { isTotal } from "../renderers/table-scale.mjs";
|
|
|
5
5
|
import { crumbText } from "./Header.mjs";
|
|
6
6
|
import { rowEntry } from "./state.mjs";
|
|
7
7
|
import { useDrill } from "./useDrill.mjs";
|
|
8
|
-
import { Fragment, useId, useState } from "react";
|
|
9
8
|
import { MAX_DRILL_STEPS, isMark } from "derive-dashboards/core";
|
|
9
|
+
import { Fragment, useId, useState } from "react";
|
|
10
10
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
11
|
// src/drill/Comparison.tsx
|
|
12
12
|
function GroupName({ label }) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ItemOptions } from "./Items.mjs";
|
|
2
2
|
import { DrillChange } from "./state.mjs";
|
|
3
3
|
import { DrillController } from "./useDrill.mjs";
|
|
4
|
-
import { ComponentType, ReactNode } from "react";
|
|
5
4
|
import { DrillState } from "derive-dashboards/core";
|
|
5
|
+
import { ComponentType, ReactNode } from "react";
|
|
6
6
|
export type PanelOptions = ItemOptions & {
|
|
7
7
|
/** The panel's title: the tile's. */
|
|
8
8
|
title?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useDashboards } from "../context.mjs";
|
|
2
2
|
import { Tabs } from "./DrillTabs.mjs";
|
|
3
|
-
import { Crumbs, DrillHead, Value, crumbText } from "./Header.mjs";
|
|
3
|
+
import { Crumbs, DrillHead, Value, crumbText, pathPeriod } from "./Header.mjs";
|
|
4
4
|
import { Main } from "./PanelBody.mjs";
|
|
5
5
|
import { useFocusReturn, usePanelLandmark, usePeek } from "./panel-focus.mjs";
|
|
6
6
|
import { showsFields } from "./state.mjs";
|
|
@@ -60,6 +60,7 @@ function PanelHead({ d, title, close }) {
|
|
|
60
60
|
})
|
|
61
61
|
}), d.summary === void 0 || comparison ? null : /* @__PURE__ */ jsx(Value, {
|
|
62
62
|
summary: d.summary,
|
|
63
|
+
period: pathPeriod(d.path),
|
|
63
64
|
parent: parentText(parent, title, (c) => crumbText(c, format, zone)),
|
|
64
65
|
onRefresh: d.retry
|
|
65
66
|
})] });
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { formatInstantAt } from "../format-time.mjs";
|
|
2
|
+
import { bucketName } from "../bucket-name.mjs";
|
|
2
3
|
import { useDashboards } from "../context.mjs";
|
|
3
4
|
import { formatCell } from "../format.mjs";
|
|
5
|
+
import { formatFull, formatHeadline } from "../headline.mjs";
|
|
4
6
|
import { countOf, countText } from "./counts.mjs";
|
|
5
7
|
import { Notes, valueColumn } from "./Notes.mjs";
|
|
6
|
-
import { useEffect, useRef } from "react";
|
|
7
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { useEffect, useId, useRef } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
// src/drill/Header.tsx
|
|
9
11
|
/** A number of rows in words: "36 orders" with the source's noun, else "36 rows". */
|
|
10
12
|
function rowsText(count, summary, format) {
|
|
@@ -84,15 +86,36 @@ function markedText(c, messages) {
|
|
|
84
86
|
if (c.kind === "total") return c.previous === true ? messages.drillPeriodBefore : messages.total;
|
|
85
87
|
if (c.kind === "search") return `"${typeof c.value === "string" ? c.value : JSON.stringify(c.value)}"`;
|
|
86
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* One field of a step over several: its value as that field reads. A text names itself
|
|
91
|
+
* ("Discount"); a number or a yes or no beside other fields' values does not ("1"), so it says
|
|
92
|
+
* its field ("Pause months: 1").
|
|
93
|
+
*/
|
|
94
|
+
function partText(part, format, timeZone) {
|
|
95
|
+
const text = crumbText(part, format, timeZone);
|
|
96
|
+
return (part.kind === "group" || part.kind === void 0) && isFigure(part.value) ? `${part.label}: ${text}` : text;
|
|
97
|
+
}
|
|
98
|
+
/** A text that is a number as a driver writes one: digits, a sign, a decimal point. */
|
|
99
|
+
const DIGITS = /^-?\d+(?:\.\d+)?$/u;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a value reads as nothing alone beside other fields' values: a number, however it was
|
|
102
|
+
* sent (a number, an exact amount, the text of one), or a yes or no.
|
|
103
|
+
*/
|
|
104
|
+
function isFigure(value) {
|
|
105
|
+
if (typeof value === "number" || typeof value === "boolean") return true;
|
|
106
|
+
if (typeof value === "string") return DIGITS.test(value);
|
|
107
|
+
return value !== null && "v" in value;
|
|
108
|
+
}
|
|
87
109
|
function crumbText(c, format, timeZone) {
|
|
88
110
|
const { messages } = format;
|
|
89
|
-
if (c.parts !== void 0) return c.parts.filter((p) => p.kind !== "search").map((p) =>
|
|
111
|
+
if (c.parts !== void 0) return c.parts.filter((p) => p.kind !== "search").map((p) => partText(p, format, timeZone)).join(" · ");
|
|
90
112
|
const marked = markedText(c, messages);
|
|
91
113
|
if (marked !== void 0) return marked;
|
|
92
|
-
if (c.value === null) return messages.drillNone(c.label);
|
|
114
|
+
if (c.value === null || c.value === "") return messages.drillNone(c.label);
|
|
93
115
|
if (c.kind === "time" && typeof c.value === "string") {
|
|
116
|
+
if (timeZone === void 0) return c.label;
|
|
94
117
|
const date = formatInstantAt(c.value, c.grain ?? "day", format.locale, timeZone);
|
|
95
|
-
return c.grain === "week" ? messages.drillWeekOf(date) : date;
|
|
118
|
+
return bucketName(c.grain === "week" ? messages.drillWeekOf(date) : date, c.bucket, messages);
|
|
96
119
|
}
|
|
97
120
|
return formatCell(c.value, {}, format);
|
|
98
121
|
}
|
|
@@ -105,7 +128,7 @@ function Crumbs(props) {
|
|
|
105
128
|
"aria-label": format.messages.drillTitle,
|
|
106
129
|
children: /* @__PURE__ */ jsx("ol", { children: props.path.map((c, i) => c.kind === "total" ? null : /* @__PURE__ */ jsx("li", {
|
|
107
130
|
"aria-current": i === props.path.length - 1 ? "step" : void 0,
|
|
108
|
-
children: i === props.path.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [c.kind === "group" && !c.parts && c.value !== null ? /* @__PURE__ */ jsxs("small", {
|
|
131
|
+
children: i === props.path.length - 1 ? /* @__PURE__ */ jsxs("span", { children: [c.kind === "group" && !c.parts && c.value !== null && c.value !== "" ? /* @__PURE__ */ jsxs("small", {
|
|
109
132
|
className: "dd-sr-only",
|
|
110
133
|
children: [c.label, " "]
|
|
111
134
|
}) : null, crumbText(c, format, props.timeZone)] }) : /* @__PURE__ */ jsx("button", {
|
|
@@ -129,15 +152,41 @@ function rowsLine(summary, format) {
|
|
|
129
152
|
function shareText(summary, parent, format) {
|
|
130
153
|
const share = summary.share;
|
|
131
154
|
if (share === void 0) return null;
|
|
132
|
-
const percent =
|
|
155
|
+
const percent = formatCell(share.value, {
|
|
156
|
+
format: "percent",
|
|
157
|
+
fraction: true
|
|
158
|
+
}, format);
|
|
133
159
|
const metric = summary.column?.label;
|
|
134
160
|
const tile = metric === void 0 ? void 0 : format.messages.drillMetricTotal?.(metric);
|
|
135
161
|
return format.messages.drillShare(percent, share.of === "parent" ? parent : tile);
|
|
136
162
|
}
|
|
137
|
-
/**
|
|
138
|
-
|
|
163
|
+
/**
|
|
164
|
+
* The panel's large number. Where it is rounded, the amount in full is a pointer away (its
|
|
165
|
+
* `title`) and in the page too, where a screen reader finds it: a `title` is a pointer's alone.
|
|
166
|
+
*/
|
|
167
|
+
function Headline({ shown, full }) {
|
|
168
|
+
const id = useId();
|
|
169
|
+
if (shown === full) return /* @__PURE__ */ jsx("strong", { children: shown });
|
|
170
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("strong", {
|
|
171
|
+
title: full,
|
|
172
|
+
"aria-describedby": id,
|
|
173
|
+
children: shown
|
|
174
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
175
|
+
id,
|
|
176
|
+
className: "dd-sr-only",
|
|
177
|
+
children: full
|
|
178
|
+
})] });
|
|
179
|
+
}
|
|
180
|
+
/** The range of the time step a path reads in, the last one: the bucket's own, so far. */
|
|
181
|
+
const pathPeriod = (path) => path.flatMap((c) => [c, ...c.parts ?? []]).findLast((c) => c.bucket !== void 0)?.bucket;
|
|
182
|
+
/**
|
|
183
|
+
* The value, the rows behind it when they differ, its share, and what the viewer should know
|
|
184
|
+
* about it. It is dated by `period` when it is one time step's (`pathPeriod`), else the tile's.
|
|
185
|
+
*/
|
|
186
|
+
function Value({ summary, period, parent, onRefresh }) {
|
|
139
187
|
const format = useDashboards();
|
|
140
|
-
const value =
|
|
188
|
+
const value = formatFull(summary.value, valueColumn(summary), format);
|
|
189
|
+
const headline = formatHeadline(summary.value, valueColumn(summary), format);
|
|
141
190
|
const rows = rowsLine(summary, format);
|
|
142
191
|
const share = shareText(summary, parent, format);
|
|
143
192
|
const counted = sameCount(summary);
|
|
@@ -147,16 +196,20 @@ function Value({ summary, parent, onRefresh }) {
|
|
|
147
196
|
children: [
|
|
148
197
|
/* @__PURE__ */ jsxs("p", {
|
|
149
198
|
className: "dd-drill-stat",
|
|
150
|
-
children: [/* @__PURE__ */ jsx(
|
|
199
|
+
children: [/* @__PURE__ */ jsx(Headline, {
|
|
200
|
+
shown: headline,
|
|
201
|
+
full: value
|
|
202
|
+
}), label === void 0 ? null : /* @__PURE__ */ jsx("span", { children: label })]
|
|
151
203
|
}),
|
|
152
204
|
rows !== void 0 && !counted ? /* @__PURE__ */ jsx("p", { children: rows }) : null,
|
|
153
205
|
share === null ? null : /* @__PURE__ */ jsx("p", { children: share }),
|
|
154
206
|
/* @__PURE__ */ jsx(Notes, {
|
|
155
207
|
summary,
|
|
208
|
+
period,
|
|
156
209
|
value,
|
|
157
210
|
onRefresh
|
|
158
211
|
})
|
|
159
212
|
]
|
|
160
213
|
});
|
|
161
214
|
}
|
|
162
|
-
export { Crumbs, DrillHead, Value, crumbText };
|
|
215
|
+
export { Crumbs, DrillHead, Value, crumbText, pathPeriod };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ItemParts } from "./item-parts.mjs";
|
|
2
2
|
import "./item-type.mjs";
|
|
3
3
|
import { Item } from "../index.mjs";
|
|
4
|
-
import { ComponentType, MouseEvent, ReactNode } from "react";
|
|
5
4
|
import { DrillItem, DrillItemsView, ItemLinks } from "derive-dashboards/core";
|
|
5
|
+
import { ComponentType, MouseEvent, ReactNode } from "react";
|
|
6
6
|
/** What a host's own item row is given: the item's link and parts, and how to open it. */
|
|
7
7
|
export type ItemHelpers = ItemParts & {
|
|
8
8
|
href?: string;
|