@designbasekorea/ui-wc 0.5.6 → 0.6.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 (202) hide show
  1. package/dist/chunks/lottie-0e23d630.js +1 -0
  2. package/dist/esm/components/animation-background/canvas-controller.js +1 -121
  3. package/dist/esm/components/animation-background/controls.js +1 -180
  4. package/dist/esm/components/animation-background/graphite-controller.js +1 -196
  5. package/dist/esm/components/animation-background/graphite-presets.js +1 -42
  6. package/dist/esm/components/animation-background/graphite-shader.js +1 -111
  7. package/dist/esm/components/animation-background/layers.js +1 -369
  8. package/dist/esm/components/animation-background/lumina-presets.js +1 -53
  9. package/dist/esm/components/animation-background/lumina-shaders.js +1 -181
  10. package/dist/esm/components/animation-background/lumina-utils.js +1 -60
  11. package/dist/esm/components/animation-background/particle-defaults.js +1 -36
  12. package/dist/esm/components/animation-background/renderers.js +1 -167
  13. package/dist/esm/components/animation-background/shader-controller.js +1 -154
  14. package/dist/esm/components/color-picker-utils.js +1 -134
  15. package/dist/esm/components/date-picker-utils.js +1 -140
  16. package/dist/esm/components/db-accordion.js +1 -304
  17. package/dist/esm/components/db-ad-banner.js +1 -455
  18. package/dist/esm/components/db-ai-chat-list.d.ts +43 -0
  19. package/dist/esm/components/db-ai-chat-list.js +1 -0
  20. package/dist/esm/components/db-ai-chat.d.ts +159 -0
  21. package/dist/esm/components/db-ai-chat.js +1 -0
  22. package/dist/esm/components/db-alert.js +1 -149
  23. package/dist/esm/components/db-animation-background.js +1 -486
  24. package/dist/esm/components/db-animation-text.js +1 -601
  25. package/dist/esm/components/db-app-badge.js +1 -88
  26. package/dist/esm/components/db-audio-player.js +1 -752
  27. package/dist/esm/components/db-avatar.js +1 -188
  28. package/dist/esm/components/db-backdrop.js +1 -139
  29. package/dist/esm/components/db-badge.js +1 -91
  30. package/dist/esm/components/db-banner.js +1 -188
  31. package/dist/esm/components/db-bottom-navigation.js +1 -146
  32. package/dist/esm/components/db-bottom-sheet.js +1 -481
  33. package/dist/esm/components/db-breadcrumbs.js +1 -329
  34. package/dist/esm/components/db-button.js +1 -316
  35. package/dist/esm/components/db-calendar.js +1 -675
  36. package/dist/esm/components/db-card.js +1 -265
  37. package/dist/esm/components/db-carousel.js +1 -264
  38. package/dist/esm/components/db-chat-composer.d.ts +134 -0
  39. package/dist/esm/components/db-chat-composer.js +1 -0
  40. package/dist/esm/components/db-chat-list.d.ts +47 -0
  41. package/dist/esm/components/db-chat-list.js +1 -0
  42. package/dist/esm/components/db-chat-message.d.ts +39 -0
  43. package/dist/esm/components/db-chat-message.js +1 -0
  44. package/dist/esm/components/db-chat-orb.d.ts +99 -0
  45. package/dist/esm/components/db-chat-orb.js +1 -0
  46. package/dist/esm/components/db-chat-room.d.ts +71 -0
  47. package/dist/esm/components/db-chat-room.js +1 -0
  48. package/dist/esm/components/db-chat-suggestions.d.ts +44 -0
  49. package/dist/esm/components/db-chat-suggestions.js +1 -0
  50. package/dist/esm/components/db-chat-typing.d.ts +22 -0
  51. package/dist/esm/components/db-chat-typing.js +1 -0
  52. package/dist/esm/components/db-chat-welcome.d.ts +32 -0
  53. package/dist/esm/components/db-chat-welcome.js +1 -0
  54. package/dist/esm/components/db-chat-widget.d.ts +146 -0
  55. package/dist/esm/components/db-chat-widget.js +1 -0
  56. package/dist/esm/components/db-checkbox.js +1 -202
  57. package/dist/esm/components/db-chip.js +1 -104
  58. package/dist/esm/components/db-code-block.js +1 -304
  59. package/dist/esm/components/db-color-picker.js +1 -746
  60. package/dist/esm/components/db-confirm.js +1 -191
  61. package/dist/esm/components/db-container.js +1 -39
  62. package/dist/esm/components/db-context-menu.js +1 -265
  63. package/dist/esm/components/db-countdown.js +1 -146
  64. package/dist/esm/components/db-cursor-follower.js +1 -173
  65. package/dist/esm/components/db-date-picker.js +1 -837
  66. package/dist/esm/components/db-divider.js +1 -66
  67. package/dist/esm/components/db-download-progress.d.ts +89 -0
  68. package/dist/esm/components/db-download-progress.js +1 -0
  69. package/dist/esm/components/db-drawer.js +1 -245
  70. package/dist/esm/components/db-dropdown.js +1 -493
  71. package/dist/esm/components/db-dropzone.js +1 -266
  72. package/dist/esm/components/db-email-verify.d.ts +62 -0
  73. package/dist/esm/components/db-email-verify.js +1 -0
  74. package/dist/esm/components/db-empty-state.js +1 -97
  75. package/dist/esm/components/db-file-uploader.js +1 -256
  76. package/dist/esm/components/db-floating-action-button.js +1 -139
  77. package/dist/esm/components/db-footer.js +1 -385
  78. package/dist/esm/components/db-form.js +1 -566
  79. package/dist/esm/components/db-gantt.js +1 -882
  80. package/dist/esm/components/db-gradient.js +1 -133
  81. package/dist/esm/components/db-grid-background.js +1 -909
  82. package/dist/esm/components/db-grid.js +1 -73
  83. package/dist/esm/components/db-icons.d.ts +3 -0
  84. package/dist/esm/components/db-icons.js +1 -82
  85. package/dist/esm/components/db-image-list.js +1 -214
  86. package/dist/esm/components/db-image-placeholder.js +1 -96
  87. package/dist/esm/components/db-image.js +1 -289
  88. package/dist/esm/components/db-indicator.js +1 -517
  89. package/dist/esm/components/db-input.js +1 -420
  90. package/dist/esm/components/db-kanban.js +1 -538
  91. package/dist/esm/components/db-label.js +1 -66
  92. package/dist/esm/components/db-lightbox.js +1 -372
  93. package/dist/esm/components/db-list.js +1 -340
  94. package/dist/esm/components/db-logo-svg.js +1 -72
  95. package/dist/esm/components/db-logo.js +1 -106
  96. package/dist/esm/components/db-lottie.js +1 -109
  97. package/dist/esm/components/db-markdown-editor.js +1 -458
  98. package/dist/esm/components/db-marquee.js +1 -402
  99. package/dist/esm/components/db-masonry.js +1 -94
  100. package/dist/esm/components/db-menu-item.js +1 -211
  101. package/dist/esm/components/db-modal.js +1 -522
  102. package/dist/esm/components/db-navbar.js +1 -680
  103. package/dist/esm/components/db-onboarding-modal.js +1 -322
  104. package/dist/esm/components/db-otp-input.d.ts +53 -0
  105. package/dist/esm/components/db-otp-input.js +1 -0
  106. package/dist/esm/components/db-page-header.js +1 -312
  107. package/dist/esm/components/db-pagination.js +1 -271
  108. package/dist/esm/components/db-phone-verify.d.ts +61 -0
  109. package/dist/esm/components/db-phone-verify.js +1 -0
  110. package/dist/esm/components/db-popover.js +1 -580
  111. package/dist/esm/components/db-progress-step.js +1 -166
  112. package/dist/esm/components/db-progress.js +1 -171
  113. package/dist/esm/components/db-progressbar.js +1 -72
  114. package/dist/esm/components/db-radio.js +1 -172
  115. package/dist/esm/components/db-random-gradient.js +1 -121
  116. package/dist/esm/components/db-range-slider.js +1 -811
  117. package/dist/esm/components/db-rating.js +1 -325
  118. package/dist/esm/components/db-reorder.js +1 -286
  119. package/dist/esm/components/db-resizable-panels.js +1 -282
  120. package/dist/esm/components/db-scroll-area.js +1 -126
  121. package/dist/esm/components/db-search-bar.js +1 -668
  122. package/dist/esm/components/db-section-app-download.js +1 -101
  123. package/dist/esm/components/db-section-contact.js +1 -102
  124. package/dist/esm/components/db-section-cta.js +1 -150
  125. package/dist/esm/components/db-section-faq.js +1 -120
  126. package/dist/esm/components/db-section-feature-grid.js +1 -137
  127. package/dist/esm/components/db-section-feature.js +1 -179
  128. package/dist/esm/components/db-section-hero.js +1 -243
  129. package/dist/esm/components/db-section-logo-cloud.js +1 -138
  130. package/dist/esm/components/db-section-pricing.js +1 -166
  131. package/dist/esm/components/db-section-stats.js +1 -129
  132. package/dist/esm/components/db-section-testimonials.js +1 -252
  133. package/dist/esm/components/db-section.js +1 -385
  134. package/dist/esm/components/db-segment-control.js +1 -231
  135. package/dist/esm/components/db-select.js +1 -571
  136. package/dist/esm/components/db-share-icons.js +1 -40
  137. package/dist/esm/components/db-share.js +1 -489
  138. package/dist/esm/components/db-sidebar.js +1 -1068
  139. package/dist/esm/components/db-skeleton.js +1 -94
  140. package/dist/esm/components/db-spinner.js +1 -102
  141. package/dist/esm/components/db-split-view.js +1 -297
  142. package/dist/esm/components/db-stack.js +1 -46
  143. package/dist/esm/components/db-stat.js +1 -218
  144. package/dist/esm/components/db-stepper.js +1 -398
  145. package/dist/esm/components/db-table.js +1 -412
  146. package/dist/esm/components/db-tabs.js +1 -335
  147. package/dist/esm/components/db-testimonial.d.ts +2 -0
  148. package/dist/esm/components/db-testimonial.js +1 -162
  149. package/dist/esm/components/db-textarea.js +1 -233
  150. package/dist/esm/components/db-time-picker.js +1 -523
  151. package/dist/esm/components/db-timeline.js +1 -174
  152. package/dist/esm/components/db-toast.js +1 -158
  153. package/dist/esm/components/db-toggle.js +1 -162
  154. package/dist/esm/components/db-toolbar.js +1 -94
  155. package/dist/esm/components/db-tooltip.js +1 -440
  156. package/dist/esm/components/db-top-banner.js +1 -121
  157. package/dist/esm/components/db-tutorial.js +1 -324
  158. package/dist/esm/components/db-two-factor.d.ts +60 -0
  159. package/dist/esm/components/db-two-factor.js +1 -0
  160. package/dist/esm/components/db-video-player.js +1 -503
  161. package/dist/esm/components/db-youtube-player.js +1 -194
  162. package/dist/esm/components/highlight-code.js +1 -65
  163. package/dist/esm/components/input-validation.js +1 -50
  164. package/dist/esm/components/marketing-block-host-utils.js +1 -9
  165. package/dist/esm/components/number-scrub.js +1 -117
  166. package/dist/esm/components/random-gradient-palettes.js +1 -67
  167. package/dist/esm/components/section-block-header-utils.js +1 -48
  168. package/dist/esm/helpers/confirm.js +1 -52
  169. package/dist/esm/helpers/toast.js +1 -73
  170. package/dist/esm/index.d.ts +16 -0
  171. package/dist/esm/index.js +1 -111
  172. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-bash.js +1 -0
  173. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-clike.js +1 -0
  174. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-css.js +1 -0
  175. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-javascript.js +1 -0
  176. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-json.js +1 -0
  177. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-jsx.js +1 -0
  178. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-markup.js +1 -0
  179. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-scss.js +1 -0
  180. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-tsx.js +1 -0
  181. package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-typescript.js +1 -0
  182. package/dist/index.cjs +1 -55414
  183. package/dist/index.css +1 -1
  184. package/dist/index.d.ts +1091 -2
  185. package/dist/index.esm.js +1 -38284
  186. package/dist/react/chunks/lottie-14e7addb.js +1 -0
  187. package/dist/react/index.cjs +1 -56503
  188. package/dist/react/index.d.ts +1620 -54
  189. package/dist/react/index.esm.js +1 -39373
  190. package/package.json +1 -1
  191. package/dist/chunks/lottie-e273b936.js +0 -17032
  192. package/dist/esm/node_modules/prismjs/components/prism-bash.js +0 -235
  193. package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -31
  194. package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -64
  195. package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -172
  196. package/dist/esm/node_modules/prismjs/components/prism-json.js +0 -27
  197. package/dist/esm/node_modules/prismjs/components/prism-jsx.js +0 -143
  198. package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -186
  199. package/dist/esm/node_modules/prismjs/components/prism-scss.js +0 -81
  200. package/dist/esm/node_modules/prismjs/components/prism-tsx.js +0 -15
  201. package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -60
  202. package/dist/react/chunks/lottie-72a4c6d4.js +0 -17032
@@ -1,166 +1 @@
1
- import { createDbIcon } from './db-icons.js';
2
-
3
- class DbProgressStep extends HTMLElement {
4
- static get observedAttributes() {
5
- return ['items', 'size', 'layout', 'current-step', 'clickable', 'full-width', 'disabled'];
6
- }
7
- get items() {
8
- try {
9
- return JSON.parse(this.getAttribute('items') || '[]');
10
- }
11
- catch {
12
- return [];
13
- }
14
- }
15
- set items(value) {
16
- this.setAttribute('items', typeof value === 'string' ? value : JSON.stringify(value));
17
- }
18
- connectedCallback() {
19
- this.render();
20
- }
21
- attributeChangedCallback() {
22
- this.render();
23
- }
24
- resolveStatus(index, item) {
25
- const itemStatus = item.status ?? 'pending';
26
- if (itemStatus !== 'pending')
27
- return itemStatus;
28
- const current = Number(this.getAttribute('current-step') || 0);
29
- if (index < current)
30
- return 'completed';
31
- if (index === current)
32
- return 'active';
33
- return 'pending';
34
- }
35
- iconSize(size) {
36
- if (size === 's')
37
- return 12;
38
- if (size === 'l')
39
- return 20;
40
- return 16;
41
- }
42
- renderIndicatorContent(status, index, size) {
43
- const iconWrap = document.createElement('div');
44
- iconWrap.className = 'designbase-wc-progress-step__icon';
45
- if (status === 'completed') {
46
- iconWrap.append(createDbIcon('done', this.iconSize(size)));
47
- }
48
- else if (status === 'error') {
49
- iconWrap.append(createDbIcon('warning-filled', this.iconSize(size)));
50
- }
51
- else {
52
- const number = document.createElement('span');
53
- number.className = 'designbase-wc-progress-step__number';
54
- number.textContent = String(index + 1);
55
- iconWrap.append(number);
56
- }
57
- return iconWrap;
58
- }
59
- handleStepClick(item, index) {
60
- const disabled = this.hasAttribute('disabled');
61
- const clickable = this.hasAttribute('clickable');
62
- if (disabled || item.disabled || !clickable)
63
- return;
64
- this.dispatchEvent(new CustomEvent('db-step-click', {
65
- detail: { item, index },
66
- bubbles: true,
67
- composed: true,
68
- }));
69
- }
70
- render() {
71
- const size = this.getAttribute('size') || 'm';
72
- const layout = this.getAttribute('layout') || 'horizontal';
73
- const clickable = this.hasAttribute('clickable');
74
- const disabled = this.hasAttribute('disabled');
75
- const items = this.items;
76
- this.className = [
77
- 'designbase-wc-progress-step',
78
- `designbase-wc-progress-step--${size}`,
79
- `designbase-wc-progress-step--${layout}`,
80
- clickable && 'designbase-wc-progress-step--clickable',
81
- this.hasAttribute('full-width') && 'designbase-wc-progress-step--full-width',
82
- disabled && 'designbase-wc-progress-step--disabled',
83
- ]
84
- .filter(Boolean)
85
- .join(' ');
86
- this.replaceChildren();
87
- items.forEach((item, index) => {
88
- const status = this.resolveStatus(index, item);
89
- const isLast = index === items.length - 1;
90
- const isClickable = clickable && !disabled && !item.disabled;
91
- const prevStatus = index > 0 ? this.resolveStatus(index - 1, items[index - 1]) : 'pending';
92
- const connectorStatus = prevStatus === 'completed' ? 'completed' : status;
93
- const row = document.createElement('div');
94
- row.className = [
95
- 'designbase-wc-progress-step__item',
96
- `designbase-wc-progress-step__item--${status}`,
97
- isClickable && 'designbase-wc-progress-step__item--clickable',
98
- item.disabled && 'designbase-wc-progress-step__item--disabled',
99
- ]
100
- .filter(Boolean)
101
- .join(' ');
102
- const indicatorContainer = document.createElement('div');
103
- indicatorContainer.className = 'designbase-wc-progress-step__indicator-container';
104
- const indicator = document.createElement('div');
105
- indicator.className = 'designbase-wc-progress-step__indicator';
106
- if (isClickable) {
107
- indicator.tabIndex = 0;
108
- indicator.setAttribute('role', 'button');
109
- indicator.setAttribute('aria-label', `${item.title} 단계로 이동`);
110
- indicator.addEventListener('click', () => this.handleStepClick(item, index));
111
- indicator.addEventListener('keydown', (event) => {
112
- if (event.key === 'Enter' || event.key === ' ') {
113
- event.preventDefault();
114
- this.handleStepClick(item, index);
115
- }
116
- });
117
- }
118
- else {
119
- indicator.tabIndex = -1;
120
- }
121
- if (status === 'active') {
122
- const pulse = document.createElement('div');
123
- pulse.className = 'designbase-wc-progress-step__pulse';
124
- indicator.append(pulse);
125
- }
126
- indicator.append(this.renderIndicatorContent(status, index, size));
127
- indicatorContainer.append(indicator);
128
- if (!isLast) {
129
- const connector = document.createElement('div');
130
- connector.className = [
131
- 'designbase-wc-progress-step__connector',
132
- `designbase-wc-progress-step__connector--${connectorStatus}`,
133
- ].join(' ');
134
- indicatorContainer.append(connector);
135
- }
136
- row.append(indicatorContainer);
137
- const content = document.createElement('div');
138
- content.className = 'designbase-wc-progress-step__content';
139
- const header = document.createElement('div');
140
- header.className = 'designbase-wc-progress-step__header';
141
- const title = document.createElement('h3');
142
- title.className = 'designbase-wc-progress-step__title';
143
- title.textContent = item.title;
144
- header.append(title);
145
- content.append(header);
146
- if (item.description) {
147
- const description = document.createElement('p');
148
- description.className = 'designbase-wc-progress-step__description';
149
- description.textContent = item.description;
150
- content.append(description);
151
- }
152
- if (item.timestamp) {
153
- const timestamp = document.createElement('span');
154
- timestamp.className = 'designbase-wc-progress-step__timestamp';
155
- timestamp.textContent = item.timestamp;
156
- content.append(timestamp);
157
- }
158
- row.append(content);
159
- this.append(row);
160
- });
161
- }
162
- }
163
- if (!customElements.get('db-progress-step'))
164
- customElements.define('db-progress-step', DbProgressStep);
165
-
166
- export { DbProgressStep };
1
+ import{createDbIcon as e}from"./db-icons.js";class DbProgressStep extends HTMLElement{static get observedAttributes(){return["items","size","layout","current-step","clickable","full-width","disabled"]}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()}attributeChangedCallback(){this.render()}resolveStatus(e,t){const s=t.status??"pending";if("pending"!==s)return s;const n=Number(this.getAttribute("current-step")||0);return e<n?"completed":e===n?"active":"pending"}iconSize(e){return"s"===e?12:"l"===e?20:16}renderIndicatorContent(t,s,n){const i=document.createElement("div");if(i.className="designbase-wc-progress-step__icon","completed"===t)i.append(e("done",this.iconSize(n)));else if("error"===t)i.append(e("warning-filled",this.iconSize(n)));else{const e=document.createElement("span");e.className="designbase-wc-progress-step__number",e.textContent=String(s+1),i.append(e)}return i}handleStepClick(e,t){const s=this.hasAttribute("disabled"),n=this.hasAttribute("clickable");s||e.disabled||!n||this.dispatchEvent(new CustomEvent("db-step-click",{detail:{item:e,index:t},bubbles:!0,composed:!0}))}render(){const e=this.getAttribute("size")||"m",t=this.getAttribute("layout")||"horizontal",s=this.hasAttribute("clickable"),n=this.hasAttribute("disabled"),i=this.items;this.className=["designbase-wc-progress-step",`designbase-wc-progress-step--${e}`,`designbase-wc-progress-step--${t}`,s&&"designbase-wc-progress-step--clickable",this.hasAttribute("full-width")&&"designbase-wc-progress-step--full-width",n&&"designbase-wc-progress-step--disabled"].filter(Boolean).join(" "),this.replaceChildren(),i.forEach((t,r)=>{const a=this.resolveStatus(r,t),c=r===i.length-1,d=s&&!n&&!t.disabled,o="completed"===(r>0?this.resolveStatus(r-1,i[r-1]):"pending")?"completed":a,p=document.createElement("div");p.className=["designbase-wc-progress-step__item",`designbase-wc-progress-step__item--${a}`,d&&"designbase-wc-progress-step__item--clickable",t.disabled&&"designbase-wc-progress-step__item--disabled"].filter(Boolean).join(" ");const l=document.createElement("div");l.className="designbase-wc-progress-step__indicator-container";const m=document.createElement("div");if(m.className="designbase-wc-progress-step__indicator",d?(m.tabIndex=0,m.setAttribute("role","button"),m.setAttribute("aria-label",`${t.title} 단계로 이동`),m.addEventListener("click",()=>this.handleStepClick(t,r)),m.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleStepClick(t,r))})):m.tabIndex=-1,"active"===a){const e=document.createElement("div");e.className="designbase-wc-progress-step__pulse",m.append(e)}if(m.append(this.renderIndicatorContent(a,r,e)),l.append(m),!c){const e=document.createElement("div");e.className=["designbase-wc-progress-step__connector",`designbase-wc-progress-step__connector--${o}`].join(" "),l.append(e)}p.append(l);const b=document.createElement("div");b.className="designbase-wc-progress-step__content";const g=document.createElement("div");g.className="designbase-wc-progress-step__header";const u=document.createElement("h3");if(u.className="designbase-wc-progress-step__title",u.textContent=t.title,g.append(u),b.append(g),t.description){const e=document.createElement("p");e.className="designbase-wc-progress-step__description",e.textContent=t.description,b.append(e)}if(t.timestamp){const e=document.createElement("span");e.className="designbase-wc-progress-step__timestamp",e.textContent=t.timestamp,b.append(e)}p.append(b),this.append(p)})}}customElements.get("db-progress-step")||customElements.define("db-progress-step",DbProgressStep);export{DbProgressStep};
@@ -1,171 +1 @@
1
- const SIZES = ['s', 'm', 'l'];
2
- const VARIANTS = ['default', 'success', 'warning', 'danger'];
3
- const CIRCULAR_STYLES = ['default', 'minimal'];
4
- function getCircularMetrics(circularStyle, size) {
5
- if (circularStyle === 'minimal') {
6
- return { svgSize: 20, radius: 8, strokeWidth: 2, center: 10 };
7
- }
8
- switch (size) {
9
- case 's':
10
- return { svgSize: 64, radius: 26, strokeWidth: 4, center: 32 };
11
- case 'l':
12
- return { svgSize: 160, radius: 62, strokeWidth: 10, center: 80 };
13
- default:
14
- return { svgSize: 120, radius: 45, strokeWidth: 8, center: 60 };
15
- }
16
- }
17
- function createSvgCircle(className, cx, cy, radius, strokeWidth, extras) {
18
- const circle = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
19
- circle.setAttribute('class', className);
20
- circle.setAttribute('cx', String(cx));
21
- circle.setAttribute('cy', String(cy));
22
- circle.setAttribute('r', String(radius));
23
- circle.setAttribute('stroke-width', String(strokeWidth));
24
- if (extras) {
25
- Object.entries(extras).forEach(([key, value]) => circle.setAttribute(key, value));
26
- }
27
- return circle;
28
- }
29
- class DbProgress extends HTMLElement {
30
- constructor() {
31
- super(...arguments);
32
- // 재사용을 위한 DOM 참조 — 매 렌더마다 새로 만들지 않아야 width/offset 트랜지션이 부드럽다.
33
- this.structureSignature = '';
34
- this.circumference = 0;
35
- }
36
- static get observedAttributes() {
37
- return ['value', 'max', 'size', 'variant', 'type', 'circular-style', 'show-value', 'animated', 'striped', 'glow', 'gradient'];
38
- }
39
- get value() {
40
- return Number(this.getAttribute('value') || 0);
41
- }
42
- set value(value) {
43
- this.setAttribute('value', String(value));
44
- }
45
- connectedCallback() {
46
- this.render();
47
- }
48
- attributeChangedCallback() {
49
- this.render();
50
- }
51
- render() {
52
- const max = Number(this.getAttribute('max') || 100);
53
- const percentage = Math.min(Math.max((this.value / max) * 100, 0), 100);
54
- const size = this.getAttribute('size') || 'm';
55
- const variant = this.getAttribute('variant') || 'default';
56
- const type = this.getAttribute('type') || 'linear';
57
- const circularStyle = this.getAttribute('circular-style') || 'default';
58
- const resolvedSize = SIZES.includes(size) ? size : 'm';
59
- const resolvedVariant = VARIANTS.includes(variant) ? variant : 'default';
60
- const resolvedCircularStyle = CIRCULAR_STYLES.includes(circularStyle)
61
- ? circularStyle
62
- : 'default';
63
- const showValue = this.hasAttribute('show-value');
64
- this.className = [
65
- 'designbase-wc-progress',
66
- `designbase-wc-progress--size-${resolvedSize}`,
67
- `designbase-wc-progress--variant-${resolvedVariant}`,
68
- `designbase-wc-progress--type-${type}`,
69
- type === 'circular' && resolvedCircularStyle === 'minimal' ? 'designbase-wc-progress--circular-minimal' : '',
70
- this.hasAttribute('animated') ? 'designbase-wc-progress--animated' : '',
71
- this.hasAttribute('striped') ? 'designbase-wc-progress--striped' : '',
72
- this.hasAttribute('gradient') ? 'designbase-wc-progress--gradient' : '',
73
- this.hasAttribute('glow') ? 'designbase-wc-progress--glow' : '',
74
- ].filter(Boolean).join(' ');
75
- this.setAttribute('role', 'progressbar');
76
- this.setAttribute('aria-valuemin', '0');
77
- this.setAttribute('aria-valuemax', String(max));
78
- this.setAttribute('aria-valuenow', String(this.value));
79
- // 구조가 바뀔 때만 다시 만든다. 값만 바뀔 땐 in-place 업데이트로 트랜지션 유지.
80
- const signature = [type, resolvedCircularStyle, resolvedSize, showValue ? '1' : '0'].join('|');
81
- if (signature !== this.structureSignature) {
82
- this.structureSignature = signature;
83
- if (type === 'circular') {
84
- this.buildCircular(resolvedCircularStyle, resolvedSize, showValue);
85
- }
86
- else {
87
- this.buildLinear(showValue);
88
- }
89
- }
90
- if (type === 'circular') {
91
- this.updateCircular(percentage);
92
- }
93
- else {
94
- this.updateLinear(percentage);
95
- }
96
- }
97
- buildLinear(showValue) {
98
- this.circularBarEl = undefined;
99
- this.circularValueEl = undefined;
100
- const linear = document.createElement('div');
101
- linear.className = 'designbase-wc-progress__linear';
102
- const track = document.createElement('div');
103
- track.className = 'designbase-wc-progress__track';
104
- const bar = document.createElement('div');
105
- bar.className = 'designbase-wc-progress__bar';
106
- track.append(bar);
107
- linear.append(track);
108
- this.barEl = bar;
109
- if (showValue) {
110
- const value = document.createElement('span');
111
- value.className = 'designbase-wc-progress__value';
112
- linear.append(value);
113
- this.linearValueEl = value;
114
- }
115
- else {
116
- this.linearValueEl = undefined;
117
- }
118
- this.replaceChildren(linear);
119
- }
120
- updateLinear(percentage) {
121
- if (this.barEl)
122
- this.barEl.style.width = `${percentage}%`;
123
- if (this.linearValueEl)
124
- this.linearValueEl.textContent = `${Math.round(percentage)}%`;
125
- }
126
- buildCircular(circularStyle, size, showValue) {
127
- this.barEl = undefined;
128
- this.linearValueEl = undefined;
129
- const { svgSize, radius, strokeWidth, center } = getCircularMetrics(circularStyle, size);
130
- this.circumference = 2 * Math.PI * radius;
131
- const wrapper = document.createElement('div');
132
- wrapper.className = 'designbase-wc-progress__circular';
133
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
134
- svg.setAttribute('class', 'designbase-wc-progress__circular-svg');
135
- svg.setAttribute('width', String(svgSize));
136
- svg.setAttribute('height', String(svgSize));
137
- svg.setAttribute('viewBox', `0 0 ${svgSize} ${svgSize}`);
138
- svg.setAttribute('aria-hidden', 'true');
139
- const barCircle = createSvgCircle('designbase-wc-progress__circular-bar', center, center, radius, strokeWidth, {
140
- 'stroke-dasharray': String(this.circumference),
141
- 'stroke-dashoffset': String(this.circumference),
142
- transform: `rotate(-90 ${center} ${center})`,
143
- });
144
- this.circularBarEl = barCircle;
145
- svg.append(createSvgCircle('designbase-wc-progress__circular-track', center, center, radius, strokeWidth), barCircle);
146
- wrapper.append(svg);
147
- if (showValue && circularStyle !== 'minimal') {
148
- const value = document.createElement('span');
149
- value.className = 'designbase-wc-progress__circular-value';
150
- wrapper.append(value);
151
- this.circularValueEl = value;
152
- }
153
- else {
154
- this.circularValueEl = undefined;
155
- }
156
- this.replaceChildren(wrapper);
157
- }
158
- updateCircular(percentage) {
159
- if (this.circularBarEl) {
160
- const offset = this.circumference - (percentage / 100) * this.circumference;
161
- this.circularBarEl.setAttribute('stroke-dashoffset', String(offset));
162
- }
163
- if (this.circularValueEl)
164
- this.circularValueEl.textContent = `${Math.round(percentage)}%`;
165
- }
166
- }
167
- if (!customElements.get('db-progress')) {
168
- customElements.define('db-progress', DbProgress);
169
- }
170
-
171
- export { DbProgress };
1
+ const e=["s","m","l"],t=["default","success","warning","danger"],r=["default","minimal"];function createSvgCircle(e,t,r,s,i,a){const c=document.createElementNS("http://www.w3.org/2000/svg","circle");return c.setAttribute("class",e),c.setAttribute("cx",String(t)),c.setAttribute("cy",String(r)),c.setAttribute("r",String(s)),c.setAttribute("stroke-width",String(i)),a&&Object.entries(a).forEach(([e,t])=>c.setAttribute(e,t)),c}class DbProgress extends HTMLElement{constructor(){super(...arguments),this.structureSignature="",this.circumference=0}static get observedAttributes(){return["value","max","size","variant","type","circular-style","show-value","animated","striped","glow","gradient"]}get value(){return Number(this.getAttribute("value")||0)}set value(e){this.setAttribute("value",String(e))}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}render(){const s=Number(this.getAttribute("max")||100),i=Math.min(Math.max(this.value/s*100,0),100),a=this.getAttribute("size")||"m",c=this.getAttribute("variant")||"default",n=this.getAttribute("type")||"linear",u=this.getAttribute("circular-style")||"default",l=e.includes(a)?a:"m",d=t.includes(c)?c:"default",o=r.includes(u)?u:"default",g=this.hasAttribute("show-value");this.className=["designbase-wc-progress",`designbase-wc-progress--size-${l}`,`designbase-wc-progress--variant-${d}`,`designbase-wc-progress--type-${n}`,"circular"===n&&"minimal"===o?"designbase-wc-progress--circular-minimal":"",this.hasAttribute("animated")?"designbase-wc-progress--animated":"",this.hasAttribute("striped")?"designbase-wc-progress--striped":"",this.hasAttribute("gradient")?"designbase-wc-progress--gradient":"",this.hasAttribute("glow")?"designbase-wc-progress--glow":""].filter(Boolean).join(" "),this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","0"),this.setAttribute("aria-valuemax",String(s)),this.setAttribute("aria-valuenow",String(this.value));const h=[n,o,l,g?"1":"0"].join("|");h!==this.structureSignature&&(this.structureSignature=h,"circular"===n?this.buildCircular(o,l,g):this.buildLinear(g)),"circular"===n?this.updateCircular(i):this.updateLinear(i)}buildLinear(e){this.circularBarEl=void 0,this.circularValueEl=void 0;const t=document.createElement("div");t.className="designbase-wc-progress__linear";const r=document.createElement("div");r.className="designbase-wc-progress__track";const s=document.createElement("div");if(s.className="designbase-wc-progress__bar",r.append(s),t.append(r),this.barEl=s,e){const e=document.createElement("span");e.className="designbase-wc-progress__value",t.append(e),this.linearValueEl=e}else this.linearValueEl=void 0;this.replaceChildren(t)}updateLinear(e){this.barEl&&(this.barEl.style.width=`${e}%`),this.linearValueEl&&(this.linearValueEl.textContent=`${Math.round(e)}%`)}buildCircular(e,t,r){this.barEl=void 0,this.linearValueEl=void 0;const{svgSize:s,radius:i,strokeWidth:a,center:c}=function getCircularMetrics(e,t){if("minimal"===e)return{svgSize:20,radius:8,strokeWidth:2,center:10};switch(t){case"s":return{svgSize:64,radius:26,strokeWidth:4,center:32};case"l":return{svgSize:160,radius:62,strokeWidth:10,center:80};default:return{svgSize:120,radius:45,strokeWidth:8,center:60}}}(e,t);this.circumference=2*Math.PI*i;const n=document.createElement("div");n.className="designbase-wc-progress__circular";const u=document.createElementNS("http://www.w3.org/2000/svg","svg");u.setAttribute("class","designbase-wc-progress__circular-svg"),u.setAttribute("width",String(s)),u.setAttribute("height",String(s)),u.setAttribute("viewBox",`0 0 ${s} ${s}`),u.setAttribute("aria-hidden","true");const l=createSvgCircle("designbase-wc-progress__circular-bar",c,c,i,a,{"stroke-dasharray":String(this.circumference),"stroke-dashoffset":String(this.circumference),transform:`rotate(-90 ${c} ${c})`});if(this.circularBarEl=l,u.append(createSvgCircle("designbase-wc-progress__circular-track",c,c,i,a),l),n.append(u),r&&"minimal"!==e){const e=document.createElement("span");e.className="designbase-wc-progress__circular-value",n.append(e),this.circularValueEl=e}else this.circularValueEl=void 0;this.replaceChildren(n)}updateCircular(e){if(this.circularBarEl){const t=this.circumference-e/100*this.circumference;this.circularBarEl.setAttribute("stroke-dashoffset",String(t))}this.circularValueEl&&(this.circularValueEl.textContent=`${Math.round(e)}%`)}}customElements.get("db-progress")||customElements.define("db-progress",DbProgress);export{DbProgress};
@@ -1,72 +1 @@
1
- const SIZES = ['s', 'm', 'l'];
2
- const VARIANTS = ['default', 'primary', 'success', 'warning', 'danger'];
3
- const STYLES = ['solid', 'striped', 'animated'];
4
- class DbProgressbar extends HTMLElement {
5
- static get observedAttributes() {
6
- return ['value', 'min', 'max', 'size', 'variant', 'bar-style', 'show-label', 'label', 'label-position', 'full-width', 'disabled'];
7
- }
8
- connectedCallback() {
9
- this.render();
10
- }
11
- attributeChangedCallback() {
12
- this.render();
13
- }
14
- render() {
15
- const min = Number(this.getAttribute('min') || 0);
16
- const max = Number(this.getAttribute('max') || 100);
17
- const rawValue = Number(this.getAttribute('value') || 0);
18
- const value = Math.max(min, Math.min(max, rawValue));
19
- const percentage = max === min ? 0 : ((value - min) / (max - min)) * 100;
20
- const size = this.getAttribute('size') || 'm';
21
- const variant = this.getAttribute('variant') || 'default';
22
- const barStyle = this.getAttribute('bar-style') || 'solid';
23
- const labelPosition = this.getAttribute('label-position') || 'top';
24
- const showLabel = this.hasAttribute('show-label');
25
- const label = this.getAttribute('label') || (showLabel ? `${Math.round(percentage)}%` : '');
26
- const disabled = this.hasAttribute('disabled');
27
- this.className = [
28
- 'designbase-wc-progressbar',
29
- `designbase-wc-progressbar--${SIZES.includes(size) ? size : 'm'}`,
30
- `designbase-wc-progressbar--${VARIANTS.includes(variant) ? variant : 'default'}`,
31
- `designbase-wc-progressbar--${STYLES.includes(barStyle) ? barStyle : 'solid'}`,
32
- this.hasAttribute('full-width') && 'designbase-wc-progressbar--full-width',
33
- disabled && 'designbase-wc-progressbar--disabled',
34
- percentage === 100 && 'designbase-wc-progressbar--completed',
35
- ]
36
- .filter(Boolean)
37
- .join(' ');
38
- this.setAttribute('role', 'progressbar');
39
- this.setAttribute('aria-valuemin', String(min));
40
- this.setAttribute('aria-valuemax', String(max));
41
- this.setAttribute('aria-valuenow', String(value));
42
- if (label)
43
- this.setAttribute('aria-label', label);
44
- this.replaceChildren();
45
- const container = document.createElement('div');
46
- container.className = `designbase-wc-progressbar__container designbase-wc-progressbar__container--${labelPosition}`;
47
- if (label && labelPosition !== 'inside') {
48
- const labelEl = document.createElement('span');
49
- labelEl.className = `designbase-wc-progressbar__label designbase-wc-progressbar__label--${labelPosition}`;
50
- labelEl.textContent = label;
51
- container.append(labelEl);
52
- }
53
- const track = document.createElement('div');
54
- track.className = 'designbase-wc-progressbar__track';
55
- const fill = document.createElement('div');
56
- fill.className = 'designbase-wc-progressbar__fill';
57
- fill.style.width = `${percentage}%`;
58
- if (label && labelPosition === 'inside') {
59
- const inside = document.createElement('span');
60
- inside.className = 'designbase-wc-progressbar__fill-label';
61
- inside.textContent = label;
62
- fill.append(inside);
63
- }
64
- track.append(fill);
65
- container.append(track);
66
- this.append(container);
67
- }
68
- }
69
- if (!customElements.get('db-progressbar'))
70
- customElements.define('db-progressbar', DbProgressbar);
71
-
72
- export { DbProgressbar };
1
+ const e=["s","m","l"],t=["default","primary","success","warning","danger"],s=["solid","striped","animated"];class DbProgressbar extends HTMLElement{static get observedAttributes(){return["value","min","max","size","variant","bar-style","show-label","label","label-position","full-width","disabled"]}connectedCallback(){this.render()}attributeChangedCallback(){this.render()}render(){const a=Number(this.getAttribute("min")||0),r=Number(this.getAttribute("max")||100),i=Number(this.getAttribute("value")||0),n=Math.max(a,Math.min(r,i)),b=r===a?0:(n-a)/(r-a)*100,l=this.getAttribute("size")||"m",d=this.getAttribute("variant")||"default",o=this.getAttribute("bar-style")||"solid",c=this.getAttribute("label-position")||"top",g=this.hasAttribute("show-label"),u=this.getAttribute("label")||(g?`${Math.round(b)}%`:""),m=this.hasAttribute("disabled");this.className=["designbase-wc-progressbar",`designbase-wc-progressbar--${e.includes(l)?l:"m"}`,`designbase-wc-progressbar--${t.includes(d)?d:"default"}`,`designbase-wc-progressbar--${s.includes(o)?o:"solid"}`,this.hasAttribute("full-width")&&"designbase-wc-progressbar--full-width",m&&"designbase-wc-progressbar--disabled",100===b&&"designbase-wc-progressbar--completed"].filter(Boolean).join(" "),this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin",String(a)),this.setAttribute("aria-valuemax",String(r)),this.setAttribute("aria-valuenow",String(n)),u&&this.setAttribute("aria-label",u),this.replaceChildren();const p=document.createElement("div");if(p.className=`designbase-wc-progressbar__container designbase-wc-progressbar__container--${c}`,u&&"inside"!==c){const e=document.createElement("span");e.className=`designbase-wc-progressbar__label designbase-wc-progressbar__label--${c}`,e.textContent=u,p.append(e)}const h=document.createElement("div");h.className="designbase-wc-progressbar__track";const w=document.createElement("div");if(w.className="designbase-wc-progressbar__fill",w.style.width=`${b}%`,u&&"inside"===c){const e=document.createElement("span");e.className="designbase-wc-progressbar__fill-label",e.textContent=u,w.append(e)}h.append(w),p.append(h),this.append(p)}}customElements.get("db-progressbar")||customElements.define("db-progressbar",DbProgressbar);export{DbProgressbar};
@@ -1,172 +1 @@
1
- const SIZES = ['s', 'm', 'l'];
2
- class DbRadio extends HTMLElement {
3
- constructor() {
4
- super(...arguments);
5
- this.built = false;
6
- this.handleChange = () => {
7
- if (!this.input || this.disabled || this.readOnly)
8
- return;
9
- const checked = this.input.checked;
10
- this.toggleAttribute('checked', checked);
11
- this.syncVisual();
12
- this.syncClasses();
13
- this.dispatchEvent(new CustomEvent('db-change', {
14
- detail: {
15
- checked,
16
- selected: checked,
17
- value: this.getAttribute('value') || '',
18
- },
19
- bubbles: true,
20
- composed: true,
21
- }));
22
- };
23
- }
24
- static get observedAttributes() {
25
- return [
26
- 'checked',
27
- 'selected',
28
- 'default-checked',
29
- 'default-selected',
30
- 'size',
31
- 'disabled',
32
- 'readonly',
33
- 'required',
34
- 'name',
35
- 'value',
36
- 'has-label',
37
- ];
38
- }
39
- get checked() {
40
- return this.input?.checked ?? (this.hasAttribute('checked') || this.hasAttribute('selected'));
41
- }
42
- set checked(value) {
43
- this.toggleAttribute('checked', value);
44
- if (this.input) {
45
- this.input.checked = value;
46
- this.syncVisual();
47
- this.syncClasses();
48
- }
49
- }
50
- get disabled() {
51
- return this.hasAttribute('disabled');
52
- }
53
- set disabled(value) {
54
- this.toggleAttribute('disabled', value);
55
- if (this.input)
56
- this.input.disabled = value;
57
- this.syncClasses();
58
- }
59
- get readOnly() {
60
- return this.hasAttribute('readonly');
61
- }
62
- set readOnly(value) {
63
- this.toggleAttribute('readonly', value);
64
- if (this.input)
65
- this.input.readOnly = value;
66
- this.syncClasses();
67
- }
68
- get required() {
69
- return this.hasAttribute('required');
70
- }
71
- set required(value) {
72
- this.toggleAttribute('required', value);
73
- if (this.input)
74
- this.input.required = value;
75
- }
76
- get size() {
77
- return this.getAttribute('size') || 'm';
78
- }
79
- set size(value) {
80
- this.setAttribute('size', value);
81
- }
82
- connectedCallback() {
83
- this.style.display = 'contents';
84
- if (!this.built) {
85
- this.build();
86
- }
87
- this.syncState();
88
- }
89
- attributeChangedCallback(name) {
90
- if (!this.built)
91
- return;
92
- if (name === 'checked' || name === 'selected') {
93
- if (this.input) {
94
- this.input.checked = this.hasAttribute('checked') || this.hasAttribute('selected');
95
- }
96
- this.syncVisual();
97
- this.syncClasses();
98
- return;
99
- }
100
- this.syncState();
101
- }
102
- get hasLabel() {
103
- return !this.hasAttribute('has-label') || this.getAttribute('has-label') !== 'false';
104
- }
105
- build() {
106
- this.root = document.createElement('label');
107
- this.root.className = 'designbase-wc-radio';
108
- this.input = document.createElement('input');
109
- this.input.type = 'radio';
110
- this.input.className = 'designbase-wc-radio__input';
111
- this.visual = document.createElement('span');
112
- this.visual.className = 'designbase-wc-radio__visual';
113
- this.visual.setAttribute('aria-hidden', 'true');
114
- this.dot = document.createElement('span');
115
- this.dot.className = 'designbase-wc-radio__dot';
116
- this.visual.appendChild(this.dot);
117
- this.labelEl = document.createElement('span');
118
- this.labelEl.className = 'designbase-wc-radio__label';
119
- while (this.firstChild) {
120
- this.labelEl.appendChild(this.firstChild);
121
- }
122
- this.root.append(this.input, this.visual, this.labelEl);
123
- this.appendChild(this.root);
124
- this.input.addEventListener('change', this.handleChange);
125
- this.built = true;
126
- }
127
- syncState() {
128
- if (!this.root || !this.input || !this.visual)
129
- return;
130
- const checked = this.hasAttribute('checked')
131
- || this.hasAttribute('selected')
132
- || (!this.hasAttribute('checked')
133
- && !this.hasAttribute('selected')
134
- && (this.hasAttribute('default-checked') || this.hasAttribute('default-selected')));
135
- this.input.checked = checked;
136
- this.input.disabled = this.disabled;
137
- this.input.readOnly = this.readOnly;
138
- this.input.required = this.required;
139
- this.input.name = this.getAttribute('name') || '';
140
- this.input.value = this.getAttribute('value') || '';
141
- if (this.hasLabel) {
142
- this.labelEl?.removeAttribute('hidden');
143
- }
144
- else {
145
- this.labelEl?.setAttribute('hidden', '');
146
- }
147
- this.syncVisual();
148
- this.syncClasses();
149
- }
150
- syncVisual() {
151
- // Dot stays in DOM; visibility is controlled via --selected CSS.
152
- }
153
- syncClasses() {
154
- if (!this.root || !this.input)
155
- return;
156
- const size = SIZES.includes(this.size) ? this.size : 'm';
157
- const hasLabelText = this.hasLabel && Boolean(this.labelEl?.textContent?.trim());
158
- this.root.className = [
159
- 'designbase-wc-radio',
160
- `designbase-wc-radio--${size}`,
161
- this.input.checked && 'designbase-wc-radio--selected',
162
- this.disabled && 'designbase-wc-radio--disabled',
163
- this.readOnly && 'designbase-wc-radio--readonly',
164
- !hasLabelText && 'designbase-wc-radio--no-label',
165
- ].filter(Boolean).join(' ');
166
- }
167
- }
168
- if (!customElements.get('db-radio')) {
169
- customElements.define('db-radio', DbRadio);
170
- }
171
-
172
- export { DbRadio };
1
+ const t=["s","m","l"];class DbRadio extends HTMLElement{constructor(){super(...arguments),this.built=!1,this.handleChange=()=>{if(!this.input||this.disabled||this.readOnly)return;const t=this.input.checked;this.toggleAttribute("checked",t),this.syncVisual(),this.syncClasses(),this.dispatchEvent(new CustomEvent("db-change",{detail:{checked:t,selected:t,value:this.getAttribute("value")||""},bubbles:!0,composed:!0}))}}static get observedAttributes(){return["checked","selected","default-checked","default-selected","size","disabled","readonly","required","name","value","has-label"]}get checked(){return this.input?.checked??(this.hasAttribute("checked")||this.hasAttribute("selected"))}set checked(t){this.toggleAttribute("checked",t),this.input&&(this.input.checked=t,this.syncVisual(),this.syncClasses())}get disabled(){return this.hasAttribute("disabled")}set disabled(t){this.toggleAttribute("disabled",t),this.input&&(this.input.disabled=t),this.syncClasses()}get readOnly(){return this.hasAttribute("readonly")}set readOnly(t){this.toggleAttribute("readonly",t),this.input&&(this.input.readOnly=t),this.syncClasses()}get required(){return this.hasAttribute("required")}set required(t){this.toggleAttribute("required",t),this.input&&(this.input.required=t)}get size(){return this.getAttribute("size")||"m"}set size(t){this.setAttribute("size",t)}connectedCallback(){this.style.display="contents",this.built||this.build(),this.syncState()}attributeChangedCallback(t){if(this.built)return"checked"===t||"selected"===t?(this.input&&(this.input.checked=this.hasAttribute("checked")||this.hasAttribute("selected")),this.syncVisual(),void this.syncClasses()):void this.syncState()}get hasLabel(){return!this.hasAttribute("has-label")||"false"!==this.getAttribute("has-label")}build(){for(this.root=document.createElement("label"),this.root.className="designbase-wc-radio",this.input=document.createElement("input"),this.input.type="radio",this.input.className="designbase-wc-radio__input",this.visual=document.createElement("span"),this.visual.className="designbase-wc-radio__visual",this.visual.setAttribute("aria-hidden","true"),this.dot=document.createElement("span"),this.dot.className="designbase-wc-radio__dot",this.visual.appendChild(this.dot),this.labelEl=document.createElement("span"),this.labelEl.className="designbase-wc-radio__label";this.firstChild;)this.labelEl.appendChild(this.firstChild);this.root.append(this.input,this.visual,this.labelEl),this.appendChild(this.root),this.input.addEventListener("change",this.handleChange),this.built=!0}syncState(){if(!this.root||!this.input||!this.visual)return;const t=this.hasAttribute("checked")||this.hasAttribute("selected")||!this.hasAttribute("checked")&&!this.hasAttribute("selected")&&(this.hasAttribute("default-checked")||this.hasAttribute("default-selected"));this.input.checked=t,this.input.disabled=this.disabled,this.input.readOnly=this.readOnly,this.input.required=this.required,this.input.name=this.getAttribute("name")||"",this.input.value=this.getAttribute("value")||"",this.hasLabel?this.labelEl?.removeAttribute("hidden"):this.labelEl?.setAttribute("hidden",""),this.syncVisual(),this.syncClasses()}syncVisual(){}syncClasses(){if(!this.root||!this.input)return;const e=t.includes(this.size)?this.size:"m",s=this.hasLabel&&Boolean(this.labelEl?.textContent?.trim());this.root.className=["designbase-wc-radio",`designbase-wc-radio--${e}`,this.input.checked&&"designbase-wc-radio--selected",this.disabled&&"designbase-wc-radio--disabled",this.readOnly&&"designbase-wc-radio--readonly",!s&&"designbase-wc-radio--no-label"].filter(Boolean).join(" ")}}customElements.get("db-radio")||customElements.define("db-radio",DbRadio);export{DbRadio};