@designbasekorea/ui-wc 0.5.5 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/dist/chunks/lottie-e273b936.js +17032 -0
  2. package/dist/esm/components/animation-background/canvas-controller.js +121 -1
  3. package/dist/esm/components/animation-background/controls.js +180 -1
  4. package/dist/esm/components/animation-background/graphite-controller.js +196 -1
  5. package/dist/esm/components/animation-background/graphite-presets.js +42 -1
  6. package/dist/esm/components/animation-background/graphite-shader.js +111 -1
  7. package/dist/esm/components/animation-background/layers.js +369 -1
  8. package/dist/esm/components/animation-background/lumina-presets.js +53 -1
  9. package/dist/esm/components/animation-background/lumina-shaders.js +181 -1
  10. package/dist/esm/components/animation-background/lumina-utils.js +60 -1
  11. package/dist/esm/components/animation-background/particle-defaults.js +36 -1
  12. package/dist/esm/components/animation-background/renderers.js +167 -1
  13. package/dist/esm/components/animation-background/shader-controller.js +154 -1
  14. package/dist/esm/components/color-picker-utils.js +134 -1
  15. package/dist/esm/components/date-picker-utils.js +140 -1
  16. package/dist/esm/components/db-accordion.js +304 -1
  17. package/dist/esm/components/db-ad-banner.js +455 -1
  18. package/dist/esm/components/db-alert.js +149 -1
  19. package/dist/esm/components/db-animation-background.js +486 -1
  20. package/dist/esm/components/db-animation-text.js +601 -1
  21. package/dist/esm/components/db-app-badge.js +88 -1
  22. package/dist/esm/components/db-audio-player.js +752 -1
  23. package/dist/esm/components/db-avatar.js +188 -1
  24. package/dist/esm/components/db-backdrop.js +139 -1
  25. package/dist/esm/components/db-badge.js +91 -1
  26. package/dist/esm/components/db-banner.js +188 -1
  27. package/dist/esm/components/db-bottom-navigation.js +146 -1
  28. package/dist/esm/components/db-bottom-sheet.js +481 -1
  29. package/dist/esm/components/db-breadcrumbs.js +329 -1
  30. package/dist/esm/components/db-button.js +316 -1
  31. package/dist/esm/components/db-calendar.js +675 -1
  32. package/dist/esm/components/db-card.js +265 -1
  33. package/dist/esm/components/db-carousel.js +264 -1
  34. package/dist/esm/components/db-checkbox.js +202 -1
  35. package/dist/esm/components/db-chip.js +104 -1
  36. package/dist/esm/components/db-code-block.js +304 -1
  37. package/dist/esm/components/db-color-picker.js +746 -1
  38. package/dist/esm/components/db-confirm.js +191 -1
  39. package/dist/esm/components/db-container.js +39 -1
  40. package/dist/esm/components/db-context-menu.js +265 -1
  41. package/dist/esm/components/db-countdown.js +146 -1
  42. package/dist/esm/components/db-cursor-follower.js +173 -1
  43. package/dist/esm/components/db-date-picker.js +837 -1
  44. package/dist/esm/components/db-divider.js +66 -1
  45. package/dist/esm/components/db-drawer.js +245 -1
  46. package/dist/esm/components/db-dropdown.js +493 -1
  47. package/dist/esm/components/db-dropzone.js +266 -1
  48. package/dist/esm/components/db-empty-state.js +97 -1
  49. package/dist/esm/components/db-file-uploader.js +256 -1
  50. package/dist/esm/components/db-floating-action-button.js +139 -1
  51. package/dist/esm/components/db-footer.js +385 -1
  52. package/dist/esm/components/db-form.js +566 -1
  53. package/dist/esm/components/db-gantt.js +882 -1
  54. package/dist/esm/components/db-gradient.js +133 -1
  55. package/dist/esm/components/db-grid-background.js +909 -1
  56. package/dist/esm/components/db-grid.js +73 -1
  57. package/dist/esm/components/db-icons.js +82 -1
  58. package/dist/esm/components/db-image-list.js +214 -1
  59. package/dist/esm/components/db-image-placeholder.js +96 -1
  60. package/dist/esm/components/db-image.js +289 -1
  61. package/dist/esm/components/db-indicator.js +517 -1
  62. package/dist/esm/components/db-input.js +420 -1
  63. package/dist/esm/components/db-kanban.js +538 -1
  64. package/dist/esm/components/db-label.js +66 -1
  65. package/dist/esm/components/db-lightbox.js +372 -1
  66. package/dist/esm/components/db-list.js +340 -1
  67. package/dist/esm/components/db-logo-svg.js +72 -1
  68. package/dist/esm/components/db-logo.js +106 -1
  69. package/dist/esm/components/db-lottie.js +109 -1
  70. package/dist/esm/components/db-markdown-editor.js +458 -1
  71. package/dist/esm/components/db-marquee.js +402 -1
  72. package/dist/esm/components/db-masonry.js +94 -1
  73. package/dist/esm/components/db-menu-item.js +211 -1
  74. package/dist/esm/components/db-modal.js +522 -1
  75. package/dist/esm/components/db-navbar.js +680 -1
  76. package/dist/esm/components/db-onboarding-modal.js +322 -1
  77. package/dist/esm/components/db-page-header.js +312 -1
  78. package/dist/esm/components/db-pagination.js +271 -1
  79. package/dist/esm/components/db-popover.js +580 -1
  80. package/dist/esm/components/db-progress-step.js +166 -1
  81. package/dist/esm/components/db-progress.js +171 -1
  82. package/dist/esm/components/db-progressbar.js +72 -1
  83. package/dist/esm/components/db-radio.js +172 -1
  84. package/dist/esm/components/db-random-gradient.js +121 -1
  85. package/dist/esm/components/db-range-slider.js +811 -1
  86. package/dist/esm/components/db-rating.js +325 -1
  87. package/dist/esm/components/db-reorder.js +286 -1
  88. package/dist/esm/components/db-resizable-panels.js +282 -1
  89. package/dist/esm/components/db-scroll-area.js +126 -1
  90. package/dist/esm/components/db-search-bar.js +668 -1
  91. package/dist/esm/components/db-section-app-download.js +101 -1
  92. package/dist/esm/components/db-section-contact.js +102 -1
  93. package/dist/esm/components/db-section-cta.js +150 -1
  94. package/dist/esm/components/db-section-faq.js +120 -1
  95. package/dist/esm/components/db-section-feature-grid.js +137 -1
  96. package/dist/esm/components/db-section-feature.js +179 -1
  97. package/dist/esm/components/db-section-hero.js +243 -1
  98. package/dist/esm/components/db-section-logo-cloud.js +138 -1
  99. package/dist/esm/components/db-section-pricing.js +166 -1
  100. package/dist/esm/components/db-section-stats.js +129 -1
  101. package/dist/esm/components/db-section-testimonials.js +252 -1
  102. package/dist/esm/components/db-section.js +385 -1
  103. package/dist/esm/components/db-segment-control.js +231 -1
  104. package/dist/esm/components/db-select.js +571 -1
  105. package/dist/esm/components/db-share-icons.js +40 -1
  106. package/dist/esm/components/db-share.js +489 -1
  107. package/dist/esm/components/db-sidebar.js +1068 -1
  108. package/dist/esm/components/db-skeleton.js +94 -1
  109. package/dist/esm/components/db-spinner.js +102 -1
  110. package/dist/esm/components/db-split-view.js +297 -1
  111. package/dist/esm/components/db-stack.js +46 -1
  112. package/dist/esm/components/db-stat.js +218 -1
  113. package/dist/esm/components/db-stepper.js +398 -1
  114. package/dist/esm/components/db-table.js +412 -1
  115. package/dist/esm/components/db-tabs.js +335 -1
  116. package/dist/esm/components/db-testimonial.js +162 -1
  117. package/dist/esm/components/db-textarea.js +233 -1
  118. package/dist/esm/components/db-time-picker.js +523 -1
  119. package/dist/esm/components/db-timeline.js +174 -1
  120. package/dist/esm/components/db-toast.js +158 -1
  121. package/dist/esm/components/db-toggle.js +162 -1
  122. package/dist/esm/components/db-toolbar.js +94 -1
  123. package/dist/esm/components/db-tooltip.js +440 -1
  124. package/dist/esm/components/db-top-banner.js +121 -1
  125. package/dist/esm/components/db-tutorial.js +324 -1
  126. package/dist/esm/components/db-video-player.js +503 -1
  127. package/dist/esm/components/db-youtube-player.js +194 -1
  128. package/dist/esm/components/highlight-code.js +65 -1
  129. package/dist/esm/components/input-validation.js +50 -1
  130. package/dist/esm/components/marketing-block-host-utils.js +9 -1
  131. package/dist/esm/components/number-scrub.js +117 -1
  132. package/dist/esm/components/random-gradient-palettes.js +67 -1
  133. package/dist/esm/components/section-block-header-utils.js +48 -1
  134. package/dist/esm/helpers/confirm.js +52 -1
  135. package/dist/esm/helpers/toast.js +73 -1
  136. package/dist/esm/index.js +111 -1
  137. package/dist/esm/node_modules/prismjs/components/prism-bash.js +235 -1
  138. package/dist/esm/node_modules/prismjs/components/prism-clike.js +31 -1
  139. package/dist/esm/node_modules/prismjs/components/prism-css.js +64 -1
  140. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +172 -1
  141. package/dist/esm/node_modules/prismjs/components/prism-json.js +27 -1
  142. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +143 -1
  143. package/dist/esm/node_modules/prismjs/components/prism-markup.js +186 -1
  144. package/dist/esm/node_modules/prismjs/components/prism-scss.js +81 -1
  145. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +15 -1
  146. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +60 -1
  147. package/dist/index.cjs +55414 -1
  148. package/dist/index.css +1 -1
  149. package/dist/index.esm.js +38284 -1
  150. package/dist/react/chunks/lottie-72a4c6d4.js +17032 -0
  151. package/dist/react/index.cjs +56503 -1
  152. package/dist/react/index.esm.js +39373 -1
  153. package/package.json +1 -1
  154. package/dist/chunks/lottie-2637aa0f.js +0 -1
  155. package/dist/react/chunks/lottie-14e7addb.js +0 -1
@@ -1 +1,329 @@
1
- import{createDbIcon as e}from"./db-icons.js";const t={s:12,m:14,l:16};class DbBreadcrumbs extends HTMLElement{constructor(){super(...arguments),this.openMenuId=null,this.onDocumentMouseDown=null,this.onDocumentKeyDown=null}static get observedAttributes(){return["items","size","variant","breadcrumb-style","max-items","menu-dropdown","max-label-length"]}get items(){try{return JSON.parse(this.getAttribute("items")||"[]")}catch{return[]}}set items(e){this.setAttribute("items","string"==typeof e?e:JSON.stringify(e))}connectedCallback(){this.render()}disconnectedCallback(){this.removeGlobalListeners()}attributeChangedCallback(){this.isConnected&&(this.openMenuId=null,this.render())}get menuDropdown(){return this.hasAttribute("menu-dropdown")}get maxLabelLength(){const e=Number(this.getAttribute("max-label-length"));return Number.isFinite(e)&&e>0?e:12}get resolvedVariant(){return this.getAttribute("variant")||this.getAttribute("breadcrumb-style")||"default"}itemId(e,t){return e.id||`item-${t}`}menuItemId(e,t){return e.id||`menu-${t}`}visibleItems(){const e=this.items,t=Number(this.getAttribute("max-items")||0);if(!t||e.length<=t)return e;const n=e[0],s=e[e.length-1],a=e.slice(1,-1),r=t-2;if(r<=0)return[n,s];const i=Math.floor(a.length/2)-Math.floor(r/2);return[n,...a.slice(i,i+r),s]}shouldUseDropdown(e){return this.menuDropdown&&Boolean(e.menu?.length)}closeMenu(){this.openMenuId&&(this.openMenuId=null,this.removeGlobalListeners(),this.updateDropdownStates())}openMenu(e){this.openMenuId=e,this.addGlobalListeners(),this.updateDropdownStates()}toggleMenu(e){this.openMenuId===e?this.closeMenu():this.openMenu(e)}addGlobalListeners(){this.onDocumentMouseDown||(this.onDocumentMouseDown=e=>{this.contains(e.target)||this.closeMenu()},this.onDocumentKeyDown=e=>{"Escape"===e.key&&this.closeMenu()},document.addEventListener("mousedown",this.onDocumentMouseDown),document.addEventListener("keydown",this.onDocumentKeyDown))}removeGlobalListeners(){this.onDocumentMouseDown&&(document.removeEventListener("mousedown",this.onDocumentMouseDown),this.onDocumentMouseDown=null),this.onDocumentKeyDown&&(document.removeEventListener("keydown",this.onDocumentKeyDown),this.onDocumentKeyDown=null)}updateDropdownStates(){this.querySelectorAll("[data-breadcrumb-dropdown]").forEach(e=>{const t=e.dataset.breadcrumbDropdown||"",n=this.openMenuId===t;e.classList.toggle("designbase-wc-breadcrumbs__dropdown--open",n);const s=e.querySelector(".designbase-wc-breadcrumbs__trigger");s&&s.setAttribute("aria-expanded",String(n))})}createLabel(e){const t=function formatBreadcrumbLabel(e,t){return!t||e.length<=t?{text:e,full:e,truncated:!1}:{text:`${e.slice(0,t)}...`,full:e,truncated:!0}}(e,this.maxLabelLength),n=document.createElement("span");return n.className="designbase-wc-breadcrumbs__label",n.textContent=t.text,t.truncated&&n.setAttribute("title",t.full),n}createMenuItem(t,n,s){const a=t.href&&!t.disabled?document.createElement("a"):document.createElement("button");if(a.className=["designbase-wc-breadcrumbs__menu-item",t.active&&"designbase-wc-breadcrumbs__menu-item--active",t.disabled&&"designbase-wc-breadcrumbs__menu-item--disabled"].filter(Boolean).join(" "),a.setAttribute("role","menuitem"),a instanceof HTMLButtonElement?(a.type="button",a.disabled=Boolean(t.disabled)):a.href=t.href||"#",t.icon){const n=document.createElement("span");n.className="designbase-wc-breadcrumbs__icon",n.append(e(t.icon,16)),a.append(n)}return a.append(this.createLabel(t.label)),a.addEventListener("click",e=>{t.disabled?e.preventDefault():(this.closeMenu(),this.dispatchEvent(new CustomEvent("db-menu-click",{detail:{menuItem:{...t,id:this.menuItemId(t,n)},parentItem:s},bubbles:!0,composed:!0})))}),a}createDropdownItem(t,n,s,a){const r=this.itemId(t,n),i=this.openMenuId===r,d=document.createElement("div");d.className=["designbase-wc-breadcrumbs__dropdown",i&&"designbase-wc-breadcrumbs__dropdown--open"].filter(Boolean).join(" "),d.dataset.breadcrumbDropdown=r;const o=document.createElement("button");if(o.type="button",o.className=["designbase-wc-breadcrumbs__trigger",(s||t.active)&&"designbase-wc-breadcrumbs__trigger--active",t.disabled&&"designbase-wc-breadcrumbs__trigger--disabled"].filter(Boolean).join(" "),o.setAttribute("aria-haspopup","menu"),o.setAttribute("aria-expanded",String(i)),o.disabled=Boolean(t.disabled),t.icon){const n=document.createElement("span");n.className="designbase-wc-breadcrumbs__icon",n.append(e(t.icon,16)),o.append(n)}o.append(this.createLabel(t.label));const c=document.createElement("span");c.className="designbase-wc-breadcrumbs__chevron",c.setAttribute("aria-hidden","true"),c.append(e("chevron-down",a)),o.append(c),o.addEventListener("click",e=>{e.stopPropagation(),t.disabled||this.toggleMenu(r)}),d.append(o);const u=document.createElement("div");return u.className="designbase-wc-breadcrumbs__menu",u.setAttribute("role","menu"),t.menu?.forEach((e,n)=>{u.append(this.createMenuItem(e,n,t))}),d.append(u),d}createStandardItem(t,n,s){const a=!t.href||s||t.disabled?document.createElement("span"):document.createElement("a");if(a.className=a instanceof HTMLAnchorElement?["designbase-wc-breadcrumbs__link",t.active&&"designbase-wc-breadcrumbs__link--active",t.disabled&&"designbase-wc-breadcrumbs__link--disabled"].filter(Boolean).join(" "):["designbase-wc-breadcrumbs__text",s&&"designbase-wc-breadcrumbs__text--active",t.disabled&&"designbase-wc-breadcrumbs__text--disabled"].filter(Boolean).join(" "),t.icon){const n=document.createElement("span");n.className="designbase-wc-breadcrumbs__icon",n.append(e(t.icon,16)),a.append(n)}return a.append(this.createLabel(t.label)),a instanceof HTMLAnchorElement&&(a.href=t.href||"#"),a.addEventListener("click",e=>{(t.disabled||t.active||s)&&e.preventDefault(),this.dispatchEvent(new CustomEvent("db-click",{detail:{item:t},bubbles:!0,composed:!0}))}),a}render(){const n=this.getAttribute("size")||"m",s=this.resolvedVariant,a=this.visibleItems(),r=a.length<this.items.length,i=t[n]||14;this.className=["designbase-wc-breadcrumbs",`designbase-wc-breadcrumbs--${n}`,`designbase-wc-breadcrumbs--${s}`,r&&"designbase-wc-breadcrumbs--collapsed"].filter(Boolean).join(" "),this.setAttribute("role","navigation"),this.setAttribute("aria-label","브레드크럼 네비게이션"),this.replaceChildren();const d=document.createElement("ol");d.className="designbase-wc-breadcrumbs__list",a.forEach((t,n)=>{const s=n===a.length-1,r=document.createElement("li");if(r.className="designbase-wc-breadcrumbs__item",this.shouldUseDropdown(t)?r.append(this.createDropdownItem(t,n,s,i)):r.append(this.createStandardItem(t,n,s)),!s){const t=document.createElement("span");t.className="designbase-wc-breadcrumbs__separator",t.setAttribute("aria-hidden","true"),t.append(e("chevron-right",16)),r.append(t)}d.append(r)}),this.append(d)}}customElements.get("db-breadcrumbs")||customElements.define("db-breadcrumbs",DbBreadcrumbs);export{DbBreadcrumbs};
1
+ import { createDbIcon } from './db-icons.js';
2
+
3
+ const CHEVRON_SIZE = { s: 12, m: 14, l: 16 };
4
+ function formatBreadcrumbLabel(label, maxLabelLength) {
5
+ if (!maxLabelLength || label.length <= maxLabelLength) {
6
+ return { text: label, full: label, truncated: false };
7
+ }
8
+ return {
9
+ text: `${label.slice(0, maxLabelLength)}...`,
10
+ full: label,
11
+ truncated: true,
12
+ };
13
+ }
14
+ class DbBreadcrumbs extends HTMLElement {
15
+ constructor() {
16
+ super(...arguments);
17
+ this.openMenuId = null;
18
+ this.onDocumentMouseDown = null;
19
+ this.onDocumentKeyDown = null;
20
+ }
21
+ static get observedAttributes() {
22
+ return ['items', 'size', 'variant', 'breadcrumb-style', 'max-items', 'menu-dropdown', 'max-label-length'];
23
+ }
24
+ get items() {
25
+ try {
26
+ return JSON.parse(this.getAttribute('items') || '[]');
27
+ }
28
+ catch {
29
+ return [];
30
+ }
31
+ }
32
+ set items(value) {
33
+ this.setAttribute('items', typeof value === 'string' ? value : JSON.stringify(value));
34
+ }
35
+ connectedCallback() {
36
+ this.render();
37
+ }
38
+ disconnectedCallback() {
39
+ this.removeGlobalListeners();
40
+ }
41
+ attributeChangedCallback() {
42
+ if (!this.isConnected)
43
+ return;
44
+ this.openMenuId = null;
45
+ this.render();
46
+ }
47
+ get menuDropdown() {
48
+ return this.hasAttribute('menu-dropdown');
49
+ }
50
+ get maxLabelLength() {
51
+ const value = Number(this.getAttribute('max-label-length'));
52
+ return Number.isFinite(value) && value > 0 ? value : 12;
53
+ }
54
+ get resolvedVariant() {
55
+ return this.getAttribute('variant') || this.getAttribute('breadcrumb-style') || 'default';
56
+ }
57
+ itemId(item, index) {
58
+ return item.id || `item-${index}`;
59
+ }
60
+ menuItemId(menuItem, index) {
61
+ return menuItem.id || `menu-${index}`;
62
+ }
63
+ visibleItems() {
64
+ const items = this.items;
65
+ const maxItems = Number(this.getAttribute('max-items') || 0);
66
+ if (!maxItems || items.length <= maxItems)
67
+ return items;
68
+ const firstItem = items[0];
69
+ const lastItem = items[items.length - 1];
70
+ const middleItems = items.slice(1, -1);
71
+ const visibleMiddleCount = maxItems - 2;
72
+ if (visibleMiddleCount <= 0) {
73
+ return [firstItem, lastItem];
74
+ }
75
+ const startIndex = Math.floor(middleItems.length / 2) - Math.floor(visibleMiddleCount / 2);
76
+ const visibleMiddleItems = middleItems.slice(startIndex, startIndex + visibleMiddleCount);
77
+ return [firstItem, ...visibleMiddleItems, lastItem];
78
+ }
79
+ shouldUseDropdown(item) {
80
+ return this.menuDropdown && Boolean(item.menu?.length);
81
+ }
82
+ closeMenu() {
83
+ if (!this.openMenuId)
84
+ return;
85
+ this.openMenuId = null;
86
+ this.removeGlobalListeners();
87
+ this.updateDropdownStates();
88
+ }
89
+ openMenu(id) {
90
+ this.openMenuId = id;
91
+ this.addGlobalListeners();
92
+ this.updateDropdownStates();
93
+ }
94
+ toggleMenu(id) {
95
+ if (this.openMenuId === id) {
96
+ this.closeMenu();
97
+ }
98
+ else {
99
+ this.openMenu(id);
100
+ }
101
+ }
102
+ addGlobalListeners() {
103
+ if (this.onDocumentMouseDown)
104
+ return;
105
+ this.onDocumentMouseDown = (event) => {
106
+ if (!this.contains(event.target)) {
107
+ this.closeMenu();
108
+ }
109
+ };
110
+ this.onDocumentKeyDown = (event) => {
111
+ if (event.key === 'Escape') {
112
+ this.closeMenu();
113
+ }
114
+ };
115
+ document.addEventListener('mousedown', this.onDocumentMouseDown);
116
+ document.addEventListener('keydown', this.onDocumentKeyDown);
117
+ }
118
+ removeGlobalListeners() {
119
+ if (this.onDocumentMouseDown) {
120
+ document.removeEventListener('mousedown', this.onDocumentMouseDown);
121
+ this.onDocumentMouseDown = null;
122
+ }
123
+ if (this.onDocumentKeyDown) {
124
+ document.removeEventListener('keydown', this.onDocumentKeyDown);
125
+ this.onDocumentKeyDown = null;
126
+ }
127
+ }
128
+ updateDropdownStates() {
129
+ this.querySelectorAll('[data-breadcrumb-dropdown]').forEach((dropdown) => {
130
+ const id = dropdown.dataset.breadcrumbDropdown || '';
131
+ const isOpen = this.openMenuId === id;
132
+ dropdown.classList.toggle('designbase-wc-breadcrumbs__dropdown--open', isOpen);
133
+ const trigger = dropdown.querySelector('.designbase-wc-breadcrumbs__trigger');
134
+ if (trigger) {
135
+ trigger.setAttribute('aria-expanded', String(isOpen));
136
+ }
137
+ });
138
+ }
139
+ createLabel(label) {
140
+ const formatted = formatBreadcrumbLabel(label, this.maxLabelLength);
141
+ const labelEl = document.createElement('span');
142
+ labelEl.className = 'designbase-wc-breadcrumbs__label';
143
+ labelEl.textContent = formatted.text;
144
+ if (formatted.truncated) {
145
+ labelEl.setAttribute('title', formatted.full);
146
+ }
147
+ return labelEl;
148
+ }
149
+ createMenuItem(menuItem, menuIndex, parentItem) {
150
+ const menuItemEl = menuItem.href && !menuItem.disabled
151
+ ? document.createElement('a')
152
+ : document.createElement('button');
153
+ menuItemEl.className = [
154
+ 'designbase-wc-breadcrumbs__menu-item',
155
+ menuItem.active && 'designbase-wc-breadcrumbs__menu-item--active',
156
+ menuItem.disabled && 'designbase-wc-breadcrumbs__menu-item--disabled',
157
+ ]
158
+ .filter(Boolean)
159
+ .join(' ');
160
+ menuItemEl.setAttribute('role', 'menuitem');
161
+ if (menuItemEl instanceof HTMLButtonElement) {
162
+ menuItemEl.type = 'button';
163
+ menuItemEl.disabled = Boolean(menuItem.disabled);
164
+ }
165
+ else {
166
+ menuItemEl.href = menuItem.href || '#';
167
+ }
168
+ if (menuItem.icon) {
169
+ const icon = document.createElement('span');
170
+ icon.className = 'designbase-wc-breadcrumbs__icon';
171
+ icon.append(createDbIcon(menuItem.icon, 16));
172
+ menuItemEl.append(icon);
173
+ }
174
+ menuItemEl.append(this.createLabel(menuItem.label));
175
+ menuItemEl.addEventListener('click', (event) => {
176
+ if (menuItem.disabled) {
177
+ event.preventDefault();
178
+ return;
179
+ }
180
+ this.closeMenu();
181
+ this.dispatchEvent(new CustomEvent('db-menu-click', {
182
+ detail: {
183
+ menuItem: { ...menuItem, id: this.menuItemId(menuItem, menuIndex) },
184
+ parentItem,
185
+ },
186
+ bubbles: true,
187
+ composed: true,
188
+ }));
189
+ });
190
+ return menuItemEl;
191
+ }
192
+ createDropdownItem(item, index, isLast, chevronSize) {
193
+ const id = this.itemId(item, index);
194
+ const isOpen = this.openMenuId === id;
195
+ const dropdown = document.createElement('div');
196
+ dropdown.className = [
197
+ 'designbase-wc-breadcrumbs__dropdown',
198
+ isOpen && 'designbase-wc-breadcrumbs__dropdown--open',
199
+ ]
200
+ .filter(Boolean)
201
+ .join(' ');
202
+ dropdown.dataset.breadcrumbDropdown = id;
203
+ const trigger = document.createElement('button');
204
+ trigger.type = 'button';
205
+ trigger.className = [
206
+ 'designbase-wc-breadcrumbs__trigger',
207
+ (isLast || item.active) && 'designbase-wc-breadcrumbs__trigger--active',
208
+ item.disabled && 'designbase-wc-breadcrumbs__trigger--disabled',
209
+ ]
210
+ .filter(Boolean)
211
+ .join(' ');
212
+ trigger.setAttribute('aria-haspopup', 'menu');
213
+ trigger.setAttribute('aria-expanded', String(isOpen));
214
+ trigger.disabled = Boolean(item.disabled);
215
+ if (item.icon) {
216
+ const icon = document.createElement('span');
217
+ icon.className = 'designbase-wc-breadcrumbs__icon';
218
+ icon.append(createDbIcon(item.icon, 16));
219
+ trigger.append(icon);
220
+ }
221
+ trigger.append(this.createLabel(item.label));
222
+ const chevron = document.createElement('span');
223
+ chevron.className = 'designbase-wc-breadcrumbs__chevron';
224
+ chevron.setAttribute('aria-hidden', 'true');
225
+ chevron.append(createDbIcon('chevron-down', chevronSize));
226
+ trigger.append(chevron);
227
+ trigger.addEventListener('click', (event) => {
228
+ event.stopPropagation();
229
+ if (item.disabled)
230
+ return;
231
+ this.toggleMenu(id);
232
+ });
233
+ dropdown.append(trigger);
234
+ const menu = document.createElement('div');
235
+ menu.className = 'designbase-wc-breadcrumbs__menu';
236
+ menu.setAttribute('role', 'menu');
237
+ item.menu?.forEach((menuItem, menuIndex) => {
238
+ menu.append(this.createMenuItem(menuItem, menuIndex, item));
239
+ });
240
+ dropdown.append(menu);
241
+ return dropdown;
242
+ }
243
+ createStandardItem(item, index, isLast) {
244
+ const content = item.href && !isLast && !item.disabled
245
+ ? document.createElement('a')
246
+ : document.createElement('span');
247
+ content.className = content instanceof HTMLAnchorElement
248
+ ? [
249
+ 'designbase-wc-breadcrumbs__link',
250
+ item.active && 'designbase-wc-breadcrumbs__link--active',
251
+ item.disabled && 'designbase-wc-breadcrumbs__link--disabled',
252
+ ]
253
+ .filter(Boolean)
254
+ .join(' ')
255
+ : [
256
+ 'designbase-wc-breadcrumbs__text',
257
+ isLast && 'designbase-wc-breadcrumbs__text--active',
258
+ item.disabled && 'designbase-wc-breadcrumbs__text--disabled',
259
+ ]
260
+ .filter(Boolean)
261
+ .join(' ');
262
+ if (item.icon) {
263
+ const icon = document.createElement('span');
264
+ icon.className = 'designbase-wc-breadcrumbs__icon';
265
+ icon.append(createDbIcon(item.icon, 16));
266
+ content.append(icon);
267
+ }
268
+ content.append(this.createLabel(item.label));
269
+ if (content instanceof HTMLAnchorElement) {
270
+ content.href = item.href || '#';
271
+ }
272
+ content.addEventListener('click', (event) => {
273
+ if (item.disabled || item.active || isLast) {
274
+ event.preventDefault();
275
+ }
276
+ this.dispatchEvent(new CustomEvent('db-click', {
277
+ detail: { item },
278
+ bubbles: true,
279
+ composed: true,
280
+ }));
281
+ });
282
+ return content;
283
+ }
284
+ render() {
285
+ const size = this.getAttribute('size') || 'm';
286
+ const variant = this.resolvedVariant;
287
+ const visibleItems = this.visibleItems();
288
+ const hasCollapsedItems = visibleItems.length < this.items.length;
289
+ const chevronSize = CHEVRON_SIZE[size] || 14;
290
+ this.className = [
291
+ 'designbase-wc-breadcrumbs',
292
+ `designbase-wc-breadcrumbs--${size}`,
293
+ `designbase-wc-breadcrumbs--${variant}`,
294
+ hasCollapsedItems && 'designbase-wc-breadcrumbs--collapsed',
295
+ ]
296
+ .filter(Boolean)
297
+ .join(' ');
298
+ this.setAttribute('role', 'navigation');
299
+ this.setAttribute('aria-label', '브레드크럼 네비게이션');
300
+ this.replaceChildren();
301
+ const list = document.createElement('ol');
302
+ list.className = 'designbase-wc-breadcrumbs__list';
303
+ visibleItems.forEach((item, index) => {
304
+ const isLast = index === visibleItems.length - 1;
305
+ const listItem = document.createElement('li');
306
+ listItem.className = 'designbase-wc-breadcrumbs__item';
307
+ if (this.shouldUseDropdown(item)) {
308
+ listItem.append(this.createDropdownItem(item, index, isLast, chevronSize));
309
+ }
310
+ else {
311
+ listItem.append(this.createStandardItem(item, index, isLast));
312
+ }
313
+ if (!isLast) {
314
+ const separator = document.createElement('span');
315
+ separator.className = 'designbase-wc-breadcrumbs__separator';
316
+ separator.setAttribute('aria-hidden', 'true');
317
+ separator.append(createDbIcon('chevron-right', 16));
318
+ listItem.append(separator);
319
+ }
320
+ list.append(listItem);
321
+ });
322
+ this.append(list);
323
+ }
324
+ }
325
+ if (!customElements.get('db-breadcrumbs')) {
326
+ customElements.define('db-breadcrumbs', DbBreadcrumbs);
327
+ }
328
+
329
+ export { DbBreadcrumbs };
@@ -1 +1,316 @@
1
- import{isDbIconName as t,createDbIcon as e}from"./db-icons.js";const s=["disabled","loading","icon-only","full-width"],i=["primary","secondary","tertiary","danger","ghost","accent"],n=["s","m","l"],a=["none","s","m","l","pill"],r=["gradient","backlight"];class DbButton extends HTMLElement{constructor(){super(...arguments),this.handleClick=t=>{if(this.disabled||this.loading)return t.preventDefault(),void t.stopPropagation();this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0}))},this.handleKeyDown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.disabled||this.loading||this.classList.add("designbase-wc-button--pressed"),this.click())},this.handleKeyUp=t=>{"Enter"!==t.key&&" "!==t.key||this.classList.remove("designbase-wc-button--pressed")},this.handlePointerDown=()=>{this.disabled||this.loading||this.classList.add("designbase-wc-button--pressed")},this.handlePointerUp=()=>{this.classList.remove("designbase-wc-button--pressed")}}static get observedAttributes(){return["variant","size","radius","accent-style","type","loading-text","start-icon","end-icon",...s]}get variant(){return this.getAttribute("variant")||"primary"}set variant(t){this.setAttribute("variant",t)}get size(){return this.getAttribute("size")||"m"}set size(t){this.setAttribute("size",t)}get radius(){return this.getAttribute("radius")||""}set radius(t){t?this.setAttribute("radius",t):this.removeAttribute("radius")}get accentStyle(){return this.getAttribute("accent-style")||"gradient"}set accentStyle(t){t?this.setAttribute("accent-style",t):this.removeAttribute("accent-style")}get type(){return this.getAttribute("type")||"button"}set type(t){this.setAttribute("type",t)}get loadingText(){return this.getAttribute("loading-text")||""}set loadingText(t){t?this.setAttribute("loading-text",t):this.removeAttribute("loading-text")}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t)}get loading(){return this.hasAttribute("loading")}set loading(t){this.toggleAttribute("loading",t)}get iconOnly(){return this.hasAttribute("icon-only")}set iconOnly(t){this.toggleAttribute("icon-only",t)}get fullWidth(){return this.hasAttribute("full-width")}set fullWidth(t){this.toggleAttribute("full-width",t)}connectedCallback(){this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown),this.addEventListener("keyup",this.handleKeyUp),this.addEventListener("pointerdown",this.handlePointerDown),this.addEventListener("pointerup",this.handlePointerUp),this.addEventListener("pointerleave",this.handlePointerUp),this.addEventListener("pointercancel",this.handlePointerUp),this.syncAttributes()}disconnectedCallback(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown),this.removeEventListener("keyup",this.handleKeyUp),this.removeEventListener("pointerdown",this.handlePointerDown),this.removeEventListener("pointerup",this.handlePointerUp),this.removeEventListener("pointerleave",this.handlePointerUp),this.removeEventListener("pointercancel",this.handlePointerUp)}attributeChangedCallback(){this.syncAttributes()}syncAttributes(){this.classList.add("designbase-wc-button"),this.setAttribute("role","button"),this.setAttribute("aria-disabled",String(this.disabled||this.loading)),this.disabled||this.loading?this.removeAttribute("tabindex"):this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this.syncModifier("variant",this.variant),this.syncModifier("size",this.size),this.syncRadius(),this.syncAccentStyle(),this.syncAccentField(),this.syncBooleanModifier("disabled"),this.syncBooleanModifier("icon-only"),this.syncBooleanModifier("full-width"),this.syncLoadingVisual(),this.loading?(this.querySelector(":scope > .designbase-wc-button__start-icon")?.remove(),this.querySelector(":scope > .designbase-wc-button__end-icon")?.remove()):this.syncIcons()}getIconSize(){return"s"===this.size?16:"l"===this.size?24:20}resolveIconName(e){if(e&&t(e))return e}isManagedIconNode(t){return t instanceof HTMLElement&&(t.classList.contains("designbase-wc-button__start-icon")||t.classList.contains("designbase-wc-button__end-icon")||t.classList.contains("designbase-wc-button__spinner")||t.classList.contains("designbase-wc-button__accent-field")||t.classList.contains("designbase-wc-button__accent-glass")||t.classList.contains("designbase-wc-button__accent-orb"))}syncIcons(){const t=this.resolveIconName(this.getAttribute("start-icon")),s=this.resolveIconName(this.getAttribute("end-icon")),i=this.getIconSize();let n=this.querySelector(":scope > .designbase-wc-button__start-icon");if(t){if(!n){n=document.createElement("span"),n.className="designbase-wc-button__start-icon",n.setAttribute("aria-hidden","true");const t=Array.from(this.childNodes).find(t=>!this.isManagedIconNode(t));t?this.insertBefore(n,t):this.append(n)}n.replaceChildren(e(t,i))}else n?.remove();let a=this.querySelector(":scope > .designbase-wc-button__end-icon");s?(a||(a=document.createElement("span"),a.className="designbase-wc-button__end-icon",a.setAttribute("aria-hidden","true")),a.replaceChildren(e(s,i)),this.append(a)):a?.remove()}getDefaultRadiusClass(){if(a.includes(this.radius))return`designbase-wc-button--radius-${this.radius}`;const t=n.includes(this.size)?this.size:"m";return`designbase-wc-button--radius-${"s"===t||"l"===t?t:"m"}`}syncRadius(){a.forEach(t=>this.classList.remove(`designbase-wc-button--radius-${t}`)),this.classList.add(this.getDefaultRadiusClass())}syncAccentStyle(){if(r.forEach(t=>this.classList.remove(`designbase-wc-button--accent-${t}`)),"accent"!==this.variant)return;const t=this.accentStyle,e=r.includes(t)?t:"gradient";this.classList.add(`designbase-wc-button--accent-${e}`)}syncAccentField(){const t="accent"===this.variant&&"gradient"===this.accentStyle,e=this.querySelector(":scope > .designbase-wc-button__accent-field"),s=this.querySelector(":scope > .designbase-wc-button__accent-glass");if(!t)return e?.remove(),void s?.remove();let i=e;if(!i){i=document.createElement("span"),i.className="designbase-wc-button__accent-field",i.setAttribute("aria-hidden","true");for(let t=1;t<=5;t+=1){const e=document.createElement("span");e.className=`designbase-wc-button__accent-orb designbase-wc-button__accent-orb--${t}`,i.appendChild(e)}this.insertBefore(i,this.firstChild)}if(!s){const t=document.createElement("span");t.className="designbase-wc-button__accent-glass",t.setAttribute("aria-hidden","true"),i.insertAdjacentElement("afterend",t)}}syncModifier(t,e){if(Array.from(this.classList).filter(e=>e.startsWith(`designbase-wc-button--${t}-`)).forEach(t=>this.classList.remove(t)),"variant"===t||"size"===t){("variant"===t?i:n).forEach(t=>this.classList.remove(`designbase-wc-button--${t}`)),this.classList.add(`designbase-wc-button--${e}`)}}syncBooleanModifier(t){const e=`designbase-wc-button--${t}`;this.classList.toggle(e,this.hasAttribute(t))}getSpinnerSize(){return n.includes(this.size)?this.size:"m"}syncLoadingVisual(){this.classList.toggle("designbase-wc-button--loading",this.loading);const t=this.querySelector(":scope > .designbase-wc-button__spinner");if(!this.loading)return void t?.remove();const e=`designbase-wc-button__spinner designbase-wc-spinner designbase-wc-spinner--circular designbase-wc-spinner--${this.getSpinnerSize()}`;if(t)return t.className=e,void t.setAttribute("aria-hidden","true");const s=document.createElement("span");s.className=e,s.setAttribute("aria-hidden","true"),s.innerHTML='<svg class="designbase-wc-spinner__circular" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle class="designbase-wc-spinner__circular-track" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" fill="none"></circle><circle class="designbase-wc-spinner__circular-indicator" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"></circle></svg>',this.insertBefore(s,this.firstChild)}}customElements.get("db-button")||customElements.define("db-button",DbButton);export{DbButton};
1
+ import { isDbIconName, createDbIcon } from './db-icons.js';
2
+
3
+ const BOOLEAN_ATTRIBUTES = ['disabled', 'loading', 'icon-only', 'full-width'];
4
+ const VARIANTS = ['primary', 'secondary', 'tertiary', 'danger', 'ghost', 'accent'];
5
+ const SIZES = ['s', 'm', 'l'];
6
+ const RADIUS_VALUES = ['none', 's', 'm', 'l', 'pill'];
7
+ const ACCENT_STYLES = ['gradient', 'backlight'];
8
+ const CIRCULAR_SPINNER_HTML = '<svg class="designbase-wc-spinner__circular" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><circle class="designbase-wc-spinner__circular-track" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" fill="none"></circle><circle class="designbase-wc-spinner__circular-indicator" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" fill="none" stroke-linecap="round"></circle></svg>';
9
+ /**
10
+ * Light DOM custom element for the canonical web Button.
11
+ *
12
+ * The host itself behaves like the button so framework children stay owned by
13
+ * their renderer. This keeps React/Vue slots stable while sharing one element.
14
+ */
15
+ class DbButton extends HTMLElement {
16
+ constructor() {
17
+ super(...arguments);
18
+ this.handleClick = (e) => {
19
+ if (this.disabled || this.loading) {
20
+ e.preventDefault();
21
+ e.stopPropagation();
22
+ return;
23
+ }
24
+ this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
25
+ };
26
+ this.handleKeyDown = (e) => {
27
+ if (e.key !== 'Enter' && e.key !== ' ')
28
+ return;
29
+ e.preventDefault();
30
+ if (!this.disabled && !this.loading) {
31
+ this.classList.add('designbase-wc-button--pressed');
32
+ }
33
+ this.click();
34
+ };
35
+ this.handleKeyUp = (e) => {
36
+ if (e.key === 'Enter' || e.key === ' ') {
37
+ this.classList.remove('designbase-wc-button--pressed');
38
+ }
39
+ };
40
+ this.handlePointerDown = () => {
41
+ if (this.disabled || this.loading)
42
+ return;
43
+ this.classList.add('designbase-wc-button--pressed');
44
+ };
45
+ this.handlePointerUp = () => {
46
+ this.classList.remove('designbase-wc-button--pressed');
47
+ };
48
+ }
49
+ static get observedAttributes() {
50
+ return ['variant', 'size', 'radius', 'accent-style', 'type', 'loading-text', 'start-icon', 'end-icon', ...BOOLEAN_ATTRIBUTES];
51
+ }
52
+ get variant() {
53
+ return this.getAttribute('variant') || 'primary';
54
+ }
55
+ set variant(value) {
56
+ this.setAttribute('variant', value);
57
+ }
58
+ get size() {
59
+ return this.getAttribute('size') || 'm';
60
+ }
61
+ set size(value) {
62
+ this.setAttribute('size', value);
63
+ }
64
+ get radius() {
65
+ return this.getAttribute('radius') || '';
66
+ }
67
+ set radius(value) {
68
+ if (value)
69
+ this.setAttribute('radius', value);
70
+ else
71
+ this.removeAttribute('radius');
72
+ }
73
+ get accentStyle() {
74
+ return this.getAttribute('accent-style') || 'gradient';
75
+ }
76
+ set accentStyle(value) {
77
+ if (value)
78
+ this.setAttribute('accent-style', value);
79
+ else
80
+ this.removeAttribute('accent-style');
81
+ }
82
+ get type() {
83
+ return this.getAttribute('type') || 'button';
84
+ }
85
+ set type(value) {
86
+ this.setAttribute('type', value);
87
+ }
88
+ get loadingText() {
89
+ return this.getAttribute('loading-text') || '';
90
+ }
91
+ set loadingText(value) {
92
+ if (value)
93
+ this.setAttribute('loading-text', value);
94
+ else
95
+ this.removeAttribute('loading-text');
96
+ }
97
+ get disabled() {
98
+ return this.hasAttribute('disabled');
99
+ }
100
+ set disabled(value) {
101
+ this.toggleAttribute('disabled', value);
102
+ }
103
+ get loading() {
104
+ return this.hasAttribute('loading');
105
+ }
106
+ set loading(value) {
107
+ this.toggleAttribute('loading', value);
108
+ }
109
+ get iconOnly() {
110
+ return this.hasAttribute('icon-only');
111
+ }
112
+ set iconOnly(value) {
113
+ this.toggleAttribute('icon-only', value);
114
+ }
115
+ get fullWidth() {
116
+ return this.hasAttribute('full-width');
117
+ }
118
+ set fullWidth(value) {
119
+ this.toggleAttribute('full-width', value);
120
+ }
121
+ connectedCallback() {
122
+ this.addEventListener('click', this.handleClick);
123
+ this.addEventListener('keydown', this.handleKeyDown);
124
+ this.addEventListener('keyup', this.handleKeyUp);
125
+ this.addEventListener('pointerdown', this.handlePointerDown);
126
+ this.addEventListener('pointerup', this.handlePointerUp);
127
+ this.addEventListener('pointerleave', this.handlePointerUp);
128
+ this.addEventListener('pointercancel', this.handlePointerUp);
129
+ this.syncAttributes();
130
+ }
131
+ disconnectedCallback() {
132
+ this.removeEventListener('click', this.handleClick);
133
+ this.removeEventListener('keydown', this.handleKeyDown);
134
+ this.removeEventListener('keyup', this.handleKeyUp);
135
+ this.removeEventListener('pointerdown', this.handlePointerDown);
136
+ this.removeEventListener('pointerup', this.handlePointerUp);
137
+ this.removeEventListener('pointerleave', this.handlePointerUp);
138
+ this.removeEventListener('pointercancel', this.handlePointerUp);
139
+ }
140
+ attributeChangedCallback() {
141
+ this.syncAttributes();
142
+ }
143
+ syncAttributes() {
144
+ this.classList.add('designbase-wc-button');
145
+ this.setAttribute('role', 'button');
146
+ this.setAttribute('aria-disabled', String(this.disabled || this.loading));
147
+ if (this.disabled || this.loading) {
148
+ this.removeAttribute('tabindex');
149
+ }
150
+ else if (!this.hasAttribute('tabindex')) {
151
+ this.setAttribute('tabindex', '0');
152
+ }
153
+ this.syncModifier('variant', this.variant);
154
+ this.syncModifier('size', this.size);
155
+ this.syncRadius();
156
+ this.syncAccentStyle();
157
+ this.syncAccentField();
158
+ this.syncBooleanModifier('disabled');
159
+ this.syncBooleanModifier('icon-only');
160
+ this.syncBooleanModifier('full-width');
161
+ this.syncLoadingVisual();
162
+ if (!this.loading) {
163
+ this.syncIcons();
164
+ }
165
+ else {
166
+ this.querySelector(':scope > .designbase-wc-button__start-icon')?.remove();
167
+ this.querySelector(':scope > .designbase-wc-button__end-icon')?.remove();
168
+ }
169
+ }
170
+ getIconSize() {
171
+ if (this.size === 's')
172
+ return 16;
173
+ if (this.size === 'l')
174
+ return 24;
175
+ return 20;
176
+ }
177
+ resolveIconName(raw) {
178
+ if (!raw || !isDbIconName(raw))
179
+ return undefined;
180
+ return raw;
181
+ }
182
+ isManagedIconNode(node) {
183
+ return (node instanceof HTMLElement &&
184
+ (node.classList.contains('designbase-wc-button__start-icon') ||
185
+ node.classList.contains('designbase-wc-button__end-icon') ||
186
+ node.classList.contains('designbase-wc-button__spinner') ||
187
+ node.classList.contains('designbase-wc-button__accent-field') ||
188
+ node.classList.contains('designbase-wc-button__accent-glass') ||
189
+ node.classList.contains('designbase-wc-button__accent-orb')));
190
+ }
191
+ syncIcons() {
192
+ const startIconName = this.resolveIconName(this.getAttribute('start-icon'));
193
+ const endIconName = this.resolveIconName(this.getAttribute('end-icon'));
194
+ const iconPx = this.getIconSize();
195
+ let startHost = this.querySelector(':scope > .designbase-wc-button__start-icon');
196
+ if (startIconName) {
197
+ if (!startHost) {
198
+ startHost = document.createElement('span');
199
+ startHost.className = 'designbase-wc-button__start-icon';
200
+ startHost.setAttribute('aria-hidden', 'true');
201
+ const anchor = Array.from(this.childNodes).find((node) => !this.isManagedIconNode(node));
202
+ if (anchor)
203
+ this.insertBefore(startHost, anchor);
204
+ else
205
+ this.append(startHost);
206
+ }
207
+ startHost.replaceChildren(createDbIcon(startIconName, iconPx));
208
+ }
209
+ else {
210
+ startHost?.remove();
211
+ }
212
+ let endHost = this.querySelector(':scope > .designbase-wc-button__end-icon');
213
+ if (endIconName) {
214
+ if (!endHost) {
215
+ endHost = document.createElement('span');
216
+ endHost.className = 'designbase-wc-button__end-icon';
217
+ endHost.setAttribute('aria-hidden', 'true');
218
+ }
219
+ endHost.replaceChildren(createDbIcon(endIconName, iconPx));
220
+ this.append(endHost);
221
+ }
222
+ else {
223
+ endHost?.remove();
224
+ }
225
+ }
226
+ getDefaultRadiusClass() {
227
+ if (RADIUS_VALUES.includes(this.radius)) {
228
+ return `designbase-wc-button--radius-${this.radius}`;
229
+ }
230
+ const size = SIZES.includes(this.size) ? this.size : 'm';
231
+ const radiusBySize = size === 's' || size === 'l' ? size : 'm';
232
+ return `designbase-wc-button--radius-${radiusBySize}`;
233
+ }
234
+ syncRadius() {
235
+ RADIUS_VALUES.forEach((value) => this.classList.remove(`designbase-wc-button--radius-${value}`));
236
+ this.classList.add(this.getDefaultRadiusClass());
237
+ }
238
+ syncAccentStyle() {
239
+ ACCENT_STYLES.forEach((style) => this.classList.remove(`designbase-wc-button--accent-${style}`));
240
+ if (this.variant !== 'accent')
241
+ return;
242
+ const raw = this.accentStyle;
243
+ const style = ACCENT_STYLES.includes(raw) ? raw : 'gradient';
244
+ this.classList.add(`designbase-wc-button--accent-${style}`);
245
+ }
246
+ syncAccentField() {
247
+ const useGradientField = this.variant === 'accent' && this.accentStyle === 'gradient';
248
+ const field = this.querySelector(':scope > .designbase-wc-button__accent-field');
249
+ const glass = this.querySelector(':scope > .designbase-wc-button__accent-glass');
250
+ if (!useGradientField) {
251
+ field?.remove();
252
+ glass?.remove();
253
+ return;
254
+ }
255
+ let accentField = field;
256
+ if (!accentField) {
257
+ accentField = document.createElement('span');
258
+ accentField.className = 'designbase-wc-button__accent-field';
259
+ accentField.setAttribute('aria-hidden', 'true');
260
+ for (let index = 1; index <= 5; index += 1) {
261
+ const orb = document.createElement('span');
262
+ orb.className = `designbase-wc-button__accent-orb designbase-wc-button__accent-orb--${index}`;
263
+ accentField.appendChild(orb);
264
+ }
265
+ this.insertBefore(accentField, this.firstChild);
266
+ }
267
+ if (!glass) {
268
+ const accentGlass = document.createElement('span');
269
+ accentGlass.className = 'designbase-wc-button__accent-glass';
270
+ accentGlass.setAttribute('aria-hidden', 'true');
271
+ accentField.insertAdjacentElement('afterend', accentGlass);
272
+ }
273
+ }
274
+ syncModifier(name, value) {
275
+ Array.from(this.classList)
276
+ .filter((className) => className.startsWith(`designbase-wc-button--${name}-`))
277
+ .forEach((className) => this.classList.remove(className));
278
+ if (name === 'variant' || name === 'size') {
279
+ const values = name === 'variant' ? VARIANTS : SIZES;
280
+ values.forEach((item) => this.classList.remove(`designbase-wc-button--${item}`));
281
+ this.classList.add(`designbase-wc-button--${value}`);
282
+ }
283
+ }
284
+ syncBooleanModifier(attribute) {
285
+ const className = `designbase-wc-button--${attribute}`;
286
+ this.classList.toggle(className, this.hasAttribute(attribute));
287
+ }
288
+ getSpinnerSize() {
289
+ return SIZES.includes(this.size) ? this.size : 'm';
290
+ }
291
+ syncLoadingVisual() {
292
+ this.classList.toggle('designbase-wc-button--loading', this.loading);
293
+ const spinnerHost = this.querySelector(':scope > .designbase-wc-button__spinner');
294
+ if (!this.loading) {
295
+ spinnerHost?.remove();
296
+ return;
297
+ }
298
+ const spinnerSize = this.getSpinnerSize();
299
+ const spinnerClassName = `designbase-wc-button__spinner designbase-wc-spinner designbase-wc-spinner--circular designbase-wc-spinner--${spinnerSize}`;
300
+ if (spinnerHost) {
301
+ spinnerHost.className = spinnerClassName;
302
+ spinnerHost.setAttribute('aria-hidden', 'true');
303
+ return;
304
+ }
305
+ const spinner = document.createElement('span');
306
+ spinner.className = spinnerClassName;
307
+ spinner.setAttribute('aria-hidden', 'true');
308
+ spinner.innerHTML = CIRCULAR_SPINNER_HTML;
309
+ this.insertBefore(spinner, this.firstChild);
310
+ }
311
+ }
312
+ if (!customElements.get('db-button')) {
313
+ customElements.define('db-button', DbButton);
314
+ }
315
+
316
+ export { DbButton };