@designbasekorea/ui-wc 0.5.6 → 0.6.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 (193) hide show
  1. package/dist/chunks/lottie-35a9b0f5.js +1 -0
  2. package/dist/esm/components/animation-background/canvas-controller.js +1 -121
  3. package/dist/esm/components/animation-background/controls.js +1 -180
  4. package/dist/esm/components/animation-background/graphite-controller.js +1 -196
  5. package/dist/esm/components/animation-background/graphite-presets.js +1 -42
  6. package/dist/esm/components/animation-background/graphite-shader.js +1 -111
  7. package/dist/esm/components/animation-background/layers.js +1 -369
  8. package/dist/esm/components/animation-background/lumina-presets.js +1 -53
  9. package/dist/esm/components/animation-background/lumina-shaders.js +1 -181
  10. package/dist/esm/components/animation-background/lumina-utils.js +1 -60
  11. package/dist/esm/components/animation-background/particle-defaults.js +1 -36
  12. package/dist/esm/components/animation-background/renderers.js +1 -167
  13. package/dist/esm/components/animation-background/shader-controller.js +1 -154
  14. package/dist/esm/components/color-picker-utils.js +1 -134
  15. package/dist/esm/components/date-picker-utils.js +1 -140
  16. package/dist/esm/components/db-accordion.js +1 -304
  17. package/dist/esm/components/db-ad-banner.js +1 -455
  18. package/dist/esm/components/db-ai-chat-list.d.ts +43 -0
  19. package/dist/esm/components/db-ai-chat-list.js +1 -0
  20. package/dist/esm/components/db-ai-chat.d.ts +159 -0
  21. package/dist/esm/components/db-ai-chat.js +1 -0
  22. package/dist/esm/components/db-alert.js +1 -149
  23. package/dist/esm/components/db-animation-background.js +1 -486
  24. package/dist/esm/components/db-animation-text.js +1 -601
  25. package/dist/esm/components/db-app-badge.js +1 -88
  26. package/dist/esm/components/db-audio-player.js +1 -752
  27. package/dist/esm/components/db-avatar.js +1 -188
  28. package/dist/esm/components/db-backdrop.js +1 -139
  29. package/dist/esm/components/db-badge.js +1 -91
  30. package/dist/esm/components/db-banner.js +1 -188
  31. package/dist/esm/components/db-bottom-navigation.js +1 -146
  32. package/dist/esm/components/db-bottom-sheet.js +1 -481
  33. package/dist/esm/components/db-breadcrumbs.js +1 -329
  34. package/dist/esm/components/db-button.js +1 -316
  35. package/dist/esm/components/db-calendar.js +1 -675
  36. package/dist/esm/components/db-card.js +1 -265
  37. package/dist/esm/components/db-carousel.js +1 -264
  38. package/dist/esm/components/db-chat-composer.d.ts +134 -0
  39. package/dist/esm/components/db-chat-composer.js +1 -0
  40. package/dist/esm/components/db-chat-list.d.ts +47 -0
  41. package/dist/esm/components/db-chat-list.js +1 -0
  42. package/dist/esm/components/db-chat-message.d.ts +39 -0
  43. package/dist/esm/components/db-chat-message.js +1 -0
  44. package/dist/esm/components/db-chat-orb.d.ts +99 -0
  45. package/dist/esm/components/db-chat-orb.js +1 -0
  46. package/dist/esm/components/db-chat-room.d.ts +71 -0
  47. package/dist/esm/components/db-chat-room.js +1 -0
  48. package/dist/esm/components/db-chat-suggestions.d.ts +44 -0
  49. package/dist/esm/components/db-chat-suggestions.js +1 -0
  50. package/dist/esm/components/db-chat-typing.d.ts +22 -0
  51. package/dist/esm/components/db-chat-typing.js +1 -0
  52. package/dist/esm/components/db-chat-welcome.d.ts +32 -0
  53. package/dist/esm/components/db-chat-welcome.js +1 -0
  54. package/dist/esm/components/db-chat-widget.d.ts +146 -0
  55. package/dist/esm/components/db-chat-widget.js +1 -0
  56. package/dist/esm/components/db-checkbox.js +1 -202
  57. package/dist/esm/components/db-chip.js +1 -104
  58. package/dist/esm/components/db-code-block.js +1 -304
  59. package/dist/esm/components/db-color-picker.js +1 -746
  60. package/dist/esm/components/db-confirm.js +1 -191
  61. package/dist/esm/components/db-container.js +1 -39
  62. package/dist/esm/components/db-context-menu.js +1 -265
  63. package/dist/esm/components/db-countdown.js +1 -146
  64. package/dist/esm/components/db-cursor-follower.js +1 -173
  65. package/dist/esm/components/db-date-picker.js +1 -837
  66. package/dist/esm/components/db-divider.js +1 -66
  67. package/dist/esm/components/db-download-progress.d.ts +89 -0
  68. package/dist/esm/components/db-download-progress.js +1 -0
  69. package/dist/esm/components/db-drawer.js +1 -245
  70. package/dist/esm/components/db-dropdown.js +1 -493
  71. package/dist/esm/components/db-dropzone.js +1 -266
  72. package/dist/esm/components/db-email-verify.d.ts +64 -0
  73. package/dist/esm/components/db-email-verify.js +1 -0
  74. package/dist/esm/components/db-empty-state.js +1 -97
  75. package/dist/esm/components/db-file-uploader.js +1 -256
  76. package/dist/esm/components/db-floating-action-button.js +1 -139
  77. package/dist/esm/components/db-footer.js +1 -385
  78. package/dist/esm/components/db-form.js +1 -566
  79. package/dist/esm/components/db-gantt.js +1 -882
  80. package/dist/esm/components/db-gradient.js +1 -133
  81. package/dist/esm/components/db-grid-background.js +1 -909
  82. package/dist/esm/components/db-grid.js +1 -73
  83. package/dist/esm/components/db-icons.d.ts +3 -0
  84. package/dist/esm/components/db-icons.js +1 -82
  85. package/dist/esm/components/db-image-list.js +1 -214
  86. package/dist/esm/components/db-image-placeholder.js +1 -96
  87. package/dist/esm/components/db-image.js +1 -289
  88. package/dist/esm/components/db-indicator.js +1 -517
  89. package/dist/esm/components/db-input.js +1 -420
  90. package/dist/esm/components/db-kanban.js +1 -538
  91. package/dist/esm/components/db-label.js +1 -66
  92. package/dist/esm/components/db-lightbox.js +1 -372
  93. package/dist/esm/components/db-list.js +1 -340
  94. package/dist/esm/components/db-logo-svg.js +1 -72
  95. package/dist/esm/components/db-logo.js +1 -106
  96. package/dist/esm/components/db-lottie.js +1 -109
  97. package/dist/esm/components/db-markdown-editor.js +1 -458
  98. package/dist/esm/components/db-marquee.js +1 -402
  99. package/dist/esm/components/db-masonry.js +1 -94
  100. package/dist/esm/components/db-menu-item.js +1 -211
  101. package/dist/esm/components/db-modal.js +1 -522
  102. package/dist/esm/components/db-navbar.js +1 -680
  103. package/dist/esm/components/db-onboarding-modal.js +1 -322
  104. package/dist/esm/components/db-otp-input.d.ts +53 -0
  105. package/dist/esm/components/db-otp-input.js +1 -0
  106. package/dist/esm/components/db-page-header.js +1 -312
  107. package/dist/esm/components/db-pagination.js +1 -271
  108. package/dist/esm/components/db-phone-verify.d.ts +63 -0
  109. package/dist/esm/components/db-phone-verify.js +1 -0
  110. package/dist/esm/components/db-popover.js +1 -580
  111. package/dist/esm/components/db-progress-step.js +1 -166
  112. package/dist/esm/components/db-progress.js +1 -171
  113. package/dist/esm/components/db-progressbar.js +1 -72
  114. package/dist/esm/components/db-radio.js +1 -172
  115. package/dist/esm/components/db-random-gradient.js +1 -121
  116. package/dist/esm/components/db-range-slider.js +1 -811
  117. package/dist/esm/components/db-rating.js +1 -325
  118. package/dist/esm/components/db-reorder.js +1 -286
  119. package/dist/esm/components/db-resizable-panels.js +1 -282
  120. package/dist/esm/components/db-scroll-area.js +1 -126
  121. package/dist/esm/components/db-search-bar.js +1 -668
  122. package/dist/esm/components/db-section-app-download.js +1 -101
  123. package/dist/esm/components/db-section-contact.js +1 -102
  124. package/dist/esm/components/db-section-cta.js +1 -150
  125. package/dist/esm/components/db-section-faq.js +1 -120
  126. package/dist/esm/components/db-section-feature-grid.js +1 -137
  127. package/dist/esm/components/db-section-feature.js +1 -179
  128. package/dist/esm/components/db-section-hero.js +1 -243
  129. package/dist/esm/components/db-section-logo-cloud.js +1 -138
  130. package/dist/esm/components/db-section-pricing.js +1 -166
  131. package/dist/esm/components/db-section-stats.js +1 -129
  132. package/dist/esm/components/db-section-testimonials.js +1 -252
  133. package/dist/esm/components/db-section.js +1 -385
  134. package/dist/esm/components/db-segment-control.js +1 -231
  135. package/dist/esm/components/db-select.js +1 -571
  136. package/dist/esm/components/db-share-icons.js +1 -40
  137. package/dist/esm/components/db-share.js +1 -489
  138. package/dist/esm/components/db-sidebar.d.ts +20 -0
  139. package/dist/esm/components/db-sidebar.js +1 -1068
  140. package/dist/esm/components/db-skeleton.js +1 -94
  141. package/dist/esm/components/db-spinner.js +1 -102
  142. package/dist/esm/components/db-split-view.js +1 -297
  143. package/dist/esm/components/db-stack.js +1 -46
  144. package/dist/esm/components/db-stat.js +1 -218
  145. package/dist/esm/components/db-stepper.js +1 -398
  146. package/dist/esm/components/db-table.js +1 -412
  147. package/dist/esm/components/db-tabs.js +1 -335
  148. package/dist/esm/components/db-testimonial.d.ts +2 -0
  149. package/dist/esm/components/db-testimonial.js +1 -162
  150. package/dist/esm/components/db-textarea.js +1 -233
  151. package/dist/esm/components/db-time-picker.js +1 -523
  152. package/dist/esm/components/db-timeline.js +1 -174
  153. package/dist/esm/components/db-toast.js +1 -158
  154. package/dist/esm/components/db-toggle.js +1 -162
  155. package/dist/esm/components/db-toolbar.js +1 -94
  156. package/dist/esm/components/db-tooltip.js +1 -440
  157. package/dist/esm/components/db-top-banner.js +1 -121
  158. package/dist/esm/components/db-tutorial.js +1 -324
  159. package/dist/esm/components/db-two-factor.d.ts +71 -0
  160. package/dist/esm/components/db-two-factor.js +1 -0
  161. package/dist/esm/components/db-video-player.js +1 -503
  162. package/dist/esm/components/db-youtube-player.js +1 -194
  163. package/dist/esm/components/highlight-code.js +1 -65
  164. package/dist/esm/components/input-validation.js +1 -50
  165. package/dist/esm/components/marketing-block-host-utils.js +1 -9
  166. package/dist/esm/components/number-scrub.js +1 -117
  167. package/dist/esm/components/random-gradient-palettes.js +1 -67
  168. package/dist/esm/components/section-block-header-utils.js +1 -48
  169. package/dist/esm/helpers/confirm.js +1 -52
  170. package/dist/esm/helpers/toast.js +1 -73
  171. package/dist/esm/index.d.ts +16 -0
  172. package/dist/esm/index.js +1 -111
  173. package/dist/esm/node_modules/prismjs/components/prism-bash.js +1 -235
  174. package/dist/esm/node_modules/prismjs/components/prism-clike.js +1 -31
  175. package/dist/esm/node_modules/prismjs/components/prism-css.js +1 -64
  176. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +1 -172
  177. package/dist/esm/node_modules/prismjs/components/prism-json.js +1 -27
  178. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +1 -143
  179. package/dist/esm/node_modules/prismjs/components/prism-markup.js +1 -186
  180. package/dist/esm/node_modules/prismjs/components/prism-scss.js +1 -81
  181. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +1 -15
  182. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +1 -60
  183. package/dist/index.cjs +1 -55414
  184. package/dist/index.css +1 -1
  185. package/dist/index.d.ts +1125 -2
  186. package/dist/index.esm.js +1 -38284
  187. package/dist/react/chunks/lottie-14e7addb.js +1 -0
  188. package/dist/react/index.cjs +1 -56503
  189. package/dist/react/index.d.ts +1637 -21
  190. package/dist/react/index.esm.js +1 -39373
  191. package/package.json +2 -2
  192. package/dist/chunks/lottie-e273b936.js +0 -17032
  193. package/dist/react/chunks/lottie-72a4c6d4.js +0 -17032
@@ -1,440 +1 @@
1
- const POSITIONS = [
2
- 'top',
3
- 'bottom',
4
- 'left',
5
- 'right',
6
- 'top-start',
7
- 'top-end',
8
- 'bottom-start',
9
- 'bottom-end',
10
- 'left-start',
11
- 'left-end',
12
- 'right-start',
13
- 'right-end',
14
- ];
15
- const SIZES = ['s', 'm', 'l'];
16
- const VARIANTS = ['default', 'primary', 'success', 'warning', 'danger', 'info'];
17
- const GAP = 8;
18
- const ARW = 6;
19
- const PAD = 8;
20
- const OUT = -10;
21
- const INSET = 2;
22
- class DbTooltip extends HTMLElement {
23
- constructor() {
24
- super(...arguments);
25
- this.tooltipId = `db-tooltip-${Math.random().toString(36).slice(2, 9)}`;
26
- this.visible = false;
27
- this.handleShow = () => {
28
- if (this.disabled || this.alwaysShow)
29
- return;
30
- this.clearTimers();
31
- this.showTimer = setTimeout(() => this.setVisible(true), Math.max(0, this.delay));
32
- };
33
- this.handleHide = () => {
34
- if (this.alwaysShow)
35
- return;
36
- this.clearTimers();
37
- this.hideTimer = setTimeout(() => this.setVisible(false), Math.max(0, this.hideDelay));
38
- };
39
- this.handleKeyDown = (event) => {
40
- if (event.key === 'Escape') {
41
- this.clearTimers();
42
- this.setVisible(false);
43
- }
44
- };
45
- this.handleReposition = () => {
46
- if (!this.visible && !this.alwaysShow)
47
- return;
48
- if (this.repositionRaf)
49
- cancelAnimationFrame(this.repositionRaf);
50
- this.repositionRaf = requestAnimationFrame(() => this.calculatePosition());
51
- };
52
- }
53
- static get observedAttributes() {
54
- return [
55
- 'content',
56
- 'position',
57
- 'size',
58
- 'variant',
59
- 'disabled',
60
- 'always-show',
61
- 'delay',
62
- 'hide-delay',
63
- 'max-width',
64
- 'show-arrow',
65
- ];
66
- }
67
- get content() {
68
- return this.getAttribute('content') || '';
69
- }
70
- set content(value) {
71
- this.setAttribute('content', value);
72
- }
73
- get position() {
74
- return this.getAttribute('position') || 'top';
75
- }
76
- set position(value) {
77
- this.setAttribute('position', value);
78
- }
79
- get size() {
80
- return this.getAttribute('size') || 'm';
81
- }
82
- set size(value) {
83
- this.setAttribute('size', value);
84
- }
85
- get variant() {
86
- return this.getAttribute('variant') || 'default';
87
- }
88
- set variant(value) {
89
- this.setAttribute('variant', value);
90
- }
91
- get disabled() {
92
- return this.hasAttribute('disabled');
93
- }
94
- set disabled(value) {
95
- this.toggleAttribute('disabled', value);
96
- }
97
- get alwaysShow() {
98
- return this.hasAttribute('always-show');
99
- }
100
- set alwaysShow(value) {
101
- this.toggleAttribute('always-show', value);
102
- }
103
- get delay() {
104
- return Number(this.getAttribute('delay') ?? '200');
105
- }
106
- get hideDelay() {
107
- return Number(this.getAttribute('hide-delay') ?? '80');
108
- }
109
- get maxWidth() {
110
- return Number(this.getAttribute('max-width') ?? '240');
111
- }
112
- get showArrow() {
113
- return this.getAttribute('show-arrow') !== 'false';
114
- }
115
- connectedCallback() {
116
- this.render();
117
- this.childObserver = new MutationObserver(() => this.render());
118
- this.childObserver.observe(this, { childList: true });
119
- window.addEventListener('scroll', this.handleReposition, true);
120
- window.addEventListener('resize', this.handleReposition);
121
- }
122
- disconnectedCallback() {
123
- this.childObserver?.disconnect();
124
- this.clearTimers();
125
- if (this.repositionRaf)
126
- cancelAnimationFrame(this.repositionRaf);
127
- if (this.enterRaf)
128
- cancelAnimationFrame(this.enterRaf);
129
- if (this.removalTimer)
130
- clearTimeout(this.removalTimer);
131
- window.removeEventListener('scroll', this.handleReposition, true);
132
- window.removeEventListener('resize', this.handleReposition);
133
- this.tooltip?.remove();
134
- this.tooltip = undefined;
135
- }
136
- attributeChangedCallback() {
137
- if (!this.isConnected)
138
- return;
139
- this.render();
140
- if (this.alwaysShow) {
141
- this.setVisible(true);
142
- }
143
- else if (!this.visible) {
144
- this.removeTooltip();
145
- }
146
- }
147
- clearTimers() {
148
- if (this.showTimer)
149
- clearTimeout(this.showTimer);
150
- if (this.hideTimer)
151
- clearTimeout(this.hideTimer);
152
- this.showTimer = undefined;
153
- this.hideTimer = undefined;
154
- }
155
- groupOf(position) {
156
- if (position.startsWith('top'))
157
- return 'top';
158
- if (position.startsWith('bottom'))
159
- return 'bottom';
160
- if (position.startsWith('left'))
161
- return 'left';
162
- return 'right';
163
- }
164
- resolvedPosition() {
165
- return POSITIONS.includes(this.position) ? this.position : 'top';
166
- }
167
- collectTriggerChildren() {
168
- const isInternalNode = (child) => child.hasAttribute('data-wc-internal') || child === this.trigger;
169
- const fromHost = Array.from(this.children).filter((child) => !isInternalNode(child));
170
- if (fromHost.length > 0)
171
- return fromHost;
172
- return Array.from(this.trigger?.children || []);
173
- }
174
- ensureTrigger() {
175
- if (!this.trigger) {
176
- this.trigger = document.createElement('span');
177
- this.trigger.className = 'designbase-wc-tooltip__trigger';
178
- this.trigger.setAttribute('data-wc-internal', '');
179
- this.trigger.tabIndex = 0;
180
- this.trigger.addEventListener('mouseenter', this.handleShow);
181
- this.trigger.addEventListener('mouseleave', this.handleHide);
182
- this.trigger.addEventListener('focus', this.handleShow);
183
- this.trigger.addEventListener('blur', this.handleHide);
184
- this.trigger.addEventListener('keydown', this.handleKeyDown);
185
- }
186
- if (this.trigger.parentElement !== this) {
187
- this.append(this.trigger);
188
- }
189
- }
190
- mountTriggerChildren(children) {
191
- if (!this.trigger)
192
- return;
193
- children.forEach((child) => {
194
- if (child.parentElement !== this.trigger) {
195
- this.trigger.append(child);
196
- }
197
- });
198
- }
199
- render() {
200
- this.ensureTrigger();
201
- this.mountTriggerChildren(this.collectTriggerChildren());
202
- if (this.alwaysShow) {
203
- this.setVisible(true);
204
- }
205
- }
206
- ensureTooltip() {
207
- if (this.tooltip)
208
- return;
209
- this.tooltip = document.createElement('div');
210
- this.tooltip.className = 'designbase-wc-tooltip';
211
- this.tooltip.setAttribute('data-wc-internal', '');
212
- this.tooltip.setAttribute('role', 'tooltip');
213
- this.tooltip.id = this.tooltipId;
214
- this.contentEl = document.createElement('div');
215
- this.contentEl.className = 'designbase-wc-tooltip__content';
216
- this.arrow = document.createElement('div');
217
- this.arrow.className = 'designbase-wc-tooltip__arrow';
218
- this.tooltip.append(this.contentEl, this.arrow);
219
- document.body.append(this.tooltip);
220
- }
221
- syncTooltipClasses(showVisible = this.visible || this.alwaysShow) {
222
- if (!this.tooltip || !this.arrow)
223
- return;
224
- const position = this.resolvedPosition();
225
- const size = SIZES.includes(this.size) ? this.size : 'm';
226
- const variant = VARIANTS.includes(this.variant) ? this.variant : 'default';
227
- this.tooltip.className = [
228
- 'designbase-wc-tooltip',
229
- `designbase-wc-tooltip--${size}`,
230
- `designbase-wc-tooltip--${variant}`,
231
- `designbase-wc-tooltip--${position}`,
232
- showVisible && 'designbase-wc-tooltip--visible',
233
- this.disabled && 'designbase-wc-tooltip--disabled',
234
- ]
235
- .filter(Boolean)
236
- .join(' ');
237
- this.arrow.className = `designbase-wc-tooltip__arrow designbase-wc-tooltip__arrow--${position}`;
238
- this.arrow.hidden = !this.showArrow;
239
- this.tooltip.setAttribute('data-placement-group', this.groupOf(position));
240
- this.tooltip.setAttribute('aria-hidden', String(!showVisible));
241
- this.tooltip.style.maxWidth = `${this.maxWidth}px`;
242
- this.tooltip.style.zIndex = '9999';
243
- this.tooltip.style.pointerEvents = 'none';
244
- if (this.contentEl) {
245
- this.contentEl.textContent = this.content;
246
- }
247
- }
248
- calculatePosition() {
249
- if (!this.trigger || !this.tooltip || !this.arrow)
250
- return;
251
- const position = this.resolvedPosition();
252
- const tRect = this.trigger.getBoundingClientRect();
253
- // offsetWidth/Height 는 transform(스케일/이동) 영향을 받지 않으므로
254
- // 등장 트랜지션 중에도 정확한 크기로 위치를 계산할 수 있다.
255
- const pRect = { width: this.tooltip.offsetWidth, height: this.tooltip.offsetHeight };
256
- let top = 0;
257
- let left = 0;
258
- let aTop = 0;
259
- let aLeft = 0;
260
- switch (position) {
261
- case 'top':
262
- top = tRect.top - pRect.height - GAP;
263
- left = tRect.left + tRect.width / 2 - pRect.width / 2;
264
- aTop = pRect.height - INSET;
265
- aLeft = pRect.width / 2 - ARW;
266
- break;
267
- case 'top-start':
268
- top = tRect.top - pRect.height - GAP;
269
- left = tRect.left;
270
- aTop = pRect.height - INSET;
271
- aLeft = PAD;
272
- break;
273
- case 'top-end':
274
- top = tRect.top - pRect.height - GAP;
275
- left = tRect.right - pRect.width;
276
- aTop = pRect.height - INSET;
277
- aLeft = pRect.width - PAD - ARW;
278
- break;
279
- case 'bottom':
280
- top = tRect.bottom + GAP;
281
- left = tRect.left + tRect.width / 2 - pRect.width / 2;
282
- aTop = OUT;
283
- aLeft = pRect.width / 2 - ARW;
284
- break;
285
- case 'bottom-start':
286
- top = tRect.bottom + GAP;
287
- left = tRect.left;
288
- aTop = OUT;
289
- aLeft = PAD;
290
- break;
291
- case 'bottom-end':
292
- top = tRect.bottom + GAP;
293
- left = tRect.right - pRect.width;
294
- aTop = OUT;
295
- aLeft = pRect.width - PAD - ARW;
296
- break;
297
- case 'left':
298
- top = tRect.top + tRect.height / 2 - pRect.height / 2;
299
- left = tRect.left - pRect.width - GAP;
300
- aTop = pRect.height / 2 - ARW;
301
- aLeft = pRect.width - INSET;
302
- break;
303
- case 'left-start':
304
- top = tRect.top;
305
- left = tRect.left - pRect.width - GAP;
306
- aTop = PAD;
307
- aLeft = pRect.width - INSET;
308
- break;
309
- case 'left-end':
310
- top = tRect.bottom - pRect.height;
311
- left = tRect.left - pRect.width - GAP;
312
- aTop = pRect.height - PAD - ARW;
313
- aLeft = pRect.width - INSET;
314
- break;
315
- case 'right':
316
- top = tRect.top + tRect.height / 2 - pRect.height / 2;
317
- left = tRect.right + GAP;
318
- aTop = pRect.height / 2 - ARW;
319
- aLeft = OUT;
320
- break;
321
- case 'right-start':
322
- top = tRect.top;
323
- left = tRect.right + GAP;
324
- aTop = PAD;
325
- aLeft = OUT;
326
- break;
327
- case 'right-end':
328
- top = tRect.bottom - pRect.height;
329
- left = tRect.right + GAP;
330
- aTop = pRect.height - PAD - ARW;
331
- aLeft = OUT;
332
- break;
333
- }
334
- const EDGE = 8;
335
- const vw = window.innerWidth;
336
- const vh = window.innerHeight;
337
- if (left < EDGE)
338
- left = EDGE;
339
- if (left + pRect.width > vw - EDGE)
340
- left = vw - pRect.width - EDGE;
341
- if (top < EDGE)
342
- top = EDGE;
343
- if (top + pRect.height > vh - EDGE)
344
- top = vh - pRect.height - EDGE;
345
- const group = this.groupOf(position);
346
- if (group === 'top' || group === 'bottom') {
347
- const triggerCenterX = tRect.left + tRect.width / 2;
348
- const localX = triggerCenterX - left - ARW;
349
- aLeft = Math.min(pRect.width - PAD - ARW, Math.max(PAD, localX));
350
- }
351
- else {
352
- const triggerCenterY = tRect.top + tRect.height / 2;
353
- const localY = triggerCenterY - top - ARW;
354
- aTop = Math.min(pRect.height - PAD - ARW, Math.max(PAD, localY));
355
- }
356
- this.tooltip.style.position = 'fixed';
357
- this.tooltip.style.top = `${top}px`;
358
- this.tooltip.style.left = `${left}px`;
359
- this.arrow.style.position = 'absolute';
360
- this.arrow.style.top = `${aTop}px`;
361
- this.arrow.style.left = `${aLeft}px`;
362
- }
363
- setVisible(next) {
364
- if (this.disabled && next)
365
- return;
366
- this.visible = next;
367
- if (!next && !this.alwaysShow) {
368
- this.hideTooltip();
369
- this.trigger?.removeAttribute('aria-describedby');
370
- return;
371
- }
372
- // 퇴장 애니메이션 중 다시 나타나는 경우 예약된 제거를 취소
373
- if (this.removalTimer) {
374
- clearTimeout(this.removalTimer);
375
- this.removalTimer = undefined;
376
- }
377
- if (this.enterRaf) {
378
- cancelAnimationFrame(this.enterRaf);
379
- this.enterRaf = undefined;
380
- }
381
- this.ensureTooltip();
382
- // 1) 먼저 "숨김" 상태로 마운트하고 위치를 잡는다.
383
- this.syncTooltipClasses(false);
384
- this.calculatePosition();
385
- this.trigger?.setAttribute('aria-describedby', this.tooltipId);
386
- // 2) 다음 프레임에 visible 로 전환해야 등장 트랜지션이 실제로 재생된다.
387
- this.enterRaf = requestAnimationFrame(() => {
388
- this.enterRaf = requestAnimationFrame(() => {
389
- this.enterRaf = undefined;
390
- this.syncTooltipClasses(true);
391
- this.calculatePosition();
392
- });
393
- });
394
- }
395
- hideTooltip() {
396
- if (this.enterRaf) {
397
- cancelAnimationFrame(this.enterRaf);
398
- this.enterRaf = undefined;
399
- }
400
- if (!this.tooltip)
401
- return;
402
- const el = this.tooltip;
403
- el.classList.remove('designbase-wc-tooltip--visible');
404
- el.setAttribute('aria-hidden', 'true');
405
- const finish = () => {
406
- el.removeEventListener('transitionend', onEnd);
407
- if (this.removalTimer) {
408
- clearTimeout(this.removalTimer);
409
- this.removalTimer = undefined;
410
- }
411
- // 퇴장이 끝나기 전에 다시 보이게 되었다면 제거하지 않는다.
412
- if (!this.visible && this.tooltip === el) {
413
- this.removeTooltip();
414
- }
415
- };
416
- const onEnd = (event) => {
417
- if (event.target !== el || event.propertyName !== 'opacity')
418
- return;
419
- finish();
420
- };
421
- el.addEventListener('transitionend', onEnd);
422
- // transitionend 가 발생하지 않는 경우를 대비한 안전장치
423
- this.removalTimer = setTimeout(finish, 400);
424
- }
425
- removeTooltip() {
426
- if (this.removalTimer) {
427
- clearTimeout(this.removalTimer);
428
- this.removalTimer = undefined;
429
- }
430
- this.tooltip?.remove();
431
- this.tooltip = undefined;
432
- this.contentEl = undefined;
433
- this.arrow = undefined;
434
- }
435
- }
436
- if (!customElements.get('db-tooltip')) {
437
- customElements.define('db-tooltip', DbTooltip);
438
- }
439
-
440
- export { DbTooltip };
1
+ const t=["top","bottom","left","right","top-start","top-end","bottom-start","bottom-end","left-start","left-end","right-start","right-end"],e=["s","m","l"],i=["default","primary","success","warning","danger","info"],s=-10;class DbTooltip extends HTMLElement{constructor(){super(...arguments),this.tooltipId=`db-tooltip-${Math.random().toString(36).slice(2,9)}`,this.visible=!1,this.handleShow=()=>{this.disabled||this.alwaysShow||(this.clearTimers(),this.showTimer=setTimeout(()=>this.setVisible(!0),Math.max(0,this.delay)))},this.handleHide=()=>{this.alwaysShow||(this.clearTimers(),this.hideTimer=setTimeout(()=>this.setVisible(!1),Math.max(0,this.hideDelay)))},this.handleKeyDown=t=>{"Escape"===t.key&&(this.clearTimers(),this.setVisible(!1))},this.handleReposition=()=>{(this.visible||this.alwaysShow)&&(this.repositionRaf&&cancelAnimationFrame(this.repositionRaf),this.repositionRaf=requestAnimationFrame(()=>this.calculatePosition()))}}static get observedAttributes(){return["content","position","size","variant","disabled","always-show","delay","hide-delay","max-width","show-arrow"]}get content(){return this.getAttribute("content")||""}set content(t){this.setAttribute("content",t)}get position(){return this.getAttribute("position")||"top"}set position(t){this.setAttribute("position",t)}get size(){return this.getAttribute("size")||"m"}set size(t){this.setAttribute("size",t)}get variant(){return this.getAttribute("variant")||"default"}set variant(t){this.setAttribute("variant",t)}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t)}get alwaysShow(){return this.hasAttribute("always-show")}set alwaysShow(t){this.toggleAttribute("always-show",t)}get delay(){return Number(this.getAttribute("delay")??"200")}get hideDelay(){return Number(this.getAttribute("hide-delay")??"80")}get maxWidth(){return Number(this.getAttribute("max-width")??"240")}get showArrow(){return"false"!==this.getAttribute("show-arrow")}connectedCallback(){this.render(),this.childObserver=new MutationObserver(()=>this.render()),this.childObserver.observe(this,{childList:!0}),window.addEventListener("scroll",this.handleReposition,!0),window.addEventListener("resize",this.handleReposition)}disconnectedCallback(){this.childObserver?.disconnect(),this.clearTimers(),this.repositionRaf&&cancelAnimationFrame(this.repositionRaf),this.enterRaf&&cancelAnimationFrame(this.enterRaf),this.removalTimer&&clearTimeout(this.removalTimer),window.removeEventListener("scroll",this.handleReposition,!0),window.removeEventListener("resize",this.handleReposition),this.tooltip?.remove(),this.tooltip=void 0}attributeChangedCallback(){this.isConnected&&(this.render(),this.alwaysShow?this.setVisible(!0):this.visible||this.removeTooltip())}clearTimers(){this.showTimer&&clearTimeout(this.showTimer),this.hideTimer&&clearTimeout(this.hideTimer),this.showTimer=void 0,this.hideTimer=void 0}groupOf(t){return t.startsWith("top")?"top":t.startsWith("bottom")?"bottom":t.startsWith("left")?"left":"right"}resolvedPosition(){return t.includes(this.position)?this.position:"top"}collectTriggerChildren(){const isInternalNode=t=>t.hasAttribute("data-wc-internal")||t===this.trigger,t=Array.from(this.children).filter(t=>!isInternalNode(t));return t.length>0?t:Array.from(this.trigger?.children||[])}ensureTrigger(){this.trigger||(this.trigger=document.createElement("span"),this.trigger.className="designbase-wc-tooltip__trigger",this.trigger.setAttribute("data-wc-internal",""),this.trigger.tabIndex=0,this.trigger.addEventListener("mouseenter",this.handleShow),this.trigger.addEventListener("mouseleave",this.handleHide),this.trigger.addEventListener("focus",this.handleShow),this.trigger.addEventListener("blur",this.handleHide),this.trigger.addEventListener("keydown",this.handleKeyDown)),this.trigger.parentElement!==this&&this.append(this.trigger)}mountTriggerChildren(t){this.trigger&&t.forEach(t=>{t.parentElement!==this.trigger&&this.trigger.append(t)})}render(){this.ensureTrigger(),this.mountTriggerChildren(this.collectTriggerChildren()),this.alwaysShow&&this.setVisible(!0)}ensureTooltip(){this.tooltip||(this.tooltip=document.createElement("div"),this.tooltip.className="designbase-wc-tooltip",this.tooltip.setAttribute("data-wc-internal",""),this.tooltip.setAttribute("role","tooltip"),this.tooltip.id=this.tooltipId,this.contentEl=document.createElement("div"),this.contentEl.className="designbase-wc-tooltip__content",this.arrow=document.createElement("div"),this.arrow.className="designbase-wc-tooltip__arrow",this.tooltip.append(this.contentEl,this.arrow),document.body.append(this.tooltip))}syncTooltipClasses(t=this.visible||this.alwaysShow){if(!this.tooltip||!this.arrow)return;const s=this.resolvedPosition(),o=e.includes(this.size)?this.size:"m",r=i.includes(this.variant)?this.variant:"default";this.tooltip.className=["designbase-wc-tooltip",`designbase-wc-tooltip--${o}`,`designbase-wc-tooltip--${r}`,`designbase-wc-tooltip--${s}`,t&&"designbase-wc-tooltip--visible",this.disabled&&"designbase-wc-tooltip--disabled"].filter(Boolean).join(" "),this.arrow.className=`designbase-wc-tooltip__arrow designbase-wc-tooltip__arrow--${s}`,this.arrow.hidden=!this.showArrow,this.tooltip.setAttribute("data-placement-group",this.groupOf(s)),this.tooltip.setAttribute("aria-hidden",String(!t)),this.tooltip.style.maxWidth=`${this.maxWidth}px`,this.tooltip.style.zIndex="9999",this.tooltip.style.pointerEvents="none",this.contentEl&&(this.contentEl.textContent=this.content)}calculatePosition(){if(!this.trigger||!this.tooltip||!this.arrow)return;const t=this.resolvedPosition(),e=this.trigger.getBoundingClientRect(),i=this.tooltip.offsetWidth,o=this.tooltip.offsetHeight;let r=0,a=0,h=0,n=0;switch(t){case"top":r=e.top-o-8,a=e.left+e.width/2-i/2,h=o-2,n=i/2-6;break;case"top-start":r=e.top-o-8,a=e.left,h=o-2,n=8;break;case"top-end":r=e.top-o-8,a=e.right-i,h=o-2,n=i-8-6;break;case"bottom":r=e.bottom+8,a=e.left+e.width/2-i/2,h=s,n=i/2-6;break;case"bottom-start":r=e.bottom+8,a=e.left,h=s,n=8;break;case"bottom-end":r=e.bottom+8,a=e.right-i,h=s,n=i-8-6;break;case"left":r=e.top+e.height/2-o/2,a=e.left-i-8,h=o/2-6,n=i-2;break;case"left-start":r=e.top,a=e.left-i-8,h=8,n=i-2;break;case"left-end":r=e.bottom-o,a=e.left-i-8,h=o-8-6,n=i-2;break;case"right":r=e.top+e.height/2-o/2,a=e.right+8,h=o/2-6,n=s;break;case"right-start":r=e.top,a=e.right+8,h=8,n=s;break;case"right-end":r=e.bottom-o,a=e.right+8,h=o-8-6,n=s}const l=window.innerWidth,d=window.innerHeight;a<8&&(a=8),a+i>l-8&&(a=l-i-8),r<8&&(r=8),r+o>d-8&&(r=d-o-8);const c=this.groupOf(t);if("top"===c||"bottom"===c){const t=e.left+e.width/2-a-6;n=Math.min(i-8-6,Math.max(8,t))}else{const t=e.top+e.height/2-r-6;h=Math.min(o-8-6,Math.max(8,t))}this.tooltip.style.position="fixed",this.tooltip.style.top=`${r}px`,this.tooltip.style.left=`${a}px`,this.arrow.style.position="absolute",this.arrow.style.top=`${h}px`,this.arrow.style.left=`${n}px`}setVisible(t){if(!this.disabled||!t){if(this.visible=t,!t&&!this.alwaysShow)return this.hideTooltip(),void this.trigger?.removeAttribute("aria-describedby");this.removalTimer&&(clearTimeout(this.removalTimer),this.removalTimer=void 0),this.enterRaf&&(cancelAnimationFrame(this.enterRaf),this.enterRaf=void 0),this.ensureTooltip(),this.syncTooltipClasses(!1),this.calculatePosition(),this.trigger?.setAttribute("aria-describedby",this.tooltipId),this.enterRaf=requestAnimationFrame(()=>{this.enterRaf=requestAnimationFrame(()=>{this.enterRaf=void 0,this.syncTooltipClasses(!0),this.calculatePosition()})})}}hideTooltip(){if(this.enterRaf&&(cancelAnimationFrame(this.enterRaf),this.enterRaf=void 0),!this.tooltip)return;const t=this.tooltip;t.classList.remove("designbase-wc-tooltip--visible"),t.setAttribute("aria-hidden","true");const finish=()=>{t.removeEventListener("transitionend",onEnd),this.removalTimer&&(clearTimeout(this.removalTimer),this.removalTimer=void 0),this.visible||this.tooltip!==t||this.removeTooltip()},onEnd=e=>{e.target===t&&"opacity"===e.propertyName&&finish()};t.addEventListener("transitionend",onEnd),this.removalTimer=setTimeout(finish,400)}removeTooltip(){this.removalTimer&&(clearTimeout(this.removalTimer),this.removalTimer=void 0),this.tooltip?.remove(),this.tooltip=void 0,this.contentEl=void 0,this.arrow=void 0}}customElements.get("db-tooltip")||customElements.define("db-tooltip",DbTooltip);export{DbTooltip};
@@ -1,121 +1 @@
1
- import { createDbIcon } from './db-icons.js';
2
-
3
- const VARIANTS = ['primary', 'white', 'dark'];
4
- class DbTopBanner extends HTMLElement {
5
- static get observedAttributes() {
6
- return ['badge-text', 'content', 'image', 'link-text', 'variant', 'fixed', 'dismissed'];
7
- }
8
- connectedCallback() {
9
- this.render();
10
- }
11
- attributeChangedCallback() {
12
- this.render();
13
- }
14
- isDarkBg(variant) {
15
- return variant === 'primary' || variant === 'dark';
16
- }
17
- createLinkButton(variant, linkText) {
18
- const isDarkBg = this.isDarkBg(variant);
19
- const button = document.createElement('db-button');
20
- button.setAttribute('variant', isDarkBg ? 'secondary' : 'ghost');
21
- button.setAttribute('size', 's');
22
- button.classList.add('designbase-wc-top-banner__link');
23
- const label = document.createElement('span');
24
- label.textContent = linkText;
25
- const endIcon = document.createElement('span');
26
- endIcon.className = 'designbase-wc-button__end-icon';
27
- endIcon.append(createDbIcon('chevron-right', 16));
28
- button.append(label, endIcon);
29
- button.addEventListener('db-click', () => {
30
- this.dispatchEvent(new CustomEvent('db-link', { bubbles: true, composed: true }));
31
- });
32
- return button;
33
- }
34
- createCloseButton() {
35
- const button = document.createElement('db-button');
36
- button.setAttribute('variant', 'ghost');
37
- button.setAttribute('size', 'm');
38
- button.setAttribute('icon-only', '');
39
- button.setAttribute('aria-label', '닫기');
40
- button.classList.add('designbase-wc-top-banner__close');
41
- button.append(createDbIcon('close', 20));
42
- button.addEventListener('db-click', () => {
43
- this.setAttribute('dismissed', '');
44
- this.dispatchEvent(new CustomEvent('db-close', { bubbles: true, composed: true }));
45
- this.render();
46
- });
47
- return button;
48
- }
49
- createBadge(badgeText, isDarkBg) {
50
- const badge = document.createElement('db-badge');
51
- badge.setAttribute('size', 's');
52
- badge.setAttribute('variant', isDarkBg ? 'secondary' : 'primary');
53
- badge.setAttribute('badge-style', 'text');
54
- badge.textContent = badgeText;
55
- badge.classList.add('designbase-wc-top-banner__badge');
56
- return badge;
57
- }
58
- render() {
59
- if (this.hasAttribute('dismissed')) {
60
- this.replaceChildren();
61
- this.className = 'designbase-wc-top-banner designbase-wc-top-banner--dismissed';
62
- this.style.display = 'none';
63
- return;
64
- }
65
- this.style.display = '';
66
- const badgeText = this.getAttribute('badge-text') || '';
67
- const content = this.getAttribute('content') || '';
68
- const image = this.getAttribute('image') || '';
69
- const linkText = this.getAttribute('link-text') || '';
70
- const rawVariant = this.getAttribute('variant') || 'primary';
71
- const variant = VARIANTS.includes(rawVariant) ? rawVariant : 'primary';
72
- const fixed = this.hasAttribute('fixed');
73
- const isDarkBg = this.isDarkBg(variant);
74
- this.className = [
75
- 'designbase-wc-top-banner',
76
- `designbase-wc-top-banner--${variant}`,
77
- fixed && 'designbase-wc-top-banner--fixed',
78
- image && 'designbase-wc-top-banner--has-image',
79
- ]
80
- .filter(Boolean)
81
- .join(' ');
82
- this.setAttribute('role', 'alert');
83
- if (image) {
84
- this.style.setProperty('--db-top-banner-bg-image', `url("${image}")`);
85
- }
86
- else {
87
- this.style.removeProperty('--db-top-banner-bg-image');
88
- }
89
- this.replaceChildren();
90
- if (image) {
91
- const background = document.createElement('div');
92
- background.className = 'designbase-wc-top-banner__background';
93
- background.setAttribute('aria-hidden', 'true');
94
- const overlay = document.createElement('div');
95
- overlay.className = 'designbase-wc-top-banner__overlay';
96
- overlay.setAttribute('aria-hidden', 'true');
97
- this.append(background, overlay);
98
- }
99
- const container = document.createElement('div');
100
- container.className = 'designbase-wc-top-banner__container';
101
- const contentWrap = document.createElement('div');
102
- contentWrap.className = 'designbase-wc-top-banner__content';
103
- if (badgeText) {
104
- contentWrap.append(this.createBadge(badgeText, isDarkBg));
105
- }
106
- const text = document.createElement('span');
107
- text.className = 'designbase-wc-top-banner__text';
108
- text.textContent = content;
109
- contentWrap.append(text);
110
- if (linkText) {
111
- contentWrap.append(this.createLinkButton(variant, linkText));
112
- }
113
- container.append(contentWrap);
114
- container.append(this.createCloseButton());
115
- this.append(container);
116
- }
117
- }
118
- if (!customElements.get('db-top-banner'))
119
- customElements.define('db-top-banner', DbTopBanner);
120
-
121
- export { DbTopBanner };
1
+ import{createDbIcon as e}from"./db-icons.js";const t=["primary","white","dark"];class DbTopBanner extends HTMLElement{static get observedAttributes(){return["badge-text","content","image","link-text","variant","fixed","dismissed"]}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}isDarkBg(e){return"primary"===e||"dark"===e}createLinkButton(t,n){const s=this.isDarkBg(t),a=document.createElement("db-button");a.setAttribute("variant",s?"secondary":"ghost"),a.setAttribute("size","s"),a.classList.add("designbase-wc-top-banner__link");const i=document.createElement("span");i.textContent=n;const r=document.createElement("span");return r.className="designbase-wc-button__end-icon",r.append(e("chevron-right",16)),a.append(i,r),a.addEventListener("db-click",()=>{this.dispatchEvent(new CustomEvent("db-link",{bubbles:!0,composed:!0}))}),a}createCloseButton(){const t=document.createElement("db-button");return t.setAttribute("variant","ghost"),t.setAttribute("size","m"),t.setAttribute("icon-only",""),t.setAttribute("aria-label","닫기"),t.classList.add("designbase-wc-top-banner__close"),t.append(e("close",20)),t.addEventListener("db-click",()=>{this.setAttribute("dismissed",""),this.dispatchEvent(new CustomEvent("db-close",{bubbles:!0,composed:!0})),this.render()}),t}createBadge(e,t){const n=document.createElement("db-badge");return n.setAttribute("size","s"),n.setAttribute("variant",t?"secondary":"primary"),n.setAttribute("badge-style","text"),n.textContent=e,n.classList.add("designbase-wc-top-banner__badge"),n}render(){if(this.hasAttribute("dismissed"))return this.replaceChildren(),this.className="designbase-wc-top-banner designbase-wc-top-banner--dismissed",void(this.style.display="none");this.style.display="";const e=this.getAttribute("badge-text")||"",n=this.getAttribute("content")||"",s=this.getAttribute("image")||"",a=this.getAttribute("link-text")||"",i=this.getAttribute("variant")||"primary",r=t.includes(i)?i:"primary",d=this.hasAttribute("fixed"),c=this.isDarkBg(r);if(this.className=["designbase-wc-top-banner",`designbase-wc-top-banner--${r}`,d&&"designbase-wc-top-banner--fixed",s&&"designbase-wc-top-banner--has-image"].filter(Boolean).join(" "),this.setAttribute("role","alert"),s?this.style.setProperty("--db-top-banner-bg-image",`url("${s}")`):this.style.removeProperty("--db-top-banner-bg-image"),this.replaceChildren(),s){const e=document.createElement("div");e.className="designbase-wc-top-banner__background",e.setAttribute("aria-hidden","true");const t=document.createElement("div");t.className="designbase-wc-top-banner__overlay",t.setAttribute("aria-hidden","true"),this.append(e,t)}const o=document.createElement("div");o.className="designbase-wc-top-banner__container";const b=document.createElement("div");b.className="designbase-wc-top-banner__content",e&&b.append(this.createBadge(e,c));const l=document.createElement("span");l.className="designbase-wc-top-banner__text",l.textContent=n,b.append(l),a&&b.append(this.createLinkButton(r,a)),o.append(b),o.append(this.createCloseButton()),this.append(o)}}customElements.get("db-top-banner")||customElements.define("db-top-banner",DbTopBanner);export{DbTopBanner};