@noraent/nora-datagrid 1.1.0-beta.30 → 1.1.0-beta.32
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 +85 -0
- package/dist/buildPackage.json +1 -1
- package/dist/common/columns/sizing.d.ts +11 -0
- package/dist/common/columns/sizing.test.d.ts +1 -0
- package/dist/common/constants/useEnhancedEffect/useEnhancedEffect.d.ts +1 -1
- package/dist/common/constants/utils.d.ts +5 -0
- package/dist/common/rows/treeData.d.ts +20 -0
- package/dist/common/rows/treeData.test.d.ts +1 -0
- package/dist/components/ColumnResize.test.d.ts +1 -0
- package/dist/components/TreeData.test.d.ts +1 -0
- package/dist/components/TwoDimensionalVirtualizedList.d.ts +6 -0
- package/dist/components/icon/ChevronDownIcon.d.ts +7 -0
- package/dist/components/icon/ChevronRightIcon.d.ts +7 -0
- package/dist/components/icon/GripIcon.d.ts +7 -0
- package/dist/nora_datagrid.cjs.js +4 -4
- package/dist/nora_datagrid.es.js +1188 -128
- package/dist/types/dataGridCoreProps.d.ts +37 -1
- package/dist/types/dataGridProps.d.ts +38 -2
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -94,6 +94,63 @@ const gridTheme = createTheme({
|
|
|
94
94
|
|
|
95
95
|
`Row.selected.background`을 생략하면 `palette.primary.main`에 10% 투명도를 적용합니다. `primary.main`에는 HEX뿐 아니라 `var(--grid-primary)` 같은 CSS 색상 표현식도 사용할 수 있습니다.
|
|
96
96
|
|
|
97
|
+
### 컬럼 크기 설정
|
|
98
|
+
|
|
99
|
+
고정 너비와 반응형 flex 컬럼을 함께 사용할 수 있습니다. `width`, `minWidth`, `maxWidth`의 단위는 px입니다.
|
|
100
|
+
|
|
101
|
+
```tsx
|
|
102
|
+
const columns = [
|
|
103
|
+
{ fieldId: "id", fieldName: "ID", width: 100 },
|
|
104
|
+
{ fieldId: "name", fieldName: "이름", flex: 1, minWidth: 120 },
|
|
105
|
+
{ fieldId: "description", fieldName: "설명", flex: 2, minWidth: 160, maxWidth: 500 },
|
|
106
|
+
];
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Grid 최초 렌더링 시 전체 폭 또는 콘텐츠에 맞추려면 `autoSizeStrategy`를 사용합니다.
|
|
110
|
+
|
|
111
|
+
```tsx
|
|
112
|
+
<DataGrid
|
|
113
|
+
columns={columns}
|
|
114
|
+
dataSource={rows}
|
|
115
|
+
autoSizeStrategy={{ type: "fitGridWidth", defaultMinWidth: 80 }}
|
|
116
|
+
/>
|
|
117
|
+
|
|
118
|
+
<DataGrid
|
|
119
|
+
columns={columns}
|
|
120
|
+
dataSource={rows}
|
|
121
|
+
autoSizeStrategy={{
|
|
122
|
+
type: "fitCellContents",
|
|
123
|
+
includeHeader: true,
|
|
124
|
+
scaleUpToFitGridWidth: true,
|
|
125
|
+
}}
|
|
126
|
+
/>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
원하는 시점에 API로 다시 계산할 수도 있습니다.
|
|
130
|
+
|
|
131
|
+
```ts
|
|
132
|
+
const gridRef = useGridApiRef();
|
|
133
|
+
|
|
134
|
+
gridRef.current.sizeColumnsToFit({ defaultMinWidth: 80 });
|
|
135
|
+
gridRef.current.autoSizeColumns(["name", "description"], {
|
|
136
|
+
includeHeader: true,
|
|
137
|
+
scaleUpToFitGridWidth: true,
|
|
138
|
+
});
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
`renderCell`이 문자열이 아닌 커스텀 UI를 반환한다면 측정에 사용할 값을 `getAutoSizeValue`로 지정할 수 있습니다.
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
{
|
|
145
|
+
fieldId: "status",
|
|
146
|
+
fieldName: "상태",
|
|
147
|
+
renderCell: ({ value }) => <StatusChip value={value} />,
|
|
148
|
+
getAutoSizeValue: ({ value }) => String(value),
|
|
149
|
+
}
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
사용자가 flex 컬럼의 resize handle을 드래그하면 해당 컬럼은 고정 너비 컬럼으로 전환됩니다. `suppressSizeToFit: true`인 컬럼은 `fitGridWidth` 실행 시 현재 너비를 유지합니다.
|
|
153
|
+
|
|
97
154
|
## 🚀 Build Setup
|
|
98
155
|
|
|
99
156
|
### install
|
|
@@ -151,7 +208,35 @@ pnpm add @emotion/react @emotion/styled @emotion/css
|
|
|
151
208
|
pnpm add rimraf
|
|
152
209
|
```
|
|
153
210
|
|
|
211
|
+
## Tree Data와 행 이동
|
|
212
|
+
|
|
213
|
+
평면 데이터의 parent id field를 사용해 계층을 구성할 수 있습니다. Tree Data에서는 행 상태와 이동을 안정적으로 유지하기 위해 `getRowId`를 지정해야 합니다.
|
|
214
|
+
|
|
215
|
+
```tsx
|
|
216
|
+
const rows = [
|
|
217
|
+
{ id: "project", parentId: null, name: "프로젝트" },
|
|
218
|
+
{ id: "design", parentId: "project", name: "디자인" },
|
|
219
|
+
{ id: "develop", parentId: "project", name: "개발" },
|
|
220
|
+
];
|
|
221
|
+
|
|
222
|
+
<DataGrid
|
|
223
|
+
columns={[{ fieldId: "name", fieldName: "이름", width: 280 }]}
|
|
224
|
+
dataSource={rows}
|
|
225
|
+
getRowId={(row) => row.id}
|
|
226
|
+
treeData
|
|
227
|
+
treeDataParentIdField="parentId"
|
|
228
|
+
treeDataColumn="name"
|
|
229
|
+
groupDefaultExpanded={-1}
|
|
230
|
+
rowDragManaged
|
|
231
|
+
onRowMove={({ dataSource }) => setRows(dataSource)}
|
|
232
|
+
/>
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
`groupDefaultExpanded`는 기본으로 펼칠 계층 수이며 `-1`은 전체 펼침입니다. Managed row drag는 정렬이 적용되지 않은 클라이언트 데이터에서 활성화됩니다. `isRowValidDropPosition`으로 업무 규칙에 맞지 않는 drop을 차단할 수 있습니다.
|
|
236
|
+
펼쳐진 그룹의 상위 행은 세로 스크롤 중 컬럼 헤더 아래에 고정됩니다. 이 동작이 필요하지 않으면 `suppressGroupRowsSticky`를 `true`로 설정합니다.
|
|
237
|
+
|
|
154
238
|
참고 레퍼런스
|
|
239
|
+
|
|
155
240
|
nora-data-grid은 @leokim97제공하는 ConveGrid 코어를 기반으로 개발 되었습니다.
|
|
156
241
|
일부 nameSpace 구조등 ConveGrid 기반이므로 중복될 수 있습니다.
|
|
157
242
|
|
package/dist/buildPackage.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DataGridColumns, DataGridPrivateColumnModel, DataGridPrivateDataSourceModel, FitCellContentsOptions, FitGridWidthOptions } from '../../types/dataGridCoreProps';
|
|
2
|
+
export declare const CHECKBOX_COLUMN_WIDTH = 40;
|
|
3
|
+
export declare const GRID_SCROLLBAR_SIZE = 14;
|
|
4
|
+
export declare function normalizeColumnWidth(width: string | number | undefined): number;
|
|
5
|
+
export declare function getColumnWidth(column: Pick<DataGridPrivateColumnModel, "width" | "__computedWidth">): number;
|
|
6
|
+
export declare function clampColumnWidth(column: DataGridPrivateColumnModel, width: number, defaultMinWidth?: number): number;
|
|
7
|
+
export declare function resizeColumn(columns: DataGridColumns, columnIndex: number, requestedWidth: number): DataGridColumns;
|
|
8
|
+
export declare function resolveFlexColumnWidths(columns: DataGridColumns, availableWidth: number): DataGridColumns;
|
|
9
|
+
export declare function fitColumnsToGridWidth(columns: DataGridColumns, availableWidth: number, options?: FitGridWidthOptions): DataGridColumns;
|
|
10
|
+
export declare function fitColumnsToCellContents(columns: DataGridColumns, rows: DataGridPrivateDataSourceModel[], options?: FitCellContentsOptions, fieldIds?: string[], root?: HTMLElement | null, availableWidth?: number): DataGridColumns;
|
|
11
|
+
export declare function haveSameComputedWidths(left: DataGridColumns, right: DataGridColumns): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -45,6 +45,11 @@ export declare const sorting: (dataSource: DataGridDataSource, newSort: GridSort
|
|
|
45
45
|
__ariaRowindex: number;
|
|
46
46
|
__dataRowindex: number;
|
|
47
47
|
__uuid: string;
|
|
48
|
+
__rowId?: import('../../types').GridRowId;
|
|
48
49
|
__originalRowindex: number;
|
|
50
|
+
__parentId?: import('../../types').GridRowId | null;
|
|
51
|
+
__treeDepth?: number;
|
|
52
|
+
__hasChildren?: boolean;
|
|
53
|
+
__expanded?: boolean;
|
|
49
54
|
height?: number;
|
|
50
55
|
}[];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DataGridPrivateDataSourceModel, GridRowId, GridSortModel } from '../../types/dataGridCoreProps';
|
|
2
|
+
export type TreeDropPosition = "before" | "inside" | "after";
|
|
3
|
+
export interface TreeRowModel {
|
|
4
|
+
sourceRows: DataGridPrivateDataSourceModel[];
|
|
5
|
+
visibleRows: DataGridPrivateDataSourceModel[];
|
|
6
|
+
nodeById: Map<GridRowId, DataGridPrivateDataSourceModel>;
|
|
7
|
+
childrenByParentId: Map<GridRowId | null, GridRowId[]>;
|
|
8
|
+
expandedIds: Set<GridRowId>;
|
|
9
|
+
}
|
|
10
|
+
interface BuildTreeRowModelOptions {
|
|
11
|
+
getRowId: (row: DataGridPrivateDataSourceModel) => GridRowId;
|
|
12
|
+
parentIdField: string;
|
|
13
|
+
expandedIds?: ReadonlySet<GridRowId>;
|
|
14
|
+
groupDefaultExpanded?: number;
|
|
15
|
+
sortModel?: GridSortModel;
|
|
16
|
+
}
|
|
17
|
+
export declare function rowIdToKey(id: GridRowId): string;
|
|
18
|
+
export declare function buildTreeRowModel(sourceRows: DataGridPrivateDataSourceModel[], options: BuildTreeRowModelOptions): TreeRowModel;
|
|
19
|
+
export declare function moveTreeRow(model: TreeRowModel, sourceId: GridRowId, targetId: GridRowId, position: TreeDropPosition, parentIdField: string, getRowId: (row: DataGridPrivateDataSourceModel) => GridRowId): DataGridPrivateDataSourceModel[] | null;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -2,6 +2,12 @@ import { default as React, ReactNode } from 'react';
|
|
|
2
2
|
import { DataGridPrivateColumnModel, DataGridPrivateDataSourceModel } from '../types/dataGridCoreProps';
|
|
3
3
|
import { DataGridPrivateApiModel, GirdApiCommon } from '../types/dataGridProps';
|
|
4
4
|
export declare const initialWindowHeight = 500;
|
|
5
|
+
export interface StickyTreeRow {
|
|
6
|
+
row: DataGridPrivateDataSourceModel;
|
|
7
|
+
top: number;
|
|
8
|
+
translateY: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function getStickyTreeRows(rows: DataGridPrivateDataSourceModel[], cumulativeHeights: number[], scrollTop: number, fallbackRowHeight: number): StickyTreeRow[];
|
|
5
11
|
interface VirtualListProps {
|
|
6
12
|
children: (props: {
|
|
7
13
|
visibleItems: Array<DataGridPrivateDataSourceModel>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function ChevronDownIcon({ size, color, strokeWidth, className, ...props }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
size?: number | undefined;
|
|
4
|
+
color?: string | undefined;
|
|
5
|
+
strokeWidth?: number | undefined;
|
|
6
|
+
className?: string | undefined;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function ChevronRightIcon({ size, color, strokeWidth, className, ...props }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
size?: number | undefined;
|
|
4
|
+
color?: string | undefined;
|
|
5
|
+
strokeWidth?: number | undefined;
|
|
6
|
+
className?: string | undefined;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function GripIcon({ size, color, strokeWidth, className, ...props }: {
|
|
2
|
+
[x: string]: any;
|
|
3
|
+
size?: number | undefined;
|
|
4
|
+
color?: string | undefined;
|
|
5
|
+
strokeWidth?: number | undefined;
|
|
6
|
+
className?: string | undefined;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|