@designbasekorea/ui-wc 0.13.0 → 0.15.0

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 (168) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +21 -0
  3. package/README.en.md +45 -0
  4. package/README.md +13 -5
  5. package/THIRD-PARTY-NOTICES.md +5 -0
  6. package/dist/esm/components/db-ad-banner.d.ts +6 -0
  7. package/dist/esm/components/db-ad-banner.js +1 -1
  8. package/dist/esm/components/db-animation-background.d.ts +7 -0
  9. package/dist/esm/components/db-animation-background.js +1 -1
  10. package/dist/esm/components/db-avatar.d.ts +2 -0
  11. package/dist/esm/components/db-avatar.js +1 -1
  12. package/dist/esm/components/db-banner.d.ts +2 -0
  13. package/dist/esm/components/db-banner.js +1 -1
  14. package/dist/esm/components/db-bottom-navigation.d.ts +2 -0
  15. package/dist/esm/components/db-bottom-navigation.js +1 -1
  16. package/dist/esm/components/db-card.d.ts +2 -0
  17. package/dist/esm/components/db-card.js +1 -1
  18. package/dist/esm/components/db-carousel.d.ts +2 -0
  19. package/dist/esm/components/db-carousel.js +1 -1
  20. package/dist/esm/components/db-code-block.d.ts +3 -0
  21. package/dist/esm/components/db-code-block.js +1 -1
  22. package/dist/esm/components/db-color-picker.d.ts +5 -0
  23. package/dist/esm/components/db-color-picker.js +1 -1
  24. package/dist/esm/components/db-color-swatch.d.ts +2 -0
  25. package/dist/esm/components/db-color-swatch.js +1 -1
  26. package/dist/esm/components/db-confirm.d.ts +2 -0
  27. package/dist/esm/components/db-confirm.js +1 -1
  28. package/dist/esm/components/db-context-menu.d.ts +6 -2
  29. package/dist/esm/components/db-context-menu.js +1 -1
  30. package/dist/esm/components/db-cookie-banner.d.ts +2 -0
  31. package/dist/esm/components/db-cookie-banner.js +1 -1
  32. package/dist/esm/components/db-drawer.d.ts +2 -0
  33. package/dist/esm/components/db-drawer.js +1 -1
  34. package/dist/esm/components/db-dropdown.d.ts +2 -0
  35. package/dist/esm/components/db-dropdown.js +1 -1
  36. package/dist/esm/components/db-easing-editor.d.ts +5 -0
  37. package/dist/esm/components/db-empty-state.d.ts +2 -0
  38. package/dist/esm/components/db-empty-state.js +1 -1
  39. package/dist/esm/components/db-file-uploader.d.ts +4 -0
  40. package/dist/esm/components/db-file-uploader.js +1 -1
  41. package/dist/esm/components/db-footer.d.ts +2 -0
  42. package/dist/esm/components/db-footer.js +1 -1
  43. package/dist/esm/components/db-gantt.d.ts +2 -0
  44. package/dist/esm/components/db-gantt.js +1 -1
  45. package/dist/esm/components/db-image-list.d.ts +3 -0
  46. package/dist/esm/components/db-image-list.js +1 -1
  47. package/dist/esm/components/db-keyframe-editor.d.ts +5 -0
  48. package/dist/esm/components/db-layer-list.d.ts +71 -0
  49. package/dist/esm/components/db-layer-list.js +1 -0
  50. package/dist/esm/components/db-lightbox.d.ts +4 -0
  51. package/dist/esm/components/db-lightbox.js +1 -1
  52. package/dist/esm/components/db-list.d.ts +2 -0
  53. package/dist/esm/components/db-list.js +1 -1
  54. package/dist/esm/components/db-menu-item.d.ts +2 -0
  55. package/dist/esm/components/db-menu-item.js +1 -1
  56. package/dist/esm/components/db-modal.d.ts +3 -0
  57. package/dist/esm/components/db-modal.js +1 -1
  58. package/dist/esm/components/db-navbar.d.ts +5 -0
  59. package/dist/esm/components/db-navbar.js +1 -1
  60. package/dist/esm/components/db-onboarding-modal.d.ts +3 -0
  61. package/dist/esm/components/db-onboarding-modal.js +1 -1
  62. package/dist/esm/components/db-page-header.d.ts +3 -0
  63. package/dist/esm/components/db-page-header.js +1 -1
  64. package/dist/esm/components/db-pagination.d.ts +2 -0
  65. package/dist/esm/components/db-pagination.js +1 -1
  66. package/dist/esm/components/db-popover.d.ts +2 -0
  67. package/dist/esm/components/db-popover.js +1 -1
  68. package/dist/esm/components/db-search-bar.d.ts +3 -0
  69. package/dist/esm/components/db-search-bar.js +1 -1
  70. package/dist/esm/components/db-section-app-download.d.ts +2 -0
  71. package/dist/esm/components/db-section-app-download.js +1 -1
  72. package/dist/esm/components/db-section-contact.d.ts +2 -0
  73. package/dist/esm/components/db-section-contact.js +1 -1
  74. package/dist/esm/components/db-section-cta.d.ts +3 -0
  75. package/dist/esm/components/db-section-cta.js +1 -1
  76. package/dist/esm/components/db-section-faq.d.ts +2 -0
  77. package/dist/esm/components/db-section-faq.js +1 -1
  78. package/dist/esm/components/db-section-feature.d.ts +3 -0
  79. package/dist/esm/components/db-section-feature.js +1 -1
  80. package/dist/esm/components/db-section-hero.d.ts +2 -0
  81. package/dist/esm/components/db-section-hero.js +1 -1
  82. package/dist/esm/components/db-section-logo-cloud.d.ts +2 -0
  83. package/dist/esm/components/db-section-logo-cloud.js +1 -1
  84. package/dist/esm/components/db-section-pricing.d.ts +3 -0
  85. package/dist/esm/components/db-section-pricing.js +1 -1
  86. package/dist/esm/components/db-section-stats.d.ts +2 -0
  87. package/dist/esm/components/db-section-stats.js +1 -1
  88. package/dist/esm/components/db-section-testimonials.d.ts +4 -0
  89. package/dist/esm/components/db-section-testimonials.js +1 -1
  90. package/dist/esm/components/db-section.d.ts +2 -0
  91. package/dist/esm/components/db-section.js +1 -1
  92. package/dist/esm/components/db-share.d.ts +5 -0
  93. package/dist/esm/components/db-share.js +1 -1
  94. package/dist/esm/components/db-sidebar.d.ts +7 -0
  95. package/dist/esm/components/db-sidebar.js +1 -1
  96. package/dist/esm/components/db-stat.d.ts +2 -0
  97. package/dist/esm/components/db-stat.js +1 -1
  98. package/dist/esm/components/db-table.d.ts +5 -0
  99. package/dist/esm/components/db-table.js +1 -1
  100. package/dist/esm/components/db-testimonial.d.ts +3 -0
  101. package/dist/esm/components/db-testimonial.js +1 -1
  102. package/dist/esm/components/db-time-picker.d.ts +1 -0
  103. package/dist/esm/components/db-time-picker.js +1 -1
  104. package/dist/esm/components/db-top-banner.d.ts +3 -0
  105. package/dist/esm/components/db-top-banner.js +1 -1
  106. package/dist/esm/components/db-tutorial.d.ts +3 -0
  107. package/dist/esm/components/db-tutorial.js +1 -1
  108. package/dist/esm/components/db-video-timeline.d.ts +34 -2
  109. package/dist/esm/components/db-video-timeline.js +1 -1
  110. package/dist/esm/components/db-world-map.d.ts +5 -0
  111. package/dist/esm/components/media-editor-model.d.ts +10 -1
  112. package/dist/esm/core/i18n-en.js +1 -1
  113. package/dist/esm/core/i18n.d.ts +11 -0
  114. package/dist/esm/core/i18n.js +1 -1
  115. package/dist/esm/index.d.ts +2 -1
  116. package/dist/esm/index.js +1 -1
  117. package/dist/index.cjs +1 -1
  118. package/dist/index.css +1 -1
  119. package/dist/index.d.ts +619 -486
  120. package/dist/index.esm.js +1 -1
  121. package/dist/react/index.cjs +1 -1
  122. package/dist/react/index.d.ts +47 -3
  123. package/dist/react/index.esm.js +1 -1
  124. package/docs/ACCORDION.md +17 -0
  125. package/docs/ACHIEVEMENTS.md +15 -0
  126. package/docs/AI-ELEMENTS.md +86 -0
  127. package/docs/APP-UPDATE.md +60 -0
  128. package/docs/ATTACHMENTS.md +32 -0
  129. package/docs/BUTTON.md +17 -0
  130. package/docs/CDN-GUIDE.md +82 -0
  131. package/docs/COMPONENT-CHECKLIST.md +98 -0
  132. package/docs/CONTEXT-MENU.md +22 -0
  133. package/docs/CREDIT-AI.md +136 -0
  134. package/docs/CREDIT-CARD.md +52 -0
  135. package/docs/CROSS_PLATFORM_COMPONENT_STRATEGY.md +81 -0
  136. package/docs/EASING-EDITOR.md +42 -0
  137. package/docs/EFFECT-KEYFRAMES.md +60 -0
  138. package/docs/LAYER-LIST.md +31 -0
  139. package/docs/MEDIA-EDITORS.md +63 -0
  140. package/docs/MODULE-REUSE.md +43 -0
  141. package/docs/MULTI-PLATFORM-GUIDE.md +246 -0
  142. package/docs/NOTIFICATIONS.md +23 -0
  143. package/docs/PAPER-CARDS.md +61 -0
  144. package/docs/QUALITY-GUIDELINES.md +196 -0
  145. package/docs/RANGE-SLIDER.md +29 -0
  146. package/docs/REACT-WC-INTEGRATION.md +96 -0
  147. package/docs/RECENT-COMPONENTS-QUALITY.md +96 -0
  148. package/docs/SELECT.md +26 -0
  149. package/docs/SELECTION-CONTROLS.md +33 -0
  150. package/docs/SITE-SHELL.md +37 -0
  151. package/docs/STYLING.md +60 -0
  152. package/docs/SUPPORT.md +39 -0
  153. package/docs/TABS.md +19 -0
  154. package/docs/TEXT-FIELDS.md +28 -0
  155. package/docs/TIME-PICKER-DEVELOPMENT.md +115 -0
  156. package/docs/TOGGLE.md +40 -0
  157. package/docs/TRAVEL.md +30 -0
  158. package/docs/UI-NATIVE.md +90 -0
  159. package/docs/VIDEO-EXPORT.md +12 -0
  160. package/docs/VOICE-INPUT.md +24 -0
  161. package/docs/VUE-ANGULAR-INTEGRATION.md +197 -0
  162. package/docs/WORDPRESS-INTEGRATION.md +250 -0
  163. package/docs/WORKSPACE.md +27 -0
  164. package/docs/quality/AXE-REPORT.md +35 -0
  165. package/docs/quality/CREDIT-AI-RELEASE-2026-10-18.md +34 -0
  166. package/docs/quality/ENUM-MIGRATION-WORKSHEET.md +288 -0
  167. package/docs/quality/SCORECARD.md +389 -0
  168. package/package.json +136 -130
@@ -1 +1 @@
1
- import{subscribeDbLocale as t,dbText as e,dbFormat as s}from"../core/i18n.js";import{createShareIcon as r,createSharePlatformIcon as n}from"./db-share-icons.js";import{sanitizeHref as i}from"../core/safe-url.js";import{coerceToContract as a}from"../node_modules/@designbasekorea/ui-contracts/dist/primitives.js";import{SHARE_VARIANTS as o,SHARE_SIZES as l,SHARE_POSITIONS as c}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";const h=["facebook","x","linkedin","whatsapp","email","link"],d={facebook:{name:"Facebook",color:"#1877f2",shareUrl:"https://www.facebook.com/sharer/sharer.php?u={url}"},x:{name:"X",color:"#000000",shareUrl:"https://twitter.com/intent/tweet?url={url}&text={title}&hashtags={hashtags}"},instagram:{name:"Instagram",color:"#e4405f",shareUrl:"https://www.instagram.com/",customShare:()=>{window.alert(e("Instagram에 직접 공유하려면 링크를 복사하여 사용하세요."))}},linkedin:{name:"LinkedIn",color:"#0077b5",shareUrl:"https://www.linkedin.com/sharing/share-offsite/?url={url}"},pinterest:{name:"Pinterest",color:"#bd081c",shareUrl:"https://pinterest.com/pin/create/button/?url={url}&description={title}&media={imageUrl}"},whatsapp:{name:"WhatsApp",color:"#25d366",shareUrl:"https://wa.me/?text={title}%20{url}"},telegram:{name:"Telegram",color:"#0088cc",shareUrl:"https://t.me/share/url?url={url}&text={title}"},email:{name:"이메일",color:"#ea4335",shareUrl:"mailto:?subject={title}&body={description}%20{url}"},link:{name:"링크 복사",color:"#6c757d",shareUrl:""},qr:{name:"QR 코드",color:"#6c757d",shareUrl:""}};class DbShare extends HTMLElement{constructor(){super(...arguments),this.isCopied=!1,this.qrCodeData="",this.copyResetTimer=null,this.modalEl=null,this.contentSlot=null,this.dropdownEl=null}static get observedAttributes(){return["url","title","share-title","description","image-url","hashtags","variant","size","position","platforms","button-text","modal-title","show-qr-code","qr-code-size","copy-success-message","open"]}connectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=t(()=>this.syncLocale()),this.render()}disconnectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=void 0,this.copyResetTimer&&clearTimeout(this.copyResetTimer)}platformName(t){return["email","link","qr"].includes(t)?e(d[t].name):d[t].name}platformAriaLabel(t){return"email"===t?e("이메일로 공유"):"link"===t?e("링크 복사"):"qr"===t?e("QR 코드 보기"):s("{0}에 공유하기",[this.platformName(t)])}copySuccessLabel(){return this.getAttribute("copy-success-message")||e("복사됨!")}syncLocale(){const t=this.contentSlot||this,s=this.querySelector(".designbase-wc-share__trigger"),r=s&&Array.from(s.childNodes).find(t=>t.nodeType===Node.TEXT_NODE);r&&(r.textContent=this.getAttribute("button-text")||e("공유")),this.modalEl&&this.modalEl.setAttribute("title",this.getAttribute("modal-title")||e("공유하기")),t.querySelectorAll("[data-share-platform]").forEach(t=>{const e=t.dataset.sharePlatform,s=this.platformName(e);t.title=s,t.setAttribute("aria-label",this.platformAriaLabel(e));const r=t.querySelector(".designbase-wc-share__platform-name");r&&(r.textContent=s);const n=t.querySelector(".designbase-wc-share__copy-success span");n&&(n.textContent=this.copySuccessLabel())});const n=t.querySelector(".designbase-wc-share__copy-button"),i=n&&Array.from(n.childNodes).find(t=>t.nodeType===Node.TEXT_NODE);i&&(i.textContent=this.isCopied?this.copySuccessLabel():e("복사"));const a=[[".designbase-wc-share__qr-title","QR 코드"],[".designbase-wc-share__qr-description","QR 코드를 스캔하여 링크에 접속하세요"],[".designbase-wc-share__link-title","공유 링크"]];for(const[s,r]of a){const n=t.querySelector(s);n&&(n.textContent=e(r))}if(this.dropdownEl){const t=document.activeElement,s=Array.from(this.dropdownEl.querySelectorAll(".designbase-wc-dropdown__item")).findIndex(e=>e===t||e.contains(t));this.dropdownEl.setAttribute("label",this.getAttribute("button-text")||e("공유")),this.dropdownEl.setAttribute("items",JSON.stringify(this.getActivePlatforms().map(t=>({id:t,label:this.platformName(t)})))),s>=0&&this.dropdownEl.querySelectorAll(".designbase-wc-dropdown__item")[s]?.focus({preventScroll:!0})}}getVariant(){return a(this.getAttribute("variant"),o,"button")}getSize(){return a(this.getAttribute("size"),l,"m")}getPosition(){return a(this.getAttribute("position"),c,"bottom")}attributeChangedCallback(t){"open"===t&&"modal"===this.getVariant()&&this.modalEl?this.syncModalOpen():"url"===t&&this.contentSlot?this.refreshLinkInputValue():this.render()}get open(){return this.hasAttribute("open")&&"false"!==this.getAttribute("open")}set open(t){t?this.setAttribute("open","true"):this.removeAttribute("open")}parseListAttribute(t){const e=this.getAttribute(t);if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(t=>String(t).trim()).filter(Boolean)}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}getResolvedUrl(){const t=this.getAttribute("url");return t?i(t,""):"undefined"!=typeof window&&window.location?.href?i(window.location.href,""):""}getContext(){return{url:this.getResolvedUrl(),title:this.getAttribute("share-title")||this.getAttribute("title")||"",description:this.getAttribute("description")||"",imageUrl:this.getAttribute("image-url")||"",hashtags:this.parseListAttribute("hashtags"),host:this}}getActivePlatforms(){const t=this.parseListAttribute("platforms");return(t.length>0?t:h).filter(t=>t in d)}replaceUrlVariables(t,e){return t.replace("{url}",encodeURIComponent(e.url)).replace("{title}",encodeURIComponent(e.title)).replace("{description}",encodeURIComponent(e.description)).replace("{imageUrl}",encodeURIComponent(e.imageUrl)).replace("{hashtags}",e.hashtags.join(","))}async handleCopyLink(t){try{await navigator.clipboard.writeText(t.url),this.isCopied=!0,this.dispatchEvent(new CustomEvent("db-copy-success",{bubbles:!0,composed:!0,detail:{url:t.url}})),this.refreshContent(),this.copyResetTimer&&clearTimeout(this.copyResetTimer),this.copyResetTimer=setTimeout(()=>{this.isCopied=!1,this.refreshContent()},3e3)}catch(t){this.dispatchEvent(new CustomEvent("db-copy-error",{bubbles:!0,composed:!0,detail:{error:t}}))}}handleShowQrCode(t){if(this.qrCodeData=t.url,"modal"===this.getVariant())return this.open=!0,void this.refreshContent();this.refreshContent()}handlePlatformShare(t){const e=this.getContext(),s=d[t];if(s)try{if("link"===t)this.handleCopyLink(e);else if("qr"===t)this.handleShowQrCode(e);else if(s.customShare)s.customShare(e);else if(s.shareUrl){const t=this.replaceUrlVariables(s.shareUrl,e),r=i(t,"");if(!r)throw new Error("Invalid share URL");window.open(r,"_blank","noopener,noreferrer,width=600,height=400")}this.dispatchEvent(new CustomEvent("db-share",{bubbles:!0,composed:!0,detail:{platform:t,url:e.url}}))}catch(e){this.dispatchEvent(new CustomEvent("db-share-error",{bubbles:!0,composed:!0,detail:{platform:t,error:e}}))}}getPlacement(){const t=this.getPosition();return"top"===t||"left"===t?"top-left":"right"===t?"bottom-right":"bottom-left"}mapButtonSize(){const t=this.getSize();return"s"===t?"s":"l"===t?"l":"m"}createTriggerButton(t){const s=document.createElement("db-button");return s.className=t||"designbase-wc-share__trigger",s.setAttribute("variant","secondary"),s.setAttribute("size",this.mapButtonSize()),s.textContent=this.getAttribute("button-text")||e("공유"),s.prepend(r("share-alt",16)),s.addEventListener("db-click",()=>{"modal"!==this.getVariant()?this.open=!this.open:this.open=!0}),s}createPlatformIcon(t){const e=document.createElement("span");return e.className="designbase-wc-share__platform-icon",e.append(n(t,24)),e}createPlatformButton(t){const e=d[t],s=document.createElement("button");s.type="button",s.className=["designbase-wc-share__platform-button",`designbase-wc-share__platform-button--${t}`,"link"===t&&this.isCopied?"designbase-wc-share__platform-button--copied":""].filter(Boolean).join(" "),s.style.setProperty("--platform-color",e.color),s.dataset.sharePlatform=t;const n=this.platformName(t);s.title=n,s.setAttribute("aria-label",this.platformAriaLabel(t)),s.append(this.createPlatformIcon(t));const i=document.createElement("span");if(i.className="designbase-wc-share__platform-name",i.textContent=n,s.append(i),"link"===t&&this.isCopied){const t=document.createElement("span");t.className="designbase-wc-share__copy-success",t.append(r("copy",12));const e=document.createElement("span");e.textContent=this.copySuccessLabel(),t.append(e),s.append(t)}return s.addEventListener("click",()=>this.handlePlatformShare(t)),s}createLinkInput(t){const e=document.createElement("db-input");return e.className="designbase-wc-share__link-input",e.setAttribute("type","text"),e.setAttribute("readonly",""),e.setAttribute("size","s"),e.setAttribute("full-width",""),e.setAttribute("value",t),customElements.whenDefined("db-input").then(()=>{e.setAttribute("value",t),e.value=t}),e}refreshLinkInputValue(){const t=this.getResolvedUrl(),e=this.contentSlot?.querySelector("db-input.designbase-wc-share__link-input");e&&(e.setAttribute("value",t),e.value=t)}createCopyButton(t){const s=document.createElement("db-button");s.className="designbase-wc-share__copy-button",s.setAttribute("size","s"),s.setAttribute("variant","primary");const n=document.createElement("span");return n.className="designbase-wc-button__start-icon",n.setAttribute("aria-hidden","true"),n.append(r(this.isCopied?"copy":"link",16)),s.append(n),s.append(document.createTextNode(this.isCopied?this.copySuccessLabel():e("복사"))),s.addEventListener("db-click",()=>{this.handleCopyLink(t)}),s}generateQrCodeUrl(){const t=Number(this.getAttribute("qr-code-size")||200);return`https://api.qrserver.com/v1/create-qr-code/?size=${t}x${t}&data=${encodeURIComponent(this.qrCodeData)}`}createShareContent(){const t=document.createElement("div");return t.className="designbase-wc-share__content",this.populateShareContent(t),t}populateShareContent(t){const s=document.createElement("div");s.className="designbase-wc-share__platforms",this.getActivePlatforms().forEach(t=>{s.append(this.createPlatformButton(t))}),t.append(s);if("false"!==this.getAttribute("show-qr-code")&&this.qrCodeData){const s=document.createElement("div");s.className="designbase-wc-share__qr-section";const r=document.createElement("h4");r.className="designbase-wc-share__qr-title",r.textContent=e("QR 코드"),s.append(r);const n=document.createElement("div");n.className="designbase-wc-share__qr-code";const i=document.createElement("img"),a=Number(this.getAttribute("qr-code-size")||200);i.src=this.generateQrCodeUrl(),i.alt="QR Code",i.width=a,i.height=a,n.append(i),s.append(n);const o=document.createElement("p");o.className="designbase-wc-share__qr-description",o.textContent=e("QR 코드를 스캔하여 링크에 접속하세요"),s.append(o),t.append(s)}const r=this.getContext(),n=document.createElement("div");n.className="designbase-wc-share__link-preview";const i=document.createElement("h4");i.className="designbase-wc-share__link-title",i.textContent=e("공유 링크"),n.append(i);const a=document.createElement("div");a.className="designbase-wc-share__link-container",a.append(this.createLinkInput(r.url)),a.append(this.createCopyButton(r)),n.append(a),t.append(n)}refreshContent(){const t=this.getVariant();if("inline"===t){const t=this.querySelector(":scope > .designbase-wc-share__content");return void t?.replaceWith(this.createShareContent())}"modal"===t&&this.contentSlot&&(this.contentSlot.replaceChildren(),this.populateShareContent(this.contentSlot))}syncModalOpen(){this.modalEl&&(this.open?(this.refreshLinkInputValue(),this.modalEl.setAttribute("open","true")):this.modalEl.removeAttribute("open"))}renderDropdown(){const t=document.createElement("db-dropdown");t.className="designbase-wc-share__dropdown",t.setAttribute("placement",this.getPlacement()),t.setAttribute("label",this.getAttribute("button-text")||e("공유")),t.setAttribute("trigger-variant","secondary"),t.setAttribute("trigger-icon","share-alt"),t.setAttribute("size",this.mapButtonSize()),t.setAttribute("items",JSON.stringify(this.getActivePlatforms().map(t=>({id:t,label:this.platformName(t)})))),t.addEventListener("db-change",t=>{const e=t.detail,s=e?.id;s&&this.handlePlatformShare(s)}),this.dropdownEl=t,this.append(t)}renderModal(){const t=this.createTriggerButton();this.append(t);const s=document.createElement("db-modal");s.className="designbase-wc-share__modal",s.setAttribute("title",this.getAttribute("modal-title")||e("공유하기")),s.setAttribute("size","m"),this.contentSlot=document.createElement("div"),this.contentSlot.className="designbase-wc-share designbase-wc-share__content",this.contentSlot.setAttribute("data-modal-part","body"),this.populateShareContent(this.contentSlot),s.append(this.contentSlot),s.addEventListener("db-close",()=>{this.open=!1,this.qrCodeData="",this.contentSlot&&(this.contentSlot.replaceChildren(),this.populateShareContent(this.contentSlot))}),this.modalEl=s,this.append(s),this.syncModalOpen()}render(){const t=this.getVariant();this.className=`designbase-wc-share designbase-wc-share--${t}`,this.replaceChildren(),this.modalEl=null,this.contentSlot=null,this.dropdownEl=null,"inline"!==t?"dropdown"!==t?"modal"!==t?this.append(this.createTriggerButton()):this.renderModal():this.renderDropdown():this.append(this.createShareContent())}}customElements.get("db-share")||customElements.define("db-share",DbShare);export{DbShare};
1
+ import"./db-button.js";import"./db-input.js";import"./db-dropdown.js";import"./db-modal.js";import{subscribeDbLocale as t,dbText as e,dbFormat as s}from"../core/i18n.js";import{createShareIcon as r,createSharePlatformIcon as n}from"./db-share-icons.js";import{sanitizeHref as i}from"../core/safe-url.js";import{coerceToContract as a}from"../node_modules/@designbasekorea/ui-contracts/dist/primitives.js";import{SHARE_VARIANTS as o,SHARE_SIZES as l,SHARE_POSITIONS as c}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";const d=["facebook","x","linkedin","whatsapp","email","link"],h={facebook:{name:"Facebook",color:"#1877f2",shareUrl:"https://www.facebook.com/sharer/sharer.php?u={url}"},x:{name:"X",color:"#000000",shareUrl:"https://twitter.com/intent/tweet?url={url}&text={title}&hashtags={hashtags}"},instagram:{name:"Instagram",color:"#e4405f",shareUrl:"https://www.instagram.com/",customShare:()=>{window.alert(e("Instagram에 직접 공유하려면 링크를 복사하여 사용하세요."))}},linkedin:{name:"LinkedIn",color:"#0077b5",shareUrl:"https://www.linkedin.com/sharing/share-offsite/?url={url}"},pinterest:{name:"Pinterest",color:"#bd081c",shareUrl:"https://pinterest.com/pin/create/button/?url={url}&description={title}&media={imageUrl}"},whatsapp:{name:"WhatsApp",color:"#25d366",shareUrl:"https://wa.me/?text={title}%20{url}"},telegram:{name:"Telegram",color:"#0088cc",shareUrl:"https://t.me/share/url?url={url}&text={title}"},email:{name:"이메일",color:"#ea4335",shareUrl:"mailto:?subject={title}&body={description}%20{url}"},link:{name:"링크 복사",color:"#6c757d",shareUrl:""},qr:{name:"QR 코드",color:"#6c757d",shareUrl:""}};class DbShare extends HTMLElement{constructor(){super(...arguments),this.isCopied=!1,this.qrCodeData="",this.copyResetTimer=null,this.modalEl=null,this.contentSlot=null,this.dropdownEl=null}static get observedAttributes(){return["url","title","share-title","description","image-url","hashtags","variant","size","position","platforms","button-text","modal-title","show-qr-code","qr-code-size","copy-success-message","open"]}connectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=t(()=>this.syncLocale()),this.render()}disconnectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=void 0,this.copyResetTimer&&clearTimeout(this.copyResetTimer)}platformName(t){return["email","link","qr"].includes(t)?e(h[t].name):h[t].name}platformAriaLabel(t){return"email"===t?e("이메일로 공유"):"link"===t?e("링크 복사"):"qr"===t?e("QR 코드 보기"):s("{0}에 공유하기",[this.platformName(t)])}copySuccessLabel(){return this.getAttribute("copy-success-message")||e("복사됨!")}syncLocale(){const t=this.contentSlot||this,s=this.querySelector(".designbase-wc-share__trigger"),r=s&&Array.from(s.childNodes).find(t=>t.nodeType===Node.TEXT_NODE);r&&(r.textContent=this.getAttribute("button-text")||e("공유")),this.modalEl&&this.modalEl.setAttribute("title",this.getAttribute("modal-title")||e("공유하기")),t.querySelectorAll("[data-share-platform]").forEach(t=>{const e=t.dataset.sharePlatform,s=this.platformName(e);t.title=s,t.setAttribute("aria-label",this.platformAriaLabel(e));const r=t.querySelector(".designbase-wc-share__platform-name");r&&(r.textContent=s);const n=t.querySelector(".designbase-wc-share__copy-success span");n&&(n.textContent=this.copySuccessLabel())});const n=t.querySelector(".designbase-wc-share__copy-button"),i=n&&Array.from(n.childNodes).find(t=>t.nodeType===Node.TEXT_NODE);i&&(i.textContent=this.isCopied?this.copySuccessLabel():e("복사"));const a=[[".designbase-wc-share__qr-title","QR 코드"],[".designbase-wc-share__qr-description","QR 코드를 스캔하여 링크에 접속하세요"],[".designbase-wc-share__link-title","공유 링크"]];for(const[s,r]of a){const n=t.querySelector(s);n&&(n.textContent=e(r))}if(this.dropdownEl){const t=document.activeElement,s=Array.from(this.dropdownEl.querySelectorAll(".designbase-wc-dropdown__item")).findIndex(e=>e===t||e.contains(t));this.dropdownEl.setAttribute("label",this.getAttribute("button-text")||e("공유")),this.dropdownEl.setAttribute("items",JSON.stringify(this.getActivePlatforms().map(t=>({id:t,label:this.platformName(t)})))),s>=0&&this.dropdownEl.querySelectorAll(".designbase-wc-dropdown__item")[s]?.focus({preventScroll:!0})}}getVariant(){return a(this.getAttribute("variant"),o,"button")}getSize(){return a(this.getAttribute("size"),l,"m")}getPosition(){return a(this.getAttribute("position"),c,"bottom")}attributeChangedCallback(t){"open"===t&&"modal"===this.getVariant()&&this.modalEl?this.syncModalOpen():"url"===t&&this.contentSlot?this.refreshLinkInputValue():this.render()}get open(){return this.hasAttribute("open")&&"false"!==this.getAttribute("open")}set open(t){t?this.setAttribute("open","true"):this.removeAttribute("open")}parseListAttribute(t){const e=this.getAttribute(t);if(!e)return[];try{const t=JSON.parse(e);if(Array.isArray(t))return t.map(t=>String(t).trim()).filter(Boolean)}catch{}return e.split(",").map(t=>t.trim()).filter(Boolean)}getResolvedUrl(){const t=this.getAttribute("url");return t?i(t,""):"undefined"!=typeof window&&window.location?.href?i(window.location.href,""):""}getContext(){return{url:this.getResolvedUrl(),title:this.getAttribute("share-title")||this.getAttribute("title")||"",description:this.getAttribute("description")||"",imageUrl:this.getAttribute("image-url")||"",hashtags:this.parseListAttribute("hashtags"),host:this}}getActivePlatforms(){const t=this.parseListAttribute("platforms");return(t.length>0?t:d).filter(t=>t in h)}replaceUrlVariables(t,e){return t.replace("{url}",encodeURIComponent(e.url)).replace("{title}",encodeURIComponent(e.title)).replace("{description}",encodeURIComponent(e.description)).replace("{imageUrl}",encodeURIComponent(e.imageUrl)).replace("{hashtags}",e.hashtags.join(","))}async handleCopyLink(t){try{await navigator.clipboard.writeText(t.url),this.isCopied=!0,this.dispatchEvent(new CustomEvent("db-copy-success",{bubbles:!0,composed:!0,detail:{url:t.url}})),this.refreshContent(),this.copyResetTimer&&clearTimeout(this.copyResetTimer),this.copyResetTimer=setTimeout(()=>{this.isCopied=!1,this.refreshContent()},3e3)}catch(t){this.dispatchEvent(new CustomEvent("db-copy-error",{bubbles:!0,composed:!0,detail:{error:t}}))}}handleShowQrCode(t){if(this.qrCodeData=t.url,"modal"===this.getVariant())return this.open=!0,void this.refreshContent();this.refreshContent()}handlePlatformShare(t){const e=this.getContext(),s=h[t];if(s)try{if("link"===t)this.handleCopyLink(e);else if("qr"===t)this.handleShowQrCode(e);else if(s.customShare)s.customShare(e);else if(s.shareUrl){const t=this.replaceUrlVariables(s.shareUrl,e),r=i(t,"");if(!r)throw new Error("Invalid share URL");window.open(r,"_blank","noopener,noreferrer,width=600,height=400")}this.dispatchEvent(new CustomEvent("db-share",{bubbles:!0,composed:!0,detail:{platform:t,url:e.url}}))}catch(e){this.dispatchEvent(new CustomEvent("db-share-error",{bubbles:!0,composed:!0,detail:{platform:t,error:e}}))}}getPlacement(){const t=this.getPosition();return"top"===t||"left"===t?"top-left":"right"===t?"bottom-right":"bottom-left"}mapButtonSize(){const t=this.getSize();return"s"===t?"s":"l"===t?"l":"m"}createTriggerButton(t){const s=document.createElement("db-button");return s.className=t||"designbase-wc-share__trigger",s.setAttribute("variant","secondary"),s.setAttribute("size",this.mapButtonSize()),s.textContent=this.getAttribute("button-text")||e("공유"),s.prepend(r("share-alt",16)),s.addEventListener("db-click",()=>{"modal"!==this.getVariant()?this.open=!this.open:this.open=!0}),s}createPlatformIcon(t){const e=document.createElement("span");return e.className="designbase-wc-share__platform-icon",e.append(n(t,24)),e}createPlatformButton(t){const e=h[t],s=document.createElement("button");s.type="button",s.className=["designbase-wc-share__platform-button",`designbase-wc-share__platform-button--${t}`,"link"===t&&this.isCopied?"designbase-wc-share__platform-button--copied":""].filter(Boolean).join(" "),s.style.setProperty("--platform-color",e.color),s.dataset.sharePlatform=t;const n=this.platformName(t);s.title=n,s.setAttribute("aria-label",this.platformAriaLabel(t)),s.append(this.createPlatformIcon(t));const i=document.createElement("span");if(i.className="designbase-wc-share__platform-name",i.textContent=n,s.append(i),"link"===t&&this.isCopied){const t=document.createElement("span");t.className="designbase-wc-share__copy-success",t.append(r("copy",12));const e=document.createElement("span");e.textContent=this.copySuccessLabel(),t.append(e),s.append(t)}return s.addEventListener("click",()=>this.handlePlatformShare(t)),s}createLinkInput(t){const e=document.createElement("db-input");return e.className="designbase-wc-share__link-input",e.setAttribute("type","text"),e.setAttribute("readonly",""),e.setAttribute("size","s"),e.setAttribute("full-width",""),e.setAttribute("value",t),customElements.whenDefined("db-input").then(()=>{e.setAttribute("value",t),e.value=t}),e}refreshLinkInputValue(){const t=this.getResolvedUrl(),e=this.contentSlot?.querySelector("db-input.designbase-wc-share__link-input");e&&(e.setAttribute("value",t),e.value=t)}createCopyButton(t){const s=document.createElement("db-button");s.className="designbase-wc-share__copy-button",s.setAttribute("size","s"),s.setAttribute("variant","primary");const n=document.createElement("span");return n.className="designbase-wc-button__start-icon",n.setAttribute("aria-hidden","true"),n.append(r(this.isCopied?"copy":"link",16)),s.append(n),s.append(document.createTextNode(this.isCopied?this.copySuccessLabel():e("복사"))),s.addEventListener("db-click",()=>{this.handleCopyLink(t)}),s}generateQrCodeUrl(){const t=Number(this.getAttribute("qr-code-size")||200);return`https://api.qrserver.com/v1/create-qr-code/?size=${t}x${t}&data=${encodeURIComponent(this.qrCodeData)}`}createShareContent(){const t=document.createElement("div");return t.className="designbase-wc-share__content",this.populateShareContent(t),t}populateShareContent(t){const s=document.createElement("div");s.className="designbase-wc-share__platforms",this.getActivePlatforms().forEach(t=>{s.append(this.createPlatformButton(t))}),t.append(s);if("false"!==this.getAttribute("show-qr-code")&&this.qrCodeData){const s=document.createElement("div");s.className="designbase-wc-share__qr-section";const r=document.createElement("h4");r.className="designbase-wc-share__qr-title",r.textContent=e("QR 코드"),s.append(r);const n=document.createElement("div");n.className="designbase-wc-share__qr-code";const i=document.createElement("img"),a=Number(this.getAttribute("qr-code-size")||200);i.src=this.generateQrCodeUrl(),i.alt="QR Code",i.width=a,i.height=a,n.append(i),s.append(n);const o=document.createElement("p");o.className="designbase-wc-share__qr-description",o.textContent=e("QR 코드를 스캔하여 링크에 접속하세요"),s.append(o),t.append(s)}const r=this.getContext(),n=document.createElement("div");n.className="designbase-wc-share__link-preview";const i=document.createElement("h4");i.className="designbase-wc-share__link-title",i.textContent=e("공유 링크"),n.append(i);const a=document.createElement("div");a.className="designbase-wc-share__link-container",a.append(this.createLinkInput(r.url)),a.append(this.createCopyButton(r)),n.append(a),t.append(n)}refreshContent(){const t=this.getVariant();if("inline"===t){const t=this.querySelector(":scope > .designbase-wc-share__content");return void t?.replaceWith(this.createShareContent())}"modal"===t&&this.contentSlot&&(this.contentSlot.replaceChildren(),this.populateShareContent(this.contentSlot))}syncModalOpen(){this.modalEl&&(this.open?(this.refreshLinkInputValue(),this.modalEl.setAttribute("open","true")):this.modalEl.removeAttribute("open"))}renderDropdown(){const t=document.createElement("db-dropdown");t.className="designbase-wc-share__dropdown",t.setAttribute("placement",this.getPlacement()),t.setAttribute("label",this.getAttribute("button-text")||e("공유")),t.setAttribute("trigger-variant","secondary"),t.setAttribute("trigger-icon","share-alt"),t.setAttribute("size",this.mapButtonSize()),t.setAttribute("items",JSON.stringify(this.getActivePlatforms().map(t=>({id:t,label:this.platformName(t)})))),t.addEventListener("db-change",t=>{const e=t.detail,s=e?.id;s&&this.handlePlatformShare(s)}),this.dropdownEl=t,this.append(t)}renderModal(){const t=this.createTriggerButton();this.append(t);const s=document.createElement("db-modal");s.className="designbase-wc-share__modal",s.setAttribute("title",this.getAttribute("modal-title")||e("공유하기")),s.setAttribute("size","m"),this.contentSlot=document.createElement("div"),this.contentSlot.className="designbase-wc-share designbase-wc-share__content",this.contentSlot.setAttribute("data-modal-part","body"),this.populateShareContent(this.contentSlot),s.append(this.contentSlot),s.addEventListener("db-close",()=>{this.open=!1,this.qrCodeData="",this.contentSlot&&(this.contentSlot.replaceChildren(),this.populateShareContent(this.contentSlot))}),this.modalEl=s,this.append(s),this.syncModalOpen()}render(){const t=this.getVariant();this.className=`designbase-wc-share designbase-wc-share--${t}`,this.replaceChildren(),this.modalEl=null,this.contentSlot=null,this.dropdownEl=null,"inline"!==t?"dropdown"!==t?"modal"!==t?this.append(this.createTriggerButton()):this.renderModal():this.renderDropdown():this.append(this.createShareContent())}}customElements.get("db-share")||customElements.define("db-share",DbShare);export{DbShare};
@@ -1,3 +1,10 @@
1
+ import './db-avatar.js';
2
+ import './db-badge.js';
3
+ import './db-menu-item.js';
4
+ import './db-banner.js';
5
+ import './db-animation-background.js';
6
+ import './db-button.js';
7
+ import './db-logo.js';
1
8
  import { SIDEBAR_ACCORDION_MODES } from '../ui-contracts/dist/components.d.js';
2
9
 
3
10
  interface DbSidebarItem {
@@ -1 +1 @@
1
- import{subscribeDbLocale as e,dbText as t,dbFormat as s}from"../core/i18n.js";import{createDbIcon as i,isDbIconName as a}from"./db-icons.js";import{sanitizeHref as n}from"../core/safe-url.js";import{SIDEBAR_CUSTOM_NAV_SLOTS as r,SIDEBAR_PANEL_MODES as o,SIDEBAR_TYPES as d,SIDEBAR_SIZES as c,SIDEBAR_THEMES as l,SIDEBAR_POSITIONS as u,SIDEBAR_VARIANTS as b}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";const p="240px";class DbSidebar extends HTMLElement{constructor(){super(...arguments),this.expandedItems=new Set,this.userMenuOpen=!1,this.projectMenuOpen=!1,this.flyoutItemId=null,this.userFlyoutItemId=null,this.flyoutCloseTimer=null,this.userFlyoutCloseTimer=null,this.outsideHandler=null,this.panelMediaQuery=null,this.panelMediaHandler=null,this.resolvedPanelMode="adjacent"}collectCustomNavSlots(){const e=new Map;return r.forEach(t=>{const s=Array.from(this.children).filter(e=>e instanceof HTMLElement&&e.getAttribute("slot")===t),i=Array.from(this.querySelectorAll(`[data-sidebar-slot="${t}"]`)).flatMap(e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.getAttribute("slot")===t));e.set(t,[...new Set([...s,...i])])}),e}createCustomNavSlot(e){const t=document.createElement("div");return t.className=["designbase-wc-sidebar__custom-slot",`designbase-wc-sidebar__custom-slot--${e}`].join(" "),t.dataset.sidebarSlot=e,t}projectCustomNavSlots(e){r.forEach(t=>{const s=this.querySelector(`[data-sidebar-slot="${t}"]`),i=e.get(t)??[];s&&0!==i.length?s.append(...i):s?.remove()})}static get observedAttributes(){return["type","logo-src","logo-alt","items","sections","user-menu-items","user-profile","default-expanded-ids","expanded-ids","accordion-mode","projects","selected-project-id","project-manage-label","project-manage-href","project-section-label","project-empty-label","project-empty-trigger-label","bottom-items","bottom-sections","promo-banner","update-banner","header-type","back-label","back-href","panels","settings-sections","active-panel","panel-mode","panel-width","panel-breakpoint","size","theme","variant","position","collapsed","collapsible","show-logo","logo-type","logo-text","full-height","shadow"]}connectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=e(()=>{this.syncAccessibleName(),this.querySelectorAll("[data-panel-nav]:not([data-panel-id])").forEach(e=>e.setAttribute("aria-label",t("주 메뉴"))),this.querySelectorAll(".designbase-wc-sidebar__bottom-nav").forEach(e=>e.setAttribute("aria-label",t("하단 메뉴"))),this.querySelector(".designbase-wc-sidebar__toggle")?.setAttribute("aria-label",t(this.hasAttribute("collapsed")?"사이드바 펼치기":"사이드바 접기"));const e=this.querySelector("[data-project-empty-trigger]");if(e){e.setAttribute("aria-label",this.projectEmptyTriggerLabel);const t=e.querySelector(".designbase-wc-sidebar__project-label");t&&(t.textContent=this.projectEmptyTriggerLabel)}this.querySelector(".designbase-wc-sidebar__project-dropdown")?.setAttribute("aria-label",this.projectSectionLabel);const s=this.querySelector(".designbase-wc-sidebar__project-empty-text");s&&(s.textContent=this.projectEmptyLabel);const i=this.querySelector(".designbase-wc-sidebar__project-manage span");i&&(i.textContent=this.projectManageLabel);const a=this.querySelector(".designbase-wc-sidebar__back");if(a){a.setAttribute("aria-label",this.backLabel);const e=a.querySelector("span");e&&(e.textContent=this.backLabel)}this.querySelector(".designbase-wc-sidebar__user-dropdown")?.setAttribute("aria-label",t("사용자 메뉴"));const n=this.querySelector(".designbase-wc-sidebar__logo db-logo");n&&n.setAttribute("alt",this.getAttribute("logo-alt")||t("홈"))}),this.seedExpanded(),this.bindPanelMediaQuery(),this.render(),this.bindOutsideClick()}syncAccessibleName(){const e=this.getAttribute("aria-label");e&&e!==this.autoAriaLabel||(this.autoAriaLabel=t("사이드바 네비게이션"),this.setAttribute("aria-label",this.autoAriaLabel))}disconnectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=void 0,this.unbindOutsideClick(),this.unbindPanelMediaQuery(),this.cancelFlyoutClose(),this.cancelUserFlyoutClose()}attributeChangedCallback(e,t,s){if(this.isConnected&&t!==s){if("default-expanded-ids"===e||"expanded-ids"===e||"accordion-mode"===e)return this.seedExpanded(),void this.syncAccordionState();if("collapsed"===e&&this.hasAttribute("collapsed")&&(this.userMenuOpen=!1,this.projectMenuOpen=!1,this.flyoutItemId=null,this.userFlyoutItemId=null,this.cancelFlyoutClose(),this.cancelUserFlyoutClose()),"panel-mode"!==e&&"panel-breakpoint"!==e||this.bindPanelMediaQuery(),this.render(),"active-panel"===e){const e=this.getActivePanelConfig();this.dispatchEvent(new CustomEvent("db-panel-change",{bubbles:!0,composed:!0,detail:{panel:e?.id??"main",panelConfig:e,mode:this.resolvedPanelMode}}))}}}bindPanelMediaQuery(){this.unbindPanelMediaQuery();const e=this.panelMode;if("auto"!==e)return void(this.resolvedPanelMode=e);if("undefined"==typeof window||"function"!=typeof window.matchMedia)return void(this.resolvedPanelMode="adjacent");const t=window.matchMedia(`(min-width: ${this.panelBreakpoint}px)`);this.panelMediaQuery=t,this.resolvedPanelMode=t.matches?"adjacent":"replace",this.panelMediaHandler=e=>{const t=e.matches?"adjacent":"replace";t!==this.resolvedPanelMode&&(this.resolvedPanelMode=t,this.render(),this.dispatchEvent(new CustomEvent("db-panel-mode-change",{bubbles:!0,composed:!0,detail:{mode:t}})))},t.addEventListener("change",this.panelMediaHandler)}unbindPanelMediaQuery(){this.panelMediaQuery&&this.panelMediaHandler&&this.panelMediaQuery.removeEventListener("change",this.panelMediaHandler),this.panelMediaQuery=null,this.panelMediaHandler=null}seedExpanded(){try{const e=JSON.parse(this.getAttribute("expanded-ids")??this.getAttribute("default-expanded-ids")??"[]"),t=Array.isArray(e)?[...new Set(e.filter(e=>"string"==typeof e))]:[];this.expandedItems=new Set("single"===this.accordionMode?t.slice(0,1):t)}catch{this.expandedItems=new Set}}get expandedIds(){return[...this.expandedItems]}set expandedIds(e){this.setAttribute("expanded-ids","string"==typeof e?e:JSON.stringify(e)),this.isConnected||this.seedExpanded()}get accordionMode(){return"multiple"===this.getAttribute("accordion-mode")?"multiple":"single"}set accordionMode(e){this.setAttribute("accordion-mode",e)}get hideExpandIcon(){return this.hasAttribute("hide-expand-icon")&&"false"!==this.getAttribute("hide-expand-icon")}set hideExpandIcon(e){this.toggleAttribute("hide-expand-icon",e)}get showDepthGuide(){return this.hasAttribute("show-depth-guide")&&"false"!==this.getAttribute("show-depth-guide")}set showDepthGuide(e){this.toggleAttribute("show-depth-guide",e)}get items(){try{const e=JSON.parse(this.getAttribute("items")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}set items(e){this.setAttribute("items","string"==typeof e?e:JSON.stringify(e))}get sections(){return this.parseSections()}set sections(e){this.setAttribute("sections","string"==typeof e?e:JSON.stringify(e))}get userMenuItems(){return this.parseUserMenuItems()}set userMenuItems(e){this.setAttribute("user-menu-items","string"==typeof e?e:JSON.stringify(e))}get userProfile(){return this.parseUserProfile()}set userProfile(e){null==e?this.removeAttribute("user-profile"):this.setAttribute("user-profile","string"==typeof e?e:JSON.stringify(e))}get projects(){return this.parseProjects()}set projects(e){this.setAttribute("projects","string"==typeof e?e:JSON.stringify(e))}get selectedProjectId(){return this.getAttribute("selected-project-id")||""}set selectedProjectId(e){e?this.setAttribute("selected-project-id",e):this.removeAttribute("selected-project-id")}get projectManageLabel(){return this.getAttribute("project-manage-label")||t("프로젝트 관리")}set projectManageLabel(e){this.setAttribute("project-manage-label",e)}get projectManageHref(){return this.getAttribute("project-manage-href")||""}set projectManageHref(e){e?this.setAttribute("project-manage-href",e):this.removeAttribute("project-manage-href")}get projectSectionLabel(){return this.getAttribute("project-section-label")||t("프로젝트")}set projectSectionLabel(e){this.setAttribute("project-section-label",e)}get projectEmptyLabel(){return this.getAttribute("project-empty-label")||t("프로젝트를 추가해 주세요")}set projectEmptyLabel(e){this.setAttribute("project-empty-label",e)}get projectEmptyTriggerLabel(){return this.getAttribute("project-empty-trigger-label")||t("프로젝트 추가")}set projectEmptyTriggerLabel(e){this.setAttribute("project-empty-trigger-label",e)}get bottomItems(){return this.parseBottomItems()}set bottomItems(e){this.setAttribute("bottom-items","string"==typeof e?e:JSON.stringify(e))}get bottomSections(){return this.parseBottomSections()}set bottomSections(e){this.setAttribute("bottom-sections","string"==typeof e?e:JSON.stringify(e))}get promoBanner(){return this.parsePromoBanner()}set promoBanner(e){null==e?this.removeAttribute("promo-banner"):this.setAttribute("promo-banner","string"==typeof e?e:JSON.stringify(e))}get updateBanner(){return this.parseUpdateBanner()}set updateBanner(e){null==e?this.removeAttribute("update-banner"):this.setAttribute("update-banner","string"==typeof e?e:JSON.stringify(e))}get headerType(){return"back"===this.getAttribute("header-type")?"back":"default"}set headerType(e){this.setAttribute("header-type",e)}get backLabel(){return this.getAttribute("back-label")||t("뒤로가기")}set backLabel(e){this.setAttribute("back-label",e)}get backHref(){return this.getAttribute("back-href")||""}set backHref(e){e?this.setAttribute("back-href",e):this.removeAttribute("back-href")}get panels(){return this.parsePanels()}set panels(e){this.setAttribute("panels","string"==typeof e?e:JSON.stringify(e))}get settingsSections(){return this.parseSettingsSections()}set settingsSections(e){this.setAttribute("settings-sections","string"==typeof e?e:JSON.stringify(e))}get activePanel(){const e=this.getAttribute("active-panel")||"main";return"main"===e?"main":this.findPanel(e)?e:"main"}set activePanel(e){const t=e&&"main"!==e&&this.findPanel(e)?e:"main";this.setAttribute("active-panel",t)}get panelMode(){const e=this.getAttribute("panel-mode")||"auto";return o.includes(e)?e:"auto"}set panelMode(e){this.setAttribute("panel-mode",o.includes(e)?e:"auto")}get panelWidth(){return this.normalizeCssLength(this.getAttribute("panel-width")||p)}set panelWidth(e){this.setAttribute("panel-width",this.normalizeCssLength(e))}get panelBreakpoint(){const e=Number(this.getAttribute("panel-breakpoint"));return Number.isFinite(e)&&e>0?e:1024}set panelBreakpoint(e){const t=Number.isFinite(e)&&e>0?Math.round(e):1024;this.setAttribute("panel-breakpoint",String(t))}normalizeCssLength(e){if("number"==typeof e)return`${Math.max(0,e)}px`;const t=String(e??"").trim();return t?/^-?\d+(?:\.\d+)?$/.test(t)?`${Math.max(0,Number(t))}px`:t:p}parseSettingsSections(){try{const e=JSON.parse(this.getAttribute("settings-sections")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parsePanels(){let e=[];const t=this.getAttribute("panels");if(t)try{const s=JSON.parse(t);Array.isArray(s)&&(e=s.filter(e=>Boolean(e&&"string"==typeof e.id&&e.id.trim())).map(e=>({...e,id:e.id.trim(),title:String(e.title||e.id).trim(),sections:Array.isArray(e.sections)?e.sections:[]})))}catch{e=[]}const s=this.parseSettingsSections();return s.length&&!e.some(e=>"settings"===e.id)&&e.push({id:"settings",title:"Settings",backLabel:this.backLabel,sections:s}),e}hasPanels(){return this.parsePanels().length>0}findPanel(e){return e&&"main"!==e?this.parsePanels().find(t=>t.id===e)??null:null}getActivePanelConfig(){return this.findPanel(this.getAttribute("active-panel")||"main")}parseSections(){const e=this.getAttribute("sections");if(e)try{const t=JSON.parse(e);if(Array.isArray(t)&&t.length)return t}catch{}try{const e=JSON.parse(this.getAttribute("items")||"[]");return[{id:"main",items:Array.isArray(e)?e:[]}]}catch{return[{id:"main",items:[]}]}}parseUserMenuItems(){try{const e=JSON.parse(this.getAttribute("user-menu-items")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parseUserProfile(){const e=this.getAttribute("user-profile");if(!e)return null;try{return JSON.parse(e)}catch{return null}}parseProjects(){try{const e=JSON.parse(this.getAttribute("projects")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parseBottomItems(){try{const e=JSON.parse(this.getAttribute("bottom-items")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parseBottomSections(){const e=this.getAttribute("bottom-sections");if(e)try{const t=JSON.parse(e);if(Array.isArray(t)&&t.length)return t}catch{}const t=this.parseBottomItems();return t.length?[{id:"bottom",items:t}]:[]}parsePromoBanner(){const e=this.getAttribute("promo-banner");if(!e)return null;try{return JSON.parse(e)}catch{return null}}parseUpdateBanner(){const e=this.getAttribute("update-banner");if(!e)return null;try{return JSON.parse(e)}catch{return null}}getSelectedProject(){const e=this.parseProjects();if(!e.length)return null;const t=this.selectedProjectId;return e.find(e=>e.id===t)||e[0]}bindOutsideClick(){this.outsideHandler||(this.outsideHandler=e=>{const t=e.target;if(this.contains(t))return;let s=!1;this.userMenuOpen&&(this.userMenuOpen=!1,this.userFlyoutItemId=null,s=!0),this.projectMenuOpen&&(this.projectMenuOpen=!1,s=!0),s&&this.render()},document.addEventListener("mousedown",this.outsideHandler))}closeOverlayMenus(){const e=this.projectMenuOpen,t=this.userMenuOpen;if(!e&&!t)return!1;this.projectMenuOpen=!1,this.userMenuOpen=!1,this.userFlyoutItemId=null,this.cancelUserFlyoutClose(),this.classList.remove("designbase-wc-sidebar--user-menu-open"),this.querySelector(".designbase-wc-sidebar__project-dropdown")?.remove(),this.querySelector(".designbase-wc-sidebar__project-selector")?.classList.remove("designbase-wc-sidebar__project-selector--open");const s=this.querySelector(".designbase-wc-sidebar__project-trigger");s?.setAttribute("aria-expanded","false");const i=this.querySelector(".designbase-wc-sidebar__user-dropdown");return i&&(i.hidden=!0),this.querySelector(".designbase-wc-sidebar__user-info")?.setAttribute("aria-expanded","false"),this.querySelector(".designbase-wc-sidebar__user-collapsed")?.setAttribute("aria-expanded","false"),this.querySelector(".designbase-wc-sidebar__user-collapsed")?.classList.remove("designbase-wc-sidebar__user-collapsed--open"),!0}syncAccordionState(){[...Array.from(this.querySelectorAll(".designbase-wc-sidebar__nav-list > .designbase-wc-sidebar__item > db-menu-item")),...Array.from(this.querySelectorAll(".designbase-wc-sidebar__bottom-nav .designbase-wc-sidebar__nav-list > .designbase-wc-sidebar__item > db-menu-item"))].forEach(e=>{const t=e.getAttribute("data-item-id");t&&(this.expandedItems.has(t)?e.setAttribute("expanded",""):e.removeAttribute("expanded"))})}unbindOutsideClick(){this.outsideHandler&&(document.removeEventListener("mousedown",this.outsideHandler),this.outsideHandler=null)}cancelFlyoutClose(){this.flyoutCloseTimer&&(clearTimeout(this.flyoutCloseTimer),this.flyoutCloseTimer=null)}showFlyout(e){this.cancelFlyoutClose(),this.flyoutItemId!==e&&(this.flyoutItemId=e,this.renderNav(),this.renderBottomNav())}scheduleFlyoutClose(){this.cancelFlyoutClose(),this.flyoutCloseTimer=setTimeout(()=>{this.flyoutCloseTimer=null,this.flyoutItemId=null,this.renderNav(),this.renderBottomNav()},120)}cancelUserFlyoutClose(){this.userFlyoutCloseTimer&&(clearTimeout(this.userFlyoutCloseTimer),this.userFlyoutCloseTimer=null)}setUserFlyout(e){this.cancelUserFlyoutClose(),this.userFlyoutItemId=e,this.querySelectorAll(".designbase-wc-sidebar__user-menu-item").forEach(t=>{const s=Boolean(e&&t.dataset.itemId===e);t.classList.toggle("designbase-wc-sidebar__user-menu-item--flyout-active",s),t.querySelector(".designbase-wc-sidebar__user-menu-trigger")?.setAttribute("aria-expanded",String(s));const i=t.querySelector(".designbase-wc-sidebar__user-flyout");i&&(i.hidden=!s)})}scheduleUserFlyoutClose(){this.cancelUserFlyoutClose(),this.userFlyoutCloseTimer=setTimeout(()=>{this.userFlyoutCloseTimer=null,this.setUserFlyout(null)},120)}get sidebarType(){const e=this.getAttribute("type");return d.find(t=>t===e)||"app"}syncHostClasses(){const e=this.getAttribute("size")||"m",t=this.getAttribute("theme")||"default",s=this.getAttribute("variant")||"default",i=this.getAttribute("position")||"left",a=this.getActivePanelConfig(),n=Boolean(a),r=this.panelWidth;this.style.setProperty("--db-sidebar-panel-width",r),this.className=["designbase-wc-sidebar",`designbase-wc-sidebar--type-${this.sidebarType}`,`designbase-wc-sidebar--${c.includes(e)?e:"m"}`,`designbase-wc-sidebar--${l.includes(t)?t:"default"}`,`designbase-wc-sidebar--${u.includes(i)?i:"left"}`,`designbase-wc-sidebar--panel-${this.resolvedPanelMode}`,b.includes(s)&&"wrapper"===s&&"designbase-wc-sidebar--wrapper",this.hasAttribute("collapsed")&&"designbase-wc-sidebar--collapsed",this.hasAttribute("full-height")&&"designbase-wc-sidebar--full-height",this.hasAttribute("shadow")&&"designbase-wc-sidebar--shadow",this.userMenuOpen&&"designbase-wc-sidebar--user-menu-open",("back"===this.headerType||n&&"replace"===this.resolvedPanelMode)&&"designbase-wc-sidebar--header-back",n&&"designbase-wc-sidebar--panel-open",this.hasPanels()&&"designbase-wc-sidebar--has-panels"].filter(Boolean).join(" ")}navigateToPanel(e){const t="main"!==e&&e?this.findPanel(e)?.id:"main";t&&this.activePanel!==t&&("main"!==t&&"replace"===this.resolvedPanelMode&&this.hasAttribute("collapsed")&&this.removeAttribute("collapsed"),this.setAttribute("active-panel",t))}dispatchItemClick(e){this.dispatchEvent(new CustomEvent("db-item-click",{bubbles:!0,composed:!0,detail:{item:e}}))}dispatchUserMenuItemClick(e){this.dispatchEvent(new CustomEvent("db-user-menu-item-click",{bubbles:!0,composed:!0,detail:{item:e}}))}dispatchBackClick(){const e=this.getActivePanelConfig();e&&this.navigateToPanel("main");const t=new CustomEvent("db-back-click",{bubbles:!0,composed:!0,cancelable:!0,detail:{label:e?.backLabel||this.backLabel,href:this.backHref,panel:e}});this.dispatchEvent(t);const s=n(this.backHref,"");t.defaultPrevented||e||!s||"back"!==this.headerType||window.location.assign(s)}dispatchProjectChange(e){this.dispatchEvent(new CustomEvent("db-project-change",{bubbles:!0,composed:!0,detail:{project:e}}))}dispatchProjectManage(){this.dispatchEvent(new CustomEvent("db-project-manage",{bubbles:!0,composed:!0,detail:{}}))}dispatchPromoCtaClick(e){this.dispatchEvent(new CustomEvent("db-promo-cta-click",{bubbles:!0,composed:!0,detail:{banner:e}}))}dispatchUpdateCtaClick(e){this.dispatchEvent(new CustomEvent("db-update-cta-click",{bubbles:!0,composed:!0,detail:{banner:e}}))}createProjectAvatar(e,t="s"){const s=document.createElement("db-avatar");if(s.className="designbase-wc-sidebar__project-avatar",s.setAttribute("size",t),s.setAttribute("initials",(e.label||"?").trim()),s.setAttribute("alt",e.label),e.color){const applyColor=()=>{const t=s.querySelector(".designbase-wc-avatar__initials");return!!t&&(t.style.backgroundColor=e.color,t.style.color="#fff",!0)},t=new MutationObserver(()=>{applyColor()&&t.disconnect()});t.observe(s,{childList:!0,subtree:!0}),queueMicrotask(()=>{applyColor()&&t.disconnect()})}return s}createProjectEmptyMark(e="s"){const t=document.createElement("span");return t.className=["designbase-wc-sidebar__project-mark",`designbase-wc-sidebar__project-mark--${e}`,"designbase-wc-sidebar__project-mark--empty"].join(" "),t.setAttribute("aria-hidden","true"),t.append(i("plus","m"===e?16:14)),t}createProjectBadge(e){if(!e.badge)return null;const t=document.createElement("db-badge");return t.className="designbase-wc-sidebar__project-badge",t.setAttribute("size","s"),t.setAttribute("variant",e.badgeColor||"warning"),t.setAttribute("type","text"),t.textContent=e.badge,t}createProjectSelector(e){if(!this.hasAttribute("projects"))return null;const t=this.parseProjects(),s=0===t.length,a=this.getSelectedProject(),r=document.createElement("div");r.className=["designbase-wc-sidebar__project-selector",e&&"designbase-wc-sidebar__project-selector--collapsed",this.projectMenuOpen&&"designbase-wc-sidebar__project-selector--open",s&&"designbase-wc-sidebar__project-selector--empty"].filter(Boolean).join(" ");const o=this.getAttribute("project-section-label");if(!e&&o&&o.trim()){const e=document.createElement("div");e.className="designbase-wc-sidebar__project-section-label",e.textContent=o.trim(),r.append(e)}const d=document.createElement("button");if(d.type="button",d.className="designbase-wc-sidebar__project-trigger",d.setAttribute("aria-haspopup","menu"),d.setAttribute("aria-expanded",String(this.projectMenuOpen)),s||!a){if(d.dataset.projectEmptyTrigger="",d.setAttribute("aria-label",this.projectEmptyTriggerLabel),d.append(this.createProjectEmptyMark(e?"m":"s")),!e){const e=document.createElement("span");e.className="designbase-wc-sidebar__project-label",e.textContent=this.projectEmptyTriggerLabel,d.append(e)}}else if(d.setAttribute("aria-label",a.label),d.append(this.createProjectAvatar(a,e?"m":"s")),!e){const e=document.createElement("span");e.className="designbase-wc-sidebar__project-label",e.textContent=a.label,d.append(e)}const c=document.createElement("span");if(c.className="designbase-wc-sidebar__project-chevron",c.setAttribute("aria-hidden","true"),c.append(i("chevron-down",14)),d.append(c),d.addEventListener("click",()=>{this.projectMenuOpen=!this.projectMenuOpen,this.userMenuOpen=!1,this.render()}),r.append(d),this.projectMenuOpen){const e=document.createElement("div");if(e.className="designbase-wc-sidebar__project-dropdown",e.setAttribute("role","menu"),e.setAttribute("aria-label",this.projectSectionLabel),s){const t=document.createElement("div");t.className="designbase-wc-sidebar__project-empty",t.setAttribute("role","presentation");const s=document.createElement("p");s.className="designbase-wc-sidebar__project-empty-text",s.textContent=this.projectEmptyLabel,t.append(s),e.append(t)}else{const s=document.createElement("ul");s.className="designbase-wc-sidebar__project-list",t.forEach(e=>{const t=document.createElement("li");t.className="designbase-wc-sidebar__project-option";const i=document.createElement("button");i.type="button",i.className=["designbase-wc-sidebar__project-option-btn",a&&e.id===a.id&&"designbase-wc-sidebar__project-option-btn--active"].filter(Boolean).join(" "),i.setAttribute("role","menuitem"),i.append(this.createProjectAvatar(e,"s"));const n=document.createElement("span");n.className="designbase-wc-sidebar__project-option-label",n.textContent=e.label,i.append(n);const r=this.createProjectBadge(e);r&&i.append(r),i.addEventListener("click",()=>{this.projectMenuOpen=!1,this.setAttribute("selected-project-id",e.id),this.dispatchProjectChange(e),this.render()}),t.append(i),s.append(t)}),e.append(s)}const o=document.createElement("button");o.type="button",o.className="designbase-wc-sidebar__project-manage",o.setAttribute("role","menuitem"),o.append(i("plus",14));const d=document.createElement("span");d.textContent=this.projectManageLabel,o.append(d),o.addEventListener("click",()=>{this.projectMenuOpen=!1;const e=this.projectManageHref,t=n(e,"");t&&window.location.assign(t),this.dispatchProjectManage(),this.render()}),e.append(o),r.append(e)}return r}createFlyout(e,t){const i=this.getAttribute("position")||"left",a=document.createElement("div");a.className=["designbase-wc-sidebar__flyout","right"===i&&"designbase-wc-sidebar__flyout--align-left"].filter(Boolean).join(" "),a.setAttribute("role","menu"),a.setAttribute("aria-label",s("{0} 하위 메뉴",[e.label])),a.addEventListener("mouseenter",()=>this.cancelFlyoutClose()),a.addEventListener("mouseleave",()=>this.scheduleFlyoutClose());const r=document.createElement("div");r.className="designbase-wc-sidebar__flyout-title",r.textContent=e.label,a.append(r);const o=document.createElement("ul");return o.className="designbase-wc-sidebar__flyout-list",(e.children||[]).forEach(e=>{const s=document.createElement("li");s.className="designbase-wc-sidebar__flyout-item";const i=document.createElement("db-menu-item");i.setAttribute("label",e.label),i.setAttribute("type","block"),i.setAttribute("menu-style","dropdown"),i.setAttribute("size",t);const a=n(e.href,"");a&&i.setAttribute("href",a),e.active&&i.setAttribute("active",""),e.disabled&&i.setAttribute("disabled",""),void 0!==e.badge&&i.setAttribute("badge",String(e.badge)),e.badgeColor&&i.setAttribute("badge-color",e.badgeColor),i.addEventListener("db-click",()=>{e.disabled||(this.flyoutItemId=null,this.dispatchItemClick(e),this.renderNav(),this.renderBottomNav())}),s.append(i),o.append(s)}),a.append(o),a}createSidebarMenuItem(e,t,s=0){const i=Boolean(e.children?.length),a=this.expandedItems.has(e.id),r=this.hasAttribute("collapsed"),o=r&&i,d=document.createElement("li");d.className=["designbase-wc-sidebar__item",o&&this.flyoutItemId===e.id&&"designbase-wc-sidebar__item--flyout-active"].filter(Boolean).join(" "),o&&(d.addEventListener("mouseenter",()=>this.showFlyout(e.id)),d.addEventListener("mouseleave",()=>this.scheduleFlyoutClose()));const c=document.createElement("db-menu-item");c.setAttribute("data-item-id",e.id),c.setAttribute("label",e.label),c.setAttribute("type","block"),c.setAttribute("menu-style","accordion"),c.setAttribute("size",t),c.setAttribute("depth",String(s));const l=n(e.href,"");if(l&&c.setAttribute("href",l),e.icon&&c.setAttribute("icon",e.icon),(e.active||e.openPanel&&e.openPanel===this.activePanel)&&c.setAttribute("active",""),e.disabled&&c.setAttribute("disabled",""),void 0!==e.badge&&c.setAttribute("badge",String(e.badge)),e.badgeColor&&c.setAttribute("badge-color",e.badgeColor),i&&!o&&(c.setAttribute("expandable",""),c.subItems=(e.children||[]).map(e=>({id:e.id,label:e.label,href:e.href,active:e.active,disabled:e.disabled,badge:e.badge,badgeColor:e.badgeColor,icon:e.icon})),a&&!r&&c.setAttribute("expanded","")),c.addEventListener("db-click",t=>{if(!e.disabled){if(i&&!r){const s=t.detail?.expanded??!this.expandedItems.has(e.id);return this.closeOverlayMenus(),s?("single"===this.accordionMode&&this.expandedItems.clear(),this.expandedItems.add(e.id)):this.expandedItems.delete(e.id),this.expandedIds=[...this.expandedItems],this.syncAccordionState(),this.dispatchEvent(new CustomEvent("db-expanded-change",{detail:{itemId:e.id,expanded:s,expandedIds:this.expandedIds},bubbles:!0,composed:!0})),void("app"!==this.sidebarType&&this.dispatchItemClick(e))}if(o)return this.closeOverlayMenus(),void this.showFlyout(e.id);if(this.closeOverlayMenus(),e.openPanel&&this.findPanel(e.openPanel))return this.dispatchItemClick(e),void this.navigateToPanel(e.openPanel);this.dispatchItemClick(e)}}),c.addEventListener("db-child-click",e=>{const t=e.detail;this.dispatchItemClick(t.child)}),d.append(c),r&&void 0!==e.badge&&null!==e.badge&&""!==e.badge){const t=e.badgeColor||"primary",s=document.createElement("span");s.className=["designbase-wc-sidebar__collapsed-badge-dot",`designbase-wc-sidebar__collapsed-badge-dot--${t}`].join(" "),s.setAttribute("aria-hidden","true"),d.append(s)}if(r&&!i){const t=document.createElement("span");t.className="designbase-wc-sidebar__item-tooltip",t.textContent=e.label,t.setAttribute("role","tooltip"),d.append(t)}return o&&this.flyoutItemId===e.id&&d.append(this.createFlyout(e,t)),d}renderSectionList(e,t,s){const i=document.createDocumentFragment();return e.forEach(e=>{const a=document.createElement("div");if(a.className=["designbase-wc-sidebar__section",e.gap&&`designbase-wc-sidebar__section--gap-${e.gap}`].filter(Boolean).join(" "),!s&&e.title){const t=document.createElement("div");t.className="designbase-wc-sidebar__section-title",t.textContent=e.title,a.append(t)}const n=document.createElement("ul");n.className="designbase-wc-sidebar__nav-list",e.items.forEach(e=>n.append(this.createSidebarMenuItem(e,t))),a.append(n),i.append(a)}),i}renderNav(){const e=this.getAttribute("size")||"m",t=this.hasAttribute("collapsed"),s=this.querySelector('.designbase-wc-sidebar__nav[data-panel-nav="main"]');s&&s.replaceChildren(this.renderSectionList(this.parseSections(),e,t),this.createCustomNavSlot("nav"));const i=this.getActivePanelConfig(),a=this.querySelector('.designbase-wc-sidebar__nav[data-panel-nav="panel"]');a&&i&&a.replaceChildren(this.renderSectionList(i.sections,e,!1))}renderBottomNav(){const e=this.querySelector(".designbase-wc-sidebar__bottom-nav");if(!e)return;const t=this.getAttribute("size")||"m",s=this.hasAttribute("collapsed");e.replaceChildren(this.renderSectionList(this.parseBottomSections(),t,s))}createUserDropdown(e,r=!1){if(!e.length)return null;const o=this.getAttribute("position")||"left",d=document.createElement("div");d.className=["designbase-wc-sidebar__user-dropdown",r&&"designbase-wc-sidebar__user-dropdown--collapsed"].filter(Boolean).join(" "),d.setAttribute("role","menu"),d.setAttribute("aria-label",t("사용자 메뉴")),d.hidden=!this.userMenuOpen,d.addEventListener("keydown",e=>{"Escape"===e.key&&(e.stopPropagation(),this.userFlyoutItemId?this.setUserFlyout(null):(this.userMenuOpen=!1,this.render()))});const c=document.createElement("ul");return c.className="designbase-wc-sidebar__user-menu",e.forEach(e=>{const t=Boolean(e.children?.length),r=document.createElement("li");r.dataset.itemId=e.id,r.className=["designbase-wc-sidebar__user-menu-item",e.dividerBefore&&"designbase-wc-sidebar__user-menu-item--divider",e.disabled&&"designbase-wc-sidebar__user-menu-item--disabled",t&&"designbase-wc-sidebar__user-menu-item--has-children"].filter(Boolean).join(" ");const d=document.createElement("button");if(d.type="button",d.className="designbase-wc-sidebar__user-menu-trigger",d.setAttribute("role","menuitem"),d.disabled=Boolean(e.disabled),e.icon&&a(e.icon)){const t=document.createElement("span");t.className="designbase-wc-sidebar__user-menu-icon",t.setAttribute("aria-hidden","true"),t.append(i(e.icon,16)),d.append(t)}const l=document.createElement("span");if(l.className="designbase-wc-sidebar__user-menu-label",l.textContent=e.label,d.append(l),e.value){const t=document.createElement("span");t.className="designbase-wc-sidebar__user-menu-value",t.textContent=e.value,d.append(t)}if(t){const t=document.createElement("span");t.className="designbase-wc-sidebar__user-menu-chevron",t.setAttribute("aria-hidden","true"),t.append(i("right"===o?"chevron-left":"chevron-right",16)),d.append(t),d.setAttribute("aria-haspopup","menu"),d.setAttribute("aria-expanded",String(this.userFlyoutItemId===e.id));const openFlyout=()=>this.setUserFlyout(e.id);r.addEventListener("mouseenter",openFlyout),r.addEventListener("mouseleave",()=>this.scheduleUserFlyoutClose()),r.addEventListener("focusin",openFlyout),r.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&r.contains(t)||this.scheduleUserFlyoutClose()}),d.addEventListener("click",openFlyout);const c=document.createElement("div");c.className=["designbase-wc-sidebar__user-flyout","right"===o&&"designbase-wc-sidebar__user-flyout--align-left"].filter(Boolean).join(" "),c.setAttribute("role","menu"),c.setAttribute("aria-label",s("{0} 하위 메뉴",[e.label])),c.hidden=this.userFlyoutItemId!==e.id,c.addEventListener("mouseenter",()=>this.cancelUserFlyoutClose()),c.addEventListener("mouseleave",()=>this.scheduleUserFlyoutClose());const l=document.createElement("ul");l.className="designbase-wc-sidebar__user-flyout-list",(e.children||[]).forEach(e=>{const t=document.createElement("li");t.className="designbase-wc-sidebar__user-flyout-item";const s=document.createElement("button");if(s.type="button",s.className=["designbase-wc-sidebar__user-menu-trigger","designbase-wc-sidebar__user-flyout-trigger",e.selected&&"designbase-wc-sidebar__user-flyout-trigger--selected"].filter(Boolean).join(" "),s.setAttribute("role","menuitemradio"),s.setAttribute("aria-checked",String(Boolean(e.selected))),s.disabled=Boolean(e.disabled),e.icon&&a(e.icon)){const t=document.createElement("span");t.className="designbase-wc-sidebar__user-menu-icon",t.setAttribute("aria-hidden","true"),t.append(i(e.icon,16)),s.append(t)}const r=document.createElement("span");if(r.className="designbase-wc-sidebar__user-menu-label",r.textContent=e.label,s.append(r),e.selected){const e=document.createElement("span");e.className="designbase-wc-sidebar__user-menu-check",e.setAttribute("aria-hidden","true"),e.append(i("done",16)),s.append(e)}s.addEventListener("click",()=>{if(e.disabled)return;this.userFlyoutItemId=null,this.userMenuOpen=!1,this.dispatchUserMenuItemClick(e);const t=n(e.href,"");t&&window.location.assign(t),this.render()}),t.append(s),l.append(t)}),c.append(l),r.append(d,c)}else d.addEventListener("click",()=>{if(e.disabled)return;this.userFlyoutItemId=null,this.userMenuOpen=!1,this.dispatchUserMenuItemClick(e);const t=n(e.href,"");t&&window.location.assign(t),this.render()}),r.append(d);c.append(r)}),d.append(c),d}createUpdateBanner(e){if("back"===this.headerType)return null;const t=this.parseUpdateBanner();if(!t)return null;if(e)return null;const s=document.createElement("div");s.className="designbase-wc-sidebar__update";const i=document.createElement("db-banner");return i.className="designbase-wc-sidebar__update-banner",i.setAttribute("size","s"),i.setAttribute("variant",t.variant||"outline"),i.setAttribute("title",t.title),t.description&&i.setAttribute("description",t.description),t.icon&&i.setAttribute("icon",t.icon),i.setAttribute("clickable",""),i.setAttribute("aria-label",t.ctaLabel||t.title),i.addEventListener("db-click",()=>{const e=n(t.ctaHref,"");e&&window.location.assign(e),this.dispatchUpdateCtaClick(t)}),s.append(i),s}createPromoBanner(e){if("back"===this.headerType)return null;const t=this.parsePromoBanner();if(!t)return null;if(e){const e=document.createElement("button");e.type="button",e.className="designbase-wc-sidebar__promo-collapsed",e.setAttribute("aria-label",t.ctaLabel||t.title);const s=document.createElement("db-animation-background");s.className="designbase-wc-sidebar__promo-bg",s.setAttribute("type","aurora"),s.setAttribute("theme","light"),s.setAttribute("intensity","subtle"),s.setAttribute("blur","40"),s.setAttribute("speed","4000"),s.setAttribute("colors",JSON.stringify(["#c7d2fe","#ddd6fe","#fbcfe8"])),e.append(s),e.append(i(t.icon&&a(t.icon)?t.icon:"sparkle",18)),e.addEventListener("click",()=>this.dispatchPromoCtaClick(t));const n=document.createElement("span");n.className="designbase-wc-sidebar__item-tooltip",n.textContent=t.title,n.setAttribute("role","tooltip");const r=document.createElement("div");return r.className="designbase-wc-sidebar__promo-collapsed-wrap",r.append(e,n),r}const s=document.createElement("div");s.className="designbase-wc-sidebar__promo";const r=document.createElement("db-animation-background");r.className="designbase-wc-sidebar__promo-bg",r.setAttribute("type","aurora"),r.setAttribute("theme","light"),r.setAttribute("intensity","subtle"),r.setAttribute("blur","60"),r.setAttribute("speed","5000"),r.setAttribute("colors",JSON.stringify(["#c7d2fe","#ddd6fe","#fbcfe8","#bfdbfe"])),s.append(r);const o=document.createElement("div");o.className="designbase-wc-sidebar__promo-content";const d=document.createElement("div");d.className="designbase-wc-sidebar__promo-title-row";const c=document.createElement("span");c.className="designbase-wc-sidebar__promo-icon",c.setAttribute("aria-hidden","true"),c.append(i(t.icon&&a(t.icon)?t.icon:"sparkle",16));const l=document.createElement("div");if(l.className="designbase-wc-sidebar__promo-title",l.textContent=t.title,d.append(c,l),o.append(d),t.description){const e=document.createElement("div");e.className="designbase-wc-sidebar__promo-desc",e.textContent=t.description,o.append(e)}if(t.ctaLabel){const e=document.createElement("db-button");e.className="designbase-wc-sidebar__promo-action",e.setAttribute("variant","secondary"),e.setAttribute("size","s"),e.setAttribute("full-width",""),e.textContent=t.ctaLabel,e.addEventListener("db-click",()=>{const e=n(t.ctaHref,"");e&&window.location.assign(e),this.dispatchPromoCtaClick(t)}),o.append(e)}return s.append(o),s}createMainHeader(e){const{size:s,collapsible:a,showLogo:n,collapsed:r}=e,o="back"===this.headerType,d="l"===s?"m":"s"===s?"xs":"s";if(!o&&!a&&(!n||r))return null;const c=document.createElement("div");if(c.className=["designbase-wc-sidebar__header",(r||!n)&&!o&&"designbase-wc-sidebar__header--collapsed-only",o&&"designbase-wc-sidebar__header--back"].filter(Boolean).join(" "),o){const e=document.createElement("button");if(e.type="button",e.className=["designbase-wc-sidebar__back",r&&"designbase-wc-sidebar__back--collapsed"].filter(Boolean).join(" "),e.setAttribute("aria-label",this.backLabel),e.append(i("chevron-left",18)),!r){const t=document.createElement("span");t.textContent=this.backLabel,e.append(t)}e.addEventListener("click",()=>this.dispatchBackClick()),c.append(e)}else if(!r&&n){const e=document.createElement("div");e.className="designbase-wc-sidebar__logo";const s=this.getAttribute("logo-type")||"designbase",i=this.getAttribute("logo-text")||"",a=this.getAttribute("logo-src");if(a){const s=document.createElement("db-logo");s.setAttribute("type","custom"),s.setAttribute("src",a),s.setAttribute("alt",this.getAttribute("logo-alt")||t("홈")),s.setAttribute("size",d),e.append(s)}else if("custom"===s&&i){const t=document.createElement("span");t.className="designbase-wc-sidebar__logo-text",t.textContent=i,e.append(t)}else{const t=document.createElement("db-logo");t.setAttribute("type",s),t.setAttribute("size",d),i&&t.setAttribute("text",i),e.append(t)}e.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-logo-click",{bubbles:!0,composed:!0}))}),c.append(e)}if(a&&!o){const e=document.createElement("db-button");e.className="designbase-wc-sidebar__toggle",e.setAttribute("variant","tertiary"),e.setAttribute("size","s"),e.setAttribute("icon-only",""),e.setAttribute("start-icon",r?"arrow-bar-right":"arrow-bar-left"),e.setAttribute("aria-label",t(r?"사이드바 펼치기":"사이드바 접기")),e.addEventListener("db-click",()=>{const e=!this.hasAttribute("collapsed");e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),this.dispatchEvent(new CustomEvent("db-toggle",{bubbles:!0,composed:!0,detail:{collapsed:e}}))}),c.append(e)}return c}createPanelHeader(e){const t="replace"===this.resolvedPanelMode,s=document.createElement("div");if(s.className=["designbase-wc-sidebar__panel-header",t&&"designbase-wc-sidebar__panel-header--replace"].filter(Boolean).join(" "),t){const t=document.createElement("button");t.type="button",t.className="designbase-wc-sidebar__panel-back",t.setAttribute("aria-label",e.backLabel||this.backLabel),t.append(i("chevron-left",18)),t.addEventListener("click",()=>this.dispatchBackClick()),s.append(t)}const a=document.createElement("div");a.className="designbase-wc-sidebar__panel-heading";const n=document.createElement("div");if(n.className="designbase-wc-sidebar__panel-title",n.textContent=e.title,a.append(n),e.description){const t=document.createElement("div");t.className="designbase-wc-sidebar__panel-description",t.textContent=e.description,a.append(t)}return s.append(a),s}createNavWrapper(e){const{mode:s,collapsed:i,includeProjects:a,includeBottom:n,panel:r}=e,o=document.createElement("div");if(o.className="designbase-wc-sidebar__nav-wrapper",a){const e=this.createProjectSelector(i);e&&o.append(e)}"main"===s&&o.append(this.createCustomNavSlot("nav-top"));const d=document.createElement("nav");if(d.className="designbase-wc-sidebar__nav",d.setAttribute("data-panel-nav",s),r&&(d.dataset.panelId=r.id),d.setAttribute("aria-label",r?.ariaLabel||r?.title||t("주 메뉴")),o.append(d),"main"===s&&o.append(this.createCustomNavSlot("nav-bottom")),n){const e=document.createElement("nav");e.className="designbase-wc-sidebar__bottom-nav",e.setAttribute("aria-label",t("하단 메뉴")),o.append(e)}return o}createFooter(e){const{collapsed:t,userProfile:s,userMenuItems:a}=e,n=document.createElement("div");n.className="designbase-wc-sidebar__footer";const r=this.createUpdateBanner(t);r&&n.append(r);const o=this.createPromoBanner(t);if(o&&n.append(o),s&&!t){const e=document.createElement("div");e.className="designbase-wc-sidebar__user";const t=this.createUserDropdown(a);t&&e.append(t);const r=document.createElement("div");r.className="designbase-wc-sidebar__user-info",r.setAttribute("role","button"),r.setAttribute("tabindex","0"),r.setAttribute("aria-expanded",String(this.userMenuOpen));const o=document.createElement("db-avatar");o.className="designbase-wc-sidebar__user-avatar",o.setAttribute("size","s"),o.setAttribute("initials",s.name),o.setAttribute("alt",s.name),s.avatar&&o.setAttribute("src",s.avatar);const d=document.createElement("div");d.className="designbase-wc-sidebar__user-details";const c=document.createElement("div");if(c.className="designbase-wc-sidebar__user-name",c.textContent=s.name,d.append(c),s.email){const e=document.createElement("div");e.className="designbase-wc-sidebar__user-email",e.textContent=s.email,d.append(e)}if(r.append(o,d),a.length){const e=document.createElement("span");e.className="designbase-wc-sidebar__user-more",e.setAttribute("aria-hidden","true"),e.append(i("more-vertical",16)),r.append(e),r.setAttribute("aria-haspopup","menu")}r.addEventListener("click",()=>{a.length&&(this.userMenuOpen=!this.userMenuOpen,this.userFlyoutItemId=null,this.cancelUserFlyoutClose(),this.projectMenuOpen=!1,this.render())}),r.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r.click())}),e.append(r),n.append(e)}else if(s&&t){const e=document.createElement("div");e.className=["designbase-wc-sidebar__user-collapsed",this.userMenuOpen&&"designbase-wc-sidebar__user-collapsed--open"].filter(Boolean).join(" "),e.setAttribute("role","button"),e.setAttribute("tabindex","0"),e.setAttribute("aria-label",s.name),e.setAttribute("aria-expanded",String(this.userMenuOpen)),a.length&&e.setAttribute("aria-haspopup","menu");const t=document.createElement("db-avatar");if(t.className="designbase-wc-sidebar__user-avatar-collapsed",t.setAttribute("size","s"),t.setAttribute("initials",s.name),t.setAttribute("alt",s.name),s.avatar&&t.setAttribute("src",s.avatar),e.append(t),!this.userMenuOpen){const t=document.createElement("span");t.className="designbase-wc-sidebar__item-tooltip",t.textContent=s.name,t.setAttribute("role","tooltip"),e.append(t)}const i=this.createUserDropdown(a,!0);i&&e.append(i),e.addEventListener("click",e=>{a.length&&(e.target.closest(".designbase-wc-sidebar__user-dropdown")||(this.userMenuOpen=!this.userMenuOpen,this.userFlyoutItemId=null,this.cancelUserFlyoutClose(),this.projectMenuOpen=!1,this.render()))}),e.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e.click())}),n.append(e)}return n}render(){const e=this.getActivePanelConfig();this.syncHostClasses(),this.setAttribute("role","complementary"),this.syncAccessibleName();const t=this.getAttribute("size")||"m",s="false"!==(this.getAttribute("collapsible")??("app"===this.sidebarType?"true":"false")),i="false"!==(this.getAttribute("show-logo")??("app"===this.sidebarType?"true":"false")),a=this.hasAttribute("collapsed"),n=this.parseUserProfile(),r=this.parseUserMenuItems(),o=this.parseBottomSections(),d=this.collectCustomNavSlots(),c=Boolean(e),l="replace"===this.resolvedPanelMode;this.replaceChildren();const u=document.createElement("div");u.className="designbase-wc-sidebar__container";const b=document.createElement("div");b.className="designbase-wc-sidebar__panel-viewport";const p=document.createElement("div");p.className="designbase-wc-sidebar__panel-track",p.dataset.active=c&&l?"main":c?"panel":"main";const m=document.createElement("div");m.className=["designbase-wc-sidebar__panel-slide","designbase-wc-sidebar__panel-slide--main"].join(" "),m.dataset.panel="main";const h=c&&l;m.toggleAttribute("inert",h),m.setAttribute("aria-hidden",String(h));const g=this.createMainHeader({size:t,collapsible:s,showLogo:i,collapsed:a});if(g&&m.append(g),m.append(this.createNavWrapper({mode:"main",collapsed:a,includeProjects:"back"!==this.headerType,includeBottom:o.length>0})),m.append(this.createFooter({collapsed:a,userProfile:n,userMenuItems:r})),p.append(m),e){const t=document.createElement("div");t.className=["designbase-wc-sidebar__panel-slide","designbase-wc-sidebar__panel-slide--secondary"].join(" "),t.dataset.panel=e.id,t.setAttribute("aria-hidden","false"),t.append(this.createPanelHeader(e)),t.append(this.createNavWrapper({mode:"panel",collapsed:!1,includeProjects:!1,includeBottom:!1,panel:e})),p.append(t)}b.append(p),u.append(b),this.append(u),this.renderNav(),this.renderBottomNav(),this.projectCustomNavSlots(d),c&&l&&requestAnimationFrame(()=>{this.isConnected&&this.activePanel===e?.id&&(p.dataset.active="panel")})}}customElements.get("db-sidebar")||customElements.define("db-sidebar",DbSidebar);export{DbSidebar};
1
+ import"./db-avatar.js";import"./db-badge.js";import"./db-menu-item.js";import"./db-banner.js";import"./db-animation-background.js";import"./db-button.js";import"./db-logo.js";import{subscribeDbLocale as e,dbText as t,dbFormat as s}from"../core/i18n.js";import{createDbIcon as i,isDbIconName as a}from"./db-icons.js";import{sanitizeHref as n}from"../core/safe-url.js";import{SIDEBAR_CUSTOM_NAV_SLOTS as r,SIDEBAR_PANEL_MODES as o,SIDEBAR_TYPES as d,SIDEBAR_SIZES as c,SIDEBAR_THEMES as l,SIDEBAR_POSITIONS as u,SIDEBAR_VARIANTS as b}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";const p="240px";class DbSidebar extends HTMLElement{constructor(){super(...arguments),this.expandedItems=new Set,this.userMenuOpen=!1,this.projectMenuOpen=!1,this.flyoutItemId=null,this.userFlyoutItemId=null,this.flyoutCloseTimer=null,this.userFlyoutCloseTimer=null,this.outsideHandler=null,this.panelMediaQuery=null,this.panelMediaHandler=null,this.resolvedPanelMode="adjacent"}collectCustomNavSlots(){const e=new Map;return r.forEach(t=>{const s=Array.from(this.children).filter(e=>e instanceof HTMLElement&&e.getAttribute("slot")===t),i=Array.from(this.querySelectorAll(`[data-sidebar-slot="${t}"]`)).flatMap(e=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.getAttribute("slot")===t));e.set(t,[...new Set([...s,...i])])}),e}createCustomNavSlot(e){const t=document.createElement("div");return t.className=["designbase-wc-sidebar__custom-slot",`designbase-wc-sidebar__custom-slot--${e}`].join(" "),t.dataset.sidebarSlot=e,t}projectCustomNavSlots(e){r.forEach(t=>{const s=this.querySelector(`[data-sidebar-slot="${t}"]`),i=e.get(t)??[];s&&0!==i.length?s.append(...i):s?.remove()})}static get observedAttributes(){return["type","logo-src","logo-alt","items","sections","user-menu-items","user-profile","default-expanded-ids","expanded-ids","accordion-mode","projects","selected-project-id","project-manage-label","project-manage-href","project-section-label","project-empty-label","project-empty-trigger-label","bottom-items","bottom-sections","promo-banner","update-banner","header-type","back-label","back-href","panels","settings-sections","active-panel","panel-mode","panel-width","panel-breakpoint","size","theme","variant","position","collapsed","collapsible","show-logo","logo-type","logo-text","full-height","shadow"]}connectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=e(()=>{this.syncAccessibleName(),this.querySelectorAll("[data-panel-nav]:not([data-panel-id])").forEach(e=>e.setAttribute("aria-label",t("주 메뉴"))),this.querySelectorAll(".designbase-wc-sidebar__bottom-nav").forEach(e=>e.setAttribute("aria-label",t("하단 메뉴"))),this.querySelector(".designbase-wc-sidebar__toggle")?.setAttribute("aria-label",t(this.hasAttribute("collapsed")?"사이드바 펼치기":"사이드바 접기"));const e=this.querySelector("[data-project-empty-trigger]");if(e){e.setAttribute("aria-label",this.projectEmptyTriggerLabel);const t=e.querySelector(".designbase-wc-sidebar__project-label");t&&(t.textContent=this.projectEmptyTriggerLabel)}this.querySelector(".designbase-wc-sidebar__project-dropdown")?.setAttribute("aria-label",this.projectSectionLabel);const s=this.querySelector(".designbase-wc-sidebar__project-empty-text");s&&(s.textContent=this.projectEmptyLabel);const i=this.querySelector(".designbase-wc-sidebar__project-manage span");i&&(i.textContent=this.projectManageLabel);const a=this.querySelector(".designbase-wc-sidebar__back");if(a){a.setAttribute("aria-label",this.backLabel);const e=a.querySelector("span");e&&(e.textContent=this.backLabel)}this.querySelector(".designbase-wc-sidebar__user-dropdown")?.setAttribute("aria-label",t("사용자 메뉴"));const n=this.querySelector(".designbase-wc-sidebar__logo db-logo");n&&n.setAttribute("alt",this.getAttribute("logo-alt")||t("홈"))}),this.seedExpanded(),this.bindPanelMediaQuery(),this.render(),this.bindOutsideClick()}syncAccessibleName(){const e=this.getAttribute("aria-label");e&&e!==this.autoAriaLabel||(this.autoAriaLabel=t("사이드바 네비게이션"),this.setAttribute("aria-label",this.autoAriaLabel))}disconnectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=void 0,this.unbindOutsideClick(),this.unbindPanelMediaQuery(),this.cancelFlyoutClose(),this.cancelUserFlyoutClose()}attributeChangedCallback(e,t,s){if(this.isConnected&&t!==s){if("default-expanded-ids"===e||"expanded-ids"===e||"accordion-mode"===e)return this.seedExpanded(),void this.syncAccordionState();if("collapsed"===e&&this.hasAttribute("collapsed")&&(this.userMenuOpen=!1,this.projectMenuOpen=!1,this.flyoutItemId=null,this.userFlyoutItemId=null,this.cancelFlyoutClose(),this.cancelUserFlyoutClose()),"panel-mode"!==e&&"panel-breakpoint"!==e||this.bindPanelMediaQuery(),this.render(),"active-panel"===e){const e=this.getActivePanelConfig();this.dispatchEvent(new CustomEvent("db-panel-change",{bubbles:!0,composed:!0,detail:{panel:e?.id??"main",panelConfig:e,mode:this.resolvedPanelMode}}))}}}bindPanelMediaQuery(){this.unbindPanelMediaQuery();const e=this.panelMode;if("auto"!==e)return void(this.resolvedPanelMode=e);if("undefined"==typeof window||"function"!=typeof window.matchMedia)return void(this.resolvedPanelMode="adjacent");const t=window.matchMedia(`(min-width: ${this.panelBreakpoint}px)`);this.panelMediaQuery=t,this.resolvedPanelMode=t.matches?"adjacent":"replace",this.panelMediaHandler=e=>{const t=e.matches?"adjacent":"replace";t!==this.resolvedPanelMode&&(this.resolvedPanelMode=t,this.render(),this.dispatchEvent(new CustomEvent("db-panel-mode-change",{bubbles:!0,composed:!0,detail:{mode:t}})))},t.addEventListener("change",this.panelMediaHandler)}unbindPanelMediaQuery(){this.panelMediaQuery&&this.panelMediaHandler&&this.panelMediaQuery.removeEventListener("change",this.panelMediaHandler),this.panelMediaQuery=null,this.panelMediaHandler=null}seedExpanded(){try{const e=JSON.parse(this.getAttribute("expanded-ids")??this.getAttribute("default-expanded-ids")??"[]"),t=Array.isArray(e)?[...new Set(e.filter(e=>"string"==typeof e))]:[];this.expandedItems=new Set("single"===this.accordionMode?t.slice(0,1):t)}catch{this.expandedItems=new Set}}get expandedIds(){return[...this.expandedItems]}set expandedIds(e){this.setAttribute("expanded-ids","string"==typeof e?e:JSON.stringify(e)),this.isConnected||this.seedExpanded()}get accordionMode(){return"multiple"===this.getAttribute("accordion-mode")?"multiple":"single"}set accordionMode(e){this.setAttribute("accordion-mode",e)}get hideExpandIcon(){return this.hasAttribute("hide-expand-icon")&&"false"!==this.getAttribute("hide-expand-icon")}set hideExpandIcon(e){this.toggleAttribute("hide-expand-icon",e)}get showDepthGuide(){return this.hasAttribute("show-depth-guide")&&"false"!==this.getAttribute("show-depth-guide")}set showDepthGuide(e){this.toggleAttribute("show-depth-guide",e)}get items(){try{const e=JSON.parse(this.getAttribute("items")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}set items(e){this.setAttribute("items","string"==typeof e?e:JSON.stringify(e))}get sections(){return this.parseSections()}set sections(e){this.setAttribute("sections","string"==typeof e?e:JSON.stringify(e))}get userMenuItems(){return this.parseUserMenuItems()}set userMenuItems(e){this.setAttribute("user-menu-items","string"==typeof e?e:JSON.stringify(e))}get userProfile(){return this.parseUserProfile()}set userProfile(e){null==e?this.removeAttribute("user-profile"):this.setAttribute("user-profile","string"==typeof e?e:JSON.stringify(e))}get projects(){return this.parseProjects()}set projects(e){this.setAttribute("projects","string"==typeof e?e:JSON.stringify(e))}get selectedProjectId(){return this.getAttribute("selected-project-id")||""}set selectedProjectId(e){e?this.setAttribute("selected-project-id",e):this.removeAttribute("selected-project-id")}get projectManageLabel(){return this.getAttribute("project-manage-label")||t("프로젝트 관리")}set projectManageLabel(e){this.setAttribute("project-manage-label",e)}get projectManageHref(){return this.getAttribute("project-manage-href")||""}set projectManageHref(e){e?this.setAttribute("project-manage-href",e):this.removeAttribute("project-manage-href")}get projectSectionLabel(){return this.getAttribute("project-section-label")||t("프로젝트")}set projectSectionLabel(e){this.setAttribute("project-section-label",e)}get projectEmptyLabel(){return this.getAttribute("project-empty-label")||t("프로젝트를 추가해 주세요")}set projectEmptyLabel(e){this.setAttribute("project-empty-label",e)}get projectEmptyTriggerLabel(){return this.getAttribute("project-empty-trigger-label")||t("프로젝트 추가")}set projectEmptyTriggerLabel(e){this.setAttribute("project-empty-trigger-label",e)}get bottomItems(){return this.parseBottomItems()}set bottomItems(e){this.setAttribute("bottom-items","string"==typeof e?e:JSON.stringify(e))}get bottomSections(){return this.parseBottomSections()}set bottomSections(e){this.setAttribute("bottom-sections","string"==typeof e?e:JSON.stringify(e))}get promoBanner(){return this.parsePromoBanner()}set promoBanner(e){null==e?this.removeAttribute("promo-banner"):this.setAttribute("promo-banner","string"==typeof e?e:JSON.stringify(e))}get updateBanner(){return this.parseUpdateBanner()}set updateBanner(e){null==e?this.removeAttribute("update-banner"):this.setAttribute("update-banner","string"==typeof e?e:JSON.stringify(e))}get headerType(){return"back"===this.getAttribute("header-type")?"back":"default"}set headerType(e){this.setAttribute("header-type",e)}get backLabel(){return this.getAttribute("back-label")||t("뒤로가기")}set backLabel(e){this.setAttribute("back-label",e)}get backHref(){return this.getAttribute("back-href")||""}set backHref(e){e?this.setAttribute("back-href",e):this.removeAttribute("back-href")}get panels(){return this.parsePanels()}set panels(e){this.setAttribute("panels","string"==typeof e?e:JSON.stringify(e))}get settingsSections(){return this.parseSettingsSections()}set settingsSections(e){this.setAttribute("settings-sections","string"==typeof e?e:JSON.stringify(e))}get activePanel(){const e=this.getAttribute("active-panel")||"main";return"main"===e?"main":this.findPanel(e)?e:"main"}set activePanel(e){const t=e&&"main"!==e&&this.findPanel(e)?e:"main";this.setAttribute("active-panel",t)}get panelMode(){const e=this.getAttribute("panel-mode")||"auto";return o.includes(e)?e:"auto"}set panelMode(e){this.setAttribute("panel-mode",o.includes(e)?e:"auto")}get panelWidth(){return this.normalizeCssLength(this.getAttribute("panel-width")||p)}set panelWidth(e){this.setAttribute("panel-width",this.normalizeCssLength(e))}get panelBreakpoint(){const e=Number(this.getAttribute("panel-breakpoint"));return Number.isFinite(e)&&e>0?e:1024}set panelBreakpoint(e){const t=Number.isFinite(e)&&e>0?Math.round(e):1024;this.setAttribute("panel-breakpoint",String(t))}normalizeCssLength(e){if("number"==typeof e)return`${Math.max(0,e)}px`;const t=String(e??"").trim();return t?/^-?\d+(?:\.\d+)?$/.test(t)?`${Math.max(0,Number(t))}px`:t:p}parseSettingsSections(){try{const e=JSON.parse(this.getAttribute("settings-sections")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parsePanels(){let e=[];const t=this.getAttribute("panels");if(t)try{const s=JSON.parse(t);Array.isArray(s)&&(e=s.filter(e=>Boolean(e&&"string"==typeof e.id&&e.id.trim())).map(e=>({...e,id:e.id.trim(),title:String(e.title||e.id).trim(),sections:Array.isArray(e.sections)?e.sections:[]})))}catch{e=[]}const s=this.parseSettingsSections();return s.length&&!e.some(e=>"settings"===e.id)&&e.push({id:"settings",title:"Settings",backLabel:this.backLabel,sections:s}),e}hasPanels(){return this.parsePanels().length>0}findPanel(e){return e&&"main"!==e?this.parsePanels().find(t=>t.id===e)??null:null}getActivePanelConfig(){return this.findPanel(this.getAttribute("active-panel")||"main")}parseSections(){const e=this.getAttribute("sections");if(e)try{const t=JSON.parse(e);if(Array.isArray(t)&&t.length)return t}catch{}try{const e=JSON.parse(this.getAttribute("items")||"[]");return[{id:"main",items:Array.isArray(e)?e:[]}]}catch{return[{id:"main",items:[]}]}}parseUserMenuItems(){try{const e=JSON.parse(this.getAttribute("user-menu-items")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parseUserProfile(){const e=this.getAttribute("user-profile");if(!e)return null;try{return JSON.parse(e)}catch{return null}}parseProjects(){try{const e=JSON.parse(this.getAttribute("projects")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parseBottomItems(){try{const e=JSON.parse(this.getAttribute("bottom-items")||"[]");return Array.isArray(e)?e:[]}catch{return[]}}parseBottomSections(){const e=this.getAttribute("bottom-sections");if(e)try{const t=JSON.parse(e);if(Array.isArray(t)&&t.length)return t}catch{}const t=this.parseBottomItems();return t.length?[{id:"bottom",items:t}]:[]}parsePromoBanner(){const e=this.getAttribute("promo-banner");if(!e)return null;try{return JSON.parse(e)}catch{return null}}parseUpdateBanner(){const e=this.getAttribute("update-banner");if(!e)return null;try{return JSON.parse(e)}catch{return null}}getSelectedProject(){const e=this.parseProjects();if(!e.length)return null;const t=this.selectedProjectId;return e.find(e=>e.id===t)||e[0]}bindOutsideClick(){this.outsideHandler||(this.outsideHandler=e=>{const t=e.target;if(this.contains(t))return;let s=!1;this.userMenuOpen&&(this.userMenuOpen=!1,this.userFlyoutItemId=null,s=!0),this.projectMenuOpen&&(this.projectMenuOpen=!1,s=!0),s&&this.render()},document.addEventListener("mousedown",this.outsideHandler))}closeOverlayMenus(){const e=this.projectMenuOpen,t=this.userMenuOpen;if(!e&&!t)return!1;this.projectMenuOpen=!1,this.userMenuOpen=!1,this.userFlyoutItemId=null,this.cancelUserFlyoutClose(),this.classList.remove("designbase-wc-sidebar--user-menu-open"),this.querySelector(".designbase-wc-sidebar__project-dropdown")?.remove(),this.querySelector(".designbase-wc-sidebar__project-selector")?.classList.remove("designbase-wc-sidebar__project-selector--open");const s=this.querySelector(".designbase-wc-sidebar__project-trigger");s?.setAttribute("aria-expanded","false");const i=this.querySelector(".designbase-wc-sidebar__user-dropdown");return i&&(i.hidden=!0),this.querySelector(".designbase-wc-sidebar__user-info")?.setAttribute("aria-expanded","false"),this.querySelector(".designbase-wc-sidebar__user-collapsed")?.setAttribute("aria-expanded","false"),this.querySelector(".designbase-wc-sidebar__user-collapsed")?.classList.remove("designbase-wc-sidebar__user-collapsed--open"),!0}syncAccordionState(){[...Array.from(this.querySelectorAll(".designbase-wc-sidebar__nav-list > .designbase-wc-sidebar__item > db-menu-item")),...Array.from(this.querySelectorAll(".designbase-wc-sidebar__bottom-nav .designbase-wc-sidebar__nav-list > .designbase-wc-sidebar__item > db-menu-item"))].forEach(e=>{const t=e.getAttribute("data-item-id");t&&(this.expandedItems.has(t)?e.setAttribute("expanded",""):e.removeAttribute("expanded"))})}unbindOutsideClick(){this.outsideHandler&&(document.removeEventListener("mousedown",this.outsideHandler),this.outsideHandler=null)}cancelFlyoutClose(){this.flyoutCloseTimer&&(clearTimeout(this.flyoutCloseTimer),this.flyoutCloseTimer=null)}showFlyout(e){this.cancelFlyoutClose(),this.flyoutItemId!==e&&(this.flyoutItemId=e,this.renderNav(),this.renderBottomNav())}scheduleFlyoutClose(){this.cancelFlyoutClose(),this.flyoutCloseTimer=setTimeout(()=>{this.flyoutCloseTimer=null,this.flyoutItemId=null,this.renderNav(),this.renderBottomNav()},120)}cancelUserFlyoutClose(){this.userFlyoutCloseTimer&&(clearTimeout(this.userFlyoutCloseTimer),this.userFlyoutCloseTimer=null)}setUserFlyout(e){this.cancelUserFlyoutClose(),this.userFlyoutItemId=e,this.querySelectorAll(".designbase-wc-sidebar__user-menu-item").forEach(t=>{const s=Boolean(e&&t.dataset.itemId===e);t.classList.toggle("designbase-wc-sidebar__user-menu-item--flyout-active",s),t.querySelector(".designbase-wc-sidebar__user-menu-trigger")?.setAttribute("aria-expanded",String(s));const i=t.querySelector(".designbase-wc-sidebar__user-flyout");i&&(i.hidden=!s)})}scheduleUserFlyoutClose(){this.cancelUserFlyoutClose(),this.userFlyoutCloseTimer=setTimeout(()=>{this.userFlyoutCloseTimer=null,this.setUserFlyout(null)},120)}get sidebarType(){const e=this.getAttribute("type");return d.find(t=>t===e)||"app"}syncHostClasses(){const e=this.getAttribute("size")||"m",t=this.getAttribute("theme")||"default",s=this.getAttribute("variant")||"default",i=this.getAttribute("position")||"left",a=this.getActivePanelConfig(),n=Boolean(a),r=this.panelWidth;this.style.setProperty("--db-sidebar-panel-width",r),this.className=["designbase-wc-sidebar",`designbase-wc-sidebar--type-${this.sidebarType}`,`designbase-wc-sidebar--${c.includes(e)?e:"m"}`,`designbase-wc-sidebar--${l.includes(t)?t:"default"}`,`designbase-wc-sidebar--${u.includes(i)?i:"left"}`,`designbase-wc-sidebar--panel-${this.resolvedPanelMode}`,b.includes(s)&&"wrapper"===s&&"designbase-wc-sidebar--wrapper",this.hasAttribute("collapsed")&&"designbase-wc-sidebar--collapsed",this.hasAttribute("full-height")&&"designbase-wc-sidebar--full-height",this.hasAttribute("shadow")&&"designbase-wc-sidebar--shadow",this.userMenuOpen&&"designbase-wc-sidebar--user-menu-open",("back"===this.headerType||n&&"replace"===this.resolvedPanelMode)&&"designbase-wc-sidebar--header-back",n&&"designbase-wc-sidebar--panel-open",this.hasPanels()&&"designbase-wc-sidebar--has-panels"].filter(Boolean).join(" ")}navigateToPanel(e){const t="main"!==e&&e?this.findPanel(e)?.id:"main";t&&this.activePanel!==t&&("main"!==t&&"replace"===this.resolvedPanelMode&&this.hasAttribute("collapsed")&&this.removeAttribute("collapsed"),this.setAttribute("active-panel",t))}dispatchItemClick(e){this.dispatchEvent(new CustomEvent("db-item-click",{bubbles:!0,composed:!0,detail:{item:e}}))}dispatchUserMenuItemClick(e){this.dispatchEvent(new CustomEvent("db-user-menu-item-click",{bubbles:!0,composed:!0,detail:{item:e}}))}dispatchBackClick(){const e=this.getActivePanelConfig();e&&this.navigateToPanel("main");const t=new CustomEvent("db-back-click",{bubbles:!0,composed:!0,cancelable:!0,detail:{label:e?.backLabel||this.backLabel,href:this.backHref,panel:e}});this.dispatchEvent(t);const s=n(this.backHref,"");t.defaultPrevented||e||!s||"back"!==this.headerType||window.location.assign(s)}dispatchProjectChange(e){this.dispatchEvent(new CustomEvent("db-project-change",{bubbles:!0,composed:!0,detail:{project:e}}))}dispatchProjectManage(){this.dispatchEvent(new CustomEvent("db-project-manage",{bubbles:!0,composed:!0,detail:{}}))}dispatchPromoCtaClick(e){this.dispatchEvent(new CustomEvent("db-promo-cta-click",{bubbles:!0,composed:!0,detail:{banner:e}}))}dispatchUpdateCtaClick(e){this.dispatchEvent(new CustomEvent("db-update-cta-click",{bubbles:!0,composed:!0,detail:{banner:e}}))}createProjectAvatar(e,t="s"){const s=document.createElement("db-avatar");if(s.className="designbase-wc-sidebar__project-avatar",s.setAttribute("size",t),s.setAttribute("initials",(e.label||"?").trim()),s.setAttribute("alt",e.label),e.color){const applyColor=()=>{const t=s.querySelector(".designbase-wc-avatar__initials");return!!t&&(t.style.backgroundColor=e.color,t.style.color="#fff",!0)},t=new MutationObserver(()=>{applyColor()&&t.disconnect()});t.observe(s,{childList:!0,subtree:!0}),queueMicrotask(()=>{applyColor()&&t.disconnect()})}return s}createProjectEmptyMark(e="s"){const t=document.createElement("span");return t.className=["designbase-wc-sidebar__project-mark",`designbase-wc-sidebar__project-mark--${e}`,"designbase-wc-sidebar__project-mark--empty"].join(" "),t.setAttribute("aria-hidden","true"),t.append(i("plus","m"===e?16:14)),t}createProjectBadge(e){if(!e.badge)return null;const t=document.createElement("db-badge");return t.className="designbase-wc-sidebar__project-badge",t.setAttribute("size","s"),t.setAttribute("variant",e.badgeColor||"warning"),t.setAttribute("type","text"),t.textContent=e.badge,t}createProjectSelector(e){if(!this.hasAttribute("projects"))return null;const t=this.parseProjects(),s=0===t.length,a=this.getSelectedProject(),r=document.createElement("div");r.className=["designbase-wc-sidebar__project-selector",e&&"designbase-wc-sidebar__project-selector--collapsed",this.projectMenuOpen&&"designbase-wc-sidebar__project-selector--open",s&&"designbase-wc-sidebar__project-selector--empty"].filter(Boolean).join(" ");const o=this.getAttribute("project-section-label");if(!e&&o&&o.trim()){const e=document.createElement("div");e.className="designbase-wc-sidebar__project-section-label",e.textContent=o.trim(),r.append(e)}const d=document.createElement("button");if(d.type="button",d.className="designbase-wc-sidebar__project-trigger",d.setAttribute("aria-haspopup","menu"),d.setAttribute("aria-expanded",String(this.projectMenuOpen)),s||!a){if(d.dataset.projectEmptyTrigger="",d.setAttribute("aria-label",this.projectEmptyTriggerLabel),d.append(this.createProjectEmptyMark(e?"m":"s")),!e){const e=document.createElement("span");e.className="designbase-wc-sidebar__project-label",e.textContent=this.projectEmptyTriggerLabel,d.append(e)}}else if(d.setAttribute("aria-label",a.label),d.append(this.createProjectAvatar(a,e?"m":"s")),!e){const e=document.createElement("span");e.className="designbase-wc-sidebar__project-label",e.textContent=a.label,d.append(e)}const c=document.createElement("span");if(c.className="designbase-wc-sidebar__project-chevron",c.setAttribute("aria-hidden","true"),c.append(i("chevron-down",14)),d.append(c),d.addEventListener("click",()=>{this.projectMenuOpen=!this.projectMenuOpen,this.userMenuOpen=!1,this.render()}),r.append(d),this.projectMenuOpen){const e=document.createElement("div");if(e.className="designbase-wc-sidebar__project-dropdown",e.setAttribute("role","menu"),e.setAttribute("aria-label",this.projectSectionLabel),s){const t=document.createElement("div");t.className="designbase-wc-sidebar__project-empty",t.setAttribute("role","presentation");const s=document.createElement("p");s.className="designbase-wc-sidebar__project-empty-text",s.textContent=this.projectEmptyLabel,t.append(s),e.append(t)}else{const s=document.createElement("ul");s.className="designbase-wc-sidebar__project-list",t.forEach(e=>{const t=document.createElement("li");t.className="designbase-wc-sidebar__project-option";const i=document.createElement("button");i.type="button",i.className=["designbase-wc-sidebar__project-option-btn",a&&e.id===a.id&&"designbase-wc-sidebar__project-option-btn--active"].filter(Boolean).join(" "),i.setAttribute("role","menuitem"),i.append(this.createProjectAvatar(e,"s"));const n=document.createElement("span");n.className="designbase-wc-sidebar__project-option-label",n.textContent=e.label,i.append(n);const r=this.createProjectBadge(e);r&&i.append(r),i.addEventListener("click",()=>{this.projectMenuOpen=!1,this.setAttribute("selected-project-id",e.id),this.dispatchProjectChange(e),this.render()}),t.append(i),s.append(t)}),e.append(s)}const o=document.createElement("button");o.type="button",o.className="designbase-wc-sidebar__project-manage",o.setAttribute("role","menuitem"),o.append(i("plus",14));const d=document.createElement("span");d.textContent=this.projectManageLabel,o.append(d),o.addEventListener("click",()=>{this.projectMenuOpen=!1;const e=this.projectManageHref,t=n(e,"");t&&window.location.assign(t),this.dispatchProjectManage(),this.render()}),e.append(o),r.append(e)}return r}createFlyout(e,t){const i=this.getAttribute("position")||"left",a=document.createElement("div");a.className=["designbase-wc-sidebar__flyout","right"===i&&"designbase-wc-sidebar__flyout--align-left"].filter(Boolean).join(" "),a.setAttribute("role","menu"),a.setAttribute("aria-label",s("{0} 하위 메뉴",[e.label])),a.addEventListener("mouseenter",()=>this.cancelFlyoutClose()),a.addEventListener("mouseleave",()=>this.scheduleFlyoutClose());const r=document.createElement("div");r.className="designbase-wc-sidebar__flyout-title",r.textContent=e.label,a.append(r);const o=document.createElement("ul");return o.className="designbase-wc-sidebar__flyout-list",(e.children||[]).forEach(e=>{const s=document.createElement("li");s.className="designbase-wc-sidebar__flyout-item";const i=document.createElement("db-menu-item");i.setAttribute("label",e.label),i.setAttribute("type","block"),i.setAttribute("menu-style","dropdown"),i.setAttribute("size",t);const a=n(e.href,"");a&&i.setAttribute("href",a),e.active&&i.setAttribute("active",""),e.disabled&&i.setAttribute("disabled",""),void 0!==e.badge&&i.setAttribute("badge",String(e.badge)),e.badgeColor&&i.setAttribute("badge-color",e.badgeColor),i.addEventListener("db-click",()=>{e.disabled||(this.flyoutItemId=null,this.dispatchItemClick(e),this.renderNav(),this.renderBottomNav())}),s.append(i),o.append(s)}),a.append(o),a}createSidebarMenuItem(e,t,s=0){const i=Boolean(e.children?.length),a=this.expandedItems.has(e.id),r=this.hasAttribute("collapsed"),o=r&&i,d=document.createElement("li");d.className=["designbase-wc-sidebar__item",o&&this.flyoutItemId===e.id&&"designbase-wc-sidebar__item--flyout-active"].filter(Boolean).join(" "),o&&(d.addEventListener("mouseenter",()=>this.showFlyout(e.id)),d.addEventListener("mouseleave",()=>this.scheduleFlyoutClose()));const c=document.createElement("db-menu-item");c.setAttribute("data-item-id",e.id),c.setAttribute("label",e.label),c.setAttribute("type","block"),c.setAttribute("menu-style","accordion"),c.setAttribute("size",t),c.setAttribute("depth",String(s));const l=n(e.href,"");if(l&&c.setAttribute("href",l),e.icon&&c.setAttribute("icon",e.icon),(e.active||e.openPanel&&e.openPanel===this.activePanel)&&c.setAttribute("active",""),e.disabled&&c.setAttribute("disabled",""),void 0!==e.badge&&c.setAttribute("badge",String(e.badge)),e.badgeColor&&c.setAttribute("badge-color",e.badgeColor),i&&!o&&(c.setAttribute("expandable",""),c.subItems=(e.children||[]).map(e=>({id:e.id,label:e.label,href:e.href,active:e.active,disabled:e.disabled,badge:e.badge,badgeColor:e.badgeColor,icon:e.icon})),a&&!r&&c.setAttribute("expanded","")),c.addEventListener("db-click",t=>{if(!e.disabled){if(i&&!r){const s=t.detail?.expanded??!this.expandedItems.has(e.id);return this.closeOverlayMenus(),s?("single"===this.accordionMode&&this.expandedItems.clear(),this.expandedItems.add(e.id)):this.expandedItems.delete(e.id),this.expandedIds=[...this.expandedItems],this.syncAccordionState(),this.dispatchEvent(new CustomEvent("db-expanded-change",{detail:{itemId:e.id,expanded:s,expandedIds:this.expandedIds},bubbles:!0,composed:!0})),void("app"!==this.sidebarType&&this.dispatchItemClick(e))}if(o)return this.closeOverlayMenus(),void this.showFlyout(e.id);if(this.closeOverlayMenus(),e.openPanel&&this.findPanel(e.openPanel))return this.dispatchItemClick(e),void this.navigateToPanel(e.openPanel);this.dispatchItemClick(e)}}),c.addEventListener("db-child-click",e=>{const t=e.detail;this.dispatchItemClick(t.child)}),d.append(c),r&&void 0!==e.badge&&null!==e.badge&&""!==e.badge){const t=e.badgeColor||"primary",s=document.createElement("span");s.className=["designbase-wc-sidebar__collapsed-badge-dot",`designbase-wc-sidebar__collapsed-badge-dot--${t}`].join(" "),s.setAttribute("aria-hidden","true"),d.append(s)}if(r&&!i){const t=document.createElement("span");t.className="designbase-wc-sidebar__item-tooltip",t.textContent=e.label,t.setAttribute("role","tooltip"),d.append(t)}return o&&this.flyoutItemId===e.id&&d.append(this.createFlyout(e,t)),d}renderSectionList(e,t,s){const i=document.createDocumentFragment();return e.forEach(e=>{const a=document.createElement("div");if(a.className=["designbase-wc-sidebar__section",e.gap&&`designbase-wc-sidebar__section--gap-${e.gap}`].filter(Boolean).join(" "),!s&&e.title){const t=document.createElement("div");t.className="designbase-wc-sidebar__section-title",t.textContent=e.title,a.append(t)}const n=document.createElement("ul");n.className="designbase-wc-sidebar__nav-list",e.items.forEach(e=>n.append(this.createSidebarMenuItem(e,t))),a.append(n),i.append(a)}),i}renderNav(){const e=this.getAttribute("size")||"m",t=this.hasAttribute("collapsed"),s=this.querySelector('.designbase-wc-sidebar__nav[data-panel-nav="main"]');s&&s.replaceChildren(this.renderSectionList(this.parseSections(),e,t),this.createCustomNavSlot("nav"));const i=this.getActivePanelConfig(),a=this.querySelector('.designbase-wc-sidebar__nav[data-panel-nav="panel"]');a&&i&&a.replaceChildren(this.renderSectionList(i.sections,e,!1))}renderBottomNav(){const e=this.querySelector(".designbase-wc-sidebar__bottom-nav");if(!e)return;const t=this.getAttribute("size")||"m",s=this.hasAttribute("collapsed");e.replaceChildren(this.renderSectionList(this.parseBottomSections(),t,s))}createUserDropdown(e,r=!1){if(!e.length)return null;const o=this.getAttribute("position")||"left",d=document.createElement("div");d.className=["designbase-wc-sidebar__user-dropdown",r&&"designbase-wc-sidebar__user-dropdown--collapsed"].filter(Boolean).join(" "),d.setAttribute("role","menu"),d.setAttribute("aria-label",t("사용자 메뉴")),d.hidden=!this.userMenuOpen,d.addEventListener("keydown",e=>{"Escape"===e.key&&(e.stopPropagation(),this.userFlyoutItemId?this.setUserFlyout(null):(this.userMenuOpen=!1,this.render()))});const c=document.createElement("ul");return c.className="designbase-wc-sidebar__user-menu",e.forEach(e=>{const t=Boolean(e.children?.length),r=document.createElement("li");r.dataset.itemId=e.id,r.className=["designbase-wc-sidebar__user-menu-item",e.dividerBefore&&"designbase-wc-sidebar__user-menu-item--divider",e.disabled&&"designbase-wc-sidebar__user-menu-item--disabled",t&&"designbase-wc-sidebar__user-menu-item--has-children"].filter(Boolean).join(" ");const d=document.createElement("button");if(d.type="button",d.className="designbase-wc-sidebar__user-menu-trigger",d.setAttribute("role","menuitem"),d.disabled=Boolean(e.disabled),e.icon&&a(e.icon)){const t=document.createElement("span");t.className="designbase-wc-sidebar__user-menu-icon",t.setAttribute("aria-hidden","true"),t.append(i(e.icon,16)),d.append(t)}const l=document.createElement("span");if(l.className="designbase-wc-sidebar__user-menu-label",l.textContent=e.label,d.append(l),e.value){const t=document.createElement("span");t.className="designbase-wc-sidebar__user-menu-value",t.textContent=e.value,d.append(t)}if(t){const t=document.createElement("span");t.className="designbase-wc-sidebar__user-menu-chevron",t.setAttribute("aria-hidden","true"),t.append(i("right"===o?"chevron-left":"chevron-right",16)),d.append(t),d.setAttribute("aria-haspopup","menu"),d.setAttribute("aria-expanded",String(this.userFlyoutItemId===e.id));const openFlyout=()=>this.setUserFlyout(e.id);r.addEventListener("mouseenter",openFlyout),r.addEventListener("mouseleave",()=>this.scheduleUserFlyoutClose()),r.addEventListener("focusin",openFlyout),r.addEventListener("focusout",e=>{const t=e.relatedTarget;t&&r.contains(t)||this.scheduleUserFlyoutClose()}),d.addEventListener("click",openFlyout);const c=document.createElement("div");c.className=["designbase-wc-sidebar__user-flyout","right"===o&&"designbase-wc-sidebar__user-flyout--align-left"].filter(Boolean).join(" "),c.setAttribute("role","menu"),c.setAttribute("aria-label",s("{0} 하위 메뉴",[e.label])),c.hidden=this.userFlyoutItemId!==e.id,c.addEventListener("mouseenter",()=>this.cancelUserFlyoutClose()),c.addEventListener("mouseleave",()=>this.scheduleUserFlyoutClose());const l=document.createElement("ul");l.className="designbase-wc-sidebar__user-flyout-list",(e.children||[]).forEach(e=>{const t=document.createElement("li");t.className="designbase-wc-sidebar__user-flyout-item";const s=document.createElement("button");if(s.type="button",s.className=["designbase-wc-sidebar__user-menu-trigger","designbase-wc-sidebar__user-flyout-trigger",e.selected&&"designbase-wc-sidebar__user-flyout-trigger--selected"].filter(Boolean).join(" "),s.setAttribute("role","menuitemradio"),s.setAttribute("aria-checked",String(Boolean(e.selected))),s.disabled=Boolean(e.disabled),e.icon&&a(e.icon)){const t=document.createElement("span");t.className="designbase-wc-sidebar__user-menu-icon",t.setAttribute("aria-hidden","true"),t.append(i(e.icon,16)),s.append(t)}const r=document.createElement("span");if(r.className="designbase-wc-sidebar__user-menu-label",r.textContent=e.label,s.append(r),e.selected){const e=document.createElement("span");e.className="designbase-wc-sidebar__user-menu-check",e.setAttribute("aria-hidden","true"),e.append(i("done",16)),s.append(e)}s.addEventListener("click",()=>{if(e.disabled)return;this.userFlyoutItemId=null,this.userMenuOpen=!1,this.dispatchUserMenuItemClick(e);const t=n(e.href,"");t&&window.location.assign(t),this.render()}),t.append(s),l.append(t)}),c.append(l),r.append(d,c)}else d.addEventListener("click",()=>{if(e.disabled)return;this.userFlyoutItemId=null,this.userMenuOpen=!1,this.dispatchUserMenuItemClick(e);const t=n(e.href,"");t&&window.location.assign(t),this.render()}),r.append(d);c.append(r)}),d.append(c),d}createUpdateBanner(e){if("back"===this.headerType)return null;const t=this.parseUpdateBanner();if(!t)return null;if(e)return null;const s=document.createElement("div");s.className="designbase-wc-sidebar__update";const i=document.createElement("db-banner");return i.className="designbase-wc-sidebar__update-banner",i.setAttribute("size","s"),i.setAttribute("variant",t.variant||"outline"),i.setAttribute("title",t.title),t.description&&i.setAttribute("description",t.description),t.icon&&i.setAttribute("icon",t.icon),i.setAttribute("clickable",""),i.setAttribute("aria-label",t.ctaLabel||t.title),i.addEventListener("db-click",()=>{const e=n(t.ctaHref,"");e&&window.location.assign(e),this.dispatchUpdateCtaClick(t)}),s.append(i),s}createPromoBanner(e){if("back"===this.headerType)return null;const t=this.parsePromoBanner();if(!t)return null;if(e){const e=document.createElement("button");e.type="button",e.className="designbase-wc-sidebar__promo-collapsed",e.setAttribute("aria-label",t.ctaLabel||t.title);const s=document.createElement("db-animation-background");s.className="designbase-wc-sidebar__promo-bg",s.setAttribute("type","aurora"),s.setAttribute("theme","light"),s.setAttribute("intensity","subtle"),s.setAttribute("blur","40"),s.setAttribute("speed","4000"),s.setAttribute("colors",JSON.stringify(["#c7d2fe","#ddd6fe","#fbcfe8"])),e.append(s),e.append(i(t.icon&&a(t.icon)?t.icon:"sparkle",18)),e.addEventListener("click",()=>this.dispatchPromoCtaClick(t));const n=document.createElement("span");n.className="designbase-wc-sidebar__item-tooltip",n.textContent=t.title,n.setAttribute("role","tooltip");const r=document.createElement("div");return r.className="designbase-wc-sidebar__promo-collapsed-wrap",r.append(e,n),r}const s=document.createElement("div");s.className="designbase-wc-sidebar__promo";const r=document.createElement("db-animation-background");r.className="designbase-wc-sidebar__promo-bg",r.setAttribute("type","aurora"),r.setAttribute("theme","light"),r.setAttribute("intensity","subtle"),r.setAttribute("blur","60"),r.setAttribute("speed","5000"),r.setAttribute("colors",JSON.stringify(["#c7d2fe","#ddd6fe","#fbcfe8","#bfdbfe"])),s.append(r);const o=document.createElement("div");o.className="designbase-wc-sidebar__promo-content";const d=document.createElement("div");d.className="designbase-wc-sidebar__promo-title-row";const c=document.createElement("span");c.className="designbase-wc-sidebar__promo-icon",c.setAttribute("aria-hidden","true"),c.append(i(t.icon&&a(t.icon)?t.icon:"sparkle",16));const l=document.createElement("div");if(l.className="designbase-wc-sidebar__promo-title",l.textContent=t.title,d.append(c,l),o.append(d),t.description){const e=document.createElement("div");e.className="designbase-wc-sidebar__promo-desc",e.textContent=t.description,o.append(e)}if(t.ctaLabel){const e=document.createElement("db-button");e.className="designbase-wc-sidebar__promo-action",e.setAttribute("variant","secondary"),e.setAttribute("size","s"),e.setAttribute("full-width",""),e.textContent=t.ctaLabel,e.addEventListener("db-click",()=>{const e=n(t.ctaHref,"");e&&window.location.assign(e),this.dispatchPromoCtaClick(t)}),o.append(e)}return s.append(o),s}createMainHeader(e){const{size:s,collapsible:a,showLogo:n,collapsed:r}=e,o="back"===this.headerType,d="l"===s?"m":"s"===s?"xs":"s";if(!o&&!a&&(!n||r))return null;const c=document.createElement("div");if(c.className=["designbase-wc-sidebar__header",(r||!n)&&!o&&"designbase-wc-sidebar__header--collapsed-only",o&&"designbase-wc-sidebar__header--back"].filter(Boolean).join(" "),o){const e=document.createElement("button");if(e.type="button",e.className=["designbase-wc-sidebar__back",r&&"designbase-wc-sidebar__back--collapsed"].filter(Boolean).join(" "),e.setAttribute("aria-label",this.backLabel),e.append(i("chevron-left",18)),!r){const t=document.createElement("span");t.textContent=this.backLabel,e.append(t)}e.addEventListener("click",()=>this.dispatchBackClick()),c.append(e)}else if(!r&&n){const e=document.createElement("div");e.className="designbase-wc-sidebar__logo";const s=this.getAttribute("logo-type")||"designbase",i=this.getAttribute("logo-text")||"",a=this.getAttribute("logo-src");if(a){const s=document.createElement("db-logo");s.setAttribute("type","custom"),s.setAttribute("src",a),s.setAttribute("alt",this.getAttribute("logo-alt")||t("홈")),s.setAttribute("size",d),e.append(s)}else if("custom"===s&&i){const t=document.createElement("span");t.className="designbase-wc-sidebar__logo-text",t.textContent=i,e.append(t)}else{const t=document.createElement("db-logo");t.setAttribute("type",s),t.setAttribute("size",d),i&&t.setAttribute("text",i),e.append(t)}e.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-logo-click",{bubbles:!0,composed:!0}))}),c.append(e)}if(a&&!o){const e=document.createElement("db-button");e.className="designbase-wc-sidebar__toggle",e.setAttribute("variant","tertiary"),e.setAttribute("size","s"),e.setAttribute("icon-only",""),e.setAttribute("start-icon",r?"arrow-bar-right":"arrow-bar-left"),e.setAttribute("aria-label",t(r?"사이드바 펼치기":"사이드바 접기")),e.addEventListener("db-click",()=>{const e=!this.hasAttribute("collapsed");e?this.setAttribute("collapsed",""):this.removeAttribute("collapsed"),this.dispatchEvent(new CustomEvent("db-toggle",{bubbles:!0,composed:!0,detail:{collapsed:e}}))}),c.append(e)}return c}createPanelHeader(e){const t="replace"===this.resolvedPanelMode,s=document.createElement("div");if(s.className=["designbase-wc-sidebar__panel-header",t&&"designbase-wc-sidebar__panel-header--replace"].filter(Boolean).join(" "),t){const t=document.createElement("button");t.type="button",t.className="designbase-wc-sidebar__panel-back",t.setAttribute("aria-label",e.backLabel||this.backLabel),t.append(i("chevron-left",18)),t.addEventListener("click",()=>this.dispatchBackClick()),s.append(t)}const a=document.createElement("div");a.className="designbase-wc-sidebar__panel-heading";const n=document.createElement("div");if(n.className="designbase-wc-sidebar__panel-title",n.textContent=e.title,a.append(n),e.description){const t=document.createElement("div");t.className="designbase-wc-sidebar__panel-description",t.textContent=e.description,a.append(t)}return s.append(a),s}createNavWrapper(e){const{mode:s,collapsed:i,includeProjects:a,includeBottom:n,panel:r}=e,o=document.createElement("div");if(o.className="designbase-wc-sidebar__nav-wrapper",a){const e=this.createProjectSelector(i);e&&o.append(e)}"main"===s&&o.append(this.createCustomNavSlot("nav-top"));const d=document.createElement("nav");if(d.className="designbase-wc-sidebar__nav",d.setAttribute("data-panel-nav",s),r&&(d.dataset.panelId=r.id),d.setAttribute("aria-label",r?.ariaLabel||r?.title||t("주 메뉴")),o.append(d),"main"===s&&o.append(this.createCustomNavSlot("nav-bottom")),n){const e=document.createElement("nav");e.className="designbase-wc-sidebar__bottom-nav",e.setAttribute("aria-label",t("하단 메뉴")),o.append(e)}return o}createFooter(e){const{collapsed:t,userProfile:s,userMenuItems:a}=e,n=document.createElement("div");n.className="designbase-wc-sidebar__footer";const r=this.createUpdateBanner(t);r&&n.append(r);const o=this.createPromoBanner(t);if(o&&n.append(o),s&&!t){const e=document.createElement("div");e.className="designbase-wc-sidebar__user";const t=this.createUserDropdown(a);t&&e.append(t);const r=document.createElement("div");r.className="designbase-wc-sidebar__user-info",r.setAttribute("role","button"),r.setAttribute("tabindex","0"),r.setAttribute("aria-expanded",String(this.userMenuOpen));const o=document.createElement("db-avatar");o.className="designbase-wc-sidebar__user-avatar",o.setAttribute("size","s"),o.setAttribute("initials",s.name),o.setAttribute("alt",s.name),s.avatar&&o.setAttribute("src",s.avatar);const d=document.createElement("div");d.className="designbase-wc-sidebar__user-details";const c=document.createElement("div");if(c.className="designbase-wc-sidebar__user-name",c.textContent=s.name,d.append(c),s.email){const e=document.createElement("div");e.className="designbase-wc-sidebar__user-email",e.textContent=s.email,d.append(e)}if(r.append(o,d),a.length){const e=document.createElement("span");e.className="designbase-wc-sidebar__user-more",e.setAttribute("aria-hidden","true"),e.append(i("more-vertical",16)),r.append(e),r.setAttribute("aria-haspopup","menu")}r.addEventListener("click",()=>{a.length&&(this.userMenuOpen=!this.userMenuOpen,this.userFlyoutItemId=null,this.cancelUserFlyoutClose(),this.projectMenuOpen=!1,this.render())}),r.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),r.click())}),e.append(r),n.append(e)}else if(s&&t){const e=document.createElement("div");e.className=["designbase-wc-sidebar__user-collapsed",this.userMenuOpen&&"designbase-wc-sidebar__user-collapsed--open"].filter(Boolean).join(" "),e.setAttribute("role","button"),e.setAttribute("tabindex","0"),e.setAttribute("aria-label",s.name),e.setAttribute("aria-expanded",String(this.userMenuOpen)),a.length&&e.setAttribute("aria-haspopup","menu");const t=document.createElement("db-avatar");if(t.className="designbase-wc-sidebar__user-avatar-collapsed",t.setAttribute("size","s"),t.setAttribute("initials",s.name),t.setAttribute("alt",s.name),s.avatar&&t.setAttribute("src",s.avatar),e.append(t),!this.userMenuOpen){const t=document.createElement("span");t.className="designbase-wc-sidebar__item-tooltip",t.textContent=s.name,t.setAttribute("role","tooltip"),e.append(t)}const i=this.createUserDropdown(a,!0);i&&e.append(i),e.addEventListener("click",e=>{a.length&&(e.target.closest(".designbase-wc-sidebar__user-dropdown")||(this.userMenuOpen=!this.userMenuOpen,this.userFlyoutItemId=null,this.cancelUserFlyoutClose(),this.projectMenuOpen=!1,this.render()))}),e.addEventListener("keydown",t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e.click())}),n.append(e)}return n}render(){const e=this.getActivePanelConfig();this.syncHostClasses(),this.setAttribute("role","complementary"),this.syncAccessibleName();const t=this.getAttribute("size")||"m",s="false"!==(this.getAttribute("collapsible")??("app"===this.sidebarType?"true":"false")),i="false"!==(this.getAttribute("show-logo")??("app"===this.sidebarType?"true":"false")),a=this.hasAttribute("collapsed"),n=this.parseUserProfile(),r=this.parseUserMenuItems(),o=this.parseBottomSections(),d=this.collectCustomNavSlots(),c=Boolean(e),l="replace"===this.resolvedPanelMode;this.replaceChildren();const u=document.createElement("div");u.className="designbase-wc-sidebar__container";const b=document.createElement("div");b.className="designbase-wc-sidebar__panel-viewport";const p=document.createElement("div");p.className="designbase-wc-sidebar__panel-track",p.dataset.active=c&&l?"main":c?"panel":"main";const m=document.createElement("div");m.className=["designbase-wc-sidebar__panel-slide","designbase-wc-sidebar__panel-slide--main"].join(" "),m.dataset.panel="main";const h=c&&l;m.toggleAttribute("inert",h),m.setAttribute("aria-hidden",String(h));const g=this.createMainHeader({size:t,collapsible:s,showLogo:i,collapsed:a});if(g&&m.append(g),m.append(this.createNavWrapper({mode:"main",collapsed:a,includeProjects:"back"!==this.headerType,includeBottom:o.length>0})),m.append(this.createFooter({collapsed:a,userProfile:n,userMenuItems:r})),p.append(m),e){const t=document.createElement("div");t.className=["designbase-wc-sidebar__panel-slide","designbase-wc-sidebar__panel-slide--secondary"].join(" "),t.dataset.panel=e.id,t.setAttribute("aria-hidden","false"),t.append(this.createPanelHeader(e)),t.append(this.createNavWrapper({mode:"panel",collapsed:!1,includeProjects:!1,includeBottom:!1,panel:e})),p.append(t)}b.append(p),u.append(b),this.append(u),this.renderNav(),this.renderBottomNav(),this.projectCustomNavSlots(d),c&&l&&requestAnimationFrame(()=>{this.isConnected&&this.activePanel===e?.id&&(p.dataset.active="panel")})}}customElements.get("db-sidebar")||customElements.define("db-sidebar",DbSidebar);export{DbSidebar};
@@ -1,3 +1,5 @@
1
+ import './db-progressbar.js';
2
+
1
3
  interface DbStatChange {
2
4
  value: number;
3
5
  type: 'increase' | 'decrease';
@@ -1 +1 @@
1
- import{createDbIcon as t}from"./db-icons.js";import{STAT_SIZES as e,STAT_VARIANTS as s,STAT_LAYOUTS as i,STAT_COLORS as a}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";const n={s:16,m:20,l:24};class DbStat extends HTMLElement{constructor(){super(...arguments),this.handleClick=()=>{!this.hasAttribute("disabled")&&this.hasAttribute("clickable")&&this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0}))},this.handleKeyDown=t=>{this.hasAttribute("clickable")&&!this.hasAttribute("disabled")&&("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleClick()))}}static get observedAttributes(){return["value","label","icon","icon-position","size","variant","layout","color","custom-color","progress","show-progress","change","show-change","description","show-description","clickable","disabled","animated"]}connectedCallback(){this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this.render()}disconnectedCallback(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}attributeChangedCallback(){this.render()}parseChange(){const t=this.getAttribute("change");if(!t)return null;try{const e=JSON.parse(t);if(e&&"number"==typeof e.value&&e.type)return e}catch{}return null}getChangeText(t){const e="increase"===t.type?"+":"-",s=t.period?` ${t.period}`:"";return`${e}${Math.abs(t.value)}%${s}`}resolveIconName(t){if(!t)return;return t in{user:1,sparkle:1,award:1,bulb:1,edit:1,search:1}?t:void 0}getProgressVariant(t){return"primary"===t?"primary":"success"===t?"success":"warning"===t?"warning":"error"===t?"danger":"default"}render(){const r=this.getAttribute("value")??"",c=this.getAttribute("label")||"",o=this.getAttribute("icon")||"",d=this.getAttribute("icon-position")||"left",l=this.getAttribute("size")||"m",h=e.includes(l)?l:"m",b=this.getAttribute("variant")||"default",u=s.includes(b)?b:"default",g=this.getAttribute("layout")||"horizontal",m=i.includes(g)?g:"horizontal",p=this.getAttribute("color")||"primary",w=a.includes(p)?p:"primary",v=this.getAttribute("custom-color")||"",A=this.getAttribute("progress"),_=null!==A?Number(A):NaN,y=this.hasAttribute("show-progress"),k=this.parseChange(),E=this.hasAttribute("show-change"),N=this.getAttribute("description")||"",f=this.hasAttribute("show-description"),C=this.hasAttribute("clickable"),x=this.hasAttribute("disabled"),$=this.hasAttribute("animated");this.className=["designbase-wc-stat",`designbase-wc-stat--size-${h}`,`designbase-wc-stat--variant-${u}`,`designbase-wc-stat--layout-${m}`,`designbase-wc-stat--color-${w}`,C&&"designbase-wc-stat--clickable",x&&"designbase-wc-stat--disabled",$&&"designbase-wc-stat--animated",y&&"designbase-wc-stat--with-progress",E&&k&&"designbase-wc-stat--with-change",f&&N&&"designbase-wc-stat--with-description"].filter(Boolean).join(" "),v?this.style.setProperty("--stat-color",v):this.style.removeProperty("--stat-color"),C?(this.setAttribute("role","button"),this.setAttribute("aria-disabled",String(x)),x?this.removeAttribute("tabindex"):this.setAttribute("tabindex","0")):(this.removeAttribute("aria-disabled"),this.removeAttribute("role"),this.removeAttribute("tabindex")),this.replaceChildren();const D=document.createElement("div");D.className="designbase-wc-stat__body";const S=this.resolveIconName(o);if(S){const e=document.createElement("div");e.className=`designbase-wc-stat__icon designbase-wc-stat__icon--${d}`;const s="iconBox"===u?n[h]:20;e.append(t(S,s)),D.append(e)}const z=document.createElement("div");z.className="designbase-wc-stat__content";const L=document.createElement("div");L.className="designbase-wc-stat__main";const j=document.createElement("div");j.className="designbase-wc-stat__label",j.textContent=c;const M=document.createElement("div");if(M.className="designbase-wc-stat__value",M.textContent=String(r),L.append(j,M),z.append(L),E&&k){const t=document.createElement("div");t.className=["designbase-wc-stat__change","increase"===k.type?"designbase-wc-stat__change--increase":"designbase-wc-stat__change--decrease"].join(" "),t.textContent=this.getChangeText(k),z.append(t)}if(f&&N){const t=document.createElement("div");t.className="designbase-wc-stat__description",t.textContent=N,z.append(t)}if(D.append(z),this.append(D),y&&!Number.isNaN(_)){const t=Math.min(Math.max(_,0),100),e=document.createElement("div");e.className="designbase-wc-stat__progress";const s=document.createElement("db-progressbar");s.setAttribute("value",String(t)),s.setAttribute("size","s"),s.setAttribute("variant",this.getProgressVariant(w)),s.setAttribute("full-width",""),e.append(s),this.append(e)}}}customElements.get("db-stat")||customElements.define("db-stat",DbStat);export{DbStat};
1
+ import"./db-progressbar.js";import{createDbIcon as t}from"./db-icons.js";import{STAT_SIZES as e,STAT_VARIANTS as s,STAT_LAYOUTS as i,STAT_COLORS as a}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";const n={s:16,m:20,l:24};class DbStat extends HTMLElement{constructor(){super(...arguments),this.handleClick=()=>{!this.hasAttribute("disabled")&&this.hasAttribute("clickable")&&this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0}))},this.handleKeyDown=t=>{this.hasAttribute("clickable")&&!this.hasAttribute("disabled")&&("Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleClick()))}}static get observedAttributes(){return["value","label","icon","icon-position","size","variant","layout","color","custom-color","progress","show-progress","change","show-change","description","show-description","clickable","disabled","animated"]}connectedCallback(){this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this.render()}disconnectedCallback(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}attributeChangedCallback(){this.render()}parseChange(){const t=this.getAttribute("change");if(!t)return null;try{const e=JSON.parse(t);if(e&&"number"==typeof e.value&&e.type)return e}catch{}return null}getChangeText(t){const e="increase"===t.type?"+":"-",s=t.period?` ${t.period}`:"";return`${e}${Math.abs(t.value)}%${s}`}resolveIconName(t){if(!t)return;return t in{user:1,sparkle:1,award:1,bulb:1,edit:1,search:1}?t:void 0}getProgressVariant(t){return"primary"===t?"primary":"success"===t?"success":"warning"===t?"warning":"error"===t?"danger":"default"}render(){const r=this.getAttribute("value")??"",c=this.getAttribute("label")||"",o=this.getAttribute("icon")||"",d=this.getAttribute("icon-position")||"left",l=this.getAttribute("size")||"m",b=e.includes(l)?l:"m",h=this.getAttribute("variant")||"default",u=s.includes(h)?h:"default",g=this.getAttribute("layout")||"horizontal",m=i.includes(g)?g:"horizontal",p=this.getAttribute("color")||"primary",w=a.includes(p)?p:"primary",v=this.getAttribute("custom-color")||"",A=this.getAttribute("progress"),_=null!==A?Number(A):NaN,y=this.hasAttribute("show-progress"),k=this.parseChange(),E=this.hasAttribute("show-change"),N=this.getAttribute("description")||"",f=this.hasAttribute("show-description"),C=this.hasAttribute("clickable"),x=this.hasAttribute("disabled"),$=this.hasAttribute("animated");this.className=["designbase-wc-stat",`designbase-wc-stat--size-${b}`,`designbase-wc-stat--variant-${u}`,`designbase-wc-stat--layout-${m}`,`designbase-wc-stat--color-${w}`,C&&"designbase-wc-stat--clickable",x&&"designbase-wc-stat--disabled",$&&"designbase-wc-stat--animated",y&&"designbase-wc-stat--with-progress",E&&k&&"designbase-wc-stat--with-change",f&&N&&"designbase-wc-stat--with-description"].filter(Boolean).join(" "),v?this.style.setProperty("--stat-color",v):this.style.removeProperty("--stat-color"),C?(this.setAttribute("role","button"),this.setAttribute("aria-disabled",String(x)),x?this.removeAttribute("tabindex"):this.setAttribute("tabindex","0")):(this.removeAttribute("aria-disabled"),this.removeAttribute("role"),this.removeAttribute("tabindex")),this.replaceChildren();const D=document.createElement("div");D.className="designbase-wc-stat__body";const S=this.resolveIconName(o);if(S){const e=document.createElement("div");e.className=`designbase-wc-stat__icon designbase-wc-stat__icon--${d}`;const s="iconBox"===u?n[b]:20;e.append(t(S,s)),D.append(e)}const z=document.createElement("div");z.className="designbase-wc-stat__content";const j=document.createElement("div");j.className="designbase-wc-stat__main";const L=document.createElement("div");L.className="designbase-wc-stat__label",L.textContent=c;const M=document.createElement("div");if(M.className="designbase-wc-stat__value",M.textContent=String(r),j.append(L,M),z.append(j),E&&k){const t=document.createElement("div");t.className=["designbase-wc-stat__change","increase"===k.type?"designbase-wc-stat__change--increase":"designbase-wc-stat__change--decrease"].join(" "),t.textContent=this.getChangeText(k),z.append(t)}if(f&&N){const t=document.createElement("div");t.className="designbase-wc-stat__description",t.textContent=N,z.append(t)}if(D.append(z),this.append(D),y&&!Number.isNaN(_)){const t=Math.min(Math.max(_,0),100),e=document.createElement("div");e.className="designbase-wc-stat__progress";const s=document.createElement("db-progressbar");s.setAttribute("value",String(t)),s.setAttribute("size","s"),s.setAttribute("variant",this.getProgressVariant(w)),s.setAttribute("full-width",""),e.append(s),this.append(e)}}}customElements.get("db-stat")||customElements.define("db-stat",DbStat);export{DbStat};
@@ -1,3 +1,8 @@
1
+ import './db-checkbox.js';
2
+ import './db-badge.js';
3
+ import './db-empty-state.js';
4
+ import './db-pagination.js';
5
+
1
6
  interface TableColumn {
2
7
  key: string;
3
8
  header: string;
@@ -1 +1 @@
1
- import{subscribeDbLocale as e,dbText as t}from"../core/i18n.js";import{createDbIcon as s}from"./db-icons.js";import{TABLE_SIZES as n,TABLE_VARIANTS as a}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";class DbTable extends HTMLElement{constructor(){super(...arguments),this.internalSelectedRows=[],this.internalSortDirection=null,this.internalPage=1}static get observedAttributes(){return["columns","data","title","size","variant","empty-message","sortable","sort-column","sort-direction","selectable","multi-select","selected-rows","row-key","loading","pagination","page","page-size","total-items","show-count-badge","clickable"]}get columns(){try{return JSON.parse(this.getAttribute("columns")||"[]")}catch{return[]}}set columns(e){this.setAttribute("columns","string"==typeof e?e:JSON.stringify(e))}get data(){try{return JSON.parse(this.getAttribute("data")||"[]")}catch{return[]}}set data(e){this.setAttribute("data","string"==typeof e?e:JSON.stringify(e))}connectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=e(()=>{const e=this.querySelector(".designbase-wc-table__loading span");e&&(e.textContent=t("로딩 중..."));const s=this.querySelector(".designbase-wc-table__td--empty db-empty-state");s&&(s.setAttribute("title",t("데이터가 없습니다")),s.setAttribute("description",this.getAttribute("empty-message")||t("데이터가 없습니다.")))}),this.render()}disconnectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=void 0}attributeChangedCallback(e){"selected-rows"===e&&this.syncSelectedRowsFromAttribute(),"sort-column"!==e&&"sort-direction"!==e||this.syncSortFromAttributes(),"page"===e&&(this.internalPage=Number(this.getAttribute("page")||1)),this.render()}syncSelectedRowsFromAttribute(){try{this.internalSelectedRows=JSON.parse(this.getAttribute("selected-rows")||"[]")}catch{this.internalSelectedRows=[]}}syncSortFromAttributes(){const e=this.getAttribute("sort-column"),t=this.getAttribute("sort-direction");this.internalSortColumn=e||void 0,this.internalSortDirection="asc"===t||"desc"===t?t:null}getRowKey(e,t){const s=e[this.getAttribute("row-key")||"id"];return String(null!=s?s:t)}getSortedData(){const e=this.data,t=this.getAttribute("sort-column")||this.internalSortColumn,s=this.getAttribute("sort-direction")||this.internalSortDirection;if(!t||!s)return e;const n=this.columns.find(e=>e.key===t);return n?.sortable?[...e].sort((e,n)=>{const a=e[t],i=n[t];return a===i?0:null==a?1:null==i?-1:a<i?"asc"===s?-1:1:"asc"===s?1:-1}):e}handleSort(e){if(!this.hasAttribute("sortable")||!e.sortable)return;let t="asc";this.internalSortColumn===e.key&&("asc"===this.internalSortDirection?t="desc":"desc"===this.internalSortDirection&&(t=null)),this.internalSortColumn=t?e.key:void 0,this.internalSortDirection=t,this.dispatchEvent(new CustomEvent("db-sort-change",{bubbles:!0,composed:!0,detail:{column:e.key,direction:t}})),this.render()}handleRowSelect(e,t,s){s?.stopPropagation();let n;n=this.hasAttribute("multi-select")?t?[...this.internalSelectedRows,e]:this.internalSelectedRows.filter(t=>t!==e):t?[e]:[],this.internalSelectedRows=n,this.dispatchEvent(new CustomEvent("db-selection-change",{bubbles:!0,composed:!0,detail:{selectedRows:n}})),this.render()}handleSelectAll(e){const t=e?this.data.map((e,t)=>this.getRowKey(e,t)):[];this.internalSelectedRows=t,this.dispatchEvent(new CustomEvent("db-selection-change",{bubbles:!0,composed:!0,detail:{selectedRows:t}})),this.render()}getPaginatedData(){const e=this.getSortedData();if(!this.hasAttribute("pagination"))return e;const t=Number(this.getAttribute("page-size")||10),s=Number(this.getAttribute("total-items")||e.length),n=Math.max(1,Math.ceil(s/t)),a=(Math.min(this.internalPage,n)-1)*t;return e.slice(a,a+t)}createSortIcon(e){const t=document.createElement("span");t.className="designbase-wc-table__sort-icon";if(!(this.internalSortColumn===e.key&&Boolean(this.internalSortDirection))){t.classList.add("designbase-wc-table__sort-icon--idle");const e=document.createElement("span");return e.className="designbase-wc-table__sort-icon-stack",e.append(s("chevron-up",10),s("chevron-down",10)),t.append(e),t}return t.classList.add("asc"===this.internalSortDirection?"designbase-wc-table__sort-icon--asc":"designbase-wc-table__sort-icon--desc"),t.append(s("asc"===this.internalSortDirection?"chevron-up":"chevron-down",14)),t}createCheckbox(e){const t=document.createElement("db-checkbox");return t.setAttribute("size","s"),t.setAttribute("has-label","false"),e.checked&&t.setAttribute("checked",""),e.indeterminate&&t.setAttribute("indeterminate",""),e.stopPropagation&&t.addEventListener("click",e=>e.stopPropagation()),t.addEventListener("db-change",t=>{const s=t.detail;e.onChange?.(s.checked)}),t}render(){const e=this.getAttribute("size")||"m",s=this.getAttribute("variant")||"default",i=n.includes(e)?e:"m",c=a.includes(s)?s:"default",r=this.columns,o=this.getPaginatedData(),l=this.getSortedData(),d=this.hasAttribute("loading");d?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");const b=this.hasAttribute("selectable"),h=this.hasAttribute("sortable"),u=this.getAttribute("empty-message")||t("데이터가 없습니다.");if(this.className=["designbase-wc-table",`designbase-wc-table--${i}`,`designbase-wc-table--${c}`,b&&"designbase-wc-table--selectable",h&&"designbase-wc-table--sortable",d&&"designbase-wc-table--loading"].filter(Boolean).join(" "),this.replaceChildren(),d){const e=document.createElement("div");e.className="designbase-wc-table__loading";const s=document.createElement("div");s.className="designbase-wc-table__loading-spinner";const n=document.createElement("span");return n.textContent=t("로딩 중..."),e.append(s,n),void this.append(e)}const m=this.getAttribute("title"),g=this.hasAttribute("show-count-badge");if(m||g){const e=document.createElement("div");e.className="designbase-wc-table__header";const t=document.createElement("div");if(t.className="designbase-wc-table__header-left",m){const e=document.createElement("h3");e.className="designbase-wc-table__title",e.textContent=m,t.append(e)}if(g){const e=document.createElement("db-badge");e.setAttribute("count",String(this.data.length)),e.setAttribute("type","number"),e.setAttribute("variant","primary"),e.setAttribute("size","s"),t.append(e)}e.append(t),this.append(e)}const p=document.createElement("div");p.className="designbase-wc-table__container";const w=document.createElement("table");w.className="designbase-wc-table__table";const _=document.createElement("thead");_.className="designbase-wc-table__thead";const A=document.createElement("tr");A.className="designbase-wc-table__tr";const S=o.map((e,t)=>this.getRowKey(e,t)),E=S.filter(e=>this.internalSelectedRows.includes(e)),y=this.hasAttribute("clickable");if(b){const e=document.createElement("th");e.className="designbase-wc-table__th designbase-wc-table__th--checkbox";const t=this.createCheckbox({checked:S.length>0&&E.length===S.length,indeterminate:E.length>0&&E.length<S.length,onChange:e=>this.handleSelectAll(e)});e.append(t),A.append(e)}r.forEach(e=>{const t=document.createElement("th");t.className=["designbase-wc-table__th",`designbase-wc-table__th--${e.align||"left"}`,h&&e.sortable&&"designbase-wc-table__th--sortable",this.internalSortColumn===e.key&&this.internalSortDirection&&"designbase-wc-table__th--sorted"].filter(Boolean).join(" "),e.width&&(t.style.width="number"==typeof e.width?`${e.width}px`:e.width);const s=document.createElement("div");s.className="designbase-wc-table__th-content";const n=document.createElement("span");n.className="designbase-wc-table__th-text",n.textContent=e.header,s.append(n),h&&e.sortable&&s.append(this.createSortIcon(e)),t.append(s),h&&e.sortable&&t.addEventListener("click",()=>this.handleSort(e)),A.append(t)}),_.append(A);const f=document.createElement("tbody");if(f.className="designbase-wc-table__tbody",0===l.length){const e=document.createElement("tr");e.className="designbase-wc-table__tr";const s=document.createElement("td");s.className="designbase-wc-table__td designbase-wc-table__td--empty",s.colSpan=Math.max(r.length+(b?1:0),1);const n=document.createElement("db-empty-state");n.setAttribute("title",t("데이터가 없습니다")),n.setAttribute("description",u),n.setAttribute("variant","no-data"),n.setAttribute("size","m"),s.append(n),e.append(s),f.append(e)}else o.forEach((e,t)=>{const s=this.getRowKey(e,t),n=this.internalSelectedRows.includes(s),a=document.createElement("tr");if(a.className=["designbase-wc-table__tr",y&&"designbase-wc-table__tr--clickable",n&&"designbase-wc-table__tr--selected"].filter(Boolean).join(" "),y&&a.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-row-click",{detail:{item:e,index:t},bubbles:!0,composed:!0}))}),b){const e=document.createElement("td");e.className="designbase-wc-table__td designbase-wc-table__td--checkbox";const t=this.createCheckbox({checked:n,stopPropagation:!0,onChange:e=>this.handleRowSelect(s,e)});e.append(t),a.append(e)}r.forEach(t=>{const s=document.createElement("td");s.className=["designbase-wc-table__td",`designbase-wc-table__td--${t.align||"left"}`].join(" "),s.textContent=String(e[t.key]??""),a.append(s)}),f.append(a)});if(w.append(_,f),p.append(w),this.append(p),this.hasAttribute("pagination")){const e=Number(this.getAttribute("page-size")||10),t=Number(this.getAttribute("total-items")||l.length),s=Math.max(1,Math.ceil(t/e)),n=document.createElement("div");n.className="designbase-wc-table__footer";const a=document.createElement("db-pagination");a.setAttribute("current-page",String(this.internalPage)),a.setAttribute("total-pages",String(s)),a.setAttribute("size",i),a.setAttribute("show-first-last",""),a.addEventListener("db-change",e=>{const t=Number(e.detail?.page||1);this.internalPage=t,this.dispatchEvent(new CustomEvent("db-page-change",{bubbles:!0,composed:!0,detail:{page:t}})),this.render()}),n.append(a),this.append(n)}}}customElements.get("db-table")||customElements.define("db-table",DbTable);export{DbTable};
1
+ import"./db-checkbox.js";import"./db-badge.js";import"./db-empty-state.js";import"./db-pagination.js";import{subscribeDbLocale as t,dbText as e}from"../core/i18n.js";import{createDbIcon as s}from"./db-icons.js";import{TABLE_SIZES as n,TABLE_VARIANTS as a}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";class DbTable extends HTMLElement{constructor(){super(...arguments),this.internalSelectedRows=[],this.internalSortDirection=null,this.internalPage=1}static get observedAttributes(){return["columns","data","title","size","variant","empty-message","sortable","sort-column","sort-direction","selectable","multi-select","selected-rows","row-key","loading","pagination","page","page-size","total-items","show-count-badge","clickable"]}get columns(){try{return JSON.parse(this.getAttribute("columns")||"[]")}catch{return[]}}set columns(t){this.setAttribute("columns","string"==typeof t?t:JSON.stringify(t))}get data(){try{return JSON.parse(this.getAttribute("data")||"[]")}catch{return[]}}set data(t){this.setAttribute("data","string"==typeof t?t:JSON.stringify(t))}connectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=t(()=>{const t=this.querySelector(".designbase-wc-table__loading span");t&&(t.textContent=e("로딩 중..."));const s=this.querySelector(".designbase-wc-table__td--empty db-empty-state");s&&(s.setAttribute("title",e("데이터가 없습니다")),s.setAttribute("description",this.getAttribute("empty-message")||e("데이터가 없습니다.")))}),this.render()}disconnectedCallback(){this.unsubscribeLocale?.(),this.unsubscribeLocale=void 0}attributeChangedCallback(t){"selected-rows"===t&&this.syncSelectedRowsFromAttribute(),"sort-column"!==t&&"sort-direction"!==t||this.syncSortFromAttributes(),"page"===t&&(this.internalPage=Number(this.getAttribute("page")||1)),this.render()}syncSelectedRowsFromAttribute(){try{this.internalSelectedRows=JSON.parse(this.getAttribute("selected-rows")||"[]")}catch{this.internalSelectedRows=[]}}syncSortFromAttributes(){const t=this.getAttribute("sort-column"),e=this.getAttribute("sort-direction");this.internalSortColumn=t||void 0,this.internalSortDirection="asc"===e||"desc"===e?e:null}getRowKey(t,e){const s=t[this.getAttribute("row-key")||"id"];return String(null!=s?s:e)}getSortedData(){const t=this.data,e=this.getAttribute("sort-column")||this.internalSortColumn,s=this.getAttribute("sort-direction")||this.internalSortDirection;if(!e||!s)return t;const n=this.columns.find(t=>t.key===e);return n?.sortable?[...t].sort((t,n)=>{const a=t[e],i=n[e];return a===i?0:null==a?1:null==i?-1:a<i?"asc"===s?-1:1:"asc"===s?1:-1}):t}handleSort(t){if(!this.hasAttribute("sortable")||!t.sortable)return;let e="asc";this.internalSortColumn===t.key&&("asc"===this.internalSortDirection?e="desc":"desc"===this.internalSortDirection&&(e=null)),this.internalSortColumn=e?t.key:void 0,this.internalSortDirection=e,this.dispatchEvent(new CustomEvent("db-sort-change",{bubbles:!0,composed:!0,detail:{column:t.key,direction:e}})),this.render()}handleRowSelect(t,e,s){s?.stopPropagation();let n;n=this.hasAttribute("multi-select")?e?[...this.internalSelectedRows,t]:this.internalSelectedRows.filter(e=>e!==t):e?[t]:[],this.internalSelectedRows=n,this.dispatchEvent(new CustomEvent("db-selection-change",{bubbles:!0,composed:!0,detail:{selectedRows:n}})),this.render()}handleSelectAll(t){const e=t?this.data.map((t,e)=>this.getRowKey(t,e)):[];this.internalSelectedRows=e,this.dispatchEvent(new CustomEvent("db-selection-change",{bubbles:!0,composed:!0,detail:{selectedRows:e}})),this.render()}getPaginatedData(){const t=this.getSortedData();if(!this.hasAttribute("pagination"))return t;const e=Number(this.getAttribute("page-size")||10),s=Number(this.getAttribute("total-items")||t.length),n=Math.max(1,Math.ceil(s/e)),a=(Math.min(this.internalPage,n)-1)*e;return t.slice(a,a+e)}createSortIcon(t){const e=document.createElement("span");e.className="designbase-wc-table__sort-icon";if(!(this.internalSortColumn===t.key&&Boolean(this.internalSortDirection))){e.classList.add("designbase-wc-table__sort-icon--idle");const t=document.createElement("span");return t.className="designbase-wc-table__sort-icon-stack",t.append(s("chevron-up",10),s("chevron-down",10)),e.append(t),e}return e.classList.add("asc"===this.internalSortDirection?"designbase-wc-table__sort-icon--asc":"designbase-wc-table__sort-icon--desc"),e.append(s("asc"===this.internalSortDirection?"chevron-up":"chevron-down",14)),e}createCheckbox(t){const e=document.createElement("db-checkbox");return e.setAttribute("size","s"),e.setAttribute("has-label","false"),t.checked&&e.setAttribute("checked",""),t.indeterminate&&e.setAttribute("indeterminate",""),t.stopPropagation&&e.addEventListener("click",t=>t.stopPropagation()),e.addEventListener("db-change",e=>{const s=e.detail;t.onChange?.(s.checked)}),e}render(){const t=this.getAttribute("size")||"m",s=this.getAttribute("variant")||"default",i=n.includes(t)?t:"m",c=a.includes(s)?s:"default",r=this.columns,o=this.getPaginatedData(),l=this.getSortedData(),d=this.hasAttribute("loading");d?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");const b=this.hasAttribute("selectable"),h=this.hasAttribute("sortable"),u=this.getAttribute("empty-message")||e("데이터가 없습니다.");if(this.className=["designbase-wc-table",`designbase-wc-table--${i}`,`designbase-wc-table--${c}`,b&&"designbase-wc-table--selectable",h&&"designbase-wc-table--sortable",d&&"designbase-wc-table--loading"].filter(Boolean).join(" "),this.replaceChildren(),d){const t=document.createElement("div");t.className="designbase-wc-table__loading";const s=document.createElement("div");s.className="designbase-wc-table__loading-spinner";const n=document.createElement("span");return n.textContent=e("로딩 중..."),t.append(s,n),void this.append(t)}const m=this.getAttribute("title"),g=this.hasAttribute("show-count-badge");if(m||g){const t=document.createElement("div");t.className="designbase-wc-table__header";const e=document.createElement("div");if(e.className="designbase-wc-table__header-left",m){const t=document.createElement("h3");t.className="designbase-wc-table__title",t.textContent=m,e.append(t)}if(g){const t=document.createElement("db-badge");t.setAttribute("count",String(this.data.length)),t.setAttribute("type","number"),t.setAttribute("variant","primary"),t.setAttribute("size","s"),e.append(t)}t.append(e),this.append(t)}const p=document.createElement("div");p.className="designbase-wc-table__container";const w=document.createElement("table");w.className="designbase-wc-table__table";const _=document.createElement("thead");_.className="designbase-wc-table__thead";const A=document.createElement("tr");A.className="designbase-wc-table__tr";const S=o.map((t,e)=>this.getRowKey(t,e)),E=S.filter(t=>this.internalSelectedRows.includes(t)),y=this.hasAttribute("clickable");if(b){const t=document.createElement("th");t.className="designbase-wc-table__th designbase-wc-table__th--checkbox";const e=this.createCheckbox({checked:S.length>0&&E.length===S.length,indeterminate:E.length>0&&E.length<S.length,onChange:t=>this.handleSelectAll(t)});t.append(e),A.append(t)}r.forEach(t=>{const e=document.createElement("th");e.className=["designbase-wc-table__th",`designbase-wc-table__th--${t.align||"left"}`,h&&t.sortable&&"designbase-wc-table__th--sortable",this.internalSortColumn===t.key&&this.internalSortDirection&&"designbase-wc-table__th--sorted"].filter(Boolean).join(" "),t.width&&(e.style.width="number"==typeof t.width?`${t.width}px`:t.width);const s=document.createElement("div");s.className="designbase-wc-table__th-content";const n=document.createElement("span");n.className="designbase-wc-table__th-text",n.textContent=t.header,s.append(n),h&&t.sortable&&s.append(this.createSortIcon(t)),e.append(s),h&&t.sortable&&e.addEventListener("click",()=>this.handleSort(t)),A.append(e)}),_.append(A);const f=document.createElement("tbody");if(f.className="designbase-wc-table__tbody",0===l.length){const t=document.createElement("tr");t.className="designbase-wc-table__tr";const s=document.createElement("td");s.className="designbase-wc-table__td designbase-wc-table__td--empty",s.colSpan=Math.max(r.length+(b?1:0),1);const n=document.createElement("db-empty-state");n.setAttribute("title",e("데이터가 없습니다")),n.setAttribute("description",u),n.setAttribute("variant","no-data"),n.setAttribute("size","m"),s.append(n),t.append(s),f.append(t)}else o.forEach((t,e)=>{const s=this.getRowKey(t,e),n=this.internalSelectedRows.includes(s),a=document.createElement("tr");if(a.className=["designbase-wc-table__tr",y&&"designbase-wc-table__tr--clickable",n&&"designbase-wc-table__tr--selected"].filter(Boolean).join(" "),y&&a.addEventListener("click",()=>{this.dispatchEvent(new CustomEvent("db-row-click",{detail:{item:t,index:e},bubbles:!0,composed:!0}))}),b){const t=document.createElement("td");t.className="designbase-wc-table__td designbase-wc-table__td--checkbox";const e=this.createCheckbox({checked:n,stopPropagation:!0,onChange:t=>this.handleRowSelect(s,t)});t.append(e),a.append(t)}r.forEach(e=>{const s=document.createElement("td");s.className=["designbase-wc-table__td",`designbase-wc-table__td--${e.align||"left"}`].join(" "),s.textContent=String(t[e.key]??""),a.append(s)}),f.append(a)});if(w.append(_,f),p.append(w),this.append(p),this.hasAttribute("pagination")){const t=Number(this.getAttribute("page-size")||10),e=Number(this.getAttribute("total-items")||l.length),s=Math.max(1,Math.ceil(e/t)),n=document.createElement("div");n.className="designbase-wc-table__footer";const a=document.createElement("db-pagination");a.setAttribute("current-page",String(this.internalPage)),a.setAttribute("total-pages",String(s)),a.setAttribute("size",i),a.setAttribute("show-first-last",""),a.addEventListener("db-change",t=>{const e=Number(t.detail?.page||1);this.internalPage=e,this.dispatchEvent(new CustomEvent("db-page-change",{bubbles:!0,composed:!0,detail:{page:e}})),this.render()}),n.append(a),this.append(n)}}}customElements.get("db-table")||customElements.define("db-table",DbTable);export{DbTable};
@@ -1,3 +1,6 @@
1
+ import './db-avatar.js';
2
+ import './db-rating.js';
3
+
1
4
  declare class DbTestimonial extends HTMLElement {
2
5
  static get observedAttributes(): string[];
3
6
  private built;
@@ -1 +1 @@
1
- import{dbFormat as t}from"../core/i18n.js";import{TESTIMONIAL_VARIANTS as e}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";const i="designbase-wc-testimonial";class DbTestimonial extends HTMLElement{constructor(){super(...arguments),this.built=!1}static get observedAttributes(){return["quote","author","role","company","avatar","avatar-initials","rating","max-rating","variant","logo","logo-alt","image","image-alt","tone","align"]}connectedCallback(){this.built||(this.built=!0,this.build()),this.updateUI()}attributeChangedCallback(){this.built&&this.updateUI()}build(){this.innerEl=document.createElement("div"),this.quoteEl=document.createElement("p"),this.quoteEl.className=`${i}__quote`,this.backgroundEl=document.createElement("div"),this.backgroundEl.className=`${i}__background`,this.backgroundEl.hidden=!0,this.backgroundEl.setAttribute("aria-hidden","true"),this.logoWrapEl=document.createElement("div"),this.logoWrapEl.className=`${i}__logo`,this.logoWrapEl.hidden=!0,this.logoEl=document.createElement("img"),this.logoEl.alt="",this.logoWrapEl.append(this.logoEl),this.footerEl=document.createElement("div"),this.footerEl.className=`${i}__footer`,this.avatarWrapEl=document.createElement("div"),this.avatarWrapEl.className=`${i}__avatar`,this.avatarEl=document.createElement("db-avatar"),this.avatarEl.className=`${i}__avatar-image`,this.avatarWrapEl.append(this.avatarEl);const t=document.createElement("div");t.className=`${i}__meta`,this.authorEl=document.createElement("span"),this.authorEl.className=`${i}__author`,this.roleEl=document.createElement("span"),this.roleEl.className=`${i}__role`,this.ratingEl=document.createElement("db-rating"),this.ratingEl.className=`${i}__rating`,this.ratingEl.setAttribute("display","stars"),this.ratingEl.setAttribute("variant","inline"),this.ratingEl.setAttribute("allow-half",""),this.ratingEl.setAttribute("readonly",""),this.ratingEl.setAttribute("hover-effect","false"),this.ratingEl.setAttribute("color","primary"),this.ratingEl.hidden=!0,t.append(this.authorEl,this.roleEl,this.ratingEl),this.footerEl.append(this.avatarWrapEl,t),this.extraEl=document.createElement("div"),this.extraEl.className=`${i}__extra`,this.extraEl.hidden=!0,this.innerEl.append(this.logoWrapEl,this.quoteEl,this.footerEl,this.extraEl),this.append(this.backgroundEl,this.innerEl)}getVariant(){const t=this.getAttribute("variant")||"card";return e.includes(t)?t:"card"}getAvatarSize(){return"list"===this.getVariant()?"s":"m"}syncExtraContent(){if(!this.extraEl)return;const t=Array.from(this.childNodes).filter(t=>t!==this.innerEl&&t!==this.backgroundEl&&(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&Boolean(t.textContent?.trim())));if(0===t.length)return this.extraEl.hidden=!0,void this.extraEl.replaceChildren();this.extraEl.hidden=!1,this.extraEl.replaceChildren(...t.map(t=>t.cloneNode(!0)))}updateUI(){const e=this.getAttribute("quote")||"",a=this.getAttribute("author")||"",r=this.getAttribute("role")||"",l=this.getAttribute("company")||"",s=this.getAttribute("avatar")||"",n=this.getAttribute("avatar-initials")||"",o=this.getAttribute("rating"),h=Number(this.getAttribute("max-rating")||5),u=null!==o&&""!==o?function clampRating(t,e){if("number"==typeof t&&!Number.isNaN(t))return t<0?0:t>e?e:Math.round(10*t)/10}(Number(o),h):void 0,E=this.getVariant(),d=this.getAttribute("logo")||"",g=this.getAttribute("logo-alt")||"",c=this.getAttribute("image")||"",m=this.getAttribute("image-alt")||"",b=this.getAttribute("tone")||"violet",v=this.getAttribute("align")||"left",p=[i,`${i}--variant-${E}`,`${i}--tone-${b}`,"left"!==v?`${i}--align-${v}`:""].filter(Boolean).join(" ");if(this.className=p,this.innerEl&&(this.innerEl.className=`${i}__inner`),this.quoteEl&&(this.quoteEl.textContent=e?`“${e}”`:""),this.backgroundEl){const t="image"===E&&Boolean(c);this.backgroundEl.hidden=!t,t?(this.backgroundEl.style.backgroundImage=`url("${c}")`,this.backgroundEl.setAttribute("role","img"),this.backgroundEl.setAttribute("aria-label",m||"Testimonial background"),this.backgroundEl.removeAttribute("aria-hidden")):(this.backgroundEl.style.removeProperty("background-image"),this.backgroundEl.removeAttribute("role"),this.backgroundEl.removeAttribute("aria-label"),this.backgroundEl.setAttribute("aria-hidden","true"))}if(this.logoWrapEl&&this.logoEl){const t="logo"===E&&Boolean(d);this.logoWrapEl.hidden=!t,t?(this.logoEl.src=d,this.logoEl.alt=g||"logo"):(this.logoEl.removeAttribute("src"),this.logoEl.alt="")}this.authorEl&&(this.authorEl.textContent=a);const A=[r,l].filter(Boolean).join(" · ");this.roleEl&&(this.roleEl.textContent=A,this.roleEl.hidden=!A);const _=Boolean(s||n);this.avatarWrapEl&&(this.avatarWrapEl.hidden=!_),this.avatarEl&&_&&(this.avatarEl.setAttribute("size",this.getAvatarSize()),s?this.avatarEl.setAttribute("src",s):this.avatarEl.removeAttribute("src"),n?this.avatarEl.setAttribute("initials",n):this.avatarEl.removeAttribute("initials"),this.avatarEl.setAttribute("alt",t("{0} 프로필 이미지",[a]))),this.ratingEl&&("number"==typeof u?(this.ratingEl.hidden=!1,this.ratingEl.removeAttribute("hidden"),this.ratingEl.style.removeProperty("display"),this.ratingEl.setAttribute("value",String(u)),this.ratingEl.setAttribute("max-value",String(h)),this.ratingEl.setAttribute("size","s")):(this.ratingEl.hidden=!0,this.ratingEl.setAttribute("hidden",""),this.ratingEl.style.display="none",this.ratingEl.removeAttribute("value"))),this.syncExtraContent()}}customElements.get("db-testimonial")||customElements.define("db-testimonial",DbTestimonial);export{DbTestimonial};
1
+ import"./db-avatar.js";import"./db-rating.js";import{dbFormat as t}from"../core/i18n.js";import{TESTIMONIAL_VARIANTS as e}from"../node_modules/@designbasekorea/ui-contracts/dist/components.js";const i="designbase-wc-testimonial";class DbTestimonial extends HTMLElement{constructor(){super(...arguments),this.built=!1}static get observedAttributes(){return["quote","author","role","company","avatar","avatar-initials","rating","max-rating","variant","logo","logo-alt","image","image-alt","tone","align"]}connectedCallback(){this.built||(this.built=!0,this.build()),this.updateUI()}attributeChangedCallback(){this.built&&this.updateUI()}build(){this.innerEl=document.createElement("div"),this.quoteEl=document.createElement("p"),this.quoteEl.className=`${i}__quote`,this.backgroundEl=document.createElement("div"),this.backgroundEl.className=`${i}__background`,this.backgroundEl.hidden=!0,this.backgroundEl.setAttribute("aria-hidden","true"),this.logoWrapEl=document.createElement("div"),this.logoWrapEl.className=`${i}__logo`,this.logoWrapEl.hidden=!0,this.logoEl=document.createElement("img"),this.logoEl.alt="",this.logoWrapEl.append(this.logoEl),this.footerEl=document.createElement("div"),this.footerEl.className=`${i}__footer`,this.avatarWrapEl=document.createElement("div"),this.avatarWrapEl.className=`${i}__avatar`,this.avatarEl=document.createElement("db-avatar"),this.avatarEl.className=`${i}__avatar-image`,this.avatarWrapEl.append(this.avatarEl);const t=document.createElement("div");t.className=`${i}__meta`,this.authorEl=document.createElement("span"),this.authorEl.className=`${i}__author`,this.roleEl=document.createElement("span"),this.roleEl.className=`${i}__role`,this.ratingEl=document.createElement("db-rating"),this.ratingEl.className=`${i}__rating`,this.ratingEl.setAttribute("display","stars"),this.ratingEl.setAttribute("variant","inline"),this.ratingEl.setAttribute("allow-half",""),this.ratingEl.setAttribute("readonly",""),this.ratingEl.setAttribute("hover-effect","false"),this.ratingEl.setAttribute("color","primary"),this.ratingEl.hidden=!0,t.append(this.authorEl,this.roleEl,this.ratingEl),this.footerEl.append(this.avatarWrapEl,t),this.extraEl=document.createElement("div"),this.extraEl.className=`${i}__extra`,this.extraEl.hidden=!0,this.innerEl.append(this.logoWrapEl,this.quoteEl,this.footerEl,this.extraEl),this.append(this.backgroundEl,this.innerEl)}getVariant(){const t=this.getAttribute("variant")||"card";return e.includes(t)?t:"card"}getAvatarSize(){return"list"===this.getVariant()?"s":"m"}syncExtraContent(){if(!this.extraEl)return;const t=Array.from(this.childNodes).filter(t=>t!==this.innerEl&&t!==this.backgroundEl&&(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE&&Boolean(t.textContent?.trim())));if(0===t.length)return this.extraEl.hidden=!0,void this.extraEl.replaceChildren();this.extraEl.hidden=!1,this.extraEl.replaceChildren(...t.map(t=>t.cloneNode(!0)))}updateUI(){const e=this.getAttribute("quote")||"",a=this.getAttribute("author")||"",r=this.getAttribute("role")||"",s=this.getAttribute("company")||"",l=this.getAttribute("avatar")||"",n=this.getAttribute("avatar-initials")||"",o=this.getAttribute("rating"),h=Number(this.getAttribute("max-rating")||5),u=null!==o&&""!==o?function clampRating(t,e){if("number"==typeof t&&!Number.isNaN(t))return t<0?0:t>e?e:Math.round(10*t)/10}(Number(o),h):void 0,E=this.getVariant(),d=this.getAttribute("logo")||"",g=this.getAttribute("logo-alt")||"",c=this.getAttribute("image")||"",m=this.getAttribute("image-alt")||"",b=this.getAttribute("tone")||"violet",v=this.getAttribute("align")||"left",p=[i,`${i}--variant-${E}`,`${i}--tone-${b}`,"left"!==v?`${i}--align-${v}`:""].filter(Boolean).join(" ");if(this.className=p,this.innerEl&&(this.innerEl.className=`${i}__inner`),this.quoteEl&&(this.quoteEl.textContent=e?`“${e}”`:""),this.backgroundEl){const t="image"===E&&Boolean(c);this.backgroundEl.hidden=!t,t?(this.backgroundEl.style.backgroundImage=`url("${c}")`,this.backgroundEl.setAttribute("role","img"),this.backgroundEl.setAttribute("aria-label",m||"Testimonial background"),this.backgroundEl.removeAttribute("aria-hidden")):(this.backgroundEl.style.removeProperty("background-image"),this.backgroundEl.removeAttribute("role"),this.backgroundEl.removeAttribute("aria-label"),this.backgroundEl.setAttribute("aria-hidden","true"))}if(this.logoWrapEl&&this.logoEl){const t="logo"===E&&Boolean(d);this.logoWrapEl.hidden=!t,t?(this.logoEl.src=d,this.logoEl.alt=g||"logo"):(this.logoEl.removeAttribute("src"),this.logoEl.alt="")}this.authorEl&&(this.authorEl.textContent=a);const A=[r,s].filter(Boolean).join(" · ");this.roleEl&&(this.roleEl.textContent=A,this.roleEl.hidden=!A);const _=Boolean(l||n);this.avatarWrapEl&&(this.avatarWrapEl.hidden=!_),this.avatarEl&&_&&(this.avatarEl.setAttribute("size",this.getAvatarSize()),l?this.avatarEl.setAttribute("src",l):this.avatarEl.removeAttribute("src"),n?this.avatarEl.setAttribute("initials",n):this.avatarEl.removeAttribute("initials"),this.avatarEl.setAttribute("alt",t("{0} 프로필 이미지",[a]))),this.ratingEl&&("number"==typeof u?(this.ratingEl.hidden=!1,this.ratingEl.removeAttribute("hidden"),this.ratingEl.style.removeProperty("display"),this.ratingEl.setAttribute("value",String(u)),this.ratingEl.setAttribute("max-value",String(h)),this.ratingEl.setAttribute("size","s")):(this.ratingEl.hidden=!0,this.ratingEl.setAttribute("hidden",""),this.ratingEl.style.display="none",this.ratingEl.removeAttribute("value"))),this.syncExtraContent()}}customElements.get("db-testimonial")||customElements.define("db-testimonial",DbTestimonial);export{DbTestimonial};
@@ -1,3 +1,4 @@
1
+ import './db-modal.js';
1
2
  import './db-button.js';
2
3
  import { TIME_PICKER_FORMATS } from '../ui-contracts/dist/components.d.js';
3
4