callix-dialer-widget 1.1.7 → 1.1.8
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.
|
@@ -53084,7 +53084,8 @@ function FloatingDialer({
|
|
|
53084
53084
|
onLogin,
|
|
53085
53085
|
onLogout,
|
|
53086
53086
|
isLoadingSession,
|
|
53087
|
-
sessionError
|
|
53087
|
+
sessionError,
|
|
53088
|
+
variant = "default"
|
|
53088
53089
|
}) {
|
|
53089
53090
|
const containerRef = useRef(null);
|
|
53090
53091
|
const cardRef = useRef(null);
|
|
@@ -53110,6 +53111,7 @@ function FloatingDialer({
|
|
|
53110
53111
|
});
|
|
53111
53112
|
const prevAuthRef = useRef(isAuthenticated);
|
|
53112
53113
|
const dialValue = useMemo(() => sanitizeDialInput(rawDialValue), [rawDialValue]);
|
|
53114
|
+
const isMiniMode = variant === "min";
|
|
53113
53115
|
const contentScale = useMemo(() => {
|
|
53114
53116
|
const widthRatio = observedSize.width / DEFAULT_DIALER_DIMENSIONS.width;
|
|
53115
53117
|
const heightRatio = observedSize.height / DEFAULT_DIALER_DIMENSIONS.height;
|
|
@@ -53401,7 +53403,8 @@ function FloatingDialer({
|
|
|
53401
53403
|
username: username ?? "",
|
|
53402
53404
|
dialValue,
|
|
53403
53405
|
setDialValue: updateDialValue,
|
|
53404
|
-
onLogout
|
|
53406
|
+
onLogout,
|
|
53407
|
+
variant
|
|
53405
53408
|
}
|
|
53406
53409
|
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
53407
53410
|
LoginForm,
|
|
@@ -53412,6 +53415,17 @@ function FloatingDialer({
|
|
|
53412
53415
|
error: sessionError
|
|
53413
53416
|
}
|
|
53414
53417
|
);
|
|
53418
|
+
if (isMiniMode) {
|
|
53419
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
53420
|
+
"div",
|
|
53421
|
+
{
|
|
53422
|
+
className: ["callix", "mode", "min", tw`w-full`].join(" "),
|
|
53423
|
+
"data-callix-variant": "min",
|
|
53424
|
+
style: { width: "100%", height: "100%" },
|
|
53425
|
+
children: dialerContent
|
|
53426
|
+
}
|
|
53427
|
+
);
|
|
53428
|
+
}
|
|
53415
53429
|
const scale = Number.isFinite(contentScale) && contentScale > 0 ? contentScale : 1;
|
|
53416
53430
|
const scaledWidth = DEFAULT_DIALER_DIMENSIONS.width / scale;
|
|
53417
53431
|
const scaledHeight = DEFAULT_DIALER_DIMENSIONS.height / scale;
|
|
@@ -53443,7 +53457,8 @@ function FloatingDialer({
|
|
|
53443
53457
|
"div",
|
|
53444
53458
|
{
|
|
53445
53459
|
ref: containerRef,
|
|
53446
|
-
className: tw`fixed z-50 select-none
|
|
53460
|
+
className: ["callix", "mode", "full", tw`fixed z-50 select-none`].join(" "),
|
|
53461
|
+
"data-callix-variant": "default",
|
|
53447
53462
|
style: {
|
|
53448
53463
|
transform: `translate3d(${position2.x}px, ${position2.y}px, 0)`,
|
|
53449
53464
|
top: 0,
|
|
@@ -53592,9 +53607,10 @@ function LoginForm({ defaultValue, onSubmit, isLoading, error: error2 }) {
|
|
|
53592
53607
|
)
|
|
53593
53608
|
] });
|
|
53594
53609
|
}
|
|
53595
|
-
function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
|
|
53610
|
+
function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, variant }) {
|
|
53596
53611
|
var _a2, _b;
|
|
53597
53612
|
const operator = clientSdkReactExports.useCallOperator();
|
|
53613
|
+
const isMiniMode = variant === "min";
|
|
53598
53614
|
const operatorState = clientSdkReactExports.useCallOperatorState();
|
|
53599
53615
|
const currentCall = clientSdkReactExports.useCallOperatorCurrentCall();
|
|
53600
53616
|
const currentCallInfo = clientSdkReactExports.useCallOperatorCurrentCallInfo();
|
|
@@ -54297,6 +54313,164 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
|
|
|
54297
54313
|
}
|
|
54298
54314
|
);
|
|
54299
54315
|
}
|
|
54316
|
+
const breakModal = isBreakModalOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`bg-white rounded-2xl shadow-2xl max-w-md w-full p-6 space-y-4`, children: [
|
|
54317
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between`, children: [
|
|
54318
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: tw`text-lg font-bold text-slate-800`, children: "Selecione uma Pausa" }),
|
|
54319
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54320
|
+
"button",
|
|
54321
|
+
{
|
|
54322
|
+
type: "button",
|
|
54323
|
+
onClick: () => {
|
|
54324
|
+
setIsBreakModalOpen(false);
|
|
54325
|
+
setBreakError(null);
|
|
54326
|
+
},
|
|
54327
|
+
className: tw`text-slate-400 hover:text-slate-600 transition`,
|
|
54328
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-xl` })
|
|
54329
|
+
}
|
|
54330
|
+
)
|
|
54331
|
+
] }),
|
|
54332
|
+
breakError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`rounded-lg bg-red-50 border border-red-200 px-3 py-2 flex items-start gap-2`, children: [
|
|
54333
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`text-red-500 shrink-0 mt-0.5` }),
|
|
54334
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm text-red-700`, children: breakError })
|
|
54335
|
+
] }),
|
|
54336
|
+
!breaks || breaks.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`text-center py-8`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-slate-500`, children: "Nenhuma pausa disponivel" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`space-y-2 max-h-96 overflow-y-auto`, children: breaks.map((breakItem) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54337
|
+
"button",
|
|
54338
|
+
{
|
|
54339
|
+
type: "button",
|
|
54340
|
+
onClick: () => handleGoOnBreak(breakItem.id),
|
|
54341
|
+
className: tw`w-full flex items-center gap-3 rounded-lg border border-slate-200 bg-white px-4 py-3 text-left transition-all hover:border-amber-300 hover:bg-amber-50 hover:shadow-md`,
|
|
54342
|
+
children: [
|
|
54343
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-xl text-amber-600 shrink-0` }),
|
|
54344
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex-1 min-w-0`, children: [
|
|
54345
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`font-semibold text-slate-800 truncate`, children: breakItem.name }),
|
|
54346
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: tw`text-xs text-slate-500`, children: [
|
|
54347
|
+
"ID: ",
|
|
54348
|
+
breakItem.id
|
|
54349
|
+
] })
|
|
54350
|
+
] })
|
|
54351
|
+
]
|
|
54352
|
+
},
|
|
54353
|
+
breakItem.id
|
|
54354
|
+
)) }),
|
|
54355
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54356
|
+
"button",
|
|
54357
|
+
{
|
|
54358
|
+
type: "button",
|
|
54359
|
+
onClick: () => {
|
|
54360
|
+
setIsBreakModalOpen(false);
|
|
54361
|
+
setBreakError(null);
|
|
54362
|
+
},
|
|
54363
|
+
className: tw`w-full rounded-lg border border-slate-200 bg-slate-50 px-4 py-2 text-sm font-semibold text-slate-600 transition hover:bg-slate-100`,
|
|
54364
|
+
children: "Cancelar"
|
|
54365
|
+
}
|
|
54366
|
+
)
|
|
54367
|
+
] }) }) : null;
|
|
54368
|
+
if (isMiniMode) {
|
|
54369
|
+
const isCallActive = isInCall || isConnecting;
|
|
54370
|
+
const callButtonDisabled = !isCallActive && !isNumberValid;
|
|
54371
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54372
|
+
"div",
|
|
54373
|
+
{
|
|
54374
|
+
className: ["callix", "mode", "min", tw`flex w-full max-w-full flex-col gap-3 rounded-2xl border border-slate-200 bg-white/95 p-3 shadow-sm text-slate-800`].join(" "),
|
|
54375
|
+
"data-callix-variant": "min",
|
|
54376
|
+
children: [
|
|
54377
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between gap-2`, children: [
|
|
54378
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`${statusVisual.badgeClass} flex items-center gap-1 rounded-full border px-2 py-0.5 text-[10px] font-semibold uppercase leading-tight`, children: [
|
|
54379
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(statusVisual.Icon, { className: tw`text-xs` }),
|
|
54380
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: statusLabel })
|
|
54381
|
+
] }),
|
|
54382
|
+
isOnBreak ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54383
|
+
"button",
|
|
54384
|
+
{
|
|
54385
|
+
type: "button",
|
|
54386
|
+
onClick: () => handleGoOffBreak(),
|
|
54387
|
+
className: tw`inline-flex items-center gap-1 rounded-full border border-emerald-400 bg-emerald-50 px-2.5 py-1 text-[10px] font-semibold text-emerald-700 transition hover:bg-emerald-100`,
|
|
54388
|
+
children: [
|
|
54389
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiCheckCircle, { className: tw`text-xs` }),
|
|
54390
|
+
"Voltar"
|
|
54391
|
+
]
|
|
54392
|
+
}
|
|
54393
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54394
|
+
"button",
|
|
54395
|
+
{
|
|
54396
|
+
type: "button",
|
|
54397
|
+
onClick: () => setIsBreakModalOpen(true),
|
|
54398
|
+
className: tw`inline-flex items-center gap-1 rounded-full border border-amber-300 bg-amber-50 px-2.5 py-1 text-[10px] font-semibold text-amber-700 transition hover:bg-amber-100`,
|
|
54399
|
+
children: [
|
|
54400
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-xs` }),
|
|
54401
|
+
"Pausa"
|
|
54402
|
+
]
|
|
54403
|
+
}
|
|
54404
|
+
)
|
|
54405
|
+
] }),
|
|
54406
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`space-y-1 rounded-xl border border-slate-200 bg-slate-50 px-3 py-2`, children: [
|
|
54407
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-[10px] font-semibold uppercase tracking-wide text-slate-500`, children: "Numero" }),
|
|
54408
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center gap-2`, children: [
|
|
54409
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`flex-1 truncate text-lg font-semibold text-slate-800`, children: dialDisplayText || /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-slate-400 text-base font-normal`, children: "Digite um numero" }) }),
|
|
54410
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54411
|
+
"button",
|
|
54412
|
+
{
|
|
54413
|
+
type: "button",
|
|
54414
|
+
onClick: handleBackspace,
|
|
54415
|
+
className: tw`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-slate-300 bg-white text-slate-600 transition hover:border-slate-400 hover:text-slate-800`,
|
|
54416
|
+
"aria-label": "Apagar ultimo digito",
|
|
54417
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiDelete, { className: tw`text-base` })
|
|
54418
|
+
}
|
|
54419
|
+
),
|
|
54420
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54421
|
+
"button",
|
|
54422
|
+
{
|
|
54423
|
+
type: "button",
|
|
54424
|
+
onClick: handleClear,
|
|
54425
|
+
className: tw`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-rose-300 bg-rose-50 text-rose-600 transition hover:border-rose-400 hover:bg-rose-100`,
|
|
54426
|
+
"aria-label": "Limpar numero",
|
|
54427
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-sm` })
|
|
54428
|
+
}
|
|
54429
|
+
)
|
|
54430
|
+
] })
|
|
54431
|
+
] }),
|
|
54432
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`grid grid-cols-3 gap-2`, children: keypadKeys.map((item) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54433
|
+
"button",
|
|
54434
|
+
{
|
|
54435
|
+
type: "button",
|
|
54436
|
+
onClick: () => handleDial(item.value),
|
|
54437
|
+
disabled: !canUseKeypad,
|
|
54438
|
+
className: tw`flex h-12 flex-col items-center justify-center rounded-lg border border-slate-200 bg-white text-base font-semibold text-slate-800 shadow-sm transition active:scale-95 hover:border-slate-300 hover:shadow-md disabled:cursor-not-allowed disabled:opacity-50`,
|
|
54439
|
+
children: [
|
|
54440
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: item.value }),
|
|
54441
|
+
item.detail && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`text-[8px] font-semibold uppercase tracking-widest text-slate-400`, children: item.detail })
|
|
54442
|
+
]
|
|
54443
|
+
},
|
|
54444
|
+
item.value
|
|
54445
|
+
)) }),
|
|
54446
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54447
|
+
"button",
|
|
54448
|
+
{
|
|
54449
|
+
type: "button",
|
|
54450
|
+
onClick: () => {
|
|
54451
|
+
if (isCallActive) {
|
|
54452
|
+
void handleHangup();
|
|
54453
|
+
} else {
|
|
54454
|
+
void handleCall();
|
|
54455
|
+
}
|
|
54456
|
+
},
|
|
54457
|
+
disabled: callButtonDisabled,
|
|
54458
|
+
className: tw`${isCallActive ? "bg-rose-500 hover:bg-rose-600" : "bg-emerald-500 hover:bg-emerald-600"} flex h-11 w-full items-center justify-center gap-2 rounded-xl text-sm font-bold text-white shadow-md transition disabled:cursor-not-allowed disabled:opacity-60`,
|
|
54459
|
+
children: [
|
|
54460
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiPhone, { className: tw`text-base` }),
|
|
54461
|
+
isCallActive ? "Encerrar" : "Ligar"
|
|
54462
|
+
]
|
|
54463
|
+
}
|
|
54464
|
+
),
|
|
54465
|
+
(callError || availabilityError || audioDeviceError) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`rounded-lg border border-rose-200 bg-rose-50 px-2.5 py-2 text-[11px] text-rose-700`, children: [
|
|
54466
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`mr-1 inline text-xs` }),
|
|
54467
|
+
callError || availabilityError || audioDeviceError
|
|
54468
|
+
] }),
|
|
54469
|
+
breakModal
|
|
54470
|
+
]
|
|
54471
|
+
}
|
|
54472
|
+
);
|
|
54473
|
+
}
|
|
54300
54474
|
const showActiveSummary = isInCall || isConnecting;
|
|
54301
54475
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54302
54476
|
"div",
|
|
@@ -54638,58 +54812,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
|
|
|
54638
54812
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: audioDeviceError })
|
|
54639
54813
|
] })
|
|
54640
54814
|
] }),
|
|
54641
|
-
|
|
54642
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between`, children: [
|
|
54643
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: tw`text-lg font-bold text-slate-800`, children: "Selecione uma Pausa" }),
|
|
54644
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54645
|
-
"button",
|
|
54646
|
-
{
|
|
54647
|
-
type: "button",
|
|
54648
|
-
onClick: () => {
|
|
54649
|
-
setIsBreakModalOpen(false);
|
|
54650
|
-
setBreakError(null);
|
|
54651
|
-
},
|
|
54652
|
-
className: tw`text-slate-400 hover:text-slate-600 transition`,
|
|
54653
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-xl` })
|
|
54654
|
-
}
|
|
54655
|
-
)
|
|
54656
|
-
] }),
|
|
54657
|
-
breakError && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`rounded-lg bg-red-50 border border-red-200 px-3 py-2 flex items-start gap-2`, children: [
|
|
54658
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`text-red-500 shrink-0 mt-0.5` }),
|
|
54659
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm text-red-700`, children: breakError })
|
|
54660
|
-
] }),
|
|
54661
|
-
!breaks || breaks.length === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`text-center py-8`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-slate-500`, children: "Nenhuma pausa disponível" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`space-y-2 max-h-96 overflow-y-auto`, children: breaks.map((breakItem) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54662
|
-
"button",
|
|
54663
|
-
{
|
|
54664
|
-
type: "button",
|
|
54665
|
-
onClick: () => handleGoOnBreak(breakItem.id),
|
|
54666
|
-
className: tw`w-full flex items-center gap-3 rounded-lg border border-slate-200 bg-white px-4 py-3 text-left transition-all hover:border-amber-300 hover:bg-amber-50 hover:shadow-md`,
|
|
54667
|
-
children: [
|
|
54668
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-xl text-amber-600 shrink-0` }),
|
|
54669
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex-1 min-w-0`, children: [
|
|
54670
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`font-semibold text-slate-800 truncate`, children: breakItem.name }),
|
|
54671
|
-
/* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: tw`text-xs text-slate-500`, children: [
|
|
54672
|
-
"ID: ",
|
|
54673
|
-
breakItem.id
|
|
54674
|
-
] })
|
|
54675
|
-
] })
|
|
54676
|
-
]
|
|
54677
|
-
},
|
|
54678
|
-
breakItem.id
|
|
54679
|
-
)) }),
|
|
54680
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
54681
|
-
"button",
|
|
54682
|
-
{
|
|
54683
|
-
type: "button",
|
|
54684
|
-
onClick: () => {
|
|
54685
|
-
setIsBreakModalOpen(false);
|
|
54686
|
-
setBreakError(null);
|
|
54687
|
-
},
|
|
54688
|
-
className: tw`w-full rounded-lg border border-slate-200 bg-slate-50 px-4 py-2 text-sm font-semibold text-slate-600 transition hover:bg-slate-100`,
|
|
54689
|
-
children: "Cancelar"
|
|
54690
|
-
}
|
|
54691
|
-
)
|
|
54692
|
-
] }) }),
|
|
54815
|
+
breakModal,
|
|
54693
54816
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
54694
54817
|
"button",
|
|
54695
54818
|
{
|
|
@@ -55039,8 +55162,8 @@ function ActiveCallSummary({
|
|
|
55039
55162
|
] })
|
|
55040
55163
|
] }) });
|
|
55041
55164
|
}
|
|
55042
|
-
function InlineDialer(props) {
|
|
55043
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { style: { width: "100%", height: "100%" }, children: [
|
|
55165
|
+
function InlineDialer({ variant = "default", ...props }) {
|
|
55166
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: ["callix", "mode", variant === "min" ? "min" : "inline"].join(" "), "data-callix-variant": variant === "min" ? "min" : "inline", style: { width: "100%", height: "100%" }, children: [
|
|
55044
55167
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
55045
55168
|
"style",
|
|
55046
55169
|
{
|
|
@@ -55085,9 +55208,41 @@ function InlineDialer(props) {
|
|
|
55085
55208
|
}
|
|
55086
55209
|
}
|
|
55087
55210
|
),
|
|
55088
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "callix-inline-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingDialer, { ...props }) })
|
|
55211
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "callix-inline-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingDialer, { ...props, variant }) })
|
|
55089
55212
|
] });
|
|
55090
55213
|
}
|
|
55214
|
+
function deriveOptionsFromElement(element) {
|
|
55215
|
+
const result2 = {};
|
|
55216
|
+
const datasetMode = element.getAttribute("data-callix-mode") || element.dataset.callixMode || element.dataset.mode;
|
|
55217
|
+
const datasetUsername = element.getAttribute("data-callix-username") || element.dataset.callixUsername || element.dataset.username;
|
|
55218
|
+
const classList = Array.from(element.classList);
|
|
55219
|
+
const lowerClasses = classList.map((cls) => cls.toLowerCase());
|
|
55220
|
+
const hasCallixClass = lowerClasses.includes("callix");
|
|
55221
|
+
const normalizedMode = datasetMode ? datasetMode.toLowerCase() : void 0;
|
|
55222
|
+
if (normalizedMode === "min" || normalizedMode === "mini") {
|
|
55223
|
+
result2.uiVariant = "min";
|
|
55224
|
+
} else if (hasCallixClass) {
|
|
55225
|
+
if (lowerClasses.includes("mode-min") || lowerClasses.includes("mode-mini") || lowerClasses.includes("mode") && lowerClasses.includes("min")) {
|
|
55226
|
+
result2.uiVariant = "min";
|
|
55227
|
+
}
|
|
55228
|
+
}
|
|
55229
|
+
if (!result2.presetUsername && datasetUsername) {
|
|
55230
|
+
result2.presetUsername = datasetUsername.trim();
|
|
55231
|
+
}
|
|
55232
|
+
if (!result2.presetUsername) {
|
|
55233
|
+
for (const className of classList) {
|
|
55234
|
+
const match2 = className.match(/(?:user|username|callix-user)[-_:]([A-Za-z0-9.@_-]+)/i);
|
|
55235
|
+
if (match2) {
|
|
55236
|
+
result2.presetUsername = match2[1];
|
|
55237
|
+
break;
|
|
55238
|
+
}
|
|
55239
|
+
}
|
|
55240
|
+
}
|
|
55241
|
+
if (result2.presetUsername) {
|
|
55242
|
+
result2.presetUsername = result2.presetUsername.trim();
|
|
55243
|
+
}
|
|
55244
|
+
return result2;
|
|
55245
|
+
}
|
|
55091
55246
|
class CallixDialerWidget {
|
|
55092
55247
|
constructor(options) {
|
|
55093
55248
|
this.root = null;
|
|
@@ -55108,6 +55263,13 @@ class CallixDialerWidget {
|
|
|
55108
55263
|
if (!this.container) {
|
|
55109
55264
|
throw new Error(`Container não encontrado: ${this.options.container}`);
|
|
55110
55265
|
}
|
|
55266
|
+
const derived = deriveOptionsFromElement(this.container);
|
|
55267
|
+
if (!this.options.uiVariant && derived.uiVariant) {
|
|
55268
|
+
this.options.uiVariant = derived.uiVariant;
|
|
55269
|
+
}
|
|
55270
|
+
if (!this.options.presetUsername && derived.presetUsername) {
|
|
55271
|
+
this.options.presetUsername = derived.presetUsername;
|
|
55272
|
+
}
|
|
55111
55273
|
this.root = clientExports.createRoot(this.container);
|
|
55112
55274
|
this.root.render(
|
|
55113
55275
|
/* @__PURE__ */ jsxRuntimeExports.jsx(StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialerWrapper, { options: this.options }) })
|
|
@@ -55148,6 +55310,10 @@ function DialerWrapper({ options }) {
|
|
|
55148
55310
|
const [sessionToken, setSessionToken] = useState(null);
|
|
55149
55311
|
const [callixDomain, setCallixDomain] = useState(null);
|
|
55150
55312
|
const [isRestoringSession, setIsRestoringSession] = useState(true);
|
|
55313
|
+
const presetUsername = options.presetUsername ? options.presetUsername.trim() : null;
|
|
55314
|
+
const uiVariant = options.uiVariant ?? "default";
|
|
55315
|
+
const autoLoginAttemptedRef = useRef(false);
|
|
55316
|
+
const lastPresetRef = useRef(presetUsername);
|
|
55151
55317
|
useEffect(() => {
|
|
55152
55318
|
if (typeof window === "undefined") {
|
|
55153
55319
|
setIsRestoringSession(false);
|
|
@@ -55159,6 +55325,11 @@ function DialerWrapper({ options }) {
|
|
|
55159
55325
|
setIsRestoringSession(false);
|
|
55160
55326
|
return;
|
|
55161
55327
|
}
|
|
55328
|
+
if (presetUsername && storedLastUsername !== presetUsername) {
|
|
55329
|
+
console.log("[Callix Dialer] Ignorando sessao salva por mismatch com preset:", storedLastUsername, "!=", presetUsername);
|
|
55330
|
+
setIsRestoringSession(false);
|
|
55331
|
+
return;
|
|
55332
|
+
}
|
|
55162
55333
|
const STORAGE_KEYS = getStorageKeys(storedLastUsername);
|
|
55163
55334
|
const storedToken = localStorage.getItem(STORAGE_KEYS.SESSION_TOKEN);
|
|
55164
55335
|
const storedDomain = localStorage.getItem(STORAGE_KEYS.DOMAIN);
|
|
@@ -55186,7 +55357,12 @@ function DialerWrapper({ options }) {
|
|
|
55186
55357
|
setIsRestoringSession(false);
|
|
55187
55358
|
}
|
|
55188
55359
|
}, []);
|
|
55189
|
-
|
|
55360
|
+
useEffect(() => {
|
|
55361
|
+
if (presetUsername && username !== presetUsername) {
|
|
55362
|
+
setUsername(presetUsername);
|
|
55363
|
+
}
|
|
55364
|
+
}, [presetUsername, username]);
|
|
55365
|
+
const handleLogin = useCallback(async (user) => {
|
|
55190
55366
|
setIsLoading(true);
|
|
55191
55367
|
setError(null);
|
|
55192
55368
|
try {
|
|
@@ -55231,14 +55407,32 @@ function DialerWrapper({ options }) {
|
|
|
55231
55407
|
} finally {
|
|
55232
55408
|
setIsLoading(false);
|
|
55233
55409
|
}
|
|
55234
|
-
};
|
|
55410
|
+
}, [options.apiUrl]);
|
|
55411
|
+
useEffect(() => {
|
|
55412
|
+
if (!presetUsername) {
|
|
55413
|
+
lastPresetRef.current = null;
|
|
55414
|
+
autoLoginAttemptedRef.current = false;
|
|
55415
|
+
return;
|
|
55416
|
+
}
|
|
55417
|
+
if (lastPresetRef.current !== presetUsername) {
|
|
55418
|
+
lastPresetRef.current = presetUsername;
|
|
55419
|
+
autoLoginAttemptedRef.current = false;
|
|
55420
|
+
}
|
|
55421
|
+
if (isAuthenticated || isLoading || isRestoringSession || autoLoginAttemptedRef.current) {
|
|
55422
|
+
return;
|
|
55423
|
+
}
|
|
55424
|
+
autoLoginAttemptedRef.current = true;
|
|
55425
|
+
void handleLogin(presetUsername);
|
|
55426
|
+
}, [presetUsername, isAuthenticated, isLoading, isRestoringSession, handleLogin]);
|
|
55235
55427
|
const handleLogout = () => {
|
|
55236
55428
|
const currentUsername = username;
|
|
55237
|
-
setUsername(null);
|
|
55429
|
+
setUsername(presetUsername ?? null);
|
|
55238
55430
|
setIsAuthenticated(false);
|
|
55239
55431
|
setSessionToken(null);
|
|
55240
55432
|
setCallixDomain(null);
|
|
55241
55433
|
setError(null);
|
|
55434
|
+
autoLoginAttemptedRef.current = false;
|
|
55435
|
+
lastPresetRef.current = presetUsername ?? null;
|
|
55242
55436
|
if (typeof window !== "undefined" && currentUsername) {
|
|
55243
55437
|
try {
|
|
55244
55438
|
const STORAGE_KEYS = getStorageKeys(currentUsername);
|
|
@@ -55262,7 +55456,8 @@ function DialerWrapper({ options }) {
|
|
|
55262
55456
|
onLogin: handleLogin,
|
|
55263
55457
|
onLogout: handleLogout,
|
|
55264
55458
|
isLoadingSession: isLoading || isRestoringSession,
|
|
55265
|
-
sessionError: error2
|
|
55459
|
+
sessionError: error2,
|
|
55460
|
+
variant: uiVariant
|
|
55266
55461
|
}
|
|
55267
55462
|
);
|
|
55268
55463
|
}
|
|
@@ -55279,7 +55474,8 @@ function DialerWrapper({ options }) {
|
|
|
55279
55474
|
onLogin: handleLogin,
|
|
55280
55475
|
onLogout: handleLogout,
|
|
55281
55476
|
isLoadingSession: isLoading,
|
|
55282
|
-
sessionError: error2
|
|
55477
|
+
sessionError: error2,
|
|
55478
|
+
variant: uiVariant
|
|
55283
55479
|
}
|
|
55284
55480
|
)
|
|
55285
55481
|
}
|