@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 CHANGED
@@ -683,6 +683,12 @@
683
683
  overflow-x: hidden;
684
684
  padding: 0.25rem 0;
685
685
  }
686
+ .select_list_up {
687
+ top: auto;
688
+ bottom: 100%;
689
+ margin-top: 0;
690
+ margin-bottom: 0.25rem;
691
+ }
686
692
  .select_option {
687
693
  width: 100%;
688
694
  box-sizing: border-box;
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: "select_list",
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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigtablet/design-system",
3
- "version": "1.15.0",
3
+ "version": "1.16.0",
4
4
  "description": "Bigtablet Design System UI Components",
5
5
  "type": "module",
6
6
  "types": "dist/index.d.ts",