derive-dashboards 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +90 -2
- package/dist/adapter/sql-adapter.mjs +80 -0
- package/dist/adapter/statement.mjs +140 -0
- package/dist/authorize.mjs +55 -0
- package/dist/body.mjs +164 -0
- package/dist/bounded.mjs +31 -0
- package/dist/cache.d.mts +21 -0
- package/dist/cache.mjs +138 -0
- package/dist/checks.mjs +98 -0
- package/dist/cli/bin.d.mts +1 -0
- package/dist/cli/bin.mjs +13 -0
- package/dist/cli/check.mjs +52 -0
- package/dist/cli/cli.d.mts +5 -0
- package/dist/cli/cli.mjs +144 -0
- package/dist/cli/config.d.mts +21 -0
- package/dist/cli/config.mjs +14 -0
- package/dist/cli/conformance.mjs +34 -0
- package/dist/cli/import/build.mjs +118 -0
- package/dist/cli/import/catalog.mjs +42 -0
- package/dist/cli/import/cube-schema.mjs +51 -0
- package/dist/cli/import/cube-sql.mjs +52 -0
- package/dist/cli/import/cube.mjs +172 -0
- package/dist/cli/import/dbt-metrics.mjs +76 -0
- package/dist/cli/import/dbt-schema.mjs +82 -0
- package/dist/cli/import/dbt.mjs +154 -0
- package/dist/cli/import/draft.mjs +46 -0
- package/dist/cli/import/index.mjs +71 -0
- package/dist/cli/import/storage.mjs +92 -0
- package/dist/cli/import/tenancy.mjs +76 -0
- package/dist/cli/index.d.mts +6 -0
- package/dist/cli/index.mjs +5 -0
- package/dist/cli/init.mjs +72 -0
- package/dist/cli/io.d.mts +6 -0
- package/dist/cli/load.mjs +18 -0
- package/dist/cli/propose.d.mts +13 -0
- package/dist/cli/propose.mjs +215 -0
- package/dist/cli/render.d.mts +14 -0
- package/dist/cli/render.mjs +106 -0
- package/dist/core/conformance/cases.d.mts +12 -0
- package/dist/core/conformance/cases.mjs +82 -0
- package/dist/core/conformance/check.d.mts +33 -0
- package/dist/core/conformance/check.mjs +81 -0
- package/dist/core/conformance/dataset-model.mjs +306 -0
- package/dist/core/conformance/dataset-rows.mjs +246 -0
- package/dist/core/conformance/dataset.d.mts +381 -0
- package/dist/core/conformance/dataset.mjs +58 -0
- package/dist/core/conformance/index.d.mts +10 -0
- package/dist/core/conformance/index.mjs +9 -0
- package/dist/core/conformance/memory/aggregate.mjs +76 -0
- package/dist/core/conformance/memory/rows.d.mts +10 -0
- package/dist/core/conformance/memory/rows.mjs +98 -0
- package/dist/core/conformance/memory/source.d.mts +4 -0
- package/dist/core/conformance/memory/source.mjs +129 -0
- package/dist/core/conformance/queries.mjs +108 -0
- package/dist/core/conformance/records-cases.mjs +68 -0
- package/dist/core/document/diff.d.mts +68 -0
- package/dist/core/document/diff.mjs +155 -0
- package/dist/core/document/layout.d.mts +51 -0
- package/dist/core/document/layout.mjs +228 -0
- package/dist/core/document/outcome.d.mts +10 -0
- package/dist/core/document/outcome.mjs +14 -0
- package/dist/core/document/reduce.d.mts +16 -0
- package/dist/core/document/reduce.mjs +191 -0
- package/dist/core/document/replay.d.mts +28 -0
- package/dist/core/document/replay.mjs +38 -0
- package/dist/core/document/stacked.d.mts +14 -0
- package/dist/core/document/stacked.mjs +70 -0
- package/dist/core/document/tabs.mjs +70 -0
- package/dist/core/document/types.d.mts +138 -0
- package/dist/core/document/types.mjs +16 -0
- package/dist/core/document/upgrade.d.mts +25 -0
- package/dist/core/document/upgrade.mjs +49 -0
- package/dist/core/document/view.d.mts +30 -0
- package/dist/core/document/view.mjs +50 -0
- package/dist/core/engine/access.mjs +113 -0
- package/dist/core/engine/assert.d.mts +21 -0
- package/dist/core/engine/assert.mjs +132 -0
- package/dist/core/engine/bucket.mjs +52 -0
- package/dist/core/engine/build.mjs +71 -0
- package/dist/core/engine/checks.mjs +29 -0
- package/dist/core/engine/context.mjs +46 -0
- package/dist/core/engine/cursor.mjs +30 -0
- package/dist/core/engine/custom/ask.mjs +13 -0
- package/dist/core/engine/custom/cells.mjs +80 -0
- package/dist/core/engine/custom/fields.mjs +130 -0
- package/dist/core/engine/custom/level.mjs +136 -0
- package/dist/core/engine/custom/measures.mjs +146 -0
- package/dist/core/engine/custom/query.mjs +37 -0
- package/dist/core/engine/custom/reader.d.mts +7 -0
- package/dist/core/engine/custom/reader.mjs +67 -0
- package/dist/core/engine/custom/records.mjs +51 -0
- package/dist/core/engine/custom/request.d.mts +283 -0
- package/dist/core/engine/custom/seen.mjs +79 -0
- package/dist/core/engine/custom/where.mjs +34 -0
- package/dist/core/engine/dialect.d.mts +54 -0
- package/dist/core/engine/filter.mjs +129 -0
- package/dist/core/engine/index.d.mts +16 -0
- package/dist/core/engine/index.mjs +9 -0
- package/dist/core/engine/leaf.mjs +141 -0
- package/dist/core/engine/levels.mjs +175 -0
- package/dist/core/engine/measure.mjs +81 -0
- package/dist/core/engine/members.mjs +149 -0
- package/dist/core/engine/nan.mjs +9 -0
- package/dist/core/engine/native.mjs +59 -0
- package/dist/core/engine/numbers.mjs +191 -0
- package/dist/core/engine/other.mjs +45 -0
- package/dist/core/engine/plan.d.mts +54 -0
- package/dist/core/engine/postgres.d.mts +6 -0
- package/dist/core/engine/postgres.mjs +136 -0
- package/dist/core/engine/prepare.mjs +133 -0
- package/dist/core/engine/rank-sets.mjs +119 -0
- package/dist/core/engine/rank.mjs +149 -0
- package/dist/core/engine/read.mjs +74 -0
- package/dist/core/engine/reader.d.mts +128 -0
- package/dist/core/engine/reader.mjs +18 -0
- package/dist/core/engine/record-layout.d.mts +10 -0
- package/dist/core/engine/record-layout.mjs +37 -0
- package/dist/core/engine/records.d.mts +14 -0
- package/dist/core/engine/records.mjs +51 -0
- package/dist/core/engine/refs.mjs +58 -0
- package/dist/core/engine/run.d.mts +3 -0
- package/dist/core/engine/run.mjs +102 -0
- package/dist/core/engine/segmented.d.mts +11 -0
- package/dist/core/engine/segmented.mjs +80 -0
- package/dist/core/engine/series.mjs +95 -0
- package/dist/core/engine/shape.d.mts +12 -0
- package/dist/core/engine/shape.mjs +92 -0
- package/dist/core/engine/sql-marked.mjs +77 -0
- package/dist/core/engine/sql-pass.mjs +24 -0
- package/dist/core/engine/sql-reader.d.mts +10 -0
- package/dist/core/engine/sql-reader.mjs +51 -0
- package/dist/core/engine/sql-reads.mjs +28 -0
- package/dist/core/engine/sql-records.mjs +100 -0
- package/dist/core/engine/sql-split.mjs +158 -0
- package/dist/core/engine/sql.d.mts +8 -0
- package/dist/core/engine/sql.mjs +33 -0
- package/dist/core/engine/statement.mjs +78 -0
- package/dist/core/engine/time.mjs +52 -0
- package/dist/core/engine/two-step.mjs +104 -0
- package/dist/core/engine/types.d.mts +55 -0
- package/dist/core/engine/version.d.mts +7 -0
- package/dist/core/engine/version.mjs +9 -0
- package/dist/core/error/codes.d.mts +154 -0
- package/dist/core/error/codes.mjs +127 -0
- package/dist/core/error/refusal.d.mts +8 -0
- package/dist/core/error/refusal.mjs +11 -0
- package/dist/core/exact/decimal.d.mts +22 -0
- package/dist/core/exact/decimal.mjs +51 -0
- package/dist/core/exact/sum.d.mts +17 -0
- package/dist/core/exact/sum.mjs +31 -0
- package/dist/core/index.d.mts +56 -0
- package/dist/core/index.mjs +45 -0
- package/dist/core/model/catalog/check.d.mts +10 -0
- package/dist/core/model/catalog/check.mjs +141 -0
- package/dist/core/model/catalog/columns.mjs +34 -0
- package/dist/core/model/catalog/queries.d.mts +12 -0
- package/dist/core/model/catalog/queries.mjs +50 -0
- package/dist/core/model/defaults.d.mts +3 -0
- package/dist/core/model/defaults.mjs +24 -0
- package/dist/core/model/define.d.mts +32 -0
- package/dist/core/model/define.mjs +21 -0
- package/dist/core/model/member.d.mts +26 -0
- package/dist/core/model/member.mjs +58 -0
- package/dist/core/model/storage.mjs +28 -0
- package/dist/core/model/types.d.mts +270 -0
- package/dist/core/model/types.mjs +9 -0
- package/dist/core/model/validate/expr.d.mts +10 -0
- package/dist/core/model/validate/expr.mjs +56 -0
- package/dist/core/model/validate/filter.mjs +28 -0
- package/dist/core/model/validate/index.d.mts +10 -0
- package/dist/core/model/validate/index.mjs +36 -0
- package/dist/core/model/validate/issues.mjs +17 -0
- package/dist/core/model/validate/members.mjs +98 -0
- package/dist/core/model/validate/policy.mjs +76 -0
- package/dist/core/model/validate/source.mjs +143 -0
- package/dist/core/model/validate/via.d.mts +4 -0
- package/dist/core/model/validate/via.mjs +47 -0
- package/dist/core/oracle/data.d.mts +37 -0
- package/dist/core/oracle/data.mjs +30 -0
- package/dist/core/oracle/evaluate.d.mts +23 -0
- package/dist/core/oracle/evaluate.mjs +117 -0
- package/dist/core/oracle/expr.mjs +74 -0
- package/dist/core/oracle/facts.mjs +72 -0
- package/dist/core/oracle/filter.d.mts +6 -0
- package/dist/core/oracle/filter.mjs +25 -0
- package/dist/core/oracle/groups.mjs +33 -0
- package/dist/core/oracle/index.d.mts +4 -0
- package/dist/core/oracle/index.mjs +3 -0
- package/dist/core/oracle/levels.mjs +46 -0
- package/dist/core/oracle/logic.mjs +38 -0
- package/dist/core/oracle/measure.mjs +85 -0
- package/dist/core/oracle/members.mjs +80 -0
- package/dist/core/oracle/request.mjs +38 -0
- package/dist/core/oracle/segmented.d.mts +7 -0
- package/dist/core/oracle/segmented.mjs +35 -0
- package/dist/core/oracle/split.mjs +84 -0
- package/dist/core/oracle/time-axis.mjs +37 -0
- package/dist/core/oracle/time-value.mjs +28 -0
- package/dist/core/oracle/tree.mjs +24 -0
- package/dist/core/oracle/values.mjs +41 -0
- package/dist/core/oracle/visibility.mjs +49 -0
- package/dist/core/policy/bind.d.mts +25 -0
- package/dist/core/policy/bind.mjs +64 -0
- package/dist/core/policy/match.d.mts +16 -0
- package/dist/core/policy/match.mjs +44 -0
- package/dist/core/query/alias.mjs +14 -0
- package/dist/core/query/closure.d.mts +17 -0
- package/dist/core/query/closure.mjs +131 -0
- package/dist/core/query/compose-tile.d.mts +50 -0
- package/dist/core/query/compose-tile.mjs +140 -0
- package/dist/core/query/compose.d.mts +105 -0
- package/dist/core/query/compose.mjs +12 -0
- package/dist/core/query/derived-rules.mjs +56 -0
- package/dist/core/query/effective.d.mts +32 -0
- package/dist/core/query/effective.mjs +22 -0
- package/dist/core/query/filter.d.mts +99 -0
- package/dist/core/query/filter.mjs +79 -0
- package/dist/core/query/formulas.d.mts +17 -0
- package/dist/core/query/formulas.mjs +52 -0
- package/dist/core/query/picks.d.mts +10 -0
- package/dist/core/query/picks.mjs +25 -0
- package/dist/core/query/segments.d.mts +6 -0
- package/dist/core/query/segments.mjs +182 -0
- package/dist/core/query/to-wire.d.mts +21 -0
- package/dist/core/query/to-wire.mjs +124 -0
- package/dist/core/query/types.d.mts +238 -0
- package/dist/core/result/calc.mjs +95 -0
- package/dist/core/result/columns.d.mts +13 -0
- package/dist/core/result/columns.mjs +118 -0
- package/dist/core/result/marks.d.mts +20 -0
- package/dist/core/result/marks.mjs +35 -0
- package/dist/core/result/number.mjs +78 -0
- package/dist/core/result/order.d.mts +2 -0
- package/dist/core/result/order.mjs +57 -0
- package/dist/core/result/types.d.mts +66 -0
- package/dist/core/result/zero.mjs +18 -0
- package/dist/core/schema/answers.d.mts +2071 -0
- package/dist/core/schema/answers.mjs +217 -0
- package/dist/core/schema/commands.d.mts +273 -0
- package/dist/core/schema/commands.mjs +129 -0
- package/dist/core/schema/custom.d.mts +13 -0
- package/dist/core/schema/custom.mjs +250 -0
- package/dist/core/schema/document.d.mts +149 -0
- package/dist/core/schema/document.mjs +216 -0
- package/dist/core/schema/editing.mjs +166 -0
- package/dist/core/schema/index.d.mts +9 -0
- package/dist/core/schema/index.mjs +9 -0
- package/dist/core/schema/issue.mjs +18 -0
- package/dist/core/schema/query.d.mts +92 -0
- package/dist/core/schema/query.mjs +174 -0
- package/dist/core/schema/tools.d.mts +17 -0
- package/dist/core/schema/tools.mjs +62 -0
- package/dist/core/schema/view.d.mts +47 -0
- package/dist/core/schema/view.mjs +71 -0
- package/dist/core/store/ddl.d.mts +38 -0
- package/dist/core/store/ddl.mjs +79 -0
- package/dist/core/store/schema.d.mts +315 -0
- package/dist/core/store/schema.mjs +181 -0
- package/dist/core/time/bucket.d.mts +25 -0
- package/dist/core/time/bucket.mjs +103 -0
- package/dist/core/time/compare.d.mts +30 -0
- package/dist/core/time/compare.mjs +73 -0
- package/dist/core/time/index.d.mts +7 -0
- package/dist/core/time/instant.d.mts +14 -0
- package/dist/core/time/instant.mjs +58 -0
- package/dist/core/time/range.d.mts +21 -0
- package/dist/core/time/range.mjs +41 -0
- package/dist/core/time/stored.d.mts +10 -0
- package/dist/core/time/stored.mjs +29 -0
- package/dist/core/time/temporal.d.mts +14 -0
- package/dist/core/time/temporal.mjs +27 -0
- package/dist/core/time/zone.d.mts +27 -0
- package/dist/core/time/zone.mjs +55 -0
- package/dist/core/types/api.d.mts +327 -0
- package/dist/core/types/api.mjs +9 -0
- package/dist/core/types/infer.d.mts +91 -0
- package/dist/core/types/options.d.mts +94 -0
- package/dist/core/types/plugin.d.mts +82 -0
- package/dist/core/types/plugin.mjs +12 -0
- package/dist/core/types/primitives.d.mts +26 -0
- package/dist/core/types/provider.d.mts +74 -0
- package/dist/core/types/source.d.mts +73 -0
- package/dist/core/types/store.d.mts +327 -0
- package/dist/core/types/viewer.d.mts +74 -0
- package/dist/core/types/viewer.mjs +6 -0
- package/dist/core/value/canonical.d.mts +5 -0
- package/dist/core/value/canonical.mjs +10 -0
- package/dist/core/value/casefold-data.mjs +3 -0
- package/dist/core/value/casefold.d.mts +8 -0
- package/dist/core/value/casefold.mjs +36 -0
- package/dist/core/value/compare.d.mts +3 -0
- package/dist/core/value/compare.mjs +18 -0
- package/dist/custom-source.d.mts +21 -0
- package/dist/custom-source.mjs +30 -0
- package/dist/dashboard-id.mjs +31 -0
- package/dist/dashboards.mjs +84 -0
- package/dist/editing.mjs +114 -0
- package/dist/endpoints/access.mjs +44 -0
- package/dist/endpoints/dashboards.mjs +109 -0
- package/dist/endpoints/drafts.mjs +138 -0
- package/dist/endpoints/index.d.mts +453 -0
- package/dist/endpoints/index.mjs +39 -0
- package/dist/endpoints/meta.mjs +123 -0
- package/dist/endpoints/query.mjs +72 -0
- package/dist/endpoints/read.mjs +79 -0
- package/dist/endpoints/review.mjs +91 -0
- package/dist/endpoints/values.mjs +58 -0
- package/dist/endpoints/versions.mjs +103 -0
- package/dist/execute.d.mts +10 -0
- package/dist/execute.mjs +152 -0
- package/dist/handler.mjs +189 -0
- package/dist/http.d.mts +16 -0
- package/dist/http.mjs +67 -0
- package/dist/index.d.mts +24 -0
- package/dist/index.mjs +115 -0
- package/dist/introspect.mjs +180 -0
- package/dist/mcp/api.d.mts +10 -0
- package/dist/mcp/api.mjs +34 -0
- package/dist/mcp/format.d.mts +10 -0
- package/dist/mcp/format.mjs +59 -0
- package/dist/mcp/index.d.mts +61 -0
- package/dist/mcp/index.mjs +88 -0
- package/dist/mcp/query.d.mts +6 -0
- package/dist/mcp/query.mjs +123 -0
- package/dist/mcp/resolve.mjs +67 -0
- package/dist/node-postgres.d.mts +33 -0
- package/dist/node-postgres.mjs +59 -0
- package/dist/owner.mjs +34 -0
- package/dist/postgres-connection.d.mts +33 -0
- package/dist/postgres-connection.mjs +84 -0
- package/dist/postgres-store.d.mts +38 -0
- package/dist/postgres-store.mjs +60 -0
- package/dist/principal.mjs +28 -0
- package/dist/react/CancelRestore.mjs +21 -0
- package/dist/react/Canvas.mjs +97 -0
- package/dist/react/Cell.mjs +106 -0
- package/dist/react/ConfirmButton.mjs +31 -0
- package/dist/react/Dashboard.d.mts +27 -0
- package/dist/react/Dashboard.mjs +80 -0
- package/dist/react/DashboardList.d.mts +12 -0
- package/dist/react/DashboardList.mjs +155 -0
- package/dist/react/Discard.mjs +99 -0
- package/dist/react/EditBar.d.mts +16 -0
- package/dist/react/EditBar.mjs +141 -0
- package/dist/react/Editing.mjs +124 -0
- package/dist/react/FilterBar.d.mts +9 -0
- package/dist/react/FilterBar.mjs +119 -0
- package/dist/react/Grid.mjs +133 -0
- package/dist/react/Header.mjs +107 -0
- package/dist/react/History.d.mts +30 -0
- package/dist/react/History.mjs +202 -0
- package/dist/react/Notice.d.mts +8 -0
- package/dist/react/Notice.mjs +51 -0
- package/dist/react/Overlaps.mjs +54 -0
- package/dist/react/Panel.d.mts +16 -0
- package/dist/react/Panel.mjs +93 -0
- package/dist/react/Parts.mjs +98 -0
- package/dist/react/Records.d.mts +12 -0
- package/dist/react/Records.mjs +97 -0
- package/dist/react/ReviewPanel.d.mts +15 -0
- package/dist/react/ReviewPanel.mjs +200 -0
- package/dist/react/Spaces.mjs +108 -0
- package/dist/react/Tile.d.mts +20 -0
- package/dist/react/Tile.mjs +123 -0
- package/dist/react/arrange-steps.mjs +108 -0
- package/dist/react/arrange.mjs +135 -0
- package/dist/react/board.d.mts +16 -0
- package/dist/react/board.mjs +156 -0
- package/dist/react/builder/Calcs.mjs +87 -0
- package/dist/react/builder/Filters.mjs +165 -0
- package/dist/react/builder/Groups.mjs +189 -0
- package/dist/react/builder/Picker.mjs +154 -0
- package/dist/react/builder/Preview.d.mts +6 -0
- package/dist/react/builder/Preview.mjs +102 -0
- package/dist/react/builder/Sections.mjs +85 -0
- package/dist/react/builder/Time.mjs +119 -0
- package/dist/react/builder/WidgetBuilder.d.mts +23 -0
- package/dist/react/builder/WidgetBuilder.mjs +202 -0
- package/dist/react/builder/base.d.mts +19 -0
- package/dist/react/builder/base.mjs +111 -0
- package/dist/react/builder/calc.d.mts +5 -0
- package/dist/react/builder/calc.mjs +110 -0
- package/dist/react/builder/labels.d.mts +1 -0
- package/dist/react/builder/labels.mjs +55 -0
- package/dist/react/builder/options.mjs +55 -0
- package/dist/react/builder/state.d.mts +12 -0
- package/dist/react/builder/state.mjs +201 -0
- package/dist/react/builder/useBuilder.d.mts +46 -0
- package/dist/react/builder/useBuilder.mjs +60 -0
- package/dist/react/builder/usePreview.mjs +56 -0
- package/dist/react/client.d.mts +93 -0
- package/dist/react/client.mjs +107 -0
- package/dist/react/context.d.mts +32 -0
- package/dist/react/context.mjs +44 -0
- package/dist/react/debounce.mjs +19 -0
- package/dist/react/draft.d.mts +55 -0
- package/dist/react/draft.mjs +230 -0
- package/dist/react/english.d.mts +3 -0
- package/dist/react/english.mjs +149 -0
- package/dist/react/errors.d.mts +12 -0
- package/dist/react/errors.mjs +13 -0
- package/dist/react/format.d.mts +25 -0
- package/dist/react/format.mjs +153 -0
- package/dist/react/index.d.mts +27 -0
- package/dist/react/index.mjs +25 -0
- package/dist/react/marks.d.mts +11 -0
- package/dist/react/marks.mjs +62 -0
- package/dist/react/messages.d.mts +159 -0
- package/dist/react/place.mjs +21 -0
- package/dist/react/read.d.mts +15 -0
- package/dist/react/read.mjs +54 -0
- package/dist/react/renderers/index.d.mts +19 -0
- package/dist/react/renderers/index.mjs +85 -0
- package/dist/react/review-words.d.mts +79 -0
- package/dist/react/review-words.mjs +132 -0
- package/dist/react/review.d.mts +26 -0
- package/dist/react/review.mjs +110 -0
- package/dist/react/scope.mjs +9 -0
- package/dist/react/stable.mjs +39 -0
- package/dist/react/theme.css +1337 -0
- package/dist/react/tile-keys.d.mts +20 -0
- package/dist/react/tile-keys.mjs +21 -0
- package/dist/react/tile-store.mjs +99 -0
- package/dist/react/useBoard.d.mts +80 -0
- package/dist/react/useBoard.mjs +53 -0
- package/dist/react/useDashboard.d.mts +51 -0
- package/dist/react/useDashboard.mjs +56 -0
- package/dist/react/useTiles.d.mts +20 -0
- package/dist/react/useTiles.mjs +133 -0
- package/dist/react/view.mjs +52 -0
- package/dist/reading.mjs +43 -0
- package/dist/recharts/charts.d.mts +10 -0
- package/dist/recharts/charts.mjs +121 -0
- package/dist/recharts/index.d.mts +3 -0
- package/dist/recharts/index.mjs +3 -0
- package/dist/recharts/series.d.mts +22 -0
- package/dist/recharts/series.mjs +64 -0
- package/dist/request-rows.mjs +21 -0
- package/dist/request.mjs +20 -0
- package/dist/storage.d.mts +3 -0
- package/dist/storage.mjs +54 -0
- package/dist/store/apply.mjs +102 -0
- package/dist/store/commands.mjs +74 -0
- package/dist/store/conflicts.mjs +79 -0
- package/dist/store/create-tables.d.mts +29 -0
- package/dist/store/create-tables.mjs +91 -0
- package/dist/store/discard.mjs +60 -0
- package/dist/store/drafts.mjs +132 -0
- package/dist/store/editor.mjs +22 -0
- package/dist/store/log.mjs +22 -0
- package/dist/store/publish.mjs +177 -0
- package/dist/store/publisher.mjs +16 -0
- package/dist/store/reader.mjs +139 -0
- package/dist/store/review.mjs +177 -0
- package/dist/store/rows.mjs +205 -0
- package/dist/store/tenant.mjs +23 -0
- package/dist/store/undo.mjs +49 -0
- package/dist/store/unpublished.mjs +47 -0
- package/dist/store/versions.mjs +93 -0
- package/dist/store/writer.mjs +19 -0
- package/dist/testing/adapter-suite.d.mts +12 -0
- package/dist/testing/adapter-suite.mjs +281 -0
- package/dist/testing/index.d.mts +2 -0
- package/dist/testing/index.mjs +1 -0
- package/dist/tile-doc.mjs +44 -0
- package/dist/tiles.mjs +102 -0
- package/package.json +125 -3
- package/src/adapter/sql-adapter.ts +95 -0
- package/src/adapter/statement.ts +185 -0
- package/src/authorize.ts +73 -0
- package/src/body.ts +169 -0
- package/src/bounded.ts +43 -0
- package/src/cache.ts +192 -0
- package/src/checks.ts +170 -0
- package/src/custom-source.ts +59 -0
- package/src/dashboard-id.ts +36 -0
- package/src/dashboards.ts +132 -0
- package/src/editing.ts +148 -0
- package/src/endpoints/access.ts +41 -0
- package/src/endpoints/dashboards.ts +92 -0
- package/src/endpoints/drafts.ts +138 -0
- package/src/endpoints/index.ts +21 -0
- package/src/endpoints/meta.ts +137 -0
- package/src/endpoints/query.ts +86 -0
- package/src/endpoints/read.ts +92 -0
- package/src/endpoints/review.ts +89 -0
- package/src/endpoints/values.ts +62 -0
- package/src/endpoints/versions.ts +104 -0
- package/src/execute.ts +207 -0
- package/src/handler.ts +232 -0
- package/src/http.ts +66 -0
- package/src/index.ts +163 -0
- package/src/introspect.ts +205 -0
- package/src/mcp/api.ts +59 -0
- package/src/mcp/format.ts +67 -0
- package/src/mcp/index.ts +151 -0
- package/src/mcp/query.ts +153 -0
- package/src/mcp/resolve.ts +114 -0
- package/src/node-postgres.ts +81 -0
- package/src/owner.ts +36 -0
- package/src/postgres-connection.ts +143 -0
- package/src/postgres-store.ts +82 -0
- package/src/principal.ts +39 -0
- package/src/reading.ts +56 -0
- package/src/request-rows.ts +23 -0
- package/src/request.ts +22 -0
- package/src/storage.ts +63 -0
- package/src/store/apply.ts +129 -0
- package/src/store/commands.ts +75 -0
- package/src/store/conflicts.ts +98 -0
- package/src/store/create-tables.ts +104 -0
- package/src/store/discard.ts +42 -0
- package/src/store/drafts.ts +133 -0
- package/src/store/editor.ts +28 -0
- package/src/store/log.ts +28 -0
- package/src/store/publish.ts +199 -0
- package/src/store/publisher.ts +21 -0
- package/src/store/reader.ts +139 -0
- package/src/store/review.ts +239 -0
- package/src/store/rows.ts +250 -0
- package/src/store/tenant.ts +28 -0
- package/src/store/undo.ts +56 -0
- package/src/store/unpublished.ts +33 -0
- package/src/store/versions.ts +106 -0
- package/src/store/writer.ts +19 -0
- package/src/testing/adapter-suite.ts +239 -0
- package/src/testing/index.ts +2 -0
- package/src/tile-doc.ts +46 -0
- package/src/tiles.ts +120 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { FilterBar } from "./FilterBar.mjs";
|
|
3
|
+
import { Grid } from "./Grid.mjs";
|
|
4
|
+
import { Header } from "./Header.mjs";
|
|
5
|
+
import { linkTo } from "./view.mjs";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/Canvas.tsx
|
|
8
|
+
function Tabs({ doc, current, onSelect }) {
|
|
9
|
+
if (doc.tabs.length < 2) return null;
|
|
10
|
+
return /* @__PURE__ */ jsx("div", {
|
|
11
|
+
className: "dd-tabs",
|
|
12
|
+
role: "tablist",
|
|
13
|
+
children: doc.tabs.map((t) => /* @__PURE__ */ jsx("button", {
|
|
14
|
+
type: "button",
|
|
15
|
+
role: "tab",
|
|
16
|
+
"aria-selected": t.id === current.id,
|
|
17
|
+
onClick: () => {
|
|
18
|
+
onSelect(t.id);
|
|
19
|
+
},
|
|
20
|
+
children: t.title
|
|
21
|
+
}, t.id))
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
/** The filters a link carried that this dashboard does not have, named once. */
|
|
25
|
+
function Dropped({ names }) {
|
|
26
|
+
const { messages } = useDashboards();
|
|
27
|
+
return names.length === 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
28
|
+
className: "dd-tile-note",
|
|
29
|
+
role: "status",
|
|
30
|
+
children: messages.droppedFromLink(names)
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** Whether the tab shown has nothing on it, not even a removed tile. */
|
|
34
|
+
const emptyTab = (shown) => shown.tab.layout.length === 0 && (shown.ghosts ?? []).length === 0;
|
|
35
|
+
/** A tab with nothing on it while editing: what to do first. */
|
|
36
|
+
function EmptyTab({ onAdd }) {
|
|
37
|
+
const { messages } = useDashboards();
|
|
38
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
39
|
+
className: "dd-empty",
|
|
40
|
+
children: [/* @__PURE__ */ jsx("p", { children: messages.emptyTab }), /* @__PURE__ */ jsx("button", {
|
|
41
|
+
type: "button",
|
|
42
|
+
className: "dd-button dd-primary",
|
|
43
|
+
onClick: onAdd,
|
|
44
|
+
children: messages.addWidget
|
|
45
|
+
})]
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** The canvas: header, tabs, filters, and the grid with its marks. */
|
|
49
|
+
function Canvas(props) {
|
|
50
|
+
const { board, shown } = props;
|
|
51
|
+
const { edit, panels, view } = board;
|
|
52
|
+
const add = () => {
|
|
53
|
+
props.onBuild({});
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
56
|
+
/* @__PURE__ */ jsx(Header, {
|
|
57
|
+
doc: shown.doc,
|
|
58
|
+
version: board.version,
|
|
59
|
+
unpublished: board.unpublished,
|
|
60
|
+
canEdit: board.canEdit && panels.previewing === void 0,
|
|
61
|
+
waiting: board.waiting,
|
|
62
|
+
edit,
|
|
63
|
+
historyOpen: panels.panel === "history",
|
|
64
|
+
onAdd: add,
|
|
65
|
+
onHistory: panels.toggleHistory,
|
|
66
|
+
link: () => linkTo(view.current, props.dashboard.linkFor)
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsx(Dropped, { names: view.dropped }),
|
|
69
|
+
/* @__PURE__ */ jsx(Tabs, {
|
|
70
|
+
doc: shown.doc,
|
|
71
|
+
current: shown.tab,
|
|
72
|
+
onSelect: view.setTab
|
|
73
|
+
}),
|
|
74
|
+
/* @__PURE__ */ jsx(FilterBar, {
|
|
75
|
+
controls: shown.doc.controls,
|
|
76
|
+
picks: view.picks,
|
|
77
|
+
onChange: view.setPicks
|
|
78
|
+
}),
|
|
79
|
+
edit.draft === void 0 || !emptyTab(shown) ? null : /* @__PURE__ */ jsx(EmptyTab, { onAdd: add }),
|
|
80
|
+
/* @__PURE__ */ jsx(Grid, {
|
|
81
|
+
doc: shown.doc,
|
|
82
|
+
tab: shown.tab,
|
|
83
|
+
edit,
|
|
84
|
+
results: board.tiles.results,
|
|
85
|
+
pending: board.tiles.pending,
|
|
86
|
+
marks: shown.marks,
|
|
87
|
+
ghosts: shown.ghosts,
|
|
88
|
+
highlight: panels.point,
|
|
89
|
+
fresh: props.fresh,
|
|
90
|
+
arrangeable: shown.arrangeable,
|
|
91
|
+
onEdit: (widgetId) => {
|
|
92
|
+
props.onBuild({ widgetId });
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
] });
|
|
96
|
+
}
|
|
97
|
+
export { Canvas };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { TileActions } from "./Editing.mjs";
|
|
3
|
+
import { placeOf, useBringIntoView } from "./place.mjs";
|
|
4
|
+
import { Tile } from "./Tile.mjs";
|
|
5
|
+
import { memo, useEffect, useMemo } from "react";
|
|
6
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// src/Cell.tsx
|
|
8
|
+
/** The grip that moves a tile, and the corner that resizes it, while the dashboard is a draft. */
|
|
9
|
+
function Handles(props) {
|
|
10
|
+
const { messages } = useDashboards();
|
|
11
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("button", {
|
|
12
|
+
type: "button",
|
|
13
|
+
className: "dd-move",
|
|
14
|
+
"aria-label": messages.moveWidget(props.title),
|
|
15
|
+
"aria-keyshortcuts": "ArrowUp ArrowDown ArrowLeft ArrowRight Shift+ArrowRight Shift+ArrowDown",
|
|
16
|
+
title: messages.arrangeHint,
|
|
17
|
+
...props.handle(props.item, "move"),
|
|
18
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
19
|
+
"aria-hidden": "true",
|
|
20
|
+
children: "⠿"
|
|
21
|
+
})
|
|
22
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
23
|
+
type: "button",
|
|
24
|
+
className: "dd-resize",
|
|
25
|
+
"aria-label": messages.resizeWidget(props.title),
|
|
26
|
+
title: messages.arrangeHint,
|
|
27
|
+
...props.handle(props.item, "resize")
|
|
28
|
+
})] });
|
|
29
|
+
}
|
|
30
|
+
const samePlace = (a, b) => a.widget === b.widget && a.x === b.x && a.y === b.y && a.w === b.w && a.h === b.h;
|
|
31
|
+
/** A cell draws again only when something it shows changed; a new layout list with its place unchanged is not that. */
|
|
32
|
+
const sameCell = (a, b) => samePlace(a.item, b.item) && Object.entries(a).every(([key, value]) => key === "item" || Object.is(value, Reflect.get(b, key)));
|
|
33
|
+
/** A tile's own buttons while editing: Edit, Remove, and on a phone Move up and Move down. */
|
|
34
|
+
function useActions(props) {
|
|
35
|
+
const { item, widget, editing, busy, onEdit, onRemove, onStep, first, last } = props;
|
|
36
|
+
return useMemo(() => {
|
|
37
|
+
const step = (by) => () => {
|
|
38
|
+
onStep(item.widget, by);
|
|
39
|
+
};
|
|
40
|
+
return editing ? /* @__PURE__ */ jsx(TileActions, {
|
|
41
|
+
busy,
|
|
42
|
+
title: widget.title,
|
|
43
|
+
onEdit: () => {
|
|
44
|
+
onEdit(item.widget);
|
|
45
|
+
},
|
|
46
|
+
onRemove: () => {
|
|
47
|
+
onRemove(item.widget);
|
|
48
|
+
},
|
|
49
|
+
onUp: first ? void 0 : step(-1),
|
|
50
|
+
onDown: last ? void 0 : step(1)
|
|
51
|
+
}) : null;
|
|
52
|
+
}, [
|
|
53
|
+
editing,
|
|
54
|
+
busy,
|
|
55
|
+
widget.title,
|
|
56
|
+
item.widget,
|
|
57
|
+
onEdit,
|
|
58
|
+
onRemove,
|
|
59
|
+
onStep,
|
|
60
|
+
first,
|
|
61
|
+
last
|
|
62
|
+
]);
|
|
63
|
+
}
|
|
64
|
+
/** One widget in its place on the grid; while editing, with its grip, corner, Edit and Remove. */
|
|
65
|
+
const Cell = memo(function Cell(props) {
|
|
66
|
+
const { messages } = useDashboards();
|
|
67
|
+
const { item, widget, mark, editing } = props;
|
|
68
|
+
const ref = useBringIntoView(props.fresh || props.lit);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
if (props.fresh && editing) ref.current?.querySelector(".dd-tile-edit")?.focus();
|
|
71
|
+
}, [
|
|
72
|
+
props.fresh,
|
|
73
|
+
editing,
|
|
74
|
+
ref
|
|
75
|
+
]);
|
|
76
|
+
const actions = useActions(props);
|
|
77
|
+
const badge = useMemo(() => mark === void 0 ? void 0 : /* @__PURE__ */ jsx("span", {
|
|
78
|
+
className: "dd-mark",
|
|
79
|
+
children: messages.marks[mark]
|
|
80
|
+
}), [mark, messages]);
|
|
81
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
82
|
+
ref,
|
|
83
|
+
className: "dd-cell",
|
|
84
|
+
"data-widget": item.widget,
|
|
85
|
+
"data-kind": widget.kind,
|
|
86
|
+
"data-fresh": props.fresh,
|
|
87
|
+
"data-lit": props.lit,
|
|
88
|
+
"data-mark": mark,
|
|
89
|
+
"data-moving": props.moving,
|
|
90
|
+
style: placeOf(item),
|
|
91
|
+
children: [editing ? /* @__PURE__ */ jsx(Handles, {
|
|
92
|
+
item,
|
|
93
|
+
title: widget.title,
|
|
94
|
+
handle: props.handle
|
|
95
|
+
}) : null, /* @__PURE__ */ jsx(Tile, {
|
|
96
|
+
widgetId: item.widget,
|
|
97
|
+
widget,
|
|
98
|
+
result: props.result,
|
|
99
|
+
loading: props.loading,
|
|
100
|
+
controlLabels: props.controlLabels,
|
|
101
|
+
actions,
|
|
102
|
+
badge
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
}, sameCell);
|
|
106
|
+
export { Cell };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// src/ConfirmButton.tsx
|
|
4
|
+
/**
|
|
5
|
+
* A button for a step that cannot be undone: the first press asks, in the button itself, and
|
|
6
|
+
* the second does it. Leaving it (Escape, or focus moving on) takes the question back.
|
|
7
|
+
*/
|
|
8
|
+
function ConfirmButton(props) {
|
|
9
|
+
const [asking, setAsking] = useState(false);
|
|
10
|
+
return /* @__PURE__ */ jsx("button", {
|
|
11
|
+
type: "button",
|
|
12
|
+
className: asking ? "dd-button dd-danger" : "dd-button",
|
|
13
|
+
"aria-disabled": props.busy,
|
|
14
|
+
onClick: () => {
|
|
15
|
+
if (props.busy) return;
|
|
16
|
+
if (asking) props.onConfirm();
|
|
17
|
+
setAsking(!asking);
|
|
18
|
+
},
|
|
19
|
+
onBlur: () => {
|
|
20
|
+
setAsking(false);
|
|
21
|
+
},
|
|
22
|
+
onKeyDown: (event) => {
|
|
23
|
+
if (event.key === "Escape" && asking) {
|
|
24
|
+
event.stopPropagation();
|
|
25
|
+
setAsking(false);
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
children: asking ? props.confirm : props.label
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
export { ConfirmButton };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DashboardEvents } from "./useDashboard.mjs";
|
|
2
|
+
import { ViewState } from "derive-dashboards/core";
|
|
3
|
+
/**
|
|
4
|
+
* A dashboard by id: its title, filter bar and tiles on a 12-column grid. Picks change the
|
|
5
|
+
* tiles' answers, never the dashboard. Those who may edit it get Edit: changes go to their own
|
|
6
|
+
* draft, which only they see; the edit bar counts them and undoes and redoes any of them;
|
|
7
|
+
* changed tiles are marked in place. Review and publish opens the review beside the canvas:
|
|
8
|
+
* every change, and over a newer version the merged result, then Publish. History opens the
|
|
9
|
+
* 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 filters. An agent's proposal waits in a violet bar.
|
|
11
|
+
*
|
|
12
|
+
* `view` and `onViewChange` let the host keep the tab and filters in its URL (`encodeView`,
|
|
13
|
+
* `decodeView`); `linkFor` makes the link Share copies. `editable={false}` shows it read-only.
|
|
14
|
+
*/
|
|
15
|
+
export type DashboardProps = {
|
|
16
|
+
id: string;
|
|
17
|
+
/** False shows it read-only, whatever the viewer may do: no Edit, no Restore. */
|
|
18
|
+
editable?: boolean;
|
|
19
|
+
/** The tab and filters to show, when the host keeps them (from a link, say). */
|
|
20
|
+
view?: ViewState;
|
|
21
|
+
onViewChange?: (view: ViewState) => void;
|
|
22
|
+
/** What the host's `decodeView` could not read from a link, so the page says it was left out. */
|
|
23
|
+
linkDropped?: readonly string[];
|
|
24
|
+
/** The link Share copies for a view; by default, this page's address with the view in it. */
|
|
25
|
+
linkFor?: (view: ViewState) => string;
|
|
26
|
+
} & DashboardEvents;
|
|
27
|
+
export declare function Dashboard(props: DashboardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Canvas } from "./Canvas.mjs";
|
|
2
|
+
import { useDashboards } from "./context.mjs";
|
|
3
|
+
import { BuildPage } from "./Editing.mjs";
|
|
4
|
+
import { Bars, Side } from "./Parts.mjs";
|
|
5
|
+
import { ScopeContext } from "./scope.mjs";
|
|
6
|
+
import { useBoard } from "./useBoard.mjs";
|
|
7
|
+
import { useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
// src/Dashboard.tsx
|
|
10
|
+
/** Focuses what opened the builder once the dashboard is back: the tile's Edit, or Add widget. */
|
|
11
|
+
function focusOpener(widgetId) {
|
|
12
|
+
requestAnimationFrame(() => {
|
|
13
|
+
((widgetId === void 0 ? null : document.querySelector(`.dd-cell[data-widget="${CSS.escape(widgetId)}"] .dd-tile-edit`)) ?? document.querySelector("[data-focus-after]"))?.focus();
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function Dashboard(props) {
|
|
17
|
+
const { messages } = useDashboards();
|
|
18
|
+
const board = useBoard(props);
|
|
19
|
+
const [building, setBuilding] = useState();
|
|
20
|
+
const [fresh, setFresh] = useState();
|
|
21
|
+
const { error, edit, shown, panels, view } = board;
|
|
22
|
+
if (board.missing) return /* @__PURE__ */ jsx("div", {
|
|
23
|
+
className: "dd-tile-state",
|
|
24
|
+
children: messages.dashboardMissing
|
|
25
|
+
});
|
|
26
|
+
if (error) return /* @__PURE__ */ jsx("div", {
|
|
27
|
+
className: "dd-tile-error",
|
|
28
|
+
role: "alert",
|
|
29
|
+
children: messages.dashboardFailed
|
|
30
|
+
});
|
|
31
|
+
if (shown?.tab === void 0) return /* @__PURE__ */ jsx("div", {
|
|
32
|
+
className: "dd-dashboard",
|
|
33
|
+
"aria-busy": "true"
|
|
34
|
+
});
|
|
35
|
+
const tab = shown.tab;
|
|
36
|
+
if (building !== void 0 && edit.draft !== void 0) return /* @__PURE__ */ jsx(BuildPage, {
|
|
37
|
+
doc: edit.draft.doc,
|
|
38
|
+
tab,
|
|
39
|
+
edit,
|
|
40
|
+
...building,
|
|
41
|
+
onDone: (saved) => {
|
|
42
|
+
setBuilding(void 0);
|
|
43
|
+
setFresh(saved);
|
|
44
|
+
if (saved === void 0) focusOpener(building.widgetId);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const editing = edit.draft !== void 0;
|
|
48
|
+
return /* @__PURE__ */ jsx(ScopeContext.Provider, {
|
|
49
|
+
value: {
|
|
50
|
+
dashboardId: props.id,
|
|
51
|
+
picks: view.picks,
|
|
52
|
+
...editing ? { draft: true } : {}
|
|
53
|
+
},
|
|
54
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
55
|
+
className: "dd-dashboard",
|
|
56
|
+
"data-editing": editing,
|
|
57
|
+
"data-panel": panels.panel !== void 0,
|
|
58
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
59
|
+
className: "dd-board",
|
|
60
|
+
children: [/* @__PURE__ */ jsx(Bars, {
|
|
61
|
+
board,
|
|
62
|
+
props
|
|
63
|
+
}), /* @__PURE__ */ jsx(Canvas, {
|
|
64
|
+
board,
|
|
65
|
+
shown: {
|
|
66
|
+
...shown,
|
|
67
|
+
tab
|
|
68
|
+
},
|
|
69
|
+
fresh,
|
|
70
|
+
onBuild: setBuilding,
|
|
71
|
+
dashboard: props
|
|
72
|
+
})]
|
|
73
|
+
}), /* @__PURE__ */ jsx(Side, {
|
|
74
|
+
board,
|
|
75
|
+
props
|
|
76
|
+
})]
|
|
77
|
+
})
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
export { Dashboard };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every dashboard the viewer can open, theirs not yet published marked as drafts, and
|
|
3
|
+
* "+ New dashboard" for those who may make one, which opens it straight into editing. A long
|
|
4
|
+
* list gets a search box. The host decides where a dashboard opens (`onOpen` gets its id) and,
|
|
5
|
+
* with `linkFor`, how to link to one: each row then has Copy link.
|
|
6
|
+
*/
|
|
7
|
+
export declare function DashboardList({ current, onOpen, linkFor }: {
|
|
8
|
+
current?: string;
|
|
9
|
+
onOpen: (id: string) => void;
|
|
10
|
+
/** A link to a dashboard by id: each row gets Copy link. */
|
|
11
|
+
linkFor?: (id: string) => string;
|
|
12
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import useSWR from "swr";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/DashboardList.tsx
|
|
6
|
+
/** The SWR key of the dashboard list, refreshed whenever a dashboard is made, published or discarded. */
|
|
7
|
+
const LIST_KEY = "dd-list";
|
|
8
|
+
/** Makes a new dashboard, once per click even if the request is retried, and opens it. */
|
|
9
|
+
function useCreate(onOpen, refresh) {
|
|
10
|
+
const { client, messages } = useDashboards();
|
|
11
|
+
const [error, setError] = useState();
|
|
12
|
+
const [making, setMaking] = useState(false);
|
|
13
|
+
const create = async () => {
|
|
14
|
+
setMaking(true);
|
|
15
|
+
setError(void 0);
|
|
16
|
+
try {
|
|
17
|
+
const draft = await client.newDashboard({
|
|
18
|
+
title: messages.untitledDashboard,
|
|
19
|
+
requestId: crypto.randomUUID()
|
|
20
|
+
});
|
|
21
|
+
await refresh();
|
|
22
|
+
onOpen(draft.dashboardId);
|
|
23
|
+
} catch (failure) {
|
|
24
|
+
setError(failure instanceof Error ? failure.message : String(failure));
|
|
25
|
+
} finally {
|
|
26
|
+
setMaking(false);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
return {
|
|
30
|
+
making,
|
|
31
|
+
error,
|
|
32
|
+
create
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Copy link on a row, shown on hover or focus, when the host says how to link a dashboard. It
|
|
37
|
+
* comes after the row's own button and says which dashboard it links, so it never names the row.
|
|
38
|
+
*/
|
|
39
|
+
function CopyLink(props) {
|
|
40
|
+
const { id, linkFor } = props;
|
|
41
|
+
const { messages } = useDashboards();
|
|
42
|
+
const [copied, setCopied] = useState(false);
|
|
43
|
+
return /* @__PURE__ */ jsx("button", {
|
|
44
|
+
type: "button",
|
|
45
|
+
className: "dd-list-copy",
|
|
46
|
+
"aria-label": messages.copyLinkTo(props.title),
|
|
47
|
+
onClick: () => {
|
|
48
|
+
const copy = async () => {
|
|
49
|
+
await navigator.clipboard.writeText(linkFor(id));
|
|
50
|
+
setCopied(true);
|
|
51
|
+
};
|
|
52
|
+
copy();
|
|
53
|
+
},
|
|
54
|
+
children: copied ? messages.copied : messages.copyLink
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** A search box once the list is long, and a line when nothing matches. */
|
|
58
|
+
function Search(props) {
|
|
59
|
+
const { messages } = useDashboards();
|
|
60
|
+
const { all, search, setSearch } = props;
|
|
61
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [all.length > 6 ? /* @__PURE__ */ jsx("input", {
|
|
62
|
+
type: "search",
|
|
63
|
+
className: "dd-list-search",
|
|
64
|
+
"aria-label": messages.searchDashboards,
|
|
65
|
+
placeholder: messages.searchDashboards,
|
|
66
|
+
value: search,
|
|
67
|
+
onChange: (event) => {
|
|
68
|
+
setSearch(event.target.value);
|
|
69
|
+
}
|
|
70
|
+
}) : null, props.shown === 0 && all.length > 0 ? /* @__PURE__ */ jsx("p", {
|
|
71
|
+
className: "dd-tile-note",
|
|
72
|
+
children: messages.noMatches
|
|
73
|
+
}) : null] });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The dashboards, each a button named for the dashboard that opens it; the viewer's unpublished
|
|
77
|
+
* ones say so, as the button's description rather than its name.
|
|
78
|
+
*/
|
|
79
|
+
function Items({ items, current, onOpen, linkFor }) {
|
|
80
|
+
const { messages } = useDashboards();
|
|
81
|
+
const base = useId();
|
|
82
|
+
return /* @__PURE__ */ jsx("ul", { children: items.map((d, i) => /* @__PURE__ */ jsxs("li", { children: [/* @__PURE__ */ jsxs("button", {
|
|
83
|
+
type: "button",
|
|
84
|
+
"aria-label": d.title,
|
|
85
|
+
"aria-describedby": d.unpublished === true ? `${base}-${String(i)}` : void 0,
|
|
86
|
+
"aria-current": d.id === current ? "page" : void 0,
|
|
87
|
+
onClick: () => {
|
|
88
|
+
onOpen(d.id);
|
|
89
|
+
},
|
|
90
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
91
|
+
className: "dd-list-name",
|
|
92
|
+
children: d.title
|
|
93
|
+
}), d.unpublished === true ? /* @__PURE__ */ jsx("em", {
|
|
94
|
+
id: `${base}-${String(i)}`,
|
|
95
|
+
children: messages.unpublished
|
|
96
|
+
}) : null]
|
|
97
|
+
}), linkFor === void 0 || d.unpublished === true ? null : /* @__PURE__ */ jsx(CopyLink, {
|
|
98
|
+
id: d.id,
|
|
99
|
+
title: d.title,
|
|
100
|
+
linkFor
|
|
101
|
+
})] }, d.id)) });
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Every dashboard the viewer can open, theirs not yet published marked as drafts, and
|
|
105
|
+
* "+ New dashboard" for those who may make one, which opens it straight into editing. A long
|
|
106
|
+
* list gets a search box. The host decides where a dashboard opens (`onOpen` gets its id) and,
|
|
107
|
+
* with `linkFor`, how to link to one: each row then has Copy link.
|
|
108
|
+
*/
|
|
109
|
+
function DashboardList({ current, onOpen, linkFor }) {
|
|
110
|
+
const { client, messages } = useDashboards();
|
|
111
|
+
const list = useSWR(LIST_KEY, () => client.listDashboards());
|
|
112
|
+
const [search, setSearch] = useState("");
|
|
113
|
+
const all = list.data?.dashboards ?? [];
|
|
114
|
+
const words = search.trim().toLocaleLowerCase();
|
|
115
|
+
const shown = words === "" ? all : all.filter((d) => d.title.toLocaleLowerCase().includes(words));
|
|
116
|
+
const { making, error, create } = useCreate(onOpen, async () => {
|
|
117
|
+
await list.mutate();
|
|
118
|
+
});
|
|
119
|
+
return /* @__PURE__ */ jsxs("nav", {
|
|
120
|
+
className: "dd-list",
|
|
121
|
+
"aria-label": messages.dashboards,
|
|
122
|
+
children: [
|
|
123
|
+
list.data?.can.create === true ? /* @__PURE__ */ jsx("button", {
|
|
124
|
+
type: "button",
|
|
125
|
+
className: "dd-button dd-list-new",
|
|
126
|
+
disabled: making,
|
|
127
|
+
onClick: () => void create(),
|
|
128
|
+
children: messages.newDashboard
|
|
129
|
+
}) : null,
|
|
130
|
+
error === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
131
|
+
className: "dd-draft-error",
|
|
132
|
+
role: "alert",
|
|
133
|
+
children: error
|
|
134
|
+
}),
|
|
135
|
+
list.error === void 0 ? null : /* @__PURE__ */ jsx("p", {
|
|
136
|
+
className: "dd-draft-error",
|
|
137
|
+
role: "alert",
|
|
138
|
+
children: messages.listFailed
|
|
139
|
+
}),
|
|
140
|
+
/* @__PURE__ */ jsx(Search, {
|
|
141
|
+
all,
|
|
142
|
+
search,
|
|
143
|
+
setSearch,
|
|
144
|
+
shown: shown.length
|
|
145
|
+
}),
|
|
146
|
+
/* @__PURE__ */ jsx(Items, {
|
|
147
|
+
items: shown,
|
|
148
|
+
current,
|
|
149
|
+
onOpen,
|
|
150
|
+
linkFor
|
|
151
|
+
})
|
|
152
|
+
]
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
export { DashboardList, LIST_KEY };
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { useDashboards } from "./context.mjs";
|
|
2
|
+
import { isShifted } from "./marks.mjs";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/Discard.tsx
|
|
6
|
+
/**
|
|
7
|
+
* Discard, asked once in the bar itself: the draft cannot be recovered. A dashboard never
|
|
8
|
+
* published goes with its draft, and the question says so.
|
|
9
|
+
*/
|
|
10
|
+
function DiscardButton({ edit, isNew = false }) {
|
|
11
|
+
const { messages } = useDashboards();
|
|
12
|
+
const [asking, setAsking] = useState(false);
|
|
13
|
+
const discard = useRef(null);
|
|
14
|
+
const keep = useRef(null);
|
|
15
|
+
const answered = useRef(false);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (asking) keep.current?.focus();
|
|
18
|
+
else if (answered.current) discard.current?.focus();
|
|
19
|
+
}, [asking]);
|
|
20
|
+
const ask = (on) => {
|
|
21
|
+
answered.current = !on;
|
|
22
|
+
setAsking(on);
|
|
23
|
+
};
|
|
24
|
+
if (!asking) return /* @__PURE__ */ jsx("button", {
|
|
25
|
+
ref: discard,
|
|
26
|
+
type: "button",
|
|
27
|
+
className: "dd-button dd-quiet",
|
|
28
|
+
"aria-disabled": edit.busy,
|
|
29
|
+
onClick: () => {
|
|
30
|
+
if (!edit.busy) ask(true);
|
|
31
|
+
},
|
|
32
|
+
children: messages.discard
|
|
33
|
+
});
|
|
34
|
+
return /* @__PURE__ */ jsx(DiscardAsk, {
|
|
35
|
+
edit,
|
|
36
|
+
isNew,
|
|
37
|
+
keep,
|
|
38
|
+
onKeep: () => {
|
|
39
|
+
ask(false);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** After a discard the bar is gone: say so, and put focus back on Edit. */
|
|
44
|
+
function saidAndBack(text) {
|
|
45
|
+
requestAnimationFrame(() => {
|
|
46
|
+
const said = document.querySelector(".dd-placed");
|
|
47
|
+
if (said !== null) said.textContent = text;
|
|
48
|
+
document.querySelector("[data-focus-after]")?.focus();
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/** Escape answers "keep": the question goes, and nothing else Escape does happens with it. */
|
|
52
|
+
function useEscape(onEscape) {
|
|
53
|
+
const latest = useRef(onEscape);
|
|
54
|
+
latest.current = onEscape;
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const onKey = (event) => {
|
|
57
|
+
if (event.key !== "Escape") return;
|
|
58
|
+
event.stopImmediatePropagation();
|
|
59
|
+
latest.current();
|
|
60
|
+
};
|
|
61
|
+
globalThis.addEventListener("keydown", onKey, { capture: true });
|
|
62
|
+
return () => {
|
|
63
|
+
globalThis.removeEventListener("keydown", onKey, { capture: true });
|
|
64
|
+
};
|
|
65
|
+
}, []);
|
|
66
|
+
}
|
|
67
|
+
/** The question Discard asks in the bar: how many changes go, Keep editing, and the step itself. */
|
|
68
|
+
function DiscardAsk(props) {
|
|
69
|
+
const { messages } = useDashboards();
|
|
70
|
+
const { edit, isNew, onKeep } = props;
|
|
71
|
+
useEscape(onKeep);
|
|
72
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
73
|
+
className: "dd-row",
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsx("span", { children: isNew ? messages.deleteNewAsk : messages.discardAsk(edit.draft?.changes.filter((c) => !isShifted(c)).length ?? 0) }),
|
|
76
|
+
/* @__PURE__ */ jsx("button", {
|
|
77
|
+
ref: props.keep,
|
|
78
|
+
type: "button",
|
|
79
|
+
className: "dd-button dd-quiet",
|
|
80
|
+
onClick: props.onKeep,
|
|
81
|
+
children: messages.keepEditing
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsx("button", {
|
|
84
|
+
type: "button",
|
|
85
|
+
className: "dd-button dd-danger",
|
|
86
|
+
disabled: edit.busy,
|
|
87
|
+
onClick: () => {
|
|
88
|
+
const discard = async () => {
|
|
89
|
+
await edit.discard();
|
|
90
|
+
if (!isNew) saidAndBack(messages.changesDiscarded);
|
|
91
|
+
};
|
|
92
|
+
discard();
|
|
93
|
+
},
|
|
94
|
+
children: isNew ? messages.deleteNewConfirm : messages.discardConfirm
|
|
95
|
+
})
|
|
96
|
+
]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export { DiscardButton };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DraftEditor } from "./draft.mjs";
|
|
2
|
+
import { Doc } from "derive-dashboards/core";
|
|
3
|
+
/**
|
|
4
|
+
* The bar over a dashboard being edited: who sees the changes, how many there are (which opens
|
|
5
|
+
* the review), Undo and Redo across the whole draft, Discard, and Review and publish. Every
|
|
6
|
+
* action has a keyboard shortcut.
|
|
7
|
+
*/
|
|
8
|
+
export declare function EditBar(props: {
|
|
9
|
+
edit: DraftEditor;
|
|
10
|
+
doc: Doc;
|
|
11
|
+
/** Nothing is published yet: publishing makes the first version, changed or not. */
|
|
12
|
+
firstPublish: boolean;
|
|
13
|
+
/** Never published: Discard deletes the dashboard, and says so. */
|
|
14
|
+
unpublished?: boolean;
|
|
15
|
+
onReview: () => void;
|
|
16
|
+
}): import("react").JSX.Element;
|