@dxos/plugin-sheet 0.6.12-main.5cc132e → 0.6.12-main.7907542
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/lib/browser/SheetContainer-T2QWJOFD.mjs +262 -0
- package/dist/lib/browser/SheetContainer-T2QWJOFD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-WUPTZUTX.mjs → chunk-5ZMVZYGB.mjs} +21 -19
- package/dist/lib/browser/chunk-5ZMVZYGB.mjs.map +7 -0
- package/dist/lib/browser/{chunk-GNNVBNCX.mjs → chunk-GSV5QNLD.mjs} +409 -686
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +7 -0
- package/dist/lib/browser/{chunk-JRL5LGCE.mjs → chunk-QILRZNE5.mjs} +2 -5
- package/dist/lib/browser/chunk-QILRZNE5.mjs.map +7 -0
- package/dist/lib/browser/{SheetContainer-Y7ZMFBAP.mjs → chunk-ZL2V5UJR.mjs} +982 -508
- package/dist/lib/browser/chunk-ZL2V5UJR.mjs.map +7 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs +33 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +86 -59
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/meta.mjs +1 -1
- package/dist/lib/browser/types.mjs +4 -6
- package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs +280 -0
- package/dist/lib/node/SheetContainer-PV5ET4UJ.cjs.map +7 -0
- package/dist/lib/node/{SheetContainer-KEOKUKAQ.cjs → chunk-2K53Z2TU.cjs} +1036 -558
- package/dist/lib/node/chunk-2K53Z2TU.cjs.map +7 -0
- package/dist/lib/node/{chunk-ZRQZFV5T.cjs → chunk-5XPK2V4A.cjs} +418 -691
- package/dist/lib/node/chunk-5XPK2V4A.cjs.map +7 -0
- package/dist/lib/node/{chunk-BJ6ZD7MN.cjs → chunk-BNARJ5GM.cjs} +5 -18
- package/dist/lib/node/chunk-BNARJ5GM.cjs.map +7 -0
- package/dist/lib/node/{chunk-VJU3NPUJ.cjs → chunk-STAVQ2JE.cjs} +25 -24
- package/dist/lib/node/chunk-STAVQ2JE.cjs.map +7 -0
- package/dist/lib/node/graph-Q3N2X26H.cjs +55 -0
- package/dist/lib/node/graph-Q3N2X26H.cjs.map +7 -0
- package/dist/lib/node/index.cjs +98 -66
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.cjs +3 -3
- package/dist/lib/node/meta.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/types.cjs +10 -12
- package/dist/lib/node/types.cjs.map +2 -2
- package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs +263 -0
- package/dist/lib/node-esm/SheetContainer-FOZD2WLT.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-WUPTZUTX.mjs → chunk-2HAM45RC.mjs} +22 -19
- package/dist/lib/node-esm/chunk-2HAM45RC.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-GNNVBNCX.mjs → chunk-5WPZCXNS.mjs} +411 -686
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-JRL5LGCE.mjs → chunk-IU2L277A.mjs} +4 -5
- package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +7 -0
- package/dist/lib/node-esm/{SheetContainer-Y7ZMFBAP.mjs → chunk-QEUCIHIN.mjs} +983 -508
- package/dist/lib/node-esm/chunk-QEUCIHIN.mjs.map +7 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +34 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +87 -59
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/meta.mjs +2 -1
- package/dist/lib/node-esm/types.mjs +5 -6
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.d.ts +23 -3
- package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts +2 -2
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts +11 -0
- package/dist/types/src/components/ComputeGraph/ComputeGraphContextProvider.d.ts.map +1 -0
- package/dist/types/src/components/ComputeGraph/index.d.ts +1 -3
- package/dist/types/src/components/ComputeGraph/index.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +10 -0
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +9 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -0
- package/dist/types/src/components/GridSheet/util.d.ts +16 -0
- package/dist/types/src/components/GridSheet/util.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts +5 -6
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/grid.d.ts +2 -2
- package/dist/types/src/components/Sheet/grid.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/nav.d.ts +3 -3
- package/dist/types/src/components/Sheet/nav.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/sheet-context.d.ts +6 -7
- package/dist/types/src/components/Sheet/sheet-context.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/threads.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts +1 -1
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/Toolbar/Toolbar.stories.d.ts +1 -1
- package/dist/types/src/components/index.d.ts +2 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/defs/index.d.ts +3 -0
- package/dist/types/src/defs/index.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/types.d.ts +8 -3
- package/dist/types/src/defs/types.d.ts.map +1 -0
- package/dist/types/src/defs/types.test.d.ts.map +1 -0
- package/dist/types/src/{model → defs}/util.d.ts +8 -4
- package/dist/types/src/defs/util.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.d.ts +6 -0
- package/dist/types/src/extensions/compute.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts +26 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -0
- package/dist/types/src/extensions/index.d.ts +2 -0
- package/dist/types/src/extensions/index.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts +34 -0
- package/dist/types/src/graph/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.d.ts +64 -0
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts +10 -0
- package/dist/types/src/graph/compute-graph.stories.d.ts.map +1 -0
- package/dist/types/src/graph/compute-graph.test.d.ts +2 -0
- package/dist/types/src/graph/compute-graph.test.d.ts.map +1 -0
- package/dist/types/src/graph/compute-node.d.ts +26 -0
- package/dist/types/src/graph/compute-node.d.ts.map +1 -0
- package/dist/types/src/{components/ComputeGraph → graph/functions}/async-function.d.ts +14 -5
- package/dist/types/src/graph/functions/async-function.d.ts.map +1 -0
- package/dist/types/src/graph/functions/edge-function.d.ts +21 -0
- package/dist/types/src/graph/functions/edge-function.d.ts.map +1 -0
- package/dist/types/src/{model/functions.d.ts → graph/functions/function-defs.d.ts} +1 -1
- package/dist/types/src/graph/functions/function-defs.d.ts.map +1 -0
- package/dist/types/src/graph/functions/index.d.ts +4 -0
- package/dist/types/src/graph/functions/index.d.ts.map +1 -0
- package/dist/types/src/graph/hyperformula.test.d.ts +2 -0
- package/dist/types/src/graph/hyperformula.test.d.ts.map +1 -0
- package/dist/types/src/graph/index.d.ts +5 -0
- package/dist/types/src/graph/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/index.d.ts +3 -0
- package/dist/types/src/graph/testing/index.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-builder.d.ts +15 -0
- package/dist/types/src/graph/testing/test-builder.d.ts.map +1 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts +36 -0
- package/dist/types/src/graph/testing/test-plugin.d.ts.map +1 -0
- package/dist/types/src/graph/util.d.ts +2 -0
- package/dist/types/src/graph/util.d.ts.map +1 -0
- package/dist/types/src/hooks/hooks.stories.d.ts +11 -0
- package/dist/types/src/hooks/hooks.stories.d.ts.map +1 -0
- package/dist/types/src/hooks/index.d.ts +4 -0
- package/dist/types/src/hooks/index.d.ts.map +1 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts +7 -0
- package/dist/types/src/hooks/useComputeGraph.d.ts.map +1 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts +3 -0
- package/dist/types/src/hooks/useFormattingModel.d.ts.map +1 -0
- package/dist/types/src/hooks/useSheetModel.d.ts +8 -0
- package/dist/types/src/hooks/useSheetModel.d.ts.map +1 -0
- package/dist/types/src/meta.d.ts +1 -4
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/formatting-model.d.ts +16 -0
- package/dist/types/src/model/formatting-model.d.ts.map +1 -0
- package/dist/types/src/model/index.d.ts +2 -4
- package/dist/types/src/model/index.d.ts.map +1 -1
- package/dist/types/src/model/{model.d.ts → sheet-model.d.ts} +10 -49
- package/dist/types/src/model/sheet-model.d.ts.map +1 -0
- package/dist/types/src/model/sheet-model.test.d.ts +2 -0
- package/dist/types/src/model/sheet-model.test.d.ts.map +1 -0
- package/dist/types/src/sanity.test.d.ts +2 -0
- package/dist/types/src/sanity.test.d.ts.map +1 -0
- package/dist/types/src/testing/index.d.ts +2 -0
- package/dist/types/src/testing/index.d.ts.map +1 -0
- package/dist/types/src/testing/testing.d.ts +8 -0
- package/dist/types/src/testing/testing.d.ts.map +1 -0
- package/dist/types/src/types.d.ts +15 -4
- package/dist/types/src/types.d.ts.map +1 -1
- package/dist/vendor/hyperformula.mjs +37145 -0
- package/package.json +48 -44
- package/src/SheetPlugin.tsx +46 -62
- package/src/components/CellEditor/CellEditor.stories.tsx +6 -6
- package/src/components/CellEditor/CellEditor.tsx +59 -9
- package/src/components/CellEditor/extension.test.ts +3 -4
- package/src/components/CellEditor/extension.ts +5 -6
- package/src/components/ComputeGraph/ComputeGraphContextProvider.tsx +20 -0
- package/src/components/ComputeGraph/index.ts +1 -3
- package/src/components/GridSheet/GridSheet.stories.tsx +36 -0
- package/src/components/GridSheet/GridSheet.tsx +171 -0
- package/src/components/GridSheet/util.ts +148 -0
- package/src/components/Sheet/Sheet.stories.tsx +48 -88
- package/src/components/Sheet/Sheet.tsx +42 -24
- package/src/components/Sheet/grid.ts +3 -3
- package/src/components/Sheet/nav.ts +19 -19
- package/src/components/Sheet/sheet-context.tsx +12 -82
- package/src/components/Sheet/threads.tsx +10 -6
- package/src/components/SheetContainer.tsx +13 -15
- package/src/components/Toolbar/Toolbar.tsx +1 -2
- package/src/components/index.ts +1 -0
- package/src/defs/index.ts +6 -0
- package/src/{model → defs}/types.test.ts +7 -7
- package/src/{model → defs}/types.ts +24 -14
- package/src/{model → defs}/util.ts +65 -17
- package/src/extensions/compute.stories.tsx +151 -0
- package/src/extensions/compute.ts +147 -0
- package/src/extensions/index.ts +5 -0
- package/src/graph/compute-graph-registry.ts +90 -0
- package/src/graph/compute-graph.stories.tsx +93 -0
- package/src/graph/compute-graph.test.ts +87 -0
- package/src/graph/compute-graph.ts +242 -0
- package/src/graph/compute-node.ts +63 -0
- package/src/{components/ComputeGraph → graph/functions}/async-function.ts +25 -15
- package/src/{components/ComputeGraph → graph/functions}/edge-function.ts +16 -14
- package/src/graph/functions/index.ts +7 -0
- package/src/graph/hyperformula.test.ts +14 -0
- package/src/graph/index.ts +8 -0
- package/src/graph/testing/index.ts +6 -0
- package/src/graph/testing/test-builder.ts +54 -0
- package/src/{components/ComputeGraph/custom.ts → graph/testing/test-plugin.ts} +44 -14
- package/src/graph/util.ts +8 -0
- package/src/hooks/hooks.stories.tsx +50 -0
- package/src/hooks/index.ts +7 -0
- package/src/hooks/useComputeGraph.ts +28 -0
- package/src/hooks/useFormattingModel.ts +11 -0
- package/src/hooks/useSheetModel.ts +40 -0
- package/src/meta.tsx +1 -5
- package/src/{components/Sheet/formatting.ts → model/formatting-model.ts} +20 -13
- package/src/model/index.ts +2 -4
- package/src/model/sheet-model.test.ts +57 -0
- package/src/model/{model.ts → sheet-model.ts} +88 -188
- package/src/sanity.test.ts +40 -0
- package/src/testing/index.ts +5 -0
- package/src/testing/testing.tsx +68 -0
- package/src/types.ts +19 -17
- package/dist/lib/browser/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/browser/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/browser/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/browser/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/browser/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/browser/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/browser/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/browser/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/browser/testing.mjs +0 -92
- package/dist/lib/browser/testing.mjs.map +0 -7
- package/dist/lib/node/SheetContainer-KEOKUKAQ.cjs.map +0 -7
- package/dist/lib/node/chunk-57PB2HPY.cjs +0 -40
- package/dist/lib/node/chunk-57PB2HPY.cjs.map +0 -7
- package/dist/lib/node/chunk-6LWBQAQZ.cjs +0 -202
- package/dist/lib/node/chunk-6LWBQAQZ.cjs.map +0 -7
- package/dist/lib/node/chunk-BJ6ZD7MN.cjs.map +0 -7
- package/dist/lib/node/chunk-VJU3NPUJ.cjs.map +0 -7
- package/dist/lib/node/chunk-ZRQZFV5T.cjs.map +0 -7
- package/dist/lib/node/testing.cjs +0 -111
- package/dist/lib/node/testing.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-Y7ZMFBAP.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-GNNVBNCX.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-JRL5LGCE.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs +0 -175
- package/dist/lib/node-esm/chunk-PGKZPKUD.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs +0 -8
- package/dist/lib/node-esm/chunk-VBF7YENS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-WUPTZUTX.mjs.map +0 -7
- package/dist/lib/node-esm/testing.mjs +0 -92
- package/dist/lib/node-esm/testing.mjs.map +0 -7
- package/dist/types/src/components/ComputeGraph/async-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/custom.d.ts +0 -21
- package/dist/types/src/components/ComputeGraph/custom.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts +0 -20
- package/dist/types/src/components/ComputeGraph/edge-function.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts +0 -12
- package/dist/types/src/components/ComputeGraph/graph-context.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts +0 -2
- package/dist/types/src/components/ComputeGraph/graph.browser.test.d.ts.map +0 -1
- package/dist/types/src/components/ComputeGraph/graph.d.ts +0 -26
- package/dist/types/src/components/ComputeGraph/graph.d.ts.map +0 -1
- package/dist/types/src/components/Sheet/formatting.d.ts +0 -14
- package/dist/types/src/components/Sheet/formatting.d.ts.map +0 -1
- package/dist/types/src/model/functions.d.ts.map +0 -1
- package/dist/types/src/model/model.browser.test.d.ts +0 -2
- package/dist/types/src/model/model.browser.test.d.ts.map +0 -1
- package/dist/types/src/model/model.d.ts.map +0 -1
- package/dist/types/src/model/types.d.ts.map +0 -1
- package/dist/types/src/model/types.test.d.ts.map +0 -1
- package/dist/types/src/model/util.d.ts.map +0 -1
- package/dist/types/src/testing.d.ts +0 -9
- package/dist/types/src/testing.d.ts.map +0 -1
- package/src/components/ComputeGraph/graph-context.tsx +0 -50
- package/src/components/ComputeGraph/graph.browser.test.ts +0 -49
- package/src/components/ComputeGraph/graph.ts +0 -62
- package/src/model/model.browser.test.ts +0 -99
- package/src/testing.ts +0 -50
- /package/dist/types/src/{model → defs}/types.test.d.ts +0 -0
- /package/src/{model/functions.ts → graph/functions/function-defs.ts} +0 -0
|
@@ -25,6 +25,7 @@ import { Resizable, type ResizeCallback, type ResizeStartCallback } from 're-res
|
|
|
25
25
|
import React, {
|
|
26
26
|
type CSSProperties,
|
|
27
27
|
type DOMAttributes,
|
|
28
|
+
type KeyboardEventHandler,
|
|
28
29
|
type PropsWithChildren,
|
|
29
30
|
forwardRef,
|
|
30
31
|
useEffect,
|
|
@@ -40,7 +41,7 @@ import { debounce } from '@dxos/async';
|
|
|
40
41
|
import { fullyQualifiedId, createDocAccessor } from '@dxos/client/echo';
|
|
41
42
|
import { log } from '@dxos/log';
|
|
42
43
|
import { type ThemedClassName } from '@dxos/react-ui';
|
|
43
|
-
import {
|
|
44
|
+
import { ATTENABLE_ATTRIBUTE, useAttendableAttributes, useAttention, useAttentionPath } from '@dxos/react-ui-attention';
|
|
44
45
|
import { mx } from '@dxos/react-ui-theme';
|
|
45
46
|
|
|
46
47
|
import {
|
|
@@ -71,7 +72,7 @@ import {
|
|
|
71
72
|
rangeToA1Notation,
|
|
72
73
|
addressToIndex,
|
|
73
74
|
addressFromIndex,
|
|
74
|
-
} from '../../
|
|
75
|
+
} from '../../defs';
|
|
75
76
|
import {
|
|
76
77
|
CellEditor,
|
|
77
78
|
type CellRangeNotifier,
|
|
@@ -138,7 +139,7 @@ const SheetRoot = ({ children, ...props }: PropsWithChildren<SheetContextProps>)
|
|
|
138
139
|
|
|
139
140
|
type SheetMainProps = ThemedClassName<Partial<GridSize>>;
|
|
140
141
|
|
|
141
|
-
const SheetMain = forwardRef<HTMLDivElement, SheetMainProps>(({ classNames, numRows,
|
|
142
|
+
const SheetMain = forwardRef<HTMLDivElement, SheetMainProps>(({ classNames, numRows, numCols }, forwardRef) => {
|
|
142
143
|
const { model, cursor, setCursor, setRange, setEditing } = useSheetContext();
|
|
143
144
|
|
|
144
145
|
// Scrolling.
|
|
@@ -263,8 +264,8 @@ const SheetMain = forwardRef<HTMLDivElement, SheetMainProps>(({ classNames, numR
|
|
|
263
264
|
ref={columnsRef}
|
|
264
265
|
columns={columns}
|
|
265
266
|
sizes={columnSizes}
|
|
266
|
-
selected={cursor?.
|
|
267
|
-
onSelect={(
|
|
267
|
+
selected={cursor?.col}
|
|
268
|
+
onSelect={(col) => setCursor(cursor?.col === col ? undefined : { row: -1, col })}
|
|
268
269
|
onResize={handleResizeColumn}
|
|
269
270
|
onMove={handleMoveColumns}
|
|
270
271
|
/>
|
|
@@ -274,13 +275,13 @@ const SheetMain = forwardRef<HTMLDivElement, SheetMainProps>(({ classNames, numR
|
|
|
274
275
|
rows={rows}
|
|
275
276
|
sizes={rowSizes}
|
|
276
277
|
selected={cursor?.row}
|
|
277
|
-
onSelect={(row) => setCursor(cursor?.row === row ? undefined : { row,
|
|
278
|
+
onSelect={(row) => setCursor(cursor?.row === row ? undefined : { row, col: -1 })}
|
|
278
279
|
onResize={handleResizeRow}
|
|
279
280
|
onMove={handleMoveRows}
|
|
280
281
|
/>
|
|
281
282
|
<SheetGrid
|
|
282
283
|
ref={contentRef}
|
|
283
|
-
size={{ numRows: numRows ?? rows.length,
|
|
284
|
+
size={{ numRows: numRows ?? rows.length, numCols: numCols ?? columns.length }}
|
|
284
285
|
rows={rows}
|
|
285
286
|
columns={columns}
|
|
286
287
|
rowSizes={rowSizes}
|
|
@@ -861,10 +862,8 @@ const SheetGrid = forwardRef<HTMLDivElement, SheetGridProps>(
|
|
|
861
862
|
columnSizes,
|
|
862
863
|
});
|
|
863
864
|
|
|
864
|
-
// TODO(burdon): Prevent scroll if not attended.
|
|
865
865
|
const id = fullyQualifiedId(model.sheet);
|
|
866
|
-
const
|
|
867
|
-
const hasAttention = useHasAttention(id);
|
|
866
|
+
const { hasAttention } = useAttention(id);
|
|
868
867
|
|
|
869
868
|
return (
|
|
870
869
|
<div ref={containerRef} role='grid' className='relative flex grow overflow-hidden'>
|
|
@@ -872,6 +871,7 @@ const SheetGrid = forwardRef<HTMLDivElement, SheetGridProps>(
|
|
|
872
871
|
<div className={mx('z-20 absolute inset-0 border border-gridLine pointer-events-none')} />
|
|
873
872
|
|
|
874
873
|
{/* Grid scroll container. */}
|
|
874
|
+
{/* NOTE: Prevents scroll if not attended. */}
|
|
875
875
|
<div ref={scrollerRef} className={mx('grow', hasAttention && 'overflow-auto scrollbar-thin')}>
|
|
876
876
|
{/* Scroll content. */}
|
|
877
877
|
<div
|
|
@@ -885,9 +885,9 @@ const SheetGrid = forwardRef<HTMLDivElement, SheetGridProps>(
|
|
|
885
885
|
|
|
886
886
|
{/* Grid cells. */}
|
|
887
887
|
{rowRange.map(({ row, top, height }) => {
|
|
888
|
-
return columnRange.map(({
|
|
888
|
+
return columnRange.map(({ col, left, width }) => {
|
|
889
889
|
const style: CSSProperties = { position: 'absolute', top, left, width, height };
|
|
890
|
-
const cell = { row,
|
|
890
|
+
const cell: CellAddress = { row, col };
|
|
891
891
|
const id = addressToA1Notation(cell);
|
|
892
892
|
const idx = addressToIndex(model.sheet, cell);
|
|
893
893
|
const active = posEquals(cursor, cell);
|
|
@@ -952,21 +952,37 @@ const SheetGrid = forwardRef<HTMLDivElement, SheetGridProps>(
|
|
|
952
952
|
</div>
|
|
953
953
|
|
|
954
954
|
{/* Hidden input for key navigation. */}
|
|
955
|
-
{createPortal(
|
|
956
|
-
<input
|
|
957
|
-
ref={inputRef}
|
|
958
|
-
autoFocus
|
|
959
|
-
className='absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent'
|
|
960
|
-
onKeyDown={handleKeyDown}
|
|
961
|
-
{...attendableAttrs}
|
|
962
|
-
/>,
|
|
963
|
-
document.body,
|
|
964
|
-
)}
|
|
955
|
+
{createPortal(<SheetInput ref={inputRef} id={id} onKeyDown={handleKeyDown} />, document.body)}
|
|
965
956
|
</div>
|
|
966
957
|
);
|
|
967
958
|
},
|
|
968
959
|
);
|
|
969
960
|
|
|
961
|
+
type SheetInputProps = {
|
|
962
|
+
id: string;
|
|
963
|
+
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
const SheetInput = forwardRef<HTMLInputElement, SheetInputProps>(({ id, onKeyDown }, forwardedRef) => {
|
|
967
|
+
const path = useAttentionPath();
|
|
968
|
+
const attendableAttrs = useAttendableAttributes(id);
|
|
969
|
+
|
|
970
|
+
// TODO(wittjosiah): Consider factoring out as an attention util.
|
|
971
|
+
// Wrap input in attendable divs for each part of the path.
|
|
972
|
+
// This ensures that the sheet stays attended when the input is focused.
|
|
973
|
+
return path.toReversed().reduce(
|
|
974
|
+
(acc, part) => {
|
|
975
|
+
return <div {...{ [ATTENABLE_ATTRIBUTE]: part }}>{acc}</div>;
|
|
976
|
+
},
|
|
977
|
+
<input
|
|
978
|
+
ref={forwardedRef}
|
|
979
|
+
className='absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent'
|
|
980
|
+
onKeyDown={onKeyDown}
|
|
981
|
+
{...attendableAttrs}
|
|
982
|
+
/>,
|
|
983
|
+
);
|
|
984
|
+
});
|
|
985
|
+
|
|
970
986
|
//
|
|
971
987
|
// Selection
|
|
972
988
|
//
|
|
@@ -1082,10 +1098,11 @@ const GridCellEditor = ({ style, value, onNav, onClose }: GridCellEditorProps) =
|
|
|
1082
1098
|
notifier.current?.(rangeToA1Notation(range));
|
|
1083
1099
|
}
|
|
1084
1100
|
}, [range]);
|
|
1101
|
+
|
|
1085
1102
|
const extension = useMemo(
|
|
1086
1103
|
() => [
|
|
1087
1104
|
editorKeys({ onNav, onClose }),
|
|
1088
|
-
sheetExtension({ functions: model.
|
|
1105
|
+
sheetExtension({ functions: model.graph.getFunctions() }),
|
|
1089
1106
|
rangeExtension((fn) => (notifier.current = fn)),
|
|
1090
1107
|
],
|
|
1091
1108
|
[model],
|
|
@@ -1109,12 +1126,13 @@ const GridCellEditor = ({ style, value, onNav, onClose }: GridCellEditorProps) =
|
|
|
1109
1126
|
|
|
1110
1127
|
const SheetStatusBar = () => {
|
|
1111
1128
|
const { model, cursor, range } = useSheetContext();
|
|
1129
|
+
|
|
1112
1130
|
let value;
|
|
1113
1131
|
let isFormula = false;
|
|
1114
1132
|
if (cursor) {
|
|
1115
1133
|
value = model.getCellValue(cursor);
|
|
1116
1134
|
if (typeof value === 'string' && value.charAt(0) === '=') {
|
|
1117
|
-
value = model.
|
|
1135
|
+
value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));
|
|
1118
1136
|
isFormula = true;
|
|
1119
1137
|
} else if (value != null) {
|
|
1120
1138
|
value = String(value);
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { type MouseEvent, useEffect, useState } from 'react';
|
|
6
6
|
|
|
7
|
-
import { type CellAddress, type CellIndex, addressFromA1Notation, addressToA1Notation } from '../../
|
|
7
|
+
import { type CellAddress, type CellIndex, addressFromA1Notation, addressToA1Notation } from '../../defs';
|
|
8
8
|
|
|
9
9
|
// export type Bounds = Pick<DOMRect, 'left' | 'top' | 'width' | 'height'>;
|
|
10
10
|
// export type Dimension = Pick<DOMRect, 'width' | 'height'>;
|
|
@@ -12,7 +12,7 @@ import { type CellAddress, type CellIndex, addressFromA1Notation, addressToA1Not
|
|
|
12
12
|
export type SizeMap = Record<string, number>;
|
|
13
13
|
|
|
14
14
|
export type RowPosition = { row: number } & Pick<DOMRect, 'top' | 'height'>;
|
|
15
|
-
export type ColumnPosition = {
|
|
15
|
+
export type ColumnPosition = { col: number } & Pick<DOMRect, 'left' | 'width'>;
|
|
16
16
|
|
|
17
17
|
export const axisWidth = 'calc(var(--rail-size)-2px)';
|
|
18
18
|
export const axisHeight = 34;
|
|
@@ -88,7 +88,7 @@ export const useGridLayout = ({
|
|
|
88
88
|
const width = columnSizes?.[idx] ?? defaultWidth;
|
|
89
89
|
const left = x;
|
|
90
90
|
x += width - 1;
|
|
91
|
-
return {
|
|
91
|
+
return { col: i, left, width };
|
|
92
92
|
}),
|
|
93
93
|
);
|
|
94
94
|
}, [columns, columnSizes]);
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
import { type KeyboardEvent, type MouseEventHandler, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { getCellAtPointer } from './grid';
|
|
8
|
-
import { type CellAddress, type CellRange, posEquals } from '../../
|
|
8
|
+
import { type CellAddress, type CellRange, posEquals } from '../../defs';
|
|
9
9
|
|
|
10
10
|
export type GridSize = {
|
|
11
11
|
numRows: number;
|
|
12
|
-
|
|
12
|
+
numCols: number;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -38,14 +38,14 @@ export const handleNav = (
|
|
|
38
38
|
break;
|
|
39
39
|
}
|
|
40
40
|
case 'ArrowLeft': {
|
|
41
|
-
if (opposite.
|
|
42
|
-
opposite.
|
|
41
|
+
if (opposite.col > 0) {
|
|
42
|
+
opposite.col -= 1;
|
|
43
43
|
}
|
|
44
44
|
break;
|
|
45
45
|
}
|
|
46
46
|
case 'ArrowRight': {
|
|
47
|
-
if (opposite.
|
|
48
|
-
opposite.
|
|
47
|
+
if (opposite.col < size.numCols - 1) {
|
|
48
|
+
opposite.col += 1;
|
|
49
49
|
}
|
|
50
50
|
break;
|
|
51
51
|
}
|
|
@@ -64,41 +64,41 @@ export const handleNav = (
|
|
|
64
64
|
export const handleArrowNav = (
|
|
65
65
|
ev: Pick<KeyboardEvent<HTMLInputElement>, 'key' | 'metaKey'>,
|
|
66
66
|
cursor: CellAddress | undefined,
|
|
67
|
-
{ numRows,
|
|
67
|
+
{ numRows, numCols }: GridSize,
|
|
68
68
|
): CellAddress | undefined => {
|
|
69
69
|
switch (ev.key) {
|
|
70
70
|
case 'ArrowUp':
|
|
71
71
|
if (cursor === undefined) {
|
|
72
|
-
return { row: 0,
|
|
72
|
+
return { row: 0, col: 0 };
|
|
73
73
|
} else if (cursor.row > 0) {
|
|
74
|
-
return { row: ev.metaKey ? 0 : cursor.row - 1,
|
|
74
|
+
return { row: ev.metaKey ? 0 : cursor.row - 1, col: cursor.col };
|
|
75
75
|
}
|
|
76
76
|
break;
|
|
77
77
|
case 'ArrowDown':
|
|
78
78
|
if (cursor === undefined) {
|
|
79
|
-
return { row: 0,
|
|
79
|
+
return { row: 0, col: 0 };
|
|
80
80
|
} else if (cursor.row < numRows - 1) {
|
|
81
|
-
return { row: ev.metaKey ? numRows - 1 : cursor.row + 1,
|
|
81
|
+
return { row: ev.metaKey ? numRows - 1 : cursor.row + 1, col: cursor.col };
|
|
82
82
|
}
|
|
83
83
|
break;
|
|
84
84
|
case 'ArrowLeft':
|
|
85
85
|
if (cursor === undefined) {
|
|
86
|
-
return { row: 0,
|
|
87
|
-
} else if (cursor.
|
|
88
|
-
return { row: cursor.row,
|
|
86
|
+
return { row: 0, col: 0 };
|
|
87
|
+
} else if (cursor.col > 0) {
|
|
88
|
+
return { row: cursor.row, col: ev.metaKey ? 0 : cursor.col - 1 };
|
|
89
89
|
}
|
|
90
90
|
break;
|
|
91
91
|
case 'ArrowRight':
|
|
92
92
|
if (cursor === undefined) {
|
|
93
|
-
return { row: 0,
|
|
94
|
-
} else if (cursor.
|
|
95
|
-
return { row: cursor.row,
|
|
93
|
+
return { row: 0, col: 0 };
|
|
94
|
+
} else if (cursor.col < numCols - 1) {
|
|
95
|
+
return { row: cursor.row, col: ev.metaKey ? numCols - 1 : cursor.col + 1 };
|
|
96
96
|
}
|
|
97
97
|
break;
|
|
98
98
|
case 'Home':
|
|
99
|
-
return { row: 0,
|
|
99
|
+
return { row: 0, col: 0 };
|
|
100
100
|
case 'End':
|
|
101
|
-
return { row: numRows - 1,
|
|
101
|
+
return { row: numRows - 1, col: numCols - 1 };
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
|
|
@@ -2,22 +2,16 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import React, { type PropsWithChildren, createContext, useContext,
|
|
5
|
+
import React, { type PropsWithChildren, createContext, useContext, useMemo, useState } from 'react';
|
|
6
6
|
|
|
7
7
|
import { invariant } from '@dxos/invariant';
|
|
8
|
-
import { type FunctionType } from '@dxos/plugin-script';
|
|
9
|
-
import { fullyQualifiedId, type Space } from '@dxos/react-client/echo';
|
|
10
8
|
|
|
11
9
|
import { createDecorations } from './decorations';
|
|
12
|
-
import {
|
|
13
|
-
import { type
|
|
10
|
+
import { type CellAddress, type CellRange } from '../../defs';
|
|
11
|
+
import { type ComputeGraph } from '../../graph';
|
|
12
|
+
import { useSheetModel, useFormattingModel } from '../../hooks';
|
|
13
|
+
import { type FormattingModel, type SheetModel } from '../../model';
|
|
14
14
|
import { type SheetType } from '../../types';
|
|
15
|
-
import { type FunctionContextOptions } from '../ComputeGraph';
|
|
16
|
-
// TODO(wittjosiah): Refactor. This is not exported from ./components due to depending on ECHO.
|
|
17
|
-
import { useComputeGraph } from '../ComputeGraph/graph-context';
|
|
18
|
-
|
|
19
|
-
// TODO(wittjosiah): Factor out.
|
|
20
|
-
const OBJECT_ID_LENGTH = 60; // 33 (space id) + 26 (object id) + 1 (separator).
|
|
21
15
|
|
|
22
16
|
export type SheetContextType = {
|
|
23
17
|
model: SheetModel;
|
|
@@ -51,92 +45,28 @@ export const useSheetContext = (): SheetContextType => {
|
|
|
51
45
|
};
|
|
52
46
|
|
|
53
47
|
export type SheetContextProps = {
|
|
48
|
+
graph: ComputeGraph;
|
|
54
49
|
sheet: SheetType;
|
|
55
|
-
space: Space;
|
|
56
50
|
readonly?: boolean;
|
|
57
|
-
} & Pick<SheetContextType, 'onInfo'
|
|
58
|
-
Partial<FunctionContextOptions>;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Map from binding to fully qualified ECHO ID.
|
|
62
|
-
*/
|
|
63
|
-
const mapFormulaBindingToId =
|
|
64
|
-
(functions: FunctionType[]) =>
|
|
65
|
-
(formula: string): string => {
|
|
66
|
-
return formula.replace(/([a-zA-Z0-9]+)\((.*)\)/g, (match, binding, args) => {
|
|
67
|
-
if (defaultFunctions.find((fn) => fn.name === binding) || binding === 'EDGE') {
|
|
68
|
-
return match;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const fn = functions.find((fn) => fn.binding === binding);
|
|
72
|
-
if (fn) {
|
|
73
|
-
return `${fullyQualifiedId(fn)}(${args})`;
|
|
74
|
-
} else {
|
|
75
|
-
return match;
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Map from fully qualified ECHO ID to binding.
|
|
82
|
-
*/
|
|
83
|
-
const mapFormulaBindingFromId =
|
|
84
|
-
(functions: FunctionType[]) =>
|
|
85
|
-
(formula: string): string => {
|
|
86
|
-
return formula.replace(/([a-zA-Z0-9]+):([a-zA-Z0-9]+)\((.*)\)/g, (match, spaceId, objectId, args) => {
|
|
87
|
-
const id = `${spaceId}:${objectId}`;
|
|
88
|
-
if (id.length !== OBJECT_ID_LENGTH) {
|
|
89
|
-
return match;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const fn = functions.find((fn) => fullyQualifiedId(fn) === id);
|
|
93
|
-
if (fn?.binding) {
|
|
94
|
-
return `${fn.binding}(${args})`;
|
|
95
|
-
} else {
|
|
96
|
-
return match;
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
};
|
|
51
|
+
} & Pick<SheetContextType, 'onInfo'>;
|
|
100
52
|
|
|
101
53
|
export const SheetContextProvider = ({
|
|
102
54
|
children,
|
|
55
|
+
graph,
|
|
103
56
|
sheet,
|
|
104
|
-
space,
|
|
105
57
|
readonly,
|
|
106
58
|
onInfo,
|
|
107
|
-
...options
|
|
108
59
|
}: PropsWithChildren<SheetContextProps>) => {
|
|
109
|
-
const
|
|
60
|
+
const model = useSheetModel(graph, sheet, { readonly });
|
|
61
|
+
const formatting = useFormattingModel(model);
|
|
110
62
|
|
|
111
|
-
// TODO(Zan):
|
|
112
|
-
// that cell or range if it is not visible.
|
|
63
|
+
// TODO(Zan): Impl. set range and set cursor that scrolls to that cell or range if it is not visible.
|
|
113
64
|
const [cursor, setCursor] = useState<CellAddress>();
|
|
114
65
|
const [range, setRange] = useState<CellRange>();
|
|
115
66
|
const [editing, setEditing] = useState<boolean>(false);
|
|
116
67
|
const decorations = useMemo(() => createDecorations(), []);
|
|
117
68
|
|
|
118
|
-
|
|
119
|
-
useEffect(() => {
|
|
120
|
-
let model: SheetModel | undefined;
|
|
121
|
-
let formatting;
|
|
122
|
-
const t = setTimeout(async () => {
|
|
123
|
-
model = new SheetModel(graph, sheet, space, { readonly, mapFormulaBindingToId, mapFormulaBindingFromId });
|
|
124
|
-
await model.initialize();
|
|
125
|
-
formatting = new FormattingModel(model);
|
|
126
|
-
setModels([model, formatting]);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
return () => {
|
|
130
|
-
clearTimeout(t);
|
|
131
|
-
void model?.destroy();
|
|
132
|
-
};
|
|
133
|
-
}, [graph, readonly]);
|
|
134
|
-
|
|
135
|
-
if (!model || !formatting) {
|
|
136
|
-
return null;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
return (
|
|
69
|
+
return !model || !formatting ? null : (
|
|
140
70
|
<SheetContext.Provider
|
|
141
71
|
value={{
|
|
142
72
|
model,
|
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { effect } from '@preact/signals-core';
|
|
6
|
-
import React, { useCallback, useEffect, useMemo } from 'react';
|
|
6
|
+
import React, { type PropsWithChildren, useCallback, useEffect, useMemo } from 'react';
|
|
7
7
|
|
|
8
8
|
import { type IntentResolver, LayoutAction, useIntentDispatcher, useIntentResolver } from '@dxos/app-framework';
|
|
9
9
|
import { debounce } from '@dxos/async';
|
|
10
10
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
11
11
|
import { Icon, useTranslation } from '@dxos/react-ui';
|
|
12
|
-
import { mx } from '@dxos/react-ui-theme';
|
|
13
12
|
|
|
14
13
|
import { type Decoration } from './decorations';
|
|
15
14
|
import { useSheetContext } from './sheet-context';
|
|
15
|
+
import { addressFromIndex, addressToIndex, type CellAddress, closest } from '../../defs';
|
|
16
16
|
import { SHEET_PLUGIN } from '../../meta';
|
|
17
|
-
|
|
17
|
+
|
|
18
|
+
// TODO(burdon): Move into folder; split hooks.
|
|
18
19
|
|
|
19
20
|
const CommentIndicator = () => {
|
|
20
21
|
return (
|
|
@@ -25,9 +26,9 @@ const CommentIndicator = () => {
|
|
|
25
26
|
);
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
const ThreadedCellWrapper
|
|
29
|
+
const ThreadedCellWrapper = ({ children }: PropsWithChildren) => {
|
|
29
30
|
const dispatch = useIntentDispatcher();
|
|
30
|
-
const [isHovered, setIsHovered] = React.useState(
|
|
31
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
31
32
|
const { t } = useTranslation(SHEET_PLUGIN);
|
|
32
33
|
|
|
33
34
|
const handleClick = React.useCallback(
|
|
@@ -40,7 +41,7 @@ const ThreadedCellWrapper: React.FC<{ children: React.ReactNode }> = ({ children
|
|
|
40
41
|
return (
|
|
41
42
|
<div
|
|
42
43
|
role='none'
|
|
43
|
-
className=
|
|
44
|
+
className='relative h-full is-full'
|
|
44
45
|
onMouseEnter={() => {
|
|
45
46
|
setIsHovered(true);
|
|
46
47
|
}}
|
|
@@ -73,6 +74,8 @@ const createThreadDecoration = (cellIndex: string, threadId: string, sheetId: st
|
|
|
73
74
|
};
|
|
74
75
|
};
|
|
75
76
|
|
|
77
|
+
// TODO(burdon): Factor out hooks.
|
|
78
|
+
|
|
76
79
|
const useUpdateCursorOnThreadSelection = () => {
|
|
77
80
|
const { setCursor, model } = useSheetContext();
|
|
78
81
|
|
|
@@ -190,6 +193,7 @@ const useThreadDecorations = () => {
|
|
|
190
193
|
}
|
|
191
194
|
}
|
|
192
195
|
});
|
|
196
|
+
|
|
193
197
|
return () => unsubscribe();
|
|
194
198
|
});
|
|
195
199
|
};
|
|
@@ -6,27 +6,22 @@ import React, { useCallback } from 'react';
|
|
|
6
6
|
|
|
7
7
|
import { useIntentDispatcher } from '@dxos/app-framework';
|
|
8
8
|
import { fullyQualifiedId } from '@dxos/react-client/echo';
|
|
9
|
-
import {
|
|
9
|
+
import { useAttendableAttributes, useAttention } from '@dxos/react-ui-attention';
|
|
10
10
|
import { focusRing, mx } from '@dxos/react-ui-theme';
|
|
11
11
|
|
|
12
12
|
import { Sheet, type SheetRootProps } from './Sheet';
|
|
13
13
|
import { Toolbar, type ToolbarAction } from './Toolbar';
|
|
14
14
|
|
|
15
|
-
// TODO(Zan): Factor out, copied this from MarkdownPlugin.
|
|
16
|
-
const attentionFragment = mx(
|
|
17
|
-
'group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface',
|
|
18
|
-
'group-focus-within/editor:border-separator',
|
|
19
|
-
);
|
|
20
|
-
|
|
21
15
|
// TODO(Zan): Factor out, copied this from MarkdownPlugin.
|
|
22
16
|
export const sectionToolbarLayout =
|
|
23
17
|
'bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity';
|
|
24
18
|
|
|
25
|
-
const SheetContainer = ({
|
|
19
|
+
const SheetContainer = ({ graph, sheet, role }: SheetRootProps & { role?: string }) => {
|
|
26
20
|
const dispatch = useIntentDispatcher();
|
|
27
21
|
|
|
28
22
|
const id = fullyQualifiedId(sheet);
|
|
29
|
-
const
|
|
23
|
+
const attendableAttrs = useAttendableAttributes(id);
|
|
24
|
+
const { hasAttention } = useAttention(id);
|
|
30
25
|
|
|
31
26
|
// TODO(Zan): Centralise the toolbar action handler. Current implementation in stories.
|
|
32
27
|
const handleAction = useCallback(
|
|
@@ -49,15 +44,19 @@ const SheetContainer = ({ sheet, space, role, remoteFunctionUrl }: SheetRootProp
|
|
|
49
44
|
);
|
|
50
45
|
|
|
51
46
|
return (
|
|
52
|
-
<div
|
|
53
|
-
|
|
47
|
+
<div
|
|
48
|
+
role='none'
|
|
49
|
+
className={role === 'article' ? 'row-span-2 grid grid-rows-subgrid' : undefined}
|
|
50
|
+
{...(role === 'article' && attendableAttrs)}
|
|
51
|
+
>
|
|
52
|
+
<Sheet.Root graph={graph} sheet={sheet}>
|
|
54
53
|
<div role='none' className={mx('flex flex-0 justify-center overflow-x-auto')}>
|
|
55
54
|
<Toolbar.Root
|
|
56
55
|
onAction={handleAction}
|
|
57
56
|
classNames={mx(
|
|
58
57
|
role === 'section'
|
|
59
|
-
? ['z-[2] group-focus-within/section:visible', !
|
|
60
|
-
: '
|
|
58
|
+
? ['z-[2] group-focus-within/section:visible', !hasAttention && 'invisible', sectionToolbarLayout]
|
|
59
|
+
: 'attention-surface',
|
|
61
60
|
)}
|
|
62
61
|
>
|
|
63
62
|
{/* TODO(Zan): Restore some of this functionality */}
|
|
@@ -73,9 +72,8 @@ const SheetContainer = ({ sheet, space, role, remoteFunctionUrl }: SheetRootProp
|
|
|
73
72
|
className={mx(
|
|
74
73
|
role === 'section' && 'aspect-square border-is border-bs border-be border-separator',
|
|
75
74
|
role === 'article' &&
|
|
76
|
-
'flex is-full overflow-hidden focus-visible:ring-inset row-span-1 data-[toolbar=disabled]:pbs-2 data-[toolbar=disabled]:row-span-2 border-bs border-separator',
|
|
75
|
+
'flex is-full overflow-hidden focus-visible:ring-inset row-span-1 data-[toolbar=disabled]:pbs-2 data-[toolbar=disabled]:row-span-2 border-bs border-separator attention-surface',
|
|
77
76
|
focusRing,
|
|
78
|
-
attentionFragment,
|
|
79
77
|
)}
|
|
80
78
|
>
|
|
81
79
|
<Sheet.Main />
|
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
import { nonNullable } from '@dxos/util';
|
|
27
27
|
|
|
28
28
|
import { ToolbarButton, ToolbarSeparator, ToolbarToggleButton } from './common';
|
|
29
|
+
import { addressToIndex } from '../../defs';
|
|
29
30
|
import { SHEET_PLUGIN } from '../../meta';
|
|
30
|
-
import { addressToIndex } from '../../model';
|
|
31
31
|
import { type Formatting } from '../../types';
|
|
32
32
|
import { useSheetContext } from '../Sheet/sheet-context';
|
|
33
33
|
|
|
@@ -179,7 +179,6 @@ const Styles = () => {
|
|
|
179
179
|
// Actions
|
|
180
180
|
//
|
|
181
181
|
|
|
182
|
-
// TODO(Zan): Instead of taking props, can we access the state from sheet context?
|
|
183
182
|
const Actions = () => {
|
|
184
183
|
const { onAction } = useToolbarContext('Actions');
|
|
185
184
|
const { cursor, range, model } = useSheetContext();
|
package/src/components/index.ts
CHANGED
|
@@ -9,8 +9,8 @@ import { inRange, addressFromA1Notation, addressToA1Notation, rangeFromA1Notatio
|
|
|
9
9
|
|
|
10
10
|
describe('cell', () => {
|
|
11
11
|
test('posToA1Notation', () => {
|
|
12
|
-
expect(addressToA1Notation({
|
|
13
|
-
expect(addressFromA1Notation('C2')).to.deep.eq({
|
|
12
|
+
expect(addressToA1Notation({ col: 0, row: 0 })).to.eq('A1');
|
|
13
|
+
expect(addressFromA1Notation('C2')).to.deep.eq({ col: 2, row: 1 });
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
test('rangeToA1Notation', () => {
|
|
@@ -55,19 +55,19 @@ describe('cell', () => {
|
|
|
55
55
|
// Values.
|
|
56
56
|
const cells: Record<string, any> = {};
|
|
57
57
|
const setCell = (cell: string, value: any) => {
|
|
58
|
-
const {
|
|
58
|
+
const { col, row } = addressFromA1Notation(cell);
|
|
59
59
|
// Reallocate if > current bounds.
|
|
60
|
-
if (
|
|
61
|
-
insertIndex(columns,
|
|
60
|
+
if (col >= columns.length) {
|
|
61
|
+
insertIndex(columns, col);
|
|
62
62
|
}
|
|
63
63
|
if (row >= rows.length) {
|
|
64
64
|
insertIndex(rows, row);
|
|
65
65
|
}
|
|
66
|
-
const index = `${columns[
|
|
66
|
+
const index = `${columns[col]}@${rows[row]}`;
|
|
67
67
|
cells[index] = value;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
expect(addressFromA1Notation('A1')).to.deep.eq({
|
|
70
|
+
expect(addressFromA1Notation('A1')).to.deep.eq({ col: 0, row: 0 });
|
|
71
71
|
|
|
72
72
|
expect(columns).to.deep.eq(['a1', 'a2', 'a3', 'a4', 'a5']);
|
|
73
73
|
insertIndex(columns, 7);
|