@acusti/dropdown 0.52.0 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Dropdown.js CHANGED
@@ -1,1045 +1,712 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
1
  import { c } from "react/compiler-runtime";
3
- import { SYSTEM_UI_FONT, Style } from "@acusti/styling";
4
2
  import useBoundingClientRect from "@acusti/use-bounding-client-rect";
5
3
  import useKeyboardEvents, { isEventTargetUsingKeyEvent } from "@acusti/use-keyboard-events";
6
4
  import clsx from "clsx";
7
- import { Children, useState, useId, useRef, useEffect, isValidElement, Fragment } from "react";
5
+ import { Children, Fragment, isValidElement, useEffect, useRef, useState } from "react";
8
6
  import { getBestMatch } from "@acusti/matchmaking";
9
- const ROOT_CLASS_NAME = "uktdropdown";
10
- const ROOT_SELECTOR = `.${ROOT_CLASS_NAME}`;
11
- const BODY_CLASS_NAME = `${ROOT_CLASS_NAME}-body`;
12
- const LABEL_CLASS_NAME = `${ROOT_CLASS_NAME}-label`;
13
- const LABEL_TEXT_CLASS_NAME = `${ROOT_CLASS_NAME}-label-text`;
14
- const TRIGGER_CLASS_NAME = `${ROOT_CLASS_NAME}-trigger`;
15
- const BODY_SELECTOR = `.${BODY_CLASS_NAME}`;
16
- const LABEL_SELECTOR = `.${LABEL_CLASS_NAME}`;
17
- const LABEL_TEXT_SELECTOR = `.${LABEL_TEXT_CLASS_NAME}`;
18
- const TRIGGER_SELECTOR = `.${TRIGGER_CLASS_NAME}`;
19
- const BODY_MAX_HEIGHT_VAR = "--uktdd-body-max-height";
20
- const BODY_MAX_WIDTH_VAR = "--uktdd-body-max-width";
21
- const STYLES = `
22
- :root {
23
- --uktdd-font-family: ${SYSTEM_UI_FONT};
24
- --uktdd-body-bg-color: #fff;
25
- --uktdd-body-bg-color-hover: rgb(105,162,249);
26
- --uktdd-body-color-hover: #fff;
27
- --uktdd-body-buffer: 10px;
28
- ${BODY_MAX_HEIGHT_VAR}: calc(100vh - var(--uktdd-body-buffer));
29
- ${BODY_MAX_WIDTH_VAR}: calc(100vw - var(--uktdd-body-buffer));
30
- --uktdd-body-pad-bottom: 9px;
31
- --uktdd-body-pad-left: 12px;
32
- --uktdd-body-pad-right: 12px;
33
- --uktdd-body-pad-top: 9px;
34
- --uktdd-label-pad-right: 10px;
35
- }
36
- ${ROOT_SELECTOR},
37
- ${TRIGGER_SELECTOR} {
38
- font-family: var(--uktdd-font-family);
39
- }
40
- ${ROOT_SELECTOR} {
41
- width: max-content;
42
- }
43
- ${ROOT_SELECTOR}.disabled {
44
- pointer-events: none;
45
- }
46
- ${ROOT_SELECTOR} > * {
47
- cursor: default;
48
- }
49
- ${LABEL_SELECTOR} {
50
- display: flex;
51
- align-items: center;
52
- }
53
- ${LABEL_TEXT_SELECTOR} {
54
- padding-right: var(--uktdd-label-pad-right);
55
- }
56
- ${BODY_SELECTOR} {
57
- box-sizing: border-box;
58
- position: absolute;
59
- top: anchor(bottom);
60
- left: anchor(left);
61
- bottom: auto;
62
- right: auto;
63
- position-try-fallbacks: --uktdd-top-left, --uktdd-bottom-right, --uktdd-top-right;
64
- min-height: 50px;
65
- max-height: var(${BODY_MAX_HEIGHT_VAR});
66
- min-width: min(50px, 100%);
67
- max-width: var(${BODY_MAX_WIDTH_VAR});
68
- overflow: auto;
69
- z-index: 2;
70
- padding: var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);
71
- background-color: var(--uktdd-body-bg-color);
72
- box-shadow: 0 8px 18px rgba(0,0,0,0.25);
73
- }
74
- @position-try --uktdd-top-left {
75
- bottom: anchor(top);
76
- left: anchor(left);
77
- top: auto;
78
- right: auto;
79
- }
80
- @position-try --uktdd-bottom-right {
81
- top: anchor(bottom);
82
- right: anchor(right);
83
- bottom: auto;
84
- left: auto;
85
- }
86
- @position-try --uktdd-top-right {
87
- bottom: anchor(top);
88
- right: anchor(right);
89
- top: auto;
90
- left: auto;
91
- }
92
- ${BODY_SELECTOR}.has-items {
93
- user-select: none;
94
- }
95
- ${BODY_SELECTOR} [data-ukt-active] {
96
- background-color: var(--uktdd-body-bg-color-hover);
97
- color: var(--uktdd-body-color-hover);
98
- }
99
- `;
7
+ import { jsx, jsxs } from "react/jsx-runtime";
8
+ var Dropdown_default = ":root{--uktdd-font-family:system-ui, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, Helvetica, Arial, sans-serif;--uktdd-body-bg-color:#fff;--uktdd-body-bg-color-hover:#69a2f9;--uktdd-body-color-hover:#fff;--uktdd-body-buffer:10px;--uktdd-body-max-height:calc(100vh - var(--uktdd-body-buffer));--uktdd-body-max-width:calc(100vw - var(--uktdd-body-buffer));--uktdd-body-pad-bottom:9px;--uktdd-body-pad-left:12px;--uktdd-body-pad-right:12px;--uktdd-body-pad-top:9px;--uktdd-body-min-width:min(50px, 100%);--uktdd-label-pad-right:10px}.uktdropdown,.uktdropdown-trigger{font-family:var(--uktdd-font-family)}.uktdropdown{anchor-scope:--uktdd-anchor;width:max-content}.uktdropdown.disabled{pointer-events:none}.uktdropdown>*{cursor:default}.uktdropdown>:first-child{anchor-name:--uktdd-anchor}.uktdropdown-label{align-items:center;display:flex}.uktdropdown-label-text{padding-right:var(--uktdd-label-pad-right)}.uktdropdown-body{box-sizing:border-box;position-anchor:--uktdd-anchor;top:anchor(bottom);left:anchor(left);position-try-fallbacks:--uktdd-top-left, --uktdd-bottom-right, --uktdd-top-right;min-height:50px;max-height:var(--uktdd-body-max-height);min-width:var(--uktdd-body-min-width);max-width:var(--uktdd-body-max-width);z-index:2;padding:var(--uktdd-body-pad-top) var(--uktdd-body-pad-right) var(--uktdd-body-pad-bottom) var(--uktdd-body-pad-left);background-color:var(--uktdd-body-bg-color);position:absolute;bottom:auto;right:auto;overflow:auto;box-shadow:0 8px 18px #00000040}.uktdropdown-body.has-items{-webkit-user-select:none;user-select:none}.uktdropdown-body [data-ukt-active]{background-color:var(--uktdd-body-bg-color-hover);color:var(--uktdd-body-color-hover)}@position-try --uktdd-top-left{bottom: anchor(top); left: anchor(left); top: auto; right: auto;}@position-try --uktdd-bottom-right{top: anchor(bottom); right: anchor(right); bottom: auto; left: auto;}@position-try --uktdd-top-right{bottom: anchor(top); right: anchor(right); top: auto; left: auto;}";
100
9
  const ITEM_SELECTOR = `[data-ukt-item], [data-ukt-value]`;
101
10
  const getItemElements = (dropdownElement) => {
102
- if (!dropdownElement) return null;
103
- const bodyElement = dropdownElement.querySelector(BODY_SELECTOR);
104
- if (!bodyElement) return null;
105
- let items = bodyElement.querySelectorAll(ITEM_SELECTOR);
106
- if (items.length) return items;
107
- items = bodyElement.children;
108
- while (items.length === 1) {
109
- if (items[0].children == null) break;
110
- items = items[0].children;
111
- }
112
- if (items.length === 1) {
113
- items = bodyElement.children;
114
- }
115
- return items;
11
+ if (!dropdownElement) return null;
12
+ const bodyElement = dropdownElement.querySelector(".uktdropdown-body");
13
+ if (!bodyElement) return null;
14
+ let items = bodyElement.querySelectorAll(ITEM_SELECTOR);
15
+ if (items.length) return items;
16
+ items = bodyElement.children;
17
+ while (items.length === 1) {
18
+ if (items[0].children == null) break;
19
+ items = items[0].children;
20
+ }
21
+ if (items.length === 1) items = bodyElement.children;
22
+ return items;
116
23
  };
117
24
  const getActiveItemElement = (dropdownElement) => {
118
- if (!dropdownElement) return null;
119
- return dropdownElement.querySelector("[data-ukt-active]");
25
+ if (!dropdownElement) return null;
26
+ return dropdownElement.querySelector("[data-ukt-active]");
120
27
  };
121
- const clearItemElementsState = (itemElements) => {
122
- itemElements.forEach((itemElement) => {
123
- if (itemElement.hasAttribute("data-ukt-active")) {
124
- delete itemElement.dataset.uktActive;
125
- }
126
- });
28
+ var clearItemElementsState = (itemElements) => {
29
+ itemElements.forEach((itemElement) => {
30
+ if (itemElement.hasAttribute("data-ukt-active")) delete itemElement.dataset.uktActive;
31
+ });
127
32
  };
128
- const setActiveItem = ({
129
- dropdownElement,
130
- element,
131
- event,
132
- index,
133
- indexAddend,
134
- isExactMatch,
135
- onActiveItem,
136
- text
137
- }) => {
138
- const items = getItemElements(dropdownElement);
139
- if (!items) return;
140
- const itemElements = Array.from(items);
141
- if (!itemElements.length) return;
142
- const lastIndex = itemElements.length - 1;
143
- const currentActiveIndex = itemElements.findIndex((itemElement) => itemElement.hasAttribute("data-ukt-active"));
144
- let nextActiveIndex = currentActiveIndex;
145
- if (typeof index === "number") {
146
- nextActiveIndex = index < 0 ? itemElements.length + index : index;
147
- }
148
- if (element) {
149
- nextActiveIndex = itemElements.findIndex((itemElement) => itemElement === element);
150
- } else if (typeof indexAddend === "number") {
151
- if (currentActiveIndex === -1 && indexAddend === -1) {
152
- nextActiveIndex = lastIndex;
153
- } else {
154
- nextActiveIndex += indexAddend;
155
- }
156
- nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));
157
- } else if (typeof text === "string") {
158
- if (!text) {
159
- clearItemElementsState(itemElements);
160
- return;
161
- }
162
- const itemTexts = itemElements.map((itemElement) => itemElement.innerText);
163
- if (isExactMatch) {
164
- const textToCompare = text.toLowerCase();
165
- nextActiveIndex = itemTexts.findIndex((itemText) => itemText.toLowerCase().startsWith(textToCompare));
166
- if (nextActiveIndex === -1) {
167
- clearItemElementsState(itemElements);
168
- }
169
- } else {
170
- const bestMatch = getBestMatch({
171
- items: itemTexts,
172
- text
173
- });
174
- nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);
175
- }
176
- }
177
- const nextActiveItem = items[nextActiveIndex];
178
- if (nextActiveItem == null || nextActiveIndex === currentActiveIndex) return;
179
- clearItemElementsState(itemElements);
180
- nextActiveItem.setAttribute("data-ukt-active", "");
181
- const label = nextActiveItem.innerText;
182
- const value = nextActiveItem.dataset.uktValue ?? label;
183
- onActiveItem?.({
184
- element: nextActiveItem,
185
- event,
186
- label,
187
- value
188
- });
189
- let {
190
- parentElement
191
- } = nextActiveItem;
192
- let scrollableParent = null;
193
- while (!scrollableParent && parentElement && parentElement !== dropdownElement) {
194
- const isScrollable = parentElement.scrollHeight > parentElement.clientHeight + 15;
195
- if (isScrollable) {
196
- scrollableParent = parentElement;
197
- } else {
198
- parentElement = parentElement.parentElement;
199
- }
200
- }
201
- if (scrollableParent) {
202
- const parentRect = scrollableParent.getBoundingClientRect();
203
- const itemRect = nextActiveItem.getBoundingClientRect();
204
- const isAboveTop = itemRect.top < parentRect.top;
205
- const isBelowBottom = itemRect.bottom > parentRect.bottom;
206
- if (isAboveTop || isBelowBottom) {
207
- let {
208
- scrollTop
209
- } = scrollableParent;
210
- if (isAboveTop) {
211
- scrollTop -= parentRect.top - itemRect.top;
212
- } else {
213
- scrollTop += itemRect.bottom - parentRect.bottom;
214
- }
215
- scrollableParent.scrollTop = scrollTop;
216
- }
217
- }
33
+ const setActiveItem = ({ dropdownElement, element, event, index, indexAddend, isExactMatch, onActiveItem, text }) => {
34
+ const items = getItemElements(dropdownElement);
35
+ if (!items) return;
36
+ const itemElements = Array.from(items);
37
+ if (!itemElements.length) return;
38
+ const lastIndex = itemElements.length - 1;
39
+ const currentActiveIndex = itemElements.findIndex((itemElement) => itemElement.hasAttribute("data-ukt-active"));
40
+ let nextActiveIndex = currentActiveIndex;
41
+ if (typeof index === "number") nextActiveIndex = index < 0 ? itemElements.length + index : index;
42
+ if (element) nextActiveIndex = itemElements.findIndex((itemElement) => itemElement === element);
43
+ else if (typeof indexAddend === "number") {
44
+ if (currentActiveIndex === -1 && indexAddend === -1) nextActiveIndex = lastIndex;
45
+ else nextActiveIndex += indexAddend;
46
+ nextActiveIndex = Math.max(0, Math.min(nextActiveIndex, lastIndex));
47
+ } else if (typeof text === "string") {
48
+ if (!text) {
49
+ clearItemElementsState(itemElements);
50
+ return;
51
+ }
52
+ const itemTexts = itemElements.map((itemElement) => itemElement.innerText);
53
+ if (isExactMatch) {
54
+ const textToCompare = text.toLowerCase();
55
+ nextActiveIndex = itemTexts.findIndex((itemText) => itemText.toLowerCase().startsWith(textToCompare));
56
+ if (nextActiveIndex === -1) clearItemElementsState(itemElements);
57
+ } else {
58
+ const bestMatch = getBestMatch({
59
+ items: itemTexts,
60
+ text
61
+ });
62
+ nextActiveIndex = itemTexts.findIndex((itemText) => itemText === bestMatch);
63
+ }
64
+ }
65
+ const nextActiveItem = items[nextActiveIndex];
66
+ if (nextActiveItem == null || nextActiveIndex === currentActiveIndex) return;
67
+ clearItemElementsState(itemElements);
68
+ nextActiveItem.setAttribute("data-ukt-active", "");
69
+ const label = nextActiveItem.innerText;
70
+ const value = nextActiveItem.dataset.uktValue ?? label;
71
+ onActiveItem?.({
72
+ element: nextActiveItem,
73
+ event,
74
+ label,
75
+ value
76
+ });
77
+ let { parentElement } = nextActiveItem;
78
+ let scrollableParent = null;
79
+ while (!scrollableParent && parentElement && parentElement !== dropdownElement) if (parentElement.scrollHeight > parentElement.clientHeight + 15) scrollableParent = parentElement;
80
+ else parentElement = parentElement.parentElement;
81
+ if (scrollableParent) {
82
+ const parentRect = scrollableParent.getBoundingClientRect();
83
+ const itemRect = nextActiveItem.getBoundingClientRect();
84
+ const isAboveTop = itemRect.top < parentRect.top;
85
+ const isBelowBottom = itemRect.bottom > parentRect.bottom;
86
+ if (isAboveTop || isBelowBottom) {
87
+ let { scrollTop } = scrollableParent;
88
+ if (isAboveTop) scrollTop -= parentRect.top - itemRect.top;
89
+ else scrollTop += itemRect.bottom - parentRect.bottom;
90
+ scrollableParent.scrollTop = scrollTop;
91
+ }
92
+ }
218
93
  };
219
- const CHILDREN_ERROR = "@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.";
220
- const CLICKABLE_SELECTOR = 'button, a[href], input[type="button"], input[type="submit"]';
221
- const TEXT_INPUT_SELECTOR = "input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea";
94
+ var CHILDREN_ERROR = "@acusti/dropdown requires either 1 child (the dropdown body) or 2 children: the dropdown trigger and the dropdown body.";
95
+ var CLICKABLE_SELECTOR = "button, a[href], input[type=\"button\"], input[type=\"submit\"]";
96
+ var TEXT_INPUT_SELECTOR = "input:not([type=radio]):not([type=checkbox]):not([type=range]),textarea";
222
97
  function Dropdown(t0) {
223
- const $ = c(102);
224
- const {
225
- allowCreate,
226
- allowEmpty: t1,
227
- children,
228
- className,
229
- disabled,
230
- hasItems: t2,
231
- isOpenOnMount,
232
- isSearchable,
233
- keepOpenOnSubmit: t3,
234
- label,
235
- minHeightBody: t4,
236
- minWidthBody: t5,
237
- name,
238
- onActiveItem,
239
- onClick,
240
- onClose,
241
- onMouseDown,
242
- onMouseUp,
243
- onOpen,
244
- onSubmitItem,
245
- placeholder,
246
- style: styleFromProps,
247
- tabIndex,
248
- value
249
- } = t0;
250
- const allowEmpty = t1 === void 0 ? true : t1;
251
- const hasItems = t2 === void 0 ? true : t2;
252
- const keepOpenOnSubmit = t3 === void 0 ? !hasItems : t3;
253
- const minHeightBody = t4 === void 0 ? 30 : t4;
254
- const minWidthBody = t5 === void 0 ? 100 : t5;
255
- const childrenCount = Children.count(children);
256
- if (childrenCount !== 1 && childrenCount !== 2) {
257
- if (childrenCount === 0) {
258
- throw new Error(CHILDREN_ERROR + " Received no children.");
259
- }
260
- console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);
261
- }
262
- let trigger;
263
- if (childrenCount > 1) {
264
- trigger = children[0];
265
- }
266
- const [isOpen, setIsOpen] = useState(isOpenOnMount ?? false);
267
- const [isOpening, setIsOpening] = useState(!isOpenOnMount);
268
- const [dropdownElement, setDropdownElement] = useState(null);
269
- const [dropdownBodyElement, setDropdownBodyElement] = useState(null);
270
- const id = useId();
271
- const inputElementRef = useRef(null);
272
- const closingTimerRef = useRef(null);
273
- const isOpeningTimerRef = useRef(null);
274
- const currentInputMethodRef = useRef("mouse");
275
- const clearEnteredCharactersTimerRef = useRef(null);
276
- const enteredCharactersRef = useRef("");
277
- const mouseDownPositionRef = useRef(null);
278
- const allowCreateRef = useRef(allowCreate);
279
- const allowEmptyRef = useRef(allowEmpty);
280
- const hasItemsRef = useRef(hasItems);
281
- const isOpenRef = useRef(isOpen);
282
- const isOpeningRef = useRef(isOpening);
283
- const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);
284
- const onCloseRef = useRef(onClose);
285
- const onOpenRef = useRef(onOpen);
286
- const onSubmitItemRef = useRef(onSubmitItem);
287
- const valueRef = useRef(value);
288
- let t6;
289
- let t7;
290
- if ($[0] !== allowCreate || $[1] !== allowEmpty || $[2] !== hasItems || $[3] !== isOpen || $[4] !== isOpening || $[5] !== keepOpenOnSubmit || $[6] !== onClose || $[7] !== onOpen || $[8] !== onSubmitItem || $[9] !== value) {
291
- t6 = () => {
292
- allowCreateRef.current = allowCreate;
293
- allowEmptyRef.current = allowEmpty;
294
- hasItemsRef.current = hasItems;
295
- isOpenRef.current = isOpen;
296
- isOpeningRef.current = isOpening;
297
- keepOpenOnSubmitRef.current = keepOpenOnSubmit;
298
- onCloseRef.current = onClose;
299
- onOpenRef.current = onOpen;
300
- onSubmitItemRef.current = onSubmitItem;
301
- valueRef.current = value;
302
- };
303
- t7 = [allowCreate, allowEmpty, hasItems, isOpen, isOpening, keepOpenOnSubmit, onClose, onOpen, onSubmitItem, value];
304
- $[0] = allowCreate;
305
- $[1] = allowEmpty;
306
- $[2] = hasItems;
307
- $[3] = isOpen;
308
- $[4] = isOpening;
309
- $[5] = keepOpenOnSubmit;
310
- $[6] = onClose;
311
- $[7] = onOpen;
312
- $[8] = onSubmitItem;
313
- $[9] = value;
314
- $[10] = t6;
315
- $[11] = t7;
316
- } else {
317
- t6 = $[10];
318
- t7 = $[11];
319
- }
320
- useEffect(t6, t7);
321
- const isMountedRef = useRef(false);
322
- let t8;
323
- let t9;
324
- if ($[12] !== isOpen) {
325
- t8 = () => {
326
- if (!isMountedRef.current) {
327
- isMountedRef.current = true;
328
- if (isOpenRef.current && onOpenRef.current) {
329
- onOpenRef.current();
330
- }
331
- return;
332
- }
333
- if (isOpen && onOpenRef.current) {
334
- onOpenRef.current();
335
- } else {
336
- if (!isOpen && onCloseRef.current) {
337
- onCloseRef.current();
338
- }
339
- }
340
- };
341
- t9 = [isOpen];
342
- $[12] = isOpen;
343
- $[13] = t8;
344
- $[14] = t9;
345
- } else {
346
- t8 = $[13];
347
- t9 = $[14];
348
- }
349
- useEffect(t8, t9);
350
- let t10;
351
- if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
352
- t10 = () => {
353
- setIsOpen(false);
354
- setIsOpening(false);
355
- mouseDownPositionRef.current = null;
356
- if (closingTimerRef.current) {
357
- clearTimeout(closingTimerRef.current);
358
- closingTimerRef.current = null;
359
- }
360
- };
361
- $[15] = t10;
362
- } else {
363
- t10 = $[15];
364
- }
365
- const closeDropdown = t10;
366
- let t11;
367
- if ($[16] !== dropdownElement) {
368
- t11 = (event) => {
369
- if (isOpenRef.current && !keepOpenOnSubmitRef.current) {
370
- closingTimerRef.current = setTimeout(closeDropdown, 90);
371
- }
372
- if (!hasItemsRef.current) {
373
- return;
374
- }
375
- const element = getActiveItemElement(dropdownElement);
376
- if (!element && !allowCreateRef.current) {
377
- if (!allowEmptyRef.current) {
378
- return;
379
- }
380
- if (inputElementRef.current?.value) {
381
- return;
382
- }
383
- }
384
- let itemLabel = element?.innerText ?? "";
385
- if (inputElementRef.current) {
386
- if (!element) {
387
- itemLabel = inputElementRef.current.value;
388
- } else {
389
- inputElementRef.current.value = itemLabel;
390
- }
391
- if (inputElementRef.current === inputElementRef.current.ownerDocument.activeElement) {
392
- inputElementRef.current.blur();
393
- }
394
- }
395
- const nextValue = element?.dataset.uktValue ?? itemLabel;
396
- if (valueRef.current && valueRef.current === nextValue) {
397
- return;
398
- }
399
- if (element) {
400
- const eventTarget = event.target;
401
- if (element.matches(CLICKABLE_SELECTOR)) {
402
- if (element !== eventTarget && !element.contains(eventTarget)) {
403
- element.click();
404
- }
405
- } else {
406
- const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);
407
- if (clickableElements.length === 1) {
408
- const clickableElement = clickableElements[0];
409
- if (clickableElement !== eventTarget && !clickableElement.contains(eventTarget)) {
410
- clickableElement.click();
411
- }
412
- }
413
- }
414
- }
415
- onSubmitItemRef.current?.({
416
- element,
417
- event,
418
- label: itemLabel,
419
- value: nextValue
420
- });
421
- };
422
- $[16] = dropdownElement;
423
- $[17] = t11;
424
- } else {
425
- t11 = $[17];
426
- }
427
- const handleSubmitItem = t11;
428
- let t12;
429
- if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
430
- t12 = (t132) => {
431
- const {
432
- clientX,
433
- clientY
434
- } = t132;
435
- currentInputMethodRef.current = "mouse";
436
- const initialPosition = mouseDownPositionRef.current;
437
- if (!initialPosition) {
438
- return;
439
- }
440
- if (Math.abs(initialPosition.clientX - clientX) < 12 && Math.abs(initialPosition.clientY - clientY) < 12) {
441
- return;
442
- }
443
- setIsOpening(false);
444
- };
445
- $[18] = t12;
446
- } else {
447
- t12 = $[18];
448
- }
449
- const handleMouseMove = t12;
450
- let t13;
451
- if ($[19] !== dropdownElement || $[20] !== onActiveItem) {
452
- t13 = (event_0) => {
453
- if (!hasItemsRef.current) {
454
- return;
455
- }
456
- if (currentInputMethodRef.current !== "mouse") {
457
- return;
458
- }
459
- if (!dropdownElement) {
460
- return;
461
- }
462
- const itemElements = getItemElements(dropdownElement);
463
- if (!itemElements) {
464
- return;
465
- }
466
- const eventTarget_0 = event_0.target;
467
- const item = eventTarget_0.closest(ITEM_SELECTOR);
468
- const element_0 = item ?? eventTarget_0;
469
- for (const itemElement of itemElements) {
470
- if (itemElement === element_0) {
471
- setActiveItem({
472
- dropdownElement,
473
- element: element_0,
474
- event: event_0,
475
- onActiveItem
476
- });
477
- return;
478
- }
479
- }
480
- };
481
- $[19] = dropdownElement;
482
- $[20] = onActiveItem;
483
- $[21] = t13;
484
- } else {
485
- t13 = $[21];
486
- }
487
- const handleMouseOver = t13;
488
- let t14;
489
- if ($[22] !== dropdownElement) {
490
- t14 = (event_1) => {
491
- if (!hasItemsRef.current) {
492
- return;
493
- }
494
- const activeItem = getActiveItemElement(dropdownElement);
495
- if (!activeItem) {
496
- return;
497
- }
498
- const eventRelatedTarget = event_1.relatedTarget;
499
- if (activeItem !== event_1.target || activeItem.contains(eventRelatedTarget)) {
500
- return;
501
- }
502
- delete activeItem.dataset.uktActive;
503
- };
504
- $[22] = dropdownElement;
505
- $[23] = t14;
506
- } else {
507
- t14 = $[23];
508
- }
509
- const handleMouseOut = t14;
510
- let t15;
511
- if ($[24] !== onMouseDown) {
512
- t15 = (event_2) => {
513
- if (onMouseDown) {
514
- onMouseDown(event_2);
515
- }
516
- if (isOpenRef.current) {
517
- return;
518
- }
519
- setIsOpen(true);
520
- setIsOpening(true);
521
- mouseDownPositionRef.current = {
522
- clientX: event_2.clientX,
523
- clientY: event_2.clientY
524
- };
525
- isOpeningTimerRef.current = setTimeout(() => {
526
- setIsOpening(false);
527
- isOpeningTimerRef.current = null;
528
- }, 1e3);
529
- };
530
- $[24] = onMouseDown;
531
- $[25] = t15;
532
- } else {
533
- t15 = $[25];
534
- }
535
- const handleMouseDown = t15;
536
- let t16;
537
- if ($[26] !== handleSubmitItem || $[27] !== onMouseUp) {
538
- t16 = (event_3) => {
539
- if (onMouseUp) {
540
- onMouseUp(event_3);
541
- }
542
- if (isOpeningRef.current || !isOpenRef.current || closingTimerRef.current) {
543
- return;
544
- }
545
- const eventTarget_1 = event_3.target;
546
- if (!eventTarget_1.closest(BODY_SELECTOR)) {
547
- if (!isOpeningRef.current && inputElementRef.current !== eventTarget_1.ownerDocument.activeElement) {
548
- closeDropdown();
549
- }
550
- return;
551
- }
552
- if (!hasItemsRef.current) {
553
- return;
554
- }
555
- handleSubmitItem(event_3);
556
- };
557
- $[26] = handleSubmitItem;
558
- $[27] = onMouseUp;
559
- $[28] = t16;
560
- } else {
561
- t16 = $[28];
562
- }
563
- const handleMouseUp = t16;
564
- let t17;
565
- if ($[29] !== dropdownElement || $[30] !== handleSubmitItem || $[31] !== onActiveItem) {
566
- t17 = (event_4) => {
567
- const {
568
- altKey,
569
- ctrlKey,
570
- key,
571
- metaKey
572
- } = event_4;
573
- const eventTarget_2 = event_4.target;
574
- if (!dropdownElement) {
575
- return;
576
- }
577
- const onEventHandled = () => {
578
- event_4.stopPropagation();
579
- event_4.preventDefault();
580
- currentInputMethodRef.current = "keyboard";
581
- };
582
- const isEventTargetingDropdown = dropdownElement.contains(eventTarget_2);
583
- if (!isOpenRef.current) {
584
- if (!isEventTargetingDropdown) {
585
- return;
586
- }
587
- if (key === " " || key === "Enter" || hasItemsRef.current && (key === "ArrowUp" || key === "ArrowDown")) {
588
- onEventHandled();
589
- setIsOpen(true);
590
- }
591
- return;
592
- }
593
- const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event_4);
594
- if (hasItemsRef.current && !isTargetUsingKeyEvents) {
595
- let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);
596
- if (!isEditingCharacters && enteredCharactersRef.current) {
597
- isEditingCharacters = key === " " || key === "Backspace";
598
- }
599
- if (isEditingCharacters) {
600
- onEventHandled();
601
- if (key === "Backspace") {
602
- enteredCharactersRef.current = enteredCharactersRef.current.slice(0, -1);
603
- } else {
604
- enteredCharactersRef.current = enteredCharactersRef.current + key;
605
- }
606
- setActiveItem({
607
- dropdownElement,
608
- event: event_4,
609
- isExactMatch: allowCreateRef.current,
610
- onActiveItem,
611
- text: enteredCharactersRef.current
612
- });
613
- if (clearEnteredCharactersTimerRef.current) {
614
- clearTimeout(clearEnteredCharactersTimerRef.current);
615
- }
616
- clearEnteredCharactersTimerRef.current = setTimeout(() => {
617
- enteredCharactersRef.current = "";
618
- clearEnteredCharactersTimerRef.current = null;
619
- }, 1500);
620
- return;
621
- }
622
- }
623
- if (key === "Enter" || key === " " && !inputElementRef.current) {
624
- onEventHandled();
625
- handleSubmitItem(event_4);
626
- return;
627
- }
628
- if (key === "Escape" || isEventTargetingDropdown && key === " " && !hasItemsRef.current) {
629
- if (hasItemsRef.current || !isTargetUsingKeyEvents) {
630
- closeDropdown();
631
- }
632
- return;
633
- }
634
- if (hasItemsRef.current) {
635
- if (key === "ArrowUp") {
636
- onEventHandled();
637
- if (altKey || metaKey) {
638
- setActiveItem({
639
- dropdownElement,
640
- event: event_4,
641
- index: 0,
642
- onActiveItem
643
- });
644
- } else {
645
- setActiveItem({
646
- dropdownElement,
647
- event: event_4,
648
- indexAddend: -1,
649
- onActiveItem
650
- });
651
- }
652
- return;
653
- }
654
- if (key === "ArrowDown") {
655
- onEventHandled();
656
- if (altKey || metaKey) {
657
- setActiveItem({
658
- dropdownElement,
659
- event: event_4,
660
- index: -1,
661
- onActiveItem
662
- });
663
- } else {
664
- setActiveItem({
665
- dropdownElement,
666
- event: event_4,
667
- indexAddend: 1,
668
- onActiveItem
669
- });
670
- }
671
- return;
672
- }
673
- }
674
- };
675
- $[29] = dropdownElement;
676
- $[30] = handleSubmitItem;
677
- $[31] = onActiveItem;
678
- $[32] = t17;
679
- } else {
680
- t17 = $[32];
681
- }
682
- const handleKeyDown = t17;
683
- let t18;
684
- if ($[33] !== handleKeyDown) {
685
- t18 = {
686
- ignoreUsedKeyboardEvents: false,
687
- onKeyDown: handleKeyDown
688
- };
689
- $[33] = handleKeyDown;
690
- $[34] = t18;
691
- } else {
692
- t18 = $[34];
693
- }
694
- useKeyboardEvents(t18);
695
- let t19;
696
- if ($[35] !== isOpenOnMount || $[36] !== onActiveItem) {
697
- t19 = (ref) => {
698
- setDropdownElement(ref);
699
- if (!ref) {
700
- return;
701
- }
702
- const {
703
- ownerDocument
704
- } = ref;
705
- let inputElement = inputElementRef.current;
706
- if (!inputElement && ref.firstElementChild) {
707
- if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) {
708
- inputElement = ref.firstElementChild;
709
- } else {
710
- inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);
711
- }
712
- inputElementRef.current = inputElement;
713
- }
714
- const handleGlobalMouseDown = (t202) => {
715
- const {
716
- target
717
- } = t202;
718
- const eventTarget_3 = target;
719
- if (!ref.contains(eventTarget_3)) {
720
- closeDropdown();
721
- }
722
- };
723
- const handleGlobalMouseUp = (t212) => {
724
- const {
725
- target: target_0
726
- } = t212;
727
- if (!isOpenRef.current || closingTimerRef.current) {
728
- return;
729
- }
730
- if (isOpeningRef.current) {
731
- setIsOpening(false);
732
- if (isOpeningTimerRef.current) {
733
- clearTimeout(isOpeningTimerRef.current);
734
- isOpeningTimerRef.current = null;
735
- }
736
- return;
737
- }
738
- const eventTarget_4 = target_0;
739
- if (!ref.contains(eventTarget_4)) {
740
- closeDropdown();
741
- }
742
- };
743
- const handleGlobalFocusIn = (t222) => {
744
- const {
745
- target: target_1
746
- } = t222;
747
- if (!isOpenRef.current) {
748
- return;
749
- }
750
- const eventTarget_5 = target_1;
751
- if (ref.contains(eventTarget_5) || eventTarget_5.contains(ref)) {
752
- return;
753
- }
754
- closeDropdown();
755
- };
756
- document.addEventListener("focusin", handleGlobalFocusIn);
757
- document.addEventListener("mousedown", handleGlobalMouseDown);
758
- document.addEventListener("mouseup", handleGlobalMouseUp);
759
- if (ownerDocument !== document) {
760
- ownerDocument.addEventListener("focusin", handleGlobalFocusIn);
761
- ownerDocument.addEventListener("mousedown", handleGlobalMouseDown);
762
- ownerDocument.addEventListener("mouseup", handleGlobalMouseUp);
763
- }
764
- if (isOpenOnMount) {
765
- ref.focus();
766
- }
767
- const handleInput = (event_5) => {
768
- if (!isOpenRef.current) {
769
- setIsOpen(true);
770
- }
771
- const input = event_5.target;
772
- const isDeleting = enteredCharactersRef.current.length > input.value.length;
773
- enteredCharactersRef.current = input.value;
774
- if (isDeleting && input.value.length && getActiveItemElement(ref)) {
775
- return;
776
- }
777
- setActiveItem({
778
- dropdownElement: ref,
779
- event: event_5,
780
- isExactMatch: allowCreateRef.current,
781
- onActiveItem,
782
- text: enteredCharactersRef.current
783
- });
784
- };
785
- if (inputElement) {
786
- inputElement.addEventListener("input", handleInput);
787
- }
788
- return () => {
789
- document.removeEventListener("focusin", handleGlobalFocusIn);
790
- document.removeEventListener("mousedown", handleGlobalMouseDown);
791
- document.removeEventListener("mouseup", handleGlobalMouseUp);
792
- if (ownerDocument !== document) {
793
- ownerDocument.removeEventListener("focusin", handleGlobalFocusIn);
794
- ownerDocument.removeEventListener("mousedown", handleGlobalMouseDown);
795
- ownerDocument.removeEventListener("mouseup", handleGlobalMouseUp);
796
- }
797
- if (inputElement) {
798
- inputElement.removeEventListener("input", handleInput);
799
- }
800
- };
801
- };
802
- $[35] = isOpenOnMount;
803
- $[36] = onActiveItem;
804
- $[37] = t19;
805
- } else {
806
- t19 = $[37];
807
- }
808
- const handleRef = t19;
809
- if (!isValidElement(trigger)) {
810
- if (isSearchable) {
811
- const t202 = value ?? "";
812
- let t212;
813
- if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
814
- t212 = () => setIsOpen(true);
815
- $[38] = t212;
816
- } else {
817
- t212 = $[38];
818
- }
819
- let t222;
820
- if ($[39] !== disabled || $[40] !== name || $[41] !== placeholder || $[42] !== t202 || $[43] !== tabIndex) {
821
- t222 = /* @__PURE__ */ jsx("input", { autoComplete: "off", className: TRIGGER_CLASS_NAME, defaultValue: t202, disabled, name, onFocus: t212, placeholder, ref: inputElementRef, tabIndex, type: "text" });
822
- $[39] = disabled;
823
- $[40] = name;
824
- $[41] = placeholder;
825
- $[42] = t202;
826
- $[43] = tabIndex;
827
- $[44] = t222;
828
- } else {
829
- t222 = $[44];
830
- }
831
- trigger = t222;
832
- } else {
833
- let t202;
834
- if ($[45] !== trigger) {
835
- t202 = /* @__PURE__ */ jsx("button", { className: TRIGGER_CLASS_NAME, tabIndex: 0, type: "button", children: trigger });
836
- $[45] = trigger;
837
- $[46] = t202;
838
- } else {
839
- t202 = $[46];
840
- }
841
- trigger = t202;
842
- }
843
- }
844
- if (label) {
845
- let t202;
846
- if ($[47] !== label) {
847
- t202 = /* @__PURE__ */ jsx("div", { className: LABEL_TEXT_CLASS_NAME, children: label });
848
- $[47] = label;
849
- $[48] = t202;
850
- } else {
851
- t202 = $[48];
852
- }
853
- let t212;
854
- if ($[49] !== t202 || $[50] !== trigger) {
855
- t212 = /* @__PURE__ */ jsxs("label", { className: LABEL_CLASS_NAME, children: [
856
- t202,
857
- trigger
858
- ] });
859
- $[49] = t202;
860
- $[50] = trigger;
861
- $[51] = t212;
862
- } else {
863
- t212 = $[51];
864
- }
865
- trigger = t212;
866
- }
867
- const dropdownRect = useBoundingClientRect(dropdownElement);
868
- const dropdownBodyRect = useBoundingClientRect(dropdownBodyElement);
869
- let t20;
870
- if ($[52] !== dropdownBodyElement) {
871
- t20 = getBoundingAncestor(dropdownBodyElement);
872
- $[52] = dropdownBodyElement;
873
- $[53] = t20;
874
- } else {
875
- t20 = $[53];
876
- }
877
- const boundingElement = t20;
878
- const boundingElementRect = useBoundingClientRect(boundingElement);
879
- let maxHeight;
880
- let maxWidth;
881
- if (dropdownBodyRect.top != null && dropdownRect.top != null && boundingElementRect.top != null) {
882
- const maxHeightUp = dropdownBodyRect.bottom - boundingElementRect.top;
883
- const maxHeightDown = boundingElementRect.bottom - dropdownBodyRect.top;
884
- let t212;
885
- if ($[54] !== dropdownBodyRect.top || $[55] !== dropdownRect.top || $[56] !== maxHeightDown || $[57] !== maxHeightUp) {
886
- t212 = Math.round(dropdownBodyRect.top > dropdownRect.top ? maxHeightDown : maxHeightUp);
887
- $[54] = dropdownBodyRect.top;
888
- $[55] = dropdownRect.top;
889
- $[56] = maxHeightDown;
890
- $[57] = maxHeightUp;
891
- $[58] = t212;
892
- } else {
893
- t212 = $[58];
894
- }
895
- maxHeight = t212;
896
- const maxWidthLeft = dropdownBodyRect.right - boundingElementRect.left;
897
- const maxWidthRight = boundingElementRect.right - dropdownBodyRect.left;
898
- let t222;
899
- if ($[59] !== dropdownBodyRect.left || $[60] !== dropdownRect.left || $[61] !== maxWidthLeft || $[62] !== maxWidthRight) {
900
- t222 = Math.round(dropdownBodyRect.left > dropdownRect.left ? maxWidthRight : maxWidthLeft);
901
- $[59] = dropdownBodyRect.left;
902
- $[60] = dropdownRect.left;
903
- $[61] = maxWidthLeft;
904
- $[62] = maxWidthRight;
905
- $[63] = t222;
906
- } else {
907
- t222 = $[63];
908
- }
909
- maxWidth = t222;
910
- }
911
- let t21;
912
- if ($[64] !== maxHeight || $[65] !== minHeightBody) {
913
- t21 = maxHeight != null && maxHeight > minHeightBody ? {
914
- [BODY_MAX_HEIGHT_VAR]: `calc(${maxHeight}px - var(--uktdd-body-buffer))`
915
- } : null;
916
- $[64] = maxHeight;
917
- $[65] = minHeightBody;
918
- $[66] = t21;
919
- } else {
920
- t21 = $[66];
921
- }
922
- let t22;
923
- if ($[67] !== maxWidth || $[68] !== minWidthBody) {
924
- t22 = maxWidth != null && maxWidth > minWidthBody ? {
925
- [BODY_MAX_WIDTH_VAR]: `calc(${maxWidth}px - var(--uktdd-body-buffer))`
926
- } : null;
927
- $[67] = maxWidth;
928
- $[68] = minWidthBody;
929
- $[69] = t22;
930
- } else {
931
- t22 = $[69];
932
- }
933
- let t23;
934
- if ($[70] !== styleFromProps || $[71] !== t21 || $[72] !== t22) {
935
- t23 = {
936
- ...styleFromProps,
937
- ...t21,
938
- ...t22
939
- };
940
- $[70] = styleFromProps;
941
- $[71] = t21;
942
- $[72] = t22;
943
- $[73] = t23;
944
- } else {
945
- t23 = $[73];
946
- }
947
- const style = t23;
948
- const anchorStyles = `[data-ukt-id="${id}"] > :first-child {
949
- anchor-name: --uktdd-anchor${id};
950
- }
951
- [data-ukt-id="${id}"] ${BODY_SELECTOR} {
952
- position-anchor: --uktdd-anchor${id};
953
- }`;
954
- let t24;
955
- if ($[74] === Symbol.for("react.memo_cache_sentinel")) {
956
- t24 = /* @__PURE__ */ jsx(Style, { href: "@acusti/dropdown/Dropdown", children: STYLES });
957
- $[74] = t24;
958
- } else {
959
- t24 = $[74];
960
- }
961
- const t25 = `@acusti/dropdown/Dropdown/${id}`;
962
- let t26;
963
- if ($[75] !== anchorStyles || $[76] !== t25) {
964
- t26 = /* @__PURE__ */ jsx(Style, { href: t25, children: anchorStyles });
965
- $[75] = anchorStyles;
966
- $[76] = t25;
967
- $[77] = t26;
968
- } else {
969
- t26 = $[77];
970
- }
971
- let t27;
972
- if ($[78] !== className || $[79] !== disabled || $[80] !== isOpen || $[81] !== isSearchable) {
973
- t27 = clsx(ROOT_CLASS_NAME, className, {
974
- disabled,
975
- "is-open": isOpen,
976
- "is-searchable": isSearchable
977
- });
978
- $[78] = className;
979
- $[79] = disabled;
980
- $[80] = isOpen;
981
- $[81] = isSearchable;
982
- $[82] = t27;
983
- } else {
984
- t27 = $[82];
985
- }
986
- let t28;
987
- if ($[83] !== children || $[84] !== childrenCount || $[85] !== isOpen) {
988
- t28 = isOpen ? /* @__PURE__ */ jsx("div", { className: BODY_CLASS_NAME, ref: setDropdownBodyElement, children: childrenCount > 1 ? children[1] : children }) : null;
989
- $[83] = children;
990
- $[84] = childrenCount;
991
- $[85] = isOpen;
992
- $[86] = t28;
993
- } else {
994
- t28 = $[86];
995
- }
996
- let t29;
997
- if ($[87] !== handleMouseDown || $[88] !== handleMouseOut || $[89] !== handleMouseOver || $[90] !== handleMouseUp || $[91] !== handleRef || $[92] !== id || $[93] !== onClick || $[94] !== style || $[95] !== t27 || $[96] !== t28 || $[97] !== trigger) {
998
- t29 = /* @__PURE__ */ jsxs("div", { className: t27, "data-ukt-id": id, onClick, onMouseDown: handleMouseDown, onMouseMove: handleMouseMove, onMouseOut: handleMouseOut, onMouseOver: handleMouseOver, onMouseUp: handleMouseUp, ref: handleRef, style, children: [
999
- trigger,
1000
- t28
1001
- ] });
1002
- $[87] = handleMouseDown;
1003
- $[88] = handleMouseOut;
1004
- $[89] = handleMouseOver;
1005
- $[90] = handleMouseUp;
1006
- $[91] = handleRef;
1007
- $[92] = id;
1008
- $[93] = onClick;
1009
- $[94] = style;
1010
- $[95] = t27;
1011
- $[96] = t28;
1012
- $[97] = trigger;
1013
- $[98] = t29;
1014
- } else {
1015
- t29 = $[98];
1016
- }
1017
- let t30;
1018
- if ($[99] !== t26 || $[100] !== t29) {
1019
- t30 = /* @__PURE__ */ jsxs(Fragment, { children: [
1020
- t24,
1021
- t26,
1022
- t29
1023
- ] });
1024
- $[99] = t26;
1025
- $[100] = t29;
1026
- $[101] = t30;
1027
- } else {
1028
- t30 = $[101];
1029
- }
1030
- return t30;
98
+ const $ = c(89);
99
+ const { allowCreate, allowEmpty: t1, children, className, disabled, hasItems: t2, isOpenOnMount, isSearchable, keepOpenOnSubmit: t3, label, minHeightBody: t4, minWidthBody, name, onActiveItem, onClick, onClose, onMouseDown, onMouseUp, onOpen, onSubmitItem, placeholder, style: styleFromProps, tabIndex, value } = t0;
100
+ const allowEmpty = t1 === void 0 ? true : t1;
101
+ const hasItems = t2 === void 0 ? true : t2;
102
+ const keepOpenOnSubmit = t3 === void 0 ? !hasItems : t3;
103
+ const minHeightBody = t4 === void 0 ? 30 : t4;
104
+ const childrenCount = Children.count(children);
105
+ if (childrenCount !== 1 && childrenCount !== 2) {
106
+ if (childrenCount === 0) throw new Error(CHILDREN_ERROR + " Received no children.");
107
+ console.error(`${CHILDREN_ERROR} Received ${childrenCount} children.`);
108
+ }
109
+ let trigger;
110
+ if (childrenCount > 1) trigger = children[0];
111
+ const [isOpen, setIsOpen] = useState(isOpenOnMount ?? false);
112
+ const [isOpening, setIsOpening] = useState(!isOpenOnMount);
113
+ const [dropdownElement, setDropdownElement] = useState(null);
114
+ const [dropdownBodyElement, setDropdownBodyElement] = useState(null);
115
+ const inputElementRef = useRef(null);
116
+ const closingTimerRef = useRef(null);
117
+ const isOpeningTimerRef = useRef(null);
118
+ const currentInputMethodRef = useRef("mouse");
119
+ const clearEnteredCharactersTimerRef = useRef(null);
120
+ const enteredCharactersRef = useRef("");
121
+ const mouseDownPositionRef = useRef(null);
122
+ const allowCreateRef = useRef(allowCreate);
123
+ const allowEmptyRef = useRef(allowEmpty);
124
+ const hasItemsRef = useRef(hasItems);
125
+ const isOpenRef = useRef(isOpen);
126
+ const isOpeningRef = useRef(isOpening);
127
+ const keepOpenOnSubmitRef = useRef(keepOpenOnSubmit);
128
+ const onCloseRef = useRef(onClose);
129
+ const onOpenRef = useRef(onOpen);
130
+ const onSubmitItemRef = useRef(onSubmitItem);
131
+ const valueRef = useRef(value);
132
+ let t5;
133
+ let t6;
134
+ if ($[0] !== allowCreate || $[1] !== allowEmpty || $[2] !== hasItems || $[3] !== isOpen || $[4] !== isOpening || $[5] !== keepOpenOnSubmit || $[6] !== onClose || $[7] !== onOpen || $[8] !== onSubmitItem || $[9] !== value) {
135
+ t5 = () => {
136
+ allowCreateRef.current = allowCreate;
137
+ allowEmptyRef.current = allowEmpty;
138
+ hasItemsRef.current = hasItems;
139
+ isOpenRef.current = isOpen;
140
+ isOpeningRef.current = isOpening;
141
+ keepOpenOnSubmitRef.current = keepOpenOnSubmit;
142
+ onCloseRef.current = onClose;
143
+ onOpenRef.current = onOpen;
144
+ onSubmitItemRef.current = onSubmitItem;
145
+ valueRef.current = value;
146
+ };
147
+ t6 = [
148
+ allowCreate,
149
+ allowEmpty,
150
+ hasItems,
151
+ isOpen,
152
+ isOpening,
153
+ keepOpenOnSubmit,
154
+ onClose,
155
+ onOpen,
156
+ onSubmitItem,
157
+ value
158
+ ];
159
+ $[0] = allowCreate;
160
+ $[1] = allowEmpty;
161
+ $[2] = hasItems;
162
+ $[3] = isOpen;
163
+ $[4] = isOpening;
164
+ $[5] = keepOpenOnSubmit;
165
+ $[6] = onClose;
166
+ $[7] = onOpen;
167
+ $[8] = onSubmitItem;
168
+ $[9] = value;
169
+ $[10] = t5;
170
+ $[11] = t6;
171
+ } else {
172
+ t5 = $[10];
173
+ t6 = $[11];
174
+ }
175
+ useEffect(t5, t6);
176
+ const isMountedRef = useRef(false);
177
+ let t7;
178
+ let t8;
179
+ if ($[12] !== isOpen) {
180
+ t7 = () => {
181
+ if (!isMountedRef.current) {
182
+ isMountedRef.current = true;
183
+ if (isOpenRef.current && onOpenRef.current) onOpenRef.current();
184
+ return;
185
+ }
186
+ if (isOpen && onOpenRef.current) onOpenRef.current();
187
+ else if (!isOpen && onCloseRef.current) onCloseRef.current();
188
+ };
189
+ t8 = [isOpen];
190
+ $[12] = isOpen;
191
+ $[13] = t7;
192
+ $[14] = t8;
193
+ } else {
194
+ t7 = $[13];
195
+ t8 = $[14];
196
+ }
197
+ useEffect(t7, t8);
198
+ let t9;
199
+ if ($[15] === Symbol.for("react.memo_cache_sentinel")) {
200
+ t9 = () => {
201
+ setIsOpen(false);
202
+ setIsOpening(false);
203
+ mouseDownPositionRef.current = null;
204
+ if (closingTimerRef.current != null) {
205
+ clearTimeout(closingTimerRef.current);
206
+ closingTimerRef.current = null;
207
+ }
208
+ };
209
+ $[15] = t9;
210
+ } else t9 = $[15];
211
+ const closeDropdown = t9;
212
+ let t10;
213
+ if ($[16] !== dropdownElement) {
214
+ t10 = (event) => {
215
+ if (isOpenRef.current && !keepOpenOnSubmitRef.current) closingTimerRef.current = setTimeout(closeDropdown, 90);
216
+ if (!hasItemsRef.current) return;
217
+ const element = getActiveItemElement(dropdownElement);
218
+ if (!element && !allowCreateRef.current) {
219
+ if (!allowEmptyRef.current) return;
220
+ if (inputElementRef.current?.value) return;
221
+ }
222
+ let itemLabel = element?.innerText ?? "";
223
+ if (inputElementRef.current) {
224
+ if (!element) itemLabel = inputElementRef.current.value;
225
+ else inputElementRef.current.value = itemLabel;
226
+ if (inputElementRef.current === inputElementRef.current.ownerDocument.activeElement) inputElementRef.current.blur();
227
+ }
228
+ const nextValue = element?.dataset.uktValue ?? itemLabel;
229
+ if (valueRef.current && valueRef.current === nextValue) return;
230
+ if (element) {
231
+ const eventTarget = event.target;
232
+ if (element.matches(CLICKABLE_SELECTOR)) {
233
+ if (element !== eventTarget && !element.contains(eventTarget)) element.click();
234
+ } else {
235
+ const clickableElements = element.querySelectorAll(CLICKABLE_SELECTOR);
236
+ if (clickableElements.length === 1) {
237
+ const clickableElement = clickableElements[0];
238
+ if (clickableElement !== eventTarget && !clickableElement.contains(eventTarget)) clickableElement.click();
239
+ }
240
+ }
241
+ }
242
+ onSubmitItemRef.current?.({
243
+ element,
244
+ event,
245
+ label: itemLabel,
246
+ value: nextValue
247
+ });
248
+ };
249
+ $[16] = dropdownElement;
250
+ $[17] = t10;
251
+ } else t10 = $[17];
252
+ const handleSubmitItem = t10;
253
+ let t11;
254
+ if ($[18] === Symbol.for("react.memo_cache_sentinel")) {
255
+ t11 = (t12) => {
256
+ const { clientX, clientY } = t12;
257
+ currentInputMethodRef.current = "mouse";
258
+ const initialPosition = mouseDownPositionRef.current;
259
+ if (!initialPosition) return;
260
+ if (Math.abs(initialPosition.clientX - clientX) < 12 && Math.abs(initialPosition.clientY - clientY) < 12) return;
261
+ setIsOpening(false);
262
+ };
263
+ $[18] = t11;
264
+ } else t11 = $[18];
265
+ const handleMouseMove = t11;
266
+ let t12;
267
+ if ($[19] !== dropdownElement || $[20] !== onActiveItem) {
268
+ t12 = (event_0) => {
269
+ if (!hasItemsRef.current) return;
270
+ if (currentInputMethodRef.current !== "mouse") return;
271
+ if (!dropdownElement) return;
272
+ const itemElements = getItemElements(dropdownElement);
273
+ if (!itemElements) return;
274
+ const eventTarget_0 = event_0.target;
275
+ const element_0 = eventTarget_0.closest(ITEM_SELECTOR) ?? eventTarget_0;
276
+ for (const itemElement of itemElements) if (itemElement === element_0) {
277
+ setActiveItem({
278
+ dropdownElement,
279
+ element: element_0,
280
+ event: event_0,
281
+ onActiveItem
282
+ });
283
+ return;
284
+ }
285
+ };
286
+ $[19] = dropdownElement;
287
+ $[20] = onActiveItem;
288
+ $[21] = t12;
289
+ } else t12 = $[21];
290
+ const handleMouseOver = t12;
291
+ let t13;
292
+ if ($[22] !== dropdownElement) {
293
+ t13 = (event_1) => {
294
+ if (!hasItemsRef.current) return;
295
+ const activeItem = getActiveItemElement(dropdownElement);
296
+ if (!activeItem) return;
297
+ const eventRelatedTarget = event_1.relatedTarget;
298
+ if (activeItem !== event_1.target || activeItem.contains(eventRelatedTarget)) return;
299
+ delete activeItem.dataset.uktActive;
300
+ };
301
+ $[22] = dropdownElement;
302
+ $[23] = t13;
303
+ } else t13 = $[23];
304
+ const handleMouseOut = t13;
305
+ let t14;
306
+ if ($[24] !== onMouseDown) {
307
+ t14 = (event_2) => {
308
+ if (onMouseDown) onMouseDown(event_2);
309
+ if (isOpenRef.current) return;
310
+ setIsOpen(true);
311
+ setIsOpening(true);
312
+ mouseDownPositionRef.current = {
313
+ clientX: event_2.clientX,
314
+ clientY: event_2.clientY
315
+ };
316
+ isOpeningTimerRef.current = setTimeout(() => {
317
+ setIsOpening(false);
318
+ isOpeningTimerRef.current = null;
319
+ }, 1e3);
320
+ };
321
+ $[24] = onMouseDown;
322
+ $[25] = t14;
323
+ } else t14 = $[25];
324
+ const handleMouseDown = t14;
325
+ let t15;
326
+ if ($[26] !== handleSubmitItem || $[27] !== onMouseUp) {
327
+ t15 = (event_3) => {
328
+ if (onMouseUp) onMouseUp(event_3);
329
+ if (isOpeningRef.current || !isOpenRef.current || closingTimerRef.current != null) return;
330
+ const eventTarget_1 = event_3.target;
331
+ if (!eventTarget_1.closest(".uktdropdown-body")) {
332
+ if (!isOpeningRef.current && inputElementRef.current !== eventTarget_1.ownerDocument.activeElement) closeDropdown();
333
+ return;
334
+ }
335
+ if (!hasItemsRef.current) return;
336
+ handleSubmitItem(event_3);
337
+ };
338
+ $[26] = handleSubmitItem;
339
+ $[27] = onMouseUp;
340
+ $[28] = t15;
341
+ } else t15 = $[28];
342
+ const handleMouseUp = t15;
343
+ let t16;
344
+ if ($[29] !== dropdownElement || $[30] !== handleSubmitItem || $[31] !== onActiveItem) {
345
+ t16 = (event_4) => {
346
+ const { altKey, ctrlKey, key, metaKey } = event_4;
347
+ const eventTarget_2 = event_4.target;
348
+ if (!dropdownElement) return;
349
+ const onEventHandled = () => {
350
+ event_4.stopPropagation();
351
+ event_4.preventDefault();
352
+ currentInputMethodRef.current = "keyboard";
353
+ };
354
+ const isEventTargetingDropdown = dropdownElement.contains(eventTarget_2);
355
+ if (!isOpenRef.current) {
356
+ if (!isEventTargetingDropdown) return;
357
+ if (key === " " || key === "Enter" || hasItemsRef.current && (key === "ArrowUp" || key === "ArrowDown")) {
358
+ onEventHandled();
359
+ setIsOpen(true);
360
+ }
361
+ return;
362
+ }
363
+ const isTargetUsingKeyEvents = isEventTargetUsingKeyEvent(event_4);
364
+ if (hasItemsRef.current && !isTargetUsingKeyEvents) {
365
+ let isEditingCharacters = !ctrlKey && !metaKey && /^[A-Za-z0-9]$/.test(key);
366
+ if (!isEditingCharacters && enteredCharactersRef.current) isEditingCharacters = key === " " || key === "Backspace";
367
+ if (isEditingCharacters) {
368
+ onEventHandled();
369
+ if (key === "Backspace") enteredCharactersRef.current = enteredCharactersRef.current.slice(0, -1);
370
+ else enteredCharactersRef.current = enteredCharactersRef.current + key;
371
+ setActiveItem({
372
+ dropdownElement,
373
+ event: event_4,
374
+ isExactMatch: allowCreateRef.current,
375
+ onActiveItem,
376
+ text: enteredCharactersRef.current
377
+ });
378
+ if (clearEnteredCharactersTimerRef.current != null) clearTimeout(clearEnteredCharactersTimerRef.current);
379
+ clearEnteredCharactersTimerRef.current = setTimeout(() => {
380
+ enteredCharactersRef.current = "";
381
+ clearEnteredCharactersTimerRef.current = null;
382
+ }, 1500);
383
+ return;
384
+ }
385
+ }
386
+ if (key === "Enter" || key === " " && !inputElementRef.current) {
387
+ onEventHandled();
388
+ handleSubmitItem(event_4);
389
+ return;
390
+ }
391
+ if (key === "Escape" || isEventTargetingDropdown && key === " " && !hasItemsRef.current) {
392
+ if (hasItemsRef.current || !isTargetUsingKeyEvents) closeDropdown();
393
+ return;
394
+ }
395
+ if (hasItemsRef.current) {
396
+ if (key === "ArrowUp") {
397
+ onEventHandled();
398
+ if (altKey || metaKey) setActiveItem({
399
+ dropdownElement,
400
+ event: event_4,
401
+ index: 0,
402
+ onActiveItem
403
+ });
404
+ else setActiveItem({
405
+ dropdownElement,
406
+ event: event_4,
407
+ indexAddend: -1,
408
+ onActiveItem
409
+ });
410
+ return;
411
+ }
412
+ if (key === "ArrowDown") {
413
+ onEventHandled();
414
+ if (altKey || metaKey) setActiveItem({
415
+ dropdownElement,
416
+ event: event_4,
417
+ index: -1,
418
+ onActiveItem
419
+ });
420
+ else setActiveItem({
421
+ dropdownElement,
422
+ event: event_4,
423
+ indexAddend: 1,
424
+ onActiveItem
425
+ });
426
+ return;
427
+ }
428
+ }
429
+ };
430
+ $[29] = dropdownElement;
431
+ $[30] = handleSubmitItem;
432
+ $[31] = onActiveItem;
433
+ $[32] = t16;
434
+ } else t16 = $[32];
435
+ const handleKeyDown = t16;
436
+ let t17;
437
+ if ($[33] !== handleKeyDown) {
438
+ t17 = {
439
+ ignoreUsedKeyboardEvents: false,
440
+ onKeyDown: handleKeyDown
441
+ };
442
+ $[33] = handleKeyDown;
443
+ $[34] = t17;
444
+ } else t17 = $[34];
445
+ useKeyboardEvents(t17);
446
+ let t18;
447
+ if ($[35] !== isOpenOnMount || $[36] !== onActiveItem) {
448
+ t18 = (ref) => {
449
+ setDropdownElement(ref);
450
+ if (!ref) return;
451
+ const { ownerDocument } = ref;
452
+ let inputElement = inputElementRef.current;
453
+ if (!inputElement && ref.firstElementChild) {
454
+ if (ref.firstElementChild.matches(TEXT_INPUT_SELECTOR)) inputElement = ref.firstElementChild;
455
+ else inputElement = ref.firstElementChild.querySelector(TEXT_INPUT_SELECTOR);
456
+ inputElementRef.current = inputElement;
457
+ }
458
+ const handleGlobalMouseDown = (t19) => {
459
+ const { target } = t19;
460
+ const eventTarget_3 = target;
461
+ if (!ref.contains(eventTarget_3)) closeDropdown();
462
+ };
463
+ const handleGlobalMouseUp = (t20) => {
464
+ const { target: target_0 } = t20;
465
+ if (!isOpenRef.current || closingTimerRef.current != null) return;
466
+ if (isOpeningRef.current) {
467
+ setIsOpening(false);
468
+ if (isOpeningTimerRef.current != null) {
469
+ clearTimeout(isOpeningTimerRef.current);
470
+ isOpeningTimerRef.current = null;
471
+ }
472
+ return;
473
+ }
474
+ const eventTarget_4 = target_0;
475
+ if (!ref.contains(eventTarget_4)) closeDropdown();
476
+ };
477
+ const handleGlobalFocusIn = (t21) => {
478
+ const { target: target_1 } = t21;
479
+ if (!isOpenRef.current) return;
480
+ const eventTarget_5 = target_1;
481
+ if (ref.contains(eventTarget_5) || eventTarget_5.contains(ref)) return;
482
+ closeDropdown();
483
+ };
484
+ document.addEventListener("focusin", handleGlobalFocusIn);
485
+ document.addEventListener("mousedown", handleGlobalMouseDown);
486
+ document.addEventListener("mouseup", handleGlobalMouseUp);
487
+ if (ownerDocument !== document) {
488
+ ownerDocument.addEventListener("focusin", handleGlobalFocusIn);
489
+ ownerDocument.addEventListener("mousedown", handleGlobalMouseDown);
490
+ ownerDocument.addEventListener("mouseup", handleGlobalMouseUp);
491
+ }
492
+ if (isOpenOnMount) ref.focus();
493
+ const handleInput = (event_5) => {
494
+ if (!isOpenRef.current) setIsOpen(true);
495
+ const input = event_5.target;
496
+ const isDeleting = enteredCharactersRef.current.length > input.value.length;
497
+ enteredCharactersRef.current = input.value;
498
+ if (isDeleting && input.value.length && getActiveItemElement(ref)) return;
499
+ setActiveItem({
500
+ dropdownElement: ref,
501
+ event: event_5,
502
+ isExactMatch: allowCreateRef.current,
503
+ onActiveItem,
504
+ text: enteredCharactersRef.current
505
+ });
506
+ };
507
+ if (inputElement) inputElement.addEventListener("input", handleInput);
508
+ return () => {
509
+ document.removeEventListener("focusin", handleGlobalFocusIn);
510
+ document.removeEventListener("mousedown", handleGlobalMouseDown);
511
+ document.removeEventListener("mouseup", handleGlobalMouseUp);
512
+ if (ownerDocument !== document) {
513
+ ownerDocument.removeEventListener("focusin", handleGlobalFocusIn);
514
+ ownerDocument.removeEventListener("mousedown", handleGlobalMouseDown);
515
+ ownerDocument.removeEventListener("mouseup", handleGlobalMouseUp);
516
+ }
517
+ if (inputElement) inputElement.removeEventListener("input", handleInput);
518
+ };
519
+ };
520
+ $[35] = isOpenOnMount;
521
+ $[36] = onActiveItem;
522
+ $[37] = t18;
523
+ } else t18 = $[37];
524
+ const handleRef = t18;
525
+ if (!isValidElement(trigger)) if (isSearchable) {
526
+ const t19 = value ?? "";
527
+ let t20;
528
+ if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
529
+ t20 = () => setIsOpen(true);
530
+ $[38] = t20;
531
+ } else t20 = $[38];
532
+ let t21;
533
+ if ($[39] !== disabled || $[40] !== name || $[41] !== placeholder || $[42] !== t19 || $[43] !== tabIndex) {
534
+ t21 = /* @__PURE__ */ jsx("input", {
535
+ autoComplete: "off",
536
+ className: "uktdropdown-trigger",
537
+ defaultValue: t19,
538
+ disabled,
539
+ name,
540
+ onFocus: t20,
541
+ placeholder,
542
+ ref: inputElementRef,
543
+ tabIndex,
544
+ type: "text"
545
+ });
546
+ $[39] = disabled;
547
+ $[40] = name;
548
+ $[41] = placeholder;
549
+ $[42] = t19;
550
+ $[43] = tabIndex;
551
+ $[44] = t21;
552
+ } else t21 = $[44];
553
+ trigger = t21;
554
+ } else {
555
+ let t19;
556
+ if ($[45] !== trigger) {
557
+ t19 = /* @__PURE__ */ jsx("button", {
558
+ className: "uktdropdown-trigger",
559
+ tabIndex: 0,
560
+ type: "button",
561
+ children: trigger
562
+ });
563
+ $[45] = trigger;
564
+ $[46] = t19;
565
+ } else t19 = $[46];
566
+ trigger = t19;
567
+ }
568
+ if (label) {
569
+ let t19;
570
+ if ($[47] !== label) {
571
+ t19 = /* @__PURE__ */ jsx("div", {
572
+ className: "uktdropdown-label-text",
573
+ children: label
574
+ });
575
+ $[47] = label;
576
+ $[48] = t19;
577
+ } else t19 = $[48];
578
+ let t20;
579
+ if ($[49] !== t19 || $[50] !== trigger) {
580
+ t20 = /* @__PURE__ */ jsxs("label", {
581
+ className: "uktdropdown-label",
582
+ children: [t19, trigger]
583
+ });
584
+ $[49] = t19;
585
+ $[50] = trigger;
586
+ $[51] = t20;
587
+ } else t20 = $[51];
588
+ trigger = t20;
589
+ }
590
+ const dropdownRect = useBoundingClientRect(dropdownElement);
591
+ const dropdownBodyRect = useBoundingClientRect(dropdownBodyElement);
592
+ let t19;
593
+ if ($[52] !== dropdownBodyElement) {
594
+ t19 = getBoundingAncestor(dropdownBodyElement);
595
+ $[52] = dropdownBodyElement;
596
+ $[53] = t19;
597
+ } else t19 = $[53];
598
+ const boundingElementRect = useBoundingClientRect(t19);
599
+ let maxHeight;
600
+ if (dropdownBodyRect.top != null && dropdownRect.top != null && boundingElementRect.top != null) {
601
+ const maxHeightUp = dropdownBodyRect.bottom - boundingElementRect.top;
602
+ const maxHeightDown = boundingElementRect.bottom - dropdownBodyRect.top;
603
+ let t20;
604
+ if ($[54] !== dropdownBodyRect.top || $[55] !== dropdownRect.top || $[56] !== maxHeightDown || $[57] !== maxHeightUp) {
605
+ t20 = Math.round(dropdownBodyRect.top > dropdownRect.top ? maxHeightDown : maxHeightUp);
606
+ $[54] = dropdownBodyRect.top;
607
+ $[55] = dropdownRect.top;
608
+ $[56] = maxHeightDown;
609
+ $[57] = maxHeightUp;
610
+ $[58] = t20;
611
+ } else t20 = $[58];
612
+ maxHeight = t20;
613
+ }
614
+ let t20;
615
+ if ($[59] !== maxHeight || $[60] !== minHeightBody) {
616
+ t20 = maxHeight != null && maxHeight > minHeightBody ? { "--uktdd-body-max-height": `calc(${maxHeight}px - var(--uktdd-body-buffer))` } : null;
617
+ $[59] = maxHeight;
618
+ $[60] = minHeightBody;
619
+ $[61] = t20;
620
+ } else t20 = $[61];
621
+ let t21;
622
+ if ($[62] !== minWidthBody) {
623
+ t21 = minWidthBody != null && minWidthBody > 0 ? { "--uktdd-body-min-width": `${minWidthBody}px` } : null;
624
+ $[62] = minWidthBody;
625
+ $[63] = t21;
626
+ } else t21 = $[63];
627
+ let t22;
628
+ if ($[64] !== styleFromProps || $[65] !== t20 || $[66] !== t21) {
629
+ t22 = {
630
+ ...styleFromProps,
631
+ ...t20,
632
+ ...t21
633
+ };
634
+ $[64] = styleFromProps;
635
+ $[65] = t20;
636
+ $[66] = t21;
637
+ $[67] = t22;
638
+ } else t22 = $[67];
639
+ const style = t22;
640
+ let t23;
641
+ if ($[68] === Symbol.for("react.memo_cache_sentinel")) {
642
+ t23 = /* @__PURE__ */ jsx("style", {
643
+ href: "@acusti/dropdown/Dropdown",
644
+ precedence: "medium",
645
+ children: Dropdown_default
646
+ });
647
+ $[68] = t23;
648
+ } else t23 = $[68];
649
+ let t24;
650
+ if ($[69] !== className || $[70] !== disabled || $[71] !== isOpen || $[72] !== isSearchable) {
651
+ t24 = clsx("uktdropdown", className, {
652
+ disabled,
653
+ "is-open": isOpen,
654
+ "is-searchable": isSearchable
655
+ });
656
+ $[69] = className;
657
+ $[70] = disabled;
658
+ $[71] = isOpen;
659
+ $[72] = isSearchable;
660
+ $[73] = t24;
661
+ } else t24 = $[73];
662
+ let t25;
663
+ if ($[74] !== children || $[75] !== childrenCount || $[76] !== isOpen) {
664
+ t25 = isOpen ? /* @__PURE__ */ jsx("div", {
665
+ className: "uktdropdown-body",
666
+ ref: setDropdownBodyElement,
667
+ children: childrenCount > 1 ? children[1] : children
668
+ }) : null;
669
+ $[74] = children;
670
+ $[75] = childrenCount;
671
+ $[76] = isOpen;
672
+ $[77] = t25;
673
+ } else t25 = $[77];
674
+ let t26;
675
+ if ($[78] !== handleMouseDown || $[79] !== handleMouseOut || $[80] !== handleMouseOver || $[81] !== handleMouseUp || $[82] !== handleRef || $[83] !== onClick || $[84] !== style || $[85] !== t24 || $[86] !== t25 || $[87] !== trigger) {
676
+ t26 = /* @__PURE__ */ jsxs(Fragment, { children: [t23, /* @__PURE__ */ jsxs("div", {
677
+ className: t24,
678
+ onClick,
679
+ onMouseDown: handleMouseDown,
680
+ onMouseMove: handleMouseMove,
681
+ onMouseOut: handleMouseOut,
682
+ onMouseOver: handleMouseOver,
683
+ onMouseUp: handleMouseUp,
684
+ ref: handleRef,
685
+ style,
686
+ children: [trigger, t25]
687
+ })] });
688
+ $[78] = handleMouseDown;
689
+ $[79] = handleMouseOut;
690
+ $[80] = handleMouseOver;
691
+ $[81] = handleMouseUp;
692
+ $[82] = handleRef;
693
+ $[83] = onClick;
694
+ $[84] = style;
695
+ $[85] = t24;
696
+ $[86] = t25;
697
+ $[87] = trigger;
698
+ $[88] = t26;
699
+ } else t26 = $[88];
700
+ return t26;
1031
701
  }
1032
702
  function getBoundingAncestor(element) {
1033
- while (element?.parentElement) {
1034
- if (element.parentElement.tagName === "BODY") return element.parentElement;
1035
- if (getComputedStyle(element.parentElement).overflowX !== "visible") {
1036
- return element.parentElement;
1037
- }
1038
- element = element.parentElement;
1039
- }
1040
- return null;
703
+ while (element?.parentElement) {
704
+ if (element.parentElement.tagName === "BODY") return element.parentElement;
705
+ if (getComputedStyle(element.parentElement).overflowX !== "visible") return element.parentElement;
706
+ element = element.parentElement;
707
+ }
708
+ return null;
1041
709
  }
1042
- export {
1043
- Dropdown as default
1044
- };
1045
- //# sourceMappingURL=Dropdown.js.map
710
+ export { Dropdown as default };
711
+
712
+ //# sourceMappingURL=Dropdown.js.map