derive-dashboards 0.7.1 → 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 +86 -44
- 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 -32
- 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 +51 -9
- 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 +12 -6
- 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/marks/x-axis.mjs +3 -2
- 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.d.mts +25 -25
- package/dist/charts/theme.mjs +47 -30
- 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 +11 -8
- package/dist/core/document/display.mjs +26 -3
- 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 -18
- package/dist/core/time/bucket.mjs +12 -8
- 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.d.mts +6 -1
- package/dist/core/time/zone.mjs +13 -4
- 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 +90 -69
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +15 -1
- package/dist/react/Dashboard.mjs +43 -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 +25 -52
- 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/columns.mjs +9 -1
- 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/board.mjs +1 -0
- package/dist/react/drill/host.mjs +4 -1
- package/dist/react/drill/lazy.mjs +2 -27
- package/dist/react/drill/props.d.mts +19 -8
- package/dist/react/drill/props.mjs +62 -18
- 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 +35 -122
- package/dist/react/headline.d.mts +12 -0
- package/dist/react/headline.mjs +107 -0
- package/dist/react/index.d.mts +20 -17
- package/dist/react/index.mjs +13 -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/place.mjs +4 -2
- 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 +154 -92
- 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 +23 -17
- package/dist/recharts/marks.mjs +2 -1
- package/dist/recharts/parts.mjs +19 -14
- 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 +25 -9
- 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,13 +1,16 @@
|
|
|
1
1
|
import { isValue } from "../columns.mjs";
|
|
2
|
-
import { formatCell } from "../format.mjs";
|
|
2
|
+
import { formatCell, formatTick, isTotal, plotValue } from "../format.mjs";
|
|
3
|
+
import { formatFull, headlineWriterOf } from "../headline.mjs";
|
|
3
4
|
import { answerIds } from "./entries.mjs";
|
|
4
|
-
import {
|
|
5
|
+
import { fitted } from "./props.mjs";
|
|
5
6
|
import { ListTile } from "./list.mjs";
|
|
7
|
+
import { Before } from "./number-before.mjs";
|
|
8
|
+
import { figuresAnswer } from "./number-whole.mjs";
|
|
6
9
|
import { TableTile } from "./table.mjs";
|
|
7
|
-
import { displayOf,
|
|
8
|
-
import {
|
|
10
|
+
import { displayOf, roleOf } from "derive-dashboards/core";
|
|
11
|
+
import { useId } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
9
13
|
// src/renderers/index.tsx
|
|
10
|
-
const isAll = (cell) => isMark(cell) && cell.mark === "all";
|
|
11
14
|
/**
|
|
12
15
|
* The column a number tile shows large: the entry its widget names, else a calc that is not a
|
|
13
16
|
* change (what the query was built to show: a share, a rate), else its first value. The column
|
|
@@ -64,113 +67,172 @@ function Secondary(props) {
|
|
|
64
67
|
});
|
|
65
68
|
}
|
|
66
69
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
70
|
+
* How many characters the headline is, for the theme to size it by: a long amount is set
|
|
71
|
+
* smaller so it fits its tile, where a fixed size would cut it off.
|
|
69
72
|
*/
|
|
70
|
-
|
|
73
|
+
const sizedTo = (shown) => ({ "--dd-chars": shown.length });
|
|
74
|
+
/**
|
|
75
|
+
* The large number: its row (the total row when there is one, else the first), how it is
|
|
76
|
+
* written in full and how it is written large, and what opens the rows behind it. It is
|
|
77
|
+
* written large in whole units from a thousand up, unless its widget asks for it in full.
|
|
78
|
+
*/
|
|
79
|
+
function headlineOf(props, index) {
|
|
71
80
|
const { answer } = props;
|
|
72
|
-
const
|
|
73
|
-
const row = answer.rows.find((cells) => cells.some((cell) => isAll(cell))) ?? answer.rows[0];
|
|
81
|
+
const row = answer.rows.find((cells) => cells.some((cell) => isTotal(cell))) ?? answer.rows[0];
|
|
74
82
|
const cell = row?.[index] ?? null;
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
return /* @__PURE__ */ jsxs("div", {
|
|
78
|
-
className: "dd-number",
|
|
79
|
-
children: [
|
|
80
|
-
/* @__PURE__ */ jsx("span", {
|
|
81
|
-
className: "dd-number-value",
|
|
82
|
-
title: formatCell(cell, answer.columns[index], props),
|
|
83
|
-
...marks,
|
|
84
|
-
children: formatCell(cell, answer.columns[index], props)
|
|
85
|
-
}),
|
|
86
|
-
change === -1 ? null : /* @__PURE__ */ jsx("span", {
|
|
87
|
-
className: "dd-number-change",
|
|
88
|
-
children: formatCell(row?.[change] ?? null, answer.columns[change], props)
|
|
89
|
-
}),
|
|
90
|
-
/* @__PURE__ */ jsx(Before, {
|
|
91
|
-
...props,
|
|
92
|
-
index
|
|
93
|
-
}),
|
|
94
|
-
/* @__PURE__ */ jsx(Secondary, {
|
|
95
|
-
...props,
|
|
96
|
-
row,
|
|
97
|
-
at: second,
|
|
98
|
-
shown: index
|
|
99
|
-
})
|
|
100
|
-
]
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
/** A cell as a number, for the change against the period before. */
|
|
104
|
-
const numberOf = (cell) => {
|
|
105
|
-
if (typeof cell === "number") return cell;
|
|
106
|
-
if (cell !== null && typeof cell === "object" && "v" in cell) return Number(cell.v);
|
|
107
|
-
};
|
|
108
|
-
/** now − was in floats, for values that are not exact digits. */
|
|
109
|
-
function floatDifference(now, was) {
|
|
110
|
-
const [x, y] = [numberOf(now), numberOf(was)];
|
|
111
|
-
if (x === void 0 || y === void 0) return void 0;
|
|
83
|
+
const column = answer.columns[index];
|
|
84
|
+
const shown = headlineWriterOf(props.widget)(cell, column, props);
|
|
112
85
|
return {
|
|
113
|
-
|
|
114
|
-
|
|
86
|
+
row,
|
|
87
|
+
full: formatFull(cell, column, props),
|
|
88
|
+
shown,
|
|
89
|
+
marks: headlineMarks(props, row, column, shown)
|
|
115
90
|
};
|
|
116
91
|
}
|
|
117
|
-
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
92
|
+
/**
|
|
93
|
+
* What opens the rows behind the headline, named by its measure and the number as it is
|
|
94
|
+
* written large: what is seen is what a screen reader says, with what it is a number of
|
|
95
|
+
* ("Revenue $1,487,340").
|
|
96
|
+
*/
|
|
97
|
+
function headlineMarks(props, row, column, shown) {
|
|
98
|
+
if (row === void 0 || column === void 0) return;
|
|
99
|
+
const marks = props.drill?.props(row, column.id, shown);
|
|
100
|
+
const name = props.messages.drillMark(`${column.label} ${shown}`);
|
|
101
|
+
return marks && {
|
|
102
|
+
...marks,
|
|
103
|
+
"aria-label": name
|
|
129
104
|
};
|
|
130
105
|
}
|
|
131
106
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
107
|
+
* The value in full when the headline rounds it: in the page, not only in a `title` that touch
|
|
108
|
+
* and keyboard never reach. It describes the headline to a screen reader, and the theme shows
|
|
109
|
+
* it under the headline while the headline has focus.
|
|
134
110
|
*/
|
|
135
|
-
function
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
111
|
+
function Full({ id, full, shown }) {
|
|
112
|
+
return full === shown ? null : /* @__PURE__ */ jsx("span", {
|
|
113
|
+
className: "dd-number-full",
|
|
114
|
+
id,
|
|
115
|
+
children: full
|
|
116
|
+
});
|
|
139
117
|
}
|
|
140
|
-
/**
|
|
141
|
-
function
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
if (delta === void 0) return props.messages.drillBefore(wasText);
|
|
145
|
-
if (delta.sign === 0) return props.messages.beforeSame(wasText);
|
|
146
|
-
const change = `${delta.sign > 0 ? "+" : "−"}${formatCell(delta.size, column, props)}`;
|
|
147
|
-
return props.messages.beforeChange(change, wasText);
|
|
118
|
+
/** The elements one is read with, as its one attribute; none when there are none. */
|
|
119
|
+
function readWith(...ids) {
|
|
120
|
+
const given = ids.filter((id) => id !== void 0);
|
|
121
|
+
return given.length === 0 ? {} : { "aria-describedby": given.join(" ") };
|
|
148
122
|
}
|
|
149
123
|
/**
|
|
150
|
-
* The
|
|
151
|
-
*
|
|
124
|
+
* The value a number tile shows large, as a column of its answer by bucket: what a small trend
|
|
125
|
+
* beside the number draws. Undefined when the answer has no whole, no buckets, or the tile
|
|
126
|
+
* shows no value. `index` is the column's place in `answer.columns`, so a caller reads
|
|
127
|
+
* `answer.rows[i][index]`; the tile itself reads the whole, whose columns have no time column.
|
|
152
128
|
*/
|
|
153
|
-
function
|
|
154
|
-
const { answer
|
|
155
|
-
|
|
129
|
+
function headlineColumn(props) {
|
|
130
|
+
const { answer } = props;
|
|
131
|
+
if (answer.whole === void 0 || (answer.time?.buckets.length ?? 0) === 0) return void 0;
|
|
132
|
+
const read = figuresAnswer(answer);
|
|
133
|
+
const shown = read.columns[figuresOf({
|
|
134
|
+
...props,
|
|
135
|
+
answer: read
|
|
136
|
+
}).index];
|
|
137
|
+
if (shown === void 0) return void 0;
|
|
138
|
+
const index = answer.columns.findIndex((c) => c.id === shown.id);
|
|
156
139
|
const column = answer.columns[index];
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const text = beforeText(props, column, answer.rows[0]?.[index], was);
|
|
161
|
-
const named = marks === void 0 ? marks : {
|
|
162
|
-
...marks,
|
|
163
|
-
"aria-label": props.messages.drillMark(text)
|
|
140
|
+
return column === void 0 ? void 0 : {
|
|
141
|
+
column,
|
|
142
|
+
index
|
|
164
143
|
};
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* The large number with the small trend beside it (`course`): the trend stands at the number's
|
|
147
|
+
* own height, and the number is sized by its own box (`.dd-number-lead`), so the trend takes
|
|
148
|
+
* none of the room the number reads. With no course the number is as it was.
|
|
149
|
+
*/
|
|
150
|
+
function Lead({ course, children }) {
|
|
151
|
+
if (course === void 0 || course === null) return children;
|
|
152
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
153
|
+
className: "dd-number-head",
|
|
154
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
155
|
+
className: "dd-number-lead",
|
|
156
|
+
children
|
|
157
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
158
|
+
className: "dd-number-course",
|
|
159
|
+
children: course
|
|
160
|
+
})]
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* What a number tile writes: one value, large, from the total row when there is one, else the
|
|
165
|
+
* first row; a change calc (a signed column) under it, the period before, then a second figure
|
|
166
|
+
* when the widget names one. It is handed the answer its figures are read from. A course is
|
|
167
|
+
* laid beside the large value alone: the lines under it keep the tile's whole width.
|
|
168
|
+
*/
|
|
169
|
+
function Figures(props) {
|
|
170
|
+
const { answer, course } = props;
|
|
171
|
+
const { index, second, change } = figuresOf(props);
|
|
172
|
+
const { row, full, shown, marks } = headlineOf(props, index);
|
|
173
|
+
const at = plotValue(row?.[index] ?? null);
|
|
174
|
+
const compact = at === null ? shown : formatTick(at, answer.columns[index], props.locale);
|
|
175
|
+
const id = useId();
|
|
176
|
+
const described = readWith(full === shown ? void 0 : id, marks?.["aria-describedby"]);
|
|
177
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
178
|
+
/* @__PURE__ */ jsxs(Lead, {
|
|
179
|
+
course,
|
|
180
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
181
|
+
className: "dd-number-value",
|
|
182
|
+
title: full,
|
|
183
|
+
style: sizedTo(shown),
|
|
184
|
+
...marks,
|
|
185
|
+
...described,
|
|
186
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
187
|
+
className: "dd-number-whole",
|
|
188
|
+
children: shown
|
|
189
|
+
}), compact.length >= shown.length ? null : /* @__PURE__ */ jsx("span", {
|
|
190
|
+
className: "dd-number-compact",
|
|
191
|
+
"aria-hidden": "true",
|
|
192
|
+
children: compact
|
|
193
|
+
})]
|
|
194
|
+
}), /* @__PURE__ */ jsx(Full, {
|
|
195
|
+
id,
|
|
196
|
+
full,
|
|
197
|
+
shown
|
|
198
|
+
})]
|
|
199
|
+
}),
|
|
200
|
+
change === -1 ? null : /* @__PURE__ */ jsx("span", {
|
|
201
|
+
className: "dd-number-change",
|
|
202
|
+
children: formatCell(row?.[change] ?? null, answer.columns[change], props)
|
|
203
|
+
}),
|
|
204
|
+
/* @__PURE__ */ jsx(Before, {
|
|
205
|
+
...props,
|
|
206
|
+
index
|
|
207
|
+
}),
|
|
208
|
+
/* @__PURE__ */ jsx(Secondary, {
|
|
209
|
+
...props,
|
|
210
|
+
row,
|
|
211
|
+
at: second,
|
|
212
|
+
shown: index
|
|
213
|
+
})
|
|
214
|
+
] });
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* One value, large, with how it moved and a second figure (`Figures`). With a whole
|
|
218
|
+
* (`time.whole`) every figure is the whole range's, never a bucket's. A chart kit may hand it a
|
|
219
|
+
* small trend (`course`), which it lays beside the large value, or under it in a narrow tile.
|
|
220
|
+
*/
|
|
221
|
+
function NumberTile({ course, ...props }) {
|
|
222
|
+
return /* @__PURE__ */ jsx("div", {
|
|
223
|
+
className: "dd-number",
|
|
224
|
+
...course !== void 0 && course !== null ? { "data-course": "true" } : {},
|
|
225
|
+
children: /* @__PURE__ */ jsx(Figures, {
|
|
226
|
+
...props,
|
|
227
|
+
answer: figuresAnswer(props.answer),
|
|
228
|
+
course
|
|
229
|
+
})
|
|
169
230
|
});
|
|
170
231
|
}
|
|
232
|
+
/** The renderers every dashboard has: a number, a table and a list. */
|
|
171
233
|
const BUILTIN_RENDERERS = {
|
|
172
234
|
number: NumberTile,
|
|
173
235
|
table: TableTile,
|
|
174
236
|
list: ListTile
|
|
175
237
|
};
|
|
176
|
-
export { BUILTIN_RENDERERS, NumberTile, TableTile,
|
|
238
|
+
export { BUILTIN_RENDERERS, NumberTile, TableTile, fitted, headlineColumn };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// src/renderers/list-parts.ts
|
|
2
|
+
/**
|
|
3
|
+
* A row's parts. With no title named it is the first group, and with no number named the last
|
|
4
|
+
* value. With no line under the title named, the line is every group the row does not show
|
|
5
|
+
* elsewhere: a time said at the row's end ("41 min. ago") is not written again in full under
|
|
6
|
+
* the name, nor is the name itself where the widget names another group than the first. A line
|
|
7
|
+
* named as an empty list is no line.
|
|
8
|
+
*/
|
|
9
|
+
function listParts(named, has) {
|
|
10
|
+
const title = named.title ?? has.groups[0];
|
|
11
|
+
const meta = named.meta ?? has.value;
|
|
12
|
+
const shown = /* @__PURE__ */ new Set([
|
|
13
|
+
title,
|
|
14
|
+
meta,
|
|
15
|
+
named.avatar
|
|
16
|
+
]);
|
|
17
|
+
return {
|
|
18
|
+
title,
|
|
19
|
+
subtitle: named.subtitle ?? has.groups.filter((id) => !shown.has(id)),
|
|
20
|
+
avatar: named.avatar,
|
|
21
|
+
meta
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export { listParts };
|
|
@@ -19,5 +19,6 @@ export type ListDisplay = {
|
|
|
19
19
|
/**
|
|
20
20
|
* Rows as a list: an avatar, a title, a subtitle and one number, each row a link into the
|
|
21
21
|
* app (`display.href`) or, without one, a drill like a table row. Summary rows are left out.
|
|
22
|
+
* A long list draws its first rows, and more with each press of the button under them.
|
|
22
23
|
*/
|
|
23
24
|
export declare function ListTile(props: TileRendererProps): import("react").JSX.Element;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
+
import { agoText } from "../ago.mjs";
|
|
1
2
|
import { isValue } from "../columns.mjs";
|
|
2
3
|
import { formatCell, rawCellText } from "../format.mjs";
|
|
4
|
+
import { useNow } from "../now.mjs";
|
|
3
5
|
import { RowBody } from "../RowBody.mjs";
|
|
4
6
|
import { answerIds } from "./entries.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
+
import { listParts } from "./list-parts.mjs";
|
|
8
|
+
import { MoreRows, useRowLimit } from "./more-rows.mjs";
|
|
9
|
+
import { fitted } from "./props.mjs";
|
|
10
|
+
import { displayOf, isMark, parseTextTime } from "derive-dashboards/core";
|
|
11
|
+
import { memo, useMemo, useRef } from "react";
|
|
12
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
13
|
// src/renderers/list.tsx
|
|
8
14
|
const initials = (text) => text.split(/[\s._@-]+/u).filter(Boolean).slice(0, 2).map((word) => word[0]?.toUpperCase()).join("");
|
|
9
|
-
/** With no display, the first group is the title, the others the subtitle, the last value the number. */
|
|
10
|
-
function defaults(columns) {
|
|
11
|
-
const groups = columns.filter((c) => !isValue(c)).map((c) => c.id);
|
|
12
|
-
const meta = columns.findLast((c) => isValue(c))?.id;
|
|
13
|
-
return {
|
|
14
|
-
title: groups[0],
|
|
15
|
-
subtitle: groups.slice(1),
|
|
16
|
-
meta
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
15
|
function readDisplay(widget, columns) {
|
|
20
16
|
const display = displayOf("list", widget.display);
|
|
21
17
|
const answerId = answerIds(widget);
|
|
22
18
|
const id = (entry) => entry === void 0 ? void 0 : answerId(entry);
|
|
23
|
-
const fallback = defaults(columns);
|
|
24
19
|
return {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
20
|
+
...listParts({
|
|
21
|
+
title: id(display.title),
|
|
22
|
+
subtitle: display.subtitle?.map((entry) => id(entry) ?? entry),
|
|
23
|
+
avatar: id(display.avatar),
|
|
24
|
+
meta: id(display.meta)
|
|
25
|
+
}, {
|
|
26
|
+
groups: columns.filter((c) => !isValue(c)).map((c) => c.id),
|
|
27
|
+
value: columns.findLast((c) => isValue(c))?.id
|
|
28
|
+
}),
|
|
29
29
|
href: display.href?.replaceAll(/\{([^}]+)\}/gu, (_, entry) => `{${id(entry) ?? entry}}`)
|
|
30
30
|
};
|
|
31
31
|
}
|
|
@@ -35,6 +35,32 @@ const text = ({ cells, at, props }, id) => {
|
|
|
35
35
|
const cell = cells[index] ?? null;
|
|
36
36
|
return cell === null ? "" : formatCell(cell, props.answer.columns[index], props);
|
|
37
37
|
};
|
|
38
|
+
/** Whether a column holds instants: times that are no bucket of a grain. */
|
|
39
|
+
const holdsInstants = (column) => column?.type === "time" && column.grain === void 0;
|
|
40
|
+
/** A cell of a column of instants, in milliseconds; none for anything else. */
|
|
41
|
+
function instantOf(cell, column) {
|
|
42
|
+
const micros = typeof cell === "string" && holdsInstants(column) ? parseTextTime(cell) : void 0;
|
|
43
|
+
return micros === void 0 ? void 0 : Number(micros / 1000n);
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* What ends a row: its value as written, or, when that is an instant inside a week of now, how
|
|
47
|
+
* long ago it was ("41 min. ago"), with the time itself as its title. A list of what just
|
|
48
|
+
* happened is read by how recent each row is.
|
|
49
|
+
*/
|
|
50
|
+
function endOf(line, id) {
|
|
51
|
+
const value = text(line, id);
|
|
52
|
+
const ago = agoOf(line, id);
|
|
53
|
+
return ago === void 0 ? { value } : {
|
|
54
|
+
value: ago,
|
|
55
|
+
valueTitle: value
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/** How long ago a row's end was, in words, when it is an instant and the clock is read; none otherwise. */
|
|
59
|
+
function agoOf(line, id) {
|
|
60
|
+
const index = line.at(id);
|
|
61
|
+
const instant = instantOf(line.cells[index], line.props.answer.columns[index]);
|
|
62
|
+
return instant === void 0 || line.now === void 0 ? void 0 : agoText(instant, line.now, line.props.locale);
|
|
63
|
+
}
|
|
38
64
|
/** A row's link: each `{entry}` in the template becomes that entry's raw value, encoded. */
|
|
39
65
|
const linkOf = (template, line) => {
|
|
40
66
|
let missing = false;
|
|
@@ -63,39 +89,69 @@ function Anchor(props) {
|
|
|
63
89
|
/**
|
|
64
90
|
* Rows as a list: an avatar, a title, a subtitle and one number, each row a link into the
|
|
65
91
|
* app (`display.href`) or, without one, a drill like a table row. Summary rows are left out.
|
|
92
|
+
* A long list draws its first rows, and more with each press of the button under them.
|
|
66
93
|
*/
|
|
67
94
|
function ListTile(props) {
|
|
68
95
|
const { answer } = props;
|
|
69
|
-
const shown = readDisplay(props.widget, answer.columns);
|
|
96
|
+
const shown = useMemo(() => readDisplay(props.widget, answer.columns), [props.widget, answer.columns]);
|
|
70
97
|
const at = (id) => answer.columns.findIndex((c) => c.id === id);
|
|
71
98
|
const rows = answer.rows.filter((cells) => !cells.some((cell) => isMark(cell)));
|
|
72
|
-
|
|
99
|
+
const { limit, first, drawMore, drawFirst } = useRowLimit(answer, props.fit);
|
|
100
|
+
const list = useRef(null);
|
|
101
|
+
const now = useNow(holdsInstants(answer.columns[at(shown.meta)]));
|
|
102
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("ul", {
|
|
103
|
+
ref: list,
|
|
73
104
|
className: "dd-lines",
|
|
74
|
-
|
|
75
|
-
|
|
105
|
+
...fitted(props.fit),
|
|
106
|
+
tabIndex: -1,
|
|
107
|
+
children: rows.slice(0, limit).map((cells) => /* @__PURE__ */ jsx(ListRow, {
|
|
108
|
+
line: {
|
|
76
109
|
cells,
|
|
77
110
|
at,
|
|
78
|
-
props
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
href,
|
|
95
|
-
link: props.link,
|
|
96
|
-
children: body
|
|
97
|
-
}) }, JSON.stringify(cells));
|
|
98
|
-
})
|
|
99
|
-
});
|
|
111
|
+
props,
|
|
112
|
+
now
|
|
113
|
+
},
|
|
114
|
+
shown
|
|
115
|
+
}, JSON.stringify(cells)))
|
|
116
|
+
}), /* @__PURE__ */ jsx(MoreRows, {
|
|
117
|
+
hidden: Math.max(0, rows.length - limit),
|
|
118
|
+
of: rows.length,
|
|
119
|
+
first,
|
|
120
|
+
onMore: drawMore,
|
|
121
|
+
onFirst: drawFirst,
|
|
122
|
+
rows: list,
|
|
123
|
+
row: ":scope > li",
|
|
124
|
+
tile: props,
|
|
125
|
+
className: "dd-lines-more"
|
|
126
|
+
})] });
|
|
100
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Whether a row drawn before would be drawn the same now: the same cells of the same tile, read
|
|
130
|
+
* the same way, and the same words for how long ago. The clock ticks each minute for a list
|
|
131
|
+
* that ends in times, and most of its rows say then what they said before ("3 hr. ago", a date
|
|
132
|
+
* from last month): only the rows whose words the minute changed are drawn again.
|
|
133
|
+
*/
|
|
134
|
+
const sameRow = (a, b) => a.shown === b.shown && a.line.cells === b.line.cells && a.line.props === b.line.props && agoOf(a.line, a.shown.meta) === agoOf(b.line, b.shown.meta);
|
|
135
|
+
/** One row of the list: a link into the app where the widget names one, else a drill. */
|
|
136
|
+
const ListRow = memo(function ListRow({ line, shown }) {
|
|
137
|
+
const { cells, at, props } = line;
|
|
138
|
+
const row = {
|
|
139
|
+
title: text(line, shown.title) || props.messages.empty,
|
|
140
|
+
meta: shown.subtitle.map((id) => text(line, id)).filter(Boolean),
|
|
141
|
+
lead: shown.avatar === void 0 ? void 0 : initials(text(line, shown.avatar)),
|
|
142
|
+
...endOf(line, shown.meta),
|
|
143
|
+
valueLabel: props.answer.columns[at(shown.meta)]?.label
|
|
144
|
+
};
|
|
145
|
+
const body = /* @__PURE__ */ jsx(RowBody, { row });
|
|
146
|
+
const href = shown.href === void 0 ? void 0 : linkOf(shown.href, line);
|
|
147
|
+
return /* @__PURE__ */ jsx("li", { children: href === void 0 ? /* @__PURE__ */ jsx("div", {
|
|
148
|
+
className: "dd-lines-row",
|
|
149
|
+
...props.drill?.props(cells, shown.meta),
|
|
150
|
+
children: body
|
|
151
|
+
}) : /* @__PURE__ */ jsx(Anchor, {
|
|
152
|
+
href,
|
|
153
|
+
link: props.link,
|
|
154
|
+
children: body
|
|
155
|
+
}) });
|
|
156
|
+
}, sameRow);
|
|
101
157
|
export { ListTile };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { formatCell } from "../format.mjs";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { flushSync } from "react-dom";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
// src/renderers/more-rows.tsx
|
|
6
|
+
/**
|
|
7
|
+
* How many rows are drawn: the first, and more with each press, or the first again. Another
|
|
8
|
+
* answer, or another way of sizing the tile, is drawn from its first rows again.
|
|
9
|
+
*/
|
|
10
|
+
function useRowLimit(answer, fit) {
|
|
11
|
+
const first = fit === true ? 12 : 500;
|
|
12
|
+
const [limit, setLimit] = useState(first);
|
|
13
|
+
const [seen, setSeen] = useState({
|
|
14
|
+
answer,
|
|
15
|
+
first
|
|
16
|
+
});
|
|
17
|
+
if (seen.answer !== answer || seen.first !== first) {
|
|
18
|
+
setSeen({
|
|
19
|
+
answer,
|
|
20
|
+
first
|
|
21
|
+
});
|
|
22
|
+
setLimit(first);
|
|
23
|
+
}
|
|
24
|
+
const drawMore = () => {
|
|
25
|
+
setLimit((now) => now + 500);
|
|
26
|
+
};
|
|
27
|
+
const drawFirst = () => {
|
|
28
|
+
setLimit(first);
|
|
29
|
+
};
|
|
30
|
+
return {
|
|
31
|
+
limit,
|
|
32
|
+
first,
|
|
33
|
+
drawMore,
|
|
34
|
+
drawFirst
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** Whether rows have a button under them: some are not drawn, or more than the first are and can be folded back. */
|
|
38
|
+
const holdsRows = ({ hidden, of, first }) => hidden > 0 || of > first;
|
|
39
|
+
/**
|
|
40
|
+
* Focus for a row: the row itself where it takes focus (one that opens), else the first thing
|
|
41
|
+
* in it that does (its link), else the row, made to take it.
|
|
42
|
+
*/
|
|
43
|
+
function focusRow(row) {
|
|
44
|
+
const inside = row.matches("[tabindex]") ? row : row.querySelector("a[href], button, [tabindex]");
|
|
45
|
+
if (inside === null) row.tabIndex = -1;
|
|
46
|
+
(inside ?? row).focus();
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Under rows of which only the first are drawn: the button that draws more, and once they are
|
|
50
|
+
* all drawn the same button folds them back to the first, so a long table need not stay a long
|
|
51
|
+
* page. Nothing under rows that were drawn whole from the start.
|
|
52
|
+
*/
|
|
53
|
+
function MoreRows(props) {
|
|
54
|
+
const { hidden, of, first, rows, row, tile } = props;
|
|
55
|
+
if (!holdsRows(props)) return null;
|
|
56
|
+
const written = (count) => formatCell(count, { type: "int" }, tile);
|
|
57
|
+
const more = () => {
|
|
58
|
+
if (hidden > 500) {
|
|
59
|
+
props.onMore();
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const drawn = of - hidden;
|
|
63
|
+
flushSync(props.onMore);
|
|
64
|
+
const next = rows.current?.querySelectorAll(row)[drawn];
|
|
65
|
+
if (next !== void 0) focusRow(next);
|
|
66
|
+
};
|
|
67
|
+
return /* @__PURE__ */ jsx("button", {
|
|
68
|
+
type: "button",
|
|
69
|
+
className: props.className,
|
|
70
|
+
"aria-expanded": hidden <= 0,
|
|
71
|
+
onClick: hidden > 0 ? more : props.onFirst,
|
|
72
|
+
children: hidden > 0 ? tile.messages.showMoreRows(written(Math.min(hidden, 500)), written(of)) : tile.messages.showFirstRows(written(first))
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
export { MoreRows, holdsRows, useRowLimit };
|