@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
|
@@ -2,18 +2,18 @@ import {
|
|
|
2
2
|
Sheet,
|
|
3
3
|
addressToIndex,
|
|
4
4
|
useSheetContext
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-CHQAW4F4.mjs";
|
|
6
6
|
import "./chunk-WZMOZKQZ.mjs";
|
|
7
7
|
import {
|
|
8
8
|
SHEET_PLUGIN
|
|
9
9
|
} from "./chunk-QILRZNE5.mjs";
|
|
10
|
-
import "./chunk-
|
|
10
|
+
import "./chunk-GSV5QNLD.mjs";
|
|
11
11
|
|
|
12
12
|
// packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
|
|
13
13
|
import React3, { useCallback } from "react";
|
|
14
14
|
import { useIntentDispatcher } from "@dxos/app-framework";
|
|
15
15
|
import { fullyQualifiedId } from "@dxos/react-client/echo";
|
|
16
|
-
import {
|
|
16
|
+
import { useAttendableAttributes, useAttention } from "@dxos/react-ui-attention";
|
|
17
17
|
import { focusRing, mx } from "@dxos/react-ui-theme";
|
|
18
18
|
|
|
19
19
|
// packages/plugins/plugin-sheet/src/components/Toolbar/Toolbar.tsx
|
|
@@ -209,12 +209,12 @@ var Toolbar = {
|
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
// packages/plugins/plugin-sheet/src/components/SheetContainer.tsx
|
|
212
|
-
var attentionFragment = mx("group-focus-within/editor:attention-surface group-[[aria-current]]/editor:attention-surface", "group-focus-within/editor:border-separator");
|
|
213
212
|
var sectionToolbarLayout = "bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity";
|
|
214
213
|
var SheetContainer = ({ graph, sheet, role }) => {
|
|
215
214
|
const dispatch = useIntentDispatcher();
|
|
216
215
|
const id = fullyQualifiedId(sheet);
|
|
217
|
-
const
|
|
216
|
+
const attendableAttrs = useAttendableAttributes(id);
|
|
217
|
+
const { hasAttention } = useAttention(id);
|
|
218
218
|
const handleAction = useCallback((action) => {
|
|
219
219
|
switch (action.type) {
|
|
220
220
|
case "comment": {
|
|
@@ -234,7 +234,8 @@ var SheetContainer = ({ graph, sheet, role }) => {
|
|
|
234
234
|
]);
|
|
235
235
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
236
236
|
role: "none",
|
|
237
|
-
className: role === "article" ? "row-span-2 grid grid-rows-subgrid" : void 0
|
|
237
|
+
className: role === "article" ? "row-span-2 grid grid-rows-subgrid" : void 0,
|
|
238
|
+
...role === "article" && attendableAttrs
|
|
238
239
|
}, /* @__PURE__ */ React3.createElement(Sheet.Root, {
|
|
239
240
|
graph,
|
|
240
241
|
sheet
|
|
@@ -245,12 +246,12 @@ var SheetContainer = ({ graph, sheet, role }) => {
|
|
|
245
246
|
onAction: handleAction,
|
|
246
247
|
classNames: mx(role === "section" ? [
|
|
247
248
|
"z-[2] group-focus-within/section:visible",
|
|
248
|
-
!
|
|
249
|
+
!hasAttention && "invisible",
|
|
249
250
|
sectionToolbarLayout
|
|
250
|
-
] : "
|
|
251
|
+
] : "attention-surface")
|
|
251
252
|
}, /* @__PURE__ */ React3.createElement(Toolbar.Separator, null), /* @__PURE__ */ React3.createElement(Toolbar.Actions, null))), /* @__PURE__ */ React3.createElement("div", {
|
|
252
253
|
role: "none",
|
|
253
|
-
className: mx(role === "section" && "aspect-square border-is border-bs border-be border-separator", role === "article" && "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", focusRing
|
|
254
|
+
className: mx(role === "section" && "aspect-square border-is border-bs border-be border-separator", role === "article" && "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", focusRing)
|
|
254
255
|
}, /* @__PURE__ */ React3.createElement(Sheet.Main, null))));
|
|
255
256
|
};
|
|
256
257
|
var SheetContainer_default = SheetContainer;
|
|
@@ -258,4 +259,4 @@ export {
|
|
|
258
259
|
SheetContainer_default as default,
|
|
259
260
|
sectionToolbarLayout
|
|
260
261
|
};
|
|
261
|
-
//# sourceMappingURL=SheetContainer-
|
|
262
|
+
//# sourceMappingURL=SheetContainer-LG77O4RM.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/SheetContainer.tsx", "../../../src/components/Toolbar/Toolbar.tsx", "../../../src/components/Toolbar/common.tsx"],
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React, { useCallback } from 'react';\n\nimport { useIntentDispatcher } from '@dxos/app-framework';\nimport { fullyQualifiedId } from '@dxos/react-client/echo';\nimport { useAttendableAttributes, useAttention } from '@dxos/react-ui-attention';\nimport { focusRing, mx } from '@dxos/react-ui-theme';\n\nimport { Sheet, type SheetRootProps } from './Sheet';\nimport { Toolbar, type ToolbarAction } from './Toolbar';\n\n// TODO(Zan): Factor out, copied this from MarkdownPlugin.\nexport const sectionToolbarLayout =\n 'bs-[--rail-action] bg-[--sticky-bg] sticky block-start-0 __-block-start-px transition-opacity';\n\nconst SheetContainer = ({ graph, sheet, role }: SheetRootProps & { role?: string }) => {\n const dispatch = useIntentDispatcher();\n\n const id = fullyQualifiedId(sheet);\n const attendableAttrs = useAttendableAttributes(id);\n const { hasAttention } = useAttention(id);\n\n // TODO(Zan): Centralise the toolbar action handler. Current implementation in stories.\n const handleAction = useCallback(\n (action: ToolbarAction) => {\n switch (action.type) {\n case 'comment': {\n // TODO(Zan): We shouldn't hardcode the action ID.\n void dispatch({\n action: 'dxos.org/plugin/thread/action/create',\n data: {\n cursor: action.anchor,\n name: action.cellContent,\n subject: sheet,\n },\n });\n }\n }\n },\n [sheet, dispatch],\n );\n\n return (\n <div\n role='none'\n className={role === 'article' ? 'row-span-2 grid grid-rows-subgrid' : undefined}\n {...(role === 'article' && attendableAttrs)}\n >\n <Sheet.Root graph={graph} sheet={sheet}>\n <div role='none' className={mx('flex flex-0 justify-center overflow-x-auto')}>\n <Toolbar.Root\n onAction={handleAction}\n classNames={mx(\n role === 'section'\n ? ['z-[2] group-focus-within/section:visible', !hasAttention && 'invisible', sectionToolbarLayout]\n : 'attention-surface',\n )}\n >\n {/* TODO(Zan): Restore some of this functionality */}\n {/* <Toolbar.Styles /> */}\n {/* <Toolbar.Format /> */}\n {/* <Toolbar.Alignment /> */}\n <Toolbar.Separator />\n <Toolbar.Actions />\n </Toolbar.Root>\n </div>\n <div\n role='none'\n className={mx(\n role === 'section' && 'aspect-square border-is border-bs border-be border-separator',\n role === 'article' &&\n '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',\n focusRing,\n )}\n >\n <Sheet.Main />\n </div>\n </Sheet.Root>\n </div>\n );\n};\n\nexport default SheetContainer;\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport {\n type Icon,\n Calendar,\n ChatText,\n CurrencyDollar,\n Eraser,\n HighlighterCircle,\n TextAlignCenter,\n TextAlignLeft,\n TextAlignRight,\n} from '@phosphor-icons/react';\nimport { createContext } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren } from 'react';\n\nimport {\n DensityProvider,\n ElevationProvider,\n Toolbar as NaturalToolbar,\n type ThemedClassName,\n useTranslation,\n} from '@dxos/react-ui';\nimport { nonNullable } from '@dxos/util';\n\nimport { ToolbarButton, ToolbarSeparator, ToolbarToggleButton } from './common';\nimport { addressToIndex } from '../../defs';\nimport { SHEET_PLUGIN } from '../../meta';\nimport { type Formatting } from '../../types';\nimport { useSheetContext } from '../Sheet/sheet-context';\n\n//\n// Root\n//\n\nexport type ToolbarAction =\n | { type: 'clear' }\n | { type: 'highlight' }\n | { type: 'left' }\n | { type: 'center' }\n | { type: 'right' }\n | { type: 'date' }\n | { type: 'currency' }\n | { type: 'comment'; anchor: string; cellContent?: string };\n\nexport type ToolbarActionType = ToolbarAction['type'];\n\nexport type ToolbarActionHandler = (action: ToolbarAction) => void;\n\nexport type ToolbarProps = ThemedClassName<\n PropsWithChildren<{\n onAction?: ToolbarActionHandler;\n }>\n>;\n\nconst [ToolbarContextProvider, useToolbarContext] = createContext<ToolbarProps>('Toolbar');\n\nconst ToolbarRoot = ({ children, onAction, classNames }: ToolbarProps) => {\n return (\n <ToolbarContextProvider onAction={onAction}>\n <DensityProvider density='fine'>\n <ElevationProvider elevation='chrome'>\n <NaturalToolbar.Root classNames={['is-full shrink-0 overflow-x-auto overflow-y-hidden p-1', classNames]}>\n {children}\n </NaturalToolbar.Root>\n </ElevationProvider>\n </DensityProvider>\n </ToolbarContextProvider>\n );\n};\n\n// TODO(burdon): Generalize.\n// TODO(burdon): Detect and display current state.\ntype ButtonProps = {\n type: ToolbarActionType;\n Icon: Icon;\n getState: (state: Formatting) => boolean;\n disabled?: (state: Formatting) => boolean;\n};\n\n//\n// Alignment\n//\n\nconst formatOptions: ButtonProps[] = [\n { type: 'date', Icon: Calendar, getState: (state) => false },\n { type: 'currency', Icon: CurrencyDollar, getState: (state) => false },\n];\n\nconst Format = () => {\n const { onAction } = useToolbarContext('Format');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {formatOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst alignmentOptions: ButtonProps[] = [\n { type: 'left', Icon: TextAlignLeft, getState: (state) => false },\n { type: 'center', Icon: TextAlignCenter, getState: (state) => false },\n { type: 'right', Icon: TextAlignRight, getState: (state) => false },\n];\n\nconst Alignment = () => {\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {alignmentOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst styleOptions: ButtonProps[] = [\n { type: 'clear', Icon: Eraser, getState: (state) => false },\n { type: 'highlight', Icon: HighlighterCircle, getState: (state) => false },\n];\n\nconst Styles = () => {\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n // value={cellStyles.filter(({ getState }) => state && getState(state)).map(({ type }) => type)}\n >\n {styleOptions.map(({ type, getState, Icon }) => (\n <ToolbarToggleButton\n key={type}\n value={type}\n Icon={Icon}\n // disabled={state?.blockType === 'codeblock'}\n // onClick={state ? () => onAction?.({ type, data: !getState(state) }) : undefined}\n onClick={() => onAction?.({ type: type as Exclude<typeof type, 'comment'> })}\n >\n {t(`toolbar ${type} label`)}\n </ToolbarToggleButton>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\n//\n// Actions\n//\n\nconst Actions = () => {\n const { onAction } = useToolbarContext('Actions');\n const { cursor, range, model } = useSheetContext();\n const { t } = useTranslation(SHEET_PLUGIN);\n\n const overlapsCommentAnchor = (model.sheet.threads ?? [])\n .filter(nonNullable)\n .filter((thread) => thread.status !== 'resolved')\n .some((thread) => {\n if (!cursor) {\n return false;\n }\n return addressToIndex(model.sheet, cursor) === thread.anchor;\n });\n\n const hasCursor = !!cursor;\n const cursorOnly = hasCursor && !range && !overlapsCommentAnchor;\n\n const tooltipLabelKey = !hasCursor\n ? 'no cursor label'\n : overlapsCommentAnchor\n ? 'selection overlaps existing comment label'\n : range\n ? 'comment ranges not supported label'\n : 'comment label';\n\n return (\n <ToolbarButton\n value='comment'\n Icon={ChatText}\n data-testid='editor.toolbar.comment'\n onClick={() => {\n if (!cursor) {\n return;\n }\n return onAction?.({\n type: 'comment',\n anchor: addressToIndex(model.sheet, cursor),\n cellContent: model.getCellText(cursor),\n });\n }}\n disabled={!cursorOnly || overlapsCommentAnchor}\n >\n {t(tooltipLabelKey)}\n </ToolbarButton>\n );\n};\n\nexport const Toolbar = {\n Root: ToolbarRoot,\n Separator: ToolbarSeparator,\n Alignment,\n Format,\n Styles,\n Actions,\n};\n\nexport { useToolbarContext };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { type Icon } from '@phosphor-icons/react';\nimport React from 'react';\n\nimport {\n Toolbar as NaturalToolbar,\n Tooltip,\n type ToolbarButtonProps as NaturalToolbarButtonProps,\n type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,\n} from '@dxos/react-ui';\nimport { getSize } from '@dxos/react-ui-theme';\n\n// TODO(burdon): Factor out in common with react-ui-editor.\n\nexport const iconStyles = getSize(5);\nexport const buttonStyles = 'min-bs-0 p-2';\nexport const tooltipProps = { side: 'top' as const, classNames: 'z-10' };\n\nexport const ToolbarSeparator = () => <div role='separator' className='grow' />;\n\n//\n// ToolbarButton\n//\n\ntype ToolbarButtonProps = NaturalToolbarButtonProps & { Icon: Icon };\n\nexport const ToolbarButton = ({ Icon, children, ...props }: ToolbarButtonProps) => {\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.Button variant='ghost' {...props} classNames={buttonStyles}>\n <Icon className={iconStyles} />\n <span className='sr-only'>{children}</span>\n </NaturalToolbar.Button>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content {...tooltipProps}>\n {children}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n\n//\n// ToolbarToggleButton\n//\n\nexport type ToolbarToggleButtonProps = NaturalToolbarToggleGroupItemProps & { Icon: Icon };\n\nexport const ToolbarToggleButton = ({ Icon, children, ...props }: ToolbarToggleButtonProps) => {\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n <NaturalToolbar.ToggleGroupItem variant='ghost' {...props} classNames={buttonStyles}>\n <Icon className={iconStyles} />\n <span className='sr-only'>{children}</span>\n </NaturalToolbar.ToggleGroupItem>\n </Tooltip.Trigger>\n <Tooltip.Portal>\n <Tooltip.Content {...tooltipProps}>\n {children}\n <Tooltip.Arrow />\n </Tooltip.Content>\n </Tooltip.Portal>\n </Tooltip.Root>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;AAIA,OAAOA,UAASC,mBAAmB;AAEnC,SAASC,2BAA2B;AACpC,SAASC,wBAAwB;AACjC,SAASC,yBAAyBC,oBAAoB;AACtD,SAASC,WAAWC,UAAU;;;ACL9B,SAEEC,UACAC,UACAC,gBACAC,QACAC,mBACAC,iBACAC,eACAC,sBACK;AACP,SAASC,qBAAqB;AAC9B,OAAOC,YAAuC;AAE9C,SACEC,iBACAC,mBACAC,WAAWC,iBAEXC,sBACK;AACP,SAASC,mBAAmB;;;ACpB5B,OAAOC,WAAW;AAElB,SACEC,WAAWC,gBACXC,eAGK;AACP,SAASC,eAAe;AAIjB,IAAMC,aAAaC,QAAQ,CAAA;AAC3B,IAAMC,eAAe;AACrB,IAAMC,eAAe;EAAEC,MAAM;EAAgBC,YAAY;AAAO;AAEhE,IAAMC,mBAAmB,MAAM,sBAAA,cAACC,OAAAA;EAAIC,MAAK;EAAYC,WAAU;;AAQ/D,IAAMC,gBAAgB,CAAC,EAAEC,MAAMC,UAAU,GAAGC,MAAAA,MAA2B;AAC5E,SACE,sBAAA,cAACC,QAAQC,MAAI,MACX,sBAAA,cAACD,QAAQE,SAAO;IAACC,SAAAA;KACf,sBAAA,cAACC,eAAeC,QAAM;IAACC,SAAQ;IAAS,GAAGP;IAAOR,YAAYH;KAC5D,sBAAA,cAACS,MAAAA;IAAKF,WAAWT;MACjB,sBAAA,cAACqB,QAAAA;IAAKZ,WAAU;KAAWG,QAAAA,CAAAA,CAAAA,GAG/B,sBAAA,cAACE,QAAQQ,QAAM,MACb,sBAAA,cAACR,QAAQS,SAAYpB,cAClBS,UACD,sBAAA,cAACE,QAAQU,OAAK,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uBACX;AAEF,IAAMC,iBAAiB,CAAC,EAAEC,OAAOC,OAAOC,KAAI,MAAsC;AAChF,QAAMC,WAAWC,oBAAAA;AAEjB,QAAMC,KAAKC,iBAAiBL,KAAAA;AAC5B,QAAMM,kBAAkBC,wBAAwBH,EAAAA;AAChD,QAAM,EAAEI,aAAY,IAAKC,aAAaL,EAAAA;AAGtC,QAAMM,eAAeC,YACnB,CAACC,WAAAA;AACC,YAAQA,OAAOC,MAAI;MACjB,KAAK,WAAW;AAEd,aAAKX,SAAS;UACZU,QAAQ;UACRE,MAAM;YACJC,QAAQH,OAAOI;YACfC,MAAML,OAAOM;YACbC,SAASnB;UACX;QACF,CAAA;MACF;IACF;EACF,GACA;IAACA;IAAOE;GAAS;AAGnB,SACE,gBAAAkB,OAAA,cAACC,OAAAA;IACCpB,MAAK;IACLqB,WAAWrB,SAAS,YAAY,sCAAsCsB;IACrE,GAAItB,SAAS,aAAaK;KAE3B,gBAAAc,OAAA,cAACI,MAAMC,MAAI;IAAC1B;IAAcC;KACxB,gBAAAoB,OAAA,cAACC,OAAAA;IAAIpB,MAAK;IAAOqB,WAAWI,GAAG,4CAAA;KAC7B,gBAAAN,OAAA,cAACO,QAAQF,MAAI;IACXG,UAAUlB;IACVmB,YAAYH,GACVzB,SAAS,YACL;MAAC;MAA4C,CAACO,gBAAgB;MAAaX;QAC3E,mBAAA;KAON,gBAAAuB,OAAA,cAACO,QAAQG,WAAS,IAAA,GAClB,gBAAAV,OAAA,cAACO,QAAQI,SAAO,IAAA,CAAA,CAAA,GAGpB,gBAAAX,OAAA,cAACC,OAAAA;IACCpB,MAAK;IACLqB,WAAWI,GACTzB,SAAS,aAAa,gEACtBA,SAAS,aACP,kLACF+B,SAAAA;KAGF,gBAAAZ,OAAA,cAACI,MAAMS,MAAI,IAAA,CAAA,CAAA,CAAA;AAKrB;AAEA,IAAA,yBAAenC;",
|
|
6
|
+
"names": ["React", "useCallback", "useIntentDispatcher", "fullyQualifiedId", "useAttendableAttributes", "useAttention", "focusRing", "mx", "Calendar", "ChatText", "CurrencyDollar", "Eraser", "HighlighterCircle", "TextAlignCenter", "TextAlignLeft", "TextAlignRight", "createContext", "React", "DensityProvider", "ElevationProvider", "Toolbar", "NaturalToolbar", "useTranslation", "nonNullable", "React", "Toolbar", "NaturalToolbar", "Tooltip", "getSize", "iconStyles", "getSize", "buttonStyles", "tooltipProps", "side", "classNames", "ToolbarSeparator", "div", "role", "className", "ToolbarButton", "Icon", "children", "props", "Tooltip", "Root", "Trigger", "asChild", "NaturalToolbar", "Button", "variant", "span", "Portal", "Content", "Arrow", "ToolbarToggleButton", "ToggleGroupItem", "ToolbarContextProvider", "useToolbarContext", "createContext", "ToolbarRoot", "children", "onAction", "classNames", "React", "DensityProvider", "density", "ElevationProvider", "elevation", "NaturalToolbar", "Root", "formatOptions", "type", "Icon", "Calendar", "getState", "state", "CurrencyDollar", "Format", "t", "useTranslation", "SHEET_PLUGIN", "ToggleGroup", "map", "ToolbarToggleButton", "key", "value", "onClick", "alignmentOptions", "TextAlignLeft", "TextAlignCenter", "TextAlignRight", "Alignment", "styleOptions", "Eraser", "HighlighterCircle", "Styles", "Actions", "cursor", "range", "model", "useSheetContext", "overlapsCommentAnchor", "sheet", "threads", "filter", "nonNullable", "thread", "status", "some", "addressToIndex", "anchor", "hasCursor", "cursorOnly", "tooltipLabelKey", "ToolbarButton", "ChatText", "data-testid", "cellContent", "getCellText", "disabled", "Toolbar", "Separator", "ToolbarSeparator", "sectionToolbarLayout", "SheetContainer", "graph", "sheet", "role", "dispatch", "useIntentDispatcher", "id", "fullyQualifiedId", "attendableAttrs", "useAttendableAttributes", "hasAttention", "useAttention", "handleAction", "useCallback", "action", "type", "data", "cursor", "anchor", "name", "cellContent", "subject", "React", "div", "className", "undefined", "Sheet", "Root", "mx", "Toolbar", "onAction", "classNames", "Separator", "Actions", "focusRing", "Main"]
|
|
7
|
+
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./chunk-QILRZNE5.mjs";
|
|
8
8
|
import {
|
|
9
9
|
createSheetName
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-GSV5QNLD.mjs";
|
|
11
11
|
|
|
12
12
|
// packages/plugins/plugin-sheet/src/components/Sheet/Sheet.tsx
|
|
13
13
|
import { DndContext, DragOverlay, KeyboardSensor, MouseSensor, TouchSensor, useDraggable, useDroppable, useSensor, useSensors } from "@dnd-kit/core";
|
|
@@ -21,7 +21,7 @@ import { useResizeDetector } from "react-resize-detector";
|
|
|
21
21
|
import { debounce as debounce2 } from "@dxos/async";
|
|
22
22
|
import { fullyQualifiedId as fullyQualifiedId2, createDocAccessor } from "@dxos/client/echo";
|
|
23
23
|
import { log as log2 } from "@dxos/log";
|
|
24
|
-
import {
|
|
24
|
+
import { ATTENABLE_ATTRIBUTE, useAttendableAttributes, useAttention, useAttentionPath } from "@dxos/react-ui-attention";
|
|
25
25
|
import { mx as mx2 } from "@dxos/react-ui-theme";
|
|
26
26
|
|
|
27
27
|
// packages/plugins/plugin-sheet/src/components/Sheet/grid.ts
|
|
@@ -544,12 +544,18 @@ var ComputeGraphContextProvider = ({ registry, children }) => {
|
|
|
544
544
|
};
|
|
545
545
|
|
|
546
546
|
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
547
|
-
var SheetContainer = React2.lazy(() => import("./SheetContainer-
|
|
547
|
+
var SheetContainer = React2.lazy(() => import("./SheetContainer-LG77O4RM.mjs"));
|
|
548
548
|
|
|
549
549
|
// packages/plugins/plugin-sheet/src/hooks/useComputeGraph.ts
|
|
550
550
|
var useComputeGraph = (space) => {
|
|
551
551
|
const { registry } = useContext(ComputeGraphContext) ?? raise(new Error("Missing ComputeGraphContext"));
|
|
552
|
-
const [graph] = useAsyncState(async () =>
|
|
552
|
+
const [graph] = useAsyncState(async () => {
|
|
553
|
+
if (space) {
|
|
554
|
+
const graph2 = registry.getOrCreateGraph(space);
|
|
555
|
+
await graph2.open();
|
|
556
|
+
return graph2;
|
|
557
|
+
}
|
|
558
|
+
}, [
|
|
553
559
|
space,
|
|
554
560
|
registry
|
|
555
561
|
]);
|
|
@@ -673,6 +679,7 @@ var FormattingModel = class {
|
|
|
673
679
|
// packages/plugins/plugin-sheet/src/model/sheet-model.ts
|
|
674
680
|
import { Event } from "@dxos/async";
|
|
675
681
|
import { Resource } from "@dxos/context";
|
|
682
|
+
import { getTypename } from "@dxos/echo-schema";
|
|
676
683
|
import { invariant as invariant2 } from "@dxos/invariant";
|
|
677
684
|
import { PublicKey } from "@dxos/keys";
|
|
678
685
|
import { log } from "@dxos/log";
|
|
@@ -735,12 +742,16 @@ var SheetModel = class extends Resource {
|
|
|
735
742
|
id: this.id
|
|
736
743
|
}, {
|
|
737
744
|
F: __dxlog_file2,
|
|
738
|
-
L:
|
|
745
|
+
L: 104,
|
|
739
746
|
S: this,
|
|
740
747
|
C: (f, a) => f(...a)
|
|
741
748
|
});
|
|
742
749
|
initialize(this._sheet);
|
|
743
|
-
this._node =
|
|
750
|
+
this._node = this._graph.getOrCreateNode(createSheetName({
|
|
751
|
+
type: getTypename(this._sheet),
|
|
752
|
+
id: this._sheet.id
|
|
753
|
+
}));
|
|
754
|
+
await this._node.open();
|
|
744
755
|
const unsubscribe = this._node.update.on((event) => this.update.emit(event));
|
|
745
756
|
this._ctx.onDispose(unsubscribe);
|
|
746
757
|
this.reset();
|
|
@@ -753,7 +764,7 @@ var SheetModel = class extends Resource {
|
|
|
753
764
|
reset() {
|
|
754
765
|
invariant2(this._node, void 0, {
|
|
755
766
|
F: __dxlog_file2,
|
|
756
|
-
L:
|
|
767
|
+
L: 124,
|
|
757
768
|
S: this,
|
|
758
769
|
A: [
|
|
759
770
|
"this._node",
|
|
@@ -764,7 +775,7 @@ var SheetModel = class extends Resource {
|
|
|
764
775
|
Object.entries(this._sheet.cells).forEach(([key, { value }]) => {
|
|
765
776
|
invariant2(this._node, void 0, {
|
|
766
777
|
F: __dxlog_file2,
|
|
767
|
-
L:
|
|
778
|
+
L: 127,
|
|
768
779
|
S: this,
|
|
769
780
|
A: [
|
|
770
781
|
"this._node",
|
|
@@ -810,7 +821,7 @@ var SheetModel = class extends Resource {
|
|
|
810
821
|
clear(range) {
|
|
811
822
|
invariant2(this._node, void 0, {
|
|
812
823
|
F: __dxlog_file2,
|
|
813
|
-
L:
|
|
824
|
+
L: 169,
|
|
814
825
|
S: this,
|
|
815
826
|
A: [
|
|
816
827
|
"this._node",
|
|
@@ -828,7 +839,7 @@ var SheetModel = class extends Resource {
|
|
|
828
839
|
cut(range) {
|
|
829
840
|
invariant2(this._node, void 0, {
|
|
830
841
|
F: __dxlog_file2,
|
|
831
|
-
L:
|
|
842
|
+
L: 180,
|
|
832
843
|
S: this,
|
|
833
844
|
A: [
|
|
834
845
|
"this._node",
|
|
@@ -844,7 +855,7 @@ var SheetModel = class extends Resource {
|
|
|
844
855
|
copy(range) {
|
|
845
856
|
invariant2(this._node, void 0, {
|
|
846
857
|
F: __dxlog_file2,
|
|
847
|
-
L:
|
|
858
|
+
L: 189,
|
|
848
859
|
S: this,
|
|
849
860
|
A: [
|
|
850
861
|
"this._node",
|
|
@@ -856,7 +867,7 @@ var SheetModel = class extends Resource {
|
|
|
856
867
|
paste(cell) {
|
|
857
868
|
invariant2(this._node, void 0, {
|
|
858
869
|
F: __dxlog_file2,
|
|
859
|
-
L:
|
|
870
|
+
L: 194,
|
|
860
871
|
S: this,
|
|
861
872
|
A: [
|
|
862
873
|
"this._node",
|
|
@@ -883,7 +894,7 @@ var SheetModel = class extends Resource {
|
|
|
883
894
|
undo() {
|
|
884
895
|
invariant2(this._node, void 0, {
|
|
885
896
|
F: __dxlog_file2,
|
|
886
|
-
L:
|
|
897
|
+
L: 209,
|
|
887
898
|
S: this,
|
|
888
899
|
A: [
|
|
889
900
|
"this._node",
|
|
@@ -897,7 +908,7 @@ var SheetModel = class extends Resource {
|
|
|
897
908
|
redo() {
|
|
898
909
|
invariant2(this._node, void 0, {
|
|
899
910
|
F: __dxlog_file2,
|
|
900
|
-
L:
|
|
911
|
+
L: 217,
|
|
901
912
|
S: this,
|
|
902
913
|
A: [
|
|
903
914
|
"this._node",
|
|
@@ -941,7 +952,7 @@ var SheetModel = class extends Resource {
|
|
|
941
952
|
getValue(cell) {
|
|
942
953
|
invariant2(this._node, void 0, {
|
|
943
954
|
F: __dxlog_file2,
|
|
944
|
-
L:
|
|
955
|
+
L: 260,
|
|
945
956
|
S: this,
|
|
946
957
|
A: [
|
|
947
958
|
"this._node",
|
|
@@ -960,7 +971,7 @@ var SheetModel = class extends Resource {
|
|
|
960
971
|
getValueType(cell) {
|
|
961
972
|
invariant2(this._node, void 0, {
|
|
962
973
|
F: __dxlog_file2,
|
|
963
|
-
L:
|
|
974
|
+
L: 273,
|
|
964
975
|
S: this,
|
|
965
976
|
A: [
|
|
966
977
|
"this._node",
|
|
@@ -977,7 +988,7 @@ var SheetModel = class extends Resource {
|
|
|
977
988
|
setValue(cell, value) {
|
|
978
989
|
invariant2(this._node, void 0, {
|
|
979
990
|
F: __dxlog_file2,
|
|
980
|
-
L:
|
|
991
|
+
L: 283,
|
|
981
992
|
S: this,
|
|
982
993
|
A: [
|
|
983
994
|
"this._node",
|
|
@@ -1074,7 +1085,7 @@ var SheetModel = class extends Resource {
|
|
|
1074
1085
|
mapFormulaRefsToIndices(formula) {
|
|
1075
1086
|
invariant2(formula.charAt(0) === "=", void 0, {
|
|
1076
1087
|
F: __dxlog_file2,
|
|
1077
|
-
L:
|
|
1088
|
+
L: 372,
|
|
1078
1089
|
S: this,
|
|
1079
1090
|
A: [
|
|
1080
1091
|
"formula.charAt(0) === '='",
|
|
@@ -1091,7 +1102,7 @@ var SheetModel = class extends Resource {
|
|
|
1091
1102
|
mapFormulaIndicesToRefs(formula) {
|
|
1092
1103
|
invariant2(formula.charAt(0) === "=", void 0, {
|
|
1093
1104
|
F: __dxlog_file2,
|
|
1094
|
-
L:
|
|
1105
|
+
L: 382,
|
|
1095
1106
|
S: this,
|
|
1096
1107
|
A: [
|
|
1097
1108
|
"formula.charAt(0) === '='",
|
|
@@ -1117,7 +1128,7 @@ var SheetModel = class extends Resource {
|
|
|
1117
1128
|
toDateTime(num) {
|
|
1118
1129
|
invariant2(this._node, void 0, {
|
|
1119
1130
|
F: __dxlog_file2,
|
|
1120
|
-
L:
|
|
1131
|
+
L: 403,
|
|
1121
1132
|
S: this,
|
|
1122
1133
|
A: [
|
|
1123
1134
|
"this._node",
|
|
@@ -1129,7 +1140,7 @@ var SheetModel = class extends Resource {
|
|
|
1129
1140
|
toDate(num) {
|
|
1130
1141
|
invariant2(this._node, void 0, {
|
|
1131
1142
|
F: __dxlog_file2,
|
|
1132
|
-
L:
|
|
1143
|
+
L: 408,
|
|
1133
1144
|
S: this,
|
|
1134
1145
|
A: [
|
|
1135
1146
|
"this._node",
|
|
@@ -1141,7 +1152,7 @@ var SheetModel = class extends Resource {
|
|
|
1141
1152
|
toTime(num) {
|
|
1142
1153
|
invariant2(this._node, void 0, {
|
|
1143
1154
|
F: __dxlog_file2,
|
|
1144
|
-
L:
|
|
1155
|
+
L: 413,
|
|
1145
1156
|
S: this,
|
|
1146
1157
|
A: [
|
|
1147
1158
|
"this._node",
|
|
@@ -1586,10 +1597,10 @@ var CellEditor = ({ value, extension, autoFocus, onBlur, variant = "legacy", box
|
|
|
1586
1597
|
// packages/plugins/plugin-sheet/src/components/CellEditor/extension.ts
|
|
1587
1598
|
import { acceptCompletion, autocompletion, completionStatus, startCompletion } from "@codemirror/autocomplete";
|
|
1588
1599
|
import { HighlightStyle, syntaxHighlighting } from "@codemirror/language";
|
|
1589
|
-
import { Facet } from "@codemirror/state";
|
|
1590
1600
|
import { ViewPlugin, keymap as keymap2 } from "@codemirror/view";
|
|
1591
1601
|
import { tags } from "@lezer/highlight";
|
|
1592
1602
|
import { spreadsheet } from "codemirror-lang-spreadsheet";
|
|
1603
|
+
import { singleValueFacet } from "@dxos/react-ui-editor/state";
|
|
1593
1604
|
import { mx } from "@dxos/react-ui-theme";
|
|
1594
1605
|
var highlightStyles = HighlightStyle.define([
|
|
1595
1606
|
// Function.
|
|
@@ -1621,7 +1632,7 @@ var highlightStyles = HighlightStyle.define([
|
|
|
1621
1632
|
class: "text-unAccent"
|
|
1622
1633
|
}
|
|
1623
1634
|
]);
|
|
1624
|
-
var languageFacet =
|
|
1635
|
+
var languageFacet = singleValueFacet();
|
|
1625
1636
|
var sheetExtension = ({ functions = [] }) => {
|
|
1626
1637
|
const { extension, language } = spreadsheet({
|
|
1627
1638
|
idiom: "en-US",
|
|
@@ -1738,7 +1749,7 @@ var rangeExtension = (onInit) => {
|
|
|
1738
1749
|
update(view2) {
|
|
1739
1750
|
const { anchor } = view2.state.selection.ranges[0];
|
|
1740
1751
|
activeRange = void 0;
|
|
1741
|
-
const
|
|
1752
|
+
const language = view2.state.facet(languageFacet);
|
|
1742
1753
|
const { topNode } = language.parser.parse(view2.state.doc.toString());
|
|
1743
1754
|
visitTree(topNode, ({ type, from, to }) => {
|
|
1744
1755
|
if (from <= anchor && to >= anchor) {
|
|
@@ -2302,7 +2313,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2302
2313
|
id: model.id
|
|
2303
2314
|
}, {
|
|
2304
2315
|
F: __dxlog_file4,
|
|
2305
|
-
L:
|
|
2316
|
+
L: 738,
|
|
2306
2317
|
S: void 0,
|
|
2307
2318
|
C: (f, a) => f(...a)
|
|
2308
2319
|
});
|
|
@@ -2420,8 +2431,7 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2420
2431
|
columnSizes
|
|
2421
2432
|
});
|
|
2422
2433
|
const id = fullyQualifiedId2(model.sheet);
|
|
2423
|
-
const
|
|
2424
|
-
const hasAttention = useHasAttention(id);
|
|
2434
|
+
const { hasAttention } = useAttention(id);
|
|
2425
2435
|
return /* @__PURE__ */ React6.createElement("div", {
|
|
2426
2436
|
ref: containerRef,
|
|
2427
2437
|
role: "grid",
|
|
@@ -2508,13 +2518,25 @@ var SheetGrid = /* @__PURE__ */ forwardRef(({ size, rows, columns, rowSizes, col
|
|
|
2508
2518
|
}
|
|
2509
2519
|
});
|
|
2510
2520
|
});
|
|
2511
|
-
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(
|
|
2521
|
+
}))), /* @__PURE__ */ createPortal(/* @__PURE__ */ React6.createElement(SheetInput, {
|
|
2512
2522
|
ref: inputRef,
|
|
2513
|
-
|
|
2523
|
+
id,
|
|
2524
|
+
onKeyDown: handleKeyDown
|
|
2525
|
+
}), document.body));
|
|
2526
|
+
});
|
|
2527
|
+
var SheetInput = /* @__PURE__ */ forwardRef(({ id, onKeyDown }, forwardedRef) => {
|
|
2528
|
+
const path = useAttentionPath();
|
|
2529
|
+
const attendableAttrs = useAttendableAttributes(id);
|
|
2530
|
+
return path.toReversed().reduce((acc, part) => {
|
|
2531
|
+
return /* @__PURE__ */ React6.createElement("div", {
|
|
2532
|
+
[ATTENABLE_ATTRIBUTE]: part
|
|
2533
|
+
}, acc);
|
|
2534
|
+
}, /* @__PURE__ */ React6.createElement("input", {
|
|
2535
|
+
ref: forwardedRef,
|
|
2514
2536
|
className: "absolute w-[1px] h-[1px] bg-transparent outline-none border-none caret-transparent",
|
|
2515
|
-
onKeyDown
|
|
2537
|
+
onKeyDown,
|
|
2516
2538
|
...attendableAttrs
|
|
2517
|
-
})
|
|
2539
|
+
}));
|
|
2518
2540
|
});
|
|
2519
2541
|
var SelectionOverlay = ({ root }) => {
|
|
2520
2542
|
const { range } = useSheetContext();
|
|
@@ -2680,4 +2702,4 @@ export {
|
|
|
2680
2702
|
Sheet,
|
|
2681
2703
|
SheetContainer
|
|
2682
2704
|
};
|
|
2683
|
-
//# sourceMappingURL=chunk-
|
|
2705
|
+
//# sourceMappingURL=chunk-CHQAW4F4.mjs.map
|