@sellmate/design-system 0.0.46 → 0.0.47

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 (23) hide show
  1. package/dist/cjs/design-system.cjs.js +1 -1
  2. package/dist/cjs/loader.cjs.js +1 -1
  3. package/dist/cjs/sd-button.sd-checkbox.sd-icon.sd-input.sd-loading-spinner.sd-pagination.sd-portal.sd-select.sd-select-option.sd-table-backup.sd-tooltip.sd-tooltip-portal.entry.cjs.js.map +1 -1
  4. package/dist/cjs/sd-button_12.cjs.entry.js +221 -44
  5. package/dist/collection/components/sd-table-backup/sd-table-backup.css +27 -7
  6. package/dist/collection/components/sd-table-backup/sd-table-backup.js +278 -53
  7. package/dist/collection/components/sd-table-backup/sd-table-backup.js.map +1 -1
  8. package/dist/components/sd-table-backup.js +230 -47
  9. package/dist/components/sd-table-backup.js.map +1 -1
  10. package/dist/design-system/design-system.esm.js +1 -1
  11. package/dist/design-system/{p-36f24993.entry.js → p-423025fa.entry.js} +2 -2
  12. package/dist/design-system/p-423025fa.entry.js.map +1 -0
  13. package/dist/design-system/sd-button.sd-checkbox.sd-icon.sd-input.sd-loading-spinner.sd-pagination.sd-portal.sd-select.sd-select-option.sd-table-backup.sd-tooltip.sd-tooltip-portal.entry.esm.js.map +1 -1
  14. package/dist/esm/design-system.js +1 -1
  15. package/dist/esm/loader.js +1 -1
  16. package/dist/esm/sd-button.sd-checkbox.sd-icon.sd-input.sd-loading-spinner.sd-pagination.sd-portal.sd-select.sd-select-option.sd-table-backup.sd-tooltip.sd-tooltip-portal.entry.js.map +1 -1
  17. package/dist/esm/sd-button_12.entry.js +221 -44
  18. package/dist/types/components/sd-table-backup/sd-table-backup.d.ts +21 -3
  19. package/dist/types/components.d.ts +18 -8
  20. package/hydrate/index.js +229 -47
  21. package/hydrate/index.mjs +229 -47
  22. package/package.json +2 -2
  23. package/dist/design-system/p-36f24993.entry.js.map +0 -1
@@ -14,6 +14,7 @@ export class SdTable {
14
14
  noDataLabel = '데이터가 없습니다.';
15
15
  isLoading = false;
16
16
  pagination;
17
+ headerCellRenderer;
17
18
  bodyCellRenderer;
18
19
  useInternalPagination = false;
19
20
  useRowsPerPageSelect = false;
@@ -23,9 +24,15 @@ export class SdTable {
23
24
  { label: '50개씩 보기', value: 50 },
24
25
  { label: '100개씩 보기', value: 100 },
25
26
  ];
26
- useVirtualScroll = false; // 가상 스크롤 사용 여부
27
- virtualRowHeight = 44; // 가상 스크롤 사용시 각 행의 높이 - 가상 스크롤 사용시 필수값
28
- virtualBufferSize = 5; // 가상 스크롤 위아래 버퍼 크기
27
+ useVirtualScroll = {}; // 가상 스크롤 사용 여부
28
+ virtualRowHeight = 44; // 가상 스크롤 사용시 각 행의 높이 - 세로 가상 스크롤 사용시 필수값
29
+ // 가상 스크롤 사용시 각 열의 너비 - 가로 가상 스크롤 사용시 필수값
30
+ // 가상화하려는 컬럼의 넓이는 무조건 고정(resizable의 경우 넓이가 변동되는데 이때에는 고려 x)
31
+ virtualColumnWidth = 120;
32
+ virtualBufferSize = {
33
+ vertical: 5,
34
+ horizontal: 5,
35
+ }; // 가상 스크롤 위아래 버퍼 크기
29
36
  sdSelectChange;
30
37
  sdPageChange;
31
38
  sdRowsPerPageChange;
@@ -35,17 +42,34 @@ export class SdTable {
35
42
  columnWidths = [];
36
43
  scrolledLeft = false;
37
44
  scrolledRight = false;
38
- virtualStartIndex = 0; // 렌더링 시작 인덱스
39
- virtualEndIndex = 0; // 렌더링 종료 인덱스
45
+ // 세로 가상 스크롤 상태값
46
+ virtualStartIndex = 0;
47
+ virtualEndIndex = 0;
40
48
  scrollTopPosition = 0;
49
+ // 가로 가상 스크롤 상태값
50
+ virtualStartColIdx = 0;
51
+ virtualEndColIdx = 0;
52
+ scrollLeftPosition = 0;
41
53
  scrollRequestAnimationFrame = null;
42
54
  scrollContainer = null;
43
55
  handleColumnsChange(newCols) {
44
56
  this.columnWidths = newCols.map(c => parseInt(c.width || '120', 10));
57
+ if (this.useVirtualScroll.horizontal) {
58
+ requestAnimationFrame(() => {
59
+ this.calculateVisibleColumnRange();
60
+ });
61
+ }
62
+ }
63
+ handleColumnWidthsChange() {
64
+ if (this.useVirtualScroll.horizontal) {
65
+ requestAnimationFrame(() => {
66
+ this.calculateVisibleColumnRange();
67
+ });
68
+ }
45
69
  }
46
70
  handleRowsChange(newRows) {
47
71
  this.innerRows = [...newRows];
48
- if (this.useVirtualScroll) {
72
+ if (this.useVirtualScroll.vertical) {
49
73
  requestAnimationFrame(() => {
50
74
  this.calculateVisibleRange();
51
75
  });
@@ -57,7 +81,7 @@ export class SdTable {
57
81
  handlePaginationChange(newVal) {
58
82
  if (newVal?.page && newVal.page !== this.currentPage) {
59
83
  this.currentPage = newVal.page;
60
- if (this.useVirtualScroll && this.scrollContainer) {
84
+ if (this.useVirtualScroll.vertical && this.scrollContainer) {
61
85
  this.scrollContainer.scrollTop = 0;
62
86
  this.scrollTopPosition = 0;
63
87
  this.calculateVisibleRange();
@@ -84,13 +108,21 @@ export class SdTable {
84
108
  const { scrollLeft, scrollWidth, clientWidth, scrollTop } = middle;
85
109
  this.scrolledLeft = scrollLeft > 0;
86
110
  this.scrolledRight = scrollLeft + clientWidth < scrollWidth;
87
- if (this.useVirtualScroll) {
111
+ if (this.useVirtualScroll.vertical || this.useVirtualScroll.horizontal) {
88
112
  if (this.scrollRequestAnimationFrame !== null) {
89
113
  cancelAnimationFrame(this.scrollRequestAnimationFrame);
90
114
  }
91
115
  this.scrollRequestAnimationFrame = requestAnimationFrame(() => {
92
- this.scrollTopPosition = scrollTop;
93
- this.calculateVisibleRange();
116
+ // 세로 가상 스크롤 계산
117
+ if (this.useVirtualScroll.vertical && this.scrollTopPosition !== scrollTop) {
118
+ this.scrollTopPosition = scrollTop;
119
+ this.calculateVisibleRange();
120
+ }
121
+ // 가로 가상 스크롤 계산
122
+ if (this.useVirtualScroll.horizontal && this.scrollLeftPosition !== scrollLeft) {
123
+ this.scrollLeftPosition = scrollLeft;
124
+ this.calculateVisibleColumnRange();
125
+ }
94
126
  this.scrollRequestAnimationFrame = null;
95
127
  });
96
128
  }
@@ -115,7 +147,7 @@ export class SdTable {
115
147
  return result;
116
148
  }
117
149
  get virtualRows() {
118
- if (!this.useVirtualScroll) {
150
+ if (!this.useVirtualScroll.vertical) {
119
151
  return this.paginatedRows.map((row, idx) => ({ row, actualIndex: idx }));
120
152
  }
121
153
  return this.paginatedRows
@@ -126,18 +158,40 @@ export class SdTable {
126
158
  }));
127
159
  }
128
160
  get topSpacerHeight() {
129
- if (!this.useVirtualScroll || this.virtualStartIndex === 0)
161
+ if (!this.useVirtualScroll.vertical || this.virtualStartIndex === 0)
130
162
  return 0;
131
163
  return this.virtualStartIndex * this.virtualRowHeight;
132
164
  }
133
165
  get bottomSpacerHeight() {
134
- if (!this.useVirtualScroll)
166
+ if (!this.useVirtualScroll.vertical)
135
167
  return 0;
136
168
  const remainingRows = this.paginatedRows.length - this.virtualEndIndex - 1;
137
169
  return remainingRows > 0 ? remainingRows * this.virtualRowHeight : 0;
138
170
  }
171
+ getHorizontalSpacerWidth(position) {
172
+ const stickyLeftCount = this.stickyColumn.left || 0;
173
+ const stickyRightCount = this.stickyColumn.right || 0;
174
+ const virtualColumnWidths = this.columnWidths.slice(stickyLeftCount, this.visibleColumns.length - stickyRightCount);
175
+ const remainingCols = virtualColumnWidths.length - this.virtualEndColIdx - 1;
176
+ if (position === 'right' && remainingCols <= 0)
177
+ return 0;
178
+ const targetIndex = position === 'left' ? [0, this.virtualStartColIdx] : [this.virtualEndColIdx + 1];
179
+ return virtualColumnWidths.slice(...targetIndex).reduce((sum, width) => sum + width, 0);
180
+ }
181
+ get leftSpacerWidth() {
182
+ if (!this.useVirtualScroll.horizontal || this.virtualStartColIdx === 0) {
183
+ return 0;
184
+ }
185
+ return this.getHorizontalSpacerWidth('left');
186
+ }
187
+ get rightSpacerWidth() {
188
+ if (!this.useVirtualScroll.horizontal) {
189
+ return 0;
190
+ }
191
+ return this.getHorizontalSpacerWidth('right');
192
+ }
139
193
  get totalVirtualHeight() {
140
- if (!this.useVirtualScroll)
194
+ if (!this.useVirtualScroll.vertical)
141
195
  return 0;
142
196
  return this.paginatedRows.length * this.virtualRowHeight;
143
197
  }
@@ -196,8 +250,9 @@ export class SdTable {
196
250
  return true; // 전부 선택됨
197
251
  return null; // 일부만 선택됨
198
252
  }
253
+ // 세로 가상 스크롤 렌더링 계산
199
254
  calculateVisibleRange() {
200
- if (!this.useVirtualScroll) {
255
+ if (!this.useVirtualScroll.vertical) {
201
256
  this.virtualStartIndex = 0;
202
257
  this.virtualEndIndex = this.paginatedRows.length - 1;
203
258
  return;
@@ -207,8 +262,60 @@ export class SdTable {
207
262
  const startIndex = Math.floor(scrollTop / this.virtualRowHeight);
208
263
  const visibleCount = Math.ceil(containerHeight / this.virtualRowHeight);
209
264
  const endIndex = startIndex + visibleCount;
210
- this.virtualStartIndex = Math.max(0, startIndex - this.virtualBufferSize);
211
- this.virtualEndIndex = Math.min(this.paginatedRows.length - 1, endIndex + this.virtualBufferSize);
265
+ const bufferSize = this.virtualBufferSize.vertical || 5;
266
+ this.virtualStartIndex = Math.max(0, startIndex - bufferSize);
267
+ this.virtualEndIndex = Math.min(this.paginatedRows.length - 1, endIndex + bufferSize);
268
+ }
269
+ // 가로 가상 스크롤 렌더링 계산
270
+ calculateVisibleColumnRange() {
271
+ if (!this.useVirtualScroll.horizontal) {
272
+ this.virtualStartColIdx = 0;
273
+ this.virtualEndColIdx = this.visibleColumns.length - 1;
274
+ return;
275
+ }
276
+ const scrollLeft = this.scrollLeftPosition;
277
+ const containerWidth = this.scrollContainer?.clientWidth || 0;
278
+ const stickyLeftCount = this.stickyColumn.left || 0;
279
+ const stickyRightCount = this.stickyColumn.right || 0;
280
+ // 가상 스크롤 컬럼 - sticky column 제외
281
+ const virtualColumns = this.visibleColumns.slice(stickyLeftCount, this.visibleColumns.length - stickyRightCount);
282
+ if (virtualColumns.length === 0) {
283
+ this.virtualStartColIdx = 0;
284
+ this.virtualEndColIdx = 0;
285
+ return;
286
+ }
287
+ const stickyLeftWidth = this.columnWidths.slice(0, stickyLeftCount).reduce((sum, width) => sum + width, 0) +
288
+ (this.selectable ? 52 : 0);
289
+ const stickyRightWidth = this.columnWidths
290
+ .slice(this.visibleColumns.length - stickyRightCount)
291
+ .reduce((sum, width) => sum + width, 0);
292
+ // 가상 스크롤 영역의 너비 계산
293
+ const virtualScrollableWidth = containerWidth - stickyLeftWidth - stickyRightWidth;
294
+ const virtualColumnWidths = this.columnWidths.slice(stickyLeftCount, this.visibleColumns.length - stickyRightCount);
295
+ const virtualScrollLeft = Math.max(0, scrollLeft - stickyLeftWidth);
296
+ const reducedVirtualWidth = virtualColumnWidths.reduce((acc, width, idx) => {
297
+ acc.push((acc[idx - 1] || 0) + width);
298
+ return acc;
299
+ }, []);
300
+ let startIdx = 0; // 가상 스크롤 시작 인덱스
301
+ let endIdx = virtualColumns.length - 1; // 가상 스크롤 종료 인덱스
302
+ // sticky left 영역 제외한 스크롤 위치
303
+ for (let i = 0; i < reducedVirtualWidth.length; i++) {
304
+ if (reducedVirtualWidth[i] > virtualScrollLeft) {
305
+ startIdx = Math.max(0, i);
306
+ break;
307
+ }
308
+ }
309
+ const scrollRight = virtualScrollLeft + virtualScrollableWidth;
310
+ for (let i = startIdx; i < reducedVirtualWidth.length; i++) {
311
+ if (reducedVirtualWidth[i] >= scrollRight) {
312
+ endIdx = Math.min(virtualColumns.length - 1, i);
313
+ break;
314
+ }
315
+ }
316
+ const bufferSize = this.virtualBufferSize.horizontal || 5;
317
+ this.virtualStartColIdx = Math.max(0, startIdx - bufferSize);
318
+ this.virtualEndColIdx = Math.min(virtualColumns.length - 1, endIdx + bufferSize);
212
319
  }
213
320
  // ----- Helpers -----
214
321
  getStickyStyle(colIdx) {
@@ -251,34 +358,71 @@ export class SdTable {
251
358
  const value = typeof field === 'function' ? field(row) : field ? row[field] : row[name];
252
359
  return format ? format(value, row) : value;
253
360
  }
361
+ getColumnRenderedInOrder() {
362
+ const stickyLeftCount = this.stickyColumn.left || 0;
363
+ const stickyRightCount = this.stickyColumn.right || 0;
364
+ // Sticky left 컬럼들
365
+ const stickyLeftCols = this.visibleColumns.slice(0, stickyLeftCount);
366
+ const stickyRightCols = this.visibleColumns.slice(this.visibleColumns.length - stickyRightCount);
367
+ const middleCols = this.useVirtualScroll.horizontal
368
+ ? this.visibleColumns
369
+ .slice(stickyLeftCount, this.visibleColumns.length - stickyRightCount)
370
+ .slice(this.virtualStartColIdx, this.virtualEndColIdx + 1)
371
+ : this.visibleColumns.slice(stickyLeftCount, this.visibleColumns.length - stickyRightCount);
372
+ return {
373
+ stickyLeftCount,
374
+ stickyRightCount,
375
+ stickyLeftCols,
376
+ middleCols,
377
+ stickyRightCols,
378
+ };
379
+ }
254
380
  // ----- Render -----
255
- renderHeader() {
381
+ renderHead() {
382
+ const { stickyLeftCount, stickyRightCount, stickyLeftCols, middleCols, stickyRightCols } = this.getColumnRenderedInOrder();
256
383
  return (h("thead", null, h("tr", null, this.selectable && (h("th", { class: {
257
384
  'sd-th': true,
258
385
  'sd-th--selected': true,
259
386
  'sticky-left': Boolean(this.stickyColumn.left && this.stickyColumn.left > 0),
260
387
  }, style: {
261
388
  '--sticky-left-offset': '0px',
262
- } }, h("sd-checkbox", { checked: this.isAllChecked, disabled: !this.paginatedRows.length, onSdChange: (e) => this.toggleSelectAll(e.detail) }))), this.visibleColumns.map((col, colIdx) => (h("th", { key: col.name, class: {
263
- 'sd-th': true,
264
- [`${col.thClass}`]: Boolean(col.thClass),
265
- 'sticky-left': Boolean(this.stickyColumn.left && colIdx < this.stickyColumn.left),
266
- 'sticky-right': Boolean(this.stickyColumn.right && colIdx >= this.visibleColumns.length - this.stickyColumn.right),
267
- 'sticky-left-edge': Boolean(this.stickyColumn.left && colIdx === this.stickyColumn.left - 1),
268
- 'sticky-right-edge': Boolean(this.stickyColumn.right &&
269
- colIdx === this.visibleColumns.length - this.stickyColumn.right),
270
- }, style: { ...col.thStyle, ...this.getStickyStyle(colIdx) } }, h("div", { class: `sd-th__content sd-th__content--${col.align || 'left'}` }, h("slot", { name: `header-cell-${col.name}` }, h("div", { class: "sd-th__content--label" }, col.label)), col.usePageMoveIcon && h("sd-icon", { name: "pageMove", size: "12", color: "#006AC1" }), col.tooltip && (h("sd-tooltip", { ...col.tooltipOptions }, h("div", { slot: "content" }, col.tooltip.map(text => (h("p", null, text))))))), this.resizable && typeof window !== 'undefined' && (h("div", { class: "sd-th__resizer", onMouseDown: (evt) => this.handleResize(colIdx, evt) }))))))));
389
+ } }, h("sd-checkbox", { checked: this.isAllChecked, disabled: !this.paginatedRows.length, onSdChange: (e) => this.toggleSelectAll(e.detail) }))), stickyLeftCols.map((col, idx) => {
390
+ const rendered = this.headerCellRenderer?.(col);
391
+ return (h("th", { key: col.name, class: {
392
+ 'sd-th': true,
393
+ [`${col.thClass}`]: Boolean(col.thClass),
394
+ 'sticky-left': true,
395
+ 'sticky-left-edge': idx === stickyLeftCount - 1,
396
+ }, style: { ...col.thStyle, ...this.getStickyStyle(idx) } }, h("div", { class: `sd-th__content sd-th__content--${col.align || 'left'}` }, h("slot", { name: `header-cell-${col.name}` }, h("div", { class: "sd-th__content--label" }, rendered ? (typeof rendered === 'string' ? (h("span", { innerHTML: rendered })) : (rendered)) : (col.label))), col.usePageMoveIcon && h("sd-icon", { name: "pageMove", size: "12", color: "#006AC1" }), col.tooltip && (h("sd-tooltip", { ...col.tooltipOptions }, h("div", { slot: "content" }, col.tooltip.map(text => (h("p", null, text))))))), this.resizable && typeof window !== 'undefined' && (h("div", { class: "sd-th__resizer", onMouseDown: (evt) => this.handleResize(idx, evt) }))));
397
+ }), this.renderSpacerTd('left', -1), middleCols.map((col, relativeIdx) => {
398
+ const actualColIdx = stickyLeftCount + this.virtualStartColIdx + relativeIdx;
399
+ const rendered = this.headerCellRenderer?.(col);
400
+ return (h("th", { key: col.name, class: {
401
+ 'sd-th': true,
402
+ [`${col.thClass}`]: Boolean(col.thClass),
403
+ }, style: { ...col.thStyle, ...this.getStickyStyle(actualColIdx) } }, h("div", { class: `sd-th__content sd-th__content--${col.align || 'left'}` }, h("slot", { name: `header-cell-${col.name}` }, h("div", { class: "sd-th__content--label" }, rendered ? (typeof rendered === 'string' ? (h("span", { innerHTML: rendered })) : (rendered)) : (col.label))), col.usePageMoveIcon && h("sd-icon", { name: "pageMove", size: "12", color: "#006AC1" }), col.tooltip && (h("sd-tooltip", { ...col.tooltipOptions }, h("div", { slot: "content" }, col.tooltip.map(text => (h("p", null, text))))))), this.resizable && typeof window !== 'undefined' && (h("div", { class: "sd-th__resizer", onMouseDown: (evt) => this.handleResize(actualColIdx, evt) }))));
404
+ }), this.renderSpacerTd('right', -1), stickyRightCols.map((col, relativeIdx) => {
405
+ const actualColIdx = this.visibleColumns.length - stickyRightCount + relativeIdx;
406
+ const rendered = this.headerCellRenderer?.(col);
407
+ return (h("th", { key: col.name, class: {
408
+ 'sd-th': true,
409
+ [`${col.thClass}`]: Boolean(col.thClass),
410
+ 'sticky-right': true,
411
+ 'sticky-right-edge': relativeIdx === 0,
412
+ }, style: { ...col.thStyle, ...this.getStickyStyle(actualColIdx) } }, h("div", { class: `sd-th__content sd-th__content--${col.align || 'left'}` }, h("slot", { name: `header-cell-${col.name}` }, h("div", { class: "sd-th__content--label" }, rendered ? (typeof rendered === 'string' ? (h("span", { innerHTML: rendered })) : (rendered)) : (col.label))), col.usePageMoveIcon && h("sd-icon", { name: "pageMove", size: "12", color: "#006AC1" }), col.tooltip && (h("sd-tooltip", { ...col.tooltipOptions }, h("div", { slot: "content" }, col.tooltip.map(text => (h("p", null, text))))))), this.resizable && typeof window !== 'undefined' && (h("div", { class: "sd-th__resizer", onMouseDown: (evt) => this.handleResize(actualColIdx, evt) }))));
413
+ }))));
271
414
  }
272
415
  renderBody() {
273
- return (h("tbody", { ...(!this.paginatedRows.length && { part: 'tbody-empty' }), class: `sd-table-tbody ${this.useVirtualScroll ? 'sd-table-tbody--virtual-scroll' : ''}`, style: { '--total-virtual-height': `${this.totalVirtualHeight}px` } }, this.isLoading && (h("div", { class: "sd-table__loading" }, h("sd-loading-spinner", null))), this.useVirtualScroll && this.topSpacerHeight > 0 && (h("tr", { key: "virtual-top-spacer", style: {
416
+ return (h("tbody", { ...(!this.paginatedRows.length && { part: 'tbody-empty' }), class: `sd-table-tbody ${this.useVirtualScroll.vertical ? 'sd-table-tbody--virtual-scroll' : ''}`, style: { '--total-virtual-height': `${this.totalVirtualHeight}px` } }, this.isLoading && (h("div", { class: "sd-table__loading" }, h("sd-loading-spinner", null))), this.useVirtualScroll.vertical && this.topSpacerHeight > 0 && (h("tr", { key: "virtual-top-spacer", class: "sd-table__virtual-row-spacer", style: {
274
417
  height: `${this.topSpacerHeight}px`,
275
- }, "aria-hidden": "true" })), this.paginatedRows.length > 0 &&
276
- this.virtualRows.map(({ row, actualIndex }) => this.renderRow(row, actualIndex)), this.useVirtualScroll && this.bottomSpacerHeight > 0 && (h("tr", { key: "virtual-bottom-spacer", style: {
418
+ }, "aria-hidden": "true" }, h("td", { colSpan: this.visibleColumns.length + (this.selectable ? 1 : 0) }, h("div", { class: "sd-table__skeleton" })))), this.paginatedRows.length > 0 &&
419
+ this.virtualRows.map(({ row, actualIndex }) => this.renderRow(row, actualIndex)), this.useVirtualScroll.vertical && this.bottomSpacerHeight > 0 && (h("tr", { key: "virtual-bottom-spacer", class: "sd-table__virtual-row-spacer", style: {
277
420
  height: `${this.bottomSpacerHeight}px`,
278
- }, "aria-hidden": "true" }))));
421
+ }, "aria-hidden": "true" }, h("td", { colSpan: this.visibleColumns.length + (this.selectable ? 1 : 0) }, h("div", { class: "sd-table__skeleton" }))))));
279
422
  }
280
423
  renderRow(row, rowIdx) {
281
- return (h("tr", { key: row[this.rowKey], class: "hover:bg-Grey_Lighten-6", style: this.useVirtualScroll
424
+ const { stickyLeftCount, stickyRightCount, stickyLeftCols, middleCols, stickyRightCols } = this.getColumnRenderedInOrder();
425
+ return (h("tr", { key: row[this.rowKey], class: "hover:bg-Grey_Lighten-6", style: this.useVirtualScroll.vertical
282
426
  ? {
283
427
  height: `${this.virtualRowHeight}px`,
284
428
  }
@@ -288,29 +432,61 @@ export class SdTable {
288
432
  'sticky-left': Boolean(this.stickyColumn.left && this.stickyColumn.left > 0),
289
433
  }, style: {
290
434
  '--sticky-left-offset': '0px',
291
- } }, h("sd-checkbox", { checked: this.isRowSelected(row), disabled: !this.paginatedRows.length, onSdChange: () => this.updateRowSelect(row) }))), this.visibleColumns.map((column, colIdx) => {
435
+ } }, h("sd-checkbox", { checked: this.isRowSelected(row), disabled: !this.paginatedRows.length, onSdChange: () => this.updateRowSelect(row) }))), stickyLeftCols.map((column, idx) => {
436
+ const rendered = this.bodyCellRenderer?.(column, row);
437
+ return (h("td", { key: column.name, part: `td-${column.name}`, class: {
438
+ 'sd-td': true,
439
+ [`sd-td--${column.align || 'left'}`]: true,
440
+ 'sticky-left': true,
441
+ 'sticky-left-edge': idx === stickyLeftCount - 1,
442
+ [`${column.tdClass}`]: Boolean(column.tdClass),
443
+ }, style: this.getStickyStyle(idx) }, h("slot", { name: `body-cell-${column.name}-${rowIdx}` }, rendered ? (typeof rendered === 'string' ? (h("span", { innerHTML: rendered })) : (rendered)) : (this.getCellValue(column, row)))));
444
+ }), this.renderSpacerTd('left', rowIdx), middleCols.map((column, relativeIdx) => {
445
+ const actualColIdx = stickyLeftCount + this.virtualStartColIdx + relativeIdx;
292
446
  const rendered = this.bodyCellRenderer?.(column, row);
293
447
  return (h("td", { key: column.name, part: `td-${column.name}`, class: {
294
448
  'sd-td': true,
295
449
  [`sd-td--${column.align || 'left'}`]: true,
296
- 'sticky-left': Boolean(this.stickyColumn.left && colIdx < this.stickyColumn.left),
297
- 'sticky-right': Boolean(this.stickyColumn.right && colIdx >= this.visibleColumns.length - this.stickyColumn.right),
298
- 'sticky-left-edge': Boolean(this.stickyColumn.left && colIdx === this.stickyColumn.left - 1),
299
- 'sticky-right-edge': Boolean(this.stickyColumn.right &&
300
- colIdx === this.visibleColumns.length - this.stickyColumn.right),
301
450
  [`${column.tdClass}`]: Boolean(column.tdClass),
302
- }, style: this.getStickyStyle(colIdx) }, h("slot", { name: `body-cell-${column.name}-${rowIdx}` }, rendered ? (typeof rendered === 'string' ? (h("span", { innerHTML: rendered })) : (rendered)) : (this.getCellValue(column, row)))));
451
+ }, style: this.getStickyStyle(actualColIdx) }, h("slot", { name: `body-cell-${column.name}-${rowIdx}` }, rendered ? (typeof rendered === 'string' ? (h("span", { innerHTML: rendered })) : (rendered)) : (this.getCellValue(column, row)))));
452
+ }), this.renderSpacerTd('right', rowIdx), stickyRightCols.map((column, relativeIdx) => {
453
+ const actualColIdx = this.visibleColumns.length - stickyRightCount + relativeIdx;
454
+ const rendered = this.bodyCellRenderer?.(column, row);
455
+ return (h("td", { key: column.name, part: `td-${column.name}`, class: {
456
+ 'sd-td': true,
457
+ [`sd-td--${column.align || 'left'}`]: true,
458
+ 'sticky-right': true,
459
+ 'sticky-right-edge': relativeIdx === 0,
460
+ [`${column.tdClass}`]: Boolean(column.tdClass),
461
+ }, style: this.getStickyStyle(actualColIdx) }, h("slot", { name: `body-cell-${column.name}-${rowIdx}` }, rendered ? (typeof rendered === 'string' ? (h("span", { innerHTML: rendered })) : (rendered)) : (this.getCellValue(column, row)))));
303
462
  })));
304
463
  }
464
+ renderSpacerTd(position, rowIdx) {
465
+ const spacerWidth = position === 'left' ? this.leftSpacerWidth : this.rightSpacerWidth;
466
+ const showSpacer = position === 'left'
467
+ ? this.useVirtualScroll.horizontal && this.leftSpacerWidth > 0
468
+ : this.useVirtualScroll.horizontal && this.rightSpacerWidth > 0;
469
+ if (!showSpacer)
470
+ return null;
471
+ return (h("td", { key: `virtual-${position}-spacer-${rowIdx}`, class: "sd-table__virtual-spacer", style: {
472
+ width: `${spacerWidth}px`,
473
+ minWidth: `${spacerWidth}px`,
474
+ maxWidth: `${spacerWidth}px`,
475
+ padding: '0',
476
+ border: 'none',
477
+ }, "aria-hidden": "true" }, h("div", { class: "sd-table__skeleton" })));
478
+ }
305
479
  render() {
306
- return (h(Host, { key: 'd197993fd67107e7a7d310cdc2f3c58a1edf988f' }, h("div", { key: '8176782d6413f05b8b088a35942c31c37584ea0d', class: "sd-table__wrapper", style: {
480
+ return (h(Host, { key: '06caa893329f7de501804922dea824c01fc393bb' }, h("div", { key: '7b806f1fa25c60e11dd22cf67177c4856a576e76', class: "sd-table__wrapper", style: {
307
481
  '--table-width': this.width,
308
482
  '--table-height': this.height,
309
- } }, h("div", { key: '9b158db9adedb593ecc1b6f024d237575a30be83', class: "sd-table__container" }, h("div", { key: '2152375a11adfde7ab0f5209bf86fde80b245ca7', class: {
483
+ } }, h("div", { key: '6d24df1310c746fe7742dbeee3750d62bd286c25', class: "sd-table__container", style: {
484
+ '--table-container-height': `calc(${this.height} - ${this.pagination && this.innerRows.length > 0 ? 48 : 0}px)`,
485
+ } }, h("div", { key: 'de042c2e56baa207d1602b6d9cdcbe7d2c2780dd', class: {
310
486
  'sd-table__middle': true,
311
487
  'sd-table__middle--scrollable': this.paginatedRows.length > 0,
312
488
  'sd-table__middle--loading': this.isLoading,
313
- } }, h("table", { key: '024cffa35522fd73f53a873aef9679bcd53705ba', part: "table", class: this.sdTableClasses }, this.renderHeader(), this.renderBody())), h("div", { key: '05c66542866f68d96af6dd530f051e5054d5b6a0', class: "sd-table__bottom" }, !this.paginatedRows.length && (h("div", { key: '09ed3481961c68427b85e5e973b1a94c30188af6', class: "sd-table__no-data" }, h("slot", { key: 'e754ed759750cfc3ac61c3b59ccc897cb263ea1b', name: "no-data" }, this.noDataLabel))))), this.pagination && this.innerRows.length > 0 && (h("div", { key: '390141abc35cd0bbc4c261943084e9f5ccd27c78', class: "sd-table__pagination" }, h("sd-pagination", { key: 'fa55c8ed7fc1cc811231fa4266e0021f8b03fc51', currentPage: !this.useInternalPagination ? this.pagination.page : this.currentPage, lastPage: !this.useInternalPagination ? this.pagination.lastPage : this.lastPageNumber, onPageChange: (e) => {
489
+ } }, h("table", { key: 'f392dbedf10677e704e0dd6fc1233dc931e2e017', part: "table", class: this.sdTableClasses }, this.renderHead(), this.renderBody())), h("div", { key: '99fa9cff08bd0599a63a34caba645e9893ea963d', class: "sd-table__bottom" }, !this.paginatedRows.length && (h("div", { key: '3e135dd33d5188abbe753b03c9a0c6c6f38210dc', class: "sd-table__no-data" }, h("slot", { key: '144d91b72af6ca2b966e7d3de783eb09f6880b20', name: "no-data" }, this.noDataLabel))))), this.pagination && this.innerRows.length > 0 && (h("div", { key: '0ce235dc30c09823f3bc37b47dfd4d1941d3dbd8', class: "sd-table__pagination" }, h("sd-pagination", { key: 'e68be3464a8e8c6e99290e6ec3308d22c4238738', currentPage: !this.useInternalPagination ? this.pagination.page : this.currentPage, lastPage: !this.useInternalPagination ? this.pagination.lastPage : this.lastPageNumber, onPageChange: (e) => {
314
490
  if (!this.useInternalPagination) {
315
491
  this.sdPageChange.emit(e.detail);
316
492
  }
@@ -318,7 +494,7 @@ export class SdTable {
318
494
  this.currentPage = e.detail;
319
495
  this.sdPageChange.emit(this.currentPage);
320
496
  }
321
- } }), this.useRowsPerPageSelect && (h("sd-select", { key: 'c2463db21492100f4f78b87cac9fe62bcfaca9a2', value: this.pagination.rowsPerPage, options: this.rowsPerPageOption, width: "128px", onSdChange: (e) => {
497
+ } }), this.useRowsPerPageSelect && (h("sd-select", { key: 'ba48f26b761cd65c5f52f4b4734be6c2a55120f1', value: this.pagination.rowsPerPage, options: this.rowsPerPageOption, width: "128px", onSdChange: (e) => {
322
498
  const changedRowsPerPage = e.detail.value ? Number(e.detail.value) : 0;
323
499
  if (!this.useInternalPagination) {
324
500
  this.sdRowsPerPageChange.emit(changedRowsPerPage);
@@ -620,6 +796,33 @@ export class SdTable {
620
796
  "getter": false,
621
797
  "setter": false
622
798
  },
799
+ "headerCellRenderer": {
800
+ "type": "unknown",
801
+ "mutable": false,
802
+ "complexType": {
803
+ "original": "(column: SdTableColumn) => HTMLElement | string | null | undefined",
804
+ "resolved": "((column: SdTableColumn) => string | HTMLElement | null | undefined) | undefined",
805
+ "references": {
806
+ "SdTableColumn": {
807
+ "location": "local",
808
+ "path": "/Users/meijing/Documents/sellmate/frontend/design-system/packages/stencil/src/components/sd-table-backup/sd-table-backup.tsx",
809
+ "id": "src/components/sd-table-backup/sd-table-backup.tsx::SdTableColumn"
810
+ },
811
+ "HTMLElement": {
812
+ "location": "global",
813
+ "id": "global::HTMLElement"
814
+ }
815
+ }
816
+ },
817
+ "required": false,
818
+ "optional": true,
819
+ "docs": {
820
+ "tags": [],
821
+ "text": ""
822
+ },
823
+ "getter": false,
824
+ "setter": false
825
+ },
623
826
  "bodyCellRenderer": {
624
827
  "type": "unknown",
625
828
  "mutable": false,
@@ -717,11 +920,11 @@ export class SdTable {
717
920
  "defaultValue": "[\n { label: '10\uAC1C\uC529 \uBCF4\uAE30', value: 10 },\n { label: '25\uAC1C\uC529 \uBCF4\uAE30', value: 25 },\n { label: '50\uAC1C\uC529 \uBCF4\uAE30', value: 50 },\n { label: '100\uAC1C\uC529 \uBCF4\uAE30', value: 100 },\n ]"
718
921
  },
719
922
  "useVirtualScroll": {
720
- "type": "boolean",
923
+ "type": "unknown",
721
924
  "mutable": false,
722
925
  "complexType": {
723
- "original": "boolean",
724
- "resolved": "boolean",
926
+ "original": "{ vertical?: boolean; horizontal?: boolean }",
927
+ "resolved": "{ vertical?: boolean | undefined; horizontal?: boolean | undefined; }",
725
928
  "references": {}
726
929
  },
727
930
  "required": false,
@@ -732,9 +935,7 @@ export class SdTable {
732
935
  },
733
936
  "getter": false,
734
937
  "setter": false,
735
- "reflect": false,
736
- "attribute": "use-virtual-scroll",
737
- "defaultValue": "false"
938
+ "defaultValue": "{}"
738
939
  },
739
940
  "virtualRowHeight": {
740
941
  "type": "number",
@@ -756,7 +957,7 @@ export class SdTable {
756
957
  "attribute": "virtual-row-height",
757
958
  "defaultValue": "44"
758
959
  },
759
- "virtualBufferSize": {
960
+ "virtualColumnWidth": {
760
961
  "type": "number",
761
962
  "mutable": false,
762
963
  "complexType": {
@@ -773,8 +974,26 @@ export class SdTable {
773
974
  "getter": false,
774
975
  "setter": false,
775
976
  "reflect": false,
776
- "attribute": "virtual-buffer-size",
777
- "defaultValue": "5"
977
+ "attribute": "virtual-column-width",
978
+ "defaultValue": "120"
979
+ },
980
+ "virtualBufferSize": {
981
+ "type": "unknown",
982
+ "mutable": false,
983
+ "complexType": {
984
+ "original": "{ vertical?: number; horizontal?: number }",
985
+ "resolved": "{ vertical?: number | undefined; horizontal?: number | undefined; }",
986
+ "references": {}
987
+ },
988
+ "required": false,
989
+ "optional": false,
990
+ "docs": {
991
+ "tags": [],
992
+ "text": ""
993
+ },
994
+ "getter": false,
995
+ "setter": false,
996
+ "defaultValue": "{\n vertical: 5,\n horizontal: 5,\n }"
778
997
  }
779
998
  };
780
999
  }
@@ -788,7 +1007,10 @@ export class SdTable {
788
1007
  "scrolledRight": {},
789
1008
  "virtualStartIndex": {},
790
1009
  "virtualEndIndex": {},
791
- "scrollTopPosition": {}
1010
+ "scrollTopPosition": {},
1011
+ "virtualStartColIdx": {},
1012
+ "virtualEndColIdx": {},
1013
+ "scrollLeftPosition": {}
792
1014
  };
793
1015
  }
794
1016
  static get events() {
@@ -850,6 +1072,9 @@ export class SdTable {
850
1072
  return [{
851
1073
  "propName": "columns",
852
1074
  "methodName": "handleColumnsChange"
1075
+ }, {
1076
+ "propName": "columnWidths",
1077
+ "methodName": "handleColumnWidthsChange"
853
1078
  }, {
854
1079
  "propName": "rows",
855
1080
  "methodName": "handleRowsChange"