@designbasekorea/ui-wc 0.5.3 → 0.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/chunks/lottie-e273b936.js +17032 -0
  2. package/dist/esm/components/animation-background/canvas-controller.js +121 -1
  3. package/dist/esm/components/animation-background/controls.js +180 -1
  4. package/dist/esm/components/animation-background/graphite-controller.js +196 -1
  5. package/dist/esm/components/animation-background/graphite-presets.js +42 -1
  6. package/dist/esm/components/animation-background/graphite-shader.js +111 -1
  7. package/dist/esm/components/animation-background/layers.js +369 -1
  8. package/dist/esm/components/animation-background/lumina-presets.js +53 -1
  9. package/dist/esm/components/animation-background/lumina-shaders.js +181 -1
  10. package/dist/esm/components/animation-background/lumina-utils.js +60 -1
  11. package/dist/esm/components/animation-background/particle-defaults.js +36 -1
  12. package/dist/esm/components/animation-background/renderers.js +167 -1
  13. package/dist/esm/components/animation-background/shader-controller.js +154 -1
  14. package/dist/esm/components/color-picker-utils.js +134 -1
  15. package/dist/esm/components/date-picker-utils.js +140 -1
  16. package/dist/esm/components/db-accordion.js +304 -1
  17. package/dist/esm/components/db-ad-banner.js +455 -1
  18. package/dist/esm/components/db-alert.js +149 -1
  19. package/dist/esm/components/db-animation-background.js +486 -1
  20. package/dist/esm/components/db-animation-text.js +601 -1
  21. package/dist/esm/components/db-app-badge.js +88 -1
  22. package/dist/esm/components/db-audio-player.js +752 -1
  23. package/dist/esm/components/db-avatar.js +188 -1
  24. package/dist/esm/components/db-backdrop.js +139 -1
  25. package/dist/esm/components/db-badge.js +91 -1
  26. package/dist/esm/components/db-banner.js +188 -1
  27. package/dist/esm/components/db-bottom-navigation.js +146 -1
  28. package/dist/esm/components/db-bottom-sheet.js +481 -1
  29. package/dist/esm/components/db-breadcrumbs.js +329 -1
  30. package/dist/esm/components/db-button.js +316 -1
  31. package/dist/esm/components/db-calendar.js +675 -1
  32. package/dist/esm/components/db-card.js +265 -1
  33. package/dist/esm/components/db-carousel.js +264 -1
  34. package/dist/esm/components/db-checkbox.js +202 -1
  35. package/dist/esm/components/db-chip.js +104 -1
  36. package/dist/esm/components/db-code-block.js +304 -1
  37. package/dist/esm/components/db-color-picker.js +746 -1
  38. package/dist/esm/components/db-confirm.js +191 -1
  39. package/dist/esm/components/db-container.js +39 -1
  40. package/dist/esm/components/db-context-menu.js +265 -1
  41. package/dist/esm/components/db-countdown.js +146 -1
  42. package/dist/esm/components/db-cursor-follower.js +173 -1
  43. package/dist/esm/components/db-date-picker.js +837 -1
  44. package/dist/esm/components/db-divider.js +66 -1
  45. package/dist/esm/components/db-drawer.js +245 -1
  46. package/dist/esm/components/db-dropdown.js +493 -1
  47. package/dist/esm/components/db-dropzone.js +266 -1
  48. package/dist/esm/components/db-empty-state.js +97 -1
  49. package/dist/esm/components/db-file-uploader.js +256 -1
  50. package/dist/esm/components/db-floating-action-button.js +139 -1
  51. package/dist/esm/components/db-footer.js +385 -1
  52. package/dist/esm/components/db-form.js +566 -1
  53. package/dist/esm/components/db-gantt.js +882 -1
  54. package/dist/esm/components/db-gradient.js +133 -1
  55. package/dist/esm/components/db-grid-background.js +909 -1
  56. package/dist/esm/components/db-grid.js +73 -1
  57. package/dist/esm/components/db-icons.js +82 -1
  58. package/dist/esm/components/db-image-list.js +214 -1
  59. package/dist/esm/components/db-image-placeholder.js +96 -1
  60. package/dist/esm/components/db-image.js +289 -1
  61. package/dist/esm/components/db-indicator.js +517 -1
  62. package/dist/esm/components/db-input.js +420 -1
  63. package/dist/esm/components/db-kanban.js +538 -1
  64. package/dist/esm/components/db-label.js +66 -1
  65. package/dist/esm/components/db-lightbox.js +372 -1
  66. package/dist/esm/components/db-list.js +340 -1
  67. package/dist/esm/components/db-logo-svg.js +72 -1
  68. package/dist/esm/components/db-logo.js +106 -1
  69. package/dist/esm/components/db-lottie.js +109 -1
  70. package/dist/esm/components/db-markdown-editor.js +458 -1
  71. package/dist/esm/components/db-marquee.js +402 -1
  72. package/dist/esm/components/db-masonry.js +94 -1
  73. package/dist/esm/components/db-menu-item.js +211 -1
  74. package/dist/esm/components/db-modal.js +522 -1
  75. package/dist/esm/components/db-navbar.js +680 -1
  76. package/dist/esm/components/db-onboarding-modal.js +322 -1
  77. package/dist/esm/components/db-page-header.js +312 -1
  78. package/dist/esm/components/db-pagination.js +271 -1
  79. package/dist/esm/components/db-popover.js +580 -1
  80. package/dist/esm/components/db-progress-step.js +166 -1
  81. package/dist/esm/components/db-progress.js +171 -1
  82. package/dist/esm/components/db-progressbar.js +72 -1
  83. package/dist/esm/components/db-radio.js +172 -1
  84. package/dist/esm/components/db-random-gradient.js +121 -1
  85. package/dist/esm/components/db-range-slider.js +811 -1
  86. package/dist/esm/components/db-rating.js +325 -1
  87. package/dist/esm/components/db-reorder.js +286 -1
  88. package/dist/esm/components/db-resizable-panels.js +282 -1
  89. package/dist/esm/components/db-scroll-area.js +126 -1
  90. package/dist/esm/components/db-search-bar.js +668 -1
  91. package/dist/esm/components/db-section-app-download.js +101 -1
  92. package/dist/esm/components/db-section-contact.js +102 -1
  93. package/dist/esm/components/db-section-cta.js +150 -1
  94. package/dist/esm/components/db-section-faq.js +120 -1
  95. package/dist/esm/components/db-section-feature-grid.js +137 -1
  96. package/dist/esm/components/db-section-feature.js +179 -1
  97. package/dist/esm/components/db-section-hero.js +243 -1
  98. package/dist/esm/components/db-section-logo-cloud.js +138 -1
  99. package/dist/esm/components/db-section-pricing.js +166 -1
  100. package/dist/esm/components/db-section-stats.js +129 -1
  101. package/dist/esm/components/db-section-testimonials.js +252 -1
  102. package/dist/esm/components/db-section.js +385 -1
  103. package/dist/esm/components/db-segment-control.js +231 -1
  104. package/dist/esm/components/db-select.js +571 -1
  105. package/dist/esm/components/db-share-icons.js +40 -1
  106. package/dist/esm/components/db-share.js +489 -1
  107. package/dist/esm/components/db-sidebar.js +1068 -1
  108. package/dist/esm/components/db-skeleton.js +94 -1
  109. package/dist/esm/components/db-spinner.js +102 -1
  110. package/dist/esm/components/db-split-view.js +297 -1
  111. package/dist/esm/components/db-stack.js +46 -1
  112. package/dist/esm/components/db-stat.js +218 -1
  113. package/dist/esm/components/db-stepper.js +398 -1
  114. package/dist/esm/components/db-table.js +412 -1
  115. package/dist/esm/components/db-tabs.js +335 -1
  116. package/dist/esm/components/db-testimonial.js +162 -1
  117. package/dist/esm/components/db-textarea.js +233 -1
  118. package/dist/esm/components/db-time-picker.js +523 -1
  119. package/dist/esm/components/db-timeline.js +174 -1
  120. package/dist/esm/components/db-toast.js +158 -1
  121. package/dist/esm/components/db-toggle.js +162 -1
  122. package/dist/esm/components/db-toolbar.js +94 -1
  123. package/dist/esm/components/db-tooltip.js +440 -1
  124. package/dist/esm/components/db-top-banner.js +121 -1
  125. package/dist/esm/components/db-tutorial.js +324 -1
  126. package/dist/esm/components/db-video-player.js +503 -1
  127. package/dist/esm/components/db-youtube-player.js +194 -1
  128. package/dist/esm/components/highlight-code.js +65 -1
  129. package/dist/esm/components/input-validation.js +50 -1
  130. package/dist/esm/components/marketing-block-host-utils.js +9 -1
  131. package/dist/esm/components/number-scrub.js +117 -1
  132. package/dist/esm/components/random-gradient-palettes.js +67 -1
  133. package/dist/esm/components/section-block-header-utils.js +48 -1
  134. package/dist/esm/helpers/confirm.js +52 -1
  135. package/dist/esm/helpers/toast.js +73 -1
  136. package/dist/esm/index.js +111 -1
  137. package/dist/esm/node_modules/prismjs/components/prism-bash.js +235 -1
  138. package/dist/esm/node_modules/prismjs/components/prism-clike.js +31 -1
  139. package/dist/esm/node_modules/prismjs/components/prism-css.js +64 -1
  140. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +172 -1
  141. package/dist/esm/node_modules/prismjs/components/prism-json.js +27 -1
  142. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +143 -1
  143. package/dist/esm/node_modules/prismjs/components/prism-markup.js +186 -1
  144. package/dist/esm/node_modules/prismjs/components/prism-scss.js +81 -1
  145. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +15 -1
  146. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +60 -1
  147. package/dist/index.cjs +55414 -1
  148. package/dist/index.css +1 -1
  149. package/dist/index.esm.js +38284 -1
  150. package/dist/react/chunks/lottie-72a4c6d4.js +17032 -0
  151. package/dist/react/index.cjs +56503 -1
  152. package/dist/react/index.d.ts +1 -1
  153. package/dist/react/index.esm.js +39373 -1
  154. package/package.json +1 -1
  155. package/dist/chunks/lottie-2d1f6278.js +0 -1
  156. package/dist/react/chunks/lottie-14e7addb.js +0 -1
@@ -1 +1,188 @@
1
- import{createDbIcon as t}from"./db-icons.js";const e=["xs","s","m","l","xl","2xl"],a=["default","primary","success","warning","danger","info"],s=["online","offline","away","busy"],i=["#E3F2FD","#F3E5F5","#E8F5E8","#FFF3E0","#FCE4EC","#E0F2F1","#FFF8E1","#F1F8E9","#E8EAF6","#FFEBEE"],n=["#1976D2","#7B1FA2","#388E3C","#F57C00","#C2185B","#00796B","#F9A825","#689F38","#3F51B5","#D32F2F"];class DbAvatar extends HTMLElement{constructor(){super(...arguments),this.imageFailed=!1,this.imageLoaded=!1,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["src","alt","initials","size","variant","status","disabled","clickable","badge","badge-max-count","badge-variant","badge-style","badge-text"]}connectedCallback(){this.render(),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeyDown)}disconnectedCallback(){this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeyDown)}attributeChangedCallback(t){"src"===t&&(this.imageFailed=!1,this.imageLoaded=!1),this.render()}render(){const r=e.includes(this.getAttribute("size")||"m")&&this.getAttribute("size")||"m",d=a.includes(this.getAttribute("variant")||"default")&&this.getAttribute("variant")||"default",l=this.hasAttribute("disabled"),c=this.hasAttribute("clickable"),o=this.getAttribute("src"),b=this.getAttribute("initials")||"",h=Boolean(o&&!this.imageFailed),u=h&&!this.imageLoaded;if(this.className=["designbase-wc-avatar",`designbase-wc-avatar--${r}`,`designbase-wc-avatar--${d}`,c&&"designbase-wc-avatar--clickable",l&&"designbase-wc-avatar--disabled",u&&"designbase-wc-avatar--loading"].filter(Boolean).join(" "),c&&!l?(this.setAttribute("role","button"),this.tabIndex=0):(this.removeAttribute("role"),this.removeAttribute("tabindex")),this.toggleAttribute("aria-disabled",l),this.replaceChildren(),u){const t=document.createElement("div");t.className="designbase-wc-avatar__loading";const e=document.createElement("div");e.className="designbase-wc-avatar__skeleton",t.append(e),this.append(t)}if(h){const t=document.createElement("img");t.className="designbase-wc-avatar__image",t.src=o,t.alt=this.getAttribute("alt")||"아바타 이미지",t.loading="lazy",t.addEventListener("load",()=>{this.imageLoaded=!0,this.classList.remove("designbase-wc-avatar--loading"),this.querySelector(".designbase-wc-avatar__loading")?.remove()}),t.addEventListener("error",()=>{this.imageFailed=!0,this.imageLoaded=!1,this.render()}),this.append(t)}else if(b){const t=document.createElement("div");if(t.className="designbase-wc-avatar__initials","default"===d){const e=function initialsColor(t){let e=0;for(let a=0;a<t.length;a++)e=t.charCodeAt(a)+((e<<5)-e);const a=Math.abs(e)%i.length;return{backgroundColor:i[a],color:n[a]}}(b);t.style.backgroundColor=e.backgroundColor,t.style.color=e.color}t.textContent=b.charAt(0).toUpperCase(),this.append(t)}else{const e=document.createElement("div");e.className="designbase-wc-avatar__icon",e.append(t("user",function iconSize(t){return"xs"===t?12:"s"===t?16:"m"===t?20:"l"===t?24:"xl"===t?32:40}(r))),this.append(e)}const g=this.getAttribute("status")||"";if(s.includes(g)){const t=document.createElement("span");t.className=`designbase-wc-avatar__status designbase-wc-avatar__status--${g}`,this.append(t)}if(this.hasAttribute("badge")){const t=document.createElement("div");t.className="designbase-wc-avatar__badge";const e=document.createElement("db-badge");e.setAttribute("count",this.getAttribute("badge")||"0");const a=this.getAttribute("badge-style")||"number";e.setAttribute("badge-style",a),this.hasAttribute("badge-max-count")&&e.setAttribute("max-count",this.getAttribute("badge-max-count")),e.setAttribute("variant",this.getAttribute("badge-variant")||"danger"),this.hasAttribute("badge-text")&&(e.textContent=this.getAttribute("badge-text"));const s="xl"===r||"2xl"===r?"m":"s";e.setAttribute("size",s),t.append(e),this.append(t)}}}customElements.get("db-avatar")||customElements.define("db-avatar",DbAvatar);export{DbAvatar};
1
+ import { createDbIcon } from './db-icons.js';
2
+
3
+ const SIZES = ['xs', 's', 'm', 'l', 'xl', '2xl'];
4
+ const VARIANTS = ['default', 'primary', 'success', 'warning', 'danger', 'info'];
5
+ const STATUSES = ['online', 'offline', 'away', 'busy'];
6
+ const LIGHT_COLORS = ['#E3F2FD', '#F3E5F5', '#E8F5E8', '#FFF3E0', '#FCE4EC', '#E0F2F1', '#FFF8E1', '#F1F8E9', '#E8EAF6', '#FFEBEE'];
7
+ const DARK_COLORS = ['#1976D2', '#7B1FA2', '#388E3C', '#F57C00', '#C2185B', '#00796B', '#F9A825', '#689F38', '#3F51B5', '#D32F2F'];
8
+ function initialsColor(text) {
9
+ let hash = 0;
10
+ for (let i = 0; i < text.length; i++) {
11
+ hash = text.charCodeAt(i) + ((hash << 5) - hash);
12
+ }
13
+ const index = Math.abs(hash) % LIGHT_COLORS.length;
14
+ return { backgroundColor: LIGHT_COLORS[index], color: DARK_COLORS[index] };
15
+ }
16
+ function iconSize(size) {
17
+ if (size === 'xs')
18
+ return 12;
19
+ if (size === 's')
20
+ return 16;
21
+ if (size === 'm')
22
+ return 20;
23
+ if (size === 'l')
24
+ return 24;
25
+ if (size === 'xl')
26
+ return 32;
27
+ return 40;
28
+ }
29
+ class DbAvatar extends HTMLElement {
30
+ constructor() {
31
+ super(...arguments);
32
+ this.imageFailed = false;
33
+ this.imageLoaded = false;
34
+ this.handleClick = () => {
35
+ if (this.hasAttribute('disabled') || !this.hasAttribute('clickable'))
36
+ return;
37
+ this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
38
+ };
39
+ this.handleKeyDown = (event) => {
40
+ if (!this.hasAttribute('clickable') || this.hasAttribute('disabled'))
41
+ return;
42
+ if (event.key === 'Enter' || event.key === ' ') {
43
+ event.preventDefault();
44
+ this.handleClick();
45
+ }
46
+ };
47
+ }
48
+ static get observedAttributes() {
49
+ return [
50
+ 'src',
51
+ 'alt',
52
+ 'initials',
53
+ 'size',
54
+ 'variant',
55
+ 'status',
56
+ 'disabled',
57
+ 'clickable',
58
+ 'badge',
59
+ 'badge-max-count',
60
+ 'badge-variant',
61
+ 'badge-style',
62
+ 'badge-text',
63
+ ];
64
+ }
65
+ connectedCallback() {
66
+ this.render();
67
+ this.addEventListener('click', this.handleClick);
68
+ this.addEventListener('keydown', this.handleKeyDown);
69
+ }
70
+ disconnectedCallback() {
71
+ this.removeEventListener('click', this.handleClick);
72
+ this.removeEventListener('keydown', this.handleKeyDown);
73
+ }
74
+ attributeChangedCallback(name) {
75
+ if (name === 'src') {
76
+ this.imageFailed = false;
77
+ this.imageLoaded = false;
78
+ }
79
+ this.render();
80
+ }
81
+ render() {
82
+ const size = SIZES.includes((this.getAttribute('size') || 'm'))
83
+ ? this.getAttribute('size') || 'm'
84
+ : 'm';
85
+ const variant = VARIANTS.includes((this.getAttribute('variant') || 'default'))
86
+ ? this.getAttribute('variant') || 'default'
87
+ : 'default';
88
+ const disabled = this.hasAttribute('disabled');
89
+ const clickable = this.hasAttribute('clickable');
90
+ const src = this.getAttribute('src');
91
+ const initials = this.getAttribute('initials') || '';
92
+ const showImage = Boolean(src && !this.imageFailed);
93
+ const showLoading = showImage && !this.imageLoaded;
94
+ this.className = [
95
+ 'designbase-wc-avatar',
96
+ `designbase-wc-avatar--${size}`,
97
+ `designbase-wc-avatar--${variant}`,
98
+ clickable && 'designbase-wc-avatar--clickable',
99
+ disabled && 'designbase-wc-avatar--disabled',
100
+ showLoading && 'designbase-wc-avatar--loading',
101
+ ]
102
+ .filter(Boolean)
103
+ .join(' ');
104
+ if (clickable && !disabled) {
105
+ this.setAttribute('role', 'button');
106
+ this.tabIndex = 0;
107
+ }
108
+ else {
109
+ this.removeAttribute('role');
110
+ this.removeAttribute('tabindex');
111
+ }
112
+ this.toggleAttribute('aria-disabled', disabled);
113
+ this.replaceChildren();
114
+ if (showLoading) {
115
+ const loading = document.createElement('div');
116
+ loading.className = 'designbase-wc-avatar__loading';
117
+ const skeleton = document.createElement('div');
118
+ skeleton.className = 'designbase-wc-avatar__skeleton';
119
+ loading.append(skeleton);
120
+ this.append(loading);
121
+ }
122
+ if (showImage) {
123
+ const image = document.createElement('img');
124
+ image.className = 'designbase-wc-avatar__image';
125
+ image.src = src;
126
+ image.alt = this.getAttribute('alt') || '아바타 이미지';
127
+ image.loading = 'lazy';
128
+ image.addEventListener('load', () => {
129
+ this.imageLoaded = true;
130
+ this.classList.remove('designbase-wc-avatar--loading');
131
+ this.querySelector('.designbase-wc-avatar__loading')?.remove();
132
+ });
133
+ image.addEventListener('error', () => {
134
+ this.imageFailed = true;
135
+ this.imageLoaded = false;
136
+ this.render();
137
+ });
138
+ this.append(image);
139
+ }
140
+ else if (initials) {
141
+ const initialsEl = document.createElement('div');
142
+ initialsEl.className = 'designbase-wc-avatar__initials';
143
+ if (variant === 'default') {
144
+ const colors = initialsColor(initials);
145
+ initialsEl.style.backgroundColor = colors.backgroundColor;
146
+ initialsEl.style.color = colors.color;
147
+ }
148
+ initialsEl.textContent = initials.charAt(0).toUpperCase();
149
+ this.append(initialsEl);
150
+ }
151
+ else {
152
+ const iconWrap = document.createElement('div');
153
+ iconWrap.className = 'designbase-wc-avatar__icon';
154
+ iconWrap.append(createDbIcon('user', iconSize(size)));
155
+ this.append(iconWrap);
156
+ }
157
+ const status = this.getAttribute('status') || '';
158
+ if (STATUSES.includes(status)) {
159
+ const statusElement = document.createElement('span');
160
+ statusElement.className = `designbase-wc-avatar__status designbase-wc-avatar__status--${status}`;
161
+ this.append(statusElement);
162
+ }
163
+ if (this.hasAttribute('badge')) {
164
+ const badgeWrap = document.createElement('div');
165
+ badgeWrap.className = 'designbase-wc-avatar__badge';
166
+ const badge = document.createElement('db-badge');
167
+ badge.setAttribute('count', this.getAttribute('badge') || '0');
168
+ const badgeStyle = this.getAttribute('badge-style') || 'number';
169
+ badge.setAttribute('badge-style', badgeStyle);
170
+ if (this.hasAttribute('badge-max-count')) {
171
+ badge.setAttribute('max-count', this.getAttribute('badge-max-count'));
172
+ }
173
+ badge.setAttribute('variant', this.getAttribute('badge-variant') || 'danger');
174
+ if (this.hasAttribute('badge-text')) {
175
+ badge.textContent = this.getAttribute('badge-text');
176
+ }
177
+ const badgeSize = size === 'xl' || size === '2xl' ? 'm' : 's';
178
+ badge.setAttribute('size', badgeSize);
179
+ badgeWrap.append(badge);
180
+ this.append(badgeWrap);
181
+ }
182
+ }
183
+ }
184
+ if (!customElements.get('db-avatar')) {
185
+ customElements.define('db-avatar', DbAvatar);
186
+ }
187
+
188
+ export { DbAvatar };
@@ -1 +1,139 @@
1
- const t=["fade","slide","zoom","none"];class DbBackdrop extends HTMLElement{constructor(){super(...arguments),this.keyHandler=null,this.handlePortalClick=t=>{t.target===this.portal&&"true"!==this.getAttribute("disable-backdrop-click")&&(this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("db-close",{bubbles:!0,composed:!0})))}}static get observedAttributes(){return["open","blur","opacity","blur-amount","animation","animation-duration","z-index","background-color","disable-backdrop-click","disable-escape-key-down"]}get open(){return this.hasAttribute("open")&&"false"!==this.getAttribute("open")}set open(t){t?this.setAttribute("open",""):this.removeAttribute("open")}connectedCallback(){this.style.display="contents",this.syncOpenState()}disconnectedCallback(){this.detachListeners(),this.portal?.remove(),this.portal=void 0,document.body.style.overflow=""}attributeChangedCallback(){this.isConnected&&this.syncOpenState()}isOpen(){return this.open}syncOpenState(){this.isOpen()?this.render():(document.body.style.overflow="",this.detachListeners(),this.portal?.remove())}collectChildren(){return Array.from(this.children).filter(t=>!t.hasAttribute("data-wc-internal"))}attachListeners(){this.keyHandler||(this.keyHandler=t=>{"Escape"===t.key&&"true"!==this.getAttribute("disable-escape-key-down")&&(this.dispatchEvent(new CustomEvent("db-click",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("db-close",{bubbles:!0,composed:!0})))},document.addEventListener("keydown",this.keyHandler))}detachListeners(){this.keyHandler&&(document.removeEventListener("keydown",this.keyHandler),this.keyHandler=null)}render(){if(!this.isOpen())return void this.syncOpenState();const e=this.hasAttribute("blur"),s=this.getAttribute("opacity")||"0.5",i=this.getAttribute("blur-amount")||"4",r=t.includes(this.getAttribute("animation")||"fade")&&this.getAttribute("animation")||"fade",o=this.getAttribute("animation-duration")||"300",n=this.getAttribute("z-index")||"1000",a=this.getAttribute("background-color"),d=this.collectChildren();document.body.style.overflow="hidden",this.attachListeners(),this.portal||(this.portal=document.createElement("div"),this.portal.setAttribute("data-wc-internal",""),this.portal.addEventListener("click",this.handlePortalClick)),this.portal.className=["designbase-wc-backdrop",`designbase-wc-backdrop--${r}`,"designbase-wc-backdrop--open",e?"designbase-wc-backdrop--blur":""].filter(Boolean).join(" "),this.portal.setAttribute("role","presentation"),this.portal.setAttribute("aria-hidden","false"),this.portal.style.setProperty("--backdrop-opacity",s),this.portal.style.setProperty("--backdrop-blur-amount",`${i}px`),this.portal.style.setProperty("--backdrop-animation-duration",`${o}ms`),this.portal.style.setProperty("--backdrop-z-index",n),a?this.portal.style.backgroundColor=a:this.portal.style.removeProperty("background-color"),this.portal.replaceChildren(...d),this.portal.isConnected||document.body.append(this.portal)}}customElements.get("db-backdrop")||customElements.define("db-backdrop",DbBackdrop);export{DbBackdrop};
1
+ const ANIMATIONS = ['fade', 'slide', 'zoom', 'none'];
2
+ class DbBackdrop extends HTMLElement {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.keyHandler = null;
6
+ this.handlePortalClick = (event) => {
7
+ if (event.target !== this.portal)
8
+ return;
9
+ if (this.getAttribute('disable-backdrop-click') === 'true')
10
+ return;
11
+ this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
12
+ this.dispatchEvent(new CustomEvent('db-close', { bubbles: true, composed: true }));
13
+ };
14
+ }
15
+ static get observedAttributes() {
16
+ return [
17
+ 'open',
18
+ 'blur',
19
+ 'opacity',
20
+ 'blur-amount',
21
+ 'animation',
22
+ 'animation-duration',
23
+ 'z-index',
24
+ 'background-color',
25
+ 'disable-backdrop-click',
26
+ 'disable-escape-key-down',
27
+ ];
28
+ }
29
+ get open() {
30
+ return this.hasAttribute('open') && this.getAttribute('open') !== 'false';
31
+ }
32
+ set open(value) {
33
+ if (value)
34
+ this.setAttribute('open', '');
35
+ else
36
+ this.removeAttribute('open');
37
+ }
38
+ connectedCallback() {
39
+ this.style.display = 'contents';
40
+ this.syncOpenState();
41
+ }
42
+ disconnectedCallback() {
43
+ this.detachListeners();
44
+ this.portal?.remove();
45
+ this.portal = undefined;
46
+ document.body.style.overflow = '';
47
+ }
48
+ attributeChangedCallback() {
49
+ if (!this.isConnected)
50
+ return;
51
+ this.syncOpenState();
52
+ }
53
+ isOpen() {
54
+ return this.open;
55
+ }
56
+ syncOpenState() {
57
+ if (this.isOpen()) {
58
+ this.render();
59
+ return;
60
+ }
61
+ document.body.style.overflow = '';
62
+ this.detachListeners();
63
+ this.portal?.remove();
64
+ }
65
+ collectChildren() {
66
+ return Array.from(this.children).filter((child) => !child.hasAttribute('data-wc-internal'));
67
+ }
68
+ attachListeners() {
69
+ if (this.keyHandler)
70
+ return;
71
+ this.keyHandler = (event) => {
72
+ if (event.key !== 'Escape')
73
+ return;
74
+ if (this.getAttribute('disable-escape-key-down') === 'true')
75
+ return;
76
+ this.dispatchEvent(new CustomEvent('db-click', { bubbles: true, composed: true }));
77
+ this.dispatchEvent(new CustomEvent('db-close', { bubbles: true, composed: true }));
78
+ };
79
+ document.addEventListener('keydown', this.keyHandler);
80
+ }
81
+ detachListeners() {
82
+ if (!this.keyHandler)
83
+ return;
84
+ document.removeEventListener('keydown', this.keyHandler);
85
+ this.keyHandler = null;
86
+ }
87
+ render() {
88
+ if (!this.isOpen()) {
89
+ this.syncOpenState();
90
+ return;
91
+ }
92
+ const blur = this.hasAttribute('blur');
93
+ const opacity = this.getAttribute('opacity') || '0.5';
94
+ const blurAmount = this.getAttribute('blur-amount') || '4';
95
+ const animation = ANIMATIONS.includes((this.getAttribute('animation') || 'fade'))
96
+ ? this.getAttribute('animation') || 'fade'
97
+ : 'fade';
98
+ const animationDuration = this.getAttribute('animation-duration') || '300';
99
+ const zIndex = this.getAttribute('z-index') || '1000';
100
+ const backgroundColor = this.getAttribute('background-color');
101
+ const userChildren = this.collectChildren();
102
+ document.body.style.overflow = 'hidden';
103
+ this.attachListeners();
104
+ if (!this.portal) {
105
+ this.portal = document.createElement('div');
106
+ this.portal.setAttribute('data-wc-internal', '');
107
+ this.portal.addEventListener('click', this.handlePortalClick);
108
+ }
109
+ this.portal.className = [
110
+ 'designbase-wc-backdrop',
111
+ `designbase-wc-backdrop--${animation}`,
112
+ 'designbase-wc-backdrop--open',
113
+ blur ? 'designbase-wc-backdrop--blur' : '',
114
+ ]
115
+ .filter(Boolean)
116
+ .join(' ');
117
+ this.portal.setAttribute('role', 'presentation');
118
+ this.portal.setAttribute('aria-hidden', 'false');
119
+ this.portal.style.setProperty('--backdrop-opacity', opacity);
120
+ this.portal.style.setProperty('--backdrop-blur-amount', `${blurAmount}px`);
121
+ this.portal.style.setProperty('--backdrop-animation-duration', `${animationDuration}ms`);
122
+ this.portal.style.setProperty('--backdrop-z-index', zIndex);
123
+ if (backgroundColor) {
124
+ this.portal.style.backgroundColor = backgroundColor;
125
+ }
126
+ else {
127
+ this.portal.style.removeProperty('background-color');
128
+ }
129
+ this.portal.replaceChildren(...userChildren);
130
+ if (!this.portal.isConnected) {
131
+ document.body.append(this.portal);
132
+ }
133
+ }
134
+ }
135
+ if (!customElements.get('db-backdrop')) {
136
+ customElements.define('db-backdrop', DbBackdrop);
137
+ }
138
+
139
+ export { DbBackdrop };
@@ -1 +1,91 @@
1
- const t="designbase-wc-badge",e=["primary","secondary","info","success","warning","danger"],s=["s","m","l"],i=["dot","number","text","outlined"];class DbBadge extends HTMLElement{static get observedAttributes(){return["variant","size","badge-style","count","max-count","disabled"]}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 badgeStyle(){return this.getAttribute("badge-style")||"text"}set badgeStyle(t){this.setAttribute("badge-style",t)}get count(){const t=this.getAttribute("count");return null===t?void 0:Number(t)}set count(t){void 0===t?this.removeAttribute("count"):this.setAttribute("count",String(t))}get maxCount(){return Number(this.getAttribute("max-count")||99)}set maxCount(t){this.setAttribute("max-count",String(t))}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t)}connectedCallback(){this.syncAttributes()}attributeChangedCallback(t,e,s){"count"!==t&&"max-count"!==t&&"badge-style"!==t||this.syncContent(),this.syncAttributes()}syncAttributes(){this.classList.add(t),this.setAttribute("aria-disabled",String(this.disabled)),this.syncEnum("variant",this.variant,e),this.syncEnum("size",this.size,s),this.syncEnum("style",this.badgeStyle,i),this.classList.toggle(`${t}--disabled`,this.disabled),this.syncContent()}syncContent(){"number"!==this.badgeStyle||void 0===this.count?"dot"===this.badgeStyle&&(this.textContent=""):this.textContent=this.count>this.maxCount?`${this.maxCount}+`:String(this.count)}syncEnum(e,s,i){i.forEach(e=>this.classList.remove(`${t}--${e}`)),i.includes(s)?this.classList.add(`${t}--${s}`):"style"===e&&this.classList.add(`${t}--text`)}}customElements.get("db-badge")||customElements.define("db-badge",DbBadge);export{DbBadge};
1
+ const CLASS = 'designbase-wc-badge';
2
+ const VARIANTS = ['primary', 'secondary', 'info', 'success', 'warning', 'danger'];
3
+ const SIZES = ['s', 'm', 'l'];
4
+ const STYLES = ['dot', 'number', 'text', 'outlined'];
5
+ class DbBadge extends HTMLElement {
6
+ static get observedAttributes() {
7
+ return ['variant', 'size', 'badge-style', 'count', 'max-count', 'disabled'];
8
+ }
9
+ get variant() {
10
+ return this.getAttribute('variant') || 'primary';
11
+ }
12
+ set variant(value) {
13
+ this.setAttribute('variant', value);
14
+ }
15
+ get size() {
16
+ return this.getAttribute('size') || 'm';
17
+ }
18
+ set size(value) {
19
+ this.setAttribute('size', value);
20
+ }
21
+ get badgeStyle() {
22
+ return this.getAttribute('badge-style') || 'text';
23
+ }
24
+ set badgeStyle(value) {
25
+ this.setAttribute('badge-style', value);
26
+ }
27
+ get count() {
28
+ const value = this.getAttribute('count');
29
+ return value === null ? undefined : Number(value);
30
+ }
31
+ set count(value) {
32
+ if (value === undefined)
33
+ this.removeAttribute('count');
34
+ else
35
+ this.setAttribute('count', String(value));
36
+ }
37
+ get maxCount() {
38
+ return Number(this.getAttribute('max-count') || 99);
39
+ }
40
+ set maxCount(value) {
41
+ this.setAttribute('max-count', String(value));
42
+ }
43
+ get disabled() {
44
+ return this.hasAttribute('disabled');
45
+ }
46
+ set disabled(value) {
47
+ this.toggleAttribute('disabled', value);
48
+ }
49
+ connectedCallback() {
50
+ this.syncAttributes();
51
+ }
52
+ attributeChangedCallback(name, _oldValue, _newValue) {
53
+ if (name === 'count' || name === 'max-count' || name === 'badge-style') {
54
+ this.syncContent();
55
+ }
56
+ this.syncAttributes();
57
+ }
58
+ syncAttributes() {
59
+ this.classList.add(CLASS);
60
+ this.setAttribute('aria-disabled', String(this.disabled));
61
+ this.syncEnum('variant', this.variant, VARIANTS);
62
+ this.syncEnum('size', this.size, SIZES);
63
+ this.syncEnum('style', this.badgeStyle, STYLES);
64
+ this.classList.toggle(`${CLASS}--disabled`, this.disabled);
65
+ this.syncContent();
66
+ }
67
+ syncContent() {
68
+ if (this.badgeStyle === 'number' && this.count !== undefined) {
69
+ this.textContent =
70
+ this.count > this.maxCount ? `${this.maxCount}+` : String(this.count);
71
+ return;
72
+ }
73
+ if (this.badgeStyle === 'dot') {
74
+ this.textContent = '';
75
+ }
76
+ }
77
+ syncEnum(name, value, values) {
78
+ values.forEach((item) => this.classList.remove(`${CLASS}--${item}`));
79
+ if (values.includes(value)) {
80
+ this.classList.add(`${CLASS}--${value}`);
81
+ }
82
+ else if (name === 'style') {
83
+ this.classList.add(`${CLASS}--text`);
84
+ }
85
+ }
86
+ }
87
+ if (!customElements.get('db-badge')) {
88
+ customElements.define('db-badge', DbBadge);
89
+ }
90
+
91
+ export { DbBadge };
@@ -1 +1,188 @@
1
- import{createDbIcon as e}from"./db-icons.js";const t={primary:"primary",secondary:"secondary",outline:"tertiary",ghost:"ghost"},n={s:"s",sm:"s",m:"m",md:"m",l:"l",lg:"l"};class DbBanner extends HTMLElement{static get observedAttributes(){return["title","description","icon","image","image-alt","actions","size","variant","background-image"]}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}parseActions(){const e=this.getAttribute("actions");if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}getIconSize(e){return"s"===e?16:"l"===e?24:20}getActionIconSize(e){return"s"===e?16:"l"===e?20:18}resolveIconName(e){if(e)return e in{close:1,"info-filled":1}?e:void 0}createActionControl(t,n,a,s){const i=this.resolveIconName(t.icon),r=Boolean(t.iconOnly&&i);if(t.href){const n=document.createElement("a");return n.className=`designbase-wc-button designbase-wc-button--${a} designbase-wc-button--${s}`,r&&n.classList.add("designbase-wc-button--icon-only"),n.href=t.href,n.setAttribute("aria-label",t.text),r&&i?n.append(e(i,this.getActionIconSize(s))):n.textContent=t.text,t.external&&(n.target="_blank",n.rel="noopener noreferrer"),n}const c=document.createElement("db-button");return c.setAttribute("variant",a),c.setAttribute("size",s),r?(c.setAttribute("icon-only",""),c.setAttribute("aria-label",t.text),i&&c.append(e(i,this.getActionIconSize(s)))):c.textContent=t.text,(e=>{e.addEventListener("db-click",()=>{this.dispatchEvent(new CustomEvent("db-action",{bubbles:!0,composed:!0,detail:{index:n,action:t}}))})})(c),c}render(){const a=this.getAttribute("title")||"",s=this.getAttribute("description")||"",i=this.getAttribute("icon"),r=this.getAttribute("image"),c=this.getAttribute("image-alt")||a||"Banner image",o=this.getAttribute("size")||"m",d=this.getAttribute("variant")||"primary",b=this.getAttribute("background-image"),l=this.parseActions();if(this.className=`designbase-wc-banner designbase-wc-banner--${o} designbase-wc-banner--${d}`,this.replaceChildren(),"image"===d&&b){const e=document.createElement("div");e.className="designbase-wc-banner__background",e.style.backgroundImage=`url(${b})`,e.style.backgroundSize="cover",e.style.backgroundPosition="center",e.style.backgroundRepeat="no-repeat",this.append(e);const t=document.createElement("div");t.className="designbase-wc-banner__overlay",this.append(t)}const m=document.createElement("div");if(m.className="designbase-wc-banner__container",i){const t=document.createElement("div");t.className="designbase-wc-banner__icon",t.append(e(i,this.getIconSize(o))),m.append(t)}if(r){const e=document.createElement("div");e.className="designbase-wc-banner__image";const t=document.createElement("img");t.src=r,t.alt=c,e.append(t),m.append(e)}const g=document.createElement("div");if(g.className="designbase-wc-banner__content",a){const e=document.createElement("h3");e.className="designbase-wc-banner__title",e.textContent=a,g.append(e)}if(s){const e=document.createElement("p");e.className="designbase-wc-banner__description",e.textContent=s,g.append(e)}if(m.append(g),l.length>0){const e=document.createElement("div");e.className="designbase-wc-banner__actions",l.forEach((a,s)=>{const i=t[a.variant||"primary"]||"primary",r=n[a.size||"sm"]||"s";e.append(this.createActionControl(a,s,i,r))}),m.append(e)}this.append(m)}}customElements.get("db-banner")||customElements.define("db-banner",DbBanner);export{DbBanner};
1
+ import { createDbIcon } from './db-icons.js';
2
+
3
+ const BUTTON_VARIANT_MAP = {
4
+ primary: 'primary',
5
+ secondary: 'secondary',
6
+ outline: 'tertiary',
7
+ ghost: 'ghost',
8
+ };
9
+ const BUTTON_SIZE_MAP = {
10
+ s: 's',
11
+ sm: 's',
12
+ m: 'm',
13
+ md: 'm',
14
+ l: 'l',
15
+ lg: 'l',
16
+ };
17
+ class DbBanner extends HTMLElement {
18
+ static get observedAttributes() {
19
+ return [
20
+ 'title',
21
+ 'description',
22
+ 'icon',
23
+ 'image',
24
+ 'image-alt',
25
+ 'actions',
26
+ 'size',
27
+ 'variant',
28
+ 'background-image',
29
+ ];
30
+ }
31
+ connectedCallback() {
32
+ this.render();
33
+ }
34
+ attributeChangedCallback() {
35
+ this.render();
36
+ }
37
+ parseActions() {
38
+ const raw = this.getAttribute('actions');
39
+ if (!raw)
40
+ return [];
41
+ try {
42
+ const parsed = JSON.parse(raw);
43
+ return Array.isArray(parsed) ? parsed : [];
44
+ }
45
+ catch {
46
+ return [];
47
+ }
48
+ }
49
+ getIconSize(size) {
50
+ if (size === 's')
51
+ return 16;
52
+ if (size === 'l')
53
+ return 24;
54
+ return 20;
55
+ }
56
+ getActionIconSize(size) {
57
+ if (size === 's')
58
+ return 16;
59
+ if (size === 'l')
60
+ return 20;
61
+ return 18;
62
+ }
63
+ resolveIconName(icon) {
64
+ if (!icon)
65
+ return undefined;
66
+ if (icon in { close: 1, 'info-filled': 1 })
67
+ return icon;
68
+ return undefined;
69
+ }
70
+ createActionControl(action, index, actionVariant, actionSize) {
71
+ const iconName = this.resolveIconName(action.icon);
72
+ const iconOnly = Boolean(action.iconOnly && iconName);
73
+ const bindClick = (element) => {
74
+ element.addEventListener('db-click', () => {
75
+ this.dispatchEvent(new CustomEvent('db-action', {
76
+ bubbles: true,
77
+ composed: true,
78
+ detail: { index, action },
79
+ }));
80
+ });
81
+ };
82
+ if (action.href) {
83
+ const link = document.createElement('a');
84
+ link.className = `designbase-wc-button designbase-wc-button--${actionVariant} designbase-wc-button--${actionSize}`;
85
+ if (iconOnly)
86
+ link.classList.add('designbase-wc-button--icon-only');
87
+ link.href = action.href;
88
+ link.setAttribute('aria-label', action.text);
89
+ if (iconOnly && iconName) {
90
+ link.append(createDbIcon(iconName, this.getActionIconSize(actionSize)));
91
+ }
92
+ else {
93
+ link.textContent = action.text;
94
+ }
95
+ if (action.external) {
96
+ link.target = '_blank';
97
+ link.rel = 'noopener noreferrer';
98
+ }
99
+ return link;
100
+ }
101
+ const button = document.createElement('db-button');
102
+ button.setAttribute('variant', actionVariant);
103
+ button.setAttribute('size', actionSize);
104
+ if (iconOnly) {
105
+ button.setAttribute('icon-only', '');
106
+ button.setAttribute('aria-label', action.text);
107
+ if (iconName)
108
+ button.append(createDbIcon(iconName, this.getActionIconSize(actionSize)));
109
+ }
110
+ else {
111
+ button.textContent = action.text;
112
+ }
113
+ bindClick(button);
114
+ return button;
115
+ }
116
+ render() {
117
+ const title = this.getAttribute('title') || '';
118
+ const description = this.getAttribute('description') || '';
119
+ const iconName = this.getAttribute('icon');
120
+ const image = this.getAttribute('image');
121
+ const imageAlt = this.getAttribute('image-alt') || title || 'Banner image';
122
+ const size = this.getAttribute('size') || 'm';
123
+ const variant = this.getAttribute('variant') || 'primary';
124
+ const backgroundImage = this.getAttribute('background-image');
125
+ const actions = this.parseActions();
126
+ this.className = `designbase-wc-banner designbase-wc-banner--${size} designbase-wc-banner--${variant}`;
127
+ this.replaceChildren();
128
+ if (variant === 'image' && backgroundImage) {
129
+ const background = document.createElement('div');
130
+ background.className = 'designbase-wc-banner__background';
131
+ background.style.backgroundImage = `url(${backgroundImage})`;
132
+ background.style.backgroundSize = 'cover';
133
+ background.style.backgroundPosition = 'center';
134
+ background.style.backgroundRepeat = 'no-repeat';
135
+ this.append(background);
136
+ const overlay = document.createElement('div');
137
+ overlay.className = 'designbase-wc-banner__overlay';
138
+ this.append(overlay);
139
+ }
140
+ const container = document.createElement('div');
141
+ container.className = 'designbase-wc-banner__container';
142
+ if (iconName) {
143
+ const iconWrap = document.createElement('div');
144
+ iconWrap.className = 'designbase-wc-banner__icon';
145
+ iconWrap.append(createDbIcon(iconName, this.getIconSize(size)));
146
+ container.append(iconWrap);
147
+ }
148
+ if (image) {
149
+ const imageWrap = document.createElement('div');
150
+ imageWrap.className = 'designbase-wc-banner__image';
151
+ const imageElement = document.createElement('img');
152
+ imageElement.src = image;
153
+ imageElement.alt = imageAlt;
154
+ imageWrap.append(imageElement);
155
+ container.append(imageWrap);
156
+ }
157
+ const content = document.createElement('div');
158
+ content.className = 'designbase-wc-banner__content';
159
+ if (title) {
160
+ const heading = document.createElement('h3');
161
+ heading.className = 'designbase-wc-banner__title';
162
+ heading.textContent = title;
163
+ content.append(heading);
164
+ }
165
+ if (description) {
166
+ const body = document.createElement('p');
167
+ body.className = 'designbase-wc-banner__description';
168
+ body.textContent = description;
169
+ content.append(body);
170
+ }
171
+ container.append(content);
172
+ if (actions.length > 0) {
173
+ const actionsWrap = document.createElement('div');
174
+ actionsWrap.className = 'designbase-wc-banner__actions';
175
+ actions.forEach((action, index) => {
176
+ const actionVariant = BUTTON_VARIANT_MAP[action.variant || 'primary'] || 'primary';
177
+ const actionSize = BUTTON_SIZE_MAP[action.size || 'sm'] || 's';
178
+ actionsWrap.append(this.createActionControl(action, index, actionVariant, actionSize));
179
+ });
180
+ container.append(actionsWrap);
181
+ }
182
+ this.append(container);
183
+ }
184
+ }
185
+ if (!customElements.get('db-banner'))
186
+ customElements.define('db-banner', DbBanner);
187
+
188
+ export { DbBanner };