mimir-ui-kit 1.64.5 → 1.65.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.
@@ -45,10 +45,18 @@ type TProps = {
45
45
  * Нужна ли кнопка закрытия.
46
46
  */
47
47
  needCloseButton?: boolean;
48
+ /**
49
+ * Флаг указывающий, что компонент котроллируемый.
50
+ */
51
+ isControlled?: boolean;
48
52
  /**
49
53
  * Флаг открытия.
50
54
  */
51
55
  isOpen?: boolean;
56
+ /**
57
+ * Коллбэк изменения состояния (управляемый режим).
58
+ */
59
+ onOpenChange?: (open?: boolean) => void;
52
60
  /**
53
61
  * Время автоматического закрытия в миллисекундах.
54
62
  */
@@ -58,7 +66,8 @@ type TProps = {
58
66
  * Если указан, то buttonContent игнорируется.
59
67
  */
60
68
  triggerElement?: ReactNode | ((props: {
61
- open: boolean;
69
+ open?: boolean;
70
+ close: () => void;
62
71
  }) => JSX.Element);
63
72
  /**
64
73
  * Вариант оформления выпадающего меню.
@@ -74,5 +83,5 @@ type TProps = {
74
83
  /**
75
84
  * Компонент Dropdown, содержит в себе кнопку и панель выпадающего меню
76
85
  */
77
- export declare const Dropdown: import('react').MemoExoticComponent<({ children, position, popoverProps, className, buttonClassName, panelClassName, menuItemsClassName, buttonContent, needCloseButton, openOnHover, isOpen, autoCloseTimeout, triggerElement, variant, arrow }: TProps) => import("react/jsx-runtime").JSX.Element>;
86
+ export declare const Dropdown: import('react').MemoExoticComponent<({ children, position, popoverProps, className, buttonClassName, panelClassName, menuItemsClassName, buttonContent, needCloseButton, openOnHover, isOpen, isControlled, onOpenChange, autoCloseTimeout, triggerElement, variant, arrow }: TProps) => import("react/jsx-runtime").JSX.Element>;
78
87
  export {};
@@ -1,37 +1,37 @@
1
1
  import { jsx as re, jsxs as De, Fragment as nt } from "react/jsx-runtime";
2
- import { c as pe } from "../../index-DIxK0V-G.js";
3
- import E, { createContext as ue, useState as X, useContext as te, useRef as R, useEffect as ce, useMemo as Z, Fragment as fe, useReducer as rt, createRef as Fe, useId as be, memo as ot, useCallback as me } from "react";
4
- import { u as lt, c as G } from "../../hooks-HgN6Yauq.js";
2
+ import { c as fe } from "../../index-DIxK0V-G.js";
3
+ import E, { createContext as ie, useState as J, useContext as te, useRef as _, useEffect as ue, useMemo as q, Fragment as ve, useReducer as rt, createRef as Fe, useId as be, memo as ot, useCallback as ce } from "react";
4
+ import { u as lt, c as U } from "../../hooks-HgN6Yauq.js";
5
5
  import { Button as at } from "../Button/Button.js";
6
- import { o as S, u as He, M as ve, W as Y, y as ee, O as le, n as ie, m as ut, t as st, H as se, s as Ce, p as it, a as V, T as ct, $ as dt, b as pt, D as ke, I as ft, c as oe } from "../../keyboard-wis2TUql.js";
6
+ import { o as T, u as He, M as me, W as Y, y as ee, O as le, n as de, m as ut, t as it, H as se, s as ke, p as st, a as V, T as ct, $ as dt, b as pt, D as Be, I as ft, c as oe } from "../../keyboard-wis2TUql.js";
7
7
  import { w as vt } from "../../use-active-press-CnDeVvQq.js";
8
- import { n as $e, s as mt, l as Ge, e as bt, E as ht, R as Pt, v as $t, y as yt, x as Et, a as gt, b as St, m as Tt, f as wt, d as It, t as Ft } from "../../portal-BnEqSZwo.js";
9
- import { e as Ct } from "../../use-resolve-button-type-DhFdPxnv.js";
8
+ import { n as $e, s as mt, l as Ge, e as bt, E as ht, R as Pt, v as $t, y as yt, x as Et, a as St, b as gt, m as Tt, f as wt, d as It, t as Ft } from "../../portal-BnEqSZwo.js";
9
+ import { e as kt } from "../../use-resolve-button-type-DhFdPxnv.js";
10
10
  import { T as he, s as Pe } from "../../hidden-CkTYbiNM.js";
11
- import { R as Ne, H as xe, i as j, c as Ke, u as ye, s as kt } from "../../open-closed-CJijMeI2.js";
12
- import { C as Bt } from "../../close-provider-CEutdhG8.js";
11
+ import { R as Re, H as xe, i as W, c as Ke, u as ye, s as Bt } from "../../open-closed-CJijMeI2.js";
12
+ import { C as Mt } from "../../close-provider-CEutdhG8.js";
13
13
  import { r as Ue } from "../../bugs-diTMAGNw.js";
14
- import { b as Re, P as ae, F as z, A as Ot, h as Mt, T as Be } from "../../focus-management-BAl0GmRk.js";
15
- import { f as Nt } from "../../use-is-mounted-MBU4fiLr.js";
16
- function xt({ defaultContainers: e = [], portals: t, mainTreeNode: o } = {}) {
17
- let c = $e(o), f = S(() => {
18
- var h, m;
19
- let l = [];
20
- for (let r of e) r !== null && (r instanceof HTMLElement ? l.push(r) : "current" in r && r.current instanceof HTMLElement && l.push(r.current));
21
- if (t != null && t.current) for (let r of t.current) l.push(r);
22
- for (let r of (h = c == null ? void 0 : c.querySelectorAll("html > *, body > *")) != null ? h : []) r !== document.body && r !== document.head && r instanceof HTMLElement && r.id !== "headlessui-portal-root" && (o && (r.contains(o) || r.contains((m = o == null ? void 0 : o.getRootNode()) == null ? void 0 : m.host)) || l.some((P) => r.contains(P)) || l.push(r));
23
- return l;
14
+ import { b as Oe, P as ae, F as z, A as Ct, h as Nt, T as Me } from "../../focus-management-BAl0GmRk.js";
15
+ import { f as Rt } from "../../use-is-mounted-MBU4fiLr.js";
16
+ function xt({ defaultContainers: e = [], portals: t, mainTreeNode: l } = {}) {
17
+ let d = $e(l), v = T(() => {
18
+ var $, h;
19
+ let a = [];
20
+ for (let r of e) r !== null && (r instanceof HTMLElement ? a.push(r) : "current" in r && r.current instanceof HTMLElement && a.push(r.current));
21
+ if (t != null && t.current) for (let r of t.current) a.push(r);
22
+ for (let r of ($ = d == null ? void 0 : d.querySelectorAll("html > *, body > *")) != null ? $ : []) r !== document.body && r !== document.head && r instanceof HTMLElement && r.id !== "headlessui-portal-root" && (l && (r.contains(l) || r.contains((h = l == null ? void 0 : l.getRootNode()) == null ? void 0 : h.host)) || a.some((y) => r.contains(y)) || a.push(r));
23
+ return a;
24
24
  });
25
- return { resolveContainers: f, contains: S((h) => f().some((m) => m.contains(h))) };
25
+ return { resolveContainers: v, contains: T(($) => v().some((h) => h.contains($))) };
26
26
  }
27
- let je = ue(null);
27
+ let je = ie(null);
28
28
  function Xe({ children: e, node: t }) {
29
- let [o, c] = X(null), f = We(t ?? o);
30
- return E.createElement(je.Provider, { value: f }, e, f === null && E.createElement(he, { features: Pe.Hidden, ref: (h) => {
31
- var m, l;
32
- if (h) {
33
- for (let r of (l = (m = He(h)) == null ? void 0 : m.querySelectorAll("html > *, body > *")) != null ? l : []) if (r !== document.body && r !== document.head && r instanceof HTMLElement && r != null && r.contains(h)) {
34
- c(r);
29
+ let [l, d] = J(null), v = We(t ?? l);
30
+ return E.createElement(je.Provider, { value: v }, e, v === null && E.createElement(he, { features: Pe.Hidden, ref: ($) => {
31
+ var h, a;
32
+ if ($) {
33
+ for (let r of (a = (h = He($)) == null ? void 0 : h.querySelectorAll("html > *, body > *")) != null ? a : []) if (r !== document.body && r !== document.head && r instanceof HTMLElement && r != null && r.contains($)) {
34
+ d(r);
35
35
  break;
36
36
  }
37
37
  }
@@ -43,127 +43,127 @@ function We(e = null) {
43
43
  }
44
44
  var Q = ((e) => (e[e.Forwards = 0] = "Forwards", e[e.Backwards = 1] = "Backwards", e))(Q || {});
45
45
  function Ze() {
46
- let e = R(0);
46
+ let e = _(0);
47
47
  return mt(!0, "keydown", (t) => {
48
48
  t.key === "Tab" && (e.current = t.shiftKey ? 1 : 0);
49
49
  }, !0), e;
50
50
  }
51
51
  function qe(e) {
52
52
  var t;
53
- return !!(e.enter || e.enterFrom || e.enterTo || e.leave || e.leaveFrom || e.leaveTo) || ((t = e.as) != null ? t : Qe) !== fe || E.Children.count(e.children) === 1;
53
+ return !!(e.enter || e.enterFrom || e.enterTo || e.leave || e.leaveFrom || e.leaveTo) || ((t = e.as) != null ? t : Qe) !== ve || E.Children.count(e.children) === 1;
54
54
  }
55
- let Ee = ue(null);
55
+ let Ee = ie(null);
56
56
  Ee.displayName = "TransitionContext";
57
- var Rt = ((e) => (e.Visible = "visible", e.Hidden = "hidden", e))(Rt || {});
57
+ var Ot = ((e) => (e.Visible = "visible", e.Hidden = "hidden", e))(Ot || {});
58
58
  function Lt() {
59
59
  let e = te(Ee);
60
60
  if (e === null) throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");
61
61
  return e;
62
62
  }
63
63
  function _t() {
64
- let e = te(ge);
64
+ let e = te(Se);
65
65
  if (e === null) throw new Error("A <Transition.Child /> is used but it is missing a parent <Transition /> or <Transition.Root />.");
66
66
  return e;
67
67
  }
68
- let ge = ue(null);
69
- ge.displayName = "NestingContext";
70
- function Se(e) {
71
- return "children" in e ? Se(e.children) : e.current.filter(({ el: t }) => t.current !== null).filter(({ state: t }) => t === "visible").length > 0;
68
+ let Se = ie(null);
69
+ Se.displayName = "NestingContext";
70
+ function ge(e) {
71
+ return "children" in e ? ge(e.children) : e.current.filter(({ el: t }) => t.current !== null).filter(({ state: t }) => t === "visible").length > 0;
72
72
  }
73
73
  function Je(e, t) {
74
- let o = Ce(e), c = R([]), f = Nt(), h = it(), m = S((d, a = le.Hidden) => {
75
- let s = c.current.findIndex(({ el: u }) => u === d);
76
- s !== -1 && (V(a, { [le.Unmount]() {
77
- c.current.splice(s, 1);
74
+ let l = ke(e), d = _([]), v = Rt(), $ = st(), h = T((c, o = le.Hidden) => {
75
+ let s = d.current.findIndex(({ el: u }) => u === c);
76
+ s !== -1 && (V(o, { [le.Unmount]() {
77
+ d.current.splice(s, 1);
78
78
  }, [le.Hidden]() {
79
- c.current[s].state = "hidden";
80
- } }), h.microTask(() => {
79
+ d.current[s].state = "hidden";
80
+ } }), $.microTask(() => {
81
81
  var u;
82
- !Se(c) && f.current && ((u = o.current) == null || u.call(o));
82
+ !ge(d) && v.current && ((u = l.current) == null || u.call(l));
83
83
  }));
84
- }), l = S((d) => {
85
- let a = c.current.find(({ el: s }) => s === d);
86
- return a ? a.state !== "visible" && (a.state = "visible") : c.current.push({ el: d, state: "visible" }), () => m(d, le.Unmount);
87
- }), r = R([]), P = R(Promise.resolve()), n = R({ enter: [], leave: [] }), y = S((d, a, s) => {
88
- r.current.splice(0), t && (t.chains.current[a] = t.chains.current[a].filter(([u]) => u !== d)), t == null || t.chains.current[a].push([d, new Promise((u) => {
84
+ }), a = T((c) => {
85
+ let o = d.current.find(({ el: s }) => s === c);
86
+ return o ? o.state !== "visible" && (o.state = "visible") : d.current.push({ el: c, state: "visible" }), () => h(c, le.Unmount);
87
+ }), r = _([]), y = _(Promise.resolve()), n = _({ enter: [], leave: [] }), m = T((c, o, s) => {
88
+ r.current.splice(0), t && (t.chains.current[o] = t.chains.current[o].filter(([u]) => u !== c)), t == null || t.chains.current[o].push([c, new Promise((u) => {
89
89
  r.current.push(u);
90
- })]), t == null || t.chains.current[a].push([d, new Promise((u) => {
91
- Promise.all(n.current[a].map(([$, C]) => C)).then(() => u());
92
- })]), a === "enter" ? P.current = P.current.then(() => t == null ? void 0 : t.wait.current).then(() => s(a)) : s(a);
93
- }), b = S((d, a, s) => {
94
- Promise.all(n.current[a].splice(0).map(([u, $]) => $)).then(() => {
90
+ })]), t == null || t.chains.current[o].push([c, new Promise((u) => {
91
+ Promise.all(n.current[o].map(([p, g]) => g)).then(() => u());
92
+ })]), o === "enter" ? y.current = y.current.then(() => t == null ? void 0 : t.wait.current).then(() => s(o)) : s(o);
93
+ }), P = T((c, o, s) => {
94
+ Promise.all(n.current[o].splice(0).map(([u, p]) => p)).then(() => {
95
95
  var u;
96
96
  (u = r.current.shift()) == null || u();
97
- }).then(() => s(a));
97
+ }).then(() => s(o));
98
98
  });
99
- return Z(() => ({ children: c, register: l, unregister: m, onStart: y, onStop: b, wait: P, chains: n }), [l, m, c, y, b, n, P]);
99
+ return q(() => ({ children: d, register: a, unregister: h, onStart: m, onStop: P, wait: y, chains: n }), [a, h, d, m, P, n, y]);
100
100
  }
101
- let Qe = fe, Ve = ve.RenderStrategy;
101
+ let Qe = ve, Ve = me.RenderStrategy;
102
102
  function At(e, t) {
103
- var o, c;
104
- let { transition: f = !0, beforeEnter: h, afterEnter: m, beforeLeave: l, afterLeave: r, enter: P, enterFrom: n, enterTo: y, entered: b, leave: d, leaveFrom: a, leaveTo: s, ...u } = e, [$, C] = X(null), g = R(null), k = qe(e), L = ee(...k ? [g, t, C] : t === null ? [] : [t]), _ = (o = u.unmount) == null || o ? le.Unmount : le.Hidden, { show: F, appear: M, initial: W } = Lt(), [O, N] = X(F ? "visible" : "hidden"), H = _t(), { register: x, unregister: B } = H;
105
- ie(() => x(g), [x, g]), ie(() => {
106
- if (_ === le.Hidden && g.current) {
107
- if (F && O !== "visible") {
103
+ var l, d;
104
+ let { transition: v = !0, beforeEnter: $, afterEnter: h, beforeLeave: a, afterLeave: r, enter: y, enterFrom: n, enterTo: m, entered: P, leave: c, leaveFrom: o, leaveTo: s, ...u } = e, [p, g] = J(null), S = _(null), B = qe(e), A = ee(...B ? [S, t, g] : t === null ? [] : [t]), D = (l = u.unmount) == null || l ? le.Unmount : le.Hidden, { show: k, appear: C, initial: Z } = Lt(), [M, N] = J(k ? "visible" : "hidden"), G = _t(), { register: R, unregister: x } = G;
105
+ de(() => R(S), [R, S]), de(() => {
106
+ if (D === le.Hidden && S.current) {
107
+ if (k && M !== "visible") {
108
108
  N("visible");
109
109
  return;
110
110
  }
111
- return V(O, { hidden: () => B(g), visible: () => x(g) });
111
+ return V(M, { hidden: () => x(S), visible: () => R(S) });
112
112
  }
113
- }, [O, g, x, B, F, _]);
114
- let A = Ge();
115
- ie(() => {
116
- if (k && A && O === "visible" && g.current === null) throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?");
117
- }, [g, O, A, k]);
118
- let q = W && !M, J = M && F && W, v = R(!1), i = Je(() => {
119
- v.current || (N("hidden"), B(g));
120
- }, H), p = S((U) => {
121
- v.current = !0;
122
- let ne = U ? "enter" : "leave";
123
- i.onStart(g, ne, (de) => {
124
- de === "enter" ? h == null || h() : de === "leave" && (l == null || l());
113
+ }, [M, S, R, x, k, D]);
114
+ let K = Ge();
115
+ de(() => {
116
+ if (B && K && M === "visible" && S.current === null) throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?");
117
+ }, [S, M, K, B]);
118
+ let O = Z && !C, L = C && k && Z, b = _(!1), i = Je(() => {
119
+ b.current || (N("hidden"), x(S));
120
+ }, G), f = T((X) => {
121
+ b.current = !0;
122
+ let ne = X ? "enter" : "leave";
123
+ i.onStart(S, ne, (pe) => {
124
+ pe === "enter" ? $ == null || $() : pe === "leave" && (a == null || a());
125
125
  });
126
- }), T = S((U) => {
127
- let ne = U ? "enter" : "leave";
128
- v.current = !1, i.onStop(g, ne, (de) => {
129
- de === "enter" ? m == null || m() : de === "leave" && (r == null || r());
130
- }), ne === "leave" && !Se(i) && (N("hidden"), B(g));
126
+ }), w = T((X) => {
127
+ let ne = X ? "enter" : "leave";
128
+ b.current = !1, i.onStop(S, ne, (pe) => {
129
+ pe === "enter" ? h == null || h() : pe === "leave" && (r == null || r());
130
+ }), ne === "leave" && !ge(i) && (N("hidden"), x(S));
131
131
  });
132
- ce(() => {
133
- k && f || (p(F), T(F));
134
- }, [F, k, f]);
135
- let w = !(!f || !k || !A || q), [, I] = Ne(w, $, F, { start: p, end: T }), D = ut({ ref: L, className: ((c = st(u.className, J && P, J && n, I.enter && P, I.enter && I.closed && n, I.enter && !I.closed && y, I.leave && d, I.leave && !I.closed && a, I.leave && I.closed && s, !I.transition && F && b)) == null ? void 0 : c.trim()) || void 0, ...xe(I) }), K = 0;
136
- return O === "visible" && (K |= j.Open), O === "hidden" && (K |= j.Closed), I.enter && (K |= j.Opening), I.leave && (K |= j.Closing), E.createElement(ge.Provider, { value: i }, E.createElement(Ke, { value: K }, se({ ourProps: D, theirProps: u, defaultTag: Qe, features: Ve, visible: O === "visible", name: "Transition.Child" })));
132
+ ue(() => {
133
+ B && v || (f(k), w(k));
134
+ }, [k, B, v]);
135
+ let I = !(!v || !B || !K || O), [, F] = Re(I, p, k, { start: f, end: w }), H = ut({ ref: A, className: ((d = it(u.className, L && y, L && n, F.enter && y, F.enter && F.closed && n, F.enter && !F.closed && m, F.leave && c, F.leave && !F.closed && o, F.leave && F.closed && s, !F.transition && k && P)) == null ? void 0 : d.trim()) || void 0, ...xe(F) }), j = 0;
136
+ return M === "visible" && (j |= W.Open), M === "hidden" && (j |= W.Closed), F.enter && (j |= W.Opening), F.leave && (j |= W.Closing), E.createElement(Se.Provider, { value: i }, E.createElement(Ke, { value: j }, se({ ourProps: H, theirProps: u, defaultTag: Qe, features: Ve, visible: M === "visible", name: "Transition.Child" })));
137
137
  }
138
138
  function Dt(e, t) {
139
- let { show: o, appear: c = !1, unmount: f = !0, ...h } = e, m = R(null), l = qe(e), r = ee(...l ? [m, t] : t === null ? [] : [t]);
139
+ let { show: l, appear: d = !1, unmount: v = !0, ...$ } = e, h = _(null), a = qe(e), r = ee(...a ? [h, t] : t === null ? [] : [t]);
140
140
  Ge();
141
- let P = ye();
142
- if (o === void 0 && P !== null && (o = (P & j.Open) === j.Open), o === void 0) throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");
143
- let [n, y] = X(o ? "visible" : "hidden"), b = Je(() => {
144
- o || y("hidden");
145
- }), [d, a] = X(!0), s = R([o]);
146
- ie(() => {
147
- d !== !1 && s.current[s.current.length - 1] !== o && (s.current.push(o), a(!1));
148
- }, [s, o]);
149
- let u = Z(() => ({ show: o, appear: c, initial: d }), [o, c, d]);
150
- ie(() => {
151
- o ? y("visible") : !Se(b) && m.current !== null && y("hidden");
152
- }, [o, b]);
153
- let $ = { unmount: f }, C = S(() => {
154
- var k;
155
- d && a(!1), (k = e.beforeEnter) == null || k.call(e);
156
- }), g = S(() => {
157
- var k;
158
- d && a(!1), (k = e.beforeLeave) == null || k.call(e);
141
+ let y = ye();
142
+ if (l === void 0 && y !== null && (l = (y & W.Open) === W.Open), l === void 0) throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");
143
+ let [n, m] = J(l ? "visible" : "hidden"), P = Je(() => {
144
+ l || m("hidden");
145
+ }), [c, o] = J(!0), s = _([l]);
146
+ de(() => {
147
+ c !== !1 && s.current[s.current.length - 1] !== l && (s.current.push(l), o(!1));
148
+ }, [s, l]);
149
+ let u = q(() => ({ show: l, appear: d, initial: c }), [l, d, c]);
150
+ de(() => {
151
+ l ? m("visible") : !ge(P) && h.current !== null && m("hidden");
152
+ }, [l, P]);
153
+ let p = { unmount: v }, g = T(() => {
154
+ var B;
155
+ c && o(!1), (B = e.beforeEnter) == null || B.call(e);
156
+ }), S = T(() => {
157
+ var B;
158
+ c && o(!1), (B = e.beforeLeave) == null || B.call(e);
159
159
  });
160
- return E.createElement(ge.Provider, { value: b }, E.createElement(Ee.Provider, { value: u }, se({ ourProps: { ...$, as: fe, children: E.createElement(Ye, { ref: r, ...$, ...h, beforeEnter: C, beforeLeave: g }) }, theirProps: {}, defaultTag: fe, features: Ve, visible: n === "visible", name: "Transition" })));
160
+ return E.createElement(Se.Provider, { value: P }, E.createElement(Ee.Provider, { value: u }, se({ ourProps: { ...p, as: ve, children: E.createElement(Ye, { ref: r, ...p, ...$, beforeEnter: g, beforeLeave: S }) }, theirProps: {}, defaultTag: ve, features: Ve, visible: n === "visible", name: "Transition" })));
161
161
  }
162
162
  function Ht(e, t) {
163
- let o = te(Ee) !== null, c = ye() !== null;
164
- return E.createElement(E.Fragment, null, !o && c ? E.createElement(Oe, { ref: t, ...e }) : E.createElement(Ye, { ref: t, ...e }));
163
+ let l = te(Ee) !== null, d = ye() !== null;
164
+ return E.createElement(E.Fragment, null, !l && d ? E.createElement(Ce, { ref: t, ...e }) : E.createElement(Ye, { ref: t, ...e }));
165
165
  }
166
- let Oe = Y(Dt), Ye = Y(At), Gt = Y(Ht), Kt = Object.assign(Oe, { Child: Gt, Root: Oe });
166
+ let Ce = Y(Dt), Ye = Y(At), Gt = Y(Ht), Kt = Object.assign(Ce, { Child: Gt, Root: Ce });
167
167
  var Ut = ((e) => (e[e.Open = 0] = "Open", e[e.Closed = 1] = "Closed", e))(Ut || {}), jt = ((e) => (e[e.TogglePopover = 0] = "TogglePopover", e[e.ClosePopover = 1] = "ClosePopover", e[e.SetButton = 2] = "SetButton", e[e.SetButtonId = 3] = "SetButtonId", e[e.SetPanel = 4] = "SetPanel", e[e.SetPanelId = 5] = "SetPanelId", e))(jt || {});
168
168
  let Xt = { 0: (e) => ({ ...e, popoverState: V(e.popoverState, { 0: 1, 1: 0 }), __demoMode: !1 }), 1(e) {
169
169
  return e.popoverState === 1 ? e : { ...e, popoverState: 1, __demoMode: !1 };
@@ -175,32 +175,32 @@ let Xt = { 0: (e) => ({ ...e, popoverState: V(e.popoverState, { 0: 1, 1: 0 }), _
175
175
  return e.panel === t.panel ? e : { ...e, panel: t.panel };
176
176
  }, 5(e, t) {
177
177
  return e.panelId === t.panelId ? e : { ...e, panelId: t.panelId };
178
- } }, Le = ue(null);
178
+ } }, Le = ie(null);
179
179
  Le.displayName = "PopoverContext";
180
180
  function Te(e) {
181
181
  let t = te(Le);
182
182
  if (t === null) {
183
- let o = new Error(`<${e} /> is missing a parent <Popover /> component.`);
184
- throw Error.captureStackTrace && Error.captureStackTrace(o, Te), o;
183
+ let l = new Error(`<${e} /> is missing a parent <Popover /> component.`);
184
+ throw Error.captureStackTrace && Error.captureStackTrace(l, Te), l;
185
185
  }
186
186
  return t;
187
187
  }
188
- let we = ue(null);
188
+ let we = ie(null);
189
189
  we.displayName = "PopoverAPIContext";
190
190
  function _e(e) {
191
191
  let t = te(we);
192
192
  if (t === null) {
193
- let o = new Error(`<${e} /> is missing a parent <Popover /> component.`);
194
- throw Error.captureStackTrace && Error.captureStackTrace(o, _e), o;
193
+ let l = new Error(`<${e} /> is missing a parent <Popover /> component.`);
194
+ throw Error.captureStackTrace && Error.captureStackTrace(l, _e), l;
195
195
  }
196
196
  return t;
197
197
  }
198
- let Ae = ue(null);
198
+ let Ae = ie(null);
199
199
  Ae.displayName = "PopoverGroupContext";
200
200
  function ze() {
201
201
  return te(Ae);
202
202
  }
203
- let Ie = ue(null);
203
+ let Ie = ie(null);
204
204
  Ie.displayName = "PopoverPanelContext";
205
205
  function Wt() {
206
206
  return te(Ie);
@@ -210,324 +210,340 @@ function Zt(e, t) {
210
210
  }
211
211
  let qt = "div";
212
212
  function Jt(e, t) {
213
- var o;
214
- let { __demoMode: c = !1, ...f } = e, h = R(null), m = ee(t, ct((v) => {
215
- h.current = v;
216
- })), l = R([]), r = rt(Zt, { __demoMode: c, popoverState: c ? 0 : 1, buttons: l, button: null, buttonId: null, panel: null, panelId: null, beforePanelSentinel: Fe(), afterPanelSentinel: Fe(), afterButtonSentinel: Fe() }), [{ popoverState: P, button: n, buttonId: y, panel: b, panelId: d, beforePanelSentinel: a, afterPanelSentinel: s, afterButtonSentinel: u }, $] = r, C = $e((o = h.current) != null ? o : n), g = Z(() => {
217
- if (!n || !b) return !1;
218
- for (let D of document.querySelectorAll("body > *")) if (Number(D == null ? void 0 : D.contains(n)) ^ Number(D == null ? void 0 : D.contains(b))) return !0;
219
- let v = Re(), i = v.indexOf(n), p = (i + v.length - 1) % v.length, T = (i + 1) % v.length, w = v[p], I = v[T];
220
- return !b.contains(w) && !b.contains(I);
221
- }, [n, b]), k = Ce(y), L = Ce(d), _ = Z(() => ({ buttonId: k, panelId: L, close: () => $({ type: 1 }) }), [k, L, $]), F = ze(), M = F == null ? void 0 : F.registerPopover, W = S(() => {
222
- var v;
223
- return (v = F == null ? void 0 : F.isFocusWithinPopoverGroup()) != null ? v : (C == null ? void 0 : C.activeElement) && ((n == null ? void 0 : n.contains(C.activeElement)) || (b == null ? void 0 : b.contains(C.activeElement)));
213
+ var l;
214
+ let { __demoMode: d = !1, ...v } = e, $ = _(null), h = ee(t, ct((b) => {
215
+ $.current = b;
216
+ })), a = _([]), r = rt(Zt, { __demoMode: d, popoverState: d ? 0 : 1, buttons: a, button: null, buttonId: null, panel: null, panelId: null, beforePanelSentinel: Fe(), afterPanelSentinel: Fe(), afterButtonSentinel: Fe() }), [{ popoverState: y, button: n, buttonId: m, panel: P, panelId: c, beforePanelSentinel: o, afterPanelSentinel: s, afterButtonSentinel: u }, p] = r, g = $e((l = $.current) != null ? l : n), S = q(() => {
217
+ if (!n || !P) return !1;
218
+ for (let H of document.querySelectorAll("body > *")) if (Number(H == null ? void 0 : H.contains(n)) ^ Number(H == null ? void 0 : H.contains(P))) return !0;
219
+ let b = Oe(), i = b.indexOf(n), f = (i + b.length - 1) % b.length, w = (i + 1) % b.length, I = b[f], F = b[w];
220
+ return !P.contains(I) && !P.contains(F);
221
+ }, [n, P]), B = ke(m), A = ke(c), D = q(() => ({ buttonId: B, panelId: A, close: () => p({ type: 1 }) }), [B, A, p]), k = ze(), C = k == null ? void 0 : k.registerPopover, Z = T(() => {
222
+ var b;
223
+ return (b = k == null ? void 0 : k.isFocusWithinPopoverGroup()) != null ? b : (g == null ? void 0 : g.activeElement) && ((n == null ? void 0 : n.contains(g.activeElement)) || (P == null ? void 0 : P.contains(g.activeElement)));
224
224
  });
225
- ce(() => M == null ? void 0 : M(_), [M, _]);
226
- let [O, N] = bt(), H = We(n), x = xt({ mainTreeNode: H, portals: O, defaultContainers: [n, b] });
227
- ht(C == null ? void 0 : C.defaultView, "focus", (v) => {
228
- var i, p, T, w, I, D;
229
- v.target !== window && v.target instanceof HTMLElement && P === 0 && (W() || n && b && (x.contains(v.target) || (p = (i = a.current) == null ? void 0 : i.contains) != null && p.call(i, v.target) || (w = (T = s.current) == null ? void 0 : T.contains) != null && w.call(T, v.target) || (D = (I = u.current) == null ? void 0 : I.contains) != null && D.call(I, v.target) || $({ type: 1 })));
230
- }, !0), Pt(P === 0, x.resolveContainers, (v, i) => {
231
- $({ type: 1 }), Ot(i, Mt.Loose) || (v.preventDefault(), n == null || n.focus());
225
+ ue(() => C == null ? void 0 : C(D), [C, D]);
226
+ let [M, N] = bt(), G = We(n), R = xt({ mainTreeNode: G, portals: M, defaultContainers: [n, P] });
227
+ ht(g == null ? void 0 : g.defaultView, "focus", (b) => {
228
+ var i, f, w, I, F, H;
229
+ b.target !== window && b.target instanceof HTMLElement && y === 0 && (Z() || n && P && (R.contains(b.target) || (f = (i = o.current) == null ? void 0 : i.contains) != null && f.call(i, b.target) || (I = (w = s.current) == null ? void 0 : w.contains) != null && I.call(w, b.target) || (H = (F = u.current) == null ? void 0 : F.contains) != null && H.call(F, b.target) || p({ type: 1 })));
230
+ }, !0), Pt(y === 0, R.resolveContainers, (b, i) => {
231
+ p({ type: 1 }), Ct(i, Nt.Loose) || (b.preventDefault(), n == null || n.focus());
232
232
  });
233
- let B = S((v) => {
234
- $({ type: 1 });
235
- let i = v ? v instanceof HTMLElement ? v : "current" in v && v.current instanceof HTMLElement ? v.current : n : n;
233
+ let x = T((b) => {
234
+ p({ type: 1 });
235
+ let i = b ? b instanceof HTMLElement ? b : "current" in b && b.current instanceof HTMLElement ? b.current : n : n;
236
236
  i == null || i.focus();
237
- }), A = Z(() => ({ close: B, isPortalled: g }), [B, g]), q = Z(() => ({ open: P === 0, close: B }), [P, B]), J = { ref: m };
238
- return E.createElement(Xe, { node: H }, E.createElement($t, null, E.createElement(Ie.Provider, { value: null }, E.createElement(Le.Provider, { value: r }, E.createElement(we.Provider, { value: A }, E.createElement(Bt, { value: B }, E.createElement(Ke, { value: V(P, { 0: j.Open, 1: j.Closed }) }, E.createElement(N, null, se({ ourProps: J, theirProps: f, slot: q, defaultTag: qt, name: "Popover" })))))))));
237
+ }), K = q(() => ({ close: x, isPortalled: S }), [x, S]), O = q(() => ({ open: y === 0, close: x }), [y, x]), L = { ref: h };
238
+ return E.createElement(Xe, { node: G }, E.createElement($t, null, E.createElement(Ie.Provider, { value: null }, E.createElement(Le.Provider, { value: r }, E.createElement(we.Provider, { value: K }, E.createElement(Mt, { value: x }, E.createElement(Ke, { value: V(y, { 0: W.Open, 1: W.Closed }) }, E.createElement(N, null, se({ ourProps: L, theirProps: v, slot: O, defaultTag: qt, name: "Popover" })))))))));
239
239
  }
240
240
  let Qt = "button";
241
241
  function Vt(e, t) {
242
- let o = be(), { id: c = `headlessui-popover-button-${o}`, disabled: f = !1, autoFocus: h = !1, ...m } = e, [l, r] = Te("Popover.Button"), { isPortalled: P } = _e("Popover.Button"), n = R(null), y = `headlessui-focus-sentinel-${be()}`, b = ze(), d = b == null ? void 0 : b.closeOthers, a = Wt() !== null;
243
- ce(() => {
244
- if (!a) return r({ type: 3, buttonId: c }), () => {
242
+ let l = be(), { id: d = `headlessui-popover-button-${l}`, disabled: v = !1, autoFocus: $ = !1, ...h } = e, [a, r] = Te("Popover.Button"), { isPortalled: y } = _e("Popover.Button"), n = _(null), m = `headlessui-focus-sentinel-${be()}`, P = ze(), c = P == null ? void 0 : P.closeOthers, o = Wt() !== null;
243
+ ue(() => {
244
+ if (!o) return r({ type: 3, buttonId: d }), () => {
245
245
  r({ type: 3, buttonId: null });
246
246
  };
247
- }, [a, c, r]);
248
- let [s] = X(() => Symbol()), u = ee(n, t, yt(), S((i) => {
249
- if (!a) {
250
- if (i) l.buttons.current.push(s);
247
+ }, [o, d, r]);
248
+ let [s] = J(() => Symbol()), u = ee(n, t, yt(), T((i) => {
249
+ if (!o) {
250
+ if (i) a.buttons.current.push(s);
251
251
  else {
252
- let p = l.buttons.current.indexOf(s);
253
- p !== -1 && l.buttons.current.splice(p, 1);
252
+ let f = a.buttons.current.indexOf(s);
253
+ f !== -1 && a.buttons.current.splice(f, 1);
254
254
  }
255
- l.buttons.current.length > 1 && console.warn("You are already using a <Popover.Button /> but only 1 <Popover.Button /> is supported."), i && r({ type: 2, button: i });
255
+ a.buttons.current.length > 1 && console.warn("You are already using a <Popover.Button /> but only 1 <Popover.Button /> is supported."), i && r({ type: 2, button: i });
256
256
  }
257
- })), $ = ee(n, t), C = $e(n), g = S((i) => {
258
- var p, T, w;
259
- if (a) {
260
- if (l.popoverState === 1) return;
257
+ })), p = ee(n, t), g = $e(n), S = T((i) => {
258
+ var f, w, I;
259
+ if (o) {
260
+ if (a.popoverState === 1) return;
261
261
  switch (i.key) {
262
262
  case oe.Space:
263
263
  case oe.Enter:
264
- i.preventDefault(), (T = (p = i.target).click) == null || T.call(p), r({ type: 1 }), (w = l.button) == null || w.focus();
264
+ i.preventDefault(), (w = (f = i.target).click) == null || w.call(f), r({ type: 1 }), (I = a.button) == null || I.focus();
265
265
  break;
266
266
  }
267
267
  } else switch (i.key) {
268
268
  case oe.Space:
269
269
  case oe.Enter:
270
- i.preventDefault(), i.stopPropagation(), l.popoverState === 1 && (d == null || d(l.buttonId)), r({ type: 0 });
270
+ i.preventDefault(), i.stopPropagation(), a.popoverState === 1 && (c == null || c(a.buttonId)), r({ type: 0 });
271
271
  break;
272
272
  case oe.Escape:
273
- if (l.popoverState !== 0) return d == null ? void 0 : d(l.buttonId);
274
- if (!n.current || C != null && C.activeElement && !n.current.contains(C.activeElement)) return;
273
+ if (a.popoverState !== 0) return c == null ? void 0 : c(a.buttonId);
274
+ if (!n.current || g != null && g.activeElement && !n.current.contains(g.activeElement)) return;
275
275
  i.preventDefault(), i.stopPropagation(), r({ type: 1 });
276
276
  break;
277
277
  }
278
- }), k = S((i) => {
279
- a || i.key === oe.Space && i.preventDefault();
280
- }), L = S((i) => {
281
- var p, T;
282
- Ue(i.currentTarget) || f || (a ? (r({ type: 1 }), (p = l.button) == null || p.focus()) : (i.preventDefault(), i.stopPropagation(), l.popoverState === 1 && (d == null || d(l.buttonId)), r({ type: 0 }), (T = l.button) == null || T.focus()));
283
- }), _ = S((i) => {
278
+ }), B = T((i) => {
279
+ o || i.key === oe.Space && i.preventDefault();
280
+ }), A = T((i) => {
281
+ var f, w;
282
+ Ue(i.currentTarget) || v || (o ? (r({ type: 1 }), (f = a.button) == null || f.focus()) : (i.preventDefault(), i.stopPropagation(), a.popoverState === 1 && (c == null || c(a.buttonId)), r({ type: 0 }), (w = a.button) == null || w.focus()));
283
+ }), D = T((i) => {
284
284
  i.preventDefault(), i.stopPropagation();
285
- }), { isFocusVisible: F, focusProps: M } = dt({ autoFocus: h }), { isHovered: W, hoverProps: O } = pt({ isDisabled: f }), { pressed: N, pressProps: H } = vt({ disabled: f }), x = l.popoverState === 0, B = Z(() => ({ open: x, active: N || x, disabled: f, hover: W, focus: F, autofocus: h }), [x, W, F, N, f, h]), A = Ct(e, l.button), q = a ? ke({ ref: $, type: A, onKeyDown: g, onClick: L, disabled: f || void 0, autoFocus: h }, M, O, H) : ke({ ref: u, id: l.buttonId, type: A, "aria-expanded": l.popoverState === 0, "aria-controls": l.panel ? l.panelId : void 0, disabled: f || void 0, autoFocus: h, onKeyDown: g, onKeyUp: k, onClick: L, onMouseDown: _ }, M, O, H), J = Ze(), v = S(() => {
286
- let i = l.panel;
285
+ }), { isFocusVisible: k, focusProps: C } = dt({ autoFocus: $ }), { isHovered: Z, hoverProps: M } = pt({ isDisabled: v }), { pressed: N, pressProps: G } = vt({ disabled: v }), R = a.popoverState === 0, x = q(() => ({ open: R, active: N || R, disabled: v, hover: Z, focus: k, autofocus: $ }), [R, Z, k, N, v, $]), K = kt(e, a.button), O = o ? Be({ ref: p, type: K, onKeyDown: S, onClick: A, disabled: v || void 0, autoFocus: $ }, C, M, G) : Be({ ref: u, id: a.buttonId, type: K, "aria-expanded": a.popoverState === 0, "aria-controls": a.panel ? a.panelId : void 0, disabled: v || void 0, autoFocus: $, onKeyDown: S, onKeyUp: B, onClick: A, onMouseDown: D }, C, M, G), L = Ze(), b = T(() => {
286
+ let i = a.panel;
287
287
  if (!i) return;
288
- function p() {
289
- V(J.current, { [Q.Forwards]: () => ae(i, z.First), [Q.Backwards]: () => ae(i, z.Last) }) === Be.Error && ae(Re().filter((T) => T.dataset.headlessuiFocusGuard !== "true"), V(J.current, { [Q.Forwards]: z.Next, [Q.Backwards]: z.Previous }), { relativeTo: l.button });
288
+ function f() {
289
+ V(L.current, { [Q.Forwards]: () => ae(i, z.First), [Q.Backwards]: () => ae(i, z.Last) }) === Me.Error && ae(Oe().filter((w) => w.dataset.headlessuiFocusGuard !== "true"), V(L.current, { [Q.Forwards]: z.Next, [Q.Backwards]: z.Previous }), { relativeTo: a.button });
290
290
  }
291
- p();
291
+ f();
292
292
  });
293
- return E.createElement(E.Fragment, null, se({ ourProps: q, theirProps: m, slot: B, defaultTag: Qt, name: "Popover.Button" }), x && !a && P && E.createElement(he, { id: y, ref: l.afterButtonSentinel, features: Pe.Focusable, "data-headlessui-focus-guard": !0, as: "button", type: "button", onFocus: v }));
293
+ return E.createElement(E.Fragment, null, se({ ourProps: O, theirProps: h, slot: x, defaultTag: Qt, name: "Popover.Button" }), R && !o && y && E.createElement(he, { id: m, ref: a.afterButtonSentinel, features: Pe.Focusable, "data-headlessui-focus-guard": !0, as: "button", type: "button", onFocus: b }));
294
294
  }
295
- let Yt = "div", zt = ve.RenderStrategy | ve.Static;
295
+ let Yt = "div", zt = me.RenderStrategy | me.Static;
296
296
  function et(e, t) {
297
- let o = be(), { id: c = `headlessui-popover-backdrop-${o}`, transition: f = !1, ...h } = e, [{ popoverState: m }, l] = Te("Popover.Backdrop"), [r, P] = X(null), n = ee(t, P), y = ye(), [b, d] = Ne(f, r, y !== null ? (y & j.Open) === j.Open : m === 0), a = S(($) => {
298
- if (Ue($.currentTarget)) return $.preventDefault();
299
- l({ type: 1 });
300
- }), s = Z(() => ({ open: m === 0 }), [m]), u = { ref: n, id: c, "aria-hidden": !0, onClick: a, ...xe(d) };
301
- return se({ ourProps: u, theirProps: h, slot: s, defaultTag: Yt, features: zt, visible: b, name: "Popover.Backdrop" });
297
+ let l = be(), { id: d = `headlessui-popover-backdrop-${l}`, transition: v = !1, ...$ } = e, [{ popoverState: h }, a] = Te("Popover.Backdrop"), [r, y] = J(null), n = ee(t, y), m = ye(), [P, c] = Re(v, r, m !== null ? (m & W.Open) === W.Open : h === 0), o = T((p) => {
298
+ if (Ue(p.currentTarget)) return p.preventDefault();
299
+ a({ type: 1 });
300
+ }), s = q(() => ({ open: h === 0 }), [h]), u = { ref: n, id: d, "aria-hidden": !0, onClick: o, ...xe(c) };
301
+ return se({ ourProps: u, theirProps: $, slot: s, defaultTag: Yt, features: zt, visible: P, name: "Popover.Backdrop" });
302
302
  }
303
- let en = "div", tn = ve.RenderStrategy | ve.Static;
303
+ let en = "div", tn = me.RenderStrategy | me.Static;
304
304
  function nn(e, t) {
305
- let o = be(), { id: c = `headlessui-popover-panel-${o}`, focus: f = !1, anchor: h, portal: m = !1, modal: l = !1, transition: r = !1, ...P } = e, [n, y] = Te("Popover.Panel"), { close: b, isPortalled: d } = _e("Popover.Panel"), a = `headlessui-focus-sentinel-before-${o}`, s = `headlessui-focus-sentinel-after-${o}`, u = R(null), $ = Et(h), [C, g] = gt($), k = St();
306
- $ && (m = !0);
307
- let [L, _] = X(null), F = ee(u, t, $ ? C : null, S((p) => y({ type: 4, panel: p })), _), M = $e(u), W = ft();
308
- ie(() => (y({ type: 5, panelId: c }), () => {
309
- y({ type: 5, panelId: null });
310
- }), [c, y]);
311
- let O = ye(), [N, H] = Ne(r, L, O !== null ? (O & j.Open) === j.Open : n.popoverState === 0);
305
+ let l = be(), { id: d = `headlessui-popover-panel-${l}`, focus: v = !1, anchor: $, portal: h = !1, modal: a = !1, transition: r = !1, ...y } = e, [n, m] = Te("Popover.Panel"), { close: P, isPortalled: c } = _e("Popover.Panel"), o = `headlessui-focus-sentinel-before-${l}`, s = `headlessui-focus-sentinel-after-${l}`, u = _(null), p = Et($), [g, S] = St(p), B = gt();
306
+ p && (h = !0);
307
+ let [A, D] = J(null), k = ee(u, t, p ? g : null, T((f) => m({ type: 4, panel: f })), D), C = $e(u), Z = ft();
308
+ de(() => (m({ type: 5, panelId: d }), () => {
309
+ m({ type: 5, panelId: null });
310
+ }), [d, m]);
311
+ let M = ye(), [N, G] = Re(r, A, M !== null ? (M & W.Open) === W.Open : n.popoverState === 0);
312
312
  Tt(N, n.button, () => {
313
- y({ type: 1 });
313
+ m({ type: 1 });
314
314
  });
315
- let x = n.__demoMode ? !1 : l && N;
316
- wt(x, M);
317
- let B = S((p) => {
318
- var T;
319
- switch (p.key) {
315
+ let R = n.__demoMode ? !1 : a && N;
316
+ wt(R, C);
317
+ let x = T((f) => {
318
+ var w;
319
+ switch (f.key) {
320
320
  case oe.Escape:
321
- if (n.popoverState !== 0 || !u.current || M != null && M.activeElement && !u.current.contains(M.activeElement)) return;
322
- p.preventDefault(), p.stopPropagation(), y({ type: 1 }), (T = n.button) == null || T.focus();
321
+ if (n.popoverState !== 0 || !u.current || C != null && C.activeElement && !u.current.contains(C.activeElement)) return;
322
+ f.preventDefault(), f.stopPropagation(), m({ type: 1 }), (w = n.button) == null || w.focus();
323
323
  break;
324
324
  }
325
325
  });
326
- ce(() => {
327
- var p;
328
- e.static || n.popoverState === 1 && ((p = e.unmount) == null || p) && y({ type: 4, panel: null });
329
- }, [n.popoverState, e.unmount, e.static, y]), ce(() => {
330
- if (n.__demoMode || !f || n.popoverState !== 0 || !u.current) return;
331
- let p = M == null ? void 0 : M.activeElement;
332
- u.current.contains(p) || ae(u.current, z.First);
333
- }, [n.__demoMode, f, u.current, n.popoverState]);
334
- let A = Z(() => ({ open: n.popoverState === 0, close: b }), [n.popoverState, b]), q = ke($ ? k() : {}, { ref: F, id: c, onKeyDown: B, onBlur: f && n.popoverState === 0 ? (p) => {
335
- var T, w, I, D, K;
336
- let U = p.relatedTarget;
337
- U && u.current && ((T = u.current) != null && T.contains(U) || (y({ type: 1 }), ((I = (w = n.beforePanelSentinel.current) == null ? void 0 : w.contains) != null && I.call(w, U) || (K = (D = n.afterPanelSentinel.current) == null ? void 0 : D.contains) != null && K.call(D, U)) && U.focus({ preventScroll: !0 })));
338
- } : void 0, tabIndex: -1, style: { ...P.style, ...g, "--button-width": It(n.button, !0).width }, ...xe(H) }), J = Ze(), v = S(() => {
339
- let p = u.current;
340
- if (!p) return;
341
- function T() {
342
- V(J.current, { [Q.Forwards]: () => {
343
- var w;
344
- ae(p, z.First) === Be.Error && ((w = n.afterPanelSentinel.current) == null || w.focus());
326
+ ue(() => {
327
+ var f;
328
+ e.static || n.popoverState === 1 && ((f = e.unmount) == null || f) && m({ type: 4, panel: null });
329
+ }, [n.popoverState, e.unmount, e.static, m]), ue(() => {
330
+ if (n.__demoMode || !v || n.popoverState !== 0 || !u.current) return;
331
+ let f = C == null ? void 0 : C.activeElement;
332
+ u.current.contains(f) || ae(u.current, z.First);
333
+ }, [n.__demoMode, v, u.current, n.popoverState]);
334
+ let K = q(() => ({ open: n.popoverState === 0, close: P }), [n.popoverState, P]), O = Be(p ? B() : {}, { ref: k, id: d, onKeyDown: x, onBlur: v && n.popoverState === 0 ? (f) => {
335
+ var w, I, F, H, j;
336
+ let X = f.relatedTarget;
337
+ X && u.current && ((w = u.current) != null && w.contains(X) || (m({ type: 1 }), ((F = (I = n.beforePanelSentinel.current) == null ? void 0 : I.contains) != null && F.call(I, X) || (j = (H = n.afterPanelSentinel.current) == null ? void 0 : H.contains) != null && j.call(H, X)) && X.focus({ preventScroll: !0 })));
338
+ } : void 0, tabIndex: -1, style: { ...y.style, ...S, "--button-width": It(n.button, !0).width }, ...xe(G) }), L = Ze(), b = T(() => {
339
+ let f = u.current;
340
+ if (!f) return;
341
+ function w() {
342
+ V(L.current, { [Q.Forwards]: () => {
343
+ var I;
344
+ ae(f, z.First) === Me.Error && ((I = n.afterPanelSentinel.current) == null || I.focus());
345
345
  }, [Q.Backwards]: () => {
346
- var w;
347
- (w = n.button) == null || w.focus({ preventScroll: !0 });
346
+ var I;
347
+ (I = n.button) == null || I.focus({ preventScroll: !0 });
348
348
  } });
349
349
  }
350
- T();
351
- }), i = S(() => {
352
- let p = u.current;
353
- if (!p) return;
354
- function T() {
355
- V(J.current, { [Q.Forwards]: () => {
350
+ w();
351
+ }), i = T(() => {
352
+ let f = u.current;
353
+ if (!f) return;
354
+ function w() {
355
+ V(L.current, { [Q.Forwards]: () => {
356
356
  if (!n.button) return;
357
- let w = Re(), I = w.indexOf(n.button), D = w.slice(0, I + 1), K = [...w.slice(I + 1), ...D];
358
- for (let U of K.slice()) if (U.dataset.headlessuiFocusGuard === "true" || L != null && L.contains(U)) {
359
- let ne = K.indexOf(U);
360
- ne !== -1 && K.splice(ne, 1);
357
+ let I = Oe(), F = I.indexOf(n.button), H = I.slice(0, F + 1), j = [...I.slice(F + 1), ...H];
358
+ for (let X of j.slice()) if (X.dataset.headlessuiFocusGuard === "true" || A != null && A.contains(X)) {
359
+ let ne = j.indexOf(X);
360
+ ne !== -1 && j.splice(ne, 1);
361
361
  }
362
- ae(K, z.First, { sorted: !1 });
362
+ ae(j, z.First, { sorted: !1 });
363
363
  }, [Q.Backwards]: () => {
364
- var w;
365
- ae(p, z.Previous) === Be.Error && ((w = n.button) == null || w.focus());
364
+ var I;
365
+ ae(f, z.Previous) === Me.Error && ((I = n.button) == null || I.focus());
366
366
  } });
367
367
  }
368
- T();
368
+ w();
369
369
  });
370
- return E.createElement(kt, null, E.createElement(Ie.Provider, { value: c }, E.createElement(we.Provider, { value: { close: b, isPortalled: d } }, E.createElement(Ft, { enabled: m ? e.static || N : !1 }, N && d && E.createElement(he, { id: a, ref: n.beforePanelSentinel, features: Pe.Focusable, "data-headlessui-focus-guard": !0, as: "button", type: "button", onFocus: v }), se({ mergeRefs: W, ourProps: q, theirProps: P, slot: A, defaultTag: en, features: tn, visible: N, name: "Popover.Panel" }), N && d && E.createElement(he, { id: s, ref: n.afterPanelSentinel, features: Pe.Focusable, "data-headlessui-focus-guard": !0, as: "button", type: "button", onFocus: i })))));
370
+ return E.createElement(Bt, null, E.createElement(Ie.Provider, { value: d }, E.createElement(we.Provider, { value: { close: P, isPortalled: c } }, E.createElement(Ft, { enabled: h ? e.static || N : !1 }, N && c && E.createElement(he, { id: o, ref: n.beforePanelSentinel, features: Pe.Focusable, "data-headlessui-focus-guard": !0, as: "button", type: "button", onFocus: b }), se({ mergeRefs: Z, ourProps: O, theirProps: y, slot: K, defaultTag: en, features: tn, visible: N, name: "Popover.Panel" }), N && c && E.createElement(he, { id: s, ref: n.afterPanelSentinel, features: Pe.Focusable, "data-headlessui-focus-guard": !0, as: "button", type: "button", onFocus: i })))));
371
371
  }
372
372
  let rn = "div";
373
373
  function on(e, t) {
374
- let o = R(null), c = ee(o, t), [f, h] = X([]), m = S((a) => {
375
- h((s) => {
376
- let u = s.indexOf(a);
374
+ let l = _(null), d = ee(l, t), [v, $] = J([]), h = T((o) => {
375
+ $((s) => {
376
+ let u = s.indexOf(o);
377
377
  if (u !== -1) {
378
- let $ = s.slice();
379
- return $.splice(u, 1), $;
378
+ let p = s.slice();
379
+ return p.splice(u, 1), p;
380
380
  }
381
381
  return s;
382
382
  });
383
- }), l = S((a) => (h((s) => [...s, a]), () => m(a))), r = S(() => {
384
- var a;
385
- let s = He(o);
383
+ }), a = T((o) => ($((s) => [...s, o]), () => h(o))), r = T(() => {
384
+ var o;
385
+ let s = He(l);
386
386
  if (!s) return !1;
387
387
  let u = s.activeElement;
388
- return (a = o.current) != null && a.contains(u) ? !0 : f.some(($) => {
389
- var C, g;
390
- return ((C = s.getElementById($.buttonId.current)) == null ? void 0 : C.contains(u)) || ((g = s.getElementById($.panelId.current)) == null ? void 0 : g.contains(u));
388
+ return (o = l.current) != null && o.contains(u) ? !0 : v.some((p) => {
389
+ var g, S;
390
+ return ((g = s.getElementById(p.buttonId.current)) == null ? void 0 : g.contains(u)) || ((S = s.getElementById(p.panelId.current)) == null ? void 0 : S.contains(u));
391
391
  });
392
- }), P = S((a) => {
393
- for (let s of f) s.buttonId.current !== a && s.close();
394
- }), n = Z(() => ({ registerPopover: l, unregisterPopover: m, isFocusWithinPopoverGroup: r, closeOthers: P }), [l, m, r, P]), y = Z(() => ({}), []), b = e, d = { ref: c };
395
- return E.createElement(Xe, null, E.createElement(Ae.Provider, { value: n }, se({ ourProps: d, theirProps: b, slot: y, defaultTag: rn, name: "Popover.Group" })));
392
+ }), y = T((o) => {
393
+ for (let s of v) s.buttonId.current !== o && s.close();
394
+ }), n = q(() => ({ registerPopover: a, unregisterPopover: h, isFocusWithinPopoverGroup: r, closeOthers: y }), [a, h, r, y]), m = q(() => ({}), []), P = e, c = { ref: d };
395
+ return E.createElement(Xe, null, E.createElement(Ae.Provider, { value: n }, se({ ourProps: c, theirProps: P, slot: m, defaultTag: rn, name: "Popover.Group" })));
396
396
  }
397
- let ln = Y(Jt), Me = Y(Vt), an = Y(et), un = Y(et), tt = Y(nn), sn = Y(on), cn = Object.assign(ln, { Button: Me, Backdrop: un, Overlay: an, Panel: tt, Group: sn });
397
+ let ln = Y(Jt), Ne = Y(Vt), an = Y(et), un = Y(et), tt = Y(nn), sn = Y(on), cn = Object.assign(ln, { Button: Ne, Backdrop: un, Overlay: an, Panel: tt, Group: sn });
398
398
  const In = 300, Fn = ot(
399
399
  ({
400
400
  children: e,
401
401
  position: t = "bottom end",
402
- popoverProps: o,
403
- className: c,
404
- buttonClassName: f,
405
- panelClassName: h,
406
- menuItemsClassName: m,
407
- buttonContent: l,
402
+ popoverProps: l,
403
+ className: d,
404
+ buttonClassName: v,
405
+ panelClassName: $,
406
+ menuItemsClassName: h,
407
+ buttonContent: a,
408
408
  needCloseButton: r,
409
- openOnHover: P = !1,
410
- isOpen: n = !1,
411
- autoCloseTimeout: y = 0,
412
- triggerElement: b,
413
- variant: d = "default",
414
- arrow: a = !1
409
+ openOnHover: y = !1,
410
+ isOpen: n,
411
+ isControlled: m = !1,
412
+ onOpenChange: P,
413
+ autoCloseTimeout: c = 0,
414
+ triggerElement: o,
415
+ variant: s = "default",
416
+ arrow: u = !1
415
417
  }) => {
416
- const [s, u] = X(n), [$, C] = X(!1), [g, k] = X(!1), L = R(null), _ = R(null), F = R(null), { getArrowClasses: M, getPositionClass: W } = lt({
417
- buttonRef: _,
418
- panelRef: F,
418
+ const [p, g] = J(
419
+ n ?? !1
420
+ ), [S, B] = J(!1), A = _(null), D = _(null), k = _(null), { getArrowClasses: C, getPositionClass: Z } = lt({
421
+ buttonRef: D,
422
+ panelRef: k,
419
423
  initialPosition: t,
420
- isOpen: s || n || g,
421
- arrow: a,
422
- variant: d
423
- }), O = me(() => {
424
- L.current && clearTimeout(L.current);
425
- }, []), N = me(() => {
426
- y > 0 && !$ && (L.current = setTimeout(() => {
427
- u(!1), C(!0);
428
- }, y));
429
- }, [y, $]);
430
- ce(() => (s ? N() : O(), () => {
431
- O();
432
- }), [s, N, O]);
433
- const H = me(() => {
434
- P && u(!0);
435
- }, [P]), x = me(
436
- (B) => {
437
- if (P) {
438
- const A = B.relatedTarget;
439
- _.current && !_.current.contains(A) && F.current && !F.current.contains(A) && u(!1);
424
+ isOpen: p || n,
425
+ arrow: u,
426
+ variant: s
427
+ }), M = ce(() => {
428
+ A.current && clearTimeout(A.current);
429
+ }, []), N = ce(() => {
430
+ c > 0 && !S && (A.current = setTimeout(() => {
431
+ g(!1), B(!0);
432
+ }, c));
433
+ }, [c, S]);
434
+ ue(() => (p ? N() : M(), () => {
435
+ M();
436
+ }), [p, N, M]), ue(() => {
437
+ m && g(n);
438
+ }, [n, m]);
439
+ const G = ce(() => {
440
+ y && g(!0);
441
+ }, [y]), R = ce(
442
+ (O) => {
443
+ if (y) {
444
+ const L = O.relatedTarget;
445
+ D.current && !D.current.contains(L) && k.current && !k.current.contains(L) && g(!1);
440
446
  }
441
447
  },
442
- [P]
448
+ [y]
449
+ ), x = ce(
450
+ (O) => {
451
+ m || g(O), P == null || P(O);
452
+ },
453
+ [m, P]
454
+ ), K = ce(
455
+ (O) => {
456
+ O == null || O(), x(!1);
457
+ },
458
+ [x]
443
459
  );
444
460
  return /* @__PURE__ */ re(
445
461
  cn,
446
462
  {
447
463
  as: "div",
448
- className: pe(G.menu, c),
449
- ...o,
450
- children: ({ open: B, close: A }) => {
451
- const q = () => {
452
- A(), u(!1);
453
- };
454
- return B !== g && setTimeout(() => k(B), 0), /* @__PURE__ */ De(nt, { children: [
455
- b ? /* @__PURE__ */ re(
456
- Me,
457
- {
458
- as: "div",
459
- ref: _,
460
- onMouseEnter: H,
461
- onMouseLeave: x,
462
- className: pe(G["menu-button"], f),
463
- children: typeof b == "function" ? b({ open: s || B }) : b
464
- }
465
- ) : /* @__PURE__ */ re(
466
- Me,
467
- {
468
- ref: _,
469
- onMouseEnter: H,
470
- onMouseLeave: x,
471
- className: pe(G["menu-button"], f),
472
- children: l
473
- }
474
- ),
475
- /* @__PURE__ */ re(
476
- Kt,
477
- {
478
- show: s || B,
479
- as: fe,
480
- enter: G.enter,
481
- enterFrom: G["enter-from"],
482
- enterTo: G["enter-to"],
483
- leave: G.leave,
484
- leaveFrom: G["leave-from"],
485
- leaveTo: G["leave-to"],
486
- children: /* @__PURE__ */ De(
487
- tt,
488
- {
489
- ref: F,
490
- anchor: t,
491
- onMouseEnter: H,
492
- onMouseLeave: x,
493
- className: pe(
494
- G["menu-items"],
495
- W(),
464
+ className: fe(U.menu, d),
465
+ ...l,
466
+ children: ({ open: O, close: L }) => /* @__PURE__ */ De(nt, { children: [
467
+ o ? /* @__PURE__ */ re(
468
+ Ne,
469
+ {
470
+ as: "div",
471
+ ref: D,
472
+ onMouseEnter: G,
473
+ onMouseLeave: R,
474
+ className: fe(U["menu-button"], v),
475
+ children: typeof o == "function" ? o({
476
+ open: p,
477
+ close: () => K(L)
478
+ }) : o
479
+ }
480
+ ) : /* @__PURE__ */ re(
481
+ Ne,
482
+ {
483
+ ref: D,
484
+ onMouseEnter: G,
485
+ onMouseLeave: R,
486
+ onClick: m ? () => x(!p) : void 0,
487
+ className: fe(U["menu-button"], v),
488
+ children: a
489
+ }
490
+ ),
491
+ /* @__PURE__ */ re(
492
+ Kt,
493
+ {
494
+ show: m ? p : O || p,
495
+ as: ve,
496
+ enter: U.enter,
497
+ enterFrom: U["enter-from"],
498
+ enterTo: U["enter-to"],
499
+ leave: U.leave,
500
+ leaveFrom: U["leave-from"],
501
+ leaveTo: U["leave-to"],
502
+ children: /* @__PURE__ */ De(
503
+ tt,
504
+ {
505
+ ref: k,
506
+ anchor: t,
507
+ static: m,
508
+ onMouseEnter: G,
509
+ onMouseLeave: R,
510
+ className: fe(
511
+ U["menu-items"],
512
+ Z(),
513
+ {
514
+ [U["menu-items--black"]]: s === "black",
515
+ [U["menu-items-with-arrow"]]: u
516
+ },
517
+ $
518
+ ),
519
+ children: [
520
+ u && /* @__PURE__ */ re("div", { className: C() }),
521
+ r && /* @__PURE__ */ re(
522
+ at,
496
523
  {
497
- [G["menu-items--black"]]: d === "black",
498
- [G["menu-items-with-arrow"]]: a
499
- },
500
- h
524
+ isIconButton: !0,
525
+ iconName: "Close16px",
526
+ onClick: () => K(L),
527
+ clear: !0,
528
+ className: U["close-button"]
529
+ }
501
530
  ),
502
- children: [
503
- a && /* @__PURE__ */ re("div", { className: M() }),
504
- r && /* @__PURE__ */ re(
505
- at,
506
- {
507
- isIconButton: !0,
508
- iconName: "Close16px",
509
- onClick: q,
510
- clear: !0,
511
- className: G["close-button"]
512
- }
513
- ),
514
- /* @__PURE__ */ re(
515
- "div",
516
- {
517
- className: pe(
518
- G["menu-items-container"],
519
- m
520
- ),
521
- children: typeof e == "function" ? e({ close: q }) : e
522
- }
523
- )
524
- ]
525
- }
526
- )
527
- }
528
- )
529
- ] });
530
- }
531
+ /* @__PURE__ */ re(
532
+ "div",
533
+ {
534
+ className: fe(
535
+ U["menu-items-container"],
536
+ h
537
+ ),
538
+ children: typeof e == "function" ? e({ close: () => K(L) }) : e
539
+ }
540
+ )
541
+ ]
542
+ }
543
+ )
544
+ }
545
+ )
546
+ ] })
531
547
  }
532
548
  );
533
549
  }
@@ -8,7 +8,7 @@ type UseDropdownPositionProps = {
8
8
  buttonRef: RefObject<HTMLButtonElement>;
9
9
  panelRef: RefObject<HTMLDivElement>;
10
10
  initialPosition: string;
11
- isOpen: boolean;
11
+ isOpen?: boolean;
12
12
  arrow?: boolean;
13
13
  variant?: 'default' | 'black';
14
14
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mimir-ui-kit",
3
3
  "private": false,
4
- "version": "1.64.5",
4
+ "version": "1.65.0",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {