@ehfuse/overlay-scrollbar 1.5.8 → 1.5.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.d.ts +4 -151
- package/dist/index.esm.js +2 -1178
- package/dist/index.esm.js.map +7 -1
- package/dist/index.js +2 -1183
- package/dist/index.js.map +7 -1
- package/dist/src/OverlayScrollbar.d.ts.map +1 -1
- package/package.json +4 -8
package/dist/index.js
CHANGED
|
@@ -1,1046 +1,4 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
-
var react = require('react');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* MIT License
|
|
10
|
-
*
|
|
11
|
-
* Copyright (c) 2025 KIM YOUNG JIN (ehfuse@gmail.com)
|
|
12
|
-
*
|
|
13
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
14
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
15
|
-
* in the Software without restriction, including without limitation the rights
|
|
16
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
17
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
18
|
-
* furnished to do so, subject to the following conditions:
|
|
19
|
-
*
|
|
20
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
21
|
-
* copies or substantial portions of the Software.
|
|
22
|
-
*
|
|
23
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
24
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
25
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
26
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
27
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
28
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
29
|
-
* SOFTWARE.
|
|
30
|
-
*/
|
|
31
|
-
// 드래그 스크롤을 제외할 클래스들 (자신 또는 부모 요소에서 확인)
|
|
32
|
-
const DEFAULT_EXCLUDE_CLASSES = [
|
|
33
|
-
// 기본 입력 요소들
|
|
34
|
-
"editor",
|
|
35
|
-
"textarea",
|
|
36
|
-
"input",
|
|
37
|
-
"select",
|
|
38
|
-
"textfield",
|
|
39
|
-
"form-control",
|
|
40
|
-
"contenteditable",
|
|
41
|
-
// Material-UI 컴포넌트들
|
|
42
|
-
"MuiInputBase-input",
|
|
43
|
-
"MuiSelect-select",
|
|
44
|
-
"MuiOutlinedInput-input",
|
|
45
|
-
"MuiFilledInput-input",
|
|
46
|
-
"MuiInput-input",
|
|
47
|
-
"MuiFormControl-root",
|
|
48
|
-
"MuiTextField-root",
|
|
49
|
-
"MuiSelect-root",
|
|
50
|
-
"MuiOutlinedInput-root",
|
|
51
|
-
"MuiFilledInput-root",
|
|
52
|
-
"MuiInput-root",
|
|
53
|
-
"MuiAutocomplete-input",
|
|
54
|
-
"MuiDatePicker-input",
|
|
55
|
-
"MuiSlider-thumb",
|
|
56
|
-
"MuiSlider-rail",
|
|
57
|
-
"MuiSlider-track",
|
|
58
|
-
"MuiSlider-mark",
|
|
59
|
-
"MuiSlider-markLabel",
|
|
60
|
-
"MuiSlider-root",
|
|
61
|
-
"MuiSlider-colorPrimary",
|
|
62
|
-
"MuiSlider-sizeMedium",
|
|
63
|
-
"MuiIconButton-root",
|
|
64
|
-
"MuiButton-root",
|
|
65
|
-
"MuiButtonBase-root",
|
|
66
|
-
"MuiTouchRipple-root",
|
|
67
|
-
"MuiCheckbox-root",
|
|
68
|
-
"MuiRadio-root",
|
|
69
|
-
"MuiSwitch-root",
|
|
70
|
-
"PrivateSwitchBase-root",
|
|
71
|
-
// Ant Design 컴포넌트들
|
|
72
|
-
"ant-input",
|
|
73
|
-
"ant-input-affix-wrapper",
|
|
74
|
-
"ant-input-group-addon",
|
|
75
|
-
"ant-input-number",
|
|
76
|
-
"ant-input-number-handler",
|
|
77
|
-
"ant-select",
|
|
78
|
-
"ant-select-selector",
|
|
79
|
-
"ant-select-selection-search",
|
|
80
|
-
"ant-select-dropdown",
|
|
81
|
-
"ant-cascader",
|
|
82
|
-
"ant-cascader-input",
|
|
83
|
-
"ant-picker",
|
|
84
|
-
"ant-picker-input",
|
|
85
|
-
"ant-time-picker",
|
|
86
|
-
"ant-calendar-picker",
|
|
87
|
-
"ant-slider",
|
|
88
|
-
"ant-slider-track",
|
|
89
|
-
"ant-slider-handle",
|
|
90
|
-
"ant-switch",
|
|
91
|
-
"ant-checkbox",
|
|
92
|
-
"ant-checkbox-wrapper",
|
|
93
|
-
"ant-radio",
|
|
94
|
-
"ant-radio-wrapper",
|
|
95
|
-
"ant-rate",
|
|
96
|
-
"ant-upload",
|
|
97
|
-
"ant-upload-drag",
|
|
98
|
-
"ant-form-item",
|
|
99
|
-
"ant-form-item-control",
|
|
100
|
-
"ant-btn",
|
|
101
|
-
"ant-dropdown",
|
|
102
|
-
"ant-dropdown-trigger",
|
|
103
|
-
"ant-menu",
|
|
104
|
-
"ant-menu-item",
|
|
105
|
-
"ant-tooltip",
|
|
106
|
-
"ant-popover",
|
|
107
|
-
"ant-modal",
|
|
108
|
-
"ant-drawer",
|
|
109
|
-
"ant-tree-select",
|
|
110
|
-
"ant-auto-complete",
|
|
111
|
-
"ant-mentions",
|
|
112
|
-
"ant-transfer",
|
|
113
|
-
// Shadcn/ui 컴포넌트들
|
|
114
|
-
"ui-input",
|
|
115
|
-
"ui-textarea",
|
|
116
|
-
"ui-select",
|
|
117
|
-
"ui-select-trigger",
|
|
118
|
-
"ui-select-content",
|
|
119
|
-
"ui-select-item",
|
|
120
|
-
"ui-button",
|
|
121
|
-
"ui-checkbox",
|
|
122
|
-
"ui-radio-group",
|
|
123
|
-
"ui-switch",
|
|
124
|
-
"ui-slider",
|
|
125
|
-
"ui-range-slider",
|
|
126
|
-
"ui-calendar",
|
|
127
|
-
"ui-date-picker",
|
|
128
|
-
"ui-combobox",
|
|
129
|
-
"ui-command",
|
|
130
|
-
"ui-command-input",
|
|
131
|
-
"ui-popover",
|
|
132
|
-
"ui-dialog",
|
|
133
|
-
"ui-sheet",
|
|
134
|
-
"ui-dropdown-menu",
|
|
135
|
-
"ui-context-menu",
|
|
136
|
-
"ui-menubar",
|
|
137
|
-
"ui-navigation-menu",
|
|
138
|
-
"ui-form",
|
|
139
|
-
"ui-form-control",
|
|
140
|
-
"ui-form-item",
|
|
141
|
-
"ui-form-field",
|
|
142
|
-
"ui-label",
|
|
143
|
-
// Radix UI 기본 클래스들 (Shadcn 기반)
|
|
144
|
-
"radix-ui",
|
|
145
|
-
"radix-select",
|
|
146
|
-
"radix-dropdown",
|
|
147
|
-
"radix-dialog",
|
|
148
|
-
"radix-popover",
|
|
149
|
-
"radix-accordion",
|
|
150
|
-
"radix-tabs",
|
|
151
|
-
"radix-slider",
|
|
152
|
-
"radix-switch",
|
|
153
|
-
"radix-checkbox",
|
|
154
|
-
"radix-radio",
|
|
155
|
-
// Quill Editor
|
|
156
|
-
"ql-editor",
|
|
157
|
-
"ql-container",
|
|
158
|
-
"ql-toolbar",
|
|
159
|
-
"ql-picker",
|
|
160
|
-
"ql-picker-label",
|
|
161
|
-
"ql-picker-options",
|
|
162
|
-
"ql-formats",
|
|
163
|
-
"ql-snow",
|
|
164
|
-
"ql-bubble",
|
|
165
|
-
"quill",
|
|
166
|
-
"quilleditor",
|
|
167
|
-
// Monaco Editor
|
|
168
|
-
"monaco-editor",
|
|
169
|
-
"monaco-editor-background",
|
|
170
|
-
"view-lines",
|
|
171
|
-
"decorationsOverviewRuler",
|
|
172
|
-
"monaco-scrollable-element",
|
|
173
|
-
// CodeMirror
|
|
174
|
-
"CodeMirror",
|
|
175
|
-
"CodeMirror-code",
|
|
176
|
-
"CodeMirror-lines",
|
|
177
|
-
"CodeMirror-scroll",
|
|
178
|
-
"CodeMirror-sizer",
|
|
179
|
-
"cm-editor",
|
|
180
|
-
"cm-focused",
|
|
181
|
-
"cm-content",
|
|
182
|
-
// TinyMCE
|
|
183
|
-
"tox-editor-container",
|
|
184
|
-
"tox-editor-header",
|
|
185
|
-
"tox-edit-area",
|
|
186
|
-
"tox-tinymce",
|
|
187
|
-
"mce-content-body",
|
|
188
|
-
// CKEditor
|
|
189
|
-
"ck-editor",
|
|
190
|
-
"ck-content",
|
|
191
|
-
"ck-toolbar",
|
|
192
|
-
"ck-editor__editable",
|
|
193
|
-
"ck-widget",
|
|
194
|
-
// Slate.js
|
|
195
|
-
"slate-editor",
|
|
196
|
-
"slate-content",
|
|
197
|
-
// Draft.js
|
|
198
|
-
"DraftEditor-root",
|
|
199
|
-
"DraftEditor-editorContainer",
|
|
200
|
-
"public-DraftEditor-content",
|
|
201
|
-
// EhfuseEditor
|
|
202
|
-
"ehfuse-editor",
|
|
203
|
-
"ehfuse-editor-wrapper",
|
|
204
|
-
"ehfuse-editor-content",
|
|
205
|
-
"ehfuse-toolbar",
|
|
206
|
-
"ehfuse-toolbar-group",
|
|
207
|
-
"ehfuse-cursor",
|
|
208
|
-
// 기타 에디터들
|
|
209
|
-
"text-editor",
|
|
210
|
-
"rich-text-editor",
|
|
211
|
-
"wysiwyg",
|
|
212
|
-
"ace_editor",
|
|
213
|
-
"ace_content",
|
|
214
|
-
];
|
|
215
|
-
/**
|
|
216
|
-
* 드래그 스크롤이 허용되지 않는 요소들인지 확인
|
|
217
|
-
*/
|
|
218
|
-
/**
|
|
219
|
-
* 드래그 스크롤이 허용되지 않는 요소들인지 확인
|
|
220
|
-
*/
|
|
221
|
-
const isTextInputElement = (element, config) => {
|
|
222
|
-
const tagName = element.tagName.toLowerCase();
|
|
223
|
-
const inputTypes = [
|
|
224
|
-
"text",
|
|
225
|
-
"password",
|
|
226
|
-
"email",
|
|
227
|
-
"number",
|
|
228
|
-
"search",
|
|
229
|
-
"tel",
|
|
230
|
-
"url",
|
|
231
|
-
"checkbox",
|
|
232
|
-
"radio",
|
|
233
|
-
];
|
|
234
|
-
// input 태그이면서 텍스트 입력 타입이나 체크박스/라디오인 경우
|
|
235
|
-
if (tagName === "input") {
|
|
236
|
-
const type = element.type;
|
|
237
|
-
return inputTypes.includes(type);
|
|
238
|
-
}
|
|
239
|
-
// textarea, select, 편집 가능한 요소들
|
|
240
|
-
if (["textarea", "select", "button"].includes(tagName)) {
|
|
241
|
-
return true;
|
|
242
|
-
}
|
|
243
|
-
// SVG 요소들 (아이콘들)
|
|
244
|
-
if ([
|
|
245
|
-
"svg",
|
|
246
|
-
"path",
|
|
247
|
-
"circle",
|
|
248
|
-
"rect",
|
|
249
|
-
"line",
|
|
250
|
-
"polygon",
|
|
251
|
-
"polyline",
|
|
252
|
-
].includes(tagName)) {
|
|
253
|
-
return true;
|
|
254
|
-
}
|
|
255
|
-
// contenteditable 속성이 있는 요소
|
|
256
|
-
if (element.getAttribute("contenteditable") === "true") {
|
|
257
|
-
return true;
|
|
258
|
-
}
|
|
259
|
-
// 추가 셀렉터 체크
|
|
260
|
-
if (config === null || config === void 0 ? void 0 : config.excludeSelectors) {
|
|
261
|
-
for (const selector of config.excludeSelectors) {
|
|
262
|
-
if (element.matches(selector)) {
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
return checkElementAndParents(element, config);
|
|
268
|
-
};
|
|
269
|
-
/**
|
|
270
|
-
* 자신 또는 부모 요소들을 확인하여 드래그 스크롤을 제외할 요소인지 판단
|
|
271
|
-
*/
|
|
272
|
-
const checkElementAndParents = (element, config) => {
|
|
273
|
-
// 모든 제외 클래스들 합치기 (기본 클래스 + 사용자 추가 클래스)
|
|
274
|
-
const allExcludeClasses = [
|
|
275
|
-
...DEFAULT_EXCLUDE_CLASSES,
|
|
276
|
-
...((config === null || config === void 0 ? void 0 : config.excludeClasses) || []),
|
|
277
|
-
];
|
|
278
|
-
let currentElement = element;
|
|
279
|
-
let depth = 0;
|
|
280
|
-
const maxDepth = 5; // 최대 5단계까지 부모 요소 확인
|
|
281
|
-
while (currentElement && depth <= maxDepth) {
|
|
282
|
-
// 현재 요소가 제외 클래스를 가지고 있는지 확인
|
|
283
|
-
if (allExcludeClasses.some((cls) => currentElement.classList.contains(cls))) {
|
|
284
|
-
return true;
|
|
285
|
-
}
|
|
286
|
-
// 다이얼로그 루트에 도달하면 중단
|
|
287
|
-
if (currentElement.classList.contains("MuiDialogContent-root")) {
|
|
288
|
-
break;
|
|
289
|
-
}
|
|
290
|
-
currentElement = currentElement.parentElement;
|
|
291
|
-
depth++;
|
|
292
|
-
}
|
|
293
|
-
return false;
|
|
294
|
-
};
|
|
295
|
-
|
|
296
|
-
// 기본 설정 객체들을 컴포넌트 외부에 상수로 선언 (재렌더링 시 동일한 참조 유지)
|
|
297
|
-
const DEFAULT_THUMB_CONFIG = {};
|
|
298
|
-
const DEFAULT_TRACK_CONFIG = {};
|
|
299
|
-
const DEFAULT_ARROWS_CONFIG = {};
|
|
300
|
-
const DEFAULT_DRAG_SCROLL_CONFIG = {};
|
|
301
|
-
const DEFAULT_AUTO_HIDE_CONFIG = {};
|
|
302
|
-
const OverlayScrollbar = react.forwardRef(({ className = "", style = {}, containerStyle = {}, contentStyle = {}, children, onScroll,
|
|
303
|
-
// 그룹화된 설정 객체들
|
|
304
|
-
thumb = DEFAULT_THUMB_CONFIG, track = DEFAULT_TRACK_CONFIG, arrows = DEFAULT_ARROWS_CONFIG, dragScroll = DEFAULT_DRAG_SCROLL_CONFIG, autoHide = DEFAULT_AUTO_HIDE_CONFIG,
|
|
305
|
-
// 기타 설정들
|
|
306
|
-
showScrollbar = true, detectInnerScroll = false, }, ref) => {
|
|
307
|
-
// props 변경 추적용 ref
|
|
308
|
-
const prevPropsRef = react.useRef({});
|
|
309
|
-
// 렌더링 시 어떤 prop이 변경되었는지 체크
|
|
310
|
-
react.useEffect(() => {
|
|
311
|
-
// 현재 props 저장
|
|
312
|
-
prevPropsRef.current = {
|
|
313
|
-
children,
|
|
314
|
-
onScroll,
|
|
315
|
-
showScrollbar,
|
|
316
|
-
thumb,
|
|
317
|
-
track,
|
|
318
|
-
arrows,
|
|
319
|
-
dragScroll,
|
|
320
|
-
autoHide,
|
|
321
|
-
};
|
|
322
|
-
});
|
|
323
|
-
const wrapperRef = react.useRef(null);
|
|
324
|
-
const containerRef = react.useRef(null);
|
|
325
|
-
const contentRef = react.useRef(null);
|
|
326
|
-
const scrollbarRef = react.useRef(null);
|
|
327
|
-
const thumbRef = react.useRef(null);
|
|
328
|
-
// 스크롤 컨테이너 캐싱용 ref (성능 최적화)
|
|
329
|
-
const cachedScrollContainerRef = react.useRef(null);
|
|
330
|
-
// 기본 상태들
|
|
331
|
-
const [scrollbarVisible, setScrollbarVisible] = react.useState(false);
|
|
332
|
-
const [isDragging, setIsDragging] = react.useState(false);
|
|
333
|
-
const [isThumbHovered, setIsThumbHovered] = react.useState(false);
|
|
334
|
-
const [dragStart, setDragStart] = react.useState({ y: 0, scrollTop: 0 });
|
|
335
|
-
const [thumbHeight, setThumbHeight] = react.useState(0);
|
|
336
|
-
const [thumbTop, setThumbTop] = react.useState(0);
|
|
337
|
-
const [hasScrollableContent, setHasScrollableContent] = react.useState(false);
|
|
338
|
-
// 드래그 스크롤 상태
|
|
339
|
-
const [isDragScrolling, setIsDragScrolling] = react.useState(false);
|
|
340
|
-
const [dragScrollStart, setDragScrollStart] = react.useState({
|
|
341
|
-
x: 0,
|
|
342
|
-
y: 0,
|
|
343
|
-
scrollTop: 0,
|
|
344
|
-
scrollLeft: 0,
|
|
345
|
-
});
|
|
346
|
-
const [activeArrow, setActiveArrow] = react.useState(null);
|
|
347
|
-
const [hoveredArrow, setHoveredArrow] = react.useState(null);
|
|
348
|
-
// 초기 마운트 시 hover 방지용
|
|
349
|
-
const [isInitialized, setIsInitialized] = react.useState(false);
|
|
350
|
-
// 휠 스크롤 감지용
|
|
351
|
-
const wheelTimeoutRef = react.useRef(null);
|
|
352
|
-
const [isWheelScrolling, setIsWheelScrolling] = react.useState(false);
|
|
353
|
-
// 숨김 타이머
|
|
354
|
-
const hideTimeoutRef = react.useRef(null);
|
|
355
|
-
// 호버 진입 타이머 (디바운스용)
|
|
356
|
-
const hoverEnterTimeoutRef = react.useRef(null);
|
|
357
|
-
// 그룹화된 설정 객체들에 기본값 설정
|
|
358
|
-
const finalThumbConfig = react.useMemo(() => {
|
|
359
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
360
|
-
const baseColor = (_a = thumb.color) !== null && _a !== void 0 ? _a : "#606060";
|
|
361
|
-
return {
|
|
362
|
-
width: (_b = thumb.width) !== null && _b !== void 0 ? _b : 8,
|
|
363
|
-
minHeight: (_c = thumb.minHeight) !== null && _c !== void 0 ? _c : 50,
|
|
364
|
-
radius: (_d = thumb.radius) !== null && _d !== void 0 ? _d : ((_e = thumb.width) !== null && _e !== void 0 ? _e : 8) / 2,
|
|
365
|
-
color: baseColor,
|
|
366
|
-
opacity: (_f = thumb.opacity) !== null && _f !== void 0 ? _f : 0.6,
|
|
367
|
-
hoverColor: (_g = thumb.hoverColor) !== null && _g !== void 0 ? _g : baseColor,
|
|
368
|
-
hoverOpacity: (_h = thumb.hoverOpacity) !== null && _h !== void 0 ? _h : 1.0,
|
|
369
|
-
};
|
|
370
|
-
}, [thumb]);
|
|
371
|
-
const finalTrackConfig = react.useMemo(() => {
|
|
372
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
373
|
-
return ({
|
|
374
|
-
width: (_a = track.width) !== null && _a !== void 0 ? _a : 16,
|
|
375
|
-
color: (_b = track.color) !== null && _b !== void 0 ? _b : "rgba(128, 128, 128, 0.1)",
|
|
376
|
-
visible: (_c = track.visible) !== null && _c !== void 0 ? _c : true,
|
|
377
|
-
alignment: (_d = track.alignment) !== null && _d !== void 0 ? _d : "center",
|
|
378
|
-
radius: (_f = (_e = track.radius) !== null && _e !== void 0 ? _e : finalThumbConfig.radius) !== null && _f !== void 0 ? _f : 4,
|
|
379
|
-
margin: (_g = track.margin) !== null && _g !== void 0 ? _g : 4,
|
|
380
|
-
});
|
|
381
|
-
}, [track, finalThumbConfig.radius]);
|
|
382
|
-
const finalArrowsConfig = react.useMemo(() => {
|
|
383
|
-
var _a, _b, _c, _d, _e, _f;
|
|
384
|
-
const baseColor = (_a = arrows.color) !== null && _a !== void 0 ? _a : "#808080";
|
|
385
|
-
return {
|
|
386
|
-
visible: (_b = arrows.visible) !== null && _b !== void 0 ? _b : false,
|
|
387
|
-
step: (_c = arrows.step) !== null && _c !== void 0 ? _c : 50,
|
|
388
|
-
color: baseColor,
|
|
389
|
-
opacity: (_d = arrows.opacity) !== null && _d !== void 0 ? _d : 0.6,
|
|
390
|
-
hoverColor: (_e = arrows.hoverColor) !== null && _e !== void 0 ? _e : baseColor,
|
|
391
|
-
hoverOpacity: (_f = arrows.hoverOpacity) !== null && _f !== void 0 ? _f : 1.0,
|
|
392
|
-
};
|
|
393
|
-
}, [arrows]);
|
|
394
|
-
const finalDragScrollConfig = react.useMemo(() => {
|
|
395
|
-
var _a, _b, _c;
|
|
396
|
-
return ({
|
|
397
|
-
enabled: (_a = dragScroll.enabled) !== null && _a !== void 0 ? _a : true,
|
|
398
|
-
excludeClasses: (_b = dragScroll.excludeClasses) !== null && _b !== void 0 ? _b : [],
|
|
399
|
-
excludeSelectors: (_c = dragScroll.excludeSelectors) !== null && _c !== void 0 ? _c : [],
|
|
400
|
-
});
|
|
401
|
-
}, [dragScroll]);
|
|
402
|
-
const finalAutoHideConfig = react.useMemo(() => {
|
|
403
|
-
var _a, _b, _c;
|
|
404
|
-
return ({
|
|
405
|
-
enabled: (_a = autoHide.enabled) !== null && _a !== void 0 ? _a : true,
|
|
406
|
-
delay: (_b = autoHide.delay) !== null && _b !== void 0 ? _b : 1500,
|
|
407
|
-
delayOnWheel: (_c = autoHide.delayOnWheel) !== null && _c !== void 0 ? _c : 700,
|
|
408
|
-
});
|
|
409
|
-
}, [autoHide]);
|
|
410
|
-
// 호환성을 위한 변수들 (자주 사용되는 변수들만 유지)
|
|
411
|
-
const finalThumbWidth = finalThumbConfig.width;
|
|
412
|
-
const finalTrackWidth = finalTrackConfig.width;
|
|
413
|
-
const thumbMinHeight = finalThumbConfig.minHeight;
|
|
414
|
-
const showArrows = finalArrowsConfig.visible;
|
|
415
|
-
const arrowStep = finalArrowsConfig.step;
|
|
416
|
-
// 포커스 유지 함수 (키보드 입력이 계속 작동하도록)
|
|
417
|
-
const maintainFocus = react.useCallback(() => {
|
|
418
|
-
if (!containerRef.current)
|
|
419
|
-
return;
|
|
420
|
-
// 현재 포커스된 요소 확인
|
|
421
|
-
const activeElement = document.activeElement;
|
|
422
|
-
// 오버레이 스크롤바 내부에 이미 포커스된 요소가 있으면 스킵
|
|
423
|
-
if (activeElement &&
|
|
424
|
-
containerRef.current.contains(activeElement) &&
|
|
425
|
-
activeElement !== containerRef.current) {
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
// 포커스된 요소가 없거나 외부에 있으면 컨테이너에 포커스
|
|
429
|
-
containerRef.current.focus();
|
|
430
|
-
}, []);
|
|
431
|
-
// ref를 통해 외부에서 스크롤 컨테이너에 접근할 수 있도록 함
|
|
432
|
-
react.useImperativeHandle(ref, () => ({
|
|
433
|
-
getScrollContainer: () => containerRef.current,
|
|
434
|
-
scrollTo: (options) => {
|
|
435
|
-
if (containerRef.current) {
|
|
436
|
-
containerRef.current.scrollTo(options);
|
|
437
|
-
}
|
|
438
|
-
},
|
|
439
|
-
get scrollTop() {
|
|
440
|
-
var _a;
|
|
441
|
-
return ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.scrollTop) || 0;
|
|
442
|
-
},
|
|
443
|
-
get scrollHeight() {
|
|
444
|
-
var _a;
|
|
445
|
-
return ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.scrollHeight) || 0;
|
|
446
|
-
},
|
|
447
|
-
get clientHeight() {
|
|
448
|
-
var _a;
|
|
449
|
-
return ((_a = containerRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
|
|
450
|
-
},
|
|
451
|
-
}), []);
|
|
452
|
-
// 실제 스크롤 가능한 요소 찾기 (캐싱 최적화)
|
|
453
|
-
const findScrollableElement = react.useCallback(() => {
|
|
454
|
-
// 캐시된 요소가 여전히 유효한지 확인
|
|
455
|
-
if (cachedScrollContainerRef.current) {
|
|
456
|
-
const cached = cachedScrollContainerRef.current;
|
|
457
|
-
// DOM에 연결되어 있고 여전히 스크롤 가능한지 확인
|
|
458
|
-
if (document.contains(cached) &&
|
|
459
|
-
cached.scrollHeight > cached.clientHeight + 2) {
|
|
460
|
-
return cached;
|
|
461
|
-
}
|
|
462
|
-
// 캐시 무효화
|
|
463
|
-
cachedScrollContainerRef.current = null;
|
|
464
|
-
}
|
|
465
|
-
if (!containerRef.current) {
|
|
466
|
-
return null;
|
|
467
|
-
}
|
|
468
|
-
// 내부 컨테이너의 스크롤 가능 여부 확인
|
|
469
|
-
if (contentRef.current &&
|
|
470
|
-
contentRef.current.scrollHeight >
|
|
471
|
-
containerRef.current.clientHeight + 2) {
|
|
472
|
-
cachedScrollContainerRef.current = containerRef.current;
|
|
473
|
-
return containerRef.current;
|
|
474
|
-
}
|
|
475
|
-
// detectInnerScroll 옵션이 활성화된 경우에만 children 내부의 스크롤 요소 찾기
|
|
476
|
-
// (가상 테이블 등 내부에서 스크롤을 처리하는 경우에 사용)
|
|
477
|
-
if (!detectInnerScroll) {
|
|
478
|
-
return null;
|
|
479
|
-
}
|
|
480
|
-
// children 요소에서 스크롤 가능한 요소 찾기
|
|
481
|
-
// 중첩된 OverlayScrollbar의 영역은 제외 (다른 OverlayScrollbar의 container는 스킵)
|
|
482
|
-
const childScrollableElements = containerRef.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');
|
|
483
|
-
for (const child of childScrollableElements) {
|
|
484
|
-
const element = child;
|
|
485
|
-
// 이 요소가 다른 OverlayScrollbar의 container인지 확인
|
|
486
|
-
// (자신의 containerRef는 아니어야 하고, overlay-scrollbar-container 클래스를 가진 경우)
|
|
487
|
-
if (element !== containerRef.current &&
|
|
488
|
-
element.classList.contains("overlay-scrollbar-container")) {
|
|
489
|
-
// 중첩된 OverlayScrollbar의 container이므로 스킵
|
|
490
|
-
continue;
|
|
491
|
-
}
|
|
492
|
-
// 이 요소의 부모 중에 다른 OverlayScrollbar container가 있는지 확인
|
|
493
|
-
let parent = element.parentElement;
|
|
494
|
-
let isNestedInAnotherScrollbar = false;
|
|
495
|
-
while (parent && parent !== containerRef.current) {
|
|
496
|
-
if (parent.classList.contains("overlay-scrollbar-container") &&
|
|
497
|
-
parent !== containerRef.current) {
|
|
498
|
-
// 다른 OverlayScrollbar 내부의 요소이므로 스킵
|
|
499
|
-
isNestedInAnotherScrollbar = true;
|
|
500
|
-
break;
|
|
501
|
-
}
|
|
502
|
-
parent = parent.parentElement;
|
|
503
|
-
}
|
|
504
|
-
if (isNestedInAnotherScrollbar) {
|
|
505
|
-
continue;
|
|
506
|
-
}
|
|
507
|
-
// 스크롤 가능한 요소인지 확인
|
|
508
|
-
if (element.scrollHeight > element.clientHeight + 2) {
|
|
509
|
-
cachedScrollContainerRef.current = element;
|
|
510
|
-
return element;
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
return null;
|
|
514
|
-
}, []);
|
|
515
|
-
// 스크롤 가능 여부 체크
|
|
516
|
-
const isScrollable = react.useCallback(() => {
|
|
517
|
-
return findScrollableElement() !== null;
|
|
518
|
-
}, [findScrollableElement]);
|
|
519
|
-
// 타이머 정리
|
|
520
|
-
const clearHideTimer = react.useCallback(() => {
|
|
521
|
-
if (hideTimeoutRef.current) {
|
|
522
|
-
clearTimeout(hideTimeoutRef.current);
|
|
523
|
-
hideTimeoutRef.current = null;
|
|
524
|
-
}
|
|
525
|
-
}, []);
|
|
526
|
-
const clearHoverEnterTimer = react.useCallback(() => {
|
|
527
|
-
if (hoverEnterTimeoutRef.current) {
|
|
528
|
-
clearTimeout(hoverEnterTimeoutRef.current);
|
|
529
|
-
hoverEnterTimeoutRef.current = null;
|
|
530
|
-
}
|
|
531
|
-
}, []);
|
|
532
|
-
// 스크롤바 숨기기 타이머
|
|
533
|
-
const setHideTimer = react.useCallback((delay) => {
|
|
534
|
-
// 자동 숨김이 비활성화되어 있으면 타이머를 설정하지 않음
|
|
535
|
-
if (!finalAutoHideConfig.enabled) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
clearHideTimer();
|
|
539
|
-
hideTimeoutRef.current = setTimeout(() => {
|
|
540
|
-
setScrollbarVisible(false);
|
|
541
|
-
hideTimeoutRef.current = null;
|
|
542
|
-
}, delay);
|
|
543
|
-
}, [clearHideTimer, finalAutoHideConfig.enabled]);
|
|
544
|
-
// 스크롤바 위치 및 크기 업데이트
|
|
545
|
-
const updateScrollbar = react.useCallback(() => {
|
|
546
|
-
const scrollableElement = findScrollableElement();
|
|
547
|
-
if (!scrollableElement) {
|
|
548
|
-
// 스크롤 불가능하면 숨김
|
|
549
|
-
setScrollbarVisible(false);
|
|
550
|
-
setHasScrollableContent(false);
|
|
551
|
-
clearHideTimer();
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
// 스크롤 가능한 콘텐츠가 있음을 표시
|
|
555
|
-
setHasScrollableContent(true);
|
|
556
|
-
if (!scrollbarRef.current)
|
|
557
|
-
return;
|
|
558
|
-
// 자동 숨김이 비활성화되어 있으면 스크롤바를 항상 표시
|
|
559
|
-
if (!finalAutoHideConfig.enabled) {
|
|
560
|
-
setScrollbarVisible(true);
|
|
561
|
-
clearHideTimer();
|
|
562
|
-
}
|
|
563
|
-
const containerHeight = scrollableElement.clientHeight;
|
|
564
|
-
const contentHeight = scrollableElement.scrollHeight;
|
|
565
|
-
const scrollTop = scrollableElement.scrollTop;
|
|
566
|
-
// wrapper의 패딩 계산 (상하 패딩만 필요)
|
|
567
|
-
let wrapperPaddingTopBottom = 0;
|
|
568
|
-
if (wrapperRef.current) {
|
|
569
|
-
const computedStyle = window.getComputedStyle(wrapperRef.current);
|
|
570
|
-
const paddingTop = parseFloat(computedStyle.paddingTop) || 0;
|
|
571
|
-
const paddingBottom = parseFloat(computedStyle.paddingBottom) || 0;
|
|
572
|
-
wrapperPaddingTopBottom = paddingTop + paddingBottom;
|
|
573
|
-
}
|
|
574
|
-
// 화살표와 간격 공간 계산 (화살표 + 위아래 마진, 화살표 없어도 위아래 마진)
|
|
575
|
-
const arrowSpace = showArrows
|
|
576
|
-
? finalThumbWidth * 2 + finalTrackConfig.margin * 4
|
|
577
|
-
: finalTrackConfig.margin * 2;
|
|
578
|
-
// 썸 높이 계산 (사용자 설정 최소 높이 사용, 화살표 공간 제외, wrapper 패딩 추가)
|
|
579
|
-
const availableHeight = containerHeight - arrowSpace + wrapperPaddingTopBottom;
|
|
580
|
-
const scrollRatio = containerHeight / contentHeight;
|
|
581
|
-
const calculatedThumbHeight = Math.max(availableHeight * scrollRatio, thumbMinHeight);
|
|
582
|
-
// 썸 위치 계산 (화살표와 간격 공간 제외)
|
|
583
|
-
const scrollableHeight = contentHeight - containerHeight;
|
|
584
|
-
const thumbScrollableHeight = availableHeight - calculatedThumbHeight;
|
|
585
|
-
const calculatedThumbTop = scrollableHeight > 0
|
|
586
|
-
? (scrollTop / scrollableHeight) * thumbScrollableHeight
|
|
587
|
-
: 0;
|
|
588
|
-
setThumbHeight(calculatedThumbHeight);
|
|
589
|
-
setThumbTop(calculatedThumbTop);
|
|
590
|
-
}, [
|
|
591
|
-
findScrollableElement,
|
|
592
|
-
clearHideTimer,
|
|
593
|
-
showArrows,
|
|
594
|
-
finalThumbWidth,
|
|
595
|
-
thumbMinHeight,
|
|
596
|
-
finalAutoHideConfig.enabled,
|
|
597
|
-
]);
|
|
598
|
-
// 썸 드래그 시작
|
|
599
|
-
const handleThumbMouseDown = react.useCallback((event) => {
|
|
600
|
-
event.preventDefault();
|
|
601
|
-
event.stopPropagation();
|
|
602
|
-
const actualScrollContainer = findScrollableElement();
|
|
603
|
-
if (!actualScrollContainer) {
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
setIsDragging(true);
|
|
607
|
-
setDragStart({
|
|
608
|
-
y: event.clientY,
|
|
609
|
-
scrollTop: actualScrollContainer.scrollTop,
|
|
610
|
-
});
|
|
611
|
-
clearHideTimer();
|
|
612
|
-
setScrollbarVisible(true);
|
|
613
|
-
// 포커스 유지 (키보드 입력이 계속 작동하도록)
|
|
614
|
-
maintainFocus();
|
|
615
|
-
}, [findScrollableElement, clearHideTimer, maintainFocus]);
|
|
616
|
-
// 썸 드래그 중
|
|
617
|
-
const handleMouseMove = react.useCallback((event) => {
|
|
618
|
-
if (!isDragging)
|
|
619
|
-
return;
|
|
620
|
-
const actualScrollContainer = findScrollableElement();
|
|
621
|
-
if (!actualScrollContainer) {
|
|
622
|
-
return;
|
|
623
|
-
}
|
|
624
|
-
const containerHeight = actualScrollContainer.clientHeight;
|
|
625
|
-
const contentHeight = actualScrollContainer.scrollHeight;
|
|
626
|
-
const scrollableHeight = contentHeight - containerHeight;
|
|
627
|
-
const deltaY = event.clientY - dragStart.y;
|
|
628
|
-
const thumbScrollableHeight = containerHeight - thumbHeight;
|
|
629
|
-
const scrollDelta = (deltaY / thumbScrollableHeight) * scrollableHeight;
|
|
630
|
-
const newScrollTop = Math.max(0, Math.min(scrollableHeight, dragStart.scrollTop + scrollDelta));
|
|
631
|
-
actualScrollContainer.scrollTop = newScrollTop;
|
|
632
|
-
updateScrollbar();
|
|
633
|
-
}, [
|
|
634
|
-
isDragging,
|
|
635
|
-
dragStart,
|
|
636
|
-
thumbHeight,
|
|
637
|
-
updateScrollbar,
|
|
638
|
-
findScrollableElement,
|
|
639
|
-
]);
|
|
640
|
-
// 썸 드래그 종료
|
|
641
|
-
const handleMouseUp = react.useCallback(() => {
|
|
642
|
-
setIsDragging(false);
|
|
643
|
-
if (isScrollable()) {
|
|
644
|
-
setHideTimer(finalAutoHideConfig.delay); // 기본 숨김 시간 적용
|
|
645
|
-
}
|
|
646
|
-
}, [isScrollable, setHideTimer, finalAutoHideConfig.delay]);
|
|
647
|
-
// 트랙 클릭으로 스크롤 점프
|
|
648
|
-
const handleTrackClick = react.useCallback((event) => {
|
|
649
|
-
if (!scrollbarRef.current) {
|
|
650
|
-
return;
|
|
651
|
-
}
|
|
652
|
-
const scrollbar = scrollbarRef.current;
|
|
653
|
-
const rect = scrollbar.getBoundingClientRect();
|
|
654
|
-
const clickY = event.clientY - rect.top;
|
|
655
|
-
const actualScrollContainer = findScrollableElement();
|
|
656
|
-
if (!actualScrollContainer) {
|
|
657
|
-
return;
|
|
658
|
-
}
|
|
659
|
-
const containerHeight = actualScrollContainer.clientHeight;
|
|
660
|
-
const contentHeight = actualScrollContainer.scrollHeight;
|
|
661
|
-
const scrollRatio = clickY / containerHeight;
|
|
662
|
-
const newScrollTop = scrollRatio * (contentHeight - containerHeight);
|
|
663
|
-
actualScrollContainer.scrollTop = Math.max(0, Math.min(contentHeight - containerHeight, newScrollTop));
|
|
664
|
-
updateScrollbar();
|
|
665
|
-
setScrollbarVisible(true);
|
|
666
|
-
setHideTimer(finalAutoHideConfig.delay);
|
|
667
|
-
// 포커스 유지 (키보드 입력이 계속 작동하도록)
|
|
668
|
-
maintainFocus();
|
|
669
|
-
}, [
|
|
670
|
-
updateScrollbar,
|
|
671
|
-
setHideTimer,
|
|
672
|
-
finalAutoHideConfig.delay,
|
|
673
|
-
findScrollableElement,
|
|
674
|
-
maintainFocus,
|
|
675
|
-
]);
|
|
676
|
-
// 위쪽 화살표 클릭 핸들러
|
|
677
|
-
const handleUpArrowClick = react.useCallback((event) => {
|
|
678
|
-
event.preventDefault();
|
|
679
|
-
event.stopPropagation();
|
|
680
|
-
if (!containerRef.current)
|
|
681
|
-
return;
|
|
682
|
-
const newScrollTop = Math.max(0, containerRef.current.scrollTop - arrowStep);
|
|
683
|
-
containerRef.current.scrollTop = newScrollTop;
|
|
684
|
-
updateScrollbar();
|
|
685
|
-
setScrollbarVisible(true);
|
|
686
|
-
setHideTimer(finalAutoHideConfig.delay);
|
|
687
|
-
// 포커스 유지 (키보드 입력이 계속 작동하도록)
|
|
688
|
-
maintainFocus();
|
|
689
|
-
}, [
|
|
690
|
-
updateScrollbar,
|
|
691
|
-
setHideTimer,
|
|
692
|
-
arrowStep,
|
|
693
|
-
finalAutoHideConfig.delay,
|
|
694
|
-
maintainFocus,
|
|
695
|
-
]);
|
|
696
|
-
// 아래쪽 화살표 클릭 핸들러
|
|
697
|
-
const handleDownArrowClick = react.useCallback((event) => {
|
|
698
|
-
event.preventDefault();
|
|
699
|
-
event.stopPropagation();
|
|
700
|
-
if (!containerRef.current || !contentRef.current)
|
|
701
|
-
return;
|
|
702
|
-
const container = containerRef.current;
|
|
703
|
-
const content = contentRef.current;
|
|
704
|
-
const maxScrollTop = content.scrollHeight - container.clientHeight;
|
|
705
|
-
const newScrollTop = Math.min(maxScrollTop, container.scrollTop + arrowStep);
|
|
706
|
-
container.scrollTop = newScrollTop;
|
|
707
|
-
updateScrollbar();
|
|
708
|
-
setScrollbarVisible(true);
|
|
709
|
-
setHideTimer(finalAutoHideConfig.delay);
|
|
710
|
-
// 포커스 유지 (키보드 입력이 계속 작동하도록)
|
|
711
|
-
maintainFocus();
|
|
712
|
-
}, [
|
|
713
|
-
updateScrollbar,
|
|
714
|
-
setHideTimer,
|
|
715
|
-
arrowStep,
|
|
716
|
-
finalAutoHideConfig.delay,
|
|
717
|
-
maintainFocus,
|
|
718
|
-
]);
|
|
719
|
-
// 드래그 스크롤 시작
|
|
720
|
-
const handleDragScrollStart = react.useCallback((event) => {
|
|
721
|
-
// 드래그 스크롤이 비활성화된 경우
|
|
722
|
-
if (!finalDragScrollConfig.enabled)
|
|
723
|
-
return;
|
|
724
|
-
// 텍스트 입력 요소나 제외 대상이면 드래그 스크롤 하지 않음
|
|
725
|
-
const target = event.target;
|
|
726
|
-
if (isTextInputElement(target, finalDragScrollConfig)) {
|
|
727
|
-
return;
|
|
728
|
-
}
|
|
729
|
-
// 오른쪽 클릭이나 휠 클릭은 제외
|
|
730
|
-
if (event.button !== 0)
|
|
731
|
-
return;
|
|
732
|
-
const scrollableElement = findScrollableElement();
|
|
733
|
-
if (!scrollableElement)
|
|
734
|
-
return;
|
|
735
|
-
// 스크롤 가능한 영역이 아니면 제외
|
|
736
|
-
if (scrollableElement.scrollHeight <=
|
|
737
|
-
scrollableElement.clientHeight)
|
|
738
|
-
return;
|
|
739
|
-
event.preventDefault();
|
|
740
|
-
setIsDragScrolling(true);
|
|
741
|
-
setDragScrollStart({
|
|
742
|
-
x: event.clientX,
|
|
743
|
-
y: event.clientY,
|
|
744
|
-
scrollTop: scrollableElement.scrollTop,
|
|
745
|
-
scrollLeft: scrollableElement.scrollLeft || 0,
|
|
746
|
-
});
|
|
747
|
-
// 스크롤바 표시
|
|
748
|
-
clearHideTimer();
|
|
749
|
-
setScrollbarVisible(true);
|
|
750
|
-
}, [
|
|
751
|
-
finalDragScrollConfig,
|
|
752
|
-
isTextInputElement,
|
|
753
|
-
findScrollableElement,
|
|
754
|
-
clearHideTimer,
|
|
755
|
-
]);
|
|
756
|
-
// 드래그 스크롤 중
|
|
757
|
-
const handleDragScrollMove = react.useCallback((event) => {
|
|
758
|
-
if (!isDragScrolling)
|
|
759
|
-
return;
|
|
760
|
-
const scrollableElement = findScrollableElement();
|
|
761
|
-
if (!scrollableElement)
|
|
762
|
-
return;
|
|
763
|
-
dragScrollStart.x - event.clientX;
|
|
764
|
-
const deltaY = dragScrollStart.y - event.clientY;
|
|
765
|
-
// 세로 스크롤만 처리 (가로 스크롤은 필요시 나중에 추가)
|
|
766
|
-
const newScrollTop = Math.max(0, Math.min(scrollableElement.scrollHeight -
|
|
767
|
-
scrollableElement.clientHeight, dragScrollStart.scrollTop + deltaY));
|
|
768
|
-
scrollableElement.scrollTop = newScrollTop;
|
|
769
|
-
updateScrollbar();
|
|
770
|
-
}, [
|
|
771
|
-
isDragScrolling,
|
|
772
|
-
dragScrollStart,
|
|
773
|
-
findScrollableElement,
|
|
774
|
-
updateScrollbar,
|
|
775
|
-
]);
|
|
776
|
-
// 드래그 스크롤 종료
|
|
777
|
-
const handleDragScrollEnd = react.useCallback(() => {
|
|
778
|
-
setIsDragScrolling(false);
|
|
779
|
-
if (isScrollable()) {
|
|
780
|
-
setHideTimer(finalAutoHideConfig.delay);
|
|
781
|
-
}
|
|
782
|
-
}, [isScrollable, setHideTimer, finalAutoHideConfig.delay]);
|
|
783
|
-
// 스크롤 이벤트 리스너 (externalScrollContainer 우선 사용)
|
|
784
|
-
react.useEffect(() => {
|
|
785
|
-
const handleScroll = (event) => {
|
|
786
|
-
updateScrollbar();
|
|
787
|
-
// 스크롤 중에는 스크롤바 표시
|
|
788
|
-
clearHideTimer();
|
|
789
|
-
setScrollbarVisible(true);
|
|
790
|
-
// 휠 스크롤 중이면 빠른 숨김, 아니면 기본 숨김 시간 적용
|
|
791
|
-
const delay = isWheelScrolling
|
|
792
|
-
? finalAutoHideConfig.delayOnWheel
|
|
793
|
-
: finalAutoHideConfig.delay;
|
|
794
|
-
setHideTimer(delay);
|
|
795
|
-
if (onScroll) {
|
|
796
|
-
onScroll(event);
|
|
797
|
-
}
|
|
798
|
-
};
|
|
799
|
-
const handleWheel = () => {
|
|
800
|
-
// 휠 스크롤 상태 표시
|
|
801
|
-
setIsWheelScrolling(true);
|
|
802
|
-
// 기존 휠 타이머 제거
|
|
803
|
-
if (wheelTimeoutRef.current) {
|
|
804
|
-
clearTimeout(wheelTimeoutRef.current);
|
|
805
|
-
}
|
|
806
|
-
// 300ms 후 휠 스크롤 상태 해제 (휠 스크롤이 끝났다고 간주)
|
|
807
|
-
wheelTimeoutRef.current = setTimeout(() => {
|
|
808
|
-
setIsWheelScrolling(false);
|
|
809
|
-
}, 300);
|
|
810
|
-
clearHideTimer();
|
|
811
|
-
setScrollbarVisible(true);
|
|
812
|
-
};
|
|
813
|
-
const elementsToWatch = [];
|
|
814
|
-
// 실제 스크롤 가능한 요소 찾기
|
|
815
|
-
const scrollableElement = findScrollableElement();
|
|
816
|
-
if (scrollableElement) {
|
|
817
|
-
elementsToWatch.push(scrollableElement);
|
|
818
|
-
}
|
|
819
|
-
// fallback: 내부 컨테이너와 children 요소도 감지
|
|
820
|
-
const container = containerRef.current;
|
|
821
|
-
if (container && !scrollableElement) {
|
|
822
|
-
elementsToWatch.push(container);
|
|
823
|
-
// children 요소들의 스크롤도 감지 (중첩된 OverlayScrollbar 제외)
|
|
824
|
-
const childScrollableElements = container.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');
|
|
825
|
-
childScrollableElements.forEach((child) => {
|
|
826
|
-
const element = child;
|
|
827
|
-
// 다른 OverlayScrollbar의 container는 제외
|
|
828
|
-
if (element !== container &&
|
|
829
|
-
element.classList.contains("overlay-scrollbar-container")) {
|
|
830
|
-
return;
|
|
831
|
-
}
|
|
832
|
-
// 부모 중에 다른 OverlayScrollbar container가 있으면 제외
|
|
833
|
-
let parent = element.parentElement;
|
|
834
|
-
while (parent && parent !== container) {
|
|
835
|
-
if (parent.classList.contains("overlay-scrollbar-container") &&
|
|
836
|
-
parent !== container) {
|
|
837
|
-
return; // 중첩된 OverlayScrollbar 내부이므로 제외
|
|
838
|
-
}
|
|
839
|
-
parent = parent.parentElement;
|
|
840
|
-
}
|
|
841
|
-
elementsToWatch.push(element);
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
|
-
// 모든 요소에 이벤트 리스너 등록
|
|
845
|
-
elementsToWatch.forEach((element) => {
|
|
846
|
-
element.addEventListener("scroll", handleScroll, {
|
|
847
|
-
passive: true,
|
|
848
|
-
});
|
|
849
|
-
element.addEventListener("wheel", handleWheel, {
|
|
850
|
-
passive: true,
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
return () => {
|
|
854
|
-
// 모든 이벤트 리스너 제거
|
|
855
|
-
elementsToWatch.forEach((element) => {
|
|
856
|
-
element.removeEventListener("scroll", handleScroll);
|
|
857
|
-
element.removeEventListener("wheel", handleWheel);
|
|
858
|
-
});
|
|
859
|
-
if (wheelTimeoutRef.current) {
|
|
860
|
-
clearTimeout(wheelTimeoutRef.current);
|
|
861
|
-
}
|
|
862
|
-
};
|
|
863
|
-
}, [
|
|
864
|
-
findScrollableElement,
|
|
865
|
-
updateScrollbar,
|
|
866
|
-
onScroll,
|
|
867
|
-
clearHideTimer,
|
|
868
|
-
setHideTimer,
|
|
869
|
-
finalAutoHideConfig,
|
|
870
|
-
isWheelScrolling,
|
|
871
|
-
]);
|
|
872
|
-
// 키보드 네비게이션 핸들러 (방향키, PageUp/PageDown/Home/End)
|
|
873
|
-
react.useEffect(() => {
|
|
874
|
-
const handleKeyDown = (event) => {
|
|
875
|
-
const scrollableElement = findScrollableElement();
|
|
876
|
-
if (!scrollableElement)
|
|
877
|
-
return;
|
|
878
|
-
const { key } = event;
|
|
879
|
-
const { scrollTop, scrollHeight, clientHeight } = scrollableElement;
|
|
880
|
-
const maxScrollTop = scrollHeight - clientHeight;
|
|
881
|
-
// 한 줄 스크롤 단위 (rowHeight 또는 기본값)
|
|
882
|
-
const lineScrollStep = 50;
|
|
883
|
-
let newScrollTop = null;
|
|
884
|
-
switch (key) {
|
|
885
|
-
case "ArrowUp":
|
|
886
|
-
event.preventDefault();
|
|
887
|
-
newScrollTop = Math.max(0, scrollTop - lineScrollStep);
|
|
888
|
-
break;
|
|
889
|
-
case "ArrowDown":
|
|
890
|
-
event.preventDefault();
|
|
891
|
-
newScrollTop = Math.min(maxScrollTop, scrollTop + lineScrollStep);
|
|
892
|
-
break;
|
|
893
|
-
case "PageUp":
|
|
894
|
-
event.preventDefault();
|
|
895
|
-
newScrollTop = Math.max(0, scrollTop - clientHeight);
|
|
896
|
-
break;
|
|
897
|
-
case "PageDown":
|
|
898
|
-
event.preventDefault();
|
|
899
|
-
newScrollTop = Math.min(maxScrollTop, scrollTop + clientHeight);
|
|
900
|
-
break;
|
|
901
|
-
case "Home":
|
|
902
|
-
event.preventDefault();
|
|
903
|
-
newScrollTop = 0;
|
|
904
|
-
break;
|
|
905
|
-
case "End":
|
|
906
|
-
event.preventDefault();
|
|
907
|
-
newScrollTop = maxScrollTop;
|
|
908
|
-
break;
|
|
909
|
-
default:
|
|
910
|
-
return;
|
|
911
|
-
}
|
|
912
|
-
if (newScrollTop !== null) {
|
|
913
|
-
// 썸 위치를 먼저 업데이트
|
|
914
|
-
const scrollRatio = newScrollTop / maxScrollTop;
|
|
915
|
-
const arrowSpace = showArrows
|
|
916
|
-
? finalThumbWidth * 2 + finalTrackConfig.margin * 4
|
|
917
|
-
: finalTrackConfig.margin * 2;
|
|
918
|
-
const availableHeight = clientHeight - arrowSpace;
|
|
919
|
-
const scrollableThumbHeight = availableHeight - thumbHeight;
|
|
920
|
-
const newThumbTop = scrollableThumbHeight * scrollRatio;
|
|
921
|
-
setThumbTop(newThumbTop);
|
|
922
|
-
// 스크롤 위치를 즉시 변경 (애니메이션 없음)
|
|
923
|
-
scrollableElement.scrollTop = newScrollTop;
|
|
924
|
-
// 스크롤바 표시
|
|
925
|
-
clearHideTimer();
|
|
926
|
-
setScrollbarVisible(true);
|
|
927
|
-
setHideTimer(finalAutoHideConfig.delay);
|
|
928
|
-
}
|
|
929
|
-
};
|
|
930
|
-
const container = containerRef.current;
|
|
931
|
-
if (container) {
|
|
932
|
-
container.addEventListener("keydown", handleKeyDown);
|
|
933
|
-
return () => {
|
|
934
|
-
container.removeEventListener("keydown", handleKeyDown);
|
|
935
|
-
};
|
|
936
|
-
}
|
|
937
|
-
}, [
|
|
938
|
-
findScrollableElement,
|
|
939
|
-
showArrows,
|
|
940
|
-
finalThumbWidth,
|
|
941
|
-
finalTrackConfig.margin,
|
|
942
|
-
thumbHeight,
|
|
943
|
-
clearHideTimer,
|
|
944
|
-
setHideTimer,
|
|
945
|
-
finalAutoHideConfig.delay,
|
|
946
|
-
]);
|
|
947
|
-
// 드래그 스크롤 전역 마우스 이벤트 리스너
|
|
948
|
-
react.useEffect(() => {
|
|
949
|
-
if (isDragScrolling) {
|
|
950
|
-
document.addEventListener("mousemove", handleDragScrollMove);
|
|
951
|
-
document.addEventListener("mouseup", handleDragScrollEnd);
|
|
952
|
-
return () => {
|
|
953
|
-
document.removeEventListener("mousemove", handleDragScrollMove);
|
|
954
|
-
document.removeEventListener("mouseup", handleDragScrollEnd);
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
}, [isDragScrolling, handleDragScrollMove, handleDragScrollEnd]);
|
|
958
|
-
// 전역 마우스 이벤트 리스너
|
|
959
|
-
react.useEffect(() => {
|
|
960
|
-
if (isDragging) {
|
|
961
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
962
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
963
|
-
return () => {
|
|
964
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
965
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
966
|
-
};
|
|
967
|
-
}
|
|
968
|
-
}, [isDragging, handleMouseMove, handleMouseUp]);
|
|
969
|
-
// 초기 스크롤바 업데이트
|
|
970
|
-
react.useEffect(() => {
|
|
971
|
-
// 즉시 업데이트
|
|
972
|
-
updateScrollbar();
|
|
973
|
-
// 약간의 지연 후에도 업데이트 (DOM이 완전히 렌더링된 후)
|
|
974
|
-
const timer = setTimeout(() => {
|
|
975
|
-
updateScrollbar();
|
|
976
|
-
}, 100);
|
|
977
|
-
return () => clearTimeout(timer);
|
|
978
|
-
}, [updateScrollbar]);
|
|
979
|
-
// 컴포넌트 초기화 완료 표시 (hover 이벤트 활성화용)
|
|
980
|
-
react.useLayoutEffect(() => {
|
|
981
|
-
setIsInitialized(true);
|
|
982
|
-
// 초기화 직후 스크롤바 업데이트 (썸 높이 정확하게 계산)
|
|
983
|
-
updateScrollbar();
|
|
984
|
-
// 자동 숨김이 비활성화되어 있으면 스크롤바를 항상 표시
|
|
985
|
-
if (!finalAutoHideConfig.enabled && isScrollable()) {
|
|
986
|
-
setScrollbarVisible(true);
|
|
987
|
-
}
|
|
988
|
-
}, [isScrollable, updateScrollbar, finalAutoHideConfig.enabled]);
|
|
989
|
-
// Resize observer로 크기 변경 감지
|
|
990
|
-
react.useEffect(() => {
|
|
991
|
-
const resizeObserver = new ResizeObserver(() => {
|
|
992
|
-
updateScrollbar();
|
|
993
|
-
});
|
|
994
|
-
const elementsToObserve = [];
|
|
995
|
-
// 내부 컨테이너들 관찰
|
|
996
|
-
if (containerRef.current) {
|
|
997
|
-
elementsToObserve.push(containerRef.current);
|
|
998
|
-
}
|
|
999
|
-
if (contentRef.current) {
|
|
1000
|
-
elementsToObserve.push(contentRef.current);
|
|
1001
|
-
}
|
|
1002
|
-
// 캐시된 스크롤 컨테이너도 관찰
|
|
1003
|
-
if (cachedScrollContainerRef.current &&
|
|
1004
|
-
document.contains(cachedScrollContainerRef.current)) {
|
|
1005
|
-
elementsToObserve.push(cachedScrollContainerRef.current);
|
|
1006
|
-
}
|
|
1007
|
-
// 모든 요소들 관찰 시작
|
|
1008
|
-
elementsToObserve.forEach((element) => {
|
|
1009
|
-
resizeObserver.observe(element);
|
|
1010
|
-
});
|
|
1011
|
-
return () => resizeObserver.disconnect();
|
|
1012
|
-
}, [updateScrollbar]);
|
|
1013
|
-
// MutationObserver로 DOM 변경 감지
|
|
1014
|
-
react.useEffect(() => {
|
|
1015
|
-
if (!containerRef.current) {
|
|
1016
|
-
return;
|
|
1017
|
-
}
|
|
1018
|
-
const observer = new MutationObserver(() => {
|
|
1019
|
-
// 캐시 초기화하여 새로운 스크롤 컨테이너 감지
|
|
1020
|
-
cachedScrollContainerRef.current = null;
|
|
1021
|
-
updateScrollbar();
|
|
1022
|
-
});
|
|
1023
|
-
observer.observe(containerRef.current, {
|
|
1024
|
-
childList: true,
|
|
1025
|
-
subtree: true,
|
|
1026
|
-
attributes: true,
|
|
1027
|
-
attributeFilter: ["style"],
|
|
1028
|
-
});
|
|
1029
|
-
return () => observer.disconnect();
|
|
1030
|
-
}, [updateScrollbar]);
|
|
1031
|
-
// trackWidth가 thumbWidth보다 작으면 thumbWidth와 같게 설정
|
|
1032
|
-
const adjustedTrackWidth = Math.max(finalTrackWidth, finalThumbWidth);
|
|
1033
|
-
// 웹킷 스크롤바 숨기기용 CSS 동적 주입
|
|
1034
|
-
react.useEffect(() => {
|
|
1035
|
-
const styleId = "overlay-scrollbar-webkit-hide";
|
|
1036
|
-
// 이미 스타일이 있으면 제거
|
|
1037
|
-
const existingStyle = document.getElementById(styleId);
|
|
1038
|
-
if (existingStyle) {
|
|
1039
|
-
existingStyle.remove();
|
|
1040
|
-
}
|
|
1041
|
-
const style = document.createElement("style");
|
|
1042
|
-
style.id = styleId;
|
|
1043
|
-
style.textContent = `
|
|
1
|
+
"use strict";var pe=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var Ye=Object.prototype.hasOwnProperty;var Ge=(m,f)=>{for(var S in f)pe(m,S,{get:f[S],enumerable:!0})},Je=(m,f,S,M)=>{if(f&&typeof f=="object"||typeof f=="function")for(let g of Be(f))!Ye.call(m,g)&&g!==S&&pe(m,g,{get:()=>f[g],enumerable:!(M=ze(f,g))||M.enumerable});return m};var Xe=m=>Je(pe({},"__esModule",{value:!0}),m);var rt={};Ge(rt,{OverlayScrollbar:()=>fe,default:()=>fe});module.exports=Xe(rt);var e=require("react");var Ke=["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"],me=(m,f)=>{let S=m.tagName.toLowerCase(),M=["text","password","email","number","search","tel","url","checkbox","radio"];if(S==="input"){let g=m.type;return M.includes(g)}if(["textarea","select","button"].includes(S)||["svg","path","circle","rect","line","polygon","polyline"].includes(S)||m.getAttribute("contenteditable")==="true")return!0;if(f?.excludeSelectors){for(let g of f.excludeSelectors)if(m.matches(g))return!0}return Ze(m,f)},Ze=(m,f)=>{let S=[...Ke,...f?.excludeClasses||[]],M=m,g=0,P=5;for(;M&&g<=P;){if(S.some(E=>M.classList.contains(E)))return!0;if(M.classList.contains("MuiDialogContent-root"))break;M=M.parentElement,g++}return!1};var D=require("react/jsx-runtime"),je={},Ve={},Qe={},et={},tt={},ot=(0,e.forwardRef)(({className:m="",style:f={},containerStyle:S={},contentStyle:M={},children:g,onScroll:P,thumb:E=je,track:R=Ve,arrows:I=Qe,dragScroll:_=et,autoHide:q=tt,showScrollbar:X=!0,detectInnerScroll:Ee=!1},Ce)=>{let He=(0,e.useRef)({});(0,e.useEffect)(()=>{He.current={children:g,onScroll:P,showScrollbar:X,thumb:E,track:R,arrows:I,dragScroll:_,autoHide:q}});let te=(0,e.useRef)(null),n=(0,e.useRef)(null),O=(0,e.useRef)(null),K=(0,e.useRef)(null),De=(0,e.useRef)(null),k=(0,e.useRef)(null),[oe,x]=(0,e.useState)(!1),[N,he]=(0,e.useState)(!1),[ge,be]=(0,e.useState)(!1),[re,ke]=(0,e.useState)({y:0,scrollTop:0}),[U,Le]=(0,e.useState)(0),[Re,ve]=(0,e.useState)(0),[ne,ye]=(0,e.useState)(!1),[W,xe]=(0,e.useState)(!1),[Z,Ie]=(0,e.useState)({x:0,y:0,scrollTop:0,scrollLeft:0}),[nt,lt]=(0,e.useState)(null),[j,V]=(0,e.useState)(null),[it,Ae]=(0,e.useState)(!1),z=(0,e.useRef)(null),[Te,we]=(0,e.useState)(!1),B=(0,e.useRef)(null),Y=(0,e.useRef)(null),$=(0,e.useRef)(null),T=(0,e.useMemo)(()=>{let t=E.color??"#606060";return{width:E.width??8,minHeight:E.minHeight??50,radius:E.radius??(E.width??8)/2,color:t,opacity:E.opacity??.6,hoverColor:E.hoverColor??t,hoverOpacity:E.hoverOpacity??1}},[E]),a=(0,e.useMemo)(()=>({width:R.width??16,color:R.color??"rgba(128, 128, 128, 0.1)",visible:R.visible??!0,alignment:R.alignment??"center",radius:R.radius??T.radius??4,margin:R.margin??4}),[R,T.radius]),H=(0,e.useMemo)(()=>{let t=I.color??"#808080";return{visible:I.visible??!1,step:I.step??50,color:t,opacity:I.opacity??.6,hoverColor:I.hoverColor??t,hoverOpacity:I.hoverOpacity??1}},[I]),le=(0,e.useMemo)(()=>({enabled:_.enabled??!0,excludeClasses:_.excludeClasses??[],excludeSelectors:_.excludeSelectors??[]}),[_]),c=(0,e.useMemo)(()=>({enabled:q.enabled??!0,delay:q.delay??1500,delayOnWheel:q.delayOnWheel??700}),[q]),h=T.width,Oe=a.width,ie=T.minHeight,L=H.visible,Q=H.step,A=(0,e.useCallback)(()=>{if(!n.current)return;let t=document.activeElement;t&&n.current.contains(t)&&t!==n.current||n.current.focus()},[]);(0,e.useImperativeHandle)(Ce,()=>({getScrollContainer:()=>n.current,scrollTo:t=>{n.current&&n.current.scrollTo(t)},get scrollTop(){return n.current?.scrollTop||0},get scrollHeight(){return n.current?.scrollHeight||0},get clientHeight(){return n.current?.clientHeight||0}}),[]);let d=(0,e.useCallback)(()=>{if(k.current){let o=k.current;if(document.contains(o)&&o.scrollHeight>o.clientHeight+2)return o;k.current=null}if(!n.current)return null;if(O.current&&O.current.scrollHeight>n.current.clientHeight+2)return k.current=n.current,n.current;if(!Ee)return null;let t=n.current.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]');for(let o of t){let r=o;if(r!==n.current&&r.classList.contains("overlay-scrollbar-container"))continue;let l=r.parentElement,i=!1;for(;l&&l!==n.current;){if(l.classList.contains("overlay-scrollbar-container")&&l!==n.current){i=!0;break}l=l.parentElement}if(!i&&r.scrollHeight>r.clientHeight+2)return k.current=r,r}return null},[]),F=(0,e.useCallback)(()=>d()!==null,[d]),b=(0,e.useCallback)(()=>{B.current&&(clearTimeout(B.current),B.current=null)},[]),Ne=(0,e.useCallback)(()=>{Y.current&&(clearTimeout(Y.current),Y.current=null)},[]),$e=(0,e.useCallback)(()=>{$.current&&(clearTimeout($.current),$.current=null)},[]),v=(0,e.useCallback)(t=>{c.enabled&&(b(),B.current=setTimeout(()=>{x(!1),B.current=null},t))},[b,c.enabled]),s=(0,e.useCallback)(()=>{let t=d();if(!t){x(!1),ye(!1),b();return}if(ye(!0),!K.current)return;c.enabled||(x(!0),b());let o=t.clientHeight,r=t.scrollHeight,l=t.scrollTop,i=0;if(te.current){let ee=window.getComputedStyle(te.current),Se=parseFloat(ee.paddingTop)||0,Me=parseFloat(ee.paddingBottom)||0;i=Se+Me}let u=L?h*2+a.margin*4:a.margin*2,w=o-u+i,y=o/r,p=Math.max(w*y,ie),J=r-o,C=w-p,de=J>0?l/J*C:0;Le(p),ve(de)},[d,b,L,h,ie,c.enabled]),Pe=(0,e.useCallback)(t=>{t.preventDefault(),t.stopPropagation();let o=d();o&&(he(!0),ke({y:t.clientY,scrollTop:o.scrollTop}),b(),x(!0),A())},[d,b,A]),ce=(0,e.useCallback)(t=>{if(!N)return;let o=d();if(!o)return;let r=o.clientHeight,i=o.scrollHeight-r,u=t.clientY-re.y,w=r-U,y=u/w*i,p=Math.max(0,Math.min(i,re.scrollTop+y));o.scrollTop=p,s()},[N,re,U,s,d]),ae=(0,e.useCallback)(()=>{he(!1),F()&&v(c.delay)},[F,v,c.delay]),Fe=(0,e.useCallback)(t=>{if(!K.current)return;let r=K.current.getBoundingClientRect(),l=t.clientY-r.top,i=d();if(!i)return;let u=i.clientHeight,w=i.scrollHeight,p=l/u*(w-u);i.scrollTop=Math.max(0,Math.min(w-u,p)),s(),x(!0),v(c.delay),A()},[s,v,c.delay,d,A]),_e=(0,e.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),!n.current)return;let o=Math.max(0,n.current.scrollTop-Q);n.current.scrollTop=o,s(),x(!0),v(c.delay),A()},[s,v,Q,c.delay,A]),qe=(0,e.useCallback)(t=>{if(t.preventDefault(),t.stopPropagation(),!n.current||!O.current)return;let o=n.current,l=O.current.scrollHeight-o.clientHeight,i=Math.min(l,o.scrollTop+Q);o.scrollTop=i,s(),x(!0),v(c.delay),A()},[s,v,Q,c.delay,A]),Ue=(0,e.useCallback)(t=>{if(!le.enabled)return;let o=t.target;if(me(o,le)||t.button!==0)return;let r=d();r&&(r.scrollHeight<=r.clientHeight||(t.preventDefault(),xe(!0),Ie({x:t.clientX,y:t.clientY,scrollTop:r.scrollTop,scrollLeft:r.scrollLeft||0}),b()))},[le,me,d,b]),se=(0,e.useCallback)(t=>{if(!W)return;let o=d();if(!o)return;let r=Z.x-t.clientX,l=Z.y-t.clientY;if(Math.abs(l)<3&&Math.abs(r)<3)return;x(!0);let i=Math.max(0,Math.min(o.scrollHeight-o.clientHeight,Z.scrollTop+l));o.scrollTop=i,s()},[W,Z,d,s]),ue=(0,e.useCallback)(()=>{xe(!1),F()&&v(c.delay)},[F,v,c.delay]);(0,e.useEffect)(()=>{let t=u=>{s(),b(),x(!0);let w=Te?c.delayOnWheel:c.delay;v(w),P&&P(u)},o=()=>{we(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{we(!1)},300),b(),$e(),$.current=setTimeout(()=>{x(!0),$.current=null},50)},r=[],l=d();l&&r.push(l);let i=n.current;return i&&!l&&(r.push(i),i.querySelectorAll('[data-virtuoso-scroller], [style*="overflow"], .virtuoso-scroller, [style*="overflow: auto"], [style*="overflow:auto"]').forEach(w=>{let y=w;if(y!==i&&y.classList.contains("overlay-scrollbar-container"))return;let p=y.parentElement;for(;p&&p!==i;){if(p.classList.contains("overlay-scrollbar-container")&&p!==i)return;p=p.parentElement}r.push(y)})),r.forEach(u=>{u.addEventListener("scroll",t,{passive:!0}),u.addEventListener("wheel",o,{passive:!0})}),()=>{r.forEach(u=>{u.removeEventListener("scroll",t),u.removeEventListener("wheel",o)}),z.current&&clearTimeout(z.current),$.current&&clearTimeout($.current)}},[d,s,P,b,v,c,Te]),(0,e.useEffect)(()=>{let t=r=>{let l=d();if(!l)return;let{key:i}=r,{scrollTop:u,scrollHeight:w,clientHeight:y}=l,p=w-y,J=50,C=null;switch(i){case"ArrowUp":r.preventDefault(),C=Math.max(0,u-J);break;case"ArrowDown":r.preventDefault(),C=Math.min(p,u+J);break;case"PageUp":r.preventDefault(),C=Math.max(0,u-y);break;case"PageDown":r.preventDefault(),C=Math.min(p,u+y);break;case"Home":r.preventDefault(),C=0;break;case"End":r.preventDefault(),C=p;break;default:return}if(C!==null){let de=C/p,ee=L?h*2+a.margin*4:a.margin*2,We=(y-ee-U)*de;ve(We),l.scrollTop=C,b(),x(!0),v(c.delay)}},o=n.current;if(o)return o.addEventListener("keydown",t),()=>{o.removeEventListener("keydown",t)}},[d,L,h,a.margin,U,b,v,c.delay]),(0,e.useEffect)(()=>{if(W)return document.addEventListener("mousemove",se),document.addEventListener("mouseup",ue),()=>{document.removeEventListener("mousemove",se),document.removeEventListener("mouseup",ue)}},[W,se,ue]),(0,e.useEffect)(()=>{if(N)return document.addEventListener("mousemove",ce),document.addEventListener("mouseup",ae),()=>{document.removeEventListener("mousemove",ce),document.removeEventListener("mouseup",ae)}},[N,ce,ae]),(0,e.useEffect)(()=>{s();let t=setTimeout(()=>{s()},100);return()=>clearTimeout(t)},[s]),(0,e.useLayoutEffect)(()=>{Ae(!0),s(),!c.enabled&&F()&&x(!0)},[F,s,c.enabled]),(0,e.useEffect)(()=>{let t=new ResizeObserver(()=>{s()}),o=[];return n.current&&o.push(n.current),O.current&&o.push(O.current),k.current&&document.contains(k.current)&&o.push(k.current),o.forEach(r=>{t.observe(r)}),()=>t.disconnect()},[s]),(0,e.useEffect)(()=>{if(!n.current)return;let t=new MutationObserver(()=>{k.current=null,s()});return t.observe(n.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style"]}),()=>t.disconnect()},[s]);let G=Math.max(Oe,h);return(0,e.useEffect)(()=>{let t="overlay-scrollbar-webkit-hide",o=document.getElementById(t);o&&o.remove();let r=document.createElement("style");return r.id=t,r.textContent=`
|
|
1044
2
|
.overlay-scrollbar-container::-webkit-scrollbar {
|
|
1045
3
|
display: none !important;
|
|
1046
4
|
width: 0 !important;
|
|
@@ -1060,144 +18,5 @@ showScrollbar = true, detectInnerScroll = false, }, ref) => {
|
|
|
1060
18
|
outline: 2px solid rgba(0, 123, 255, 0.5);
|
|
1061
19
|
outline-offset: -2px;
|
|
1062
20
|
}
|
|
1063
|
-
|
|
1064
|
-
document.head.appendChild(style);
|
|
1065
|
-
return () => {
|
|
1066
|
-
const styleToRemove = document.getElementById(styleId);
|
|
1067
|
-
if (styleToRemove) {
|
|
1068
|
-
styleToRemove.remove();
|
|
1069
|
-
}
|
|
1070
|
-
};
|
|
1071
|
-
}, []);
|
|
1072
|
-
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",
|
|
1073
|
-
// 브라우저 기본 스크롤바만 숨기기
|
|
1074
|
-
scrollbarWidth: "none", msOverflowStyle: "none",
|
|
1075
|
-
// 키보드 포커스 스타일 (접근성)
|
|
1076
|
-
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: () => {
|
|
1077
|
-
// 숨김 타이머는 즉시 취소
|
|
1078
|
-
clearHideTimer();
|
|
1079
|
-
// 호버 진입 타이머 설정 (100ms 후 표시)
|
|
1080
|
-
hoverEnterTimeoutRef.current = setTimeout(() => {
|
|
1081
|
-
setScrollbarVisible(true);
|
|
1082
|
-
hoverEnterTimeoutRef.current = null;
|
|
1083
|
-
}, 100);
|
|
1084
|
-
}, onMouseLeave: () => {
|
|
1085
|
-
// 호버 진입 타이머 취소 (지나가기만 한 경우)
|
|
1086
|
-
clearHoverEnterTimer();
|
|
1087
|
-
if (!isDragging) {
|
|
1088
|
-
setHideTimer(finalAutoHideConfig.delay);
|
|
1089
|
-
}
|
|
1090
|
-
}, style: {
|
|
1091
|
-
position: "absolute",
|
|
1092
|
-
top: 0,
|
|
1093
|
-
right: 0,
|
|
1094
|
-
width: `${adjustedTrackWidth}px`,
|
|
1095
|
-
height: "100%",
|
|
1096
|
-
opacity: scrollbarVisible ? 1 : 0,
|
|
1097
|
-
transition: "opacity 0.2s ease-in-out",
|
|
1098
|
-
cursor: "pointer",
|
|
1099
|
-
zIndex: 1000,
|
|
1100
|
-
pointerEvents: "auto",
|
|
1101
|
-
}, children: [finalTrackConfig.visible && (jsxRuntime.jsx("div", { className: "overlay-scrollbar-track-background", onClick: (e) => {
|
|
1102
|
-
e.preventDefault();
|
|
1103
|
-
e.stopPropagation();
|
|
1104
|
-
handleTrackClick(e);
|
|
1105
|
-
}, style: {
|
|
1106
|
-
position: "absolute",
|
|
1107
|
-
top: showArrows
|
|
1108
|
-
? `${finalThumbConfig.width +
|
|
1109
|
-
finalTrackConfig.margin * 2}px`
|
|
1110
|
-
: `${finalTrackConfig.margin}px`,
|
|
1111
|
-
right: finalTrackConfig.alignment === "right"
|
|
1112
|
-
? "0px"
|
|
1113
|
-
: `${(adjustedTrackWidth -
|
|
1114
|
-
finalThumbConfig.width) /
|
|
1115
|
-
2}px`, // 트랙 정렬
|
|
1116
|
-
width: `${finalThumbConfig.width}px`,
|
|
1117
|
-
height: showArrows
|
|
1118
|
-
? `calc(100% - ${finalThumbConfig.width * 2 +
|
|
1119
|
-
finalTrackConfig.margin * 4}px)`
|
|
1120
|
-
: `calc(100% - ${finalTrackConfig.margin * 2}px)`,
|
|
1121
|
-
backgroundColor: finalTrackConfig.color,
|
|
1122
|
-
borderRadius: `${finalTrackConfig.radius}px`,
|
|
1123
|
-
cursor: "pointer",
|
|
1124
|
-
} })), jsxRuntime.jsx("div", { ref: thumbRef, className: "overlay-scrollbar-thumb", onMouseDown: handleThumbMouseDown, onMouseEnter: () => setIsThumbHovered(true), onMouseLeave: () => setIsThumbHovered(false), style: {
|
|
1125
|
-
position: "absolute",
|
|
1126
|
-
top: `${(showArrows
|
|
1127
|
-
? finalThumbWidth +
|
|
1128
|
-
finalTrackConfig.margin * 2
|
|
1129
|
-
: finalTrackConfig.margin) + thumbTop}px`,
|
|
1130
|
-
right: finalTrackConfig.alignment === "right"
|
|
1131
|
-
? "0px"
|
|
1132
|
-
: `${(adjustedTrackWidth -
|
|
1133
|
-
finalThumbWidth) /
|
|
1134
|
-
2}px`, // 트랙 정렬
|
|
1135
|
-
width: `${finalThumbWidth}px`,
|
|
1136
|
-
height: `${Math.max(thumbHeight, thumbMinHeight)}px`,
|
|
1137
|
-
backgroundColor: isThumbHovered || isDragging
|
|
1138
|
-
? finalThumbConfig.hoverColor
|
|
1139
|
-
: finalThumbConfig.color,
|
|
1140
|
-
opacity: isThumbHovered || isDragging
|
|
1141
|
-
? finalThumbConfig.hoverOpacity
|
|
1142
|
-
: finalThumbConfig.opacity,
|
|
1143
|
-
borderRadius: `${finalThumbConfig.radius}px`,
|
|
1144
|
-
cursor: "pointer",
|
|
1145
|
-
transition: "background-color 0.2s ease-in-out, opacity 0.2s ease-in-out",
|
|
1146
|
-
} })] })), showScrollbar && hasScrollableContent && showArrows && (jsxRuntime.jsx("div", { className: "overlay-scrollbar-up-arrow", onClick: handleUpArrowClick, onMouseEnter: () => setHoveredArrow("up"), onMouseLeave: () => setHoveredArrow(null), style: {
|
|
1147
|
-
position: "absolute",
|
|
1148
|
-
top: `${finalTrackConfig.margin}px`,
|
|
1149
|
-
right: finalTrackConfig.alignment === "right"
|
|
1150
|
-
? "0px"
|
|
1151
|
-
: `${(adjustedTrackWidth -
|
|
1152
|
-
finalThumbWidth) /
|
|
1153
|
-
2}px`, // 트랙 정렬
|
|
1154
|
-
width: `${finalThumbWidth}px`,
|
|
1155
|
-
height: `${finalThumbWidth}px`,
|
|
1156
|
-
cursor: "pointer",
|
|
1157
|
-
display: "flex",
|
|
1158
|
-
alignItems: "center",
|
|
1159
|
-
justifyContent: "center",
|
|
1160
|
-
fontSize: `${Math.max(finalThumbWidth * 0.75, 8)}px`,
|
|
1161
|
-
color: hoveredArrow === "up"
|
|
1162
|
-
? finalArrowsConfig.hoverColor
|
|
1163
|
-
: finalArrowsConfig.color,
|
|
1164
|
-
userSelect: "none",
|
|
1165
|
-
zIndex: 1001,
|
|
1166
|
-
opacity: scrollbarVisible
|
|
1167
|
-
? hoveredArrow === "up"
|
|
1168
|
-
? finalArrowsConfig.hoverOpacity
|
|
1169
|
-
: finalArrowsConfig.opacity
|
|
1170
|
-
: 0,
|
|
1171
|
-
transition: "opacity 0.2s ease-in-out, color 0.15s ease-in-out",
|
|
1172
|
-
}, children: "\u25B2" })), showScrollbar && hasScrollableContent && showArrows && (jsxRuntime.jsx("div", { className: "overlay-scrollbar-down-arrow", onClick: handleDownArrowClick, onMouseEnter: () => setHoveredArrow("down"), onMouseLeave: () => setHoveredArrow(null), style: {
|
|
1173
|
-
position: "absolute",
|
|
1174
|
-
bottom: `${finalTrackConfig.margin}px`,
|
|
1175
|
-
right: finalTrackConfig.alignment === "right"
|
|
1176
|
-
? "0px"
|
|
1177
|
-
: `${(adjustedTrackWidth -
|
|
1178
|
-
finalThumbWidth) /
|
|
1179
|
-
2}px`, // 트랙 정렬
|
|
1180
|
-
width: `${finalThumbWidth}px`,
|
|
1181
|
-
height: `${finalThumbWidth}px`,
|
|
1182
|
-
cursor: "pointer",
|
|
1183
|
-
display: "flex",
|
|
1184
|
-
alignItems: "center",
|
|
1185
|
-
justifyContent: "center",
|
|
1186
|
-
fontSize: `${Math.max(finalThumbWidth * 0.75, 8)}px`,
|
|
1187
|
-
color: hoveredArrow === "down"
|
|
1188
|
-
? finalArrowsConfig.hoverColor
|
|
1189
|
-
: finalArrowsConfig.color,
|
|
1190
|
-
userSelect: "none",
|
|
1191
|
-
zIndex: 1001,
|
|
1192
|
-
opacity: scrollbarVisible
|
|
1193
|
-
? hoveredArrow === "down"
|
|
1194
|
-
? finalArrowsConfig.hoverOpacity
|
|
1195
|
-
: finalArrowsConfig.opacity
|
|
1196
|
-
: 0,
|
|
1197
|
-
transition: "opacity 0.2s ease-in-out, color 0.15s ease-in-out",
|
|
1198
|
-
}, children: "\u25BC" }))] }));
|
|
1199
|
-
});
|
|
1200
|
-
|
|
1201
|
-
exports.OverlayScrollbar = OverlayScrollbar;
|
|
1202
|
-
exports.default = OverlayScrollbar;
|
|
21
|
+
`,document.head.appendChild(r),()=>{let l=document.getElementById(t);l&&l.remove()}},[]),(0,D.jsxs)("div",{ref:te,className:`overlay-scrollbar-wrapper ${m}`,style:{display:"flex",flexDirection:"column",position:"relative",minHeight:0,height:"100%",flex:"1 1 0%",...f},children:[(0,D.jsx)("div",{ref:n,className:"overlay-scrollbar-container",tabIndex:-1,onMouseDown:Ue,style:{display:"flex",width:"100%",flex:"1 1 auto",minHeight:0,overflow:"auto",scrollbarWidth:"none",msOverflowStyle:"none",outline:"none",userSelect:W?"none":"auto",...S},children:(0,D.jsx)("div",{ref:O,className:"overlay-scrollbar-content",style:{flex:"1 1 0%",minHeight:0,display:"flex",flexDirection:"column",...M},children:g})}),X&&ne&&(0,D.jsxs)("div",{ref:K,className:"overlay-scrollbar-track",onMouseEnter:()=>{b(),Y.current=setTimeout(()=>{x(!0),Y.current=null},100)},onMouseLeave:()=>{Ne(),N||v(c.delay)},style:{position:"absolute",top:0,right:0,width:`${G}px`,height:"100%",opacity:oe?1:0,transition:"opacity 0.2s ease-in-out",cursor:"pointer",zIndex:1e3,pointerEvents:"auto"},children:[a.visible&&(0,D.jsx)("div",{className:"overlay-scrollbar-track-background",onClick:t=>{t.preventDefault(),t.stopPropagation(),Fe(t)},style:{position:"absolute",top:L?`${T.width+a.margin*2}px`:`${a.margin}px`,right:a.alignment==="right"?"0px":`${(G-T.width)/2}px`,width:`${T.width}px`,height:L?`calc(100% - ${T.width*2+a.margin*4}px)`:`calc(100% - ${a.margin*2}px)`,backgroundColor:a.color,borderRadius:`${a.radius}px`,cursor:"pointer"}}),(0,D.jsx)("div",{ref:De,className:"overlay-scrollbar-thumb",onMouseDown:Pe,onMouseEnter:()=>be(!0),onMouseLeave:()=>be(!1),style:{position:"absolute",top:`${(L?h+a.margin*2:a.margin)+Re}px`,right:a.alignment==="right"?"0px":`${(G-h)/2}px`,width:`${h}px`,height:`${Math.max(U,ie)}px`,backgroundColor:ge||N?T.hoverColor:T.color,opacity:ge||N?T.hoverOpacity:T.opacity,borderRadius:`${T.radius}px`,cursor:"pointer",transition:"background-color 0.2s ease-in-out, opacity 0.2s ease-in-out"}})]}),X&&ne&&L&&(0,D.jsx)("div",{className:"overlay-scrollbar-up-arrow",onClick:_e,onMouseEnter:()=>V("up"),onMouseLeave:()=>V(null),style:{position:"absolute",top:`${a.margin}px`,right:a.alignment==="right"?"0px":`${(G-h)/2}px`,width:`${h}px`,height:`${h}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(h*.75,8)}px`,color:j==="up"?H.hoverColor:H.color,userSelect:"none",zIndex:1001,opacity:oe?j==="up"?H.hoverOpacity:H.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25B2"}),X&&ne&&L&&(0,D.jsx)("div",{className:"overlay-scrollbar-down-arrow",onClick:qe,onMouseEnter:()=>V("down"),onMouseLeave:()=>V(null),style:{position:"absolute",bottom:`${a.margin}px`,right:a.alignment==="right"?"0px":`${(G-h)/2}px`,width:`${h}px`,height:`${h}px`,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:`${Math.max(h*.75,8)}px`,color:j==="down"?H.hoverColor:H.color,userSelect:"none",zIndex:1001,opacity:oe?j==="down"?H.hoverOpacity:H.opacity:0,transition:"opacity 0.2s ease-in-out, color 0.15s ease-in-out"},children:"\u25BC"})]})}),fe=ot;
|
|
1203
22
|
//# sourceMappingURL=index.js.map
|