@designbasekorea/ui 0.1.59 → 0.1.61
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 +35 -2
- package/dist/index.esm.css +1 -1
- package/dist/index.esm.css.map +1 -1
- package/dist/index.esm.js +61 -9
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +61 -6
- 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 +61 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11054,14 +11054,15 @@ const Toast = ({ id, status = 'info', title, description, icon: Icon, duration =
|
|
|
11054
11054
|
const getStatusIcon = () => {
|
|
11055
11055
|
if (Icon)
|
|
11056
11056
|
return jsxRuntime.jsx(Icon, { size: 20 });
|
|
11057
|
-
// 기본 상태 아이콘 (
|
|
11057
|
+
// 기본 상태 아이콘 (아이콘 패키지에서 가져온 아이콘 사용)
|
|
11058
11058
|
const iconMap = {
|
|
11059
|
-
success:
|
|
11060
|
-
error:
|
|
11061
|
-
warning:
|
|
11062
|
-
info:
|
|
11059
|
+
success: icons.CircleCheckFilledIcon,
|
|
11060
|
+
error: icons.XIcon,
|
|
11061
|
+
warning: icons.WarningIcon,
|
|
11062
|
+
info: icons.InfoIcon,
|
|
11063
11063
|
};
|
|
11064
|
-
|
|
11064
|
+
const StatusIcon = iconMap[status];
|
|
11065
|
+
return jsxRuntime.jsx(StatusIcon, { size: 20 });
|
|
11065
11066
|
};
|
|
11066
11067
|
const getIconColor = () => {
|
|
11067
11068
|
const colorMap = {
|
|
@@ -11076,6 +11077,57 @@ const Toast = ({ id, status = 'info', title, description, icon: Icon, duration =
|
|
|
11076
11077
|
};
|
|
11077
11078
|
Toast.displayName = 'Toast';
|
|
11078
11079
|
|
|
11080
|
+
const ToastContainer = ({ position = 'top-right', maxToasts = 5, className, toasts: externalToasts, onRemoveToast, }) => {
|
|
11081
|
+
const [internalToasts, setInternalToasts] = React.useState([]);
|
|
11082
|
+
// 외부에서 toasts를 제공하면 그것을 사용, 아니면 내부 상태 사용
|
|
11083
|
+
const toasts = externalToasts || internalToasts;
|
|
11084
|
+
const removeToast = onRemoveToast || React.useCallback((id) => {
|
|
11085
|
+
setInternalToasts(prev => prev.filter(toast => toast.id !== id));
|
|
11086
|
+
}, []);
|
|
11087
|
+
React.useCallback((toast) => {
|
|
11088
|
+
const id = `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
11089
|
+
const newToast = {
|
|
11090
|
+
...toast,
|
|
11091
|
+
id,
|
|
11092
|
+
createdAt: Date.now(),
|
|
11093
|
+
};
|
|
11094
|
+
setInternalToasts(prev => {
|
|
11095
|
+
const updated = [newToast, ...prev];
|
|
11096
|
+
return updated.slice(0, maxToasts);
|
|
11097
|
+
});
|
|
11098
|
+
}, [maxToasts]);
|
|
11099
|
+
const classes = clsx('designbase-toast-container', `designbase-toast-container--${position}`, className);
|
|
11100
|
+
return (jsxRuntime.jsx("div", { className: classes, children: toasts.map((toast) => (jsxRuntime.jsx(Toast, { ...toast, onClose: removeToast }, toast.id))) }));
|
|
11101
|
+
};
|
|
11102
|
+
ToastContainer.displayName = 'ToastContainer';
|
|
11103
|
+
const ToastContext = React.createContext(null);
|
|
11104
|
+
const useToast = () => {
|
|
11105
|
+
const context = React.useContext(ToastContext);
|
|
11106
|
+
if (!context) {
|
|
11107
|
+
throw new Error('useToast must be used within a ToastProvider');
|
|
11108
|
+
}
|
|
11109
|
+
return context;
|
|
11110
|
+
};
|
|
11111
|
+
const ToastProvider = ({ children }) => {
|
|
11112
|
+
const [toasts, setToasts] = React.useState([]);
|
|
11113
|
+
const addToast = React.useCallback((toast) => {
|
|
11114
|
+
const id = `toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
11115
|
+
const newToast = {
|
|
11116
|
+
...toast,
|
|
11117
|
+
id,
|
|
11118
|
+
createdAt: Date.now(),
|
|
11119
|
+
};
|
|
11120
|
+
setToasts(prev => {
|
|
11121
|
+
const updated = [newToast, ...prev];
|
|
11122
|
+
return updated.slice(0, 5); // 최대 5개
|
|
11123
|
+
});
|
|
11124
|
+
}, []);
|
|
11125
|
+
const removeToast = React.useCallback((id) => {
|
|
11126
|
+
setToasts(prev => prev.filter(toast => toast.id !== id));
|
|
11127
|
+
}, []);
|
|
11128
|
+
return (jsxRuntime.jsxs(ToastContext.Provider, { value: { addToast, removeToast }, children: [children, jsxRuntime.jsx(ToastContainer, { toasts: toasts, onRemoveToast: removeToast })] }));
|
|
11129
|
+
};
|
|
11130
|
+
|
|
11079
11131
|
const Toggle = React.forwardRef(({ isSelected, defaultSelected, isDisabled = false, isReadOnly = false, size = 'm', children, className, onChange, ...props }, forwardedRef) => {
|
|
11080
11132
|
const [selected, setSelected] = React.useState(isSelected ?? defaultSelected ?? false);
|
|
11081
11133
|
React.useEffect(() => {
|
|
@@ -11732,6 +11784,8 @@ exports.Textarea = Textarea;
|
|
|
11732
11784
|
exports.TimePicker = TimePicker;
|
|
11733
11785
|
exports.Timeline = Timeline;
|
|
11734
11786
|
exports.Toast = Toast;
|
|
11787
|
+
exports.ToastContainer = ToastContainer;
|
|
11788
|
+
exports.ToastProvider = ToastProvider;
|
|
11735
11789
|
exports.Toggle = Toggle;
|
|
11736
11790
|
exports.Toolbar = Toolbar;
|
|
11737
11791
|
exports.Tooltip = Tooltip;
|
|
@@ -11741,4 +11795,5 @@ exports.YouTubePlayer = YouTubePlayer;
|
|
|
11741
11795
|
exports.getTheme = getTheme;
|
|
11742
11796
|
exports.setTheme = setTheme;
|
|
11743
11797
|
exports.toggleTheme = toggleTheme;
|
|
11798
|
+
exports.useToast = useToast;
|
|
11744
11799
|
//# sourceMappingURL=index.js.map
|