mimir-ui-kit 1.64.5 → 1.65.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.
@@ -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,171 +1,171 @@
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";
1
+ import { jsx as z, jsxs as De, Fragment as nt } from "react/jsx-runtime";
2
+ import { c as fe } from "../../index-DIxK0V-G.js";
3
+ import E, { createContext as ie, useState as J, useContext as re, useRef as A, useEffect as te, useMemo as q, Fragment as ve, useReducer as rt, createRef as ke, 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 ne, O as ae, n as de, m as ut, t as it, H as se, s as Fe, p as st, a as V, T as ct, $ as dt, b as pt, D as Be, I as ft, c as le } 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 ye, s as mt, l as Ke, e as bt, E as ht, R as Pt, v as yt, y as $t, x as Et, a as St, b as gt, m as Tt, f as wt, d as It, t as kt } from "../../portal-BnEqSZwo.js";
9
+ import { e as Ft } 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 Oe, H as xe, i as X, c as Ge, u as $e, 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";
14
+ import { b as Re, P as ue, F as ee, A as Nt, h as Lt, T as Me } from "../../focus-management-BAl0GmRk.js";
15
+ import { f as Ot } from "../../use-is-mounted-MBU4fiLr.js";
16
16
  function xt({ defaultContainers: e = [], portals: t, mainTreeNode: o } = {}) {
17
- let c = $e(o), f = S(() => {
18
- var h, m;
17
+ let c = ye(o), p = T(() => {
18
+ var P, m;
19
19
  let l = [];
20
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
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));
22
+ for (let r of (P = c == null ? void 0 : c.querySelectorAll("html > *, body > *")) != null ? P : []) 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((h) => r.contains(h)) || l.push(r));
23
23
  return l;
24
24
  });
25
- return { resolveContainers: f, contains: S((h) => f().some((m) => m.contains(h))) };
25
+ return { resolveContainers: p, contains: T((P) => p().some((m) => m.contains(P))) };
26
26
  }
27
- let je = ue(null);
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) => {
27
+ let je = ie(null);
28
+ function We({ children: e, node: t }) {
29
+ let [o, c] = J(null), p = Xe(t ?? o);
30
+ return E.createElement(je.Provider, { value: p }, e, p === null && E.createElement(he, { features: Pe.Hidden, ref: (P) => {
31
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)) {
32
+ if (P) {
33
+ for (let r of (l = (m = He(P)) == null ? void 0 : m.querySelectorAll("html > *, body > *")) != null ? l : []) if (r !== document.body && r !== document.head && r instanceof HTMLElement && r != null && r.contains(P)) {
34
34
  c(r);
35
35
  break;
36
36
  }
37
37
  }
38
38
  } }));
39
39
  }
40
- function We(e = null) {
40
+ function Xe(e = null) {
41
41
  var t;
42
- return (t = te(je)) != null ? t : e;
42
+ return (t = re(je)) != null ? t : e;
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 = A(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
57
  var Rt = ((e) => (e.Visible = "visible", e.Hidden = "hidden", e))(Rt || {});
58
- function Lt() {
59
- let e = te(Ee);
58
+ function _t() {
59
+ let e = re(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
- function _t() {
64
- let e = te(ge);
63
+ function At() {
64
+ let e = re(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) => {
74
+ let o = Fe(e), c = A([]), p = Ot(), P = st(), m = T((d, a = ae.Hidden) => {
75
75
  let s = c.current.findIndex(({ el: u }) => u === d);
76
- s !== -1 && (V(a, { [le.Unmount]() {
76
+ s !== -1 && (V(a, { [ae.Unmount]() {
77
77
  c.current.splice(s, 1);
78
- }, [le.Hidden]() {
78
+ }, [ae.Hidden]() {
79
79
  c.current[s].state = "hidden";
80
- } }), h.microTask(() => {
80
+ } }), P.microTask(() => {
81
81
  var u;
82
- !Se(c) && f.current && ((u = o.current) == null || u.call(o));
82
+ !ge(c) && p.current && ((u = o.current) == null || u.call(o));
83
83
  }));
84
- }), l = S((d) => {
84
+ }), l = T((d) => {
85
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) => {
86
+ return a ? a.state !== "visible" && (a.state = "visible") : c.current.push({ el: d, state: "visible" }), () => m(d, ae.Unmount);
87
+ }), r = A([]), h = A(Promise.resolve()), n = A({ enter: [], leave: [] }), f = T((d, a, s) => {
88
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) => {
89
89
  r.current.push(u);
90
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(() => {
91
+ Promise.all(n.current[a].map(([v, g]) => g)).then(() => u());
92
+ })]), a === "enter" ? h.current = h.current.then(() => t == null ? void 0 : t.wait.current).then(() => s(a)) : s(a);
93
+ }), $ = T((d, a, s) => {
94
+ Promise.all(n.current[a].splice(0).map(([u, v]) => v)).then(() => {
95
95
  var u;
96
96
  (u = r.current.shift()) == null || u();
97
97
  }).then(() => s(a));
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: c, register: l, unregister: m, onStart: f, onStop: $, wait: h, chains: n }), [l, m, c, f, $, n, h]);
100
100
  }
101
- let Qe = fe, Ve = ve.RenderStrategy;
102
- function At(e, t) {
101
+ let Qe = ve, Ve = me.RenderStrategy;
102
+ function Ct(e, t) {
103
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") {
108
- N("visible");
104
+ let { transition: p = !0, beforeEnter: P, afterEnter: m, beforeLeave: l, afterLeave: r, enter: h, enterFrom: n, enterTo: f, entered: $, leave: d, leaveFrom: a, leaveTo: s, ...u } = e, [v, g] = J(null), S = A(null), B = qe(e), D = ne(...B ? [S, t, g] : t === null ? [] : [t]), C = (o = u.unmount) == null || o ? ae.Unmount : ae.Hidden, { show: F, appear: N, initial: Z } = _t(), [M, L] = J(F ? "visible" : "hidden"), G = At(), { register: O, unregister: x } = G;
105
+ de(() => O(S), [O, S]), de(() => {
106
+ if (C === ae.Hidden && S.current) {
107
+ if (F && M !== "visible") {
108
+ L("visible");
109
109
  return;
110
110
  }
111
- return V(O, { hidden: () => B(g), visible: () => x(g) });
111
+ return V(M, { hidden: () => x(S), visible: () => O(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, O, x, F, C]);
114
+ let H = Ke();
115
+ de(() => {
116
+ if (B && H && M === "visible" && S.current === null) throw new Error("Did you forget to passthrough the `ref` to the actual DOM node?");
117
+ }, [S, M, H, B]);
118
+ let R = Z && !N, _ = N && F && Z, y = A(!1), i = Je(() => {
119
+ y.current || (L("hidden"), x(S));
120
+ }, G), b = T((W) => {
121
+ y.current = !0;
122
+ let oe = W ? "enter" : "leave";
123
+ i.onStart(S, oe, (pe) => {
124
+ pe === "enter" ? P == null || P() : pe === "leave" && (l == null || l());
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((W) => {
127
+ let oe = W ? "enter" : "leave";
128
+ y.current = !1, i.onStop(S, oe, (pe) => {
129
+ pe === "enter" ? m == null || m() : pe === "leave" && (r == null || r());
130
+ }), oe === "leave" && !ge(i) && (L("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
+ te(() => {
133
+ B && p || (b(F), w(F));
134
+ }, [F, B, p]);
135
+ let I = !(!p || !B || !H || R), [, k] = Oe(I, v, F, { start: b, end: w }), K = ut({ ref: D, className: ((c = it(u.className, _ && h, _ && n, k.enter && h, k.enter && k.closed && n, k.enter && !k.closed && f, k.leave && d, k.leave && !k.closed && a, k.leave && k.closed && s, !k.transition && F && $)) == null ? void 0 : c.trim()) || void 0, ...xe(k) }), j = 0;
136
+ return M === "visible" && (j |= X.Open), M === "hidden" && (j |= X.Closed), k.enter && (j |= X.Opening), k.leave && (j |= X.Closing), E.createElement(Se.Provider, { value: i }, E.createElement(Ge, { value: j }, se({ ourProps: K, 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]);
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(() => {
139
+ let { show: o, appear: c = !1, unmount: p = !0, ...P } = e, m = A(null), l = qe(e), r = ne(...l ? [m, t] : t === null ? [] : [t]);
140
+ Ke();
141
+ let h = $e();
142
+ if (o === void 0 && h !== null && (o = (h & X.Open) === X.Open), o === void 0) throw new Error("A <Transition /> is used but it is missing a `show={true | false}` prop.");
143
+ let [n, f] = J(o ? "visible" : "hidden"), $ = Je(() => {
144
+ o || f("hidden");
145
+ }), [d, a] = J(!0), s = A([o]);
146
+ de(() => {
147
147
  d !== !1 && s.current[s.current.length - 1] !== o && (s.current.push(o), a(!1));
148
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);
149
+ let u = q(() => ({ show: o, appear: c, initial: d }), [o, c, d]);
150
+ de(() => {
151
+ o ? f("visible") : !ge($) && m.current !== null && f("hidden");
152
+ }, [o, $]);
153
+ let v = { unmount: p }, g = T(() => {
154
+ var B;
155
+ d && a(!1), (B = e.beforeEnter) == null || B.call(e);
156
+ }), S = T(() => {
157
+ var B;
158
+ d && a(!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: $ }, E.createElement(Ee.Provider, { value: u }, se({ ourProps: { ...v, as: ve, children: E.createElement(Ye, { ref: r, ...v, ...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 o = re(Ee) !== null, c = $e() !== null;
164
+ return E.createElement(E.Fragment, null, !o && c ? E.createElement(Ne, { 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 Ne = Y(Dt), Ye = Y(Ct), Kt = Y(Ht), Gt = Object.assign(Ne, { Child: Kt, Root: Ne });
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
- let Xt = { 0: (e) => ({ ...e, popoverState: V(e.popoverState, { 0: 1, 1: 0 }), __demoMode: !1 }), 1(e) {
168
+ let Wt = { 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 };
170
170
  }, 2(e, t) {
171
171
  return e.button === t.button ? e : { ...e, button: t.button };
@@ -175,364 +175,409 @@ 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);
179
- Le.displayName = "PopoverContext";
178
+ } }, _e = ie(null);
179
+ _e.displayName = "PopoverContext";
180
180
  function Te(e) {
181
- let t = te(Le);
181
+ let t = re(_e);
182
182
  if (t === null) {
183
183
  let o = new Error(`<${e} /> is missing a parent <Popover /> component.`);
184
184
  throw Error.captureStackTrace && Error.captureStackTrace(o, Te), o;
185
185
  }
186
186
  return t;
187
187
  }
188
- let we = ue(null);
188
+ let we = ie(null);
189
189
  we.displayName = "PopoverAPIContext";
190
- function _e(e) {
191
- let t = te(we);
190
+ function Ae(e) {
191
+ let t = re(we);
192
192
  if (t === null) {
193
193
  let o = new Error(`<${e} /> is missing a parent <Popover /> component.`);
194
- throw Error.captureStackTrace && Error.captureStackTrace(o, _e), o;
194
+ throw Error.captureStackTrace && Error.captureStackTrace(o, Ae), o;
195
195
  }
196
196
  return t;
197
197
  }
198
- let Ae = ue(null);
199
- Ae.displayName = "PopoverGroupContext";
198
+ let Ce = ie(null);
199
+ Ce.displayName = "PopoverGroupContext";
200
200
  function ze() {
201
- return te(Ae);
201
+ return re(Ce);
202
202
  }
203
- let Ie = ue(null);
203
+ let Ie = ie(null);
204
204
  Ie.displayName = "PopoverPanelContext";
205
- function Wt() {
206
- return te(Ie);
205
+ function Xt() {
206
+ return re(Ie);
207
207
  }
208
208
  function Zt(e, t) {
209
- return V(t.type, Xt, e, t);
209
+ return V(t.type, Wt, e, t);
210
210
  }
211
211
  let qt = "div";
212
212
  function Jt(e, t) {
213
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)));
214
+ let { __demoMode: c = !1, ...p } = e, P = A(null), m = ne(t, ct((y) => {
215
+ P.current = y;
216
+ })), l = A([]), r = rt(Zt, { __demoMode: c, popoverState: c ? 0 : 1, buttons: l, button: null, buttonId: null, panel: null, panelId: null, beforePanelSentinel: ke(), afterPanelSentinel: ke(), afterButtonSentinel: ke() }), [{ popoverState: h, button: n, buttonId: f, panel: $, panelId: d, beforePanelSentinel: a, afterPanelSentinel: s, afterButtonSentinel: u }, v] = r, g = ye((o = P.current) != null ? o : n), S = q(() => {
217
+ if (!n || !$) return !1;
218
+ for (let K of document.querySelectorAll("body > *")) if (Number(K == null ? void 0 : K.contains(n)) ^ Number(K == null ? void 0 : K.contains($))) return !0;
219
+ let y = Re(), i = y.indexOf(n), b = (i + y.length - 1) % y.length, w = (i + 1) % y.length, I = y[b], k = y[w];
220
+ return !$.contains(I) && !$.contains(k);
221
+ }, [n, $]), B = Fe(f), D = Fe(d), C = q(() => ({ buttonId: B, panelId: D, close: () => v({ type: 1 }) }), [B, D, v]), F = ze(), N = F == null ? void 0 : F.registerPopover, Z = T(() => {
222
+ var y;
223
+ return (y = F == null ? void 0 : F.isFocusWithinPopoverGroup()) != null ? y : (g == null ? void 0 : g.activeElement) && ((n == null ? void 0 : n.contains(g.activeElement)) || ($ == null ? void 0 : $.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
+ te(() => N == null ? void 0 : N(C), [N, C]);
226
+ let [M, L] = bt(), G = Xe(n), O = xt({ mainTreeNode: G, portals: M, defaultContainers: [n, $] });
227
+ ht(g == null ? void 0 : g.defaultView, "focus", (y) => {
228
+ var i, b, w, I, k, K;
229
+ y.target !== window && y.target instanceof HTMLElement && h === 0 && (Z() || n && $ && (O.contains(y.target) || (b = (i = a.current) == null ? void 0 : i.contains) != null && b.call(i, y.target) || (I = (w = s.current) == null ? void 0 : w.contains) != null && I.call(w, y.target) || (K = (k = u.current) == null ? void 0 : k.contains) != null && K.call(k, y.target) || v({ type: 1 })));
230
+ }, !0), Pt(h === 0, O.resolveContainers, (y, i) => {
231
+ v({ type: 1 }), Nt(i, Lt.Loose) || (y.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((y) => {
234
+ v({ type: 1 });
235
+ let i = y ? y instanceof HTMLElement ? y : "current" in y && y.current instanceof HTMLElement ? y.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
+ }), H = q(() => ({ close: x, isPortalled: S }), [x, S]), R = q(() => ({ open: h === 0, close: x }), [h, x]), _ = { ref: m };
238
+ return E.createElement(We, { node: G }, E.createElement(yt, null, E.createElement(Ie.Provider, { value: null }, E.createElement(_e.Provider, { value: r }, E.createElement(we.Provider, { value: H }, E.createElement(Mt, { value: x }, E.createElement(Ge, { value: V(h, { 0: X.Open, 1: X.Closed }) }, E.createElement(L, null, se({ ourProps: _, theirProps: p, slot: R, 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(() => {
242
+ let o = be(), { id: c = `headlessui-popover-button-${o}`, disabled: p = !1, autoFocus: P = !1, ...m } = e, [l, r] = Te("Popover.Button"), { isPortalled: h } = Ae("Popover.Button"), n = A(null), f = `headlessui-focus-sentinel-${be()}`, $ = ze(), d = $ == null ? void 0 : $.closeOthers, a = Xt() !== null;
243
+ te(() => {
244
244
  if (!a) return r({ type: 3, buttonId: c }), () => {
245
245
  r({ type: 3, buttonId: null });
246
246
  };
247
247
  }, [a, c, r]);
248
- let [s] = X(() => Symbol()), u = ee(n, t, yt(), S((i) => {
248
+ let [s] = J(() => Symbol()), u = ne(n, t, $t(), T((i) => {
249
249
  if (!a) {
250
250
  if (i) l.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 b = l.buttons.current.indexOf(s);
253
+ b !== -1 && l.buttons.current.splice(b, 1);
254
254
  }
255
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 });
256
256
  }
257
- })), $ = ee(n, t), C = $e(n), g = S((i) => {
258
- var p, T, w;
257
+ })), v = ne(n, t), g = ye(n), S = T((i) => {
258
+ var b, w, I;
259
259
  if (a) {
260
260
  if (l.popoverState === 1) return;
261
261
  switch (i.key) {
262
- case oe.Space:
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();
262
+ case le.Space:
263
+ case le.Enter:
264
+ i.preventDefault(), (w = (b = i.target).click) == null || w.call(b), r({ type: 1 }), (I = l.button) == null || I.focus();
265
265
  break;
266
266
  }
267
267
  } else switch (i.key) {
268
- case oe.Space:
269
- case oe.Enter:
268
+ case le.Space:
269
+ case le.Enter:
270
270
  i.preventDefault(), i.stopPropagation(), l.popoverState === 1 && (d == null || d(l.buttonId)), r({ type: 0 });
271
271
  break;
272
- case oe.Escape:
272
+ case le.Escape:
273
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;
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
+ a || i.key === le.Space && i.preventDefault();
280
+ }), D = T((i) => {
281
+ var b, w;
282
+ Ue(i.currentTarget) || p || (a ? (r({ type: 1 }), (b = l.button) == null || b.focus()) : (i.preventDefault(), i.stopPropagation(), l.popoverState === 1 && (d == null || d(l.buttonId)), r({ type: 0 }), (w = l.button) == null || w.focus()));
283
+ }), C = 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(() => {
285
+ }), { isFocusVisible: F, focusProps: N } = dt({ autoFocus: P }), { isHovered: Z, hoverProps: M } = pt({ isDisabled: p }), { pressed: L, pressProps: G } = vt({ disabled: p }), O = l.popoverState === 0, x = q(() => ({ open: O, active: L || O, disabled: p, hover: Z, focus: F, autofocus: P }), [O, Z, F, L, p, P]), H = Ft(e, l.button), R = a ? Be({ ref: v, type: H, onKeyDown: S, onClick: D, disabled: p || void 0, autoFocus: P }, N, M, G) : Be({ ref: u, id: l.buttonId, type: H, "aria-expanded": l.popoverState === 0, "aria-controls": l.panel ? l.panelId : void 0, disabled: p || void 0, autoFocus: P, onKeyDown: S, onKeyUp: B, onClick: D, onMouseDown: C }, N, M, G), _ = Ze(), y = T(() => {
286
286
  let i = l.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 b() {
289
+ V(_.current, { [Q.Forwards]: () => ue(i, ee.First), [Q.Backwards]: () => ue(i, ee.Last) }) === Me.Error && ue(Re().filter((w) => w.dataset.headlessuiFocusGuard !== "true"), V(_.current, { [Q.Forwards]: ee.Next, [Q.Backwards]: ee.Previous }), { relativeTo: l.button });
290
290
  }
291
- p();
291
+ b();
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: R, theirProps: m, slot: x, defaultTag: Qt, name: "Popover.Button" }), O && !a && h && E.createElement(he, { id: f, ref: l.afterButtonSentinel, features: Pe.Focusable, "data-headlessui-focus-guard": !0, as: "button", type: "button", onFocus: y }));
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();
297
+ let o = be(), { id: c = `headlessui-popover-backdrop-${o}`, transition: p = !1, ...P } = e, [{ popoverState: m }, l] = Te("Popover.Backdrop"), [r, h] = J(null), n = ne(t, h), f = $e(), [$, d] = Oe(p, r, f !== null ? (f & X.Open) === X.Open : m === 0), a = T((v) => {
298
+ if (Ue(v.currentTarget)) return v.preventDefault();
299
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" });
300
+ }), s = q(() => ({ open: m === 0 }), [m]), u = { ref: n, id: c, "aria-hidden": !0, onClick: a, ...xe(d) };
301
+ return se({ ourProps: u, theirProps: P, slot: s, defaultTag: Yt, features: zt, visible: $, 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);
312
- Tt(N, n.button, () => {
313
- y({ type: 1 });
305
+ let o = be(), { id: c = `headlessui-popover-panel-${o}`, focus: p = !1, anchor: P, portal: m = !1, modal: l = !1, transition: r = !1, ...h } = e, [n, f] = Te("Popover.Panel"), { close: $, isPortalled: d } = Ae("Popover.Panel"), a = `headlessui-focus-sentinel-before-${o}`, s = `headlessui-focus-sentinel-after-${o}`, u = A(null), v = Et(P), [g, S] = St(v), B = gt();
306
+ v && (m = !0);
307
+ let [D, C] = J(null), F = ne(u, t, v ? g : null, T((b) => f({ type: 4, panel: b })), C), N = ye(u), Z = ft();
308
+ de(() => (f({ type: 5, panelId: c }), () => {
309
+ f({ type: 5, panelId: null });
310
+ }), [c, f]);
311
+ let M = $e(), [L, G] = Oe(r, D, M !== null ? (M & X.Open) === X.Open : n.popoverState === 0);
312
+ Tt(L, n.button, () => {
313
+ f({ 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) {
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();
315
+ let O = n.__demoMode ? !1 : l && L;
316
+ wt(O, N);
317
+ let x = T((b) => {
318
+ var w;
319
+ switch (b.key) {
320
+ case le.Escape:
321
+ if (n.popoverState !== 0 || !u.current || N != null && N.activeElement && !u.current.contains(N.activeElement)) return;
322
+ b.preventDefault(), b.stopPropagation(), f({ 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
+ te(() => {
327
+ var b;
328
+ e.static || n.popoverState === 1 && ((b = e.unmount) == null || b) && f({ type: 4, panel: null });
329
+ }, [n.popoverState, e.unmount, e.static, f]), te(() => {
330
+ if (n.__demoMode || !p || n.popoverState !== 0 || !u.current) return;
331
+ let b = N == null ? void 0 : N.activeElement;
332
+ u.current.contains(b) || ue(u.current, ee.First);
333
+ }, [n.__demoMode, p, u.current, n.popoverState]);
334
+ let H = q(() => ({ open: n.popoverState === 0, close: $ }), [n.popoverState, $]), R = Be(v ? B() : {}, { ref: F, id: c, onKeyDown: x, onBlur: p && n.popoverState === 0 ? (b) => {
335
+ var w, I, k, K, j;
336
+ let W = b.relatedTarget;
337
+ W && u.current && ((w = u.current) != null && w.contains(W) || (f({ type: 1 }), ((k = (I = n.beforePanelSentinel.current) == null ? void 0 : I.contains) != null && k.call(I, W) || (j = (K = n.afterPanelSentinel.current) == null ? void 0 : K.contains) != null && j.call(K, W)) && W.focus({ preventScroll: !0 })));
338
+ } : void 0, tabIndex: -1, style: { ...h.style, ...S, "--button-width": It(n.button, !0).width }, ...xe(G) }), _ = Ze(), y = T(() => {
339
+ let b = u.current;
340
+ if (!b) return;
341
+ function w() {
342
+ V(_.current, { [Q.Forwards]: () => {
343
+ var I;
344
+ ue(b, ee.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 b = u.current;
353
+ if (!b) return;
354
+ function w() {
355
+ V(_.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 = Re(), k = I.indexOf(n.button), K = I.slice(0, k + 1), j = [...I.slice(k + 1), ...K];
358
+ for (let W of j.slice()) if (W.dataset.headlessuiFocusGuard === "true" || D != null && D.contains(W)) {
359
+ let oe = j.indexOf(W);
360
+ oe !== -1 && j.splice(oe, 1);
361
361
  }
362
- ae(K, z.First, { sorted: !1 });
362
+ ue(j, ee.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
+ ue(b, ee.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: c }, E.createElement(we.Provider, { value: { close: $, isPortalled: d } }, E.createElement(kt, { enabled: m ? e.static || L : !1 }, L && d && E.createElement(he, { id: a, ref: n.beforePanelSentinel, features: Pe.Focusable, "data-headlessui-focus-guard": !0, as: "button", type: "button", onFocus: y }), se({ mergeRefs: Z, ourProps: R, theirProps: h, slot: H, defaultTag: en, features: tn, visible: L, name: "Popover.Panel" }), L && d && 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) => {
374
+ let o = A(null), c = ne(o, t), [p, P] = J([]), m = T((a) => {
375
+ P((s) => {
376
376
  let u = s.indexOf(a);
377
377
  if (u !== -1) {
378
- let $ = s.slice();
379
- return $.splice(u, 1), $;
378
+ let v = s.slice();
379
+ return v.splice(u, 1), v;
380
380
  }
381
381
  return s;
382
382
  });
383
- }), l = S((a) => (h((s) => [...s, a]), () => m(a))), r = S(() => {
383
+ }), l = T((a) => (P((s) => [...s, a]), () => m(a))), r = T(() => {
384
384
  var a;
385
385
  let s = He(o);
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 (a = o.current) != null && a.contains(u) ? !0 : p.some((v) => {
389
+ var g, S;
390
+ return ((g = s.getElementById(v.buttonId.current)) == null ? void 0 : g.contains(u)) || ((S = s.getElementById(v.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
+ }), h = T((a) => {
393
+ for (let s of p) s.buttonId.current !== a && s.close();
394
+ }), n = q(() => ({ registerPopover: l, unregisterPopover: m, isFocusWithinPopoverGroup: r, closeOthers: h }), [l, m, r, h]), f = q(() => ({}), []), $ = e, d = { ref: c };
395
+ return E.createElement(We, null, E.createElement(Ce.Provider, { value: n }, se({ ourProps: d, theirProps: $, slot: f, 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 });
398
- const In = 300, Fn = ot(
397
+ let ln = Y(Jt), Le = Y(Vt), an = Y(et), un = Y(et), tt = Y(nn), sn = Y(on), cn = Object.assign(ln, { Button: Le, Backdrop: un, Overlay: an, Panel: tt, Group: sn });
398
+ const kn = 300, Fn = ot(
399
399
  ({
400
400
  children: e,
401
401
  position: t = "bottom end",
402
402
  popoverProps: o,
403
403
  className: c,
404
- buttonClassName: f,
405
- panelClassName: h,
404
+ buttonClassName: p,
405
+ panelClassName: P,
406
406
  menuItemsClassName: m,
407
407
  buttonContent: l,
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: h = !1,
410
+ isOpen: n,
411
+ isControlled: f = !1,
412
+ onOpenChange: $,
413
+ autoCloseTimeout: d = 0,
414
+ triggerElement: a,
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
+ const [v, g] = J(
419
+ n ?? !1
420
+ ), [S, B] = J(!1), D = A(null), C = A(null), F = A(null), { getArrowClasses: N, getPositionClass: Z } = lt({
421
+ buttonRef: C,
418
422
  panelRef: F,
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: v || n,
425
+ arrow: u,
426
+ variant: s
427
+ }), M = ce(() => {
428
+ D.current && clearTimeout(D.current);
429
+ }, []), L = ce(() => {
430
+ d > 0 && !S && (D.current = setTimeout(() => {
431
+ g(!1), B(!0);
432
+ }, d));
433
+ }, [d, S]), G = ce(() => {
434
+ h && g(!0);
435
+ }, [h]), O = ce(
436
+ (R) => {
437
+ if (h) {
438
+ const _ = R.relatedTarget;
439
+ C.current && !C.current.contains(_) && F.current && !F.current.contains(_) && g(!1);
440
440
  }
441
441
  },
442
- [P]
442
+ [h]
443
+ ), x = ce(
444
+ (R) => {
445
+ f || g(R), $ == null || $(R);
446
+ },
447
+ [f, $]
448
+ ), H = ce(
449
+ (R) => {
450
+ R == null || R(), x(!1);
451
+ },
452
+ [x]
443
453
  );
444
- return /* @__PURE__ */ re(
454
+ return te(() => (v ? L() : M(), () => {
455
+ M();
456
+ }), [v, L, M]), te(() => {
457
+ f && g(n);
458
+ }, [n, f]), /* @__PURE__ */ z(
445
459
  cn,
446
460
  {
447
461
  as: "div",
448
- className: pe(G.menu, c),
462
+ className: fe(U.menu, c),
449
463
  ...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(),
496
- {
497
- [G["menu-items--black"]]: d === "black",
498
- [G["menu-items-with-arrow"]]: a
499
- },
500
- h
501
- ),
502
- children: [
503
- a && /* @__PURE__ */ re("div", { className: M() }),
504
- r && /* @__PURE__ */ re(
505
- at,
464
+ children: ({ open: R, close: _ }) => /* @__PURE__ */ De(
465
+ dn,
466
+ {
467
+ isOpen: v,
468
+ isControlled: f,
469
+ onClose: () => H(_),
470
+ buttonRef: C,
471
+ panelRef: F,
472
+ children: [
473
+ a ? /* @__PURE__ */ z(
474
+ Le,
475
+ {
476
+ as: "div",
477
+ ref: C,
478
+ onMouseEnter: G,
479
+ onMouseLeave: O,
480
+ className: fe(U["menu-button"], p),
481
+ children: typeof a == "function" ? a({
482
+ open: v,
483
+ close: () => H(_)
484
+ }) : a
485
+ }
486
+ ) : /* @__PURE__ */ z(
487
+ Le,
488
+ {
489
+ ref: C,
490
+ onMouseEnter: G,
491
+ onMouseLeave: O,
492
+ onClick: f ? () => x(!v) : void 0,
493
+ className: fe(U["menu-button"], p),
494
+ children: l
495
+ }
496
+ ),
497
+ /* @__PURE__ */ z(
498
+ Gt,
499
+ {
500
+ show: f ? v : R || v,
501
+ as: ve,
502
+ enter: U.enter,
503
+ enterFrom: U["enter-from"],
504
+ enterTo: U["enter-to"],
505
+ leave: U.leave,
506
+ leaveFrom: U["leave-from"],
507
+ leaveTo: U["leave-to"],
508
+ children: /* @__PURE__ */ De(
509
+ tt,
510
+ {
511
+ ref: F,
512
+ anchor: t,
513
+ static: f,
514
+ onMouseEnter: G,
515
+ onMouseLeave: O,
516
+ className: fe(
517
+ U["menu-items"],
518
+ Z(),
506
519
  {
507
- isIconButton: !0,
508
- iconName: "Close16px",
509
- onClick: q,
510
- clear: !0,
511
- className: G["close-button"]
512
- }
520
+ [U["menu-items--black"]]: s === "black",
521
+ [U["menu-items-with-arrow"]]: u
522
+ },
523
+ P
513
524
  ),
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
- }
525
+ children: [
526
+ u && /* @__PURE__ */ z("div", { className: N() }),
527
+ r && /* @__PURE__ */ z(
528
+ at,
529
+ {
530
+ isIconButton: !0,
531
+ iconName: "Close16px",
532
+ onClick: () => H(_),
533
+ clear: !0,
534
+ className: U["close-button"]
535
+ }
536
+ ),
537
+ /* @__PURE__ */ z(
538
+ "div",
539
+ {
540
+ className: fe(
541
+ U["menu-items-container"],
542
+ m
543
+ ),
544
+ children: typeof e == "function" ? e({ close: () => H(_) }) : e
545
+ }
546
+ )
547
+ ]
548
+ }
549
+ )
550
+ }
551
+ )
552
+ ]
553
+ }
554
+ )
531
555
  }
532
556
  );
533
557
  }
534
558
  );
559
+ function dn({
560
+ isControlled: e,
561
+ isOpen: t,
562
+ onClose: o,
563
+ buttonRef: c,
564
+ panelRef: p,
565
+ children: P
566
+ }) {
567
+ return te(() => {
568
+ if (!t || !e) return;
569
+ const m = (r) => {
570
+ console.log("handle key", r.key), r.key === "Escape" && (console.log("if if if handle key ===>", r.key), o == null || o());
571
+ }, l = (r) => {
572
+ const h = r.target, n = c.current && !c.current.contains(h), f = p.current && !p.current.contains(h);
573
+ n && f && (o == null || o());
574
+ };
575
+ return document.addEventListener("keydown", m), document.addEventListener("mousedown", l), () => {
576
+ document.removeEventListener("keydown", m), document.removeEventListener("mousedown", l);
577
+ };
578
+ }, [e, e, t, o]), /* @__PURE__ */ z(nt, { children: P });
579
+ }
535
580
  export {
536
- In as ANIMATION_DELAY,
581
+ kn as ANIMATION_DELAY,
537
582
  Fn as Dropdown
538
583
  };
@@ -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.1",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {