@diffsome/react 1.3.3 → 1.4.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/chat.css +92 -0
- package/dist/index.d.mts +12 -2
- package/dist/index.d.ts +12 -2
- package/dist/index.js +171 -2
- package/dist/index.mjs +170 -2
- package/package.json +3 -3
package/dist/chat.css
CHANGED
|
@@ -500,6 +500,98 @@
|
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
|
|
503
|
+
/* Offline Form */
|
|
504
|
+
.diffsome-chat-offline-body {
|
|
505
|
+
flex: 1;
|
|
506
|
+
padding: 24px 20px;
|
|
507
|
+
display: flex;
|
|
508
|
+
flex-direction: column;
|
|
509
|
+
overflow-y: auto;
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
.diffsome-chat-offline-form {
|
|
513
|
+
display: flex;
|
|
514
|
+
flex-direction: column;
|
|
515
|
+
gap: 12px;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
.diffsome-chat-offline-msg {
|
|
519
|
+
color: var(--diffsome-chat-text-muted);
|
|
520
|
+
font-size: 14px;
|
|
521
|
+
line-height: 1.5;
|
|
522
|
+
margin-bottom: 4px;
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
.diffsome-chat-offline-input {
|
|
526
|
+
width: 100%;
|
|
527
|
+
padding: 10px 14px;
|
|
528
|
+
border: 1px solid var(--diffsome-chat-border);
|
|
529
|
+
border-radius: 8px;
|
|
530
|
+
font-size: 14px;
|
|
531
|
+
outline: none;
|
|
532
|
+
transition: border-color 0.2s;
|
|
533
|
+
background: var(--diffsome-chat-bg);
|
|
534
|
+
color: var(--diffsome-chat-text);
|
|
535
|
+
font-family: inherit;
|
|
536
|
+
box-sizing: border-box;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
.diffsome-chat-offline-input:focus {
|
|
540
|
+
border-color: var(--diffsome-chat-primary);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
.diffsome-chat-offline-textarea {
|
|
544
|
+
width: 100%;
|
|
545
|
+
padding: 10px 14px;
|
|
546
|
+
border: 1px solid var(--diffsome-chat-border);
|
|
547
|
+
border-radius: 8px;
|
|
548
|
+
font-size: 14px;
|
|
549
|
+
outline: none;
|
|
550
|
+
resize: vertical;
|
|
551
|
+
transition: border-color 0.2s;
|
|
552
|
+
background: var(--diffsome-chat-bg);
|
|
553
|
+
color: var(--diffsome-chat-text);
|
|
554
|
+
font-family: inherit;
|
|
555
|
+
box-sizing: border-box;
|
|
556
|
+
}
|
|
557
|
+
|
|
558
|
+
.diffsome-chat-offline-textarea:focus {
|
|
559
|
+
border-color: var(--diffsome-chat-primary);
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.diffsome-chat-offline-btn {
|
|
563
|
+
width: 100%;
|
|
564
|
+
padding: 12px;
|
|
565
|
+
background: var(--diffsome-chat-primary);
|
|
566
|
+
color: white;
|
|
567
|
+
border: none;
|
|
568
|
+
border-radius: 8px;
|
|
569
|
+
font-size: 14px;
|
|
570
|
+
font-weight: 600;
|
|
571
|
+
cursor: pointer;
|
|
572
|
+
transition: opacity 0.2s;
|
|
573
|
+
font-family: inherit;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
.diffsome-chat-offline-btn:hover:not(:disabled) {
|
|
577
|
+
opacity: 0.9;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
.diffsome-chat-offline-btn:disabled {
|
|
581
|
+
opacity: 0.5;
|
|
582
|
+
cursor: not-allowed;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
.diffsome-chat-offline-success {
|
|
586
|
+
display: flex;
|
|
587
|
+
flex-direction: column;
|
|
588
|
+
align-items: center;
|
|
589
|
+
justify-content: center;
|
|
590
|
+
gap: 12px;
|
|
591
|
+
height: 100%;
|
|
592
|
+
text-align: center;
|
|
593
|
+
}
|
|
594
|
+
|
|
503
595
|
/* Dark mode support */
|
|
504
596
|
@media (prefers-color-scheme: dark) {
|
|
505
597
|
.diffsome-chat-bubble-container {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { ReactNode } from 'react';
|
|
4
|
-
import { Diffsome, Member, Cart, WishlistItem, DiffsomeConfig, CurrencyInfo, SiteInfo, LoginCredentials, AuthResponse, RegisterData, UpdateProfileData, ResetPasswordData, SocialProvider, WishlistToggleResult, WishlistMoveToCartResult, BundlePricing, ProductCategory, Product, PaginationMeta, ProductListParams, ProductType, CreateOrderData, Order, OrderListParams, PaymentStatusResponse, StripeCheckoutResponse, StripeVerifyResponse, TossPaymentReadyResponse, TossPaymentConfirmResponse, Coupon, CouponValidation, MemberSubscription, DigitalDownloadLink, CanReviewResponse, CreateProductReviewData, ProductReview, UpdateProductReviewData, ProductReviewStats, ProductReviewListParams, BlogCategory, BlogListParams, BlogPost, BoardPost, Board, CreateBoardPostData, BoardPostListParams, BoardListParams, Comment, CreateCommentData, Form, FormSubmissionData, FormSubmission, ReservationSlot, CreateReservationData, Reservation, ReservationService, ReservationSettings, ReservationStaff, ReservationListParams, Media, CustomEntity, EntityRecord, EntityListParams, ChatConversation, ChatMessage as ChatMessage$1 } from '@diffsome/sdk';
|
|
4
|
+
import { Diffsome, Member, Cart, WishlistItem, DiffsomeConfig, CurrencyInfo, SiteInfo, LoginCredentials, AuthResponse, RegisterData, UpdateProfileData, ResetPasswordData, SocialProvider, WishlistToggleResult, WishlistMoveToCartResult, BundlePricing, ProductCategory, Product, PaginationMeta, ProductListParams, ProductType, CreateOrderData, Order, OrderListParams, NicePaymentReadyResponse, NicePaymentConfirmResponse, PaymentStatusResponse, StripeCheckoutResponse, StripeVerifyResponse, TossPaymentReadyResponse, TossPaymentConfirmResponse, Coupon, CouponValidation, MemberSubscription, DigitalDownloadLink, CanReviewResponse, CreateProductReviewData, ProductReview, UpdateProductReviewData, ProductReviewStats, ProductReviewListParams, BlogCategory, BlogListParams, BlogPost, BoardPost, Board, CreateBoardPostData, BoardPostListParams, BoardListParams, Comment, CreateCommentData, Form, FormSubmissionData, FormSubmission, ReservationSlot, CreateReservationData, Reservation, ReservationService, ReservationSettings, ReservationStaff, ReservationListParams, Media, CustomEntity, EntityRecord, EntityListParams, ChatConversation, ChatMessage as ChatMessage$1 } from '@diffsome/sdk';
|
|
5
5
|
export { AddToCartData, AuthResponse, BlogCategory, BlogListParams, BlogPost, Board, BoardListParams, BoardPost, BoardPostListParams, CanReviewResponse, Cart, CartItem, Comment, Coupon, CouponType, CouponValidation, CreateBoardPostData, CreateCommentData, CreateOrderData, CreateProductReviewData, CreateReservationData, CustomEntity, DiffsomeConfig, DigitalDownloadLink, DigitalFile, EntityField, EntityListParams, EntityRecord, EntitySchema, Form, FormSubmission, FormSubmissionData, ListResponse, LoginCredentials, Media, Member, MemberSubscription, Order, OrderItem, OrderListParams, OrderStatus, PaginatedResponse, PaginationMeta, Payment, PaymentMethod, PaymentStatus, PaymentStatusResponse, Product, ProductCategory, ProductListParams, ProductReview, ProductReviewStats, ProductType, ProductVariant, RegisterData, Reservation, ReservationService, ReservationSettings, ReservationSlot, ReservationStaff, ResetPasswordData, SiteInfo, SocialAuthUrl, SocialProvider, StripeCheckoutResponse, StripeVerifyResponse, SubscriptionInterval, SubscriptionPlan, SubscriptionStatus, TossPaymentConfirmResponse, TossPaymentReadyResponse, UpdateProfileData, WishlistItem, WishlistMoveToCartResult, WishlistToggleResult } from '@diffsome/sdk';
|
|
6
6
|
|
|
7
7
|
interface DiffsomeContextValue {
|
|
@@ -386,6 +386,8 @@ interface UsePaymentStatusReturn {
|
|
|
386
386
|
currency: CurrencyInfo | null;
|
|
387
387
|
formatPrice: (amount: number) => string;
|
|
388
388
|
isTossAvailable: boolean;
|
|
389
|
+
isNiceAvailable: boolean;
|
|
390
|
+
niceClientKey: string | null;
|
|
389
391
|
isStripeAvailable: boolean;
|
|
390
392
|
stripePublishableKey: string | null;
|
|
391
393
|
}
|
|
@@ -398,6 +400,14 @@ interface UseTossPaymentReturn {
|
|
|
398
400
|
error: Error | null;
|
|
399
401
|
}
|
|
400
402
|
declare function useTossPayment(): UseTossPaymentReturn;
|
|
403
|
+
interface UseNicePaymentReturn {
|
|
404
|
+
preparePayment: (orderNumber: string, returnUrl: string) => Promise<NicePaymentReadyResponse>;
|
|
405
|
+
confirmPayment: (tid: string, orderId: string, amount: number) => Promise<NicePaymentConfirmResponse>;
|
|
406
|
+
cancelPayment: (orderNumber: string, reason: string, amount?: number) => Promise<void>;
|
|
407
|
+
loading: boolean;
|
|
408
|
+
error: Error | null;
|
|
409
|
+
}
|
|
410
|
+
declare function useNicePayment(): UseNicePaymentReturn;
|
|
401
411
|
interface UseStripePaymentReturn {
|
|
402
412
|
createCheckout: (orderNumber: string, successUrl: string, cancelUrl: string) => Promise<StripeCheckoutResponse>;
|
|
403
413
|
verifyPayment: (sessionId: string) => Promise<StripeVerifyResponse>;
|
|
@@ -937,4 +947,4 @@ interface ChatInputProps {
|
|
|
937
947
|
}
|
|
938
948
|
declare const ChatInput: React__default.FC<ChatInputProps>;
|
|
939
949
|
|
|
940
|
-
export { ChatBubble, type ChatBubbleProps, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, ChatWidget, type ChatWidgetProps, type CommentType, DiffsomeContext, type DiffsomeContextValue, DiffsomeProvider, type DiffsomeProviderProps, type Message, RichContent, type RichContentProps, type UseAuthReturn, type UseAvailableSlotsReturn, type UseBlogCategoriesReturn, type UseBlogOptions, type UseBlogPostReturn, type UseBlogReturn, type UseBlogSearchReturn, type UseBlogTagsReturn, type UseBoardPostReturn, type UseBoardPostsReturn, type UseBoardReturn, type UseBoardsReturn, type UseBundleItemsReturn, type UseCanReviewReturn, type UseCartReturn, type UseCategoriesReturn, type UseChatOptions, type UseChatReturn, type UseCommentsOptions, type UseCommentsReturn, type UseCouponsReturn, type UseCreateBoardPostReturn, type UseCreateOrderReturn, type UseCreateReservationReturn, type UseCreateReviewReturn, type UseCreateSubscriptionReturn, type UseCurrencyReturn, type UseDownloadsReturn, type UseEntitiesReturn, type UseEntityRecordReturn, type UseEntityRecordsReturn, type UseEntityReturn, type UseFeaturedBlogReturn, type UseFeaturedProductsReturn, type UseFormReturn, type UseMediaOptions, type UseMediaReturn, type UseMyReservationsReturn, type UseMyReviewsReturn, type UseOrderDownloadsReturn, type UseOrderReturn, type UseOrdersReturn, type UsePaymentStatusReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductsByTypeReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationServicesReturn, type UseReservationSettingsReturn, type UseReservationStaffsReturn, type UseSiteReturn, type UseSocialAuthReturn, type UseStripePaymentReturn, type UseSubscriptionReturn, type UseSubscriptionsReturn, type UseTossPaymentReturn, type UseValidateCouponReturn, type UseWishlistReturn, useAuth, useAvailableSlots, useBlog, useBlogCategories, useBlogPost, useBlogSearch, useBlogTags, useBoard, useBoardPost, useBoardPosts, useBoards, useBundleItems, useBundleProducts, useCanReview, useCart, useCategories, useChat, useClient, useComments, useCoupons, useCreateBoardPost, useCreateOrder, useCreateReservation, useCreateReview, useCreateSubscription, useCurrency, useDiffsome, useDigitalProducts, useDownloads, useEntities, useEntity, useEntityRecord, useEntityRecords, useFeaturedBlog, useFeaturedProducts, useForm, useMedia, useMyReservations, useMyReviews, useOrder, useOrderDownloads, useOrders, usePaymentStatus, useProduct, useProductReviews, useProducts, useProductsByType, useReservationServices, useReservationSettings, useReservationStaffs, useSite, useSocialAuth, useStripePayment, useSubscription, useSubscriptionProducts, useSubscriptions, useTossPayment, useTypedEntity, useValidateCoupon, useWishlist };
|
|
950
|
+
export { ChatBubble, type ChatBubbleProps, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, ChatWidget, type ChatWidgetProps, type CommentType, DiffsomeContext, type DiffsomeContextValue, DiffsomeProvider, type DiffsomeProviderProps, type Message, RichContent, type RichContentProps, type UseAuthReturn, type UseAvailableSlotsReturn, type UseBlogCategoriesReturn, type UseBlogOptions, type UseBlogPostReturn, type UseBlogReturn, type UseBlogSearchReturn, type UseBlogTagsReturn, type UseBoardPostReturn, type UseBoardPostsReturn, type UseBoardReturn, type UseBoardsReturn, type UseBundleItemsReturn, type UseCanReviewReturn, type UseCartReturn, type UseCategoriesReturn, type UseChatOptions, type UseChatReturn, type UseCommentsOptions, type UseCommentsReturn, type UseCouponsReturn, type UseCreateBoardPostReturn, type UseCreateOrderReturn, type UseCreateReservationReturn, type UseCreateReviewReturn, type UseCreateSubscriptionReturn, type UseCurrencyReturn, type UseDownloadsReturn, type UseEntitiesReturn, type UseEntityRecordReturn, type UseEntityRecordsReturn, type UseEntityReturn, type UseFeaturedBlogReturn, type UseFeaturedProductsReturn, type UseFormReturn, type UseMediaOptions, type UseMediaReturn, type UseMyReservationsReturn, type UseMyReviewsReturn, type UseNicePaymentReturn, type UseOrderDownloadsReturn, type UseOrderReturn, type UseOrdersReturn, type UsePaymentStatusReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductsByTypeReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationServicesReturn, type UseReservationSettingsReturn, type UseReservationStaffsReturn, type UseSiteReturn, type UseSocialAuthReturn, type UseStripePaymentReturn, type UseSubscriptionReturn, type UseSubscriptionsReturn, type UseTossPaymentReturn, type UseValidateCouponReturn, type UseWishlistReturn, useAuth, useAvailableSlots, useBlog, useBlogCategories, useBlogPost, useBlogSearch, useBlogTags, useBoard, useBoardPost, useBoardPosts, useBoards, useBundleItems, useBundleProducts, useCanReview, useCart, useCategories, useChat, useClient, useComments, useCoupons, useCreateBoardPost, useCreateOrder, useCreateReservation, useCreateReview, useCreateSubscription, useCurrency, useDiffsome, useDigitalProducts, useDownloads, useEntities, useEntity, useEntityRecord, useEntityRecords, useFeaturedBlog, useFeaturedProducts, useForm, useMedia, useMyReservations, useMyReviews, useNicePayment, useOrder, useOrderDownloads, useOrders, usePaymentStatus, useProduct, useProductReviews, useProducts, useProductsByType, useReservationServices, useReservationSettings, useReservationStaffs, useSite, useSocialAuth, useStripePayment, useSubscription, useSubscriptionProducts, useSubscriptions, useTossPayment, useTypedEntity, useValidateCoupon, useWishlist };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { ReactNode } from 'react';
|
|
4
|
-
import { Diffsome, Member, Cart, WishlistItem, DiffsomeConfig, CurrencyInfo, SiteInfo, LoginCredentials, AuthResponse, RegisterData, UpdateProfileData, ResetPasswordData, SocialProvider, WishlistToggleResult, WishlistMoveToCartResult, BundlePricing, ProductCategory, Product, PaginationMeta, ProductListParams, ProductType, CreateOrderData, Order, OrderListParams, PaymentStatusResponse, StripeCheckoutResponse, StripeVerifyResponse, TossPaymentReadyResponse, TossPaymentConfirmResponse, Coupon, CouponValidation, MemberSubscription, DigitalDownloadLink, CanReviewResponse, CreateProductReviewData, ProductReview, UpdateProductReviewData, ProductReviewStats, ProductReviewListParams, BlogCategory, BlogListParams, BlogPost, BoardPost, Board, CreateBoardPostData, BoardPostListParams, BoardListParams, Comment, CreateCommentData, Form, FormSubmissionData, FormSubmission, ReservationSlot, CreateReservationData, Reservation, ReservationService, ReservationSettings, ReservationStaff, ReservationListParams, Media, CustomEntity, EntityRecord, EntityListParams, ChatConversation, ChatMessage as ChatMessage$1 } from '@diffsome/sdk';
|
|
4
|
+
import { Diffsome, Member, Cart, WishlistItem, DiffsomeConfig, CurrencyInfo, SiteInfo, LoginCredentials, AuthResponse, RegisterData, UpdateProfileData, ResetPasswordData, SocialProvider, WishlistToggleResult, WishlistMoveToCartResult, BundlePricing, ProductCategory, Product, PaginationMeta, ProductListParams, ProductType, CreateOrderData, Order, OrderListParams, NicePaymentReadyResponse, NicePaymentConfirmResponse, PaymentStatusResponse, StripeCheckoutResponse, StripeVerifyResponse, TossPaymentReadyResponse, TossPaymentConfirmResponse, Coupon, CouponValidation, MemberSubscription, DigitalDownloadLink, CanReviewResponse, CreateProductReviewData, ProductReview, UpdateProductReviewData, ProductReviewStats, ProductReviewListParams, BlogCategory, BlogListParams, BlogPost, BoardPost, Board, CreateBoardPostData, BoardPostListParams, BoardListParams, Comment, CreateCommentData, Form, FormSubmissionData, FormSubmission, ReservationSlot, CreateReservationData, Reservation, ReservationService, ReservationSettings, ReservationStaff, ReservationListParams, Media, CustomEntity, EntityRecord, EntityListParams, ChatConversation, ChatMessage as ChatMessage$1 } from '@diffsome/sdk';
|
|
5
5
|
export { AddToCartData, AuthResponse, BlogCategory, BlogListParams, BlogPost, Board, BoardListParams, BoardPost, BoardPostListParams, CanReviewResponse, Cart, CartItem, Comment, Coupon, CouponType, CouponValidation, CreateBoardPostData, CreateCommentData, CreateOrderData, CreateProductReviewData, CreateReservationData, CustomEntity, DiffsomeConfig, DigitalDownloadLink, DigitalFile, EntityField, EntityListParams, EntityRecord, EntitySchema, Form, FormSubmission, FormSubmissionData, ListResponse, LoginCredentials, Media, Member, MemberSubscription, Order, OrderItem, OrderListParams, OrderStatus, PaginatedResponse, PaginationMeta, Payment, PaymentMethod, PaymentStatus, PaymentStatusResponse, Product, ProductCategory, ProductListParams, ProductReview, ProductReviewStats, ProductType, ProductVariant, RegisterData, Reservation, ReservationService, ReservationSettings, ReservationSlot, ReservationStaff, ResetPasswordData, SiteInfo, SocialAuthUrl, SocialProvider, StripeCheckoutResponse, StripeVerifyResponse, SubscriptionInterval, SubscriptionPlan, SubscriptionStatus, TossPaymentConfirmResponse, TossPaymentReadyResponse, UpdateProfileData, WishlistItem, WishlistMoveToCartResult, WishlistToggleResult } from '@diffsome/sdk';
|
|
6
6
|
|
|
7
7
|
interface DiffsomeContextValue {
|
|
@@ -386,6 +386,8 @@ interface UsePaymentStatusReturn {
|
|
|
386
386
|
currency: CurrencyInfo | null;
|
|
387
387
|
formatPrice: (amount: number) => string;
|
|
388
388
|
isTossAvailable: boolean;
|
|
389
|
+
isNiceAvailable: boolean;
|
|
390
|
+
niceClientKey: string | null;
|
|
389
391
|
isStripeAvailable: boolean;
|
|
390
392
|
stripePublishableKey: string | null;
|
|
391
393
|
}
|
|
@@ -398,6 +400,14 @@ interface UseTossPaymentReturn {
|
|
|
398
400
|
error: Error | null;
|
|
399
401
|
}
|
|
400
402
|
declare function useTossPayment(): UseTossPaymentReturn;
|
|
403
|
+
interface UseNicePaymentReturn {
|
|
404
|
+
preparePayment: (orderNumber: string, returnUrl: string) => Promise<NicePaymentReadyResponse>;
|
|
405
|
+
confirmPayment: (tid: string, orderId: string, amount: number) => Promise<NicePaymentConfirmResponse>;
|
|
406
|
+
cancelPayment: (orderNumber: string, reason: string, amount?: number) => Promise<void>;
|
|
407
|
+
loading: boolean;
|
|
408
|
+
error: Error | null;
|
|
409
|
+
}
|
|
410
|
+
declare function useNicePayment(): UseNicePaymentReturn;
|
|
401
411
|
interface UseStripePaymentReturn {
|
|
402
412
|
createCheckout: (orderNumber: string, successUrl: string, cancelUrl: string) => Promise<StripeCheckoutResponse>;
|
|
403
413
|
verifyPayment: (sessionId: string) => Promise<StripeVerifyResponse>;
|
|
@@ -937,4 +947,4 @@ interface ChatInputProps {
|
|
|
937
947
|
}
|
|
938
948
|
declare const ChatInput: React__default.FC<ChatInputProps>;
|
|
939
949
|
|
|
940
|
-
export { ChatBubble, type ChatBubbleProps, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, ChatWidget, type ChatWidgetProps, type CommentType, DiffsomeContext, type DiffsomeContextValue, DiffsomeProvider, type DiffsomeProviderProps, type Message, RichContent, type RichContentProps, type UseAuthReturn, type UseAvailableSlotsReturn, type UseBlogCategoriesReturn, type UseBlogOptions, type UseBlogPostReturn, type UseBlogReturn, type UseBlogSearchReturn, type UseBlogTagsReturn, type UseBoardPostReturn, type UseBoardPostsReturn, type UseBoardReturn, type UseBoardsReturn, type UseBundleItemsReturn, type UseCanReviewReturn, type UseCartReturn, type UseCategoriesReturn, type UseChatOptions, type UseChatReturn, type UseCommentsOptions, type UseCommentsReturn, type UseCouponsReturn, type UseCreateBoardPostReturn, type UseCreateOrderReturn, type UseCreateReservationReturn, type UseCreateReviewReturn, type UseCreateSubscriptionReturn, type UseCurrencyReturn, type UseDownloadsReturn, type UseEntitiesReturn, type UseEntityRecordReturn, type UseEntityRecordsReturn, type UseEntityReturn, type UseFeaturedBlogReturn, type UseFeaturedProductsReturn, type UseFormReturn, type UseMediaOptions, type UseMediaReturn, type UseMyReservationsReturn, type UseMyReviewsReturn, type UseOrderDownloadsReturn, type UseOrderReturn, type UseOrdersReturn, type UsePaymentStatusReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductsByTypeReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationServicesReturn, type UseReservationSettingsReturn, type UseReservationStaffsReturn, type UseSiteReturn, type UseSocialAuthReturn, type UseStripePaymentReturn, type UseSubscriptionReturn, type UseSubscriptionsReturn, type UseTossPaymentReturn, type UseValidateCouponReturn, type UseWishlistReturn, useAuth, useAvailableSlots, useBlog, useBlogCategories, useBlogPost, useBlogSearch, useBlogTags, useBoard, useBoardPost, useBoardPosts, useBoards, useBundleItems, useBundleProducts, useCanReview, useCart, useCategories, useChat, useClient, useComments, useCoupons, useCreateBoardPost, useCreateOrder, useCreateReservation, useCreateReview, useCreateSubscription, useCurrency, useDiffsome, useDigitalProducts, useDownloads, useEntities, useEntity, useEntityRecord, useEntityRecords, useFeaturedBlog, useFeaturedProducts, useForm, useMedia, useMyReservations, useMyReviews, useOrder, useOrderDownloads, useOrders, usePaymentStatus, useProduct, useProductReviews, useProducts, useProductsByType, useReservationServices, useReservationSettings, useReservationStaffs, useSite, useSocialAuth, useStripePayment, useSubscription, useSubscriptionProducts, useSubscriptions, useTossPayment, useTypedEntity, useValidateCoupon, useWishlist };
|
|
950
|
+
export { ChatBubble, type ChatBubbleProps, ChatInput, type ChatInputProps, ChatMessage, type ChatMessageProps, ChatWidget, type ChatWidgetProps, type CommentType, DiffsomeContext, type DiffsomeContextValue, DiffsomeProvider, type DiffsomeProviderProps, type Message, RichContent, type RichContentProps, type UseAuthReturn, type UseAvailableSlotsReturn, type UseBlogCategoriesReturn, type UseBlogOptions, type UseBlogPostReturn, type UseBlogReturn, type UseBlogSearchReturn, type UseBlogTagsReturn, type UseBoardPostReturn, type UseBoardPostsReturn, type UseBoardReturn, type UseBoardsReturn, type UseBundleItemsReturn, type UseCanReviewReturn, type UseCartReturn, type UseCategoriesReturn, type UseChatOptions, type UseChatReturn, type UseCommentsOptions, type UseCommentsReturn, type UseCouponsReturn, type UseCreateBoardPostReturn, type UseCreateOrderReturn, type UseCreateReservationReturn, type UseCreateReviewReturn, type UseCreateSubscriptionReturn, type UseCurrencyReturn, type UseDownloadsReturn, type UseEntitiesReturn, type UseEntityRecordReturn, type UseEntityRecordsReturn, type UseEntityReturn, type UseFeaturedBlogReturn, type UseFeaturedProductsReturn, type UseFormReturn, type UseMediaOptions, type UseMediaReturn, type UseMyReservationsReturn, type UseMyReviewsReturn, type UseNicePaymentReturn, type UseOrderDownloadsReturn, type UseOrderReturn, type UseOrdersReturn, type UsePaymentStatusReturn, type UseProductReturn, type UseProductReviewsReturn, type UseProductsByTypeReturn, type UseProductsOptions, type UseProductsReturn, type UseReservationServicesReturn, type UseReservationSettingsReturn, type UseReservationStaffsReturn, type UseSiteReturn, type UseSocialAuthReturn, type UseStripePaymentReturn, type UseSubscriptionReturn, type UseSubscriptionsReturn, type UseTossPaymentReturn, type UseValidateCouponReturn, type UseWishlistReturn, useAuth, useAvailableSlots, useBlog, useBlogCategories, useBlogPost, useBlogSearch, useBlogTags, useBoard, useBoardPost, useBoardPosts, useBoards, useBundleItems, useBundleProducts, useCanReview, useCart, useCategories, useChat, useClient, useComments, useCoupons, useCreateBoardPost, useCreateOrder, useCreateReservation, useCreateReview, useCreateSubscription, useCurrency, useDiffsome, useDigitalProducts, useDownloads, useEntities, useEntity, useEntityRecord, useEntityRecords, useFeaturedBlog, useFeaturedProducts, useForm, useMedia, useMyReservations, useMyReviews, useNicePayment, useOrder, useOrderDownloads, useOrders, usePaymentStatus, useProduct, useProductReviews, useProducts, useProductsByType, useReservationServices, useReservationSettings, useReservationStaffs, useSite, useSocialAuth, useStripePayment, useSubscription, useSubscriptionProducts, useSubscriptions, useTossPayment, useTypedEntity, useValidateCoupon, useWishlist };
|
package/dist/index.js
CHANGED
|
@@ -66,6 +66,7 @@ __export(index_exports, {
|
|
|
66
66
|
useMedia: () => useMedia,
|
|
67
67
|
useMyReservations: () => useMyReservations,
|
|
68
68
|
useMyReviews: () => useMyReviews,
|
|
69
|
+
useNicePayment: () => useNicePayment,
|
|
69
70
|
useOrder: () => useOrder,
|
|
70
71
|
useOrderDownloads: () => useOrderDownloads,
|
|
71
72
|
useOrders: () => useOrders,
|
|
@@ -943,6 +944,8 @@ function usePaymentStatus() {
|
|
|
943
944
|
currency,
|
|
944
945
|
formatPrice,
|
|
945
946
|
isTossAvailable: status?.toss?.available ?? false,
|
|
947
|
+
isNiceAvailable: status?.nice?.available ?? false,
|
|
948
|
+
niceClientKey: status?.nice?.client_key ?? null,
|
|
946
949
|
isStripeAvailable: status?.stripe?.available ?? false,
|
|
947
950
|
stripePublishableKey: status?.stripe?.publishable_key ?? null
|
|
948
951
|
};
|
|
@@ -1006,6 +1009,64 @@ function useTossPayment() {
|
|
|
1006
1009
|
error
|
|
1007
1010
|
};
|
|
1008
1011
|
}
|
|
1012
|
+
function useNicePayment() {
|
|
1013
|
+
const client = useClient();
|
|
1014
|
+
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
1015
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
1016
|
+
const preparePayment = (0, import_react9.useCallback)(async (orderNumber, returnUrl) => {
|
|
1017
|
+
setLoading(true);
|
|
1018
|
+
setError(null);
|
|
1019
|
+
try {
|
|
1020
|
+
return await client.shop.nicePaymentReady({
|
|
1021
|
+
order_number: orderNumber,
|
|
1022
|
+
return_url: returnUrl
|
|
1023
|
+
});
|
|
1024
|
+
} catch (err) {
|
|
1025
|
+
const error2 = err instanceof Error ? err : new Error("Failed to prepare payment");
|
|
1026
|
+
setError(error2);
|
|
1027
|
+
throw error2;
|
|
1028
|
+
} finally {
|
|
1029
|
+
setLoading(false);
|
|
1030
|
+
}
|
|
1031
|
+
}, [client]);
|
|
1032
|
+
const confirmPayment = (0, import_react9.useCallback)(async (tid, orderId, amount) => {
|
|
1033
|
+
setLoading(true);
|
|
1034
|
+
setError(null);
|
|
1035
|
+
try {
|
|
1036
|
+
return await client.shop.nicePaymentConfirm({
|
|
1037
|
+
tid,
|
|
1038
|
+
order_id: orderId,
|
|
1039
|
+
amount
|
|
1040
|
+
});
|
|
1041
|
+
} catch (err) {
|
|
1042
|
+
const error2 = err instanceof Error ? err : new Error("Failed to confirm payment");
|
|
1043
|
+
setError(error2);
|
|
1044
|
+
throw error2;
|
|
1045
|
+
} finally {
|
|
1046
|
+
setLoading(false);
|
|
1047
|
+
}
|
|
1048
|
+
}, [client]);
|
|
1049
|
+
const cancelPayment = (0, import_react9.useCallback)(async (orderNumber, reason, amount) => {
|
|
1050
|
+
setLoading(true);
|
|
1051
|
+
setError(null);
|
|
1052
|
+
try {
|
|
1053
|
+
await client.shop.nicePaymentCancel(orderNumber, reason, amount);
|
|
1054
|
+
} catch (err) {
|
|
1055
|
+
const error2 = err instanceof Error ? err : new Error("Failed to cancel payment");
|
|
1056
|
+
setError(error2);
|
|
1057
|
+
throw error2;
|
|
1058
|
+
} finally {
|
|
1059
|
+
setLoading(false);
|
|
1060
|
+
}
|
|
1061
|
+
}, [client]);
|
|
1062
|
+
return {
|
|
1063
|
+
preparePayment,
|
|
1064
|
+
confirmPayment,
|
|
1065
|
+
cancelPayment,
|
|
1066
|
+
loading,
|
|
1067
|
+
error
|
|
1068
|
+
};
|
|
1069
|
+
}
|
|
1009
1070
|
function useStripePayment() {
|
|
1010
1071
|
const client = useClient();
|
|
1011
1072
|
const [loading, setLoading] = (0, import_react9.useState)(false);
|
|
@@ -2901,8 +2962,22 @@ var ChatBubble = ({
|
|
|
2901
2962
|
const [unreadCount, setUnreadCount] = (0, import_react24.useState)(0);
|
|
2902
2963
|
const [initialized, setInitialized] = (0, import_react24.useState)(false);
|
|
2903
2964
|
const [ended, setEnded] = (0, import_react24.useState)(false);
|
|
2965
|
+
const [offline, setOffline] = (0, import_react24.useState)(false);
|
|
2966
|
+
const [offlineMessage, setOfflineMessage] = (0, import_react24.useState)("");
|
|
2967
|
+
const [offlineSent, setOfflineSent] = (0, import_react24.useState)(false);
|
|
2968
|
+
const [offlineLoading, setOfflineLoading] = (0, import_react24.useState)(false);
|
|
2904
2969
|
const seenMessageIds = (0, import_react24.useRef)(/* @__PURE__ */ new Set());
|
|
2905
2970
|
const connectionRef = (0, import_react24.useRef)(null);
|
|
2971
|
+
(0, import_react24.useEffect)(() => {
|
|
2972
|
+
client.chat.checkAvailability().then((result) => {
|
|
2973
|
+
const data = result?.data ?? result;
|
|
2974
|
+
if (data?.within_operating_hours === false) {
|
|
2975
|
+
setOffline(true);
|
|
2976
|
+
setOfflineMessage(data.offline_message || "We are currently offline. Please leave a message.");
|
|
2977
|
+
}
|
|
2978
|
+
}).catch(() => {
|
|
2979
|
+
});
|
|
2980
|
+
}, [client.chat]);
|
|
2906
2981
|
const setupListeners = (0, import_react24.useCallback)((conn) => {
|
|
2907
2982
|
conn.onMessage((msg) => {
|
|
2908
2983
|
if (seenMessageIds.current.has(msg.id)) {
|
|
@@ -3045,6 +3120,23 @@ var ChatBubble = ({
|
|
|
3045
3120
|
seenMessageIds.current.clear();
|
|
3046
3121
|
initChat();
|
|
3047
3122
|
};
|
|
3123
|
+
const handleOfflineSubmit = async (name, email, message) => {
|
|
3124
|
+
setOfflineLoading(true);
|
|
3125
|
+
try {
|
|
3126
|
+
await client.chat.start({
|
|
3127
|
+
visitor_name: name || "Visitor",
|
|
3128
|
+
visitor_email: email,
|
|
3129
|
+
initial_message: message,
|
|
3130
|
+
channel: "web",
|
|
3131
|
+
metadata: { offline: true }
|
|
3132
|
+
});
|
|
3133
|
+
setOfflineSent(true);
|
|
3134
|
+
} catch (error) {
|
|
3135
|
+
console.error("Failed to send offline message:", error);
|
|
3136
|
+
} finally {
|
|
3137
|
+
setOfflineLoading(false);
|
|
3138
|
+
}
|
|
3139
|
+
};
|
|
3048
3140
|
(0, import_react24.useEffect)(() => {
|
|
3049
3141
|
return () => {
|
|
3050
3142
|
connectionRef.current?.disconnect();
|
|
@@ -3057,7 +3149,17 @@ var ChatBubble = ({
|
|
|
3057
3149
|
className: `diffsome-chat-bubble-container ${positionClass} ${className}`,
|
|
3058
3150
|
style: { "--diffsome-chat-primary": primaryColor, zIndex },
|
|
3059
3151
|
children: [
|
|
3060
|
-
isOpen && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3152
|
+
isOpen && (offline ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3153
|
+
OfflineForm,
|
|
3154
|
+
{
|
|
3155
|
+
title,
|
|
3156
|
+
offlineMessage,
|
|
3157
|
+
onClose: handleClose,
|
|
3158
|
+
onSubmit: handleOfflineSubmit,
|
|
3159
|
+
submitted: offlineSent,
|
|
3160
|
+
loading: offlineLoading
|
|
3161
|
+
}
|
|
3162
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3061
3163
|
ChatWidget,
|
|
3062
3164
|
{
|
|
3063
3165
|
messages,
|
|
@@ -3077,7 +3179,7 @@ var ChatBubble = ({
|
|
|
3077
3179
|
loginUrl,
|
|
3078
3180
|
loginPromptMessage
|
|
3079
3181
|
}
|
|
3080
|
-
),
|
|
3182
|
+
)),
|
|
3081
3183
|
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
3082
3184
|
"button",
|
|
3083
3185
|
{
|
|
@@ -3114,6 +3216,72 @@ var ChatBubble = ({
|
|
|
3114
3216
|
}
|
|
3115
3217
|
);
|
|
3116
3218
|
};
|
|
3219
|
+
var OfflineForm = ({
|
|
3220
|
+
title,
|
|
3221
|
+
offlineMessage,
|
|
3222
|
+
onClose,
|
|
3223
|
+
onSubmit,
|
|
3224
|
+
submitted,
|
|
3225
|
+
loading
|
|
3226
|
+
}) => {
|
|
3227
|
+
const [name, setName] = (0, import_react24.useState)("");
|
|
3228
|
+
const [email, setEmail] = (0, import_react24.useState)("");
|
|
3229
|
+
const [message, setMessage] = (0, import_react24.useState)("");
|
|
3230
|
+
const handleSubmit = (e) => {
|
|
3231
|
+
e.preventDefault();
|
|
3232
|
+
if (!email || !message) return;
|
|
3233
|
+
onSubmit(name, email, message);
|
|
3234
|
+
};
|
|
3235
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "diffsome-chat-widget", children: [
|
|
3236
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "diffsome-chat-header", children: [
|
|
3237
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "diffsome-chat-header-info", children: [
|
|
3238
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "diffsome-chat-header-title", children: title }),
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "diffsome-chat-header-subtitle", children: "Offline" })
|
|
3240
|
+
] }),
|
|
3241
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "diffsome-chat-header-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", width: "24", height: "24", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) })
|
|
3242
|
+
] }),
|
|
3243
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "diffsome-chat-offline-body", children: submitted ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "diffsome-chat-offline-success", children: [
|
|
3244
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#10b981", width: "48", height: "48", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" }) }),
|
|
3245
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { style: { fontWeight: 600, fontSize: "16px", color: "#1f2937" }, children: "Message sent!" }),
|
|
3246
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { style: { color: "#6b7280" }, children: "We'll get back to you soon." })
|
|
3247
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { onSubmit: handleSubmit, className: "diffsome-chat-offline-form", children: [
|
|
3248
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "diffsome-chat-offline-msg", children: offlineMessage }),
|
|
3249
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3250
|
+
"input",
|
|
3251
|
+
{
|
|
3252
|
+
type: "text",
|
|
3253
|
+
placeholder: "Your name",
|
|
3254
|
+
value: name,
|
|
3255
|
+
onChange: (e) => setName(e.target.value),
|
|
3256
|
+
className: "diffsome-chat-offline-input"
|
|
3257
|
+
}
|
|
3258
|
+
),
|
|
3259
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3260
|
+
"input",
|
|
3261
|
+
{
|
|
3262
|
+
type: "email",
|
|
3263
|
+
placeholder: "Email *",
|
|
3264
|
+
value: email,
|
|
3265
|
+
onChange: (e) => setEmail(e.target.value),
|
|
3266
|
+
required: true,
|
|
3267
|
+
className: "diffsome-chat-offline-input"
|
|
3268
|
+
}
|
|
3269
|
+
),
|
|
3270
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
3271
|
+
"textarea",
|
|
3272
|
+
{
|
|
3273
|
+
placeholder: "Your message *",
|
|
3274
|
+
value: message,
|
|
3275
|
+
onChange: (e) => setMessage(e.target.value),
|
|
3276
|
+
required: true,
|
|
3277
|
+
rows: 4,
|
|
3278
|
+
className: "diffsome-chat-offline-textarea"
|
|
3279
|
+
}
|
|
3280
|
+
),
|
|
3281
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "submit", disabled: loading || !email || !message, className: "diffsome-chat-offline-btn", children: loading ? "Sending..." : "Leave Message" })
|
|
3282
|
+
] }) })
|
|
3283
|
+
] });
|
|
3284
|
+
};
|
|
3117
3285
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3118
3286
|
0 && (module.exports = {
|
|
3119
3287
|
ChatBubble,
|
|
@@ -3162,6 +3330,7 @@ var ChatBubble = ({
|
|
|
3162
3330
|
useMedia,
|
|
3163
3331
|
useMyReservations,
|
|
3164
3332
|
useMyReviews,
|
|
3333
|
+
useNicePayment,
|
|
3165
3334
|
useOrder,
|
|
3166
3335
|
useOrderDownloads,
|
|
3167
3336
|
useOrders,
|
package/dist/index.mjs
CHANGED
|
@@ -851,6 +851,8 @@ function usePaymentStatus() {
|
|
|
851
851
|
currency,
|
|
852
852
|
formatPrice,
|
|
853
853
|
isTossAvailable: status?.toss?.available ?? false,
|
|
854
|
+
isNiceAvailable: status?.nice?.available ?? false,
|
|
855
|
+
niceClientKey: status?.nice?.client_key ?? null,
|
|
854
856
|
isStripeAvailable: status?.stripe?.available ?? false,
|
|
855
857
|
stripePublishableKey: status?.stripe?.publishable_key ?? null
|
|
856
858
|
};
|
|
@@ -914,6 +916,64 @@ function useTossPayment() {
|
|
|
914
916
|
error
|
|
915
917
|
};
|
|
916
918
|
}
|
|
919
|
+
function useNicePayment() {
|
|
920
|
+
const client = useClient();
|
|
921
|
+
const [loading, setLoading] = useState8(false);
|
|
922
|
+
const [error, setError] = useState8(null);
|
|
923
|
+
const preparePayment = useCallback9(async (orderNumber, returnUrl) => {
|
|
924
|
+
setLoading(true);
|
|
925
|
+
setError(null);
|
|
926
|
+
try {
|
|
927
|
+
return await client.shop.nicePaymentReady({
|
|
928
|
+
order_number: orderNumber,
|
|
929
|
+
return_url: returnUrl
|
|
930
|
+
});
|
|
931
|
+
} catch (err) {
|
|
932
|
+
const error2 = err instanceof Error ? err : new Error("Failed to prepare payment");
|
|
933
|
+
setError(error2);
|
|
934
|
+
throw error2;
|
|
935
|
+
} finally {
|
|
936
|
+
setLoading(false);
|
|
937
|
+
}
|
|
938
|
+
}, [client]);
|
|
939
|
+
const confirmPayment = useCallback9(async (tid, orderId, amount) => {
|
|
940
|
+
setLoading(true);
|
|
941
|
+
setError(null);
|
|
942
|
+
try {
|
|
943
|
+
return await client.shop.nicePaymentConfirm({
|
|
944
|
+
tid,
|
|
945
|
+
order_id: orderId,
|
|
946
|
+
amount
|
|
947
|
+
});
|
|
948
|
+
} catch (err) {
|
|
949
|
+
const error2 = err instanceof Error ? err : new Error("Failed to confirm payment");
|
|
950
|
+
setError(error2);
|
|
951
|
+
throw error2;
|
|
952
|
+
} finally {
|
|
953
|
+
setLoading(false);
|
|
954
|
+
}
|
|
955
|
+
}, [client]);
|
|
956
|
+
const cancelPayment = useCallback9(async (orderNumber, reason, amount) => {
|
|
957
|
+
setLoading(true);
|
|
958
|
+
setError(null);
|
|
959
|
+
try {
|
|
960
|
+
await client.shop.nicePaymentCancel(orderNumber, reason, amount);
|
|
961
|
+
} catch (err) {
|
|
962
|
+
const error2 = err instanceof Error ? err : new Error("Failed to cancel payment");
|
|
963
|
+
setError(error2);
|
|
964
|
+
throw error2;
|
|
965
|
+
} finally {
|
|
966
|
+
setLoading(false);
|
|
967
|
+
}
|
|
968
|
+
}, [client]);
|
|
969
|
+
return {
|
|
970
|
+
preparePayment,
|
|
971
|
+
confirmPayment,
|
|
972
|
+
cancelPayment,
|
|
973
|
+
loading,
|
|
974
|
+
error
|
|
975
|
+
};
|
|
976
|
+
}
|
|
917
977
|
function useStripePayment() {
|
|
918
978
|
const client = useClient();
|
|
919
979
|
const [loading, setLoading] = useState8(false);
|
|
@@ -2809,8 +2869,22 @@ var ChatBubble = ({
|
|
|
2809
2869
|
const [unreadCount, setUnreadCount] = useState22(0);
|
|
2810
2870
|
const [initialized, setInitialized] = useState22(false);
|
|
2811
2871
|
const [ended, setEnded] = useState22(false);
|
|
2872
|
+
const [offline, setOffline] = useState22(false);
|
|
2873
|
+
const [offlineMessage, setOfflineMessage] = useState22("");
|
|
2874
|
+
const [offlineSent, setOfflineSent] = useState22(false);
|
|
2875
|
+
const [offlineLoading, setOfflineLoading] = useState22(false);
|
|
2812
2876
|
const seenMessageIds = useRef3(/* @__PURE__ */ new Set());
|
|
2813
2877
|
const connectionRef = useRef3(null);
|
|
2878
|
+
useEffect20(() => {
|
|
2879
|
+
client.chat.checkAvailability().then((result) => {
|
|
2880
|
+
const data = result?.data ?? result;
|
|
2881
|
+
if (data?.within_operating_hours === false) {
|
|
2882
|
+
setOffline(true);
|
|
2883
|
+
setOfflineMessage(data.offline_message || "We are currently offline. Please leave a message.");
|
|
2884
|
+
}
|
|
2885
|
+
}).catch(() => {
|
|
2886
|
+
});
|
|
2887
|
+
}, [client.chat]);
|
|
2814
2888
|
const setupListeners = useCallback22((conn) => {
|
|
2815
2889
|
conn.onMessage((msg) => {
|
|
2816
2890
|
if (seenMessageIds.current.has(msg.id)) {
|
|
@@ -2953,6 +3027,23 @@ var ChatBubble = ({
|
|
|
2953
3027
|
seenMessageIds.current.clear();
|
|
2954
3028
|
initChat();
|
|
2955
3029
|
};
|
|
3030
|
+
const handleOfflineSubmit = async (name, email, message) => {
|
|
3031
|
+
setOfflineLoading(true);
|
|
3032
|
+
try {
|
|
3033
|
+
await client.chat.start({
|
|
3034
|
+
visitor_name: name || "Visitor",
|
|
3035
|
+
visitor_email: email,
|
|
3036
|
+
initial_message: message,
|
|
3037
|
+
channel: "web",
|
|
3038
|
+
metadata: { offline: true }
|
|
3039
|
+
});
|
|
3040
|
+
setOfflineSent(true);
|
|
3041
|
+
} catch (error) {
|
|
3042
|
+
console.error("Failed to send offline message:", error);
|
|
3043
|
+
} finally {
|
|
3044
|
+
setOfflineLoading(false);
|
|
3045
|
+
}
|
|
3046
|
+
};
|
|
2956
3047
|
useEffect20(() => {
|
|
2957
3048
|
return () => {
|
|
2958
3049
|
connectionRef.current?.disconnect();
|
|
@@ -2965,7 +3056,17 @@ var ChatBubble = ({
|
|
|
2965
3056
|
className: `diffsome-chat-bubble-container ${positionClass} ${className}`,
|
|
2966
3057
|
style: { "--diffsome-chat-primary": primaryColor, zIndex },
|
|
2967
3058
|
children: [
|
|
2968
|
-
isOpen && /* @__PURE__ */ jsx6(
|
|
3059
|
+
isOpen && (offline ? /* @__PURE__ */ jsx6(
|
|
3060
|
+
OfflineForm,
|
|
3061
|
+
{
|
|
3062
|
+
title,
|
|
3063
|
+
offlineMessage,
|
|
3064
|
+
onClose: handleClose,
|
|
3065
|
+
onSubmit: handleOfflineSubmit,
|
|
3066
|
+
submitted: offlineSent,
|
|
3067
|
+
loading: offlineLoading
|
|
3068
|
+
}
|
|
3069
|
+
) : /* @__PURE__ */ jsx6(
|
|
2969
3070
|
ChatWidget,
|
|
2970
3071
|
{
|
|
2971
3072
|
messages,
|
|
@@ -2985,7 +3086,7 @@ var ChatBubble = ({
|
|
|
2985
3086
|
loginUrl,
|
|
2986
3087
|
loginPromptMessage
|
|
2987
3088
|
}
|
|
2988
|
-
),
|
|
3089
|
+
)),
|
|
2989
3090
|
/* @__PURE__ */ jsxs5(
|
|
2990
3091
|
"button",
|
|
2991
3092
|
{
|
|
@@ -3022,6 +3123,72 @@ var ChatBubble = ({
|
|
|
3022
3123
|
}
|
|
3023
3124
|
);
|
|
3024
3125
|
};
|
|
3126
|
+
var OfflineForm = ({
|
|
3127
|
+
title,
|
|
3128
|
+
offlineMessage,
|
|
3129
|
+
onClose,
|
|
3130
|
+
onSubmit,
|
|
3131
|
+
submitted,
|
|
3132
|
+
loading
|
|
3133
|
+
}) => {
|
|
3134
|
+
const [name, setName] = useState22("");
|
|
3135
|
+
const [email, setEmail] = useState22("");
|
|
3136
|
+
const [message, setMessage] = useState22("");
|
|
3137
|
+
const handleSubmit = (e) => {
|
|
3138
|
+
e.preventDefault();
|
|
3139
|
+
if (!email || !message) return;
|
|
3140
|
+
onSubmit(name, email, message);
|
|
3141
|
+
};
|
|
3142
|
+
return /* @__PURE__ */ jsxs5("div", { className: "diffsome-chat-widget", children: [
|
|
3143
|
+
/* @__PURE__ */ jsxs5("div", { className: "diffsome-chat-header", children: [
|
|
3144
|
+
/* @__PURE__ */ jsxs5("div", { className: "diffsome-chat-header-info", children: [
|
|
3145
|
+
/* @__PURE__ */ jsx6("div", { className: "diffsome-chat-header-title", children: title }),
|
|
3146
|
+
/* @__PURE__ */ jsx6("div", { className: "diffsome-chat-header-subtitle", children: "Offline" })
|
|
3147
|
+
] }),
|
|
3148
|
+
/* @__PURE__ */ jsx6("button", { className: "diffsome-chat-header-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx6("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", width: "24", height: "24", children: /* @__PURE__ */ jsx6("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) }) })
|
|
3149
|
+
] }),
|
|
3150
|
+
/* @__PURE__ */ jsx6("div", { className: "diffsome-chat-offline-body", children: submitted ? /* @__PURE__ */ jsxs5("div", { className: "diffsome-chat-offline-success", children: [
|
|
3151
|
+
/* @__PURE__ */ jsx6("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "#10b981", width: "48", height: "48", children: /* @__PURE__ */ jsx6("path", { d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z" }) }),
|
|
3152
|
+
/* @__PURE__ */ jsx6("p", { style: { fontWeight: 600, fontSize: "16px", color: "#1f2937" }, children: "Message sent!" }),
|
|
3153
|
+
/* @__PURE__ */ jsx6("p", { style: { color: "#6b7280" }, children: "We'll get back to you soon." })
|
|
3154
|
+
] }) : /* @__PURE__ */ jsxs5("form", { onSubmit: handleSubmit, className: "diffsome-chat-offline-form", children: [
|
|
3155
|
+
/* @__PURE__ */ jsx6("p", { className: "diffsome-chat-offline-msg", children: offlineMessage }),
|
|
3156
|
+
/* @__PURE__ */ jsx6(
|
|
3157
|
+
"input",
|
|
3158
|
+
{
|
|
3159
|
+
type: "text",
|
|
3160
|
+
placeholder: "Your name",
|
|
3161
|
+
value: name,
|
|
3162
|
+
onChange: (e) => setName(e.target.value),
|
|
3163
|
+
className: "diffsome-chat-offline-input"
|
|
3164
|
+
}
|
|
3165
|
+
),
|
|
3166
|
+
/* @__PURE__ */ jsx6(
|
|
3167
|
+
"input",
|
|
3168
|
+
{
|
|
3169
|
+
type: "email",
|
|
3170
|
+
placeholder: "Email *",
|
|
3171
|
+
value: email,
|
|
3172
|
+
onChange: (e) => setEmail(e.target.value),
|
|
3173
|
+
required: true,
|
|
3174
|
+
className: "diffsome-chat-offline-input"
|
|
3175
|
+
}
|
|
3176
|
+
),
|
|
3177
|
+
/* @__PURE__ */ jsx6(
|
|
3178
|
+
"textarea",
|
|
3179
|
+
{
|
|
3180
|
+
placeholder: "Your message *",
|
|
3181
|
+
value: message,
|
|
3182
|
+
onChange: (e) => setMessage(e.target.value),
|
|
3183
|
+
required: true,
|
|
3184
|
+
rows: 4,
|
|
3185
|
+
className: "diffsome-chat-offline-textarea"
|
|
3186
|
+
}
|
|
3187
|
+
),
|
|
3188
|
+
/* @__PURE__ */ jsx6("button", { type: "submit", disabled: loading || !email || !message, className: "diffsome-chat-offline-btn", children: loading ? "Sending..." : "Leave Message" })
|
|
3189
|
+
] }) })
|
|
3190
|
+
] });
|
|
3191
|
+
};
|
|
3025
3192
|
export {
|
|
3026
3193
|
ChatBubble,
|
|
3027
3194
|
ChatInput,
|
|
@@ -3069,6 +3236,7 @@ export {
|
|
|
3069
3236
|
useMedia,
|
|
3070
3237
|
useMyReservations,
|
|
3071
3238
|
useMyReviews,
|
|
3239
|
+
useNicePayment,
|
|
3072
3240
|
useOrder,
|
|
3073
3241
|
useOrderDownloads,
|
|
3074
3242
|
useOrders,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diffsome/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "React hooks and providers for Diffsome SDK - Headless e-commerce & CMS",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"url": "https://github.com/diffsome/diffsome-react.git"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@diffsome/sdk": ">=3.
|
|
42
|
+
"@diffsome/sdk": ">=3.4.0",
|
|
43
43
|
"react": ">=18.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@diffsome/sdk": "
|
|
46
|
+
"@diffsome/sdk": "file:../sdk",
|
|
47
47
|
"@types/node": "^25.0.10",
|
|
48
48
|
"@types/react": "^18.2.0",
|
|
49
49
|
"react": "^18.2.0",
|