@dxos/plugin-sheet 0.7.1 → 0.7.2-main.f1adc9f
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-YAMIOFC6.mjs → SheetContainer-DBDIZU6U.mjs} +4 -3
- package/dist/lib/browser/{SheetContainer-YAMIOFC6.mjs.map → SheetContainer-DBDIZU6U.mjs.map} +3 -3
- package/dist/lib/browser/{chunk-QHQFM7LV.mjs → chunk-IXA5HC36.mjs} +48 -22
- package/dist/lib/browser/{chunk-QHQFM7LV.mjs.map → chunk-IXA5HC36.mjs.map} +4 -4
- package/dist/lib/browser/index.mjs +8 -13
- package/dist/lib/browser/index.mjs.map +3 -3
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/{SheetContainer-BSDHHYXE.cjs → SheetContainer-3373SORI.cjs} +16 -15
- package/dist/lib/node/{SheetContainer-BSDHHYXE.cjs.map → SheetContainer-3373SORI.cjs.map} +3 -3
- package/dist/lib/node/{chunk-J5ZFWMOD.cjs → chunk-TS6IBEPZ.cjs} +34 -10
- package/dist/lib/node/{chunk-J5ZFWMOD.cjs.map → chunk-TS6IBEPZ.cjs.map} +4 -4
- package/dist/lib/node/index.cjs +10 -15
- package/dist/lib/node/index.cjs.map +3 -3
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node-esm/{SheetContainer-T47T2NYJ.mjs → SheetContainer-CH2RYBXJ.mjs} +4 -3
- package/dist/lib/node-esm/{SheetContainer-T47T2NYJ.mjs.map → SheetContainer-CH2RYBXJ.mjs.map} +3 -3
- package/dist/lib/node-esm/{chunk-6GSTEN7N.mjs → chunk-7F3BRKP7.mjs} +48 -22
- package/dist/lib/node-esm/{chunk-6GSTEN7N.mjs.map → chunk-7F3BRKP7.mjs.map} +4 -4
- package/dist/lib/node-esm/index.mjs +8 -13
- package/dist/lib/node-esm/index.mjs.map +3 -3
- package/dist/lib/node-esm/meta.json +1 -1
- package/dist/types/src/SheetPlugin.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts +1 -0
- package/dist/types/src/components/GridSheet/GridSheet.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts +2 -0
- package/dist/types/src/components/SheetContainer/SheetContainer.stories.d.ts.map +1 -1
- package/dist/types/src/components/SheetObjectSettings.d.ts +7 -0
- package/dist/types/src/components/SheetObjectSettings.d.ts.map +1 -0
- package/dist/types/src/components/Toolbar/Toolbar.d.ts.map +1 -1
- package/dist/types/src/components/index.d.ts +1 -0
- package/dist/types/src/components/index.d.ts.map +1 -1
- package/dist/types/src/integrations/thread-ranges.d.ts.map +1 -1
- package/dist/types/src/testing/playwright/playwright.config.d.ts +3 -0
- package/dist/types/src/testing/playwright/playwright.config.d.ts.map +1 -0
- package/dist/types/src/testing/playwright/sheet-manager.d.ts +24 -0
- package/dist/types/src/testing/playwright/sheet-manager.d.ts.map +1 -0
- package/dist/types/src/testing/playwright/sheet.spec.d.ts +2 -0
- package/dist/types/src/testing/playwright/sheet.spec.d.ts.map +1 -0
- package/package.json +39 -37
- package/src/SheetPlugin.tsx +5 -13
- package/src/components/GridSheet/GridSheet.stories.tsx +2 -0
- package/src/components/GridSheet/GridSheet.tsx +12 -3
- package/src/components/GridSheet/SheetCellEditor.stories.tsx +2 -2
- package/src/components/SheetContainer/SheetContainer.stories.tsx +44 -2
- package/src/components/SheetObjectSettings.tsx +38 -0
- package/src/components/Toolbar/Toolbar.tsx +7 -1
- package/src/components/index.ts +1 -0
- package/src/compute-graph/compute-graph.stories.tsx +1 -1
- package/src/compute-graph/compute-graph.test.ts +1 -1
- package/src/integrations/thread-ranges.ts +2 -0
- package/src/sanity.test.ts +1 -1
- package/src/testing/playwright/playwright.config.ts +18 -0
- package/src/testing/playwright/sheet-manager.ts +91 -0
- package/src/testing/playwright/sheet.spec.ts +78 -0
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
completeCellRangeToThreadCursor,
|
|
5
5
|
useComputeGraph,
|
|
6
6
|
useSheetContext
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-IXA5HC36.mjs";
|
|
8
8
|
import {
|
|
9
9
|
addressToA1Notation,
|
|
10
10
|
alignKey,
|
|
@@ -190,7 +190,8 @@ var Alignment = () => {
|
|
|
190
190
|
itemType: "toggleGroupItem",
|
|
191
191
|
key: value2,
|
|
192
192
|
value: value2,
|
|
193
|
-
icon
|
|
193
|
+
icon,
|
|
194
|
+
"data-testid": `grid.toolbar.${alignKey}.${value2}`
|
|
194
195
|
}, t("toolbar action label", {
|
|
195
196
|
key: t(`range key ${alignKey} label`),
|
|
196
197
|
value: t(`range value ${value2} label`)
|
|
@@ -291,4 +292,4 @@ var SheetContainer_default = SheetContainer;
|
|
|
291
292
|
export {
|
|
292
293
|
SheetContainer_default as default
|
|
293
294
|
};
|
|
294
|
-
//# sourceMappingURL=SheetContainer-
|
|
295
|
+
//# sourceMappingURL=SheetContainer-DBDIZU6U.mjs.map
|
package/dist/lib/browser/{SheetContainer-YAMIOFC6.mjs.map → SheetContainer-DBDIZU6U.mjs.map}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/SheetContainer/SheetContainer.tsx", "../../../src/components/FunctionEditor/FunctionEditor.tsx", "../../../src/components/Toolbar/Toolbar.tsx", "../../../src/components/SheetContainer/index.ts"],
|
|
4
|
-
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { type SheetType } from '../../types';\nimport { useComputeGraph } from '../ComputeGraph';\nimport { FunctionEditor } from '../FunctionEditor';\nimport { GridSheet } from '../GridSheet';\nimport { SheetProvider } from '../SheetContext';\nimport { Toolbar } from '../Toolbar';\n\nexport const SheetContainer = ({\n space,\n sheet,\n role,\n ignoreAttention,\n}: {\n space: Space;\n sheet: SheetType;\n role?: string;\n ignoreAttention?: boolean;\n}) => {\n const graph = useComputeGraph(space);\n\n return graph ? (\n <SheetProvider sheet={sheet} graph={graph} ignoreAttention={ignoreAttention}>\n <StackItem.Content toolbar statusbar {...(role === 'section' && { classNames: 'aspect-video' })}>\n <Toolbar.Root role={role}>\n <Toolbar.Styles />\n <Toolbar.Alignment />\n <Toolbar.Separator />\n <Toolbar.Actions />\n </Toolbar.Root>\n <GridSheet />\n <FunctionEditor />\n </StackItem.Content>\n </SheetProvider>\n ) : null;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Icon } from '@dxos/react-ui';\n\nimport { addressToA1Notation, isFormula, rangeToA1Notation } from '../../defs';\nimport { useSheetContext } from '../SheetContext';\n\nexport const FunctionEditor = () => {\n const { model, cursor, range } = useSheetContext();\n\n let value;\n let formula = false;\n if (cursor) {\n value = model.getCellValue(cursor);\n if (isFormula(value)) {\n value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));\n formula = true;\n } else if (value != null) {\n value = String(value);\n }\n }\n\n return (\n <div className='flex shrink-0 justify-between items-center px-4 py-1 text-sm attention-surface border-bs !border-separator'>\n <div className='flex gap-4 items-center'>\n <div className='flex w-16 items-center font-mono'>\n {(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}\n </div>\n <div className='flex gap-2 items-center'>\n <Icon icon='ph--function--regular' classNames={['text-greenText', formula ? 'visible' : 'invisible']} />\n <span className='font-mono'>{value}</span>\n </div>\n </div>\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren, useCallback } from 'react';\n\nimport { useIntentDispatcher } from '@dxos/app-framework';\nimport {\n Icon,\n type ThemedClassName,\n Toolbar as NaturalToolbar,\n type ToolbarButtonProps as NaturalToolbarButtonProps,\n type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,\n type ToolbarToggleProps as NaturalToolbarToggleProps,\n Tooltip,\n useTranslation,\n} from '@dxos/react-ui';\nimport { useAttention } from '@dxos/react-ui-attention';\nimport { nonNullable } from '@dxos/util';\n\nimport {\n alignKey,\n type AlignKey,\n type AlignValue,\n type CommentKey,\n type CommentValue,\n inRange,\n rangeFromIndex,\n rangeToIndex,\n styleKey,\n type StyleKey,\n type StyleValue,\n} from '../../defs';\nimport { completeCellRangeToThreadCursor } from '../../integrations';\nimport { SHEET_PLUGIN } from '../../meta';\nimport { type SheetType } from '../../types';\nimport { useSheetContext } from '../SheetContext';\n\n//\n// Buttons\n//\n\nconst buttonStyles = 'min-bs-0 p-2';\nconst tooltipProps = { side: 'bottom' as const, classNames: 'z-10' };\n\nconst ToolbarSeparator = () => <div role='separator' className='grow' />;\n\n//\n// ToolbarItem\n//\n\ntype ToolbarItemProps =\n | (NaturalToolbarButtonProps & { itemType: 'button'; icon: string })\n | (NaturalToolbarToggleGroupItemProps & { itemType: 'toggleGroupItem'; icon: string })\n | (NaturalToolbarToggleProps & { itemType: 'toggle'; icon: string });\n\nexport const ToolbarItem = ({ itemType, icon, children, ...props }: ToolbarItemProps) => {\n const Invoker =\n itemType === 'toggleGroupItem'\n ? NaturalToolbar.ToggleGroupItem\n : itemType === 'toggle'\n ? NaturalToolbar.Toggle\n : NaturalToolbar.Button;\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n {/* TODO(thure): type the props spread better. */}\n <Invoker variant='ghost' {...(props as any)} classNames={buttonStyles}>\n <Icon icon={icon} size={5} />\n <span className='sr-only'>{children}</span>\n </Invoker>\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// Root\n//\n\ntype AlignAction = { key: AlignKey; value: AlignValue };\ntype CommentAction = { key: CommentKey; value: CommentValue; cellContent?: string };\ntype StyleAction = { key: StyleKey; value: StyleValue };\n\nexport type ToolbarAction = StyleAction | AlignAction | CommentAction;\nexport type ToolbarActionAnnotated = ToolbarAction & { unset?: boolean };\n\nexport type ToolbarActionType = ToolbarAction['key'];\n\nexport type ToolbarActionHandler = (action: ToolbarActionAnnotated) => void;\n\nexport type ToolbarProps = ThemedClassName<\n PropsWithChildren<{\n role?: string;\n }>\n>;\n\nconst [ToolbarContextProvider, useToolbarContext] = createContext<{\n onAction: (action: ToolbarActionAnnotated) => void;\n}>('Toolbar');\n\ntype Range = SheetType['ranges'][number];\n\nconst ToolbarRoot = ({ children, role, classNames }: ToolbarProps) => {\n const { id, model, cursorFallbackRange, cursor } = useSheetContext();\n const { hasAttention } = useAttention(id);\n const dispatch = useIntentDispatcher();\n\n // TODO(Zan): Externalize the toolbar action handler. E.g., Toolbar/keys should both fire events.\n const handleAction = useCallback(\n (action: ToolbarActionAnnotated) => {\n switch (action.key) {\n case 'alignment':\n if (cursorFallbackRange) {\n const index =\n model.sheet.ranges?.findIndex(\n (range) =>\n range.key === action.key &&\n inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),\n ) ?? -1;\n const nextRangeEntity = {\n range: rangeToIndex(model.sheet, cursorFallbackRange),\n key: action.key,\n value: action.value,\n };\n if (index < 0) {\n model.sheet.ranges?.push(nextRangeEntity);\n } else if (model.sheet.ranges![index].value === action.value) {\n model.sheet.ranges?.splice(index, 1);\n } else {\n model.sheet.ranges?.splice(index, 1, nextRangeEntity);\n }\n }\n break;\n case 'style':\n if (action.unset) {\n const index = model.sheet.ranges?.findIndex(\n (range) =>\n range.key === action.key &&\n cursorFallbackRange &&\n inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),\n );\n if (index >= 0) {\n model.sheet.ranges?.splice(index, 1);\n }\n } else if (cursorFallbackRange) {\n model.sheet.ranges?.push({\n range: rangeToIndex(model.sheet, cursorFallbackRange),\n key: action.key,\n value: action.value,\n });\n }\n break;\n case 'comment': {\n // TODO(Zan): We shouldn't hardcode the action ID.\n if (cursorFallbackRange) {\n void dispatch({\n action: 'dxos.org/plugin/thread/action/create',\n data: {\n cursor: completeCellRangeToThreadCursor(cursorFallbackRange),\n name: action.cellContent,\n subject: model.sheet,\n },\n });\n }\n }\n }\n },\n [model.sheet, cursorFallbackRange, cursor, dispatch],\n );\n\n return (\n <ToolbarContextProvider onAction={handleAction}>\n <NaturalToolbar.Root classNames={['pli-0.5 attention-surface', !hasAttention && 'opacity-20', classNames]}>\n {children}\n </NaturalToolbar.Root>\n </ToolbarContextProvider>\n );\n};\n\n// TODO(burdon): Generalize.\n// TODO(burdon): Detect and display current state.\ntype ButtonProps<T> = {\n value: T;\n icon: string;\n disabled?: (state: Range) => boolean;\n};\n\n//\n// Alignment\n//\n\nconst alignmentOptions: ButtonProps<AlignValue>[] = [\n { value: 'start', icon: 'ph--text-align-left--regular' },\n { value: 'center', icon: 'ph--text-align-center--regular' },\n { value: 'end', icon: 'ph--text-align-right--regular' },\n];\n\nconst Alignment = () => {\n const { cursor, model } = useSheetContext();\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n // TODO(thure): Can this O(n) call be memoized?\n const value = cursor\n ? model.sheet.ranges?.findLast(\n ({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),\n )?.value\n : undefined;\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n value={\n // TODO(thure): providing `undefined` leaves the last item active which was active rather than showing none.\n value ?? 'never'\n }\n onValueChange={(value: AlignValue) => onAction?.({ key: alignKey, value })}\n >\n {alignmentOptions.map(({ value, icon }) => (\n <ToolbarItem itemType='toggleGroupItem' key={value} value={value} icon={icon}>\n {t('toolbar action label', {\n key: t(`range key ${alignKey} label`),\n value: t(`range value ${value} label`),\n })}\n </ToolbarItem>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst styleOptions: ButtonProps<StyleValue>[] = [\n { value: 'highlight', icon: 'ph--highlighter--regular' },\n { value: 'softwrap', icon: 'ph--paragraph--regular' },\n];\n\nconst Styles = () => {\n const { cursorFallbackRange, model } = useSheetContext();\n const { onAction } = useToolbarContext('Styles');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n // TODO(thure): Can this O(n) call be memoized?\n const activeValues = cursorFallbackRange\n ? model.sheet.ranges\n ?.filter(\n ({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),\n )\n .reduce((acc, { value }) => {\n acc.add(value);\n return acc;\n }, new Set())\n : undefined;\n\n return (\n <>\n {styleOptions.map(({ value, icon }) => (\n <ToolbarItem\n itemType='toggle'\n key={value}\n pressed={activeValues?.has(value)}\n onPressedChange={(nextPressed: boolean) => {\n onAction?.({ key: 'style', value, unset: !nextPressed });\n }}\n icon={icon}\n >\n {t('toolbar action label', {\n key: t(`range key ${styleKey} label`),\n value: t(`range value ${value} label`),\n })}\n </ToolbarItem>\n ))}\n </>\n );\n};\n\n//\n// Actions\n//\n\nconst Actions = () => {\n const { onAction } = useToolbarContext('Actions');\n const { cursorFallbackRange, cursor, model } = useSheetContext();\n const { t } = useTranslation(SHEET_PLUGIN);\n\n // TODO(thure): Can this O(n) call be memoized?\n const overlapsCommentAnchor = (model.sheet.threads ?? [])\n .filter(nonNullable)\n .filter((thread) => thread.status !== 'resolved')\n .some((thread) => {\n if (!cursorFallbackRange) {\n return false;\n }\n return rangeToIndex(model.sheet, cursorFallbackRange) === thread.anchor;\n });\n\n const tooltipLabelKey = !cursor\n ? 'no cursor label'\n : overlapsCommentAnchor\n ? 'selection overlaps existing comment label'\n : 'comment label';\n\n return (\n <ToolbarItem\n itemType='button'\n value='comment'\n icon='ph--chat-text--regular'\n data-testid='editor.toolbar.comment'\n onClick={() => {\n if (!cursorFallbackRange) {\n return;\n }\n return onAction?.({\n key: 'comment',\n value: rangeToIndex(model.sheet, cursorFallbackRange),\n cellContent: model.getCellText(cursorFallbackRange.from),\n });\n }}\n disabled={!cursorFallbackRange || overlapsCommentAnchor}\n >\n {t(tooltipLabelKey)}\n </ToolbarItem>\n );\n};\n\nexport const Toolbar = {\n Root: ToolbarRoot,\n Separator: ToolbarSeparator,\n Alignment,\n Styles,\n Actions,\n};\n\nexport { useToolbarContext };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { SheetContainer } from './SheetContainer';\n\nexport default SheetContainer;\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAIA,OAAOA,YAAW;AAGlB,SAASC,iBAAiB;;;ACH1B,OAAOC,WAAW;AAElB,SAASC,YAAY;AAKd,IAAMC,iBAAiB,MAAA;AAC5B,QAAM,EAAEC,OAAOC,QAAQC,MAAK,IAAKC,gBAAAA;AAEjC,MAAIC;AACJ,MAAIC,UAAU;AACd,MAAIJ,QAAQ;AACVG,YAAQJ,MAAMM,aAAaL,MAAAA;AAC3B,QAAIM,UAAUH,KAAAA,GAAQ;AACpBA,cAAQJ,MAAMQ,MAAMC,yBAAyBT,MAAMU,wBAAwBN,KAAAA,CAAAA;AAC3EC,gBAAU;IACZ,WAAWD,SAAS,MAAM;AACxBA,cAAQO,OAAOP,KAAAA;IACjB;EACF;AAEA,SACE,sBAAA,cAACQ,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACD,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACD,OAAAA;IAAIC,WAAU;KACXX,SAASY,kBAAkBZ,KAAAA,KAAYD,UAAUc,oBAAoBd,MAAAA,CAAAA,GAEzE,sBAAA,cAACW,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACG,MAAAA;IAAKC,MAAK;IAAwBC,YAAY;MAAC;MAAkBb,UAAU,YAAY;;MACxF,sBAAA,cAACc,QAAAA;IAAKN,WAAU;KAAaT,KAAAA,CAAAA,CAAAA,CAAAA;AAKvC;;;ACnCA,SAASgB,qBAAqB;AAC9B,OAAOC,UAAiCC,mBAAmB;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ACF,CAAA;QACF;MACF;IACF;EACF,GACA;IAACb,MAAMa;IAAOZ;IAAqBC;IAAQI;GAAS;AAGtD,SACE,gBAAApC,OAAA,cAACyB,wBAAAA;IAAuBoC,UAAUvB;KAChC,gBAAAtC,OAAA,cAACU,eAAeK,MAAI;IAACjB,YAAY;MAAC;MAA6B,CAACoC,gBAAgB;MAAcpC;;KAC3FS,QAAAA,CAAAA;AAIT;AAcA,IAAMuD,mBAA8C;EAClD;IAAEV,OAAO;IAAS9C,MAAM;EAA+B;EACvD;IAAE8C,OAAO;IAAU9C,MAAM;EAAiC;EAC1D;IAAE8C,OAAO;IAAO9C,MAAM;EAAgC;;AAGxD,IAAMyD,YAAY,MAAA;AAChB,QAAM,EAAE/B,QAAQF,MAAK,IAAKG,gBAAAA;AAC1B,QAAM,EAAE4B,SAAQ,IAAKnC,kBAAkB,WAAA;AACvC,QAAM,EAAEsC,EAAC,IAAKC,eAAeC,YAAAA;AAG7B,QAAMd,QAAQpB,SACVF,MAAMa,MAAMC,QAAQuB,SAClB,CAAC,EAAErB,OAAOL,IAAG,MAAOA,QAAQ2B,YAAYrB,QAAQC,eAAelB,MAAMa,OAAOG,KAAAA,GAAQd,MAAAA,CAAAA,GACnFoB,QACHiB;AAEJ,SACE,gBAAArE,OAAA,cAACU,eAAe4D,aAAW;IACzBC,MAAK;IACLnB;;MAEEA,SAAS;;IAEXoB,eAAe,CAACpB,WAAsBS,WAAW;MAAEpB,KAAK2B;MAAUhB,OAAAA;IAAM,CAAA;KAEvEU,iBAAiBW,IAAI,CAAC,EAAErB,OAAAA,QAAO9C,KAAI,MAClC,gBAAAN,OAAA,cAACI,aAAAA;
|
|
6
|
-
"names": ["React", "StackItem", "React", "Icon", "FunctionEditor", "model", "cursor", "range", "useSheetContext", "value", "formula", "getCellValue", "isFormula", "graph", "mapFunctionBindingFromId", "mapFormulaIndicesToRefs", "String", "div", "className", "rangeToA1Notation", "addressToA1Notation", "Icon", "icon", "classNames", "span", "createContext", "React", "useCallback", "useIntentDispatcher", "Icon", "Toolbar", "NaturalToolbar", "Tooltip", "useTranslation", "useAttention", "nonNullable", "buttonStyles", "tooltipProps", "side", "classNames", "ToolbarSeparator", "React", "div", "role", "className", "ToolbarItem", "itemType", "icon", "children", "props", "Invoker", "NaturalToolbar", "ToggleGroupItem", "Toggle", "Button", "Tooltip", "Root", "Trigger", "asChild", "variant", "Icon", "size", "span", "Portal", "Content", "Arrow", "ToolbarContextProvider", "useToolbarContext", "createContext", "ToolbarRoot", "id", "model", "cursorFallbackRange", "cursor", "useSheetContext", "hasAttention", "useAttention", "dispatch", "useIntentDispatcher", "handleAction", "useCallback", "action", "key", "index", "sheet", "ranges", "findIndex", "range", "inRange", "rangeFromIndex", "from", "nextRangeEntity", "rangeToIndex", "value", "push", "splice", "unset", "data", "completeCellRangeToThreadCursor", "name", "cellContent", "subject", "onAction", "alignmentOptions", "Alignment", "t", "useTranslation", "SHEET_PLUGIN", "findLast", "alignKey", "undefined", "ToggleGroup", "type", "onValueChange", "map", "styleOptions", "Styles", "activeValues", "filter", "reduce", "acc", "add", "Set", "pressed", "has", "onPressedChange", "nextPressed", "styleKey", "Actions", "overlapsCommentAnchor", "threads", "nonNullable", "thread", "status", "some", "anchor", "tooltipLabelKey", "
|
|
4
|
+
"sourcesContent": ["//\n// Copyright 2023 DXOS.org\n//\n\nimport React from 'react';\n\nimport { type Space } from '@dxos/react-client/echo';\nimport { StackItem } from '@dxos/react-ui-stack';\n\nimport { type SheetType } from '../../types';\nimport { useComputeGraph } from '../ComputeGraph';\nimport { FunctionEditor } from '../FunctionEditor';\nimport { GridSheet } from '../GridSheet';\nimport { SheetProvider } from '../SheetContext';\nimport { Toolbar } from '../Toolbar';\n\nexport const SheetContainer = ({\n space,\n sheet,\n role,\n ignoreAttention,\n}: {\n space: Space;\n sheet: SheetType;\n role?: string;\n ignoreAttention?: boolean;\n}) => {\n const graph = useComputeGraph(space);\n\n return graph ? (\n <SheetProvider sheet={sheet} graph={graph} ignoreAttention={ignoreAttention}>\n <StackItem.Content toolbar statusbar {...(role === 'section' && { classNames: 'aspect-video' })}>\n <Toolbar.Root role={role}>\n <Toolbar.Styles />\n <Toolbar.Alignment />\n <Toolbar.Separator />\n <Toolbar.Actions />\n </Toolbar.Root>\n <GridSheet />\n <FunctionEditor />\n </StackItem.Content>\n </SheetProvider>\n ) : null;\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport React from 'react';\n\nimport { Icon } from '@dxos/react-ui';\n\nimport { addressToA1Notation, isFormula, rangeToA1Notation } from '../../defs';\nimport { useSheetContext } from '../SheetContext';\n\nexport const FunctionEditor = () => {\n const { model, cursor, range } = useSheetContext();\n\n let value;\n let formula = false;\n if (cursor) {\n value = model.getCellValue(cursor);\n if (isFormula(value)) {\n value = model.graph.mapFunctionBindingFromId(model.mapFormulaIndicesToRefs(value));\n formula = true;\n } else if (value != null) {\n value = String(value);\n }\n }\n\n return (\n <div className='flex shrink-0 justify-between items-center px-4 py-1 text-sm attention-surface border-bs !border-separator'>\n <div className='flex gap-4 items-center'>\n <div className='flex w-16 items-center font-mono'>\n {(range && rangeToA1Notation(range)) || (cursor && addressToA1Notation(cursor))}\n </div>\n <div className='flex gap-2 items-center'>\n <Icon icon='ph--function--regular' classNames={['text-greenText', formula ? 'visible' : 'invisible']} />\n <span className='font-mono'>{value}</span>\n </div>\n </div>\n </div>\n );\n};\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { createContext } from '@radix-ui/react-context';\nimport React, { type PropsWithChildren, useCallback } from 'react';\n\nimport { useIntentDispatcher } from '@dxos/app-framework';\nimport {\n Icon,\n type ThemedClassName,\n Toolbar as NaturalToolbar,\n type ToolbarButtonProps as NaturalToolbarButtonProps,\n type ToolbarToggleGroupItemProps as NaturalToolbarToggleGroupItemProps,\n type ToolbarToggleProps as NaturalToolbarToggleProps,\n Tooltip,\n useTranslation,\n} from '@dxos/react-ui';\nimport { useAttention } from '@dxos/react-ui-attention';\nimport { nonNullable } from '@dxos/util';\n\nimport {\n alignKey,\n type AlignKey,\n type AlignValue,\n type CommentKey,\n type CommentValue,\n inRange,\n rangeFromIndex,\n rangeToIndex,\n styleKey,\n type StyleKey,\n type StyleValue,\n} from '../../defs';\nimport { completeCellRangeToThreadCursor } from '../../integrations';\nimport { SHEET_PLUGIN } from '../../meta';\nimport { type SheetType } from '../../types';\nimport { useSheetContext } from '../SheetContext';\n\n//\n// Buttons\n//\n\nconst buttonStyles = 'min-bs-0 p-2';\nconst tooltipProps = { side: 'bottom' as const, classNames: 'z-10' };\n\nconst ToolbarSeparator = () => <div role='separator' className='grow' />;\n\n//\n// ToolbarItem\n//\n\ntype ToolbarItemProps =\n | (NaturalToolbarButtonProps & { itemType: 'button'; icon: string })\n | (NaturalToolbarToggleGroupItemProps & { itemType: 'toggleGroupItem'; icon: string })\n | (NaturalToolbarToggleProps & { itemType: 'toggle'; icon: string });\n\nexport const ToolbarItem = ({ itemType, icon, children, ...props }: ToolbarItemProps) => {\n const Invoker =\n itemType === 'toggleGroupItem'\n ? NaturalToolbar.ToggleGroupItem\n : itemType === 'toggle'\n ? NaturalToolbar.Toggle\n : NaturalToolbar.Button;\n return (\n <Tooltip.Root>\n <Tooltip.Trigger asChild>\n {/* TODO(thure): type the props spread better. */}\n <Invoker variant='ghost' {...(props as any)} classNames={buttonStyles}>\n <Icon icon={icon} size={5} />\n <span className='sr-only'>{children}</span>\n </Invoker>\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// Root\n//\n\ntype AlignAction = { key: AlignKey; value: AlignValue };\ntype CommentAction = { key: CommentKey; value: CommentValue; cellContent?: string };\ntype StyleAction = { key: StyleKey; value: StyleValue };\n\nexport type ToolbarAction = StyleAction | AlignAction | CommentAction;\nexport type ToolbarActionAnnotated = ToolbarAction & { unset?: boolean };\n\nexport type ToolbarActionType = ToolbarAction['key'];\n\nexport type ToolbarActionHandler = (action: ToolbarActionAnnotated) => void;\n\nexport type ToolbarProps = ThemedClassName<\n PropsWithChildren<{\n role?: string;\n }>\n>;\n\nconst [ToolbarContextProvider, useToolbarContext] = createContext<{\n onAction: (action: ToolbarActionAnnotated) => void;\n}>('Toolbar');\n\ntype Range = SheetType['ranges'][number];\n\nconst ToolbarRoot = ({ children, role, classNames }: ToolbarProps) => {\n const { id, model, cursorFallbackRange, cursor } = useSheetContext();\n const { hasAttention } = useAttention(id);\n const dispatch = useIntentDispatcher();\n\n // TODO(Zan): Externalize the toolbar action handler. E.g., Toolbar/keys should both fire events.\n const handleAction = useCallback(\n (action: ToolbarActionAnnotated) => {\n switch (action.key) {\n case 'alignment':\n if (cursorFallbackRange) {\n const index =\n model.sheet.ranges?.findIndex(\n (range) =>\n range.key === action.key &&\n inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),\n ) ?? -1;\n const nextRangeEntity = {\n range: rangeToIndex(model.sheet, cursorFallbackRange),\n key: action.key,\n value: action.value,\n };\n if (index < 0) {\n model.sheet.ranges?.push(nextRangeEntity);\n } else if (model.sheet.ranges![index].value === action.value) {\n model.sheet.ranges?.splice(index, 1);\n } else {\n model.sheet.ranges?.splice(index, 1, nextRangeEntity);\n }\n }\n break;\n case 'style':\n if (action.unset) {\n const index = model.sheet.ranges?.findIndex(\n (range) =>\n range.key === action.key &&\n cursorFallbackRange &&\n inRange(rangeFromIndex(model.sheet, range.range), cursorFallbackRange.from),\n );\n if (index >= 0) {\n model.sheet.ranges?.splice(index, 1);\n }\n } else if (cursorFallbackRange) {\n model.sheet.ranges?.push({\n range: rangeToIndex(model.sheet, cursorFallbackRange),\n key: action.key,\n value: action.value,\n });\n }\n break;\n case 'comment': {\n // TODO(Zan): We shouldn't hardcode the action ID.\n if (cursorFallbackRange) {\n void dispatch({\n action: 'dxos.org/plugin/thread/action/create',\n data: {\n cursor: completeCellRangeToThreadCursor(cursorFallbackRange),\n name: action.cellContent,\n subject: model.sheet,\n },\n });\n }\n }\n }\n },\n [model.sheet, cursorFallbackRange, cursor, dispatch],\n );\n\n return (\n <ToolbarContextProvider onAction={handleAction}>\n <NaturalToolbar.Root classNames={['pli-0.5 attention-surface', !hasAttention && 'opacity-20', classNames]}>\n {children}\n </NaturalToolbar.Root>\n </ToolbarContextProvider>\n );\n};\n\n// TODO(burdon): Generalize.\n// TODO(burdon): Detect and display current state.\ntype ButtonProps<T> = {\n value: T;\n icon: string;\n disabled?: (state: Range) => boolean;\n};\n\n//\n// Alignment\n//\n\nconst alignmentOptions: ButtonProps<AlignValue>[] = [\n { value: 'start', icon: 'ph--text-align-left--regular' },\n { value: 'center', icon: 'ph--text-align-center--regular' },\n { value: 'end', icon: 'ph--text-align-right--regular' },\n];\n\nconst Alignment = () => {\n const { cursor, model } = useSheetContext();\n const { onAction } = useToolbarContext('Alignment');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n // TODO(thure): Can this O(n) call be memoized?\n const value = cursor\n ? model.sheet.ranges?.findLast(\n ({ range, key }) => key === alignKey && inRange(rangeFromIndex(model.sheet, range), cursor),\n )?.value\n : undefined;\n\n return (\n <NaturalToolbar.ToggleGroup\n type='single'\n value={\n // TODO(thure): providing `undefined` leaves the last item active which was active rather than showing none.\n value ?? 'never'\n }\n onValueChange={(value: AlignValue) => onAction?.({ key: alignKey, value })}\n >\n {alignmentOptions.map(({ value, icon }) => (\n <ToolbarItem\n itemType='toggleGroupItem'\n key={value}\n value={value}\n icon={icon}\n data-testid={`grid.toolbar.${alignKey}.${value}`}\n >\n {t('toolbar action label', {\n key: t(`range key ${alignKey} label`),\n value: t(`range value ${value} label`),\n })}\n </ToolbarItem>\n ))}\n </NaturalToolbar.ToggleGroup>\n );\n};\n\nconst styleOptions: ButtonProps<StyleValue>[] = [\n { value: 'highlight', icon: 'ph--highlighter--regular' },\n { value: 'softwrap', icon: 'ph--paragraph--regular' },\n];\n\nconst Styles = () => {\n const { cursorFallbackRange, model } = useSheetContext();\n const { onAction } = useToolbarContext('Styles');\n const { t } = useTranslation(SHEET_PLUGIN);\n\n // TODO(thure): Can this O(n) call be memoized?\n const activeValues = cursorFallbackRange\n ? model.sheet.ranges\n ?.filter(\n ({ range, key }) => key === 'style' && inRange(rangeFromIndex(model.sheet, range), cursorFallbackRange.from),\n )\n .reduce((acc, { value }) => {\n acc.add(value);\n return acc;\n }, new Set())\n : undefined;\n\n return (\n <>\n {styleOptions.map(({ value, icon }) => (\n <ToolbarItem\n itemType='toggle'\n key={value}\n pressed={activeValues?.has(value)}\n onPressedChange={(nextPressed: boolean) => {\n onAction?.({ key: 'style', value, unset: !nextPressed });\n }}\n icon={icon}\n >\n {t('toolbar action label', {\n key: t(`range key ${styleKey} label`),\n value: t(`range value ${value} label`),\n })}\n </ToolbarItem>\n ))}\n </>\n );\n};\n\n//\n// Actions\n//\n\nconst Actions = () => {\n const { onAction } = useToolbarContext('Actions');\n const { cursorFallbackRange, cursor, model } = useSheetContext();\n const { t } = useTranslation(SHEET_PLUGIN);\n\n // TODO(thure): Can this O(n) call be memoized?\n const overlapsCommentAnchor = (model.sheet.threads ?? [])\n .filter(nonNullable)\n .filter((thread) => thread.status !== 'resolved')\n .some((thread) => {\n if (!cursorFallbackRange) {\n return false;\n }\n return rangeToIndex(model.sheet, cursorFallbackRange) === thread.anchor;\n });\n\n const tooltipLabelKey = !cursor\n ? 'no cursor label'\n : overlapsCommentAnchor\n ? 'selection overlaps existing comment label'\n : 'comment label';\n\n return (\n <ToolbarItem\n itemType='button'\n value='comment'\n icon='ph--chat-text--regular'\n data-testid='editor.toolbar.comment'\n onClick={() => {\n if (!cursorFallbackRange) {\n return;\n }\n return onAction?.({\n key: 'comment',\n value: rangeToIndex(model.sheet, cursorFallbackRange),\n cellContent: model.getCellText(cursorFallbackRange.from),\n });\n }}\n disabled={!cursorFallbackRange || overlapsCommentAnchor}\n >\n {t(tooltipLabelKey)}\n </ToolbarItem>\n );\n};\n\nexport const Toolbar = {\n Root: ToolbarRoot,\n Separator: ToolbarSeparator,\n Alignment,\n Styles,\n Actions,\n};\n\nexport { useToolbarContext };\n", "//\n// Copyright 2024 DXOS.org\n//\n\nimport { SheetContainer } from './SheetContainer';\n\nexport default SheetContainer;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAIA,OAAOA,YAAW;AAGlB,SAASC,iBAAiB;;;ACH1B,OAAOC,WAAW;AAElB,SAASC,YAAY;AAKd,IAAMC,iBAAiB,MAAA;AAC5B,QAAM,EAAEC,OAAOC,QAAQC,MAAK,IAAKC,gBAAAA;AAEjC,MAAIC;AACJ,MAAIC,UAAU;AACd,MAAIJ,QAAQ;AACVG,YAAQJ,MAAMM,aAAaL,MAAAA;AAC3B,QAAIM,UAAUH,KAAAA,GAAQ;AACpBA,cAAQJ,MAAMQ,MAAMC,yBAAyBT,MAAMU,wBAAwBN,KAAAA,CAAAA;AAC3EC,gBAAU;IACZ,WAAWD,SAAS,MAAM;AACxBA,cAAQO,OAAOP,KAAAA;IACjB;EACF;AAEA,SACE,sBAAA,cAACQ,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACD,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACD,OAAAA;IAAIC,WAAU;KACXX,SAASY,kBAAkBZ,KAAAA,KAAYD,UAAUc,oBAAoBd,MAAAA,CAAAA,GAEzE,sBAAA,cAACW,OAAAA;IAAIC,WAAU;KACb,sBAAA,cAACG,MAAAA;IAAKC,MAAK;IAAwBC,YAAY;MAAC;MAAkBb,UAAU,YAAY;;MACxF,sBAAA,cAACc,QAAAA;IAAKN,WAAU;KAAaT,KAAAA,CAAAA,CAAAA,CAAAA;AAKvC;;;ACnCA,SAASgB,qBAAqB;AAC9B,OAAOC,UAAiCC,mBAAmB;AAE3D,SAASC,2BAA2B;AACpC,SACEC,QAAAA,OAEAC,WAAWC,gBAIXC,SACAC,sBACK;AACP,SAASC,oBAAoB;AAC7B,SAASC,mBAAmB;AAwB5B,IAAMC,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AA,cAACc,gBAAAA,IAAAA,CAAAA,CAAAA,IAGH;AACN;;;AGrCA,IAAA,yBAAeC;",
|
|
6
|
+
"names": ["React", "StackItem", "React", "Icon", "FunctionEditor", "model", "cursor", "range", "useSheetContext", "value", "formula", "getCellValue", "isFormula", "graph", "mapFunctionBindingFromId", "mapFormulaIndicesToRefs", "String", "div", "className", "rangeToA1Notation", "addressToA1Notation", "Icon", "icon", "classNames", "span", "createContext", "React", "useCallback", "useIntentDispatcher", "Icon", "Toolbar", "NaturalToolbar", "Tooltip", "useTranslation", "useAttention", "nonNullable", "buttonStyles", "tooltipProps", "side", "classNames", "ToolbarSeparator", "React", "div", "role", "className", "ToolbarItem", "itemType", "icon", "children", "props", "Invoker", "NaturalToolbar", "ToggleGroupItem", "Toggle", "Button", "Tooltip", "Root", "Trigger", "asChild", "variant", "Icon", "size", "span", "Portal", "Content", "Arrow", "ToolbarContextProvider", "useToolbarContext", "createContext", "ToolbarRoot", "id", "model", "cursorFallbackRange", "cursor", "useSheetContext", "hasAttention", "useAttention", "dispatch", "useIntentDispatcher", "handleAction", "useCallback", "action", "key", "index", "sheet", "ranges", "findIndex", "range", "inRange", "rangeFromIndex", "from", "nextRangeEntity", "rangeToIndex", "value", "push", "splice", "unset", "data", "completeCellRangeToThreadCursor", "name", "cellContent", "subject", "onAction", "alignmentOptions", "Alignment", "t", "useTranslation", "SHEET_PLUGIN", "findLast", "alignKey", "undefined", "ToggleGroup", "type", "onValueChange", "map", "data-testid", "styleOptions", "Styles", "activeValues", "filter", "reduce", "acc", "add", "Set", "pressed", "has", "onPressedChange", "nextPressed", "styleKey", "Actions", "overlapsCommentAnchor", "threads", "nonNullable", "thread", "status", "some", "anchor", "tooltipLabelKey", "onClick", "getCellText", "disabled", "Toolbar", "Separator", "SheetContainer", "space", "sheet", "role", "ignoreAttention", "graph", "useComputeGraph", "React", "SheetProvider", "StackItem", "Content", "toolbar", "statusbar", "classNames", "Toolbar", "Root", "Styles", "Alignment", "Separator", "Actions", "GridSheet", "FunctionEditor", "SheetContainer"]
|
|
7
7
|
}
|
|
@@ -976,9 +976,9 @@ var SheetProvider = ({ children, graph, sheet, readonly, ignoreAttention, onInfo
|
|
|
976
976
|
};
|
|
977
977
|
|
|
978
978
|
// packages/plugins/plugin-sheet/src/components/GridSheet/GridSheet.tsx
|
|
979
|
-
import
|
|
979
|
+
import React5, { useCallback as useCallback4, useMemo as useMemo2, useRef, useState as useState4 } from "react";
|
|
980
980
|
import { useIntentDispatcher as useIntentDispatcher2 } from "@dxos/app-framework";
|
|
981
|
-
import { DropdownMenu, Icon, useTranslation as
|
|
981
|
+
import { DropdownMenu, Icon, useTranslation as useTranslation3 } from "@dxos/react-ui";
|
|
982
982
|
import { useAttention } from "@dxos/react-ui-attention";
|
|
983
983
|
import { closestCell, defaultSizeRow, editorKeys, Grid as Grid2, GridCellEditor } from "@dxos/react-ui-grid";
|
|
984
984
|
|
|
@@ -1037,8 +1037,28 @@ var RangeList = ({ sheet }) => {
|
|
|
1037
1037
|
})))));
|
|
1038
1038
|
};
|
|
1039
1039
|
|
|
1040
|
+
// packages/plugins/plugin-sheet/src/components/SheetObjectSettings.tsx
|
|
1041
|
+
import React4 from "react";
|
|
1042
|
+
import { SPACE_PLUGIN } from "@dxos/plugin-space/meta";
|
|
1043
|
+
import { Input, useTranslation as useTranslation2 } from "@dxos/react-ui";
|
|
1044
|
+
var SheetObjectSettings = ({ sheet }) => {
|
|
1045
|
+
const { t } = useTranslation2(SPACE_PLUGIN);
|
|
1046
|
+
return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement("div", {
|
|
1047
|
+
role: "form",
|
|
1048
|
+
className: "flex flex-col w-full p-2 gap-1"
|
|
1049
|
+
}, /* @__PURE__ */ React4.createElement(Input.Root, null, /* @__PURE__ */ React4.createElement(Input.Label, null, t("name label")), /* @__PURE__ */ React4.createElement(Input.TextInput, {
|
|
1050
|
+
placeholder: t("name placeholder"),
|
|
1051
|
+
value: sheet.name ?? "",
|
|
1052
|
+
onChange: (event) => {
|
|
1053
|
+
sheet.name = event.target.value;
|
|
1054
|
+
}
|
|
1055
|
+
}))), /* @__PURE__ */ React4.createElement(RangeList, {
|
|
1056
|
+
sheet
|
|
1057
|
+
}));
|
|
1058
|
+
};
|
|
1059
|
+
|
|
1040
1060
|
// packages/plugins/plugin-sheet/src/components/index.ts
|
|
1041
|
-
var SheetContainer = lazy(() => import("./SheetContainer-
|
|
1061
|
+
var SheetContainer = lazy(() => import("./SheetContainer-DBDIZU6U.mjs"));
|
|
1042
1062
|
|
|
1043
1063
|
// packages/plugins/plugin-sheet/src/integrations/thread-ranges.ts
|
|
1044
1064
|
var completeCellRangeToThreadCursor = (range) => {
|
|
@@ -1076,6 +1096,9 @@ var useUpdateFocusedCellOnThreadSelection = (grid) => {
|
|
|
1076
1096
|
...range.to,
|
|
1077
1097
|
plane: "grid"
|
|
1078
1098
|
}, true);
|
|
1099
|
+
return {
|
|
1100
|
+
data: true
|
|
1101
|
+
};
|
|
1079
1102
|
}
|
|
1080
1103
|
}
|
|
1081
1104
|
}, [
|
|
@@ -1347,7 +1370,7 @@ var sheetColDefault = {
|
|
|
1347
1370
|
}
|
|
1348
1371
|
};
|
|
1349
1372
|
var GridSheet = () => {
|
|
1350
|
-
const { t } =
|
|
1373
|
+
const { t } = useTranslation3(SHEET_PLUGIN);
|
|
1351
1374
|
const { id, model, editing, setCursor, setRange, cursor, cursorFallbackRange, activeRefs, ignoreAttention } = useSheetContext();
|
|
1352
1375
|
const [dxGrid, setDxGrid] = useState4(null);
|
|
1353
1376
|
const [extraplanarFocus, setExtraplanarFocus] = useState4(null);
|
|
@@ -1607,14 +1630,14 @@ var GridSheet = () => {
|
|
|
1607
1630
|
]);
|
|
1608
1631
|
useUpdateFocusedCellOnThreadSelection(dxGrid);
|
|
1609
1632
|
useSelectThreadOnCellFocus();
|
|
1610
|
-
return /* @__PURE__ */
|
|
1633
|
+
return /* @__PURE__ */ React5.createElement("div", {
|
|
1611
1634
|
role: "none",
|
|
1612
1635
|
className: "relative min-bs-0"
|
|
1613
|
-
}, /* @__PURE__ */
|
|
1636
|
+
}, /* @__PURE__ */ React5.createElement(GridCellEditor, {
|
|
1614
1637
|
getCellContent,
|
|
1615
1638
|
extension,
|
|
1616
1639
|
onBlur: handleBlur
|
|
1617
|
-
}), /* @__PURE__ */
|
|
1640
|
+
}), /* @__PURE__ */ React5.createElement(Grid2.Content, {
|
|
1618
1641
|
initialCells,
|
|
1619
1642
|
limitColumns: DEFAULT_COLUMNS,
|
|
1620
1643
|
limitRows: DEFAULT_ROWS,
|
|
@@ -1634,32 +1657,35 @@ var GridSheet = () => {
|
|
|
1634
1657
|
className: "[--dx-grid-base:var(--surface-bg)] [&_.dx-grid]:border-bs [&_.dx-grid]:absolute [&_.dx-grid]:inset-0 [&_.dx-grid]:border-separator",
|
|
1635
1658
|
activeRefs,
|
|
1636
1659
|
ref: setDxGrid
|
|
1637
|
-
}), /* @__PURE__ */
|
|
1660
|
+
}), /* @__PURE__ */ React5.createElement(DropdownMenu.Root, {
|
|
1638
1661
|
modal: false,
|
|
1639
1662
|
open: !!contextMenuOpen,
|
|
1640
1663
|
onOpenChange: (nextOpen) => setContextMenuOpen(nextOpen ? inertPosition : null)
|
|
1641
|
-
}, /* @__PURE__ */
|
|
1664
|
+
}, /* @__PURE__ */ React5.createElement(DropdownMenu.VirtualTrigger, {
|
|
1642
1665
|
virtualRef: contextMenuAnchorRef
|
|
1643
|
-
}), /* @__PURE__ */
|
|
1666
|
+
}), /* @__PURE__ */ React5.createElement(DropdownMenu.Content, {
|
|
1644
1667
|
side: contextMenuAxis === "col" ? "bottom" : "right",
|
|
1645
1668
|
sideOffset: 4,
|
|
1646
1669
|
collisionPadding: 8
|
|
1647
|
-
}, /* @__PURE__ */
|
|
1648
|
-
onClick: () => handleAxisMenuAction("insert-before")
|
|
1649
|
-
|
|
1670
|
+
}, /* @__PURE__ */ React5.createElement(DropdownMenu.Viewport, null, /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
1671
|
+
onClick: () => handleAxisMenuAction("insert-before"),
|
|
1672
|
+
"data-testid": `grid.${contextMenuAxis}.insert-before`
|
|
1673
|
+
}, /* @__PURE__ */ React5.createElement(Icon, {
|
|
1650
1674
|
size: 5,
|
|
1651
1675
|
icon: contextMenuAxis === "col" ? "ph--columns-plus-left--regular" : "ph--rows-plus-top--regular"
|
|
1652
|
-
}), /* @__PURE__ */
|
|
1653
|
-
onClick: () => handleAxisMenuAction("insert-after")
|
|
1654
|
-
|
|
1676
|
+
}), /* @__PURE__ */ React5.createElement("span", null, t(`add ${contextMenuAxis} before label`))), /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
1677
|
+
onClick: () => handleAxisMenuAction("insert-after"),
|
|
1678
|
+
"data-testid": `grid.${contextMenuAxis}.insert-after`
|
|
1679
|
+
}, /* @__PURE__ */ React5.createElement(Icon, {
|
|
1655
1680
|
size: 5,
|
|
1656
1681
|
icon: contextMenuAxis === "col" ? "ph--columns-plus-right--regular" : "ph--rows-plus-bottom--regular"
|
|
1657
|
-
}), /* @__PURE__ */
|
|
1658
|
-
onClick: () => handleAxisMenuAction("drop")
|
|
1659
|
-
|
|
1682
|
+
}), /* @__PURE__ */ React5.createElement("span", null, t(`add ${contextMenuAxis} after label`))), /* @__PURE__ */ React5.createElement(DropdownMenu.Item, {
|
|
1683
|
+
onClick: () => handleAxisMenuAction("drop"),
|
|
1684
|
+
"data-testid": `grid.${contextMenuAxis}.drop`
|
|
1685
|
+
}, /* @__PURE__ */ React5.createElement(Icon, {
|
|
1660
1686
|
size: 5,
|
|
1661
1687
|
icon: "ph--backspace--regular"
|
|
1662
|
-
}), /* @__PURE__ */
|
|
1688
|
+
}), /* @__PURE__ */ React5.createElement("span", null, t(`delete ${contextMenuAxis} label`)))), /* @__PURE__ */ React5.createElement(DropdownMenu.Arrow, null))));
|
|
1663
1689
|
};
|
|
1664
1690
|
|
|
1665
1691
|
export {
|
|
@@ -1670,7 +1696,7 @@ export {
|
|
|
1670
1696
|
useSheetContext,
|
|
1671
1697
|
SheetProvider,
|
|
1672
1698
|
GridSheet,
|
|
1673
|
-
|
|
1699
|
+
SheetObjectSettings,
|
|
1674
1700
|
SheetContainer
|
|
1675
1701
|
};
|
|
1676
|
-
//# sourceMappingURL=chunk-
|
|
1702
|
+
//# sourceMappingURL=chunk-IXA5HC36.mjs.map
|