@dxos/plugin-sheet 0.6.12-main.89e9959 → 0.6.12-main.c1d977f

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.
Files changed (85) hide show
  1. package/dist/lib/browser/{SheetContainer-LG77O4RM.mjs → SheetContainer-7QG5RIM4.mjs} +4 -4
  2. package/dist/lib/browser/{chunk-WZMOZKQZ.mjs → chunk-4DPOO6BK.mjs} +18 -6
  3. package/dist/lib/browser/{chunk-WZMOZKQZ.mjs.map → chunk-4DPOO6BK.mjs.map} +3 -3
  4. package/dist/lib/browser/{chunk-CHQAW4F4.mjs → chunk-BKTLTM2Y.mjs} +83 -227
  5. package/dist/lib/browser/chunk-BKTLTM2Y.mjs.map +7 -0
  6. package/dist/lib/browser/{chunk-QILRZNE5.mjs → chunk-D3QTX46O.mjs} +4 -5
  7. package/dist/lib/browser/chunk-D3QTX46O.mjs.map +7 -0
  8. package/dist/lib/browser/index.mjs +8 -17
  9. package/dist/lib/browser/index.mjs.map +4 -4
  10. package/dist/lib/browser/meta.json +1 -1
  11. package/dist/lib/browser/meta.mjs +1 -1
  12. package/dist/lib/browser/types.mjs +2 -2
  13. package/dist/lib/node/{SheetContainer-OZ7DHH4L.cjs → SheetContainer-DXDD2G3A.cjs} +16 -16
  14. package/dist/lib/node/{chunk-5FTFZL5W.cjs → chunk-4FMMRVT2.cjs} +42 -185
  15. package/dist/lib/node/chunk-4FMMRVT2.cjs.map +7 -0
  16. package/dist/lib/node/{chunk-AOP42UAA.cjs → chunk-PJY2K5S2.cjs} +22 -10
  17. package/dist/lib/node/{chunk-AOP42UAA.cjs.map → chunk-PJY2K5S2.cjs.map} +3 -3
  18. package/dist/lib/node/{chunk-BNARJ5GM.cjs → chunk-QIFIGEKV.cjs} +6 -7
  19. package/dist/lib/node/chunk-QIFIGEKV.cjs.map +7 -0
  20. package/dist/lib/node/index.cjs +29 -37
  21. package/dist/lib/node/index.cjs.map +4 -4
  22. package/dist/lib/node/meta.cjs +3 -3
  23. package/dist/lib/node/meta.cjs.map +1 -1
  24. package/dist/lib/node/meta.json +1 -1
  25. package/dist/lib/node/types.cjs +9 -9
  26. package/dist/lib/node/types.cjs.map +1 -1
  27. package/dist/lib/node-esm/{SheetContainer-4XS2G25Z.mjs → SheetContainer-5WYNOYYD.mjs} +4 -4
  28. package/dist/lib/node-esm/{chunk-RR2AO4SM.mjs → chunk-2X36GIGW.mjs} +18 -6
  29. package/dist/lib/node-esm/{chunk-RR2AO4SM.mjs.map → chunk-2X36GIGW.mjs.map} +3 -3
  30. package/dist/lib/node-esm/{chunk-KK3XL37M.mjs → chunk-JYDBXLDH.mjs} +83 -227
  31. package/dist/lib/node-esm/chunk-JYDBXLDH.mjs.map +7 -0
  32. package/dist/lib/node-esm/{chunk-IU2L277A.mjs → chunk-VCYJWE3O.mjs} +4 -5
  33. package/dist/lib/node-esm/chunk-VCYJWE3O.mjs.map +7 -0
  34. package/dist/lib/node-esm/index.mjs +8 -17
  35. package/dist/lib/node-esm/index.mjs.map +4 -4
  36. package/dist/lib/node-esm/meta.json +1 -1
  37. package/dist/lib/node-esm/meta.mjs +1 -1
  38. package/dist/lib/node-esm/types.mjs +2 -2
  39. package/dist/types/src/components/GridSheet/GridSheet.d.ts.map +1 -1
  40. package/dist/types/src/components/{CellEditor/CellEditor.stories.d.ts → GridSheet/SheetCellEditor.stories.d.ts} +2 -2
  41. package/dist/types/src/components/GridSheet/SheetCellEditor.stories.d.ts.map +1 -0
  42. package/dist/types/src/components/GridSheet/util.d.ts +2 -2
  43. package/dist/types/src/components/GridSheet/util.d.ts.map +1 -1
  44. package/dist/types/src/components/Sheet/Sheet.d.ts.map +1 -1
  45. package/dist/types/src/components/Sheet/Sheet.stories.d.ts.map +1 -1
  46. package/dist/types/src/extensions/editor/extension.d.ts.map +1 -0
  47. package/dist/types/src/extensions/editor/extension.test.d.ts.map +1 -0
  48. package/dist/types/src/extensions/editor/index.d.ts +2 -0
  49. package/dist/types/src/extensions/editor/index.d.ts.map +1 -0
  50. package/dist/types/src/extensions/index.d.ts +1 -0
  51. package/dist/types/src/extensions/index.d.ts.map +1 -1
  52. package/dist/types/src/meta.d.ts +3 -6
  53. package/dist/types/src/meta.d.ts.map +1 -1
  54. package/dist/types/src/types.d.ts.map +1 -1
  55. package/package.json +34 -34
  56. package/src/components/GridSheet/GridSheet.tsx +14 -32
  57. package/src/components/{CellEditor/CellEditor.stories.tsx → GridSheet/SheetCellEditor.stories.tsx} +2 -2
  58. package/src/components/GridSheet/util.ts +2 -6
  59. package/src/components/Sheet/Sheet.tsx +2 -8
  60. package/src/{components/CellEditor → extensions/editor}/index.ts +0 -1
  61. package/src/extensions/index.ts +1 -0
  62. package/src/{meta.tsx → meta.ts} +3 -3
  63. package/src/model/sheet-model.test.ts +1 -3
  64. package/src/types.ts +4 -4
  65. package/dist/lib/browser/chunk-CHQAW4F4.mjs.map +0 -7
  66. package/dist/lib/browser/chunk-QILRZNE5.mjs.map +0 -7
  67. package/dist/lib/node/chunk-5FTFZL5W.cjs.map +0 -7
  68. package/dist/lib/node/chunk-BNARJ5GM.cjs.map +0 -7
  69. package/dist/lib/node-esm/chunk-IU2L277A.mjs.map +0 -7
  70. package/dist/lib/node-esm/chunk-KK3XL37M.mjs.map +0 -7
  71. package/dist/types/src/components/CellEditor/CellEditor.d.ts +0 -34
  72. package/dist/types/src/components/CellEditor/CellEditor.d.ts.map +0 -1
  73. package/dist/types/src/components/CellEditor/CellEditor.stories.d.ts.map +0 -1
  74. package/dist/types/src/components/CellEditor/extension.d.ts.map +0 -1
  75. package/dist/types/src/components/CellEditor/extension.test.d.ts.map +0 -1
  76. package/dist/types/src/components/CellEditor/index.d.ts +0 -3
  77. package/dist/types/src/components/CellEditor/index.d.ts.map +0 -1
  78. package/src/components/CellEditor/CellEditor.tsx +0 -163
  79. /package/dist/lib/browser/{SheetContainer-LG77O4RM.mjs.map → SheetContainer-7QG5RIM4.mjs.map} +0 -0
  80. /package/dist/lib/node/{SheetContainer-OZ7DHH4L.cjs.map → SheetContainer-DXDD2G3A.cjs.map} +0 -0
  81. /package/dist/lib/node-esm/{SheetContainer-4XS2G25Z.mjs.map → SheetContainer-5WYNOYYD.mjs.map} +0 -0
  82. /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.d.ts +0 -0
  83. /package/dist/types/src/{components/CellEditor → extensions/editor}/extension.test.d.ts +0 -0
  84. /package/src/{components/CellEditor → extensions/editor}/extension.test.ts +0 -0
  85. /package/src/{components/CellEditor → extensions/editor}/extension.ts +0 -0
@@ -1,163 +0,0 @@
1
- //
2
- // Copyright 2024 DXOS.org
3
- //
4
-
5
- import { type Extension } from '@codemirror/state';
6
- import { EditorView, keymap } from '@codemirror/view';
7
- import React, { type DOMAttributes, type KeyboardEvent } from 'react';
8
-
9
- import { useThemeContext } from '@dxos/react-ui';
10
- import {
11
- type UseTextEditorProps,
12
- createBasicExtensions,
13
- createThemeExtensions,
14
- preventNewline,
15
- useTextEditor,
16
- } from '@dxos/react-ui-editor';
17
- import { type GridEditBox } from '@dxos/react-ui-grid';
18
-
19
- type EditorKeyEvent = Pick<KeyboardEvent<HTMLInputElement>, 'key'> & { shift?: boolean };
20
-
21
- export type EditorKeysProps = {
22
- onClose: (value: string | undefined, event: EditorKeyEvent) => void;
23
- onNav?: (value: string | undefined, event: EditorKeyEvent) => void;
24
- };
25
-
26
- export const editorKeys = ({ onNav, onClose }: EditorKeysProps): Extension => {
27
- return keymap.of([
28
- {
29
- key: 'ArrowUp',
30
- run: (editor) => {
31
- const value = editor.state.doc.toString();
32
- onNav?.(value, { key: 'ArrowUp' });
33
- return !!onNav;
34
- },
35
- },
36
- {
37
- key: 'ArrowDown',
38
- run: (editor) => {
39
- const value = editor.state.doc.toString();
40
- onNav?.(value, { key: 'ArrowDown' });
41
- return !!onNav;
42
- },
43
- },
44
- {
45
- key: 'ArrowLeft',
46
- run: (editor) => {
47
- const value = editor.state.doc.toString();
48
- onNav?.(value, { key: 'ArrowLeft' });
49
- return !!onNav;
50
- },
51
- },
52
- {
53
- key: 'ArrowRight',
54
- run: (editor) => {
55
- const value = editor.state.doc.toString();
56
- onNav?.(value, { key: 'ArrowRight' });
57
- return !!onNav;
58
- },
59
- },
60
- {
61
- key: 'Enter',
62
- run: (editor) => {
63
- onClose(editor.state.doc.toString(), { key: 'Enter' });
64
- return true;
65
- },
66
- shift: (editor) => {
67
- onClose(editor.state.doc.toString(), { key: 'Enter', shift: true });
68
- return true;
69
- },
70
- },
71
- {
72
- key: 'Tab',
73
- run: (editor) => {
74
- onClose(editor.state.doc.toString(), { key: 'Tab' });
75
- return true;
76
- },
77
- shift: (editor) => {
78
- onClose(editor.state.doc.toString(), { key: 'Tab', shift: true });
79
- return true;
80
- },
81
- },
82
- {
83
- key: 'Escape',
84
- run: () => {
85
- onClose(undefined, { key: 'Escape' });
86
- return true;
87
- },
88
- },
89
- ]);
90
- };
91
-
92
- export type CellEditorProps = {
93
- value?: string;
94
- extension?: Extension;
95
- variant?: keyof typeof editorVariants;
96
- box?: GridEditBox;
97
- gridId?: string;
98
- } & Pick<UseTextEditorProps, 'autoFocus'> &
99
- Pick<DOMAttributes<HTMLInputElement>, 'onBlur' | 'onKeyDown'>;
100
-
101
- const editorVariants = {
102
- // TODO(thure): remove when legacy is no longer used.
103
- legacy: {
104
- root: 'flex w-full',
105
- editor: 'flex w-full [&>.cm-scroller]:scrollbar-none',
106
- content: '!px-2 !py-1',
107
- },
108
- grid: {
109
- root: 'absolute z-[1]',
110
- editor: '[&>.cm-scroller]:scrollbar-none tabular-nums',
111
- content: '!border !border-transparent !p-0.5',
112
- },
113
- };
114
-
115
- export const CellEditor = ({
116
- value,
117
- extension,
118
- autoFocus,
119
- onBlur,
120
- variant = 'legacy',
121
- box,
122
- gridId,
123
- }: CellEditorProps) => {
124
- const { themeMode } = useThemeContext();
125
- const { parentRef } = useTextEditor(() => {
126
- return {
127
- autoFocus,
128
- initialValue: value,
129
- selection: { anchor: value?.length ?? 0 },
130
- extensions: [
131
- extension ?? [],
132
- preventNewline,
133
- EditorView.focusChangeEffect.of((_, focusing) => {
134
- if (!focusing) {
135
- onBlur?.({ type: 'blur' } as any);
136
- }
137
- return null;
138
- }),
139
- createBasicExtensions({ lineWrapping: false }),
140
- createThemeExtensions({
141
- themeMode,
142
- slots: {
143
- editor: {
144
- className: editorVariants[variant].editor,
145
- },
146
- content: {
147
- className: editorVariants[variant].content,
148
- },
149
- },
150
- }),
151
- ],
152
- };
153
- }, [extension, autoFocus, value, variant, onBlur]);
154
-
155
- return (
156
- <div
157
- ref={parentRef}
158
- className={editorVariants[variant].root}
159
- style={box}
160
- {...(gridId && { 'data-grid': gridId })}
161
- />
162
- );
163
- };