@webless/agent 0.6.9 → 0.6.10

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.
@@ -3197,7 +3197,7 @@ var defaultDarkAgentRailTheme = {
3197
3197
  };
3198
3198
 
3199
3199
  // src/react/components/AgentRail/AgentRail.tsx
3200
- import { useEffect as useEffect3, useRef as useRef3, useState as useState8 } from "react";
3200
+ import { useEffect as useEffect4, useRef as useRef4, useState as useState8 } from "react";
3201
3201
 
3202
3202
  // src/react/hooks/useAgentColorScheme.ts
3203
3203
  import { useSyncExternalStore } from "react";
@@ -3610,7 +3610,13 @@ function FollowUpChips({
3610
3610
  import { useState as useState5 } from "react";
3611
3611
 
3612
3612
  // src/react/components/BookingCard/BookingCard.tsx
3613
- import { useId as useId2, useMemo as useMemo2, useState as useState4 } from "react";
3613
+ import {
3614
+ useEffect as useEffect3,
3615
+ useId as useId2,
3616
+ useMemo as useMemo2,
3617
+ useRef as useRef3,
3618
+ useState as useState4
3619
+ } from "react";
3614
3620
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
3615
3621
  var BOOKING_STEPS = [
3616
3622
  { id: "date", label: "Date" },
@@ -3656,7 +3662,14 @@ function BookingCard({
3656
3662
  const [startTime, setStartTime] = useState4("");
3657
3663
  const [name, setName] = useState4("");
3658
3664
  const [email, setEmail] = useState4("");
3665
+ const activeStepRef = useRef3(null);
3666
+ const previousStepRef = useRef3(step);
3659
3667
  const stepIndex = BOOKING_STEPS.findIndex((item) => item.id === step);
3668
+ useEffect3(() => {
3669
+ if (previousStepRef.current === step) return;
3670
+ previousStepRef.current = step;
3671
+ activeStepRef.current?.scrollIntoView({ block: "nearest" });
3672
+ }, [step]);
3660
3673
  const slots = useMemo2(
3661
3674
  () => bookingSlotsForEventType(offer.slots, eventTypeUri),
3662
3675
  [eventTypeUri, offer.slots]
@@ -3750,7 +3763,7 @@ function BookingCard({
3750
3763
  },
3751
3764
  item.id
3752
3765
  )) }),
3753
- step === "date" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", children: [
3766
+ step === "date" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", ref: activeStepRef, children: [
3754
3767
  /* @__PURE__ */ jsx4("p", { className: "booking-card__title", children: selectedType?.name || "Pick a date" }),
3755
3768
  timeZone ? /* @__PURE__ */ jsxs4("p", { className: "booking-card__tz", children: [
3756
3769
  "Times in ",
@@ -3840,7 +3853,7 @@ function BookingCard({
3840
3853
  }
3841
3854
  )
3842
3855
  ] }, "date") : null,
3843
- step === "time" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", children: [
3856
+ step === "time" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", ref: activeStepRef, children: [
3844
3857
  /* @__PURE__ */ jsxs4("div", { className: "booking-card__step-bar", children: [
3845
3858
  /* @__PURE__ */ jsx4(
3846
3859
  "button",
@@ -3871,7 +3884,7 @@ function BookingCard({
3871
3884
  slot.startTime
3872
3885
  )) })
3873
3886
  ] }, "time") : null,
3874
- step === "details" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", children: [
3887
+ step === "details" ? /* @__PURE__ */ jsxs4("div", { className: "booking-card__step", ref: activeStepRef, children: [
3875
3888
  /* @__PURE__ */ jsxs4("div", { className: "booking-card__step-bar", children: [
3876
3889
  /* @__PURE__ */ jsx4(
3877
3890
  "button",
@@ -4839,7 +4852,7 @@ function AgentRail({
4839
4852
  onInputResponse,
4840
4853
  onToolInput
4841
4854
  }) {
4842
- const transcriptRef = useRef3(null);
4855
+ const transcriptRef = useRef4(null);
4843
4856
  const resolvedBrandLabel = brandLabel.trim();
4844
4857
  const resolvedBrandLogoUrl = brandLogoUrl?.trim();
4845
4858
  const [failedLogoUrl, setFailedLogoUrl] = useState8(null);
@@ -4944,7 +4957,7 @@ function AgentRail({
4944
4957
  hasPendingConfirmation,
4945
4958
  enabled: lastIsAgent && !isBusy
4946
4959
  });
4947
- useEffect3(() => {
4960
+ useEffect4(() => {
4948
4961
  const node = transcriptRef.current;
4949
4962
  if (!node) return;
4950
4963
  node.scrollTop = node.scrollHeight;
@@ -5355,10 +5368,10 @@ function AssistEdgeTab({
5355
5368
  }
5356
5369
 
5357
5370
  // src/react/components/AgentWidget/AgentWidget.tsx
5358
- import { useEffect as useEffect6, useRef as useRef4, useState as useState10 } from "react";
5371
+ import { useEffect as useEffect7, useRef as useRef5, useState as useState10 } from "react";
5359
5372
 
5360
5373
  // src/react/page-shift.ts
5361
- import { useEffect as useEffect4 } from "react";
5374
+ import { useEffect as useEffect5 } from "react";
5362
5375
  var PAGE_SHIFT_CLASS = "webless-agent-page-shift";
5363
5376
  var DEFAULT_RAIL_WIDTH_PX = 450;
5364
5377
  function shouldApplyPageShift(input) {
@@ -5410,7 +5423,7 @@ function clearPageMargin() {
5410
5423
  }
5411
5424
  function usePageShift(input) {
5412
5425
  const { active, railSlotRef } = input;
5413
- useEffect4(() => {
5426
+ useEffect5(() => {
5414
5427
  if (typeof document === "undefined") {
5415
5428
  return;
5416
5429
  }
@@ -5438,12 +5451,12 @@ function usePageShift(input) {
5438
5451
  }
5439
5452
 
5440
5453
  // src/react/hooks/useIsMobile.ts
5441
- import { useEffect as useEffect5, useState as useState9 } from "react";
5454
+ import { useEffect as useEffect6, useState as useState9 } from "react";
5442
5455
  function useIsMobile(breakpoint = 767) {
5443
5456
  const [isMobile, setIsMobile] = useState9(
5444
5457
  () => typeof window !== "undefined" && window.matchMedia(`(max-width: ${breakpoint}px)`).matches
5445
5458
  );
5446
- useEffect5(() => {
5459
+ useEffect6(() => {
5447
5460
  const media = window.matchMedia(`(max-width: ${breakpoint}px)`);
5448
5461
  const onChange = () => setIsMobile(media.matches);
5449
5462
  onChange();
@@ -5472,7 +5485,7 @@ function AgentWidget({
5472
5485
  }) {
5473
5486
  const isMobile = useIsMobile();
5474
5487
  const placement = normalizeAgentPlacement(placementInput);
5475
- const railSlotRef = useRef4(null);
5488
+ const railSlotRef = useRef5(null);
5476
5489
  const [railCollapsed, setRailCollapsed] = useState10(defaultCollapsed);
5477
5490
  const [railExpanded, setRailExpanded] = useState10(false);
5478
5491
  const pageShiftActive = shouldApplyPageShift({
@@ -5517,7 +5530,7 @@ function AgentWidget({
5517
5530
  } : {},
5518
5531
  ...branding?.colors?.border ? { border: branding.colors.border } : {}
5519
5532
  };
5520
- useEffect6(() => {
5533
+ useEffect7(() => {
5521
5534
  if (!registerPanelController) return;
5522
5535
  registerAgentPanelController(customerId, {
5523
5536
  open: () => setRailCollapsed(false),
@@ -5534,7 +5547,7 @@ function AgentWidget({
5534
5547
  if (isMobile) setRailCollapsed(false);
5535
5548
  await submit(message);
5536
5549
  }
5537
- useEffect6(() => {
5550
+ useEffect7(() => {
5538
5551
  if (railCollapsed) return;
5539
5552
  const handleKeyDown = (event) => {
5540
5553
  if (event.key === "Tab" && (isMobile || railExpanded)) {
@@ -5657,4 +5670,4 @@ export {
5657
5670
  AssistEdgeTab,
5658
5671
  AgentWidget
5659
5672
  };
5660
- //# sourceMappingURL=chunk-U2SU2CGF.js.map
5673
+ //# sourceMappingURL=chunk-NEI5GKGH.js.map