@bigtablet/design-system 1.15.0 → 1.16.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/index.css +6 -0
- package/dist/index.js +12 -1
- package/package.json +1 -1
package/dist/index.css
CHANGED
package/dist/index.js
CHANGED
|
@@ -315,7 +315,9 @@ var Select = ({
|
|
|
315
315
|
const currentValue = isControlled ? value ?? null : internalValue;
|
|
316
316
|
const [isOpen, setIsOpen] = React3.useState(false);
|
|
317
317
|
const [activeIndex, setActiveIndex] = React3.useState(-1);
|
|
318
|
+
const [dropUp, setDropUp] = React3.useState(false);
|
|
318
319
|
const wrapperRef = React3.useRef(null);
|
|
320
|
+
const controlRef = React3.useRef(null);
|
|
319
321
|
const currentOption = React3.useMemo(
|
|
320
322
|
() => options.find((o) => o.value === currentValue) ?? null,
|
|
321
323
|
[options, currentValue]
|
|
@@ -413,6 +415,14 @@ var Select = ({
|
|
|
413
415
|
)
|
|
414
416
|
);
|
|
415
417
|
}, [isOpen, options, currentValue]);
|
|
418
|
+
React3.useLayoutEffect(() => {
|
|
419
|
+
if (!isOpen || !controlRef.current) return;
|
|
420
|
+
const rect = controlRef.current.getBoundingClientRect();
|
|
421
|
+
const listHeight = Math.min(options.length * 40, 288);
|
|
422
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
423
|
+
const spaceAbove = rect.top;
|
|
424
|
+
setDropUp(spaceBelow < listHeight && spaceAbove > spaceBelow);
|
|
425
|
+
}, [isOpen, options.length]);
|
|
416
426
|
const rootClassName = ["select", className ?? ""].filter(Boolean).join(" ");
|
|
417
427
|
const controlClassName = [
|
|
418
428
|
"select_control",
|
|
@@ -439,6 +449,7 @@ var Select = ({
|
|
|
439
449
|
/* @__PURE__ */ jsxs(
|
|
440
450
|
"button",
|
|
441
451
|
{
|
|
452
|
+
ref: controlRef,
|
|
442
453
|
id: selectId,
|
|
443
454
|
type: "button",
|
|
444
455
|
className: controlClassName,
|
|
@@ -466,7 +477,7 @@ var Select = ({
|
|
|
466
477
|
{
|
|
467
478
|
id: `${selectId}_listbox`,
|
|
468
479
|
role: "listbox",
|
|
469
|
-
className:
|
|
480
|
+
className: `select_list${dropUp ? " select_list_up" : ""}`,
|
|
470
481
|
children: options.map((opt, i) => {
|
|
471
482
|
const selected = currentValue === opt.value;
|
|
472
483
|
const active = i === activeIndex;
|