@ehfuse/mui-virtual-data-table 1.0.7 → 1.0.9

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/dist/index.js CHANGED
@@ -1,1157 +1,4 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var material = require('@mui/material');
6
- var reactVirtuoso = require('react-virtuoso');
7
-
8
- /******************************************************************************
9
- Copyright (c) Microsoft Corporation.
10
-
11
- Permission to use, copy, modify, and/or distribute this software for any
12
- purpose with or without fee is hereby granted.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
15
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
16
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
17
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
18
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
19
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
- PERFORMANCE OF THIS SOFTWARE.
21
- ***************************************************************************** */
22
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
23
-
24
-
25
- var __assign = function() {
26
- __assign = Object.assign || function __assign(t) {
27
- for (var s, i = 1, n = arguments.length; i < n; i++) {
28
- s = arguments[i];
29
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
30
- }
31
- return t;
32
- };
33
- return __assign.apply(this, arguments);
34
- };
35
-
36
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
37
- var e = new Error(message);
38
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
39
- };
40
-
41
- function LoadingProgress(_a) {
42
- var visible = _a.visible, onComplete = _a.onComplete, _b = _a.fadeoutDuration, fadeoutDuration = _b === void 0 ? 200 : _b, _c = _a.exitDelay, exitDelay = _c === void 0 ? 0 : _c, _d = _a.size, size = _d === void 0 ? 40 : _d, className = _a.className, style = _a.style, sx = _a.sx, indicator = _a.indicator, _e = _a.background, background = _e === void 0 ? {
43
- show: true,
44
- color: "255, 255, 255",
45
- opacity: 0.9,
46
- } : _e;
47
- var prevVisibleRef = react.useRef(undefined);
48
- var boxRef = react.useRef(null);
49
- var _f = react.useState(visible), shouldRender = _f[0], setShouldRender = _f[1];
50
- // 배경 설정 기본값 처리
51
- var _g = background.show, showBackground = _g === void 0 ? true : _g, _h = background.color, backgroundColor = _h === void 0 ? "255, 255, 255" : _h, _j = background.opacity, backgroundOpacity = _j === void 0 ? 0.9 : _j;
52
- react.useEffect(function () {
53
- var prevVisible = prevVisibleRef.current;
54
- // visible이 true에서 false로 변경될 때 페이드아웃 후 onComplete 호출
55
- if (prevVisible === true && visible === false && boxRef.current) {
56
- // CSS transition으로 페이드아웃 시작
57
- var box = boxRef.current;
58
- box.style.opacity = "0";
59
- // fadeoutDuration + exitDelay 후 onComplete 호출 및 언마운트
60
- setTimeout(function () {
61
- setShouldRender(false); // 페이드아웃 완료 후 언마운트
62
- onComplete === null || onComplete === void 0 ? void 0 : onComplete();
63
- }, fadeoutDuration + exitDelay);
64
- }
65
- else if (visible === true) {
66
- // visible이 true가 되면 다시 렌더링하고 opacity 복원
67
- setShouldRender(true);
68
- if (boxRef.current) {
69
- boxRef.current.style.opacity = "1";
70
- }
71
- }
72
- // 현재 visible 값을 ref에 저장
73
- prevVisibleRef.current = visible;
74
- }, [visible, onComplete, fadeoutDuration, exitDelay]);
75
- if (!shouldRender) {
76
- return null;
77
- }
78
- // indicator 렌더링 로직
79
- var renderIndicator = function () {
80
- // string이면 이미지 URL로 간주
81
- if (typeof indicator === "string") {
82
- return (jsxRuntime.jsx("img", { src: indicator, alt: "Loading", style: { width: size, height: size } }));
83
- }
84
- // ReactNode가 제공되면 그대로 렌더링
85
- if (indicator) {
86
- return indicator;
87
- }
88
- // 기본값: MUI CircularProgress
89
- return jsxRuntime.jsx(material.CircularProgress, { size: size });
90
- };
91
- // 배경색 처리: 다양한 색상 형식 지원
92
- var getBackgroundStyle = function () {
93
- if (!showBackground) {
94
- return { backgroundColor: "transparent" };
95
- }
96
- // 이미 rgba 형식이면 그대로 사용
97
- if (backgroundColor.startsWith("rgba")) {
98
- return { backgroundColor: backgroundColor };
99
- }
100
- // RGB 문자열 형식 (예: "255, 255, 255")
101
- if (/^\d+,\s*\d+,\s*\d+$/.test(backgroundColor)) {
102
- return {
103
- backgroundColor: "rgba(".concat(backgroundColor, ", ").concat(backgroundOpacity, ")"),
104
- };
105
- }
106
- // hex, rgb(), named color 등의 경우
107
- // CSS에서 color와 opacity를 함께 사용
108
- if (backgroundOpacity !== 1) {
109
- return {
110
- backgroundColor: backgroundColor,
111
- // 배경에만 opacity를 적용하기 위해 before pseudo-element 사용하거나
112
- // 직접 rgba로 변환하는 대신 CSS custom property 사용
113
- "&::before": {
114
- content: '""',
115
- position: "absolute",
116
- top: 0,
117
- left: 0,
118
- right: 0,
119
- bottom: 0,
120
- backgroundColor: backgroundColor,
121
- opacity: backgroundOpacity,
122
- zIndex: -1,
123
- },
124
- };
125
- }
126
- // opacity가 1이면 그냥 색상만
127
- return { backgroundColor: backgroundColor };
128
- };
129
- return (jsxRuntime.jsx(material.Box, { ref: boxRef, className: className, style: __assign({}, style), sx: __assign(__assign({ position: "absolute", top: 0, left: 0, right: 0, bottom: 0, display: "flex", alignItems: "center", justifyContent: "center", zIndex: 1000, opacity: visible ? 1 : 0, transition: "opacity ".concat(fadeoutDuration, "ms ease-out") }, getBackgroundStyle()), sx), children: renderIndicator() }));
130
- }
131
-
132
- /**
133
- * MIT License
134
- *
135
- * Copyright (c) 2025 KIM YOUNG JIN (ehfuse@gmail.com)
136
- *
137
- * Permission is hereby granted, free of charge, to any person obtaining a copy
138
- * of this software and associated documentation files (the "Software"), to deal
139
- * in the Software without restriction, including without limitation the rights
140
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
141
- * copies of the Software, and to permit persons to whom the Software is
142
- * furnished to do so, subject to the following conditions:
143
- *
144
- * The above copyright notice and this permission notice shall be included in all
145
- * copies or substantial portions of the Software.
146
- *
147
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
148
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
149
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
150
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
151
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
152
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
153
- * SOFTWARE.
154
- */
155
- // 드래그 스크롤을 제외할 클래스들 (자신 또는 부모 요소에서 확인)
156
- const DEFAULT_EXCLUDE_CLASSES = [
157
- // 기본 입력 요소들
158
- "editor",
159
- "textarea",
160
- "input",
161
- "select",
162
- "textfield",
163
- "form-control",
164
- "contenteditable",
165
- // Material-UI 컴포넌트들
166
- "MuiInputBase-input",
167
- "MuiSelect-select",
168
- "MuiOutlinedInput-input",
169
- "MuiFilledInput-input",
170
- "MuiInput-input",
171
- "MuiFormControl-root",
172
- "MuiTextField-root",
173
- "MuiSelect-root",
174
- "MuiOutlinedInput-root",
175
- "MuiFilledInput-root",
176
- "MuiInput-root",
177
- "MuiAutocomplete-input",
178
- "MuiDatePicker-input",
179
- "MuiSlider-thumb",
180
- "MuiSlider-rail",
181
- "MuiSlider-track",
182
- "MuiSlider-mark",
183
- "MuiSlider-markLabel",
184
- "MuiSlider-root",
185
- "MuiSlider-colorPrimary",
186
- "MuiSlider-sizeMedium",
187
- "MuiIconButton-root",
188
- "MuiButton-root",
189
- "MuiButtonBase-root",
190
- "MuiTouchRipple-root",
191
- "MuiCheckbox-root",
192
- "MuiRadio-root",
193
- "MuiSwitch-root",
194
- "PrivateSwitchBase-root",
195
- // Ant Design 컴포넌트들
196
- "ant-input",
197
- "ant-input-affix-wrapper",
198
- "ant-input-group-addon",
199
- "ant-input-number",
200
- "ant-input-number-handler",
201
- "ant-select",
202
- "ant-select-selector",
203
- "ant-select-selection-search",
204
- "ant-select-dropdown",
205
- "ant-cascader",
206
- "ant-cascader-input",
207
- "ant-picker",
208
- "ant-picker-input",
209
- "ant-time-picker",
210
- "ant-calendar-picker",
211
- "ant-slider",
212
- "ant-slider-track",
213
- "ant-slider-handle",
214
- "ant-switch",
215
- "ant-checkbox",
216
- "ant-checkbox-wrapper",
217
- "ant-radio",
218
- "ant-radio-wrapper",
219
- "ant-rate",
220
- "ant-upload",
221
- "ant-upload-drag",
222
- "ant-form-item",
223
- "ant-form-item-control",
224
- "ant-btn",
225
- "ant-dropdown",
226
- "ant-dropdown-trigger",
227
- "ant-menu",
228
- "ant-menu-item",
229
- "ant-tooltip",
230
- "ant-popover",
231
- "ant-modal",
232
- "ant-drawer",
233
- "ant-tree-select",
234
- "ant-auto-complete",
235
- "ant-mentions",
236
- "ant-transfer",
237
- // Shadcn/ui 컴포넌트들
238
- "ui-input",
239
- "ui-textarea",
240
- "ui-select",
241
- "ui-select-trigger",
242
- "ui-select-content",
243
- "ui-select-item",
244
- "ui-button",
245
- "ui-checkbox",
246
- "ui-radio-group",
247
- "ui-switch",
248
- "ui-slider",
249
- "ui-range-slider",
250
- "ui-calendar",
251
- "ui-date-picker",
252
- "ui-combobox",
253
- "ui-command",
254
- "ui-command-input",
255
- "ui-popover",
256
- "ui-dialog",
257
- "ui-sheet",
258
- "ui-dropdown-menu",
259
- "ui-context-menu",
260
- "ui-menubar",
261
- "ui-navigation-menu",
262
- "ui-form",
263
- "ui-form-control",
264
- "ui-form-item",
265
- "ui-form-field",
266
- "ui-label",
267
- // Radix UI 기본 클래스들 (Shadcn 기반)
268
- "radix-ui",
269
- "radix-select",
270
- "radix-dropdown",
271
- "radix-dialog",
272
- "radix-popover",
273
- "radix-accordion",
274
- "radix-tabs",
275
- "radix-slider",
276
- "radix-switch",
277
- "radix-checkbox",
278
- "radix-radio",
279
- // Quill Editor
280
- "ql-editor",
281
- "ql-container",
282
- "ql-toolbar",
283
- "ql-picker",
284
- "ql-picker-label",
285
- "ql-picker-options",
286
- "ql-formats",
287
- "ql-snow",
288
- "ql-bubble",
289
- "quill",
290
- "quilleditor",
291
- // Monaco Editor
292
- "monaco-editor",
293
- "monaco-editor-background",
294
- "view-lines",
295
- "decorationsOverviewRuler",
296
- "monaco-scrollable-element",
297
- // CodeMirror
298
- "CodeMirror",
299
- "CodeMirror-code",
300
- "CodeMirror-lines",
301
- "CodeMirror-scroll",
302
- "CodeMirror-sizer",
303
- "cm-editor",
304
- "cm-focused",
305
- "cm-content",
306
- // TinyMCE
307
- "tox-editor-container",
308
- "tox-editor-header",
309
- "tox-edit-area",
310
- "tox-tinymce",
311
- "mce-content-body",
312
- // CKEditor
313
- "ck-editor",
314
- "ck-content",
315
- "ck-toolbar",
316
- "ck-editor__editable",
317
- "ck-widget",
318
- // Slate.js
319
- "slate-editor",
320
- "slate-content",
321
- // Draft.js
322
- "DraftEditor-root",
323
- "DraftEditor-editorContainer",
324
- "public-DraftEditor-content",
325
- // EhfuseEditor
326
- "ehfuse-editor",
327
- "ehfuse-editor-wrapper",
328
- "ehfuse-editor-content",
329
- "ehfuse-toolbar",
330
- "ehfuse-toolbar-group",
331
- "ehfuse-cursor",
332
- // 기타 에디터들
333
- "text-editor",
334
- "rich-text-editor",
335
- "wysiwyg",
336
- "ace_editor",
337
- "ace_content",
338
- ];
339
- /**
340
- * 드래그 스크롤이 허용되지 않는 요소들인지 확인
341
- */
342
- /**
343
- * 드래그 스크롤이 허용되지 않는 요소들인지 확인
344
- */
345
- const isTextInputElement = (element, config) => {
346
- const tagName = element.tagName.toLowerCase();
347
- const inputTypes = [
348
- "text",
349
- "password",
350
- "email",
351
- "number",
352
- "search",
353
- "tel",
354
- "url",
355
- "checkbox",
356
- "radio",
357
- ];
358
- // input 태그이면서 텍스트 입력 타입이나 체크박스/라디오인 경우
359
- if (tagName === "input") {
360
- const type = element.type;
361
- return inputTypes.includes(type);
362
- }
363
- // textarea, select, 편집 가능한 요소들
364
- if (["textarea", "select", "button"].includes(tagName)) {
365
- return true;
366
- }
367
- // SVG 요소들 (아이콘들)
368
- if ([
369
- "svg",
370
- "path",
371
- "circle",
372
- "rect",
373
- "line",
374
- "polygon",
375
- "polyline",
376
- ].includes(tagName)) {
377
- return true;
378
- }
379
- // contenteditable 속성이 있는 요소
380
- if (element.getAttribute("contenteditable") === "true") {
381
- return true;
382
- }
383
- // 추가 셀렉터 체크
384
- if (config === null || config === void 0 ? void 0 : config.excludeSelectors) {
385
- for (const selector of config.excludeSelectors) {
386
- if (element.matches(selector)) {
387
- return true;
388
- }
389
- }
390
- }
391
- return checkElementAndParents(element, config);
392
- };
393
- /**
394
- * 자신 또는 부모 요소들을 확인하여 드래그 스크롤을 제외할 요소인지 판단
395
- */
396
- const checkElementAndParents = (element, config) => {
397
- // 모든 제외 클래스들 합치기 (기본 클래스 + 사용자 추가 클래스)
398
- const allExcludeClasses = [
399
- ...DEFAULT_EXCLUDE_CLASSES,
400
- ...((config === null || config === void 0 ? void 0 : config.excludeClasses) || []),
401
- ];
402
- let currentElement = element;
403
- let depth = 0;
404
- const maxDepth = 5; // 최대 5단계까지 부모 요소 확인
405
- while (currentElement && depth <= maxDepth) {
406
- // 현재 요소가 제외 클래스를 가지고 있는지 확인
407
- if (allExcludeClasses.some((cls) => currentElement.classList.contains(cls))) {
408
- return true;
409
- }
410
- // 다이얼로그 루트에 도달하면 중단
411
- if (currentElement.classList.contains("MuiDialogContent-root")) {
412
- break;
413
- }
414
- currentElement = currentElement.parentElement;
415
- depth++;
416
- }
417
- return false;
418
- };
419
-
420
- // 기본 설정 객체들을 컴포넌트 외부에 상수로 선언 (재렌더링 시 동일한 참조 유지)
421
- const DEFAULT_THUMB_CONFIG = {};
422
- const DEFAULT_TRACK_CONFIG = {};
423
- const DEFAULT_ARROWS_CONFIG = {};
424
- const DEFAULT_DRAG_SCROLL_CONFIG = {};
425
- const DEFAULT_AUTO_HIDE_CONFIG = {};
426
- const OverlayScrollbar = react.forwardRef(({ className = "", style = {}, containerStyle = {}, contentStyle = {}, children, onScroll,
427
- // 그룹화된 설정 객체들
428
- thumb = DEFAULT_THUMB_CONFIG, track = DEFAULT_TRACK_CONFIG, arrows = DEFAULT_ARROWS_CONFIG, dragScroll = DEFAULT_DRAG_SCROLL_CONFIG, autoHide = DEFAULT_AUTO_HIDE_CONFIG,
429
- // 기타 설정들
430
- showScrollbar = true, }, ref) => {
431
- // props 변경 추적용 ref
432
- const prevPropsRef = react.useRef({});
433
- // 렌더링 시 어떤 prop이 변경되었는지 체크
434
- react.useEffect(() => {
435
- // 현재 props 저장
436
- prevPropsRef.current = {
437
- children,
438
- onScroll,
439
- showScrollbar,
440
- thumb,
441
- track,
442
- arrows,
443
- dragScroll,
444
- autoHide,
445
- };
446
- });
447
- const wrapperRef = react.useRef(null);
448
- const containerRef = react.useRef(null);
449
- const contentRef = react.useRef(null);
450
- const scrollbarRef = react.useRef(null);
451
- const thumbRef = react.useRef(null);
452
- // 스크롤 컨테이너 캐싱용 ref (성능 최적화)
453
- const cachedScrollContainerRef = react.useRef(null);
454
- // 기본 상태들
455
- const [scrollbarVisible, setScrollbarVisible] = react.useState(false);
456
- const [isDragging, setIsDragging] = react.useState(false);
457
- const [isThumbHovered, setIsThumbHovered] = react.useState(false);
458
- const [dragStart, setDragStart] = react.useState({ y: 0, scrollTop: 0 });
459
- const [thumbHeight, setThumbHeight] = react.useState(0);
460
- const [thumbTop, setThumbTop] = react.useState(0);
461
- const [hasScrollableContent, setHasScrollableContent] = react.useState(false);
462
- // 드래그 스크롤 상태
463
- const [isDragScrolling, setIsDragScrolling] = react.useState(false);
464
- const [dragScrollStart, setDragScrollStart] = react.useState({
465
- x: 0,
466
- y: 0,
467
- scrollTop: 0,
468
- scrollLeft: 0,
469
- });
470
- const [activeArrow, setActiveArrow] = react.useState(null);
471
- const [hoveredArrow, setHoveredArrow] = react.useState(null);
472
- // 초기 마운트 시 hover 방지용
473
- const [isInitialized, setIsInitialized] = react.useState(false);
474
- // 휠 스크롤 감지용
475
- const wheelTimeoutRef = react.useRef(null);
476
- const [isWheelScrolling, setIsWheelScrolling] = react.useState(false);
477
- // 숨김 타이머
478
- const hideTimeoutRef = react.useRef(null);
479
- // 그룹화된 설정 객체들에 기본값 설정
480
- const finalThumbConfig = react.useMemo(() => {
481
- var _a, _b, _c, _d, _e, _f, _g, _h;
482
- const baseColor = (_a = thumb.color) !== null && _a !== void 0 ? _a : "#606060";
483
- return {
484
- width: (_b = thumb.width) !== null && _b !== void 0 ? _b : 8,
485
- minHeight: (_c = thumb.minHeight) !== null && _c !== void 0 ? _c : 50,
486
- radius: (_d = thumb.radius) !== null && _d !== void 0 ? _d : ((_e = thumb.width) !== null && _e !== void 0 ? _e : 8) / 2,
487
- color: baseColor,
488
- opacity: (_f = thumb.opacity) !== null && _f !== void 0 ? _f : 0.6,
489
- hoverColor: (_g = thumb.hoverColor) !== null && _g !== void 0 ? _g : baseColor,
490
- hoverOpacity: (_h = thumb.hoverOpacity) !== null && _h !== void 0 ? _h : 1.0,
491
- };
492
- }, [thumb]);
493
- const finalTrackConfig = react.useMemo(() => {
494
- var _a, _b, _c, _d, _e, _f, _g;
495
- return ({
496
- width: (_a = track.width) !== null && _a !== void 0 ? _a : 16,
497
- color: (_b = track.color) !== null && _b !== void 0 ? _b : "rgba(128, 128, 128, 0.1)",
498
- visible: (_c = track.visible) !== null && _c !== void 0 ? _c : true,
499
- alignment: (_d = track.alignment) !== null && _d !== void 0 ? _d : "center",
500
- radius: (_f = (_e = track.radius) !== null && _e !== void 0 ? _e : finalThumbConfig.radius) !== null && _f !== void 0 ? _f : 4,
501
- margin: (_g = track.margin) !== null && _g !== void 0 ? _g : 4,
502
- });
503
- }, [track, finalThumbConfig.radius]);
504
- const finalArrowsConfig = react.useMemo(() => {
505
- var _a, _b, _c, _d, _e, _f;
506
- const baseColor = (_a = arrows.color) !== null && _a !== void 0 ? _a : "#808080";
507
- return {
508
- visible: (_b = arrows.visible) !== null && _b !== void 0 ? _b : false,
509
- step: (_c = arrows.step) !== null && _c !== void 0 ? _c : 50,
510
- color: baseColor,
511
- opacity: (_d = arrows.opacity) !== null && _d !== void 0 ? _d : 0.6,
512
- hoverColor: (_e = arrows.hoverColor) !== null && _e !== void 0 ? _e : baseColor,
513
- hoverOpacity: (_f = arrows.hoverOpacity) !== null && _f !== void 0 ? _f : 1.0,
514
- };
515
- }, [arrows]);
516
- const finalDragScrollConfig = react.useMemo(() => {
517
- var _a, _b, _c;
518
- return ({
519
- enabled: (_a = dragScroll.enabled) !== null && _a !== void 0 ? _a : true,
520
- excludeClasses: (_b = dragScroll.excludeClasses) !== null && _b !== void 0 ? _b : [],
521
- excludeSelectors: (_c = dragScroll.excludeSelectors) !== null && _c !== void 0 ? _c : [],
522
- });
523
- }, [dragScroll]);
524
- const finalAutoHideConfig = react.useMemo(() => {
525
- var _a, _b, _c;
526
- return ({
527
- enabled: (_a = autoHide.enabled) !== null && _a !== void 0 ? _a : true,
528
- delay: (_b = autoHide.delay) !== null && _b !== void 0 ? _b : 1500,
529
- delayOnWheel: (_c = autoHide.delayOnWheel) !== null && _c !== void 0 ? _c : 700,
530
- });
531
- }, [autoHide]);
532
- // 호환성을 위한 변수들 (자주 사용되는 변수들만 유지)
533
- const finalThumbWidth = finalThumbConfig.width;
534
- const finalTrackWidth = finalTrackConfig.width;
535
- const thumbMinHeight = finalThumbConfig.minHeight;
536
- const showArrows = finalArrowsConfig.visible;
537
- const arrowStep = finalArrowsConfig.step;
538
- // 포커스 유지 함수 (키보드 입력이 계속 작동하도록)
539
- const maintainFocus = react.useCallback(() => {
540
- if (!containerRef.current)
541
- return;
542
- // 현재 포커스된 요소 확인
543
- const activeElement = document.activeElement;
544
- // 오버레이 스크롤바 내부에 이미 포커스된 요소가 있으면 스킵
545
- if (activeElement &&
546
- containerRef.current.contains(activeElement) &&
547
- activeElement !== containerRef.current) {
548
- return;
549
- }
550
- // 포커스된 요소가 없거나 외부에 있으면 컨테이너에 포커스
551
- containerRef.current.focus();
552
- }, []);
553
- // ref를 통해 외부에서 스크롤 컨테이너에 접근할 수 있도록 함
554
- react.useImperativeHandle(ref, () => ({
555
- getScrollContainer: () => containerRef.current,
556
- scrollTo: (options) => {
557
- if (containerRef.current) {
558
- containerRef.current.scrollTo(options);
559
- }
560
- },
561
- get scrollTop() {
562
- var _a;
563
- return ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.scrollTop) || 0;
564
- },
565
- get scrollHeight() {
566
- var _a;
567
- return ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) || 0;
568
- },
569
- get clientHeight() {
570
- var _a;
571
- return ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
572
- },
573
- }), []);
574
- // 실제 스크롤 가능한 요소 찾기 (캐싱 최적화)
575
- const findScrollableElement = react.useCallback(() => {
576
- // 캐시된 요소가 여전히 유효한지 확인
577
- if (cachedScrollContainerRef.current) {
578
- const cached = cachedScrollContainerRef.current;
579
- // DOM에 연결되어 있고 여전히 스크롤 가능한지 확인
580
- if (document.contains(cached) &&
581
- cached.scrollHeight > cached.clientHeight + 2) {
582
- return cached;
583
- }
584
- // 캐시 무효화
585
- cachedScrollContainerRef.current = null;
586
- }
587
- if (!containerRef.current) {
588
- return null;
589
- }
590
- // 내부 컨테이너의 스크롤 가능 여부 확인
591
- if (contentRef.current &&
592
- contentRef.current.scrollHeight >
593
- containerRef.current.clientHeight + 2) {
594
- cachedScrollContainerRef.current = containerRef.current;
595
- return containerRef.current;
596
- }
597
- // children 요소에서 스크롤 가능한 요소 찾기
598
- // 중첩된 OverlayScrollbar의 영역은 제외 (다른 OverlayScrollbar의 container는 스킵)
599
- const childScrollableElements = containerRef.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');
600
- for (const child of childScrollableElements) {
601
- const element = child;
602
- // 이 요소가 다른 OverlayScrollbar의 container인지 확인
603
- // (자신의 containerRef는 아니어야 하고, overlay-scrollbar-container 클래스를 가진 경우)
604
- if (element !== containerRef.current &&
605
- element.classList.contains("overlay-scrollbar-container")) {
606
- // 중첩된 OverlayScrollbar의 container이므로 스킵
607
- continue;
608
- }
609
- // 이 요소의 부모 중에 다른 OverlayScrollbar container가 있는지 확인
610
- let parent = element.parentElement;
611
- let isNestedInAnotherScrollbar = false;
612
- while (parent && parent !== containerRef.current) {
613
- if (parent.classList.contains("overlay-scrollbar-container") &&
614
- parent !== containerRef.current) {
615
- // 다른 OverlayScrollbar 내부의 요소이므로 스킵
616
- isNestedInAnotherScrollbar = true;
617
- break;
618
- }
619
- parent = parent.parentElement;
620
- }
621
- if (isNestedInAnotherScrollbar) {
622
- continue;
623
- }
624
- // 스크롤 가능한 요소인지 확인
625
- if (element.scrollHeight > element.clientHeight + 2) {
626
- cachedScrollContainerRef.current = element;
627
- return element;
628
- }
629
- }
630
- return null;
631
- }, []);
632
- // 스크롤 가능 여부 체크
633
- const isScrollable = react.useCallback(() => {
634
- return findScrollableElement() !== null;
635
- }, [findScrollableElement]);
636
- // 타이머 정리
637
- const clearHideTimer = react.useCallback(() => {
638
- if (hideTimeoutRef.current) {
639
- clearTimeout(hideTimeoutRef.current);
640
- hideTimeoutRef.current = null;
641
- }
642
- }, []);
643
- // 스크롤바 숨기기 타이머
644
- const setHideTimer = react.useCallback((delay) => {
645
- // 자동 숨김이 비활성화되어 있으면 타이머를 설정하지 않음
646
- if (!finalAutoHideConfig.enabled) {
647
- return;
648
- }
649
- clearHideTimer();
650
- hideTimeoutRef.current = setTimeout(() => {
651
- setScrollbarVisible(false);
652
- hideTimeoutRef.current = null;
653
- }, delay);
654
- }, [clearHideTimer, finalAutoHideConfig.enabled]);
655
- // 스크롤바 위치 및 크기 업데이트
656
- const updateScrollbar = react.useCallback(() => {
657
- const scrollableElement = findScrollableElement();
658
- if (!scrollableElement) {
659
- // 스크롤 불가능하면 숨김
660
- setScrollbarVisible(false);
661
- setHasScrollableContent(false);
662
- clearHideTimer();
663
- return;
664
- }
665
- // 스크롤 가능한 콘텐츠가 있음을 표시
666
- setHasScrollableContent(true);
667
- if (!scrollbarRef.current)
668
- return;
669
- // 자동 숨김이 비활성화되어 있으면 스크롤바를 항상 표시
670
- if (!finalAutoHideConfig.enabled) {
671
- setScrollbarVisible(true);
672
- clearHideTimer();
673
- }
674
- const containerHeight = scrollableElement.clientHeight;
675
- const contentHeight = scrollableElement.scrollHeight;
676
- const scrollTop = scrollableElement.scrollTop;
677
- // wrapper의 패딩 계산 (상하 패딩만 필요)
678
- let wrapperPaddingTopBottom = 0;
679
- if (wrapperRef.current) {
680
- const computedStyle = window.getComputedStyle(wrapperRef.current);
681
- const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
682
- const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
683
- wrapperPaddingTopBottom = paddingTop + paddingBottom;
684
- }
685
- // 화살표와 간격 공간 계산 (화살표 + 위아래 마진, 화살표 없어도 위아래 마진)
686
- const arrowSpace = showArrows
687
- ? finalThumbWidth * 2 + finalTrackConfig.margin * 4
688
- : finalTrackConfig.margin * 2;
689
- // 썸 높이 계산 (사용자 설정 최소 높이 사용, 화살표 공간 제외, wrapper 패딩 추가)
690
- const availableHeight = containerHeight - arrowSpace + wrapperPaddingTopBottom;
691
- const scrollRatio = containerHeight / contentHeight;
692
- const calculatedThumbHeight = Math.max(availableHeight * scrollRatio, thumbMinHeight);
693
- // 썸 위치 계산 (화살표와 간격 공간 제외)
694
- const scrollableHeight = contentHeight - containerHeight;
695
- const thumbScrollableHeight = availableHeight - calculatedThumbHeight;
696
- const calculatedThumbTop = scrollableHeight > 0
697
- ? (scrollTop / scrollableHeight) * thumbScrollableHeight
698
- : 0;
699
- setThumbHeight(calculatedThumbHeight);
700
- setThumbTop(calculatedThumbTop);
701
- }, [
702
- findScrollableElement,
703
- clearHideTimer,
704
- showArrows,
705
- finalThumbWidth,
706
- thumbMinHeight,
707
- finalAutoHideConfig.enabled,
708
- ]);
709
- // 썸 드래그 시작
710
- const handleThumbMouseDown = react.useCallback((event) => {
711
- event.preventDefault();
712
- event.stopPropagation();
713
- const actualScrollContainer = findScrollableElement();
714
- if (!actualScrollContainer) {
715
- return;
716
- }
717
- setIsDragging(true);
718
- setDragStart({
719
- y: event.clientY,
720
- scrollTop: actualScrollContainer.scrollTop,
721
- });
722
- clearHideTimer();
723
- setScrollbarVisible(true);
724
- // 포커스 유지 (키보드 입력이 계속 작동하도록)
725
- maintainFocus();
726
- }, [findScrollableElement, clearHideTimer, maintainFocus]);
727
- // 썸 드래그 중
728
- const handleMouseMove = react.useCallback((event) => {
729
- if (!isDragging)
730
- return;
731
- const actualScrollContainer = findScrollableElement();
732
- if (!actualScrollContainer) {
733
- return;
734
- }
735
- const containerHeight = actualScrollContainer.clientHeight;
736
- const contentHeight = actualScrollContainer.scrollHeight;
737
- const scrollableHeight = contentHeight - containerHeight;
738
- const deltaY = event.clientY - dragStart.y;
739
- const thumbScrollableHeight = containerHeight - thumbHeight;
740
- const scrollDelta = (deltaY / thumbScrollableHeight) * scrollableHeight;
741
- const newScrollTop = Math.max(0, Math.min(scrollableHeight, dragStart.scrollTop + scrollDelta));
742
- actualScrollContainer.scrollTop = newScrollTop;
743
- updateScrollbar();
744
- }, [
745
- isDragging,
746
- dragStart,
747
- thumbHeight,
748
- updateScrollbar,
749
- findScrollableElement,
750
- ]);
751
- // 썸 드래그 종료
752
- const handleMouseUp = react.useCallback(() => {
753
- setIsDragging(false);
754
- if (isScrollable()) {
755
- setHideTimer(finalAutoHideConfig.delay); // 기본 숨김 시간 적용
756
- }
757
- }, [isScrollable, setHideTimer, finalAutoHideConfig.delay]);
758
- // 트랙 클릭으로 스크롤 점프
759
- const handleTrackClick = react.useCallback((event) => {
760
- if (!scrollbarRef.current) {
761
- return;
762
- }
763
- const scrollbar = scrollbarRef.current;
764
- const rect = scrollbar.getBoundingClientRect();
765
- const clickY = event.clientY - rect.top;
766
- const actualScrollContainer = findScrollableElement();
767
- if (!actualScrollContainer) {
768
- return;
769
- }
770
- const containerHeight = actualScrollContainer.clientHeight;
771
- const contentHeight = actualScrollContainer.scrollHeight;
772
- const scrollRatio = clickY / containerHeight;
773
- const newScrollTop = scrollRatio * (contentHeight - containerHeight);
774
- actualScrollContainer.scrollTop = Math.max(0, Math.min(contentHeight - containerHeight, newScrollTop));
775
- updateScrollbar();
776
- setScrollbarVisible(true);
777
- setHideTimer(finalAutoHideConfig.delay);
778
- // 포커스 유지 (키보드 입력이 계속 작동하도록)
779
- maintainFocus();
780
- }, [
781
- updateScrollbar,
782
- setHideTimer,
783
- finalAutoHideConfig.delay,
784
- findScrollableElement,
785
- maintainFocus,
786
- ]);
787
- // 위쪽 화살표 클릭 핸들러
788
- const handleUpArrowClick = react.useCallback((event) => {
789
- event.preventDefault();
790
- event.stopPropagation();
791
- if (!containerRef.current)
792
- return;
793
- const newScrollTop = Math.max(0, containerRef.current.scrollTop - arrowStep);
794
- containerRef.current.scrollTop = newScrollTop;
795
- updateScrollbar();
796
- setScrollbarVisible(true);
797
- setHideTimer(finalAutoHideConfig.delay);
798
- // 포커스 유지 (키보드 입력이 계속 작동하도록)
799
- maintainFocus();
800
- }, [
801
- updateScrollbar,
802
- setHideTimer,
803
- arrowStep,
804
- finalAutoHideConfig.delay,
805
- maintainFocus,
806
- ]);
807
- // 아래쪽 화살표 클릭 핸들러
808
- const handleDownArrowClick = react.useCallback((event) => {
809
- event.preventDefault();
810
- event.stopPropagation();
811
- if (!containerRef.current || !contentRef.current)
812
- return;
813
- const container = containerRef.current;
814
- const content = contentRef.current;
815
- const maxScrollTop = content.scrollHeight - container.clientHeight;
816
- const newScrollTop = Math.min(maxScrollTop, container.scrollTop + arrowStep);
817
- container.scrollTop = newScrollTop;
818
- updateScrollbar();
819
- setScrollbarVisible(true);
820
- setHideTimer(finalAutoHideConfig.delay);
821
- // 포커스 유지 (키보드 입력이 계속 작동하도록)
822
- maintainFocus();
823
- }, [
824
- updateScrollbar,
825
- setHideTimer,
826
- arrowStep,
827
- finalAutoHideConfig.delay,
828
- maintainFocus,
829
- ]);
830
- // 드래그 스크롤 시작
831
- const handleDragScrollStart = react.useCallback((event) => {
832
- // 드래그 스크롤이 비활성화된 경우
833
- if (!finalDragScrollConfig.enabled)
834
- return;
835
- // 텍스트 입력 요소나 제외 대상이면 드래그 스크롤 하지 않음
836
- const target = event.target;
837
- if (isTextInputElement(target, finalDragScrollConfig)) {
838
- return;
839
- }
840
- // 오른쪽 클릭이나 휠 클릭은 제외
841
- if (event.button !== 0)
842
- return;
843
- const scrollableElement = findScrollableElement();
844
- if (!scrollableElement)
845
- return;
846
- // 스크롤 가능한 영역이 아니면 제외
847
- if (scrollableElement.scrollHeight <=
848
- scrollableElement.clientHeight)
849
- return;
850
- event.preventDefault();
851
- setIsDragScrolling(true);
852
- setDragScrollStart({
853
- x: event.clientX,
854
- y: event.clientY,
855
- scrollTop: scrollableElement.scrollTop,
856
- scrollLeft: scrollableElement.scrollLeft || 0,
857
- });
858
- // 스크롤바 표시
859
- clearHideTimer();
860
- setScrollbarVisible(true);
861
- }, [
862
- finalDragScrollConfig,
863
- isTextInputElement,
864
- findScrollableElement,
865
- clearHideTimer,
866
- ]);
867
- // 드래그 스크롤 중
868
- const handleDragScrollMove = react.useCallback((event) => {
869
- if (!isDragScrolling)
870
- return;
871
- const scrollableElement = findScrollableElement();
872
- if (!scrollableElement)
873
- return;
874
- dragScrollStart.x - event.clientX;
875
- const deltaY = dragScrollStart.y - event.clientY;
876
- // 세로 스크롤만 처리 (가로 스크롤은 필요시 나중에 추가)
877
- const newScrollTop = Math.max(0, Math.min(scrollableElement.scrollHeight -
878
- scrollableElement.clientHeight, dragScrollStart.scrollTop + deltaY));
879
- scrollableElement.scrollTop = newScrollTop;
880
- updateScrollbar();
881
- }, [
882
- isDragScrolling,
883
- dragScrollStart,
884
- findScrollableElement,
885
- updateScrollbar,
886
- ]);
887
- // 드래그 스크롤 종료
888
- const handleDragScrollEnd = react.useCallback(() => {
889
- setIsDragScrolling(false);
890
- if (isScrollable()) {
891
- setHideTimer(finalAutoHideConfig.delay);
892
- }
893
- }, [isScrollable, setHideTimer, finalAutoHideConfig.delay]);
894
- // 스크롤 이벤트 리스너 (externalScrollContainer 우선 사용)
895
- react.useEffect(() => {
896
- const handleScroll = (event) => {
897
- updateScrollbar();
898
- // 스크롤 중에는 스크롤바 표시
899
- clearHideTimer();
900
- setScrollbarVisible(true);
901
- // 휠 스크롤 중이면 빠른 숨김, 아니면 기본 숨김 시간 적용
902
- const delay = isWheelScrolling
903
- ? finalAutoHideConfig.delayOnWheel
904
- : finalAutoHideConfig.delay;
905
- setHideTimer(delay);
906
- if (onScroll) {
907
- onScroll(event);
908
- }
909
- };
910
- const handleWheel = () => {
911
- // 휠 스크롤 상태 표시
912
- setIsWheelScrolling(true);
913
- // 기존 휠 타이머 제거
914
- if (wheelTimeoutRef.current) {
915
- clearTimeout(wheelTimeoutRef.current);
916
- }
917
- // 300ms 후 휠 스크롤 상태 해제 (휠 스크롤이 끝났다고 간주)
918
- wheelTimeoutRef.current = setTimeout(() => {
919
- setIsWheelScrolling(false);
920
- }, 300);
921
- clearHideTimer();
922
- setScrollbarVisible(true);
923
- };
924
- const elementsToWatch = [];
925
- // 실제 스크롤 가능한 요소 찾기
926
- const scrollableElement = findScrollableElement();
927
- if (scrollableElement) {
928
- elementsToWatch.push(scrollableElement);
929
- }
930
- // fallback: 내부 컨테이너와 children 요소도 감지
931
- const container = containerRef.current;
932
- if (container && !scrollableElement) {
933
- elementsToWatch.push(container);
934
- // children 요소들의 스크롤도 감지 (중첩된 OverlayScrollbar 제외)
935
- const childScrollableElements = container.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');
936
- childScrollableElements.forEach((child) => {
937
- const element = child;
938
- // 다른 OverlayScrollbar의 container는 제외
939
- if (element !== container &&
940
- element.classList.contains("overlay-scrollbar-container")) {
941
- return;
942
- }
943
- // 부모 중에 다른 OverlayScrollbar container가 있으면 제외
944
- let parent = element.parentElement;
945
- while (parent && parent !== container) {
946
- if (parent.classList.contains("overlay-scrollbar-container") &&
947
- parent !== container) {
948
- return; // 중첩된 OverlayScrollbar 내부이므로 제외
949
- }
950
- parent = parent.parentElement;
951
- }
952
- elementsToWatch.push(element);
953
- });
954
- }
955
- // 모든 요소에 이벤트 리스너 등록
956
- elementsToWatch.forEach((element) => {
957
- element.addEventListener("scroll", handleScroll, {
958
- passive: true,
959
- });
960
- element.addEventListener("wheel", handleWheel, {
961
- passive: true,
962
- });
963
- });
964
- return () => {
965
- // 모든 이벤트 리스너 제거
966
- elementsToWatch.forEach((element) => {
967
- element.removeEventListener("scroll", handleScroll);
968
- element.removeEventListener("wheel", handleWheel);
969
- });
970
- if (wheelTimeoutRef.current) {
971
- clearTimeout(wheelTimeoutRef.current);
972
- }
973
- };
974
- }, [
975
- findScrollableElement,
976
- updateScrollbar,
977
- onScroll,
978
- clearHideTimer,
979
- setHideTimer,
980
- finalAutoHideConfig,
981
- isWheelScrolling,
982
- ]);
983
- // 키보드 네비게이션 핸들러 (방향키, PageUp/PageDown/Home/End)
984
- react.useEffect(() => {
985
- const handleKeyDown = (event) => {
986
- const scrollableElement = findScrollableElement();
987
- if (!scrollableElement)
988
- return;
989
- const { key } = event;
990
- const { scrollTop, scrollHeight, clientHeight } = scrollableElement;
991
- const maxScrollTop = scrollHeight - clientHeight;
992
- // 한 줄 스크롤 단위 (rowHeight 또는 기본값)
993
- const lineScrollStep = 50;
994
- let newScrollTop = null;
995
- switch (key) {
996
- case "ArrowUp":
997
- event.preventDefault();
998
- newScrollTop = Math.max(0, scrollTop - lineScrollStep);
999
- break;
1000
- case "ArrowDown":
1001
- event.preventDefault();
1002
- newScrollTop = Math.min(maxScrollTop, scrollTop + lineScrollStep);
1003
- break;
1004
- case "PageUp":
1005
- event.preventDefault();
1006
- newScrollTop = Math.max(0, scrollTop - clientHeight);
1007
- break;
1008
- case "PageDown":
1009
- event.preventDefault();
1010
- newScrollTop = Math.min(maxScrollTop, scrollTop + clientHeight);
1011
- break;
1012
- case "Home":
1013
- event.preventDefault();
1014
- newScrollTop = 0;
1015
- break;
1016
- case "End":
1017
- event.preventDefault();
1018
- newScrollTop = maxScrollTop;
1019
- break;
1020
- default:
1021
- return;
1022
- }
1023
- if (newScrollTop !== null) {
1024
- // 썸 위치를 먼저 업데이트
1025
- const scrollRatio = newScrollTop / maxScrollTop;
1026
- const arrowSpace = showArrows
1027
- ? finalThumbWidth * 2 + finalTrackConfig.margin * 4
1028
- : finalTrackConfig.margin * 2;
1029
- const availableHeight = clientHeight - arrowSpace;
1030
- const scrollableThumbHeight = availableHeight - thumbHeight;
1031
- const newThumbTop = scrollableThumbHeight * scrollRatio;
1032
- setThumbTop(newThumbTop);
1033
- // 스크롤 위치를 즉시 변경 (애니메이션 없음)
1034
- scrollableElement.scrollTop = newScrollTop;
1035
- // 스크롤바 표시
1036
- clearHideTimer();
1037
- setScrollbarVisible(true);
1038
- setHideTimer(finalAutoHideConfig.delay);
1039
- }
1040
- };
1041
- const container = containerRef.current;
1042
- if (container) {
1043
- container.addEventListener("keydown", handleKeyDown);
1044
- return () => {
1045
- container.removeEventListener("keydown", handleKeyDown);
1046
- };
1047
- }
1048
- }, [
1049
- findScrollableElement,
1050
- showArrows,
1051
- finalThumbWidth,
1052
- finalTrackConfig.margin,
1053
- thumbHeight,
1054
- clearHideTimer,
1055
- setHideTimer,
1056
- finalAutoHideConfig.delay,
1057
- ]);
1058
- // 드래그 스크롤 전역 마우스 이벤트 리스너
1059
- react.useEffect(() => {
1060
- if (isDragScrolling) {
1061
- document.addEventListener("mousemove", handleDragScrollMove);
1062
- document.addEventListener("mouseup", handleDragScrollEnd);
1063
- return () => {
1064
- document.removeEventListener("mousemove", handleDragScrollMove);
1065
- document.removeEventListener("mouseup", handleDragScrollEnd);
1066
- };
1067
- }
1068
- }, [isDragScrolling, handleDragScrollMove, handleDragScrollEnd]);
1069
- // 전역 마우스 이벤트 리스너
1070
- react.useEffect(() => {
1071
- if (isDragging) {
1072
- document.addEventListener("mousemove", handleMouseMove);
1073
- document.addEventListener("mouseup", handleMouseUp);
1074
- return () => {
1075
- document.removeEventListener("mousemove", handleMouseMove);
1076
- document.removeEventListener("mouseup", handleMouseUp);
1077
- };
1078
- }
1079
- }, [isDragging, handleMouseMove, handleMouseUp]);
1080
- // 초기 스크롤바 업데이트
1081
- react.useEffect(() => {
1082
- // 즉시 업데이트
1083
- updateScrollbar();
1084
- // 약간의 지연 후에도 업데이트 (DOM이 완전히 렌더링된 후)
1085
- const timer = setTimeout(() => {
1086
- updateScrollbar();
1087
- }, 100);
1088
- return () => clearTimeout(timer);
1089
- }, [updateScrollbar]);
1090
- // 컴포넌트 초기화 완료 표시 (hover 이벤트 활성화용)
1091
- react.useLayoutEffect(() => {
1092
- setIsInitialized(true);
1093
- // 초기화 직후 스크롤바 업데이트 (썸 높이 정확하게 계산)
1094
- updateScrollbar();
1095
- // 자동 숨김이 비활성화되어 있으면 스크롤바를 항상 표시
1096
- if (!finalAutoHideConfig.enabled && isScrollable()) {
1097
- setScrollbarVisible(true);
1098
- }
1099
- }, [isScrollable, updateScrollbar, finalAutoHideConfig.enabled]);
1100
- // Resize observer로 크기 변경 감지
1101
- react.useEffect(() => {
1102
- const resizeObserver = new ResizeObserver(() => {
1103
- updateScrollbar();
1104
- });
1105
- const elementsToObserve = [];
1106
- // 내부 컨테이너들 관찰
1107
- if (containerRef.current) {
1108
- elementsToObserve.push(containerRef.current);
1109
- }
1110
- if (contentRef.current) {
1111
- elementsToObserve.push(contentRef.current);
1112
- }
1113
- // 캐시된 스크롤 컨테이너도 관찰
1114
- if (cachedScrollContainerRef.current &&
1115
- document.contains(cachedScrollContainerRef.current)) {
1116
- elementsToObserve.push(cachedScrollContainerRef.current);
1117
- }
1118
- // 모든 요소들 관찰 시작
1119
- elementsToObserve.forEach((element) => {
1120
- resizeObserver.observe(element);
1121
- });
1122
- return () => resizeObserver.disconnect();
1123
- }, [updateScrollbar]);
1124
- // MutationObserver로 DOM 변경 감지
1125
- react.useEffect(() => {
1126
- if (!containerRef.current) {
1127
- return;
1128
- }
1129
- const observer = new MutationObserver(() => {
1130
- // 캐시 초기화하여 새로운 스크롤 컨테이너 감지
1131
- cachedScrollContainerRef.current = null;
1132
- updateScrollbar();
1133
- });
1134
- observer.observe(containerRef.current, {
1135
- childList: true,
1136
- subtree: true,
1137
- attributes: true,
1138
- attributeFilter: ["style"],
1139
- });
1140
- return () => observer.disconnect();
1141
- }, [updateScrollbar]);
1142
- // trackWidth가 thumbWidth보다 작으면 thumbWidth와 같게 설정
1143
- const adjustedTrackWidth = Math.max(finalTrackWidth, finalThumbWidth);
1144
- // 웹킷 스크롤바 숨기기용 CSS 동적 주입
1145
- react.useEffect(() => {
1146
- const styleId = "overlay-scrollbar-webkit-hide";
1147
- // 이미 스타일이 있으면 제거
1148
- const existingStyle = document.getElementById(styleId);
1149
- if (existingStyle) {
1150
- existingStyle.remove();
1151
- }
1152
- const style = document.createElement("style");
1153
- style.id = styleId;
1154
- style.textContent = `
1
+ "use strict";var Ve=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var ot=Object.prototype.hasOwnProperty;var nt=(a,d)=>{for(var g in d)Ve(a,g,{get:d[g],enumerable:!0})},it=(a,d,g,v)=>{if(d&&typeof d=="object"||typeof d=="function")for(let x of rt(d))!ot.call(a,x)&&x!==g&&Ve(a,x,{get:()=>d[x],enumerable:!(v=tt(d,x))||v.enumerable});return a};var lt=a=>it(Ve({},"__esModule",{value:!0}),a);var bt={};nt(bt,{VirtualDataTable:()=>Xe});module.exports=lt(bt);var u=require("react"),f=require("@mui/material"),Ue=require("react-virtuoso");var Ne=require("react/jsx-runtime"),ye=require("react"),je=require("@mui/material"),Re=function(){return Re=Object.assign||function(d){for(var g,v=1,x=arguments.length;v<x;v++){g=arguments[v];for(var H in g)Object.prototype.hasOwnProperty.call(g,H)&&(d[H]=g[H])}return d},Re.apply(this,arguments)};function Fe(a){var d=a.visible,g=a.onComplete,v=a.fadeoutDuration,x=v===void 0?200:v,H=a.exitDelay,L=H===void 0?0:H,j=a.size,R=j===void 0?40:j,z=a.className,S=a.style,A=a.sx,J=a.indicator,Z=a.background,fe=Z===void 0?{show:!0,color:"255, 255, 255",opacity:.9}:Z,Q=(0,ye.useRef)(void 0),p=(0,ye.useRef)(null),Y=(0,ye.useState)(d),ee=Y[0],te=Y[1],P=fe.show,re=P===void 0?!0:P,D=fe.color,I=D===void 0?"255, 255, 255":D,oe=fe.opacity,ne=oe===void 0?.9:oe;if((0,ye.useEffect)(function(){var Te=Q.current;if(Te===!0&&d===!1&&p.current){var le=p.current;le.style.opacity="0",setTimeout(function(){te(!1),g?.()},x+L)}else d===!0&&(te(!0),p.current&&(p.current.style.opacity="1"));Q.current=d},[d,g,x,L]),!ee)return null;var ve=function(){return typeof J=="string"?(0,Ne.jsx)("img",{src:J,alt:"Loading",style:{width:R,height:R}}):J||(0,Ne.jsx)(je.CircularProgress,{size:R})},ie=function(){return re?I.startsWith("rgba")?{backgroundColor:I}:/^\d+,\s*\d+,\s*\d+$/.test(I)?{backgroundColor:"rgba(".concat(I,", ").concat(ne,")")}:ne!==1?{backgroundColor:I,"&::before":{content:'""',position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:I,opacity:ne,zIndex:-1}}:{backgroundColor:I}:{backgroundColor:"transparent"}};return(0,Ne.jsx)(je.Box,{ref:p,className:z,style:Re({},S),sx:Re(Re({position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,opacity:d?1:0,transition:"opacity ".concat(x,"ms ease-out")},ie()),A),children:ve()})}var t=require("react"),X=require("react/jsx-runtime"),at=["editor","textarea","input","select","textfield","form-control","contenteditable","MuiInputBase-input","MuiSelect-select","MuiOutlinedInput-input","MuiFilledInput-input","MuiInput-input","MuiFormControl-root","MuiTextField-root","MuiSelect-root","MuiOutlinedInput-root","MuiFilledInput-root","MuiInput-root","MuiAutocomplete-input","MuiDatePicker-input","MuiSlider-thumb","MuiSlider-rail","MuiSlider-track","MuiSlider-mark","MuiSlider-markLabel","MuiSlider-root","MuiSlider-colorPrimary","MuiSlider-sizeMedium","MuiIconButton-root","MuiButton-root","MuiButtonBase-root","MuiTouchRipple-root","MuiCheckbox-root","MuiRadio-root","MuiSwitch-root","PrivateSwitchBase-root","ant-input","ant-input-affix-wrapper","ant-input-group-addon","ant-input-number","ant-input-number-handler","ant-select","ant-select-selector","ant-select-selection-search","ant-select-dropdown","ant-cascader","ant-cascader-input","ant-picker","ant-picker-input","ant-time-picker","ant-calendar-picker","ant-slider","ant-slider-track","ant-slider-handle","ant-switch","ant-checkbox","ant-checkbox-wrapper","ant-radio","ant-radio-wrapper","ant-rate","ant-upload","ant-upload-drag","ant-form-item","ant-form-item-control","ant-btn","ant-dropdown","ant-dropdown-trigger","ant-menu","ant-menu-item","ant-tooltip","ant-popover","ant-modal","ant-drawer","ant-tree-select","ant-auto-complete","ant-mentions","ant-transfer","ui-input","ui-textarea","ui-select","ui-select-trigger","ui-select-content","ui-select-item","ui-button","ui-checkbox","ui-radio-group","ui-switch","ui-slider","ui-range-slider","ui-calendar","ui-date-picker","ui-combobox","ui-command","ui-command-input","ui-popover","ui-dialog","ui-sheet","ui-dropdown-menu","ui-context-menu","ui-menubar","ui-navigation-menu","ui-form","ui-form-control","ui-form-item","ui-form-field","ui-label","radix-ui","radix-select","radix-dropdown","radix-dialog","radix-popover","radix-accordion","radix-tabs","radix-slider","radix-switch","radix-checkbox","radix-radio","ql-editor","ql-container","ql-toolbar","ql-picker","ql-picker-label","ql-picker-options","ql-formats","ql-snow","ql-bubble","quill","quilleditor","monaco-editor","monaco-editor-background","view-lines","decorationsOverviewRuler","monaco-scrollable-element","CodeMirror","CodeMirror-code","CodeMirror-lines","CodeMirror-scroll","CodeMirror-sizer","cm-editor","cm-focused","cm-content","tox-editor-container","tox-editor-header","tox-edit-area","tox-tinymce","mce-content-body","ck-editor","ck-content","ck-toolbar","ck-editor__editable","ck-widget","slate-editor","slate-content","DraftEditor-root","DraftEditor-editorContainer","public-DraftEditor-content","ehfuse-editor","ehfuse-editor-wrapper","ehfuse-editor-content","ehfuse-toolbar","ehfuse-toolbar-group","ehfuse-cursor","text-editor","rich-text-editor","wysiwyg","ace_editor","ace_content"],_e=(a,d)=>{let g=a.tagName.toLowerCase(),v=["text","password","email","number","search","tel","url","checkbox","radio"];if(g==="input"){let x=a.type;return v.includes(x)}if(["textarea","select","button"].includes(g)||["svg","path","circle","rect","line","polygon","polyline"].includes(g)||a.getAttribute("contenteditable")==="true")return!0;if(d?.excludeSelectors){for(let x of d.excludeSelectors)if(a.matches(x))return!0}return st(a,d)},st=(a,d)=>{let g=[...at,...d?.excludeClasses||[]],v=a,x=0,H=5;for(;v&&x<=H;){if(g.some(L=>v.classList.contains(L)))return!0;if(v.classList.contains("MuiDialogContent-root"))break;v=v.parentElement,x++}return!1},ct={},ut={},dt={},pt={},ft={},mt=(0,t.forwardRef)(({className:a="",style:d={},containerStyle:g={},contentStyle:v={},children:x,onScroll:H,thumb:L=ct,track:j=ut,arrows:R=dt,dragScroll:z=pt,autoHide:S=ft,showScrollbar:A=!0,detectInnerScroll:J=!1},Z)=>{let fe=(0,t.useRef)({});(0,t.useEffect)(()=>{fe.current={children:x,onScroll:H,showScrollbar:A,thumb:L,track:j,arrows:R,dragScroll:z,autoHide:S}});let Q=(0,t.useRef)(null),p=(0,t.useRef)(null),Y=(0,t.useRef)(null),ee=(0,t.useRef)(null),te=(0,t.useRef)(null),P=(0,t.useRef)(null),[re,D]=(0,t.useState)(!1),[I,oe]=(0,t.useState)(!1),[ne,ve]=(0,t.useState)(!1),[ie,Te]=(0,t.useState)({y:0,scrollTop:0}),[le,Se]=(0,t.useState)(0),[ze,q]=(0,t.useState)(0),[U,Ce]=(0,t.useState)(!1),[ae,ke]=(0,t.useState)(!1),[K,xe]=(0,t.useState)({x:0,y:0,scrollTop:0,scrollLeft:0}),[Ie,Ke]=(0,t.useState)(null),[we,se]=(0,t.useState)(null),[$e,Me]=(0,t.useState)(!1),me=(0,t.useRef)(null),[Oe,Pe]=(0,t.useState)(!1),he=(0,t.useRef)(null),ce=(0,t.useRef)(null),o=(0,t.useRef)(null),i=(0,t.useMemo)(()=>{let r=L.color??"#606060";return{width:L.width??8,minHeight:L.minHeight??50,radius:L.radius??(L.width??8)/2,color:r,opacity:L.opacity??.6,hoverColor:L.hoverColor??r,hoverOpacity:L.hoverOpacity??1}},[L]),c=(0,t.useMemo)(()=>({width:j.width??16,color:j.color??"rgba(128, 128, 128, 0.1)",visible:j.visible??!0,alignment:j.alignment??"center",radius:j.radius??i.radius??4,margin:j.margin??4}),[j,i.radius]),y=(0,t.useMemo)(()=>{let r=R.color??"#808080";return{visible:R.visible??!1,step:R.step??50,color:r,opacity:R.opacity??.6,hoverColor:R.hoverColor??r,hoverOpacity:R.hoverOpacity??1}},[R]),W=(0,t.useMemo)(()=>({enabled:z.enabled??!0,excludeClasses:z.excludeClasses??[],excludeSelectors:z.excludeSelectors??[]}),[z]),e=(0,t.useMemo)(()=>({enabled:S.enabled??!0,delay:S.delay??1500,delayOnWheel:S.delayOnWheel??700}),[S]),w=i.width,Le=c.width,ue=i.minHeight,V=y.visible,de=y.step,$=(0,t.useCallback)(()=>{if(!p.current)return;let r=document.activeElement;r&&p.current.contains(r)&&r!==p.current||p.current.focus()},[]);(0,t.useImperativeHandle)(Z,()=>({getScrollContainer:()=>p.current,scrollTo:r=>{p.current&&p.current.scrollTo(r)},get scrollTop(){return p.current?.scrollTop||0},get scrollHeight(){return p.current?.scrollHeight||0},get clientHeight(){return p.current?.clientHeight||0}}),[]);let b=(0,t.useCallback)(()=>{if(P.current){let n=P.current;if(document.contains(n)&&n.scrollHeight>n.clientHeight+2)return n;P.current=null}if(!p.current)return null;if(Y.current&&Y.current.scrollHeight>p.current.clientHeight+2)return P.current=p.current,p.current;if(!J)return null;let r=p.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let n of r){let l=n;if(l!==p.current&&l.classList.contains("overlay-scrollbar-container"))continue;let m=l.parentElement,T=!1;for(;m&&m!==p.current;){if(m.classList.contains("overlay-scrollbar-container")&&m!==p.current){T=!0;break}m=m.parentElement}if(!T&&l.scrollHeight>l.clientHeight+2)return P.current=l,l}return null},[]),O=(0,t.useCallback)(()=>b()!==null,[b]),M=(0,t.useCallback)(()=>{he.current&&(clearTimeout(he.current),he.current=null)},[]),ge=(0,t.useCallback)(()=>{ce.current&&(clearTimeout(ce.current),ce.current=null)},[]),pe=(0,t.useCallback)(()=>{o.current&&(clearTimeout(o.current),o.current=null)},[]),C=(0,t.useCallback)(r=>{e.enabled&&(M(),he.current=setTimeout(()=>{D(!1),he.current=null},r))},[M,e.enabled]),h=(0,t.useCallback)(()=>{let r=b();if(!r){D(!1),Ce(!1),M();return}if(Ce(!0),!ee.current)return;e.enabled||(D(!0),M());let n=r.clientHeight,l=r.scrollHeight,m=r.scrollTop,T=0;if(Q.current){let Be=window.getComputedStyle(Q.current),We=parseFloat(Be.paddingTop)||0,et=parseFloat(Be.paddingBottom)||0;T=We+et}let k=V?w*2+c.margin*4:c.margin*2,B=n-k+T,N=n/l,be=Math.max(B*N,ue),He=l-n,G=B-be,qe=He>0?m/He*G:0;Se(be),q(qe)},[b,M,V,w,ue,e.enabled]),De=(0,t.useCallback)(r=>{r.preventDefault(),r.stopPropagation();let n=b();n&&(oe(!0),Te({y:r.clientY,scrollTop:n.scrollTop}),M(),D(!0),$())},[b,M,$]),E=(0,t.useCallback)(r=>{if(!I)return;let n=b();if(!n)return;let l=n.clientHeight,m=n.scrollHeight-l,T=r.clientY-ie.y,k=l-le,B=T/k*m,N=Math.max(0,Math.min(m,ie.scrollTop+B));n.scrollTop=N,h()},[I,ie,le,h,b]),F=(0,t.useCallback)(()=>{oe(!1),O()&&C(e.delay)},[O,C,e.delay]),_=(0,t.useCallback)(r=>{if(!ee.current)return;let n=ee.current.getBoundingClientRect(),l=r.clientY-n.top,m=b();if(!m)return;let T=m.clientHeight,k=m.scrollHeight,B=l/T*(k-T);m.scrollTop=Math.max(0,Math.min(k-T,B)),h(),D(!0),C(e.delay),$()},[h,C,e.delay,b,$]),Je=(0,t.useCallback)(r=>{if(r.preventDefault(),r.stopPropagation(),!p.current)return;let n=Math.max(0,p.current.scrollTop-de);p.current.scrollTop=n,h(),D(!0),C(e.delay),$()},[h,C,de,e.delay,$]),Ze=(0,t.useCallback)(r=>{if(r.preventDefault(),r.stopPropagation(),!p.current||!Y.current)return;let n=p.current,l=Y.current.scrollHeight-n.clientHeight,m=Math.min(l,n.scrollTop+de);n.scrollTop=m,h(),D(!0),C(e.delay),$()},[h,C,de,e.delay,$]),Qe=(0,t.useCallback)(r=>{if(!W.enabled)return;let n=r.target;if(_e(n,W)||r.button!==0)return;let l=b();l&&(l.scrollHeight<=l.clientHeight||(r.preventDefault(),ke(!0),xe({x:r.clientX,y:r.clientY,scrollTop:l.scrollTop,scrollLeft:l.scrollLeft||0}),M()))},[W,_e,b,M]),Ae=(0,t.useCallback)(r=>{if(!ae)return;let n=b();if(!n)return;let l=K.x-r.clientX,m=K.y-r.clientY;if(Math.abs(m)<3&&Math.abs(l)<3)return;D(!0);let T=Math.max(0,Math.min(n.scrollHeight-n.clientHeight,K.scrollTop+m));n.scrollTop=T,h()},[ae,K,b,h]),Ye=(0,t.useCallback)(()=>{ke(!1),O()&&C(e.delay)},[O,C,e.delay]);(0,t.useEffect)(()=>{let r=k=>{h(),M(),D(!0);let B=Oe?e.delayOnWheel:e.delay;C(B),H&&H(k)},n=()=>{Pe(!0),me.current&&clearTimeout(me.current),me.current=setTimeout(()=>{Pe(!1)},300),M(),pe(),o.current=setTimeout(()=>{D(!0),o.current=null},50)},l=[],m=b();m&&l.push(m);let T=p.current;return T&&!m&&(l.push(T),T.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(k=>{let B=k;if(B!==T&&B.classList.contains("overlay-scrollbar-container"))return;let N=B.parentElement;for(;N&&N!==T;){if(N.classList.contains("overlay-scrollbar-container")&&N!==T)return;N=N.parentElement}l.push(B)})),l.forEach(k=>{k.addEventListener("scroll",r,{passive:!0}),k.addEventListener("wheel",n,{passive:!0})}),()=>{l.forEach(k=>{k.removeEventListener("scroll",r),k.removeEventListener("wheel",n)}),me.current&&clearTimeout(me.current),o.current&&clearTimeout(o.current)}},[b,h,H,M,C,e,Oe]),(0,t.useEffect)(()=>{let r=l=>{let m=b();if(!m)return;let{key:T}=l,{scrollTop:k,scrollHeight:B,clientHeight:N}=m,be=B-N,He=50,G=null;switch(T){case"ArrowUp":l.preventDefault(),G=Math.max(0,k-He);break;case"ArrowDown":l.preventDefault(),G=Math.min(be,k+He);break;case"PageUp":l.preventDefault(),G=Math.max(0,k-N);break;case"PageDown":l.preventDefault(),G=Math.min(be,k+N);break;case"Home":l.preventDefault(),G=0;break;case"End":l.preventDefault(),G=be;break;default:return}if(G!==null){let qe=G/be,Be=V?w*2+c.margin*4:c.margin*2,We=(N-Be-le)*qe;q(We),m.scrollTop=G,M(),D(!0),C(e.delay)}},n=p.current;if(n)return n.addEventListener("keydown",r),()=>{n.removeEventListener("keydown",r)}},[b,V,w,c.margin,le,M,C,e.delay]),(0,t.useEffect)(()=>{if(ae)return document.addEventListener("mousemove",Ae),document.addEventListener("mouseup",Ye),()=>{document.removeEventListener("mousemove",Ae),document.removeEventListener("mouseup",Ye)}},[ae,Ae,Ye]),(0,t.useEffect)(()=>{if(I)return document.addEventListener("mousemove",E),document.addEventListener("mouseup",F),()=>{document.removeEventListener("mousemove",E),document.removeEventListener("mouseup",F)}},[I,E,F]),(0,t.useEffect)(()=>{h();let r=setTimeout(()=>{h()},100);return()=>clearTimeout(r)},[h]),(0,t.useLayoutEffect)(()=>{Me(!0),h(),!e.enabled&&O()&&D(!0)},[O,h,e.enabled]),(0,t.useEffect)(()=>{let r=new ResizeObserver(()=>{h()}),n=[];return p.current&&n.push(p.current),Y.current&&n.push(Y.current),P.current&&document.contains(P.current)&&n.push(P.current),n.forEach(l=>{r.observe(l)}),()=>r.disconnect()},[h]),(0,t.useEffect)(()=>{if(!p.current)return;let r=new MutationObserver(()=>{P.current=null,h()});return r.observe(p.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>r.disconnect()},[h]);let Ee=Math.max(Le,w);return(0,t.useEffect)(()=>{let r="overlay-scrollbar-webkit-hide",n=document.getElementById(r);n&&n.remove();let l=document.createElement("style");return l.id=r,l.textContent=`
1155
2
  .overlay-scrollbar-container::-webkit-scrollbar {
1156
3
  display: none !important;
1157
4
  width: 0 !important;
@@ -1171,870 +18,12 @@ showScrollbar = true, }, ref) => {
1171
18
  outline: 2px solid rgba(0, 123, 255, 0.5);
1172
19
  outline-offset: -2px;
1173
20
  }
1174
- `;
1175
- document.head.appendChild(style);
1176
- return () => {
1177
- const styleToRemove = document.getElementById(styleId);
1178
- if (styleToRemove) {
1179
- styleToRemove.remove();
1180
- }
1181
- };
1182
- }, []);
1183
- return (jsxRuntime.jsxs("div", { ref: wrapperRef, className: `overlay-scrollbar-wrapper ${className}`, style: Object.assign({ display: "flex", flexDirection: "column", position: "relative", minHeight: 0, height: "100%", flex: "1 1 0%" }, style), children: [jsxRuntime.jsx("div", { ref: containerRef, className: "overlay-scrollbar-container", tabIndex: -1, onMouseDown: handleDragScrollStart, style: Object.assign({ display: "flex", width: "100%", flex: "1 1 auto", minHeight: 0, overflow: "auto",
1184
- // 브라우저 기본 스크롤바만 숨기기
1185
- scrollbarWidth: "none", msOverflowStyle: "none",
1186
- // 키보드 포커스 스타일 (접근성)
1187
- outline: "none", userSelect: isDragScrolling ? "none" : "auto" }, containerStyle), children: jsxRuntime.jsx("div", { ref: contentRef, className: "overlay-scrollbar-content", style: Object.assign({ flex: "1 1 0%", minHeight: 0, display: "flex", flexDirection: "column" }, contentStyle), children: children }) }), showScrollbar && hasScrollableContent && (jsxRuntime.jsxs("div", { ref: scrollbarRef, className: "overlay-scrollbar-track", onMouseEnter: () => {
1188
- clearHideTimer();
1189
- setScrollbarVisible(true);
1190
- }, onMouseLeave: () => {
1191
- if (!isDragging) {
1192
- setHideTimer(finalAutoHideConfig.delay);
1193
- }
1194
- }, style: {
1195
- position: "absolute",
1196
- top: 0,
1197
- right: 0,
1198
- width: `${adjustedTrackWidth}px`,
1199
- height: "100%",
1200
- opacity: scrollbarVisible ? 1 : 0,
1201
- transition: "opacity 0.2s ease-in-out",
1202
- cursor: "pointer",
1203
- zIndex: 1000,
1204
- pointerEvents: "auto",
1205
- }, children: [finalTrackConfig.visible && (jsxRuntime.jsx("div", { className: "overlay-scrollbar-track-background", onClick: (e) => {
1206
- e.preventDefault();
1207
- e.stopPropagation();
1208
- handleTrackClick(e);
1209
- }, style: {
1210
- position: "absolute",
1211
- top: showArrows
1212
- ? `${finalThumbConfig.width +
1213
- finalTrackConfig.margin * 2}px`
1214
- : `${finalTrackConfig.margin}px`,
1215
- right: finalTrackConfig.alignment === "right"
1216
- ? "0px"
1217
- : `${(adjustedTrackWidth -
1218
- finalThumbConfig.width) /
1219
- 2}px`, // 트랙 정렬
1220
- width: `${finalThumbConfig.width}px`,
1221
- height: showArrows
1222
- ? `calc(100% - ${finalThumbConfig.width * 2 +
1223
- finalTrackConfig.margin * 4}px)`
1224
- : `calc(100% - ${finalTrackConfig.margin * 2}px)`,
1225
- backgroundColor: finalTrackConfig.color,
1226
- borderRadius: `${finalTrackConfig.radius}px`,
1227
- cursor: "pointer",
1228
- } })), jsxRuntime.jsx("div", { ref: thumbRef, className: "overlay-scrollbar-thumb", onMouseDown: handleThumbMouseDown, onMouseEnter: () => setIsThumbHovered(true), onMouseLeave: () => setIsThumbHovered(false), style: {
1229
- position: "absolute",
1230
- top: `${(showArrows
1231
- ? finalThumbWidth +
1232
- finalTrackConfig.margin * 2
1233
- : finalTrackConfig.margin) + thumbTop}px`,
1234
- right: finalTrackConfig.alignment === "right"
1235
- ? "0px"
1236
- : `${(adjustedTrackWidth -
1237
- finalThumbWidth) /
1238
- 2}px`, // 트랙 정렬
1239
- width: `${finalThumbWidth}px`,
1240
- height: `${Math.max(thumbHeight, thumbMinHeight)}px`,
1241
- backgroundColor: isThumbHovered || isDragging
1242
- ? finalThumbConfig.hoverColor
1243
- : finalThumbConfig.color,
1244
- opacity: isThumbHovered || isDragging
1245
- ? finalThumbConfig.hoverOpacity
1246
- : finalThumbConfig.opacity,
1247
- borderRadius: `${finalThumbConfig.radius}px`,
1248
- cursor: "pointer",
1249
- transition: "background-color 0.2s ease-in-out, opacity 0.2s ease-in-out",
1250
- } })] })), showScrollbar && hasScrollableContent && showArrows && (jsxRuntime.jsx("div", { className: "overlay-scrollbar-up-arrow", onClick: handleUpArrowClick, onMouseEnter: () => setHoveredArrow("up"), onMouseLeave: () => setHoveredArrow(null), style: {
1251
- position: "absolute",
1252
- top: `${finalTrackConfig.margin}px`,
1253
- right: finalTrackConfig.alignment === "right"
1254
- ? "0px"
1255
- : `${(adjustedTrackWidth -
1256
- finalThumbWidth) /
1257
- 2}px`, // 트랙 정렬
1258
- width: `${finalThumbWidth}px`,
1259
- height: `${finalThumbWidth}px`,
1260
- cursor: "pointer",
1261
- display: "flex",
1262
- alignItems: "center",
1263
- justifyContent: "center",
1264
- fontSize: `${Math.max(finalThumbWidth * 0.75, 8)}px`,
1265
- color: hoveredArrow === "up"
1266
- ? finalArrowsConfig.hoverColor
1267
- : finalArrowsConfig.color,
1268
- userSelect: "none",
1269
- zIndex: 1001,
1270
- opacity: scrollbarVisible
1271
- ? hoveredArrow === "up"
1272
- ? finalArrowsConfig.hoverOpacity
1273
- : finalArrowsConfig.opacity
1274
- : 0,
1275
- transition: "opacity 0.2s ease-in-out, color 0.15s ease-in-out",
1276
- }, children: "\u25B2" })), showScrollbar && hasScrollableContent && showArrows && (jsxRuntime.jsx("div", { className: "overlay-scrollbar-down-arrow", onClick: handleDownArrowClick, onMouseEnter: () => setHoveredArrow("down"), onMouseLeave: () => setHoveredArrow(null), style: {
1277
- position: "absolute",
1278
- bottom: `${finalTrackConfig.margin}px`,
1279
- right: finalTrackConfig.alignment === "right"
1280
- ? "0px"
1281
- : `${(adjustedTrackWidth -
1282
- finalThumbWidth) /
1283
- 2}px`, // 트랙 정렬
1284
- width: `${finalThumbWidth}px`,
1285
- height: `${finalThumbWidth}px`,
1286
- cursor: "pointer",
1287
- display: "flex",
1288
- alignItems: "center",
1289
- justifyContent: "center",
1290
- fontSize: `${Math.max(finalThumbWidth * 0.75, 8)}px`,
1291
- color: hoveredArrow === "down"
1292
- ? finalArrowsConfig.hoverColor
1293
- : finalArrowsConfig.color,
1294
- userSelect: "none",
1295
- zIndex: 1001,
1296
- opacity: scrollbarVisible
1297
- ? hoveredArrow === "down"
1298
- ? finalArrowsConfig.hoverOpacity
1299
- : finalArrowsConfig.opacity
1300
- : 0,
1301
- transition: "opacity 0.2s ease-in-out, color 0.15s ease-in-out",
1302
- }, children: "\u25BC" }))] }));
1303
- });
1304
-
1305
- // OverlayScrollbar 설정을 컴포넌트 외부에 상수로 선언 (재렌더링 시 동일한 참조 유지)
1306
- const OVERLAY_SCROLLBAR_TRACK_CONFIG = {
1307
- alignment: "right",
1308
- margin: 0,
1309
- radius: 0,
1310
- };
21
+ `,document.head.appendChild(l),()=>{let m=document.getElementById(r);m&&m.remove()}},[]),(0,X.jsxs)("div",{ref:Q,className:`overlay-scrollbar-wrapper ${a}`,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",...d},children:[(0,X.jsx)("div",{ref:p,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:Qe,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:ae?"none":"auto",...g},children:(0,X.jsx)("div",{ref:Y,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...v},children:x})}),A&&U&&(0,X.jsxs)("div",{ref:ee,className:"overlay-scrollbar-track",onMouseEnter:()=>{M(),ce.current=setTimeout(()=>{D(!0),ce.current=null},100)},onMouseLeave:()=>{ge(),I||C(e.delay)},style:{position:"absolute",top:0,right:0,width:`${Ee}px`,height:"100%",opacity:re?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[c.visible&&(0,X.jsx)("div",{className:"overlay-scrollbar-track-background",onClick:r=>{r.preventDefault(),r.stopPropagation(),_(r)},style:{position:"absolute",top:V?`${i.width+c.margin*2}px`:`${c.margin}px`,right:c.alignment==="right"?"0px":`${(Ee-i.width)/2}px`,width:`${i.width}px`,height:V?`calc(100% - ${i.width*2+c.margin*4}px)`:`calc(100% - ${c.margin*2}px)`,backgroundColor:c.color,borderRadius:`${c.radius}px`,cursor:"pointer"}}),(0,X.jsx)("div",{ref:te,className:"overlay-scrollbar-thumb",onMouseDown:De,onMouseEnter:()=>ve(!0),onMouseLeave:()=>ve(!1),style:{position:"absolute",top:`${(V?w+c.margin*2:c.margin)+ze}px`,right:c.alignment==="right"?"0px":`${(Ee-w)/2}px`,width:`${w}px`,height:`${Math.max(le,ue)}px`,backgroundColor:ne||I?i.hoverColor:i.color,opacity:ne||I?i.hoverOpacity:i.opacity,borderRadius:`${i.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),A&&U&&V&&(0,X.jsx)("div",{className:"overlay-scrollbar-up-arrow",onClick:Je,onMouseEnter:()=>se("up"),onMouseLeave:()=>se(null),style:{position:"absolute",top:`${c.margin}px`,right:c.alignment==="right"?"0px":`${(Ee-w)/2}px`,width:`${w}px`,height:`${w}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(w*.75,8)}px`,color:we==="up"?y.hoverColor:y.color,userSelect:"none",zIndex:1001,opacity:re?we==="up"?y.hoverOpacity:y.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),A&&U&&V&&(0,X.jsx)("div",{className:"overlay-scrollbar-down-arrow",onClick:Ze,onMouseEnter:()=>se("down"),onMouseLeave:()=>se(null),style:{position:"absolute",bottom:`${c.margin}px`,right:c.alignment==="right"?"0px":`${(Ee-w)/2}px`,width:`${w}px`,height:`${w}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(w*.75,8)}px`,color:we==="down"?y.hoverColor:y.color,userSelect:"none",zIndex:1001,opacity:re?we==="down"?y.hoverOpacity:y.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"})]})}),Ge=mt;var s=require("react/jsx-runtime"),ht={alignment:"right",margin:0,radius:0};function gt({data:a,loading:d=!1,columns:g,onRowClick:v,rowHeight:x=50,columnHeight:H=56,striped:L,rowDivider:j=!0,onSort:R,onLoadMore:z,sortBy:S,sortDirection:A,showPaper:J=!0,paddingX:Z="1rem",paddingTop:fe=0,paddingBottom:Q=0,rowHoverColor:p,rowHoverOpacity:Y,scrollbars:ee,emptyMessage:te="NO DATA",LoadingComponent:P}){let re=(0,u.useMemo)(()=>(0,u.forwardRef)((o,i)=>{let c=(0,u.useRef)(null);return(0,s.jsx)(Ge,{detectInnerScroll:!0,track:ht,...ee,children:(0,s.jsx)(f.TableContainer,{component:f.Box,...o,ref:y=>{c.current=y,typeof i=="function"?i(y):i&&(i.current=y)},sx:{userSelect:"auto",WebkitUserSelect:"auto",position:"relative",width:"100%",height:"100%",overflow:"auto",display:"flex",flexDirection:"column",scrollbarWidth:"none",msOverflowStyle:"none",transform:"translateZ(0)",backfaceVisibility:"hidden",willChange:"scroll-position","&::-webkit-scrollbar":{display:"none"},"& .MuiTable-root":{paddingRight:Z,paddingTop:fe,paddingBottom:Q}}})})}),[]),D=(0,u.useMemo)(()=>{if(L===!0)return"#f5f5f5";if(typeof L=="string")return L},[L]),[I,oe]=(0,u.useState)(d),[ne,ve]=(0,u.useState)(0);(0,u.useEffect)(()=>{d&&oe(!0)},[d]);let ie=(0,u.useCallback)(()=>{oe(!1)},[]),Te=I,le=d&&a.length>0,Se=(0,u.useRef)(!1),ze=(0,u.useRef)(null),q=(0,u.useRef)(null),U=(0,u.useRef)(!1),Ce=(0,u.useRef)({x:0,y:0,scrollTop:0}),ae=(0,u.useRef)(!1),ke=(0,u.useRef)(0),K=(0,u.useRef)(0),xe=(0,u.useRef)(!1),Ie=(0,u.useRef)({x:0,y:0}),Ke=(0,u.useRef)(null),we=(0,u.useCallback)(o=>{},[]),se=(0,u.useCallback)(o=>{if(!ae.current||!q.current)return;let i=o.clientY-Ce.current.y;if(!U.current&&Math.abs(i)>5&&(U.current=!0,q.current&&(q.current.style.userSelect="none")),U.current){let y=i*2;K.current+=-y;let W=q.current,e=Math.max(0,ke.current+K.current);W.scrollTop=e,Ce.current.y=o.clientY,o.preventDefault()}},[]),$e=(0,u.useCallback)(()=>{if(ae.current=!1,U.current&&q.current){let o=Math.max(0,ke.current+K.current),i=()=>{q.current&&(q.current.scrollTop=o)};i(),setTimeout(i,1),setTimeout(i,5),setTimeout(i,10)}U.current=!1,K.current=0,q.current&&(q.current.style.userSelect="auto")},[]);(0,u.useEffect)(()=>{let o=document.querySelector('[data-testid="virtuoso-scroller"]');o&&o.querySelectorAll(".MuiTableSortLabel-root").forEach(c=>{let y=new MouseEvent("mouseleave",{bubbles:!0,cancelable:!0});c.dispatchEvent(y)})},[S]);let Me=(0,u.useCallback)(o=>{if(!R)return;R(o,S===o&&A==="asc"?"desc":"asc")},[R,S,A]),me=(0,u.useCallback)(o=>{if(!z||d&&a.length===0)return;let i=Date.now(),c=window.lastRangeChangeTime||0;if(i-c<100)return;window.lastRangeChangeTime=i;let y=Math.max(10,Math.floor(a.length*.1)),W=o.endIndex>=a.length-y,e=a.length>=30;if(W&&e&&z&&!Se.current){Se.current=!0;let w=a.length;z(w,50)}},[a.length,d,z]);(0,u.useEffect)(()=>{d||(Se.current=!1)},[d]),(0,u.useEffect)(()=>{a.length===0&&ve(o=>o+1)},[a.length]),(0,u.useEffect)(()=>(document.addEventListener("mousemove",se),document.addEventListener("mouseup",$e),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",$e)}),[se,$e]);let Oe=(0,u.useCallback)(()=>{let o={},i=[];if(g.forEach(e=>{e.group?(o[e.group]||(o[e.group]=[]),o[e.group].push(e)):i.push(e)}),!(Object.keys(o).length>0))return(0,s.jsx)(f.TableRow,{children:g.map(e=>(0,s.jsx)(f.TableCell,{align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable?(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,s.jsxs)(f.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>Me(String(e.id)),children:[e.text,(0,s.jsx)(f.TableSortLabel,{active:S===e.id,direction:S===e.id?A:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:S===e.id?1:0,transition:"opacity 0.2s ease","& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(180deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(0deg)"}}})]})}):e.text},String(e.id)))});let y=[...i.map(e=>(0,s.jsx)(f.TableCell,{rowSpan:2,align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable&&R?(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,s.jsxs)(f.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>Me(String(e.id)),children:[e.text,(0,s.jsx)(f.TableSortLabel,{active:S===e.id,direction:S===e.id?A:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:S===e.id?1:0,transition:"opacity 0.2s ease","&:hover":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}},"& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(180deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(0deg)"}}})]})}):e.text},String(e.id))),...Object.entries(o).map(([e,w])=>(0,s.jsx)(f.TableCell,{align:"center",colSpan:w.length,style:{fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e},e))],W=[...Object.values(o).flat().map(e=>(0,s.jsx)(f.TableCell,{align:e.align||"left",style:{width:e.width,minWidth:e.width,...e.style,fontWeight:"bold",position:"sticky",top:0,zIndex:2,padding:"16px"},children:e.sortable&&R?(0,s.jsx)("div",{style:{display:"flex",alignItems:"center",justifyContent:e.align==="center"?"center":e.align==="right"?"flex-end":"flex-start",position:"relative",width:"100%"},children:(0,s.jsxs)(f.Box,{sx:{position:"relative",cursor:"default","&:hover .MuiTableSortLabel-root":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}}},onClick:()=>Me(String(e.id)),children:[e.text,(0,s.jsx)(f.TableSortLabel,{active:S===e.id,direction:S===e.id?A:"desc",sx:{position:"absolute",left:"100%",top:"50%",transform:"translateY(-50%)",marginLeft:"4px",minWidth:"auto",width:"16px",height:"16px",cursor:"default",opacity:S===e.id?1:0,transition:"opacity 0.2s ease","&:hover":{opacity:"1 !important","& .MuiSvgIcon-root":{color:"#000",opacity:"1 !important"}},"& .MuiTableSortLabel-icon":{position:"relative",marginLeft:0,marginRight:0,opacity:1,transition:"color 0.2s ease"},"& .MuiTableSortLabel-iconDirectionAsc":{transform:"rotate(0deg)"},"& .MuiTableSortLabel-iconDirectionDesc":{transform:"rotate(180deg)"}}})]})}):e.text},String(e.id)))];return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.TableRow,{children:y}),(0,s.jsx)(f.TableRow,{children:W})]})},[g,S,A,Me,R,H]),Pe=(0,u.useCallback)((o,i)=>i?(0,s.jsx)(s.Fragment,{children:g.map(c=>(0,s.jsx)(f.TableCell,{align:c.align||"left",style:{width:c.width,minWidth:c.width,...c.style,padding:"8px 16px"},children:c.render?c.render(i,o):String(i[c.id]||"")},String(c.id)))}):(console.log("rowContent - \uC544\uC774\uD15C \uC5C6\uC74C, \uC778\uB371\uC2A4:",o),null),[g]),he=(0,u.useMemo)(()=>({Scroller:re,Table:o=>(0,s.jsx)(f.Table,{...o,sx:{borderCollapse:"separate",tableLayout:"fixed",marginRight:"16px"}}),TableHead:(0,u.forwardRef)((o,i)=>(0,s.jsx)(f.TableHead,{...o,ref:i,sx:{userSelect:"none","& tr":{height:H,"& th":{padding:"16px",position:"sticky",top:0,zIndex:2,fontWeight:"bold"}}}})),TableRow:o=>{let{item:i,...c}=o,y=c["data-index"]??0,W=y%2===1;return(0,s.jsx)(f.TableRow,{...c,onMouseDown:e=>{xe.current=!1,Ie.current={x:e.clientX,y:e.clientY}},onMouseMove:e=>{let w=Math.abs(e.clientX-Ie.current.x),Le=Math.abs(e.clientY-Ie.current.y),ue=5;(w>ue||Le>ue)&&(xe.current=!0)},onClick:()=>{!xe.current&&!U.current&&i&&v&&v(i,y),xe.current=!1},sx:{userSelect:"none",height:x,backgroundColor:W&&D?D:"transparent","& td":{padding:"8px 16px",borderBottom:j?"1px solid rgba(224, 224, 224, 1)":"none"},"& th":{padding:"8px 16px",borderBottom:"none"},"&:hover":v?{backgroundColor:e=>{let w=e.palette.mode==="dark",ue=p??"#000000",V=Y??.06,de=ue.replace("#",""),$=parseInt(de.substring(0,2),16)/255,b=parseInt(de.substring(2,4),16)/255,O=parseInt(de.substring(4,6),16)/255;if(w){let M=Math.max($,b,O),ge=Math.min($,b,O),pe=0,C=0,h=(M+ge)/2;if(M!==ge){let E=M-ge;switch(C=h>.5?E/(2-M-ge):E/(M+ge),M){case $:pe=((b-O)/E+(b<O?6:0))/6;break;case b:pe=((O-$)/E+2)/6;break;case O:pe=(($-b)/E+4)/6;break}}h=1-h;let De=(E,F,_)=>(_<0&&(_+=1),_>1&&(_-=1),_<1/6?E+(F-E)*6*_:_<1/2?F:_<2/3?E+(F-E)*(2/3-_)*6:E);if(C===0)$=b=O=h;else{let E=h<.5?h*(1+C):h+C-h*C,F=2*h-E;$=De(F,E,pe+1/3),b=De(F,E,pe),O=De(F,E,pe-1/3)}}return`rgba(${Math.round($*255)}, ${Math.round(b*255)}, ${Math.round(O*255)}, ${V})`},transition:"background-color 0.2s ease"}:{}}})},TableBody:(0,u.forwardRef)((o,i)=>(0,s.jsx)(f.TableBody,{...o,ref:i}))}),[v,x,we,D,j,H,p,Y,re]),ce=(0,s.jsxs)(f.Box,{sx:{position:"relative",height:"100%",width:"100%","& .MuiTableHead-root":{backgroundColor:o=>o.palette.mode==="dark"?"#1e1e1e !important":"#ffffff !important"}},children:[(0,s.jsx)(Ue.TableVirtuoso,{ref:ze,data:a,totalCount:z?a.length+1:a.length,fixedHeaderContent:Oe,itemContent:Pe,rangeChanged:me,components:he,style:{height:"100%"},increaseViewportBy:{top:100,bottom:300},overscan:5,followOutput:!1},ne),a.length===0&&!d&&(0,s.jsx)(f.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2},children:typeof te=="string"?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(f.Box,{sx:{width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",backgroundColor:"#f5f5f5",color:"#999"},children:"\u{1F4C4}"}),(0,s.jsx)(f.Typography,{variant:"body1",sx:{color:"text.secondary"},children:te})]}):te}),Te&&(0,s.jsx)(s.Fragment,{children:P?(0,s.jsx)(P,{visible:d,onComplete:ie}):(0,s.jsx)(Fe,{visible:d,onComplete:ie,size:40,sx:{top:`${g.some(o=>o.group)?H*2:H}px`},background:{show:a.length===0,opacity:.8}})})]});return J?(0,s.jsx)(f.Paper,{className:"grow",elevation:1,sx:{padding:0,paddingLeft:Z,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:ce}):(0,s.jsx)(f.Box,{className:"grow",style:{padding:0,paddingLeft:Z,height:"100%",minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:ce})}var Xe=(0,u.memo)(gt);
1311
22
  /**
1312
- * 데이터 기반 무한 스크롤 가상화를 지원하는 테이블 컴포넌트
23
+ * Virtual Data Table - A high-performance virtual data table component for React
24
+ *
25
+ * @license MIT
26
+ * @copyright 2025 김영진 (Kim Young Jin)
27
+ * @author 김영진 (ehfuse@gmail.com)
1313
28
  */
1314
- function VirtualDataTableComponent({ data, loading = false, columns, onRowClick, rowHeight = 50, columnHeight = 56, striped, rowDivider = true, onSort, onLoadMore, sortBy, sortDirection, showPaper = true, paddingX = "1rem", paddingTop = 0, paddingBottom = 0, rowHoverColor, rowHoverOpacity, scrollbars, emptyMessage = "NO DATA", LoadingComponent, }) {
1315
- // console.log("=== VirtualDataTable 렌더링 ===", {
1316
- // dataLength: data.length,
1317
- // loading,
1318
- // onLoadMore: !!onLoadMore,
1319
- // columnsLength: columns.length,
1320
- // timestamp: new Date().toISOString(),
1321
- // });
1322
- // 각 테이블 인스턴스별로 Scroller 컴포넌트 생성 (scrollbars, paddingX를 초기값으로 고정)
1323
- const VirtuosoScroller = react.useMemo(() => react.forwardRef((props, ref) => {
1324
- const scrollContainerRef = react.useRef(null);
1325
- return (jsxRuntime.jsx(OverlayScrollbar, { track: OVERLAY_SCROLLBAR_TRACK_CONFIG, ...scrollbars, children: jsxRuntime.jsx(material.TableContainer, { component: material.Box, ...props, ref: (node) => {
1326
- scrollContainerRef.current =
1327
- node;
1328
- if (typeof ref === "function") {
1329
- ref(node);
1330
- }
1331
- else if (ref) {
1332
- ref.current = node;
1333
- }
1334
- }, sx: {
1335
- userSelect: "auto",
1336
- WebkitUserSelect: "auto",
1337
- position: "relative",
1338
- width: "100%",
1339
- height: "100%",
1340
- overflow: "auto",
1341
- display: "flex",
1342
- flexDirection: "column",
1343
- scrollbarWidth: "none",
1344
- msOverflowStyle: "none",
1345
- // 깜박임 방지를 위한 GPU 가속
1346
- transform: "translateZ(0)",
1347
- backfaceVisibility: "hidden",
1348
- willChange: "scroll-position",
1349
- "&::-webkit-scrollbar": {
1350
- display: "none",
1351
- },
1352
- "& .MuiTable-root": {
1353
- paddingRight: paddingX,
1354
- paddingTop: paddingTop,
1355
- paddingBottom: paddingBottom,
1356
- },
1357
- } }) }));
1358
- }),
1359
- // eslint-disable-next-line react-hooks/exhaustive-deps
1360
- [] // 빈 배열: 최초 마운트 시에만 생성, scrollbars, paddingX, paddingTop, paddingBottom은 클로저로 고정
1361
- );
1362
- // Striped row 배경색 계산
1363
- const stripedRowColor = react.useMemo(() => {
1364
- if (striped === true) {
1365
- return "#f5f5f5"; // 기본 회색
1366
- }
1367
- else if (typeof striped === "string") {
1368
- return striped; // 사용자 지정 색상
1369
- }
1370
- return undefined; // 배경색 없음
1371
- }, [striped]);
1372
- // 로딩 상태 관리 (원본 방식)
1373
- const [internalLoading, setInternalLoading] = react.useState(loading);
1374
- // 테이블 재마운트를 위한 키 (데이터가 비워지면 재마운트)
1375
- const [tableKey, setTableKey] = react.useState(0);
1376
- // 로딩 상태 변경 감지
1377
- react.useEffect(() => {
1378
- if (loading) {
1379
- // 로딩이 시작되면 즉시 표시
1380
- setInternalLoading(true);
1381
- }
1382
- // 로딩이 끝나도 internalLoading은 handleLoadingComplete에서만 false로 설정
1383
- // LoadingProgress에서는 visible={false}로 페이드아웃을 시작함
1384
- }, [loading]);
1385
- // 로딩 완료 핸들러 - LoadingProgress의 페이드아웃이 완료된 후 호출됨
1386
- const handleLoadingComplete = react.useCallback(() => {
1387
- setInternalLoading(false);
1388
- }, []);
1389
- // 로딩 오버레이 표시 조건
1390
- const shouldShowLoading = internalLoading;
1391
- // 더보기 로딩 여부 (데이터가 있고 로딩 중이면 더보기 로딩)
1392
- loading && data.length > 0;
1393
- // 무한 스크롤 로딩 상태 (기존 VirtualDataTable 방식)
1394
- const isLoadingMoreRef = react.useRef(false);
1395
- const virtuosoRef = react.useRef(null); // TableVirtuoso ref
1396
- // 스크롤 컨테이너 참조 (OverlayScrollbar용)
1397
- const scrollContainerRef = react.useRef(null); // 드래그 스크롤 상태 (OverlayScrollbar 사용시에는 비활성화)
1398
- const isDraggingRef = react.useRef(false);
1399
- const dragStartRef = react.useRef({ x: 0, y: 0, scrollTop: 0 });
1400
- const isMouseDownRef = react.useRef(false);
1401
- const initialScrollTopRef = react.useRef(0);
1402
- const totalDragDistanceRef = react.useRef(0);
1403
- const isScrollDraggingRef = react.useRef(false); // OverlayScrollbar 드래그 스크롤 감지용
1404
- const mouseDownPositionRef = react.useRef({ x: 0, y: 0 }); // 마우스 다운 시작 위치
1405
- react.useRef(null);
1406
- /**
1407
- * 마우스 버튼 누름 이벤트 핸들러
1408
- * OverlayScrollbar 사용시에는 기본 드래그 스크롤을 비활성화
1409
- */
1410
- const handleMouseDown = react.useCallback((e) => {
1411
- // OverlayScrollbar를 사용하므로 기본 드래그 스크롤 비활성화
1412
- // OverlayScrollbar가 자체적으로 스크롤을 처리함
1413
- return;
1414
- }, []);
1415
- /**
1416
- * 마우스 이동 이벤트 핸들러
1417
- * 드래그 스크롤 기능의 핵심 로직
1418
- */
1419
- const handleMouseMove = react.useCallback((e) => {
1420
- if (!isMouseDownRef.current || !scrollContainerRef.current)
1421
- return;
1422
- const deltaY = e.clientY - dragStartRef.current.y;
1423
- const threshold = 5; // 드래그 감지 임계값
1424
- // 임계값을 넘어야 드래그로 인식
1425
- if (!isDraggingRef.current && Math.abs(deltaY) > threshold) {
1426
- isDraggingRef.current = true;
1427
- // DOM 스타일 직접 변경 (리렌더링 방지)
1428
- if (scrollContainerRef.current) {
1429
- scrollContainerRef.current.style.userSelect = "none";
1430
- }
1431
- }
1432
- if (isDraggingRef.current) {
1433
- // 드래그 거리 누적
1434
- const dragDelta = deltaY * 2; // 감도 조절
1435
- totalDragDistanceRef.current += -dragDelta; // 드래그 방향과 반대
1436
- // 스크롤 위치 계산 (초기 위치 + 누적 드래그 거리)
1437
- const scrollContainer = scrollContainerRef.current;
1438
- const newScrollTop = Math.max(0, initialScrollTopRef.current + totalDragDistanceRef.current);
1439
- // 스크롤 위치 설정
1440
- scrollContainer.scrollTop = newScrollTop;
1441
- // 드래그 시작점 업데이트 (연속적인 드래그를 위해)
1442
- dragStartRef.current.y = e.clientY;
1443
- e.preventDefault();
1444
- }
1445
- }, []);
1446
- /**
1447
- * 마우스 버튼 해제 이벤트 핸들러
1448
- * 드래그 스크롤 종료 및 상태 초기화
1449
- */
1450
- const handleMouseUp = react.useCallback(() => {
1451
- isMouseDownRef.current = false;
1452
- // 드래그가 진행되었다면 최종 스크롤 위치 계산 및 설정
1453
- if (isDraggingRef.current && scrollContainerRef.current) {
1454
- const finalScrollTop = Math.max(0, initialScrollTopRef.current + totalDragDistanceRef.current);
1455
- // 스크롤 위치를 여러 번 강제로 설정하여 확실히 고정
1456
- const setScrollPosition = () => {
1457
- if (scrollContainerRef.current) {
1458
- scrollContainerRef.current.scrollTop = finalScrollTop;
1459
- }
1460
- };
1461
- // 즉시 설정 및 지연 설정 (스크롤 안정화)
1462
- setScrollPosition();
1463
- setTimeout(setScrollPosition, 1);
1464
- setTimeout(setScrollPosition, 5);
1465
- setTimeout(setScrollPosition, 10);
1466
- }
1467
- // 드래그 상태 초기화 (리렌더링 방지를 위해 ref만 사용)
1468
- isDraggingRef.current = false;
1469
- totalDragDistanceRef.current = 0;
1470
- // DOM 스타일 초기화
1471
- if (scrollContainerRef.current) {
1472
- scrollContainerRef.current.style.userSelect = "auto";
1473
- }
1474
- }, []);
1475
- // 정렬이 변경될 때 모든 TableSortLabel의 hover 상태 초기화
1476
- react.useEffect(() => {
1477
- // sortBy가 변경되면 모든 TableSortLabel 요소의 hover 상태를 강제로 초기화
1478
- const tableContainer = document.querySelector('[data-testid="virtuoso-scroller"]');
1479
- if (tableContainer) {
1480
- const sortLabels = tableContainer.querySelectorAll(".MuiTableSortLabel-root");
1481
- sortLabels.forEach((label) => {
1482
- // 마우스 이벤트를 시뮬레이션하여 hover 상태 해제
1483
- const mouseLeaveEvent = new MouseEvent("mouseleave", {
1484
- bubbles: true,
1485
- cancelable: true,
1486
- });
1487
- label.dispatchEvent(mouseLeaveEvent);
1488
- });
1489
- }
1490
- }, [sortBy]);
1491
- // 정렬 핸들러
1492
- const handleSort = react.useCallback((columnId) => {
1493
- if (!onSort)
1494
- return;
1495
- const newDirection = sortBy === columnId && sortDirection === "asc" ? "desc" : "asc";
1496
- onSort(columnId, newDirection);
1497
- }, [onSort, sortBy, sortDirection]);
1498
- // 가상화 스크롤 범위 변경 감지 핸들러 (기존 VirtualDataTable 방식)
1499
- const handleRangeChange = react.useCallback((range) => {
1500
- // onLoadMore가 없으면 무한 스크롤 비활성화
1501
- if (!onLoadMore) {
1502
- return;
1503
- }
1504
- // 이미 로딩 중이면 중단 (초기 로딩만 체크, 더 가져오기 로딩은 허용)
1505
- if (loading && data.length === 0) {
1506
- return;
1507
- }
1508
- // 추가 안전장치: 너무 빠른 연속 호출 방지 (100ms 내 중복 호출 무시)
1509
- const now = Date.now();
1510
- const lastTime = window.lastRangeChangeTime || 0;
1511
- if (now - lastTime < 100) {
1512
- return;
1513
- }
1514
- window.lastRangeChangeTime = now;
1515
- // 더 보수적인 조건: 90% 지점에서 로드 (기존 VirtualDataTable 방식)
1516
- const bufferSize = Math.max(10, Math.floor(data.length * 0.1)); // 데이터의 10% 또는 최소 10개
1517
- const shouldLoadMore = range.endIndex >= data.length - bufferSize;
1518
- // 추가 조건: 최소 30개 이상의 데이터에서만 더 가져오기 실행
1519
- const hasMinimumData = data.length >= 30;
1520
- if (shouldLoadMore &&
1521
- hasMinimumData &&
1522
- onLoadMore &&
1523
- !isLoadingMoreRef.current) {
1524
- isLoadingMoreRef.current = true;
1525
- const offset = data.length;
1526
- const limit = 50;
1527
- // console.log(">>> loadMore 호출 직전", {
1528
- // offset,
1529
- // limit,
1530
- // range,
1531
- // dataLength: data.length,
1532
- // bufferSize,
1533
- // endIndex: range.endIndex,
1534
- // threshold: data.length - bufferSize,
1535
- // timestamp: new Date().toISOString(),
1536
- // });
1537
- onLoadMore(offset, limit);
1538
- // console.log(">>> loadMore 호출 완료");
1539
- }
1540
- }, [data.length, loading, onLoadMore]);
1541
- // 로딩 상태가 변경되면 isLoadingMoreRef 업데이트 (기존 VirtualDataTable 방식)
1542
- react.useEffect(() => {
1543
- if (!loading) {
1544
- isLoadingMoreRef.current = false;
1545
- }
1546
- }, [loading]);
1547
- // 데이터가 비워지면 테이블을 재마운트하여 스크롤을 맨 위로 이동
1548
- react.useEffect(() => {
1549
- if (data.length === 0) {
1550
- setTableKey((prev) => prev + 1);
1551
- }
1552
- }, [data.length]);
1553
- /**
1554
- * 전역 마우스 이벤트 리스너 설정
1555
- * 드래그가 테이블 영역을 벗어나도 동작하도록 document에 이벤트 리스너 등록
1556
- */
1557
- react.useEffect(() => {
1558
- document.addEventListener("mousemove", handleMouseMove);
1559
- document.addEventListener("mouseup", handleMouseUp);
1560
- return () => {
1561
- document.removeEventListener("mousemove", handleMouseMove);
1562
- document.removeEventListener("mouseup", handleMouseUp);
1563
- };
1564
- }, [handleMouseMove, handleMouseUp]);
1565
- /**
1566
- * 테이블 고정 헤더 컨텐츠 정의 (기존 VirtualDataTable 스타일)
1567
- * 정렬 기능이 포함된 컬럼 헤더를 렌더링
1568
- */
1569
- const fixedHeaderContent = react.useCallback(() => {
1570
- // 1. 그룹 정보 추출
1571
- const groupMap = {};
1572
- const noGroupColumns = [];
1573
- columns.forEach((col) => {
1574
- if (col.group) {
1575
- if (!groupMap[col.group]) {
1576
- groupMap[col.group] = [];
1577
- }
1578
- groupMap[col.group].push(col);
1579
- }
1580
- else {
1581
- noGroupColumns.push(col);
1582
- }
1583
- });
1584
- // 그룹이 있는 경우 2줄 헤더, 없는 경우 1줄 헤더
1585
- const hasGroups = Object.keys(groupMap).length > 0;
1586
- if (!hasGroups) {
1587
- // 단일 행 헤더
1588
- return (jsxRuntime.jsx(material.TableRow, { children: columns.map((col) => (jsxRuntime.jsx(material.TableCell, { align: col.align || "left", style: {
1589
- width: col.width,
1590
- minWidth: col.width,
1591
- ...col.style,
1592
- fontWeight: "bold",
1593
- position: "sticky",
1594
- top: 0,
1595
- zIndex: 2,
1596
- padding: "16px",
1597
- }, children: col.sortable ? (jsxRuntime.jsx("div", { style: {
1598
- display: "flex",
1599
- alignItems: "center",
1600
- justifyContent: col.align === "center"
1601
- ? "center"
1602
- : col.align === "right"
1603
- ? "flex-end"
1604
- : "flex-start",
1605
- position: "relative",
1606
- width: "100%",
1607
- }, children: jsxRuntime.jsxs(material.Box, { sx: {
1608
- position: "relative",
1609
- cursor: "default",
1610
- "&:hover .MuiTableSortLabel-root": {
1611
- opacity: "1 !important",
1612
- "& .MuiSvgIcon-root": {
1613
- color: "#000",
1614
- opacity: "1 !important",
1615
- },
1616
- },
1617
- }, onClick: () => handleSort(String(col.id)), children: [col.text, jsxRuntime.jsx(material.TableSortLabel, { active: sortBy === col.id, direction: sortBy === col.id
1618
- ? sortDirection
1619
- : "desc", sx: {
1620
- position: "absolute",
1621
- left: "100%",
1622
- top: "50%",
1623
- transform: "translateY(-50%)",
1624
- marginLeft: "4px",
1625
- minWidth: "auto",
1626
- width: "16px",
1627
- height: "16px",
1628
- cursor: "default",
1629
- opacity: sortBy === col.id ? 1 : 0,
1630
- transition: "opacity 0.2s ease",
1631
- "& .MuiTableSortLabel-icon": {
1632
- position: "relative",
1633
- marginLeft: 0,
1634
- marginRight: 0,
1635
- opacity: 1,
1636
- transition: "color 0.2s ease",
1637
- },
1638
- "& .MuiTableSortLabel-iconDirectionAsc": {
1639
- transform: "rotate(180deg)",
1640
- },
1641
- "& .MuiTableSortLabel-iconDirectionDesc": {
1642
- transform: "rotate(0deg)",
1643
- },
1644
- } })] }) })) : (col.text) }, String(col.id)))) }));
1645
- }
1646
- // 2줄 헤더 (그룹이 있는 경우)
1647
- const firstRowCells = [
1648
- ...noGroupColumns.map((col) => (jsxRuntime.jsx(material.TableCell, { rowSpan: 2, align: col.align || "left", style: {
1649
- width: col.width,
1650
- minWidth: col.width,
1651
- ...col.style,
1652
- fontWeight: "bold",
1653
- position: "sticky",
1654
- top: 0,
1655
- zIndex: 2,
1656
- padding: "16px",
1657
- }, children: col.sortable && onSort ? (jsxRuntime.jsx("div", { style: {
1658
- display: "flex",
1659
- alignItems: "center",
1660
- justifyContent: col.align === "center"
1661
- ? "center"
1662
- : col.align === "right"
1663
- ? "flex-end"
1664
- : "flex-start",
1665
- position: "relative",
1666
- width: "100%",
1667
- }, children: jsxRuntime.jsxs(material.Box, { sx: {
1668
- position: "relative",
1669
- cursor: "default",
1670
- "&:hover .MuiTableSortLabel-root": {
1671
- opacity: "1 !important",
1672
- "& .MuiSvgIcon-root": {
1673
- color: "#000",
1674
- opacity: "1 !important",
1675
- },
1676
- },
1677
- }, onClick: () => handleSort(String(col.id)), children: [col.text, jsxRuntime.jsx(material.TableSortLabel, { active: sortBy === col.id, direction: sortBy === col.id
1678
- ? sortDirection
1679
- : "desc", sx: {
1680
- position: "absolute",
1681
- left: "100%",
1682
- top: "50%",
1683
- transform: "translateY(-50%)",
1684
- marginLeft: "4px",
1685
- minWidth: "auto",
1686
- width: "16px",
1687
- height: "16px",
1688
- cursor: "default",
1689
- opacity: sortBy === col.id ? 1 : 0,
1690
- transition: "opacity 0.2s ease",
1691
- "&:hover": {
1692
- opacity: "1 !important",
1693
- "& .MuiSvgIcon-root": {
1694
- color: "#000",
1695
- opacity: "1 !important",
1696
- },
1697
- },
1698
- "& .MuiTableSortLabel-icon": {
1699
- position: "relative",
1700
- marginLeft: 0,
1701
- marginRight: 0,
1702
- opacity: 1,
1703
- transition: "color 0.2s ease",
1704
- },
1705
- "& .MuiTableSortLabel-iconDirectionAsc": {
1706
- transform: "rotate(180deg)",
1707
- },
1708
- "& .MuiTableSortLabel-iconDirectionDesc": {
1709
- transform: "rotate(0deg)",
1710
- },
1711
- } })] }) })) : (col.text) }, String(col.id)))),
1712
- ...Object.entries(groupMap).map(([group, cols]) => (jsxRuntime.jsx(material.TableCell, { align: "center", colSpan: cols.length, style: {
1713
- fontWeight: "bold",
1714
- position: "sticky",
1715
- top: 0,
1716
- zIndex: 2,
1717
- padding: "16px",
1718
- }, children: group }, group))),
1719
- ];
1720
- const secondRowCells = [
1721
- ...Object.values(groupMap)
1722
- .flat()
1723
- .map((col) => (jsxRuntime.jsx(material.TableCell, { align: col.align || "left", style: {
1724
- width: col.width,
1725
- minWidth: col.width,
1726
- ...col.style,
1727
- fontWeight: "bold",
1728
- position: "sticky",
1729
- top: 0,
1730
- zIndex: 2,
1731
- padding: "16px",
1732
- }, children: col.sortable && onSort ? (jsxRuntime.jsx("div", { style: {
1733
- display: "flex",
1734
- alignItems: "center",
1735
- justifyContent: col.align === "center"
1736
- ? "center"
1737
- : col.align === "right"
1738
- ? "flex-end"
1739
- : "flex-start",
1740
- position: "relative",
1741
- width: "100%",
1742
- }, children: jsxRuntime.jsxs(material.Box, { sx: {
1743
- position: "relative",
1744
- cursor: "default",
1745
- "&:hover .MuiTableSortLabel-root": {
1746
- opacity: "1 !important",
1747
- "& .MuiSvgIcon-root": {
1748
- color: "#000",
1749
- opacity: "1 !important",
1750
- },
1751
- },
1752
- }, onClick: () => handleSort(String(col.id)), children: [col.text, jsxRuntime.jsx(material.TableSortLabel, { active: sortBy === col.id, direction: sortBy === col.id
1753
- ? sortDirection
1754
- : "desc", sx: {
1755
- position: "absolute",
1756
- left: "100%",
1757
- top: "50%",
1758
- transform: "translateY(-50%)",
1759
- marginLeft: "4px",
1760
- minWidth: "auto",
1761
- width: "16px",
1762
- height: "16px",
1763
- cursor: "default",
1764
- opacity: sortBy === col.id ? 1 : 0,
1765
- transition: "opacity 0.2s ease",
1766
- "&:hover": {
1767
- opacity: "1 !important",
1768
- "& .MuiSvgIcon-root": {
1769
- color: "#000",
1770
- opacity: "1 !important",
1771
- },
1772
- },
1773
- "& .MuiTableSortLabel-icon": {
1774
- position: "relative",
1775
- marginLeft: 0,
1776
- marginRight: 0,
1777
- opacity: 1,
1778
- transition: "color 0.2s ease",
1779
- },
1780
- "& .MuiTableSortLabel-iconDirectionAsc": {
1781
- transform: "rotate(0deg)",
1782
- },
1783
- "& .MuiTableSortLabel-iconDirectionDesc": {
1784
- transform: "rotate(180deg)",
1785
- },
1786
- } })] }) })) : (col.text) }, String(col.id)))),
1787
- ];
1788
- return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.TableRow, { children: firstRowCells }), jsxRuntime.jsx(material.TableRow, { children: secondRowCells })] }));
1789
- }, [columns, sortBy, sortDirection, handleSort, onSort, columnHeight]);
1790
- /**
1791
- * 테이블 행 컨텐츠 렌더링 함수 (기존 VirtualDataTable 스타일)
1792
- * 각 데이터 항목에 대한 셀 내용을 정의
1793
- */
1794
- const rowContent = react.useCallback((index, item) => {
1795
- // console.log("rowContent 렌더링:", { index, item: item ? "있음" : "없음" });
1796
- if (!item) {
1797
- console.log("rowContent - 아이템 없음, 인덱스:", index);
1798
- return null;
1799
- }
1800
- return (jsxRuntime.jsx(jsxRuntime.Fragment, { children: columns.map((column) => (jsxRuntime.jsx(material.TableCell, { align: column.align || "left", style: {
1801
- width: column.width,
1802
- minWidth: column.width,
1803
- ...column.style,
1804
- padding: "8px 16px",
1805
- }, children: column.render
1806
- ? column.render(item, index)
1807
- : String(item[column.id] || "") }, String(column.id)))) }));
1808
- }, [columns]);
1809
- // 테이블 컴포넌트 정의 (기존 VirtualDataTable 스타일)
1810
- const VirtuosoTableComponents = react.useMemo(() => ({
1811
- // 스크롤 컨테이너 (외부에서 한 번만 생성된 안정적인 컴포넌트 사용)
1812
- Scroller: VirtuosoScroller,
1813
- // 테이블 컴포넌트
1814
- Table: (props) => (jsxRuntime.jsx(material.Table, { ...props, sx: {
1815
- borderCollapse: "separate",
1816
- tableLayout: "fixed",
1817
- marginRight: "16px",
1818
- } })),
1819
- // 테이블 헤더 (고정 위치)
1820
- TableHead: react.forwardRef((props, ref) => (jsxRuntime.jsx(material.TableHead, { ...props, ref: ref, sx: {
1821
- userSelect: "none",
1822
- "& tr": {
1823
- height: columnHeight,
1824
- "& th": {
1825
- padding: "16px",
1826
- position: "sticky",
1827
- top: 0,
1828
- zIndex: 2,
1829
- fontWeight: "bold",
1830
- },
1831
- },
1832
- } }))),
1833
- // 테이블 행 (클릭 이벤트 및 호버 효과 포함)
1834
- // 테이블 행 (클릭 이벤트 및 호버 효과 포함)
1835
- TableRow: (props) => {
1836
- const { item, ...rest } = props;
1837
- // react-virtuoso는 'data-index' 속성으로 index를 전달합니다
1838
- const rowIndex = rest["data-index"] ?? 0;
1839
- const isOddRow = rowIndex % 2 === 1;
1840
- return (jsxRuntime.jsx(material.TableRow, { ...rest, onMouseDown: (e) => {
1841
- // 마우스 다운 시 드래그 플래그 초기화 및 시작 위치 저장
1842
- isScrollDraggingRef.current = false;
1843
- mouseDownPositionRef.current = {
1844
- x: e.clientX,
1845
- y: e.clientY,
1846
- };
1847
- }, onMouseMove: (e) => {
1848
- // 마우스가 5px 이상 움직였을 때만 드래그로 간주
1849
- const deltaX = Math.abs(e.clientX - mouseDownPositionRef.current.x);
1850
- const deltaY = Math.abs(e.clientY - mouseDownPositionRef.current.y);
1851
- const dragThreshold = 5; // 5px 임계값
1852
- if (deltaX > dragThreshold ||
1853
- deltaY > dragThreshold) {
1854
- isScrollDraggingRef.current = true;
1855
- }
1856
- }, onClick: () => {
1857
- // 드래그 스크롤이 아니고, 아이템이 있고, onRowClick이 있을 때만 실행
1858
- if (!isScrollDraggingRef.current &&
1859
- !isDraggingRef.current &&
1860
- item &&
1861
- onRowClick) {
1862
- onRowClick(item, rowIndex);
1863
- }
1864
- // 클릭 후 플래그 리셋
1865
- isScrollDraggingRef.current = false;
1866
- }, sx: {
1867
- userSelect: "none",
1868
- height: rowHeight,
1869
- backgroundColor: isOddRow && stripedRowColor
1870
- ? stripedRowColor
1871
- : "transparent",
1872
- "& td": {
1873
- padding: "8px 16px",
1874
- borderBottom: rowDivider
1875
- ? "1px solid rgba(224, 224, 224, 1)"
1876
- : "none",
1877
- },
1878
- "& th": {
1879
- padding: "8px 16px",
1880
- borderBottom: "none",
1881
- },
1882
- "&:hover": onRowClick
1883
- ? {
1884
- backgroundColor: (theme) => {
1885
- const isDark = theme.palette.mode === "dark";
1886
- const defaultColor = "#000000";
1887
- const color = rowHoverColor ?? defaultColor;
1888
- const opacity = rowHoverOpacity ?? 0.06;
1889
- // hex를 rgb로 변환
1890
- const hex = color.replace("#", "");
1891
- let r = parseInt(hex.substring(0, 2), 16) / 255;
1892
- let g = parseInt(hex.substring(2, 4), 16) / 255;
1893
- let b = parseInt(hex.substring(4, 6), 16) / 255;
1894
- // 다크 모드일 때 밝기만 반전 (HSL 변환)
1895
- if (isDark) {
1896
- // RGB to HSL
1897
- const max = Math.max(r, g, b);
1898
- const min = Math.min(r, g, b);
1899
- let h = 0, s = 0, l = (max + min) / 2;
1900
- if (max !== min) {
1901
- const d = max - min;
1902
- s =
1903
- l > 0.5
1904
- ? d / (2 - max - min)
1905
- : d / (max + min);
1906
- switch (max) {
1907
- case r:
1908
- h =
1909
- ((g - b) / d +
1910
- (g < b
1911
- ? 6
1912
- : 0)) /
1913
- 6;
1914
- break;
1915
- case g:
1916
- h =
1917
- ((b - r) / d +
1918
- 2) /
1919
- 6;
1920
- break;
1921
- case b:
1922
- h =
1923
- ((r - g) / d +
1924
- 4) /
1925
- 6;
1926
- break;
1927
- }
1928
- }
1929
- // 밝기만 반전 (0.0 <-> 1.0)
1930
- l = 1 - l;
1931
- // HSL to RGB
1932
- const hue2rgb = (p, q, t) => {
1933
- if (t < 0)
1934
- t += 1;
1935
- if (t > 1)
1936
- t -= 1;
1937
- if (t < 1 / 6)
1938
- return (p + (q - p) * 6 * t);
1939
- if (t < 1 / 2)
1940
- return q;
1941
- if (t < 2 / 3)
1942
- return (p +
1943
- (q - p) *
1944
- (2 / 3 - t) *
1945
- 6);
1946
- return p;
1947
- };
1948
- if (s === 0) {
1949
- r = g = b = l;
1950
- }
1951
- else {
1952
- const q = l < 0.5
1953
- ? l * (1 + s)
1954
- : l + s - l * s;
1955
- const p = 2 * l - q;
1956
- r = hue2rgb(p, q, h + 1 / 3);
1957
- g = hue2rgb(p, q, h);
1958
- b = hue2rgb(p, q, h - 1 / 3);
1959
- }
1960
- }
1961
- return `rgba(${Math.round(r * 255)}, ${Math.round(g * 255)}, ${Math.round(b * 255)}, ${opacity})`;
1962
- },
1963
- transition: "background-color 0.2s ease",
1964
- }
1965
- : {},
1966
- } }));
1967
- },
1968
- // 테이블 바디
1969
- TableBody: react.forwardRef((props, ref) => (jsxRuntime.jsx(material.TableBody, { ...props, ref: ref }))),
1970
- }), [
1971
- onRowClick,
1972
- rowHeight,
1973
- handleMouseDown,
1974
- stripedRowColor,
1975
- rowDivider,
1976
- columnHeight,
1977
- rowHoverColor,
1978
- rowHoverOpacity,
1979
- VirtuosoScroller,
1980
- ]);
1981
- // 공통 테이블 내용
1982
- const tableContent = (jsxRuntime.jsxs(material.Box, { sx: {
1983
- position: "relative",
1984
- height: "100%",
1985
- width: "100%",
1986
- "& .MuiTableHead-root": {
1987
- backgroundColor: (theme) => theme.palette.mode === "dark"
1988
- ? "#1e1e1e !important"
1989
- : "#ffffff !important",
1990
- },
1991
- }, children: [jsxRuntime.jsx(reactVirtuoso.TableVirtuoso, { ref: virtuosoRef, data: data, totalCount: onLoadMore ? data.length + 1 : data.length, fixedHeaderContent: fixedHeaderContent, itemContent: rowContent, rangeChanged: handleRangeChange, components: VirtuosoTableComponents, style: { height: "100%" }, increaseViewportBy: { top: 100, bottom: 300 }, overscan: 5, followOutput: false }, tableKey), data.length === 0 && !loading && (jsxRuntime.jsx(material.Box, { sx: {
1992
- position: "absolute",
1993
- top: 0,
1994
- left: 0,
1995
- right: 0,
1996
- bottom: 0,
1997
- display: "flex",
1998
- flexDirection: "column",
1999
- alignItems: "center",
2000
- justifyContent: "center",
2001
- gap: 2,
2002
- }, children: typeof emptyMessage === "string" ? (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsx(material.Box, { sx: {
2003
- width: 48,
2004
- height: 48,
2005
- display: "flex",
2006
- alignItems: "center",
2007
- justifyContent: "center",
2008
- borderRadius: "50%",
2009
- backgroundColor: "#f5f5f5",
2010
- color: "#999",
2011
- }, children: "\uD83D\uDCC4" }), jsxRuntime.jsx(material.Typography, { variant: "body1", sx: { color: "text.secondary" }, children: emptyMessage })] })) : (emptyMessage) })), shouldShowLoading && (jsxRuntime.jsx(jsxRuntime.Fragment, { children: LoadingComponent ? (jsxRuntime.jsx(LoadingComponent, { visible: loading, onComplete: handleLoadingComplete })) : (jsxRuntime.jsx(LoadingProgress, { visible: loading, onComplete: handleLoadingComplete, size: 40, sx: {
2012
- top: `${columns.some((col) => col.group)
2013
- ? columnHeight * 2
2014
- : columnHeight}px`,
2015
- }, background: {
2016
- show: data.length === 0, // 최초 로딩에만 배경 표시
2017
- opacity: 0.8,
2018
- } })) }))] }));
2019
- return showPaper ? (jsxRuntime.jsx(material.Paper, { className: "grow", elevation: 1, sx: {
2020
- padding: 0,
2021
- paddingLeft: paddingX,
2022
- height: "100%",
2023
- minHeight: 0,
2024
- flex: 1,
2025
- display: "flex",
2026
- flexDirection: "column",
2027
- }, children: tableContent })) : (jsxRuntime.jsx(material.Box, { className: "grow", style: {
2028
- padding: 0,
2029
- paddingLeft: paddingX,
2030
- height: "100%",
2031
- minHeight: 0,
2032
- flex: 1,
2033
- display: "flex",
2034
- flexDirection: "column",
2035
- }, children: tableContent }));
2036
- }
2037
- const VirtualDataTable = react.memo(VirtualDataTableComponent);
2038
-
2039
- exports.VirtualDataTable = VirtualDataTable;
2040
29
  //# sourceMappingURL=index.js.map