@noraent/nora-datagrid 0.0.4 → 0.0.6

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/lib/cjs/App.js CHANGED
@@ -1,131 +1,131 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import React from "react";
3
3
  import { DataGrid } from "./DataGrid";
4
4
  function App() {
5
5
  const ref = React.useRef(null);
6
- return (_jsxs("div", { style: { width: "1200px", height: "500px" }, children: [_jsx("button", { children: "dd" }), _jsx("button", { children: "dd" }), _jsx(DataGrid, { gridRef: ref, columns: [
7
- {
8
- fieldId: "firstName",
9
- fieldName: "코드",
10
- },
11
- {
12
- fieldId: "lastName",
13
- fieldName: "이름",
14
- width: "120",
15
- },
16
- {
17
- fieldId: "currency",
18
- fieldName: "성명",
19
- width: "120",
20
- },
21
- {
22
- fieldId: "currency4",
23
- fieldName: "국가",
24
- width: "140",
25
- },
26
- {
27
- fieldId: "currency5",
28
- fieldName: "구매링크",
29
- width: "120",
30
- },
31
- {
32
- fieldId: "currency6",
33
- fieldName: "카드",
34
- width: "130",
35
- },
36
- {
37
- fieldId: "currency7",
38
- fieldName: "카드번호",
39
- width: "120",
40
- },
41
- {
42
- fieldId: "currency8",
43
- fieldName: "currency8",
44
- width: "140",
45
- },
46
- {
47
- fieldId: "currency9",
48
- fieldName: "currency9",
49
- width: "120",
50
- },
51
- {
52
- fieldId: "currency10",
53
- fieldName: "currency10",
54
- width: "130",
55
- },
56
- {
57
- fieldId: "currency11",
58
- fieldName: "currency11",
59
- width: "120",
60
- },
61
- {
62
- fieldId: "currency12",
63
- fieldName: "currency12",
64
- width: "120",
65
- },
66
- {
67
- fieldId: "currency13",
68
- fieldName: "Currency13",
69
- width: "120",
70
- },
71
- {
72
- fieldId: "currency14",
73
- fieldName: "currency14",
74
- width: "120",
75
- },
76
- {
77
- fieldId: "currency15",
78
- fieldName: "currency15",
79
- width: "120",
80
- },
81
- {
82
- fieldId: "currency16",
83
- fieldName: "Currency16",
84
- width: "120",
85
- },
86
- {
87
- fieldId: "currency17",
88
- fieldName: "currency17",
89
- width: "120",
90
- },
91
- {
92
- fieldId: "currency18",
93
- fieldName: "currency18",
94
- width: "120",
95
- },
96
- {
97
- fieldId: "currency19",
98
- fieldName: "currency19",
99
- width: "120",
100
- },
101
- {
102
- fieldId: "currency19",
103
- fieldName: "Currency19",
104
- width: "120",
105
- },
106
- {
107
- fieldId: "currency20",
108
- fieldName: "currency20",
109
- width: "120",
110
- },
111
- {
112
- fieldId: "currency21",
113
- fieldName: "currency21",
114
- width: "120",
115
- },
116
- ], dataSource: Array.from({ length: 100 }, (_, i) => {
117
- return {
118
- id: i,
119
- firstName: `test-${i}`,
120
- lastName: `lastName-${i}`,
121
- currency: `currency-${i}`,
122
- currency14: `currency14-${i}`,
123
- currency15: `currency15-${i}`,
124
- __uuid: "",
125
- // height: 30,
126
- // height: Math.floor(Math.random() * 20) + 20,
127
- };
128
- }) }), _jsx("button", { children: "dd" })] }));
6
+ return (_jsxs(_Fragment, { children: [_jsx("button", { children: "dd" }), _jsx("button", { children: "dd" }), _jsx("div", { style: { width: "1200px", height: "100%", maxHeight: "600px" }, children: _jsx(DataGrid, { readOnly: true, gridRef: ref, columns: [
7
+ {
8
+ fieldId: "firstName",
9
+ fieldName: "코드",
10
+ },
11
+ {
12
+ fieldId: "lastName",
13
+ fieldName: "이름",
14
+ width: "120",
15
+ },
16
+ {
17
+ fieldId: "currency",
18
+ fieldName: "성명",
19
+ width: "120",
20
+ },
21
+ {
22
+ fieldId: "currency4",
23
+ fieldName: "국가",
24
+ width: "140",
25
+ },
26
+ {
27
+ fieldId: "currency5",
28
+ fieldName: "구매링크",
29
+ width: "120",
30
+ },
31
+ {
32
+ fieldId: "currency6",
33
+ fieldName: "카드",
34
+ width: "130",
35
+ },
36
+ {
37
+ fieldId: "currency7",
38
+ fieldName: "카드번호",
39
+ width: "120",
40
+ },
41
+ {
42
+ fieldId: "currency8",
43
+ fieldName: "currency8",
44
+ width: "140",
45
+ },
46
+ {
47
+ fieldId: "currency9",
48
+ fieldName: "currency9",
49
+ width: "120",
50
+ },
51
+ {
52
+ fieldId: "currency10",
53
+ fieldName: "currency10",
54
+ width: "130",
55
+ },
56
+ {
57
+ fieldId: "currency11",
58
+ fieldName: "currency11",
59
+ width: "120",
60
+ },
61
+ {
62
+ fieldId: "currency12",
63
+ fieldName: "currency12",
64
+ width: "120",
65
+ },
66
+ {
67
+ fieldId: "currency13",
68
+ fieldName: "Currency13",
69
+ width: "120",
70
+ },
71
+ {
72
+ fieldId: "currency14",
73
+ fieldName: "currency14",
74
+ width: "120",
75
+ },
76
+ {
77
+ fieldId: "currency15",
78
+ fieldName: "currency15",
79
+ width: "120",
80
+ },
81
+ {
82
+ fieldId: "currency16",
83
+ fieldName: "Currency16",
84
+ width: "120",
85
+ },
86
+ {
87
+ fieldId: "currency17",
88
+ fieldName: "currency17",
89
+ width: "120",
90
+ },
91
+ {
92
+ fieldId: "currency18",
93
+ fieldName: "currency18",
94
+ width: "120",
95
+ },
96
+ {
97
+ fieldId: "currency19",
98
+ fieldName: "currency19",
99
+ width: "120",
100
+ },
101
+ {
102
+ fieldId: "currency19",
103
+ fieldName: "Currency19",
104
+ width: "120",
105
+ },
106
+ {
107
+ fieldId: "currency20",
108
+ fieldName: "currency20",
109
+ width: "120",
110
+ },
111
+ {
112
+ fieldId: "currency21",
113
+ fieldName: "currency21",
114
+ width: "120",
115
+ },
116
+ ], dataSource: Array.from({ length: 30 }, (_, i) => {
117
+ return {
118
+ id: i,
119
+ firstName: `test-${i}`,
120
+ lastName: `lastName-${i}`,
121
+ currency: `currency-${i}`,
122
+ currency14: `currency14-${i}`,
123
+ currency15: `currency15-${i}`,
124
+ __uuid: "",
125
+ // height: 30,
126
+ // height: Math.floor(Math.random() * 20) + 20,
127
+ };
128
+ }) }) }), _jsx("button", { children: "dd" })] }));
129
129
  }
130
130
  export const initialItemsData = () => Array.from({ length: 10 }, (_, i) => {
131
131
  return {
@@ -32,6 +32,6 @@ const DataGridMaster = React.forwardRef((props, _ref) => {
32
32
  // }
33
33
  // return () => clearInterval(id);
34
34
  // }, [count]);
35
- return (_jsx(_Fragment, { children: _jsx(GridApiContext.Provider, { value: apiRef, children: _jsxs(GridStoreContentProvider, { value: apiRef, children: [_jsx("button", { onClick: () => { }, children: "!!" }), _jsxs(NoraDataGrid, { ref: containerRef, children: [_jsx(NoraDataGrid.Title, { children: "\uC624\uBC84\uB77C\uC774\uB4DC \uD588\uC5B4\uC6A9" }), _jsx(NoraDataGrid.Body, { children: !isPending && apiRef.current.store && _jsx(TwoDimensionalVirtualizedList, {}) })] })] }) }) }));
35
+ return (_jsx(_Fragment, { children: _jsx(GridApiContext.Provider, { value: apiRef, children: _jsx(GridStoreContentProvider, { value: apiRef, children: _jsxs(NoraDataGrid, { ref: containerRef, children: [_jsx(NoraDataGrid.Title, {}), _jsx(NoraDataGrid.Body, { children: !isPending && apiRef.current.store && _jsx(TwoDimensionalVirtualizedList, {}) })] }) }) }) }));
36
36
  });
37
37
  export const DataGrid = React.memo(DataGridMaster);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noraent/nora-datagrid",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "module": "./lib/esm/index.js",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "private": false,
@@ -10,6 +10,7 @@ import { useSelector, useStore } from "../provider/GridStoreContent";
10
10
  import { EditStatus } from "../types/dataGridCoreEnum";
11
11
  import CellMode from "./cell/CellMode";
12
12
  import ImeComponent from "./ime/IMEComponent";
13
+ import NoDataComponent from "./body/NoDataComponent";
13
14
  const initialWindowWidth = 800;
14
15
  export const initialWindowHeight = 500;
15
16
  const initialBodyHeight = initialWindowHeight - 34;
@@ -31,15 +32,30 @@ const DynamicVirtualScroll = React.memo(({ children }) => {
31
32
  const rightScrollRef = useRef(null);
32
33
  const bottomScrollRef = useRef(null);
33
34
  useEffect(() => {
34
- const handleResize = () => {
35
- var _a, _b, _c, _d, _f, _g;
36
- const store = gridRef.current.store;
37
- const width = (_c = (_b = (_a = store === null || store === void 0 ? void 0 : store.gridContainer.current) === null || _a === void 0 ? void 0 : _a.parentElement) === null || _b === void 0 ? void 0 : _b.clientWidth) !== null && _c !== void 0 ? _c : 0;
38
- const height = (_g = (_f = (_d = store === null || store === void 0 ? void 0 : store.gridContainer.current) === null || _d === void 0 ? void 0 : _d.parentElement) === null || _f === void 0 ? void 0 : _f.clientHeight) !== null && _g !== void 0 ? _g : 0;
39
- setWindowSize({ width, height });
40
- };
41
- handleResize();
42
- window.addEventListener("resize", handleResize);
35
+ var _a;
36
+ const store = gridRef.current.store;
37
+ const parentElement = (_a = store === null || store === void 0 ? void 0 : store.gridContainer.current) === null || _a === void 0 ? void 0 : _a.parentElement;
38
+ // ResizeObserver 인스턴스 생성: 부모 요소의 크기 변화를 감지함
39
+ const observer = new ResizeObserver((entries) => {
40
+ // 감지된 모든 요소에 대해 반복
41
+ for (let entry of entries) {
42
+ // 감지된 요소의 현재 너비를 가져옴
43
+ const parentWidth = entry.contentRect.width;
44
+ const parentHeight = entry.contentRect.height;
45
+ // 새로운 자식 요소의 크기 계산
46
+ const newWidth = parentWidth;
47
+ const newHeight = parentHeight;
48
+ // // 자식 요소의 현재 크기와 새 크기가 다른 경우, 크기를 업데이트
49
+ setWindowSize({
50
+ width: newWidth,
51
+ height: newHeight,
52
+ });
53
+ }
54
+ });
55
+ // 부모 요소에 대한 참조가 있을 경우, 감지 시작
56
+ if (parentElement) {
57
+ observer.observe(parentElement);
58
+ }
43
59
  window.addEventListener("focusout", (event) => {
44
60
  var _a;
45
61
  if (((_a = event.target.nextElementSibling) === null || _a === void 0 ? void 0 : _a.className) === "nora-data-grid-container") {
@@ -47,7 +63,9 @@ const DynamicVirtualScroll = React.memo(({ children }) => {
47
63
  }
48
64
  });
49
65
  return () => {
50
- window.removeEventListener("resize", handleResize);
66
+ if (parentElement) {
67
+ observer.unobserve(parentElement);
68
+ }
51
69
  };
52
70
  }, []);
53
71
  const { columns } = useSelector((store) => ({
@@ -112,7 +130,8 @@ const DynamicVirtualScroll = React.memo(({ children }) => {
112
130
  }
113
131
  // 포함 안되어있으면 추가
114
132
  if (rowIndex && rowIndex >= end) {
115
- result.push(dataSource[rowIndex - 1]); // fixedIndex가 범위에 포함되지 않으면 첫 번째에 추가
133
+ if (result[result.length - 1].__ariaRowindex !== dataSource[rowIndex - 1].__ariaRowindex)
134
+ result.push(dataSource[rowIndex - 1]); // fixedIndex가 범위에 포함되지 않으면 첫 번째에 추가
116
135
  }
117
136
  return result;
118
137
  }, [dataSource, start, end]);
@@ -194,30 +213,30 @@ const DynamicVirtualScroll = React.memo(({ children }) => {
194
213
  console.log("start, end!", start, end);
195
214
  gridRef.current.store.state.renderedRowStartEnd = [start, end];
196
215
  }, [start, end]);
197
- return (_jsxs("div", { style: { position: "relative" }, children: [_jsx("div", { style: {
216
+ return (_jsxs("div", { style: { position: "relative" }, children: [_jsxs("div", { style: {
198
217
  height: `${windowSize.height}px`,
199
218
  width: `${windowSize.width}px`,
200
- }, children: _jsxs(TableBody, { ref: domRef, style: {
201
- height: "100%",
202
- position: "relative",
203
- display: "flex",
204
- flexDirection: "column",
205
- overflow: "scroll",
206
- scrollbarWidth: "none",
207
- }, className: classes.TableClasses.body.scroll.root, onScroll: handleScroll, children: [_jsx(VirtualHorizontalHeader, { offsetLeft: offsetLeft, startColumnIndex: startColumnIndex, cumulativeWidths: cumulativeWidths, windowSize: windowSize, columnEndIndex: columnEndIndex }), _jsx("div", { style: {
208
- flexBasis: `${totalHeight}px`,
209
- flexShrink: 0,
210
- }, children: _jsx("div", { style: {
211
- willChange: "transform, opacity",
212
- transform: `translate3d(${offsetLeft}px, ${offsetTop}px, 0px)`,
213
- position: "absolute",
214
- }, children: children(React.useMemo(() => ({
215
- visibleItems,
216
- startColumnIndex,
217
- cumulativeWidths,
218
- windowSize,
219
- columnEndIndex,
220
- }), [visibleItems, startColumnIndex, cumulativeWidths, windowSize, columnEndIndex])) }) })] }) }), _jsx(RightScrollBar, { ref: rightScrollRef, style: { height: initialBodyHeight - 20, right: "0px" }, onScroll: handleScrollController, children: _jsx("div", { style: { width: "14px", height: `${totalHeight}px` } }) }), _jsx(BottomScrollBar, { ref: bottomScrollRef, style: { width: windowSize.width }, onScroll: handleScrollBottomController, children: _jsx("div", { style: { height: "14px", width: `${totalWidth}px` } }) })] }));
219
+ }, children: [_jsx(NoDataComponent, {}), _jsxs(TableBody, { ref: domRef, style: {
220
+ height: "100%",
221
+ position: "relative",
222
+ display: "flex",
223
+ flexDirection: "column",
224
+ overflow: "scroll",
225
+ scrollbarWidth: "none",
226
+ }, className: classes.TableClasses.body.scroll.root, onScroll: handleScroll, children: [_jsx(VirtualHorizontalHeader, { offsetLeft: offsetLeft, startColumnIndex: startColumnIndex, cumulativeWidths: cumulativeWidths, windowSize: windowSize, columnEndIndex: columnEndIndex }), _jsx("div", { style: {
227
+ flexBasis: `${totalHeight}px`,
228
+ flexShrink: 0,
229
+ }, children: _jsx("div", { style: {
230
+ willChange: "transform, opacity",
231
+ transform: `translate3d(${offsetLeft}px, ${offsetTop}px, 0px)`,
232
+ position: "absolute",
233
+ }, children: children(React.useMemo(() => ({
234
+ visibleItems,
235
+ startColumnIndex,
236
+ cumulativeWidths,
237
+ windowSize,
238
+ columnEndIndex,
239
+ }), [visibleItems, startColumnIndex, cumulativeWidths, windowSize, columnEndIndex])) }) })] })] }), _jsx(RightScrollBar, { ref: rightScrollRef, style: { height: windowSize.height - 40, right: "0px" }, onScroll: handleScrollController, children: _jsx("div", { style: { width: "14px", height: `${totalHeight}px` } }) }), _jsx(BottomScrollBar, { ref: bottomScrollRef, style: { width: windowSize.width }, onScroll: handleScrollBottomController, children: _jsx("div", { style: { height: "14px", width: `${totalWidth}px` } }) })] }));
221
240
  });
222
241
  const VirtualListItem = React.memo(({ item, startColumnIndex, cumulativeWidths, windowSize, columnEndIndex, isColIndex, editStatus }) => {
223
242
  const { columns, dataSource } = useSelector((store) => ({
@@ -240,7 +259,7 @@ const VirtualListItem = React.memo(({ item, startColumnIndex, cumulativeWidths,
240
259
  const VirtualItem = React.memo(({ column, row, isFocus, editStatus, rowIndex, }) => {
241
260
  const cellStyle = useMemo(() => ({ width: `${column.width}px` }), [column.width]);
242
261
  const cellClassName = useMemo(() => cx(classes.TableClasses.body.row.cell.root, classes.TableClasses.body.row.cell.classes), [classes.TableClasses.body.row.cell.root, classes.TableClasses.body.row.cell.classes]);
243
- return (_jsx(TableCell, { "aria-colindex": column.__ariaColindex, tabIndex: isFocus ? 0 : -1, style: cellStyle, className: cellClassName, children: _jsx(CellMode, { column: column, value: row[column.fieldId], editStatus: editStatus, rowIndex: rowIndex }) }, column.__uuid));
262
+ return (_jsx(TableCell, { "aria-colindex": column.__ariaColindex, tabIndex: isFocus ? 0 : -1, style: cellStyle, className: cellClassName, children: _jsx(CellMode, { column: column, value: row ? row[column.fieldId] : "", editStatus: editStatus, rowIndex: rowIndex }) }, column.__uuid));
244
263
  });
245
264
  export const TwoDimensionalVirtualizedList = React.memo(() => {
246
265
  // 마우스 다운 시작지점점
@@ -497,9 +516,13 @@ export const TwoDimensionalVirtualizedList = React.memo(() => {
497
516
  }, []);
498
517
  const handleKeydown = useCallback((e) => {
499
518
  handleArrowKey(e);
519
+ if (gridRef.current.store.state.readOnly)
520
+ return;
500
521
  handleEditEvent(e);
501
522
  }, []);
502
523
  const handleDbClick = useCallback(() => {
524
+ if (gridRef.current.store.state.readOnly)
525
+ return;
503
526
  gridRef.current.setEditStatus(EditStatus.EDITING).then((editState) => {
504
527
  store.setState(["state", "editStatus"], editState);
505
528
  });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("react").MemoExoticComponent<() => import("react/jsx-runtime").JSX.Element>;
2
+ export default _default;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { memo } from "react";
3
+ import { useSelector } from "../../provider/GridStoreContent";
4
+ import { ErrorIconBox, NoDataContent, NoDataTitle } from "./_styled";
5
+ const NoDataComponent = () => {
6
+ const { dataSource } = useSelector((store) => ({
7
+ dataSource: store.state.dataSource,
8
+ }));
9
+ if (!dataSource || (dataSource && dataSource.length === 0)) {
10
+ return (_jsxs(NoDataContent, { children: [_jsx(ErrorIconBox, { children: _jsx(ErrorSvg, {}) }), _jsx(NoDataTitle, { children: "\uB370\uC774\uD130 \uC5C6\uC74C." })] }));
11
+ }
12
+ return _jsx(_Fragment, {});
13
+ };
14
+ function ErrorSvg() {
15
+ return (_jsx("svg", { width: "24", height: "24", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: _jsx("g", { id: "bxs:error", children: _jsx("path", { id: "Vector", d: "M12.884 2.532C12.538 1.878 11.462 1.878 11.116 2.532L2.11596 19.532C2.03494 19.6844 1.99478 19.8551 1.99938 20.0276C2.00398 20.2001 2.05319 20.3685 2.14221 20.5164C2.23124 20.6642 2.35704 20.7864 2.50736 20.8712C2.65768 20.956 2.82739 21.0003 2.99996 21H21C21.1724 21.0004 21.342 20.956 21.4922 20.8713C21.6424 20.7866 21.7681 20.6644 21.8571 20.5167C21.946 20.3689 21.9951 20.2006 21.9997 20.0282C22.0042 19.8559 21.964 19.6852 21.883 19.533L12.884 2.532ZM13 18H11V16H13V18ZM11 14V9H13L13.001 14H11Z", fill: "white" }) }) }));
16
+ }
17
+ export default memo(NoDataComponent);
@@ -0,0 +1,12 @@
1
+ export declare const NoDataContent: import("@emotion/styled").StyledComponent<{
2
+ theme?: import("@emotion/react").Theme;
3
+ as?: React.ElementType;
4
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
5
+ export declare const NoDataTitle: import("@emotion/styled").StyledComponent<{
6
+ theme?: import("@emotion/react").Theme;
7
+ as?: React.ElementType;
8
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, {}>;
9
+ export declare const ErrorIconBox: import("@emotion/styled").StyledComponent<{
10
+ theme?: import("@emotion/react").Theme;
11
+ as?: React.ElementType;
12
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,26 @@
1
+ import styled from "@emotion/styled";
2
+ export const NoDataContent = styled("div")(() => ({
3
+ display: "flex",
4
+ position: "absolute",
5
+ top: "50%",
6
+ left: "50%",
7
+ transform: "translate(-50%, -50%)",
8
+ flexDirection: "column",
9
+ justifyContent: "center",
10
+ alignItems: "center",
11
+ gap: "8px",
12
+ }));
13
+ export const NoDataTitle = styled("h2")(() => ({
14
+ fontSize: "14px",
15
+ fontWeight: "500",
16
+ color: "#5e5e5e", // 색상정의 필요 디자인 토큰 없는 관계로 하드 코딩
17
+ }));
18
+ export const ErrorIconBox = styled("div")(() => ({
19
+ display: "flex",
20
+ width: "48px",
21
+ height: "48px",
22
+ background: "rgb(221, 221, 221)",
23
+ borderRadius: "50px",
24
+ justifyContent: "center",
25
+ alignItems: "center",
26
+ }));
@@ -19,13 +19,13 @@ const CellMode = ({ column, value, editStatus, rowIndex, }) => {
19
19
  }, [editStatus]);
20
20
  const store = useStore();
21
21
  const handleInputChange = React.useCallback((e) => {
22
- console.log("handleInputChange", rowIndex, e, e.target.value);
23
22
  setInputValue(e.target.value);
24
- const dataSource = gridRef.current.cellByRowIndex(rowIndex, column.fieldId, e.target.value);
25
- store.setState(["state", "dataSource"], dataSource, false);
23
+ gridRef.current.cellByRowIndex(rowIndex, column.fieldId, e.target.value).then((dataSource) => {
24
+ store.setState(["state", "dataSource"], dataSource, false);
25
+ });
26
26
  }, [rowIndex]);
27
27
  if (editStatus === EditStatus.EDITING)
28
- return _jsx(Input, { autoFocus: true, ref: inputRef, value: inputValue, onChange: handleInputChange }, 1);
28
+ return _jsx(Input, { autoFocus: true, ref: inputRef, value: inputValue, onChange: handleInputChange });
29
29
  if (editStatus === EditStatus.NON_EDITABLE)
30
30
  return _jsx(React.Fragment, { children: value });
31
31
  return _jsx(React.Fragment, { children: value });
@@ -14,48 +14,13 @@ const IMEComponent = React.forwardRef((props, ref) => {
14
14
  const { cellFocus } = useSelector((store) => ({
15
15
  cellFocus: store.state.cellFocus,
16
16
  }));
17
- // React.useEffect(() => {
18
- // const currentRef = ref as React.MutableRefObject<HTMLTextAreaElement | null>;
19
- // if (currentRef.current) {
20
- // currentRef.current.addEventListener("keydown", handleTextAreaInput);
21
- // }
22
- // return () => {
23
- // if (currentRef.current) {
24
- // currentRef.current.removeEventListener("keydown", handleTextAreaInput);
25
- // }
26
- // };
27
- // }, []);
28
17
  const handleValueChange = useCallback((e) => {
29
18
  setImeValue(e.target.value);
30
19
  }, []);
31
- const handleTextAreaInput = React.useCallback((e) => {
32
- var _a, _b;
33
- const cellFocus = gridRef.current.store.state.cellFocus;
34
- const rowIndex = cellFocus[0];
35
- const colIndex = cellFocus[1];
36
- const event = e.target;
37
- const currentRef = ref;
38
- // 셀위치 가져오기
39
- const containerElement = gridRef.current.store.gridContainer.current;
40
- if (containerElement) {
41
- const rowElement = containerElement.querySelector(`.${classes.TableClasses.body.row.root}[aria-rowindex="${rowIndex}"]`);
42
- if (rowElement) {
43
- const cellElement = rowElement.querySelector(`.${classes.TableClasses.body.row.cell.root}[aria-colindex="${colIndex}"]`);
44
- if (cellElement) {
45
- const top = (_a = cellElement.getBoundingClientRect().top) !== null && _a !== void 0 ? _a : 0;
46
- const left = (_b = cellElement.getBoundingClientRect().left) !== null && _b !== void 0 ? _b : 0;
47
- if (!currentRef.current)
48
- return;
49
- currentRef.current.style.top = `${top}px`;
50
- currentRef.current.style.left = `${left}px`;
51
- }
52
- }
53
- }
54
- if (currentRef.current)
55
- currentRef.current.value = event.value;
56
- }, [cellFocus]);
57
20
  const handleKeyDown = React.useCallback((e) => {
58
21
  var _a, _b, _c;
22
+ if (gridRef.current.store.state.readOnly)
23
+ return;
59
24
  if (e.nativeEvent.isComposing)
60
25
  return;
61
26
  if (e.key === "Enter") {
@@ -95,22 +60,6 @@ const IMEComponent = React.forwardRef((props, ref) => {
95
60
  return;
96
61
  if (!colIndex)
97
62
  return;
98
- // if (e.key === "ArrowLeft") {
99
- // colIndex = colIndex - 1;
100
- // setImeValue("");
101
- // }
102
- // if (e.key === "ArrowRight") {
103
- // colIndex = colIndex + 1;
104
- // setImeValue("");
105
- // }
106
- // if (e.key === "ArrowDown") {
107
- // rowIndex = rowIndex + 1;
108
- // setImeValue("");
109
- // }
110
- // if (e.key === "ArrowUp") {
111
- // rowIndex = rowIndex - 1;
112
- // setImeValue("");
113
- // }
114
63
  const event = e.target;
115
64
  const currentRef = ref;
116
65
  // 셀위치 가져오기
@@ -36,7 +36,7 @@ export default function useInternalPrivateApi(apiRef) {
36
36
  return apiRef.current;
37
37
  }, []);
38
38
  const setBasicStore = React.useCallback((props) => {
39
- const myFilterTypeKeys = ["columns", "dataSource", "cellFocus"];
39
+ const myFilterTypeKeys = ["columns", "dataSource", "cellFocus", "editStatus", "readOnly"];
40
40
  return myFilterTypeKeys.reduce((acc, key) => {
41
41
  if (key in props) {
42
42
  if (key === "dataSource") {
@@ -71,6 +71,7 @@ export default function useInternalPrivateApi(apiRef) {
71
71
  gridRef: undefined,
72
72
  renderedRowStartEnd: undefined,
73
73
  editStatus: undefined,
74
+ readOnly: false,
74
75
  };
75
76
  return defaultValues[key];
76
77
  }
@@ -42,6 +42,10 @@ export interface DataGridOptionPropsModel {
42
42
  * 현재 포커스된 셀의 수정 상태를 담고 있습니다.
43
43
  */
44
44
  editStatus: EditStatus;
45
+ /**
46
+ * 수정할 수 없는 상태
47
+ */
48
+ readOnly: boolean;
45
49
  }
46
50
  /**
47
51
  * 데이터 그리드 내부에서 사용되는 속성을 관리합니다