bianic-ui 1.1.0-beta.5 → 1.1.0-beta.6

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/cjs/index.js CHANGED
@@ -1816,9 +1816,25 @@ function SelectInput(_a) {
1816
1816
  };
1817
1817
  });
1818
1818
  var isObjectOptionItem = false;
1819
- if (options.every(function (item) { return typeof item === "object" && item !== null; }))
1819
+ if (options.every(function (item) { return typeof item === 'object' && item !== null; }))
1820
1820
  isObjectOptionItem = true;
1821
- var selectedLabel = isObjectOptionItem && typeof selected === 'object' ? selected.label : selected;
1821
+ var selectedLabel = isObjectOptionItem && typeof selected === 'object'
1822
+ ? selected.label
1823
+ : selected;
1824
+ var optionsRef = React.useRef(null);
1825
+ React.useEffect(function () {
1826
+ if (isOpen && inputRef.current && optionsRef.current) {
1827
+ console.log('entered');
1828
+ var selectRect = inputRef.current.getBoundingClientRect();
1829
+ var optionsElement = optionsRef.current;
1830
+ var windowHeight = window.innerHeight;
1831
+ // Cek ruang di bawah
1832
+ var spaceBelow = windowHeight - selectRect.bottom;
1833
+ var maxHeight = void 0;
1834
+ maxHeight = spaceBelow - 10; // Beri margin
1835
+ optionsElement.style.maxHeight = "".concat(Math.max(0, maxHeight), "px");
1836
+ }
1837
+ }, [isOpen]);
1822
1838
  return (React.createElement("div", { className: "field-group flex w-full flex-col", ref: inputRef },
1823
1839
  React.createElement("label", { htmlFor: id, className: "label pb-2 text-xs font-semibold" },
1824
1840
  childrenElement(label),
@@ -1826,7 +1842,7 @@ function SelectInput(_a) {
1826
1842
  React.createElement("div", { className: "group relative w-full" },
1827
1843
  React.createElement("input", __assign({ className: "field peer w-full cursor-pointer rounded border border-bia-grey-dark-10 bg-primary-white pe-8 focus-visible:outline-none enabled:hover:rounded-b-none enabled:hover:border-b-bia-blue enabled:focus:rounded-b-none enabled:focus:border-b-bia-blue disabled:bg-bia-grey-light-80 disabled:text-bia-coolgrey ".concat(searchSize), onClick: function () { return setIsOpen(!isOpen); }, value: selectedLabel, readOnly: true, id: id, disabled: disabled }, props)),
1828
1844
  React.createElement("div", { className: "pointer-events-none absolute inset-y-0 flex items-center pl-3 text-bia-coolgrey peer-disabled:text-bia-coolgrey-light-50 ".concat(iconSize) }, isOpen ? React.createElement(TbChevronUp, null) : React.createElement(TbChevronDown, null)),
1829
- isOpen && (React.createElement("div", { className: "absolute z-10 w-full rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg" }, options.map(function (option) {
1845
+ isOpen && (React.createElement("div", { className: "absolute z-10 w-full overflow-y-auto rounded-b-md border border-bia-grey-dark-10 bg-primary-white shadow-lg", ref: optionsRef }, options.map(function (option) {
1830
1846
  var isSelected = JSON.stringify(option) === JSON.stringify(selected);
1831
1847
  var optionLabel = isObjectOptionItem ? option.label : option;
1832
1848
  var optionCaption = isObjectOptionItem ? option.caption : '';