@ncds/ui-admin 1.6.3 → 1.6.4-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (262) hide show
  1. package/mcp/bin/server.d.ts +1 -0
  2. package/mcp/bin/server.js +67 -0
  3. package/mcp/bin/server.mjs +14 -0
  4. package/mcp/bin/tools/getComponentHtml.d.ts +3 -0
  5. package/mcp/bin/tools/getComponentHtml.js +30 -0
  6. package/mcp/bin/tools/getComponentProps.d.ts +3 -0
  7. package/mcp/bin/tools/getComponentProps.js +16 -0
  8. package/mcp/bin/tools/listComponents.d.ts +3 -0
  9. package/mcp/bin/tools/listComponents.js +15 -0
  10. package/mcp/bin/tools/ping.d.ts +11 -0
  11. package/mcp/bin/tools/ping.js +30 -0
  12. package/mcp/bin/tools/searchComponent.d.ts +3 -0
  13. package/mcp/bin/tools/searchComponent.js +20 -0
  14. package/mcp/bin/tools/validateHtml.d.ts +10 -0
  15. package/mcp/bin/tools/validateHtml.js +142 -0
  16. package/mcp/bin/types.d.ts +28 -0
  17. package/mcp/bin/types.js +5 -0
  18. package/mcp/bin/utils/dataLoader.d.ts +11 -0
  19. package/mcp/bin/utils/dataLoader.js +68 -0
  20. package/mcp/bin/utils/logger.d.ts +18 -0
  21. package/mcp/bin/utils/logger.js +27 -0
  22. package/mcp/bin/utils/response.d.ts +23 -0
  23. package/mcp/bin/utils/response.js +31 -0
  24. package/mcp/bin/version.d.ts +1 -0
  25. package/mcp/bin/version.js +4 -0
  26. package/mcp/data/.gitkeep +0 -0
  27. package/mcp/data/_meta.json +7 -0
  28. package/mcp/data/badge-group.json +73 -0
  29. package/mcp/data/badge.json +86 -0
  30. package/mcp/data/bread-crumb.json +22 -0
  31. package/mcp/data/breadcrumb.json +31 -0
  32. package/mcp/data/button-group.json +65 -0
  33. package/mcp/data/button.json +114 -0
  34. package/mcp/data/carousel-arrow.json +59 -0
  35. package/mcp/data/carousel-number-group.json +57 -0
  36. package/mcp/data/carousel.json +22 -0
  37. package/mcp/data/checkbox.json +31 -0
  38. package/mcp/data/combobox.json +114 -0
  39. package/mcp/data/date-picker.json +77 -0
  40. package/mcp/data/divider.json +56 -0
  41. package/mcp/data/dot.json +55 -0
  42. package/mcp/data/dropdown.json +81 -0
  43. package/mcp/data/empty-state.json +34 -0
  44. package/mcp/data/featured-icon.json +83 -0
  45. package/mcp/data/file-input.json +76 -0
  46. package/mcp/data/horizontal-tab.json +71 -0
  47. package/mcp/data/image-file-input.json +97 -0
  48. package/mcp/data/input.json +104 -0
  49. package/mcp/data/modal.json +85 -0
  50. package/mcp/data/notification.json +116 -0
  51. package/mcp/data/number-input.json +128 -0
  52. package/mcp/data/pagination.json +65 -0
  53. package/mcp/data/password-input.json +47 -0
  54. package/mcp/data/progress-bar.json +51 -0
  55. package/mcp/data/progress-circle.json +54 -0
  56. package/mcp/data/radio.json +31 -0
  57. package/mcp/data/range-date-picker-with-buttons.json +64 -0
  58. package/mcp/data/range-date-picker.json +55 -0
  59. package/mcp/data/select-dropdown.json +32 -0
  60. package/mcp/data/select.json +64 -0
  61. package/mcp/data/selectbox.json +129 -0
  62. package/mcp/data/slider.json +57 -0
  63. package/mcp/data/spinner.json +54 -0
  64. package/mcp/data/switch.json +71 -0
  65. package/mcp/data/tab.json +122 -0
  66. package/mcp/data/tag.json +66 -0
  67. package/mcp/data/textarea.json +88 -0
  68. package/mcp/data/toggle.json +59 -0
  69. package/mcp/data/tooltip.json +123 -0
  70. package/mcp/data/vertical-tab.json +64 -0
  71. package/mcp/templates/.mcp.json.example +8 -0
  72. package/mcp/templates/README.md +31 -0
  73. package/package.json +26 -3
  74. package/dist/cjs/assets/scripts/comboBox.js +0 -280
  75. package/dist/cjs/assets/scripts/datePicker.js +0 -706
  76. package/dist/cjs/assets/scripts/featuredIcon.js +0 -95
  77. package/dist/cjs/assets/scripts/fileInput/FileInput.js +0 -183
  78. package/dist/cjs/assets/scripts/fileInput/FileInputModel.js +0 -246
  79. package/dist/cjs/assets/scripts/fileInput/FileInputView.js +0 -455
  80. package/dist/cjs/assets/scripts/fileInput/const/classNames.js +0 -35
  81. package/dist/cjs/assets/scripts/fileInput/const/index.js +0 -27
  82. package/dist/cjs/assets/scripts/fileInput/const/types.js +0 -13
  83. package/dist/cjs/assets/scripts/fileInput/index.js +0 -44
  84. package/dist/cjs/assets/scripts/imageFileInput/ImageFileInput.js +0 -187
  85. package/dist/cjs/assets/scripts/imageFileInput/ImageFileInputModel.js +0 -255
  86. package/dist/cjs/assets/scripts/imageFileInput/ImageFileInputView.js +0 -354
  87. package/dist/cjs/assets/scripts/imageFileInput/const/classNames.js +0 -41
  88. package/dist/cjs/assets/scripts/imageFileInput/const/index.js +0 -27
  89. package/dist/cjs/assets/scripts/imageFileInput/const/types.js +0 -13
  90. package/dist/cjs/assets/scripts/imageFileInput/index.js +0 -44
  91. package/dist/cjs/assets/scripts/index.js +0 -30
  92. package/dist/cjs/assets/scripts/modal/Modal.js +0 -116
  93. package/dist/cjs/assets/scripts/modal/ModalActions.js +0 -128
  94. package/dist/cjs/assets/scripts/modal/ModalContent.js +0 -46
  95. package/dist/cjs/assets/scripts/modal/ModalHeader.js +0 -115
  96. package/dist/cjs/assets/scripts/modal/const/classNames.js +0 -41
  97. package/dist/cjs/assets/scripts/modal/const/index.js +0 -27
  98. package/dist/cjs/assets/scripts/modal/const/types.js +0 -5
  99. package/dist/cjs/assets/scripts/modal/index.js +0 -61
  100. package/dist/cjs/assets/scripts/modal/utils/contentUtils.js +0 -35
  101. package/dist/cjs/assets/scripts/notification/FloatingNotification.js +0 -180
  102. package/dist/cjs/assets/scripts/notification/FullWidthNotification.js +0 -120
  103. package/dist/cjs/assets/scripts/notification/MessageNotification.js +0 -146
  104. package/dist/cjs/assets/scripts/notification/Notification.js +0 -116
  105. package/dist/cjs/assets/scripts/notification/const/classNames.js +0 -50
  106. package/dist/cjs/assets/scripts/notification/const/icons.js +0 -45
  107. package/dist/cjs/assets/scripts/notification/const/index.js +0 -87
  108. package/dist/cjs/assets/scripts/notification/const/sizes.js +0 -54
  109. package/dist/cjs/assets/scripts/notification/const/types.js +0 -14
  110. package/dist/cjs/assets/scripts/notification/index.js +0 -92
  111. package/dist/cjs/assets/scripts/notification/utils.js +0 -92
  112. package/dist/cjs/assets/scripts/progress-bar/ProgressBar.js +0 -272
  113. package/dist/cjs/assets/scripts/progress-bar/index.js +0 -12
  114. package/dist/cjs/assets/scripts/selectBox.js +0 -319
  115. package/dist/cjs/assets/scripts/shared/ButtonCloseX.js +0 -46
  116. package/dist/cjs/assets/scripts/tab.js +0 -40
  117. package/dist/cjs/assets/scripts/tag/Tag.js +0 -268
  118. package/dist/cjs/assets/scripts/tag/const/classNames.js +0 -24
  119. package/dist/cjs/assets/scripts/tag/const/index.js +0 -38
  120. package/dist/cjs/assets/scripts/tag/const/sizes.js +0 -13
  121. package/dist/cjs/assets/scripts/tag/const/types.js +0 -5
  122. package/dist/cjs/assets/scripts/tag/index.js +0 -44
  123. package/dist/cjs/assets/scripts/tooltip/Tooltip.js +0 -380
  124. package/dist/cjs/assets/scripts/tooltip/TooltipLayerManager.js +0 -84
  125. package/dist/cjs/assets/scripts/tooltip/const/classNames.js +0 -29
  126. package/dist/cjs/assets/scripts/tooltip/const/constants.js +0 -56
  127. package/dist/cjs/assets/scripts/tooltip/const/icons.js +0 -15
  128. package/dist/cjs/assets/scripts/tooltip/const/index.js +0 -123
  129. package/dist/cjs/assets/scripts/tooltip/const/templates.js +0 -49
  130. package/dist/cjs/assets/scripts/tooltip/const/types.js +0 -5
  131. package/dist/cjs/assets/scripts/tooltip/index.js +0 -57
  132. package/dist/cjs/assets/scripts/tooltip/utils.js +0 -41
  133. package/dist/cjs/assets/scripts/utils/unifiedBox/DOMRenderer.js +0 -384
  134. package/dist/cjs/assets/scripts/utils/unifiedBox/DropdownModel.js +0 -368
  135. package/dist/cjs/assets/scripts/utils/unifiedBox/UnifiedBoxController.js +0 -681
  136. package/dist/cjs/assets/scripts/utils/unifiedBox/UnifiedBoxManager.js +0 -711
  137. package/dist/esm/assets/scripts/comboBox.js +0 -275
  138. package/dist/esm/assets/scripts/datePicker.js +0 -699
  139. package/dist/esm/assets/scripts/featuredIcon.js +0 -90
  140. package/dist/esm/assets/scripts/fileInput/FileInput.js +0 -178
  141. package/dist/esm/assets/scripts/fileInput/FileInputModel.js +0 -241
  142. package/dist/esm/assets/scripts/fileInput/FileInputView.js +0 -450
  143. package/dist/esm/assets/scripts/fileInput/const/classNames.js +0 -25
  144. package/dist/esm/assets/scripts/fileInput/const/index.js +0 -2
  145. package/dist/esm/assets/scripts/fileInput/const/types.js +0 -7
  146. package/dist/esm/assets/scripts/fileInput/index.js +0 -9
  147. package/dist/esm/assets/scripts/imageFileInput/ImageFileInput.js +0 -182
  148. package/dist/esm/assets/scripts/imageFileInput/ImageFileInputModel.js +0 -250
  149. package/dist/esm/assets/scripts/imageFileInput/ImageFileInputView.js +0 -349
  150. package/dist/esm/assets/scripts/imageFileInput/const/classNames.js +0 -30
  151. package/dist/esm/assets/scripts/imageFileInput/const/index.js +0 -2
  152. package/dist/esm/assets/scripts/imageFileInput/const/types.js +0 -7
  153. package/dist/esm/assets/scripts/imageFileInput/index.js +0 -9
  154. package/dist/esm/assets/scripts/index.js +0 -28
  155. package/dist/esm/assets/scripts/modal/Modal.js +0 -110
  156. package/dist/esm/assets/scripts/modal/ModalActions.js +0 -123
  157. package/dist/esm/assets/scripts/modal/ModalContent.js +0 -41
  158. package/dist/esm/assets/scripts/modal/ModalHeader.js +0 -110
  159. package/dist/esm/assets/scripts/modal/const/classNames.js +0 -31
  160. package/dist/esm/assets/scripts/modal/const/index.js +0 -2
  161. package/dist/esm/assets/scripts/modal/const/types.js +0 -1
  162. package/dist/esm/assets/scripts/modal/index.js +0 -15
  163. package/dist/esm/assets/scripts/modal/utils/contentUtils.js +0 -28
  164. package/dist/esm/assets/scripts/notification/FloatingNotification.js +0 -176
  165. package/dist/esm/assets/scripts/notification/FullWidthNotification.js +0 -115
  166. package/dist/esm/assets/scripts/notification/MessageNotification.js +0 -141
  167. package/dist/esm/assets/scripts/notification/Notification.js +0 -111
  168. package/dist/esm/assets/scripts/notification/const/classNames.js +0 -44
  169. package/dist/esm/assets/scripts/notification/const/icons.js +0 -39
  170. package/dist/esm/assets/scripts/notification/const/index.js +0 -4
  171. package/dist/esm/assets/scripts/notification/const/sizes.js +0 -48
  172. package/dist/esm/assets/scripts/notification/const/types.js +0 -8
  173. package/dist/esm/assets/scripts/notification/index.js +0 -11
  174. package/dist/esm/assets/scripts/notification/utils.js +0 -79
  175. package/dist/esm/assets/scripts/progress-bar/ProgressBar.js +0 -267
  176. package/dist/esm/assets/scripts/progress-bar/index.js +0 -1
  177. package/dist/esm/assets/scripts/selectBox.js +0 -314
  178. package/dist/esm/assets/scripts/shared/ButtonCloseX.js +0 -38
  179. package/dist/esm/assets/scripts/tab.js +0 -35
  180. package/dist/esm/assets/scripts/tag/Tag.js +0 -263
  181. package/dist/esm/assets/scripts/tag/const/classNames.js +0 -16
  182. package/dist/esm/assets/scripts/tag/const/index.js +0 -3
  183. package/dist/esm/assets/scripts/tag/const/sizes.js +0 -7
  184. package/dist/esm/assets/scripts/tag/const/types.js +0 -1
  185. package/dist/esm/assets/scripts/tag/index.js +0 -9
  186. package/dist/esm/assets/scripts/tooltip/Tooltip.js +0 -375
  187. package/dist/esm/assets/scripts/tooltip/TooltipLayerManager.js +0 -79
  188. package/dist/esm/assets/scripts/tooltip/const/classNames.js +0 -23
  189. package/dist/esm/assets/scripts/tooltip/const/constants.js +0 -50
  190. package/dist/esm/assets/scripts/tooltip/const/icons.js +0 -9
  191. package/dist/esm/assets/scripts/tooltip/const/index.js +0 -4
  192. package/dist/esm/assets/scripts/tooltip/const/templates.js +0 -42
  193. package/dist/esm/assets/scripts/tooltip/const/types.js +0 -1
  194. package/dist/esm/assets/scripts/tooltip/index.js +0 -10
  195. package/dist/esm/assets/scripts/tooltip/utils.js +0 -35
  196. package/dist/esm/assets/scripts/utils/unifiedBox/DOMRenderer.js +0 -379
  197. package/dist/esm/assets/scripts/utils/unifiedBox/DropdownModel.js +0 -363
  198. package/dist/esm/assets/scripts/utils/unifiedBox/UnifiedBoxController.js +0 -676
  199. package/dist/esm/assets/scripts/utils/unifiedBox/UnifiedBoxManager.js +0 -706
  200. package/dist/types/assets/scripts/comboBox.d.ts +0 -91
  201. package/dist/types/assets/scripts/datePicker.d.ts +0 -87
  202. package/dist/types/assets/scripts/featuredIcon.d.ts +0 -23
  203. package/dist/types/assets/scripts/fileInput/FileInput.d.ts +0 -67
  204. package/dist/types/assets/scripts/fileInput/FileInputModel.d.ts +0 -70
  205. package/dist/types/assets/scripts/fileInput/FileInputView.d.ts +0 -77
  206. package/dist/types/assets/scripts/fileInput/const/classNames.d.ts +0 -17
  207. package/dist/types/assets/scripts/fileInput/const/index.d.ts +0 -3
  208. package/dist/types/assets/scripts/fileInput/const/types.d.ts +0 -132
  209. package/dist/types/assets/scripts/fileInput/index.d.ts +0 -4
  210. package/dist/types/assets/scripts/imageFileInput/ImageFileInput.d.ts +0 -64
  211. package/dist/types/assets/scripts/imageFileInput/ImageFileInputModel.d.ts +0 -74
  212. package/dist/types/assets/scripts/imageFileInput/ImageFileInputView.d.ts +0 -80
  213. package/dist/types/assets/scripts/imageFileInput/const/classNames.d.ts +0 -20
  214. package/dist/types/assets/scripts/imageFileInput/const/index.d.ts +0 -3
  215. package/dist/types/assets/scripts/imageFileInput/const/types.d.ts +0 -126
  216. package/dist/types/assets/scripts/imageFileInput/index.d.ts +0 -4
  217. package/dist/types/assets/scripts/index.d.ts +0 -33
  218. package/dist/types/assets/scripts/modal/Modal.d.ts +0 -28
  219. package/dist/types/assets/scripts/modal/ModalActions.d.ts +0 -19
  220. package/dist/types/assets/scripts/modal/ModalContent.d.ts +0 -14
  221. package/dist/types/assets/scripts/modal/ModalHeader.d.ts +0 -16
  222. package/dist/types/assets/scripts/modal/const/classNames.d.ts +0 -23
  223. package/dist/types/assets/scripts/modal/const/index.d.ts +0 -3
  224. package/dist/types/assets/scripts/modal/const/types.d.ts +0 -62
  225. package/dist/types/assets/scripts/modal/index.d.ts +0 -8
  226. package/dist/types/assets/scripts/modal/utils/contentUtils.d.ts +0 -11
  227. package/dist/types/assets/scripts/notification/FloatingNotification.d.ts +0 -25
  228. package/dist/types/assets/scripts/notification/FullWidthNotification.d.ts +0 -22
  229. package/dist/types/assets/scripts/notification/MessageNotification.d.ts +0 -23
  230. package/dist/types/assets/scripts/notification/Notification.d.ts +0 -22
  231. package/dist/types/assets/scripts/notification/const/classNames.d.ts +0 -44
  232. package/dist/types/assets/scripts/notification/const/icons.d.ts +0 -26
  233. package/dist/types/assets/scripts/notification/const/index.d.ts +0 -6
  234. package/dist/types/assets/scripts/notification/const/sizes.d.ts +0 -33
  235. package/dist/types/assets/scripts/notification/const/types.d.ts +0 -20
  236. package/dist/types/assets/scripts/notification/index.d.ts +0 -8
  237. package/dist/types/assets/scripts/notification/utils.d.ts +0 -9
  238. package/dist/types/assets/scripts/progress-bar/ProgressBar.d.ts +0 -68
  239. package/dist/types/assets/scripts/progress-bar/index.d.ts +0 -2
  240. package/dist/types/assets/scripts/selectBox.d.ts +0 -77
  241. package/dist/types/assets/scripts/shared/ButtonCloseX.d.ts +0 -6
  242. package/dist/types/assets/scripts/tab.d.ts +0 -8
  243. package/dist/types/assets/scripts/tag/Tag.d.ts +0 -28
  244. package/dist/types/assets/scripts/tag/const/classNames.d.ts +0 -12
  245. package/dist/types/assets/scripts/tag/const/index.d.ts +0 -4
  246. package/dist/types/assets/scripts/tag/const/sizes.d.ts +0 -8
  247. package/dist/types/assets/scripts/tag/const/types.d.ts +0 -34
  248. package/dist/types/assets/scripts/tag/index.d.ts +0 -4
  249. package/dist/types/assets/scripts/tooltip/Tooltip.d.ts +0 -55
  250. package/dist/types/assets/scripts/tooltip/TooltipLayerManager.d.ts +0 -22
  251. package/dist/types/assets/scripts/tooltip/const/classNames.d.ts +0 -18
  252. package/dist/types/assets/scripts/tooltip/const/constants.d.ts +0 -34
  253. package/dist/types/assets/scripts/tooltip/const/icons.d.ts +0 -5
  254. package/dist/types/assets/scripts/tooltip/const/index.d.ts +0 -6
  255. package/dist/types/assets/scripts/tooltip/const/templates.d.ts +0 -17
  256. package/dist/types/assets/scripts/tooltip/const/types.d.ts +0 -15
  257. package/dist/types/assets/scripts/tooltip/index.d.ts +0 -7
  258. package/dist/types/assets/scripts/tooltip/utils.d.ts +0 -3
  259. package/dist/types/assets/scripts/utils/unifiedBox/DOMRenderer.d.ts +0 -108
  260. package/dist/types/assets/scripts/utils/unifiedBox/DropdownModel.d.ts +0 -158
  261. package/dist/types/assets/scripts/utils/unifiedBox/UnifiedBoxController.d.ts +0 -171
  262. package/dist/types/assets/scripts/utils/unifiedBox/UnifiedBoxManager.d.ts +0 -99
@@ -1,263 +0,0 @@
1
- var __assign = this && this.__assign || function () {
2
- __assign = Object.assign || function (t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
- }
7
- return t;
8
- };
9
- return __assign.apply(this, arguments);
10
- };
11
- import { TAG_CLASS_NAMES, getTagSizeClassName, getTooltipPositionClassName } from './const/classNames';
12
- import { iconSize, DEFAULT_TOOLTIP_WIDTH, DEFAULT_TOOLTIP_HEIGHT, MARGIN } from './const/sizes';
13
- // CSS 변수 값을 가져오는 유틸리티 함수
14
- var getCSSVariable = function (variableName, fallback) {
15
- if (fallback === void 0) {
16
- fallback = '';
17
- }
18
- return getComputedStyle(document.documentElement).getPropertyValue(variableName).trim() || fallback;
19
- };
20
- // 위치 계산 로직
21
- var calculateOptimalPosition = function (triggerElement, tooltipElement) {
22
- var triggerRect = triggerElement.getBoundingClientRect();
23
- var tooltipRect = tooltipElement.getBoundingClientRect();
24
- var viewportWidth = window.innerWidth,
25
- viewportHeight = window.innerHeight;
26
- var tooltipWidth = tooltipRect.width || DEFAULT_TOOLTIP_WIDTH;
27
- var tooltipHeight = tooltipRect.height || DEFAULT_TOOLTIP_HEIGHT;
28
- var spaces = {
29
- top: triggerRect.top,
30
- bottom: viewportHeight - triggerRect.bottom,
31
- left: triggerRect.left,
32
- right: viewportWidth - triggerRect.right
33
- };
34
- // 위/아래 공간을 먼저 확인하고 우선순위 결정
35
- var hasTopSpace = spaces.top >= tooltipHeight + MARGIN;
36
- // 위쪽 공간이 있으면 top 우선, 없으면 bottom 우선
37
- var positions = hasTopSpace ? ['top-right', 'top-left', 'bottom-right', 'bottom-left'] : ['bottom-right', 'bottom-left', 'top-right', 'top-left'];
38
- for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
39
- var position = positions_1[_i];
40
- var isTop = position.includes('top');
41
- var isRight = position.includes('right');
42
- var hasVerticalSpace = isTop ? spaces.top >= tooltipHeight + MARGIN : spaces.bottom >= tooltipHeight + MARGIN;
43
- var hasHorizontalSpace = isRight ? spaces.right >= tooltipWidth + MARGIN // right 정렬: 툴팁이 오른쪽으로 펼쳐짐
44
- : spaces.left >= tooltipWidth + MARGIN; // left 정렬: 툴팁이 왼쪽으로 펼쳐짐
45
- if (hasVerticalSpace && hasHorizontalSpace) {
46
- return position;
47
- }
48
- }
49
- // 모든 조건이 맞지 않으면 공간이 더 많은 쪽으로
50
- var fallbackPosition = hasTopSpace ? 'top-right' : 'bottom-right';
51
- return fallbackPosition;
52
- };
53
- var Tag = /** @class */function () {
54
- function Tag(options) {
55
- var _this = this;
56
- this.isTooltipVisible = false;
57
- this.calculatedPosition = 'top-right';
58
- this.tooltipElement = null;
59
- this.handleMouseEnter = function () {
60
- if (!_this.shouldTruncate()) return;
61
- _this.isTooltipVisible = true;
62
- // 위치 계산
63
- if (_this.tooltipElement) {
64
- var optimalPosition = calculateOptimalPosition(_this.element, _this.tooltipElement);
65
- _this.calculatedPosition = optimalPosition;
66
- } else {
67
- // 툴팁이 없으면 더미 요소로 계산
68
- var dummyTooltipElement = document.createElement('div');
69
- dummyTooltipElement.style.width = "".concat(DEFAULT_TOOLTIP_WIDTH, "px");
70
- dummyTooltipElement.style.height = "".concat(DEFAULT_TOOLTIP_HEIGHT, "px");
71
- var optimalPosition = calculateOptimalPosition(_this.element, dummyTooltipElement);
72
- _this.calculatedPosition = optimalPosition;
73
- }
74
- _this.createTooltip();
75
- };
76
- this.handleMouseLeave = function () {
77
- _this.removeTooltip(); // removeTooltip에서 isTooltipVisible을 false로 설정
78
- };
79
- this.options = __assign({
80
- size: 'sm',
81
- maxLength: 20
82
- }, options);
83
- this.createElement();
84
- }
85
- Tag.prototype.createElement = function () {
86
- // 메인 태그 요소 생성
87
- this.element = document.createElement('span');
88
- this.element.className = this.getTagClasses();
89
- // 텍스트 길이 체크 및 말줄임 처리
90
- var shouldTruncate = this.shouldTruncate();
91
- var displayText = shouldTruncate ? this.getTruncatedText() : this.options.text;
92
- // 아이콘 추가
93
- if (this.options.icon) {
94
- var iconElement = this.createSideSlot(this.options.icon);
95
- if (iconElement) {
96
- this.element.appendChild(iconElement);
97
- }
98
- }
99
- // 텍스트 요소 생성
100
- var textElement = document.createElement('span');
101
- textElement.className = TAG_CLASS_NAMES.text;
102
- textElement.textContent = displayText;
103
- this.element.appendChild(textElement);
104
- // 카운트 추가
105
- if (this.options.count) {
106
- var countElement = document.createElement('span');
107
- countElement.className = TAG_CLASS_NAMES.count;
108
- countElement.textContent = this.options.count;
109
- this.element.appendChild(countElement);
110
- }
111
- // 닫기 버튼 추가
112
- if (this.options.close) {
113
- var closeButton = this.createCloseButton();
114
- this.element.appendChild(closeButton);
115
- }
116
- // 툴팁 이벤트 리스너 추가 (텍스트가 잘린 경우에만)
117
- if (shouldTruncate) {
118
- this.element.addEventListener('mouseenter', this.handleMouseEnter);
119
- this.element.addEventListener('mouseleave', this.handleMouseLeave);
120
- }
121
- };
122
- Tag.prototype.getTagClasses = function () {
123
- var classes = [TAG_CLASS_NAMES.tag, getTagSizeClassName(this.options.size)];
124
- if (this.shouldTruncate()) {
125
- classes.push(TAG_CLASS_NAMES.truncated);
126
- }
127
- return classes.join(' ');
128
- };
129
- Tag.prototype.shouldTruncate = function () {
130
- return this.options.text.length > this.options.maxLength;
131
- };
132
- Tag.prototype.getTruncatedText = function () {
133
- return "".concat(this.options.text.slice(0, this.options.maxLength - 2), "...");
134
- };
135
- Tag.prototype.createSideSlot = function (slot) {
136
- if (slot.type === 'icon') {
137
- // 아이콘 SVG 문자열을 DOM 요소로 변환 (DOMParser 사용)
138
- var iconSVG = this.createIconSVG(slot.icon, iconSize[this.options.size], slot.color);
139
- var parser = new DOMParser();
140
- var doc = parser.parseFromString(iconSVG, 'image/svg+xml');
141
- return doc.documentElement;
142
- }
143
- if (slot.type === 'dot') {
144
- var dotElement = document.createElement('span');
145
- dotElement.className = "ncua-dot ncua-dot--neutral ncua-dot--".concat(slot.size || 'sm');
146
- if (slot.color) {
147
- dotElement.style.backgroundColor = slot.color;
148
- }
149
- return dotElement;
150
- }
151
- // 커스텀 요소는 그대로 반환
152
- return slot.children;
153
- };
154
- Tag.prototype.createIconSVG = function (iconName, size, color) {
155
- var colorStyle = color ? " style=\"color: ".concat(color, "\"") : '';
156
- // 현재는 arrow-left 아이콘만 지원
157
- if (iconName === 'arrow-left') {
158
- return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(size, "\" height=\"").concat(size, "\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"none\"").concat(colorStyle, ">\n <path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M19 12H5m0 0 7 7m-7-7 7-7\" />\n </svg>");
159
- }
160
- // 기본 빈 SVG
161
- return "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(size, "\" height=\"").concat(size, "\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"none\"").concat(colorStyle, "></svg>");
162
- };
163
- Tag.prototype.createCloseButton = function () {
164
- // react와 동일한 구조로 직접 구현
165
- var button = document.createElement('button');
166
- button.type = 'button';
167
- button.className = TAG_CLASS_NAMES.close;
168
- // React 버전과 동일한 SVG 생성 (문자열 방식)
169
- var grayColor = getCSSVariable('--gray-300', '#a4a5a8');
170
- var svgString = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"".concat(iconSize[this.options.size], "\" height=\"").concat(iconSize[this.options.size], "\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"none\" style=\"color: ").concat(grayColor, "\">\n <path stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M18 6 6 18M6 6l12 12\" />\n </svg>");
171
- // DOMParser로 SVG 문자열을 DOM 요소로 변환
172
- var parser = new DOMParser();
173
- var doc = parser.parseFromString(svgString, 'image/svg+xml');
174
- var svg = doc.documentElement;
175
- button.appendChild(svg);
176
- // 이벤트 리스너 추가
177
- if (this.options.onButtonClick) {
178
- button.addEventListener('click', this.options.onButtonClick);
179
- }
180
- return button;
181
- };
182
- Tag.prototype.createTooltip = function () {
183
- if (this.tooltipElement || !this.isTooltipVisible) {
184
- return; // 이미 생성됨 또는 표시하지 않음
185
- }
186
- this.tooltipElement = document.createElement('span');
187
- this.tooltipElement.className = "".concat(TAG_CLASS_NAMES.tooltip, " ").concat(getTooltipPositionClassName(this.calculatedPosition));
188
- var tooltipContent = document.createElement('span');
189
- tooltipContent.className = TAG_CLASS_NAMES.tooltipContent;
190
- tooltipContent.textContent = this.options.text;
191
- this.tooltipElement.appendChild(tooltipContent);
192
- this.element.appendChild(this.tooltipElement);
193
- };
194
- Tag.prototype.removeTooltip = function () {
195
- if (this.tooltipElement) {
196
- this.element.removeChild(this.tooltipElement);
197
- this.tooltipElement = null;
198
- }
199
- this.isTooltipVisible = false;
200
- };
201
- Tag.prototype.getElement = function () {
202
- return this.element;
203
- };
204
- Tag.prototype.isTooltipShown = function () {
205
- return this.isTooltipVisible;
206
- };
207
- Tag.prototype.setText = function (text) {
208
- this.options.text = text;
209
- this.updateTextElement();
210
- };
211
- Tag.prototype.setCount = function (count) {
212
- this.options.count = count;
213
- this.updateCountElement();
214
- };
215
- Tag.prototype.updateTextElement = function () {
216
- var textElement = this.element.querySelector(".".concat(TAG_CLASS_NAMES.text));
217
- if (textElement) {
218
- var shouldTruncate = this.shouldTruncate();
219
- var displayText = shouldTruncate ? this.getTruncatedText() : this.options.text;
220
- textElement.textContent = displayText;
221
- // 클래스 업데이트
222
- if (shouldTruncate) {
223
- this.element.classList.add(TAG_CLASS_NAMES.truncated);
224
- } else {
225
- this.element.classList.remove(TAG_CLASS_NAMES.truncated);
226
- }
227
- }
228
- };
229
- Tag.prototype.updateCountElement = function () {
230
- var existingCount = this.element.querySelector(".".concat(TAG_CLASS_NAMES.count));
231
- if (this.options.count) {
232
- if (existingCount) {
233
- existingCount.textContent = this.options.count;
234
- } else {
235
- // 카운트 요소 새로 생성
236
- var countElement = document.createElement('span');
237
- countElement.className = TAG_CLASS_NAMES.count;
238
- countElement.textContent = this.options.count;
239
- // 닫기 버튼 앞에 삽입
240
- var closeButton = this.element.querySelector(".".concat(TAG_CLASS_NAMES.close));
241
- if (closeButton) {
242
- this.element.insertBefore(countElement, closeButton);
243
- } else {
244
- this.element.appendChild(countElement);
245
- }
246
- }
247
- } else {
248
- // 카운트 제거
249
- if (existingCount) {
250
- this.element.removeChild(existingCount);
251
- }
252
- }
253
- };
254
- Tag.prototype.destroy = function () {
255
- this.element.removeEventListener('mouseenter', this.handleMouseEnter);
256
- this.element.removeEventListener('mouseleave', this.handleMouseLeave);
257
- if (this.tooltipElement) {
258
- this.removeTooltip();
259
- }
260
- };
261
- return Tag;
262
- }();
263
- export { Tag };
@@ -1,16 +0,0 @@
1
- // Tag 관련 CSS 클래스명 상수
2
- export var TAG_CLASS_NAMES = {
3
- tag: 'ncua-tag',
4
- text: 'ncua-tag__text',
5
- count: 'ncua-tag__count',
6
- close: 'ncua-tag__close',
7
- tooltip: 'ncua-tag__tooltip',
8
- tooltipContent: 'ncua-tag__tooltip-content',
9
- truncated: 'ncua-tag--truncated'
10
- };
11
- export var getTagSizeClassName = function (size) {
12
- return "ncua-tag--".concat(size);
13
- };
14
- export var getTooltipPositionClassName = function (position) {
15
- return "ncua-tag__tooltip--".concat(position);
16
- };
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export * from './classNames';
3
- export * from './sizes';
@@ -1,7 +0,0 @@
1
- export var iconSize = {
2
- sm: 14,
3
- md: 16
4
- };
5
- export var MARGIN = 10;
6
- export var DEFAULT_TOOLTIP_WIDTH = 200;
7
- export var DEFAULT_TOOLTIP_HEIGHT = 60;
@@ -1 +0,0 @@
1
- export {};
@@ -1,9 +0,0 @@
1
- import { Tag } from './Tag';
2
- export { Tag } from './Tag';
3
- export * from './const/types';
4
- export * from './const/classNames';
5
- // 전역 등록 ( 추후 index.ts와 개별동작 할 수 있게끔 대비 )
6
- if (typeof window !== 'undefined') {
7
- window.ncua = window.ncua || {};
8
- window.ncua.Tag = Tag;
9
- }
@@ -1,375 +0,0 @@
1
- var __assign = this && this.__assign || function () {
2
- __assign = Object.assign || function (t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
6
- }
7
- return t;
8
- };
9
- return __assign.apply(this, arguments);
10
- };
11
- import { SVG_ICONS, CLASS_NAMES, TOOLTIP_DEFAULT_VALUE, ICON_SIZES, TOOLTIP_OFFSET, VIEWPORT_MARGIN, OFFSCREEN_POSITION, OPACITY, POSITION, EVENT_OPTIONS, CSS_TEMPLATES, HTML_TEMPLATES, FALLBACK_ICON_SVG, Z_INDEX } from './const';
12
- import { ButtonCloseX } from '../shared/ButtonCloseX';
13
- import { MEDIA_QUERY } from '../../../src/constant/breakpoint';
14
- import { TooltipLayerManager } from './TooltipLayerManager';
15
- /**
16
- * Tooltip 클래스
17
- * 툴팁 패널 패턴을 사용하여 툴팁을 생성합니다.
18
- * 툴팁 패널 패턴은 바깥 컨테이너(항상 pointer-events:none) + 실제 패널(클릭 허용) 패턴을 사용합니다.
19
- * 레이어 1개 아래에 여러개의 패널과 툴팁이 생성되어 화면에 삽입됩니다.
20
- * 자동 위치조정 ( 공간이 부족하다면 상하좌우를 조절하는 기능 - 기본값: top )을 사용합니다.
21
- * Shadow DOM 지원
22
- */
23
- var Tooltip = /** @class */function () {
24
- function Tooltip(options) {
25
- if (options === void 0) {
26
- options = {};
27
- }
28
- var _this = this;
29
- this.iconElement = null;
30
- // 전역 레이어 매니저 사용
31
- this.layerManager = TooltipLayerManager.getInstance();
32
- this.panelId = null;
33
- this.panel = null;
34
- this.calculatedPosition = 'top';
35
- this.isVisible = false;
36
- this.isMeasuring = false;
37
- this.isForceHidden = false;
38
- // 이벤트 핸들러
39
- this.boundMouseEnter = function () {
40
- return _this.handleMouseEnter();
41
- };
42
- this.boundMouseLeave = function () {
43
- return _this.handleMouseLeave();
44
- };
45
- this.boundResizeScroll = function () {
46
- return _this.handleResizeScroll();
47
- };
48
- this.boundPanelClick = function (e) {
49
- return _this.handlePanelClick(e);
50
- };
51
- /* ========== 핸들러 ========== */
52
- this.handleMouseEnter = function () {
53
- _this.showTooltip();
54
- if (_this.options.type === 'long') {
55
- // long은 X로 닫을 때까지 유지 → 재호버 방지
56
- _this.disableMouseEvents();
57
- }
58
- };
59
- this.handleMouseLeave = function () {
60
- if (_this.options.type === 'short') {
61
- _this.hideTooltip();
62
- }
63
- };
64
- this.handleResizeScroll = function () {
65
- if (_this.isVisible) _this.updateTooltipPosition();
66
- };
67
- this.handlePanelClick = function (e) {
68
- var t = e.target;
69
- if (t.closest(".".concat(CLASS_NAMES.TOOLTIP_CLOSE_BUTTON))) {
70
- e.stopPropagation();
71
- e.preventDefault();
72
- _this.isForceHidden = true;
73
- _this.hideTooltip();
74
- // long 타입에서 닫았으면 다시 hover 가능
75
- if (_this.options.type === 'long') _this.enableMouseEvents();
76
- }
77
- };
78
- this.options = __assign(__assign({}, TOOLTIP_DEFAULT_VALUE), options);
79
- this.element = this.createElement();
80
- this.bindEvents();
81
- }
82
- /* ========== DOM 생성 ========== */
83
- Tooltip.prototype.createElement = function () {
84
- var _a, _b, _c;
85
- var iconSize = ICON_SIZES[(_a = this.options.size) !== null && _a !== void 0 ? _a : 'sm'];
86
- var key = this.options.iconType === 'stroke' ? 'help-circle-stroke' : 'help-circle-fill';
87
- var iconSvg = (_c = (_b = SVG_ICONS[key]) === null || _b === void 0 ? void 0 : _b.call(SVG_ICONS, iconSize)) !== null && _c !== void 0 ? _c : FALLBACK_ICON_SVG(iconSize);
88
- var wrapper = document.createElement('span');
89
- wrapper.className = this.buildAnchorClassName();
90
- wrapper.style.cssText = CSS_TEMPLATES.ANCHOR_WRAPPER;
91
- wrapper.innerHTML = HTML_TEMPLATES.ICON_WRAPPER(CLASS_NAMES.TOOLTIP_ICON, iconSvg);
92
- this.iconElement = wrapper.querySelector(".".concat(CLASS_NAMES.TOOLTIP_ICON));
93
- // body에 레이어/패널 생성(패널 패턴)
94
- this.createLayerAndPanel();
95
- return wrapper;
96
- };
97
- // 앵커(아이콘 래퍼) 클래스
98
- Tooltip.prototype.buildAnchorClassName = function () {
99
- var classes = [CLASS_NAMES.TOOLTIP, "".concat(CLASS_NAMES.TOOLTIP, "--").concat(this.options.size), "".concat(CLASS_NAMES.TOOLTIP, "--").concat(this.options.type)];
100
- if (this.options.hideArrow) classes.push(CLASS_NAMES.TOOLTIP_HIDDEN_ARROW);
101
- if (this.options.iconType === 'stroke') classes.push(CLASS_NAMES.TOOLTIP_STROKE);
102
- if (this.options.position === 'auto') classes.push(CLASS_NAMES.TOOLTIP_AUTO);
103
- if (this.options.className) classes.push(this.options.className);
104
- return classes.join(' ');
105
- };
106
- // 패널 클래스 (방향/테마 가짐)
107
- Tooltip.prototype.buildPanelClassName = function () {
108
- var finalPosition = this.options.position === 'auto' ? this.calculatedPosition : this.options.position;
109
- var classes = [CLASS_NAMES.TOOLTIP_PANEL, CLASS_NAMES.TOOLTIP_BG, "".concat(CLASS_NAMES.TOOLTIP_BG, "--").concat(this.options.tooltipType), "".concat(CLASS_NAMES.TOOLTIP_BG, "--").concat(finalPosition)];
110
- if (this.isVisible) classes.push(CLASS_NAMES.TOOLTIP_BG_VISIBLE);
111
- if (this.isMeasuring) classes.push(CLASS_NAMES.TOOLTIP_BG_MEASURING);
112
- if (this.isForceHidden) classes.push(CLASS_NAMES.TOOLTIP_BG_FORCE_HIDDEN);
113
- return classes.join(' ');
114
- };
115
- Tooltip.prototype.renderContentHTML = function () {
116
- if (!this.options.content) return '';
117
- if (this.options.useShadowDOM) {
118
- return HTML_TEMPLATES.TOOLTIP_CONTENT_SHADOW(CLASS_NAMES.TOOLTIP_CONTENT);
119
- }
120
- return HTML_TEMPLATES.TOOLTIP_CONTENT(CLASS_NAMES.TOOLTIP_CONTENT, this.options.content);
121
- };
122
- Tooltip.prototype.renderCloseButtonHTML = function () {
123
- if (this.options.type !== 'long') return '';
124
- var theme = this.options.tooltipType === 'white' ? 'dark' : 'light';
125
- var isMobile = window.matchMedia(MEDIA_QUERY.mobile).matches;
126
- var size = isMobile ? 'sm' : 'xs';
127
- return ButtonCloseX(size, theme, CLASS_NAMES.TOOLTIP_CLOSE_BUTTON, '툴팁 닫기');
128
- };
129
- /** 전역 레이어에 패널 생성 */
130
- Tooltip.prototype.createLayerAndPanel = function () {
131
- var _a;
132
- // 기존 패널 제거
133
- if (this.panelId) {
134
- this.layerManager.removePanel(this.panelId);
135
- }
136
- // 새 패널 생성 (zIndex 전달)
137
- var zIndex = (_a = this.options.zIndex) !== null && _a !== void 0 ? _a : Z_INDEX.TOOLTIP_LAYER;
138
- var _b = this.layerManager.createPanel(zIndex),
139
- id = _b.id,
140
- panel = _b.panel;
141
- this.panelId = id;
142
- this.panel = panel;
143
- // 패널 설정
144
- this.panel.className = this.buildPanelClassName();
145
- // 패널 내용 구성
146
- var titleHTML = this.options.title ? HTML_TEMPLATES.TOOLTIP_TITLE(CLASS_NAMES.TOOLTIP_TITLE, this.options.title) : '';
147
- var contentHTML = this.renderContentHTML();
148
- var closeButtonHTML = this.renderCloseButtonHTML();
149
- this.panel.innerHTML = "".concat(titleHTML).concat(contentHTML).concat(closeButtonHTML);
150
- if (this.options.useShadowDOM && this.options.content) {
151
- this.setupShadowContent();
152
- }
153
- // 패널 클릭(닫기 버튼) 위임
154
- this.panel.addEventListener('click', this.boundPanelClick);
155
- };
156
- Tooltip.prototype.setupShadowContent = function () {
157
- if (!this.panel || !this.options.content) return;
158
- var container = this.panel.querySelector('[data-shadow-content]');
159
- if (!container) return;
160
- var shadowRoot = container.attachShadow({
161
- mode: 'open'
162
- });
163
- var style = document.createElement('style');
164
- style.textContent = CSS_TEMPLATES.SHADOW_DOM_HOST;
165
- shadowRoot.appendChild(style);
166
- var temp = document.createElement('div');
167
- temp.innerHTML = this.options.content;
168
- while (temp.firstChild) shadowRoot.appendChild(temp.firstChild);
169
- };
170
- /* ========== 이벤트 바인딩/해제 ========== */
171
- Tooltip.prototype.bindEvents = function () {
172
- this.enableMouseEvents();
173
- window.addEventListener('resize', this.boundResizeScroll, EVENT_OPTIONS.PASSIVE);
174
- window.addEventListener('scroll', this.boundResizeScroll, EVENT_OPTIONS.PASSIVE);
175
- };
176
- // tooltip icon위에 마우스 올리면 툴팁 보이기
177
- Tooltip.prototype.enableMouseEvents = function () {
178
- var _a, _b;
179
- (_a = this.iconElement) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseenter', this.boundMouseEnter);
180
- (_b = this.iconElement) === null || _b === void 0 ? void 0 : _b.addEventListener('mouseleave', this.boundMouseLeave);
181
- };
182
- Tooltip.prototype.disableMouseEvents = function () {
183
- var _a, _b;
184
- (_a = this.iconElement) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseenter', this.boundMouseEnter);
185
- (_b = this.iconElement) === null || _b === void 0 ? void 0 : _b.removeEventListener('mouseleave', this.boundMouseLeave);
186
- };
187
- /* ========== 표시/숨김/위치 ========== */
188
- Tooltip.prototype.showTooltip = function () {
189
- if (!this.panel) return;
190
- this.isVisible = true;
191
- this.isForceHidden = false; // 강제 숨김 상태 리셋
192
- this.updateTooltipPosition();
193
- // 보이기
194
- this.panel.style.opacity = OPACITY.VISIBLE;
195
- this.updatePanelClass();
196
- };
197
- Tooltip.prototype.hideTooltip = function () {
198
- if (!this.panel) return;
199
- this.isVisible = false;
200
- this.isForceHidden = false; // 강제 숨김 상태 리셋 (다시 표시 가능하도록)
201
- this.panel.style.opacity = OPACITY.HIDDEN;
202
- this.updatePanelClass();
203
- // long 타입에서 hideTooltip()을 호출한 경우 마우스 이벤트 다시 활성화
204
- if (this.options.type === 'long') {
205
- this.enableMouseEvents();
206
- }
207
- // 전환 종료 후 완전히 오프스크린 이동 → 히트 테스트 0
208
- var el = this.panel;
209
- var onEnd = function () {
210
- el.style.left = OFFSCREEN_POSITION;
211
- el.style.top = OFFSCREEN_POSITION;
212
- el.removeEventListener('transitionend', onEnd);
213
- };
214
- el.addEventListener('transitionend', onEnd, {
215
- once: true
216
- });
217
- };
218
- Tooltip.prototype.updateTooltipPosition = function () {
219
- var _a;
220
- if (!this.panel) return;
221
- this.isMeasuring = true;
222
- this.updatePanelClass();
223
- // 먼저 눈에 보이도록 화면 안쪽으로 잠깐 이동해 사이즈 측정
224
- // (opacity는 showTooltip에서만 1로)
225
- if (this.panel.style.left === OFFSCREEN_POSITION) {
226
- this.panel.style.left = POSITION.INITIAL;
227
- this.panel.style.top = POSITION.INITIAL;
228
- }
229
- var tipRect = this.panel.getBoundingClientRect();
230
- var anchor = (_a = this.iconElement) !== null && _a !== void 0 ? _a : this.element;
231
- var rect = anchor.getBoundingClientRect();
232
- var left = 0;
233
- var top = 0;
234
- var prefer = this.options.position;
235
- if (prefer === 'auto') {
236
- var enoughTop = rect.top - TOOLTIP_OFFSET - tipRect.height >= VIEWPORT_MARGIN;
237
- prefer = enoughTop ? 'top' : 'bottom';
238
- }
239
- if (prefer === 'bottom') {
240
- top = rect.bottom + TOOLTIP_OFFSET;
241
- left = rect.left + rect.width / 2 - tipRect.width / 2;
242
- this.calculatedPosition = 'bottom';
243
- } else if (prefer === 'top') {
244
- top = rect.top - tipRect.height - TOOLTIP_OFFSET;
245
- left = rect.left + rect.width / 2 - tipRect.width / 2;
246
- this.calculatedPosition = 'top';
247
- } else if (prefer === 'left') {
248
- top = rect.top + rect.height / 2 - tipRect.height / 2;
249
- left = rect.left - tipRect.width - TOOLTIP_OFFSET;
250
- this.calculatedPosition = 'left';
251
- } else if (prefer === 'right') {
252
- top = rect.top + rect.height / 2 - tipRect.height / 2;
253
- left = rect.right + TOOLTIP_OFFSET;
254
- this.calculatedPosition = 'right';
255
- } else {
256
- // fallback: top
257
- top = rect.top - tipRect.height - TOOLTIP_OFFSET;
258
- left = rect.left + rect.width / 2 - tipRect.width / 2;
259
- this.calculatedPosition = 'top';
260
- }
261
- // 화면 경계 보정
262
- left = Math.max(VIEWPORT_MARGIN, Math.min(left, window.innerWidth - tipRect.width - VIEWPORT_MARGIN));
263
- top = Math.max(VIEWPORT_MARGIN, Math.min(top, window.innerHeight - tipRect.height - VIEWPORT_MARGIN));
264
- this.panel.style.left = "".concat(Math.round(left), "px");
265
- this.panel.style.top = "".concat(Math.round(top), "px");
266
- this.isMeasuring = false;
267
- this.updatePanelClass();
268
- };
269
- Tooltip.prototype.updatePanelClass = function () {
270
- if (!this.panel) return;
271
- var newClassName = this.buildPanelClassName();
272
- if (this.panel.className !== newClassName) {
273
- this.panel.className = newClassName;
274
- }
275
- };
276
- /* ========== Public API ========== */
277
- Tooltip.prototype.getElement = function () {
278
- return this.element;
279
- };
280
- /* 기존 옵션 업데이트 ( i18n 적용, 속성 변경 등 옵션 변경 시 사용 ) */
281
- Tooltip.prototype.updateOptions = function (newOptions) {
282
- var _a;
283
- // 기존 리스너/DOM 정리
284
- this.disableMouseEvents();
285
- window.removeEventListener('resize', this.boundResizeScroll);
286
- window.removeEventListener('scroll', this.boundResizeScroll);
287
- (_a = this.panel) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', this.boundPanelClick);
288
- if (this.panelId) {
289
- this.layerManager.removePanel(this.panelId);
290
- }
291
- // 옵션 병합
292
- this.options = __assign(__assign({}, this.options), newOptions);
293
- // 앵커 재구성
294
- var parent = this.element.parentNode;
295
- var newEl = this.createElement();
296
- if (parent) parent.replaceChild(newEl, this.element);
297
- this.element = newEl;
298
- // 리스너 재바인딩
299
- this.bindEvents();
300
- };
301
- /* 정리 메서드 용도 */
302
- Tooltip.prototype.destroy = function () {
303
- var _a;
304
- this.disableMouseEvents();
305
- window.removeEventListener('resize', this.boundResizeScroll);
306
- window.removeEventListener('scroll', this.boundResizeScroll);
307
- (_a = this.panel) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', this.boundPanelClick);
308
- if (this.panelId) {
309
- this.layerManager.removePanel(this.panelId);
310
- }
311
- if (this.element.parentNode) this.element.parentNode.removeChild(this.element);
312
- };
313
- /* ========== 팩토리 메서드 ========== */
314
- Tooltip.create = function (options) {
315
- if (options === void 0) {
316
- options = {};
317
- }
318
- return new Tooltip(options);
319
- };
320
- Tooltip.createShort = function (title, content, options) {
321
- if (options === void 0) {
322
- options = {};
323
- }
324
- return new Tooltip(__assign({
325
- type: 'short',
326
- title: title,
327
- content: content
328
- }, options));
329
- };
330
- Tooltip.createLong = function (title, content, options) {
331
- if (options === void 0) {
332
- options = {};
333
- }
334
- return new Tooltip(__assign({
335
- type: 'long',
336
- title: title,
337
- content: content
338
- }, options));
339
- };
340
- Tooltip.createAuto = function (title, content, options) {
341
- if (options === void 0) {
342
- options = {};
343
- }
344
- return new Tooltip(__assign({
345
- position: 'auto',
346
- title: title,
347
- content: content
348
- }, options));
349
- };
350
- Tooltip.createAutoLong = function (title, content, options) {
351
- if (options === void 0) {
352
- options = {};
353
- }
354
- return new Tooltip(__assign({
355
- type: 'long',
356
- position: 'auto',
357
- title: title,
358
- content: content
359
- }, options));
360
- };
361
- Tooltip.createAutoLongWithShadowDOM = function (title, content, options) {
362
- if (options === void 0) {
363
- options = {};
364
- }
365
- return new Tooltip(__assign({
366
- type: 'long',
367
- position: 'auto',
368
- title: title,
369
- content: content,
370
- useShadowDOM: true
371
- }, options));
372
- };
373
- return Tooltip;
374
- }();
375
- export { Tooltip };