@designbasekorea/figma-ui 0.1.68 → 0.1.69

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.esm.js CHANGED
@@ -1,6 +1,6 @@
1
- import React, { useRef, useEffect, useState } from 'react';
1
+ import React, { useRef, useEffect, useState, createContext, useContext, useCallback } from 'react';
2
2
  import { HeartFilledIcon, CoffeeFilledIcon, AppWindowIcon, YoutubeIcon, InstagramIcon, FigmaIcon, MailIcon, ExternalLinkIcon, MoreHorizontalIcon, CloseIcon, CircleCheckFilledIcon, ResizableIcon, GripVerticalIcon } from '@designbasekorea/icons';
3
- import { SplitView, Button, Toggle, Spinner, Badge, SegmentControl, Logo, Input, Modal, Progressbar } from '@designbasekorea/ui';
3
+ import { SplitView, Button, Toggle, Spinner, Badge, SegmentControl, Logo, ToastContainer, Toast, Input, Modal, Progressbar } from '@designbasekorea/ui';
4
4
  export * from '@designbasekorea/ui';
5
5
 
6
6
  function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f);}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}
@@ -426,6 +426,68 @@ const FigmaFooter = ({ onLicensePageClick, paymentStatus = 'FREE', usageCount =
426
426
  };
427
427
  FigmaFooter.displayName = 'FigmaFooter';
428
428
 
429
+ const ToastContext = createContext(null);
430
+ const useToast = () => {
431
+ const context = useContext(ToastContext);
432
+ if (!context) {
433
+ throw new Error('useToast must be used within a FigmaToastProvider');
434
+ }
435
+ return context;
436
+ };
437
+ const FigmaToastProvider = ({ children, position = 'top-right', maxToasts = 5, }) => {
438
+ const [toasts, setToasts] = useState([]);
439
+ const addToast = useCallback((toast) => {
440
+ const id = `figma-toast-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
441
+ const newToast = {
442
+ ...toast,
443
+ id,
444
+ createdAt: Date.now(),
445
+ };
446
+ setToasts(prev => {
447
+ const updated = [newToast, ...prev];
448
+ return updated.slice(0, maxToasts);
449
+ });
450
+ }, [maxToasts]);
451
+ const removeToast = useCallback((id) => {
452
+ setToasts(prev => prev.filter(toast => toast.id !== id));
453
+ }, []);
454
+ const showToast = useCallback((message, options = {}) => {
455
+ addToast({
456
+ title: message,
457
+ status: 'info',
458
+ duration: 3000,
459
+ showProgress: false,
460
+ showCloseButton: true,
461
+ ...options,
462
+ });
463
+ }, [addToast]);
464
+ const contextValue = {
465
+ addToast,
466
+ removeToast,
467
+ showToast,
468
+ };
469
+ return (React.createElement(ToastContext.Provider, { value: contextValue },
470
+ children,
471
+ React.createElement(ToastContainer, { toasts: toasts, onRemoveToast: removeToast, position: position, maxToasts: maxToasts })));
472
+ };
473
+ const FigmaToast = ({ message, isVisible, onClose, type = 'info', duration = 3000, className, }) => {
474
+ if (!isVisible)
475
+ return null;
476
+ return (React.createElement("div", { className: `figma-toast-fixed-wrap ${className || ''}` },
477
+ React.createElement(Toast, { id: "figma-toast-simple", title: message, status: type, duration: duration, showProgress: false, showCloseButton: true, onClose: onClose, position: "top-right" })));
478
+ };
479
+ const useFigmaToast = () => {
480
+ const [toast, setToast] = useState({ message: '', isVisible: false });
481
+ const showToast = useCallback((message, type = 'info') => {
482
+ setToast({ message, isVisible: true });
483
+ setTimeout(() => setToast({ message: '', isVisible: false }), 3000);
484
+ }, []);
485
+ const toastComponent = toast.isVisible ? (React.createElement(FigmaToast, { message: toast.message, isVisible: toast.isVisible, onClose: () => setToast({ message: '', isVisible: false }), type: "info", duration: 3000 })) : null;
486
+ return { showToast, toastComponent };
487
+ };
488
+ FigmaToastProvider.displayName = 'FigmaToastProvider';
489
+ FigmaToast.displayName = 'FigmaToast';
490
+
429
491
  const FormWithSubmit = ({ onLicenseSubmit, disabled = false, isSubmitting = false, value = '', onValueChange, label = { key: 'form.license_key' }, placeholder = { key: 'form.license_placeholder' }, submitText = { key: 'form.submit' }, submittingText = { key: 'form.verifying' }, className, t }) => {
430
492
  const [inputValue, setInputValue] = useState(value);
431
493
  useEffect(() => {
@@ -917,5 +979,5 @@ const UpgradeBanner = ({ onClick, isLoading = false, title = { key: 'banner.upgr
917
979
  };
918
980
  UpgradeBanner.displayName = 'UpgradeBanner';
919
981
 
920
- export { DonationBadge, FigmaContainer, FigmaFooter, FigmaHeader, FigmaSection, FigmaSidebar, FormWithSubmit, InteractionFeedback, LanguageSelector, LogoDropdown, PageLicense, PaymentBadge, PaymentStatusSection, PricingComparison, ProgressModal, ResizablePlugin, SettingsModal, TitleDescription, UpgradeBanner, getActiveSection, resolveText, scrollToSection };
982
+ export { DonationBadge, FigmaContainer, FigmaFooter, FigmaHeader, FigmaSection, FigmaSidebar, FigmaToast, FigmaToastProvider, FormWithSubmit, InteractionFeedback, LanguageSelector, LogoDropdown, PageLicense, PaymentBadge, PaymentStatusSection, PricingComparison, ProgressModal, ResizablePlugin, SettingsModal, TitleDescription, UpgradeBanner, getActiveSection, resolveText, scrollToSection, useFigmaToast, useToast };
921
983
  //# sourceMappingURL=index.esm.js.map