@designbasekorea/ui-wc 0.5.3 → 0.5.6

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 (156) hide show
  1. package/dist/chunks/lottie-e273b936.js +17032 -0
  2. package/dist/esm/components/animation-background/canvas-controller.js +121 -1
  3. package/dist/esm/components/animation-background/controls.js +180 -1
  4. package/dist/esm/components/animation-background/graphite-controller.js +196 -1
  5. package/dist/esm/components/animation-background/graphite-presets.js +42 -1
  6. package/dist/esm/components/animation-background/graphite-shader.js +111 -1
  7. package/dist/esm/components/animation-background/layers.js +369 -1
  8. package/dist/esm/components/animation-background/lumina-presets.js +53 -1
  9. package/dist/esm/components/animation-background/lumina-shaders.js +181 -1
  10. package/dist/esm/components/animation-background/lumina-utils.js +60 -1
  11. package/dist/esm/components/animation-background/particle-defaults.js +36 -1
  12. package/dist/esm/components/animation-background/renderers.js +167 -1
  13. package/dist/esm/components/animation-background/shader-controller.js +154 -1
  14. package/dist/esm/components/color-picker-utils.js +134 -1
  15. package/dist/esm/components/date-picker-utils.js +140 -1
  16. package/dist/esm/components/db-accordion.js +304 -1
  17. package/dist/esm/components/db-ad-banner.js +455 -1
  18. package/dist/esm/components/db-alert.js +149 -1
  19. package/dist/esm/components/db-animation-background.js +486 -1
  20. package/dist/esm/components/db-animation-text.js +601 -1
  21. package/dist/esm/components/db-app-badge.js +88 -1
  22. package/dist/esm/components/db-audio-player.js +752 -1
  23. package/dist/esm/components/db-avatar.js +188 -1
  24. package/dist/esm/components/db-backdrop.js +139 -1
  25. package/dist/esm/components/db-badge.js +91 -1
  26. package/dist/esm/components/db-banner.js +188 -1
  27. package/dist/esm/components/db-bottom-navigation.js +146 -1
  28. package/dist/esm/components/db-bottom-sheet.js +481 -1
  29. package/dist/esm/components/db-breadcrumbs.js +329 -1
  30. package/dist/esm/components/db-button.js +316 -1
  31. package/dist/esm/components/db-calendar.js +675 -1
  32. package/dist/esm/components/db-card.js +265 -1
  33. package/dist/esm/components/db-carousel.js +264 -1
  34. package/dist/esm/components/db-checkbox.js +202 -1
  35. package/dist/esm/components/db-chip.js +104 -1
  36. package/dist/esm/components/db-code-block.js +304 -1
  37. package/dist/esm/components/db-color-picker.js +746 -1
  38. package/dist/esm/components/db-confirm.js +191 -1
  39. package/dist/esm/components/db-container.js +39 -1
  40. package/dist/esm/components/db-context-menu.js +265 -1
  41. package/dist/esm/components/db-countdown.js +146 -1
  42. package/dist/esm/components/db-cursor-follower.js +173 -1
  43. package/dist/esm/components/db-date-picker.js +837 -1
  44. package/dist/esm/components/db-divider.js +66 -1
  45. package/dist/esm/components/db-drawer.js +245 -1
  46. package/dist/esm/components/db-dropdown.js +493 -1
  47. package/dist/esm/components/db-dropzone.js +266 -1
  48. package/dist/esm/components/db-empty-state.js +97 -1
  49. package/dist/esm/components/db-file-uploader.js +256 -1
  50. package/dist/esm/components/db-floating-action-button.js +139 -1
  51. package/dist/esm/components/db-footer.js +385 -1
  52. package/dist/esm/components/db-form.js +566 -1
  53. package/dist/esm/components/db-gantt.js +882 -1
  54. package/dist/esm/components/db-gradient.js +133 -1
  55. package/dist/esm/components/db-grid-background.js +909 -1
  56. package/dist/esm/components/db-grid.js +73 -1
  57. package/dist/esm/components/db-icons.js +82 -1
  58. package/dist/esm/components/db-image-list.js +214 -1
  59. package/dist/esm/components/db-image-placeholder.js +96 -1
  60. package/dist/esm/components/db-image.js +289 -1
  61. package/dist/esm/components/db-indicator.js +517 -1
  62. package/dist/esm/components/db-input.js +420 -1
  63. package/dist/esm/components/db-kanban.js +538 -1
  64. package/dist/esm/components/db-label.js +66 -1
  65. package/dist/esm/components/db-lightbox.js +372 -1
  66. package/dist/esm/components/db-list.js +340 -1
  67. package/dist/esm/components/db-logo-svg.js +72 -1
  68. package/dist/esm/components/db-logo.js +106 -1
  69. package/dist/esm/components/db-lottie.js +109 -1
  70. package/dist/esm/components/db-markdown-editor.js +458 -1
  71. package/dist/esm/components/db-marquee.js +402 -1
  72. package/dist/esm/components/db-masonry.js +94 -1
  73. package/dist/esm/components/db-menu-item.js +211 -1
  74. package/dist/esm/components/db-modal.js +522 -1
  75. package/dist/esm/components/db-navbar.js +680 -1
  76. package/dist/esm/components/db-onboarding-modal.js +322 -1
  77. package/dist/esm/components/db-page-header.js +312 -1
  78. package/dist/esm/components/db-pagination.js +271 -1
  79. package/dist/esm/components/db-popover.js +580 -1
  80. package/dist/esm/components/db-progress-step.js +166 -1
  81. package/dist/esm/components/db-progress.js +171 -1
  82. package/dist/esm/components/db-progressbar.js +72 -1
  83. package/dist/esm/components/db-radio.js +172 -1
  84. package/dist/esm/components/db-random-gradient.js +121 -1
  85. package/dist/esm/components/db-range-slider.js +811 -1
  86. package/dist/esm/components/db-rating.js +325 -1
  87. package/dist/esm/components/db-reorder.js +286 -1
  88. package/dist/esm/components/db-resizable-panels.js +282 -1
  89. package/dist/esm/components/db-scroll-area.js +126 -1
  90. package/dist/esm/components/db-search-bar.js +668 -1
  91. package/dist/esm/components/db-section-app-download.js +101 -1
  92. package/dist/esm/components/db-section-contact.js +102 -1
  93. package/dist/esm/components/db-section-cta.js +150 -1
  94. package/dist/esm/components/db-section-faq.js +120 -1
  95. package/dist/esm/components/db-section-feature-grid.js +137 -1
  96. package/dist/esm/components/db-section-feature.js +179 -1
  97. package/dist/esm/components/db-section-hero.js +243 -1
  98. package/dist/esm/components/db-section-logo-cloud.js +138 -1
  99. package/dist/esm/components/db-section-pricing.js +166 -1
  100. package/dist/esm/components/db-section-stats.js +129 -1
  101. package/dist/esm/components/db-section-testimonials.js +252 -1
  102. package/dist/esm/components/db-section.js +385 -1
  103. package/dist/esm/components/db-segment-control.js +231 -1
  104. package/dist/esm/components/db-select.js +571 -1
  105. package/dist/esm/components/db-share-icons.js +40 -1
  106. package/dist/esm/components/db-share.js +489 -1
  107. package/dist/esm/components/db-sidebar.js +1068 -1
  108. package/dist/esm/components/db-skeleton.js +94 -1
  109. package/dist/esm/components/db-spinner.js +102 -1
  110. package/dist/esm/components/db-split-view.js +297 -1
  111. package/dist/esm/components/db-stack.js +46 -1
  112. package/dist/esm/components/db-stat.js +218 -1
  113. package/dist/esm/components/db-stepper.js +398 -1
  114. package/dist/esm/components/db-table.js +412 -1
  115. package/dist/esm/components/db-tabs.js +335 -1
  116. package/dist/esm/components/db-testimonial.js +162 -1
  117. package/dist/esm/components/db-textarea.js +233 -1
  118. package/dist/esm/components/db-time-picker.js +523 -1
  119. package/dist/esm/components/db-timeline.js +174 -1
  120. package/dist/esm/components/db-toast.js +158 -1
  121. package/dist/esm/components/db-toggle.js +162 -1
  122. package/dist/esm/components/db-toolbar.js +94 -1
  123. package/dist/esm/components/db-tooltip.js +440 -1
  124. package/dist/esm/components/db-top-banner.js +121 -1
  125. package/dist/esm/components/db-tutorial.js +324 -1
  126. package/dist/esm/components/db-video-player.js +503 -1
  127. package/dist/esm/components/db-youtube-player.js +194 -1
  128. package/dist/esm/components/highlight-code.js +65 -1
  129. package/dist/esm/components/input-validation.js +50 -1
  130. package/dist/esm/components/marketing-block-host-utils.js +9 -1
  131. package/dist/esm/components/number-scrub.js +117 -1
  132. package/dist/esm/components/random-gradient-palettes.js +67 -1
  133. package/dist/esm/components/section-block-header-utils.js +48 -1
  134. package/dist/esm/helpers/confirm.js +52 -1
  135. package/dist/esm/helpers/toast.js +73 -1
  136. package/dist/esm/index.js +111 -1
  137. package/dist/esm/node_modules/prismjs/components/prism-bash.js +235 -1
  138. package/dist/esm/node_modules/prismjs/components/prism-clike.js +31 -1
  139. package/dist/esm/node_modules/prismjs/components/prism-css.js +64 -1
  140. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +172 -1
  141. package/dist/esm/node_modules/prismjs/components/prism-json.js +27 -1
  142. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +143 -1
  143. package/dist/esm/node_modules/prismjs/components/prism-markup.js +186 -1
  144. package/dist/esm/node_modules/prismjs/components/prism-scss.js +81 -1
  145. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +15 -1
  146. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +60 -1
  147. package/dist/index.cjs +55414 -1
  148. package/dist/index.css +1 -1
  149. package/dist/index.esm.js +38284 -1
  150. package/dist/react/chunks/lottie-72a4c6d4.js +17032 -0
  151. package/dist/react/index.cjs +56503 -1
  152. package/dist/react/index.d.ts +1 -1
  153. package/dist/react/index.esm.js +39373 -1
  154. package/package.json +1 -1
  155. package/dist/chunks/lottie-2d1f6278.js +0 -1
  156. package/dist/react/chunks/lottie-14e7addb.js +0 -1
@@ -1 +1,146 @@
1
- import{createDbIcon as t}from"./db-icons.js";const e=["s","m","l"],i=["default","glass","transparent"];class DbBottomNavigation extends HTMLElement{static get observedAttributes(){return["items","active-item-id","size","background-color","fixed"]}connectedCallback(){this.render()}attributeChangedCallback(){this.isConnected&&this.render()}get items(){return this.parseItems()}set items(t){this.setAttribute("items","string"==typeof t?t:JSON.stringify(t))}parseItems(){try{const t=JSON.parse(this.getAttribute("items")||"[]");return Array.isArray(t)?t:[]}catch{return[]}}iconSize(t){return"s"===t?20:"l"===t?28:24}syncHostClasses(){const t=this.getAttribute("size")||"m",a=e.includes(t)?t:"m",n=this.getAttribute("background-color")||"default",s=i.includes(n)?n:"default";this.className=["designbase-wc-bottom-navigation",`designbase-wc-bottom-navigation--${a}`,`designbase-wc-bottom-navigation--${s}`,"false"!==this.getAttribute("fixed")&&"designbase-wc-bottom-navigation--fixed"].filter(Boolean).join(" ")}render(){this.syncHostClasses(),this.setAttribute("role","navigation"),this.setAttribute("aria-label","하단 네비게이션");const e=this.parseItems(),i=this.getAttribute("active-item-id")||"",a=this.getAttribute("size")||"m",n=this.iconSize(a);let s=this.querySelector(".designbase-wc-bottom-navigation__container");s?s.replaceChildren():(s=document.createElement("div"),s.className="designbase-wc-bottom-navigation__container",this.replaceChildren(s)),e.forEach(e=>{const a=i===e.id||Boolean(e.isActive),o=function resolveIcon(t){if(t)return t}(a&&e.activeIcon?e.activeIcon:e.icon),r=document.createElement("button");r.type="button",r.className=["designbase-wc-bottom-navigation__item",a&&"designbase-wc-bottom-navigation__item--active",e.disabled&&"designbase-wc-bottom-navigation__item--disabled"].filter(Boolean).join(" "),r.disabled=Boolean(e.disabled),r.setAttribute("aria-label",e.label),a&&r.setAttribute("aria-current","page");const c=document.createElement("div");c.className="designbase-wc-bottom-navigation__item-content";const d=document.createElement("div");if(d.className="designbase-wc-bottom-navigation__icon-wrapper",o){const e=t(o,n);e.classList.add("designbase-wc-bottom-navigation__icon"),d.append(e)}if(void 0!==e.badge&&""!==e.badge){const t=document.createElement("db-badge");t.className="designbase-wc-bottom-navigation__badge",t.setAttribute("size","s"),t.setAttribute("variant",function mapBadgeVariant(t){return"error"===t?"danger":"warning"===t?"warning":"success"===t?"success":"info"===t?"info":"primary"===t?"primary":"secondary"}(e.badgeColor)),t.setAttribute("badge-style","number"),t.setAttribute("count",String(e.badge)),d.append(t)}const b=document.createElement("span");b.className="designbase-wc-bottom-navigation__label",b.textContent=e.label,c.append(d,b),r.append(c),r.addEventListener("click",()=>{e.disabled||this.dispatchEvent(new CustomEvent("db-item-click",{bubbles:!0,composed:!0,detail:{item:e}}))}),s.append(r)})}}customElements.get("db-bottom-navigation")||customElements.define("db-bottom-navigation",DbBottomNavigation);export{DbBottomNavigation};
1
+ import { createDbIcon } from './db-icons.js';
2
+
3
+ const SIZES = ['s', 'm', 'l'];
4
+ const BACKGROUNDS = ['default', 'glass', 'transparent'];
5
+ function resolveIcon(name) {
6
+ if (!name)
7
+ return undefined;
8
+ return name;
9
+ }
10
+ function mapBadgeVariant(color) {
11
+ if (color === 'error')
12
+ return 'danger';
13
+ if (color === 'warning')
14
+ return 'warning';
15
+ if (color === 'success')
16
+ return 'success';
17
+ if (color === 'info')
18
+ return 'info';
19
+ if (color === 'primary')
20
+ return 'primary';
21
+ return 'secondary';
22
+ }
23
+ class DbBottomNavigation extends HTMLElement {
24
+ static get observedAttributes() {
25
+ return ['items', 'active-item-id', 'size', 'background-color', 'fixed'];
26
+ }
27
+ connectedCallback() {
28
+ this.render();
29
+ }
30
+ attributeChangedCallback() {
31
+ if (!this.isConnected)
32
+ return;
33
+ this.render();
34
+ }
35
+ get items() {
36
+ return this.parseItems();
37
+ }
38
+ set items(value) {
39
+ this.setAttribute('items', typeof value === 'string' ? value : JSON.stringify(value));
40
+ }
41
+ parseItems() {
42
+ try {
43
+ const parsed = JSON.parse(this.getAttribute('items') || '[]');
44
+ return Array.isArray(parsed) ? parsed : [];
45
+ }
46
+ catch {
47
+ return [];
48
+ }
49
+ }
50
+ iconSize(size) {
51
+ if (size === 's')
52
+ return 20;
53
+ if (size === 'l')
54
+ return 28;
55
+ return 24;
56
+ }
57
+ syncHostClasses() {
58
+ const size = this.getAttribute('size') || 'm';
59
+ const safeSize = SIZES.includes(size) ? size : 'm';
60
+ const background = this.getAttribute('background-color') || 'default';
61
+ const safeBackground = BACKGROUNDS.includes(background)
62
+ ? background
63
+ : 'default';
64
+ this.className = [
65
+ 'designbase-wc-bottom-navigation',
66
+ `designbase-wc-bottom-navigation--${safeSize}`,
67
+ `designbase-wc-bottom-navigation--${safeBackground}`,
68
+ this.getAttribute('fixed') !== 'false' && 'designbase-wc-bottom-navigation--fixed',
69
+ ]
70
+ .filter(Boolean)
71
+ .join(' ');
72
+ }
73
+ render() {
74
+ this.syncHostClasses();
75
+ this.setAttribute('role', 'navigation');
76
+ this.setAttribute('aria-label', '하단 네비게이션');
77
+ const items = this.parseItems();
78
+ const activeItemId = this.getAttribute('active-item-id') || '';
79
+ const size = this.getAttribute('size') || 'm';
80
+ const iconPx = this.iconSize(size);
81
+ let container = this.querySelector('.designbase-wc-bottom-navigation__container');
82
+ if (!container) {
83
+ container = document.createElement('div');
84
+ container.className = 'designbase-wc-bottom-navigation__container';
85
+ this.replaceChildren(container);
86
+ }
87
+ else {
88
+ container.replaceChildren();
89
+ }
90
+ items.forEach((item) => {
91
+ const isActive = activeItemId === item.id || Boolean(item.isActive);
92
+ const iconName = resolveIcon(isActive && item.activeIcon ? item.activeIcon : item.icon);
93
+ const button = document.createElement('button');
94
+ button.type = 'button';
95
+ button.className = [
96
+ 'designbase-wc-bottom-navigation__item',
97
+ isActive && 'designbase-wc-bottom-navigation__item--active',
98
+ item.disabled && 'designbase-wc-bottom-navigation__item--disabled',
99
+ ]
100
+ .filter(Boolean)
101
+ .join(' ');
102
+ button.disabled = Boolean(item.disabled);
103
+ button.setAttribute('aria-label', item.label);
104
+ if (isActive)
105
+ button.setAttribute('aria-current', 'page');
106
+ const content = document.createElement('div');
107
+ content.className = 'designbase-wc-bottom-navigation__item-content';
108
+ const iconWrap = document.createElement('div');
109
+ iconWrap.className = 'designbase-wc-bottom-navigation__icon-wrapper';
110
+ if (iconName) {
111
+ const icon = createDbIcon(iconName, iconPx);
112
+ icon.classList.add('designbase-wc-bottom-navigation__icon');
113
+ iconWrap.append(icon);
114
+ }
115
+ if (item.badge !== undefined && item.badge !== '') {
116
+ const badge = document.createElement('db-badge');
117
+ badge.className = 'designbase-wc-bottom-navigation__badge';
118
+ badge.setAttribute('size', 's');
119
+ badge.setAttribute('variant', mapBadgeVariant(item.badgeColor));
120
+ badge.setAttribute('badge-style', 'number');
121
+ badge.setAttribute('count', String(item.badge));
122
+ iconWrap.append(badge);
123
+ }
124
+ const label = document.createElement('span');
125
+ label.className = 'designbase-wc-bottom-navigation__label';
126
+ label.textContent = item.label;
127
+ content.append(iconWrap, label);
128
+ button.append(content);
129
+ button.addEventListener('click', () => {
130
+ if (item.disabled)
131
+ return;
132
+ this.dispatchEvent(new CustomEvent('db-item-click', {
133
+ bubbles: true,
134
+ composed: true,
135
+ detail: { item },
136
+ }));
137
+ });
138
+ container.append(button);
139
+ });
140
+ }
141
+ }
142
+ if (!customElements.get('db-bottom-navigation')) {
143
+ customElements.define('db-bottom-navigation', DbBottomNavigation);
144
+ }
145
+
146
+ export { DbBottomNavigation };
@@ -1 +1,481 @@
1
- import{createDbIcon as t}from"./db-icons.js";const e={s:40,m:60,l:80,full:100},s=["default","persistent","temporary","fullscreen"],i=["slide","fade","scale","none"];function resolveHeightPercent(t){if(!t)return e.m;const s=e[t];if(s)return Math.min(100,Math.max(20,s));const i=Number(t);return Number.isFinite(i)?Math.min(100,Math.max(20,i)):e.m}class DbBottomSheet extends HTMLElement{constructor(){super(...arguments),this.sheetHeightPercent=e.m,this.isDragging=!1,this.isVisible=!1,this.isMounted=!1,this.keyHandler=null,this.dragState={active:!1,pointerId:-1,startY:0,startHeight:e.m,lastY:0,lastTime:0},this.handlePointerDown=t=>{"true"!==this.getAttribute("disable-drag")&&0===t.button&&(t.preventDefault(),t.currentTarget.setPointerCapture(t.pointerId),this.dragState={active:!0,pointerId:t.pointerId,startY:t.clientY,startHeight:this.sheetHeightPercent,lastY:t.clientY,lastTime:Date.now()},this.isDragging=!0,this.syncActiveClasses())},this.handlePointerMove=t=>{const e=this.dragState;if(!e.active||t.pointerId!==e.pointerId)return;t.preventDefault(),e.lastY=t.clientY,e.lastTime=Date.now();const s=window.innerHeight||1,i=(e.startY-t.clientY)/s*100,r=this.getMaxHeightLimit(resolveHeightPercent(this.getAttribute("height")));this.sheetHeightPercent=Math.min(r,Math.max(20,e.startHeight+i)),this.applySheetDimensions()},this.handlePointerUp=t=>{const e=this.dragState;if(!e.active||t.pointerId!==e.pointerId)return;const s=t.currentTarget;s.hasPointerCapture(t.pointerId)&&s.releasePointerCapture(t.pointerId),this.finishDrag()}}static get observedAttributes(){return["open","title","subtitle","height","max-height","variant","disable-backdrop-click","disable-escape-key-down","disable-drag","show-close-button","animation","animation-duration","z-index","show-backdrop","backdrop-blur","backdrop-opacity","sticky-header","sticky-footer"]}get open(){return this.hasAttribute("open")&&"false"!==this.getAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}shouldMountPortal(){return this.isOpenRequested()||this.isMounted}connectedCallback(){this.style.display="contents",this.childObserver=new MutationObserver(()=>{this.isOpenRequested()&&this.render()}),this.childObserver.observe(this,{childList:!0}),this.syncOpenState()}disconnectedCallback(){this.childObserver?.disconnect(),this.childObserver=void 0,this.clearTimers(),this.detachEscape(),this.root?.remove(),this.root=void 0,document.body.style.overflow=""}attributeChangedCallback(t){this.isConnected&&("open"!==t?("height"===t&&this.isOpenRequested()&&(this.sheetHeightPercent=resolveHeightPercent(this.getAttribute("height"))),this.shouldMountPortal()&&(this.render(),this.isMounted&&this.syncActiveClasses())):this.syncOpenState())}isOpenRequested(){return this.open}clearTimers(){this.enterFrame&&(cancelAnimationFrame(this.enterFrame),this.enterFrame=void 0),this.exitTimer&&(clearTimeout(this.exitTimer),this.exitTimer=void 0)}scheduleEnterAnimation(){this.enterFrame&&cancelAnimationFrame(this.enterFrame),this.enterFrame=requestAnimationFrame(()=>{this.enterFrame=requestAnimationFrame(()=>{this.enterFrame=void 0,this.isOpenRequested()&&this.sheet&&(this.sheet.offsetHeight,this.isVisible=!0,this.syncActiveClasses())})})}getMaxHeightLimit(t){const e=Number(this.getAttribute("max-height")||0),s=t>=100;return Math.min(100,Math.max(t,e||(s?100:90)))}close(){this.open=!1,this.dispatchEvent(new CustomEvent("db-close",{bubbles:!0,composed:!0}))}attachEscape(){this.keyHandler||(this.keyHandler=t=>{"Escape"===t.key&&"true"!==this.getAttribute("disable-escape-key-down")&&this.close()},document.addEventListener("keydown",this.keyHandler))}detachEscape(){this.keyHandler&&(document.removeEventListener("keydown",this.keyHandler),this.keyHandler=null)}collectSlotted(t){const e=Array.from(this.querySelectorAll(`:scope > [slot="${t}"]`));if(e.length)return e;if("header"===t){const t=this.sheet?.querySelector(".designbase-wc-bottom-sheet__header-main");return t?Array.from(t.children):[]}if("footer"===t){const t=this.sheet?.querySelector(".designbase-wc-bottom-sheet__footer");return t?Array.from(t.children):[]}return[]}collectContentNodes(){const t=Array.from(this.children).filter(t=>{const e=t.getAttribute("slot");return!e||"default"===e});return t.length?t:this.contentEl?Array.from(this.contentEl.children):[]}finishDrag(){const t=this.dragState;if(!t.active)return;t.active=!1,this.isDragging=!1;const e=t.lastY-t.startY,s=e/Math.max(1,Date.now()-t.lastTime),i=window.innerHeight||1,r=(t.startY-t.lastY)/i*100,n=this.getMaxHeightLimit(resolveHeightPercent(this.getAttribute("height"))),o=Math.min(n,Math.max(20,t.startHeight+r));o<=22||e>72||s>.6?this.close():(this.sheetHeightPercent=o,this.applySheetDimensions(),this.syncActiveClasses())}syncOpenState(){const t=this.isOpenRequested(),e=Number(this.getAttribute("animation-duration")||400);if(this.clearTimers(),t)return this.sheetHeightPercent=resolveHeightPercent(this.getAttribute("height")),this.render(),this.isMounted=!0,this.isVisible=!1,this.syncActiveClasses(),this.root&&!this.root.isConnected&&document.body.append(this.root),this.scheduleEnterAnimation(),document.body.style.overflow="hidden",void this.attachEscape();this.isVisible=!1,this.syncActiveClasses(),this.exitTimer=setTimeout(()=>{this.exitTimer=void 0,this.detachContentToHost(),this.isMounted=!1,this.syncActiveClasses(),this.root?.remove(),document.body.style.overflow="",this.detachEscape()},e),this.detachEscape()}syncActiveClasses(){if(!this.sheet)return;const t=resolveHeightPercent(this.getAttribute("height")),e=this.getAttribute("variant")||"default",r=this.getAttribute("animation")||"slide",n=s.includes(e)?e:"default",o=i.includes(r)?r:"slide",a="false"!==this.getAttribute("show-backdrop"),h=this.hasAttribute("sticky-header"),c=this.hasAttribute("sticky-footer");this.sheet.className=["designbase-wc-bottom-sheet",`designbase-wc-bottom-sheet--${n}`,`designbase-wc-bottom-sheet--${o}`,this.isMounted&&this.isVisible&&"designbase-wc-bottom-sheet--open",this.isDragging&&"designbase-wc-bottom-sheet--dragging",h&&"designbase-wc-bottom-sheet--sticky-header",c&&"designbase-wc-bottom-sheet--sticky-footer",!a&&"designbase-wc-bottom-sheet--no-backdrop",(t>=100||this.sheetHeightPercent>=100)&&"designbase-wc-bottom-sheet--full"].filter(Boolean).join(" "),this.backdrop?.classList.toggle("designbase-wc-backdrop--open",this.isMounted&&this.isVisible)}applySheetDimensions(){if(!this.sheet)return;const t=this.getMaxHeightLimit(resolveHeightPercent(this.getAttribute("height")));this.sheet.style.height=`${this.sheetHeightPercent}vh`,this.sheet.style.maxHeight=`${t}vh`}detachContentToHost(){this.contentEl&&Array.from(this.contentEl.children).forEach(t=>this.append(t));const t=this.sheet?.querySelector(".designbase-wc-bottom-sheet__header-main");t&&Array.from(t.children).forEach(t=>{"bottom-sheet-title"!==t.id&&"bottom-sheet-subtitle"!==t.id&&this.append(t)});const e=this.sheet?.querySelector(".designbase-wc-bottom-sheet__footer");e&&Array.from(e.children).forEach(t=>this.append(t))}render(){if(!this.shouldMountPortal())return;const e=this.getAttribute("title"),s=this.getAttribute("subtitle"),i="false"!==this.getAttribute("show-close-button"),r="false"!==this.getAttribute("show-backdrop"),n=this.hasAttribute("backdrop-blur"),o=this.getAttribute("backdrop-opacity")||"0.5",a=this.getAttribute("animation-duration")||"400",h=this.getAttribute("z-index")||"1000",c=this.hasAttribute("sticky-header"),d=this.hasAttribute("sticky-footer"),l=this.collectSlotted("header"),b=this.collectSlotted("footer"),m=this.collectContentNodes();if(this.root||(this.root=document.createElement("div"),this.root.setAttribute("data-wc-internal",""),this.backdrop=document.createElement("div"),this.backdrop.className="designbase-wc-backdrop designbase-wc-backdrop--bottom-sheet",this.backdrop.setAttribute("role","presentation"),this.backdrop.addEventListener("click",t=>{t.target===this.backdrop&&"true"!==this.getAttribute("disable-backdrop-click")&&this.close()}),this.sheet=document.createElement("div"),this.sheet.setAttribute("role","dialog"),this.sheet.setAttribute("aria-modal","true"),this.grabBar=document.createElement("div"),this.grabBar.className="designbase-wc-bottom-sheet__grab-bar",this.grabBar.addEventListener("pointerdown",this.handlePointerDown),this.grabBar.addEventListener("pointermove",this.handlePointerMove),this.grabBar.addEventListener("pointerup",this.handlePointerUp),this.grabBar.addEventListener("pointercancel",this.handlePointerUp),this.contentEl=document.createElement("div"),this.contentEl.className="designbase-wc-bottom-sheet__content"),this.root.replaceChildren(),r&&this.backdrop&&(this.backdrop.className=["designbase-wc-backdrop","designbase-wc-backdrop--bottom-sheet",n&&"designbase-wc-backdrop--blur"].filter(Boolean).join(" "),this.backdrop.style.setProperty("--backdrop-opacity",o),this.backdrop.style.setProperty("--bottom-sheet-animation-duration",`${a}ms`),this.backdrop.style.zIndex=h,this.backdrop.setAttribute("aria-hidden",String(!this.isOpenRequested())),this.root.append(this.backdrop)),!this.sheet||!this.grabBar||!this.contentEl)return;this.sheet.style.zIndex=String(Number(h)+1),this.sheet.style.setProperty("--bottom-sheet-animation-duration",`${a}ms`),this.applySheetDimensions(),e?this.sheet.setAttribute("aria-labelledby","bottom-sheet-title"):this.sheet.removeAttribute("aria-labelledby"),s?this.sheet.setAttribute("aria-describedby","bottom-sheet-subtitle"):this.sheet.removeAttribute("aria-describedby"),this.sheet.replaceChildren();const u="true"===this.getAttribute("disable-drag");if(this.grabBar.className=["designbase-wc-bottom-sheet__grab-bar",!u&&"designbase-wc-bottom-sheet__grab-bar--draggable"].filter(Boolean).join(" "),this.grabBar.replaceChildren(),!u){const t=document.createElement("div");t.className="designbase-wc-bottom-sheet__handle",t.setAttribute("aria-hidden","true"),this.grabBar.append(t)}this.sheet.append(this.grabBar);if(Boolean(e||s||l.length||i)){const r=document.createElement("div");r.className=["designbase-wc-bottom-sheet__header",c&&"designbase-wc-bottom-sheet__header--sticky"].filter(Boolean).join(" ");const n=document.createElement("div");if(n.className="designbase-wc-bottom-sheet__header-main",l.length)l.forEach(t=>n.append(t));else{if(e){const t=document.createElement("h2");t.id="bottom-sheet-title",t.className="designbase-wc-bottom-sheet__title",t.textContent=e,n.append(t)}if(s){const t=document.createElement("p");t.id="bottom-sheet-subtitle",t.className="designbase-wc-bottom-sheet__subtitle",t.textContent=s,n.append(t)}}if(r.append(n),i){const e=document.createElement("button");e.type="button",e.className="designbase-wc-bottom-sheet__close-button",e.setAttribute("aria-label","닫기"),e.append(t("close",20)),e.addEventListener("click",()=>this.close()),r.append(e)}this.sheet.append(r)}if(this.contentEl.replaceChildren(...m),this.sheet.append(this.contentEl),b.length){const t=document.createElement("div");t.className=["designbase-wc-bottom-sheet__footer",d&&"designbase-wc-bottom-sheet__footer--sticky"].filter(Boolean).join(" "),b.forEach(e=>t.append(e)),this.sheet.append(t)}this.root.append(this.sheet),this.isMounted&&!this.root.isConnected&&document.body.append(this.root),this.syncActiveClasses()}}customElements.get("db-bottom-sheet")||customElements.define("db-bottom-sheet",DbBottomSheet);export{DbBottomSheet};
1
+ import { createDbIcon } from './db-icons.js';
2
+
3
+ const HEIGHT_PRESETS = {
4
+ s: 40,
5
+ m: 60,
6
+ l: 80,
7
+ full: 100,
8
+ };
9
+ const VARIANTS = ['default', 'persistent', 'temporary', 'fullscreen'];
10
+ const ANIMATIONS = ['slide', 'fade', 'scale', 'none'];
11
+ const MIN_HEIGHT_PERCENT = 20;
12
+ const CLOSE_HEIGHT_PERCENT = 22;
13
+ const CLOSE_DRAG_PX = 72;
14
+ function resolveHeightPercent(height) {
15
+ if (!height)
16
+ return HEIGHT_PRESETS.m;
17
+ const preset = HEIGHT_PRESETS[height];
18
+ if (preset)
19
+ return Math.min(100, Math.max(MIN_HEIGHT_PERCENT, preset));
20
+ const numeric = Number(height);
21
+ if (Number.isFinite(numeric))
22
+ return Math.min(100, Math.max(MIN_HEIGHT_PERCENT, numeric));
23
+ return HEIGHT_PRESETS.m;
24
+ }
25
+ class DbBottomSheet extends HTMLElement {
26
+ constructor() {
27
+ super(...arguments);
28
+ this.sheetHeightPercent = HEIGHT_PRESETS.m;
29
+ this.isDragging = false;
30
+ this.isVisible = false;
31
+ this.isMounted = false;
32
+ this.keyHandler = null;
33
+ this.dragState = {
34
+ active: false,
35
+ pointerId: -1,
36
+ startY: 0,
37
+ startHeight: HEIGHT_PRESETS.m,
38
+ lastY: 0,
39
+ lastTime: 0,
40
+ };
41
+ this.handlePointerDown = (event) => {
42
+ if (this.getAttribute('disable-drag') === 'true' || event.button !== 0)
43
+ return;
44
+ event.preventDefault();
45
+ event.currentTarget.setPointerCapture(event.pointerId);
46
+ this.dragState = {
47
+ active: true,
48
+ pointerId: event.pointerId,
49
+ startY: event.clientY,
50
+ startHeight: this.sheetHeightPercent,
51
+ lastY: event.clientY,
52
+ lastTime: Date.now(),
53
+ };
54
+ this.isDragging = true;
55
+ this.syncActiveClasses();
56
+ };
57
+ this.handlePointerMove = (event) => {
58
+ const drag = this.dragState;
59
+ if (!drag.active || event.pointerId !== drag.pointerId)
60
+ return;
61
+ event.preventDefault();
62
+ drag.lastY = event.clientY;
63
+ drag.lastTime = Date.now();
64
+ const viewportHeight = window.innerHeight || 1;
65
+ const deltaPercent = ((drag.startY - event.clientY) / viewportHeight) * 100;
66
+ const maxHeightLimit = this.getMaxHeightLimit(resolveHeightPercent(this.getAttribute('height')));
67
+ this.sheetHeightPercent = Math.min(maxHeightLimit, Math.max(MIN_HEIGHT_PERCENT, drag.startHeight + deltaPercent));
68
+ this.applySheetDimensions();
69
+ };
70
+ this.handlePointerUp = (event) => {
71
+ const drag = this.dragState;
72
+ if (!drag.active || event.pointerId !== drag.pointerId)
73
+ return;
74
+ const target = event.currentTarget;
75
+ if (target.hasPointerCapture(event.pointerId)) {
76
+ target.releasePointerCapture(event.pointerId);
77
+ }
78
+ this.finishDrag();
79
+ };
80
+ }
81
+ static get observedAttributes() {
82
+ return [
83
+ 'open',
84
+ 'title',
85
+ 'subtitle',
86
+ 'height',
87
+ 'max-height',
88
+ 'variant',
89
+ 'disable-backdrop-click',
90
+ 'disable-escape-key-down',
91
+ 'disable-drag',
92
+ 'show-close-button',
93
+ 'animation',
94
+ 'animation-duration',
95
+ 'z-index',
96
+ 'show-backdrop',
97
+ 'backdrop-blur',
98
+ 'backdrop-opacity',
99
+ 'sticky-header',
100
+ 'sticky-footer',
101
+ ];
102
+ }
103
+ get open() {
104
+ return this.hasAttribute('open') && this.getAttribute('open') !== 'false';
105
+ }
106
+ set open(value) {
107
+ if (value)
108
+ this.setAttribute('open', '');
109
+ else
110
+ this.removeAttribute('open');
111
+ }
112
+ shouldMountPortal() {
113
+ return this.isOpenRequested() || this.isMounted;
114
+ }
115
+ connectedCallback() {
116
+ this.style.display = 'contents';
117
+ this.childObserver = new MutationObserver(() => {
118
+ if (this.isOpenRequested())
119
+ this.render();
120
+ });
121
+ this.childObserver.observe(this, { childList: true });
122
+ this.syncOpenState();
123
+ }
124
+ disconnectedCallback() {
125
+ this.childObserver?.disconnect();
126
+ this.childObserver = undefined;
127
+ this.clearTimers();
128
+ this.detachEscape();
129
+ this.root?.remove();
130
+ this.root = undefined;
131
+ document.body.style.overflow = '';
132
+ }
133
+ attributeChangedCallback(name) {
134
+ if (!this.isConnected)
135
+ return;
136
+ if (name === 'open') {
137
+ this.syncOpenState();
138
+ return;
139
+ }
140
+ if (name === 'height' && this.isOpenRequested()) {
141
+ this.sheetHeightPercent = resolveHeightPercent(this.getAttribute('height'));
142
+ }
143
+ if (!this.shouldMountPortal())
144
+ return;
145
+ this.render();
146
+ if (this.isMounted)
147
+ this.syncActiveClasses();
148
+ }
149
+ isOpenRequested() {
150
+ return this.open;
151
+ }
152
+ clearTimers() {
153
+ if (this.enterFrame) {
154
+ cancelAnimationFrame(this.enterFrame);
155
+ this.enterFrame = undefined;
156
+ }
157
+ if (this.exitTimer) {
158
+ clearTimeout(this.exitTimer);
159
+ this.exitTimer = undefined;
160
+ }
161
+ }
162
+ /** 닫힌 transform이 페인트된 뒤 --open을 붙여 슬라이드 업 전환이 보이게 함 */
163
+ scheduleEnterAnimation() {
164
+ if (this.enterFrame)
165
+ cancelAnimationFrame(this.enterFrame);
166
+ this.enterFrame = requestAnimationFrame(() => {
167
+ this.enterFrame = requestAnimationFrame(() => {
168
+ this.enterFrame = undefined;
169
+ if (!this.isOpenRequested() || !this.sheet)
170
+ return;
171
+ void this.sheet.offsetHeight;
172
+ this.isVisible = true;
173
+ this.syncActiveClasses();
174
+ });
175
+ });
176
+ }
177
+ getMaxHeightLimit(initialHeight) {
178
+ const maxHeightProp = Number(this.getAttribute('max-height') || 0);
179
+ const isFullHeight = initialHeight >= 100;
180
+ return Math.min(100, Math.max(initialHeight, maxHeightProp || (isFullHeight ? 100 : 90)));
181
+ }
182
+ close() {
183
+ this.open = false;
184
+ this.dispatchEvent(new CustomEvent('db-close', { bubbles: true, composed: true }));
185
+ }
186
+ attachEscape() {
187
+ if (this.keyHandler)
188
+ return;
189
+ this.keyHandler = (event) => {
190
+ if (event.key !== 'Escape')
191
+ return;
192
+ if (this.getAttribute('disable-escape-key-down') === 'true')
193
+ return;
194
+ this.close();
195
+ };
196
+ document.addEventListener('keydown', this.keyHandler);
197
+ }
198
+ detachEscape() {
199
+ if (!this.keyHandler)
200
+ return;
201
+ document.removeEventListener('keydown', this.keyHandler);
202
+ this.keyHandler = null;
203
+ }
204
+ collectSlotted(name) {
205
+ const direct = Array.from(this.querySelectorAll(`:scope > [slot="${name}"]`));
206
+ if (direct.length)
207
+ return direct;
208
+ if (name === 'header') {
209
+ const main = this.sheet?.querySelector('.designbase-wc-bottom-sheet__header-main');
210
+ return main ? Array.from(main.children) : [];
211
+ }
212
+ if (name === 'footer') {
213
+ const footer = this.sheet?.querySelector('.designbase-wc-bottom-sheet__footer');
214
+ return footer ? Array.from(footer.children) : [];
215
+ }
216
+ return [];
217
+ }
218
+ collectContentNodes() {
219
+ const direct = Array.from(this.children).filter((child) => {
220
+ const slot = child.getAttribute('slot');
221
+ return !slot || slot === 'default';
222
+ });
223
+ if (direct.length)
224
+ return direct;
225
+ return this.contentEl ? Array.from(this.contentEl.children) : [];
226
+ }
227
+ finishDrag() {
228
+ const drag = this.dragState;
229
+ if (!drag.active)
230
+ return;
231
+ drag.active = false;
232
+ this.isDragging = false;
233
+ const deltaY = drag.lastY - drag.startY;
234
+ const elapsed = Math.max(1, Date.now() - drag.lastTime);
235
+ const velocity = deltaY / elapsed;
236
+ const viewportHeight = window.innerHeight || 1;
237
+ const deltaPercent = ((drag.startY - drag.lastY) / viewportHeight) * 100;
238
+ const maxHeightLimit = this.getMaxHeightLimit(resolveHeightPercent(this.getAttribute('height')));
239
+ const finalHeight = Math.min(maxHeightLimit, Math.max(MIN_HEIGHT_PERCENT, drag.startHeight + deltaPercent));
240
+ if (finalHeight <= CLOSE_HEIGHT_PERCENT || deltaY > CLOSE_DRAG_PX || velocity > 0.6) {
241
+ this.close();
242
+ return;
243
+ }
244
+ this.sheetHeightPercent = finalHeight;
245
+ this.applySheetDimensions();
246
+ this.syncActiveClasses();
247
+ }
248
+ syncOpenState() {
249
+ const shouldOpen = this.isOpenRequested();
250
+ const duration = Number(this.getAttribute('animation-duration') || 400);
251
+ this.clearTimers();
252
+ if (shouldOpen) {
253
+ this.sheetHeightPercent = resolveHeightPercent(this.getAttribute('height'));
254
+ this.render();
255
+ this.isMounted = true;
256
+ this.isVisible = false;
257
+ this.syncActiveClasses();
258
+ if (this.root && !this.root.isConnected) {
259
+ document.body.append(this.root);
260
+ }
261
+ this.scheduleEnterAnimation();
262
+ document.body.style.overflow = 'hidden';
263
+ this.attachEscape();
264
+ return;
265
+ }
266
+ this.isVisible = false;
267
+ this.syncActiveClasses();
268
+ this.exitTimer = setTimeout(() => {
269
+ this.exitTimer = undefined;
270
+ this.detachContentToHost();
271
+ this.isMounted = false;
272
+ this.syncActiveClasses();
273
+ this.root?.remove();
274
+ document.body.style.overflow = '';
275
+ this.detachEscape();
276
+ }, duration);
277
+ this.detachEscape();
278
+ }
279
+ syncActiveClasses() {
280
+ if (!this.sheet)
281
+ return;
282
+ const initialHeight = resolveHeightPercent(this.getAttribute('height'));
283
+ const variant = this.getAttribute('variant') || 'default';
284
+ const animation = this.getAttribute('animation') || 'slide';
285
+ const safeVariant = VARIANTS.includes(variant) ? variant : 'default';
286
+ const safeAnimation = ANIMATIONS.includes(animation) ? animation : 'slide';
287
+ const showBackdrop = this.getAttribute('show-backdrop') !== 'false';
288
+ const stickyHeader = this.hasAttribute('sticky-header');
289
+ const stickyFooter = this.hasAttribute('sticky-footer');
290
+ this.sheet.className = [
291
+ 'designbase-wc-bottom-sheet',
292
+ `designbase-wc-bottom-sheet--${safeVariant}`,
293
+ `designbase-wc-bottom-sheet--${safeAnimation}`,
294
+ this.isMounted && this.isVisible && 'designbase-wc-bottom-sheet--open',
295
+ this.isDragging && 'designbase-wc-bottom-sheet--dragging',
296
+ stickyHeader && 'designbase-wc-bottom-sheet--sticky-header',
297
+ stickyFooter && 'designbase-wc-bottom-sheet--sticky-footer',
298
+ !showBackdrop && 'designbase-wc-bottom-sheet--no-backdrop',
299
+ (initialHeight >= 100 || this.sheetHeightPercent >= 100) && 'designbase-wc-bottom-sheet--full',
300
+ ]
301
+ .filter(Boolean)
302
+ .join(' ');
303
+ this.backdrop?.classList.toggle('designbase-wc-backdrop--open', this.isMounted && this.isVisible);
304
+ }
305
+ applySheetDimensions() {
306
+ if (!this.sheet)
307
+ return;
308
+ const maxHeightLimit = this.getMaxHeightLimit(resolveHeightPercent(this.getAttribute('height')));
309
+ this.sheet.style.height = `${this.sheetHeightPercent}vh`;
310
+ this.sheet.style.maxHeight = `${maxHeightLimit}vh`;
311
+ }
312
+ detachContentToHost() {
313
+ if (this.contentEl) {
314
+ Array.from(this.contentEl.children).forEach((child) => this.append(child));
315
+ }
316
+ const headerMain = this.sheet?.querySelector('.designbase-wc-bottom-sheet__header-main');
317
+ if (headerMain) {
318
+ Array.from(headerMain.children).forEach((child) => {
319
+ if (child.id !== 'bottom-sheet-title' && child.id !== 'bottom-sheet-subtitle') {
320
+ this.append(child);
321
+ }
322
+ });
323
+ }
324
+ const footer = this.sheet?.querySelector('.designbase-wc-bottom-sheet__footer');
325
+ if (footer) {
326
+ Array.from(footer.children).forEach((child) => this.append(child));
327
+ }
328
+ }
329
+ render() {
330
+ if (!this.shouldMountPortal()) {
331
+ return;
332
+ }
333
+ const title = this.getAttribute('title');
334
+ const subtitle = this.getAttribute('subtitle');
335
+ const showCloseButton = this.getAttribute('show-close-button') !== 'false';
336
+ const showBackdrop = this.getAttribute('show-backdrop') !== 'false';
337
+ const backdropBlur = this.hasAttribute('backdrop-blur');
338
+ const backdropOpacity = this.getAttribute('backdrop-opacity') || '0.5';
339
+ const animationDuration = this.getAttribute('animation-duration') || '400';
340
+ const zIndex = this.getAttribute('z-index') || '1000';
341
+ const stickyHeader = this.hasAttribute('sticky-header');
342
+ const stickyFooter = this.hasAttribute('sticky-footer');
343
+ const headerSlot = this.collectSlotted('header');
344
+ const footerSlot = this.collectSlotted('footer');
345
+ const contentNodes = this.collectContentNodes();
346
+ if (!this.root) {
347
+ this.root = document.createElement('div');
348
+ this.root.setAttribute('data-wc-internal', '');
349
+ this.backdrop = document.createElement('div');
350
+ this.backdrop.className = 'designbase-wc-backdrop designbase-wc-backdrop--bottom-sheet';
351
+ this.backdrop.setAttribute('role', 'presentation');
352
+ this.backdrop.addEventListener('click', (event) => {
353
+ if (event.target !== this.backdrop)
354
+ return;
355
+ if (this.getAttribute('disable-backdrop-click') === 'true')
356
+ return;
357
+ this.close();
358
+ });
359
+ this.sheet = document.createElement('div');
360
+ this.sheet.setAttribute('role', 'dialog');
361
+ this.sheet.setAttribute('aria-modal', 'true');
362
+ this.grabBar = document.createElement('div');
363
+ this.grabBar.className = 'designbase-wc-bottom-sheet__grab-bar';
364
+ this.grabBar.addEventListener('pointerdown', this.handlePointerDown);
365
+ this.grabBar.addEventListener('pointermove', this.handlePointerMove);
366
+ this.grabBar.addEventListener('pointerup', this.handlePointerUp);
367
+ this.grabBar.addEventListener('pointercancel', this.handlePointerUp);
368
+ this.contentEl = document.createElement('div');
369
+ this.contentEl.className = 'designbase-wc-bottom-sheet__content';
370
+ }
371
+ this.root.replaceChildren();
372
+ if (showBackdrop && this.backdrop) {
373
+ this.backdrop.className = [
374
+ 'designbase-wc-backdrop',
375
+ 'designbase-wc-backdrop--bottom-sheet',
376
+ backdropBlur && 'designbase-wc-backdrop--blur',
377
+ ]
378
+ .filter(Boolean)
379
+ .join(' ');
380
+ this.backdrop.style.setProperty('--backdrop-opacity', backdropOpacity);
381
+ this.backdrop.style.setProperty('--bottom-sheet-animation-duration', `${animationDuration}ms`);
382
+ this.backdrop.style.zIndex = zIndex;
383
+ this.backdrop.setAttribute('aria-hidden', String(!this.isOpenRequested()));
384
+ this.root.append(this.backdrop);
385
+ }
386
+ if (!this.sheet || !this.grabBar || !this.contentEl)
387
+ return;
388
+ this.sheet.style.zIndex = String(Number(zIndex) + 1);
389
+ this.sheet.style.setProperty('--bottom-sheet-animation-duration', `${animationDuration}ms`);
390
+ this.applySheetDimensions();
391
+ if (title)
392
+ this.sheet.setAttribute('aria-labelledby', 'bottom-sheet-title');
393
+ else
394
+ this.sheet.removeAttribute('aria-labelledby');
395
+ if (subtitle)
396
+ this.sheet.setAttribute('aria-describedby', 'bottom-sheet-subtitle');
397
+ else
398
+ this.sheet.removeAttribute('aria-describedby');
399
+ this.sheet.replaceChildren();
400
+ const disableDrag = this.getAttribute('disable-drag') === 'true';
401
+ this.grabBar.className = [
402
+ 'designbase-wc-bottom-sheet__grab-bar',
403
+ !disableDrag && 'designbase-wc-bottom-sheet__grab-bar--draggable',
404
+ ]
405
+ .filter(Boolean)
406
+ .join(' ');
407
+ this.grabBar.replaceChildren();
408
+ if (!disableDrag) {
409
+ const handle = document.createElement('div');
410
+ handle.className = 'designbase-wc-bottom-sheet__handle';
411
+ handle.setAttribute('aria-hidden', 'true');
412
+ this.grabBar.append(handle);
413
+ }
414
+ this.sheet.append(this.grabBar);
415
+ const showHeaderBlock = Boolean(title || subtitle || headerSlot.length || showCloseButton);
416
+ if (showHeaderBlock) {
417
+ const header = document.createElement('div');
418
+ header.className = [
419
+ 'designbase-wc-bottom-sheet__header',
420
+ stickyHeader && 'designbase-wc-bottom-sheet__header--sticky',
421
+ ]
422
+ .filter(Boolean)
423
+ .join(' ');
424
+ const headerMain = document.createElement('div');
425
+ headerMain.className = 'designbase-wc-bottom-sheet__header-main';
426
+ if (headerSlot.length) {
427
+ headerSlot.forEach((node) => headerMain.append(node));
428
+ }
429
+ else {
430
+ if (title) {
431
+ const heading = document.createElement('h2');
432
+ heading.id = 'bottom-sheet-title';
433
+ heading.className = 'designbase-wc-bottom-sheet__title';
434
+ heading.textContent = title;
435
+ headerMain.append(heading);
436
+ }
437
+ if (subtitle) {
438
+ const sub = document.createElement('p');
439
+ sub.id = 'bottom-sheet-subtitle';
440
+ sub.className = 'designbase-wc-bottom-sheet__subtitle';
441
+ sub.textContent = subtitle;
442
+ headerMain.append(sub);
443
+ }
444
+ }
445
+ header.append(headerMain);
446
+ if (showCloseButton) {
447
+ const close = document.createElement('button');
448
+ close.type = 'button';
449
+ close.className = 'designbase-wc-bottom-sheet__close-button';
450
+ close.setAttribute('aria-label', '닫기');
451
+ close.append(createDbIcon('close', 20));
452
+ close.addEventListener('click', () => this.close());
453
+ header.append(close);
454
+ }
455
+ this.sheet.append(header);
456
+ }
457
+ this.contentEl.replaceChildren(...contentNodes);
458
+ this.sheet.append(this.contentEl);
459
+ if (footerSlot.length) {
460
+ const footer = document.createElement('div');
461
+ footer.className = [
462
+ 'designbase-wc-bottom-sheet__footer',
463
+ stickyFooter && 'designbase-wc-bottom-sheet__footer--sticky',
464
+ ]
465
+ .filter(Boolean)
466
+ .join(' ');
467
+ footerSlot.forEach((node) => footer.append(node));
468
+ this.sheet.append(footer);
469
+ }
470
+ this.root.append(this.sheet);
471
+ if (this.isMounted && !this.root.isConnected) {
472
+ document.body.append(this.root);
473
+ }
474
+ this.syncActiveClasses();
475
+ }
476
+ }
477
+ if (!customElements.get('db-bottom-sheet')) {
478
+ customElements.define('db-bottom-sheet', DbBottomSheet);
479
+ }
480
+
481
+ export { DbBottomSheet };