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
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
import { amountExact, betterMark, pointsExact, pointsText, wentFor } from "../change-text.mjs";
|
|
2
|
+
import { formatCell, numberSent } from "../format.mjs";
|
|
3
|
+
import { headlineWriterOf } from "../headline.mjs";
|
|
4
|
+
import { exactDifference, exactDigits } from "./exact.mjs";
|
|
5
|
+
import { daysBefore } from "./number-period.mjs";
|
|
6
|
+
import { MINUS, cellDigits } from "derive-dashboards/core";
|
|
7
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// src/renderers/number-before.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A cell as its number is read: a number a driver sent as text, in a column of numbers, is its
|
|
11
|
+
* digits, as the headline above writes it (`numberSent`). Any other cell is itself.
|
|
12
|
+
*/
|
|
13
|
+
function readOf(cell, column) {
|
|
14
|
+
const sent = typeof cell === "string" ? numberSent(cell, column) : void 0;
|
|
15
|
+
return sent === void 0 ? cell : {
|
|
16
|
+
t: "decimal",
|
|
17
|
+
v: sent.v
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/** A cell's number as it is held: a float, or an exact amount's digits read as one. */
|
|
21
|
+
const held = (cell) => cell !== null && typeof cell === "object" && "v" in cell ? Number(cell.v) : NaN;
|
|
22
|
+
/**
|
|
23
|
+
* A cell as a number to compare, for the change against the period before. None for what is no
|
|
24
|
+
* amount: no value, words, and a float that is not a number or has no end (NaN, an infinity).
|
|
25
|
+
*/
|
|
26
|
+
const numberOf = (cell) => {
|
|
27
|
+
const value = typeof cell === "number" ? cell : held(cell);
|
|
28
|
+
return Number.isFinite(value) ? value : void 0;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Two floats that agree to this many parts are one number written twice: the average of 0.1,
|
|
32
|
+
* 0.2 and 0.6 is 0.30000000000000004, which did not move from 0.3.
|
|
33
|
+
*/
|
|
34
|
+
const FLOAT_NOISE = 1e-12;
|
|
35
|
+
/**
|
|
36
|
+
* now − was of two floats as each is written (the shortest digits that read back as it), so
|
|
37
|
+
* 0.440000001 less 0.44 is 0.000000001, where the floats' own difference is 9.99999971718E−10.
|
|
38
|
+
* None when either is not written as a plain decimal.
|
|
39
|
+
*/
|
|
40
|
+
function writtenDifference(now, was) {
|
|
41
|
+
const [a, b] = [cellDigits(now), cellDigits(was)];
|
|
42
|
+
return a === void 0 || b === void 0 ? void 0 : exactDifference(a, b, "decimal").size;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* now − was in floats, for values that are not exact digits. None when either is no number to
|
|
46
|
+
* compare, or their difference is past what a float holds: the line then says only what it was.
|
|
47
|
+
* Which way it went, whether it moved at all and how far a reader takes it to have moved are
|
|
48
|
+
* the floats' own; how far it moved as it is, is by their written digits where they have them.
|
|
49
|
+
*/
|
|
50
|
+
function floatDifference(now, was) {
|
|
51
|
+
const [x, y] = [numberOf(now), numberOf(was)];
|
|
52
|
+
if (x === void 0 || y === void 0 || !Number.isFinite(x - y)) return void 0;
|
|
53
|
+
const size = Math.abs(x - y);
|
|
54
|
+
const same = size <= FLOAT_NOISE * Math.max(Math.abs(x), Math.abs(y));
|
|
55
|
+
const written = writtenDifference(now, was);
|
|
56
|
+
return {
|
|
57
|
+
sign: same ? 0 : Math.sign(x - y),
|
|
58
|
+
size,
|
|
59
|
+
...written === void 0 ? {} : { written }
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* now − was exactly, where both are exact digits and their column is not one of floats (a 2^53
|
|
64
|
+
* amount that moved by 1 moved by 1). A column of floats is held to a float's figures though
|
|
65
|
+
* its values be whole numbers: 1,000,000,000,001 did not move from 1,000,000,000,000 there.
|
|
66
|
+
*/
|
|
67
|
+
function exactOf(now, was, column) {
|
|
68
|
+
const [a, b] = [exactDigits(now), exactDigits(was)];
|
|
69
|
+
if (column.type === "float" || a === void 0 || b === void 0) return void 0;
|
|
70
|
+
const type = typeof now === "object" && now !== null && "t" in now ? now.t : "decimal";
|
|
71
|
+
return exactDifference(a, b, type);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* now − was, exactly where it can be (`exactOf`), else in floats; its sign and its size as a
|
|
75
|
+
* cell to format. Undefined when either is not a number, and for a rate whose move no float
|
|
76
|
+
* holds (exact digits past a float's range): its points cannot be written, and as an amount it
|
|
77
|
+
* would read as an infinite percent, so the line says only what it was.
|
|
78
|
+
*/
|
|
79
|
+
function difference(now, was, column) {
|
|
80
|
+
const delta = exactOf(now, was, column) ?? floatDifference(now, was);
|
|
81
|
+
return column.format === "percent" && numberOf(delta?.size) === void 0 ? void 0 : delta;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The size of a rate's change, as its column holds its values (a fraction of one, or points).
|
|
85
|
+
* Two floats' change is read from their written digits, so half a tenth of a point is that
|
|
86
|
+
* whatever rate it moved from, where the floats' own difference falls a hair to either side.
|
|
87
|
+
* None for a column that is no rate.
|
|
88
|
+
*/
|
|
89
|
+
const rateSize = (delta, column) => column.format === "percent" ? numberOf(delta.written ?? delta.size) : void 0;
|
|
90
|
+
/** The least share worth writing: under a twentieth of a percent it would read as no change. */
|
|
91
|
+
const LEAST_SHARE = 5e-4;
|
|
92
|
+
/** The share from which the amount says more: a hundredfold is 10,000%, which no one takes in. */
|
|
93
|
+
const MOST_SHARE = 100;
|
|
94
|
+
/**
|
|
95
|
+
* An amount's change as a share of where it was ("14%"), written as any percent is: none from
|
|
96
|
+
* nothing or from less than nothing, where a share says nothing, none where the share is too
|
|
97
|
+
* small to write (an amount of 2^53 that moved by 1), and none from a hundredfold up (a move
|
|
98
|
+
* from next to nothing). The amount is said then.
|
|
99
|
+
*/
|
|
100
|
+
function shareText(size, was, props) {
|
|
101
|
+
const [moved, base] = [numberOf(size), numberOf(was)];
|
|
102
|
+
if (moved === void 0 || base === void 0 || base <= 0) return void 0;
|
|
103
|
+
const share = moved / base;
|
|
104
|
+
if (!(share >= LEAST_SHARE) || share >= MOST_SHARE) return void 0;
|
|
105
|
+
return formatCell(share, {
|
|
106
|
+
format: "percent",
|
|
107
|
+
fraction: true
|
|
108
|
+
}, props);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* An amount that moved, written beside the headline: a length of time in the unit the headline
|
|
112
|
+
* is written in ("0.8 days" by "4.8 days", never "19.2 hr"). It is written by its own size, not
|
|
113
|
+
* in the headline's places: a move of 51 cents under "$27,001" is "$0.51", never "$1".
|
|
114
|
+
*/
|
|
115
|
+
function amountMoved(size, at) {
|
|
116
|
+
const shown = numberOf(at.now);
|
|
117
|
+
const beside = shown === void 0 ? at.column : {
|
|
118
|
+
...at.column,
|
|
119
|
+
beside: shown
|
|
120
|
+
};
|
|
121
|
+
return headlineWriterOf(at.props.widget)(size, beside, at.props);
|
|
122
|
+
}
|
|
123
|
+
/** How far the number moved, as a reader takes it in: points for a rate, else a share, else the amount. */
|
|
124
|
+
function movedText(delta, was, at) {
|
|
125
|
+
const { column, props } = at;
|
|
126
|
+
const rate = rateSize(delta, column);
|
|
127
|
+
if (rate !== void 0) return pointsText(rate, column, props);
|
|
128
|
+
return shareText(delta.size, was, props) ?? amountMoved(delta.size, at);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* The change as it is, without a sign, for whoever asks: a rate's in points, never as a percent
|
|
132
|
+
* of a percent; an amount's with every digit it holds, where the line itself rounds.
|
|
133
|
+
*/
|
|
134
|
+
function exactText(delta, column, props) {
|
|
135
|
+
const float = delta.written !== void 0;
|
|
136
|
+
const size = delta.written ?? delta.size;
|
|
137
|
+
return rateSize(delta, column) === void 0 ? amountExact(size, column, {
|
|
138
|
+
...props,
|
|
139
|
+
float
|
|
140
|
+
}) : pointsExact(size, column, {
|
|
141
|
+
...props,
|
|
142
|
+
float
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/** How the number moved from what it was, or undefined when it did not. */
|
|
146
|
+
function movedOf(delta, was, at) {
|
|
147
|
+
if (delta.sign === 0) return void 0;
|
|
148
|
+
const up = delta.sign > 0;
|
|
149
|
+
const { signed: _signed, ...plain } = at.column;
|
|
150
|
+
const way = up ? "up" : "down";
|
|
151
|
+
const went = wentFor(at.column, way);
|
|
152
|
+
return {
|
|
153
|
+
way,
|
|
154
|
+
size: movedText(delta, was, {
|
|
155
|
+
...at,
|
|
156
|
+
column: plain
|
|
157
|
+
}),
|
|
158
|
+
exact: `${up ? "+" : MINUS}${exactText(delta, plain, at.props)}`,
|
|
159
|
+
...went === void 0 ? {} : { went }
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const ARROW = {
|
|
163
|
+
up: "↑",
|
|
164
|
+
down: "↓"
|
|
165
|
+
};
|
|
166
|
+
/** The word for a change for the better or the worse, in the host's words. */
|
|
167
|
+
const wentWord = (went, props) => went === "better" ? props.messages.changeBetter : props.messages.changeWorse;
|
|
168
|
+
/** Every place a part is written in a sentence. */
|
|
169
|
+
function placesOf(sentence, part) {
|
|
170
|
+
const places = [];
|
|
171
|
+
for (let at = sentence.indexOf(part); at !== -1; at = sentence.indexOf(part, at + 1)) places.push(at);
|
|
172
|
+
return places;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Where a sentence wrote the size: its first writing that leaves room for what the number
|
|
176
|
+
* moved from. A sentence may say that first, and its figures may hold the size's ("−17" holds
|
|
177
|
+
* "17"), so the first match alone could set apart a piece of the wrong number. None when the
|
|
178
|
+
* sentence does not write the size.
|
|
179
|
+
*/
|
|
180
|
+
function sizeAt(sentence, size, was) {
|
|
181
|
+
const sizes = placesOf(sentence, size);
|
|
182
|
+
const froms = placesOf(sentence, was);
|
|
183
|
+
const clear = (at) => froms.some((from) => at + size.length <= from || from + was.length <= at);
|
|
184
|
+
return sizes.find((at) => clear(at)) ?? sizes[0] ?? -1;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The line when the number moved: the arrow and the word for it, then the sentence the host's
|
|
188
|
+
* words make of how far and from what (`changeSeen`). The size is set apart wherever the
|
|
189
|
+
* sentence puts it, since a language may say what it moved from first.
|
|
190
|
+
*/
|
|
191
|
+
function MovedLine({ moved, from, props }) {
|
|
192
|
+
const word = moved.way === "up" ? props.messages.changeUp : props.messages.changeDown;
|
|
193
|
+
const went = moved.went === void 0 ? void 0 : wentWord(moved.went, props);
|
|
194
|
+
const sentence = props.messages.changeSeen({
|
|
195
|
+
size: moved.size,
|
|
196
|
+
...from
|
|
197
|
+
});
|
|
198
|
+
const at = sizeAt(sentence, moved.size, from.was);
|
|
199
|
+
const [lead, rest] = at === -1 ? [sentence, ""] : [sentence.slice(0, at), sentence.slice(at + moved.size.length)];
|
|
200
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
201
|
+
/* @__PURE__ */ jsx("span", {
|
|
202
|
+
className: "dd-number-way",
|
|
203
|
+
"data-way": moved.way,
|
|
204
|
+
...betterMark(moved.went),
|
|
205
|
+
title: went,
|
|
206
|
+
"aria-hidden": "true",
|
|
207
|
+
children: ARROW[moved.way]
|
|
208
|
+
}),
|
|
209
|
+
" ",
|
|
210
|
+
/* @__PURE__ */ jsxs("span", {
|
|
211
|
+
className: "dd-sr-only",
|
|
212
|
+
children: [word, " "]
|
|
213
|
+
}),
|
|
214
|
+
lead,
|
|
215
|
+
at === -1 ? null : /* @__PURE__ */ jsx("span", {
|
|
216
|
+
className: "dd-number-moved",
|
|
217
|
+
"data-way": moved.way,
|
|
218
|
+
...betterMark(moved.went),
|
|
219
|
+
title: moved.exact,
|
|
220
|
+
children: moved.size
|
|
221
|
+
}),
|
|
222
|
+
rest,
|
|
223
|
+
went === void 0 ? null : /* @__PURE__ */ jsxs("span", {
|
|
224
|
+
className: "dd-sr-only",
|
|
225
|
+
children: [
|
|
226
|
+
" (",
|
|
227
|
+
went,
|
|
228
|
+
")"
|
|
229
|
+
]
|
|
230
|
+
})
|
|
231
|
+
] });
|
|
232
|
+
}
|
|
233
|
+
/** The line in words alone, for the mark's name: "up 14.5% (+462) from 3,189 in the 13 weeks before". */
|
|
234
|
+
function spokenOf(moved, from, props) {
|
|
235
|
+
if (moved === void 0) return props.messages.changeNone(from);
|
|
236
|
+
const exact = moved.size === moved.exact.slice(1) ? void 0 : moved.exact;
|
|
237
|
+
const said = {
|
|
238
|
+
way: moved.way,
|
|
239
|
+
size: moved.size,
|
|
240
|
+
exact,
|
|
241
|
+
...from
|
|
242
|
+
};
|
|
243
|
+
return props.messages.changeSaid(moved.went === void 0 ? said : {
|
|
244
|
+
...said,
|
|
245
|
+
better: moved.went
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
/** Whether a cell is a float that is no number to write: NaN, or an infinity. */
|
|
249
|
+
const noNumber = (cell) => typeof cell === "number" && !Number.isFinite(cell);
|
|
250
|
+
/**
|
|
251
|
+
* What the answer says of the period before, for the column shown large; none when it says
|
|
252
|
+
* nothing, or what it says is no number (a rate over no rows may come back as NaN).
|
|
253
|
+
*/
|
|
254
|
+
function wasOf(answer, index) {
|
|
255
|
+
const row = answer.compare?.rows[0];
|
|
256
|
+
const column = answer.columns[index];
|
|
257
|
+
if (row === void 0 || column === void 0) return void 0;
|
|
258
|
+
const was = readOf(row[index], column) ?? null;
|
|
259
|
+
return was === null || noNumber(was) ? void 0 : {
|
|
260
|
+
row,
|
|
261
|
+
column,
|
|
262
|
+
was
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
/** What the line says, to the eye and in the mark's name: how the number moved from what, or only what it was. */
|
|
266
|
+
function lineOf(props, before, index) {
|
|
267
|
+
const { column, was } = before;
|
|
268
|
+
const read = readOf(props.answer.rows[0]?.[index], column);
|
|
269
|
+
const now = read ?? null;
|
|
270
|
+
const wasText = headlineWriterOf(props.widget)(was, column, props, now);
|
|
271
|
+
const delta = difference(read, was, column);
|
|
272
|
+
if (delta === void 0) {
|
|
273
|
+
const only = props.messages.drillBefore(wasText);
|
|
274
|
+
return {
|
|
275
|
+
seen: only,
|
|
276
|
+
spoken: only,
|
|
277
|
+
moved: false
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
const moved = movedOf(delta, was, {
|
|
281
|
+
column,
|
|
282
|
+
props,
|
|
283
|
+
now
|
|
284
|
+
});
|
|
285
|
+
const from = {
|
|
286
|
+
was: wasText,
|
|
287
|
+
days: daysBefore(props.answer)
|
|
288
|
+
};
|
|
289
|
+
return {
|
|
290
|
+
seen: moved === void 0 ? props.messages.changeNone(from) : /* @__PURE__ */ jsx(MovedLine, {
|
|
291
|
+
moved,
|
|
292
|
+
from,
|
|
293
|
+
props
|
|
294
|
+
}),
|
|
295
|
+
spoken: spokenOf(moved, from, props),
|
|
296
|
+
moved: moved !== void 0
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* The change against the period before, when the answer compares ("↑ 14% from 3,189 in the 13
|
|
301
|
+
* weeks before"): it opens that period's rows. No value before (a rate over no rows) says
|
|
302
|
+
* nothing, so it is left out.
|
|
303
|
+
*/
|
|
304
|
+
function Before(props) {
|
|
305
|
+
const before = wasOf(props.answer, props.index);
|
|
306
|
+
if (before === void 0) return null;
|
|
307
|
+
const { seen, spoken, moved } = lineOf(props, before, props.index);
|
|
308
|
+
const marks = props.drill?.props(before.row, before.column.id);
|
|
309
|
+
const name = props.messages.drillMark(`${before.column.label}${moved ? "" : ":"} ${spoken}`);
|
|
310
|
+
const named = marks === void 0 ? marks : {
|
|
311
|
+
...marks,
|
|
312
|
+
"aria-label": name
|
|
313
|
+
};
|
|
314
|
+
return /* @__PURE__ */ jsx("span", {
|
|
315
|
+
className: "dd-number-before",
|
|
316
|
+
...named,
|
|
317
|
+
children: seen
|
|
318
|
+
});
|
|
319
|
+
}
|
|
320
|
+
export { Before };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { parseTextTime } from "derive-dashboards/core";
|
|
2
|
+
// src/renderers/number-period.ts
|
|
3
|
+
const DAY_MICROS = 864e8;
|
|
4
|
+
/** Whole days between two instants, to the nearest: a clock change shifts an end by an hour, not a day. */
|
|
5
|
+
const daysBetween = (from, to) => Math.round(Number(to - from) / DAY_MICROS);
|
|
6
|
+
/** How long a span is, in days and parts of one. */
|
|
7
|
+
const daysIn = (from, to) => Number(to - from) / DAY_MICROS;
|
|
8
|
+
/** A range's two ends as instants; none when there is no range, or an end is not a time. */
|
|
9
|
+
function endsOf(range) {
|
|
10
|
+
const [from, to] = [range?.from, range?.to].map((text) => parseTextTime(text ?? ""));
|
|
11
|
+
return from === void 0 || to === void 0 ? void 0 : {
|
|
12
|
+
from,
|
|
13
|
+
to
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
/** A month's days, at their fewest and their most. */
|
|
17
|
+
const MONTH = {
|
|
18
|
+
least: 28,
|
|
19
|
+
most: 31
|
|
20
|
+
};
|
|
21
|
+
/** How far a clock change moves the end of a day: an hour, in a few places two. */
|
|
22
|
+
const CLOCK_SLACK = 1 / 12;
|
|
23
|
+
const near = (a, b) => Math.abs(a - b) <= CLOCK_SLACK;
|
|
24
|
+
/** Whether a span is as long as a month is, give or take a clock change. */
|
|
25
|
+
const monthLong = (days) => days >= MONTH.least - CLOCK_SLACK && days <= MONTH.most + CLOCK_SLACK;
|
|
26
|
+
/**
|
|
27
|
+
* Whether a period is the one just before another, `days` between their starts. It is the
|
|
28
|
+
* answer's own period moved back that many whole days: it ends where the answer starts, or,
|
|
29
|
+
* for an answer that runs to now and so stops partway through its last day, as far short of
|
|
30
|
+
* there as the answer is short of whole days (yesterday up to this hour, against today so
|
|
31
|
+
* far). A period that only stops short of an answer that is whole is not it. Nor is one of
|
|
32
|
+
* another length: four days are not the period just before a single day, nor 91 days the one
|
|
33
|
+
* before 92. A month is the one exception: the month before it is a month too, of up to three
|
|
34
|
+
* days more or fewer, and ends where it starts.
|
|
35
|
+
*/
|
|
36
|
+
function justBefore(before, own, days) {
|
|
37
|
+
const gap = daysIn(before.to, own.from);
|
|
38
|
+
const long = daysIn(own.from, own.to);
|
|
39
|
+
if (gap >= 0 && gap < 1 && near(gap, days - long)) return true;
|
|
40
|
+
return near(gap, 0) && monthLong(days) && monthLong(long);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* How long the period before is, in days, when it is the one just before the answer's own
|
|
44
|
+
* (`justBefore`): "in the 13 weeks before". None for the same period a year before, which is
|
|
45
|
+
* not before in that sense, and none where a range is not known.
|
|
46
|
+
*/
|
|
47
|
+
function daysBefore(answer) {
|
|
48
|
+
const before = endsOf(answer.compare?.range);
|
|
49
|
+
const own = before === void 0 ? void 0 : endsOf(answer.receipt.range);
|
|
50
|
+
if (before === void 0 || own === void 0) return void 0;
|
|
51
|
+
const days = daysBetween(before.from, own.from);
|
|
52
|
+
return days > 0 && justBefore(before, own, days) ? days : void 0;
|
|
53
|
+
}
|
|
54
|
+
export { daysBefore };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { wholeAnswer } from "derive-dashboards/core";
|
|
2
|
+
// src/renderers/number-whole.ts
|
|
3
|
+
/**
|
|
4
|
+
* The answer a number tile reads its figures from. An answer with a whole (`time.whole`) is
|
|
5
|
+
* read as its whole: the whole's columns and rows, and the comparison's whole as the
|
|
6
|
+
* comparison's rows, so the headline, its second figure, its change and the line under it
|
|
7
|
+
* are the whole range's and never a bucket's. A comparison with no whole has no rows to read,
|
|
8
|
+
* so the line under the number is left out. The rows are the answer's own, so a drill finds
|
|
9
|
+
* them where the answer holds them. An answer with no whole is read as it is.
|
|
10
|
+
*/
|
|
11
|
+
function figuresAnswer(answer) {
|
|
12
|
+
const whole = wholeAnswer(answer);
|
|
13
|
+
if (whole === void 0) return answer;
|
|
14
|
+
const { time: _time, whole: _whole, compare, ...rest } = answer;
|
|
15
|
+
if (compare === void 0) return {
|
|
16
|
+
...rest,
|
|
17
|
+
...whole
|
|
18
|
+
};
|
|
19
|
+
const { time: _before, whole: before, ...kept } = compare;
|
|
20
|
+
return {
|
|
21
|
+
...rest,
|
|
22
|
+
...whole,
|
|
23
|
+
compare: {
|
|
24
|
+
...kept,
|
|
25
|
+
rows: before?.rows ?? []
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export { figuresAnswer };
|
|
@@ -2,8 +2,8 @@ import { LinkComponent } from "../context.mjs";
|
|
|
2
2
|
import { TileDrill } from "../drill/props.mjs";
|
|
3
3
|
import { Messages } from "../messages.mjs";
|
|
4
4
|
import { SeriesSlots } from "../series-slots.mjs";
|
|
5
|
-
import { ReactNode } from "react";
|
|
6
5
|
import { TileAnswer, Widget } from "derive-dashboards/core";
|
|
6
|
+
import { ReactNode } from "react";
|
|
7
7
|
/**
|
|
8
8
|
* What a renderer draws, and how: pass the props as `formatCell`'s format to use both. `drill`
|
|
9
9
|
* is there when drilling is on: spread `drill.props(row, entry)` on a mark to make it open.
|
|
@@ -21,6 +21,29 @@ export type TileRendererProps = {
|
|
|
21
21
|
* same on every tile and under every filter.
|
|
22
22
|
*/
|
|
23
23
|
slots?: SeriesSlots;
|
|
24
|
+
/**
|
|
25
|
+
* The zone the answer's days are cut in (`answer.receipt.calendar.timezone`). `formatCell`
|
|
26
|
+
* reads it off these props, so an instant and an hour's bucket are written in the
|
|
27
|
+
* dashboard's zone on a tile, as they are in its drill.
|
|
28
|
+
*/
|
|
29
|
+
timeZone?: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether the tile is as tall as what it holds, which it is on a dashboard, read or edited: a
|
|
32
|
+
* table then draws its first rows and a button for the rest, a list likewise, and a chart of
|
|
33
|
+
* rows lying down as many as it has, and the tile's row on the grid is as tall as that. A
|
|
34
|
+
* renderer that sizes itself so says it on its root (`{...fitted(fit)}`); one that does
|
|
35
|
+
* not fills the rows its tile was given. Left out for a tile on a page of the host's own:
|
|
36
|
+
* there a tile fills its box, and scrolls inside it.
|
|
37
|
+
*/
|
|
38
|
+
fit?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* What a renderer spreads on its root element to say it is as tall as what it holds, when it is
|
|
42
|
+
* told to be (`fit`): the mark the theme sizes a tile by (`data-fit="content"`), and nothing
|
|
43
|
+
* when the tile fills its box. Written here once, so a renderer cannot misspell it.
|
|
44
|
+
*/
|
|
45
|
+
export declare const fitted: (fit: boolean | undefined) => {
|
|
46
|
+
"data-fit"?: "content";
|
|
24
47
|
};
|
|
25
48
|
/** Draws one tile's answer. Register more by widget kind on the provider. */
|
|
26
49
|
export type TileRenderer = (props: TileRendererProps) => ReactNode;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// src/renderers/props.ts
|
|
2
|
+
/**
|
|
3
|
+
* What a renderer spreads on its root element to say it is as tall as what it holds, when it is
|
|
4
|
+
* told to be (`fit`): the mark the theme sizes a tile by (`data-fit="content"`), and nothing
|
|
5
|
+
* when the tile fills its box. Written here once, so a renderer cannot misspell it.
|
|
6
|
+
*/
|
|
7
|
+
const fitted = (fit) => fit === true ? { "data-fit": "content" } : {};
|
|
8
|
+
export { fitted };
|
|
@@ -1,10 +1,43 @@
|
|
|
1
|
+
import { groupName } from "../bucket-name.mjs";
|
|
2
|
+
import { betterMark, wentFor } from "../change-text.mjs";
|
|
1
3
|
import { isNumeric, isValue } from "../columns.mjs";
|
|
2
4
|
import { compareGroupLabel } from "../drill/words.mjs";
|
|
3
|
-
import { formatCell,
|
|
5
|
+
import { formatCell, plotValue } from "../format.mjs";
|
|
4
6
|
import { depthOf, reachOf } from "./table-scale.mjs";
|
|
7
|
+
import { valueText } from "./table-whole.mjs";
|
|
5
8
|
import { isMark } from "derive-dashboards/core";
|
|
6
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
10
|
// src/renderers/table-cells.tsx
|
|
11
|
+
/** A row that opens whole: the row takes a click anywhere, the button in its heading cell the keyboard. */
|
|
12
|
+
function rowMark(marks) {
|
|
13
|
+
if (marks === void 0) return {
|
|
14
|
+
row: void 0,
|
|
15
|
+
button: void 0
|
|
16
|
+
};
|
|
17
|
+
const { role: _role, onClick, ...button } = marks;
|
|
18
|
+
return {
|
|
19
|
+
row: {
|
|
20
|
+
onClick,
|
|
21
|
+
"data-drill": ""
|
|
22
|
+
},
|
|
23
|
+
button
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A cell's content, inside the button that opens it when the cell is a mark. A card's cell is
|
|
28
|
+
* led by its column's name (`label`), and the button holds that too: one box then lays the
|
|
29
|
+
* name, the value and its bar on a line, and the whole line opens the cell.
|
|
30
|
+
*/
|
|
31
|
+
function Marked(props) {
|
|
32
|
+
const { mark, label, children } = props;
|
|
33
|
+
if (mark === void 0) return /* @__PURE__ */ jsxs(Fragment, { children: [label, children] });
|
|
34
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
35
|
+
type: "button",
|
|
36
|
+
className: "dd-cell-mark",
|
|
37
|
+
...mark,
|
|
38
|
+
children: [label, children]
|
|
39
|
+
});
|
|
40
|
+
}
|
|
8
41
|
/** The tone of a value's bar: the rest in grey, a value below zero in the warning colour, else the first series' colour. */
|
|
9
42
|
function toneOf(cell, other) {
|
|
10
43
|
if (other) return "other";
|
|
@@ -69,61 +102,133 @@ function valueBody(text, cell, at, how) {
|
|
|
69
102
|
children: text
|
|
70
103
|
}) : text;
|
|
71
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Whether a cell of a column of changes is for the better or the worse, by its own value's
|
|
107
|
+
* sign, where the column says which way is better. None for no change, no value, or a column
|
|
108
|
+
* that is no change: a level is never good or bad by itself.
|
|
109
|
+
*/
|
|
110
|
+
function wentOf(cell, column) {
|
|
111
|
+
if (column.signed !== true) return void 0;
|
|
112
|
+
const sign = Math.sign(plotValue(cell) ?? 0);
|
|
113
|
+
if (sign !== 1 && sign !== -1) return void 0;
|
|
114
|
+
return wentFor(column, sign === 1 ? "up" : "down");
|
|
115
|
+
}
|
|
116
|
+
/** For a screen reader, after the value: the colour of a change is never the only thing that says it. */
|
|
117
|
+
function WentWord({ went, messages }) {
|
|
118
|
+
if (went === void 0) return null;
|
|
119
|
+
return /* @__PURE__ */ jsx("span", {
|
|
120
|
+
className: "dd-sr-only",
|
|
121
|
+
children: went === "better" ? messages.changeBetter : messages.changeWorse
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* An amount written in whole units is in full a pointer away. It is written as the pointer moves over
|
|
126
|
+
* the cell, never for every cell drawn, and again on each move, so it is the amount the cell holds now.
|
|
127
|
+
*/
|
|
128
|
+
function fullOn(text, props) {
|
|
129
|
+
const { cell, column, at } = props;
|
|
130
|
+
if (!at.whole.has(column.id)) return;
|
|
131
|
+
return ({ currentTarget }) => {
|
|
132
|
+
const full = formatCell(cell, column, at.format);
|
|
133
|
+
if (full === text) currentTarget.removeAttribute("title");
|
|
134
|
+
else currentTarget.title = full;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
72
137
|
/** A cell of a column of values: its number, with its bar or its shade when the column draws one. */
|
|
73
138
|
function ValueCell(props) {
|
|
74
|
-
const { cell, column, at,
|
|
139
|
+
const { cell, column, at, mark } = props;
|
|
75
140
|
const Tag = at.heading ? "th" : "td";
|
|
76
141
|
const how = at.total || cell === null ? void 0 : at.measured.get(column.id);
|
|
77
|
-
const text = how?.texts.get(at.place) ??
|
|
142
|
+
const text = how?.texts.get(at.place) ?? valueText(cell, column, at);
|
|
78
143
|
const shade = shadeOf(cell, how);
|
|
79
|
-
|
|
144
|
+
const went = wentOf(cell, column);
|
|
145
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
80
146
|
"data-numeric": "true",
|
|
147
|
+
...betterMark(went),
|
|
148
|
+
onPointerMove: fullOn(text, props),
|
|
81
149
|
"data-empty": cell === null ? "true" : void 0,
|
|
82
150
|
"data-heat": shade === void 0 ? void 0 : "true",
|
|
83
151
|
style: shade,
|
|
84
152
|
...semantics(at),
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
153
|
+
children: /* @__PURE__ */ jsxs(Marked, {
|
|
154
|
+
mark,
|
|
155
|
+
label: /* @__PURE__ */ jsx(Label, {
|
|
156
|
+
column,
|
|
157
|
+
at
|
|
158
|
+
}),
|
|
159
|
+
children: [valueBody(text, cell, at, how), /* @__PURE__ */ jsx(WentWord, {
|
|
160
|
+
went,
|
|
161
|
+
messages: at.format.messages
|
|
162
|
+
})]
|
|
163
|
+
})
|
|
90
164
|
});
|
|
91
165
|
}
|
|
92
166
|
/** A cell of words: yes or no as a badge, anything else on one line, cut where it has no room. */
|
|
93
|
-
function WordCell(
|
|
167
|
+
function WordCell(props) {
|
|
168
|
+
const { cell, column, at, mark } = props;
|
|
94
169
|
const Tag = at.heading ? "th" : "td";
|
|
95
|
-
if (typeof cell === "boolean") return /* @__PURE__ */
|
|
170
|
+
if (typeof cell === "boolean") return /* @__PURE__ */ jsx(Tag, {
|
|
96
171
|
...semantics(at),
|
|
97
|
-
children:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
children:
|
|
104
|
-
|
|
172
|
+
children: /* @__PURE__ */ jsx(Marked, {
|
|
173
|
+
mark,
|
|
174
|
+
label: /* @__PURE__ */ jsx(Label, {
|
|
175
|
+
column,
|
|
176
|
+
at
|
|
177
|
+
}),
|
|
178
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
179
|
+
className: "dd-badge",
|
|
180
|
+
"data-tone": cell ? "accent" : "neutral",
|
|
181
|
+
children: formatCell(cell, column, at.format)
|
|
182
|
+
})
|
|
183
|
+
})
|
|
105
184
|
});
|
|
106
|
-
const text =
|
|
107
|
-
|
|
185
|
+
const text = groupName(at, {
|
|
186
|
+
cell,
|
|
187
|
+
column
|
|
188
|
+
}, at.format);
|
|
189
|
+
const none = cell === null && !at.heading;
|
|
190
|
+
return /* @__PURE__ */ jsx(Tag, {
|
|
108
191
|
"data-empty": cell === null ? "true" : void 0,
|
|
192
|
+
"data-numeric": isNumeric(column) ? "true" : void 0,
|
|
193
|
+
title: none ? text : void 0,
|
|
109
194
|
...semantics(at),
|
|
110
|
-
children:
|
|
111
|
-
|
|
112
|
-
|
|
195
|
+
children: /* @__PURE__ */ jsx(Marked, {
|
|
196
|
+
mark,
|
|
197
|
+
label: /* @__PURE__ */ jsx(Label, {
|
|
198
|
+
column,
|
|
199
|
+
at
|
|
200
|
+
}),
|
|
201
|
+
children: none ? /* @__PURE__ */ jsx(NoValue, { text }) : /* @__PURE__ */ jsx("span", {
|
|
202
|
+
className: "dd-table-text",
|
|
203
|
+
children: text
|
|
204
|
+
})
|
|
205
|
+
})
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/** No value, in a column that is not the row's name: a dash for the eye, the words ("No coupon") for a screen reader. */
|
|
209
|
+
function NoValue({ text }) {
|
|
210
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
211
|
+
className: "dd-table-text",
|
|
212
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
213
|
+
"aria-hidden": "true",
|
|
214
|
+
children: "–"
|
|
113
215
|
}), /* @__PURE__ */ jsx("span", {
|
|
114
|
-
className: "dd-
|
|
216
|
+
className: "dd-sr-only",
|
|
115
217
|
children: text
|
|
116
218
|
})]
|
|
117
219
|
});
|
|
118
220
|
}
|
|
119
221
|
/** One cell: a mark that folds dimensions as the row's heading, a value, or words. */
|
|
120
222
|
function Cell$1(props) {
|
|
121
|
-
const { cell, column, at } = props;
|
|
223
|
+
const { cell, column, at, mark } = props;
|
|
122
224
|
if (isMark(cell) || column === void 0) return /* @__PURE__ */ jsx("th", {
|
|
123
225
|
scope: "row",
|
|
124
226
|
colSpan: props.span,
|
|
125
227
|
role: at.cards ? "rowheader" : void 0,
|
|
126
|
-
children:
|
|
228
|
+
children: /* @__PURE__ */ jsx(Marked, {
|
|
229
|
+
mark,
|
|
230
|
+
children: formatCell(cell, column, at.format)
|
|
231
|
+
})
|
|
127
232
|
});
|
|
128
233
|
if (props.compare) {
|
|
129
234
|
const text = formatCell(cell, column, at.format);
|
|
@@ -149,11 +254,12 @@ function Cell$1(props) {
|
|
|
149
254
|
cell,
|
|
150
255
|
column,
|
|
151
256
|
at,
|
|
152
|
-
|
|
257
|
+
mark
|
|
153
258
|
}) : /* @__PURE__ */ jsx(WordCell, {
|
|
154
259
|
cell,
|
|
155
260
|
column,
|
|
156
|
-
at
|
|
261
|
+
at,
|
|
262
|
+
mark
|
|
157
263
|
});
|
|
158
264
|
}
|
|
159
|
-
export { Cell$1 as Cell };
|
|
265
|
+
export { Cell$1 as Cell, rowMark };
|