@arbidocs/blocks 0.5.151 → 0.5.152
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/dist/{ConnectedNativeDocxComparison-JLT3VHYQ.cjs → ConnectedNativeDocxComparison-244UIHSM.cjs} +9 -9
- package/dist/{ConnectedStreamedWordArtifact-KWK6HLCZ.cjs.map → ConnectedNativeDocxComparison-244UIHSM.cjs.map} +1 -1
- package/dist/{ConnectedPresentation-SY42ADRU.cjs → ConnectedPresentation-JUXIXKYN.cjs} +9 -8
- package/dist/ConnectedPresentation-JUXIXKYN.cjs.map +1 -0
- package/dist/{ConnectedSlidesTab-JATNBI22.cjs → ConnectedSlidesTab-JA3VB66W.cjs} +8 -7
- package/dist/ConnectedSlidesTab-JA3VB66W.cjs.map +1 -0
- package/dist/{ConnectedStreamedWordArtifact-KWK6HLCZ.cjs → ConnectedStreamedWordArtifact-V6BRZMEQ.cjs} +9 -9
- package/dist/{ConnectedNativeDocxComparison-JLT3VHYQ.cjs.map → ConnectedStreamedWordArtifact-V6BRZMEQ.cjs.map} +1 -1
- package/dist/{DocumentReviewCard-USFBTVEL.cjs → DocumentReviewCard-5W2QQWKA.cjs} +14 -14
- package/dist/{DocumentReviewCard-USFBTVEL.cjs.map → DocumentReviewCard-5W2QQWKA.cjs.map} +1 -1
- package/dist/{FilesViewerDialog-O4CY7GM3.cjs → FilesViewerDialog-63QUTG4L.cjs} +12 -12
- package/dist/{FilesViewerDialog-O4CY7GM3.cjs.map → FilesViewerDialog-63QUTG4L.cjs.map} +1 -1
- package/dist/{RechartsRenderer-NRLQZSSY.cjs → RechartsRenderer-NU6WUZJS.cjs} +21 -20
- package/dist/RechartsRenderer-NU6WUZJS.cjs.map +1 -0
- package/dist/{SpotlightStrip-QQ2WUI32.cjs → SpotlightStrip-HXQFPAAL.cjs} +6 -5
- package/dist/SpotlightStrip-HXQFPAAL.cjs.map +1 -0
- package/dist/agents/index.cjs +179 -179
- package/dist/{chunk-3XCYPWC5.cjs → chunk-2P7VH2SK.cjs} +3 -3
- package/dist/chunk-2P7VH2SK.cjs.map +1 -0
- package/dist/{chunk-7Q46YAX4.cjs → chunk-3CJTO6RV.cjs} +152 -199
- package/dist/chunk-3CJTO6RV.cjs.map +1 -0
- package/dist/{chunk-PJTKXKDS.cjs → chunk-4I2PCP7O.cjs} +28 -28
- package/dist/{chunk-PJTKXKDS.cjs.map → chunk-4I2PCP7O.cjs.map} +1 -1
- package/dist/{chunk-OGJCEWME.cjs → chunk-4XNP27N4.cjs} +36 -36
- package/dist/{chunk-OGJCEWME.cjs.map → chunk-4XNP27N4.cjs.map} +1 -1
- package/dist/{chunk-2SILSQNF.cjs → chunk-4ZR4O5SP.cjs} +26 -8
- package/dist/chunk-4ZR4O5SP.cjs.map +1 -0
- package/dist/{chunk-ILATBO5Z.cjs → chunk-6ZZWQ3OL.cjs} +4 -4
- package/dist/{chunk-ILATBO5Z.cjs.map → chunk-6ZZWQ3OL.cjs.map} +1 -1
- package/dist/{chunk-VH4QXK5W.cjs → chunk-AG6KAGAX.cjs} +4 -4
- package/dist/{chunk-VH4QXK5W.cjs.map → chunk-AG6KAGAX.cjs.map} +1 -1
- package/dist/{chunk-MFZW4FEW.cjs → chunk-B5BGVPQ5.cjs} +4 -4
- package/dist/{chunk-MFZW4FEW.cjs.map → chunk-B5BGVPQ5.cjs.map} +1 -1
- package/dist/{chunk-PJ6J4EMZ.cjs → chunk-CULUTYOD.cjs} +4 -4
- package/dist/{chunk-PJ6J4EMZ.cjs.map → chunk-CULUTYOD.cjs.map} +1 -1
- package/dist/{chunk-H7AI54V2.cjs → chunk-CVVQHFLR.cjs} +3 -3
- package/dist/{chunk-H7AI54V2.cjs.map → chunk-CVVQHFLR.cjs.map} +1 -1
- package/dist/{chunk-R3C3S6EH.cjs → chunk-D5DOK2AE.cjs} +58 -58
- package/dist/{chunk-R3C3S6EH.cjs.map → chunk-D5DOK2AE.cjs.map} +1 -1
- package/dist/{chunk-MH7P5FEK.cjs → chunk-FCT62ZPE.cjs} +4 -4
- package/dist/{chunk-MH7P5FEK.cjs.map → chunk-FCT62ZPE.cjs.map} +1 -1
- package/dist/{chunk-QX2LAMVE.cjs → chunk-IXTDOPSB.cjs} +4 -4
- package/dist/{chunk-QX2LAMVE.cjs.map → chunk-IXTDOPSB.cjs.map} +1 -1
- package/dist/{chunk-AKR4JN6I.cjs → chunk-JCFXS336.cjs} +3 -3
- package/dist/{chunk-AKR4JN6I.cjs.map → chunk-JCFXS336.cjs.map} +1 -1
- package/dist/{chunk-N4TOSY7B.cjs → chunk-JLNKD56X.cjs} +4 -4
- package/dist/{chunk-N4TOSY7B.cjs.map → chunk-JLNKD56X.cjs.map} +1 -1
- package/dist/{chunk-DNTSR7UV.cjs → chunk-LYKT336H.cjs} +5 -5
- package/dist/{chunk-DNTSR7UV.cjs.map → chunk-LYKT336H.cjs.map} +1 -1
- package/dist/{chunk-MGGDT6JK.cjs → chunk-MAKCWF45.cjs} +4 -4
- package/dist/{chunk-MGGDT6JK.cjs.map → chunk-MAKCWF45.cjs.map} +1 -1
- package/dist/{chunk-DGUQK5GA.cjs → chunk-TFRCNIUY.cjs} +6 -6
- package/dist/{chunk-DGUQK5GA.cjs.map → chunk-TFRCNIUY.cjs.map} +1 -1
- package/dist/chunk-UM3EWCDE.cjs +105 -0
- package/dist/chunk-UM3EWCDE.cjs.map +1 -0
- package/dist/{chunk-WPUEGDBE.cjs → chunk-WUM76MJU.cjs} +6 -6
- package/dist/{chunk-WPUEGDBE.cjs.map → chunk-WUM76MJU.cjs.map} +1 -1
- package/dist/{chunk-6WWYH66F.cjs → chunk-Z3N32LL4.cjs} +8 -8
- package/dist/{chunk-6WWYH66F.cjs.map → chunk-Z3N32LL4.cjs.map} +1 -1
- package/dist/{chunk-JMBAUHI7.cjs → chunk-ZCQXQIBA.cjs} +28 -28
- package/dist/{chunk-JMBAUHI7.cjs.map → chunk-ZCQXQIBA.cjs.map} +1 -1
- package/dist/components/MetricCard.js +1 -1
- package/dist/components/MetricCard.js.map +2 -2
- package/dist/components/gestures/GestureHandle.d.ts +21 -0
- package/dist/components/gestures/GestureHandle.js +44 -0
- package/dist/components/gestures/GestureHandle.js.map +7 -0
- package/dist/components/gestures/handles.d.ts +43 -0
- package/dist/components/gestures/handles.js +18 -0
- package/dist/components/gestures/handles.js.map +7 -0
- package/dist/components/gestures/index.d.ts +3 -0
- package/dist/components/gestures/index.js +5 -0
- package/dist/components/gestures/index.js.map +7 -0
- package/dist/components/gestures/usePointerGesture.d.ts +51 -0
- package/dist/components/gestures/usePointerGesture.js +61 -0
- package/dist/components/gestures/usePointerGesture.js.map +7 -0
- package/dist/connect/docx.cjs +12 -12
- package/dist/connect/index.cjs +613 -613
- package/dist/connect/viewer.cjs +10 -10
- package/dist/connection/dashboards/DashboardPanel.js +6 -1
- package/dist/connection/dashboards/DashboardPanel.js.map +2 -2
- package/dist/connection/pages/BlockEditor.d.ts +0 -5
- package/dist/connection/pages/BlockEditor.js +3 -65
- package/dist/connection/pages/BlockEditor.js.map +2 -2
- package/dist/connection/pages/ConnectedPagesPage.d.ts +4 -1
- package/dist/connection/pages/ConnectedPagesPage.js +52 -71
- package/dist/connection/pages/ConnectedPagesPage.js.map +2 -2
- package/dist/connection/pages/DocumentBlocks.js +3 -3
- package/dist/connection/pages/DocumentBlocks.js.map +2 -2
- package/dist/connection/pages/DocumentsPicker.js +1 -1
- package/dist/connection/pages/DocumentsPicker.js.map +2 -2
- package/dist/connection/pages/EditablePageGrid.d.ts +31 -0
- package/dist/connection/pages/EditablePageGrid.js +200 -0
- package/dist/connection/pages/EditablePageGrid.js.map +7 -0
- package/dist/connection/pages/PageGrid.d.ts +7 -4
- package/dist/connection/pages/PageGrid.js +9 -3
- package/dist/connection/pages/PageGrid.js.map +2 -2
- package/dist/connection/pages/TableViewBlock.js +1 -1
- package/dist/connection/pages/TableViewBlock.js.map +2 -2
- package/dist/connection/pages/grid-layout.d.ts +38 -0
- package/dist/connection/pages/grid-layout.js +98 -0
- package/dist/connection/pages/grid-layout.js.map +7 -0
- package/dist/connection/pages/index.d.ts +2 -0
- package/dist/connection/pages/index.js +19 -1
- package/dist/connection/pages/index.js.map +2 -2
- package/dist/connection/pages/labels.d.ts +0 -2
- package/dist/connection/pages/labels.js +0 -2
- package/dist/connection/pages/labels.js.map +2 -2
- package/dist/connection/shell/experimentalNav.d.ts +8 -0
- package/dist/connection/shell/experimentalNav.js +23 -0
- package/dist/connection/shell/experimentalNav.js.map +7 -0
- package/dist/dashboards/ChartRenderer.d.ts +6 -0
- package/dist/dashboards/ChartRenderer.js +7 -2
- package/dist/dashboards/ChartRenderer.js.map +2 -2
- package/dist/dashboards/PanelView.d.ts +2 -0
- package/dist/dashboards/PanelView.js +12 -2
- package/dist/dashboards/PanelView.js.map +2 -2
- package/dist/dashboards/RechartsRenderer.js +19 -18
- package/dist/dashboards/RechartsRenderer.js.map +2 -2
- package/dist/dashboards/index.cjs +16 -16
- package/dist/embed/index.cjs +13 -13
- package/dist/facts/index.cjs +1 -1
- package/dist/files/index.cjs +226 -226
- package/dist/index.cjs +338 -320
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +2 -2
- package/dist/pages/index.cjs +389 -181
- package/dist/pages/index.cjs.map +1 -1
- package/dist/presentation/StageBox.js +63 -86
- package/dist/presentation/StageBox.js.map +2 -2
- package/dist/presentation/StageItem.js +86 -117
- package/dist/presentation/StageItem.js.map +2 -2
- package/dist/site/index.cjs +5 -5
- package/dist/studio/index.cjs +13 -13
- package/dist/styles.css +1 -1
- package/dist/workflow-canvas/index.cjs +25 -25
- package/node_modules/@arbidocs/coedit/package.json +1 -1
- package/package.json +5 -5
- package/dist/ConnectedPresentation-SY42ADRU.cjs.map +0 -1
- package/dist/ConnectedSlidesTab-JATNBI22.cjs.map +0 -1
- package/dist/RechartsRenderer-NRLQZSSY.cjs.map +0 -1
- package/dist/SpotlightStrip-QQ2WUI32.cjs.map +0 -1
- package/dist/chunk-2SILSQNF.cjs.map +0 -1
- package/dist/chunk-3XCYPWC5.cjs.map +0 -1
- package/dist/chunk-7Q46YAX4.cjs.map +0 -1
package/dist/connect/viewer.cjs
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var chunkD5DOK2AE_cjs = require('../chunk-D5DOK2AE.cjs');
|
|
5
5
|
require('../chunk-JITYC4OS.cjs');
|
|
6
6
|
require('../chunk-WVZLAAIZ.cjs');
|
|
7
7
|
require('../chunk-X7ALF4MP.cjs');
|
|
8
8
|
require('../chunk-4CIVQWAX.cjs');
|
|
9
9
|
require('../chunk-QWVUBTW3.cjs');
|
|
10
10
|
require('../chunk-JVEDKKNO.cjs');
|
|
11
|
-
require('../chunk-
|
|
11
|
+
require('../chunk-B5BGVPQ5.cjs');
|
|
12
12
|
require('../chunk-CYWOL2LS.cjs');
|
|
13
|
-
require('../chunk-
|
|
13
|
+
require('../chunk-4XNP27N4.cjs');
|
|
14
14
|
require('../chunk-DUNXLT63.cjs');
|
|
15
15
|
require('../chunk-HYUKPHCT.cjs');
|
|
16
|
-
require('../chunk-
|
|
16
|
+
require('../chunk-JCFXS336.cjs');
|
|
17
17
|
require('../chunk-223D4727.cjs');
|
|
18
18
|
require('../chunk-SNUBQMIS.cjs');
|
|
19
19
|
var chunkDLGYR4JL_cjs = require('../chunk-DLGYR4JL.cjs');
|
|
20
|
-
require('../chunk-
|
|
20
|
+
require('../chunk-FCT62ZPE.cjs');
|
|
21
|
+
require('../chunk-4ONPEVTP.cjs');
|
|
22
|
+
require('../chunk-V3KLUWQQ.cjs');
|
|
21
23
|
require('../chunk-5GBM7BQB.cjs');
|
|
22
24
|
require('../chunk-5DGNJ6VJ.cjs');
|
|
23
25
|
require('../chunk-3RAW2ZH5.cjs');
|
|
@@ -25,8 +27,6 @@ require('../chunk-D4SJT3NG.cjs');
|
|
|
25
27
|
require('../chunk-OUYBYZ7Y.cjs');
|
|
26
28
|
require('../chunk-QQMMCXBP.cjs');
|
|
27
29
|
require('../chunk-DTMBAFIL.cjs');
|
|
28
|
-
require('../chunk-4ONPEVTP.cjs');
|
|
29
|
-
require('../chunk-V3KLUWQQ.cjs');
|
|
30
30
|
require('../chunk-7NJKDJVO.cjs');
|
|
31
31
|
require('../chunk-LIDXIX36.cjs');
|
|
32
32
|
require('../chunk-34HQO4ZQ.cjs');
|
|
@@ -40,11 +40,11 @@ require('../chunk-WQMR3O2D.cjs');
|
|
|
40
40
|
require('../chunk-NZNBJF3M.cjs');
|
|
41
41
|
require('../chunk-NWNVWO6L.cjs');
|
|
42
42
|
require('../chunk-SK6HQ46Q.cjs');
|
|
43
|
-
require('../chunk-OEJQFPWO.cjs');
|
|
44
43
|
require('../chunk-MNIQDXM6.cjs');
|
|
45
44
|
require('../chunk-EKFA2OS3.cjs');
|
|
46
45
|
require('../chunk-WCT6FT2K.cjs');
|
|
47
46
|
require('../chunk-LH3PDPJP.cjs');
|
|
47
|
+
require('../chunk-OEJQFPWO.cjs');
|
|
48
48
|
require('../chunk-OYXWQTHF.cjs');
|
|
49
49
|
require('../chunk-S237ORM3.cjs');
|
|
50
50
|
require('../chunk-II2OEXHW.cjs');
|
|
@@ -56,8 +56,8 @@ require('../chunk-AHDJXIUB.cjs');
|
|
|
56
56
|
require('../chunk-RL2HI6NP.cjs');
|
|
57
57
|
require('../chunk-6UZC4XVV.cjs');
|
|
58
58
|
require('../chunk-A5SKK3CU.cjs');
|
|
59
|
-
require('../chunk-YA6GXWC2.cjs');
|
|
60
59
|
require('../chunk-DKY67DA6.cjs');
|
|
60
|
+
require('../chunk-YA6GXWC2.cjs');
|
|
61
61
|
require('../chunk-ZVEW3JBT.cjs');
|
|
62
62
|
require('../chunk-MHIG6GGS.cjs');
|
|
63
63
|
require('../chunk-VG24E4JJ.cjs');
|
|
@@ -95,7 +95,7 @@ require('../chunk-PLIF5CUV.cjs');
|
|
|
95
95
|
|
|
96
96
|
Object.defineProperty(exports, "ConnectedDocumentViewer", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkD5DOK2AE_cjs.ConnectedDocumentViewer; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "ConnectedDocumentToolsProvider", {
|
|
101
101
|
enumerable: true,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useMemo } from "react";
|
|
3
|
+
import { useEffect, useMemo } from "react";
|
|
4
4
|
import {
|
|
5
5
|
formatGbp,
|
|
6
6
|
useArbiSessionState,
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
formatterOf,
|
|
17
17
|
metricValueOf
|
|
18
18
|
} from "../../dashboards/chartModel.js";
|
|
19
|
+
import { preloadChartRenderer } from "../../dashboards/ChartRenderer.js";
|
|
19
20
|
import { PanelView } from "../../dashboards/PanelView.js";
|
|
20
21
|
const PANEL_FORMATTERS = {
|
|
21
22
|
...DEFAULT_UNIT_FORMATTERS,
|
|
@@ -44,6 +45,10 @@ function SourcePanel({
|
|
|
44
45
|
}) {
|
|
45
46
|
const environment = useBlocksEnvironment();
|
|
46
47
|
const { chart } = panel;
|
|
48
|
+
const drawn = DRAWN.has(chart.type) && enabled !== false;
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (drawn) preloadChartRenderer();
|
|
51
|
+
}, [drawn]);
|
|
47
52
|
const { dataset, fields, isLoading, error } = usePanelDataset(
|
|
48
53
|
source,
|
|
49
54
|
panel.source.params,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/dashboards/DashboardPanel.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * `DashboardPanel`: one panel of a dashboard, from its `PanelSpec`. It looks its source up in the\n * host's registry (`useDataSources`), reads the dataset the spec asks for (`usePanelDataset`:\n * grouped and measured by the source) and shows it through `PanelView`.\n */\nimport { useMemo, type ReactNode } from 'react'\nimport {\n formatGbp,\n useArbiSessionState,\n useDataSources,\n usePanelDataset,\n type DataSource,\n type PanelSpec,\n} from '@arbidocs/react'\nimport { Button } from '@arbidocs/react/ui'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { formatBytes } from '../storage/storage-labels'\nimport {\n chartModelOf,\n DEFAULT_UNIT_FORMATTERS,\n formatterOf,\n metricValueOf,\n type DrawnChartType,\n type UnitFormatters,\n} from '../../dashboards/chartModel'\nimport { PanelView, type PanelBody, type PanelViewLabels } from '../../dashboards/PanelView'\n\n/** The package's formatters: the one \u00A3 formatter for AI usage, and file sizes. */\nexport const PANEL_FORMATTERS: UnitFormatters = {\n ...DEFAULT_UNIT_FORMATTERS,\n gbp: (v) => formatGbp(v),\n bytes: (v) => formatBytes(v),\n}\n\nexport interface DashboardPanelLabels extends PanelViewLabels {\n /** A panel whose source the host does not offer. */\n unknownSource: (id: string) => string\n /** The empty state's link to the databases (where data is created or imported). */\n openDatabases: string\n /** A panel over workspace data (documents, threads\u2026) while no workspace is open. */\n noWorkspace: string\n}\n\nexport const DEFAULT_DASHBOARD_PANEL_LABELS: Partial<DashboardPanelLabels> = {\n unknownSource: (id) => `This panel reads \u201C${id}\u201D, which is not available here.`,\n openDatabases: 'Open databases',\n noWorkspace: 'Open a workspace to see this.',\n}\n\nexport interface DashboardPanelProps {\n panel: PanelSpec\n /** Buttons in the panel's corner (a dashboard being edited). */\n actions?: ReactNode\n /** Don't read data (an editor showing the panel's frame only). */\n enabled?: boolean\n /** `plain`: no card around it (a chart placed in a page). */\n variant?: 'card' | 'plain'\n formatters?: UnitFormatters\n labels?: Partial<DashboardPanelLabels>\n className?: string\n testId?: string\n}\n\nconst DRAWN = new Set(['bar', 'line', 'area', 'pie', 'donut'])\n\nfunction kindOf(panel: PanelSpec): 'metric' | 'chart' | 'table' {\n return panel.chart.type === 'metric' ? 'metric' : panel.chart.type === 'table' ? 'table' : 'chart'\n}\n\nfunction SourcePanel({\n source,\n panel,\n actions,\n enabled,\n variant,\n formatters,\n labels,\n className,\n testId,\n}: DashboardPanelProps & { source: DataSource; labels: Partial<DashboardPanelLabels> }) {\n const environment = useBlocksEnvironment()\n const { chart } = panel\n const { dataset, fields, isLoading, error } = usePanelDataset(\n source,\n panel.source.params,\n chart,\n { enabled }\n )\n const body = useMemo((): PanelBody | undefined => {\n if (!dataset) return undefined\n const other = labels.other\n if (chart.type === 'metric') {\n const valueField = dataset.fields.find((f) => f.id === 'value')\n // Nothing matched: a count or a sum of nothing is 0; an average of nothing has no value.\n const op = chart.aggregate ?? 'count'\n return {\n kind: 'metric',\n value: metricValueOf(dataset) ?? (op === 'count' || op === 'sum' ? 0 : null),\n format: formatterOf(valueField, formatters),\n }\n }\n if (DRAWN.has(chart.type)) {\n return {\n kind: 'chart',\n model: chartModelOf({ ...chart, type: chart.type as DrawnChartType }, dataset, {\n fields,\n formatters,\n otherLabel: other,\n }),\n }\n }\n if (chart.x) {\n return {\n kind: 'groups',\n model: chartModelOf({ ...chart, type: 'bar' }, dataset, {\n fields,\n formatters,\n otherLabel: other,\n }),\n }\n }\n const shown = chart.columns?.length\n ? chart.columns.flatMap((id) => dataset.fields.filter((f) => f.id === id))\n : dataset.fields\n return { kind: 'records', fields: shown, rows: dataset.rows }\n }, [dataset, chart, fields, formatters, labels.other])\n\n const state = error\n ? 'error'\n : !dataset\n ? isLoading\n ? 'loading'\n : 'empty'\n : chart.type !== 'metric' && dataset.rows.length === 0\n ? 'empty'\n : 'ready'\n\n const emptyAction =\n source.id === 'database' && environment.openDatabases ? (\n <Button variant=\"outline\" size=\"sm\" onClick={() => environment.openDatabases?.()}>\n {labels.openDatabases}\n </Button>\n ) : undefined\n\n return (\n <PanelView\n kind={kindOf(panel)}\n title={panel.title}\n description={panel.description}\n state={state}\n body={body}\n errorDetail={error instanceof Error ? error.message : undefined}\n emptyAction={emptyAction}\n actions={actions}\n variant={variant}\n formatters={formatters}\n labels={labels}\n className={className}\n testId={testId}\n />\n )\n}\n\nexport function DashboardPanel({\n formatters = PANEL_FORMATTERS,\n labels,\n ...props\n}: DashboardPanelProps) {\n const registry = useDataSources()\n const l = { ...DEFAULT_DASHBOARD_PANEL_LABELS, ...labels }\n const source = registry.get(props.panel.source.id)\n const workspaceId = useArbiSessionState((s) => s.workspaceId)\n const scope =\n typeof source?.scope === 'function'\n ? source.scope(props.panel.source.params ?? {})\n : source?.scope\n if (scope === 'workspace' && !workspaceId) {\n return (\n <PanelView\n kind={kindOf(props.panel)}\n title={props.panel.title}\n state=\"empty\"\n actions={props.actions}\n labels={{ ...l, empty: l.noWorkspace ?? l.empty }}\n variant={props.variant}\n className={props.className}\n testId={props.testId}\n />\n )\n }\n if (!source) {\n return (\n <PanelView\n kind={kindOf(props.panel)}\n title={props.panel.title}\n state=\"error\"\n errorDetail={l.unknownSource?.(props.panel.source.id)}\n actions={props.actions}\n labels={l}\n className={props.className}\n testId={props.testId}\n />\n )\n }\n // Keyed by source: a source's hooks differ from another's, so a new source mounts afresh.\n return (\n <SourcePanel key={source.id} source={source} formatters={formatters} labels={l} {...props} />\n )\n}\n"],
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * `DashboardPanel`: one panel of a dashboard, from its `PanelSpec`. It looks its source up in the\n * host's registry (`useDataSources`), reads the dataset the spec asks for (`usePanelDataset`:\n * grouped and measured by the source) and shows it through `PanelView`.\n */\nimport { useEffect, useMemo, type ReactNode } from 'react'\nimport {\n formatGbp,\n useArbiSessionState,\n useDataSources,\n usePanelDataset,\n type DataSource,\n type PanelSpec,\n} from '@arbidocs/react'\nimport { Button } from '@arbidocs/react/ui'\nimport { useBlocksEnvironment } from '../../provider/environment'\nimport { formatBytes } from '../storage/storage-labels'\nimport {\n chartModelOf,\n DEFAULT_UNIT_FORMATTERS,\n formatterOf,\n metricValueOf,\n type DrawnChartType,\n type UnitFormatters,\n} from '../../dashboards/chartModel'\nimport { preloadChartRenderer } from '../../dashboards/ChartRenderer'\nimport { PanelView, type PanelBody, type PanelViewLabels } from '../../dashboards/PanelView'\n\n/** The package's formatters: the one \u00A3 formatter for AI usage, and file sizes. */\nexport const PANEL_FORMATTERS: UnitFormatters = {\n ...DEFAULT_UNIT_FORMATTERS,\n gbp: (v) => formatGbp(v),\n bytes: (v) => formatBytes(v),\n}\n\nexport interface DashboardPanelLabels extends PanelViewLabels {\n /** A panel whose source the host does not offer. */\n unknownSource: (id: string) => string\n /** The empty state's link to the databases (where data is created or imported). */\n openDatabases: string\n /** A panel over workspace data (documents, threads\u2026) while no workspace is open. */\n noWorkspace: string\n}\n\nexport const DEFAULT_DASHBOARD_PANEL_LABELS: Partial<DashboardPanelLabels> = {\n unknownSource: (id) => `This panel reads \u201C${id}\u201D, which is not available here.`,\n openDatabases: 'Open databases',\n noWorkspace: 'Open a workspace to see this.',\n}\n\nexport interface DashboardPanelProps {\n panel: PanelSpec\n /** Buttons in the panel's corner (a dashboard being edited). */\n actions?: ReactNode\n /** Don't read data (an editor showing the panel's frame only). */\n enabled?: boolean\n /** `plain`: no card around it (a chart placed in a page). */\n variant?: 'card' | 'plain'\n formatters?: UnitFormatters\n labels?: Partial<DashboardPanelLabels>\n className?: string\n testId?: string\n}\n\nconst DRAWN = new Set(['bar', 'line', 'area', 'pie', 'donut'])\n\nfunction kindOf(panel: PanelSpec): 'metric' | 'chart' | 'table' {\n return panel.chart.type === 'metric' ? 'metric' : panel.chart.type === 'table' ? 'table' : 'chart'\n}\n\nfunction SourcePanel({\n source,\n panel,\n actions,\n enabled,\n variant,\n formatters,\n labels,\n className,\n testId,\n}: DashboardPanelProps & { source: DataSource; labels: Partial<DashboardPanelLabels> }) {\n const environment = useBlocksEnvironment()\n const { chart } = panel\n // A drawn chart fetches its drawing code while its data loads, not after.\n const drawn = DRAWN.has(chart.type) && enabled !== false\n useEffect(() => {\n if (drawn) preloadChartRenderer()\n }, [drawn])\n const { dataset, fields, isLoading, error } = usePanelDataset(\n source,\n panel.source.params,\n chart,\n { enabled }\n )\n const body = useMemo((): PanelBody | undefined => {\n if (!dataset) return undefined\n const other = labels.other\n if (chart.type === 'metric') {\n const valueField = dataset.fields.find((f) => f.id === 'value')\n // Nothing matched: a count or a sum of nothing is 0; an average of nothing has no value.\n const op = chart.aggregate ?? 'count'\n return {\n kind: 'metric',\n value: metricValueOf(dataset) ?? (op === 'count' || op === 'sum' ? 0 : null),\n format: formatterOf(valueField, formatters),\n }\n }\n if (DRAWN.has(chart.type)) {\n return {\n kind: 'chart',\n model: chartModelOf({ ...chart, type: chart.type as DrawnChartType }, dataset, {\n fields,\n formatters,\n otherLabel: other,\n }),\n }\n }\n if (chart.x) {\n return {\n kind: 'groups',\n model: chartModelOf({ ...chart, type: 'bar' }, dataset, {\n fields,\n formatters,\n otherLabel: other,\n }),\n }\n }\n const shown = chart.columns?.length\n ? chart.columns.flatMap((id) => dataset.fields.filter((f) => f.id === id))\n : dataset.fields\n return { kind: 'records', fields: shown, rows: dataset.rows }\n }, [dataset, chart, fields, formatters, labels.other])\n\n const state = error\n ? 'error'\n : !dataset\n ? isLoading\n ? 'loading'\n : 'empty'\n : chart.type !== 'metric' && dataset.rows.length === 0\n ? 'empty'\n : 'ready'\n\n const emptyAction =\n source.id === 'database' && environment.openDatabases ? (\n <Button variant=\"outline\" size=\"sm\" onClick={() => environment.openDatabases?.()}>\n {labels.openDatabases}\n </Button>\n ) : undefined\n\n return (\n <PanelView\n kind={kindOf(panel)}\n title={panel.title}\n description={panel.description}\n state={state}\n body={body}\n errorDetail={error instanceof Error ? error.message : undefined}\n emptyAction={emptyAction}\n actions={actions}\n variant={variant}\n formatters={formatters}\n labels={labels}\n className={className}\n testId={testId}\n />\n )\n}\n\nexport function DashboardPanel({\n formatters = PANEL_FORMATTERS,\n labels,\n ...props\n}: DashboardPanelProps) {\n const registry = useDataSources()\n const l = { ...DEFAULT_DASHBOARD_PANEL_LABELS, ...labels }\n const source = registry.get(props.panel.source.id)\n const workspaceId = useArbiSessionState((s) => s.workspaceId)\n const scope =\n typeof source?.scope === 'function'\n ? source.scope(props.panel.source.params ?? {})\n : source?.scope\n if (scope === 'workspace' && !workspaceId) {\n return (\n <PanelView\n kind={kindOf(props.panel)}\n title={props.panel.title}\n state=\"empty\"\n actions={props.actions}\n labels={{ ...l, empty: l.noWorkspace ?? l.empty }}\n variant={props.variant}\n className={props.className}\n testId={props.testId}\n />\n )\n }\n if (!source) {\n return (\n <PanelView\n kind={kindOf(props.panel)}\n title={props.panel.title}\n state=\"error\"\n errorDetail={l.unknownSource?.(props.panel.source.id)}\n actions={props.actions}\n labels={l}\n className={props.className}\n testId={props.testId}\n />\n )\n }\n // Keyed by source: a source's hooks differ from another's, so a new source mounts afresh.\n return (\n <SourcePanel key={source.id} source={source} formatters={formatters} labels={l} {...props} />\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAiJM;AA5IN,SAAS,WAAW,eAA+B;AACnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,cAAc;AACvB,SAAS,4BAA4B;AACrC,SAAS,mBAAmB;AAC5B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,4BAA4B;AACrC,SAAS,iBAAuD;AAGzD,MAAM,mBAAmC;AAAA,EAC9C,GAAG;AAAA,EACH,KAAK,CAAC,MAAM,UAAU,CAAC;AAAA,EACvB,OAAO,CAAC,MAAM,YAAY,CAAC;AAC7B;AAWO,MAAM,iCAAgE;AAAA,EAC3E,eAAe,CAAC,OAAO,0BAAqB,EAAE;AAAA,EAC9C,eAAe;AAAA,EACf,aAAa;AACf;AAgBA,MAAM,QAAQ,oBAAI,IAAI,CAAC,OAAO,QAAQ,QAAQ,OAAO,OAAO,CAAC;AAE7D,SAAS,OAAO,OAAgD;AAC9D,SAAO,MAAM,MAAM,SAAS,WAAW,WAAW,MAAM,MAAM,S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C;AAAA;AAAA,QACC,MAAM,OAAO,MAAM,KAAK;AAAA,QACxB,OAAO,MAAM,MAAM;AAAA,QACnB,OAAM;AAAA,QACN,SAAS,MAAM;AAAA,QACf,QAAQ,EAAE,GAAG,GAAG,OAAO,EAAE,eAAe,EAAE,MAAM;AAAA,QAChD,SAAS,MAAM;AAAA,QACf,WAAW,MAAM;AAAA,QACjB,QAAQ,MAAM;AAAA;AAAA,IAChB;AAAA,EAEJ;AACA,MAAI,CAAC,QAAQ;AACX,WACE;AAAA,MAAC;AAAA;AAAA,QACC,MAAM,OAAO,MAAM,KAAK;AAAA,QACxB,OAAO,MAAM,MAAM;AAAA,QACnB,OAAM;AAAA,QACN,aAAa,EAAE,gBAAgB,MAAM,MAAM,OAAO,EAAE;AAAA,QACpD,SAAS,MAAM;AAAA,QACf,QAAQ;AAAA,QACR,WAAW,MAAM;AAAA,QACjB,QAAQ,MAAM;AAAA;AAAA,IAChB;AAAA,EAEJ;AAEA,SACE,oBAAC,eAA4B,QAAgB,YAAwB,QAAQ,GAAI,GAAG,SAAlE,OAAO,EAAkE;AAE/F;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,11 +7,6 @@ export interface BlockEditorLabels {
|
|
|
7
7
|
description: string;
|
|
8
8
|
text: string;
|
|
9
9
|
view: string;
|
|
10
|
-
width: string;
|
|
11
|
-
height: string;
|
|
12
|
-
/** A width in columns, e.g. "Half (6 of 12)". */
|
|
13
|
-
columns: (n: number) => string;
|
|
14
|
-
rows: (n: number) => string;
|
|
15
10
|
cancel: string;
|
|
16
11
|
done: string;
|
|
17
12
|
}
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useState } from "react";
|
|
4
|
-
import {
|
|
5
|
-
blockOfPanel,
|
|
6
|
-
panelOfBlock,
|
|
7
|
-
PAGE_GRID_COLUMNS
|
|
8
|
-
} from "@arbidocs/react";
|
|
4
|
+
import { blockOfPanel, panelOfBlock } from "@arbidocs/react";
|
|
9
5
|
import {
|
|
10
6
|
Button,
|
|
11
7
|
Dialog,
|
|
@@ -22,43 +18,12 @@ import { DocumentsPicker } from "./DocumentsPicker.js";
|
|
|
22
18
|
import { ViewPicker } from "./ViewPicker.js";
|
|
23
19
|
const DEFAULT_BLOCK_EDITOR_LABELS = {
|
|
24
20
|
title: "Block",
|
|
25
|
-
description: "Choose what the block shows
|
|
21
|
+
description: "Choose what the block shows. Drag it on the page to place and size it.",
|
|
26
22
|
text: "Text (Markdown)",
|
|
27
23
|
view: "Table view",
|
|
28
|
-
width: "Width",
|
|
29
|
-
height: "Height",
|
|
30
|
-
columns: (n) => n === PAGE_GRID_COLUMNS ? "Full width" : n === 6 ? "Half" : `${n} of ${PAGE_GRID_COLUMNS} columns`,
|
|
31
|
-
rows: (n) => `${n} ${n === 1 ? "row" : "rows"}`,
|
|
32
24
|
cancel: "Cancel",
|
|
33
25
|
done: "Done"
|
|
34
26
|
};
|
|
35
|
-
const WIDTHS = [3, 4, 6, 8, 9, 12];
|
|
36
|
-
const HEIGHTS = [1, 2, 3, 4, 5, 6, 8, 10, 12];
|
|
37
|
-
function SizeSelect({
|
|
38
|
-
id,
|
|
39
|
-
label,
|
|
40
|
-
value,
|
|
41
|
-
options,
|
|
42
|
-
format,
|
|
43
|
-
onChange,
|
|
44
|
-
testId
|
|
45
|
-
}) {
|
|
46
|
-
const all = options.includes(value) ? options : [...options, value].sort((a, b) => a - b);
|
|
47
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-1.5", children: [
|
|
48
|
-
/* @__PURE__ */ jsx(Label, { htmlFor: id, children: label }),
|
|
49
|
-
/* @__PURE__ */ jsx(
|
|
50
|
-
"select",
|
|
51
|
-
{
|
|
52
|
-
id,
|
|
53
|
-
className: "h-9 rounded-md border border-input bg-background px-2 text-sm",
|
|
54
|
-
value,
|
|
55
|
-
onChange: (e) => onChange(Number(e.target.value)),
|
|
56
|
-
"data-testid": testId,
|
|
57
|
-
children: all.map((n) => /* @__PURE__ */ jsx("option", { value: n, children: format(n) }, n))
|
|
58
|
-
}
|
|
59
|
-
)
|
|
60
|
-
] });
|
|
61
|
-
}
|
|
62
27
|
function BlockEditor({
|
|
63
28
|
block,
|
|
64
29
|
shared,
|
|
@@ -73,7 +38,6 @@ function BlockEditor({
|
|
|
73
38
|
const l = { ...DEFAULT_BLOCK_EDITOR_LABELS, ...labels };
|
|
74
39
|
const [value, setValue] = useState(block);
|
|
75
40
|
useEffect(() => setValue(block), [block]);
|
|
76
|
-
const setLayout = (patch) => setValue((b) => b ? { ...b, layout: { ...b.layout, ...patch } } : b);
|
|
77
41
|
const setPanel = (panel) => setValue((b) => b ? { ...blockOfPanel(panel, b.layout.h), layout: b.layout } : b);
|
|
78
42
|
const ready = !!value && (value.kind === "table" ? !!value.config.view : value.kind === "document" ? !!value.config.document : value.kind === "gallery" ? value.config.documents.length > 0 : true);
|
|
79
43
|
return /* @__PURE__ */ jsx(Dialog, { open: block !== null, onOpenChange: (open) => !open && onCancel(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90dvh] max-w-5xl overflow-y-auto", "data-testid": testId, children: [
|
|
@@ -126,33 +90,7 @@ function BlockEditor({
|
|
|
126
90
|
labels: documentsLabels,
|
|
127
91
|
testId: `${testId}-documents`
|
|
128
92
|
}
|
|
129
|
-
)
|
|
130
|
-
/* @__PURE__ */ jsxs("div", { className: "grid gap-4 sm:grid-cols-2", children: [
|
|
131
|
-
/* @__PURE__ */ jsx(
|
|
132
|
-
SizeSelect,
|
|
133
|
-
{
|
|
134
|
-
id: `${testId}-width`,
|
|
135
|
-
label: l.width,
|
|
136
|
-
value: value.layout.w,
|
|
137
|
-
options: WIDTHS,
|
|
138
|
-
format: l.columns,
|
|
139
|
-
onChange: (w) => setLayout({ w }),
|
|
140
|
-
testId: `${testId}-width`
|
|
141
|
-
}
|
|
142
|
-
),
|
|
143
|
-
/* @__PURE__ */ jsx(
|
|
144
|
-
SizeSelect,
|
|
145
|
-
{
|
|
146
|
-
id: `${testId}-height`,
|
|
147
|
-
label: l.height,
|
|
148
|
-
value: value.layout.h,
|
|
149
|
-
options: HEIGHTS,
|
|
150
|
-
format: l.rows,
|
|
151
|
-
onChange: (h) => setLayout({ h }),
|
|
152
|
-
testId: `${testId}-height`
|
|
153
|
-
}
|
|
154
|
-
)
|
|
155
|
-
] })
|
|
93
|
+
)
|
|
156
94
|
] }),
|
|
157
95
|
/* @__PURE__ */ jsxs(DialogFooter, { children: [
|
|
158
96
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", onClick: onCancel, children: l.cancel }),
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/connection/pages/BlockEditor.tsx"],
|
|
4
|
-
"sourcesContent": ["/**\n * `BlockEditor`: the dialog that changes one block of a page being edited: a chart or metric through\n * the Analytics `PanelEditor`, a text block's Markdown, a table block's view (`ViewPicker`: on a\n * shared page, shared views only),
|
|
5
|
-
"mappings": ";
|
|
4
|
+
"sourcesContent": ["/**\n * `BlockEditor`: the dialog that changes one block of a page being edited: a chart or metric through\n * the Analytics `PanelEditor`, a text block's Markdown, a table block's view (`ViewPicker`: on a\n * shared page, shared views only), a document or a gallery's documents. Its place and size are set\n * on the page itself, by dragging it (`EditablePageGrid`).\n */\nimport { useEffect, useState } from 'react'\nimport { blockOfPanel, panelOfBlock, type PageBlock, type PanelSpec } from '@arbidocs/react'\nimport {\n Button,\n Dialog,\n DialogContent,\n DialogDescription,\n DialogFooter,\n DialogHeader,\n DialogTitle,\n Label,\n Textarea,\n} from '@arbidocs/react/ui'\nimport { PanelEditor, type PanelEditorLabels } from '../dashboards/PanelEditor'\nimport { DocumentsPicker, type DocumentsPickerLabels } from './DocumentsPicker'\nimport { ViewPicker, type ViewPickerLabels } from './ViewPicker'\n\nexport interface BlockEditorLabels {\n title: string\n description: string\n text: string\n view: string\n cancel: string\n done: string\n}\n\nexport const DEFAULT_BLOCK_EDITOR_LABELS: BlockEditorLabels = {\n title: 'Block',\n description: 'Choose what the block shows. Drag it on the page to place and size it.',\n text: 'Text (Markdown)',\n view: 'Table view',\n cancel: 'Cancel',\n done: 'Done',\n}\n\nexport interface BlockEditorProps {\n /** The block being edited; `null` closes the dialog. */\n block: PageBlock | null\n /** The page is shared: a table block offers shared views only. */\n shared: boolean\n onDone: (block: PageBlock) => void\n onCancel: () => void\n labels?: Partial<BlockEditorLabels>\n editorLabels?: Partial<PanelEditorLabels>\n pickerLabels?: Partial<ViewPickerLabels>\n documentsLabels?: Partial<DocumentsPickerLabels>\n testId?: string\n}\n\nexport function BlockEditor({\n block,\n shared,\n onDone,\n onCancel,\n labels,\n editorLabels,\n pickerLabels,\n documentsLabels,\n testId = 'page-block-editor',\n}: BlockEditorProps) {\n const l = { ...DEFAULT_BLOCK_EDITOR_LABELS, ...labels }\n const [value, setValue] = useState<PageBlock | null>(block)\n useEffect(() => setValue(block), [block])\n\n const setPanel = (panel: PanelSpec) =>\n setValue((b) => (b ? { ...blockOfPanel(panel, b.layout.h), layout: b.layout } : b))\n\n const ready =\n !!value &&\n (value.kind === 'table'\n ? !!value.config.view\n : value.kind === 'document'\n ? !!value.config.document\n : value.kind === 'gallery'\n ? value.config.documents.length > 0\n : true)\n\n return (\n <Dialog open={block !== null} onOpenChange={(open) => !open && onCancel()}>\n <DialogContent className=\"max-h-[90dvh] max-w-5xl overflow-y-auto\" data-testid={testId}>\n <DialogHeader>\n <DialogTitle>{l.title}</DialogTitle>\n <DialogDescription>{l.description}</DialogDescription>\n </DialogHeader>\n {value && (\n <div className=\"space-y-4\">\n {(value.kind === 'chart' || value.kind === 'metric') && (\n <PanelEditor\n value={panelOfBlock(value)}\n onChange={setPanel}\n labels={editorLabels}\n testId={`${testId}-panel`}\n />\n )}\n {value.kind === 'text' && (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${testId}-text`}>{l.text}</Label>\n <Textarea\n id={`${testId}-text`}\n rows={8}\n value={value.config.text}\n onChange={(e) =>\n setValue({ ...value, config: { text: e.target.value } } as PageBlock)\n }\n data-testid={`${testId}-text`}\n />\n </div>\n )}\n {value.kind === 'table' && (\n <ViewPicker\n value={value.config.view || null}\n sharedOnly={shared}\n onChange={(view) => setValue({ ...value, config: { view } } as PageBlock)}\n labels={pickerLabels}\n testId={`${testId}-view`}\n />\n )}\n {(value.kind === 'document' || value.kind === 'gallery') && (\n <DocumentsPicker\n value={\n value.kind === 'document'\n ? value.config.document\n ? [value.config.document]\n : []\n : value.config.documents\n }\n multiple={value.kind === 'gallery'}\n sharedOnly={shared}\n onChange={(ids) =>\n setValue(\n (value.kind === 'document'\n ? { ...value, config: { document: ids[0] ?? '' } }\n : { ...value, config: { documents: ids } }) as PageBlock\n )\n }\n labels={documentsLabels}\n testId={`${testId}-documents`}\n />\n )}\n </div>\n )}\n <DialogFooter>\n <Button variant=\"ghost\" onClick={onCancel}>\n {l.cancel}\n </Button>\n <Button\n disabled={!ready}\n onClick={() => value && onDone(value)}\n data-testid={`${testId}-done`}\n >\n {l.done}\n </Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"],
|
|
5
|
+
"mappings": ";AAsFQ,SACE,KADF;AAhFR,SAAS,WAAW,gBAAgB;AACpC,SAAS,cAAc,oBAAoD;AAC3E;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,mBAA2C;AACpD,SAAS,uBAAmD;AAC5D,SAAS,kBAAyC;AAW3C,MAAM,8BAAiD;AAAA,EAC5D,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,MAAM;AACR;AAgBO,SAAS,YAAY;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA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
2
2
|
import type { DashboardPanelLabels } from '../dashboards/DashboardPanel';
|
|
3
3
|
import type { PanelEditorLabels } from '../dashboards/PanelEditor';
|
|
4
4
|
import { type BlockEditorLabels } from './BlockEditor';
|
|
5
|
+
import { type EditablePageGridLabels } from './EditablePageGrid';
|
|
5
6
|
import { type PagesPageLabels } from './labels';
|
|
6
7
|
import type { TableViewBlockLabels } from './TableViewBlock';
|
|
7
8
|
import type { ViewPickerLabels } from './ViewPicker';
|
|
@@ -19,6 +20,8 @@ export interface ConnectedPagesPageProps {
|
|
|
19
20
|
panelLabels?: Partial<DashboardPanelLabels>;
|
|
20
21
|
editorLabels?: Partial<PanelEditorLabels>;
|
|
21
22
|
blockLabels?: Partial<BlockEditorLabels>;
|
|
23
|
+
/** The editor's grid: its grip and resize handles. */
|
|
24
|
+
gridLabels?: Partial<EditablePageGridLabels>;
|
|
22
25
|
tableLabels?: Partial<TableViewBlockLabels>;
|
|
23
26
|
pickerLabels?: Partial<ViewPickerLabels>;
|
|
24
27
|
/**
|
|
@@ -28,4 +31,4 @@ export interface ConnectedPagesPageProps {
|
|
|
28
31
|
className?: string;
|
|
29
32
|
testId?: string;
|
|
30
33
|
}
|
|
31
|
-
export declare function ConnectedPagesPage({ templates: siteTemplates, pageId, onPageChange, labels, panelLabels, editorLabels, blockLabels, tableLabels, pickerLabels, className, testId, }: ConnectedPagesPageProps): import("react").JSX.Element;
|
|
34
|
+
export declare function ConnectedPagesPage({ templates: siteTemplates, pageId, onPageChange, labels, panelLabels, editorLabels, blockLabels, gridLabels, tableLabels, pickerLabels, className, testId, }: ConnectedPagesPageProps): import("react").JSX.Element;
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import {
|
|
5
|
-
ArrowDown,
|
|
6
|
-
ArrowUp,
|
|
7
5
|
FileText,
|
|
8
6
|
Pencil,
|
|
9
7
|
Plus,
|
|
@@ -18,7 +16,6 @@ import {
|
|
|
18
16
|
ANALYTICS_CHART_VIEW,
|
|
19
17
|
DEFAULT_BLOCK_HEIGHT,
|
|
20
18
|
blockOfPanel,
|
|
21
|
-
packBlocks,
|
|
22
19
|
pageFromDashboard,
|
|
23
20
|
useArbi,
|
|
24
21
|
useCanEditShared,
|
|
@@ -45,6 +42,8 @@ import { PageHeader } from "../../components/PageHeader.js";
|
|
|
45
42
|
import { useBlocksEnvironment } from "../../provider/environment.js";
|
|
46
43
|
import { DASHBOARD_TEMPLATES, newPanel, newPanelId, templatesFor } from "../dashboards/templates.js";
|
|
47
44
|
import { BlockEditor } from "./BlockEditor.js";
|
|
45
|
+
import { EditablePageGrid } from "./EditablePageGrid.js";
|
|
46
|
+
import { appendBlock, compactLayout } from "./grid-layout.js";
|
|
48
47
|
import { PageBlockView } from "./PageBlockView.js";
|
|
49
48
|
import { PageCell, PageGrid, inReadingOrder } from "./PageGrid.js";
|
|
50
49
|
import { PagesList } from "./PagesList.js";
|
|
@@ -81,6 +80,7 @@ function ConnectedPagesPage({
|
|
|
81
80
|
panelLabels,
|
|
82
81
|
editorLabels,
|
|
83
82
|
blockLabels,
|
|
83
|
+
gridLabels,
|
|
84
84
|
tableLabels,
|
|
85
85
|
pickerLabels,
|
|
86
86
|
className,
|
|
@@ -166,7 +166,7 @@ function ConnectedPagesPage({
|
|
|
166
166
|
setDraft(null);
|
|
167
167
|
};
|
|
168
168
|
const updateDraft = (patch) => setDraft((d) => d ? { ...d, spec: { ...d.spec, ...patch } } : d);
|
|
169
|
-
const setBlocks = (blocks) => updateDraft({ blocks
|
|
169
|
+
const setBlocks = (blocks) => updateDraft({ blocks });
|
|
170
170
|
const commit = async () => {
|
|
171
171
|
if (!draft) return;
|
|
172
172
|
try {
|
|
@@ -201,13 +201,7 @@ function ConnectedPagesPage({
|
|
|
201
201
|
};
|
|
202
202
|
let content;
|
|
203
203
|
if (draft) {
|
|
204
|
-
const blocks =
|
|
205
|
-
const move = (index, by) => {
|
|
206
|
-
const next = [...blocks];
|
|
207
|
-
const [moved] = next.splice(index, 1);
|
|
208
|
-
next.splice(index + by, 0, moved);
|
|
209
|
-
setBlocks(next);
|
|
210
|
-
};
|
|
204
|
+
const blocks = draft.spec.blocks;
|
|
211
205
|
content = /* @__PURE__ */ jsxs("div", { className: "space-y-6", "data-testid": `${testId}-editor`, children: [
|
|
212
206
|
/* @__PURE__ */ jsx(
|
|
213
207
|
PageHeader,
|
|
@@ -260,64 +254,51 @@ function ConnectedPagesPage({
|
|
|
260
254
|
)
|
|
261
255
|
] })
|
|
262
256
|
] }),
|
|
263
|
-
blocks.length ? /* @__PURE__ */ jsx(
|
|
264
|
-
|
|
257
|
+
blocks.length ? /* @__PURE__ */ jsx(
|
|
258
|
+
EditablePageGrid,
|
|
265
259
|
{
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
testId
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
),
|
|
307
|
-
/* @__PURE__ */ jsx(
|
|
308
|
-
Button,
|
|
309
|
-
{
|
|
310
|
-
variant: "ghost",
|
|
311
|
-
size: "icon",
|
|
312
|
-
className: "size-7",
|
|
313
|
-
"aria-label": l.removeBlock,
|
|
314
|
-
onClick: () => setBlocks(blocks.filter((_, j) => j !== i)),
|
|
315
|
-
children: /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" })
|
|
316
|
-
}
|
|
317
|
-
)
|
|
318
|
-
] })
|
|
260
|
+
blocks,
|
|
261
|
+
onChange: setBlocks,
|
|
262
|
+
labels: gridLabels,
|
|
263
|
+
testId,
|
|
264
|
+
renderBlock: (block, grip) => /* @__PURE__ */ jsx(
|
|
265
|
+
PageBlockView,
|
|
266
|
+
{
|
|
267
|
+
block,
|
|
268
|
+
panelLabels,
|
|
269
|
+
tableLabels,
|
|
270
|
+
testId: `${testId}-block-${block.id}`,
|
|
271
|
+
actions: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
272
|
+
grip,
|
|
273
|
+
/* @__PURE__ */ jsx(
|
|
274
|
+
Button,
|
|
275
|
+
{
|
|
276
|
+
variant: "ghost",
|
|
277
|
+
size: "icon",
|
|
278
|
+
className: "size-7",
|
|
279
|
+
"aria-label": l.editBlock,
|
|
280
|
+
onClick: () => setEditing({ block, isNew: false }),
|
|
281
|
+
"data-testid": `${testId}-edit-block-${block.id}`,
|
|
282
|
+
children: /* @__PURE__ */ jsx(Pencil, { className: "size-3.5" })
|
|
283
|
+
}
|
|
284
|
+
),
|
|
285
|
+
/* @__PURE__ */ jsx(
|
|
286
|
+
Button,
|
|
287
|
+
{
|
|
288
|
+
variant: "ghost",
|
|
289
|
+
size: "icon",
|
|
290
|
+
className: "size-7",
|
|
291
|
+
"aria-label": l.removeBlock,
|
|
292
|
+
onClick: () => setBlocks(compactLayout(blocks.filter((b) => b.id !== block.id))),
|
|
293
|
+
"data-testid": `${testId}-remove-block-${block.id}`,
|
|
294
|
+
children: /* @__PURE__ */ jsx(Trash2, { className: "size-3.5" })
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
] })
|
|
298
|
+
}
|
|
299
|
+
)
|
|
319
300
|
}
|
|
320
|
-
)
|
|
301
|
+
) : /* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground", children: l.noBlocks }),
|
|
321
302
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
322
303
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(Button, { variant: "outline", "data-testid": `${testId}-add-block`, children: [
|
|
323
304
|
/* @__PURE__ */ jsx(Plus, { className: "size-4" }),
|
|
@@ -329,7 +310,7 @@ function ConnectedPagesPage({
|
|
|
329
310
|
return /* @__PURE__ */ jsxs(
|
|
330
311
|
DropdownMenuItem,
|
|
331
312
|
{
|
|
332
|
-
onSelect: () => setEditing({
|
|
313
|
+
onSelect: () => setEditing({ block: newBlock(kind), isNew: true }),
|
|
333
314
|
"data-testid": `${testId}-add-${kind}`,
|
|
334
315
|
children: [
|
|
335
316
|
/* @__PURE__ */ jsx(Icon, { className: "size-4" }),
|
|
@@ -353,9 +334,9 @@ function ConnectedPagesPage({
|
|
|
353
334
|
onCancel: () => setEditing(null),
|
|
354
335
|
onDone: (block) => {
|
|
355
336
|
if (!editing) return;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
337
|
+
setBlocks(
|
|
338
|
+
editing.isNew ? appendBlock(blocks, block) : blocks.map((b) => b.id === block.id ? block : b)
|
|
339
|
+
);
|
|
359
340
|
setEditing(null);
|
|
360
341
|
}
|
|
361
342
|
}
|