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/node-postgres.d.mts
CHANGED
|
@@ -10,11 +10,14 @@ export type PgQueryable = {
|
|
|
10
10
|
rows: unknown[];
|
|
11
11
|
}>;
|
|
12
12
|
};
|
|
13
|
+
/** A pooled client: node-postgres gives its backend's `processID`, which a cancel names. */
|
|
14
|
+
type PgClient = PgQueryable & {
|
|
15
|
+
release(destroy?: boolean | Error): void;
|
|
16
|
+
processID?: number;
|
|
17
|
+
};
|
|
13
18
|
/** What `nodePostgres` uses of a node-postgres `Pool`: `query`, and `connect` for a transaction. */
|
|
14
19
|
export type PgPool = PgQueryable & {
|
|
15
|
-
connect(): Promise<
|
|
16
|
-
release(destroy?: boolean | Error): void;
|
|
17
|
-
}>;
|
|
20
|
+
connect(): Promise<PgClient>;
|
|
18
21
|
};
|
|
19
22
|
/**
|
|
20
23
|
* The query connection and the store for a node-postgres `Pool`, set up the safe way: each
|
|
@@ -30,4 +33,5 @@ export declare function nodePostgres(pool: PgPool, options?: {
|
|
|
30
33
|
}): {
|
|
31
34
|
connection: IntrospectingConnection;
|
|
32
35
|
store: ReturnType<typeof postgresStore>;
|
|
33
|
-
};
|
|
36
|
+
};
|
|
37
|
+
export {};
|
package/dist/node-postgres.mjs
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
1
1
|
import { postgresConnection } from "./postgres-connection.mjs";
|
|
2
2
|
import { postgresStore } from "./postgres-store.mjs";
|
|
3
3
|
// src/node-postgres.ts
|
|
4
|
+
/**
|
|
5
|
+
* Cancels the client's running statement from another connection when the request aborts, so
|
|
6
|
+
* a statement nobody waits for stops in the database and gives its connection back.
|
|
7
|
+
*/
|
|
8
|
+
async function cancelling(pool, client, signal, work) {
|
|
9
|
+
const pid = "processID" in client && typeof client.processID === "number" ? client.processID : void 0;
|
|
10
|
+
if (signal === void 0 || pid === void 0) return work;
|
|
11
|
+
const cancel = () => {
|
|
12
|
+
pool.query({
|
|
13
|
+
text: "SELECT pg_cancel_backend($1)",
|
|
14
|
+
values: [pid]
|
|
15
|
+
}).catch(() => null);
|
|
16
|
+
};
|
|
17
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
18
|
+
try {
|
|
19
|
+
return await work;
|
|
20
|
+
} finally {
|
|
21
|
+
signal.removeEventListener("abort", cancel);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
4
24
|
/** Rows as arrays in select order, for queries; as objects by column, for the store. */
|
|
5
|
-
const arrays = (client) => async (text, params) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
25
|
+
const arrays = (client, pool) => async (text, params, options) => {
|
|
26
|
+
const work = client.query({
|
|
27
|
+
text,
|
|
28
|
+
values: [...params],
|
|
29
|
+
rowMode: "array"
|
|
30
|
+
});
|
|
31
|
+
return (pool === void 0 ? await work : await cancelling(pool, client, options?.signal, work)).rows;
|
|
32
|
+
};
|
|
10
33
|
const objects = (client) => async (text, params) => (await client.query({
|
|
11
34
|
text,
|
|
12
35
|
values: [...params]
|
|
@@ -48,7 +71,7 @@ function nodePostgres(pool, options = {}) {
|
|
|
48
71
|
...options.id === void 0 ? {} : { id: options.id },
|
|
49
72
|
run: arrays(pool),
|
|
50
73
|
sendsBegin: true,
|
|
51
|
-
transaction: (fn, begin) => inTransaction(pool, begin, (client) => fn(arrays(client)))
|
|
74
|
+
transaction: (fn, begin) => inTransaction(pool, begin, (client) => fn(arrays(client, pool)))
|
|
52
75
|
}),
|
|
53
76
|
store: postgresStore({
|
|
54
77
|
run: objects(pool),
|
package/dist/owner.mjs
CHANGED
|
@@ -5,8 +5,8 @@ import { principalTenant } from "derive-dashboards/core";
|
|
|
5
5
|
// src/owner.ts
|
|
6
6
|
/** Who made a stored dashboard, as `can` receives it. */
|
|
7
7
|
const ownerOf = (row) => ({
|
|
8
|
-
id: String(row
|
|
9
|
-
kind: row
|
|
8
|
+
id: String(row.owner_id),
|
|
9
|
+
kind: row.owner_kind === "agent" ? "agent" : "user"
|
|
10
10
|
});
|
|
11
11
|
/**
|
|
12
12
|
* A dashboard as `can` sees it: its id, and who made it when it is stored, so a host's rule
|
|
@@ -21,7 +21,7 @@ async function dashboardResource(options, request, principal, id) {
|
|
|
21
21
|
};
|
|
22
22
|
const tenant = principalTenant(principal);
|
|
23
23
|
const row = await requestDashboardRow(request, adapter, tenant, parseDashboardId(id));
|
|
24
|
-
if (row === null || row
|
|
24
|
+
if (row === null || row.default_of !== null) return {
|
|
25
25
|
kind: "dashboard",
|
|
26
26
|
id
|
|
27
27
|
};
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { IntrospectingConnection } from "derive-dashboards/core";
|
|
2
|
-
/**
|
|
3
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Runs one statement with its parameters and returns its rows as arrays, in select order.
|
|
4
|
+
* `signal` aborts when the request no longer wants the answer (the person moved on): a driver
|
|
5
|
+
* that can should cancel the statement in the database then (`nodePostgres` does).
|
|
6
|
+
*/
|
|
7
|
+
export type RunSql = (text: string, params: readonly unknown[], options?: {
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
}) => Promise<readonly (readonly unknown[])[]>;
|
|
4
10
|
export type PostgresConnectionOptions = {
|
|
5
11
|
/** Defaults to "main". */
|
|
6
12
|
id?: string;
|
|
@@ -40,7 +40,8 @@ function sessionOf(run, options, concurrent) {
|
|
|
40
40
|
options.signal.throwIfAborted();
|
|
41
41
|
if (Date.now() >= options.deadline) throw pastDeadline();
|
|
42
42
|
try {
|
|
43
|
-
|
|
43
|
+
const rows = run(sql.text, sql.params, { signal: options.signal });
|
|
44
|
+
return { rows: arrayRows(await bounded(rows, options)) };
|
|
44
45
|
} catch (error) {
|
|
45
46
|
if (timedOut(error)) throw pastDeadline();
|
|
46
47
|
if (badValue(error)) throw new HttpError(400, "QUERY_INVALID", "A value does not fit its column's type in the database. Check the viewer's tenant values against the tenant columns, and the query's filter values.", { cause: error });
|
package/dist/postgres-store.mjs
CHANGED
|
@@ -55,6 +55,7 @@ function runner(options, run, depth) {
|
|
|
55
55
|
* Its `dd_` tables come from `generate` in your own schema, or from `createTables`.
|
|
56
56
|
*/
|
|
57
57
|
function postgresStore(options) {
|
|
58
|
+
for (const name of ["run", "transaction"]) if (typeof options[name] !== "function") throw new TypeError(`postgresStore needs ${name === "run" ? "a run (a statement to rows as objects)" : "a transaction (fn) => Promise, so every store write is one transaction"}. See docs/quick-start.md, step 4, or use nodePostgres(pool).`);
|
|
58
59
|
return sqlAdapter("postgres", runner(options, options.run, 0));
|
|
59
60
|
}
|
|
60
61
|
export { postgresStore };
|
package/dist/react/Canvas.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
|
-
import { FilterBar } from "./FilterBar.mjs";
|
|
3
2
|
import { Grid } from "./Grid.mjs";
|
|
4
3
|
import { Header } from "./Header.mjs";
|
|
4
|
+
import { Span, sharedSpan, spanKey } from "./Tile.mjs";
|
|
5
5
|
import { linkTo } from "./view.mjs";
|
|
6
6
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
7
|
// src/Canvas.tsx
|
|
@@ -45,6 +45,29 @@ function EmptyTab({ onAdd }) {
|
|
|
45
45
|
})]
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
+
/** The zone the server read the tiles in, from any answer's receipt: the host's default included. */
|
|
49
|
+
function answeredZone(results) {
|
|
50
|
+
for (const result of results.values()) if (!("error" in result)) return result.receipt.calendar.timezone;
|
|
51
|
+
}
|
|
52
|
+
/** The host's filter bar (the built-in one by default), told the zone dates are read in. */
|
|
53
|
+
function Filters({ board, doc }) {
|
|
54
|
+
const Bar = useDashboards().components.FilterBar;
|
|
55
|
+
return /* @__PURE__ */ jsx(Bar, {
|
|
56
|
+
controls: doc.controls,
|
|
57
|
+
picks: board.view.picks,
|
|
58
|
+
onChange: board.view.setPicks,
|
|
59
|
+
timezone: doc.scope.timezone ?? answeredZone(board.tiles.results)
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/** The span most tiles cover, said once under the filters; the tiles that cover it leave it out. */
|
|
63
|
+
function DashboardSpan({ results }) {
|
|
64
|
+
const shared = sharedSpan(results);
|
|
65
|
+
const one = [...results.values()].find((result) => spanKey(result) === shared);
|
|
66
|
+
return shared === void 0 || one === void 0 ? null : /* @__PURE__ */ jsx("div", {
|
|
67
|
+
className: "dd-span-all",
|
|
68
|
+
children: /* @__PURE__ */ jsx(Span, { result: one })
|
|
69
|
+
});
|
|
70
|
+
}
|
|
48
71
|
/** The canvas: header, tabs, filters, and the grid with its marks. */
|
|
49
72
|
function Canvas(props) {
|
|
50
73
|
const { board, shown } = props;
|
|
@@ -71,11 +94,11 @@ function Canvas(props) {
|
|
|
71
94
|
current: shown.tab,
|
|
72
95
|
onSelect: view.setTab
|
|
73
96
|
}),
|
|
74
|
-
/* @__PURE__ */ jsx(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
onChange: view.setPicks
|
|
97
|
+
/* @__PURE__ */ jsx(Filters, {
|
|
98
|
+
board,
|
|
99
|
+
doc: shown.doc
|
|
78
100
|
}),
|
|
101
|
+
/* @__PURE__ */ jsx(DashboardSpan, { results: board.tiles.results }),
|
|
79
102
|
edit.draft === void 0 || !emptyTab(shown) ? null : /* @__PURE__ */ jsx(EmptyTab, { onAdd: add }),
|
|
80
103
|
/* @__PURE__ */ jsx(Grid, {
|
|
81
104
|
doc: shown.doc,
|
package/dist/react/Cell.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ViewChange } from "./view.mjs";
|
|
2
|
+
import { DashboardDrillProps } from "./drill/board.mjs";
|
|
1
3
|
import { DashboardEvents } from "./useDashboard.mjs";
|
|
2
4
|
import { ViewState } from "derive-dashboards/core";
|
|
3
5
|
/**
|
|
@@ -7,10 +9,12 @@ import { ViewState } from "derive-dashboards/core";
|
|
|
7
9
|
* changed tiles are marked in place. Review and publish opens the review beside the canvas:
|
|
8
10
|
* every change, and over a newer version the merged result, then Publish. History opens the
|
|
9
11
|
* timeline in the same panel; any version can be looked at in place, restored or copied.
|
|
10
|
-
* Share copies a link with the tab and
|
|
12
|
+
* Share copies a link with the tab, filters and drill. A click on a bar, a point, a table row
|
|
13
|
+
* or a number opens what is behind it beside the dashboard (`drill={false}` turns it off).
|
|
11
14
|
*
|
|
12
|
-
* `view` and `onViewChange` let the host keep the tab and
|
|
13
|
-
* `decodeView`); `linkFor` makes the link Share copies. `editable={false}` shows
|
|
15
|
+
* `view` and `onViewChange` let the host keep the tab, filters and drill in its URL
|
|
16
|
+
* (`encodeView`, `decodeView`); `linkFor` makes the link Share copies. `editable={false}` shows
|
|
17
|
+
* it read-only.
|
|
14
18
|
*/
|
|
15
19
|
export type DashboardProps = {
|
|
16
20
|
id: string;
|
|
@@ -18,10 +22,11 @@ export type DashboardProps = {
|
|
|
18
22
|
editable?: boolean;
|
|
19
23
|
/** The tab and filters to show, when the host keeps them (from a link, say). */
|
|
20
24
|
view?: ViewState;
|
|
21
|
-
|
|
25
|
+
/** The view changed: `history` says whether Back should undo it (`push`, a drill step) or not. */
|
|
26
|
+
onViewChange?: (view: ViewState, change: ViewChange) => void;
|
|
22
27
|
/** What the host's `decodeView` could not read from a link, so the page says it was left out. */
|
|
23
28
|
linkDropped?: readonly string[];
|
|
24
29
|
/** The link Share copies for a view; by default, this page's address with the view in it. */
|
|
25
30
|
linkFor?: (view: ViewState) => string;
|
|
26
|
-
} & DashboardEvents;
|
|
31
|
+
} & DashboardEvents & DashboardDrillProps;
|
|
27
32
|
export declare function Dashboard(props: DashboardProps): import("react").JSX.Element;
|
package/dist/react/Dashboard.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Canvas } from "./Canvas.mjs";
|
|
2
2
|
import { useDashboards } from "./context.mjs";
|
|
3
|
+
import { DrillScope } from "./drill/board.mjs";
|
|
3
4
|
import { BuildPage } from "./Editing.mjs";
|
|
4
5
|
import { Bars, Side } from "./Parts.mjs";
|
|
5
6
|
import { ScopeContext } from "./scope.mjs";
|
|
@@ -13,20 +14,55 @@ function focusOpener(widgetId) {
|
|
|
13
14
|
((widgetId === void 0 ? null : document.querySelector(`.dd-cell[data-widget="${CSS.escape(widgetId)}"] .dd-tile-edit`)) ?? document.querySelector("[data-focus-after]"))?.focus();
|
|
14
15
|
});
|
|
15
16
|
}
|
|
17
|
+
/** The dashboard could not be read and there is nothing to show: say so, and offer to try again. */
|
|
18
|
+
function LoadFailed({ onRetry, failure }) {
|
|
19
|
+
const { messages } = useDashboards();
|
|
20
|
+
const refused = failure !== void 0 && failure.status >= 400 && failure.status < 500;
|
|
21
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
22
|
+
className: "dd-tile-error",
|
|
23
|
+
role: "alert",
|
|
24
|
+
children: [
|
|
25
|
+
messages.dashboardFailed,
|
|
26
|
+
" ",
|
|
27
|
+
refused ? /* @__PURE__ */ jsxs("span", {
|
|
28
|
+
className: "dd-tile-note",
|
|
29
|
+
children: [
|
|
30
|
+
failure.message,
|
|
31
|
+
" (",
|
|
32
|
+
failure.code,
|
|
33
|
+
")"
|
|
34
|
+
]
|
|
35
|
+
}) : /* @__PURE__ */ jsx("button", {
|
|
36
|
+
type: "button",
|
|
37
|
+
className: "dd-button dd-quiet",
|
|
38
|
+
onClick: onRetry,
|
|
39
|
+
children: messages.drillRetry
|
|
40
|
+
})
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
/** The dashboard stays while the server cannot be reached, and says so quietly. */
|
|
45
|
+
function Unreachable() {
|
|
46
|
+
const { messages } = useDashboards();
|
|
47
|
+
return /* @__PURE__ */ jsx("p", {
|
|
48
|
+
className: "dd-tile-note",
|
|
49
|
+
role: "status",
|
|
50
|
+
children: messages.dashboardUnreachable
|
|
51
|
+
});
|
|
52
|
+
}
|
|
16
53
|
function Dashboard(props) {
|
|
17
54
|
const { messages } = useDashboards();
|
|
18
55
|
const board = useBoard(props);
|
|
19
56
|
const [building, setBuilding] = useState();
|
|
20
57
|
const [fresh, setFresh] = useState();
|
|
21
|
-
const { error, edit, shown,
|
|
58
|
+
const { error, edit, shown, view } = board;
|
|
22
59
|
if (board.missing) return /* @__PURE__ */ jsx("div", {
|
|
23
60
|
className: "dd-tile-state",
|
|
24
61
|
children: messages.dashboardMissing
|
|
25
62
|
});
|
|
26
|
-
if (error) return /* @__PURE__ */ jsx(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
children: messages.dashboardFailed
|
|
63
|
+
if (error) return /* @__PURE__ */ jsx(LoadFailed, {
|
|
64
|
+
onRetry: board.refresh,
|
|
65
|
+
failure: board.failure
|
|
30
66
|
});
|
|
31
67
|
if (shown?.tab === void 0) return /* @__PURE__ */ jsx("div", {
|
|
32
68
|
className: "dd-dashboard",
|
|
@@ -51,25 +87,29 @@ function Dashboard(props) {
|
|
|
51
87
|
picks: view.picks,
|
|
52
88
|
...editing ? { draft: true } : {}
|
|
53
89
|
},
|
|
54
|
-
children: /* @__PURE__ */ jsxs(
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
90
|
+
children: /* @__PURE__ */ jsxs(DrillScope, {
|
|
91
|
+
id: props.id,
|
|
92
|
+
board,
|
|
93
|
+
drill: props,
|
|
58
94
|
children: [/* @__PURE__ */ jsxs("div", {
|
|
59
95
|
className: "dd-board",
|
|
60
|
-
children: [
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
96
|
+
children: [
|
|
97
|
+
/* @__PURE__ */ jsx(Bars, {
|
|
98
|
+
board,
|
|
99
|
+
props
|
|
100
|
+
}),
|
|
101
|
+
board.unreachable ? /* @__PURE__ */ jsx(Unreachable, {}) : null,
|
|
102
|
+
/* @__PURE__ */ jsx(Canvas, {
|
|
103
|
+
board,
|
|
104
|
+
shown: {
|
|
105
|
+
...shown,
|
|
106
|
+
tab
|
|
107
|
+
},
|
|
108
|
+
fresh,
|
|
109
|
+
onBuild: setBuilding,
|
|
110
|
+
dashboard: props
|
|
111
|
+
})
|
|
112
|
+
]
|
|
73
113
|
}), /* @__PURE__ */ jsx(Side, {
|
|
74
114
|
board,
|
|
75
115
|
props
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { Row } from "./DashboardListRow.mjs";
|
|
2
3
|
import { useId, useState } from "react";
|
|
3
4
|
import useSWR from "swr";
|
|
4
5
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -73,32 +74,59 @@ function Search(props) {
|
|
|
73
74
|
}) : null] });
|
|
74
75
|
}
|
|
75
76
|
/**
|
|
76
|
-
* The dashboards, each
|
|
77
|
-
*
|
|
77
|
+
* The dashboards, each named for itself, its description and Draft as its description rather
|
|
78
|
+
* than its name. With `linkFor` each is a link and a published one has Copy link beside it.
|
|
78
79
|
*/
|
|
79
80
|
function Items({ items, current, onOpen, linkFor }) {
|
|
80
81
|
const { messages } = useDashboards();
|
|
81
82
|
const base = useId();
|
|
82
|
-
return /* @__PURE__ */ jsx("ul", { children: items.map((d, i) => /* @__PURE__ */ jsxs("li", { children: [
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
onOpen
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
children: d.title
|
|
93
|
-
}), d.unpublished === true ? /* @__PURE__ */ jsx("em", {
|
|
83
|
+
return /* @__PURE__ */ jsx("ul", { children: items.map((d, i) => /* @__PURE__ */ jsxs("li", { children: [
|
|
84
|
+
/* @__PURE__ */ jsx(Row, {
|
|
85
|
+
d,
|
|
86
|
+
href: linkFor?.(d.id),
|
|
87
|
+
current: d.id === current,
|
|
88
|
+
describedBy: `${base}-${String(i)}`,
|
|
89
|
+
onOpen
|
|
90
|
+
}),
|
|
91
|
+
/* @__PURE__ */ jsx("span", {
|
|
92
|
+
hidden: true,
|
|
94
93
|
id: `${base}-${String(i)}`,
|
|
95
|
-
children: messages.unpublished
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
94
|
+
children: [d.unpublished === true ? messages.unpublished : void 0, d.description].filter((part) => part !== void 0).join(". ")
|
|
95
|
+
}),
|
|
96
|
+
linkFor === void 0 || d.unpublished === true ? null : /* @__PURE__ */ jsx(CopyLink, {
|
|
97
|
+
id: d.id,
|
|
98
|
+
title: d.title,
|
|
99
|
+
linkFor
|
|
100
|
+
})
|
|
101
|
+
] }, d.id)) });
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The built-in dashboards (`default:` ids) first, under a heading, then the ones made here, when
|
|
105
|
+
* the list has both; otherwise one plain list.
|
|
106
|
+
*/
|
|
107
|
+
function Groups(props) {
|
|
108
|
+
const { messages } = useDashboards();
|
|
109
|
+
const builtIn = props.items.filter((d) => d.id.startsWith("default:"));
|
|
110
|
+
const made = props.items.filter((d) => !d.id.startsWith("default:"));
|
|
111
|
+
if (builtIn.length === 0 || made.length === 0) return /* @__PURE__ */ jsx(Items, { ...props });
|
|
112
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
113
|
+
/* @__PURE__ */ jsx("h3", {
|
|
114
|
+
className: "dd-list-group",
|
|
115
|
+
children: messages.builtIn
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ jsx(Items, {
|
|
118
|
+
...props,
|
|
119
|
+
items: builtIn
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ jsx("h3", {
|
|
122
|
+
className: "dd-list-group",
|
|
123
|
+
children: messages.madeHere
|
|
124
|
+
}),
|
|
125
|
+
/* @__PURE__ */ jsx(Items, {
|
|
126
|
+
...props,
|
|
127
|
+
items: made
|
|
128
|
+
})
|
|
129
|
+
] });
|
|
102
130
|
}
|
|
103
131
|
/**
|
|
104
132
|
* Every dashboard the viewer can open, theirs not yet published marked as drafts, and
|
|
@@ -112,7 +140,7 @@ function DashboardList({ current, onOpen, linkFor }) {
|
|
|
112
140
|
const [search, setSearch] = useState("");
|
|
113
141
|
const all = list.data?.dashboards ?? [];
|
|
114
142
|
const words = search.trim().toLocaleLowerCase();
|
|
115
|
-
const shown = words === "" ? all : all.filter((d) => d.title.toLocaleLowerCase().includes(words));
|
|
143
|
+
const shown = words === "" ? all : all.filter((d) => `${d.title} ${d.description ?? ""}`.toLocaleLowerCase().includes(words));
|
|
116
144
|
const { making, error, create } = useCreate(onOpen, async () => {
|
|
117
145
|
await list.mutate();
|
|
118
146
|
});
|
|
@@ -132,7 +160,7 @@ function DashboardList({ current, onOpen, linkFor }) {
|
|
|
132
160
|
role: "alert",
|
|
133
161
|
children: error
|
|
134
162
|
}),
|
|
135
|
-
list.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
163
|
+
list.error === void 0 || list.data !== void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
136
164
|
className: "dd-draft-error",
|
|
137
165
|
role: "alert",
|
|
138
166
|
children: messages.listFailed
|
|
@@ -143,7 +171,7 @@ function DashboardList({ current, onOpen, linkFor }) {
|
|
|
143
171
|
setSearch,
|
|
144
172
|
shown: shown.length
|
|
145
173
|
}),
|
|
146
|
-
/* @__PURE__ */ jsx(
|
|
174
|
+
/* @__PURE__ */ jsx(Groups, {
|
|
147
175
|
items: shown,
|
|
148
176
|
current,
|
|
149
177
|
onOpen,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
// src/DashboardListRow.tsx
|
|
4
|
+
/** A click a link would follow itself: a modified or middle click opens a new tab as usual. */
|
|
5
|
+
const plainClick = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
|
|
6
|
+
/**
|
|
7
|
+
* One row: the dashboard's name, Draft for the viewer's unpublished one, and its description.
|
|
8
|
+
* With `href` it is a link, so Cmd-click and middle-click open a new tab while a plain click
|
|
9
|
+
* still goes to `onOpen`; without one it is a button. Draft and the description describe the
|
|
10
|
+
* row; its name stays the dashboard's.
|
|
11
|
+
*/
|
|
12
|
+
function Row(props) {
|
|
13
|
+
const { d, href, describedBy, onOpen } = props;
|
|
14
|
+
const { messages } = useDashboards();
|
|
15
|
+
const shared = {
|
|
16
|
+
className: "dd-list-open",
|
|
17
|
+
"aria-label": d.title,
|
|
18
|
+
"aria-describedby": d.unpublished === true || d.description !== void 0 ? describedBy : void 0,
|
|
19
|
+
"aria-current": props.current ? "page" : void 0
|
|
20
|
+
};
|
|
21
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
|
|
22
|
+
className: "dd-list-name",
|
|
23
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
24
|
+
className: "dd-list-title",
|
|
25
|
+
children: d.title
|
|
26
|
+
}), d.unpublished === true ? /* @__PURE__ */ jsx("em", { children: messages.unpublished }) : null]
|
|
27
|
+
}), d.description === void 0 ? null : /* @__PURE__ */ jsx("span", {
|
|
28
|
+
className: "dd-list-desc",
|
|
29
|
+
children: d.description
|
|
30
|
+
})] });
|
|
31
|
+
return href === void 0 ? /* @__PURE__ */ jsx("button", {
|
|
32
|
+
type: "button",
|
|
33
|
+
...shared,
|
|
34
|
+
onClick: () => {
|
|
35
|
+
onOpen(d.id);
|
|
36
|
+
},
|
|
37
|
+
children: body
|
|
38
|
+
}) : /* @__PURE__ */ jsx("a", {
|
|
39
|
+
href,
|
|
40
|
+
...shared,
|
|
41
|
+
onClick: (event) => {
|
|
42
|
+
if (event.defaultPrevented || !plainClick(event)) return;
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
onOpen(d.id);
|
|
45
|
+
},
|
|
46
|
+
children: body
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export { Row };
|
package/dist/react/Discard.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useDashboards } from "./context.mjs";
|
|
2
2
|
import { isShifted } from "./marks.mjs";
|
|
3
|
-
import { useEffect, useRef, useState } from "react";
|
|
3
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
// src/Discard.tsx
|
|
6
6
|
/**
|
|
@@ -21,15 +21,18 @@ function DiscardButton({ edit, isNew = false }) {
|
|
|
21
21
|
answered.current = !on;
|
|
22
22
|
setAsking(on);
|
|
23
23
|
};
|
|
24
|
+
const untouched = !isNew && (edit.draft?.changes.filter((c) => !isShifted(c)).length ?? 0) === 0;
|
|
24
25
|
if (!asking) return /* @__PURE__ */ jsx("button", {
|
|
25
26
|
ref: discard,
|
|
26
27
|
type: "button",
|
|
27
28
|
className: "dd-button dd-quiet",
|
|
28
29
|
"aria-disabled": edit.busy,
|
|
29
30
|
onClick: () => {
|
|
30
|
-
if (
|
|
31
|
+
if (edit.busy) return;
|
|
32
|
+
if (untouched) edit.discard();
|
|
33
|
+
else ask(true);
|
|
31
34
|
},
|
|
32
|
-
children: messages.discard
|
|
35
|
+
children: untouched ? messages.doneEditing : messages.discard
|
|
33
36
|
});
|
|
34
37
|
return /* @__PURE__ */ jsx(DiscardAsk, {
|
|
35
38
|
edit,
|
|
@@ -69,14 +72,19 @@ function DiscardAsk(props) {
|
|
|
69
72
|
const { messages } = useDashboards();
|
|
70
73
|
const { edit, isNew, onKeep } = props;
|
|
71
74
|
useEscape(onKeep);
|
|
75
|
+
const question = useId();
|
|
72
76
|
return /* @__PURE__ */ jsxs("span", {
|
|
73
77
|
className: "dd-row",
|
|
74
78
|
children: [
|
|
75
|
-
/* @__PURE__ */ jsx("span", {
|
|
79
|
+
/* @__PURE__ */ jsx("span", {
|
|
80
|
+
id: question,
|
|
81
|
+
children: isNew ? messages.deleteNewAsk : messages.discardAsk(edit.draft?.changes.filter((c) => !isShifted(c)).length ?? 0)
|
|
82
|
+
}),
|
|
76
83
|
/* @__PURE__ */ jsx("button", {
|
|
77
84
|
ref: props.keep,
|
|
78
85
|
type: "button",
|
|
79
86
|
className: "dd-button dd-quiet",
|
|
87
|
+
"aria-describedby": question,
|
|
80
88
|
onClick: props.onKeep,
|
|
81
89
|
children: messages.keepEditing
|
|
82
90
|
}),
|
package/dist/react/Editing.mjs
CHANGED
|
@@ -81,14 +81,14 @@ function saveCommands(doc, tab, widget, widgetId) {
|
|
|
81
81
|
at: placeFor(tab, widget)
|
|
82
82
|
}];
|
|
83
83
|
const before = doc.widgets[widgetId];
|
|
84
|
-
const query = widget.queries
|
|
84
|
+
const query = widget.queries.main;
|
|
85
85
|
return [{
|
|
86
86
|
type: "widget.update",
|
|
87
87
|
id: widgetId,
|
|
88
88
|
title: widget.title,
|
|
89
89
|
kind: widget.kind,
|
|
90
90
|
...widget.display === void 0 ? {} : { display: widget.display }
|
|
91
|
-
}, ...query === void 0 || before?.queries
|
|
91
|
+
}, ...query === void 0 || before?.queries.main === query ? [] : [{
|
|
92
92
|
type: "widget.setQuery",
|
|
93
93
|
id: widgetId,
|
|
94
94
|
name: "main",
|
|
@@ -103,6 +103,22 @@ function BuildPage({ doc, tab, edit, widgetId, onDone }) {
|
|
|
103
103
|
const { messages } = useDashboards();
|
|
104
104
|
const [id] = useState(() => widgetId ?? `w${crypto.randomUUID().slice(0, 8)}`);
|
|
105
105
|
const initial = widgetId === void 0 ? void 0 : doc.widgets[widgetId];
|
|
106
|
+
const cancel = () => {
|
|
107
|
+
onDone();
|
|
108
|
+
};
|
|
109
|
+
if (initial !== void 0 && initial.queries["main"] === void 0) return /* @__PURE__ */ jsxs("div", {
|
|
110
|
+
className: "dd-builder",
|
|
111
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
112
|
+
type: "button",
|
|
113
|
+
className: "dd-back",
|
|
114
|
+
onClick: cancel,
|
|
115
|
+
children: ["‹ ", doc.meta.title]
|
|
116
|
+
}), /* @__PURE__ */ jsx("p", {
|
|
117
|
+
className: "dd-builder-error",
|
|
118
|
+
role: "alert",
|
|
119
|
+
children: messages.noMainQuery(initial.title)
|
|
120
|
+
})]
|
|
121
|
+
});
|
|
106
122
|
return /* @__PURE__ */ jsx(WidgetBuilder, {
|
|
107
123
|
...initial === void 0 ? {} : { initial },
|
|
108
124
|
backLabel: doc.meta.title,
|
|
@@ -110,9 +126,7 @@ function BuildPage({ doc, tab, edit, widgetId, onDone }) {
|
|
|
110
126
|
saveLabel: widgetId === void 0 ? messages.addToDashboard : messages.save,
|
|
111
127
|
saving: edit.busy,
|
|
112
128
|
...edit.error === void 0 ? {} : { error: edit.error },
|
|
113
|
-
onCancel:
|
|
114
|
-
onDone();
|
|
115
|
-
},
|
|
129
|
+
onCancel: cancel,
|
|
116
130
|
onSave: (widget) => {
|
|
117
131
|
const save = async () => {
|
|
118
132
|
if (await edit.apply(saveCommands(doc, tab, widget, id))) onDone(id);
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
export declare function FilterBar({ controls, picks, onChange }: Props): import("react").JSX.Element | null;
|
|
9
|
-
export {};
|
|
1
|
+
import { ENGLISH_FILTERS, FilterWords } from "./filters/words.mjs";
|
|
2
|
+
import { FilterBar } from "./filters/bar.mjs";
|
|
3
|
+
import { FilterBarOptions, FilterIcon } from "./filters/context.mjs";
|
|
4
|
+
import { FilterBarProps, fieldOf, useControlValues, useFilterFields } from "./filters/hooks.mjs";
|
|
5
|
+
import { Popover } from "./filters/popover.mjs";
|
|
6
|
+
import { rules_d_exports } from "./filters/rules.mjs";
|
|
7
|
+
export { ENGLISH_FILTERS, FilterBar, type FilterBarOptions, type FilterBarProps, type FilterIcon, type FilterWords, Popover, fieldOf, rules_d_exports as filterRules, useControlValues, useFilterFields };
|