@malloy-publisher/sdk 0.9.2 → 0.9.3
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/{RenderedResult-CBLHr32C.es.js → RenderedResult-DwB0-9Yx.es.js} +118 -119
- package/dist/{RenderedResult-B48wAjM8.cjs.js → RenderedResult-hKjFEqaN.cjs.js} +2 -2
- package/dist/{ServerProvider-DCV8BUWD.es.js → ServerProvider-CcSrGaRN.es.js} +1281 -1142
- package/dist/ServerProvider-Gbf1YPOP.cjs.js +1 -0
- package/dist/builder/index.cjs.js +112 -115
- package/dist/builder/index.es.js +11766 -11502
- package/dist/builder-entry.d.ts +1 -1
- package/dist/client/api.d.ts +170 -9
- package/dist/client/index.cjs.js +1 -1
- package/dist/client/index.es.js +93 -89
- package/dist/client-entry.d.ts +2 -0
- package/dist/components/ApiErrorDisplay.d.ts +11 -0
- package/dist/components/AppDialog.d.ts +6 -6
- package/dist/components/Dashboard/DashboardGrid.d.ts +18 -3
- package/dist/components/Dashboard/DashboardTile.d.ts +12 -2
- package/dist/components/Dashboard/DashboardView.d.ts +38 -3
- package/dist/components/Dashboard/TileCard.d.ts +16 -2
- package/dist/components/Dashboard/dropValueUrlTags.d.ts +6 -0
- package/dist/components/Dashboard/index.d.ts +3 -2
- package/dist/components/Dashboard/telemetry.d.ts +2 -1
- package/dist/components/Dashboard/textSource.d.ts +19 -0
- package/dist/components/DashboardBuilder/AddTileDialog.d.ts +7 -8
- package/dist/components/DashboardBuilder/BuilderDialogs.d.ts +25 -0
- package/dist/components/DashboardBuilder/BuilderGrid.d.ts +31 -0
- package/dist/components/DashboardBuilder/BuilderHeader.d.ts +17 -0
- package/dist/components/DashboardBuilder/BuilderToolbar.d.ts +14 -17
- package/dist/components/DashboardBuilder/ChartPicker.d.ts +3 -1
- package/dist/components/DashboardBuilder/DashboardBuilder.d.ts +15 -7
- package/dist/components/DashboardBuilder/DashboardEditor.d.ts +28 -2
- package/dist/components/DashboardBuilder/EditorSurface.d.ts +33 -0
- package/dist/components/DashboardBuilder/FilterStrip.d.ts +6 -4
- package/dist/components/DashboardBuilder/InlineText.d.ts +1 -1
- package/dist/components/DashboardBuilder/NotebookEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/TextTileBody.d.ts +4 -1
- package/dist/components/DashboardBuilder/TileFrame.d.ts +43 -6
- package/dist/components/DashboardBuilder/TileMenu.d.ts +6 -8
- package/dist/components/DashboardBuilder/builderReport.d.ts +13 -0
- package/dist/components/DashboardBuilder/catalog.d.ts +0 -18
- package/dist/components/DashboardBuilder/documentSession.d.ts +2 -2
- package/dist/components/DashboardBuilder/imports.d.ts +19 -0
- package/dist/components/DashboardBuilder/inlineEdit.d.ts +18 -0
- package/dist/components/DashboardBuilder/readDocument.d.ts +3 -1
- package/dist/components/DashboardBuilder/readForEditor.d.ts +1 -1
- package/dist/components/DashboardBuilder/sortable.d.ts +2 -0
- package/dist/components/DashboardBuilder/spliceDocument.d.ts +2 -0
- package/dist/components/DashboardBuilder/testing/resize.d.ts +7 -0
- package/dist/components/DashboardBuilder/tileDisplayTitle.d.ts +7 -0
- package/dist/components/DashboardBuilder/useBuilderSelection.d.ts +53 -0
- package/dist/components/DashboardBuilder/useBuilderSession.d.ts +4 -7
- package/dist/components/DashboardBuilder/useControlBindings.d.ts +30 -0
- package/dist/components/DashboardBuilder/useConversionConfirm.d.ts +20 -0
- package/dist/components/DashboardBuilder/useDashboardEditor.d.ts +2 -0
- package/dist/components/DashboardBuilder/useDraft.d.ts +3 -1
- package/dist/components/DashboardBuilder/useHostCopy.d.ts +26 -0
- package/dist/components/DashboardBuilder/useOpenDraftCommit.d.ts +17 -0
- package/dist/components/DashboardBuilder/useOpenedDocument.d.ts +71 -0
- package/dist/components/DashboardBuilder/useSaveChannel.d.ts +50 -0
- package/dist/components/DashboardBuilder/useTileEditing.d.ts +33 -0
- package/dist/components/DashboardBuilder/useTileResize.d.ts +32 -0
- package/dist/components/Loading.d.ts +13 -0
- package/dist/components/Notebook/NotebookCell.d.ts +1 -5
- package/dist/components/Package/Package.d.ts +16 -1
- package/dist/components/Package/index.d.ts +1 -1
- package/dist/components/Prose.d.ts +1 -1
- package/dist/components/RenderedResult/loadRenderer.d.ts +7 -0
- package/dist/components/given/paramCodec.d.ts +8 -1
- package/dist/components/index.d.ts +1 -2
- package/dist/components/styles.d.ts +4 -4
- package/dist/hooks/givenValue.d.ts +6 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/useCompiledDocument.d.ts +23 -0
- package/dist/hooks/useDocumentControls.d.ts +6 -1
- package/dist/hooks/useNearViewport.d.ts +16 -0
- package/dist/hooks/useQueryWithApiError.d.ts +7 -2
- package/dist/hooks/useSuggestOptions.d.ts +9 -2
- package/dist/index.cjs.js +14 -14
- package/dist/index.es.js +9760 -10363
- package/dist/text/index.es.js +1 -1
- package/dist/{text-entry-CbbBcZl8.es.js → text-entry-CA0LZ1xL.es.js} +8 -8
- package/dist/text-entry.d.ts +1 -1
- package/dist/theme/accent.d.ts +29 -0
- package/dist/theme/buildVegaThemeOverride.d.ts +3 -3
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/keys.d.ts +1 -1
- package/dist/theme/motion.d.ts +31 -0
- package/dist/theme/readChartAnnotations.d.ts +1 -1
- package/dist/theme/resolveTheme.d.ts +4 -4
- package/dist/theme/types.d.ts +33 -5
- package/dist/{DashboardTile-BFcxdv7R.es.js → useCompiledDocument-BU6d8FPp.es.js} +6978 -6289
- package/dist/useCompiledDocument-pOg2W-Yt.cjs.js +142 -0
- package/package.json +11 -11
- package/src/builder-entry.ts +1 -0
- package/src/client-entry.ts +8 -0
- package/src/clientEntry.spec.ts +17 -0
- package/src/components/ApiErrorDisplay.tsx +37 -18
- package/src/components/AppDialog.tsx +8 -7
- package/src/components/Dashboard/Dashboard.spec.tsx +3 -32
- package/src/components/Dashboard/Dashboard.tsx +2 -2
- package/src/components/Dashboard/DashboardGrid.tsx +23 -5
- package/src/components/Dashboard/DashboardTile.spec.tsx +97 -2
- package/src/components/Dashboard/DashboardTile.tsx +95 -31
- package/src/components/Dashboard/DashboardView.spec.tsx +156 -0
- package/src/components/Dashboard/DashboardView.tsx +165 -89
- package/src/components/Dashboard/RowsDialog.tsx +3 -2
- package/src/components/Dashboard/TileCard.tsx +17 -2
- package/src/components/Dashboard/dropValueUrlTags.spec.ts +177 -0
- package/src/components/Dashboard/dropValueUrlTags.ts +108 -0
- package/src/components/Dashboard/index.ts +11 -2
- package/src/components/Dashboard/telemetry.ts +2 -1
- package/src/components/Dashboard/textSource.spec.ts +36 -0
- package/src/components/Dashboard/textSource.ts +39 -0
- package/src/components/DashboardBuilder/AddTileDialog.tsx +16 -56
- package/src/components/DashboardBuilder/BuilderDialogs.tsx +162 -0
- package/src/components/DashboardBuilder/BuilderGrid.tsx +245 -0
- package/src/components/DashboardBuilder/BuilderHeader.tsx +107 -0
- package/src/components/DashboardBuilder/BuilderToolbar.tsx +86 -113
- package/src/components/DashboardBuilder/ChartPicker.tsx +4 -1
- package/src/components/DashboardBuilder/DashboardBuilder.charts.spec.tsx +5 -5
- package/src/components/DashboardBuilder/DashboardBuilder.exit.spec.tsx +74 -83
- package/src/components/DashboardBuilder/DashboardBuilder.inline.spec.tsx +62 -18
- package/src/components/DashboardBuilder/DashboardBuilder.notebook.spec.tsx +55 -108
- package/src/components/DashboardBuilder/DashboardBuilder.openDraft.spec.tsx +10 -62
- package/src/components/DashboardBuilder/DashboardBuilder.sources.spec.tsx +50 -57
- package/src/components/DashboardBuilder/DashboardBuilder.spec.tsx +53 -40
- package/src/components/DashboardBuilder/DashboardBuilder.textTiles.spec.tsx +10 -8
- package/src/components/DashboardBuilder/DashboardBuilder.tsx +227 -704
- package/src/components/DashboardBuilder/DashboardEditor.authoritative.spec.tsx +32 -52
- package/src/components/DashboardBuilder/DashboardEditor.emptyStart.spec.tsx +1 -50
- package/src/components/DashboardBuilder/DashboardEditor.notebook.spec.tsx +12 -18
- package/src/components/DashboardBuilder/DashboardEditor.package.spec.tsx +4 -24
- package/src/components/DashboardBuilder/DashboardEditor.resourceUri.spec.tsx +4 -4
- package/src/components/DashboardBuilder/DashboardEditor.spec.tsx +8 -13
- package/src/components/DashboardBuilder/DashboardEditor.textSource.spec.tsx +317 -0
- package/src/components/DashboardBuilder/DashboardEditor.tsx +142 -820
- package/src/components/DashboardBuilder/DrillDialog.tsx +2 -2
- package/src/components/DashboardBuilder/EditorSurface.tsx +471 -0
- package/src/components/DashboardBuilder/FilterDialog.tsx +13 -8
- package/src/components/DashboardBuilder/FilterStrip.tsx +117 -79
- package/src/components/DashboardBuilder/InlineMarkdown.tsx +7 -9
- package/src/components/DashboardBuilder/InlineText.tsx +23 -17
- package/src/components/DashboardBuilder/NotebookEditor.tsx +3 -3
- package/src/components/DashboardBuilder/TextTileBody.tsx +5 -2
- package/src/components/DashboardBuilder/TileFrame.tsx +255 -90
- package/src/components/DashboardBuilder/TileMenu.tsx +41 -91
- package/src/components/DashboardBuilder/artifactBlock.spec.ts +1 -1
- package/src/components/DashboardBuilder/artifactTagParity.spec.ts +9 -4
- package/src/components/DashboardBuilder/builderReport.ts +74 -0
- package/src/components/DashboardBuilder/catalog.spec.ts +0 -44
- package/src/components/DashboardBuilder/catalog.ts +0 -36
- package/src/components/DashboardBuilder/controls.spec.ts +1 -1
- package/src/components/DashboardBuilder/controls.ts +1 -1
- package/src/components/DashboardBuilder/documentSession.ts +3 -2
- package/src/components/DashboardBuilder/imports.spec.ts +61 -0
- package/src/components/DashboardBuilder/imports.ts +93 -0
- package/src/components/DashboardBuilder/inlineEdit.tsx +78 -0
- package/src/components/DashboardBuilder/legacyNotebook.ts +1 -1
- package/src/components/DashboardBuilder/malloyTree.ts +5 -1
- package/src/components/DashboardBuilder/newDashboard.ts +1 -1
- package/src/components/DashboardBuilder/preview.ts +1 -1
- package/src/components/DashboardBuilder/readDocument.spec.ts +36 -0
- package/src/components/DashboardBuilder/readDocument.ts +10 -4
- package/src/components/DashboardBuilder/readForEditor.ts +7 -2
- package/src/components/DashboardBuilder/sortable.spec.ts +25 -1
- package/src/components/DashboardBuilder/sortable.tsx +11 -0
- package/src/components/DashboardBuilder/spliceDocument.ts +8 -3
- package/src/components/DashboardBuilder/testing/artifactTagParity.json +62 -6
- package/src/components/DashboardBuilder/testing/documentKindRule.json +40 -0
- package/src/components/DashboardBuilder/testing/inline.ts +1 -1
- package/src/components/DashboardBuilder/testing/resize.ts +48 -0
- package/src/components/DashboardBuilder/testing/urlRenderTags.json +62 -0
- package/src/components/DashboardBuilder/textTiles.spec.ts +43 -1
- package/src/components/DashboardBuilder/tileDisplayTitle.ts +13 -0
- package/src/components/DashboardBuilder/useBuilderSelection.ts +121 -0
- package/src/components/DashboardBuilder/useBuilderSession.spec.ts +0 -85
- package/src/components/DashboardBuilder/useBuilderSession.ts +6 -43
- package/src/components/DashboardBuilder/useBuilderShortcuts.overlay.spec.tsx +32 -0
- package/src/components/DashboardBuilder/useBuilderShortcuts.ts +11 -1
- package/src/components/DashboardBuilder/useControlBindings.ts +152 -0
- package/src/components/DashboardBuilder/useConversionConfirm.ts +55 -0
- package/src/components/DashboardBuilder/useDashboardEditor.ts +5 -2
- package/src/components/DashboardBuilder/useDraft.ts +15 -2
- package/src/components/DashboardBuilder/useHostCopy.ts +104 -0
- package/src/components/DashboardBuilder/useOpenDraftCommit.ts +47 -0
- package/src/components/DashboardBuilder/useOpenedDocument.ts +314 -0
- package/src/components/DashboardBuilder/useSaveChannel.ts +275 -0
- package/src/components/DashboardBuilder/useTileEditing.ts +141 -0
- package/src/components/DashboardBuilder/useTileResize.spec.tsx +146 -0
- package/src/components/DashboardBuilder/useTileResize.ts +133 -0
- package/src/components/DataAppViewer/DataAppViewer.tsx +7 -4
- package/src/components/DocumentCreate/guards.ts +1 -1
- package/src/components/Environment/Environment.tsx +0 -10
- package/src/components/Loading.tsx +14 -0
- package/src/components/Model/Model.tsx +16 -9
- package/src/components/Model/ModelExplorer.tsx +2 -2
- package/src/components/Notebook/Notebook.tsx +6 -2
- package/src/components/Notebook/NotebookCell.tsx +90 -215
- package/src/components/Package/Package.artifacts.spec.tsx +8 -12
- package/src/components/Package/Package.create.spec.tsx +22 -1
- package/src/components/Package/Package.tsx +51 -27
- package/src/components/Package/index.ts +1 -1
- package/src/components/Prose.spec.tsx +37 -0
- package/src/components/Prose.tsx +35 -5
- package/src/components/RenderedResult/RenderedResult.tsx +5 -7
- package/src/components/RenderedResult/ResultContainer.tsx +7 -2
- package/src/components/RenderedResult/ResultPanel.tsx +20 -5
- package/src/components/RenderedResult/loadRenderer.ts +42 -0
- package/src/components/given/GivenInput.spec.tsx +5 -5
- package/src/components/given/GivenInput.tsx +46 -38
- package/src/components/given/GivensPanel.tsx +2 -8
- package/src/components/given/paramCodec.ts +27 -1
- package/src/components/index.ts +1 -2
- package/src/components/styles.ts +4 -5
- package/src/hooks/givenValue.ts +9 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCompiledDocument.spec.tsx +86 -0
- package/src/hooks/useCompiledDocument.ts +59 -0
- package/src/hooks/useDimensionalFilterRangeData.ts +3 -1
- package/src/hooks/useDocumentControls.ts +13 -1
- package/src/hooks/useNearViewport.spec.tsx +150 -0
- package/src/hooks/useNearViewport.ts +102 -0
- package/src/hooks/useQueryResult.ts +7 -1
- package/src/hooks/useQueryWithApiError.ts +10 -3
- package/src/hooks/useRawQueryData.ts +3 -1
- package/src/hooks/useSuggestOptions.dom.spec.ts +40 -1
- package/src/hooks/useSuggestOptions.ts +42 -10
- package/src/text-entry.ts +1 -1
- package/src/textEntry.spec.ts +2 -8
- package/src/theme/accent.spec.ts +116 -0
- package/src/theme/accent.ts +148 -0
- package/src/theme/buildTableCssVars.spec.ts +24 -0
- package/src/theme/buildTableCssVars.ts +1 -2
- package/src/theme/buildVegaThemeOverride.spec.ts +38 -2
- package/src/theme/buildVegaThemeOverride.ts +5 -5
- package/src/theme/defaults.ts +34 -0
- package/src/theme/index.ts +9 -0
- package/src/theme/keys.ts +6 -0
- package/src/theme/motion.ts +44 -0
- package/src/theme/readChartAnnotations.spec.ts +18 -0
- package/src/theme/readChartAnnotations.ts +1 -1
- package/src/theme/resolveTheme.spec.ts +73 -0
- package/src/theme/resolveTheme.ts +61 -20
- package/src/theme/types.ts +30 -5
- package/src/utils/queryClient.ts +8 -0
- package/dist/DashboardTile-sg8LjUk8.cjs.js +0 -137
- package/dist/ServerProvider-HRqT3w1C.cjs.js +0 -1
- package/dist/components/Dashboard/DashboardBar.d.ts +0 -21
- package/dist/components/Dashboard/ExploreDialog.d.ts +0 -20
- package/dist/components/DashboardBuilder/DiffDialog.d.ts +0 -7
- package/dist/components/DashboardBuilder/SaveNotice.d.ts +0 -27
- package/dist/components/DashboardBuilder/SettingsPopover.d.ts +0 -32
- package/dist/components/DashboardBuilder/diff.d.ts +0 -35
- package/src/components/Dashboard/DashboardBar.tsx +0 -88
- package/src/components/Dashboard/ExploreDialog.tsx +0 -89
- package/src/components/DashboardBuilder/DashboardBuilder.notice.spec.tsx +0 -194
- package/src/components/DashboardBuilder/DiffDialog.spec.tsx +0 -25
- package/src/components/DashboardBuilder/DiffDialog.tsx +0 -103
- package/src/components/DashboardBuilder/SaveNotice.tsx +0 -113
- package/src/components/DashboardBuilder/SettingsPopover.spec.tsx +0 -87
- package/src/components/DashboardBuilder/SettingsPopover.tsx +0 -326
- package/src/components/DashboardBuilder/diff.spec.ts +0 -44
- package/src/components/DashboardBuilder/diff.ts +0 -93
- /package/dist/{components/DashboardBuilder → utils}/malloyText.d.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.spec.ts +0 -0
- /package/src/{components/DashboardBuilder → utils}/malloyText.ts +0 -0
|
@@ -2,17 +2,25 @@
|
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
|
|
4
4
|
import AddIcon from "@mui/icons-material/Add";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import type {
|
|
5
|
+
import { Box, IconButton, SvgIcon, Typography } from "@mui/material";
|
|
6
|
+
import type { PointerEvent, ReactNode } from "react";
|
|
7
|
+
import type { Theme } from "@mui/material";
|
|
8
|
+
import type { SystemStyleObject } from "@mui/system";
|
|
9
|
+
import { MOTION_FAST, reducedMotionSx } from "../../theme/motion";
|
|
9
10
|
import { usePublisherTheme } from "../../theme/ThemeContext";
|
|
10
|
-
import {
|
|
11
|
+
import type { ResolvedTheme } from "../../theme/types";
|
|
12
|
+
import {
|
|
13
|
+
BARE_RING_OFFSET_PX,
|
|
14
|
+
GRID_GAP_PX,
|
|
15
|
+
NOTEBOOK_GAP_PX,
|
|
16
|
+
} from "../Dashboard/DashboardGrid";
|
|
11
17
|
import {
|
|
12
18
|
TileCard,
|
|
13
19
|
TileHeading,
|
|
20
|
+
type TileChrome,
|
|
14
21
|
type TileHeadingSlots,
|
|
15
22
|
} from "../Dashboard/TileCard";
|
|
23
|
+
import { tileDisplayTitle } from "./tileDisplayTitle";
|
|
16
24
|
import {
|
|
17
25
|
tileKey,
|
|
18
26
|
tileLabel,
|
|
@@ -20,11 +28,11 @@ import {
|
|
|
20
28
|
type QueryTile,
|
|
21
29
|
} from "./document";
|
|
22
30
|
import { gapId } from "./layout";
|
|
23
|
-
import { GapDroppable, TileSortable } from "./sortable";
|
|
31
|
+
import { GapDroppable, NO_DRAG, TileSortable } from "./sortable";
|
|
24
32
|
|
|
25
33
|
/**
|
|
26
|
-
* Everything the builder draws AROUND a tile: the selection outline, the
|
|
27
|
-
* the
|
|
34
|
+
* Everything the builder draws AROUND a tile: the selection outline, the menu
|
|
35
|
+
* button, the handle at the right edge and, in a notebook, the insert button. The tile
|
|
28
36
|
* itself is `children` — the host's real `DashboardTile`, or a placeholder
|
|
29
37
|
* saying what the tile will run.
|
|
30
38
|
*/
|
|
@@ -34,9 +42,15 @@ export function TileFrame({
|
|
|
34
42
|
selected,
|
|
35
43
|
flash = false,
|
|
36
44
|
menuOpen,
|
|
45
|
+
bare = false,
|
|
37
46
|
onInsertAfter,
|
|
38
47
|
onSelect,
|
|
39
48
|
onOpenMenu,
|
|
49
|
+
resizing = false,
|
|
50
|
+
width,
|
|
51
|
+
onResizeStart,
|
|
52
|
+
onResizeMove,
|
|
53
|
+
onResizeEnd,
|
|
40
54
|
children,
|
|
41
55
|
}: {
|
|
42
56
|
tile: DashboardTile;
|
|
@@ -46,16 +60,34 @@ export function TileFrame({
|
|
|
46
60
|
flash?: boolean;
|
|
47
61
|
/** Whether this tile's menu is open, which keeps its button showing. */
|
|
48
62
|
menuOpen: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* The tile has no card (a notebook's): its ring is drawn clear of the
|
|
65
|
+
* content and its menu sits on the ring's top edge, so neither touches the
|
|
66
|
+
* text, and the tile reads where the reader draws it.
|
|
67
|
+
*/
|
|
68
|
+
bare?: boolean;
|
|
49
69
|
/** Offers a "+" on the bottom edge that adds a tile after this one; set where tiles stack in one column. */
|
|
50
70
|
onInsertAfter?: () => void;
|
|
51
71
|
onSelect: () => void;
|
|
52
72
|
onOpenMenu: (anchor: HTMLElement) => void;
|
|
73
|
+
/** This tile's edge is being dragged. */
|
|
74
|
+
resizing?: boolean;
|
|
75
|
+
/** Dragging the right edge sets the width; absent, the tile has no edge handle (one column, or tags the file does not own). */
|
|
76
|
+
onResizeStart?: (event: PointerEvent<HTMLDivElement>) => void;
|
|
77
|
+
onResizeMove?: (event: PointerEvent<HTMLDivElement>) => void;
|
|
78
|
+
onResizeEnd?: (event: PointerEvent<HTMLDivElement>) => void;
|
|
79
|
+
/** The tile's width and the grid's, and a step of one column: the edge's keyboard route. */
|
|
80
|
+
width?: {
|
|
81
|
+
span: number;
|
|
82
|
+
columns: number;
|
|
83
|
+
onStep: (to: number) => void;
|
|
84
|
+
};
|
|
53
85
|
children: ReactNode;
|
|
54
86
|
}) {
|
|
55
87
|
const { theme } = usePublisherTheme();
|
|
56
88
|
return (
|
|
57
89
|
<TileSortable id={tileKey(tile)} index={index}>
|
|
58
|
-
{({ ref, handleRef
|
|
90
|
+
{({ ref, handleRef }) => (
|
|
59
91
|
<Box
|
|
60
92
|
ref={ref}
|
|
61
93
|
onClick={onSelect}
|
|
@@ -65,12 +97,18 @@ export function TileFrame({
|
|
|
65
97
|
onPointerDown={(event) => {
|
|
66
98
|
if (event.button === 0) onSelect();
|
|
67
99
|
}}
|
|
100
|
+
// A named group, so the name is announced: a label on a plain
|
|
101
|
+
// element is not.
|
|
102
|
+
role="group"
|
|
68
103
|
aria-label={`Tile ${tile.name}`}
|
|
69
104
|
aria-current={selected}
|
|
105
|
+
// Keyboard focus anywhere in the tile selects it, as a press
|
|
106
|
+
// does, so the arrow-key nudge and the menu follow the keyboard.
|
|
107
|
+
onFocus={onSelect}
|
|
70
108
|
data-tile-key={tileKey(tile)}
|
|
71
109
|
data-flash={flash || undefined}
|
|
72
110
|
sx={{
|
|
73
|
-
// Anchors the
|
|
111
|
+
// Anchors the menu, edge and insert buttons to
|
|
74
112
|
// this tile.
|
|
75
113
|
position: "relative",
|
|
76
114
|
// Same again: this wrapper sits BETWEEN
|
|
@@ -90,24 +128,8 @@ export function TileFrame({
|
|
|
90
128
|
// a scrollbar — still wins over its own
|
|
91
129
|
// pixels.
|
|
92
130
|
cursor: "grab",
|
|
93
|
-
|
|
94
|
-
//
|
|
95
|
-
// outside the tile rather than on it: the
|
|
96
|
-
// tile already has an edge of its own, and
|
|
97
|
-
// an outline neither doubles that edge nor
|
|
98
|
-
// takes up space, so selecting a tile
|
|
99
|
-
// cannot shift the layout being arranged.
|
|
100
|
-
outline: selected
|
|
101
|
-
? `2px solid ${theme.drillLink}`
|
|
102
|
-
: `2px solid transparent`,
|
|
103
|
-
outlineOffset: 2,
|
|
104
|
-
...(flash && {
|
|
105
|
-
outlineColor: theme.drillLink,
|
|
106
|
-
boxShadow: `0 0 0 6px color-mix(in srgb, ${theme.drillLink} 25%, transparent)`,
|
|
107
|
-
}),
|
|
108
|
-
transition:
|
|
109
|
-
"outline-color 120ms, opacity 120ms, box-shadow 120ms",
|
|
110
|
-
// The handles, grip and menu are invisible
|
|
131
|
+
...selectionSx(theme, { selected, flash, bare }),
|
|
132
|
+
// The edge handle and menu are invisible
|
|
111
133
|
// until wanted, and wanted is: the pointer
|
|
112
134
|
// over the tile, or the tile selected. A
|
|
113
135
|
// hover rule on the WRAPPER, so all three
|
|
@@ -129,70 +151,41 @@ export function TileFrame({
|
|
|
129
151
|
"&&[data-dnd-dragging]": {
|
|
130
152
|
opacity: 1,
|
|
131
153
|
outline: "none",
|
|
132
|
-
boxShadow:
|
|
154
|
+
boxShadow: theme.shadow.drag,
|
|
133
155
|
},
|
|
134
156
|
"&&[data-dnd-placeholder]": {
|
|
135
157
|
opacity: 0.45,
|
|
136
|
-
outline: `2px dashed ${theme.
|
|
158
|
+
outline: `2px dashed ${theme.accent}`,
|
|
137
159
|
boxShadow: "none",
|
|
138
160
|
},
|
|
139
161
|
"&:hover .builder-affordance, &:focus-within .builder-affordance":
|
|
140
162
|
{ opacity: 1 },
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
// from the ones that will not.
|
|
145
|
-
"&:hover": {
|
|
146
|
-
outlineColor: selected
|
|
147
|
-
? theme.drillLink
|
|
148
|
-
: theme.cardBorder,
|
|
149
|
-
boxShadow: "0 2px 10px rgba(0, 0, 0, 0.10)",
|
|
163
|
+
// No hover on a touch screen: the affordances stand.
|
|
164
|
+
"@media (hover: none)": {
|
|
165
|
+
"& .builder-affordance": { opacity: 1 },
|
|
150
166
|
},
|
|
151
167
|
}}
|
|
152
168
|
>
|
|
153
169
|
{children}
|
|
154
170
|
|
|
155
|
-
{/* The
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
is the sign of it and the library's HANDLE,
|
|
160
|
-
where keyboard focus and the screen-reader
|
|
161
|
-
instructions land: Space picks the tile up,
|
|
162
|
-
the arrows move it, Escape puts it back. */}
|
|
171
|
+
{/* The library's HANDLE, where keyboard focus and the
|
|
172
|
+
screen-reader instructions land: Space picks the tile up, the
|
|
173
|
+
arrows move it, Escape puts it back. Visually hidden: a pointer
|
|
174
|
+
drags the whole card, and the open hand over it says so. */}
|
|
163
175
|
<Box
|
|
164
176
|
ref={handleRef}
|
|
165
|
-
className="builder-affordance"
|
|
166
177
|
aria-label={`Move ${tileLabel(tile)}`}
|
|
167
178
|
sx={{
|
|
168
179
|
position: "absolute",
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
height: "22px",
|
|
175
|
-
borderRadius: "4px",
|
|
176
|
-
cursor: "grab",
|
|
177
|
-
touchAction: "none",
|
|
178
|
-
zIndex: 2,
|
|
179
|
-
color: theme.tileTitle,
|
|
180
|
-
bgcolor: theme.tile,
|
|
181
|
-
opacity: isDragSource || selected ? 0.9 : 0,
|
|
182
|
-
transition: "opacity 120ms",
|
|
183
|
-
"&:hover": { opacity: 1 },
|
|
184
|
-
"&:active": { cursor: "grabbing" },
|
|
185
|
-
"&:focus-visible": {
|
|
186
|
-
opacity: 1,
|
|
187
|
-
outline: `2px solid ${theme.drillLink}`,
|
|
188
|
-
outlineOffset: 1,
|
|
189
|
-
},
|
|
180
|
+
width: "1px",
|
|
181
|
+
height: "1px",
|
|
182
|
+
overflow: "hidden",
|
|
183
|
+
clipPath: "inset(50%)",
|
|
184
|
+
whiteSpace: "nowrap",
|
|
190
185
|
}}
|
|
191
|
-
|
|
192
|
-
<DragIndicatorIcon sx={{ fontSize: 16 }} />
|
|
193
|
-
</Box>
|
|
186
|
+
/>
|
|
194
187
|
|
|
195
|
-
{/* The tile's menu: its chart
|
|
188
|
+
{/* The tile's menu: its chart and drill-through.
|
|
196
189
|
A press here is never the start of a drag: the
|
|
197
190
|
sensor refuses to activate from a button. */}
|
|
198
191
|
<IconButton
|
|
@@ -205,24 +198,113 @@ export function TileFrame({
|
|
|
205
198
|
}}
|
|
206
199
|
sx={{
|
|
207
200
|
position: "absolute",
|
|
208
|
-
top
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
201
|
+
// A tab on the tile's top edge, the same on a card and
|
|
202
|
+
// on bare content: centred on the card's border, or on
|
|
203
|
+
// a bare tile's ring, so it never covers the tile's title
|
|
204
|
+
// or text.
|
|
205
|
+
top: `${-((bare ? BARE_RING_OFFSET_PX + 1 : 0) + 12)}px`,
|
|
206
|
+
right: bare ? 0 : "12px",
|
|
207
|
+
border: theme.cardBorder,
|
|
208
|
+
borderRadius: 1,
|
|
209
|
+
// A 24px hit target at least, whatever the glyph.
|
|
210
|
+
width: 28,
|
|
211
|
+
height: 24,
|
|
212
212
|
zIndex: 2,
|
|
213
213
|
color: theme.tileTitle,
|
|
214
214
|
bgcolor: theme.tile,
|
|
215
215
|
opacity: selected || menuOpen ? 0.9 : 0,
|
|
216
|
-
transition:
|
|
216
|
+
transition: `opacity ${MOTION_FAST}`,
|
|
217
|
+
...reducedMotionSx,
|
|
217
218
|
"&:hover": {
|
|
218
219
|
opacity: 1,
|
|
219
220
|
bgcolor: theme.tile,
|
|
220
221
|
},
|
|
221
222
|
}}
|
|
222
223
|
>
|
|
223
|
-
<
|
|
224
|
+
<SpreadDotsIcon />
|
|
224
225
|
</IconButton>
|
|
225
226
|
|
|
227
|
+
{/* The right edge, which sets the width: dragged, or focused and
|
|
228
|
+
stepped with the arrow keys a column at a time (Home and End go
|
|
229
|
+
to one column and the full grid). Marked so the move sensor
|
|
230
|
+
never takes a press on it. */}
|
|
231
|
+
{onResizeStart && (
|
|
232
|
+
<Box
|
|
233
|
+
className="builder-affordance"
|
|
234
|
+
{...{ [NO_DRAG]: "" }}
|
|
235
|
+
role="separator"
|
|
236
|
+
tabIndex={width ? 0 : -1}
|
|
237
|
+
aria-orientation="vertical"
|
|
238
|
+
aria-label={`Width of ${tileLabel(tile)}`}
|
|
239
|
+
{...(width
|
|
240
|
+
? {
|
|
241
|
+
"aria-valuenow": width.span,
|
|
242
|
+
"aria-valuemin": 1,
|
|
243
|
+
"aria-valuemax": width.columns,
|
|
244
|
+
"aria-valuetext": `${width.span} of ${width.columns} columns`,
|
|
245
|
+
}
|
|
246
|
+
: {})}
|
|
247
|
+
onKeyDown={(event) => {
|
|
248
|
+
if (!width) return;
|
|
249
|
+
const to =
|
|
250
|
+
event.key === "ArrowRight"
|
|
251
|
+
? width.span + 1
|
|
252
|
+
: event.key === "ArrowLeft"
|
|
253
|
+
? width.span - 1
|
|
254
|
+
: event.key === "Home"
|
|
255
|
+
? 1
|
|
256
|
+
: event.key === "End"
|
|
257
|
+
? width.columns
|
|
258
|
+
: undefined;
|
|
259
|
+
if (to === undefined) return;
|
|
260
|
+
// The builder's own arrow-key nudge must not step it again.
|
|
261
|
+
event.preventDefault();
|
|
262
|
+
event.stopPropagation();
|
|
263
|
+
width.onStep(Math.min(Math.max(to, 1), width.columns));
|
|
264
|
+
}}
|
|
265
|
+
onPointerDown={onResizeStart}
|
|
266
|
+
onPointerMove={onResizeMove}
|
|
267
|
+
onPointerUp={onResizeEnd}
|
|
268
|
+
onPointerCancel={onResizeEnd}
|
|
269
|
+
onClick={(event) => event.stopPropagation()}
|
|
270
|
+
sx={{
|
|
271
|
+
position: "absolute",
|
|
272
|
+
top: 0,
|
|
273
|
+
bottom: 0,
|
|
274
|
+
// Straddles the edge, so the target is a usable width
|
|
275
|
+
// without eating into the tile's content.
|
|
276
|
+
right: "-5px",
|
|
277
|
+
width: "10px",
|
|
278
|
+
cursor: "col-resize",
|
|
279
|
+
touchAction: "none",
|
|
280
|
+
zIndex: 2,
|
|
281
|
+
// Invisible until wanted: a rule down every tile edge
|
|
282
|
+
// would read as a table.
|
|
283
|
+
opacity: resizing || selected ? 1 : 0,
|
|
284
|
+
transition: `opacity ${MOTION_FAST}`,
|
|
285
|
+
...reducedMotionSx,
|
|
286
|
+
"&:hover": { opacity: 1 },
|
|
287
|
+
"&:focus-visible": {
|
|
288
|
+
opacity: 1,
|
|
289
|
+
outline: `2px solid ${theme.accent}`,
|
|
290
|
+
outlineOffset: 1,
|
|
291
|
+
borderRadius: "3px",
|
|
292
|
+
},
|
|
293
|
+
"&::after": {
|
|
294
|
+
content: '""',
|
|
295
|
+
position: "absolute",
|
|
296
|
+
top: "50%",
|
|
297
|
+
left: "50%",
|
|
298
|
+
transform: "translate(-50%, -50%)",
|
|
299
|
+
width: "4px",
|
|
300
|
+
height: "28px",
|
|
301
|
+
borderRadius: "2px",
|
|
302
|
+
bgcolor: theme.accent,
|
|
303
|
+
},
|
|
304
|
+
}}
|
|
305
|
+
/>
|
|
306
|
+
)}
|
|
307
|
+
|
|
226
308
|
{onInsertAfter && (
|
|
227
309
|
<IconButton
|
|
228
310
|
className="builder-affordance"
|
|
@@ -234,17 +316,21 @@ export function TileFrame({
|
|
|
234
316
|
}}
|
|
235
317
|
sx={{
|
|
236
318
|
position: "absolute",
|
|
237
|
-
|
|
319
|
+
// Centred in the gap below the tile, not on its edge: on
|
|
320
|
+
// a one-line notebook text tile, an edge-centred button
|
|
321
|
+
// covered the middle of the text it sits under.
|
|
322
|
+
bottom: `-${(bare ? NOTEBOOK_GAP_PX : GRID_GAP_PX) / 2 + 12}px`,
|
|
238
323
|
left: "50%",
|
|
239
324
|
transform: "translateX(-50%)",
|
|
240
|
-
width:
|
|
241
|
-
height:
|
|
325
|
+
width: 24,
|
|
326
|
+
height: 24,
|
|
242
327
|
zIndex: 3,
|
|
243
328
|
color: theme.tileTitle,
|
|
244
329
|
bgcolor: theme.tile,
|
|
245
330
|
border: theme.cardBorder,
|
|
246
331
|
opacity: 0,
|
|
247
|
-
transition:
|
|
332
|
+
transition: `opacity ${MOTION_FAST}`,
|
|
333
|
+
...reducedMotionSx,
|
|
248
334
|
"&:hover, &:focus-visible": {
|
|
249
335
|
opacity: 1,
|
|
250
336
|
bgcolor: theme.tile,
|
|
@@ -260,6 +346,67 @@ export function TileFrame({
|
|
|
260
346
|
);
|
|
261
347
|
}
|
|
262
348
|
|
|
349
|
+
/** How far the selection ring stands outside what it selects: its 2px offset plus its 2px width. */
|
|
350
|
+
export const SELECTION_RING_PX = 4;
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* The builder's selection look, for anything a person can select — a tile,
|
|
354
|
+
* the description: an outline outside the element (so selecting moves no
|
|
355
|
+
* layout), solid in the accent when selected, lifting on hover the way a card
|
|
356
|
+
* does in any builder's edit mode, and a brief halo when an undo or redo just
|
|
357
|
+
* changed it. One definition, so the description selects exactly as a tile.
|
|
358
|
+
*/
|
|
359
|
+
export const selectionSx = (
|
|
360
|
+
theme: ResolvedTheme,
|
|
361
|
+
{
|
|
362
|
+
selected,
|
|
363
|
+
flash = false,
|
|
364
|
+
bare = false,
|
|
365
|
+
}: { selected: boolean; flash?: boolean; bare?: boolean },
|
|
366
|
+
): SystemStyleObject<Theme> => {
|
|
367
|
+
const ring = selected || flash ? theme.accent : "transparent";
|
|
368
|
+
const hoverRing = selected
|
|
369
|
+
? theme.accent
|
|
370
|
+
: theme.cardBorder.replace(/^1px solid /, "");
|
|
371
|
+
const transition = `outline-color ${MOTION_FAST}, border-color ${MOTION_FAST}, opacity ${MOTION_FAST}, box-shadow ${MOTION_FAST}`;
|
|
372
|
+
if (bare)
|
|
373
|
+
// Bare content has no padding of its own, so the ring stands off it by
|
|
374
|
+
// the clear space a card's text has, without moving the text from where
|
|
375
|
+
// the reader draws it. Drawn as its own layer rather than an offset
|
|
376
|
+
// outline: an outline's corners grow by the offset, and the ring would
|
|
377
|
+
// read rounder than every card on the page. No lift: there is no
|
|
378
|
+
// surface to lift, only the ring.
|
|
379
|
+
return {
|
|
380
|
+
borderRadius: 1,
|
|
381
|
+
"&::before": {
|
|
382
|
+
content: '""',
|
|
383
|
+
position: "absolute",
|
|
384
|
+
inset: `${-BARE_RING_OFFSET_PX}px`,
|
|
385
|
+
borderRadius: 1,
|
|
386
|
+
border: `2px solid ${ring}`,
|
|
387
|
+
pointerEvents: "none",
|
|
388
|
+
transition,
|
|
389
|
+
...reducedMotionSx,
|
|
390
|
+
},
|
|
391
|
+
"&:hover::before": { borderColor: hoverRing },
|
|
392
|
+
};
|
|
393
|
+
// A card carries its own padding, so its ring hugs its edge.
|
|
394
|
+
return {
|
|
395
|
+
borderRadius: 1,
|
|
396
|
+
outline: `2px solid ${ring}`,
|
|
397
|
+
outlineOffset: 2,
|
|
398
|
+
...(flash && {
|
|
399
|
+
boxShadow: `0 0 0 6px color-mix(in srgb, ${theme.accent} 25%, transparent)`,
|
|
400
|
+
}),
|
|
401
|
+
transition,
|
|
402
|
+
...reducedMotionSx,
|
|
403
|
+
"&:hover": {
|
|
404
|
+
outlineColor: hoverRing,
|
|
405
|
+
boxShadow: theme.shadow.lift,
|
|
406
|
+
},
|
|
407
|
+
};
|
|
408
|
+
};
|
|
409
|
+
|
|
263
410
|
/**
|
|
264
411
|
* No host-supplied tile: say what this one will run, so the surface is still
|
|
265
412
|
* legible without a server.
|
|
@@ -268,17 +415,20 @@ export function TilePlaceholder({
|
|
|
268
415
|
tile,
|
|
269
416
|
heading,
|
|
270
417
|
note,
|
|
418
|
+
chrome = "card",
|
|
271
419
|
}: {
|
|
272
420
|
tile: QueryTile;
|
|
273
421
|
heading?: TileHeadingSlots;
|
|
274
422
|
/** Why there is no preview, in place of an empty body. */
|
|
275
423
|
note?: string;
|
|
424
|
+
/** The document's tile chrome, as the reader draws it. */
|
|
425
|
+
chrome?: TileChrome;
|
|
276
426
|
}) {
|
|
277
427
|
const { theme } = usePublisherTheme();
|
|
278
428
|
return (
|
|
279
|
-
<TileCard
|
|
429
|
+
<TileCard chrome={chrome}>
|
|
280
430
|
<TileHeading
|
|
281
|
-
title={heading?.title ?? tile
|
|
431
|
+
title={heading?.title ?? tileDisplayTitle(tile)}
|
|
282
432
|
subtitle={heading ? heading.subtitle : tile.subtitle}
|
|
283
433
|
/>
|
|
284
434
|
{note && (
|
|
@@ -308,17 +458,18 @@ export function GapTarget({ after }: { after: string }) {
|
|
|
308
458
|
sx={{
|
|
309
459
|
minHeight: 48,
|
|
310
460
|
borderRadius: 1,
|
|
311
|
-
border: `1px dashed ${theme.
|
|
461
|
+
border: `1px dashed ${theme.accent}`,
|
|
312
462
|
// Tinted with the same hue as the dashed edge, so the fill
|
|
313
463
|
// and the border read as one affordance lighting up. It was
|
|
314
464
|
// `theme.tile`, the CARD colour, which is the one value
|
|
315
465
|
// guaranteed to match whatever this sits on: a near-no-op
|
|
316
466
|
// before the card went white, and an exact one after.
|
|
317
467
|
bgcolor: isDropTarget
|
|
318
|
-
? `color-mix(in srgb, ${theme.
|
|
468
|
+
? `color-mix(in srgb, ${theme.accent} 12%, transparent)`
|
|
319
469
|
: "transparent",
|
|
320
470
|
opacity: isDropTarget ? 0.95 : 0.4,
|
|
321
|
-
transition:
|
|
471
|
+
transition: `opacity ${MOTION_FAST}, background-color ${MOTION_FAST}`,
|
|
472
|
+
...reducedMotionSx,
|
|
322
473
|
}}
|
|
323
474
|
/>
|
|
324
475
|
)}
|
|
@@ -349,10 +500,10 @@ export function GridGuides({ columns }: { columns: number }) {
|
|
|
349
500
|
<Box
|
|
350
501
|
key={column}
|
|
351
502
|
sx={{
|
|
352
|
-
borderLeft: `1px dashed ${theme.
|
|
503
|
+
borderLeft: `1px dashed ${theme.accent}`,
|
|
353
504
|
borderRight:
|
|
354
505
|
column === columns - 1
|
|
355
|
-
? `1px dashed ${theme.
|
|
506
|
+
? `1px dashed ${theme.accent}`
|
|
356
507
|
: "none",
|
|
357
508
|
opacity: 0.35,
|
|
358
509
|
}}
|
|
@@ -361,3 +512,17 @@ export function GridGuides({ columns }: { columns: number }) {
|
|
|
361
512
|
</Box>
|
|
362
513
|
);
|
|
363
514
|
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* The tile menu's ⋯, with its dots spread wider than the stock icon's so it
|
|
518
|
+
* reads as three dots rather than a dash at this size.
|
|
519
|
+
*/
|
|
520
|
+
function SpreadDotsIcon() {
|
|
521
|
+
return (
|
|
522
|
+
<SvgIcon sx={{ fontSize: 18 }} viewBox="0 0 24 24">
|
|
523
|
+
<circle cx="3.5" cy="12" r="2" />
|
|
524
|
+
<circle cx="12" cy="12" r="2" />
|
|
525
|
+
<circle cx="20.5" cy="12" r="2" />
|
|
526
|
+
</SvgIcon>
|
|
527
|
+
);
|
|
528
|
+
}
|