@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.
- package/dist/chunks/lottie-0e23d630.js +1 -0
- package/dist/esm/components/animation-background/canvas-controller.js +1 -121
- package/dist/esm/components/animation-background/controls.js +1 -180
- package/dist/esm/components/animation-background/graphite-controller.js +1 -196
- package/dist/esm/components/animation-background/graphite-presets.js +1 -42
- package/dist/esm/components/animation-background/graphite-shader.js +1 -111
- package/dist/esm/components/animation-background/layers.js +1 -369
- package/dist/esm/components/animation-background/lumina-presets.js +1 -53
- package/dist/esm/components/animation-background/lumina-shaders.js +1 -181
- package/dist/esm/components/animation-background/lumina-utils.js +1 -60
- package/dist/esm/components/animation-background/particle-defaults.js +1 -36
- package/dist/esm/components/animation-background/renderers.js +1 -167
- package/dist/esm/components/animation-background/shader-controller.js +1 -154
- package/dist/esm/components/color-picker-utils.js +1 -134
- package/dist/esm/components/date-picker-utils.js +1 -140
- package/dist/esm/components/db-accordion.js +1 -304
- package/dist/esm/components/db-ad-banner.js +1 -455
- package/dist/esm/components/db-ai-chat-list.d.ts +43 -0
- package/dist/esm/components/db-ai-chat-list.js +1 -0
- package/dist/esm/components/db-ai-chat.d.ts +159 -0
- package/dist/esm/components/db-ai-chat.js +1 -0
- package/dist/esm/components/db-alert.js +1 -149
- package/dist/esm/components/db-animation-background.js +1 -486
- package/dist/esm/components/db-animation-text.js +1 -601
- package/dist/esm/components/db-app-badge.js +1 -88
- package/dist/esm/components/db-audio-player.js +1 -752
- package/dist/esm/components/db-avatar.js +1 -188
- package/dist/esm/components/db-backdrop.js +1 -139
- package/dist/esm/components/db-badge.js +1 -91
- package/dist/esm/components/db-banner.js +1 -188
- package/dist/esm/components/db-bottom-navigation.js +1 -146
- package/dist/esm/components/db-bottom-sheet.js +1 -481
- package/dist/esm/components/db-breadcrumbs.js +1 -329
- package/dist/esm/components/db-button.js +1 -316
- package/dist/esm/components/db-calendar.js +1 -675
- package/dist/esm/components/db-card.js +1 -265
- package/dist/esm/components/db-carousel.js +1 -264
- package/dist/esm/components/db-chat-composer.d.ts +134 -0
- package/dist/esm/components/db-chat-composer.js +1 -0
- package/dist/esm/components/db-chat-list.d.ts +47 -0
- package/dist/esm/components/db-chat-list.js +1 -0
- package/dist/esm/components/db-chat-message.d.ts +39 -0
- package/dist/esm/components/db-chat-message.js +1 -0
- package/dist/esm/components/db-chat-orb.d.ts +99 -0
- package/dist/esm/components/db-chat-orb.js +1 -0
- package/dist/esm/components/db-chat-room.d.ts +71 -0
- package/dist/esm/components/db-chat-room.js +1 -0
- package/dist/esm/components/db-chat-suggestions.d.ts +44 -0
- package/dist/esm/components/db-chat-suggestions.js +1 -0
- package/dist/esm/components/db-chat-typing.d.ts +22 -0
- package/dist/esm/components/db-chat-typing.js +1 -0
- package/dist/esm/components/db-chat-welcome.d.ts +32 -0
- package/dist/esm/components/db-chat-welcome.js +1 -0
- package/dist/esm/components/db-chat-widget.d.ts +146 -0
- package/dist/esm/components/db-chat-widget.js +1 -0
- package/dist/esm/components/db-checkbox.js +1 -202
- package/dist/esm/components/db-chip.js +1 -104
- package/dist/esm/components/db-code-block.js +1 -304
- package/dist/esm/components/db-color-picker.js +1 -746
- package/dist/esm/components/db-confirm.js +1 -191
- package/dist/esm/components/db-container.js +1 -39
- package/dist/esm/components/db-context-menu.js +1 -265
- package/dist/esm/components/db-countdown.js +1 -146
- package/dist/esm/components/db-cursor-follower.js +1 -173
- package/dist/esm/components/db-date-picker.js +1 -837
- package/dist/esm/components/db-divider.js +1 -66
- package/dist/esm/components/db-download-progress.d.ts +89 -0
- package/dist/esm/components/db-download-progress.js +1 -0
- package/dist/esm/components/db-drawer.js +1 -245
- package/dist/esm/components/db-dropdown.js +1 -493
- package/dist/esm/components/db-dropzone.js +1 -266
- package/dist/esm/components/db-email-verify.d.ts +62 -0
- package/dist/esm/components/db-email-verify.js +1 -0
- package/dist/esm/components/db-empty-state.js +1 -97
- package/dist/esm/components/db-file-uploader.js +1 -256
- package/dist/esm/components/db-floating-action-button.js +1 -139
- package/dist/esm/components/db-footer.js +1 -385
- package/dist/esm/components/db-form.js +1 -566
- package/dist/esm/components/db-gantt.js +1 -882
- package/dist/esm/components/db-gradient.js +1 -133
- package/dist/esm/components/db-grid-background.js +1 -909
- package/dist/esm/components/db-grid.js +1 -73
- package/dist/esm/components/db-icons.d.ts +3 -0
- package/dist/esm/components/db-icons.js +1 -82
- package/dist/esm/components/db-image-list.js +1 -214
- package/dist/esm/components/db-image-placeholder.js +1 -96
- package/dist/esm/components/db-image.js +1 -289
- package/dist/esm/components/db-indicator.js +1 -517
- package/dist/esm/components/db-input.js +1 -420
- package/dist/esm/components/db-kanban.js +1 -538
- package/dist/esm/components/db-label.js +1 -66
- package/dist/esm/components/db-lightbox.js +1 -372
- package/dist/esm/components/db-list.js +1 -340
- package/dist/esm/components/db-logo-svg.js +1 -72
- package/dist/esm/components/db-logo.js +1 -106
- package/dist/esm/components/db-lottie.js +1 -109
- package/dist/esm/components/db-markdown-editor.js +1 -458
- package/dist/esm/components/db-marquee.js +1 -402
- package/dist/esm/components/db-masonry.js +1 -94
- package/dist/esm/components/db-menu-item.js +1 -211
- package/dist/esm/components/db-modal.js +1 -522
- package/dist/esm/components/db-navbar.js +1 -680
- package/dist/esm/components/db-onboarding-modal.js +1 -322
- package/dist/esm/components/db-otp-input.d.ts +53 -0
- package/dist/esm/components/db-otp-input.js +1 -0
- package/dist/esm/components/db-page-header.js +1 -312
- package/dist/esm/components/db-pagination.js +1 -271
- package/dist/esm/components/db-phone-verify.d.ts +61 -0
- package/dist/esm/components/db-phone-verify.js +1 -0
- package/dist/esm/components/db-popover.js +1 -580
- package/dist/esm/components/db-progress-step.js +1 -166
- package/dist/esm/components/db-progress.js +1 -171
- package/dist/esm/components/db-progressbar.js +1 -72
- package/dist/esm/components/db-radio.js +1 -172
- package/dist/esm/components/db-random-gradient.js +1 -121
- package/dist/esm/components/db-range-slider.js +1 -811
- package/dist/esm/components/db-rating.js +1 -325
- package/dist/esm/components/db-reorder.js +1 -286
- package/dist/esm/components/db-resizable-panels.js +1 -282
- package/dist/esm/components/db-scroll-area.js +1 -126
- package/dist/esm/components/db-search-bar.js +1 -668
- package/dist/esm/components/db-section-app-download.js +1 -101
- package/dist/esm/components/db-section-contact.js +1 -102
- package/dist/esm/components/db-section-cta.js +1 -150
- package/dist/esm/components/db-section-faq.js +1 -120
- package/dist/esm/components/db-section-feature-grid.js +1 -137
- package/dist/esm/components/db-section-feature.js +1 -179
- package/dist/esm/components/db-section-hero.js +1 -243
- package/dist/esm/components/db-section-logo-cloud.js +1 -138
- package/dist/esm/components/db-section-pricing.js +1 -166
- package/dist/esm/components/db-section-stats.js +1 -129
- package/dist/esm/components/db-section-testimonials.js +1 -252
- package/dist/esm/components/db-section.js +1 -385
- package/dist/esm/components/db-segment-control.js +1 -231
- package/dist/esm/components/db-select.js +1 -571
- package/dist/esm/components/db-share-icons.js +1 -40
- package/dist/esm/components/db-share.js +1 -489
- package/dist/esm/components/db-sidebar.js +1 -1068
- package/dist/esm/components/db-skeleton.js +1 -94
- package/dist/esm/components/db-spinner.js +1 -102
- package/dist/esm/components/db-split-view.js +1 -297
- package/dist/esm/components/db-stack.js +1 -46
- package/dist/esm/components/db-stat.js +1 -218
- package/dist/esm/components/db-stepper.js +1 -398
- package/dist/esm/components/db-table.js +1 -412
- package/dist/esm/components/db-tabs.js +1 -335
- package/dist/esm/components/db-testimonial.d.ts +2 -0
- package/dist/esm/components/db-testimonial.js +1 -162
- package/dist/esm/components/db-textarea.js +1 -233
- package/dist/esm/components/db-time-picker.js +1 -523
- package/dist/esm/components/db-timeline.js +1 -174
- package/dist/esm/components/db-toast.js +1 -158
- package/dist/esm/components/db-toggle.js +1 -162
- package/dist/esm/components/db-toolbar.js +1 -94
- package/dist/esm/components/db-tooltip.js +1 -440
- package/dist/esm/components/db-top-banner.js +1 -121
- package/dist/esm/components/db-tutorial.js +1 -324
- package/dist/esm/components/db-two-factor.d.ts +60 -0
- package/dist/esm/components/db-two-factor.js +1 -0
- package/dist/esm/components/db-video-player.js +1 -503
- package/dist/esm/components/db-youtube-player.js +1 -194
- package/dist/esm/components/highlight-code.js +1 -65
- package/dist/esm/components/input-validation.js +1 -50
- package/dist/esm/components/marketing-block-host-utils.js +1 -9
- package/dist/esm/components/number-scrub.js +1 -117
- package/dist/esm/components/random-gradient-palettes.js +1 -67
- package/dist/esm/components/section-block-header-utils.js +1 -48
- package/dist/esm/helpers/confirm.js +1 -52
- package/dist/esm/helpers/toast.js +1 -73
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +1 -111
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-bash.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-clike.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-css.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-javascript.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-json.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-jsx.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-markup.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-scss.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-tsx.js +1 -0
- package/dist/esm/node_modules/.pnpm/prismjs@1.30.0/node_modules/prismjs/components/prism-typescript.js +1 -0
- package/dist/index.cjs +1 -55414
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1091 -2
- package/dist/index.esm.js +1 -38284
- package/dist/react/chunks/lottie-14e7addb.js +1 -0
- package/dist/react/index.cjs +1 -56503
- package/dist/react/index.d.ts +1620 -54
- package/dist/react/index.esm.js +1 -39373
- package/package.json +1 -1
- package/dist/chunks/lottie-e273b936.js +0 -17032
- package/dist/esm/node_modules/prismjs/components/prism-bash.js +0 -235
- package/dist/esm/node_modules/prismjs/components/prism-clike.js +0 -31
- package/dist/esm/node_modules/prismjs/components/prism-css.js +0 -64
- package/dist/esm/node_modules/prismjs/components/prism-javascript.js +0 -172
- package/dist/esm/node_modules/prismjs/components/prism-json.js +0 -27
- package/dist/esm/node_modules/prismjs/components/prism-jsx.js +0 -143
- package/dist/esm/node_modules/prismjs/components/prism-markup.js +0 -186
- package/dist/esm/node_modules/prismjs/components/prism-scss.js +0 -81
- package/dist/esm/node_modules/prismjs/components/prism-tsx.js +0 -15
- package/dist/esm/node_modules/prismjs/components/prism-typescript.js +0 -60
- package/dist/react/chunks/lottie-72a4c6d4.js +0 -17032
|
@@ -1,517 +1 @@
|
|
|
1
|
-
import { createDbIcon } from './db-icons.js';
|
|
2
|
-
|
|
3
|
-
const TYPES = ['dots', 'numbers', 'line', 'dot-line', 'slide', 'fill', 'combined'];
|
|
4
|
-
const SIZES = ['s', 'm', 'l'];
|
|
5
|
-
const DIRECTIONS = ['horizontal', 'vertical'];
|
|
6
|
-
class DbIndicator extends HTMLElement {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(...arguments);
|
|
9
|
-
this.timerFrame = 0;
|
|
10
|
-
this.progress = 0;
|
|
11
|
-
this.pausedProgress = 0;
|
|
12
|
-
this.activeStep = 0;
|
|
13
|
-
this.isPlayingInternal = false;
|
|
14
|
-
}
|
|
15
|
-
static get observedAttributes() {
|
|
16
|
-
return [
|
|
17
|
-
'total',
|
|
18
|
-
'current',
|
|
19
|
-
'default-current',
|
|
20
|
-
'indicator-type',
|
|
21
|
-
'type',
|
|
22
|
-
'size',
|
|
23
|
-
'direction',
|
|
24
|
-
'number-background',
|
|
25
|
-
'playback',
|
|
26
|
-
'clickable',
|
|
27
|
-
'timer',
|
|
28
|
-
'timer-duration',
|
|
29
|
-
'auto-roll',
|
|
30
|
-
'playing',
|
|
31
|
-
'default-playing',
|
|
32
|
-
'playback-disabled',
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
get total() {
|
|
36
|
-
return Math.max(1, Number(this.getAttribute('total') || 1));
|
|
37
|
-
}
|
|
38
|
-
set total(value) {
|
|
39
|
-
this.setAttribute('total', String(value));
|
|
40
|
-
}
|
|
41
|
-
normalizeStep(step) {
|
|
42
|
-
const total = this.total;
|
|
43
|
-
return ((step % total) + total) % total;
|
|
44
|
-
}
|
|
45
|
-
get isCurrentControlled() {
|
|
46
|
-
return this.hasAttribute('current');
|
|
47
|
-
}
|
|
48
|
-
get isPlayingControlled() {
|
|
49
|
-
return this.hasAttribute('playing');
|
|
50
|
-
}
|
|
51
|
-
get resolvedCurrent() {
|
|
52
|
-
if (this.isCurrentControlled) {
|
|
53
|
-
return this.normalizeStep(Number(this.getAttribute('current') || 0));
|
|
54
|
-
}
|
|
55
|
-
return this.activeStep;
|
|
56
|
-
}
|
|
57
|
-
get resolvedPlaying() {
|
|
58
|
-
if (this.isPlayingControlled) {
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
return this.isPlayingInternal;
|
|
62
|
-
}
|
|
63
|
-
get indicatorType() {
|
|
64
|
-
const value = this.getAttribute('indicator-type') || this.getAttribute('type') || 'dots';
|
|
65
|
-
return TYPES.includes(value) ? value : 'dots';
|
|
66
|
-
}
|
|
67
|
-
get size() {
|
|
68
|
-
const value = this.getAttribute('size') || 'm';
|
|
69
|
-
return SIZES.includes(value) ? value : 'm';
|
|
70
|
-
}
|
|
71
|
-
set size(value) {
|
|
72
|
-
this.setAttribute('size', value);
|
|
73
|
-
}
|
|
74
|
-
get direction() {
|
|
75
|
-
const value = this.getAttribute('direction') || 'horizontal';
|
|
76
|
-
return DIRECTIONS.includes(value) ? value : 'horizontal';
|
|
77
|
-
}
|
|
78
|
-
set direction(value) {
|
|
79
|
-
this.setAttribute('direction', value);
|
|
80
|
-
}
|
|
81
|
-
get numberBackground() {
|
|
82
|
-
return this.hasAttribute('number-background');
|
|
83
|
-
}
|
|
84
|
-
set numberBackground(value) {
|
|
85
|
-
this.toggleAttribute('number-background', Boolean(value));
|
|
86
|
-
}
|
|
87
|
-
get playback() {
|
|
88
|
-
return this.hasAttribute('playback');
|
|
89
|
-
}
|
|
90
|
-
set playback(value) {
|
|
91
|
-
this.toggleAttribute('playback', Boolean(value));
|
|
92
|
-
}
|
|
93
|
-
get clickable() {
|
|
94
|
-
return this.hasAttribute('clickable');
|
|
95
|
-
}
|
|
96
|
-
set clickable(value) {
|
|
97
|
-
this.toggleAttribute('clickable', Boolean(value));
|
|
98
|
-
}
|
|
99
|
-
get timer() {
|
|
100
|
-
return this.hasAttribute('timer');
|
|
101
|
-
}
|
|
102
|
-
set timer(value) {
|
|
103
|
-
this.toggleAttribute('timer', Boolean(value));
|
|
104
|
-
}
|
|
105
|
-
connectedCallback() {
|
|
106
|
-
this.activeStep = this.normalizeStep(Number(this.getAttribute('default-current') || 0));
|
|
107
|
-
this.isPlayingInternal = this.hasAttribute('default-playing');
|
|
108
|
-
this.render();
|
|
109
|
-
this.startTimer();
|
|
110
|
-
}
|
|
111
|
-
disconnectedCallback() {
|
|
112
|
-
cancelAnimationFrame(this.timerFrame);
|
|
113
|
-
}
|
|
114
|
-
attributeChangedCallback(name) {
|
|
115
|
-
if (!this.isConnected)
|
|
116
|
-
return;
|
|
117
|
-
if (name === 'current' && this.isCurrentControlled) {
|
|
118
|
-
this.resetProgress();
|
|
119
|
-
this.render();
|
|
120
|
-
this.startTimer();
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
if (name === 'playing') {
|
|
124
|
-
if (!this.resolvedPlaying) {
|
|
125
|
-
this.pausedProgress = this.progress;
|
|
126
|
-
}
|
|
127
|
-
this.syncRootClasses();
|
|
128
|
-
this.syncPlaybackButton();
|
|
129
|
-
this.startTimer();
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
if (name === 'default-current' && !this.isCurrentControlled) {
|
|
133
|
-
this.activeStep = this.normalizeStep(Number(this.getAttribute('default-current') || 0));
|
|
134
|
-
this.resetProgress();
|
|
135
|
-
this.render();
|
|
136
|
-
this.startTimer();
|
|
137
|
-
return;
|
|
138
|
-
}
|
|
139
|
-
if (name === 'default-playing' && !this.isPlayingControlled) {
|
|
140
|
-
this.isPlayingInternal = this.hasAttribute('default-playing');
|
|
141
|
-
this.syncRootClasses();
|
|
142
|
-
this.syncPlaybackButton();
|
|
143
|
-
this.startTimer();
|
|
144
|
-
return;
|
|
145
|
-
}
|
|
146
|
-
if (name === 'timer' || name === 'timer-duration' || name === 'auto-roll') {
|
|
147
|
-
this.resetProgress();
|
|
148
|
-
this.render();
|
|
149
|
-
this.startTimer();
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
this.render();
|
|
153
|
-
this.startTimer();
|
|
154
|
-
}
|
|
155
|
-
resetProgress() {
|
|
156
|
-
this.pausedProgress = 0;
|
|
157
|
-
this.progress = 0;
|
|
158
|
-
}
|
|
159
|
-
emitChange(current) {
|
|
160
|
-
const detail = { current, index: current };
|
|
161
|
-
this.dispatchEvent(new CustomEvent('db-change', { detail, bubbles: true, composed: true }));
|
|
162
|
-
this.dispatchEvent(new CustomEvent('db-current-change', { detail, bubbles: true, composed: true }));
|
|
163
|
-
}
|
|
164
|
-
goToStep(step) {
|
|
165
|
-
const normalized = this.normalizeStep(step);
|
|
166
|
-
if (!this.isCurrentControlled) {
|
|
167
|
-
this.activeStep = normalized;
|
|
168
|
-
this.resetProgress();
|
|
169
|
-
this.render();
|
|
170
|
-
this.startTimer();
|
|
171
|
-
}
|
|
172
|
-
this.emitChange(normalized);
|
|
173
|
-
}
|
|
174
|
-
startTimer() {
|
|
175
|
-
cancelAnimationFrame(this.timerFrame);
|
|
176
|
-
if (!this.timer || !this.resolvedPlaying || !this.isConnected)
|
|
177
|
-
return;
|
|
178
|
-
const duration = Number(this.getAttribute('timer-duration') || 3000);
|
|
179
|
-
const start = Date.now() - this.pausedProgress * duration;
|
|
180
|
-
const tick = () => {
|
|
181
|
-
const elapsed = Date.now() - start;
|
|
182
|
-
const ratio = Math.min(elapsed / duration, 1);
|
|
183
|
-
this.progress = ratio;
|
|
184
|
-
this.pausedProgress = ratio;
|
|
185
|
-
this.updateTimerVisuals();
|
|
186
|
-
if (ratio < 1) {
|
|
187
|
-
this.timerFrame = requestAnimationFrame(tick);
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
this.dispatchEvent(new CustomEvent('db-timer-complete', {
|
|
191
|
-
detail: { step: this.resolvedCurrent },
|
|
192
|
-
bubbles: true,
|
|
193
|
-
composed: true,
|
|
194
|
-
}));
|
|
195
|
-
this.resetProgress();
|
|
196
|
-
if (this.getAttribute('auto-roll') !== 'false') {
|
|
197
|
-
this.goToStep(this.resolvedCurrent + 1);
|
|
198
|
-
return;
|
|
199
|
-
}
|
|
200
|
-
this.render();
|
|
201
|
-
};
|
|
202
|
-
this.timerFrame = requestAnimationFrame(tick);
|
|
203
|
-
}
|
|
204
|
-
updateTimerVisuals() {
|
|
205
|
-
const fills = this.querySelectorAll('.designbase-wc-indicator__line-fill, .designbase-wc-indicator__track-fill, .designbase-wc-indicator__dot-line-fill');
|
|
206
|
-
fills.forEach((fill) => {
|
|
207
|
-
fill.style.transform =
|
|
208
|
-
this.direction === 'vertical' ? `scaleY(${this.progress})` : `scaleX(${this.progress})`;
|
|
209
|
-
});
|
|
210
|
-
const fillBar = this.querySelector('.designbase-wc-indicator__track-progress');
|
|
211
|
-
if (fillBar) {
|
|
212
|
-
const size = `${this.fillRatio() * 100}%`;
|
|
213
|
-
if (this.direction === 'vertical') {
|
|
214
|
-
fillBar.style.height = size;
|
|
215
|
-
}
|
|
216
|
-
else {
|
|
217
|
-
fillBar.style.width = size;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
const ring = this.querySelector('.designbase-wc-indicator__dot-ring-progress');
|
|
221
|
-
if (ring) {
|
|
222
|
-
const radius = 15.9155;
|
|
223
|
-
const circumference = 2 * Math.PI * radius;
|
|
224
|
-
ring.setAttribute('stroke-dashoffset', String(circumference * (1 - this.progress)));
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
syncRootClasses() {
|
|
228
|
-
const type = this.indicatorType;
|
|
229
|
-
this.className = [
|
|
230
|
-
'designbase-wc-indicator',
|
|
231
|
-
`designbase-wc-indicator--${type}`,
|
|
232
|
-
type === 'combined' && 'designbase-wc-indicator--dots',
|
|
233
|
-
`designbase-wc-indicator--${this.size}`,
|
|
234
|
-
`designbase-wc-indicator--${this.direction}`,
|
|
235
|
-
this.clickable && 'designbase-wc-indicator--clickable',
|
|
236
|
-
this.timer && !this.resolvedPlaying && 'designbase-wc-indicator--paused',
|
|
237
|
-
]
|
|
238
|
-
.filter(Boolean)
|
|
239
|
-
.join(' ');
|
|
240
|
-
}
|
|
241
|
-
syncPlaybackButton() {
|
|
242
|
-
const button = this.querySelector('.designbase-wc-indicator__playback-button');
|
|
243
|
-
if (!button)
|
|
244
|
-
return;
|
|
245
|
-
button.disabled = this.hasAttribute('playback-disabled');
|
|
246
|
-
button.setAttribute('aria-label', this.resolvedPlaying ? '일시정지' : '재생');
|
|
247
|
-
button.replaceChildren(createDbIcon(this.resolvedPlaying ? 'pause' : 'play'));
|
|
248
|
-
}
|
|
249
|
-
renderDotRing() {
|
|
250
|
-
const radius = 15.9155;
|
|
251
|
-
const circumference = 2 * Math.PI * radius;
|
|
252
|
-
const wrap = document.createElement('span');
|
|
253
|
-
wrap.className = 'designbase-wc-indicator__dot-ring';
|
|
254
|
-
wrap.setAttribute('aria-hidden', 'true');
|
|
255
|
-
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
256
|
-
svg.setAttribute('class', 'designbase-wc-indicator__dot-ring-svg');
|
|
257
|
-
svg.setAttribute('viewBox', '0 0 36 36');
|
|
258
|
-
const bg = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
259
|
-
bg.setAttribute('class', 'designbase-wc-indicator__dot-ring-bg');
|
|
260
|
-
bg.setAttribute('cx', '18');
|
|
261
|
-
bg.setAttribute('cy', '18');
|
|
262
|
-
bg.setAttribute('r', String(radius));
|
|
263
|
-
bg.setAttribute('fill', 'none');
|
|
264
|
-
const progress = document.createElementNS('http://www.w3.org/2000/svg', 'circle');
|
|
265
|
-
progress.setAttribute('class', 'designbase-wc-indicator__dot-ring-progress');
|
|
266
|
-
progress.setAttribute('cx', '18');
|
|
267
|
-
progress.setAttribute('cy', '18');
|
|
268
|
-
progress.setAttribute('r', String(radius));
|
|
269
|
-
progress.setAttribute('fill', 'none');
|
|
270
|
-
progress.setAttribute('stroke-dasharray', String(circumference));
|
|
271
|
-
progress.setAttribute('stroke-dashoffset', String(circumference * (1 - this.progress)));
|
|
272
|
-
progress.setAttribute('stroke-linecap', 'round');
|
|
273
|
-
svg.append(bg, progress);
|
|
274
|
-
wrap.append(svg);
|
|
275
|
-
return wrap;
|
|
276
|
-
}
|
|
277
|
-
renderStep(index, className, content) {
|
|
278
|
-
const isActive = index === this.resolvedCurrent;
|
|
279
|
-
const element = this.clickable ? document.createElement('button') : document.createElement('span');
|
|
280
|
-
element.className = className;
|
|
281
|
-
if (this.clickable && element instanceof HTMLButtonElement) {
|
|
282
|
-
element.type = 'button';
|
|
283
|
-
element.setAttribute('aria-label', `${index + 1}단계`);
|
|
284
|
-
if (isActive)
|
|
285
|
-
element.setAttribute('aria-current', 'step');
|
|
286
|
-
element.addEventListener('click', () => {
|
|
287
|
-
this.goToStep(index);
|
|
288
|
-
this.dispatchEvent(new CustomEvent('db-step-click', {
|
|
289
|
-
detail: { current: index, index },
|
|
290
|
-
bubbles: true,
|
|
291
|
-
composed: true,
|
|
292
|
-
}));
|
|
293
|
-
});
|
|
294
|
-
}
|
|
295
|
-
else if (!isActive) {
|
|
296
|
-
element.setAttribute('aria-hidden', 'true');
|
|
297
|
-
}
|
|
298
|
-
if (content)
|
|
299
|
-
element.append(content);
|
|
300
|
-
return element;
|
|
301
|
-
}
|
|
302
|
-
renderDots() {
|
|
303
|
-
const fragment = document.createDocumentFragment();
|
|
304
|
-
const type = this.indicatorType;
|
|
305
|
-
const visualType = type === 'combined' ? 'dots' : type;
|
|
306
|
-
const timer = this.timer;
|
|
307
|
-
const playing = this.resolvedPlaying;
|
|
308
|
-
const current = this.resolvedCurrent;
|
|
309
|
-
this.direction;
|
|
310
|
-
const total = this.total;
|
|
311
|
-
if (visualType !== 'dots') {
|
|
312
|
-
return fragment;
|
|
313
|
-
}
|
|
314
|
-
for (let index = 0; index < total; index += 1) {
|
|
315
|
-
const isActive = index === current;
|
|
316
|
-
const showTimerRing = timer && isActive && playing;
|
|
317
|
-
const core = document.createElement('span');
|
|
318
|
-
core.className = 'designbase-wc-indicator__dot-core';
|
|
319
|
-
const dotContent = document.createDocumentFragment();
|
|
320
|
-
dotContent.append(core);
|
|
321
|
-
if (timer && isActive && (showTimerRing || this.progress > 0)) {
|
|
322
|
-
dotContent.append(this.renderDotRing());
|
|
323
|
-
}
|
|
324
|
-
fragment.append(this.renderStep(index, [
|
|
325
|
-
'designbase-wc-indicator__dot',
|
|
326
|
-
isActive && 'designbase-wc-indicator__dot--active',
|
|
327
|
-
]
|
|
328
|
-
.filter(Boolean)
|
|
329
|
-
.join(' '), dotContent));
|
|
330
|
-
}
|
|
331
|
-
return fragment;
|
|
332
|
-
}
|
|
333
|
-
renderPlaybackButton() {
|
|
334
|
-
const button = document.createElement('button');
|
|
335
|
-
button.type = 'button';
|
|
336
|
-
button.className = 'designbase-wc-indicator__playback-button';
|
|
337
|
-
button.disabled = this.hasAttribute('playback-disabled');
|
|
338
|
-
button.setAttribute('aria-label', this.resolvedPlaying ? '일시정지' : '재생');
|
|
339
|
-
button.append(createDbIcon(this.resolvedPlaying ? 'pause' : 'play'));
|
|
340
|
-
button.addEventListener('click', () => {
|
|
341
|
-
if (this.hasAttribute('playback-disabled'))
|
|
342
|
-
return;
|
|
343
|
-
const nextPlaying = !this.resolvedPlaying;
|
|
344
|
-
if (!this.isPlayingControlled) {
|
|
345
|
-
this.isPlayingInternal = nextPlaying;
|
|
346
|
-
if (!nextPlaying) {
|
|
347
|
-
this.pausedProgress = this.progress;
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
else if (nextPlaying) {
|
|
351
|
-
this.setAttribute('playing', '');
|
|
352
|
-
}
|
|
353
|
-
else {
|
|
354
|
-
this.removeAttribute('playing');
|
|
355
|
-
this.pausedProgress = this.progress;
|
|
356
|
-
}
|
|
357
|
-
this.syncRootClasses();
|
|
358
|
-
this.syncPlaybackButton();
|
|
359
|
-
this.startTimer();
|
|
360
|
-
this.dispatchEvent(new CustomEvent('db-playing-change', {
|
|
361
|
-
detail: { playing: nextPlaying },
|
|
362
|
-
bubbles: true,
|
|
363
|
-
composed: true,
|
|
364
|
-
}));
|
|
365
|
-
});
|
|
366
|
-
return button;
|
|
367
|
-
}
|
|
368
|
-
renderNumbers() {
|
|
369
|
-
const wrapper = document.createElement('div');
|
|
370
|
-
wrapper.className = [
|
|
371
|
-
'designbase-wc-indicator__numbers',
|
|
372
|
-
this.numberBackground && 'designbase-wc-indicator__numbers--bg',
|
|
373
|
-
]
|
|
374
|
-
.filter(Boolean)
|
|
375
|
-
.join(' ');
|
|
376
|
-
const currentEl = document.createElement('span');
|
|
377
|
-
currentEl.className = 'designbase-wc-indicator__current';
|
|
378
|
-
currentEl.textContent = String(this.resolvedCurrent + 1);
|
|
379
|
-
const separator = document.createElement('span');
|
|
380
|
-
separator.className = 'designbase-wc-indicator__separator';
|
|
381
|
-
separator.textContent = '/';
|
|
382
|
-
const totalEl = document.createElement('span');
|
|
383
|
-
totalEl.className = 'designbase-wc-indicator__total';
|
|
384
|
-
totalEl.textContent = String(this.total);
|
|
385
|
-
wrapper.append(currentEl, separator, totalEl);
|
|
386
|
-
return wrapper;
|
|
387
|
-
}
|
|
388
|
-
renderSlide() {
|
|
389
|
-
const direction = this.direction;
|
|
390
|
-
const current = this.resolvedCurrent;
|
|
391
|
-
const track = document.createElement('div');
|
|
392
|
-
track.className = 'designbase-wc-indicator__track';
|
|
393
|
-
const thumb = document.createElement('div');
|
|
394
|
-
thumb.className = 'designbase-wc-indicator__track-thumb';
|
|
395
|
-
const segmentSize = 100 / this.total;
|
|
396
|
-
if (direction === 'vertical') {
|
|
397
|
-
thumb.style.height = `${segmentSize}%`;
|
|
398
|
-
thumb.style.transform = `translateY(${current * 100}%)`;
|
|
399
|
-
}
|
|
400
|
-
else {
|
|
401
|
-
thumb.style.width = `${segmentSize}%`;
|
|
402
|
-
thumb.style.transform = `translateX(${current * 100}%)`;
|
|
403
|
-
}
|
|
404
|
-
if (this.timer && this.resolvedPlaying) {
|
|
405
|
-
const fill = document.createElement('div');
|
|
406
|
-
fill.className = 'designbase-wc-indicator__track-fill';
|
|
407
|
-
fill.style.transform = direction === 'vertical' ? `scaleY(${this.progress})` : `scaleX(${this.progress})`;
|
|
408
|
-
thumb.append(fill);
|
|
409
|
-
}
|
|
410
|
-
track.append(thumb);
|
|
411
|
-
return track;
|
|
412
|
-
}
|
|
413
|
-
renderScaleFill(className) {
|
|
414
|
-
const span = document.createElement('span');
|
|
415
|
-
span.className = className;
|
|
416
|
-
span.style.transform = this.direction === 'vertical' ? `scaleY(${this.progress})` : `scaleX(${this.progress})`;
|
|
417
|
-
return span;
|
|
418
|
-
}
|
|
419
|
-
renderLine() {
|
|
420
|
-
const fragment = document.createDocumentFragment();
|
|
421
|
-
const timer = this.timer;
|
|
422
|
-
const playing = this.resolvedPlaying;
|
|
423
|
-
const current = this.resolvedCurrent;
|
|
424
|
-
for (let index = 0; index < this.total; index += 1) {
|
|
425
|
-
const isActive = index === current;
|
|
426
|
-
const fill = timer && isActive && playing ? this.renderScaleFill('designbase-wc-indicator__line-fill') : undefined;
|
|
427
|
-
fragment.append(this.renderStep(index, [
|
|
428
|
-
'designbase-wc-indicator__line-segment',
|
|
429
|
-
isActive && !timer && 'designbase-wc-indicator__line-segment--active',
|
|
430
|
-
isActive && timer && 'designbase-wc-indicator__line-segment--current',
|
|
431
|
-
]
|
|
432
|
-
.filter(Boolean)
|
|
433
|
-
.join(' '), fill));
|
|
434
|
-
}
|
|
435
|
-
return fragment;
|
|
436
|
-
}
|
|
437
|
-
renderDotLine() {
|
|
438
|
-
const fragment = document.createDocumentFragment();
|
|
439
|
-
const timer = this.timer;
|
|
440
|
-
const playing = this.resolvedPlaying;
|
|
441
|
-
const current = this.resolvedCurrent;
|
|
442
|
-
for (let index = 0; index < this.total; index += 1) {
|
|
443
|
-
const isActive = index === current;
|
|
444
|
-
const fill = timer && isActive && playing ? this.renderScaleFill('designbase-wc-indicator__dot-line-fill') : undefined;
|
|
445
|
-
fragment.append(this.renderStep(index, [
|
|
446
|
-
'designbase-wc-indicator__dot-line-item',
|
|
447
|
-
isActive && !timer && 'designbase-wc-indicator__dot-line-item--active',
|
|
448
|
-
isActive && timer && 'designbase-wc-indicator__dot-line-item--current',
|
|
449
|
-
]
|
|
450
|
-
.filter(Boolean)
|
|
451
|
-
.join(' '), fill));
|
|
452
|
-
}
|
|
453
|
-
return fragment;
|
|
454
|
-
}
|
|
455
|
-
fillRatio() {
|
|
456
|
-
const step = this.resolvedCurrent;
|
|
457
|
-
const base = step / this.total;
|
|
458
|
-
const segment = 1 / this.total;
|
|
459
|
-
return this.timer && this.resolvedPlaying
|
|
460
|
-
? Math.min(base + segment * this.progress, 1)
|
|
461
|
-
: (step + 1) / this.total;
|
|
462
|
-
}
|
|
463
|
-
renderFill() {
|
|
464
|
-
const track = document.createElement('div');
|
|
465
|
-
track.className = 'designbase-wc-indicator__track';
|
|
466
|
-
const progress = document.createElement('div');
|
|
467
|
-
progress.className = 'designbase-wc-indicator__track-progress';
|
|
468
|
-
const size = `${this.fillRatio() * 100}%`;
|
|
469
|
-
if (this.direction === 'vertical') {
|
|
470
|
-
progress.style.height = size;
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
progress.style.width = size;
|
|
474
|
-
}
|
|
475
|
-
track.append(progress);
|
|
476
|
-
return track;
|
|
477
|
-
}
|
|
478
|
-
renderContent() {
|
|
479
|
-
const visualType = this.indicatorType === 'combined' ? 'dots' : this.indicatorType;
|
|
480
|
-
if (visualType === 'numbers')
|
|
481
|
-
return this.renderNumbers();
|
|
482
|
-
if (visualType === 'slide')
|
|
483
|
-
return this.renderSlide();
|
|
484
|
-
if (visualType === 'fill')
|
|
485
|
-
return this.renderFill();
|
|
486
|
-
if (visualType === 'line')
|
|
487
|
-
return this.renderLine();
|
|
488
|
-
if (visualType === 'dot-line')
|
|
489
|
-
return this.renderDotLine();
|
|
490
|
-
return this.renderDots();
|
|
491
|
-
}
|
|
492
|
-
render() {
|
|
493
|
-
const type = this.indicatorType;
|
|
494
|
-
const current = this.resolvedCurrent;
|
|
495
|
-
const total = this.total;
|
|
496
|
-
this.syncRootClasses();
|
|
497
|
-
this.setAttribute('role', 'progressbar');
|
|
498
|
-
this.setAttribute('aria-valuemin', '1');
|
|
499
|
-
this.setAttribute('aria-valuemax', String(total));
|
|
500
|
-
this.setAttribute('aria-valuenow', String(current + 1));
|
|
501
|
-
this.replaceChildren();
|
|
502
|
-
const showPlayback = type === 'combined' || this.playback;
|
|
503
|
-
if (showPlayback) {
|
|
504
|
-
const steps = document.createElement('div');
|
|
505
|
-
steps.className = 'designbase-wc-indicator__steps';
|
|
506
|
-
steps.append(this.renderContent());
|
|
507
|
-
this.append(steps, this.renderPlaybackButton());
|
|
508
|
-
return;
|
|
509
|
-
}
|
|
510
|
-
this.append(this.renderContent());
|
|
511
|
-
}
|
|
512
|
-
}
|
|
513
|
-
if (!customElements.get('db-indicator')) {
|
|
514
|
-
customElements.define('db-indicator', DbIndicator);
|
|
515
|
-
}
|
|
516
|
-
|
|
517
|
-
export { DbIndicator };
|
|
1
|
+
import{createDbIcon as t}from"./db-icons.js";const e=["dots","numbers","line","dot-line","slide","fill","combined"],i=["s","m","l"],s=["horizontal","vertical"];class DbIndicator extends HTMLElement{constructor(){super(...arguments),this.timerFrame=0,this.progress=0,this.pausedProgress=0,this.activeStep=0,this.isPlayingInternal=!1}static get observedAttributes(){return["total","current","default-current","indicator-type","type","size","direction","number-background","playback","clickable","timer","timer-duration","auto-roll","playing","default-playing","playback-disabled"]}get total(){return Math.max(1,Number(this.getAttribute("total")||1))}set total(t){this.setAttribute("total",String(t))}normalizeStep(t){const e=this.total;return(t%e+e)%e}get isCurrentControlled(){return this.hasAttribute("current")}get isPlayingControlled(){return this.hasAttribute("playing")}get resolvedCurrent(){return this.isCurrentControlled?this.normalizeStep(Number(this.getAttribute("current")||0)):this.activeStep}get resolvedPlaying(){return!!this.isPlayingControlled||this.isPlayingInternal}get indicatorType(){const t=this.getAttribute("indicator-type")||this.getAttribute("type")||"dots";return e.includes(t)?t:"dots"}get size(){const t=this.getAttribute("size")||"m";return i.includes(t)?t:"m"}set size(t){this.setAttribute("size",t)}get direction(){const t=this.getAttribute("direction")||"horizontal";return s.includes(t)?t:"horizontal"}set direction(t){this.setAttribute("direction",t)}get numberBackground(){return this.hasAttribute("number-background")}set numberBackground(t){this.toggleAttribute("number-background",Boolean(t))}get playback(){return this.hasAttribute("playback")}set playback(t){this.toggleAttribute("playback",Boolean(t))}get clickable(){return this.hasAttribute("clickable")}set clickable(t){this.toggleAttribute("clickable",Boolean(t))}get timer(){return this.hasAttribute("timer")}set timer(t){this.toggleAttribute("timer",Boolean(t))}connectedCallback(){this.activeStep=this.normalizeStep(Number(this.getAttribute("default-current")||0)),this.isPlayingInternal=this.hasAttribute("default-playing"),this.render(),this.startTimer()}disconnectedCallback(){cancelAnimationFrame(this.timerFrame)}attributeChangedCallback(t){if(this.isConnected){if("current"===t&&this.isCurrentControlled)return this.resetProgress(),this.render(),void this.startTimer();if("playing"===t)return this.resolvedPlaying||(this.pausedProgress=this.progress),this.syncRootClasses(),this.syncPlaybackButton(),void this.startTimer();if("default-current"===t&&!this.isCurrentControlled)return this.activeStep=this.normalizeStep(Number(this.getAttribute("default-current")||0)),this.resetProgress(),this.render(),void this.startTimer();if("default-playing"===t&&!this.isPlayingControlled)return this.isPlayingInternal=this.hasAttribute("default-playing"),this.syncRootClasses(),this.syncPlaybackButton(),void this.startTimer();if("timer"===t||"timer-duration"===t||"auto-roll"===t)return this.resetProgress(),this.render(),void this.startTimer();this.render(),this.startTimer()}}resetProgress(){this.pausedProgress=0,this.progress=0}emitChange(t){const e={current:t,index:t};this.dispatchEvent(new CustomEvent("db-change",{detail:e,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("db-current-change",{detail:e,bubbles:!0,composed:!0}))}goToStep(t){const e=this.normalizeStep(t);this.isCurrentControlled||(this.activeStep=e,this.resetProgress(),this.render(),this.startTimer()),this.emitChange(e)}startTimer(){if(cancelAnimationFrame(this.timerFrame),!this.timer||!this.resolvedPlaying||!this.isConnected)return;const t=Number(this.getAttribute("timer-duration")||3e3),e=Date.now()-this.pausedProgress*t,tick=()=>{const i=Date.now()-e,s=Math.min(i/t,1);this.progress=s,this.pausedProgress=s,this.updateTimerVisuals(),s<1?this.timerFrame=requestAnimationFrame(tick):(this.dispatchEvent(new CustomEvent("db-timer-complete",{detail:{step:this.resolvedCurrent},bubbles:!0,composed:!0})),this.resetProgress(),"false"===this.getAttribute("auto-roll")?this.render():this.goToStep(this.resolvedCurrent+1))};this.timerFrame=requestAnimationFrame(tick)}updateTimerVisuals(){this.querySelectorAll(".designbase-wc-indicator__line-fill, .designbase-wc-indicator__track-fill, .designbase-wc-indicator__dot-line-fill").forEach(t=>{t.style.transform="vertical"===this.direction?`scaleY(${this.progress})`:`scaleX(${this.progress})`});const t=this.querySelector(".designbase-wc-indicator__track-progress");if(t){const e=100*this.fillRatio()+"%";"vertical"===this.direction?t.style.height=e:t.style.width=e}const e=this.querySelector(".designbase-wc-indicator__dot-ring-progress");if(e){const t=15.9155,i=2*Math.PI*t;e.setAttribute("stroke-dashoffset",String(i*(1-this.progress)))}}syncRootClasses(){const t=this.indicatorType;this.className=["designbase-wc-indicator",`designbase-wc-indicator--${t}`,"combined"===t&&"designbase-wc-indicator--dots",`designbase-wc-indicator--${this.size}`,`designbase-wc-indicator--${this.direction}`,this.clickable&&"designbase-wc-indicator--clickable",this.timer&&!this.resolvedPlaying&&"designbase-wc-indicator--paused"].filter(Boolean).join(" ")}syncPlaybackButton(){const e=this.querySelector(".designbase-wc-indicator__playback-button");e&&(e.disabled=this.hasAttribute("playback-disabled"),e.setAttribute("aria-label",this.resolvedPlaying?"일시정지":"재생"),e.replaceChildren(t(this.resolvedPlaying?"pause":"play")))}renderDotRing(){const t=15.9155,e=2*Math.PI*t,i=document.createElement("span");i.className="designbase-wc-indicator__dot-ring",i.setAttribute("aria-hidden","true");const s=document.createElementNS("http://www.w3.org/2000/svg","svg");s.setAttribute("class","designbase-wc-indicator__dot-ring-svg"),s.setAttribute("viewBox","0 0 36 36");const r=document.createElementNS("http://www.w3.org/2000/svg","circle");r.setAttribute("class","designbase-wc-indicator__dot-ring-bg"),r.setAttribute("cx","18"),r.setAttribute("cy","18"),r.setAttribute("r",String(t)),r.setAttribute("fill","none");const n=document.createElementNS("http://www.w3.org/2000/svg","circle");return n.setAttribute("class","designbase-wc-indicator__dot-ring-progress"),n.setAttribute("cx","18"),n.setAttribute("cy","18"),n.setAttribute("r",String(t)),n.setAttribute("fill","none"),n.setAttribute("stroke-dasharray",String(e)),n.setAttribute("stroke-dashoffset",String(e*(1-this.progress))),n.setAttribute("stroke-linecap","round"),s.append(r,n),i.append(s),i}renderStep(t,e,i){const s=t===this.resolvedCurrent,r=this.clickable?document.createElement("button"):document.createElement("span");return r.className=e,this.clickable&&r instanceof HTMLButtonElement?(r.type="button",r.setAttribute("aria-label",`${t+1}단계`),s&&r.setAttribute("aria-current","step"),r.addEventListener("click",()=>{this.goToStep(t),this.dispatchEvent(new CustomEvent("db-step-click",{detail:{current:t,index:t},bubbles:!0,composed:!0}))})):s||r.setAttribute("aria-hidden","true"),i&&r.append(i),r}renderDots(){const t=document.createDocumentFragment(),e=this.indicatorType,i="combined"===e?"dots":e,s=this.timer,r=this.resolvedPlaying,n=this.resolvedCurrent;this.direction;const a=this.total;if("dots"!==i)return t;for(let e=0;e<a;e+=1){const i=e===n,a=s&&i&&r,o=document.createElement("span");o.className="designbase-wc-indicator__dot-core";const c=document.createDocumentFragment();c.append(o),s&&i&&(a||this.progress>0)&&c.append(this.renderDotRing()),t.append(this.renderStep(e,["designbase-wc-indicator__dot",i&&"designbase-wc-indicator__dot--active"].filter(Boolean).join(" "),c))}return t}renderPlaybackButton(){const e=document.createElement("button");return e.type="button",e.className="designbase-wc-indicator__playback-button",e.disabled=this.hasAttribute("playback-disabled"),e.setAttribute("aria-label",this.resolvedPlaying?"일시정지":"재생"),e.append(t(this.resolvedPlaying?"pause":"play")),e.addEventListener("click",()=>{if(this.hasAttribute("playback-disabled"))return;const t=!this.resolvedPlaying;this.isPlayingControlled?t?this.setAttribute("playing",""):(this.removeAttribute("playing"),this.pausedProgress=this.progress):(this.isPlayingInternal=t,t||(this.pausedProgress=this.progress)),this.syncRootClasses(),this.syncPlaybackButton(),this.startTimer(),this.dispatchEvent(new CustomEvent("db-playing-change",{detail:{playing:t},bubbles:!0,composed:!0}))}),e}renderNumbers(){const t=document.createElement("div");t.className=["designbase-wc-indicator__numbers",this.numberBackground&&"designbase-wc-indicator__numbers--bg"].filter(Boolean).join(" ");const e=document.createElement("span");e.className="designbase-wc-indicator__current",e.textContent=String(this.resolvedCurrent+1);const i=document.createElement("span");i.className="designbase-wc-indicator__separator",i.textContent="/";const s=document.createElement("span");return s.className="designbase-wc-indicator__total",s.textContent=String(this.total),t.append(e,i,s),t}renderSlide(){const t=this.direction,e=this.resolvedCurrent,i=document.createElement("div");i.className="designbase-wc-indicator__track";const s=document.createElement("div");s.className="designbase-wc-indicator__track-thumb";const r=100/this.total;if("vertical"===t?(s.style.height=`${r}%`,s.style.transform=`translateY(${100*e}%)`):(s.style.width=`${r}%`,s.style.transform=`translateX(${100*e}%)`),this.timer&&this.resolvedPlaying){const e=document.createElement("div");e.className="designbase-wc-indicator__track-fill",e.style.transform="vertical"===t?`scaleY(${this.progress})`:`scaleX(${this.progress})`,s.append(e)}return i.append(s),i}renderScaleFill(t){const e=document.createElement("span");return e.className=t,e.style.transform="vertical"===this.direction?`scaleY(${this.progress})`:`scaleX(${this.progress})`,e}renderLine(){const t=document.createDocumentFragment(),e=this.timer,i=this.resolvedPlaying,s=this.resolvedCurrent;for(let r=0;r<this.total;r+=1){const n=r===s,a=e&&n&&i?this.renderScaleFill("designbase-wc-indicator__line-fill"):void 0;t.append(this.renderStep(r,["designbase-wc-indicator__line-segment",n&&!e&&"designbase-wc-indicator__line-segment--active",n&&e&&"designbase-wc-indicator__line-segment--current"].filter(Boolean).join(" "),a))}return t}renderDotLine(){const t=document.createDocumentFragment(),e=this.timer,i=this.resolvedPlaying,s=this.resolvedCurrent;for(let r=0;r<this.total;r+=1){const n=r===s,a=e&&n&&i?this.renderScaleFill("designbase-wc-indicator__dot-line-fill"):void 0;t.append(this.renderStep(r,["designbase-wc-indicator__dot-line-item",n&&!e&&"designbase-wc-indicator__dot-line-item--active",n&&e&&"designbase-wc-indicator__dot-line-item--current"].filter(Boolean).join(" "),a))}return t}fillRatio(){const t=this.resolvedCurrent,e=t/this.total,i=1/this.total;return this.timer&&this.resolvedPlaying?Math.min(e+i*this.progress,1):(t+1)/this.total}renderFill(){const t=document.createElement("div");t.className="designbase-wc-indicator__track";const e=document.createElement("div");e.className="designbase-wc-indicator__track-progress";const i=100*this.fillRatio()+"%";return"vertical"===this.direction?e.style.height=i:e.style.width=i,t.append(e),t}renderContent(){const t="combined"===this.indicatorType?"dots":this.indicatorType;return"numbers"===t?this.renderNumbers():"slide"===t?this.renderSlide():"fill"===t?this.renderFill():"line"===t?this.renderLine():"dot-line"===t?this.renderDotLine():this.renderDots()}render(){const t=this.indicatorType,e=this.resolvedCurrent,i=this.total;this.syncRootClasses(),this.setAttribute("role","progressbar"),this.setAttribute("aria-valuemin","1"),this.setAttribute("aria-valuemax",String(i)),this.setAttribute("aria-valuenow",String(e+1)),this.replaceChildren();if("combined"===t||this.playback){const t=document.createElement("div");return t.className="designbase-wc-indicator__steps",t.append(this.renderContent()),void this.append(t,this.renderPlaybackButton())}this.append(this.renderContent())}}customElements.get("db-indicator")||customElements.define("db-indicator",DbIndicator);export{DbIndicator};
|