@eyesee/ui-components 0.1.0 → 0.1.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.
@@ -1,51 +1,53 @@
1
- const n = "_fullWidth_1l23j_1", t = "_button_1l23j_4", o = "_wrapper_1l23j_8", _ = "_buttonContent_1l23j_25", l = "_icon_1l23j_25", s = "_buttonArrow_1l23j_26", c = "_buttonText_1l23j_34", r = "_iconOnly_1l23j_58", u = "_buttonContentDropdown_1l23j_61", e = "_hasDropdown_1l23j_67", j = "_lg_1l23j_83", x = "_isIcon_1l23j_86", i = "_md_1l23j_90", a = "_sm_1l23j_97", b = "_xs_1l23j_104", d = "_xxs_1l23j_111", p = "_xxxs_1l23j_118", w = "_primary_1l23j_128", y = "_fill_1l23j_128", m = "_outline_1l23j_159", f = "_blank_1l23j_172", h = "_secondary_1l23j_219", C = "_neutral_1l23j_310", D = {
2
- fullWidth: n,
3
- button: t,
1
+ const t = "_fullWidth_1bpdq_1", n = "_button_1bpdq_4", o = "_wrapper_1bpdq_8", _ = "_buttonContent_1bpdq_25", s = "_icon_1bpdq_25", d = "_buttonArrow_1bpdq_26", b = "_buttonText_1bpdq_34", c = "_iconOnly_1bpdq_58", p = "_buttonContentDropdown_1bpdq_61", r = "_hasDropdown_1bpdq_67", e = "_lg_1bpdq_83", l = "_isIcon_1bpdq_86", u = "_md_1bpdq_90", i = "_sm_1bpdq_97", q = "_xs_1bpdq_104", x = "_xxs_1bpdq_111", a = "_xxxs_1bpdq_118", w = "_primary_1bpdq_128", y = "_fill_1bpdq_128", m = "_outline_1bpdq_159", f = "_blank_1bpdq_172", h = "_secondary_1bpdq_219", C = "_destructive_1bpdq_310", D = "_neutral_1bpdq_401", g = {
2
+ fullWidth: t,
3
+ button: n,
4
4
  wrapper: o,
5
5
  buttonContent: _,
6
- icon: l,
7
- buttonArrow: s,
8
- buttonText: c,
9
- iconOnly: r,
10
- buttonContentDropdown: u,
11
- hasDropdown: e,
12
- lg: j,
13
- isIcon: x,
14
- md: i,
15
- sm: a,
16
- xs: b,
17
- xxs: d,
18
- xxxs: p,
6
+ icon: s,
7
+ buttonArrow: d,
8
+ buttonText: b,
9
+ iconOnly: c,
10
+ buttonContentDropdown: p,
11
+ hasDropdown: r,
12
+ lg: e,
13
+ isIcon: l,
14
+ md: u,
15
+ sm: i,
16
+ xs: q,
17
+ xxs: x,
18
+ xxxs: a,
19
19
  primary: w,
20
20
  fill: y,
21
21
  outline: m,
22
22
  blank: f,
23
23
  secondary: h,
24
- neutral: C
24
+ destructive: C,
25
+ neutral: D
25
26
  };
26
27
  export {
27
28
  f as blank,
28
- t as button,
29
- s as buttonArrow,
29
+ n as button,
30
+ d as buttonArrow,
30
31
  _ as buttonContent,
31
- u as buttonContentDropdown,
32
- c as buttonText,
33
- D as default,
32
+ p as buttonContentDropdown,
33
+ b as buttonText,
34
+ g as default,
35
+ C as destructive,
34
36
  y as fill,
35
- n as fullWidth,
36
- e as hasDropdown,
37
- l as icon,
38
- r as iconOnly,
39
- x as isIcon,
40
- j as lg,
41
- i as md,
42
- C as neutral,
37
+ t as fullWidth,
38
+ r as hasDropdown,
39
+ s as icon,
40
+ c as iconOnly,
41
+ l as isIcon,
42
+ e as lg,
43
+ u as md,
44
+ D as neutral,
43
45
  m as outline,
44
46
  w as primary,
45
47
  h as secondary,
46
- a as sm,
48
+ i as sm,
47
49
  o as wrapper,
48
- b as xs,
49
- d as xxs,
50
- p as xxxs
50
+ q as xs,
51
+ x as xxs,
52
+ a as xxxs
51
53
  };
@@ -1,37 +1,40 @@
1
- import { jsx as u } from "react/jsx-runtime";
2
- import f from "clsx";
1
+ import { jsx as g } from "react/jsx-runtime";
2
+ import w from "clsx";
3
3
  import r from "./DropdownList.module.scss.js";
4
- const h = ({
4
+ const a = ({
5
5
  children: e,
6
- align: n = "start",
7
- className: s,
6
+ align: s = "start",
7
+ className: n,
8
8
  dir: o = "down",
9
9
  id: c,
10
- maxWidth: p = "320px",
11
- maxHeight: i,
12
- onLoadMore: t
10
+ listRef: p,
11
+ maxWidth: i = "320px",
12
+ maxHeight: m,
13
+ onLoadMore: t,
14
+ style: d
13
15
  }) => {
14
- const m = (d) => {
15
- const l = d.currentTarget;
16
+ const f = (u) => {
17
+ const l = u.currentTarget;
16
18
  l.scrollHeight - l.scrollTop - l.clientHeight < 48 && (t == null || t());
17
19
  };
18
- return /* @__PURE__ */ u(
20
+ return /* @__PURE__ */ g(
19
21
  "ul",
20
22
  {
23
+ ref: p,
21
24
  id: c,
22
- className: f(
25
+ className: w(
23
26
  r.dropdown,
24
27
  o === "up" && r.dropdownUp,
25
- n === "end" && r.alignEnd,
26
- s
28
+ s === "end" && r.alignEnd,
29
+ n
27
30
  ),
28
31
  role: "menu",
29
- style: { maxWidth: p, maxHeight: i },
30
- onScroll: m,
32
+ style: { maxWidth: i, maxHeight: m, ...d },
33
+ onScroll: f,
31
34
  children: e
32
35
  }
33
36
  );
34
37
  };
35
38
  export {
36
- h as DropdownList
39
+ a as DropdownList
37
40
  };
@@ -1,220 +1,250 @@
1
- import { jsx as n, jsxs as $, Fragment as pe } from "react/jsx-runtime";
2
- import { useState as z, useRef as me, useMemo as g } from "react";
3
- import V from "./SelectField.module.scss.js";
4
- import { createField as fe } from "../InputFieldContainer.js";
5
- import { InputFieldContent as M } from "../InputField/InputField.js";
6
- import { ChevronDownIcon as de } from "../../icons-v2/ChevronDownIcon.js";
7
- import { ChevronUpIcon as ue } from "../../icons-v2/ChevronUpIcon.js";
8
- import { LoadingIcon as ge } from "../../icons-v2/LoadingIcon.js";
9
- import { SearchIcon as Se } from "../../icons-v2/SearchIcon.js";
10
- import ve from "../../../hooks/useClickOutside.js";
11
- import { DropdownList as he } from "../../DropdownList/DropdownList.js";
12
- import { ExpandableItem as ye } from "../../ExpandableItem/ExpandableItem.js";
13
- import { renderOptionRow as xe } from "./selectOptionRow.js";
14
- import { SelectFieldTags as Ie } from "./SelectFieldTags.js";
15
- import { normalizeSelectOptions as Oe, getEffectiveSelectValue as we, getSelectedOptions as Te, getSelectFieldDisplayValue as Fe, filterOptionsByQuery as H, toArrayValue as Q, filterSectionsByQuery as Ce, getNextToggleAllValues as be, getResolvedListItemType as ke, emitSelectChange as De, isOptionSelected as Be, areAllOptionsSelected as Ee } from "./selectUtils.js";
16
- const Re = ({ isOpen: r }) => r ? /* @__PURE__ */ n(ue, {}) : /* @__PURE__ */ n(de, {}), Ae = ({
17
- withSections: r,
18
- sections: p,
19
- flatOptionList: s,
20
- searchValue: i,
21
- listItemType: F,
22
- value: l,
23
- selectAllLabel: v,
24
- onSelectOption: C,
25
- onToggleAll: h
1
+ import { jsx as n, jsxs as H, Fragment as ye } from "react/jsx-runtime";
2
+ import { useState as j, useRef as G, useLayoutEffect as xe, useEffect as Ie, useMemo as h } from "react";
3
+ import { createPortal as we } from "react-dom";
4
+ import Q from "./SelectField.module.scss.js";
5
+ import { createField as Oe } from "../InputFieldContainer.js";
6
+ import { InputFieldContent as J } from "../InputField/InputField.js";
7
+ import { ChevronDownIcon as Te } from "../../icons-v2/ChevronDownIcon.js";
8
+ import { ChevronUpIcon as be } from "../../icons-v2/ChevronUpIcon.js";
9
+ import { LoadingIcon as De } from "../../icons-v2/LoadingIcon.js";
10
+ import { SearchIcon as Ee } from "../../icons-v2/SearchIcon.js";
11
+ import { DropdownList as Fe } from "../../DropdownList/DropdownList.js";
12
+ import { ExpandableItem as Ce } from "../../ExpandableItem/ExpandableItem.js";
13
+ import { renderOptionRow as Re } from "./selectOptionRow.js";
14
+ import { SelectFieldTags as ke } from "./SelectFieldTags.js";
15
+ import { useSelectFieldDropdownPosition as Be } from "./useSelectFieldDropdownPosition.js";
16
+ import { normalizeSelectOptions as Le, getEffectiveSelectValue as Ae, getSelectedOptions as Ve, getSelectFieldDisplayValue as $e, filterOptionsByQuery as Y, toArrayValue as X, emitSelectChange as Me, filterSectionsByQuery as We, getNextToggleAllValues as ze, getResolvedListItemType as Ke, isOptionSelected as Ne, areAllOptionsSelected as je } from "./selectUtils.js";
17
+ const Qe = ({ isOpen: s }) => s ? /* @__PURE__ */ n(be, {}) : /* @__PURE__ */ n(Te, {}), He = ({
18
+ withSections: s,
19
+ sections: f,
20
+ flatOptionList: c,
21
+ searchValue: r,
22
+ listItemType: k,
23
+ value: i,
24
+ selectAllLabel: I,
25
+ onSelectOption: B,
26
+ onToggleAll: w
26
27
  }) => {
27
- const m = g(
28
- () => Ce(p, i),
29
- [p, i]
30
- ), y = g(
31
- () => H(s, i),
32
- [s, i]
33
- ), b = (t) => Be(l, t), S = (t, c = F, x = b, f = !1) => xe(t, c, x, C, h, f);
34
- return /* @__PURE__ */ $(pe, { children: [
35
- v ? S(
36
- { label: v },
28
+ const p = h(
29
+ () => We(f, r),
30
+ [f, r]
31
+ ), O = h(
32
+ () => Y(c, r),
33
+ [c, r]
34
+ ), L = (o) => Ne(i, o), y = (o, a = k, T = L, m = !1) => Re(o, a, T, B, w, m);
35
+ return /* @__PURE__ */ H(ye, { children: [
36
+ I ? y(
37
+ { label: I },
37
38
  "checkbox",
38
- () => Ee(l, s),
39
+ () => je(i, c),
39
40
  !0
40
41
  ) : null,
41
- r ? m.map((t) => /* @__PURE__ */ n(
42
- ye,
42
+ s ? p.map((o) => /* @__PURE__ */ n(
43
+ Ce,
43
44
  {
44
- title: t.sectionTitle,
45
+ title: o.sectionTitle,
45
46
  defaultOpen: !0,
46
47
  arrowPositionEnd: !0,
47
- children: t.options.map((c) => /* @__PURE__ */ n("div", { children: S(c) }, `${t.sectionTitle}-${String(c.value)}`))
48
+ children: o.options.map((a) => /* @__PURE__ */ n("div", { children: y(a) }, `${o.sectionTitle}-${String(a.value)}`))
48
49
  },
49
- t.sectionTitle
50
- )) : y.map((t) => /* @__PURE__ */ n("div", { children: S(t) }, String(t.value)))
50
+ o.sectionTitle
51
+ )) : O.map((o) => /* @__PURE__ */ n("div", { children: y(o) }, String(o.value)))
51
52
  ] });
52
- }, Ve = ({
53
- id: r,
54
- name: p,
55
- value: s,
56
- defaultValue: i,
57
- placeholder: F = "Select",
58
- disabled: l = !1,
59
- onChange: v = () => {
53
+ }, Pe = ({
54
+ id: s,
55
+ name: f,
56
+ value: c,
57
+ defaultValue: r,
58
+ placeholder: k = "Select",
59
+ disabled: i = !1,
60
+ onChange: I = () => {
60
61
  },
61
- ariaLabel: C,
62
- label: h,
63
- inputProps: m = {},
64
- options: y = [],
65
- size: b = "lg",
66
- startIcon: S,
67
- onEndIconClick: t,
68
- containerFieldClassName: c,
69
- multiSelect: x = !1,
70
- tags: f = !1,
71
- tagsWrap: U = !1,
72
- search: q = !1,
73
- onSearchChange: k = () => {
62
+ ariaLabel: B,
63
+ label: w,
64
+ inputProps: p = {},
65
+ options: O = [],
66
+ size: L = "lg",
67
+ startIcon: y,
68
+ onEndIconClick: o,
69
+ containerFieldClassName: a,
70
+ multiSelect: T = !1,
71
+ tags: m = !1,
72
+ tagsWrap: Z = !1,
73
+ search: _ = !1,
74
+ onSearchChange: A = () => {
74
75
  },
75
- onLoadMore: G,
76
- optionsLoading: J = !1,
77
- selectAllLabel: W = null,
78
- listItemType: X = null,
79
- dir: Y = "down",
80
- dropdownMaxHeight: Z
76
+ onLoadMore: ee,
77
+ optionsLoading: te = !1,
78
+ selectAllLabel: oe = null,
79
+ listItemType: ne = null,
80
+ dir: P = "down",
81
+ dropdownMaxHeight: ie
81
82
  }) => {
82
- const d = !!(x || f), _ = !!(q || f), P = !!(f && d), ee = ke({
83
- multiSelect: x,
84
- tags: f,
85
- listItemType: X
86
- }), [D, B] = z(!1), [I, O] = z(""), L = me(null), w = r ? `${r}-listbox` : void 0;
87
- ve(L, () => {
88
- B(!1), O("");
89
- });
83
+ const u = !!(T || m), re = !!(_ || m), le = !!(m && u), se = Ke({
84
+ multiSelect: T,
85
+ tags: m,
86
+ listItemType: ne
87
+ }), [g, V] = j(!1), [b, D] = j(""), E = G(null), $ = G(null), F = s ? `${s}-listbox` : void 0, [v, ce] = j(!1);
88
+ xe(() => {
89
+ var e;
90
+ ce(!!((e = E.current) != null && e.closest("#modal")));
91
+ }, []);
92
+ const l = Be({
93
+ open: g,
94
+ anchorRef: E,
95
+ dropdownRef: $,
96
+ dir: P,
97
+ fixed: v
98
+ }), ae = (l == null ? void 0 : l.resolvedDir) ?? P;
99
+ Ie(() => {
100
+ if (!g) return () => {
101
+ };
102
+ const e = (t) => {
103
+ var x, K;
104
+ (x = E.current) != null && x.contains(t.target) || v && ((K = $.current) != null && K.contains(t.target)) || (V(!1), D(""));
105
+ };
106
+ return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
107
+ }, [g, v]);
90
108
  const {
91
- withSections: te,
92
- sections: oe,
93
- options: a
94
- } = g(() => Oe(y), [y]), u = g(
95
- () => we(s, i),
96
- [s, i]
97
- ), K = g(
98
- () => Te(u, a),
99
- [u, a]
100
- ), ne = Fe(s, i, a), le = g(
101
- () => H(a, I),
102
- [a, I]
103
- ), E = (e) => {
104
- const o = d ? e : e[0] ?? "";
105
- De(v, o);
106
- }, N = (e) => {
107
- const o = Q(u), R = o.map((A) => String(A)), j = String(e), ae = R.includes(j) ? o.filter((A) => String(A) !== j) : [...o, e];
108
- E(d ? ae : [e]), d || (B(!1), O(""));
109
- }, ie = (e) => {
110
- if (l) return;
111
- const o = Q(u).filter((R) => String(R) !== String(e));
112
- E(o);
113
- }, re = P && K.length > 0 ? /* @__PURE__ */ n(
114
- Ie,
109
+ withSections: de,
110
+ sections: fe,
111
+ options: d
112
+ } = h(() => Le(O), [O]), S = h(
113
+ () => Ae(c, r),
114
+ [c, r]
115
+ ), U = h(
116
+ () => Ve(S, d),
117
+ [S, d]
118
+ ), pe = $e(c, r, d), me = h(
119
+ () => Y(d, b),
120
+ [d, b]
121
+ ), M = (e) => {
122
+ const t = u ? e : e[0] ?? "";
123
+ Me(I, t);
124
+ }, q = (e) => {
125
+ const t = X(S), R = t.map((N) => String(N)), x = String(e), he = R.includes(x) ? t.filter((N) => String(N) !== x) : [...t, e];
126
+ M(u ? he : [e]), u || (V(!1), D(""));
127
+ }, ue = (e) => {
128
+ if (i) return;
129
+ const t = X(S).filter((R) => String(R) !== String(e));
130
+ M(t);
131
+ }, ge = le && U.length > 0 ? /* @__PURE__ */ n(
132
+ ke,
115
133
  {
116
- options: K,
117
- wrap: U,
118
- disabled: l,
119
- onRemove: ie
134
+ options: U,
135
+ wrap: Z,
136
+ disabled: i,
137
+ onRemove: ue
120
138
  }
121
- ) : null, T = () => {
122
- l || (B((e) => !e), O(""));
123
- }, se = () => {
124
- d && E(be(u, a));
125
- }, ce = () => {
126
- if (t) {
127
- t();
139
+ ) : null, C = () => {
140
+ i || (V((e) => !e), D(""));
141
+ }, ve = () => {
142
+ u && M(ze(S, d));
143
+ }, Se = () => {
144
+ if (o) {
145
+ o();
128
146
  return;
129
147
  }
130
- T();
148
+ C();
131
149
  };
132
- return /* @__PURE__ */ $("div", { className: V.wrapper, ref: L, children: [
150
+ let W;
151
+ v && l ? W = {
152
+ position: "fixed",
153
+ zIndex: 9999,
154
+ top: l.top,
155
+ bottom: l.bottom,
156
+ left: l.left,
157
+ minWidth: l.minWidth
158
+ } : v && (W = { position: "fixed", visibility: "hidden" });
159
+ const z = g ? /* @__PURE__ */ H(
160
+ Fe,
161
+ {
162
+ id: F,
163
+ listRef: $,
164
+ dir: ae,
165
+ maxHeight: ie,
166
+ onLoadMore: ee,
167
+ style: W,
168
+ children: [
169
+ re ? /* @__PURE__ */ n("div", { className: Q.search, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ n(
170
+ J,
171
+ {
172
+ id: F ? `${F}-search` : void 0,
173
+ name: f ? `${f}-search` : void 0,
174
+ value: b,
175
+ placeholder: "Search",
176
+ disabled: i,
177
+ ariaLabel: "Search options",
178
+ size: "sm",
179
+ onChange: (e) => {
180
+ D(e.target.value), A == null || A(e.target.value);
181
+ },
182
+ containerFieldClassName: a,
183
+ startIcon: /* @__PURE__ */ n(Ee, {}),
184
+ inputProps: {
185
+ onKeyDown: (e) => {
186
+ if (e.key !== "Enter") return;
187
+ const t = me[0];
188
+ t && q(t.value);
189
+ }
190
+ }
191
+ }
192
+ ) }) : null,
193
+ te ? /* @__PURE__ */ n("span", { className: Q.spinning, children: /* @__PURE__ */ n(De, {}) }) : /* @__PURE__ */ n(
194
+ He,
195
+ {
196
+ withSections: de,
197
+ sections: fe,
198
+ flatOptionList: d,
199
+ searchValue: b,
200
+ listItemType: se,
201
+ value: S,
202
+ selectAllLabel: u ? oe : null,
203
+ onSelectOption: q,
204
+ onToggleAll: ve
205
+ }
206
+ )
207
+ ]
208
+ }
209
+ ) : null;
210
+ return /* @__PURE__ */ H("div", { className: Q.wrapper, ref: E, children: [
133
211
  /* @__PURE__ */ n(
134
- M,
212
+ J,
135
213
  {
136
- id: r,
137
- name: p,
138
- value: ne,
139
- placeholder: F,
140
- disabled: l,
214
+ id: s,
215
+ name: f,
216
+ value: pe,
217
+ placeholder: k,
218
+ disabled: i,
141
219
  onChange: () => {
142
220
  },
143
- startIcon: S,
144
- endIcon: Re({ isOpen: D }),
145
- onEndIconClick: ce,
146
- onFieldClick: T,
147
- onEnter: T,
148
- size: b,
149
- ariaLabel: C ?? (h ? void 0 : "select field"),
150
- label: h,
151
- containerFieldClassName: c,
152
- content: re,
221
+ startIcon: y,
222
+ endIcon: Qe({ isOpen: g }),
223
+ onEndIconClick: Se,
224
+ onFieldClick: C,
225
+ onEnter: C,
226
+ size: L,
227
+ ariaLabel: B ?? (w ? void 0 : "select field"),
228
+ label: w,
229
+ containerFieldClassName: a,
230
+ content: ge,
153
231
  inputProps: {
154
232
  readOnly: !0,
155
233
  role: "combobox",
156
- "aria-controls": w,
157
- "aria-expanded": D,
234
+ "aria-controls": F,
235
+ "aria-expanded": g,
158
236
  "aria-haspopup": "listbox",
159
- ...m,
237
+ ...p,
160
238
  onKeyDown: (e) => {
161
- var o;
162
- e.key === " " && !l && (e.preventDefault(), T()), (o = m.onKeyDown) == null || o.call(m, e);
239
+ var t;
240
+ e.key === " " && !i && (e.preventDefault(), C()), (t = p.onKeyDown) == null || t.call(p, e);
163
241
  }
164
242
  }
165
243
  }
166
244
  ),
167
- D ? /* @__PURE__ */ $(
168
- he,
169
- {
170
- id: w,
171
- dir: Y,
172
- maxHeight: Z,
173
- onLoadMore: G,
174
- children: [
175
- _ ? /* @__PURE__ */ n("div", { className: V.search, onClick: (e) => e.stopPropagation(), children: /* @__PURE__ */ n(
176
- M,
177
- {
178
- id: w ? `${w}-search` : void 0,
179
- name: p ? `${p}-search` : void 0,
180
- value: I,
181
- placeholder: "Search",
182
- disabled: l,
183
- ariaLabel: "Search options",
184
- size: "sm",
185
- onChange: (e) => {
186
- O(e.target.value), k == null || k(e.target.value);
187
- },
188
- containerFieldClassName: c,
189
- startIcon: /* @__PURE__ */ n(Se, {}),
190
- inputProps: {
191
- onKeyDown: (e) => {
192
- if (e.key !== "Enter") return;
193
- const o = le[0];
194
- o && N(o.value);
195
- }
196
- }
197
- }
198
- ) }) : null,
199
- J ? /* @__PURE__ */ n("span", { className: V.spinning, children: /* @__PURE__ */ n(ge, {}) }) : /* @__PURE__ */ n(
200
- Ae,
201
- {
202
- withSections: te,
203
- sections: oe,
204
- flatOptionList: a,
205
- searchValue: I,
206
- listItemType: ee,
207
- value: u,
208
- selectAllLabel: d ? W : null,
209
- onSelectOption: N,
210
- onToggleAll: se
211
- }
212
- )
213
- ]
214
- }
215
- ) : null
245
+ z && (v ? we(z, document.body) : z)
216
246
  ] });
217
- }, Ze = fe(Ve);
247
+ }, ct = Oe(Pe);
218
248
  export {
219
- Ze as SelectField
249
+ ct as SelectField
220
250
  };
@@ -0,0 +1,42 @@
1
+ import { useState as d, useLayoutEffect as w } from "react";
2
+ const f = 8, p = 320, g = () => parseFloat(getComputedStyle(document.documentElement).getPropertyValue("--spacing--2xs")) || 4;
3
+ function h(s, l, o, a) {
4
+ var n;
5
+ const c = s.current;
6
+ if (!c) return null;
7
+ const i = g(), e = c.getBoundingClientRect(), r = ((n = l.current) == null ? void 0 : n.getBoundingClientRect().height) ?? p, m = r + i + f;
8
+ let t = o;
9
+ o === "down" && window.innerHeight - e.bottom < m && e.top >= r + i ? t = "up" : o === "up" && e.top < m && (t = "down");
10
+ const u = {
11
+ resolvedDir: t,
12
+ left: e.left,
13
+ minWidth: e.width
14
+ };
15
+ return a && (t === "down" ? u.top = e.bottom + i : u.bottom = window.innerHeight - e.top + i), u;
16
+ }
17
+ function L({
18
+ open: s,
19
+ anchorRef: l,
20
+ dropdownRef: o,
21
+ dir: a = "down",
22
+ fixed: c = !1
23
+ }) {
24
+ const [i, e] = d(null);
25
+ return w(() => {
26
+ if (!s)
27
+ return e(null), () => {
28
+ };
29
+ let r = 0;
30
+ const m = () => e(h(l, o, a, c)), t = () => {
31
+ cancelAnimationFrame(r), r = requestAnimationFrame(m);
32
+ };
33
+ t(), window.addEventListener("resize", t), window.addEventListener("scroll", t, !0);
34
+ const u = o.current, n = u && typeof ResizeObserver < "u" ? new ResizeObserver(t) : null;
35
+ return n == null || n.observe(u), () => {
36
+ cancelAnimationFrame(r), window.removeEventListener("resize", t), window.removeEventListener("scroll", t, !0), n == null || n.disconnect();
37
+ };
38
+ }, [s, l, o, a, c]), i;
39
+ }
40
+ export {
41
+ L as useSelectFieldDropdownPosition
42
+ };