derive-dashboards 0.8.0 → 0.9.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 +513 -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 +10 -8
- package/dist/core/document/display.mjs +25 -4
- 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 +18 -4
- 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/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 +9 -1
- 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.mjs +1 -1
- 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 +256 -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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TileSource } from "./tile-keys.mjs";
|
|
2
|
+
import { Stale } from "./tile-store.mjs";
|
|
2
3
|
import { Doc, Picks, Tab, TileResult } from "derive-dashboards/core";
|
|
3
4
|
/**
|
|
4
5
|
* The answers for one tab's tiles under the current picks, filled in as each tile finishes and
|
|
@@ -17,4 +18,6 @@ export declare function useTiles(a: {
|
|
|
17
18
|
}): {
|
|
18
19
|
results: Map<string, TileResult>;
|
|
19
20
|
pending: Set<string>;
|
|
21
|
+
notUpdated: ReadonlyMap<string, Stale>;
|
|
22
|
+
signedOut: boolean;
|
|
20
23
|
};
|
package/dist/react/useTiles.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
2
|
import { tileKeys } from "./tile-keys.mjs";
|
|
3
|
-
import { createTileStore, launch } from "./tile-store.mjs";
|
|
4
|
-
import { useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
3
|
+
import { RETRY, createTileStore, launch } from "./tile-store.mjs";
|
|
5
4
|
import { canonical } from "derive-dashboards/core";
|
|
5
|
+
import { createContext, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
6
6
|
// src/useTiles.ts
|
|
7
7
|
const NO_KEYS = /* @__PURE__ */ new Map();
|
|
8
8
|
/**
|
|
@@ -39,24 +39,69 @@ function refreshNow(a) {
|
|
|
39
39
|
})
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* The widgets whose answer shown is not the one for the filters picked now, and why: the viewer
|
|
44
|
+
* is signed out, or the request failed and is asked again. A tile reads it here, so the
|
|
45
|
+
* dashboard's grid passes nothing new down to it.
|
|
46
|
+
*/
|
|
47
|
+
const NotUpdatedContext = createContext(/* @__PURE__ */ new Map());
|
|
48
|
+
/** No tile is stale: one map for every render. */
|
|
49
|
+
const NOTHING_STALE = /* @__PURE__ */ new Map();
|
|
50
|
+
/**
|
|
51
|
+
* The same map as the render before while it holds the same widgets for the same reasons, so a
|
|
52
|
+
* tile that reads it draws again only when what it says changes, not each time the board draws.
|
|
53
|
+
*/
|
|
54
|
+
function useSameStale(stale) {
|
|
55
|
+
const held = useRef({
|
|
56
|
+
text: "",
|
|
57
|
+
stale: NOTHING_STALE
|
|
58
|
+
});
|
|
59
|
+
const text = [...stale].map(([id, why]) => `${id}\u0000${why}`).toSorted().join("");
|
|
60
|
+
if (held.current.text !== text) held.current = {
|
|
61
|
+
text,
|
|
62
|
+
stale: stale.size === 0 ? NOTHING_STALE : stale
|
|
63
|
+
};
|
|
64
|
+
return held.current.stale;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The answers read on the server for the tiles first shown, each under its key: only for the
|
|
68
|
+
* live dashboard, which is what they were read for.
|
|
69
|
+
*/
|
|
70
|
+
function servedFor(keys, served, source) {
|
|
71
|
+
if (served === void 0 || source === void 0 || !("version" in source)) return [];
|
|
72
|
+
const byWidget = new Map(served.map((result) => [result.widgetId, result]));
|
|
73
|
+
return [...keys].flatMap(([widgetId, key]) => {
|
|
74
|
+
const result = byWidget.get(widgetId);
|
|
75
|
+
return result === void 0 ? [] : [[
|
|
76
|
+
widgetId,
|
|
77
|
+
key,
|
|
78
|
+
result
|
|
79
|
+
]];
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/** Each widget's answer to show, which are still on their way, and which are not updated. */
|
|
43
83
|
function collect(keys, store) {
|
|
44
84
|
const results = /* @__PURE__ */ new Map();
|
|
45
85
|
const pending = /* @__PURE__ */ new Set();
|
|
86
|
+
const notUpdated = /* @__PURE__ */ new Map();
|
|
46
87
|
for (const [widgetId, key] of keys) {
|
|
47
88
|
const shown = store.shown(widgetId, key);
|
|
48
89
|
if (shown !== void 0) results.set(widgetId, shown);
|
|
49
90
|
if (!store.answered(key)) pending.add(widgetId);
|
|
91
|
+
const stale = store.stale(widgetId, key);
|
|
92
|
+
if (stale !== void 0) notUpdated.set(widgetId, stale);
|
|
50
93
|
}
|
|
51
94
|
return {
|
|
52
95
|
results,
|
|
53
|
-
pending
|
|
96
|
+
pending,
|
|
97
|
+
notUpdated
|
|
54
98
|
};
|
|
55
99
|
}
|
|
56
100
|
/**
|
|
57
|
-
* Tiles whose request
|
|
58
|
-
*
|
|
59
|
-
*
|
|
101
|
+
* Tiles whose request got no answer ask again when the browser is back online, when the window
|
|
102
|
+
* is focused, on a tile's Try again, and every 15 seconds while any failure may heal by waiting.
|
|
103
|
+
* The timer asks again only for those: a sign-in layer's refusal waits for the viewer to come
|
|
104
|
+
* back, signed in again, however many other tiles the timer asks for.
|
|
60
105
|
*/
|
|
61
106
|
function useRetry(store, again) {
|
|
62
107
|
const latest = useRef(again);
|
|
@@ -64,15 +109,21 @@ function useRetry(store, again) {
|
|
|
64
109
|
useEffect(() => {
|
|
65
110
|
const retry = () => {
|
|
66
111
|
if (!store.hasFailed()) return;
|
|
67
|
-
store.
|
|
112
|
+
store.forgetFailed();
|
|
68
113
|
latest.current();
|
|
69
114
|
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
115
|
+
const tick = () => {
|
|
116
|
+
if (store.forgetHealing()) latest.current();
|
|
117
|
+
};
|
|
118
|
+
const events = [
|
|
119
|
+
"online",
|
|
120
|
+
"focus",
|
|
121
|
+
RETRY
|
|
122
|
+
];
|
|
123
|
+
for (const name of events) globalThis.addEventListener(name, retry);
|
|
124
|
+
const timer = setInterval(tick, 15e3);
|
|
73
125
|
return () => {
|
|
74
|
-
globalThis.removeEventListener(
|
|
75
|
-
globalThis.removeEventListener("focus", retry);
|
|
126
|
+
for (const name of events) globalThis.removeEventListener(name, retry);
|
|
76
127
|
clearInterval(timer);
|
|
77
128
|
};
|
|
78
129
|
}, [store]);
|
|
@@ -98,7 +149,7 @@ function useStaleCheck(results, signature, onStale) {
|
|
|
98
149
|
* nothing. While a tile's new answer loads, it keeps its last one.
|
|
99
150
|
*/
|
|
100
151
|
function useTiles(a) {
|
|
101
|
-
const { client } = useDashboards();
|
|
152
|
+
const { client, served } = useDashboards();
|
|
102
153
|
const { dashboardId, doc, tab, picks } = a;
|
|
103
154
|
const sourceText = canonical(a.source ?? null);
|
|
104
155
|
const keys = useMemo(() => doc === void 0 || tab === void 0 ? NO_KEYS : tileKeys({
|
|
@@ -116,6 +167,7 @@ function useTiles(a) {
|
|
|
116
167
|
]);
|
|
117
168
|
const [, redraw] = useReducer((n) => n + 1, 0);
|
|
118
169
|
const [store] = useState(() => createTileStore(redraw));
|
|
170
|
+
if (keys.size > 0) store.seed(servedFor(keys, served?.[dashboardId], a.source));
|
|
119
171
|
const flights = useRef(/* @__PURE__ */ new Set());
|
|
120
172
|
const latest = useRef({
|
|
121
173
|
keys,
|
|
@@ -158,11 +210,15 @@ function useTiles(a) {
|
|
|
158
210
|
};
|
|
159
211
|
}, [store]);
|
|
160
212
|
useRetry(store, again);
|
|
161
|
-
const { results, pending } = collect(keys, store);
|
|
213
|
+
const { results, pending, notUpdated } = collect(keys, store);
|
|
214
|
+
const sameNotUpdated = useSameStale(notUpdated);
|
|
162
215
|
useStaleCheck(results, signature, a.onStale);
|
|
216
|
+
/** A sign-in layer turned away some tile's request: the viewer's session may have ended. */
|
|
163
217
|
return {
|
|
164
218
|
results,
|
|
165
|
-
pending
|
|
219
|
+
pending,
|
|
220
|
+
notUpdated: sameNotUpdated,
|
|
221
|
+
signedOut: store.signedOut()
|
|
166
222
|
};
|
|
167
223
|
}
|
|
168
|
-
export { useTiles };
|
|
224
|
+
export { NotUpdatedContext, useTiles };
|
package/dist/react/view-grid.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { sharedSpan } from "./
|
|
2
|
-
import { useMemo } from "react";
|
|
1
|
+
import { sharedSpan } from "./dates-shown.mjs";
|
|
3
2
|
import { viewLayout } from "derive-dashboards/core";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
4
|
// src/view-grid.ts
|
|
5
5
|
/**
|
|
6
6
|
* The grid as a viewer sees it. The layout holds only the tiles there are widgets for, each at
|
package/dist/react/view.mjs
CHANGED
package/dist/recharts/axes.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
8
8
|
*/
|
|
9
9
|
function yAxes(drawn, locale) {
|
|
10
10
|
return ["left", "right"].filter((side) => drawn.series.some((s) => s.axis === side)).map((side) => {
|
|
11
|
-
const axis = yAxis(drawn.series.filter((s) => s.axis === side), drawn.points, locale);
|
|
11
|
+
const axis = yAxis(drawn.series.filter((s) => s.axis === side), drawn.points, locale, { zero: "near" });
|
|
12
12
|
return /* @__PURE__ */ jsx(YAxis, {
|
|
13
13
|
yAxisId: side,
|
|
14
14
|
orientation: side,
|
package/dist/recharts/axis.mjs
CHANGED
|
@@ -1,75 +1,31 @@
|
|
|
1
1
|
import { formatTick } from "derive-dashboards/react";
|
|
2
|
+
import { valueAxis } from "derive-dashboards/charts";
|
|
2
3
|
// src/axis.ts
|
|
4
|
+
/** About how many ticks a tile's plot has room for: what the chart kit asks for one 220 pixels tall. */
|
|
5
|
+
const TICKS = 5;
|
|
3
6
|
/**
|
|
4
|
-
* A
|
|
5
|
-
*
|
|
7
|
+
* A value axis by the chart kit's own rule (`valueAxis`), so both kits draw the same one: round
|
|
8
|
+
* steps past the data, counts in whole numbers (no 2.5 tasks), a stacked chart reaching its
|
|
9
|
+
* tallest stack, and data below zero reached both ways.
|
|
6
10
|
*/
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
const step = [
|
|
10
|
-
.05,
|
|
11
|
-
.1,
|
|
12
|
-
.2,
|
|
13
|
-
.25,
|
|
14
|
-
.5,
|
|
15
|
-
1
|
|
16
|
-
].map((s) => s * full).find((s) => top / s <= 5) ?? full;
|
|
17
|
-
const count = Math.ceil(top / step - 1e-9);
|
|
18
|
-
return Array.from({ length: count + 1 }, (_v, i) => Number((i * step).toFixed(6)));
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* A value axis's ticks: from 0 up past the data in a step a person reads (1, 2, 2.5 or 5 times
|
|
22
|
-
* a power of ten), four or five steps, so it reads 0, 50, 100, 150 and never 35, 70, 105. A
|
|
23
|
-
* count steps in whole numbers only.
|
|
24
|
-
*/
|
|
25
|
-
function niceTicks(max, whole) {
|
|
26
|
-
if (!(max > 0)) return [0, 1];
|
|
27
|
-
const rough = max / 4;
|
|
28
|
-
const power = 10 ** Math.floor(Math.log10(rough));
|
|
29
|
-
const step = [
|
|
30
|
-
1,
|
|
31
|
-
2,
|
|
32
|
-
2.5,
|
|
33
|
-
5,
|
|
34
|
-
10
|
|
35
|
-
].map((m) => m * power).filter((s) => !whole || Number.isInteger(s)).find((s) => max / s <= 5) ?? Math.max(1, Math.ceil(rough));
|
|
36
|
-
const count = Math.ceil(max / step - 1e-9);
|
|
37
|
-
return Array.from({ length: count + 1 }, (_v, i) => Number((i * step).toPrecision(12)));
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* A value axis that reads at a glance: counts tick in whole numbers (no 2.5 tasks), percents on
|
|
41
|
-
* round steps of the whole, anything else on round steps from 0; a stacked chart reaches its
|
|
42
|
-
* tallest stack. Data below zero keeps the kit's own ticks, which reach both ways.
|
|
43
|
-
*/
|
|
44
|
-
function yAxis(series, points, locale, stacked = false) {
|
|
45
|
-
const { whole, percentOf } = shapeOf(series[0]?.column);
|
|
11
|
+
function yAxis(series, points, locale, shape) {
|
|
12
|
+
const column = series[0]?.column;
|
|
46
13
|
const values = points.flatMap((p) => series.map((s) => p[s.key]).filter((v) => typeof v === "number"));
|
|
47
|
-
const
|
|
48
|
-
const
|
|
14
|
+
const tops = shape.stacked === true ? stackedTops(series, points) : [];
|
|
15
|
+
const whole = column?.type === "int";
|
|
16
|
+
const axis = valueAxis([...values, ...tops], {
|
|
17
|
+
zero: shape.zero,
|
|
18
|
+
reads: { whole },
|
|
19
|
+
count: TICKS
|
|
20
|
+
});
|
|
49
21
|
return {
|
|
50
22
|
allowDecimals: !whole,
|
|
51
23
|
interval: 0,
|
|
52
|
-
tickFormatter:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
domain: [0, ticks.at(-1) ?? 1]
|
|
56
|
-
}
|
|
24
|
+
tickFormatter: (value) => formatTick(value, column, locale),
|
|
25
|
+
ticks: [...axis.ticks],
|
|
26
|
+
domain: [axis.min, axis.max]
|
|
57
27
|
};
|
|
58
28
|
}
|
|
59
|
-
/** What an axis reads of its column: whole counts, and a percent's whole (1 or 100). */
|
|
60
|
-
function shapeOf(column) {
|
|
61
|
-
if (column === void 0) return {
|
|
62
|
-
whole: false,
|
|
63
|
-
percentOf: void 0
|
|
64
|
-
};
|
|
65
|
-
const percentOf = column.format === "percent" ? column.fraction === true ? 1 : 100 : void 0;
|
|
66
|
-
return {
|
|
67
|
-
whole: column.type === "int",
|
|
68
|
-
percentOf
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
/** A percent axis ticks on steps of its whole; any other on round steps from 0. */
|
|
72
|
-
const ticksFor = (top, percentOf, whole) => percentOf === void 0 ? niceTicks(top, whole) : percentTicks(top, percentOf);
|
|
73
29
|
/** Each point's total over its series: a stacked bar reaches its sum, not its tallest part. */
|
|
74
30
|
function stackedTops(series, points) {
|
|
75
31
|
return points.map((p) => series.reduce((sum, s) => {
|
|
@@ -77,10 +33,6 @@ function stackedTops(series, points) {
|
|
|
77
33
|
return typeof v === "number" && v > 0 ? sum + v : sum;
|
|
78
34
|
}, 0));
|
|
79
35
|
}
|
|
80
|
-
function axisFormat(series, locale) {
|
|
81
|
-
const column = series[0]?.column;
|
|
82
|
-
return (value) => formatTick(value, column, locale);
|
|
83
|
-
}
|
|
84
36
|
/** About how wide a character of a tick's text is drawn, in pixels. */
|
|
85
37
|
const TICK_CHAR = 7;
|
|
86
38
|
/** The width a value axis is given when its ticks are short. */
|
|
@@ -91,18 +43,16 @@ const AXIS_WIDTH = 56;
|
|
|
91
43
|
* broke over two and lost its end.
|
|
92
44
|
*/
|
|
93
45
|
function axisWidth(axis) {
|
|
94
|
-
const
|
|
95
|
-
const longest = Math.max(0, ...ticks.map((tick) => axis.tickFormatter(tick).length));
|
|
46
|
+
const longest = Math.max(0, ...axis.ticks.map((tick) => axis.tickFormatter(tick).length));
|
|
96
47
|
return Math.max(AXIS_WIDTH, longest * TICK_CHAR + 12);
|
|
97
48
|
}
|
|
98
49
|
/**
|
|
99
50
|
* The room a chart whose bars lie down keeps past the end of its value axis. The last tick's
|
|
100
51
|
* text is centred on the end of the axis, so half of it stands past the end: with no room
|
|
101
|
-
* there it is cut ("6 se" for "6 sec").
|
|
102
|
-
* are the kit's own.
|
|
52
|
+
* there it is cut ("6 se" for "6 sec").
|
|
103
53
|
*/
|
|
104
|
-
function endRoom(axis
|
|
105
|
-
const last =
|
|
54
|
+
function endRoom(axis) {
|
|
55
|
+
const last = axis.ticks.at(-1) ?? 0;
|
|
106
56
|
return Math.max(8, Math.ceil(axis.tickFormatter(last).length * TICK_CHAR / 2));
|
|
107
57
|
}
|
|
108
|
-
export { axisWidth, endRoom,
|
|
58
|
+
export { axisWidth, endRoom, yAxis };
|
package/dist/recharts/bar.d.mts
CHANGED
|
@@ -3,6 +3,7 @@ import { TileRendererProps } from "derive-dashboards/react";
|
|
|
3
3
|
* Bars per x value; when a second field splits them, its values stack where the measure adds
|
|
4
4
|
* up (Other on top) and stand side by side where it does not. Bars over
|
|
5
5
|
* time stand up, the bucket still running drawn faint; bars by category lie down, so every
|
|
6
|
-
* name has room to be read and none is skipped.
|
|
6
|
+
* name has room to be read and none is skipped. Told to fit, bars by category are as tall as
|
|
7
|
+
* their rows ask; bars over time keep the box they were given.
|
|
7
8
|
*/
|
|
8
9
|
export declare function BarTile(props: TileRendererProps): import("react").JSX.Element;
|
package/dist/recharts/bar.mjs
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { axisWidth, endRoom, yAxis } from "./axis.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { FIT_MOST, lyingHeight } from "./fit.mjs";
|
|
3
|
+
import { openPoint, sameMark } from "./marks.mjs";
|
|
4
|
+
import { CHART, GRID, TOOLTIP, legendText, seriesColors, tooltipFormat, tooltipLabel } from "./parts.mjs";
|
|
4
5
|
import { toSeries } from "./series.mjs";
|
|
5
6
|
import { Beside } from "./table.mjs";
|
|
6
|
-
import { addsUp } from "derive-dashboards/core";
|
|
7
|
+
import { addsUp, isRunning } from "derive-dashboards/core";
|
|
8
|
+
import { fitted, useTapPreview } from "derive-dashboards/react";
|
|
7
9
|
import { useState } from "react";
|
|
8
10
|
import { Bar, BarChart, CartesianGrid, Legend, Rectangle, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
|
|
9
11
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -16,18 +18,32 @@ const cut = (label) => {
|
|
|
16
18
|
};
|
|
17
19
|
/** Room for the longest category label, in pixels, between a floor and a ceiling. */
|
|
18
20
|
const labelWidth = (points) => Math.min(180, Math.max(48, 12 + 7 * Math.max(0, ...points.map((p) => cut(p.x).length))));
|
|
19
|
-
/** A click on a bar opens the row behind it, with its series' line. */
|
|
20
|
-
const barClick = (drill, drawn, s) => drill === void 0 ? {} : { onClick: (_bar, point) => {
|
|
21
|
-
|
|
21
|
+
/** A tap or click on a bar opens the row behind it, with its series' line, by the touch model. */
|
|
22
|
+
const barClick = (drill, drawn, s, tap) => drill === void 0 ? {} : { onClick: (_bar, point) => {
|
|
23
|
+
tap({
|
|
22
24
|
point,
|
|
23
|
-
|
|
25
|
+
key: s.key
|
|
26
|
+
}, () => {
|
|
27
|
+
openPoint(drill, drawn, {
|
|
28
|
+
point,
|
|
29
|
+
series: s
|
|
30
|
+
});
|
|
24
31
|
});
|
|
25
32
|
} };
|
|
26
|
-
/** A
|
|
27
|
-
const
|
|
33
|
+
/** A bucket still running: faint, and outlined in its own colour, dashed, so it stands at 3:1. */
|
|
34
|
+
const RUNNING = {
|
|
35
|
+
fillOpacity: .45,
|
|
36
|
+
strokeWidth: 1.5,
|
|
37
|
+
strokeDasharray: "4 3"
|
|
38
|
+
};
|
|
39
|
+
/** A bar's shape: ringed when the keyboard or a finger is on it, faint and dashed while its bucket runs. */
|
|
40
|
+
const barShape = (ringed, key, drawn) => (props) => /* @__PURE__ */ jsx(Rectangle, {
|
|
28
41
|
...props,
|
|
29
|
-
...props.index
|
|
30
|
-
|
|
42
|
+
...isRunning(drawn.buckets?.[props.index]) ? {
|
|
43
|
+
...RUNNING,
|
|
44
|
+
stroke: props.fill
|
|
45
|
+
} : {},
|
|
46
|
+
...ringed?.key === key && ringed.point === props.index ? {
|
|
31
47
|
className: "dd-chart-focus",
|
|
32
48
|
stroke: "var(--dd-ink)",
|
|
33
49
|
strokeWidth: 2
|
|
@@ -74,17 +90,59 @@ function barAxes(overTime, values, points) {
|
|
|
74
90
|
tickFormatter: cut
|
|
75
91
|
})] });
|
|
76
92
|
}
|
|
77
|
-
/** The largest value drawn, whichever series holds it. */
|
|
78
|
-
const top = ({ points, series }) => Math.max(0, ...points.flatMap((point) => series.map((s) => point[s.key]).filter((v) => typeof v === "number")));
|
|
79
93
|
/** The chart's own settings, with room past the end of the value axis where the bars lie down along it. */
|
|
80
|
-
const chartOf = (overTime, axis
|
|
94
|
+
const chartOf = (overTime, axis) => overTime ? CHART : {
|
|
81
95
|
...CHART,
|
|
82
96
|
margin: {
|
|
83
97
|
...CHART.margin,
|
|
84
|
-
right: endRoom(axis
|
|
98
|
+
right: endRoom(axis)
|
|
85
99
|
}
|
|
86
100
|
};
|
|
87
101
|
/**
|
|
102
|
+
* What the tile and its picture are given to be as tall as their rows ask: only bars by
|
|
103
|
+
* category told to fit. The picture, which Recharts measures, is of that height and does not
|
|
104
|
+
* stretch, up to the most a tile grows; the tile is as tall as it and says so (`data-fit`), so
|
|
105
|
+
* its row on the grid follows. Otherwise both fill the box they were given.
|
|
106
|
+
*/
|
|
107
|
+
function sizeOf(fits, drawn) {
|
|
108
|
+
if (!fits) return {
|
|
109
|
+
root: {},
|
|
110
|
+
picture: void 0
|
|
111
|
+
};
|
|
112
|
+
const beside = stacksSplit(drawn) ? 1 : drawn.series.length;
|
|
113
|
+
const height = lyingHeight(drawn.points.length, beside);
|
|
114
|
+
return {
|
|
115
|
+
root: {
|
|
116
|
+
...fitted(true),
|
|
117
|
+
style: { height: "auto" }
|
|
118
|
+
},
|
|
119
|
+
picture: {
|
|
120
|
+
flex: "none",
|
|
121
|
+
height,
|
|
122
|
+
maxHeight: FIT_MOST
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* A split's legend under a picture that is as tall as its rows, outside it: however many lines
|
|
128
|
+
* its names wrap to, they add to the tile's height and take none of the bars'. Inside the
|
|
129
|
+
* picture, ten names on a phone left Recharts no plot at all. It is for the eye, as the
|
|
130
|
+
* picture is: the chart's table names every series.
|
|
131
|
+
*/
|
|
132
|
+
function SplitKey({ painted, shown }) {
|
|
133
|
+
if (!shown || painted.length < 2) return null;
|
|
134
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
135
|
+
className: "dd-chart-key",
|
|
136
|
+
"aria-hidden": "true",
|
|
137
|
+
children: painted.map(({ series, color }) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsx("span", {
|
|
138
|
+
className: "dd-chart-key-swatch",
|
|
139
|
+
style: { background: color }
|
|
140
|
+
}), series.label] }, series.key))
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
/** Whether a legend is drawn in the picture: for several series, unless it is drawn under it (`SplitKey`). */
|
|
144
|
+
const legendInside = (series, fits) => series > 1 && !fits;
|
|
145
|
+
/**
|
|
88
146
|
* Whether a split's parts stack into a whole: only where the answer says its measure adds up,
|
|
89
147
|
* which core's `addsUp` reads. The parts of an average or a rate stand side by side, since a
|
|
90
148
|
* column of one on another would reach a total that means nothing; so do the parts of an
|
|
@@ -98,67 +156,85 @@ function stacksSplit(drawn) {
|
|
|
98
156
|
* Bars per x value; when a second field splits them, its values stack where the measure adds
|
|
99
157
|
* up (Other on top) and stand side by side where it does not. Bars over
|
|
100
158
|
* time stand up, the bucket still running drawn faint; bars by category lie down, so every
|
|
101
|
-
* name has room to be read and none is skipped.
|
|
159
|
+
* name has room to be read and none is skipped. Told to fit, bars by category are as tall as
|
|
160
|
+
* their rows ask; bars over time keep the box they were given.
|
|
102
161
|
*/
|
|
103
162
|
function BarTile(props) {
|
|
104
163
|
const { answer, locale, drill } = props;
|
|
105
164
|
const [focused, setFocused] = useState(null);
|
|
165
|
+
const tap = useTapPreview(sameMark);
|
|
106
166
|
const drawn = toSeries(answer, props, props.slots);
|
|
107
167
|
const { points, series } = drawn;
|
|
108
168
|
const split = stacksSplit(drawn);
|
|
109
169
|
const painted = seriesColors(props, series);
|
|
110
170
|
const overTime = answer.columns[0]?.type === "time" || answer.columns[0]?.grain !== void 0;
|
|
111
|
-
const
|
|
112
|
-
|
|
171
|
+
const values = yAxis(series, points, locale, {
|
|
172
|
+
zero: "always",
|
|
173
|
+
stacked: split
|
|
174
|
+
});
|
|
175
|
+
const fits = props.fit === true && !overTime;
|
|
176
|
+
const size = sizeOf(fits, drawn);
|
|
177
|
+
const legend = legendInside(series.length, fits);
|
|
113
178
|
return /* @__PURE__ */ jsxs("div", {
|
|
114
179
|
className: "dd-chart",
|
|
115
180
|
"data-drillable": drill !== void 0,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
181
|
+
...size.root,
|
|
182
|
+
...tap.handlers,
|
|
183
|
+
children: [
|
|
184
|
+
/* @__PURE__ */ jsx("div", {
|
|
185
|
+
className: "dd-chart-picture",
|
|
186
|
+
"aria-hidden": "true",
|
|
187
|
+
style: size.picture,
|
|
188
|
+
children: /* @__PURE__ */ jsx(ResponsiveContainer, { children: /* @__PURE__ */ jsxs(BarChart, {
|
|
189
|
+
...chartOf(overTime, values),
|
|
190
|
+
data: points,
|
|
191
|
+
maxBarSize: overTime ? 56 : 28,
|
|
192
|
+
barGap: overTime ? 4 : 2,
|
|
193
|
+
layout: overTime ? "horizontal" : "vertical",
|
|
194
|
+
children: [
|
|
195
|
+
/* @__PURE__ */ jsx(CartesianGrid, {
|
|
196
|
+
stroke: GRID,
|
|
197
|
+
vertical: !overTime,
|
|
198
|
+
horizontal: overTime
|
|
199
|
+
}),
|
|
200
|
+
barAxes(overTime, values, points),
|
|
201
|
+
/* @__PURE__ */ jsx(Tooltip, {
|
|
202
|
+
...TOOLTIP,
|
|
203
|
+
formatter: tooltipFormat(props, drawn),
|
|
204
|
+
labelFormatter: tooltipLabel(props, drawn)
|
|
205
|
+
}),
|
|
206
|
+
legend ? /* @__PURE__ */ jsx(Legend, {
|
|
207
|
+
itemSorter: null,
|
|
208
|
+
formatter: legendText
|
|
209
|
+
}) : null,
|
|
210
|
+
painted.map(({ series: s, color }, i) => /* @__PURE__ */ jsx(Bar, {
|
|
211
|
+
dataKey: s.key,
|
|
212
|
+
name: s.label,
|
|
213
|
+
fill: color,
|
|
214
|
+
...split ? {
|
|
215
|
+
stackId: "split",
|
|
216
|
+
stroke: "var(--dd-surface)",
|
|
217
|
+
strokeWidth: 2
|
|
218
|
+
} : {},
|
|
219
|
+
radius: barRadius(split && i < series.length - 1, overTime),
|
|
220
|
+
isAnimationActive: false,
|
|
221
|
+
...barClick(drill, drawn, s, tap.tap),
|
|
222
|
+
shape: barShape(focused ?? tap.shown, s.key, drawn)
|
|
223
|
+
}, s.key))
|
|
224
|
+
]
|
|
225
|
+
}) })
|
|
226
|
+
}),
|
|
227
|
+
/* @__PURE__ */ jsx(SplitKey, {
|
|
228
|
+
painted,
|
|
229
|
+
shown: fits
|
|
230
|
+
}),
|
|
231
|
+
/* @__PURE__ */ jsx(Beside, {
|
|
232
|
+
drawn,
|
|
233
|
+
props,
|
|
234
|
+
kind: "bar",
|
|
235
|
+
onFocusMark: setFocused
|
|
236
|
+
})
|
|
237
|
+
]
|
|
162
238
|
});
|
|
163
239
|
}
|
|
164
240
|
export { BarTile, stacksSplit };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { CHART } from "./parts.mjs";
|
|
2
|
+
import { ROW_SIZES } from "derive-dashboards/charts";
|
|
3
|
+
// src/fit.ts
|
|
4
|
+
/** A row of bars lying down at its tallest: the charts kit's own, so the two kits cannot drift apart. */
|
|
5
|
+
const ROW = ROW_SIZES.most;
|
|
6
|
+
/** The value axis under bars lying down: Recharts' own height for an axis along the bottom. */
|
|
7
|
+
const VALUE_AXIS = 30;
|
|
8
|
+
/** The most a chart that fits its rows grows, where no theme says: about sixteen rows. */
|
|
9
|
+
const FIT_MOST = "var(--dd-fit-most, 560px)";
|
|
10
|
+
/**
|
|
11
|
+
* The room one bar takes of a row where several stand side by side: six pixels of bar, two
|
|
12
|
+
* between it and the next (`BAR_GAP`), and its share of the tenth of the row Recharts leaves
|
|
13
|
+
* at each end.
|
|
14
|
+
*/
|
|
15
|
+
const BESIDE = 10;
|
|
16
|
+
/**
|
|
17
|
+
* How tall a row is for so many bars side by side: the row every chart of rows has, which
|
|
18
|
+
* holds up to three, or more where the bars need it. Ten in a row of 34 pixels were hairlines.
|
|
19
|
+
*/
|
|
20
|
+
const rowFor = (beside) => Math.max(ROW, beside * BESIDE);
|
|
21
|
+
/**
|
|
22
|
+
* How tall the picture of bars by category asks to be when the tile is told to fit: a row for
|
|
23
|
+
* each category, as tall as the bars side by side in it need (`beside`; one where a split
|
|
24
|
+
* stacks), with the room above the plot and the value axis under it. Three rows of one bar are
|
|
25
|
+
* 4 + 3 × 34 + 30 = 136 pixels. A split's legend is no part of it: it is drawn under the
|
|
26
|
+
* picture (`SplitKey`), since its names wrap to as many lines as the width leaves them, and
|
|
27
|
+
* lines counted here as one took the rows' room when they were ten. Past the most a tile
|
|
28
|
+
* grows, the theme's cap holds the picture, and Recharts draws the rows thinner.
|
|
29
|
+
*/
|
|
30
|
+
function lyingHeight(rows, beside = 1) {
|
|
31
|
+
return CHART.margin.top + CHART.margin.bottom + rows * rowFor(beside) + VALUE_AXIS;
|
|
32
|
+
}
|
|
33
|
+
export { FIT_MOST, lyingHeight };
|