@iyulab/data-components 0.1.8 → 0.3.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/CHANGELOG.md +40 -2
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorate.js +9 -0
- package/dist/_virtual/_@oxc-project_runtime@0.122.0/helpers/decorateMetadata.js +6 -0
- package/dist/components/data-grid/UDataGrid.js +144 -172
- package/dist/components/data-view/UDataView.d.ts +44 -3
- package/dist/components/data-view/UDataView.js +172 -4
- package/dist/components/data-view/UDataView.styles.js +4 -83
- package/dist/components/simple-sheet/USimpleSheet.d.ts +167 -3
- package/dist/components/simple-sheet/USimpleSheet.js +934 -4
- package/dist/components/simple-sheet/USimpleSheet.styles.js +4 -4
- package/dist/components/u-rich-table/URichTable.d.ts +75 -0
- package/dist/components/u-rich-table/URichTable.js +618 -0
- package/dist/components/u-rich-table/styles.d.ts +1 -0
- package/dist/components/u-rich-table/styles.js +433 -0
- package/dist/components/u-rich-table/types.d.ts +67 -0
- package/dist/components/u-rich-table/utils/clipboard.d.ts +9 -0
- package/dist/components/u-rich-table/utils/clipboard.js +31 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -5
- package/package.json +20 -33
- package/dist/components/data-view/UDataView.component.d.ts +0 -47
- package/dist/components/data-view/UDataView.component.js +0 -226
- package/dist/components/simple-sheet/USimpleSheet.component.d.ts +0 -158
- package/dist/components/simple-sheet/USimpleSheet.component.js +0 -1014
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { html } from 'lit';
|
|
2
|
-
import { property, state } from 'lit/decorators.js';
|
|
3
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
4
|
-
import { UIcon } from '@iyulab/components/dist/components/icon/UIcon.component.js';
|
|
5
|
-
import { UButton } from '@iyulab/components/dist/components/button/UButton.component.js';
|
|
6
|
-
import { styles } from './UDataView.styles.js';
|
|
7
|
-
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
-
var result = void 0 ;
|
|
11
|
-
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
-
if (decorator = decorators[i])
|
|
13
|
-
result = (decorator(target, key, result) ) || result;
|
|
14
|
-
if (result) __defProp(target, key, result);
|
|
15
|
-
return result;
|
|
16
|
-
};
|
|
17
|
-
class UDataView extends UElement {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this.items = [];
|
|
21
|
-
this.mode = "grid";
|
|
22
|
-
this.gridMinWidth = "200px";
|
|
23
|
-
this.gap = "1rem";
|
|
24
|
-
this.selectedIndex = null;
|
|
25
|
-
}
|
|
26
|
-
static {
|
|
27
|
-
this.styles = [super.styles, styles];
|
|
28
|
-
}
|
|
29
|
-
static {
|
|
30
|
-
this.dependencies = {
|
|
31
|
-
"u-icon": UIcon,
|
|
32
|
-
"u-button": UButton
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
render() {
|
|
36
|
-
return html`
|
|
37
|
-
<div class="data-view">
|
|
38
|
-
${this.renderToolbar()}
|
|
39
|
-
${this.renderContent()}
|
|
40
|
-
</div>
|
|
41
|
-
`;
|
|
42
|
-
}
|
|
43
|
-
renderToolbar() {
|
|
44
|
-
return html`
|
|
45
|
-
<div class="toolbar">
|
|
46
|
-
<div class="view-toggles">
|
|
47
|
-
${this.renderViewButton("grid", "grid-3x3-gap", "Grid")}
|
|
48
|
-
${this.renderViewButton("list", "list-ul", "List")}
|
|
49
|
-
${this.renderViewButton("table", "table", "Table")}
|
|
50
|
-
</div>
|
|
51
|
-
<div class="info">
|
|
52
|
-
${this.items.length} items
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
`;
|
|
56
|
-
}
|
|
57
|
-
renderViewButton(mode, icon, label) {
|
|
58
|
-
return html`
|
|
59
|
-
<u-button
|
|
60
|
-
?active=${this.mode === mode}
|
|
61
|
-
@click=${() => this.switchMode(mode)}
|
|
62
|
-
title=${label}
|
|
63
|
-
>
|
|
64
|
-
<u-icon lib="bootstrap" name=${icon}></u-icon>
|
|
65
|
-
</u-button>
|
|
66
|
-
`;
|
|
67
|
-
}
|
|
68
|
-
renderContent() {
|
|
69
|
-
if (!this.items?.length) {
|
|
70
|
-
return html`<div class="empty">No data available</div>`;
|
|
71
|
-
}
|
|
72
|
-
switch (this.mode) {
|
|
73
|
-
case "grid":
|
|
74
|
-
return this.renderGrid();
|
|
75
|
-
case "list":
|
|
76
|
-
return this.renderList();
|
|
77
|
-
case "table":
|
|
78
|
-
return this.renderTable();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
renderGrid() {
|
|
82
|
-
return html`
|
|
83
|
-
<div class="grid" style="--min-width: ${this.gridMinWidth}; --gap: ${this.gap};">
|
|
84
|
-
${this.items.map((item, index) => this.renderGridItem(item, index))}
|
|
85
|
-
</div>
|
|
86
|
-
`;
|
|
87
|
-
}
|
|
88
|
-
renderList() {
|
|
89
|
-
return html`
|
|
90
|
-
<div class="list" style="--gap: ${this.gap};">
|
|
91
|
-
${this.items.map((item, index) => this.renderListItem(item, index))}
|
|
92
|
-
</div>
|
|
93
|
-
`;
|
|
94
|
-
}
|
|
95
|
-
renderTable() {
|
|
96
|
-
const cols = this.getColumns();
|
|
97
|
-
return html`
|
|
98
|
-
<div class="table-wrapper">
|
|
99
|
-
<table>
|
|
100
|
-
<thead>
|
|
101
|
-
<tr>
|
|
102
|
-
${cols.map((col) => html`
|
|
103
|
-
<th style=${col.width ? `width: ${col.width}` : ""}>
|
|
104
|
-
${col.label || this.formatLabel(col.key)}
|
|
105
|
-
</th>
|
|
106
|
-
`)}
|
|
107
|
-
</tr>
|
|
108
|
-
</thead>
|
|
109
|
-
<tbody>
|
|
110
|
-
${this.items.map((item, index) => html`
|
|
111
|
-
<tr
|
|
112
|
-
class=${this.selectedIndex === index ? "selected" : ""}
|
|
113
|
-
@click=${() => this.selectItem(index)}
|
|
114
|
-
>
|
|
115
|
-
${cols.map((col) => html`
|
|
116
|
-
<td>${this.getCellContent(item, col, index)}</td>
|
|
117
|
-
`)}
|
|
118
|
-
</tr>
|
|
119
|
-
`)}
|
|
120
|
-
</tbody>
|
|
121
|
-
</table>
|
|
122
|
-
</div>
|
|
123
|
-
`;
|
|
124
|
-
}
|
|
125
|
-
renderGridItem(item, index) {
|
|
126
|
-
const content = this.renderCard ? this.renderCard(item, index) : this.renderDefaultCard(item);
|
|
127
|
-
return html`
|
|
128
|
-
<div
|
|
129
|
-
class="card ${this.selectedIndex === index ? "selected" : ""}"
|
|
130
|
-
@click=${() => this.selectItem(index)}
|
|
131
|
-
>
|
|
132
|
-
${content}
|
|
133
|
-
</div>
|
|
134
|
-
`;
|
|
135
|
-
}
|
|
136
|
-
renderListItem(item, index) {
|
|
137
|
-
const content = this.renderCard ? this.renderCard(item, index) : this.renderDefaultCard(item);
|
|
138
|
-
return html`
|
|
139
|
-
<div
|
|
140
|
-
class="card list-card ${this.selectedIndex === index ? "selected" : ""}"
|
|
141
|
-
@click=${() => this.selectItem(index)}
|
|
142
|
-
>
|
|
143
|
-
${content}
|
|
144
|
-
</div>
|
|
145
|
-
`;
|
|
146
|
-
}
|
|
147
|
-
renderDefaultCard(item) {
|
|
148
|
-
const cols = this.getColumns();
|
|
149
|
-
return html`
|
|
150
|
-
<div class="card-content">
|
|
151
|
-
${cols.slice(0, 5).map((col) => {
|
|
152
|
-
const value = item[col.key];
|
|
153
|
-
return html`
|
|
154
|
-
<div class="card-field">
|
|
155
|
-
<span class="label">${col.label || this.formatLabel(col.key)}:</span>
|
|
156
|
-
<span class="value">${this.formatValue(value)}</span>
|
|
157
|
-
</div>
|
|
158
|
-
`;
|
|
159
|
-
})}
|
|
160
|
-
</div>
|
|
161
|
-
`;
|
|
162
|
-
}
|
|
163
|
-
getCellContent(item, column, index) {
|
|
164
|
-
if (this.renderCell) {
|
|
165
|
-
return this.renderCell(item, column, index);
|
|
166
|
-
}
|
|
167
|
-
return this.formatValue(item[column.key]);
|
|
168
|
-
}
|
|
169
|
-
getColumns() {
|
|
170
|
-
if (this.columns?.length) {
|
|
171
|
-
return this.columns;
|
|
172
|
-
}
|
|
173
|
-
if (this.items.length > 0) {
|
|
174
|
-
const firstItem = this.items[0];
|
|
175
|
-
return Object.keys(firstItem).map((key) => ({ key }));
|
|
176
|
-
}
|
|
177
|
-
return [];
|
|
178
|
-
}
|
|
179
|
-
formatLabel(key) {
|
|
180
|
-
return key.replace(/([A-Z])/g, " $1").replace(/^./, (str) => str.toUpperCase()).trim();
|
|
181
|
-
}
|
|
182
|
-
formatValue(value) {
|
|
183
|
-
if (value == null) return "—";
|
|
184
|
-
if (typeof value === "boolean") return value ? "✓" : "✗";
|
|
185
|
-
if (value instanceof Date) return value.toLocaleString();
|
|
186
|
-
if (typeof value === "object") return JSON.stringify(value);
|
|
187
|
-
return String(value);
|
|
188
|
-
}
|
|
189
|
-
switchMode(mode) {
|
|
190
|
-
this.mode = mode;
|
|
191
|
-
this.emit("mode-change", { mode });
|
|
192
|
-
}
|
|
193
|
-
selectItem(index) {
|
|
194
|
-
this.selectedIndex = index;
|
|
195
|
-
this.emit("select", {
|
|
196
|
-
item: this.items[index],
|
|
197
|
-
index
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
__decorateClass([
|
|
202
|
-
property({ type: Array })
|
|
203
|
-
], UDataView.prototype, "items");
|
|
204
|
-
__decorateClass([
|
|
205
|
-
property({ type: String })
|
|
206
|
-
], UDataView.prototype, "mode");
|
|
207
|
-
__decorateClass([
|
|
208
|
-
property({ type: Array })
|
|
209
|
-
], UDataView.prototype, "columns");
|
|
210
|
-
__decorateClass([
|
|
211
|
-
property({ type: String })
|
|
212
|
-
], UDataView.prototype, "gridMinWidth");
|
|
213
|
-
__decorateClass([
|
|
214
|
-
property({ type: String })
|
|
215
|
-
], UDataView.prototype, "gap");
|
|
216
|
-
__decorateClass([
|
|
217
|
-
property({ attribute: false })
|
|
218
|
-
], UDataView.prototype, "renderCard");
|
|
219
|
-
__decorateClass([
|
|
220
|
-
property({ attribute: false })
|
|
221
|
-
], UDataView.prototype, "renderCell");
|
|
222
|
-
__decorateClass([
|
|
223
|
-
state()
|
|
224
|
-
], UDataView.prototype, "selectedIndex");
|
|
225
|
-
|
|
226
|
-
export { UDataView };
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { TemplateResult } from 'lit';
|
|
2
|
-
import { UElement } from '@iyulab/components/dist/components/UElement.js';
|
|
3
|
-
export interface SheetColumn {
|
|
4
|
-
/** 데이터 키 (getDataAsObjects() 반환시 객체 키로 사용) */
|
|
5
|
-
key?: string;
|
|
6
|
-
/** 헤더 표시 레이블 */
|
|
7
|
-
label?: string;
|
|
8
|
-
/** 열 너비 (px) */
|
|
9
|
-
width?: number;
|
|
10
|
-
/** 읽기 전용 열 */
|
|
11
|
-
readonly?: boolean;
|
|
12
|
-
/** 선택 가능한 옵션 목록 (정적 배열 또는 동적 콜백) */
|
|
13
|
-
options?: string[] | ((row: number, col: number) => string[]);
|
|
14
|
-
/** true이면 목록에 있는 값만 입력 가능 (기본: false = 자유 입력 허용) */
|
|
15
|
-
strict?: boolean;
|
|
16
|
-
/** 자동 계산 함수. 설정 시 해당 열은 자동 readonly. 열 순서(좌→우), 행 순서(위→아래)로 계산. */
|
|
17
|
-
compute?: (rowIndex: number, data: string[][]) => string;
|
|
18
|
-
/** 표시 포맷. Intl.NumberFormatOptions(숫자) 또는 커스텀 콜백. 원본 데이터는 유지. */
|
|
19
|
-
format?: Intl.NumberFormatOptions | ((value: string, rowIndex: number) => string);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* USimpleSheet - 심플 스프레드시트 컴포넌트
|
|
23
|
-
*
|
|
24
|
-
* 편집 편의 기능:
|
|
25
|
-
* - Undo/Redo: Ctrl+Z / Ctrl+Y / Ctrl+Shift+Z
|
|
26
|
-
* - Ctrl+Enter: 편집 확정 후 현재 셀 유지
|
|
27
|
-
* - Shift+Enter: 위로 이동
|
|
28
|
-
* - Home/End: 행 처음/끝 (Ctrl+Home/End: 시트 처음/끝)
|
|
29
|
-
* - Page Up/Down: 10행 단위 이동
|
|
30
|
-
* - Ctrl+A: 전체 선택
|
|
31
|
-
* - Tab 사이클: 마지막 열 → 다음 행 첫 열
|
|
32
|
-
* - Ctrl+D: Fill Down (선택 영역 첫 행 값 아래로 채우기)
|
|
33
|
-
* - Ctrl+R: Fill Right (선택 영역 첫 열 값 오른쪽으로 채우기)
|
|
34
|
-
* - 행/열 헤더 클릭: 전체 행/열 선택
|
|
35
|
-
* - 엑셀 호환 Ctrl+C/V (TSV), Delete/Backspace
|
|
36
|
-
* - 다중 셀 선택: Shift+클릭, Shift+Arrow, 마우스 드래그
|
|
37
|
-
* - columns 미설정시 A, B, C... 자동 헤더
|
|
38
|
-
*/
|
|
39
|
-
export declare class USimpleSheet extends UElement {
|
|
40
|
-
static styles: import('lit').CSSResultGroup[];
|
|
41
|
-
/** 초기 데이터 (2D 문자열 배열) */
|
|
42
|
-
data: string[][];
|
|
43
|
-
/** 열 정의 (미설정시 A, B, C... 자동 헤더) */
|
|
44
|
-
columns?: SheetColumn[];
|
|
45
|
-
/** 초기 행 수 */
|
|
46
|
-
rows: number;
|
|
47
|
-
/** 초기 열 수 (columns 미설정시 사용) */
|
|
48
|
-
cols: number;
|
|
49
|
-
/** 읽기 전용 모드 */
|
|
50
|
-
readonly: boolean;
|
|
51
|
-
private _sel;
|
|
52
|
-
private _editing;
|
|
53
|
-
private _editVal;
|
|
54
|
-
private _replaceOnEdit;
|
|
55
|
-
private _dropdownItems;
|
|
56
|
-
private _dropdownIndex;
|
|
57
|
-
private _isDropdownClick;
|
|
58
|
-
private _data;
|
|
59
|
-
private _colWidths;
|
|
60
|
-
private _isMouseSelecting;
|
|
61
|
-
private _containerEl;
|
|
62
|
-
private _resizing;
|
|
63
|
-
private static readonly MIN_COL_WIDTH;
|
|
64
|
-
private static readonly DEFAULT_COL_WIDTH;
|
|
65
|
-
private _history;
|
|
66
|
-
private _historyIndex;
|
|
67
|
-
private static readonly HISTORY_LIMIT;
|
|
68
|
-
connectedCallback(): void;
|
|
69
|
-
disconnectedCallback(): void;
|
|
70
|
-
protected willUpdate(changed: Map<string, unknown>): void;
|
|
71
|
-
private _syncDataFromProps;
|
|
72
|
-
private _syncData;
|
|
73
|
-
private get _rowCount();
|
|
74
|
-
private get _colCount();
|
|
75
|
-
private _pushHistory;
|
|
76
|
-
private _undo;
|
|
77
|
-
private _redo;
|
|
78
|
-
/** 열 인덱스를 A, B, ..., Z, AA, AB, ... 형태로 변환 */
|
|
79
|
-
private _colLabel;
|
|
80
|
-
private _colWidthStyle;
|
|
81
|
-
private _inSel;
|
|
82
|
-
private _isAnchor;
|
|
83
|
-
private _isColSelected;
|
|
84
|
-
private _isRowSelected;
|
|
85
|
-
render(): TemplateResult<1>;
|
|
86
|
-
private _renderCell;
|
|
87
|
-
private _refContainer;
|
|
88
|
-
private _onContainerFocus;
|
|
89
|
-
private _onContainerKeyDown;
|
|
90
|
-
private _onInputChange;
|
|
91
|
-
private _onInputKeyDown;
|
|
92
|
-
private _onInputBlur;
|
|
93
|
-
private _onDropdownItemMouseDown;
|
|
94
|
-
private _onTableMouseDown;
|
|
95
|
-
private _onTableMouseOver;
|
|
96
|
-
private _onTableDblClick;
|
|
97
|
-
private _onDocMouseUp;
|
|
98
|
-
/** 열 너비 조절 시작 */
|
|
99
|
-
private _onResizeStart;
|
|
100
|
-
private _onResizeMove;
|
|
101
|
-
private _onResizeEnd;
|
|
102
|
-
/** 코너 클릭 → 전체 선택 */
|
|
103
|
-
private _onSelectAll;
|
|
104
|
-
/** 열 헤더 클릭 → 전체 열 선택 */
|
|
105
|
-
private _onColHeaderMouseDown;
|
|
106
|
-
/** 행 헤더 클릭 → 전체 행 선택 */
|
|
107
|
-
private _onRowHeaderMouseDown;
|
|
108
|
-
private _onCopy;
|
|
109
|
-
private _onPaste;
|
|
110
|
-
private _selectionToTSV;
|
|
111
|
-
private _pasteFromText;
|
|
112
|
-
/** Ctrl+D: 선택 영역 첫 행 값을 아래로 채우기 */
|
|
113
|
-
private _fillDown;
|
|
114
|
-
/** Ctrl+R: 선택 영역 첫 열 값을 오른쪽으로 채우기 */
|
|
115
|
-
private _fillRight;
|
|
116
|
-
/**
|
|
117
|
-
* @param typedChar - 타이핑으로 시작할 경우 첫 글자. 미제공시 기존 값 유지.
|
|
118
|
-
*/
|
|
119
|
-
private _startEdit;
|
|
120
|
-
private _commitEdit;
|
|
121
|
-
private _cancelEdit;
|
|
122
|
-
private _clearSelection;
|
|
123
|
-
private _select;
|
|
124
|
-
private _scrollCellIntoView;
|
|
125
|
-
private _getCellFromEvent;
|
|
126
|
-
private _isColReadonly;
|
|
127
|
-
private _isColComputed;
|
|
128
|
-
private _isNumeric;
|
|
129
|
-
/** 열의 format 설정에 따라 표시값을 반환. format 미설정 시 원본 반환. */
|
|
130
|
-
private _formatValue;
|
|
131
|
-
/** compute 열을 재계산 (열 순서 좌→우, 행 순서 위→아래) */
|
|
132
|
-
private _recompute;
|
|
133
|
-
private _getColOptions;
|
|
134
|
-
private _filterOptions;
|
|
135
|
-
private _emitChange;
|
|
136
|
-
/** 현재 데이터를 2D 배열로 반환 */
|
|
137
|
-
getData(): string[][];
|
|
138
|
-
/**
|
|
139
|
-
* 정의된 columns의 key를 기준으로 객체 배열로 반환.
|
|
140
|
-
* columns 미설정시 A, B, C... 키를 사용.
|
|
141
|
-
*/
|
|
142
|
-
getDataAsObjects(): Record<string, string>[];
|
|
143
|
-
/** 데이터를 직접 설정하고 재렌더링 */
|
|
144
|
-
setData(data: string[][]): void;
|
|
145
|
-
/** 특정 셀 값 설정 */
|
|
146
|
-
setCell(row: number, col: number, value: string): void;
|
|
147
|
-
/** 현재 선택 영역 반환 */
|
|
148
|
-
getSelection(): {
|
|
149
|
-
minRow: number;
|
|
150
|
-
maxRow: number;
|
|
151
|
-
minCol: number;
|
|
152
|
-
maxCol: number;
|
|
153
|
-
} | null;
|
|
154
|
-
/** Undo 가능 여부 */
|
|
155
|
-
get canUndo(): boolean;
|
|
156
|
-
/** Redo 가능 여부 */
|
|
157
|
-
get canRedo(): boolean;
|
|
158
|
-
}
|