callix-dialer-widget 1.1.6 → 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.
@@ -53046,7 +53046,7 @@ const MIN_DIALER_WIDTH = 280;
53046
53046
  const MIN_DIALER_HEIGHT = 420;
53047
53047
  const MAX_DIALER_WIDTH = 1024;
53048
53048
  const MAX_DIALER_HEIGHT = 960;
53049
- const MIN_DIALER_SCALE = 0.65;
53049
+ const MIN_DIALER_SCALE = 0.55;
53050
53050
  const MAX_DIALER_SCALE = 2.5;
53051
53051
  const VIEWPORT_MARGIN_SMALL = 12;
53052
53052
  const VIEWPORT_MARGIN_DEFAULT = 16;
@@ -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,7 +53415,20 @@ 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;
53430
+ const scaledWidth = DEFAULT_DIALER_DIMENSIONS.width / scale;
53431
+ const scaledHeight = DEFAULT_DIALER_DIMENSIONS.height / scale;
53416
53432
  const cardStyle = {
53417
53433
  width: manualSize ? `${manualSize.width}px` : void 0,
53418
53434
  height: manualSize ? `${manualSize.height}px` : void 0,
@@ -53421,16 +53437,28 @@ function FloatingDialer({
53421
53437
  maxWidth: `min(${MAX_DIALER_WIDTH}px, calc(100vw - 1.5rem))`,
53422
53438
  maxHeight: `calc(100vh - 3rem)`
53423
53439
  };
53424
- const scalePercent = Math.round(scale * 1e4) / 100;
53440
+ const scaledWrapperStyle = {
53441
+ flex: 1,
53442
+ display: "flex",
53443
+ flexDirection: "column",
53444
+ transform: `scale(${scale})`,
53445
+ transformOrigin: "top left",
53446
+ width: `${scaledWidth}px`,
53447
+ minHeight: `${scaledHeight}px`
53448
+ };
53425
53449
  const cardContentStyle = {
53426
- fontSize: `${scalePercent}%`,
53427
- lineHeight: 1.25
53450
+ flex: 1,
53451
+ display: "flex",
53452
+ flexDirection: "column",
53453
+ width: `${DEFAULT_DIALER_DIMENSIONS.width}px`,
53454
+ minHeight: `${DEFAULT_DIALER_DIMENSIONS.height}px`
53428
53455
  };
53429
53456
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
53430
53457
  "div",
53431
53458
  {
53432
53459
  ref: containerRef,
53433
- className: tw`fixed z-50 select-none`,
53460
+ className: ["callix", "mode", "full", tw`fixed z-50 select-none`].join(" "),
53461
+ "data-callix-variant": "default",
53434
53462
  style: {
53435
53463
  transform: `translate3d(${position2.x}px, ${position2.y}px, 0)`,
53436
53464
  top: 0,
@@ -53444,35 +53472,43 @@ function FloatingDialer({
53444
53472
  className: tw`relative flex flex-col items-start overflow-hidden rounded-3xl border border-slate-200/60 bg-gradient-to-br from-white/95 via-slate-50/95 to-white/90 shadow-2xl backdrop-blur-lg transition-all duration-300 w-[min(32rem,calc(100vw-1.5rem))] max-w-[calc(100vw-1.5rem)] sm:w-[28rem] md:w-[30rem] max-h-[calc(100vh-3rem)] sm:max-h-none`,
53445
53473
  style: cardStyle,
53446
53474
  children: [
53447
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex flex-1 flex-col rounded-3xl overflow-hidden`, style: cardContentStyle, children: [
53448
- /* @__PURE__ */ jsxRuntimeExports.jsxs(
53449
- "div",
53450
- {
53451
- className: tw`cursor-grab touch-none active:cursor-grabbing flex items-center justify-between bg-gradient-to-r from-primary to-primaryDark px-4 py-3 text-white shadow-sm`,
53452
- onPointerDown: beginDrag,
53453
- children: [
53454
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center gap-3`, children: [
53455
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`inline-flex h-10 w-10 items-center justify-center rounded-2xl bg-white/15 shadow-inner`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiPhoneCall, { className: tw`text-xl` }) }),
53456
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`space-y-0.5`, children: [
53457
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-[11px] uppercase tracking-[0.2em] text-white/70`, children: "Discadora" }),
53458
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-base font-semibold`, children: username ?? "Visitante" })
53459
- ] })
53460
- ] }),
53461
- /* @__PURE__ */ jsxRuntimeExports.jsx(
53462
- "button",
53463
- {
53464
- type: "button",
53465
- className: tw`rounded-full p-2 text-white/80 transition hover:bg-white/15 hover:text-white`,
53466
- onClick: () => setIsOpen(false),
53467
- "aria-label": "Fechar discadora",
53468
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-lg` })
53469
- }
53470
- )
53471
- ]
53472
- }
53473
- ),
53474
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`flex-1 overflow-y-auto p-3`, children: dialerContent })
53475
- ] }),
53475
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`flex flex-1 flex-col overflow-hidden`, style: scaledWrapperStyle, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
53476
+ "div",
53477
+ {
53478
+ "data-floating-dialer-content": true,
53479
+ className: tw`flex flex-1 flex-col rounded-3xl overflow-hidden`,
53480
+ style: cardContentStyle,
53481
+ children: [
53482
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(
53483
+ "div",
53484
+ {
53485
+ className: tw`cursor-grab touch-none active:cursor-grabbing flex items-center justify-between bg-gradient-to-r from-primary to-primaryDark px-4 py-3 text-white shadow-sm`,
53486
+ onPointerDown: beginDrag,
53487
+ children: [
53488
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center gap-3`, children: [
53489
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: tw`inline-flex h-10 w-10 items-center justify-center rounded-2xl bg-white/15 shadow-inner`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiPhoneCall, { className: tw`text-xl` }) }),
53490
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`space-y-0.5`, children: [
53491
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-[11px] uppercase tracking-[0.2em] text-white/70`, children: "Discadora" }),
53492
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-base font-semibold`, children: username ?? "Visitante" })
53493
+ ] })
53494
+ ] }),
53495
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
53496
+ "button",
53497
+ {
53498
+ type: "button",
53499
+ className: tw`rounded-full p-2 text-white/80 transition hover:bg-white/15 hover:text-white`,
53500
+ onClick: () => setIsOpen(false),
53501
+ "aria-label": "Fechar discadora",
53502
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-lg` })
53503
+ }
53504
+ )
53505
+ ]
53506
+ }
53507
+ ),
53508
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: tw`flex-1 overflow-y-auto p-3`, children: dialerContent })
53509
+ ]
53510
+ }
53511
+ ) }),
53476
53512
  /* @__PURE__ */ jsxRuntimeExports.jsx(
53477
53513
  "div",
53478
53514
  {
@@ -53571,9 +53607,10 @@ function LoginForm({ defaultValue, onSubmit, isLoading, error: error2 }) {
53571
53607
  )
53572
53608
  ] });
53573
53609
  }
53574
- function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
53610
+ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout, variant }) {
53575
53611
  var _a2, _b;
53576
53612
  const operator = clientSdkReactExports.useCallOperator();
53613
+ const isMiniMode = variant === "min";
53577
53614
  const operatorState = clientSdkReactExports.useCallOperatorState();
53578
53615
  const currentCall = clientSdkReactExports.useCallOperatorCurrentCall();
53579
53616
  const currentCallInfo = clientSdkReactExports.useCallOperatorCurrentCallInfo();
@@ -54276,6 +54313,164 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
54276
54313
  }
54277
54314
  );
54278
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
+ }
54279
54474
  const showActiveSummary = isInCall || isConnecting;
54280
54475
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
54281
54476
  "div",
@@ -54617,58 +54812,7 @@ function AuthenticatedDialer({ username, dialValue, setDialValue, onLogout }) {
54617
54812
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: audioDeviceError })
54618
54813
  ] })
54619
54814
  ] }),
54620
- 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: [
54621
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex items-center justify-between`, children: [
54622
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: tw`text-lg font-bold text-slate-800`, children: "Selecione uma Pausa" }),
54623
- /* @__PURE__ */ jsxRuntimeExports.jsx(
54624
- "button",
54625
- {
54626
- type: "button",
54627
- onClick: () => {
54628
- setIsBreakModalOpen(false);
54629
- setBreakError(null);
54630
- },
54631
- className: tw`text-slate-400 hover:text-slate-600 transition`,
54632
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(FiX, { className: tw`text-xl` })
54633
- }
54634
- )
54635
- ] }),
54636
- 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: [
54637
- /* @__PURE__ */ jsxRuntimeExports.jsx(FiAlertTriangle, { className: tw`text-red-500 shrink-0 mt-0.5` }),
54638
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`text-sm text-red-700`, children: breakError })
54639
- ] }),
54640
- !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(
54641
- "button",
54642
- {
54643
- type: "button",
54644
- onClick: () => handleGoOnBreak(breakItem.id),
54645
- 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`,
54646
- children: [
54647
- /* @__PURE__ */ jsxRuntimeExports.jsx(FiPauseCircle, { className: tw`text-xl text-amber-600 shrink-0` }),
54648
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: tw`flex-1 min-w-0`, children: [
54649
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: tw`font-semibold text-slate-800 truncate`, children: breakItem.name }),
54650
- /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: tw`text-xs text-slate-500`, children: [
54651
- "ID: ",
54652
- breakItem.id
54653
- ] })
54654
- ] })
54655
- ]
54656
- },
54657
- breakItem.id
54658
- )) }),
54659
- /* @__PURE__ */ jsxRuntimeExports.jsx(
54660
- "button",
54661
- {
54662
- type: "button",
54663
- onClick: () => {
54664
- setIsBreakModalOpen(false);
54665
- setBreakError(null);
54666
- },
54667
- 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`,
54668
- children: "Cancelar"
54669
- }
54670
- )
54671
- ] }) }),
54815
+ breakModal,
54672
54816
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
54673
54817
  "button",
54674
54818
  {
@@ -55018,8 +55162,8 @@ function ActiveCallSummary({
55018
55162
  ] })
55019
55163
  ] }) });
55020
55164
  }
55021
- function InlineDialer(props) {
55022
- 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: [
55023
55167
  /* @__PURE__ */ jsxRuntimeExports.jsx(
55024
55168
  "style",
55025
55169
  {
@@ -55036,31 +55180,26 @@ function InlineDialer(props) {
55036
55180
  inset: auto !important;
55037
55181
  transform: none !important;
55038
55182
  width: 100% !important;
55039
- max-width: 100% !important;
55040
- min-width: 0 !important;
55041
55183
  height: 100% !important;
55042
- max-height: 100% !important;
55043
- min-height: 0 !important;
55044
55184
  }
55045
55185
  .callix-inline-wrapper [data-floating-dialer-card] {
55046
55186
  position: relative !important;
55047
55187
  inset: auto !important;
55048
55188
  transform: none !important;
55049
55189
  width: 100% !important;
55050
- max-width: 100% !important;
55051
- min-width: 0 !important;
55052
55190
  height: 100% !important;
55053
- max-height: 100% !important;
55054
- min-height: 0 !important;
55055
55191
  box-shadow: none !important;
55056
55192
  backdrop-filter: none !important;
55057
55193
  }
55058
- .callix-inline-wrapper [data-floating-dialer-card] > div {
55194
+ .callix-inline-wrapper [data-floating-dialer-card] > div:first-child {
55059
55195
  width: 100% !important;
55060
55196
  height: 100% !important;
55197
+ transform-origin: top left !important;
55061
55198
  }
55062
- .callix-inline-wrapper [data-floating-dialer-card] .overflow-y-auto {
55063
- max-height: none !important;
55199
+ .callix-inline-wrapper [data-floating-dialer-card] [data-floating-dialer-content] {
55200
+ width: auto !important;
55201
+ min-width: 448px !important;
55202
+ min-height: 640px !important;
55064
55203
  }
55065
55204
  .callix-inline-wrapper [data-floating-dialer-resize] {
55066
55205
  display: none !important;
@@ -55069,9 +55208,41 @@ function InlineDialer(props) {
55069
55208
  }
55070
55209
  }
55071
55210
  ),
55072
- /* @__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 }) })
55073
55212
  ] });
55074
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
+ }
55075
55246
  class CallixDialerWidget {
55076
55247
  constructor(options) {
55077
55248
  this.root = null;
@@ -55092,6 +55263,13 @@ class CallixDialerWidget {
55092
55263
  if (!this.container) {
55093
55264
  throw new Error(`Container não encontrado: ${this.options.container}`);
55094
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
+ }
55095
55273
  this.root = clientExports.createRoot(this.container);
55096
55274
  this.root.render(
55097
55275
  /* @__PURE__ */ jsxRuntimeExports.jsx(StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DialerWrapper, { options: this.options }) })
@@ -55132,6 +55310,10 @@ function DialerWrapper({ options }) {
55132
55310
  const [sessionToken, setSessionToken] = useState(null);
55133
55311
  const [callixDomain, setCallixDomain] = useState(null);
55134
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);
55135
55317
  useEffect(() => {
55136
55318
  if (typeof window === "undefined") {
55137
55319
  setIsRestoringSession(false);
@@ -55143,6 +55325,11 @@ function DialerWrapper({ options }) {
55143
55325
  setIsRestoringSession(false);
55144
55326
  return;
55145
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
+ }
55146
55333
  const STORAGE_KEYS = getStorageKeys(storedLastUsername);
55147
55334
  const storedToken = localStorage.getItem(STORAGE_KEYS.SESSION_TOKEN);
55148
55335
  const storedDomain = localStorage.getItem(STORAGE_KEYS.DOMAIN);
@@ -55170,7 +55357,12 @@ function DialerWrapper({ options }) {
55170
55357
  setIsRestoringSession(false);
55171
55358
  }
55172
55359
  }, []);
55173
- const handleLogin = async (user) => {
55360
+ useEffect(() => {
55361
+ if (presetUsername && username !== presetUsername) {
55362
+ setUsername(presetUsername);
55363
+ }
55364
+ }, [presetUsername, username]);
55365
+ const handleLogin = useCallback(async (user) => {
55174
55366
  setIsLoading(true);
55175
55367
  setError(null);
55176
55368
  try {
@@ -55215,14 +55407,32 @@ function DialerWrapper({ options }) {
55215
55407
  } finally {
55216
55408
  setIsLoading(false);
55217
55409
  }
55218
- };
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]);
55219
55427
  const handleLogout = () => {
55220
55428
  const currentUsername = username;
55221
- setUsername(null);
55429
+ setUsername(presetUsername ?? null);
55222
55430
  setIsAuthenticated(false);
55223
55431
  setSessionToken(null);
55224
55432
  setCallixDomain(null);
55225
55433
  setError(null);
55434
+ autoLoginAttemptedRef.current = false;
55435
+ lastPresetRef.current = presetUsername ?? null;
55226
55436
  if (typeof window !== "undefined" && currentUsername) {
55227
55437
  try {
55228
55438
  const STORAGE_KEYS = getStorageKeys(currentUsername);
@@ -55246,7 +55456,8 @@ function DialerWrapper({ options }) {
55246
55456
  onLogin: handleLogin,
55247
55457
  onLogout: handleLogout,
55248
55458
  isLoadingSession: isLoading || isRestoringSession,
55249
- sessionError: error2
55459
+ sessionError: error2,
55460
+ variant: uiVariant
55250
55461
  }
55251
55462
  );
55252
55463
  }
@@ -55263,7 +55474,8 @@ function DialerWrapper({ options }) {
55263
55474
  onLogin: handleLogin,
55264
55475
  onLogout: handleLogout,
55265
55476
  isLoadingSession: isLoading,
55266
- sessionError: error2
55477
+ sessionError: error2,
55478
+ variant: uiVariant
55267
55479
  }
55268
55480
  )
55269
55481
  }