@designbasekorea/ui 0.1.34 → 0.1.35
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/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +53 -2
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.css.map +1 -1
- package/dist/index.esm.js +71 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -1
- package/dist/index.umd.css +1 -1
- package/dist/index.umd.css.map +1 -1
- package/dist/index.umd.js +71 -0
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -5100,6 +5100,76 @@
|
|
|
5100
5100
|
};
|
|
5101
5101
|
Confirm.displayName = 'Confirm';
|
|
5102
5102
|
|
|
5103
|
+
const Countdown = ({ endDate, duration, size = 'm', variant = 'default', showDays = true, showHours = true, showMinutes = true, showSeconds = true, showLabels = true, labels = {
|
|
5104
|
+
days: '일',
|
|
5105
|
+
hours: '시간',
|
|
5106
|
+
minutes: '분',
|
|
5107
|
+
seconds: '초',
|
|
5108
|
+
}, onComplete, onTick, className, }) => {
|
|
5109
|
+
// 종료 시간 계산
|
|
5110
|
+
const targetTime = React.useMemo(() => {
|
|
5111
|
+
if (endDate) {
|
|
5112
|
+
return typeof endDate === 'string' ? new Date(endDate).getTime() : endDate.getTime();
|
|
5113
|
+
}
|
|
5114
|
+
if (duration) {
|
|
5115
|
+
return Date.now() + duration * 1000;
|
|
5116
|
+
}
|
|
5117
|
+
return Date.now();
|
|
5118
|
+
}, [endDate, duration]);
|
|
5119
|
+
// 남은 시간 계산 함수
|
|
5120
|
+
const calculateTimeRemaining = () => {
|
|
5121
|
+
const now = Date.now();
|
|
5122
|
+
const total = targetTime - now;
|
|
5123
|
+
if (total <= 0) {
|
|
5124
|
+
return { days: 0, hours: 0, minutes: 0, seconds: 0, total: 0 };
|
|
5125
|
+
}
|
|
5126
|
+
const seconds = Math.floor((total / 1000) % 60);
|
|
5127
|
+
const minutes = Math.floor((total / 1000 / 60) % 60);
|
|
5128
|
+
const hours = Math.floor((total / (1000 * 60 * 60)) % 24);
|
|
5129
|
+
const days = Math.floor(total / (1000 * 60 * 60 * 24));
|
|
5130
|
+
return { days, hours, minutes, seconds, total };
|
|
5131
|
+
};
|
|
5132
|
+
const [timeRemaining, setTimeRemaining] = React.useState(calculateTimeRemaining());
|
|
5133
|
+
React.useEffect(() => {
|
|
5134
|
+
const timer = setInterval(() => {
|
|
5135
|
+
const newTimeRemaining = calculateTimeRemaining();
|
|
5136
|
+
setTimeRemaining(newTimeRemaining);
|
|
5137
|
+
onTick?.(newTimeRemaining);
|
|
5138
|
+
if (newTimeRemaining.total <= 0) {
|
|
5139
|
+
clearInterval(timer);
|
|
5140
|
+
onComplete?.();
|
|
5141
|
+
}
|
|
5142
|
+
}, 1000);
|
|
5143
|
+
return () => clearInterval(timer);
|
|
5144
|
+
}, [targetTime, onComplete, onTick]);
|
|
5145
|
+
const classes = clsx('designbase-countdown', `designbase-countdown--${size}`, `designbase-countdown--${variant}`, {
|
|
5146
|
+
'designbase-countdown--with-labels': showLabels,
|
|
5147
|
+
'designbase-countdown--expired': timeRemaining.total <= 0,
|
|
5148
|
+
}, className);
|
|
5149
|
+
// 숫자를 두 자리로 포맷
|
|
5150
|
+
const formatNumber = (num) => {
|
|
5151
|
+
return num.toString().padStart(2, '0');
|
|
5152
|
+
};
|
|
5153
|
+
const renderTimeUnit = (value, label, show) => {
|
|
5154
|
+
if (!show)
|
|
5155
|
+
return null;
|
|
5156
|
+
return (jsxRuntime.jsxs("div", { className: "designbase-countdown__unit", children: [jsxRuntime.jsx("div", { className: "designbase-countdown__value", children: formatNumber(value) }), showLabels && (jsxRuntime.jsx("div", { className: "designbase-countdown__label", children: label }))] }));
|
|
5157
|
+
};
|
|
5158
|
+
const renderSeparator = () => {
|
|
5159
|
+
if (variant === 'minimal')
|
|
5160
|
+
return null;
|
|
5161
|
+
return jsxRuntime.jsx("div", { className: "designbase-countdown__separator", children: ":" });
|
|
5162
|
+
};
|
|
5163
|
+
const units = [
|
|
5164
|
+
{ value: timeRemaining.days, label: labels.days || '일', show: showDays },
|
|
5165
|
+
{ value: timeRemaining.hours, label: labels.hours || '시간', show: showHours },
|
|
5166
|
+
{ value: timeRemaining.minutes, label: labels.minutes || '분', show: showMinutes },
|
|
5167
|
+
{ value: timeRemaining.seconds, label: labels.seconds || '초', show: showSeconds },
|
|
5168
|
+
].filter(unit => unit.show);
|
|
5169
|
+
return (jsxRuntime.jsx("div", { className: classes, children: units.map((unit, index) => (jsxRuntime.jsxs(React.Fragment, { children: [renderTimeUnit(unit.value, unit.label, unit.show), index < units.length - 1 && renderSeparator()] }, unit.label))) }));
|
|
5170
|
+
};
|
|
5171
|
+
Countdown.displayName = 'Countdown';
|
|
5172
|
+
|
|
5103
5173
|
const Container = ({ size = 'l', maxWidth, variant = 'plain', padding = 'm', margin = 'none', backgroundColor, border = false, rounded = false, shadow = false, className, children, }) => {
|
|
5104
5174
|
// 크기별 최대 폭 설정 (토큰 기반)
|
|
5105
5175
|
const getMaxWidth = () => {
|
|
@@ -11024,6 +11094,7 @@
|
|
|
11024
11094
|
exports.Confirm = Confirm;
|
|
11025
11095
|
exports.Container = Container;
|
|
11026
11096
|
exports.ContextMenu = ContextMenu;
|
|
11097
|
+
exports.Countdown = Countdown;
|
|
11027
11098
|
exports.DatePicker = DatePicker;
|
|
11028
11099
|
exports.Divider = Divider;
|
|
11029
11100
|
exports.Drawer = Drawer;
|