@dxos/plugin-sheet 0.8.4-main.c4373fc → 0.8.4-main.c85a9c8dae
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/RangeList-S3SHV7T6.mjs +53 -0
- package/dist/lib/browser/RangeList-S3SHV7T6.mjs.map +7 -0
- package/dist/lib/browser/SheetContainer-I3NFVVDQ.mjs +1805 -0
- package/dist/lib/browser/SheetContainer-I3NFVVDQ.mjs.map +7 -0
- package/dist/lib/browser/anchor-sort-DZ3IHHJJ.mjs +24 -0
- package/dist/lib/browser/anchor-sort-DZ3IHHJJ.mjs.map +7 -0
- package/dist/lib/browser/{chunk-SSN4HYJL.mjs → chunk-NNWF7EKC.mjs} +17 -17
- package/dist/lib/browser/chunk-NNWF7EKC.mjs.map +7 -0
- package/dist/lib/browser/chunk-S445OQGW.mjs +397 -0
- package/dist/lib/browser/chunk-S445OQGW.mjs.map +7 -0
- package/dist/lib/browser/compute-graph-registry-W6HO2G3P.mjs +21 -0
- package/dist/lib/browser/compute-graph-registry-W6HO2G3P.mjs.map +7 -0
- package/dist/lib/browser/index.mjs +71 -80
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/markdown-S6GVLHB4.mjs +29 -0
- package/dist/lib/browser/markdown-S6GVLHB4.mjs.map +7 -0
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/operation-resolver-Z4X4UWNR.mjs +79 -0
- package/dist/lib/browser/operation-resolver-Z4X4UWNR.mjs.map +7 -0
- package/dist/lib/browser/react-surface-KIU6DGKW.mjs +51 -0
- package/dist/lib/browser/react-surface-KIU6DGKW.mjs.map +7 -0
- package/dist/lib/browser/types/index.mjs +7 -12
- package/dist/lib/node-esm/RangeList-IB23OJK2.mjs +54 -0
- package/dist/lib/node-esm/RangeList-IB23OJK2.mjs.map +7 -0
- package/dist/lib/node-esm/SheetContainer-KUXNCSFP.mjs +1806 -0
- package/dist/lib/node-esm/SheetContainer-KUXNCSFP.mjs.map +7 -0
- package/dist/lib/node-esm/anchor-sort-24OXMOSX.mjs +25 -0
- package/dist/lib/node-esm/anchor-sort-24OXMOSX.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-IK4O7FUJ.mjs → chunk-M52YLLWU.mjs} +17 -17
- package/dist/lib/node-esm/chunk-M52YLLWU.mjs.map +7 -0
- package/dist/lib/node-esm/chunk-NKZ3O4OR.mjs +398 -0
- package/dist/lib/node-esm/chunk-NKZ3O4OR.mjs.map +7 -0
- package/dist/lib/node-esm/compute-graph-registry-2C3Y2RPQ.mjs +22 -0
- package/dist/lib/node-esm/compute-graph-registry-2C3Y2RPQ.mjs.map +7 -0
- package/dist/lib/node-esm/index.mjs +71 -80
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/markdown-YT5KJTQT.mjs +30 -0
- package/dist/lib/node-esm/markdown-YT5KJTQT.mjs.map +7 -0
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/lib/node-esm/operation-resolver-7VD2YXSQ.mjs +80 -0
- package/dist/lib/node-esm/operation-resolver-7VD2YXSQ.mjs.map +7 -0
- package/dist/lib/node-esm/react-surface-7FZAE3S7.mjs +52 -0
- package/dist/lib/node-esm/react-surface-7FZAE3S7.mjs.map +7 -0
- package/dist/lib/node-esm/types/index.mjs +7 -12
- package/dist/types/src/SheetPlugin.d.ts +2 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts +6 -0
- package/dist/types/src/capabilities/anchor-sort/anchor-sort.d.ts.map +1 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts +3 -0
- package/dist/types/src/capabilities/anchor-sort/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts +5 -0
- package/dist/types/src/capabilities/compute-graph-registry/compute-graph-registry.d.ts.map +1 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts +3 -0
- package/dist/types/src/capabilities/compute-graph-registry/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/index.d.ts +5 -9
- package/dist/types/src/capabilities/index.d.ts.map +1 -1
- package/dist/types/src/capabilities/markdown/index.d.ts +3 -0
- package/dist/types/src/capabilities/markdown/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts +5 -0
- package/dist/types/src/capabilities/markdown/markdown.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts +3 -0
- package/dist/types/src/capabilities/operation-resolver/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts +5 -0
- package/dist/types/src/capabilities/operation-resolver/operation-resolver.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts +3 -0
- package/dist/types/src/capabilities/react-surface/index.d.ts.map +1 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts +5 -0
- package/dist/types/src/capabilities/react-surface/react-surface.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts +11 -0
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -0
- package/dist/types/src/components/Sheet/index.d.ts +2 -0
- package/dist/types/src/components/Sheet/index.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.d.ts +1 -1
- package/dist/types/src/components/SheetContent/SheetCellEditor.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts +5 -0
- package/dist/types/src/components/SheetContent/SheetContent.d.ts.map +1 -0
- package/dist/types/src/components/{GridSheet/GridSheet.stories.d.ts → SheetContent/SheetContent.stories.d.ts} +5 -4
- package/dist/types/src/components/SheetContent/SheetContent.stories.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/index.d.ts +2 -0
- package/dist/types/src/components/SheetContent/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetContent/util.d.ts.map +1 -0
- package/dist/types/src/components/{SheetContext/SheetContext.d.ts → SheetRoot/SheetRoot.d.ts} +6 -6
- package/dist/types/src/components/SheetRoot/SheetRoot.d.ts.map +1 -0
- package/dist/types/src/components/SheetRoot/index.d.ts +2 -0
- package/dist/types/src/components/SheetRoot/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts +5 -0
- package/dist/types/src/components/SheetStatusbar/SheetStatusbar.d.ts.map +1 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts +2 -0
- package/dist/types/src/components/SheetStatusbar/index.d.ts.map +1 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts +6 -4
- package/dist/types/src/components/SheetToolbar/SheetToolbar.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts +2 -0
- package/dist/types/src/components/SheetToolbar/SheetToolbar.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/align.d.ts +12 -19
- package/dist/types/src/components/SheetToolbar/align.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/style.d.ts +12 -18
- package/dist/types/src/components/SheetToolbar/style.d.ts.map +1 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts +14 -1
- package/dist/types/src/components/SheetToolbar/useToolbarState.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -4
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/{components → containers}/RangeList/RangeList.d.ts +2 -2
- package/dist/types/src/containers/RangeList/RangeList.d.ts.map +1 -0
- package/dist/types/src/containers/RangeList/index.d.ts +3 -0
- package/dist/types/src/containers/RangeList/index.d.ts.map +1 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts +12 -0
- package/dist/types/src/containers/SheetContainer/SheetContainer.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/SheetContainer.stories.d.ts +4 -3
- package/dist/types/src/containers/SheetContainer/SheetContainer.stories.d.ts.map +1 -0
- package/dist/types/src/{components → containers}/SheetContainer/index.d.ts.map +1 -1
- package/dist/types/src/containers/index.d.ts +4 -0
- package/dist/types/src/containers/index.d.ts.map +1 -0
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- package/dist/types/src/extensions/editor/sheet-extension.d.ts.map +1 -1
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/meta.d.ts +2 -2
- package/dist/types/src/meta.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts +6 -6
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- package/dist/types/src/model/testing.d.ts +2 -2
- package/dist/types/src/model/testing.d.ts.map +1 -1
- package/dist/types/src/model/useSheetModel.d.ts +2 -2
- package/dist/types/src/model/useSheetModel.d.ts.map +1 -1
- package/dist/types/src/serializer.d.ts +2 -2
- package/dist/types/src/serializer.d.ts.map +1 -1
- package/dist/types/src/testing/data.d.ts +2 -2
- package/dist/types/src/testing/data.d.ts.map +1 -1
- package/dist/types/src/testing/testing.d.ts +26 -2
- package/dist/types/src/testing/testing.d.ts.map +1 -1
- package/dist/types/src/translations.d.ts +3 -2
- package/dist/types/src/translations.d.ts.map +1 -1
- package/dist/types/src/types/Sheet.d.ts +76 -0
- package/dist/types/src/types/Sheet.d.ts.map +1 -0
- package/dist/types/src/types/capabilities.d.ts +6 -0
- package/dist/types/src/types/capabilities.d.ts.map +1 -0
- package/dist/types/src/types/index.d.ts +2 -1
- package/dist/types/src/types/index.d.ts.map +1 -1
- package/dist/types/src/types/sheet-range-types.d.ts +2 -2
- package/dist/types/src/types/sheet-range-types.d.ts.map +1 -1
- package/dist/types/src/types/types.d.ts +91 -74
- package/dist/types/src/types/types.d.ts.map +1 -1
- package/dist/types/src/types/util.d.ts +10 -10
- package/dist/types/src/types/util.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +74 -67
- package/src/SheetPlugin.tsx +41 -61
- package/src/capabilities/anchor-sort/anchor-sort.ts +27 -0
- package/src/capabilities/anchor-sort/index.ts +7 -0
- package/src/capabilities/compute-graph-registry/compute-graph-registry.ts +27 -0
- package/src/capabilities/compute-graph-registry/index.ts +7 -0
- package/src/capabilities/index.ts +5 -9
- package/src/capabilities/markdown/index.ts +7 -0
- package/src/capabilities/markdown/markdown.ts +30 -0
- package/src/capabilities/operation-resolver/index.ts +7 -0
- package/src/capabilities/operation-resolver/operation-resolver.ts +77 -0
- package/src/capabilities/react-surface/index.ts +7 -0
- package/src/capabilities/react-surface/react-surface.tsx +46 -0
- package/src/components/ComputeGraph/compute-graph.stories.tsx +10 -10
- package/src/components/Sheet/Sheet.tsx +20 -0
- package/src/components/Sheet/index.ts +5 -0
- package/src/components/{GridSheet → SheetContent}/SheetCellEditor.stories.tsx +13 -10
- package/src/components/{GridSheet/GridSheet.stories.tsx → SheetContent/SheetContent.stories.tsx} +16 -15
- package/src/components/{GridSheet/GridSheet.tsx → SheetContent/SheetContent.tsx} +52 -39
- package/src/components/{RangeList → SheetContent}/index.ts +1 -1
- package/src/components/{GridSheet → SheetContent}/util.ts +14 -8
- package/src/components/{SheetContext/SheetContext.tsx → SheetRoot/SheetRoot.tsx} +42 -40
- package/src/components/{GridSheet → SheetRoot}/index.ts +1 -1
- package/src/components/{FunctionEditor/FunctionEditor.tsx → SheetStatusbar/SheetStatusbar.tsx} +10 -5
- package/src/components/{FunctionEditor → SheetStatusbar}/index.ts +1 -1
- package/src/components/SheetToolbar/SheetToolbar.stories.tsx +4 -4
- package/src/components/SheetToolbar/SheetToolbar.tsx +45 -35
- package/src/components/SheetToolbar/align.ts +44 -19
- package/src/components/SheetToolbar/style.ts +48 -18
- package/src/components/SheetToolbar/useToolbarState.ts +22 -5
- package/src/components/index.ts +1 -7
- package/src/{components → containers}/RangeList/RangeList.tsx +17 -12
- package/src/containers/RangeList/index.ts +7 -0
- package/src/containers/SheetContainer/SheetContainer.stories.tsx +94 -0
- package/src/containers/SheetContainer/SheetContainer.tsx +57 -0
- package/src/{components → containers}/SheetContainer/index.ts +1 -1
- package/src/containers/index.ts +8 -0
- package/src/extensions/compute.stories.tsx +24 -14
- package/src/extensions/compute.ts +1 -1
- package/src/extensions/editor/sheet-extension.ts +16 -13
- package/src/index.ts +1 -1
- package/src/integrations/thread-ranges.ts +38 -49
- package/src/meta.ts +8 -4
- package/src/model/sheet-model.test.ts +4 -4
- package/src/model/sheet-model.ts +80 -48
- package/src/model/testing.ts +4 -4
- package/src/model/useSheetModel.ts +2 -2
- package/src/playwright/playwright.config.ts +1 -1
- package/src/playwright/sheet.spec.ts +2 -1
- package/src/sanity.test.ts +3 -4
- package/src/serializer.ts +4 -4
- package/src/testing/data.ts +2 -2
- package/src/testing/testing.tsx +3 -3
- package/src/translations.ts +3 -2
- package/src/types/Sheet.ts +97 -0
- package/src/{capabilities → types}/capabilities.ts +2 -2
- package/src/types/index.ts +2 -1
- package/src/types/sheet-range-types.ts +5 -5
- package/src/types/types.ts +82 -48
- package/src/types/util.ts +11 -38
- package/dist/lib/browser/SheetContainer-VL34UND4.mjs +0 -351
- package/dist/lib/browser/SheetContainer-VL34UND4.mjs.map +0 -7
- package/dist/lib/browser/anchor-sort-3N44DS5F.mjs +0 -24
- package/dist/lib/browser/anchor-sort-3N44DS5F.mjs.map +0 -7
- package/dist/lib/browser/chunk-ADK2HW4A.mjs +0 -906
- package/dist/lib/browser/chunk-ADK2HW4A.mjs.map +0 -7
- package/dist/lib/browser/chunk-CSBSADPQ.mjs +0 -16
- package/dist/lib/browser/chunk-CSBSADPQ.mjs.map +0 -7
- package/dist/lib/browser/chunk-SSN4HYJL.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZJWJMX4E.mjs +0 -852
- package/dist/lib/browser/chunk-ZJWJMX4E.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZMPNHFIP.mjs +0 -15
- package/dist/lib/browser/chunk-ZMPNHFIP.mjs.map +0 -7
- package/dist/lib/browser/compute-graph-registry-MF65HGGM.mjs +0 -21
- package/dist/lib/browser/compute-graph-registry-MF65HGGM.mjs.map +0 -7
- package/dist/lib/browser/intent-resolver-BQLV6IAA.mjs +0 -56
- package/dist/lib/browser/intent-resolver-BQLV6IAA.mjs.map +0 -7
- package/dist/lib/browser/markdown-RMTMI237.mjs +0 -26
- package/dist/lib/browser/markdown-RMTMI237.mjs.map +0 -7
- package/dist/lib/browser/react-surface-7ZDMQDCT.mjs +0 -53
- package/dist/lib/browser/react-surface-7ZDMQDCT.mjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-NWJ7L6FC.mjs +0 -352
- package/dist/lib/node-esm/SheetContainer-NWJ7L6FC.mjs.map +0 -7
- package/dist/lib/node-esm/anchor-sort-YL2OZHYM.mjs +0 -25
- package/dist/lib/node-esm/anchor-sort-YL2OZHYM.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-BZAPYBSH.mjs +0 -907
- package/dist/lib/node-esm/chunk-BZAPYBSH.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-H3GSD33H.mjs +0 -18
- package/dist/lib/node-esm/chunk-H3GSD33H.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-IK4O7FUJ.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-LN6ZSAII.mjs +0 -16
- package/dist/lib/node-esm/chunk-LN6ZSAII.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-YL7BVJPC.mjs +0 -853
- package/dist/lib/node-esm/chunk-YL7BVJPC.mjs.map +0 -7
- package/dist/lib/node-esm/compute-graph-registry-P2O5LDFZ.mjs +0 -22
- package/dist/lib/node-esm/compute-graph-registry-P2O5LDFZ.mjs.map +0 -7
- package/dist/lib/node-esm/intent-resolver-MV5ZFXAQ.mjs +0 -57
- package/dist/lib/node-esm/intent-resolver-MV5ZFXAQ.mjs.map +0 -7
- package/dist/lib/node-esm/markdown-EDIWHA3P.mjs +0 -27
- package/dist/lib/node-esm/markdown-EDIWHA3P.mjs.map +0 -7
- package/dist/lib/node-esm/react-surface-TUME5MM2.mjs +0 -54
- package/dist/lib/node-esm/react-surface-TUME5MM2.mjs.map +0 -7
- package/dist/types/src/capabilities/anchor-sort.d.ts +0 -6
- package/dist/types/src/capabilities/anchor-sort.d.ts.map +0 -1
- package/dist/types/src/capabilities/capabilities.d.ts +0 -5
- package/dist/types/src/capabilities/capabilities.d.ts.map +0 -1
- package/dist/types/src/capabilities/compute-graph-registry.d.ts +0 -4
- package/dist/types/src/capabilities/compute-graph-registry.d.ts.map +0 -1
- package/dist/types/src/capabilities/intent-resolver.d.ts +0 -4
- package/dist/types/src/capabilities/intent-resolver.d.ts.map +0 -1
- package/dist/types/src/capabilities/markdown.d.ts +0 -4
- package/dist/types/src/capabilities/markdown.d.ts.map +0 -1
- package/dist/types/src/capabilities/react-surface.d.ts +0 -4
- package/dist/types/src/capabilities/react-surface.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts +0 -3
- package/dist/types/src/components/FunctionEditor/FunctionEditor.d.ts.map +0 -1
- package/dist/types/src/components/FunctionEditor/index.d.ts +0 -2
- package/dist/types/src/components/FunctionEditor/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts +0 -3
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/index.d.ts +0 -2
- package/dist/types/src/components/GridSheet/index.d.ts.map +0 -1
- package/dist/types/src/components/GridSheet/util.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/RangeList.d.ts.map +0 -1
- package/dist/types/src/components/RangeList/index.d.ts +0 -2
- package/dist/types/src/components/RangeList/index.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts +0 -11
- package/dist/types/src/components/SheetContainer/SheetContainer.d.ts.map +0 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/SheetContext.d.ts.map +0 -1
- package/dist/types/src/components/SheetContext/index.d.ts +0 -2
- package/dist/types/src/components/SheetContext/index.d.ts.map +0 -1
- package/dist/types/src/types/schema.d.ts +0 -37
- package/dist/types/src/types/schema.d.ts.map +0 -1
- package/src/capabilities/anchor-sort.ts +0 -22
- package/src/capabilities/compute-graph-registry.ts +0 -23
- package/src/capabilities/intent-resolver.ts +0 -38
- package/src/capabilities/markdown.ts +0 -23
- package/src/capabilities/react-surface.tsx +0 -40
- package/src/components/SheetContainer/SheetContainer.stories.tsx +0 -90
- package/src/components/SheetContainer/SheetContainer.tsx +0 -40
- package/src/components/SheetContext/index.ts +0 -5
- package/src/types/schema.ts +0 -61
- /package/dist/types/src/components/{GridSheet → SheetContent}/util.d.ts +0 -0
- /package/dist/types/src/{components → containers}/SheetContainer/index.d.ts +0 -0
|
@@ -7,7 +7,7 @@ import { useEffect, useState } from 'react';
|
|
|
7
7
|
import { type ComputeGraph } from '@dxos/compute';
|
|
8
8
|
|
|
9
9
|
import { SheetModel } from '../model';
|
|
10
|
-
import { type
|
|
10
|
+
import { type Sheet } from '../types';
|
|
11
11
|
|
|
12
12
|
export type UseSheetModelOptions = {
|
|
13
13
|
readonly?: boolean;
|
|
@@ -15,7 +15,7 @@ export type UseSheetModelOptions = {
|
|
|
15
15
|
|
|
16
16
|
export const useSheetModel = (
|
|
17
17
|
graph?: ComputeGraph,
|
|
18
|
-
sheet?:
|
|
18
|
+
sheet?: Sheet.Sheet,
|
|
19
19
|
{ readonly }: UseSheetModelOptions = {},
|
|
20
20
|
): SheetModel | undefined => {
|
|
21
21
|
const [model, setModel] = useState<SheetModel>();
|
|
@@ -10,7 +10,7 @@ export default defineConfig({
|
|
|
10
10
|
...e2ePreset(import.meta.dirname),
|
|
11
11
|
// TODO(wittjosiah): Avoid hard-coding ports.
|
|
12
12
|
webServer: {
|
|
13
|
-
command: '
|
|
13
|
+
command: 'pnpm storybook dev --ci --quiet --port=9005 --config-dir=.storybook',
|
|
14
14
|
port: 9005,
|
|
15
15
|
reuseExistingServer: false,
|
|
16
16
|
},
|
|
@@ -15,7 +15,8 @@ test.describe('plugin-sheet', () => {
|
|
|
15
15
|
|
|
16
16
|
test.beforeEach(async ({ browser }) => {
|
|
17
17
|
const setup = await setupPage(browser, {
|
|
18
|
-
url: storybookUrl('plugins-plugin-sheet-sheetcontainer--spec', 9005),
|
|
18
|
+
url: storybookUrl('plugins-plugin-sheet-containers-sheetcontainer--spec', 9005),
|
|
19
|
+
viewportSize: { width: 1280, height: 720 },
|
|
19
20
|
});
|
|
20
21
|
page = setup.page;
|
|
21
22
|
sheet = new SheetManager(page);
|
package/src/sanity.test.ts
CHANGED
|
@@ -5,8 +5,7 @@
|
|
|
5
5
|
import { describe, expect, test } from 'vitest';
|
|
6
6
|
|
|
7
7
|
import { Client } from '@dxos/client';
|
|
8
|
-
import {
|
|
9
|
-
import { FunctionType } from '@dxos/functions';
|
|
8
|
+
import { Function } from '@dxos/functions';
|
|
10
9
|
|
|
11
10
|
// Part 2.
|
|
12
11
|
// TODO(burdon): Cannot test outside of browser.
|
|
@@ -23,7 +22,7 @@ import { FunctionType } from '@dxos/functions';
|
|
|
23
22
|
describe('test', () => {
|
|
24
23
|
test('test', async () => {
|
|
25
24
|
const client = new Client();
|
|
26
|
-
client.addTypes([
|
|
25
|
+
await client.addTypes([Function.Function]);
|
|
27
26
|
await client.initialize();
|
|
28
27
|
await client.halo.createIdentity();
|
|
29
28
|
|
|
@@ -34,7 +33,7 @@ describe('test', () => {
|
|
|
34
33
|
// - ERROR "process.nextTick is not a function"
|
|
35
34
|
// - ERROR "Identifier 'Buffer' has already been declared" if { nodeExternal: true }
|
|
36
35
|
const space = await client.spaces.create();
|
|
37
|
-
const fn = space.db.add(
|
|
36
|
+
const fn = space.db.add(Function.make({ name: 'test', version: '0.0.1', binding: 'HELLO' }));
|
|
38
37
|
expect(fn).to.exist;
|
|
39
38
|
});
|
|
40
39
|
});
|
package/src/serializer.ts
CHANGED
|
@@ -3,19 +3,19 @@
|
|
|
3
3
|
//
|
|
4
4
|
|
|
5
5
|
import { Obj } from '@dxos/echo';
|
|
6
|
+
import { getObjectCore } from '@dxos/echo-db';
|
|
6
7
|
import { type TypedObjectSerializer } from '@dxos/plugin-space/types';
|
|
7
|
-
import { getObjectCore } from '@dxos/react-client/echo';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { Sheet } from './types';
|
|
10
10
|
|
|
11
|
-
export const serializer: TypedObjectSerializer<
|
|
11
|
+
export const serializer: TypedObjectSerializer<Sheet.Sheet> = {
|
|
12
12
|
serialize: async ({ object }): Promise<string> => {
|
|
13
13
|
return JSON.stringify(object, null, 2);
|
|
14
14
|
},
|
|
15
15
|
|
|
16
16
|
deserialize: async ({ content, newId }) => {
|
|
17
17
|
const { id, ...parsed } = JSON.parse(content);
|
|
18
|
-
const sheet = Obj.make(
|
|
18
|
+
const sheet = Obj.make(Sheet.Sheet, parsed);
|
|
19
19
|
|
|
20
20
|
if (!newId) {
|
|
21
21
|
const core = getObjectCore(sheet);
|
package/src/testing/data.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
// Copyright 2024 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type { Sheet } from '../types';
|
|
6
6
|
|
|
7
|
-
export const createTestCells = (testSheetName = 'test'): Record<string, CellValue> => ({
|
|
7
|
+
export const createTestCells = (testSheetName = 'test'): Record<string, Sheet.CellValue> => ({
|
|
8
8
|
B1: { value: 'Qty2' },
|
|
9
9
|
B3: { value: 1 },
|
|
10
10
|
B4: { value: 2 },
|
package/src/testing/testing.tsx
CHANGED
|
@@ -11,15 +11,15 @@ import { type Space } from '@dxos/react-client/echo';
|
|
|
11
11
|
import { useAsyncState } from '@dxos/react-hooks';
|
|
12
12
|
|
|
13
13
|
import { ComputeGraphContextProvider } from '../components';
|
|
14
|
-
import {
|
|
14
|
+
import { Sheet } from '../types';
|
|
15
15
|
|
|
16
|
-
export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?:
|
|
16
|
+
export const useTestSheet = (space?: Space, graph?: ComputeGraph, options?: Sheet.SheetProps) => {
|
|
17
17
|
const [sheet] = useAsyncState(async () => {
|
|
18
18
|
if (!space || !graph) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
const sheet =
|
|
22
|
+
const sheet = Sheet.make(options);
|
|
23
23
|
space.db.add(sheet);
|
|
24
24
|
return sheet;
|
|
25
25
|
}, [space, graph]);
|
package/src/translations.ts
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
import { type Resource } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
7
|
import { meta } from './meta';
|
|
8
|
-
import {
|
|
8
|
+
import { Sheet } from './types';
|
|
9
9
|
|
|
10
10
|
export const translations = [
|
|
11
11
|
{
|
|
12
12
|
'en-US': {
|
|
13
|
-
[
|
|
13
|
+
[Sheet.Sheet.typename]: {
|
|
14
14
|
'typename label': 'Sheet',
|
|
15
15
|
'typename label_zero': 'Sheets',
|
|
16
16
|
'typename label_one': 'Sheet',
|
|
@@ -18,6 +18,7 @@ export const translations = [
|
|
|
18
18
|
'object name placeholder': 'New sheet',
|
|
19
19
|
'rename object label': 'Rename sheet',
|
|
20
20
|
'delete object label': 'Delete sheet',
|
|
21
|
+
'object deleted label': 'Sheet deleted',
|
|
21
22
|
},
|
|
22
23
|
[meta.id]: {
|
|
23
24
|
'plugin name': 'Sheets',
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Copyright 2023 DXOS.org
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
import * as Schema from 'effect/Schema';
|
|
6
|
+
|
|
7
|
+
import { addressFromA1Notation, isFormula } from '@dxos/compute';
|
|
8
|
+
import { Obj, Type } from '@dxos/echo';
|
|
9
|
+
import { FormInputAnnotation } from '@dxos/echo/internal';
|
|
10
|
+
|
|
11
|
+
import { addressToIndex, initialize, mapFormulaRefsToIndices } from './util';
|
|
12
|
+
|
|
13
|
+
export type SheetSize = {
|
|
14
|
+
rows: number;
|
|
15
|
+
columns: number;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const CellValue = Schema.Struct({
|
|
19
|
+
// TODO(burdon): How to store dates (datetime, date, time), percentages, etc.
|
|
20
|
+
// Consider import/export; natural access for other plugins. Special handling for currency (precision).
|
|
21
|
+
// TODO(burdon): Automerge (long string) or short string or number.
|
|
22
|
+
value: Schema.Any,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export type CellValue = Schema.Schema.Type<typeof CellValue>;
|
|
26
|
+
|
|
27
|
+
// TODO(burdon): IMPORTANT: Reconcile with Field definition.
|
|
28
|
+
export const Range = Schema.Struct({
|
|
29
|
+
range: Schema.String,
|
|
30
|
+
key: Schema.String,
|
|
31
|
+
value: Schema.String,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export type Range = Schema.Schema.Type<typeof Range>;
|
|
35
|
+
|
|
36
|
+
// TODO(burdon): Visibility, locked, frozen, etc.
|
|
37
|
+
export const RowColumnMeta = Schema.Struct({
|
|
38
|
+
size: Schema.optional(Schema.Number),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// TODO(burdon): Reconcile col/column (across packages).
|
|
42
|
+
// TODO(burdon): Index to all updates when rows/columns are inserted/deleted.
|
|
43
|
+
export const Sheet = Schema.Struct({
|
|
44
|
+
name: Schema.optional(Schema.String),
|
|
45
|
+
|
|
46
|
+
// Sparse map of cells referenced by index.
|
|
47
|
+
cells: Schema.Record({ key: Schema.String, value: CellValue }).pipe(FormInputAnnotation.set(false)),
|
|
48
|
+
|
|
49
|
+
// Ordered row indices.
|
|
50
|
+
rows: Schema.Array(Schema.String).pipe(FormInputAnnotation.set(false)),
|
|
51
|
+
|
|
52
|
+
// Ordered column indices.
|
|
53
|
+
columns: Schema.Array(Schema.String).pipe(FormInputAnnotation.set(false)),
|
|
54
|
+
|
|
55
|
+
// Row metadata referenced by index.
|
|
56
|
+
rowMeta: Schema.Record({ key: Schema.String, value: RowColumnMeta }).pipe(FormInputAnnotation.set(false)),
|
|
57
|
+
|
|
58
|
+
// Column metadata referenced by index.
|
|
59
|
+
columnMeta: Schema.Record({ key: Schema.String, value: RowColumnMeta }).pipe(FormInputAnnotation.set(false)),
|
|
60
|
+
|
|
61
|
+
// Cell formatting referenced by indexed range.
|
|
62
|
+
ranges: Schema.Array(Range).pipe(FormInputAnnotation.set(false)),
|
|
63
|
+
}).pipe(
|
|
64
|
+
Type.object({
|
|
65
|
+
typename: 'dxos.org/type/Sheet',
|
|
66
|
+
version: '0.1.0',
|
|
67
|
+
}),
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
export interface Sheet extends Schema.Schema.Type<typeof Sheet> {}
|
|
71
|
+
|
|
72
|
+
export type SheetProps = {
|
|
73
|
+
name?: string;
|
|
74
|
+
cells?: Record<string, CellValue>;
|
|
75
|
+
} & Partial<SheetSize>;
|
|
76
|
+
|
|
77
|
+
export const make = ({ name, cells = {}, ...size }: SheetProps = {}) => {
|
|
78
|
+
const sheet = Obj.make(Sheet, { name, cells: {}, rows: [], columns: [], rowMeta: {}, columnMeta: {}, ranges: [] });
|
|
79
|
+
|
|
80
|
+
// Initialize and set cells within Obj.change to satisfy change context requirements.
|
|
81
|
+
Obj.change(sheet, (s) => {
|
|
82
|
+
initialize(s, size);
|
|
83
|
+
|
|
84
|
+
if (cells) {
|
|
85
|
+
Object.entries(cells).forEach(([key, { value }]) => {
|
|
86
|
+
const idx = addressToIndex(s, addressFromA1Notation(key));
|
|
87
|
+
if (isFormula(value)) {
|
|
88
|
+
value = mapFormulaRefsToIndices(s, value);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
s.cells[idx] = { value };
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return sheet;
|
|
97
|
+
};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// Copyright 2025 DXOS.org
|
|
3
3
|
//
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { Capability } from '@dxos/app-framework';
|
|
6
6
|
import { type ComputeGraphRegistry } from '@dxos/compute';
|
|
7
7
|
|
|
8
8
|
import { meta } from '../meta';
|
|
9
9
|
|
|
10
10
|
export namespace SheetCapabilities {
|
|
11
|
-
export const ComputeGraphRegistry =
|
|
11
|
+
export const ComputeGraphRegistry = Capability.make<ComputeGraphRegistry>(
|
|
12
12
|
`${meta.id}/capability/compute-graph-registry`,
|
|
13
13
|
);
|
|
14
14
|
}
|
package/src/types/index.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
import { type ClassNameValue } from '@dxos/react-ui';
|
|
6
6
|
|
|
7
|
-
import { type
|
|
7
|
+
import { type Sheet } from '../types';
|
|
8
8
|
|
|
9
9
|
export const alignKey = 'alignment';
|
|
10
10
|
export type AlignKey = typeof alignKey;
|
|
@@ -19,7 +19,7 @@ export type StyleKey = typeof styleKey;
|
|
|
19
19
|
export type StyleValue = 'highlight' | 'softwrap';
|
|
20
20
|
|
|
21
21
|
// TODO(burdon): Reconcile with plugin-table.
|
|
22
|
-
export const cellClassNameForRange = ({ key, value }:
|
|
22
|
+
export const cellClassNameForRange = ({ key, value }: Sheet.Sheet['ranges'][number]): ClassNameValue => {
|
|
23
23
|
switch (key) {
|
|
24
24
|
case alignKey:
|
|
25
25
|
switch (value) {
|
|
@@ -34,14 +34,14 @@ export const cellClassNameForRange = ({ key, value }: SheetType['ranges'][number
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
case commentKey:
|
|
37
|
-
return 'bg-
|
|
37
|
+
return 'bg-grid-comment';
|
|
38
38
|
|
|
39
39
|
case styleKey:
|
|
40
40
|
switch (value) {
|
|
41
41
|
case 'highlight':
|
|
42
|
-
return '
|
|
42
|
+
return 'bg-grid-highlight!';
|
|
43
43
|
case 'softwrap':
|
|
44
|
-
return '
|
|
44
|
+
return 'whitespace-normal!';
|
|
45
45
|
default:
|
|
46
46
|
return undefined;
|
|
47
47
|
}
|
package/src/types/types.ts
CHANGED
|
@@ -4,65 +4,99 @@
|
|
|
4
4
|
|
|
5
5
|
import * as Schema from 'effect/Schema';
|
|
6
6
|
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
7
|
+
import { Capability } from '@dxos/app-framework';
|
|
8
|
+
import { Collection } from '@dxos/echo';
|
|
9
|
+
import { Operation } from '@dxos/operation';
|
|
10
|
+
import { SpaceSchema } from '@dxos/react-client/echo';
|
|
9
11
|
|
|
10
|
-
import {
|
|
12
|
+
import { meta } from '../meta';
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
rows: number;
|
|
14
|
-
columns: number;
|
|
15
|
-
};
|
|
14
|
+
import * as Sheet from './Sheet';
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
cells?: Record<string, CellValue>;
|
|
20
|
-
} & Partial<SheetSize>;
|
|
16
|
+
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
17
|
+
const ActionAxis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
21
18
|
|
|
22
19
|
export namespace SheetAction {
|
|
23
|
-
const SHEET_ACTION = `${meta.id}/action`;
|
|
24
|
-
|
|
25
|
-
export class Create extends Schema.TaggedClass<Create>()(`${SHEET_ACTION}/create`, {
|
|
26
|
-
input: Schema.Struct({
|
|
27
|
-
name: Schema.optional(Schema.String),
|
|
28
|
-
}),
|
|
29
|
-
output: Schema.Struct({
|
|
30
|
-
object: SheetType,
|
|
31
|
-
}),
|
|
32
|
-
}) {}
|
|
33
|
-
|
|
34
|
-
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
35
|
-
const Axis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
36
|
-
|
|
37
|
-
export class InsertAxis extends Schema.TaggedClass<InsertAxis>()(`${SHEET_ACTION}/axis-insert`, {
|
|
38
|
-
input: Schema.Struct({
|
|
39
|
-
// TODO(wittjosiah): Schema.instanceOf(SheetModel) throws when running tests.
|
|
40
|
-
model: Schema.Any.pipe(Schema.filter((model) => model instanceof SheetModel)) as Schema.Schema<SheetModel>,
|
|
41
|
-
axis: Axis,
|
|
42
|
-
index: Schema.Number,
|
|
43
|
-
count: Schema.optional(Schema.Number),
|
|
44
|
-
}),
|
|
45
|
-
output: Schema.Void,
|
|
46
|
-
}) {}
|
|
47
|
-
|
|
48
20
|
export const RestoreAxis = Schema.Struct({
|
|
49
|
-
axis:
|
|
21
|
+
axis: ActionAxis,
|
|
50
22
|
axisIndex: Schema.String,
|
|
51
23
|
index: Schema.Number,
|
|
52
|
-
axisMeta: RowColumnMeta,
|
|
24
|
+
axisMeta: Sheet.RowColumnMeta,
|
|
53
25
|
values: Schema.Array(Schema.Any),
|
|
54
26
|
});
|
|
55
27
|
|
|
56
28
|
export type RestoreAxis = Schema.Schema.Type<typeof RestoreAxis>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const SHEET_OPERATION = `${meta.id}/operation`;
|
|
57
32
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
33
|
+
// TODO(wittjosiah): Factor out. This is `DxGridAxis` from `@dxos/react-ui-grid`.
|
|
34
|
+
const Axis = Schema.Union(Schema.Literal('row'), Schema.Literal('col'));
|
|
35
|
+
|
|
36
|
+
export namespace SheetOperation {
|
|
37
|
+
export const OnCreateSpace = Operation.make({
|
|
38
|
+
meta: { key: `${SHEET_OPERATION}/on-create-space`, name: 'On Create Space' },
|
|
39
|
+
services: [Capability.Service],
|
|
40
|
+
schema: {
|
|
41
|
+
input: Schema.Struct({
|
|
42
|
+
space: SpaceSchema,
|
|
43
|
+
rootCollection: Collection.Collection,
|
|
44
|
+
isDefault: Schema.optional(Schema.Boolean),
|
|
45
|
+
}),
|
|
46
|
+
output: Schema.Void,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export const InsertAxis = Operation.make({
|
|
51
|
+
meta: { key: `${SHEET_OPERATION}/axis-insert`, name: 'Insert Axis' },
|
|
52
|
+
schema: {
|
|
53
|
+
input: Schema.Struct({
|
|
54
|
+
model: Schema.Any,
|
|
55
|
+
axis: Axis,
|
|
56
|
+
index: Schema.Number,
|
|
57
|
+
count: Schema.optional(Schema.Number),
|
|
58
|
+
}),
|
|
59
|
+
output: Schema.Void,
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
export const DropAxisOutput = Schema.Struct({
|
|
64
|
+
axis: Axis.annotations({ description: 'The axis type (row or col).' }),
|
|
65
|
+
axisIndex: Schema.String.annotations({ description: 'The dropped axis index.' }),
|
|
66
|
+
index: Schema.Number.annotations({ description: 'The position the axis was at.' }),
|
|
67
|
+
axisMeta: Schema.Any.annotations({ description: 'The row/column metadata.' }),
|
|
68
|
+
values: Schema.Array(Schema.Any).annotations({ description: 'The cell values that were dropped.' }),
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
export type DropAxisOutput = Schema.Schema.Type<typeof DropAxisOutput>;
|
|
72
|
+
|
|
73
|
+
export const DropAxis = Operation.make({
|
|
74
|
+
meta: { key: `${SHEET_OPERATION}/axis-drop`, name: 'Drop Axis' },
|
|
75
|
+
schema: {
|
|
76
|
+
input: Schema.Struct({
|
|
77
|
+
model: Schema.Any,
|
|
78
|
+
axis: Axis,
|
|
79
|
+
axisIndex: Schema.String,
|
|
80
|
+
}),
|
|
81
|
+
output: DropAxisOutput,
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Restore a dropped axis (inverse of DropAxis).
|
|
87
|
+
*/
|
|
88
|
+
export const RestoreAxis = Operation.make({
|
|
89
|
+
meta: { key: `${SHEET_OPERATION}/restore-axis`, name: 'Restore Axis' },
|
|
90
|
+
schema: {
|
|
91
|
+
input: Schema.Struct({
|
|
92
|
+
model: Schema.Any.annotations({ description: 'The sheet model.' }),
|
|
93
|
+
axis: Axis.annotations({ description: 'The axis type (row or col).' }),
|
|
94
|
+
axisIndex: Schema.String.annotations({ description: 'The axis index to restore.' }),
|
|
95
|
+
index: Schema.Number.annotations({ description: 'The position to restore at.' }),
|
|
96
|
+
axisMeta: Schema.Any.annotations({ description: 'The row/column metadata.' }),
|
|
97
|
+
values: Schema.Array(Schema.Any).annotations({ description: 'The cell values to restore.' }),
|
|
98
|
+
}),
|
|
99
|
+
output: Schema.Void,
|
|
100
|
+
},
|
|
101
|
+
});
|
|
68
102
|
}
|
package/src/types/util.ts
CHANGED
|
@@ -11,10 +11,10 @@ import {
|
|
|
11
11
|
isFormula,
|
|
12
12
|
} from '@dxos/compute';
|
|
13
13
|
import { randomBytes } from '@dxos/crypto';
|
|
14
|
-
import { Obj } from '@dxos/echo';
|
|
14
|
+
import { type Obj } from '@dxos/echo';
|
|
15
15
|
import { invariant } from '@dxos/invariant';
|
|
16
16
|
|
|
17
|
-
import { type
|
|
17
|
+
import { type Sheet } from '../types';
|
|
18
18
|
|
|
19
19
|
export const MAX_ROWS = 500;
|
|
20
20
|
export const MAX_COLS = 676; // 26^2;
|
|
@@ -56,8 +56,8 @@ export const insertIndices = (indices: string[], i: number, n: number, max: numb
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
export const initialize = (
|
|
59
|
-
sheet:
|
|
60
|
-
{ rows = DEFAULT_ROWS, columns = DEFAULT_COLS }: Partial<SheetSize> = {},
|
|
59
|
+
sheet: Obj.Mutable<Sheet.Sheet>,
|
|
60
|
+
{ rows = DEFAULT_ROWS, columns = DEFAULT_COLS }: Partial<Sheet.SheetSize> = {},
|
|
61
61
|
) => {
|
|
62
62
|
if (!sheet.rows.length) {
|
|
63
63
|
insertIndices(sheet.rows, 0, rows, MAX_ROWS);
|
|
@@ -67,44 +67,17 @@ export const initialize = (
|
|
|
67
67
|
}
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
export const createSheet = ({ name, cells, ...size }: CreateSheetOptions = {}): SheetType => {
|
|
71
|
-
const sheet = Obj.make(SheetType, {
|
|
72
|
-
name,
|
|
73
|
-
cells: {},
|
|
74
|
-
rows: [],
|
|
75
|
-
columns: [],
|
|
76
|
-
rowMeta: {},
|
|
77
|
-
columnMeta: {},
|
|
78
|
-
ranges: [],
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
initialize(sheet, size);
|
|
82
|
-
|
|
83
|
-
if (cells) {
|
|
84
|
-
Object.entries(cells).forEach(([key, { value }]) => {
|
|
85
|
-
const idx = addressToIndex(sheet, addressFromA1Notation(key));
|
|
86
|
-
if (isFormula(value)) {
|
|
87
|
-
value = mapFormulaRefsToIndices(sheet, value);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
sheet.cells[idx] = { value };
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return sheet;
|
|
95
|
-
};
|
|
96
|
-
|
|
97
70
|
/**
|
|
98
71
|
* E.g., "A1" => "CA2@CB3".
|
|
99
72
|
*/
|
|
100
|
-
export const addressToIndex = (sheet:
|
|
73
|
+
export const addressToIndex = (sheet: Sheet.Sheet, cell: CellAddress): string => {
|
|
101
74
|
return `${sheet.columns[cell.col]}@${sheet.rows[cell.row]}`;
|
|
102
75
|
};
|
|
103
76
|
|
|
104
77
|
/**
|
|
105
78
|
* E.g., "CA2@CB3" => "A1".
|
|
106
79
|
*/
|
|
107
|
-
export const addressFromIndex = (sheet:
|
|
80
|
+
export const addressFromIndex = (sheet: Sheet.Sheet, idx: string): CellAddress => {
|
|
108
81
|
const [column, row] = idx.split('@');
|
|
109
82
|
return {
|
|
110
83
|
col: sheet.columns.indexOf(column),
|
|
@@ -115,14 +88,14 @@ export const addressFromIndex = (sheet: SheetType, idx: string): CellAddress =>
|
|
|
115
88
|
/**
|
|
116
89
|
* E.g., "A1:B2" => "CA2@CB3:CC4@CD5".
|
|
117
90
|
*/
|
|
118
|
-
export const rangeToIndex = (sheet:
|
|
91
|
+
export const rangeToIndex = (sheet: Sheet.Sheet, range: CellRange): string => {
|
|
119
92
|
return [range.from, range.to ?? range.from].map((cell) => addressToIndex(sheet, cell)).join(':');
|
|
120
93
|
};
|
|
121
94
|
|
|
122
95
|
/**
|
|
123
96
|
* E.g., "CA2@CB3:CC4@CD5" => "A1:B2".
|
|
124
97
|
*/
|
|
125
|
-
export const rangeFromIndex = (sheet:
|
|
98
|
+
export const rangeFromIndex = (sheet: Sheet.Sheet, idx: string): CompleteCellRange => {
|
|
126
99
|
const [from, to] = idx.split(':').map((index) => addressFromIndex(sheet, index));
|
|
127
100
|
return { from, to };
|
|
128
101
|
};
|
|
@@ -131,7 +104,7 @@ export const rangeFromIndex = (sheet: SheetType, idx: string): CompleteCellRange
|
|
|
131
104
|
* Compares the positions of two cell indexes in a sheet.
|
|
132
105
|
* Sorts primarily by row, then by column if rows are equal.
|
|
133
106
|
*/
|
|
134
|
-
export const compareIndexPositions = (sheet:
|
|
107
|
+
export const compareIndexPositions = (sheet: Sheet.Sheet, indexA: string, indexB: string): number => {
|
|
135
108
|
const { row: rowA, col: columnA } = addressFromIndex(sheet, indexA);
|
|
136
109
|
const { row: rowB, col: columnB } = addressFromIndex(sheet, indexB);
|
|
137
110
|
|
|
@@ -148,7 +121,7 @@ export const compareIndexPositions = (sheet: SheetType, indexA: string, indexB:
|
|
|
148
121
|
/**
|
|
149
122
|
* Map from A1 notation to indices.
|
|
150
123
|
*/
|
|
151
|
-
export const mapFormulaRefsToIndices = (sheet:
|
|
124
|
+
export const mapFormulaRefsToIndices = (sheet: Sheet.Sheet, formula: string): string => {
|
|
152
125
|
invariant(isFormula(formula));
|
|
153
126
|
return formula.replace(/([a-zA-Z]+)([0-9]+)/g, (match) => {
|
|
154
127
|
return addressToIndex(sheet, addressFromA1Notation(match));
|
|
@@ -158,7 +131,7 @@ export const mapFormulaRefsToIndices = (sheet: SheetType, formula: string): stri
|
|
|
158
131
|
/**
|
|
159
132
|
* Map from indices to A1 notation.
|
|
160
133
|
*/
|
|
161
|
-
export const mapFormulaIndicesToRefs = (sheet:
|
|
134
|
+
export const mapFormulaIndicesToRefs = (sheet: Sheet.Sheet, formula: string): string => {
|
|
162
135
|
invariant(isFormula(formula));
|
|
163
136
|
return formula.replace(/([a-zA-Z0-9]+)@([a-zA-Z0-9]+)/g, (idx) => {
|
|
164
137
|
return addressToA1Notation(addressFromIndex(sheet, idx));
|