@noraent/nora-datagrid 0.0.1

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 (168) hide show
  1. package/README.md +80 -0
  2. package/lib/cjs/App.d.ts +10 -0
  3. package/lib/cjs/App.js +142 -0
  4. package/lib/cjs/DataGrid.d.ts +3 -0
  5. package/lib/cjs/DataGrid.js +37 -0
  6. package/lib/cjs/buildPackage.json +59 -0
  7. package/lib/cjs/common/constants/defaultProps.d.ts +4 -0
  8. package/lib/cjs/common/constants/defaultProps.js +4 -0
  9. package/lib/cjs/common/constants/index.d.ts +1 -0
  10. package/lib/cjs/common/constants/index.js +1 -0
  11. package/lib/cjs/common/constants/path.d.ts +31 -0
  12. package/lib/cjs/common/constants/path.js +45 -0
  13. package/lib/cjs/common/constants/utils.d.ts +0 -0
  14. package/lib/cjs/common/constants/utils.js +1 -0
  15. package/lib/cjs/common/foundation/index.d.ts +4 -0
  16. package/lib/cjs/common/foundation/index.js +4 -0
  17. package/lib/cjs/common/foundation/scale/color/color.d.ts +44 -0
  18. package/lib/cjs/common/foundation/scale/color/color.js +46 -0
  19. package/lib/cjs/common/foundation/scale/color/index.d.ts +1 -0
  20. package/lib/cjs/common/foundation/scale/color/index.js +1 -0
  21. package/lib/cjs/common/foundation/scale/index.d.ts +2 -0
  22. package/lib/cjs/common/foundation/scale/index.js +2 -0
  23. package/lib/cjs/common/foundation/scale/layout/breakpoints.d.ts +4 -0
  24. package/lib/cjs/common/foundation/scale/layout/breakpoints.js +6 -0
  25. package/lib/cjs/common/foundation/scale/layout/index.d.ts +1 -0
  26. package/lib/cjs/common/foundation/scale/layout/index.js +1 -0
  27. package/lib/cjs/common/foundation/scale/layout/size.d.ts +6 -0
  28. package/lib/cjs/common/foundation/scale/layout/size.js +7 -0
  29. package/lib/cjs/common/styled/assets/components/index.d.ts +1 -0
  30. package/lib/cjs/common/styled/assets/components/index.js +1 -0
  31. package/lib/cjs/common/styled/assets/components/loading/Loading.d.ts +2 -0
  32. package/lib/cjs/common/styled/assets/components/loading/Loading.js +2 -0
  33. package/lib/cjs/common/styled/assets/index.d.ts +1 -0
  34. package/lib/cjs/common/styled/assets/index.js +1 -0
  35. package/lib/cjs/common/styled/index.d.ts +44 -0
  36. package/lib/cjs/common/styled/index.js +57 -0
  37. package/lib/cjs/components/GridBasicRows.d.ts +6 -0
  38. package/lib/cjs/components/GridBasicRows.js +88 -0
  39. package/lib/cjs/components/NoraDataGrid.d.ts +12 -0
  40. package/lib/cjs/components/NoraDataGrid.js +50 -0
  41. package/lib/cjs/components/TwoDimensionalVirtualizedList.d.ts +5 -0
  42. package/lib/cjs/components/TwoDimensionalVirtualizedList.js +538 -0
  43. package/lib/cjs/components/cell/CellMode.d.ts +10 -0
  44. package/lib/cjs/components/cell/CellMode.js +33 -0
  45. package/lib/cjs/components/header/VirtualHorizontalHeader.d.ts +5 -0
  46. package/lib/cjs/components/header/VirtualHorizontalHeader.js +13 -0
  47. package/lib/cjs/components/ime/IMEComponent.d.ts +5 -0
  48. package/lib/cjs/components/ime/IMEComponent.js +149 -0
  49. package/lib/cjs/components/virtualized/_components/VirtualHeader.d.ts +4 -0
  50. package/lib/cjs/components/virtualized/_components/VirtualHeader.js +25 -0
  51. package/lib/cjs/components/virtualized/_constants/virtualHeaderConstants.d.ts +9 -0
  52. package/lib/cjs/components/virtualized/_constants/virtualHeaderConstants.js +1 -0
  53. package/lib/cjs/components/virtualized/_styled/index.d.ts +34 -0
  54. package/lib/cjs/components/virtualized/_styled/index.js +108 -0
  55. package/lib/cjs/hooks/external/usePublicTest.d.ts +3 -0
  56. package/lib/cjs/hooks/external/usePublicTest.js +20 -0
  57. package/lib/cjs/hooks/internal/useCellRange.d.ts +8 -0
  58. package/lib/cjs/hooks/internal/useCellRange.js +275 -0
  59. package/lib/cjs/hooks/internal/useInternalPrivateApi.d.ts +3 -0
  60. package/lib/cjs/hooks/internal/useInternalPrivateApi.js +127 -0
  61. package/lib/cjs/hooks/useGridApiContext.d.ts +4 -0
  62. package/lib/cjs/hooks/useGridApiContext.js +10 -0
  63. package/lib/cjs/hooks/useGridApiMethod.d.ts +8 -0
  64. package/lib/cjs/hooks/useGridApiMethod.js +18 -0
  65. package/lib/cjs/hooks/useGridInitialization.d.ts +3 -0
  66. package/lib/cjs/hooks/useGridInitialization.js +62 -0
  67. package/lib/cjs/index.d.ts +1 -0
  68. package/lib/cjs/index.js +1 -0
  69. package/lib/cjs/main.d.ts +0 -0
  70. package/lib/cjs/main.js +9 -0
  71. package/lib/cjs/provider/GridApiContext.d.ts +2 -0
  72. package/lib/cjs/provider/GridApiContext.js +5 -0
  73. package/lib/cjs/provider/GridStoreContent.d.ts +10 -0
  74. package/lib/cjs/provider/GridStoreContent.js +140 -0
  75. package/lib/cjs/types/classes/index.d.ts +1 -0
  76. package/lib/cjs/types/classes/index.js +1 -0
  77. package/lib/cjs/types/classes/styled.d.ts +55 -0
  78. package/lib/cjs/types/classes/styled.js +56 -0
  79. package/lib/cjs/types/dataGridCoreEnum.d.ts +6 -0
  80. package/lib/cjs/types/dataGridCoreEnum.js +7 -0
  81. package/lib/cjs/types/dataGridCoreProps.d.ts +71 -0
  82. package/lib/cjs/types/dataGridCoreProps.js +1 -0
  83. package/lib/cjs/types/dataGridProps.d.ts +148 -0
  84. package/lib/cjs/types/dataGridProps.js +54 -0
  85. package/lib/esm/App.d.ts +10 -0
  86. package/lib/esm/App.js +142 -0
  87. package/lib/esm/DataGrid.d.ts +3 -0
  88. package/lib/esm/DataGrid.js +37 -0
  89. package/lib/esm/buildPackage.json +59 -0
  90. package/lib/esm/common/constants/defaultProps.d.ts +4 -0
  91. package/lib/esm/common/constants/defaultProps.js +4 -0
  92. package/lib/esm/common/constants/index.d.ts +1 -0
  93. package/lib/esm/common/constants/index.js +1 -0
  94. package/lib/esm/common/constants/path.d.ts +31 -0
  95. package/lib/esm/common/constants/path.js +45 -0
  96. package/lib/esm/common/constants/utils.d.ts +0 -0
  97. package/lib/esm/common/constants/utils.js +1 -0
  98. package/lib/esm/common/foundation/index.d.ts +4 -0
  99. package/lib/esm/common/foundation/index.js +4 -0
  100. package/lib/esm/common/foundation/scale/color/color.d.ts +44 -0
  101. package/lib/esm/common/foundation/scale/color/color.js +46 -0
  102. package/lib/esm/common/foundation/scale/color/index.d.ts +1 -0
  103. package/lib/esm/common/foundation/scale/color/index.js +1 -0
  104. package/lib/esm/common/foundation/scale/index.d.ts +2 -0
  105. package/lib/esm/common/foundation/scale/index.js +2 -0
  106. package/lib/esm/common/foundation/scale/layout/breakpoints.d.ts +4 -0
  107. package/lib/esm/common/foundation/scale/layout/breakpoints.js +6 -0
  108. package/lib/esm/common/foundation/scale/layout/index.d.ts +1 -0
  109. package/lib/esm/common/foundation/scale/layout/index.js +1 -0
  110. package/lib/esm/common/foundation/scale/layout/size.d.ts +6 -0
  111. package/lib/esm/common/foundation/scale/layout/size.js +7 -0
  112. package/lib/esm/common/styled/assets/components/index.d.ts +1 -0
  113. package/lib/esm/common/styled/assets/components/index.js +1 -0
  114. package/lib/esm/common/styled/assets/components/loading/Loading.d.ts +2 -0
  115. package/lib/esm/common/styled/assets/components/loading/Loading.js +2 -0
  116. package/lib/esm/common/styled/assets/index.d.ts +1 -0
  117. package/lib/esm/common/styled/assets/index.js +1 -0
  118. package/lib/esm/common/styled/index.d.ts +44 -0
  119. package/lib/esm/common/styled/index.js +57 -0
  120. package/lib/esm/components/GridBasicRows.d.ts +6 -0
  121. package/lib/esm/components/GridBasicRows.js +88 -0
  122. package/lib/esm/components/NoraDataGrid.d.ts +12 -0
  123. package/lib/esm/components/NoraDataGrid.js +50 -0
  124. package/lib/esm/components/TwoDimensionalVirtualizedList.d.ts +5 -0
  125. package/lib/esm/components/TwoDimensionalVirtualizedList.js +538 -0
  126. package/lib/esm/components/cell/CellMode.d.ts +10 -0
  127. package/lib/esm/components/cell/CellMode.js +33 -0
  128. package/lib/esm/components/header/VirtualHorizontalHeader.d.ts +5 -0
  129. package/lib/esm/components/header/VirtualHorizontalHeader.js +13 -0
  130. package/lib/esm/components/ime/IMEComponent.d.ts +5 -0
  131. package/lib/esm/components/ime/IMEComponent.js +149 -0
  132. package/lib/esm/components/virtualized/_components/VirtualHeader.d.ts +4 -0
  133. package/lib/esm/components/virtualized/_components/VirtualHeader.js +25 -0
  134. package/lib/esm/components/virtualized/_constants/virtualHeaderConstants.d.ts +9 -0
  135. package/lib/esm/components/virtualized/_constants/virtualHeaderConstants.js +1 -0
  136. package/lib/esm/components/virtualized/_styled/index.d.ts +34 -0
  137. package/lib/esm/components/virtualized/_styled/index.js +108 -0
  138. package/lib/esm/hooks/external/usePublicTest.d.ts +3 -0
  139. package/lib/esm/hooks/external/usePublicTest.js +20 -0
  140. package/lib/esm/hooks/internal/useCellRange.d.ts +8 -0
  141. package/lib/esm/hooks/internal/useCellRange.js +275 -0
  142. package/lib/esm/hooks/internal/useInternalPrivateApi.d.ts +3 -0
  143. package/lib/esm/hooks/internal/useInternalPrivateApi.js +127 -0
  144. package/lib/esm/hooks/useGridApiContext.d.ts +4 -0
  145. package/lib/esm/hooks/useGridApiContext.js +10 -0
  146. package/lib/esm/hooks/useGridApiMethod.d.ts +8 -0
  147. package/lib/esm/hooks/useGridApiMethod.js +18 -0
  148. package/lib/esm/hooks/useGridInitialization.d.ts +3 -0
  149. package/lib/esm/hooks/useGridInitialization.js +62 -0
  150. package/lib/esm/index.d.ts +1 -0
  151. package/lib/esm/index.js +1 -0
  152. package/lib/esm/main.d.ts +0 -0
  153. package/lib/esm/main.js +9 -0
  154. package/lib/esm/provider/GridApiContext.d.ts +2 -0
  155. package/lib/esm/provider/GridApiContext.js +5 -0
  156. package/lib/esm/provider/GridStoreContent.d.ts +10 -0
  157. package/lib/esm/provider/GridStoreContent.js +140 -0
  158. package/lib/esm/types/classes/index.d.ts +1 -0
  159. package/lib/esm/types/classes/index.js +1 -0
  160. package/lib/esm/types/classes/styled.d.ts +55 -0
  161. package/lib/esm/types/classes/styled.js +56 -0
  162. package/lib/esm/types/dataGridCoreEnum.d.ts +6 -0
  163. package/lib/esm/types/dataGridCoreEnum.js +7 -0
  164. package/lib/esm/types/dataGridCoreProps.d.ts +71 -0
  165. package/lib/esm/types/dataGridCoreProps.js +1 -0
  166. package/lib/esm/types/dataGridProps.d.ts +148 -0
  167. package/lib/esm/types/dataGridProps.js +54 -0
  168. package/package.json +59 -0
@@ -0,0 +1,149 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import React, { useCallback } from "react";
3
+ import { useSelector, useStore } from "../../provider/GridStoreContent";
4
+ import useGridApiContext from "../../hooks/useGridApiContext";
5
+ import { EditStatus } from "../../types/dataGridCoreEnum";
6
+ import { classes } from "../../types/classes";
7
+ const IMEComponent = React.forwardRef((props, ref) => {
8
+ const [imeValue, setImeValue] = React.useState(props.defaultValue);
9
+ React.useEffect(() => {
10
+ setImeValue(props.defaultValue);
11
+ }, [props.defaultValue]);
12
+ const gridRef = useGridApiContext();
13
+ const store = useStore();
14
+ const { cellFocus } = useSelector((store) => ({
15
+ cellFocus: store.state.cellFocus,
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
+ const handleValueChange = useCallback((e) => {
29
+ setImeValue(e.target.value);
30
+ }, []);
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
+ const handleKeyDown = React.useCallback((e) => {
58
+ var _a, _b, _c;
59
+ if (e.nativeEvent.isComposing)
60
+ return;
61
+ if (e.key === "Enter") {
62
+ e.preventDefault();
63
+ e.stopPropagation();
64
+ const row = cellFocus[0];
65
+ const cell = cellFocus[1];
66
+ const rowIndex = row ? row - 1 : undefined;
67
+ const colIndex = cell ? cell - 1 : undefined;
68
+ const fieldId = (_a = gridRef.current.store.state.columns.find((column) => column.__dataColindex === colIndex)) === null || _a === void 0 ? void 0 : _a.fieldId;
69
+ if (fieldId && rowIndex) {
70
+ gridRef.current.cellByRowIndex(rowIndex, fieldId, imeValue).then((dataSource) => {
71
+ store.setState(["state", "dataSource"], dataSource, false);
72
+ });
73
+ gridRef.current.setEditStatus(EditStatus.NON_EDITABLE).then((editState) => {
74
+ store.setState(["state", "editStatus"], editState);
75
+ });
76
+ gridRef.current.setCellFocus(undefined, undefined).then((res) => {
77
+ store.setState(["state", "cellFocus"], res);
78
+ gridRef.current.setCellFocus(cellFocus[0], cellFocus[1]).then((res) => {
79
+ store.setState(["state", "cellFocus"], res);
80
+ });
81
+ });
82
+ const currentRef = ref;
83
+ if (!currentRef.current)
84
+ return;
85
+ currentRef.current.style.top = `-${32000}px`;
86
+ currentRef.current.style.left = `-${32000}px`;
87
+ setImeValue("");
88
+ }
89
+ }
90
+ else {
91
+ const cellFocus = gridRef.current.store.state.cellFocus;
92
+ let rowIndex = cellFocus[0];
93
+ let colIndex = cellFocus[1];
94
+ if (!rowIndex)
95
+ return;
96
+ if (!colIndex)
97
+ 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
+ const event = e.target;
115
+ const currentRef = ref;
116
+ // 셀위치 가져오기
117
+ const containerElement = gridRef.current.store.gridContainer.current;
118
+ if (containerElement) {
119
+ const rowElement = containerElement.querySelector(`.${classes.TableClasses.body.row.root}[aria-rowindex="${rowIndex}"]`);
120
+ if (rowElement) {
121
+ const cellElement = rowElement.querySelector(`.${classes.TableClasses.body.row.cell.root}[aria-colindex="${colIndex}"]`);
122
+ if (cellElement) {
123
+ const top = (_b = cellElement.getBoundingClientRect().top) !== null && _b !== void 0 ? _b : 0;
124
+ const left = (_c = cellElement.getBoundingClientRect().left) !== null && _c !== void 0 ? _c : 0;
125
+ if (!currentRef.current)
126
+ return;
127
+ currentRef.current.style.top = `${top}px`;
128
+ currentRef.current.style.left = `${left}px`;
129
+ currentRef.current.style.width = `${cellElement.clientWidth}px`;
130
+ if (e.key === "Escape") {
131
+ currentRef.current.style.top = `-${32000}px`;
132
+ currentRef.current.style.left = `-${32000}px`;
133
+ setImeValue("");
134
+ }
135
+ if (e.key === "ArrowUp" || e.key === "ArrowRight" || e.key === "ArrowDown" || e.key === "ArrowLeft") {
136
+ currentRef.current.style.top = `-${32000}px`;
137
+ currentRef.current.style.left = `-${32000}px`;
138
+ setImeValue("");
139
+ }
140
+ }
141
+ }
142
+ }
143
+ if (currentRef.current)
144
+ currentRef.current.value = event.value;
145
+ }
146
+ }, [cellFocus, imeValue]);
147
+ return (_jsx("textarea", { className: "ime-input", ref: ref, style: { position: "absolute", resize: "none", overflow: "hidden", background: "red" }, value: imeValue, onChange: handleValueChange, onKeyDown: handleKeyDown }));
148
+ });
149
+ export default React.memo(IMEComponent);
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { VirtualHeaderProps } from "../_constants/virtualHeaderConstants";
3
+ declare const VirtualHeader: React.FC<VirtualHeaderProps>;
4
+ export default VirtualHeader;
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import React, { useMemo, useCallback } from "react";
3
+ import { unstable_batchedUpdates } from "react-dom";
4
+ import { cx } from "@emotion/css";
5
+ import useGridApiContext from "../../../hooks/useGridApiContext";
6
+ import { ResizeBox, TableCell } from "../_styled";
7
+ import { classes } from "../../../types/classes";
8
+ const VirtualHeader = React.memo(({ startColumnIndex, cumulativeWidths, windowSize, columnEndIndex }) => {
9
+ const gridRef = useGridApiContext();
10
+ const columns = gridRef.current.store.state.columns;
11
+ const getItemRange = useCallback(() => {
12
+ const start = startColumnIndex;
13
+ let end = columnEndIndex;
14
+ return { start, end };
15
+ }, [startColumnIndex, cumulativeWidths, windowSize, columnEndIndex]);
16
+ const { start, end } = getItemRange();
17
+ const visibleColumns = useMemo(() => {
18
+ return unstable_batchedUpdates(() => columns.slice(start, end + 1));
19
+ }, [start, end, columns]);
20
+ return visibleColumns.map((column) => (_jsxs(TableCell, { "aria-colindex": column.__ariaColindex, "data-width": column.width, tabIndex: -1, style: {
21
+ width: `${column.width}px`,
22
+ overflow: "initial",
23
+ }, className: cx(classes.TableClasses.title.header.row.cell.root, classes.TableClasses.title.header.row.cell.classes), children: [_jsx("div", { className: cx(classes.TableClasses.title.header.row.cell.con.root, classes.TableClasses.title.header.row.cell.con.classes), children: column.fieldName }), _jsx(ResizeBox, { className: cx(classes.TableClasses.title.header.resize.root, classes.TableClasses.title.header.resize.classes) })] }, column.__uuid)));
24
+ });
25
+ export default VirtualHeader;
@@ -0,0 +1,9 @@
1
+ export interface VirtualHeaderProps {
2
+ startColumnIndex: number;
3
+ cumulativeWidths: number[];
4
+ columnEndIndex: number;
5
+ windowSize: {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ }
@@ -0,0 +1,34 @@
1
+ export declare const TableRow: 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 TableBody: import("@emotion/styled").StyledComponent<{
6
+ theme?: import("@emotion/react").Theme;
7
+ as?: React.ElementType;
8
+ } & {
9
+ lineHeight?: number;
10
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
11
+ export declare const TableCell: import("@emotion/styled").StyledComponent<{
12
+ theme?: import("@emotion/react").Theme;
13
+ as?: React.ElementType;
14
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
15
+ export declare const Input: import("@emotion/styled").StyledComponent<{
16
+ theme?: import("@emotion/react").Theme;
17
+ as?: React.ElementType;
18
+ }, import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, {}>;
19
+ export declare const TableHeaderRoot: import("@emotion/styled").StyledComponent<{
20
+ theme?: import("@emotion/react").Theme;
21
+ as?: React.ElementType;
22
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
23
+ export declare const ResizeBox: import("@emotion/styled").StyledComponent<{
24
+ theme?: import("@emotion/react").Theme;
25
+ as?: React.ElementType;
26
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
27
+ export declare const RightScrollBar: import("@emotion/styled").StyledComponent<{
28
+ theme?: import("@emotion/react").Theme;
29
+ as?: React.ElementType;
30
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
31
+ export declare const BottomScrollBar: import("@emotion/styled").StyledComponent<{
32
+ theme?: import("@emotion/react").Theme;
33
+ as?: React.ElementType;
34
+ }, import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, {}>;
@@ -0,0 +1,108 @@
1
+ import styled from "@emotion/styled";
2
+ import { foundation } from "../../../common/foundation";
3
+ import { TableClasses } from "../../../types/classes/styled";
4
+ import { defaultProps } from "../../../common/constants";
5
+ export const TableRow = styled("div")(() => ({
6
+ display: "flex",
7
+ borderBottom: `1px solid ${foundation.$scale.color.gray95}`,
8
+ }));
9
+ export const TableBody = styled("div")(({ lineHeight = defaultProps.height }) => ({
10
+ [`& .${TableClasses.body.row.cell.root}`]: {
11
+ lineHeight: `${lineHeight}px`,
12
+ fontSize: "14px",
13
+ borderRight: `1px solid transparent`,
14
+ },
15
+ }));
16
+ export const TableCell = styled("div")(() => ({
17
+ padding: "0px 10px",
18
+ overflow: "hidden",
19
+ textOverflow: "ellipsis",
20
+ whiteSpace: "nowrap",
21
+ position: "relative",
22
+ pointerEvents: "unset",
23
+ "&[tabindex='0']": {
24
+ outline: `${foundation.$scale.color.primary45} solid 1px`,
25
+ outlineOffset: "-1px",
26
+ },
27
+ }));
28
+ export const Input = styled("input")(() => ({
29
+ width: "100%",
30
+ font: "inherit",
31
+ padding: "0",
32
+ fontSize: "14px",
33
+ outline: "none",
34
+ }));
35
+ export const TableHeaderRoot = styled("div")(() => ({
36
+ [`&.${TableClasses.title.header.root}`]: {
37
+ background: foundation.$scale.color.gray100,
38
+ borderBottom: `1px solid ${foundation.$scale.color.gray90}`,
39
+ backdropFilter: "blur(6px)",
40
+ width: "fit-content",
41
+ position: "sticky",
42
+ top: "0",
43
+ zIndex: "1",
44
+ display: "flex",
45
+ alignItems: "center",
46
+ cursor: "pointer",
47
+ "&:hover": {
48
+ [`& .${TableClasses.title.header.resize.root}`]: {
49
+ "::before": {
50
+ background: foundation.$scale.color.gray85,
51
+ },
52
+ },
53
+ },
54
+ [`& .${TableClasses.title.header.row.cell.root}`]: {
55
+ display: "flex",
56
+ height: "38px",
57
+ alignItems: "center",
58
+ [`& .${TableClasses.title.header.row.cell.con.root}`]: {
59
+ fontSize: "14px",
60
+ color: foundation.$scale.color.gray60,
61
+ },
62
+ },
63
+ },
64
+ }));
65
+ export const ResizeBox = styled("div")(() => ({
66
+ cursor: "col-resize",
67
+ height: "100%",
68
+ position: "absolute",
69
+ top: "0px",
70
+ padding: "10px 8px",
71
+ right: "-8px",
72
+ display: "flex",
73
+ flexDirection: "column",
74
+ "::before": {
75
+ content: "''",
76
+ display: "block",
77
+ width: "1px",
78
+ height: "100%",
79
+ background: "transparent",
80
+ },
81
+ "&:hover": {
82
+ "::before": {
83
+ width: "2px",
84
+ background: foundation.$scale.color.gray30,
85
+ },
86
+ },
87
+ zIndex: 5,
88
+ }));
89
+ export const RightScrollBar = styled("div")(() => ({
90
+ position: "absolute",
91
+ display: "inline-block",
92
+ zIndex: 12,
93
+ width: "14px",
94
+ overflow: "hidden auto",
95
+ outline: "0px",
96
+ top: "40px",
97
+ right: "0px",
98
+ }));
99
+ export const BottomScrollBar = styled("div")(() => ({
100
+ position: "absolute",
101
+ display: "inline-block",
102
+ zIndex: 12,
103
+ height: "14px",
104
+ overflow: "auto hidden",
105
+ outline: "0px",
106
+ bottom: "0px",
107
+ left: "0px",
108
+ }));
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { DataGridPrivateApi, GirdApiCommon } from "../../types/dataGridProps";
3
+ export default function usePublicTest(apiRef: React.MutableRefObject<GirdApiCommon<DataGridPrivateApi>>): void;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ // import {
3
+ // DataGridPrivateApi,
4
+ // DataGridPublicApi,
5
+ // GirdApiCommon,
6
+ // } from "@/core/types/dataGridProps";
7
+ import { useGridApiMethod } from "../useGridApiMethod";
8
+ export default function usePublicTest(apiRef) {
9
+ const setTextPublic = React.useCallback((_data) => {
10
+ alert("dd");
11
+ console.log("!!!! public");
12
+ }, []);
13
+ const addCellRange = React.useCallback((cellRange) => {
14
+ const updatedCellRange = structuredClone(apiRef.current.store.__cellRange);
15
+ updatedCellRange.push(cellRange);
16
+ apiRef.current = Object.assign(Object.assign({}, apiRef.current), { store: Object.assign(Object.assign({}, apiRef.current.store), { __cellRange: updatedCellRange }) });
17
+ }, []);
18
+ const apiMethods = { setTextPublic, addCellRange };
19
+ useGridApiMethod(apiRef, apiMethods, "public");
20
+ }
@@ -0,0 +1,8 @@
1
+ import { CellRangeDef } from "../../types/dataGridCoreProps";
2
+ declare const useCellRange: () => {
3
+ cellRange: CellRangeDef[];
4
+ handleMouseDown: (event: MouseEvent) => void;
5
+ handleMouseUp: (event: MouseEvent) => void;
6
+ handleMouseMove: (event: MouseEvent) => false | undefined;
7
+ };
8
+ export default useCellRange;
@@ -0,0 +1,275 @@
1
+ import React, { useRef } from "react";
2
+ import { classes } from "../../types/classes";
3
+ import useGridApiContext from "../useGridApiContext";
4
+ const useCellRange = () => {
5
+ const gridRef = useGridApiContext();
6
+ const [cellRange, setCellRange] = React.useState([]);
7
+ // useEffect(() => {
8
+ // const localCellRange = gridRef.current.store.__cellRange;
9
+ // const elementsWithClass =
10
+ // gridRef.current.store.gridContainer.current?.querySelectorAll(
11
+ // ".range-1 "
12
+ // );
13
+ // console.log("!!!!", elementsWithClass);
14
+ // elementsWithClass?.forEach((element) => {
15
+ // element.classList.remove("range-1");
16
+ // element.classList.remove("range-2");
17
+ // element.classList.remove("range-3");
18
+ // });
19
+ // localCellRange.forEach((range) => {
20
+ // console.log("????", range);
21
+ // for (
22
+ // let start = range.startRowIndex;
23
+ // start <= range.endRowIndex;
24
+ // start++
25
+ // ) {
26
+ // const element =
27
+ // gridRef.current.store.gridContainer.current?.querySelector(
28
+ // `[aria-rowindex="${start}"]`
29
+ // );
30
+ // const columnsIndex = gridRef.current.store.state.columns.reduce(
31
+ // (acc: number[], column, index) => {
32
+ // if (range.columns.includes(column.fieldId)) {
33
+ // acc.push(index);
34
+ // }
35
+ // return acc;
36
+ // },
37
+ // []
38
+ // );
39
+ // if (element) {
40
+ // const elements = element?.querySelectorAll(
41
+ // columnsIndex
42
+ // .map((columnIndex) => `[aria-colindex="${columnIndex}"]`)
43
+ // .join(", ")
44
+ // );
45
+ // elements?.forEach((element) => {
46
+ // if (!element.classList.contains("range-1")) {
47
+ // (element as HTMLDivElement).classList.add("range-1"); // 원하는 스타일 추가
48
+ // } else if (
49
+ // element.classList.contains("range-1") &&
50
+ // !element.classList.contains("range-2")
51
+ // ) {
52
+ // (element as HTMLDivElement).classList.add("range-2"); // 원하는 스타일 추가
53
+ // } else if (
54
+ // element.classList.contains("range-2") &&
55
+ // !element.classList.contains("range-3")
56
+ // ) {
57
+ // (element as HTMLDivElement).classList.add("range-3"); // 원하는 스타일 추가
58
+ // }
59
+ // });
60
+ // console.log(">>>>??", elements, columnsIndex);
61
+ // }
62
+ // }
63
+ // });
64
+ // }, [cellRange]);
65
+ const isMouseDown = useRef(false);
66
+ const prevlastCellIndex = useRef(-1);
67
+ const prevlastRowIndex = useRef(-1);
68
+ const handleMouseMove = React.useCallback((event) => {
69
+ var _a, _b;
70
+ if (!isMouseDown.current)
71
+ return false;
72
+ const targetElement = event.target;
73
+ if (targetElement) {
74
+ const rowElement = targetElement.closest(`.${classes.TableClasses.body.row.root}`);
75
+ const cellElement = targetElement.closest(`.${classes.TableClasses.body.row.cell.root}`);
76
+ if (rowElement && cellElement) {
77
+ const lastCellIndex = Number(cellElement.getAttribute("aria-colindex"));
78
+ const currentRowIndex = Number(rowElement.getAttribute("aria-rowindex"));
79
+ if (prevlastCellIndex.current === lastCellIndex &&
80
+ prevlastRowIndex.current === currentRowIndex)
81
+ return false;
82
+ prevlastCellIndex.current = lastCellIndex;
83
+ prevlastRowIndex.current = currentRowIndex;
84
+ const firstCellIndex = gridRef.current.store.state.columns.findIndex((column) => {
85
+ var _a;
86
+ return (_a = gridRef.current.store.__cellRangeTemp.columns) === null || _a === void 0 ? void 0 : _a.includes(column.fieldId);
87
+ });
88
+ const fieldObjects = gridRef.current.store.state.columns.slice(Math.min(firstCellIndex, lastCellIndex), Math.max(firstCellIndex, lastCellIndex) + 1);
89
+ gridRef.current.addCellRangeTemp({
90
+ endRowIndex: currentRowIndex,
91
+ columns: fieldObjects.flatMap((field) => field.fieldId),
92
+ });
93
+ const __cellRangeTemp = gridRef.current.store.__cellRangeTemp;
94
+ const startRowIndex = __cellRangeTemp.startRowIndex;
95
+ const endRowIndex = __cellRangeTemp.endRowIndex;
96
+ const rangeColumns = __cellRangeTemp.columns;
97
+ if (!startRowIndex || !endRowIndex || !rangeColumns)
98
+ return false;
99
+ const elementsWithClass = (_a = gridRef.current.store.gridContainer.current) === null || _a === void 0 ? void 0 : _a.querySelectorAll(".range-1 ");
100
+ elementsWithClass === null || elementsWithClass === void 0 ? void 0 : elementsWithClass.forEach((element) => {
101
+ element.classList.remove("range-1");
102
+ element.classList.remove("range-2");
103
+ element.classList.remove("range-3");
104
+ });
105
+ for (let start = startRowIndex; start <= endRowIndex; start++) {
106
+ const element = (_b = gridRef.current.store.gridContainer.current) === null || _b === void 0 ? void 0 : _b.querySelector(`[aria-rowindex="${start}"]`);
107
+ if (element) {
108
+ const columnsIndex = gridRef.current.store.state.columns.reduce((acc, column, index) => {
109
+ if (rangeColumns.includes(column.fieldId)) {
110
+ acc.push(index);
111
+ }
112
+ return acc;
113
+ }, []);
114
+ const elements = element === null || element === void 0 ? void 0 : element.querySelectorAll(columnsIndex
115
+ .map((columnIndex) => `[aria-colindex="${columnIndex}"]`)
116
+ .join(", "));
117
+ elements === null || elements === void 0 ? void 0 : elements.forEach((element) => {
118
+ if (!element.classList.contains("range-1")) {
119
+ element.classList.add("range-1"); // 원하는 스타일 추가
120
+ }
121
+ // else if (
122
+ // element.classList.contains("range-1") &&
123
+ // !element.classList.contains("range-2")
124
+ // ) {
125
+ // (element as HTMLDivElement).classList.add("range-2"); // 원하는 스타일 추가
126
+ // } else if (
127
+ // element.classList.contains("range-2") &&
128
+ // !element.classList.contains("range-3")
129
+ // ) {
130
+ // (element as HTMLDivElement).classList.add("range-3"); // 원하는 스타일 추가
131
+ // }
132
+ });
133
+ }
134
+ }
135
+ }
136
+ }
137
+ // const targetElement = event.target as HTMLElement | null;
138
+ // if (!targetElement) {
139
+ // return false;
140
+ // }
141
+ // const localCellRange = gridRef.current.store.__cellRangeTemp;
142
+ // const elementsWithClass =
143
+ // gridRef.current.store.gridContainer.current?.querySelectorAll(
144
+ // ".range-1 "
145
+ // );
146
+ // console.log("!!!!", elementsWithClass);
147
+ // elementsWithClass?.forEach((element) => {
148
+ // element.classList.remove("range-1");
149
+ // element.classList.remove("range-2");
150
+ // element.classList.remove("range-3");
151
+ // });
152
+ // const range = localCellRange;
153
+ // const startRowIndex = range.startRowIndex ?? 0;
154
+ // const rowElement = targetElement.closest(
155
+ // `.${classes.TableClasses.body.row.root}`
156
+ // );
157
+ // const cellElement = targetElement.closest(
158
+ // `.${classes.TableClasses.body.row.cell.root}`
159
+ // );
160
+ // const endRowIndex =
161
+ // range.endRowIndex ??
162
+ // Number(rowElement?.getAttribute("aria-rowindex")) ??
163
+ // 0;
164
+ // const endCellIndex =
165
+ // Number(cellElement?.getAttribute("aria-colindex")) ?? 0;
166
+ // const rangeColumns = range.columns ?? [];
167
+ // console.log("????", range);
168
+ // const firstCellIndex = gridRef.current.store.state.columns.findIndex(
169
+ // (column) =>
170
+ // gridRef.current.store.__cellRangeTemp.columns?.includes(column.fieldId)
171
+ // );
172
+ // const lastCellIndex = endCellIndex;
173
+ // const fieldObjects = gridRef.current.store.state.columns.slice(
174
+ // Math.min(firstCellIndex, lastCellIndex),
175
+ // Math.max(firstCellIndex, lastCellIndex) + 1
176
+ // );
177
+ // const columnsIndex = fieldObjects.flatMap((v, index) => {
178
+ // return index;
179
+ // }, []);
180
+ // // const columnsIndex = fieldObjects.reduce((acc: number[], column, index) => {
181
+ // // if (rangeColumns.includes(column.fieldId)) {
182
+ // // acc.push(index);
183
+ // // }
184
+ // // return acc;
185
+ // // }, []);
186
+ // console.log("하...", rangeColumns, columnsIndex);
187
+ // for (let start = startRowIndex; start <= endRowIndex; start++) {
188
+ // const element =
189
+ // gridRef.current.store.gridContainer.current?.querySelector(
190
+ // `[aria-rowindex="${start}"]`
191
+ // );
192
+ // // const columnsIndex = gridRef.current.store.state.columns.reduce(
193
+ // // (acc: number[], column, index) => {
194
+ // // if (rangeColumns.includes(column.fieldId)) {
195
+ // // acc.push(index);
196
+ // // }
197
+ // // return acc;
198
+ // // },
199
+ // // []
200
+ // // );
201
+ // if (element) {
202
+ // const elements = element?.querySelectorAll(
203
+ // columnsIndex
204
+ // .map((columnIndex) => `[aria-colindex="${columnIndex}"]`)
205
+ // .join(", ")
206
+ // );
207
+ // elements?.forEach((element) => {
208
+ // if (!element.classList.contains("range-1")) {
209
+ // (element as HTMLDivElement).classList.add("range-1"); // 원하는 스타일 추가
210
+ // } else if (
211
+ // element.classList.contains("range-1") &&
212
+ // !element.classList.contains("range-2")
213
+ // ) {
214
+ // (element as HTMLDivElement).classList.add("range-2"); // 원하는 스타일 추가
215
+ // } else if (
216
+ // element.classList.contains("range-2") &&
217
+ // !element.classList.contains("range-3")
218
+ // ) {
219
+ // (element as HTMLDivElement).classList.add("range-3"); // 원하는 스타일 추가
220
+ // }
221
+ // });
222
+ // console.log(">>>>??", elements, columnsIndex);
223
+ // }
224
+ // }
225
+ }, []);
226
+ const handleMouseDown = React.useCallback((event) => {
227
+ isMouseDown.current = true;
228
+ const targetElement = event.target;
229
+ if (targetElement) {
230
+ const rowElement = targetElement.closest(`.${classes.TableClasses.body.row.root}`);
231
+ const cellElement = targetElement.closest(`.${classes.TableClasses.body.row.cell.root}`);
232
+ if (rowElement && cellElement) {
233
+ const fieldObjects = gridRef.current.store.state.columns.slice(Number(cellElement.getAttribute("aria-colindex")), Math.min(Number(cellElement.getAttribute("aria-colindex")) + 1, gridRef.current.store.state.columns.length));
234
+ gridRef.current.addCellRangeTemp({
235
+ startRowIndex: Number(rowElement.getAttribute("aria-rowindex")),
236
+ columns: fieldObjects.flatMap((field) => field.fieldId),
237
+ });
238
+ }
239
+ }
240
+ }, []);
241
+ const handleMouseUp = React.useCallback((event) => {
242
+ isMouseDown.current = false;
243
+ prevlastCellIndex.current = -1;
244
+ prevlastRowIndex.current = -1;
245
+ const targetElement = event.target;
246
+ if (targetElement) {
247
+ const rowElement = targetElement.closest(`.${classes.TableClasses.body.row.root}`);
248
+ const cellElement = targetElement.closest(`.${classes.TableClasses.body.row.cell.root}`);
249
+ if (rowElement && cellElement) {
250
+ const firstCellIndex = gridRef.current.store.state.columns.findIndex((column) => {
251
+ var _a;
252
+ return (_a = gridRef.current.store.__cellRangeTemp.columns) === null || _a === void 0 ? void 0 : _a.includes(column.fieldId);
253
+ });
254
+ const lastCellIndex = Number(cellElement.getAttribute("aria-colindex"));
255
+ const fieldObjects = gridRef.current.store.state.columns.slice(Math.min(firstCellIndex, lastCellIndex), Math.max(firstCellIndex, lastCellIndex) + 1);
256
+ gridRef.current.addCellRangeTemp({
257
+ endRowIndex: Number(rowElement.getAttribute("aria-rowindex")),
258
+ columns: fieldObjects.flatMap((field) => field.fieldId),
259
+ });
260
+ gridRef.current
261
+ .getPublicApi()
262
+ .addCellRange(gridRef.current.store.__cellRangeTemp);
263
+ gridRef.current.store.__cellRangeTemp = {};
264
+ setCellRange(gridRef.current.store.__cellRange);
265
+ }
266
+ }
267
+ }, []);
268
+ return {
269
+ cellRange,
270
+ handleMouseDown,
271
+ handleMouseUp,
272
+ handleMouseMove,
273
+ };
274
+ };
275
+ export default useCellRange;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ import { DataGridPrivateApi, GirdApiCommon } from "../../types/dataGridProps";
3
+ export default function useInternalPrivateApi(apiRef: React.MutableRefObject<GirdApiCommon<DataGridPrivateApi>>): {};