@eshal-bot/chat-widget 0.1.125 → 0.2.1

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.
@@ -87896,6 +87896,8 @@
87896
87896
  },
87897
87897
  children: props.title
87898
87898
  }), /*#__PURE__*/jsxRuntimeExports.jsx("div", {
87899
+ role: "img",
87900
+ "aria-label": props.title || seriesName || 'Bar chart',
87899
87901
  style: {
87900
87902
  height: chartHeight,
87901
87903
  width: '100%'
@@ -88172,6 +88174,8 @@
88172
88174
  },
88173
88175
  children: props.title
88174
88176
  }), /*#__PURE__*/jsxRuntimeExports.jsx("div", {
88177
+ role: "img",
88178
+ "aria-label": props.title || (donut ? 'Donut chart' : 'Pie chart'),
88175
88179
  style: {
88176
88180
  height: 260,
88177
88181
  width: '100%'
@@ -88289,6 +88293,8 @@
88289
88293
  },
88290
88294
  children: props.title
88291
88295
  }), /*#__PURE__*/jsxRuntimeExports.jsx("div", {
88296
+ role: "img",
88297
+ "aria-label": props.title || seriesName || (area ? 'Area chart' : 'Line chart'),
88292
88298
  style: {
88293
88299
  height: 220,
88294
88300
  width: '100%'
@@ -91291,7 +91297,27 @@
91291
91297
  setOpen(false);
91292
91298
  };
91293
91299
  const onKey = e => {
91294
- if (e.key === "Escape") setOpen(false);
91300
+ if (e.key === "Escape") {
91301
+ setOpen(false);
91302
+ return;
91303
+ }
91304
+ if (e.key === "Tab" && popoverRef.current) {
91305
+ const focusables = popoverRef.current.querySelectorAll('a[href], button:not([disabled])');
91306
+ if (focusables.length === 0) return;
91307
+ const first = focusables[0];
91308
+ const last = focusables[focusables.length - 1];
91309
+ // document.activeElement is unreliable across a shadow boundary
91310
+ // (it resolves to the shadow host, not the focused element inside
91311
+ // it) - composedPath()[0] gives the true focused node either way.
91312
+ const active = typeof e.composedPath === "function" ? e.composedPath()[0] : e.target;
91313
+ if (e.shiftKey && active === first) {
91314
+ e.preventDefault();
91315
+ last.focus();
91316
+ } else if (!e.shiftKey && active === last) {
91317
+ e.preventDefault();
91318
+ first.focus();
91319
+ }
91320
+ }
91295
91321
  };
91296
91322
  document.addEventListener("mousedown", onDocClick);
91297
91323
  document.addEventListener("keydown", onKey);
@@ -91311,6 +91337,23 @@
91311
91337
  setOpen(true);
91312
91338
  };
91313
91339
 
91340
+ // Move focus into the popover on open; restore it to the pill on close
91341
+ // so keyboard users don't lose their place when Escape or a click
91342
+ // outside dismisses it.
91343
+ const wasOpenRef = React.useRef(false);
91344
+ React.useEffect(() => {
91345
+ if (open) {
91346
+ var _popoverRef$current;
91347
+ wasOpenRef.current = true;
91348
+ const firstFocusable = (_popoverRef$current = popoverRef.current) === null || _popoverRef$current === void 0 ? void 0 : _popoverRef$current.querySelector('a[href], button:not([disabled])');
91349
+ firstFocusable === null || firstFocusable === void 0 || firstFocusable.focus();
91350
+ } else if (wasOpenRef.current) {
91351
+ var _anchorRef$current;
91352
+ wasOpenRef.current = false;
91353
+ (_anchorRef$current = anchorRef.current) === null || _anchorRef$current === void 0 || _anchorRef$current.focus();
91354
+ }
91355
+ }, [open]);
91356
+
91314
91357
  // No context (rendered outside a chat) - hide the marker rather than
91315
91358
  // leaking a raw `[N]` into the bubble.
91316
91359
  if (!ctx) {
@@ -91363,6 +91406,7 @@
91363
91406
  tabIndex: 0,
91364
91407
  dir: "ltr",
91365
91408
  title: firstLabel + (extraCount ? " (+".concat(extraCount, " more)") : ""),
91409
+ "aria-label": firstLabel + (extraCount ? " (+".concat(extraCount, " more)") : ""),
91366
91410
  onClick: onPillClick,
91367
91411
  onKeyDown: e => {
91368
91412
  if (e.key === "Enter" || e.key === " ") {