derive-dashboards 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/adapter/sql-adapter.mjs +4 -4
- package/dist/body.mjs +11 -1
- package/dist/cache.d.mts +1 -1
- package/dist/cli/add.mjs +130 -0
- package/dist/cli/check.mjs +14 -1
- package/dist/cli/cli.mjs +14 -12
- package/dist/cli/config.mjs +12 -1
- package/dist/cli/doctor.mjs +147 -0
- package/dist/cli/import/dbt-schema.mjs +2 -2
- package/dist/cli/import/index.mjs +2 -2
- package/dist/cli/init.mjs +3 -2
- package/dist/cli/json.mjs +21 -0
- package/dist/cli/layers.mjs +33 -0
- package/dist/core/conformance/cases.d.mts +3 -0
- package/dist/core/conformance/cases.mjs +20 -4
- package/dist/core/conformance/check.mjs +6 -3
- package/dist/core/conformance/drill-cases.mjs +120 -0
- package/dist/core/document/layout.mjs +1 -1
- package/dist/core/document/view-layout.d.mts +14 -0
- package/dist/core/document/view-layout.mjs +157 -0
- package/dist/core/document/view.d.mts +26 -7
- package/dist/core/document/view.mjs +42 -11
- package/dist/core/engine/filter.mjs +2 -2
- package/dist/core/engine/index.d.mts +14 -2
- package/dist/core/engine/index.mjs +12 -1
- package/dist/core/engine/leaf.mjs +9 -4
- package/dist/core/engine/members.mjs +2 -2
- package/dist/core/engine/postgres.mjs +1 -1
- package/dist/core/engine/record-layout.d.mts +11 -0
- package/dist/core/engine/record-layout.mjs +7 -7
- package/dist/core/engine/records.d.mts +3 -2
- package/dist/core/engine/records.mjs +2 -1
- package/dist/core/engine/segmented.mjs +5 -2
- package/dist/core/engine/sql-records.mjs +2 -1
- package/dist/core/engine/statement.mjs +37 -3
- package/dist/core/engine/types.d.mts +3 -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 +33 -1
- package/dist/core/error/codes.mjs +30 -2
- package/dist/core/index.d.mts +13 -7
- package/dist/core/index.mjs +9 -5
- package/dist/core/model/catalog/check.mjs +1 -1
- package/dist/core/model/hints.d.mts +36 -0
- package/dist/core/model/member.d.mts +4 -2
- package/dist/core/model/member.mjs +19 -3
- package/dist/core/model/types.d.mts +21 -19
- package/dist/core/model/validate/drill.mjs +70 -0
- package/dist/core/model/validate/index.mjs +3 -0
- package/dist/core/model/validate/members.mjs +7 -4
- package/dist/core/model/validate/shape.mjs +150 -0
- package/dist/core/model/validate/source.mjs +5 -3
- package/dist/core/policy/bind-query.d.mts +12 -0
- package/dist/core/policy/bind-query.mjs +53 -0
- package/dist/core/query/alias.mjs +7 -1
- package/dist/core/query/drill/compose.d.mts +22 -0
- package/dist/core/query/drill/compose.mjs +85 -0
- package/dist/core/query/drill/fields.d.mts +21 -0
- package/dist/core/query/drill/fields.mjs +91 -0
- package/dist/core/query/drill/internal.d.mts +11 -0
- package/dist/core/query/drill/items.d.mts +29 -0
- package/dist/core/query/drill/items.mjs +98 -0
- package/dist/core/query/drill/line.d.mts +31 -0
- package/dist/core/query/drill/line.mjs +183 -0
- package/dist/core/query/drill/links.d.mts +33 -0
- package/dist/core/query/drill/links.mjs +31 -0
- package/dist/core/query/drill/operand.mjs +7 -0
- package/dist/core/query/drill/scopes.d.mts +22 -0
- package/dist/core/query/drill/scopes.mjs +58 -0
- package/dist/core/query/drill/selection.d.mts +37 -0
- package/dist/core/query/drill/selection.mjs +144 -0
- package/dist/core/query/drill/steps.d.mts +14 -0
- package/dist/core/query/drill/steps.mjs +35 -0
- package/dist/core/query/drill/synthetic-expr.mjs +85 -0
- package/dist/core/query/drill/synthetic.d.mts +22 -0
- package/dist/core/query/drill/synthetic.mjs +165 -0
- package/dist/core/query/drill/time.d.mts +11 -0
- package/dist/core/query/drill/time.mjs +71 -0
- package/dist/core/query/drill/types.d.mts +155 -0
- package/dist/core/query/drill/types.mjs +4 -0
- package/dist/core/query/drill/views.d.mts +62 -0
- package/dist/core/query/drill/views.mjs +257 -0
- package/dist/core/query/filter.d.mts +6 -0
- package/dist/core/query/picks.d.mts +8 -2
- package/dist/core/query/picks.mjs +11 -4
- package/dist/core/query/segments.d.mts +12 -2
- package/dist/core/query/segments.mjs +5 -2
- package/dist/core/result/columns.mjs +20 -4
- package/dist/core/result/types.d.mts +5 -1
- package/dist/core/schema/aliases.d.mts +7 -0
- package/dist/core/schema/aliases.mjs +77 -0
- package/dist/core/schema/answer-parts.mjs +117 -0
- package/dist/core/schema/answers.d.mts +2109 -128
- package/dist/core/schema/answers.mjs +11 -113
- package/dist/core/schema/commands.d.mts +2 -2
- package/dist/core/schema/document.d.mts +1 -1
- package/dist/core/schema/drill-answers.mjs +179 -0
- package/dist/core/schema/drill.d.mts +260 -0
- package/dist/core/schema/drill.mjs +107 -0
- package/dist/core/schema/index.d.mts +6 -3
- package/dist/core/schema/index.mjs +6 -3
- package/dist/core/schema/picks.d.mts +35 -0
- package/dist/core/schema/picks.mjs +23 -0
- package/dist/core/schema/query.d.mts +82 -1
- package/dist/core/schema/query.mjs +9 -5
- package/dist/core/schema/tools.mjs +1 -1
- package/dist/core/schema/view.d.mts +0 -35
- package/dist/core/schema/view.mjs +19 -24
- package/dist/core/store/schema.d.mts +5 -0
- package/dist/core/store/schema.mjs +10 -0
- package/dist/core/types/api.d.mts +21 -1
- package/dist/core/types/api.mjs +1 -1
- package/dist/core/types/drill-api.d.mts +210 -0
- package/dist/core/types/options.d.mts +21 -0
- package/dist/core/types/viewer.d.mts +5 -0
- package/dist/cursor-seal.d.mts +8 -0
- package/dist/cursor-seal.mjs +98 -0
- package/dist/dashboard-id.mjs +1 -1
- package/dist/dashboards.mjs +4 -0
- package/dist/drill-access.mjs +93 -0
- package/dist/drill-change.mjs +76 -0
- package/dist/drill-crumbs.mjs +113 -0
- package/dist/drill-distinct.mjs +130 -0
- package/dist/drill-explain.mjs +64 -0
- package/dist/drill-identity.mjs +35 -0
- package/dist/drill-item-id.mjs +35 -0
- package/dist/drill-items.mjs +132 -0
- package/dist/drill-open.mjs +169 -0
- package/dist/drill-seal.mjs +170 -0
- package/dist/drill-secret.mjs +14 -0
- package/dist/drill-share.mjs +53 -0
- package/dist/drill-summary.mjs +158 -0
- package/dist/drill-targets.mjs +53 -0
- package/dist/drill-totals.mjs +8 -0
- package/dist/drill-views.mjs +175 -0
- package/dist/drill.mjs +157 -0
- package/dist/editing.mjs +3 -3
- package/dist/endpoints/dashboards.mjs +28 -5
- package/dist/endpoints/drill.mjs +55 -0
- package/dist/endpoints/index.d.mts +245 -4
- package/dist/endpoints/index.mjs +5 -1
- package/dist/endpoints/meta.mjs +10 -1
- package/dist/endpoints/query.mjs +26 -4
- package/dist/execute.d.mts +19 -1
- package/dist/execute.mjs +34 -27
- package/dist/handler.mjs +5 -1
- package/dist/index.d.mts +3 -1
- package/dist/index.mjs +29 -2
- package/dist/llms.txt +22 -0
- package/dist/mcp/drill.mjs +61 -0
- package/dist/mcp/format.mjs +69 -11
- package/dist/mcp/index.d.mts +15 -4
- package/dist/mcp/index.mjs +13 -7
- package/dist/mcp/query.d.mts +7 -2
- package/dist/mcp/query.mjs +40 -6
- package/dist/node-postgres.d.mts +8 -4
- package/dist/node-postgres.mjs +29 -6
- package/dist/owner.mjs +3 -3
- package/dist/postgres-connection.d.mts +8 -2
- package/dist/postgres-connection.mjs +2 -1
- package/dist/postgres-store.mjs +1 -0
- package/dist/react/Canvas.mjs +28 -5
- package/dist/react/Cell.mjs +2 -1
- package/dist/react/Dashboard.d.mts +10 -5
- package/dist/react/Dashboard.mjs +62 -22
- package/dist/react/DashboardList.mjs +52 -24
- package/dist/react/DashboardListRow.mjs +49 -0
- package/dist/react/Discard.mjs +12 -4
- package/dist/react/Editing.mjs +19 -5
- package/dist/react/FilterBar.d.mts +7 -9
- package/dist/react/Grid.mjs +19 -24
- package/dist/react/Header.mjs +10 -1
- package/dist/react/History.mjs +5 -0
- package/dist/react/Parts.mjs +6 -2
- package/dist/react/ReadFailed.mjs +23 -0
- package/dist/react/ReviewPanel.mjs +13 -2
- package/dist/react/RowBody.d.mts +19 -0
- package/dist/react/RowBody.mjs +55 -0
- package/dist/react/Spaces.mjs +15 -1
- package/dist/react/Tile.d.mts +3 -1
- package/dist/react/Tile.mjs +84 -32
- package/dist/react/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/react/arrange-steps.mjs +16 -13
- package/dist/react/arrange.mjs +10 -3
- package/dist/react/builder/Calcs.mjs +35 -11
- package/dist/react/builder/FilterEditor.mjs +196 -0
- package/dist/react/builder/Filters.mjs +172 -116
- package/dist/react/builder/Formula.mjs +82 -0
- package/dist/react/builder/Groups.mjs +1 -0
- package/dist/react/builder/Preview.mjs +1 -1
- package/dist/react/builder/RangeEditor.mjs +184 -0
- package/dist/react/builder/Sections.mjs +41 -6
- package/dist/react/builder/Time.mjs +138 -60
- package/dist/react/builder/Values.mjs +85 -0
- package/dist/react/builder/WidgetBuilder.mjs +50 -49
- package/dist/react/builder/base.d.mts +5 -0
- package/dist/react/builder/base.mjs +33 -8
- package/dist/react/builder/calc.mjs +15 -1
- package/dist/react/builder/escape.d.mts +1 -0
- package/dist/react/builder/escape.mjs +62 -0
- package/dist/react/builder/filter-tree.d.mts +9 -0
- package/dist/react/builder/filter-tree.mjs +186 -0
- package/dist/react/builder/formula-parse.d.mts +18 -0
- package/dist/react/builder/formula-parse.mjs +136 -0
- package/dist/react/builder/labels.d.mts +1 -1
- package/dist/react/builder/state.d.mts +2 -1
- package/dist/react/builder/state.mjs +23 -37
- package/dist/react/builder/useBuilder.d.mts +12 -1
- package/dist/react/builder/useBuilder.mjs +6 -3
- package/dist/react/builder/words.d.mts +59 -0
- package/dist/react/builder/words.mjs +73 -0
- package/dist/react/client.d.mts +2 -0
- package/dist/react/client.mjs +1 -0
- package/dist/react/context.d.mts +28 -1
- package/dist/react/context.mjs +25 -4
- package/dist/react/drill/Bars.mjs +179 -0
- package/dist/react/drill/Controls.mjs +173 -0
- package/dist/react/drill/DashboardTile.d.mts +18 -0
- package/dist/react/drill/DashboardTile.mjs +107 -0
- package/dist/react/drill/DrillPanel.d.mts +31 -0
- package/dist/react/drill/DrillPanel.mjs +104 -0
- package/dist/react/drill/DrillTabs.mjs +52 -0
- package/dist/react/drill/Header.mjs +131 -0
- package/dist/react/drill/Items.d.mts +22 -0
- package/dist/react/drill/Items.mjs +164 -0
- package/dist/react/drill/ItemsFoot.mjs +60 -0
- package/dist/react/drill/Notes.mjs +58 -0
- package/dist/react/drill/PanelBody.mjs +74 -0
- package/dist/react/drill/PanelStates.mjs +37 -0
- package/dist/react/drill/board.d.mts +18 -0
- package/dist/react/drill/board.mjs +91 -0
- package/dist/react/drill/counts.mjs +14 -0
- package/dist/react/drill/host.mjs +26 -0
- package/dist/react/drill/item-parts.d.mts +5 -0
- package/dist/react/drill/item-parts.mjs +76 -0
- package/dist/react/drill/item-type.d.mts +26 -0
- package/dist/react/drill/item-type.mjs +7 -0
- package/dist/react/drill/lazy.d.mts +6 -0
- package/dist/react/drill/lazy.mjs +17 -0
- package/dist/react/drill/pages.mjs +48 -0
- package/dist/react/drill/panel-focus.mjs +51 -0
- package/dist/react/drill/props.d.mts +25 -0
- package/dist/react/drill/props.mjs +72 -0
- package/dist/react/drill/state.d.mts +18 -0
- package/dist/react/drill/state.mjs +68 -0
- package/dist/react/drill/useDrill.d.mts +46 -0
- package/dist/react/drill/useDrill.mjs +194 -0
- package/dist/react/drill/words.d.mts +101 -0
- package/dist/react/drill/words.mjs +79 -0
- package/dist/react/english.mjs +29 -6
- package/dist/react/filters/bar.d.mts +12 -0
- package/dist/react/filters/bar.mjs +135 -0
- package/dist/react/filters/calendar.mjs +193 -0
- package/dist/react/filters/chip.mjs +174 -0
- package/dist/react/filters/context.d.mts +22 -0
- package/dist/react/filters/context.mjs +78 -0
- package/dist/react/filters/dates.mjs +89 -0
- package/dist/react/filters/days.d.mts +36 -0
- package/dist/react/filters/days.mjs +87 -0
- package/dist/react/filters/field-step.mjs +81 -0
- package/dist/react/filters/hooks.d.mts +34 -0
- package/dist/react/filters/hooks.mjs +94 -0
- package/dist/react/filters/listbox.mjs +131 -0
- package/dist/react/filters/logic.d.mts +59 -0
- package/dist/react/filters/logic.mjs +109 -0
- package/dist/react/filters/menu-search.mjs +211 -0
- package/dist/react/filters/menu.mjs +85 -0
- package/dist/react/filters/number.mjs +127 -0
- package/dist/react/filters/numbers.d.mts +47 -0
- package/dist/react/filters/numbers.mjs +151 -0
- package/dist/react/filters/operator.mjs +104 -0
- package/dist/react/filters/phone.mjs +104 -0
- package/dist/react/filters/popover.d.mts +19 -0
- package/dist/react/filters/popover.mjs +153 -0
- package/dist/react/filters/rules.d.mts +8 -0
- package/dist/react/filters/rules.mjs +55 -0
- package/dist/react/filters/sheet.mjs +196 -0
- package/dist/react/filters/state.mjs +132 -0
- package/dist/react/filters/suggest.d.mts +47 -0
- package/dist/react/filters/suggest.mjs +97 -0
- package/dist/react/filters/values.mjs +166 -0
- package/dist/react/filters/words.d.mts +81 -0
- package/dist/react/filters/words.mjs +73 -0
- package/dist/react/format.d.mts +3 -3
- package/dist/react/format.mjs +45 -16
- package/dist/react/index.d.mts +34 -5
- package/dist/react/index.mjs +15 -4
- package/dist/react/messages.d.mts +47 -2
- package/dist/react/place.mjs +7 -3
- package/dist/react/renderers/index.d.mts +10 -2
- package/dist/react/renderers/index.mjs +116 -14
- package/dist/react/renderers/list.d.mts +22 -0
- package/dist/react/renderers/list.mjs +118 -0
- package/dist/react/review-words.mjs +1 -1
- package/dist/react/review.mjs +2 -2
- package/dist/react/scope.mjs +2 -7
- package/dist/react/series.d.mts +54 -0
- package/dist/react/series.mjs +191 -0
- package/dist/react/theme.css +2734 -1296
- package/dist/react/theme.css.d.ts +1 -0
- package/dist/react/tile-store.mjs +15 -3
- package/dist/react/useBoard.d.mts +7 -0
- package/dist/react/useBoard.mjs +4 -1
- package/dist/react/useDashboard.d.mts +4 -0
- package/dist/react/useDashboard.mjs +8 -1
- package/dist/react/useTiles.mjs +50 -15
- package/dist/react/view-grid.mjs +16 -0
- package/dist/react/view.d.mts +9 -0
- package/dist/react/view.mjs +22 -10
- package/dist/reading.d.mts +2 -0
- package/dist/reading.mjs +9 -1
- package/dist/recharts/axes.mjs +28 -0
- package/dist/recharts/axis.mjs +84 -0
- package/dist/recharts/bar.d.mts +7 -0
- package/dist/recharts/bar.mjs +140 -0
- package/dist/recharts/charts.d.mts +4 -6
- package/dist/recharts/charts.mjs +2 -114
- package/dist/recharts/index.d.mts +5 -3
- package/dist/recharts/index.mjs +6 -3
- package/dist/recharts/line.d.mts +2 -0
- package/dist/recharts/line.mjs +111 -0
- package/dist/recharts/marks.mjs +112 -0
- package/dist/recharts/parts.mjs +88 -0
- package/dist/recharts/series.d.mts +2 -22
- package/dist/recharts/series.mjs +1 -64
- package/dist/recharts/table.mjs +71 -0
- package/dist/records-read.mjs +44 -0
- package/dist/registry/filter-bar.json +26 -0
- package/dist/skills/derive-dashboards/SKILL.md +69 -0
- package/dist/store/apply.mjs +5 -5
- package/dist/store/commands.mjs +4 -4
- package/dist/store/discard.mjs +7 -7
- package/dist/store/drafts.mjs +5 -5
- package/dist/store/editor.mjs +1 -1
- package/dist/store/publish.mjs +12 -12
- package/dist/store/reader.mjs +41 -22
- package/dist/store/review.mjs +16 -16
- package/dist/store/rows.mjs +20 -20
- package/dist/store/undo.mjs +3 -3
- package/dist/store/unpublished.mjs +4 -4
- package/dist/store/versions.mjs +14 -14
- package/dist/testing/adapter-suite.mjs +4 -4
- package/dist/tiles.mjs +37 -3
- package/package.json +12 -10
- package/dist/react/FilterBar.mjs +0 -119
- package/dist/react/Records.d.mts +0 -12
- package/dist/react/Records.mjs +0 -97
- package/src/adapter/sql-adapter.ts +0 -95
- package/src/adapter/statement.ts +0 -185
- package/src/authorize.ts +0 -73
- package/src/body.ts +0 -169
- package/src/bounded.ts +0 -43
- package/src/cache.ts +0 -192
- package/src/checks.ts +0 -170
- package/src/custom-source.ts +0 -59
- package/src/dashboard-id.ts +0 -36
- package/src/dashboards.ts +0 -132
- package/src/editing.ts +0 -148
- package/src/endpoints/access.ts +0 -41
- package/src/endpoints/dashboards.ts +0 -92
- package/src/endpoints/drafts.ts +0 -138
- package/src/endpoints/index.ts +0 -21
- package/src/endpoints/meta.ts +0 -137
- package/src/endpoints/query.ts +0 -86
- package/src/endpoints/read.ts +0 -92
- package/src/endpoints/review.ts +0 -89
- package/src/endpoints/values.ts +0 -62
- package/src/endpoints/versions.ts +0 -104
- package/src/execute.ts +0 -207
- package/src/handler.ts +0 -232
- package/src/http.ts +0 -66
- package/src/index.ts +0 -163
- package/src/introspect.ts +0 -205
- package/src/mcp/api.ts +0 -59
- package/src/mcp/format.ts +0 -67
- package/src/mcp/index.ts +0 -151
- package/src/mcp/query.ts +0 -153
- package/src/mcp/resolve.ts +0 -114
- package/src/node-postgres.ts +0 -81
- package/src/owner.ts +0 -36
- package/src/postgres-connection.ts +0 -143
- package/src/postgres-store.ts +0 -82
- package/src/principal.ts +0 -39
- package/src/reading.ts +0 -56
- package/src/request-rows.ts +0 -23
- package/src/request.ts +0 -22
- package/src/storage.ts +0 -63
- package/src/store/apply.ts +0 -129
- package/src/store/commands.ts +0 -75
- package/src/store/conflicts.ts +0 -98
- package/src/store/create-tables.ts +0 -104
- package/src/store/discard.ts +0 -42
- package/src/store/drafts.ts +0 -133
- package/src/store/editor.ts +0 -28
- package/src/store/log.ts +0 -28
- package/src/store/publish.ts +0 -199
- package/src/store/publisher.ts +0 -21
- package/src/store/reader.ts +0 -139
- package/src/store/review.ts +0 -239
- package/src/store/rows.ts +0 -250
- package/src/store/tenant.ts +0 -28
- package/src/store/undo.ts +0 -56
- package/src/store/unpublished.ts +0 -33
- package/src/store/versions.ts +0 -106
- package/src/store/writer.ts +0 -19
- package/src/testing/adapter-suite.ts +0 -239
- package/src/testing/index.ts +0 -2
- package/src/tile-doc.ts +0 -46
- package/src/tiles.ts +0 -120
package/dist/react/Grid.mjs
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
import { useArrange } from "./arrange.mjs";
|
|
2
|
-
import { Cell } from "./Cell.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { Spaces } from "./Spaces.mjs";
|
|
2
|
+
import { Cell as Cell$1 } from "./Cell.mjs";
|
|
3
|
+
import { useDashboards } from "./context.mjs";
|
|
4
|
+
import { Drop, Spaces } from "./Spaces.mjs";
|
|
5
5
|
import { useSameWidgets, useStable } from "./stable.mjs";
|
|
6
|
+
import { useViewGrid } from "./view-grid.mjs";
|
|
6
7
|
import { useMemo, useRef } from "react";
|
|
7
8
|
import { readingOrder, stepCommands } from "derive-dashboards/core";
|
|
8
|
-
import {
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
// src/Grid.tsx
|
|
10
11
|
/** Each filter control's label by id, made once per set of controls rather than per tile. */
|
|
11
12
|
function useControlLabels(controls) {
|
|
12
13
|
return useMemo(() => new Map(controls.map((c) => [c.id, c.label])), [controls]);
|
|
13
14
|
}
|
|
14
|
-
/**
|
|
15
|
-
* The outline where a dragged tile will land, and where one moved by the keyboard is now, said
|
|
16
|
-
* to a screen reader (`arrange` writes it).
|
|
17
|
-
*/
|
|
18
|
-
function Drop({ at }) {
|
|
19
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
20
|
-
className: "dd-placed dd-sr",
|
|
21
|
-
role: "status"
|
|
22
|
-
}), at === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
23
|
-
className: "dd-drop",
|
|
24
|
-
"aria-hidden": "true",
|
|
25
|
-
style: placeOf(at)
|
|
26
|
-
})] });
|
|
27
|
-
}
|
|
28
15
|
/** Focuses the first of `selectors` that matches in a widget's cell, once it is drawn. */
|
|
29
16
|
function focusIn(widget, ...selectors) {
|
|
30
17
|
requestAnimationFrame(() => {
|
|
@@ -48,21 +35,27 @@ function useStep(edit, current) {
|
|
|
48
35
|
}
|
|
49
36
|
/** What a tile's own buttons call, each keeping one identity so tiles do not draw again. */
|
|
50
37
|
function useTileCalls(edit, props) {
|
|
38
|
+
const { messages } = useDashboards();
|
|
51
39
|
const onEdit = useStable(props.onEdit);
|
|
52
40
|
const tab = useRef(props.tab);
|
|
53
41
|
tab.current = props.tab;
|
|
42
|
+
const doc = useRef(props.doc);
|
|
43
|
+
doc.current = props.doc;
|
|
54
44
|
return {
|
|
55
45
|
onEdit,
|
|
56
46
|
onRemove: useStable((id) => {
|
|
57
47
|
const order = readingOrder(tab.current.layout).map((i) => i.widget);
|
|
58
48
|
const at = order.indexOf(id);
|
|
59
49
|
const next = order[at + 1] ?? order[at - 1];
|
|
50
|
+
const title = doc.current.widgets[id]?.title ?? "";
|
|
60
51
|
const remove = async () => {
|
|
61
|
-
await edit.apply([{
|
|
52
|
+
if (!await edit.apply([{
|
|
62
53
|
type: "widget.remove",
|
|
63
54
|
id
|
|
64
|
-
}]);
|
|
65
|
-
if (next !== void 0) focusIn(next, ".dd-tile-
|
|
55
|
+
}])) return;
|
|
56
|
+
if (next !== void 0) focusIn(next, ".dd-tile-edit");
|
|
57
|
+
const said = document.querySelector(".dd-placed");
|
|
58
|
+
if (said !== null) said.textContent = messages.removedTile(title);
|
|
66
59
|
};
|
|
67
60
|
remove();
|
|
68
61
|
}),
|
|
@@ -92,7 +85,8 @@ function Grid(props) {
|
|
|
92
85
|
const widgets = useSameWidgets(doc.widgets);
|
|
93
86
|
const { onEdit, onRemove, onStep } = useTileCalls(edit, props);
|
|
94
87
|
const editing = edit.draft !== void 0 && arrangeable;
|
|
95
|
-
const
|
|
88
|
+
const view = useViewGrid(props.tab.layout, widgets, props.results);
|
|
89
|
+
const cells = useReadingOrder(props.tab.layout, editing ? arrange.layout : view.layout);
|
|
96
90
|
return /* @__PURE__ */ jsxs("div", {
|
|
97
91
|
ref: arrange.gridRef,
|
|
98
92
|
className: "dd-grid",
|
|
@@ -107,7 +101,7 @@ function Grid(props) {
|
|
|
107
101
|
/* @__PURE__ */ jsx(Drop, { at: arrange.drop }),
|
|
108
102
|
cells.map((item) => {
|
|
109
103
|
const widget = widgets[item.widget];
|
|
110
|
-
return widget === void 0 ? null : /* @__PURE__ */ jsx(Cell, {
|
|
104
|
+
return widget === void 0 ? null : /* @__PURE__ */ jsx(Cell$1, {
|
|
111
105
|
item,
|
|
112
106
|
widget,
|
|
113
107
|
result: props.results.get(item.widget),
|
|
@@ -124,7 +118,8 @@ function Grid(props) {
|
|
|
124
118
|
onRemove,
|
|
125
119
|
onStep,
|
|
126
120
|
first: cells[0]?.widget === item.widget,
|
|
127
|
-
last: cells.at(-1)?.widget === item.widget
|
|
121
|
+
last: cells.at(-1)?.widget === item.widget,
|
|
122
|
+
sharedSpan: view.sharedSpan
|
|
128
123
|
}, item.widget);
|
|
129
124
|
})
|
|
130
125
|
]
|
package/dist/react/Header.mjs
CHANGED
|
@@ -47,6 +47,15 @@ function Title({ doc, edit, isNew }) {
|
|
|
47
47
|
function ShareButton({ link }) {
|
|
48
48
|
const { messages } = useDashboards();
|
|
49
49
|
const [said, setSaid] = useState();
|
|
50
|
+
useEffect(() => {
|
|
51
|
+
if (said !== messages.linkCopied) return;
|
|
52
|
+
const wait = setTimeout(() => {
|
|
53
|
+
setSaid(void 0);
|
|
54
|
+
}, 4e3);
|
|
55
|
+
return () => {
|
|
56
|
+
clearTimeout(wait);
|
|
57
|
+
};
|
|
58
|
+
}, [said, messages.linkCopied]);
|
|
50
59
|
const share = async () => {
|
|
51
60
|
const url = link();
|
|
52
61
|
try {
|
|
@@ -82,7 +91,7 @@ function Header(props) {
|
|
|
82
91
|
}), /* @__PURE__ */ jsxs("div", {
|
|
83
92
|
className: "dd-header-actions",
|
|
84
93
|
children: [
|
|
85
|
-
props.unpublished === true ? null : /* @__PURE__ */ jsx(ShareButton, { link: props.link }),
|
|
94
|
+
props.unpublished === true || editing ? null : /* @__PURE__ */ jsx(ShareButton, { link: props.link }),
|
|
86
95
|
editing || version === 0 ? null : /* @__PURE__ */ jsx("button", {
|
|
87
96
|
type: "button",
|
|
88
97
|
className: "dd-button dd-quiet",
|
package/dist/react/History.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { useDashboards } from "./context.mjs";
|
|
|
3
3
|
import { LIST_KEY } from "./DashboardList.mjs";
|
|
4
4
|
import { formatInstant } from "./format.mjs";
|
|
5
5
|
import { Panel } from "./Panel.mjs";
|
|
6
|
+
import { ReadFailed } from "./ReadFailed.mjs";
|
|
6
7
|
import { useState } from "react";
|
|
7
8
|
import { useSWRConfig } from "swr";
|
|
8
9
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -82,6 +83,10 @@ function HistoryPanel(props) {
|
|
|
82
83
|
className: "dd-tile-note",
|
|
83
84
|
children: messages.noHistory
|
|
84
85
|
}) : null,
|
|
86
|
+
/* @__PURE__ */ jsx(ReadFailed, {
|
|
87
|
+
error: history.error,
|
|
88
|
+
retry: () => void history.mutate()
|
|
89
|
+
}),
|
|
85
90
|
/* @__PURE__ */ jsx("ol", {
|
|
86
91
|
className: "dd-timeline",
|
|
87
92
|
children: entries.map((entry) => /* @__PURE__ */ jsx(Entry, {
|
package/dist/react/Parts.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { DrillSide } from "./drill/board.mjs";
|
|
2
3
|
import { EditBar } from "./EditBar.mjs";
|
|
3
4
|
import { HistoryPanel, VersionBar } from "./History.mjs";
|
|
4
5
|
import { PublishedNotice } from "./Notice.mjs";
|
|
@@ -77,7 +78,7 @@ function Bars({ board, props }) {
|
|
|
77
78
|
})
|
|
78
79
|
] });
|
|
79
80
|
}
|
|
80
|
-
/** The side panel: the review, or the
|
|
81
|
+
/** The side panel: the review, the history timeline, or the drill open. */
|
|
81
82
|
function Side({ board, props }) {
|
|
82
83
|
const { panels, review, edit } = board;
|
|
83
84
|
if (panels.panel === "review") return /* @__PURE__ */ jsx(ReviewPanel, {
|
|
@@ -93,6 +94,9 @@ function Side({ board, props }) {
|
|
|
93
94
|
onSelect: board.canEdit ? panels.setPreviewing : void 0,
|
|
94
95
|
onClose: panels.close
|
|
95
96
|
});
|
|
96
|
-
return
|
|
97
|
+
return /* @__PURE__ */ jsx(DrillSide, {
|
|
98
|
+
board,
|
|
99
|
+
props
|
|
100
|
+
});
|
|
97
101
|
}
|
|
98
102
|
export { Bars, Side };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/ReadFailed.tsx
|
|
4
|
+
/** A list that could not be read (the history, a page of it): said, with a way to try again. */
|
|
5
|
+
function ReadFailed({ error, retry }) {
|
|
6
|
+
const { messages } = useDashboards();
|
|
7
|
+
if (error === void 0) return null;
|
|
8
|
+
return /* @__PURE__ */ jsxs("p", {
|
|
9
|
+
className: "dd-tile-error",
|
|
10
|
+
role: "alert",
|
|
11
|
+
children: [
|
|
12
|
+
messages.readFailed,
|
|
13
|
+
" ",
|
|
14
|
+
/* @__PURE__ */ jsx("button", {
|
|
15
|
+
type: "button",
|
|
16
|
+
className: "dd-button dd-quiet",
|
|
17
|
+
onClick: retry,
|
|
18
|
+
children: messages.drillRetry
|
|
19
|
+
})
|
|
20
|
+
]
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
export { ReadFailed };
|
|
@@ -5,6 +5,12 @@ import { ChangeList, Panel } from "./Panel.mjs";
|
|
|
5
5
|
import { closeGapsCommands } from "derive-dashboards/core";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
// src/ReviewPanel.tsx
|
|
8
|
+
/** The refused changes in words, each once: "Moved “Tasks closed”; resized “Tasks closed”". */
|
|
9
|
+
function changesIn(refusals, words) {
|
|
10
|
+
const said = refusals.map((r) => words.undone(r.body.type, r.widget?.title));
|
|
11
|
+
const unique = [...new Set(said)].join("; ");
|
|
12
|
+
return unique.charAt(0).toUpperCase() + unique.slice(1);
|
|
13
|
+
}
|
|
8
14
|
/**
|
|
9
15
|
* The changes to one widget that no longer apply, for one reason: what they were, why, and the
|
|
10
16
|
* ways out. Drop drops them all, since dropping one alone leaves the others still refused. Put
|
|
@@ -18,7 +24,12 @@ function Refused(props) {
|
|
|
18
24
|
const { widget } = refusal;
|
|
19
25
|
return /* @__PURE__ */ jsxs("li", {
|
|
20
26
|
className: "dd-refused",
|
|
21
|
-
children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
27
|
+
children: [/* @__PURE__ */ jsxs("p", { children: [
|
|
28
|
+
/* @__PURE__ */ jsx("strong", { children: changesIn(refusals, messages) }),
|
|
29
|
+
":",
|
|
30
|
+
" ",
|
|
31
|
+
refusal.issue.code === "WIDGET_UNKNOWN" ? messages.widgetGone : refusal.issue.message
|
|
32
|
+
] }), /* @__PURE__ */ jsxs("div", {
|
|
22
33
|
className: "dd-row",
|
|
23
34
|
children: [/* @__PURE__ */ jsx(ConfirmButton, {
|
|
24
35
|
label: messages.dropChange,
|
|
@@ -139,7 +150,7 @@ function PublishFoot({ review, busy }) {
|
|
|
139
150
|
"data-publish": "",
|
|
140
151
|
disabled: busy || nothing || waiting,
|
|
141
152
|
onClick: () => void review.publish(),
|
|
142
|
-
children: messages.publishVersion(
|
|
153
|
+
children: preview === void 0 ? messages.publish : messages.publishVersion(preview.head + 1)
|
|
143
154
|
})
|
|
144
155
|
]
|
|
145
156
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* What one row of a list shows, for a drill's Items and the list widget alike: a title, a meta
|
|
4
|
+
* line, an optional lead (an avatar), badge and trailing value, and a chevron when it opens.
|
|
5
|
+
*/
|
|
6
|
+
export type RowContent = {
|
|
7
|
+
title: string;
|
|
8
|
+
meta: readonly string[];
|
|
9
|
+
badge?: {
|
|
10
|
+
text: string;
|
|
11
|
+
tone?: string | undefined;
|
|
12
|
+
} | undefined;
|
|
13
|
+
/** Before the text: an avatar's initials. */
|
|
14
|
+
lead?: string | undefined;
|
|
15
|
+
/** After the text: one number. */
|
|
16
|
+
value?: string | undefined;
|
|
17
|
+
/** The row opens something: a chevron says so. */
|
|
18
|
+
opens?: boolean;
|
|
19
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
// src/RowBody.tsx
|
|
3
|
+
/** The class names of one family of rows: `dd-item-*` (Items) or `dd-lines-*` (the list widget). */
|
|
4
|
+
const CLASSES = {
|
|
5
|
+
item: {
|
|
6
|
+
lead: "dd-item-lead",
|
|
7
|
+
text: "dd-item-text",
|
|
8
|
+
title: "dd-item-title",
|
|
9
|
+
meta: "dd-item-meta",
|
|
10
|
+
value: "dd-item-value"
|
|
11
|
+
},
|
|
12
|
+
lines: {
|
|
13
|
+
lead: "dd-lines-avatar",
|
|
14
|
+
text: "dd-lines-text",
|
|
15
|
+
title: "dd-lines-title",
|
|
16
|
+
meta: "dd-lines-sub",
|
|
17
|
+
value: "dd-lines-meta"
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
/** One row's parts, the one markup every list of rows shares. */
|
|
21
|
+
function RowBody({ row, family }) {
|
|
22
|
+
const c = CLASSES[family];
|
|
23
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
24
|
+
row.lead === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: c.lead,
|
|
26
|
+
"aria-hidden": "true",
|
|
27
|
+
children: row.lead
|
|
28
|
+
}),
|
|
29
|
+
/* @__PURE__ */ jsxs("span", {
|
|
30
|
+
className: c.text,
|
|
31
|
+
children: [/* @__PURE__ */ jsx("strong", {
|
|
32
|
+
className: c.title,
|
|
33
|
+
children: row.title
|
|
34
|
+
}), family === "item" && row.meta.length === 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
35
|
+
className: c.meta,
|
|
36
|
+
children: row.meta.join(" · ")
|
|
37
|
+
})]
|
|
38
|
+
}),
|
|
39
|
+
row.badge === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
40
|
+
className: "dd-item-badge",
|
|
41
|
+
"data-tone": row.badge.tone ?? "neutral",
|
|
42
|
+
children: row.badge.text
|
|
43
|
+
}),
|
|
44
|
+
row.value === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
45
|
+
className: c.value,
|
|
46
|
+
children: row.value
|
|
47
|
+
}),
|
|
48
|
+
row.opens === true ? /* @__PURE__ */ jsx("span", {
|
|
49
|
+
className: "dd-item-go",
|
|
50
|
+
"aria-hidden": "true",
|
|
51
|
+
children: "›"
|
|
52
|
+
}) : null
|
|
53
|
+
] });
|
|
54
|
+
}
|
|
55
|
+
export { RowBody };
|
package/dist/react/Spaces.mjs
CHANGED
|
@@ -105,4 +105,18 @@ function Spaces(props) {
|
|
|
105
105
|
}) : null
|
|
106
106
|
}, `${gap.widget}-gap`))] });
|
|
107
107
|
}
|
|
108
|
-
|
|
108
|
+
/**
|
|
109
|
+
* The outline where a dragged tile will land, and where one moved by the keyboard is now, said
|
|
110
|
+
* to a screen reader (`arrange` writes it).
|
|
111
|
+
*/
|
|
112
|
+
function Drop({ at }) {
|
|
113
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
|
|
114
|
+
className: "dd-placed dd-sr",
|
|
115
|
+
role: "status"
|
|
116
|
+
}), at === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
117
|
+
className: "dd-drop",
|
|
118
|
+
"aria-hidden": "true",
|
|
119
|
+
style: placeOf(at)
|
|
120
|
+
})] });
|
|
121
|
+
}
|
|
122
|
+
export { Drop, Spaces, ghostPlaces };
|
package/dist/react/Tile.d.mts
CHANGED
|
@@ -11,10 +11,12 @@ type Props = {
|
|
|
11
11
|
actions?: ReactNode;
|
|
12
12
|
/** What changed about it, beside its title: New, Edited, Moved, or a preview's mark. */
|
|
13
13
|
badge?: ReactNode;
|
|
14
|
+
/** The span most tiles cover (`spanKey`), said once for the dashboard, not on each tile. */
|
|
15
|
+
sharedSpan?: string | undefined;
|
|
14
16
|
};
|
|
15
17
|
/**
|
|
16
18
|
* One widget: its title, then its answer, a refusal, or an empty state; and the rows behind it
|
|
17
|
-
* on request. It draws again only when one of its props changes.
|
|
19
|
+
* on request (Rows opens its drill on Items). It draws again only when one of its props changes.
|
|
18
20
|
*/
|
|
19
21
|
export declare const Tile: import("react").MemoExoticComponent<(props: Props) => import("react").JSX.Element>;
|
|
20
22
|
export {};
|
package/dist/react/Tile.mjs
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useTileDrill } from "./drill/host.mjs";
|
|
3
|
+
import { formatInstantAt } from "./format.mjs";
|
|
4
|
+
import { memo } from "react";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
6
|
// src/Tile.tsx
|
|
6
7
|
/** Refusals that last only until the dashboard is read again, never shown as errors. */
|
|
7
8
|
const PASSING = /* @__PURE__ */ new Set(["VERSION_CONFLICT", "TILE_UNKNOWN"]);
|
|
8
9
|
/** The answer's state when there is nothing to draw yet or instead: waiting, refused, unreadable, empty. */
|
|
9
|
-
function TileState({ result, loading }) {
|
|
10
|
+
function TileState({ result, loading, empty }) {
|
|
10
11
|
const { messages } = useDashboards();
|
|
11
12
|
if (result === void 0 || "error" in result && PASSING.has(result.error.code)) {
|
|
12
13
|
const busy = result !== void 0 || loading;
|
|
@@ -31,24 +32,30 @@ function TileState({ result, loading }) {
|
|
|
31
32
|
});
|
|
32
33
|
return /* @__PURE__ */ jsx("div", {
|
|
33
34
|
className: "dd-tile-state",
|
|
34
|
-
children:
|
|
35
|
+
children: empty
|
|
35
36
|
});
|
|
36
37
|
}
|
|
37
38
|
/** Whether an answer has rows to draw. */
|
|
38
39
|
const drawable = (result) => result !== void 0 && !("error" in result) && result.unreadable !== true && result.rows.length > 0;
|
|
39
40
|
/** The answer drawn: a memo of its own, so a change to the tile's buttons or badge never draws the chart again. */
|
|
40
|
-
const Body = memo(function Body({ widget, result, loading }) {
|
|
41
|
-
const { renderers, locale, messages } = useDashboards();
|
|
42
|
-
if (!drawable(result))
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
const Body = memo(function Body({ widget, result, loading, drill }) {
|
|
42
|
+
const { renderers, locale, messages, link } = useDashboards();
|
|
43
|
+
if (!drawable(result)) {
|
|
44
|
+
const empty = widget.display?.empty;
|
|
45
|
+
return /* @__PURE__ */ jsx(TileState, {
|
|
46
|
+
result,
|
|
47
|
+
loading,
|
|
48
|
+
empty: typeof empty === "string" ? empty : messages.noData
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const Renderer = renderers[widget.kind] ?? renderers.table;
|
|
47
52
|
return Renderer === void 0 ? null : /* @__PURE__ */ jsx(Renderer, {
|
|
48
53
|
answer: result,
|
|
49
54
|
widget,
|
|
50
55
|
messages,
|
|
51
|
-
...locale === void 0 ? {} : { locale }
|
|
56
|
+
...locale === void 0 ? {} : { locale },
|
|
57
|
+
...drill === void 0 ? {} : { drill },
|
|
58
|
+
...link === void 0 ? {} : { link }
|
|
52
59
|
});
|
|
53
60
|
});
|
|
54
61
|
/** Notes under a tile: a viewer's filter that could not apply, or an answer cut at the row cap. */
|
|
@@ -56,27 +63,73 @@ function Notes({ result, controlLabels }) {
|
|
|
56
63
|
const { messages } = useDashboards();
|
|
57
64
|
if (result === void 0 || "error" in result) return null;
|
|
58
65
|
const dropped = result.receipt.coverage.dropped.map((id) => controlLabels?.get(id) ?? id);
|
|
59
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
67
|
+
dropped.length === 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
68
|
+
className: "dd-tile-note",
|
|
69
|
+
children: messages.notFilteredBy(dropped)
|
|
70
|
+
}),
|
|
71
|
+
result.status === "truncated" ? /* @__PURE__ */ jsx("p", {
|
|
72
|
+
className: "dd-tile-note",
|
|
73
|
+
children: messages.firstRows(result.rows.length)
|
|
74
|
+
}) : null,
|
|
75
|
+
result.drill?.reason === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
76
|
+
className: "dd-tile-note",
|
|
77
|
+
children: messages.drillCut
|
|
78
|
+
})
|
|
79
|
+
] });
|
|
66
80
|
}
|
|
67
81
|
/** Whether a tile has rows behind it to show: an answer the viewer can read. */
|
|
68
82
|
const hasRows = (result) => result !== void 0 && !("error" in result) && result.unreadable !== true && result.rows.length > 0;
|
|
83
|
+
/** The time a tile's answer covers, as a key two tiles share when they cover the same days. */
|
|
84
|
+
const spanKey = (result) => {
|
|
85
|
+
if (result === void 0 || "error" in result) return void 0;
|
|
86
|
+
const range = result.receipt.range;
|
|
87
|
+
return range === void 0 ? void 0 : `${range.from}|${range.to}`;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* The time a tile's answer covers, as it read it ("Oct 15 to Nov 14"), so a reader knows its
|
|
91
|
+
* window. A tile covering the span most tiles do leaves it to the dashboard, which says it once.
|
|
92
|
+
*/
|
|
93
|
+
function Span({ result, shared }) {
|
|
94
|
+
const format = useDashboards();
|
|
95
|
+
if (result === void 0 || "error" in result) return null;
|
|
96
|
+
const range = result.receipt.range;
|
|
97
|
+
if (range === void 0 || shared !== void 0 && spanKey(result) === shared) return null;
|
|
98
|
+
const zone = result.receipt.calendar.timezone;
|
|
99
|
+
const day = (at) => formatInstantAt(at, "day", format.locale, zone);
|
|
100
|
+
return /* @__PURE__ */ jsx("p", {
|
|
101
|
+
className: "dd-tile-span",
|
|
102
|
+
children: format.messages.drillRange(day(range.from), day(range.to))
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* The span most of the tiles cover, when at least two do and they are most of them: the
|
|
107
|
+
* dashboard says it once and those tiles leave it out. None when the tiles disagree.
|
|
108
|
+
*/
|
|
109
|
+
function sharedSpan(results) {
|
|
110
|
+
const counts = /* @__PURE__ */ new Map();
|
|
111
|
+
let spans = 0;
|
|
112
|
+
for (const result of results.values()) {
|
|
113
|
+
const key = spanKey(result);
|
|
114
|
+
if (key === void 0) continue;
|
|
115
|
+
spans += 1;
|
|
116
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
117
|
+
}
|
|
118
|
+
const [top] = [...counts].toSorted((a, b) => b[1] - a[1]);
|
|
119
|
+
return top !== void 0 && top[1] >= 2 && top[1] * 2 > spans ? top[0] : void 0;
|
|
120
|
+
}
|
|
69
121
|
/**
|
|
70
122
|
* One widget: its title, then its answer, a refusal, or an empty state; and the rows behind it
|
|
71
|
-
* on request. It draws again only when one of its props changes.
|
|
123
|
+
* on request (Rows opens its drill on Items). It draws again only when one of its props changes.
|
|
72
124
|
*/
|
|
73
125
|
const Tile = memo(function Tile(props) {
|
|
74
126
|
const { messages } = useDashboards();
|
|
75
|
-
const
|
|
127
|
+
const drill = useTileDrill(props.widgetId, props.result);
|
|
76
128
|
return /* @__PURE__ */ jsxs("section", {
|
|
77
129
|
className: "dd-tile",
|
|
78
130
|
"aria-busy": props.loading,
|
|
79
131
|
"data-kind": props.widget.kind,
|
|
132
|
+
"data-widget": props.widgetId,
|
|
80
133
|
children: [
|
|
81
134
|
/* @__PURE__ */ jsxs("header", {
|
|
82
135
|
className: "dd-tile-header",
|
|
@@ -84,40 +137,39 @@ const Tile = memo(function Tile(props) {
|
|
|
84
137
|
/* @__PURE__ */ jsx("h3", {
|
|
85
138
|
className: "dd-tile-title",
|
|
86
139
|
title: props.widget.title,
|
|
140
|
+
tabIndex: -1,
|
|
87
141
|
children: props.widget.title
|
|
88
142
|
}),
|
|
89
143
|
props.badge,
|
|
90
144
|
/* @__PURE__ */ jsxs("span", {
|
|
91
145
|
className: "dd-tile-actions",
|
|
92
|
-
children: [hasRows(props.result) ? /* @__PURE__ */ jsx("button", {
|
|
146
|
+
children: [hasRows(props.result) && drill !== void 0 ? /* @__PURE__ */ jsx("button", {
|
|
93
147
|
type: "button",
|
|
94
148
|
className: "dd-tile-rows",
|
|
95
149
|
"aria-label": messages.rowsBehind(props.widget.title),
|
|
96
150
|
onClick: () => {
|
|
97
|
-
|
|
151
|
+
drill.openAll();
|
|
98
152
|
},
|
|
99
153
|
children: messages.rows
|
|
100
154
|
}) : null, props.actions]
|
|
101
155
|
})
|
|
102
156
|
]
|
|
103
157
|
}),
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
setOpen(false);
|
|
109
|
-
}
|
|
110
|
-
}) : null,
|
|
158
|
+
/* @__PURE__ */ jsx(Span, {
|
|
159
|
+
result: props.result,
|
|
160
|
+
shared: props.sharedSpan
|
|
161
|
+
}),
|
|
111
162
|
/* @__PURE__ */ jsx("div", {
|
|
112
163
|
className: "dd-tile-body",
|
|
113
164
|
children: /* @__PURE__ */ jsx(Body, {
|
|
114
165
|
widget: props.widget,
|
|
115
166
|
result: props.result,
|
|
116
|
-
loading: props.result === void 0 && props.loading
|
|
167
|
+
loading: props.result === void 0 && props.loading,
|
|
168
|
+
drill
|
|
117
169
|
})
|
|
118
170
|
}),
|
|
119
171
|
/* @__PURE__ */ jsx(Notes, { ...props })
|
|
120
172
|
]
|
|
121
173
|
});
|
|
122
174
|
});
|
|
123
|
-
export { Tile };
|
|
175
|
+
export { Span, Tile, sharedSpan, spanKey };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// \0rolldown/runtime.js
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __exportAll = (all, no_symbols) => {
|
|
4
|
+
let target = {};
|
|
5
|
+
for (var name in all) __defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true
|
|
8
|
+
});
|
|
9
|
+
if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
|
|
10
|
+
return target;
|
|
11
|
+
};
|
|
12
|
+
export { __exportAll };
|
|
@@ -39,41 +39,44 @@ function stepOf(grid) {
|
|
|
39
39
|
y: row + rowGap
|
|
40
40
|
};
|
|
41
41
|
}
|
|
42
|
-
/** The smallest a person can resize a tile to: room for its title, its buttons and a number. */
|
|
43
|
-
const SMALLEST = {
|
|
44
|
-
w: 2,
|
|
45
|
-
h: 2
|
|
46
|
-
};
|
|
47
42
|
/**
|
|
48
43
|
* The item moved or resized by whole cells: a move keeps the size; a resize keeps the top left,
|
|
49
|
-
* stops at the grid's edge, and never makes a tile smaller than
|
|
50
|
-
* smaller stays as it is).
|
|
44
|
+
* stops at the grid's edge, and never makes a tile smaller than its kind reads at (core's
|
|
45
|
+
* `smallestFor`; one already smaller stays as it is).
|
|
51
46
|
*/
|
|
52
|
-
function shifted(item,
|
|
47
|
+
function shifted(item, how, by) {
|
|
48
|
+
const { mode, least } = how;
|
|
49
|
+
const { dx, dy } = by;
|
|
53
50
|
return mode === "move" ? {
|
|
54
51
|
...item,
|
|
55
52
|
x: Math.max(0, item.x + dx),
|
|
56
53
|
y: Math.max(0, item.y + dy)
|
|
57
54
|
} : {
|
|
58
55
|
...item,
|
|
59
|
-
w: Math.min(Math.max(Math.min(
|
|
60
|
-
h: Math.max(Math.min(
|
|
56
|
+
w: Math.min(Math.max(Math.min(least.w, item.w), item.w + dx), GRID_COLUMNS - item.x),
|
|
57
|
+
h: Math.max(Math.min(least.h, item.h), item.h + dy)
|
|
61
58
|
};
|
|
62
59
|
}
|
|
63
60
|
/** Where a drag puts the item: whole cells from where the pointer went down. */
|
|
64
61
|
function dragged(d, event) {
|
|
65
62
|
const dx = Math.round((event.clientX - d.x0) / d.step.x);
|
|
66
63
|
const dy = Math.round((event.clientY - d.y0) / d.step.y);
|
|
67
|
-
return shifted(d.start, d
|
|
64
|
+
return shifted(d.start, d, {
|
|
65
|
+
dx,
|
|
66
|
+
dy
|
|
67
|
+
});
|
|
68
68
|
}
|
|
69
69
|
/**
|
|
70
70
|
* One arrow key's move: the nearest place in that direction where the layout really changes,
|
|
71
71
|
* so moving down past a tile takes one press, not as many as it is tall.
|
|
72
72
|
*/
|
|
73
|
-
function nextStep(tab, item,
|
|
73
|
+
function nextStep(tab, item, how, key) {
|
|
74
74
|
const before = JSON.stringify(placeItem(tab.layout, item));
|
|
75
75
|
for (let n = 1; n <= 48; n += 1) {
|
|
76
|
-
const next = shifted(item,
|
|
76
|
+
const next = shifted(item, how, {
|
|
77
|
+
dx: key.dx * n,
|
|
78
|
+
dy: key.dy * n
|
|
79
|
+
});
|
|
77
80
|
if (JSON.stringify(placeItem(tab.layout, next)) !== before) return next;
|
|
78
81
|
}
|
|
79
82
|
return item;
|
package/dist/react/arrange.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { KEYS, commit, dragged, follow, nextStep, same, stepOf } from "./arrange
|
|
|
2
2
|
import { useDashboards } from "./context.mjs";
|
|
3
3
|
import { useStable } from "./stable.mjs";
|
|
4
4
|
import { useMemo, useRef, useState } from "react";
|
|
5
|
-
import { placeItem } from "derive-dashboards/core";
|
|
5
|
+
import { placeItem, smallestFor } from "derive-dashboards/core";
|
|
6
6
|
// src/arrange.ts
|
|
7
7
|
/**
|
|
8
8
|
* A preview that only changes when its place does: a pointer moving inside one grid cell
|
|
@@ -25,12 +25,18 @@ function usePreview() {
|
|
|
25
25
|
show: useStable(show)
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
|
+
/** The smallest the tile's kind reads at, from the draft's own widget. */
|
|
29
|
+
const leastOf = (a, item) => smallestFor(a.edit().draft?.doc.widgets[item.widget]?.kind);
|
|
28
30
|
/** An arrow key on a handle: a cell's move (or with Shift, a resize), then where the tile is now. */
|
|
29
31
|
const onKey = (a, send, item, mode) => (event) => {
|
|
30
32
|
const key = KEYS[event.key];
|
|
31
33
|
if (key === void 0 || a.edit().busy) return;
|
|
32
34
|
event.preventDefault();
|
|
33
|
-
const
|
|
35
|
+
const how = {
|
|
36
|
+
mode: event.shiftKey ? "resize" : mode,
|
|
37
|
+
least: leastOf(a, item)
|
|
38
|
+
};
|
|
39
|
+
const wanted = nextStep(a.tab(), item, how, key);
|
|
34
40
|
const said = async () => {
|
|
35
41
|
await send(wanted);
|
|
36
42
|
requestAnimationFrame(() => {
|
|
@@ -67,7 +73,8 @@ function handlers(a, drag, show) {
|
|
|
67
73
|
last: {
|
|
68
74
|
clientX: x0,
|
|
69
75
|
clientY: y0
|
|
70
|
-
}
|
|
76
|
+
},
|
|
77
|
+
least: leastOf(a, item)
|
|
71
78
|
};
|
|
72
79
|
show(item, mode === "move" ? item : void 0);
|
|
73
80
|
},
|