@purpurds/modal 5.24.2 → 5.25.0

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.
package/dist/modal.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { jsxs as j, jsx as b } from "react/jsx-runtime";
1
+ import { jsxs as F, jsx as b } from "react/jsx-runtime";
2
2
  import * as m from "react";
3
3
  import { useCallback as Q, createContext as Oe, useMemo as me, createElement as _, useContext as rt, useLayoutEffect as Rt, useRef as N, useEffect as A, useState as H, forwardRef as S, Children as L, isValidElement as U, cloneElement as ae, Fragment as Le, useReducer as Mt } from "react";
4
4
  import kt, { flushSync as ot } from "react-dom";
@@ -406,18 +406,18 @@ const $e = "focusScope.autoFocusOnMount", ye = "focusScope.autoFocusOnUnmount",
406
406
  let u = function(y) {
407
407
  if (f.paused || !c) return;
408
408
  const $ = y.target;
409
- c.contains($) ? l.current = $ : F(l.current, {
409
+ c.contains($) ? l.current = $ : j(l.current, {
410
410
  select: !0
411
411
  });
412
412
  }, h = function(y) {
413
413
  if (f.paused || !c) return;
414
414
  const $ = y.relatedTarget;
415
- $ !== null && (c.contains($) || F(l.current, {
415
+ $ !== null && (c.contains($) || j(l.current, {
416
416
  select: !0
417
417
  }));
418
418
  }, g = function(y) {
419
419
  if (document.activeElement === document.body)
420
- for (const x of y) x.removedNodes.length > 0 && F(c);
420
+ for (const x of y) x.removedNodes.length > 0 && j(c);
421
421
  };
422
422
  document.addEventListener("focusin", u), document.addEventListener("focusout", h);
423
423
  const C = new MutationObserver(g);
@@ -440,12 +440,12 @@ const $e = "focusScope.autoFocusOnMount", ye = "focusScope.autoFocusOnUnmount",
440
440
  const g = new CustomEvent($e, Ue);
441
441
  c.addEventListener($e, d), c.dispatchEvent(g), g.defaultPrevented || (on(ln(ct(c)), {
442
442
  select: !0
443
- }), document.activeElement === u && F(c));
443
+ }), document.activeElement === u && j(c));
444
444
  }
445
445
  return () => {
446
446
  c.removeEventListener($e, d), setTimeout(() => {
447
447
  const g = new CustomEvent(ye, Ue);
448
- c.addEventListener(ye, p), c.dispatchEvent(g), g.defaultPrevented || F(u ?? document.body, {
448
+ c.addEventListener(ye, p), c.dispatchEvent(g), g.defaultPrevented || j(u ?? document.body, {
449
449
  select: !0
450
450
  }), c.removeEventListener(ye, p), ze.remove(f);
451
451
  }, 0);
@@ -462,9 +462,9 @@ const $e = "focusScope.autoFocusOnMount", ye = "focusScope.autoFocusOnUnmount",
462
462
  const h = u.key === "Tab" && !u.altKey && !u.ctrlKey && !u.metaKey, g = document.activeElement;
463
463
  if (h && g) {
464
464
  const C = u.currentTarget, [y, $] = an(C);
465
- y && $ ? !u.shiftKey && g === $ ? (u.preventDefault(), t && F(y, {
465
+ y && $ ? !u.shiftKey && g === $ ? (u.preventDefault(), t && j(y, {
466
466
  select: !0
467
- })) : u.shiftKey && g === y && (u.preventDefault(), t && F($, {
467
+ })) : u.shiftKey && g === y && (u.preventDefault(), t && j($, {
468
468
  select: !0
469
469
  })) : g === C && u.preventDefault();
470
470
  }
@@ -483,7 +483,7 @@ const $e = "focusScope.autoFocusOnMount", ye = "focusScope.autoFocusOnUnmount",
483
483
  function on(e, { select: n = !1 } = {}) {
484
484
  const t = document.activeElement;
485
485
  for (const o of e)
486
- if (F(o, {
486
+ if (j(o, {
487
487
  select: n
488
488
  }), document.activeElement !== t) return;
489
489
  }
@@ -522,7 +522,7 @@ function cn(e, { upTo: n }) {
522
522
  function un(e) {
523
523
  return e instanceof HTMLInputElement && "select" in e;
524
524
  }
525
- function F(e, { select: n = !1 } = {}) {
525
+ function j(e, { select: n = !1 } = {}) {
526
526
  if (e && e.focus) {
527
527
  const t = document.activeElement;
528
528
  e.focus({
@@ -1527,7 +1527,7 @@ const Ir = /* @__PURE__ */ Tr(Dr), Lr = {
1527
1527
  ), u = (g) => {
1528
1528
  o || i ? g.preventDefault() : s && s(g);
1529
1529
  }, h = !!v["aria-disabled"] || o || i;
1530
- return /* @__PURE__ */ j(
1530
+ return /* @__PURE__ */ F(
1531
1531
  "button",
1532
1532
  {
1533
1533
  className: E,
@@ -2028,9 +2028,9 @@ const vo = /* @__PURE__ */ po(fo), ho = "_fadeIn_1ifm3_1", mo = {
2028
2028
  window.removeEventListener("resize", I);
2029
2029
  }), [I]), A(() => {
2030
2030
  I();
2031
- }, [l, t, I]), /* @__PURE__ */ j(br, { children: [
2031
+ }, [l, t, I]), /* @__PURE__ */ F(br, { children: [
2032
2032
  /* @__PURE__ */ b($r, { className: T(`${O}__overlay`), style: { zIndex: v } }),
2033
- /* @__PURE__ */ j(
2033
+ /* @__PURE__ */ F(
2034
2034
  yr,
2035
2035
  {
2036
2036
  ...g,
@@ -2043,7 +2043,7 @@ const vo = /* @__PURE__ */ po(fo), ho = "_fadeIn_1ifm3_1", mo = {
2043
2043
  onEscapeKeyDown: ie,
2044
2044
  style: { zIndex: `calc(${v} + 1)` },
2045
2045
  children: [
2046
- /* @__PURE__ */ j("div", { ref: $, className: T(`${O}__wrapper`), children: [
2046
+ /* @__PURE__ */ F("div", { ref: $, className: T(`${O}__wrapper`), children: [
2047
2047
  et(f) && u && c && /* @__PURE__ */ b(
2048
2048
  tt,
2049
2049
  {
@@ -2052,8 +2052,8 @@ const vo = /* @__PURE__ */ po(fo), ho = "_fadeIn_1ifm3_1", mo = {
2052
2052
  "data-testid": D("close-button")
2053
2053
  }
2054
2054
  ),
2055
- /* @__PURE__ */ j("div", { ref: x, className: T(`${O}__wrapper-inner`), children: [
2056
- /* @__PURE__ */ j("div", { className: T(`${O}__header`), children: [
2055
+ /* @__PURE__ */ F("div", { ref: x, className: T(`${O}__wrapper-inner`), children: [
2056
+ /* @__PURE__ */ F("div", { className: T(`${O}__header`), children: [
2057
2057
  et(f) && u && !c && /* @__PURE__ */ b(
2058
2058
  tt,
2059
2059
  {
@@ -2079,7 +2079,7 @@ const vo = /* @__PURE__ */ po(fo), ho = "_fadeIn_1ifm3_1", mo = {
2079
2079
  children: c
2080
2080
  }
2081
2081
  ),
2082
- /* @__PURE__ */ b("div", { className: T(`${O}__body`), children: /* @__PURE__ */ j("div", { className: T(`${O}__body-inner`), children: [
2082
+ /* @__PURE__ */ b("div", { className: T(`${O}__body`), children: /* @__PURE__ */ F("div", { className: T(`${O}__body-inner`), children: [
2083
2083
  a && i && /* @__PURE__ */ b(lo, { asChild: !0, children: /* @__PURE__ */ b(Ze, { "data-testid": D("description"), children: a }) }),
2084
2084
  a && !i && /* @__PURE__ */ b(
2085
2085
  Ze,
@@ -2140,17 +2140,21 @@ const vo = /* @__PURE__ */ po(fo), ho = "_fadeIn_1ifm3_1", mo = {
2140
2140
  return A(() => {
2141
2141
  var r, i;
2142
2142
  t && ((i = (r = o == null ? void 0 : o.current) == null ? void 0 : r.scrollIntoView) == null || i.call(r, !1));
2143
- }, [t]), e && e.length > 0 ? /* @__PURE__ */ j("div", { className: T(`${O}__actions`), children: [
2144
- /* @__PURE__ */ b("div", { className: T(`${O}__actions-buttons`), "data-testid": "modal actions", children: e.slice(0, _o).map(({ label: r, onClick: i, disabled: c, loading: s }, d) => /* @__PURE__ */ b(
2143
+ }, [t]), e && e.length > 0 ? /* @__PURE__ */ F("div", { className: T(`${O}__actions`), children: [
2144
+ /* @__PURE__ */ b("div", { className: T(`${O}__actions-buttons`), "data-testid": "modal actions", children: e.slice(0, _o).map(({ label: r, onClick: i, disabled: c, loading: s, iconPosition: d = "right", icon: p }, l) => /* @__PURE__ */ F(
2145
2145
  ke,
2146
2146
  {
2147
2147
  "data-testid": "modal actions button",
2148
- variant: a[d] || "",
2148
+ variant: a[l] || "",
2149
2149
  onClick: i,
2150
2150
  disabled: c,
2151
2151
  loading: s,
2152
2152
  className: T(`${O}__actions-button`),
2153
- children: r
2153
+ children: [
2154
+ d === "left" && p && p,
2155
+ r,
2156
+ d === "right" && p && p
2157
+ ]
2154
2158
  },
2155
2159
  r
2156
2160
  )) }),