@dxos/plugin-sheet 0.6.12-main.f9d0246 → 0.6.12-staging.e11e696
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-VISF3VUB.mjs → SheetContainer-LG77O4RM.mjs} +11 -10
- package/dist/lib/browser/SheetContainer-LG77O4RM.mjs.map +7 -0
- package/dist/lib/browser/{chunk-ZLJ2GRE2.mjs → chunk-CHQAW4F4.mjs} +55 -33
- package/dist/lib/browser/chunk-CHQAW4F4.mjs.map +7 -0
- package/dist/lib/browser/{chunk-Z2XOOC2R.mjs → chunk-GSV5QNLD.mjs} +183 -159
- package/dist/lib/browser/chunk-GSV5QNLD.mjs.map +7 -0
- package/dist/lib/browser/graph-M4IQ76QX.mjs +33 -0
- package/dist/lib/browser/index.mjs +37 -15
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/{SheetContainer-2MEALQWW.cjs → SheetContainer-OZ7DHH4L.cjs} +18 -17
- package/dist/lib/node/SheetContainer-OZ7DHH4L.cjs.map +7 -0
- package/dist/lib/node/{chunk-6DQABRGJ.cjs → chunk-5FTFZL5W.cjs} +57 -35
- package/dist/lib/node/chunk-5FTFZL5W.cjs.map +7 -0
- package/dist/lib/node/{chunk-P5QYYEHQ.cjs → chunk-5XPK2V4A.cjs} +186 -158
- package/dist/lib/node/chunk-5XPK2V4A.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 +38 -18
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/{SheetContainer-RPSUSXWS.mjs → SheetContainer-4XS2G25Z.mjs} +11 -10
- package/dist/lib/node-esm/SheetContainer-4XS2G25Z.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-4MM7THJW.mjs → chunk-5WPZCXNS.mjs} +183 -159
- package/dist/lib/node-esm/chunk-5WPZCXNS.mjs.map +7 -0
- package/dist/lib/node-esm/{chunk-5RLTCIE2.mjs → chunk-KK3XL37M.mjs} +55 -33
- package/dist/lib/node-esm/chunk-KK3XL37M.mjs.map +7 -0
- package/dist/lib/node-esm/graph-SMPUMOV2.mjs +34 -0
- package/dist/lib/node-esm/index.mjs +37 -15
- package/dist/lib/node-esm/index.mjs.map +4 -4
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +1 -1
- package/dist/types/src/components/CellEditor/extension.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
- package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.d.ts +2 -5
- package/dist/types/src/extensions/compute.d.ts.map +1 -1
- package/dist/types/src/extensions/compute.stories.d.ts.map +1 -1
- 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 +13 -33
- package/dist/types/src/graph/compute-graph.d.ts.map +1 -1
- package/dist/types/src/graph/compute-node.d.ts.map +1 -1
- package/dist/types/src/graph/{async-function.d.ts → functions/async-function.d.ts} +6 -3
- 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/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/index.d.ts +2 -1
- package/dist/types/src/graph/index.d.ts.map +1 -1
- package/dist/types/src/graph/testing/index.d.ts +2 -1
- package/dist/types/src/graph/testing/index.d.ts.map +1 -1
- 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/hooks/useComputeGraph.d.ts.map +1 -1
- package/dist/types/src/model/sheet-model.d.ts.map +1 -1
- 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/package.json +40 -39
- package/src/SheetPlugin.tsx +12 -10
- package/src/components/CellEditor/CellEditor.stories.tsx +1 -2
- package/src/components/CellEditor/extension.test.ts +0 -1
- package/src/components/CellEditor/extension.ts +4 -3
- package/src/components/Sheet/Sheet.stories.tsx +2 -2
- package/src/components/Sheet/Sheet.tsx +30 -14
- package/src/components/SheetContainer.tsx +11 -13
- package/src/extensions/compute.stories.tsx +9 -11
- package/src/extensions/compute.ts +66 -50
- package/src/graph/compute-graph-registry.ts +90 -0
- package/src/graph/compute-graph.stories.tsx +2 -2
- package/src/graph/compute-graph.test.ts +31 -71
- package/src/graph/compute-graph.ts +45 -116
- package/src/graph/compute-node.ts +1 -0
- package/src/graph/{async-function.ts → functions/async-function.ts} +10 -9
- package/src/graph/{edge-function.ts → functions/edge-function.ts} +13 -11
- package/src/graph/functions/index.ts +7 -0
- package/src/graph/hyperformula.test.ts +1 -2
- package/src/graph/index.ts +2 -1
- package/src/graph/testing/index.ts +2 -1
- package/src/graph/testing/test-builder.ts +54 -0
- package/src/graph/testing/{custom-function.ts → test-plugin.ts} +38 -12
- package/src/hooks/useComputeGraph.ts +8 -1
- package/src/model/sheet-model.test.ts +59 -0
- package/src/model/sheet-model.ts +4 -2
- package/dist/lib/browser/SheetContainer-VISF3VUB.mjs.map +0 -7
- package/dist/lib/browser/chunk-Z2XOOC2R.mjs.map +0 -7
- package/dist/lib/browser/chunk-ZLJ2GRE2.mjs.map +0 -7
- package/dist/lib/browser/graph-4XFKIHRL.mjs +0 -21
- package/dist/lib/node/SheetContainer-2MEALQWW.cjs.map +0 -7
- package/dist/lib/node/chunk-6DQABRGJ.cjs.map +0 -7
- package/dist/lib/node/chunk-P5QYYEHQ.cjs.map +0 -7
- package/dist/lib/node/graph-2LRDUXBZ.cjs +0 -43
- package/dist/lib/node/graph-2LRDUXBZ.cjs.map +0 -7
- package/dist/lib/node-esm/SheetContainer-RPSUSXWS.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-4MM7THJW.mjs.map +0 -7
- package/dist/lib/node-esm/chunk-5RLTCIE2.mjs.map +0 -7
- package/dist/lib/node-esm/graph-WG5EKOMO.mjs +0 -22
- package/dist/types/src/graph/async-function.d.ts.map +0 -1
- package/dist/types/src/graph/edge-function.d.ts +0 -20
- package/dist/types/src/graph/edge-function.d.ts.map +0 -1
- package/dist/types/src/graph/function-defs.d.ts.map +0 -1
- package/dist/types/src/graph/testing/custom-function.d.ts +0 -23
- package/dist/types/src/graph/testing/custom-function.d.ts.map +0 -1
- /package/dist/lib/browser/{graph-4XFKIHRL.mjs.map → graph-M4IQ76QX.mjs.map} +0 -0
- /package/dist/lib/node-esm/{graph-WG5EKOMO.mjs.map → graph-SMPUMOV2.mjs.map} +0 -0
- /package/dist/types/src/graph/{function-defs.d.ts → functions/function-defs.d.ts} +0 -0
- /package/src/graph/{function-defs.ts → functions/function-defs.ts} +0 -0
|
@@ -15,7 +15,7 @@ export type FunctionOptions = {
|
|
|
15
15
|
};
|
|
16
16
|
export type FunctionContextOptions = {
|
|
17
17
|
defaultTtl: number;
|
|
18
|
-
|
|
18
|
+
debounceDelay: number;
|
|
19
19
|
remoteFunctionUrl: string;
|
|
20
20
|
onUpdate?: (update: FunctionUpdateEvent) => void;
|
|
21
21
|
};
|
|
@@ -56,8 +56,11 @@ export declare class FunctionContext {
|
|
|
56
56
|
/**
|
|
57
57
|
* Base class for async functions.
|
|
58
58
|
*/
|
|
59
|
-
export declare class
|
|
59
|
+
export declare class AsyncFunctionPlugin extends FunctionPlugin {
|
|
60
60
|
get context(): FunctionContext;
|
|
61
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Immediately returns cached value then runs the async function.
|
|
63
|
+
*/
|
|
64
|
+
protected runAsyncFunction(ast: ProcedureAst, state: InterpreterState, cb: AsyncFunction, options?: FunctionOptions): import("hyperformula/typings/interpreter/InterpreterValue").RawInterpreterValue;
|
|
62
65
|
}
|
|
63
66
|
//# sourceMappingURL=async-function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-function.d.ts","sourceRoot":"","sources":["../../../../../src/graph/functions/async-function.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,EAAoC,cAAc,EAAE,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAQpG,MAAM,MAAM,aAAa,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;AAExE,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,GAAG,CAAC,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,KAAK,IAAI,CAAC;CAClD,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAE,sBAI3C,CAAC;AAEF;;;;;;;GAOG;AACH,qBAAa,eAAe;IAyBxB,OAAO,CAAC,QAAQ,CAAC,GAAG;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM;IAxBzB,MAAM,CAAC,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG;IAMrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA8D;IAGrF,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA6B;IAGtD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0C;IAGzE,OAAO,CAAC,YAAY,CAA8B;IAElD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyB;IAGlD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAwC;gBAG/C,GAAG,EAAE,YAAY,EACjB,MAAM,EAAE,KAAK,GAAG,SAAS,EAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC;IAU5C,IAAI,KAAK,sBAER;IAED,IAAI,iBAAiB,WAEpB;IAED,IAAI,IAAI;;;MAEP;IAED,KAAK;IAOL,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,mBAAmB;IAKjE;;;OAGG;IACH,cAAc,CACZ,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,gBAAgB,EACvB,IAAI,EAAE,GAAG,EAAE,EACX,EAAE,EAAE,aAAa,EACjB,OAAO,CAAC,EAAE,eAAe,GACxB,gBAAgB,GAAG,SAAS;CAgChC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,cAAc;IACrD,IAAI,OAAO,IACqB,eAAe,CAC9C;IAED;;OAEG;IACH,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB,EAAE,EAAE,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,eAAe;CAOpH"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
|
|
2
|
+
import { type ProcedureAst } from 'hyperformula/typings/parser';
|
|
3
|
+
import { AsyncFunctionPlugin } from './async-function';
|
|
4
|
+
export declare const EDGE_FUNCTION_NAME = "DX";
|
|
5
|
+
/**
|
|
6
|
+
* A hyperformula function plugin for calling remote (EDGE) functions.
|
|
7
|
+
*
|
|
8
|
+
* https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
|
|
9
|
+
*/
|
|
10
|
+
export declare class EdgeFunctionPlugin extends AsyncFunctionPlugin {
|
|
11
|
+
dx(ast: ProcedureAst, state: InterpreterState): import("hyperformula/typings/interpreter/InterpreterValue").RawInterpreterValue;
|
|
12
|
+
}
|
|
13
|
+
export declare const EdgeFunctionPluginTranslations: {
|
|
14
|
+
enGB: {
|
|
15
|
+
DX: string;
|
|
16
|
+
};
|
|
17
|
+
enUS: {
|
|
18
|
+
DX: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=edge-function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edge-function.d.ts","sourceRoot":"","sources":["../../../../../src/graph/functions/edge-function.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAShE,OAAO,EAAsB,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,eAAO,MAAM,kBAAkB,OAAO,CAAC;AAIvC;;;;GAIG;AACH,qBAAa,kBAAmB,SAAQ,mBAAmB;IACzD,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;CA0C9C;AAuBD,eAAO,MAAM,8BAA8B;;;;;;;CAO1C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-defs.d.ts","sourceRoot":"","sources":["../../../../../src/graph/functions/function-defs.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,kBAAkB,EA42EhD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/graph/functions/index.ts"],"names":[],"mappings":"AAIA,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/graph/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/graph/index.ts"],"names":[],"mappings":"AAIA,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/graph/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/graph/testing/index.ts"],"names":[],"mappings":"AAIA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Client, type ClientOptions } from '@dxos/client';
|
|
2
|
+
import { type Context, Resource } from '@dxos/context';
|
|
3
|
+
import { type ComputeGraphOptions, ComputeGraphRegistry } from '../compute-graph-registry';
|
|
4
|
+
export type TestBuilderOptions = ClientOptions & ComputeGraphOptions;
|
|
5
|
+
export declare class TestBuilder extends Resource {
|
|
6
|
+
private readonly _options;
|
|
7
|
+
private _client?;
|
|
8
|
+
private _registry?;
|
|
9
|
+
constructor(_options?: TestBuilderOptions);
|
|
10
|
+
get ctx(): Context;
|
|
11
|
+
get client(): Client;
|
|
12
|
+
get registry(): ComputeGraphRegistry;
|
|
13
|
+
_open(): Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=test-builder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-builder.d.ts","sourceRoot":"","sources":["../../../../../src/graph/testing/test-builder.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,KAAK,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,EAAE,KAAK,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAE3F,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,mBAAmB,CAAC;AAGrE,qBAAa,WAAY,SAAQ,QAAQ;IAI3B,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAHrC,OAAO,CAAC,OAAO,CAAC,CAAS;IACzB,OAAO,CAAC,SAAS,CAAC,CAAuB;gBAEZ,QAAQ,GAAE,kBAAuB;IAI9D,IAAI,GAAG,IAAI,OAAO,CAEjB;IAED,IAAI,MAAM,IAAI,MAAM,CAGnB;IAED,IAAI,QAAQ,IAAI,oBAAoB,CAGnC;IAEc,KAAK;CAkBrB"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type InterpreterState } from 'hyperformula/typings/interpreter/InterpreterState';
|
|
2
|
+
import { type ProcedureAst } from 'hyperformula/typings/parser';
|
|
3
|
+
import { type ComputeGraphPlugin } from '../compute-graph-registry';
|
|
4
|
+
import { AsyncFunctionPlugin } from '../functions';
|
|
5
|
+
/**
|
|
6
|
+
* Testing functions run locally (not run via EDGE).
|
|
7
|
+
* https://hyperformula.handsontable.com/guide/custom-functions.html#add-a-simple-custom-function
|
|
8
|
+
*/
|
|
9
|
+
export declare class TestPlugin extends AsyncFunctionPlugin {
|
|
10
|
+
/**
|
|
11
|
+
* Simple local function returns input value.
|
|
12
|
+
*/
|
|
13
|
+
test(ast: ProcedureAst, state: InterpreterState): import("hyperformula/typings/interpreter/InterpreterValue").RawInterpreterValue;
|
|
14
|
+
/**
|
|
15
|
+
* Simple local function returns random number.
|
|
16
|
+
*/
|
|
17
|
+
random(ast: ProcedureAst, state: InterpreterState): import("hyperformula/typings/interpreter/InterpreterValue").RawInterpreterValue;
|
|
18
|
+
/**
|
|
19
|
+
* Async HTTP function.
|
|
20
|
+
*/
|
|
21
|
+
crypto(ast: ProcedureAst, state: InterpreterState): import("hyperformula/typings/interpreter/InterpreterValue").RawInterpreterValue;
|
|
22
|
+
}
|
|
23
|
+
export declare const TestPluginTranslations: {
|
|
24
|
+
enGB: {
|
|
25
|
+
TEST: string;
|
|
26
|
+
RANDOM: string;
|
|
27
|
+
CRYPTO: string;
|
|
28
|
+
};
|
|
29
|
+
enUS: {
|
|
30
|
+
TEST: string;
|
|
31
|
+
RANDOM: string;
|
|
32
|
+
CRYPTO: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export declare const testFunctionPlugins: ComputeGraphPlugin[];
|
|
36
|
+
//# sourceMappingURL=test-plugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-plugin.d.ts","sourceRoot":"","sources":["../../../../../src/graph/testing/test-plugin.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAsB,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAGvE;;;GAGG;AACH,qBAAa,UAAW,SAAQ,mBAAmB;IACjD;;OAEG;IACH,IAAI,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAQ/C;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;IAQjD;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,YAAY,EAAE,KAAK,EAAE,gBAAgB;CAelD;AAsBD,eAAO,MAAM,sBAAsB;;;;;;;;;;;CAWlC,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,kBAAkB,EAKnD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useComputeGraph.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useComputeGraph.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAIrD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,eAAe,WAAY,KAAK,KAAG,YAAY,GAAG,
|
|
1
|
+
{"version":3,"file":"useComputeGraph.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useComputeGraph.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAIrD,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C;;GAEG;AACH,eAAO,MAAM,eAAe,WAAY,KAAK,KAAG,YAAY,GAAG,SAW9D,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sheet-model.d.ts","sourceRoot":"","sources":["../../../../src/model/sheet-model.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE3F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"sheet-model.d.ts","sourceRoot":"","sources":["../../../../src/model/sheet-model.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAE3F,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOzC,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,SAAS,EAGf,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAoB,KAAK,YAAY,EAAmB,KAAK,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACvG,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AA4B/F,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF;;;;GAIG;AAEH,qBAAa,UAAW,SAAQ,QAAQ;IASpC,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAV3B,SAAgB,EAAE,SAA4C;IAG9D,SAAgB,MAAM,0BAAiC;IAEvD,OAAO,CAAC,KAAK,CAAC,CAAc;gBAGT,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,SAAS,EACjB,QAAQ,GAAE,iBAAsB;IAKnD,IAAI,KAAK,iBAER;IAED,IAAI,KAAK,cAER;IAED,IAAI,QAAQ,wBAEX;IAED,IAAI,MAAM;;;MAKT;IAED;;OAEG;cACsB,KAAK;IAe9B;;;;OAIG;IACH,KAAK;IAgBL;;;;;OAKG;IAEH,WAAW;IAIX,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,SAAI;IAK3B,aAAa,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,SAAI;IAU9B;;OAEG;IACH,KAAK,CAAC,KAAK,EAAE,SAAS;IAWtB,GAAG,CAAC,KAAK,EAAE,SAAS;IASpB,IAAI,CAAC,KAAK,EAAE,SAAS;IAKrB,KAAK,CAAC,IAAI,EAAE,WAAW;IAevB,IAAI;IAQJ,IAAI;IAQJ;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe;IAKhD;;OAEG;IACH,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,SAAS;IAalD;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,SAAS,GAAG,eAAe,EAAE,EAAE;IAIpD;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,eAAe;IAW5C;;OAEG;IACH,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,aAAa;IAO9C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,WAAW,EAAE,KAAK,EAAE,eAAe;IAwClD;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC;IAM3C;;OAEG;IACH,OAAO,CAAC,UAAU;IAqBlB,OAAO,CAAC,cAAc;IAKtB,OAAO,CAAC,YAAY;IAQpB;;OAEG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAOhD;;OAEG;IACH,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAWhD;;;;OAIG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAK9B,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc;IAKvC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAK/B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;CAIhC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sheet-model.test.d.ts","sourceRoot":"","sources":["../../../../src/model/sheet-model.test.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dxos/plugin-sheet",
|
|
3
|
-
"version": "0.6.12-
|
|
3
|
+
"version": "0.6.12-staging.e11e696",
|
|
4
4
|
"description": "Braneframe sketch plugin",
|
|
5
5
|
"homepage": "https://dxos.org",
|
|
6
6
|
"bugs": "https://github.com/dxos/dxos/issues",
|
|
@@ -57,16 +57,17 @@
|
|
|
57
57
|
"src"
|
|
58
58
|
],
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@codemirror/autocomplete": "^6.18.
|
|
61
|
-
"@codemirror/language": "^6.10.
|
|
60
|
+
"@codemirror/autocomplete": "^6.18.1",
|
|
61
|
+
"@codemirror/language": "^6.10.3",
|
|
62
62
|
"@codemirror/state": "^6.4.1",
|
|
63
|
-
"@codemirror/view": "^6.
|
|
63
|
+
"@codemirror/view": "^6.34.1",
|
|
64
64
|
"@dnd-kit/core": "^6.0.5",
|
|
65
65
|
"@dnd-kit/modifiers": "^6.0.0",
|
|
66
66
|
"@dnd-kit/sortable": "^7.0.1",
|
|
67
67
|
"@dnd-kit/utilities": "^3.2.0",
|
|
68
|
-
"@
|
|
69
|
-
"@lezer/
|
|
68
|
+
"@effect/schema": "^0.67.16",
|
|
69
|
+
"@lezer/common": "^1.2.2",
|
|
70
|
+
"@lezer/highlight": "^1.2.1",
|
|
70
71
|
"@lezer/lezer": "^1.1.2",
|
|
71
72
|
"@lezer/lr": "^1.4.2",
|
|
72
73
|
"@preact/signals-core": "^1.6.0",
|
|
@@ -78,29 +79,29 @@
|
|
|
78
79
|
"re-resizable": "^6.9.17",
|
|
79
80
|
"react-markdown": "^8.0.5",
|
|
80
81
|
"react-resize-detector": "^11.0.1",
|
|
81
|
-
"@dxos/app-framework": "0.6.12-
|
|
82
|
-
"@dxos/
|
|
83
|
-
"@dxos/
|
|
84
|
-
"@dxos/
|
|
85
|
-
"@dxos/
|
|
86
|
-
"@dxos/
|
|
87
|
-
"@dxos/invariant": "0.6.12-
|
|
88
|
-
"@dxos/
|
|
89
|
-
"@dxos/keys": "0.6.12-
|
|
90
|
-
"@dxos/log": "0.6.12-
|
|
91
|
-
"@dxos/plugin-
|
|
92
|
-
"@dxos/plugin-
|
|
93
|
-
"@dxos/plugin-
|
|
94
|
-
"@dxos/plugin-
|
|
95
|
-
"@dxos/plugin-
|
|
96
|
-
"@dxos/plugin-
|
|
97
|
-
"@dxos/
|
|
98
|
-
"@dxos/
|
|
99
|
-
"@dxos/react-
|
|
100
|
-
"@dxos/react-
|
|
101
|
-
"@dxos/react-ui-
|
|
102
|
-
"@dxos/react-ui-
|
|
103
|
-
"@dxos/util": "0.6.12-
|
|
82
|
+
"@dxos/app-framework": "0.6.12-staging.e11e696",
|
|
83
|
+
"@dxos/async": "0.6.12-staging.e11e696",
|
|
84
|
+
"@dxos/client": "0.6.12-staging.e11e696",
|
|
85
|
+
"@dxos/context": "0.6.12-staging.e11e696",
|
|
86
|
+
"@dxos/debug": "0.6.12-staging.e11e696",
|
|
87
|
+
"@dxos/echo-schema": "0.6.12-staging.e11e696",
|
|
88
|
+
"@dxos/invariant": "0.6.12-staging.e11e696",
|
|
89
|
+
"@dxos/crypto": "0.6.12-staging.e11e696",
|
|
90
|
+
"@dxos/keys": "0.6.12-staging.e11e696",
|
|
91
|
+
"@dxos/log": "0.6.12-staging.e11e696",
|
|
92
|
+
"@dxos/plugin-client": "0.6.12-staging.e11e696",
|
|
93
|
+
"@dxos/plugin-attention": "0.6.12-staging.e11e696",
|
|
94
|
+
"@dxos/plugin-markdown": "0.6.12-staging.e11e696",
|
|
95
|
+
"@dxos/plugin-graph": "0.6.12-staging.e11e696",
|
|
96
|
+
"@dxos/plugin-script": "0.6.12-staging.e11e696",
|
|
97
|
+
"@dxos/plugin-stack": "0.6.12-staging.e11e696",
|
|
98
|
+
"@dxos/plugin-space": "0.6.12-staging.e11e696",
|
|
99
|
+
"@dxos/react-client": "0.6.12-staging.e11e696",
|
|
100
|
+
"@dxos/react-hooks": "0.6.12-staging.e11e696",
|
|
101
|
+
"@dxos/react-ui-editor": "0.6.12-staging.e11e696",
|
|
102
|
+
"@dxos/react-ui-grid": "0.6.12-staging.e11e696",
|
|
103
|
+
"@dxos/react-ui-attention": "0.6.12-staging.e11e696",
|
|
104
|
+
"@dxos/util": "0.6.12-staging.e11e696"
|
|
104
105
|
},
|
|
105
106
|
"devDependencies": {
|
|
106
107
|
"@lezer/generator": "^1.7.1",
|
|
@@ -113,20 +114,20 @@
|
|
|
113
114
|
"react": "~18.2.0",
|
|
114
115
|
"react-dom": "~18.2.0",
|
|
115
116
|
"vite": "5.4.7",
|
|
116
|
-
"@dxos/
|
|
117
|
-
"@dxos/
|
|
118
|
-
"@dxos/react-ui": "0.6.12-
|
|
119
|
-
"@dxos/react-ui-
|
|
120
|
-
"@dxos/react-ui-
|
|
121
|
-
"@dxos/storybook-utils": "0.6.12-
|
|
122
|
-
"@dxos/react-ui-
|
|
117
|
+
"@dxos/echo-generator": "0.6.12-staging.e11e696",
|
|
118
|
+
"@dxos/random": "0.6.12-staging.e11e696",
|
|
119
|
+
"@dxos/react-ui": "0.6.12-staging.e11e696",
|
|
120
|
+
"@dxos/react-ui-theme": "0.6.12-staging.e11e696",
|
|
121
|
+
"@dxos/react-ui-syntax-highlighter": "0.6.12-staging.e11e696",
|
|
122
|
+
"@dxos/storybook-utils": "0.6.12-staging.e11e696",
|
|
123
|
+
"@dxos/react-ui-types": "0.6.12-staging.e11e696"
|
|
123
124
|
},
|
|
124
|
-
"
|
|
125
|
+
"peerDependencies": {
|
|
125
126
|
"@phosphor-icons/react": "^2.1.5",
|
|
126
127
|
"react": "~18.2.0",
|
|
127
128
|
"react-dom": "~18.2.0",
|
|
128
|
-
"@dxos/react-ui": "0.6.12-
|
|
129
|
-
"@dxos/react-ui-theme": "0.6.12-
|
|
129
|
+
"@dxos/react-ui": "0.6.12-staging.e11e696",
|
|
130
|
+
"@dxos/react-ui-theme": "0.6.12-staging.e11e696"
|
|
130
131
|
},
|
|
131
132
|
"publishConfig": {
|
|
132
133
|
"access": "public"
|
package/src/SheetPlugin.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import { getSpace, isEchoObject } from '@dxos/react-client/echo';
|
|
|
15
15
|
|
|
16
16
|
import { ComputeGraphContextProvider, SheetContainer } from './components';
|
|
17
17
|
import { compareIndexPositions, createSheet } from './defs';
|
|
18
|
+
import { computeGraphFacet } from './extensions';
|
|
18
19
|
import { type ComputeGraphRegistry } from './graph';
|
|
19
20
|
import { useComputeGraph } from './hooks';
|
|
20
21
|
import meta, { SHEET_PLUGIN } from './meta';
|
|
@@ -22,7 +23,7 @@ import translations from './translations';
|
|
|
22
23
|
import { SheetAction, SheetType, type SheetPluginProvides } from './types';
|
|
23
24
|
|
|
24
25
|
export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
25
|
-
let
|
|
26
|
+
let computeGraphRegistry: ComputeGraphRegistry | undefined;
|
|
26
27
|
|
|
27
28
|
return {
|
|
28
29
|
meta,
|
|
@@ -38,12 +39,12 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
38
39
|
|
|
39
40
|
// Async import removes direct dependency on hyperformula.
|
|
40
41
|
const { ComputeGraphRegistry } = await import('./graph');
|
|
41
|
-
|
|
42
|
+
computeGraphRegistry = new ComputeGraphRegistry({ remoteFunctionUrl });
|
|
42
43
|
},
|
|
43
44
|
provides: {
|
|
44
45
|
context: ({ children }) => {
|
|
45
|
-
invariant(
|
|
46
|
-
return <ComputeGraphContextProvider registry={
|
|
46
|
+
invariant(computeGraphRegistry);
|
|
47
|
+
return <ComputeGraphContextProvider registry={computeGraphRegistry}>{children}</ComputeGraphContextProvider>;
|
|
47
48
|
},
|
|
48
49
|
metadata: {
|
|
49
50
|
records: {
|
|
@@ -109,12 +110,13 @@ export const SheetPlugin = (): PluginDefinition<SheetPluginProvides> => {
|
|
|
109
110
|
},
|
|
110
111
|
},
|
|
111
112
|
markdown: {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
113
|
+
extensions: ({ document: doc }) => {
|
|
114
|
+
invariant(computeGraphRegistry);
|
|
115
|
+
const space = getSpace(doc);
|
|
116
|
+
if (space) {
|
|
117
|
+
const computeGraph = computeGraphRegistry.getOrCreateGraph(space);
|
|
118
|
+
return computeGraphFacet.of(computeGraph);
|
|
119
|
+
}
|
|
118
120
|
},
|
|
119
121
|
},
|
|
120
122
|
stack: {
|
|
@@ -42,11 +42,10 @@ const AutomergeStory = ({ value, ...props }: StoryProps) => {
|
|
|
42
42
|
const [object, setObject] = useState<EchoReactiveObject<SheetType>>();
|
|
43
43
|
useEffect(() => {
|
|
44
44
|
setTimeout(async () => {
|
|
45
|
-
const client = new Client();
|
|
45
|
+
const client = new Client({ types: [SheetType] });
|
|
46
46
|
await client.initialize();
|
|
47
47
|
await client.halo.createIdentity();
|
|
48
48
|
const space = await client.spaces.create();
|
|
49
|
-
client.addTypes([SheetType]);
|
|
50
49
|
|
|
51
50
|
const sheet = createSheet();
|
|
52
51
|
sheet.name = 'Test';
|
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import { CompletionContext, type CompletionSource } from '@codemirror/autocomplete';
|
|
6
6
|
import { EditorState } from '@codemirror/state';
|
|
7
|
-
// @ts-ignore
|
|
8
7
|
import { testTree } from '@lezer/generator/test';
|
|
9
8
|
import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
10
9
|
import { describe, expect, test } from 'vitest';
|
|
@@ -12,12 +12,13 @@ import {
|
|
|
12
12
|
startCompletion,
|
|
13
13
|
} from '@codemirror/autocomplete';
|
|
14
14
|
import { HighlightStyle, type Language, syntaxHighlighting } from '@codemirror/language';
|
|
15
|
-
import { type Extension
|
|
15
|
+
import { type Extension } from '@codemirror/state';
|
|
16
16
|
import { type EditorView, ViewPlugin, type ViewUpdate, keymap } from '@codemirror/view';
|
|
17
17
|
import { type SyntaxNode } from '@lezer/common';
|
|
18
18
|
import { tags } from '@lezer/highlight';
|
|
19
19
|
import { spreadsheet } from 'codemirror-lang-spreadsheet';
|
|
20
20
|
|
|
21
|
+
import { singleValueFacet } from '@dxos/react-ui-editor/state';
|
|
21
22
|
import { mx } from '@dxos/react-ui-theme';
|
|
22
23
|
|
|
23
24
|
import { type FunctionDefinition } from '../../graph';
|
|
@@ -59,7 +60,7 @@ const highlightStyles = HighlightStyle.define([
|
|
|
59
60
|
},
|
|
60
61
|
]);
|
|
61
62
|
|
|
62
|
-
const languageFacet =
|
|
63
|
+
const languageFacet = singleValueFacet<Language>();
|
|
63
64
|
|
|
64
65
|
export type SheetExtensionOptions = {
|
|
65
66
|
functions?: FunctionDefinition[];
|
|
@@ -229,7 +230,7 @@ export const rangeExtension = (onInit: (notifier: CellRangeNotifier) => void): E
|
|
|
229
230
|
|
|
230
231
|
// Find first Range or cell at cursor.
|
|
231
232
|
activeRange = undefined;
|
|
232
|
-
const
|
|
233
|
+
const language = view.state.facet(languageFacet);
|
|
233
234
|
const { topNode } = language.parser.parse(view.state.doc.toString());
|
|
234
235
|
visitTree(topNode, ({ type, from, to }) => {
|
|
235
236
|
if (from <= anchor && to >= anchor) {
|
|
@@ -18,7 +18,7 @@ import { type SizeMap } from './grid';
|
|
|
18
18
|
import { useSheetContext } from './sheet-context';
|
|
19
19
|
import { addressToIndex, rangeToIndex } from '../../defs';
|
|
20
20
|
import { type ComputeGraph } from '../../graph';
|
|
21
|
-
import {
|
|
21
|
+
import { testFunctionPlugins } from '../../graph/testing';
|
|
22
22
|
import { useComputeGraph } from '../../hooks';
|
|
23
23
|
import { createTestCells, useTestSheet, withComputeGraphDecorator } from '../../testing';
|
|
24
24
|
import { SheetType, ValueTypeEnum } from '../../types';
|
|
@@ -105,7 +105,7 @@ export default {
|
|
|
105
105
|
component: Sheet,
|
|
106
106
|
decorators: [
|
|
107
107
|
withClientProvider({ types: [SheetType], createIdentity: true }),
|
|
108
|
-
withComputeGraphDecorator({ plugins:
|
|
108
|
+
withComputeGraphDecorator({ plugins: testFunctionPlugins }),
|
|
109
109
|
withTheme,
|
|
110
110
|
withLayout({ fullscreen: true, tooltips: true, classNames: 'inset-4' }),
|
|
111
111
|
],
|
|
@@ -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 {
|
|
@@ -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
|
|
@@ -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
|
//
|
|
@@ -6,18 +6,12 @@ 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';
|
|
@@ -26,7 +20,8 @@ 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 = ({ graph, sheet, role }: SheetRootProps & { role?: string
|
|
|
49
44
|
);
|
|
50
45
|
|
|
51
46
|
return (
|
|
52
|
-
<div
|
|
47
|
+
<div
|
|
48
|
+
role='none'
|
|
49
|
+
className={role === 'article' ? 'row-span-2 grid grid-rows-subgrid' : undefined}
|
|
50
|
+
{...(role === 'article' && attendableAttrs)}
|
|
51
|
+
>
|
|
53
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 = ({ graph, sheet, role }: SheetRootProps & { role?: string
|
|
|
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 />
|