@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.
- package/README.md +80 -0
- package/lib/cjs/App.d.ts +10 -0
- package/lib/cjs/App.js +142 -0
- package/lib/cjs/DataGrid.d.ts +3 -0
- package/lib/cjs/DataGrid.js +37 -0
- package/lib/cjs/buildPackage.json +59 -0
- package/lib/cjs/common/constants/defaultProps.d.ts +4 -0
- package/lib/cjs/common/constants/defaultProps.js +4 -0
- package/lib/cjs/common/constants/index.d.ts +1 -0
- package/lib/cjs/common/constants/index.js +1 -0
- package/lib/cjs/common/constants/path.d.ts +31 -0
- package/lib/cjs/common/constants/path.js +45 -0
- package/lib/cjs/common/constants/utils.d.ts +0 -0
- package/lib/cjs/common/constants/utils.js +1 -0
- package/lib/cjs/common/foundation/index.d.ts +4 -0
- package/lib/cjs/common/foundation/index.js +4 -0
- package/lib/cjs/common/foundation/scale/color/color.d.ts +44 -0
- package/lib/cjs/common/foundation/scale/color/color.js +46 -0
- package/lib/cjs/common/foundation/scale/color/index.d.ts +1 -0
- package/lib/cjs/common/foundation/scale/color/index.js +1 -0
- package/lib/cjs/common/foundation/scale/index.d.ts +2 -0
- package/lib/cjs/common/foundation/scale/index.js +2 -0
- package/lib/cjs/common/foundation/scale/layout/breakpoints.d.ts +4 -0
- package/lib/cjs/common/foundation/scale/layout/breakpoints.js +6 -0
- package/lib/cjs/common/foundation/scale/layout/index.d.ts +1 -0
- package/lib/cjs/common/foundation/scale/layout/index.js +1 -0
- package/lib/cjs/common/foundation/scale/layout/size.d.ts +6 -0
- package/lib/cjs/common/foundation/scale/layout/size.js +7 -0
- package/lib/cjs/common/styled/assets/components/index.d.ts +1 -0
- package/lib/cjs/common/styled/assets/components/index.js +1 -0
- package/lib/cjs/common/styled/assets/components/loading/Loading.d.ts +2 -0
- package/lib/cjs/common/styled/assets/components/loading/Loading.js +2 -0
- package/lib/cjs/common/styled/assets/index.d.ts +1 -0
- package/lib/cjs/common/styled/assets/index.js +1 -0
- package/lib/cjs/common/styled/index.d.ts +44 -0
- package/lib/cjs/common/styled/index.js +57 -0
- package/lib/cjs/components/GridBasicRows.d.ts +6 -0
- package/lib/cjs/components/GridBasicRows.js +88 -0
- package/lib/cjs/components/NoraDataGrid.d.ts +12 -0
- package/lib/cjs/components/NoraDataGrid.js +50 -0
- package/lib/cjs/components/TwoDimensionalVirtualizedList.d.ts +5 -0
- package/lib/cjs/components/TwoDimensionalVirtualizedList.js +538 -0
- package/lib/cjs/components/cell/CellMode.d.ts +10 -0
- package/lib/cjs/components/cell/CellMode.js +33 -0
- package/lib/cjs/components/header/VirtualHorizontalHeader.d.ts +5 -0
- package/lib/cjs/components/header/VirtualHorizontalHeader.js +13 -0
- package/lib/cjs/components/ime/IMEComponent.d.ts +5 -0
- package/lib/cjs/components/ime/IMEComponent.js +149 -0
- package/lib/cjs/components/virtualized/_components/VirtualHeader.d.ts +4 -0
- package/lib/cjs/components/virtualized/_components/VirtualHeader.js +25 -0
- package/lib/cjs/components/virtualized/_constants/virtualHeaderConstants.d.ts +9 -0
- package/lib/cjs/components/virtualized/_constants/virtualHeaderConstants.js +1 -0
- package/lib/cjs/components/virtualized/_styled/index.d.ts +34 -0
- package/lib/cjs/components/virtualized/_styled/index.js +108 -0
- package/lib/cjs/hooks/external/usePublicTest.d.ts +3 -0
- package/lib/cjs/hooks/external/usePublicTest.js +20 -0
- package/lib/cjs/hooks/internal/useCellRange.d.ts +8 -0
- package/lib/cjs/hooks/internal/useCellRange.js +275 -0
- package/lib/cjs/hooks/internal/useInternalPrivateApi.d.ts +3 -0
- package/lib/cjs/hooks/internal/useInternalPrivateApi.js +127 -0
- package/lib/cjs/hooks/useGridApiContext.d.ts +4 -0
- package/lib/cjs/hooks/useGridApiContext.js +10 -0
- package/lib/cjs/hooks/useGridApiMethod.d.ts +8 -0
- package/lib/cjs/hooks/useGridApiMethod.js +18 -0
- package/lib/cjs/hooks/useGridInitialization.d.ts +3 -0
- package/lib/cjs/hooks/useGridInitialization.js +62 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/main.d.ts +0 -0
- package/lib/cjs/main.js +9 -0
- package/lib/cjs/provider/GridApiContext.d.ts +2 -0
- package/lib/cjs/provider/GridApiContext.js +5 -0
- package/lib/cjs/provider/GridStoreContent.d.ts +10 -0
- package/lib/cjs/provider/GridStoreContent.js +140 -0
- package/lib/cjs/types/classes/index.d.ts +1 -0
- package/lib/cjs/types/classes/index.js +1 -0
- package/lib/cjs/types/classes/styled.d.ts +55 -0
- package/lib/cjs/types/classes/styled.js +56 -0
- package/lib/cjs/types/dataGridCoreEnum.d.ts +6 -0
- package/lib/cjs/types/dataGridCoreEnum.js +7 -0
- package/lib/cjs/types/dataGridCoreProps.d.ts +71 -0
- package/lib/cjs/types/dataGridCoreProps.js +1 -0
- package/lib/cjs/types/dataGridProps.d.ts +148 -0
- package/lib/cjs/types/dataGridProps.js +54 -0
- package/lib/esm/App.d.ts +10 -0
- package/lib/esm/App.js +142 -0
- package/lib/esm/DataGrid.d.ts +3 -0
- package/lib/esm/DataGrid.js +37 -0
- package/lib/esm/buildPackage.json +59 -0
- package/lib/esm/common/constants/defaultProps.d.ts +4 -0
- package/lib/esm/common/constants/defaultProps.js +4 -0
- package/lib/esm/common/constants/index.d.ts +1 -0
- package/lib/esm/common/constants/index.js +1 -0
- package/lib/esm/common/constants/path.d.ts +31 -0
- package/lib/esm/common/constants/path.js +45 -0
- package/lib/esm/common/constants/utils.d.ts +0 -0
- package/lib/esm/common/constants/utils.js +1 -0
- package/lib/esm/common/foundation/index.d.ts +4 -0
- package/lib/esm/common/foundation/index.js +4 -0
- package/lib/esm/common/foundation/scale/color/color.d.ts +44 -0
- package/lib/esm/common/foundation/scale/color/color.js +46 -0
- package/lib/esm/common/foundation/scale/color/index.d.ts +1 -0
- package/lib/esm/common/foundation/scale/color/index.js +1 -0
- package/lib/esm/common/foundation/scale/index.d.ts +2 -0
- package/lib/esm/common/foundation/scale/index.js +2 -0
- package/lib/esm/common/foundation/scale/layout/breakpoints.d.ts +4 -0
- package/lib/esm/common/foundation/scale/layout/breakpoints.js +6 -0
- package/lib/esm/common/foundation/scale/layout/index.d.ts +1 -0
- package/lib/esm/common/foundation/scale/layout/index.js +1 -0
- package/lib/esm/common/foundation/scale/layout/size.d.ts +6 -0
- package/lib/esm/common/foundation/scale/layout/size.js +7 -0
- package/lib/esm/common/styled/assets/components/index.d.ts +1 -0
- package/lib/esm/common/styled/assets/components/index.js +1 -0
- package/lib/esm/common/styled/assets/components/loading/Loading.d.ts +2 -0
- package/lib/esm/common/styled/assets/components/loading/Loading.js +2 -0
- package/lib/esm/common/styled/assets/index.d.ts +1 -0
- package/lib/esm/common/styled/assets/index.js +1 -0
- package/lib/esm/common/styled/index.d.ts +44 -0
- package/lib/esm/common/styled/index.js +57 -0
- package/lib/esm/components/GridBasicRows.d.ts +6 -0
- package/lib/esm/components/GridBasicRows.js +88 -0
- package/lib/esm/components/NoraDataGrid.d.ts +12 -0
- package/lib/esm/components/NoraDataGrid.js +50 -0
- package/lib/esm/components/TwoDimensionalVirtualizedList.d.ts +5 -0
- package/lib/esm/components/TwoDimensionalVirtualizedList.js +538 -0
- package/lib/esm/components/cell/CellMode.d.ts +10 -0
- package/lib/esm/components/cell/CellMode.js +33 -0
- package/lib/esm/components/header/VirtualHorizontalHeader.d.ts +5 -0
- package/lib/esm/components/header/VirtualHorizontalHeader.js +13 -0
- package/lib/esm/components/ime/IMEComponent.d.ts +5 -0
- package/lib/esm/components/ime/IMEComponent.js +149 -0
- package/lib/esm/components/virtualized/_components/VirtualHeader.d.ts +4 -0
- package/lib/esm/components/virtualized/_components/VirtualHeader.js +25 -0
- package/lib/esm/components/virtualized/_constants/virtualHeaderConstants.d.ts +9 -0
- package/lib/esm/components/virtualized/_constants/virtualHeaderConstants.js +1 -0
- package/lib/esm/components/virtualized/_styled/index.d.ts +34 -0
- package/lib/esm/components/virtualized/_styled/index.js +108 -0
- package/lib/esm/hooks/external/usePublicTest.d.ts +3 -0
- package/lib/esm/hooks/external/usePublicTest.js +20 -0
- package/lib/esm/hooks/internal/useCellRange.d.ts +8 -0
- package/lib/esm/hooks/internal/useCellRange.js +275 -0
- package/lib/esm/hooks/internal/useInternalPrivateApi.d.ts +3 -0
- package/lib/esm/hooks/internal/useInternalPrivateApi.js +127 -0
- package/lib/esm/hooks/useGridApiContext.d.ts +4 -0
- package/lib/esm/hooks/useGridApiContext.js +10 -0
- package/lib/esm/hooks/useGridApiMethod.d.ts +8 -0
- package/lib/esm/hooks/useGridApiMethod.js +18 -0
- package/lib/esm/hooks/useGridInitialization.d.ts +3 -0
- package/lib/esm/hooks/useGridInitialization.js +62 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/main.d.ts +0 -0
- package/lib/esm/main.js +9 -0
- package/lib/esm/provider/GridApiContext.d.ts +2 -0
- package/lib/esm/provider/GridApiContext.js +5 -0
- package/lib/esm/provider/GridStoreContent.d.ts +10 -0
- package/lib/esm/provider/GridStoreContent.js +140 -0
- package/lib/esm/types/classes/index.d.ts +1 -0
- package/lib/esm/types/classes/index.js +1 -0
- package/lib/esm/types/classes/styled.d.ts +55 -0
- package/lib/esm/types/classes/styled.js +56 -0
- package/lib/esm/types/dataGridCoreEnum.d.ts +6 -0
- package/lib/esm/types/dataGridCoreEnum.js +7 -0
- package/lib/esm/types/dataGridCoreProps.d.ts +71 -0
- package/lib/esm/types/dataGridCoreProps.js +1 -0
- package/lib/esm/types/dataGridProps.d.ts +148 -0
- package/lib/esm/types/dataGridProps.js +54 -0
- package/package.json +59 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
11
|
+
var t = {};
|
|
12
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
13
|
+
t[p] = s[p];
|
|
14
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
15
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
16
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
17
|
+
t[p[i]] = s[p[i]];
|
|
18
|
+
}
|
|
19
|
+
return t;
|
|
20
|
+
};
|
|
21
|
+
import React from "react";
|
|
22
|
+
import { useGridApiMethod } from "../useGridApiMethod";
|
|
23
|
+
import { defaultProps } from "../../common/constants";
|
|
24
|
+
import { classes } from "../../types/classes";
|
|
25
|
+
export default function useInternalPrivateApi(apiRef) {
|
|
26
|
+
const setText = React.useCallback(() => { }, []);
|
|
27
|
+
const setGridContainer = React.useCallback((ref) => {
|
|
28
|
+
apiRef.current = Object.assign(Object.assign({}, apiRef.current), { store: Object.assign(Object.assign({}, apiRef.current.store), { gridContainer: ref }) });
|
|
29
|
+
}, []);
|
|
30
|
+
const setInitialStore = React.useCallback((props) => {
|
|
31
|
+
const basicStore = setBasicStore(props);
|
|
32
|
+
const columns = basicStore.columns.map((column, index) => (Object.assign(Object.assign({}, column), { __uuid: window.crypto.randomUUID(), __dataColindex: index, __ariaColindex: index + 1 })));
|
|
33
|
+
apiRef.current = Object.assign(Object.assign({}, apiRef.current), { store: Object.assign(Object.assign({}, apiRef.current.store), { original: basicStore, state: Object.assign(Object.assign({}, basicStore), { columns }),
|
|
34
|
+
// 현재 내부에서 사용되는 속성은 수동으로 초기화 해야함.
|
|
35
|
+
__cellRange: [], __cellRangeTemp: {} }) });
|
|
36
|
+
return apiRef.current;
|
|
37
|
+
}, []);
|
|
38
|
+
const setBasicStore = React.useCallback((props) => {
|
|
39
|
+
const myFilterTypeKeys = ["columns", "dataSource", "cellFocus"];
|
|
40
|
+
return myFilterTypeKeys.reduce((acc, key) => {
|
|
41
|
+
if (key in props) {
|
|
42
|
+
if (key === "dataSource") {
|
|
43
|
+
const dataSource = props[key];
|
|
44
|
+
acc[key] = dataSource.map((_a, index) => {
|
|
45
|
+
var { height = defaultProps.height } = _a, data = __rest(_a, ["height"]);
|
|
46
|
+
return (Object.assign(Object.assign({ height }, data), { __dataRowindex: index, __ariaRowindex: index + 1 }));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
else if (key === "columns") {
|
|
50
|
+
const columns = props[key];
|
|
51
|
+
acc[key] = columns.map((_a) => {
|
|
52
|
+
var { width = defaultProps.width } = _a, data = __rest(_a, ["width"]);
|
|
53
|
+
return (Object.assign({ width }, data));
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
acc[key] = props[key];
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
acc[key] = createInstance(key);
|
|
62
|
+
}
|
|
63
|
+
return acc;
|
|
64
|
+
}, {});
|
|
65
|
+
}, []);
|
|
66
|
+
function createInstance(key) {
|
|
67
|
+
const defaultValues = {
|
|
68
|
+
cellFocus: [],
|
|
69
|
+
columns: undefined,
|
|
70
|
+
dataSource: undefined,
|
|
71
|
+
gridRef: undefined,
|
|
72
|
+
renderedRowStartEnd: undefined,
|
|
73
|
+
editStatus: undefined,
|
|
74
|
+
};
|
|
75
|
+
return defaultValues[key];
|
|
76
|
+
}
|
|
77
|
+
const scrollToRowIndex = React.useCallback((rowIndex) => {
|
|
78
|
+
const top = rowIndex * 32 - 32;
|
|
79
|
+
if (apiRef.current.store.gridContainer.current) {
|
|
80
|
+
const body = apiRef.current.store.gridContainer.current.querySelector(`.${classes.TableClasses.body.scroll.root}`);
|
|
81
|
+
if (body) {
|
|
82
|
+
body.scrollTop = top;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, []);
|
|
86
|
+
const addCellRangeTemp = React.useCallback((cellRange) => {
|
|
87
|
+
const updatedCellRangeTemp = Object.assign(apiRef.current.store.__cellRangeTemp, cellRange);
|
|
88
|
+
apiRef.current = Object.assign(Object.assign({}, apiRef.current), { store: Object.assign(Object.assign({}, apiRef.current.store), { __cellRangeTemp: updatedCellRangeTemp }) });
|
|
89
|
+
}, []);
|
|
90
|
+
const setCellFocus = React.useCallback((rowIndex, colIndex) => __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const { store } = apiRef.current;
|
|
92
|
+
const { dataSource, columns } = store.state;
|
|
93
|
+
const newCellFocus = [
|
|
94
|
+
rowIndex ? Math.max(1, Math.min(rowIndex, dataSource.length)) : undefined,
|
|
95
|
+
colIndex ? Math.max(1, Math.min(colIndex, columns.length)) : undefined,
|
|
96
|
+
];
|
|
97
|
+
store.state.cellFocus = newCellFocus;
|
|
98
|
+
return newCellFocus;
|
|
99
|
+
}), []);
|
|
100
|
+
const getCellFocus = React.useCallback(() => {
|
|
101
|
+
const { store } = apiRef.current;
|
|
102
|
+
return store.state.cellFocus;
|
|
103
|
+
}, []);
|
|
104
|
+
const setEditStatus = React.useCallback((editStatus) => __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
const { store } = apiRef.current;
|
|
106
|
+
store.state.editStatus = editStatus;
|
|
107
|
+
return store.state.editStatus;
|
|
108
|
+
}), []);
|
|
109
|
+
const cellByRowIndex = React.useCallback((rowIndex, fieldId, value) => __awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
const { store } = apiRef.current;
|
|
111
|
+
store.state.dataSource[rowIndex] = Object.assign(Object.assign({}, store.state.dataSource[rowIndex]), { [fieldId]: value });
|
|
112
|
+
return store.state.dataSource;
|
|
113
|
+
}), []);
|
|
114
|
+
const apiMethods = {
|
|
115
|
+
setText,
|
|
116
|
+
setGridContainer,
|
|
117
|
+
setInitialStore,
|
|
118
|
+
scrollToRowIndex,
|
|
119
|
+
addCellRangeTemp,
|
|
120
|
+
setCellFocus,
|
|
121
|
+
getCellFocus,
|
|
122
|
+
setEditStatus,
|
|
123
|
+
cellByRowIndex,
|
|
124
|
+
};
|
|
125
|
+
useGridApiMethod(apiRef, apiMethods, "private");
|
|
126
|
+
return {};
|
|
127
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { GridApiContext } from "../provider/GridApiContext";
|
|
3
|
+
function useGridApiContext() {
|
|
4
|
+
const gridRef = React.useContext(GridApiContext);
|
|
5
|
+
if (gridRef === undefined) {
|
|
6
|
+
throw new Error(`🧑💻API 컨텍스트를 찾을 수 없습니다.`);
|
|
7
|
+
}
|
|
8
|
+
return gridRef;
|
|
9
|
+
}
|
|
10
|
+
export default useGridApiContext;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DataGridPrivateApi, DataGridPublicApi, GirdApiCommon, Visibility } from "../types/dataGridProps";
|
|
3
|
+
/**
|
|
4
|
+
* 객체나 함수를 등록하고 나중에 호출하거나 참조할 때 사용합니다.
|
|
5
|
+
* @private
|
|
6
|
+
* @namespace NoraDataGrid.init.useGridApiMethod
|
|
7
|
+
*/
|
|
8
|
+
export declare function useGridApiMethod(apiRef: React.MutableRefObject<GirdApiCommon<DataGridPrivateApi>>, apiMethods: Partial<DataGridPublicApi | DataGridPrivateApi>, visibility: Visibility): void;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* 객체나 함수를 등록하고 나중에 호출하거나 참조할 때 사용합니다.
|
|
4
|
+
* @private
|
|
5
|
+
* @namespace NoraDataGrid.init.useGridApiMethod
|
|
6
|
+
*/
|
|
7
|
+
export function useGridApiMethod(apiRef, apiMethods, visibility) {
|
|
8
|
+
const apiMethodsRef = React.useRef(apiRef.current);
|
|
9
|
+
const initMethods = React.useCallback(() => {
|
|
10
|
+
if (!apiMethodsRef.current) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
apiRef.current.register(visibility, apiMethods);
|
|
14
|
+
}, [visibility]);
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
initMethods();
|
|
17
|
+
}, []);
|
|
18
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import DataGridBasicProps, { GirdApiCommon } from "../types/dataGridProps";
|
|
3
|
+
export declare function useGridInitialization(apiRef: DataGridBasicProps["gridRef"], props: DataGridBasicProps): React.MutableRefObject<GirdApiCommon<import("../types/dataGridProps").DataGridPrivateApiModel>>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import useTest from "./internal/useInternalPrivateApi";
|
|
3
|
+
import usePublicTest from "./external/usePublicTest";
|
|
4
|
+
import { useGridApiMethod } from "./useGridApiMethod";
|
|
5
|
+
export function useGridInitialization(apiRef, props) {
|
|
6
|
+
// const memoizedProps = React.useMemo(() => _.cloneDeep(props), [props]); // props를 메모이제이션
|
|
7
|
+
const privateAipRef = useGridApiInitialization(apiRef, Object.assign({}, props));
|
|
8
|
+
usePublicTest(privateAipRef);
|
|
9
|
+
useTest(privateAipRef);
|
|
10
|
+
//test
|
|
11
|
+
const [, rawForceUpdate] = React.useState();
|
|
12
|
+
// React.useState<GirdApiCommon<DataGridPublicApi>["store"]>();
|
|
13
|
+
const forceUpdate = React.useCallback(() => rawForceUpdate(() => privateAipRef.current.store.state),
|
|
14
|
+
// () => rawForceUpdate(() => privateAipRef.current.store),
|
|
15
|
+
[privateAipRef]);
|
|
16
|
+
useGridApiMethod(privateAipRef, { forceUpdate }, "public");
|
|
17
|
+
return privateAipRef;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 내부 또는 외부에서 사용하는 API를 등록 합니다.
|
|
21
|
+
* @private
|
|
22
|
+
* @namespace NoraDataGrid.init.useGridApiInitialization
|
|
23
|
+
*/
|
|
24
|
+
function useGridApiInitialization(apiRef, _props) {
|
|
25
|
+
const publicApiRef = React.useRef(null);
|
|
26
|
+
const privateApiRef = React.useRef(null);
|
|
27
|
+
if (!publicApiRef.current) {
|
|
28
|
+
publicApiRef.current = {};
|
|
29
|
+
}
|
|
30
|
+
if (!privateApiRef.current) {
|
|
31
|
+
privateApiRef.current = wrapApi(publicApiRef.current);
|
|
32
|
+
}
|
|
33
|
+
React.useImperativeHandle(apiRef, () => publicApiRef.current, []);
|
|
34
|
+
return privateApiRef;
|
|
35
|
+
}
|
|
36
|
+
function wrapApi(apiRef) {
|
|
37
|
+
const privateOnlyApi = {};
|
|
38
|
+
privateOnlyApi.getPublicApi = () => apiRef;
|
|
39
|
+
privateOnlyApi.register = (visibility, methods) => {
|
|
40
|
+
Object.keys(methods).forEach((methodName) => {
|
|
41
|
+
if (visibility === "public") {
|
|
42
|
+
apiRef[methodName] = methods[methodName];
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
privateOnlyApi[methodName] = methods[methodName];
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
const handler = {
|
|
50
|
+
get: (obj, prop) => {
|
|
51
|
+
if (prop in obj) {
|
|
52
|
+
return obj[prop];
|
|
53
|
+
}
|
|
54
|
+
return privateOnlyApi[prop];
|
|
55
|
+
},
|
|
56
|
+
set: (obj, prop, value) => {
|
|
57
|
+
obj[prop] = value;
|
|
58
|
+
return true;
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
return new Proxy(privateOnlyApi, handler);
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataGrid } from "./DataGrid";
|
package/lib/esm/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DataGrid } from "./DataGrid";
|
|
File without changes
|
package/lib/esm/main.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { DataGridPrivateApi, DataGridStoreDef, GirdApiCommon, Store } from "../types/dataGridProps";
|
|
3
|
+
export declare const GridStoreContentProvider: React.FC<GridStoreContentProviderProps>;
|
|
4
|
+
export declare const useStore: () => Store<DataGridStoreDef>;
|
|
5
|
+
export declare const useSelector: <T, Selected>(selector: (state: T) => Selected) => Selected;
|
|
6
|
+
interface GridStoreContentProviderProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
value: React.MutableRefObject<GirdApiCommon<DataGridPrivateApi>>;
|
|
9
|
+
}
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { createContext, useContext, useEffect } from "react";
|
|
3
|
+
import { Store, } from "../types/dataGridProps";
|
|
4
|
+
const StoreContext = createContext(null);
|
|
5
|
+
export const GridStoreContentProvider = ({ children, value }) => {
|
|
6
|
+
// const gridRef = useGridApiContext();
|
|
7
|
+
// const [columns, setColumns] = React.useState(
|
|
8
|
+
// gridRef.current.store?.state?.columns ?? []
|
|
9
|
+
// );
|
|
10
|
+
// const [dataSource, setDataSource] = React.useState(
|
|
11
|
+
// gridRef.current.store?.state?.dataSource ?? []
|
|
12
|
+
// );
|
|
13
|
+
if (!value.current.store)
|
|
14
|
+
return _jsx(_Fragment, {});
|
|
15
|
+
const storeRef = React.useRef(null);
|
|
16
|
+
if (!storeRef.current) {
|
|
17
|
+
storeRef.current = new Store(value.current.store);
|
|
18
|
+
return _jsx(_Fragment, {});
|
|
19
|
+
}
|
|
20
|
+
// useEffect(() => {
|
|
21
|
+
// storeRef.current?.setState(["state"], value.current.store);
|
|
22
|
+
// }, []);
|
|
23
|
+
// useEffect(() => {
|
|
24
|
+
// const handleColumnsChange = () => {
|
|
25
|
+
// setColumns([...gridRef.current.store.state.columns]);
|
|
26
|
+
// };
|
|
27
|
+
// const handleDataSourceChange = () => {
|
|
28
|
+
// setDataSource([...gridRef.current.store.state.dataSource]);
|
|
29
|
+
// };
|
|
30
|
+
// if (!storeRef.current) return;
|
|
31
|
+
// storeRef.current.setState(
|
|
32
|
+
// ["state", "columns"],
|
|
33
|
+
// gridRef.current.store?.state?.columns ?? []
|
|
34
|
+
// );
|
|
35
|
+
// const unsubscribeColumns = storeRef.current.subscribe(handleColumnsChange);
|
|
36
|
+
// const unsubscribeDataSource = storeRef.current.subscribe(
|
|
37
|
+
// handleDataSourceChange
|
|
38
|
+
// );
|
|
39
|
+
// return () => {
|
|
40
|
+
// unsubscribeColumns();
|
|
41
|
+
// unsubscribeDataSource();
|
|
42
|
+
// };
|
|
43
|
+
// }, [gridRef]);
|
|
44
|
+
return (_jsx(StoreContext.Provider, { value: new Store(value.current.store), children: children }));
|
|
45
|
+
};
|
|
46
|
+
export const useStore = () => {
|
|
47
|
+
const store = useContext(StoreContext);
|
|
48
|
+
if (!store) {
|
|
49
|
+
// throw new Error("useStore must be used within a StoreProvider");
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
return store;
|
|
53
|
+
};
|
|
54
|
+
function areArraysEqual(arr1, arr2) {
|
|
55
|
+
if (arr1.length !== arr2.length) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
// 각 요소를 순서대로 비교
|
|
59
|
+
for (let i = 0; i < arr1.length; i++) {
|
|
60
|
+
if (arr1[i] !== arr2[i]) {
|
|
61
|
+
return false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
function isArrayInSet(set, arr) {
|
|
67
|
+
for (const item of set) {
|
|
68
|
+
if (areArraysEqual(item, arr)) {
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
export const useSelector = (selector) => {
|
|
75
|
+
const store = useContext(StoreContext);
|
|
76
|
+
if (!store) {
|
|
77
|
+
throw new Error("useSelector must be used within a StoreProvider");
|
|
78
|
+
}
|
|
79
|
+
const [selectedState, setSelectedState] = React.useState(() => selector(store.getState()));
|
|
80
|
+
const accessedPaths = React.useRef(new Set());
|
|
81
|
+
const previousValue = React.useRef(selectedState);
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
const createPathProxy = (target, currentPath = []) => {
|
|
84
|
+
return new Proxy(target, {
|
|
85
|
+
get(obj, prop) {
|
|
86
|
+
if (typeof prop === "symbol" ||
|
|
87
|
+
prop === "toJSON" ||
|
|
88
|
+
prop === "toString") {
|
|
89
|
+
return obj[prop];
|
|
90
|
+
}
|
|
91
|
+
const newPath = [...currentPath, prop];
|
|
92
|
+
const value = obj[prop];
|
|
93
|
+
// 정확한 경로 저장
|
|
94
|
+
if (currentPath.length > 0 || prop === "state") {
|
|
95
|
+
if (!isArrayInSet(accessedPaths.current, newPath)) {
|
|
96
|
+
accessedPaths.current.add(newPath);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
100
|
+
return createPathProxy(value, newPath);
|
|
101
|
+
}
|
|
102
|
+
return value;
|
|
103
|
+
},
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
accessedPaths.current.clear();
|
|
107
|
+
const proxiedState = createPathProxy(store.getState());
|
|
108
|
+
selector(proxiedState);
|
|
109
|
+
const subscriptions = Array.from(accessedPaths.current).map((path) => {
|
|
110
|
+
return store.subscribe(path, () => {
|
|
111
|
+
const newState = selector(store.getState());
|
|
112
|
+
// 값이 실제로 변경되었을 때만 상태 업데이트
|
|
113
|
+
if (!isEqual(previousValue.current, newState)) {
|
|
114
|
+
previousValue.current = newState;
|
|
115
|
+
setSelectedState(newState);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
return () => {
|
|
120
|
+
subscriptions.forEach((unsubscribe) => unsubscribe());
|
|
121
|
+
};
|
|
122
|
+
}, [store, selector]);
|
|
123
|
+
return selectedState;
|
|
124
|
+
};
|
|
125
|
+
// 간단한 깊은 비교 함수
|
|
126
|
+
const isEqual = (a, b) => {
|
|
127
|
+
if (a === b)
|
|
128
|
+
return true;
|
|
129
|
+
if (typeof a !== "object" ||
|
|
130
|
+
a === null ||
|
|
131
|
+
typeof b !== "object" ||
|
|
132
|
+
b === null) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
const keysA = Object.keys(a);
|
|
136
|
+
const keysB = Object.keys(b);
|
|
137
|
+
if (keysA.length !== keysB.length)
|
|
138
|
+
return false;
|
|
139
|
+
return keysA.every((key) => isEqual(a[key], b[key]));
|
|
140
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as classes from "./styled";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as classes from "./styled";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* test
|
|
3
|
+
*/
|
|
4
|
+
export declare const TableClasses: {
|
|
5
|
+
common: {
|
|
6
|
+
"--nora-data-grid-primary-main": string;
|
|
7
|
+
};
|
|
8
|
+
container: {
|
|
9
|
+
root: string;
|
|
10
|
+
classes: string[];
|
|
11
|
+
};
|
|
12
|
+
title: {
|
|
13
|
+
root: string;
|
|
14
|
+
classes: string[];
|
|
15
|
+
header: {
|
|
16
|
+
root: string;
|
|
17
|
+
row: {
|
|
18
|
+
root: string;
|
|
19
|
+
cell: {
|
|
20
|
+
root: string;
|
|
21
|
+
classes: string[];
|
|
22
|
+
con: {
|
|
23
|
+
root: string;
|
|
24
|
+
classes: string[];
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
resize: {
|
|
29
|
+
root: string;
|
|
30
|
+
classes: never[];
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
body: {
|
|
35
|
+
root: string;
|
|
36
|
+
classes: string[];
|
|
37
|
+
scroll: {
|
|
38
|
+
root: string;
|
|
39
|
+
};
|
|
40
|
+
row: {
|
|
41
|
+
root: string;
|
|
42
|
+
hover: string;
|
|
43
|
+
focus: string;
|
|
44
|
+
cell: {
|
|
45
|
+
root: string;
|
|
46
|
+
classes: string[];
|
|
47
|
+
con: {
|
|
48
|
+
root: string;
|
|
49
|
+
classes: string[];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
footer: string;
|
|
55
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { foundation } from "../../common/foundation";
|
|
2
|
+
/**
|
|
3
|
+
* test
|
|
4
|
+
*/
|
|
5
|
+
export const TableClasses = {
|
|
6
|
+
common: {
|
|
7
|
+
"--nora-data-grid-primary-main": foundation.$scale.color.black,
|
|
8
|
+
},
|
|
9
|
+
container: {
|
|
10
|
+
root: "nora-data-grid-container-root",
|
|
11
|
+
classes: ["nora-data-grid-container"],
|
|
12
|
+
},
|
|
13
|
+
title: {
|
|
14
|
+
root: "nora-data-grid__title-root",
|
|
15
|
+
classes: ["nora-data-grid__title"],
|
|
16
|
+
header: {
|
|
17
|
+
root: "CuiDataGridHeader-root",
|
|
18
|
+
row: {
|
|
19
|
+
root: "CuiDataGridRow-root",
|
|
20
|
+
cell: {
|
|
21
|
+
root: "nora-data-grid__header_cell-root",
|
|
22
|
+
classes: ["nora-data-grid__header_cell"],
|
|
23
|
+
con: {
|
|
24
|
+
root: "nora-data-grid__con-root",
|
|
25
|
+
classes: ["nora-data-grid__con"],
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
resize: {
|
|
30
|
+
root: "CuiDataGrid-resize-root",
|
|
31
|
+
classes: [],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
body: {
|
|
36
|
+
root: "nora-data-grid__body-root",
|
|
37
|
+
classes: ["nora-data-grid__body"],
|
|
38
|
+
scroll: {
|
|
39
|
+
root: "nora-data-grid__scroll-root",
|
|
40
|
+
},
|
|
41
|
+
row: {
|
|
42
|
+
root: "CuiDataGridRow-root",
|
|
43
|
+
hover: "",
|
|
44
|
+
focus: "",
|
|
45
|
+
cell: {
|
|
46
|
+
root: "nora-data-grid__body_cell-root",
|
|
47
|
+
classes: ["nora-data-grid__body_cell"],
|
|
48
|
+
con: {
|
|
49
|
+
root: "nora-data-grid__con-root",
|
|
50
|
+
classes: ["nora-data-grid__con"],
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
footer: "nora-data-grid__footer",
|
|
56
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var EditStatus;
|
|
2
|
+
(function (EditStatus) {
|
|
3
|
+
EditStatus["EDITING"] = "\uC218\uC815\uC911";
|
|
4
|
+
EditStatus["EDITABLE"] = "\uC218\uC815\uAC00\uB2A5";
|
|
5
|
+
EditStatus["NON_EDITABLE"] = "\uC218\uC815\uBD88\uAC00\uB2A5";
|
|
6
|
+
EditStatus["IME_EDITING"] = "IME\uC785\uB825\uC911";
|
|
7
|
+
})(EditStatus || (EditStatus = {}));
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export type DataGridColumn = DataGridColumnModel;
|
|
2
|
+
export type DataGridColumns = Array<DataGridPrivateColumnModel>;
|
|
3
|
+
export type DataGridDataSource = Array<DataGridPrivateDataSourceModel>;
|
|
4
|
+
/**
|
|
5
|
+
* Grid Column을 구성하는 기본 구조 입니다.
|
|
6
|
+
* @public
|
|
7
|
+
* @namespace NoraDataGrid.DataGridColumnModel
|
|
8
|
+
*/
|
|
9
|
+
interface DataGridColumnModel {
|
|
10
|
+
fieldId: string;
|
|
11
|
+
fieldName: string;
|
|
12
|
+
width?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Grid Column을 구성하는 내부적 구조 입니다.
|
|
16
|
+
* @private
|
|
17
|
+
* @namespace NoraDataGrid.DataGridPrivateColumnModel
|
|
18
|
+
*/
|
|
19
|
+
export interface DataGridPrivateColumnModel extends DataGridColumnModel {
|
|
20
|
+
__uuid: string;
|
|
21
|
+
__ariaColindex: number;
|
|
22
|
+
__dataColindex: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Grid DataSource를 구성하는 기본 구조 입니다.
|
|
26
|
+
* @private
|
|
27
|
+
* @namespace NoraDataGrid.DataGridDataSourceModel
|
|
28
|
+
*/
|
|
29
|
+
export type DataGridDataSourceModel = Record<string, any> & {
|
|
30
|
+
height?: number;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Grid DataSource를 구성하는 내부적 구조 입니다.
|
|
34
|
+
* @private
|
|
35
|
+
* @namespace NoraDataGrid.DataGridPrivateDataSourceModel
|
|
36
|
+
*/
|
|
37
|
+
export interface DataGridPrivateDataSourceModel extends DataGridDataSourceModel {
|
|
38
|
+
__ariaRowindex: number;
|
|
39
|
+
__dataRowindex: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 특정 문자로 시작하는 타입 제거
|
|
43
|
+
* OmitStartsWith Object 경우
|
|
44
|
+
*/
|
|
45
|
+
export type OmitStartsWith<T, S extends string> = {
|
|
46
|
+
[K in keyof T as K extends string ? (K extends `${S}${string}` ? never : K) : K]: T[K];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* 특정 문자로 시작하는 타입 제거
|
|
50
|
+
* OmitStartsWithArray Array<Object> 경우
|
|
51
|
+
*/
|
|
52
|
+
export type OmitStartsWithArray<T, S extends string> = Array<OmitStartsWith<T extends Array<infer U> ? U : never, S>>;
|
|
53
|
+
/**
|
|
54
|
+
* 특정 문자로 시작하는 타입 제거
|
|
55
|
+
* DeepOmitStartsWith 재귀적으로 모든 depth를 처리하는 유틸리티 타입
|
|
56
|
+
*/
|
|
57
|
+
export type DeepOmitStartsWith<T, S extends string> = {
|
|
58
|
+
[K in keyof T as K extends string ? (K extends `${S}${string}` ? never : K) : K]: T[K] extends object ? DeepOmitStartsWith<T[K], S> : T[K];
|
|
59
|
+
};
|
|
60
|
+
/**
|
|
61
|
+
*
|
|
62
|
+
* startRowIndex
|
|
63
|
+
*/
|
|
64
|
+
export type CellRangeDef = {
|
|
65
|
+
startRowIndex: number;
|
|
66
|
+
endRowIndex: number;
|
|
67
|
+
columns: Array<string>;
|
|
68
|
+
};
|
|
69
|
+
export interface CellRangeTempDef extends Partial<CellRangeDef> {
|
|
70
|
+
}
|
|
71
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|