livechat-widget
Version:
LiveChat Widget for Next.js applications
25 lines (24 loc) • 3.11 kB
JavaScript
"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import dynamic from "next/dynamic";
// ใช้ dynamic import เพื่อหลีกเลี่ยงปัญหา SSR กับ WebSocket
var ChatWidget = dynamic(function () { return import("./ChatWidget"); }, { ssr: false });
var ChatWidgetClient = function (_a) {
var roomCode = _a.roomCode, appId = _a.appId, roomName = _a.roomName, _b = _a.theme, theme = _b === void 0 ? 'dark' : _b, bgColor = _a.bgColor, bgColorClass = _a.bgColorClass, textColor = _a.textColor, textColorClass = _a.textColorClass, bgInput = _a.bgInput, bgInputClass = _a.bgInputClass, textInputColor = _a.textInputColor, textInputColorClass = _a.textInputColorClass, currentUserColor = _a.currentUserColor, currentUserColorClass = _a.currentUserColorClass, adminColor = _a.adminColor, adminColorClass = _a.adminColorClass, buttonBgColor = _a.buttonBgColor, buttonBgClass = _a.buttonBgClass, userInfo = _a.userInfo, userCode = _a.userCode, width = _a.width, height = _a.height, _c = _a.borderWidth, borderWidth = _c === void 0 ? 1 : _c, borderColor = _a.borderColor, borderColorClass = _a.borderColorClass, _d = _a.borderRadius, borderRadius = _d === void 0 ? 4 : _d, _e = _a.hasBorder, hasBorder = _e === void 0 ? true : _e, apiUrl = _a.apiUrl, wsUrl = _a.wsUrl;
// แปลงค่า borderWidth และ borderRadius ให้เป็น string ที่มี px (ถ้าเป็นตัวเลข)
var borderWidthStyle = typeof borderWidth === 'number' ? "".concat(borderWidth, "px") : borderWidth;
var borderRadiusStyle = typeof borderRadius === 'number' ? "".concat(borderRadius, "px") : borderRadius;
// กำหนดสีเส้นขอบตาม theme ถ้าไม่ได้ระบุ
var defaultBorderColor = theme === 'dark' ? '#333333' : '#e5e7eb';
return (_jsx("div", { style: {
width: typeof width === 'number' ? "".concat(width, "px") : width || '100%',
height: typeof height === 'number' ? "".concat(height, "px") : height || '100%',
maxWidth: '100%',
border: hasBorder ? "".concat(borderWidthStyle, " solid ").concat(borderColor || defaultBorderColor) : 'none',
borderRadius: borderRadiusStyle,
overflow: 'hidden',
display: 'flex',
flexDirection: 'column'
}, className: borderColorClass ? "border-".concat(borderColorClass) : '', children: _jsx(ChatWidget, { roomCode: roomCode, appId: appId, roomName: roomName, theme: theme, bgColor: bgColor, bgColorClass: bgColorClass, textColor: textColor, textColorClass: textColorClass, bgInput: bgInput, bgInputClass: bgInputClass, textInputColor: textInputColor, textInputColorClass: textInputColorClass, currentUserColor: currentUserColor, currentUserColorClass: currentUserColorClass, adminColor: adminColor, adminColorClass: adminColorClass, buttonBgColor: buttonBgColor, buttonBgClass: buttonBgClass, userInfo: userInfo, userCode: userCode, width: width, height: height, apiUrl: apiUrl, wsUrl: wsUrl }) }));
};
export default ChatWidgetClient;