funda-ui 4.7.525 → 4.7.533

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.
@@ -2322,6 +2322,7 @@ var CascadingSelect = /*#__PURE__*/(0,external_root_React_commonjs2_react_common
2322
2322
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2323
2323
  var inputRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2324
2324
  var listRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2325
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
2325
2326
 
2326
2327
  // searchable
2327
2328
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
@@ -2439,7 +2440,7 @@ var CascadingSelect = /*#__PURE__*/(0,external_root_React_commonjs2_react_common
2439
2440
  // STEP 2:
2440
2441
  //-----------
2441
2442
  // Detect position
2442
- if (window.innerHeight - _triggerBox.top > 100) {
2443
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
2443
2444
  targetPos = 'bottom';
2444
2445
  } else {
2445
2446
  targetPos = 'top';
@@ -2679,6 +2679,7 @@ var CascadingSelectE2E = /*#__PURE__*/(0,external_root_React_commonjs2_react_com
2679
2679
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2680
2680
  var inputRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2681
2681
  var listRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2682
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
2682
2683
 
2683
2684
  // searchable
2684
2685
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
@@ -2821,7 +2822,7 @@ var CascadingSelectE2E = /*#__PURE__*/(0,external_root_React_commonjs2_react_com
2821
2822
  // STEP 2:
2822
2823
  //-----------
2823
2824
  // Detect position
2824
- if (window.innerHeight - _triggerBox.top > 100) {
2825
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
2825
2826
  targetPos = 'bottom';
2826
2827
  } else {
2827
2828
  targetPos = 'top';
package/Date/index.js CHANGED
@@ -5034,6 +5034,8 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
5034
5034
  langToday = props.langToday,
5035
5035
  attributes = _objectWithoutProperties(props, _excluded);
5036
5036
  var DEPTH = depth || 1055; // the default value same as bootstrap
5037
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
5038
+
5037
5039
  var defaultValueIsEmpty = function defaultValueIsEmpty(s) {
5038
5040
  return typeof s === 'undefined' || s === null || s === 'null' || s === '';
5039
5041
  };
@@ -5328,7 +5330,7 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
5328
5330
  // STEP 1:
5329
5331
  //-----------
5330
5332
  // Detect position
5331
- if (window.innerHeight - _triggerBox.top > 100) {
5333
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
5332
5334
  targetPos = 'bottom';
5333
5335
  } else {
5334
5336
  targetPos = 'top';
@@ -1285,6 +1285,8 @@ var DropdownMenu = function DropdownMenu(props) {
1285
1285
  selected = _useState4[0],
1286
1286
  setSelected = _useState4[1];
1287
1287
  var _hoverDelay = !isNaN(hoverDelay) && typeof hoverDelay !== 'undefined' ? hoverDelay : 150;
1288
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
1289
+
1288
1290
  var defaultLabel = triggerContent === undefined ? '' : triggerContent;
1289
1291
  var selectedLabel = triggerSwitchActive ? selected ? selected.label : defaultLabel : defaultLabel;
1290
1292
  var selectOptionsListPresentation = options === null || options === void 0 ? void 0 : options.map(function (selectOption, index) {
@@ -1375,7 +1377,7 @@ var DropdownMenu = function DropdownMenu(props) {
1375
1377
  // STEP 2:
1376
1378
  //-----------
1377
1379
  // Detect position
1378
- if (window.innerHeight - _triggerBox.top > 100) {
1380
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
1379
1381
  targetPos = 'bottom';
1380
1382
  } else {
1381
1383
  targetPos = 'top';
@@ -2892,6 +2892,7 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
2892
2892
  var EXCEEDED_SIDE_POS_OFFSET = Number(exceededSidePosOffset) || 15;
2893
2893
  var AUTO_SHOW_OPTIONS = typeof autoShowOptions !== 'undefined' && autoShowOptions === true ? true : false;
2894
2894
  var MANUAL_REQ = typeof fetchTrigger !== 'undefined' && fetchTrigger === true ? true : false; // Manual requests
2895
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
2895
2896
 
2896
2897
  var NO_MATCH_POPUP = typeof noMatchPopup === 'undefined' ? true : noMatchPopup;
2897
2898
  var WIN_WIDTH = typeof winWidth === 'function' ? winWidth() : winWidth ? winWidth : 'auto';
@@ -3052,7 +3053,7 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
3052
3053
  // STEP 2:
3053
3054
  //-----------
3054
3055
  // Detect position
3055
- if (window.innerHeight - _triggerBox.top > 100) {
3056
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
3056
3057
  targetPos = 'bottom';
3057
3058
  } else {
3058
3059
  targetPos = 'top';
package/Select/index.d.ts CHANGED
@@ -47,6 +47,7 @@ export declare type SelectProps = {
47
47
  controlClassName?: string;
48
48
  controlExClassName?: string;
49
49
  optionsExClassName?: string;
50
+ customScrollContainer?: string | HTMLElement | React.RefObject<HTMLElement>;
50
51
  exceededSidePosOffset?: number;
51
52
  clearIcon?: boolean;
52
53
  renderOption?: (optionData: OptionConfig, index: number) => React.ReactNode;
package/Select/index.js CHANGED
@@ -3578,7 +3578,7 @@ var format_string = __webpack_require__(933);
3578
3578
  // EXTERNAL MODULE: ../Utils/dist/cjs/cls.js
3579
3579
  var cls = __webpack_require__(188);
3580
3580
  ;// CONCATENATED MODULE: ./src/index.tsx
3581
- var _excluded = ["contentRef", "popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "optionsExClassName", "exceededSidePosOffset", "clearIcon", "renderOption", "multiSelect", "multiSelectEntireAreaTrigger", "multiSelectSelectedItemOnlyStatus", "renderSelectedValue", "disabled", "required", "defaultValue", "value", "label", "name", "readOnly", "placeholder", "id", "autoComplete", "autoCapitalize", "spellCheck", "options", "clearTrigger", "loader", "lockBodyScroll", "hierarchical", "indentation", "doubleIndent", "style", "depth", "controlArrow", "winWidth", "tabIndex", "firstRequestAutoExec", "fetchTrigger", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "data", "extractValueByBrackets", "fetchCallback", "onFetch", "onLoad", "onSelect", "onChange", "onBlur", "onFocus", "onKeyPressed"];
3581
+ var _excluded = ["contentRef", "popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "optionsExClassName", "customScrollContainer", "exceededSidePosOffset", "clearIcon", "renderOption", "multiSelect", "multiSelectEntireAreaTrigger", "multiSelectSelectedItemOnlyStatus", "renderSelectedValue", "disabled", "required", "defaultValue", "value", "label", "name", "readOnly", "placeholder", "id", "autoComplete", "autoCapitalize", "spellCheck", "options", "clearTrigger", "loader", "lockBodyScroll", "hierarchical", "indentation", "doubleIndent", "style", "depth", "controlArrow", "winWidth", "tabIndex", "firstRequestAutoExec", "fetchTrigger", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "data", "extractValueByBrackets", "fetchCallback", "onFetch", "onLoad", "onSelect", "onChange", "onBlur", "onFocus", "onKeyPressed"];
3582
3582
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3583
3583
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3584
3584
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -3626,6 +3626,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
3626
3626
  controlClassName = props.controlClassName,
3627
3627
  controlExClassName = props.controlExClassName,
3628
3628
  optionsExClassName = props.optionsExClassName,
3629
+ customScrollContainer = props.customScrollContainer,
3629
3630
  exceededSidePosOffset = props.exceededSidePosOffset,
3630
3631
  clearIcon = props.clearIcon,
3631
3632
  renderOption = props.renderOption,
@@ -3701,6 +3702,8 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
3701
3702
  var listContentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
3702
3703
  var optionsRes = options ? (0,validate.isJSON)(options) ? JSON.parse(options) : options : [];
3703
3704
  var LIST_CONTAINER_MAX_HEIGHT = 300;
3705
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
3706
+
3704
3707
  var keyboardSelectedItem = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
3705
3708
 
3706
3709
  // loading
@@ -4321,8 +4324,36 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4321
4324
  _contentOldHeight = listContainerHeightLimit(_contentOldHeight);
4322
4325
 
4323
4326
  // You need to wait for the height of the pop-up container to be set
4324
- // Detect position
4325
- if (window.innerHeight - _triggerBox.top > 100) {
4327
+ // Detect position
4328
+ var containerHeight = window.innerHeight;
4329
+ var containerTop = 0;
4330
+
4331
+ // If custom scroll container is specified, use it instead of window
4332
+ if (customScrollContainer) {
4333
+ var customContainer = null;
4334
+ if (typeof customScrollContainer === 'string') {
4335
+ // Handle selector string
4336
+ customContainer = document.querySelector(customScrollContainer);
4337
+ } else if (customScrollContainer instanceof HTMLElement) {
4338
+ // Handle DOM element directly
4339
+ customContainer = customScrollContainer;
4340
+ } else if (customScrollContainer && 'current' in customScrollContainer) {
4341
+ // Handle React ref
4342
+ customContainer = customScrollContainer.current;
4343
+ }
4344
+ if (customContainer) {
4345
+ var containerRect = customContainer.getBoundingClientRect();
4346
+ containerHeight = containerRect.height;
4347
+ containerTop = containerRect.top;
4348
+ }
4349
+ }
4350
+
4351
+ // Calculate available space below the trigger
4352
+ var availableSpaceBelow = containerHeight - (_triggerBox.top - containerTop);
4353
+
4354
+ // Use a more reasonable threshold for position decision
4355
+ // Consider the minimum space needed for a usable dropdown
4356
+ if (availableSpaceBelow > MIN_SPACE_FOR_DROPDOWN) {
4326
4357
  targetPos = 'bottom';
4327
4358
  } else {
4328
4359
  targetPos = 'top';
@@ -4333,7 +4364,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4333
4364
  //-----------
4334
4365
  // Set the pop-up height
4335
4366
  if (targetPos === 'top') {
4336
- contentMaxHeight = _triggerBox.top;
4367
+ // Calculate available space above the trigger
4368
+ var availableSpaceAbove = _triggerBox.top - containerTop;
4369
+ contentMaxHeight = availableSpaceAbove;
4337
4370
 
4338
4371
  // height restrictions
4339
4372
  contentMaxHeight = listContainerHeightLimit(contentMaxHeight);
@@ -4354,7 +4387,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4354
4387
  }
4355
4388
  }
4356
4389
  if (targetPos === 'bottom') {
4357
- contentMaxHeight = window.innerHeight - _triggerBox.bottom;
4390
+ // Calculate available space below the trigger
4391
+ var _availableSpaceBelow = containerHeight - (_triggerBox.bottom - containerTop);
4392
+ contentMaxHeight = _availableSpaceBelow;
4358
4393
 
4359
4394
  // height restrictions
4360
4395
  contentMaxHeight = listContainerHeightLimit(contentMaxHeight);
@@ -4380,17 +4415,16 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4380
4415
  // Adjust position
4381
4416
  if (targetPos === 'top') {
4382
4417
  _modalRef.style.left = x + 'px';
4383
- //_modalRef.style.top = y - POS_OFFSET - (listContentRef.current.clientHeight) - 2 + 'px';
4384
- _modalRef.style.top = 'auto';
4385
- _modalRef.style.bottom = window.innerHeight - _triggerBox.top + POS_OFFSET + 2 + 'px';
4386
- _modalRef.style.setProperty('position', 'fixed', 'important');
4418
+ _modalRef.style.bottom = 'auto';
4419
+ // Position the popup above the trigger without overlapping
4420
+ var topPosition = y - POS_OFFSET - listContentRef.current.clientHeight - 2;
4421
+ _modalRef.style.top = topPosition + 'px';
4387
4422
  _modalRef.classList.add('pos-top');
4388
4423
  }
4389
4424
  if (targetPos === 'bottom') {
4390
4425
  _modalRef.style.left = x + 'px';
4391
4426
  _modalRef.style.bottom = 'auto';
4392
4427
  _modalRef.style.top = y + height + POS_OFFSET + 'px';
4393
- _modalRef.style.setProperty('position', 'absolute', 'important');
4394
4428
  _modalRef.classList.remove('pos-top');
4395
4429
  }
4396
4430
 
@@ -4400,16 +4434,38 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4400
4434
  var _modalContent = _modalRef;
4401
4435
  var _modalBox = _modalContent.getBoundingClientRect();
4402
4436
  if (typeof _modalContent.dataset.offset === 'undefined' && _modalBox.left > 0) {
4437
+ // Get container width for boundary checking
4438
+ var containerWidth = window.innerWidth;
4439
+ var containerLeft = 0;
4440
+ if (customScrollContainer) {
4441
+ var _customContainer = null;
4442
+ if (typeof customScrollContainer === 'string') {
4443
+ // Handle selector string
4444
+ _customContainer = document.querySelector(customScrollContainer);
4445
+ } else if (customScrollContainer instanceof HTMLElement) {
4446
+ // Handle DOM element directly
4447
+ _customContainer = customScrollContainer;
4448
+ } else if (customScrollContainer && 'current' in customScrollContainer) {
4449
+ // Handle React ref
4450
+ _customContainer = customScrollContainer.current;
4451
+ }
4452
+ if (_customContainer) {
4453
+ var _containerRect = _customContainer.getBoundingClientRect();
4454
+ containerWidth = _containerRect.width;
4455
+ containerLeft = _containerRect.left;
4456
+ }
4457
+ }
4458
+
4403
4459
  // 10 pixels is used to account for some bias in mobile devices
4404
- if (_modalBox.right + 10 > window.innerWidth) {
4405
- var _modalOffsetPosition = _modalBox.right - window.innerWidth + EXCEEDED_SIDE_POS_OFFSET;
4460
+ if (_modalBox.right + 10 > containerLeft + containerWidth) {
4461
+ var _modalOffsetPosition = _modalBox.right - (containerLeft + containerWidth) + EXCEEDED_SIDE_POS_OFFSET;
4406
4462
  _modalContent.dataset.offset = _modalOffsetPosition;
4407
4463
  _modalContent.style.marginLeft = "-".concat(_modalOffsetPosition, "px");
4408
4464
  // console.log('_modalPosition: ', _modalOffsetPosition)
4409
4465
  }
4410
4466
 
4411
- if (_modalBox.left - 10 < 0) {
4412
- var _modalOffsetPosition2 = Math.abs(_modalBox.left) + EXCEEDED_SIDE_POS_OFFSET;
4467
+ if (_modalBox.left - 10 < containerLeft) {
4468
+ var _modalOffsetPosition2 = Math.abs(_modalBox.left - containerLeft) + EXCEEDED_SIDE_POS_OFFSET;
4413
4469
  _modalContent.dataset.offset = _modalOffsetPosition2;
4414
4470
  _modalContent.style.marginLeft = "".concat(_modalOffsetPosition2, "px");
4415
4471
  // console.log('_modalPosition: ', _modalOffsetPosition)
@@ -2322,6 +2322,7 @@ var CascadingSelect = /*#__PURE__*/(0,external_root_React_commonjs2_react_common
2322
2322
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2323
2323
  var inputRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2324
2324
  var listRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2325
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
2325
2326
 
2326
2327
  // searchable
2327
2328
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
@@ -2439,7 +2440,7 @@ var CascadingSelect = /*#__PURE__*/(0,external_root_React_commonjs2_react_common
2439
2440
  // STEP 2:
2440
2441
  //-----------
2441
2442
  // Detect position
2442
- if (window.innerHeight - _triggerBox.top > 100) {
2443
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
2443
2444
  targetPos = 'bottom';
2444
2445
  } else {
2445
2446
  targetPos = 'top';
@@ -2679,6 +2679,7 @@ var CascadingSelectE2E = /*#__PURE__*/(0,external_root_React_commonjs2_react_com
2679
2679
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2680
2680
  var inputRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2681
2681
  var listRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
2682
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
2682
2683
 
2683
2684
  // searchable
2684
2685
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
@@ -2821,7 +2822,7 @@ var CascadingSelectE2E = /*#__PURE__*/(0,external_root_React_commonjs2_react_com
2821
2822
  // STEP 2:
2822
2823
  //-----------
2823
2824
  // Detect position
2824
- if (window.innerHeight - _triggerBox.top > 100) {
2825
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
2825
2826
  targetPos = 'bottom';
2826
2827
  } else {
2827
2828
  targetPos = 'top';
@@ -5034,6 +5034,8 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
5034
5034
  langToday = props.langToday,
5035
5035
  attributes = _objectWithoutProperties(props, _excluded);
5036
5036
  var DEPTH = depth || 1055; // the default value same as bootstrap
5037
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
5038
+
5037
5039
  var defaultValueIsEmpty = function defaultValueIsEmpty(s) {
5038
5040
  return typeof s === 'undefined' || s === null || s === 'null' || s === '';
5039
5041
  };
@@ -5328,7 +5330,7 @@ var src_Date = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_reac
5328
5330
  // STEP 1:
5329
5331
  //-----------
5330
5332
  // Detect position
5331
- if (window.innerHeight - _triggerBox.top > 100) {
5333
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
5332
5334
  targetPos = 'bottom';
5333
5335
  } else {
5334
5336
  targetPos = 'top';
@@ -1285,6 +1285,8 @@ var DropdownMenu = function DropdownMenu(props) {
1285
1285
  selected = _useState4[0],
1286
1286
  setSelected = _useState4[1];
1287
1287
  var _hoverDelay = !isNaN(hoverDelay) && typeof hoverDelay !== 'undefined' ? hoverDelay : 150;
1288
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
1289
+
1288
1290
  var defaultLabel = triggerContent === undefined ? '' : triggerContent;
1289
1291
  var selectedLabel = triggerSwitchActive ? selected ? selected.label : defaultLabel : defaultLabel;
1290
1292
  var selectOptionsListPresentation = options === null || options === void 0 ? void 0 : options.map(function (selectOption, index) {
@@ -1375,7 +1377,7 @@ var DropdownMenu = function DropdownMenu(props) {
1375
1377
  // STEP 2:
1376
1378
  //-----------
1377
1379
  // Detect position
1378
- if (window.innerHeight - _triggerBox.top > 100) {
1380
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
1379
1381
  targetPos = 'bottom';
1380
1382
  } else {
1381
1383
  targetPos = 'top';
@@ -2892,6 +2892,7 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
2892
2892
  var EXCEEDED_SIDE_POS_OFFSET = Number(exceededSidePosOffset) || 15;
2893
2893
  var AUTO_SHOW_OPTIONS = typeof autoShowOptions !== 'undefined' && autoShowOptions === true ? true : false;
2894
2894
  var MANUAL_REQ = typeof fetchTrigger !== 'undefined' && fetchTrigger === true ? true : false; // Manual requests
2895
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
2895
2896
 
2896
2897
  var NO_MATCH_POPUP = typeof noMatchPopup === 'undefined' ? true : noMatchPopup;
2897
2898
  var WIN_WIDTH = typeof winWidth === 'function' ? winWidth() : winWidth ? winWidth : 'auto';
@@ -3052,7 +3053,7 @@ var LiveSearch = /*#__PURE__*/(0,react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(
3052
3053
  // STEP 2:
3053
3054
  //-----------
3054
3055
  // Detect position
3055
- if (window.innerHeight - _triggerBox.top > 100) {
3056
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
3056
3057
  targetPos = 'bottom';
3057
3058
  } else {
3058
3059
  targetPos = 'top';
@@ -47,6 +47,7 @@ export declare type SelectProps = {
47
47
  controlClassName?: string;
48
48
  controlExClassName?: string;
49
49
  optionsExClassName?: string;
50
+ customScrollContainer?: string | HTMLElement | React.RefObject<HTMLElement>;
50
51
  exceededSidePosOffset?: number;
51
52
  clearIcon?: boolean;
52
53
  renderOption?: (optionData: OptionConfig, index: number) => React.ReactNode;
@@ -3578,7 +3578,7 @@ var format_string = __webpack_require__(933);
3578
3578
  // EXTERNAL MODULE: ../Utils/dist/cjs/cls.js
3579
3579
  var cls = __webpack_require__(188);
3580
3580
  ;// CONCATENATED MODULE: ./src/index.tsx
3581
- var _excluded = ["contentRef", "popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "optionsExClassName", "exceededSidePosOffset", "clearIcon", "renderOption", "multiSelect", "multiSelectEntireAreaTrigger", "multiSelectSelectedItemOnlyStatus", "renderSelectedValue", "disabled", "required", "defaultValue", "value", "label", "name", "readOnly", "placeholder", "id", "autoComplete", "autoCapitalize", "spellCheck", "options", "clearTrigger", "loader", "lockBodyScroll", "hierarchical", "indentation", "doubleIndent", "style", "depth", "controlArrow", "winWidth", "tabIndex", "firstRequestAutoExec", "fetchTrigger", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "data", "extractValueByBrackets", "fetchCallback", "onFetch", "onLoad", "onSelect", "onChange", "onBlur", "onFocus", "onKeyPressed"];
3581
+ var _excluded = ["contentRef", "popupRef", "wrapperClassName", "controlClassName", "controlExClassName", "optionsExClassName", "customScrollContainer", "exceededSidePosOffset", "clearIcon", "renderOption", "multiSelect", "multiSelectEntireAreaTrigger", "multiSelectSelectedItemOnlyStatus", "renderSelectedValue", "disabled", "required", "defaultValue", "value", "label", "name", "readOnly", "placeholder", "id", "autoComplete", "autoCapitalize", "spellCheck", "options", "clearTrigger", "loader", "lockBodyScroll", "hierarchical", "indentation", "doubleIndent", "style", "depth", "controlArrow", "winWidth", "tabIndex", "firstRequestAutoExec", "fetchTrigger", "fetchNoneInfo", "fetchUpdate", "fetchFuncAsync", "fetchFuncMethod", "fetchFuncMethodParams", "data", "extractValueByBrackets", "fetchCallback", "onFetch", "onLoad", "onSelect", "onChange", "onBlur", "onFocus", "onKeyPressed"];
3582
3582
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3583
3583
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3584
3584
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -3626,6 +3626,7 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
3626
3626
  controlClassName = props.controlClassName,
3627
3627
  controlExClassName = props.controlExClassName,
3628
3628
  optionsExClassName = props.optionsExClassName,
3629
+ customScrollContainer = props.customScrollContainer,
3629
3630
  exceededSidePosOffset = props.exceededSidePosOffset,
3630
3631
  clearIcon = props.clearIcon,
3631
3632
  renderOption = props.renderOption,
@@ -3701,6 +3702,8 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
3701
3702
  var listContentRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
3702
3703
  var optionsRes = options ? (0,validate.isJSON)(options) ? JSON.parse(options) : options : [];
3703
3704
  var LIST_CONTAINER_MAX_HEIGHT = 300;
3705
+ var MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
3706
+
3704
3707
  var keyboardSelectedItem = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
3705
3708
 
3706
3709
  // loading
@@ -4321,8 +4324,36 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4321
4324
  _contentOldHeight = listContainerHeightLimit(_contentOldHeight);
4322
4325
 
4323
4326
  // You need to wait for the height of the pop-up container to be set
4324
- // Detect position
4325
- if (window.innerHeight - _triggerBox.top > 100) {
4327
+ // Detect position
4328
+ var containerHeight = window.innerHeight;
4329
+ var containerTop = 0;
4330
+
4331
+ // If custom scroll container is specified, use it instead of window
4332
+ if (customScrollContainer) {
4333
+ var customContainer = null;
4334
+ if (typeof customScrollContainer === 'string') {
4335
+ // Handle selector string
4336
+ customContainer = document.querySelector(customScrollContainer);
4337
+ } else if (customScrollContainer instanceof HTMLElement) {
4338
+ // Handle DOM element directly
4339
+ customContainer = customScrollContainer;
4340
+ } else if (customScrollContainer && 'current' in customScrollContainer) {
4341
+ // Handle React ref
4342
+ customContainer = customScrollContainer.current;
4343
+ }
4344
+ if (customContainer) {
4345
+ var containerRect = customContainer.getBoundingClientRect();
4346
+ containerHeight = containerRect.height;
4347
+ containerTop = containerRect.top;
4348
+ }
4349
+ }
4350
+
4351
+ // Calculate available space below the trigger
4352
+ var availableSpaceBelow = containerHeight - (_triggerBox.top - containerTop);
4353
+
4354
+ // Use a more reasonable threshold for position decision
4355
+ // Consider the minimum space needed for a usable dropdown
4356
+ if (availableSpaceBelow > MIN_SPACE_FOR_DROPDOWN) {
4326
4357
  targetPos = 'bottom';
4327
4358
  } else {
4328
4359
  targetPos = 'top';
@@ -4333,7 +4364,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4333
4364
  //-----------
4334
4365
  // Set the pop-up height
4335
4366
  if (targetPos === 'top') {
4336
- contentMaxHeight = _triggerBox.top;
4367
+ // Calculate available space above the trigger
4368
+ var availableSpaceAbove = _triggerBox.top - containerTop;
4369
+ contentMaxHeight = availableSpaceAbove;
4337
4370
 
4338
4371
  // height restrictions
4339
4372
  contentMaxHeight = listContainerHeightLimit(contentMaxHeight);
@@ -4354,7 +4387,9 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4354
4387
  }
4355
4388
  }
4356
4389
  if (targetPos === 'bottom') {
4357
- contentMaxHeight = window.innerHeight - _triggerBox.bottom;
4390
+ // Calculate available space below the trigger
4391
+ var _availableSpaceBelow = containerHeight - (_triggerBox.bottom - containerTop);
4392
+ contentMaxHeight = _availableSpaceBelow;
4358
4393
 
4359
4394
  // height restrictions
4360
4395
  contentMaxHeight = listContainerHeightLimit(contentMaxHeight);
@@ -4380,17 +4415,16 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4380
4415
  // Adjust position
4381
4416
  if (targetPos === 'top') {
4382
4417
  _modalRef.style.left = x + 'px';
4383
- //_modalRef.style.top = y - POS_OFFSET - (listContentRef.current.clientHeight) - 2 + 'px';
4384
- _modalRef.style.top = 'auto';
4385
- _modalRef.style.bottom = window.innerHeight - _triggerBox.top + POS_OFFSET + 2 + 'px';
4386
- _modalRef.style.setProperty('position', 'fixed', 'important');
4418
+ _modalRef.style.bottom = 'auto';
4419
+ // Position the popup above the trigger without overlapping
4420
+ var topPosition = y - POS_OFFSET - listContentRef.current.clientHeight - 2;
4421
+ _modalRef.style.top = topPosition + 'px';
4387
4422
  _modalRef.classList.add('pos-top');
4388
4423
  }
4389
4424
  if (targetPos === 'bottom') {
4390
4425
  _modalRef.style.left = x + 'px';
4391
4426
  _modalRef.style.bottom = 'auto';
4392
4427
  _modalRef.style.top = y + height + POS_OFFSET + 'px';
4393
- _modalRef.style.setProperty('position', 'absolute', 'important');
4394
4428
  _modalRef.classList.remove('pos-top');
4395
4429
  }
4396
4430
 
@@ -4400,16 +4434,38 @@ var Select = /*#__PURE__*/(0,external_root_React_commonjs2_react_commonjs_react_
4400
4434
  var _modalContent = _modalRef;
4401
4435
  var _modalBox = _modalContent.getBoundingClientRect();
4402
4436
  if (typeof _modalContent.dataset.offset === 'undefined' && _modalBox.left > 0) {
4437
+ // Get container width for boundary checking
4438
+ var containerWidth = window.innerWidth;
4439
+ var containerLeft = 0;
4440
+ if (customScrollContainer) {
4441
+ var _customContainer = null;
4442
+ if (typeof customScrollContainer === 'string') {
4443
+ // Handle selector string
4444
+ _customContainer = document.querySelector(customScrollContainer);
4445
+ } else if (customScrollContainer instanceof HTMLElement) {
4446
+ // Handle DOM element directly
4447
+ _customContainer = customScrollContainer;
4448
+ } else if (customScrollContainer && 'current' in customScrollContainer) {
4449
+ // Handle React ref
4450
+ _customContainer = customScrollContainer.current;
4451
+ }
4452
+ if (_customContainer) {
4453
+ var _containerRect = _customContainer.getBoundingClientRect();
4454
+ containerWidth = _containerRect.width;
4455
+ containerLeft = _containerRect.left;
4456
+ }
4457
+ }
4458
+
4403
4459
  // 10 pixels is used to account for some bias in mobile devices
4404
- if (_modalBox.right + 10 > window.innerWidth) {
4405
- var _modalOffsetPosition = _modalBox.right - window.innerWidth + EXCEEDED_SIDE_POS_OFFSET;
4460
+ if (_modalBox.right + 10 > containerLeft + containerWidth) {
4461
+ var _modalOffsetPosition = _modalBox.right - (containerLeft + containerWidth) + EXCEEDED_SIDE_POS_OFFSET;
4406
4462
  _modalContent.dataset.offset = _modalOffsetPosition;
4407
4463
  _modalContent.style.marginLeft = "-".concat(_modalOffsetPosition, "px");
4408
4464
  // console.log('_modalPosition: ', _modalOffsetPosition)
4409
4465
  }
4410
4466
 
4411
- if (_modalBox.left - 10 < 0) {
4412
- var _modalOffsetPosition2 = Math.abs(_modalBox.left) + EXCEEDED_SIDE_POS_OFFSET;
4467
+ if (_modalBox.left - 10 < containerLeft) {
4468
+ var _modalOffsetPosition2 = Math.abs(_modalBox.left - containerLeft) + EXCEEDED_SIDE_POS_OFFSET;
4413
4469
  _modalContent.dataset.offset = _modalOffsetPosition2;
4414
4470
  _modalContent.style.marginLeft = "".concat(_modalOffsetPosition2, "px");
4415
4471
  // console.log('_modalPosition: ', _modalOffsetPosition)
@@ -168,6 +168,7 @@ const CascadingSelect = forwardRef((props: CascadingSelectProps, externalRef: an
168
168
  const rootRef = useRef<any>(null);
169
169
  const inputRef = useRef<any>(null);
170
170
  const listRef = useRef<any>(null);
171
+ const MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
171
172
 
172
173
  // searchable
173
174
  const [columnSearchKeywords, setColumnSearchKeywords] = useState<string[]>([]);
@@ -282,7 +283,7 @@ const CascadingSelect = forwardRef((props: CascadingSelectProps, externalRef: an
282
283
  // STEP 2:
283
284
  //-----------
284
285
  // Detect position
285
- if (window.innerHeight - _triggerBox.top > 100) {
286
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
286
287
  targetPos = 'bottom';
287
288
  } else {
288
289
  targetPos = 'top';
@@ -184,6 +184,7 @@ const CascadingSelectE2E = forwardRef((props: CascadingSelectE2EProps, externalR
184
184
  const rootRef = useRef<any>(null);
185
185
  const inputRef = useRef<any>(null);
186
186
  const listRef = useRef<any>(null);
187
+ const MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
187
188
 
188
189
  // searchable
189
190
  const [columnSearchKeywords, setColumnSearchKeywords] = useState<string[]>([]);
@@ -318,7 +319,7 @@ const CascadingSelectE2E = forwardRef((props: CascadingSelectE2EProps, externalR
318
319
  // STEP 2:
319
320
  //-----------
320
321
  // Detect position
321
- if (window.innerHeight - _triggerBox.top > 100) {
322
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
322
323
  targetPos = 'bottom';
323
324
  } else {
324
325
  targetPos = 'top';
@@ -193,6 +193,9 @@ const Date = forwardRef((props: DateProps, externalRef: any) => {
193
193
 
194
194
 
195
195
  const DEPTH = depth || 1055; // the default value same as bootstrap
196
+ const MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
197
+
198
+
196
199
  const defaultValueIsEmpty = (s: any) => {
197
200
  return typeof s === 'undefined' || s === null || s === 'null' || s === '';
198
201
  };
@@ -521,7 +524,7 @@ const Date = forwardRef((props: DateProps, externalRef: any) => {
521
524
  // STEP 1:
522
525
  //-----------
523
526
  // Detect position
524
- if (window.innerHeight - _triggerBox.top > 100) {
527
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
525
528
  targetPos = 'bottom';
526
529
  } else {
527
530
  targetPos = 'top';
@@ -88,6 +88,7 @@ const DropdownMenu = (props: DropdownMenuProps) => {
88
88
  const [isOpen, setIsOpen] = useState<boolean>(false);
89
89
  const [selected, setSelected] = useState<any>(null);
90
90
  const _hoverDelay = !isNaN(hoverDelay as never) && typeof hoverDelay !== 'undefined' ? hoverDelay : 150;
91
+ const MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
91
92
 
92
93
 
93
94
  const defaultLabel = triggerContent === undefined ? '' : triggerContent;
@@ -207,7 +208,7 @@ const DropdownMenu = (props: DropdownMenuProps) => {
207
208
  // STEP 2:
208
209
  //-----------
209
210
  // Detect position
210
- if (window.innerHeight - _triggerBox.top > 100) {
211
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
211
212
  targetPos = 'bottom';
212
213
  } else {
213
214
  targetPos = 'top';
@@ -153,6 +153,7 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
153
153
  const EXCEEDED_SIDE_POS_OFFSET = Number(exceededSidePosOffset) || 15;
154
154
  const AUTO_SHOW_OPTIONS = typeof autoShowOptions !== 'undefined' && autoShowOptions === true ? true : false;
155
155
  const MANUAL_REQ = typeof fetchTrigger !== 'undefined' && fetchTrigger === true ? true : false; // Manual requests
156
+ const MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
156
157
 
157
158
  const NO_MATCH_POPUP = typeof noMatchPopup === 'undefined' ? true : noMatchPopup;
158
159
  const WIN_WIDTH = typeof winWidth === 'function' ? winWidth() : winWidth ? winWidth : 'auto';
@@ -300,7 +301,7 @@ const LiveSearch = forwardRef((props: LiveSearchProps, externalRef: any) => {
300
301
  // STEP 2:
301
302
  //-----------
302
303
  // Detect position
303
- if (window.innerHeight - _triggerBox.top > 100) {
304
+ if (window.innerHeight - _triggerBox.top > MIN_SPACE_FOR_DROPDOWN) {
304
305
  targetPos = 'bottom';
305
306
  } else {
306
307
  targetPos = 'top';
@@ -47,7 +47,6 @@ import {
47
47
  import { clsWrite, combinedCls } from 'funda-utils/dist/cjs/cls';
48
48
 
49
49
 
50
-
51
50
  export interface MultiSelectValue {
52
51
  items: { label: string; value: string }[];
53
52
  labels: string[];
@@ -109,6 +108,7 @@ export type SelectProps = {
109
108
  controlClassName?: string;
110
109
  controlExClassName?: string;
111
110
  optionsExClassName?: string;
111
+ customScrollContainer?: string | HTMLElement | React.RefObject<HTMLElement>;
112
112
  exceededSidePosOffset?: number;
113
113
  clearIcon?: boolean;
114
114
  renderOption?: (optionData: OptionConfig, index: number) => React.ReactNode;
@@ -188,6 +188,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
188
188
  controlClassName,
189
189
  controlExClassName,
190
190
  optionsExClassName,
191
+ customScrollContainer,
191
192
  exceededSidePosOffset,
192
193
  clearIcon,
193
194
  renderOption,
@@ -265,6 +266,7 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
265
266
  const listContentRef = useRef<any>(null);
266
267
  const optionsRes = options ? (isJSON(options) ? JSON.parse(options as string) : options) : [];
267
268
  const LIST_CONTAINER_MAX_HEIGHT = 300;
269
+ const MIN_SPACE_FOR_DROPDOWN = 200; // Minimum space needed to show dropdown below trigger
268
270
 
269
271
  const keyboardSelectedItem = useRef<any>(null);
270
272
 
@@ -850,8 +852,38 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
850
852
  _contentOldHeight = listContainerHeightLimit(_contentOldHeight);
851
853
 
852
854
  // You need to wait for the height of the pop-up container to be set
853
- // Detect position
854
- if (window.innerHeight - _triggerBox.top > 100) {
855
+ // Detect position
856
+ let containerHeight = window.innerHeight;
857
+ let containerTop = 0;
858
+
859
+ // If custom scroll container is specified, use it instead of window
860
+ if (customScrollContainer) {
861
+ let customContainer: HTMLElement | null = null;
862
+
863
+ if (typeof customScrollContainer === 'string') {
864
+ // Handle selector string
865
+ customContainer = document.querySelector(customScrollContainer);
866
+ } else if (customScrollContainer instanceof HTMLElement) {
867
+ // Handle DOM element directly
868
+ customContainer = customScrollContainer;
869
+ } else if (customScrollContainer && 'current' in customScrollContainer) {
870
+ // Handle React ref
871
+ customContainer = customScrollContainer.current;
872
+ }
873
+
874
+ if (customContainer) {
875
+ const containerRect = customContainer.getBoundingClientRect();
876
+ containerHeight = containerRect.height;
877
+ containerTop = containerRect.top;
878
+ }
879
+ }
880
+
881
+ // Calculate available space below the trigger
882
+ const availableSpaceBelow = containerHeight - (_triggerBox.top - containerTop);
883
+
884
+ // Use a more reasonable threshold for position decision
885
+ // Consider the minimum space needed for a usable dropdown
886
+ if (availableSpaceBelow > MIN_SPACE_FOR_DROPDOWN) {
855
887
  targetPos = 'bottom';
856
888
  } else {
857
889
  targetPos = 'top';
@@ -865,7 +897,9 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
865
897
  //-----------
866
898
  // Set the pop-up height
867
899
  if (targetPos === 'top') {
868
- contentMaxHeight = _triggerBox.top;
900
+ // Calculate available space above the trigger
901
+ const availableSpaceAbove = _triggerBox.top - containerTop;
902
+ contentMaxHeight = availableSpaceAbove;
869
903
 
870
904
  // height restrictions
871
905
  contentMaxHeight = listContainerHeightLimit(contentMaxHeight);
@@ -892,8 +926,9 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
892
926
  }
893
927
 
894
928
  if (targetPos === 'bottom') {
895
- contentMaxHeight = window.innerHeight - _triggerBox.bottom;
896
-
929
+ // Calculate available space below the trigger
930
+ const availableSpaceBelow = containerHeight - (_triggerBox.bottom - containerTop);
931
+ contentMaxHeight = availableSpaceBelow;
897
932
 
898
933
  // height restrictions
899
934
  contentMaxHeight = listContainerHeightLimit(contentMaxHeight);
@@ -925,18 +960,18 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
925
960
  // Adjust position
926
961
  if (targetPos === 'top') {
927
962
  _modalRef.style.left = x + 'px';
928
- //_modalRef.style.top = y - POS_OFFSET - (listContentRef.current.clientHeight) - 2 + 'px';
929
- _modalRef.style.top = 'auto';
930
- _modalRef.style.bottom = (window.innerHeight - _triggerBox.top) + POS_OFFSET + 2 + 'px';
931
- _modalRef.style.setProperty('position', 'fixed', 'important');
963
+ _modalRef.style.bottom = 'auto';
964
+ // Position the popup above the trigger without overlapping
965
+ const topPosition = y - POS_OFFSET - (listContentRef.current.clientHeight) - 2;
966
+ _modalRef.style.top = topPosition + 'px';
932
967
  _modalRef.classList.add('pos-top');
968
+
933
969
  }
934
970
 
935
971
  if (targetPos === 'bottom') {
936
972
  _modalRef.style.left = x + 'px';
937
973
  _modalRef.style.bottom = 'auto';
938
974
  _modalRef.style.top = y + height + POS_OFFSET + 'px';
939
- _modalRef.style.setProperty('position', 'absolute', 'important');
940
975
  _modalRef.classList.remove('pos-top');
941
976
  }
942
977
 
@@ -949,23 +984,46 @@ const Select = forwardRef((props: SelectProps, externalRef: any) => {
949
984
  const _modalBox = _modalContent.getBoundingClientRect();
950
985
  if (typeof _modalContent.dataset.offset === 'undefined' && _modalBox.left > 0) {
951
986
 
987
+ // Get container width for boundary checking
988
+ let containerWidth = window.innerWidth;
989
+ let containerLeft = 0;
990
+
991
+ if (customScrollContainer) {
992
+ let customContainer: HTMLElement | null = null;
993
+
994
+ if (typeof customScrollContainer === 'string') {
995
+ // Handle selector string
996
+ customContainer = document.querySelector(customScrollContainer);
997
+ } else if (customScrollContainer instanceof HTMLElement) {
998
+ // Handle DOM element directly
999
+ customContainer = customScrollContainer;
1000
+ } else if (customScrollContainer && 'current' in customScrollContainer) {
1001
+ // Handle React ref
1002
+ customContainer = customScrollContainer.current;
1003
+ }
1004
+
1005
+ if (customContainer) {
1006
+ const containerRect = customContainer.getBoundingClientRect();
1007
+ containerWidth = containerRect.width;
1008
+ containerLeft = containerRect.left;
1009
+ }
1010
+ }
1011
+
952
1012
  // 10 pixels is used to account for some bias in mobile devices
953
- if ((_modalBox.right + 10) > window.innerWidth) {
954
- const _modalOffsetPosition = _modalBox.right - window.innerWidth + EXCEEDED_SIDE_POS_OFFSET;
1013
+ if ((_modalBox.right + 10) > (containerLeft + containerWidth)) {
1014
+ const _modalOffsetPosition = _modalBox.right - (containerLeft + containerWidth) + EXCEEDED_SIDE_POS_OFFSET;
955
1015
  _modalContent.dataset.offset = _modalOffsetPosition;
956
1016
  _modalContent.style.marginLeft = `-${_modalOffsetPosition}px`;
957
1017
  // console.log('_modalPosition: ', _modalOffsetPosition)
958
1018
  }
959
1019
 
960
-
961
- if ((_modalBox.left - 10) < 0) {
962
- const _modalOffsetPosition = Math.abs(_modalBox.left) + EXCEEDED_SIDE_POS_OFFSET;
1020
+ if ((_modalBox.left - 10) < containerLeft) {
1021
+ const _modalOffsetPosition = Math.abs(_modalBox.left - containerLeft) + EXCEEDED_SIDE_POS_OFFSET;
963
1022
  _modalContent.dataset.offset = _modalOffsetPosition;
964
1023
  _modalContent.style.marginLeft = `${_modalOffsetPosition}px`;
965
1024
  // console.log('_modalPosition: ', _modalOffsetPosition)
966
1025
  }
967
1026
 
968
-
969
1027
  }
970
1028
 
971
1029
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "UIUX Lab",
3
3
  "email": "uiuxlab@gmail.com",
4
4
  "name": "funda-ui",
5
- "version": "4.7.525",
5
+ "version": "4.7.533",
6
6
  "description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
7
7
  "repository": {
8
8
  "type": "git",