@cuby-ui/core 0.0.617 → 0.0.618
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/components/collapsible-panel/collapsible-panel.component.d.ts +1 -1
- package/components/dropdown/dropdown.directive.d.ts +4 -2
- package/components/dropdown/dropdown.interfaces.d.ts +0 -1
- package/components/select/select.component.d.ts +1 -0
- package/components/sidebar/sidebar-header/sidebar-header.component.d.ts +1 -1
- package/components/sidebar/sidebar-navigation-item/sidebar-navigation-item.component.d.ts +1 -1
- package/esm2022/components/dropdown/dropdown.directive.mjs +36 -29
- package/esm2022/components/dropdown/dropdown.interfaces.mjs +1 -1
- package/esm2022/components/select/select.component.mjs +11 -3
- package/fesm2022/cuby-ui-core.mjs +45 -29
- package/fesm2022/cuby-ui-core.mjs.map +1 -1
- package/package.json +4 -4
- package/widgets/ui/categories/components/category-item/category-item.component.d.ts +2 -2
- package/widgets/ui/categories-tree/components/category-tree-item/category-tree-item.component.d.ts +2 -2
- package/widgets/ui/loader/components/stated-loader/stated-loader.component.d.ts +1 -1
- package/widgets/ui/storage-list/components/storage-list-item/storage-list-item.component.d.ts +1 -1
|
@@ -3286,7 +3286,6 @@ class CuiDropdownDirective {
|
|
|
3286
3286
|
this.document = inject(DOCUMENT);
|
|
3287
3287
|
this.viewContainerRef = inject(ViewContainerRef);
|
|
3288
3288
|
this.target = inject(ElementRef).nativeElement;
|
|
3289
|
-
this.window = inject(CUI_WINDOW);
|
|
3290
3289
|
this.SPACE_BETWEEN_TARGET_AND_LIST = 5;
|
|
3291
3290
|
this.CONTAINER_SELECTOR = 'cui-dropdowns';
|
|
3292
3291
|
this.DROPDOWN_SELECTOR = 'cui-dropdown';
|
|
@@ -3383,45 +3382,54 @@ class CuiDropdownDirective {
|
|
|
3383
3382
|
}
|
|
3384
3383
|
calculateDropdownPosition() {
|
|
3385
3384
|
this.element.style.visibility = 'hidden';
|
|
3386
|
-
setTimeout(() =>
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
});
|
|
3385
|
+
setTimeout(() => this.updateDropdownPosition());
|
|
3386
|
+
}
|
|
3387
|
+
updateDropdownPosition() {
|
|
3388
|
+
const targetRect = this.target.getBoundingClientRect();
|
|
3389
|
+
const containerRect = this.findScrollableContainer(this.target).getBoundingClientRect();
|
|
3390
|
+
const { clientHeight, clientWidth } = this.document.documentElement;
|
|
3391
|
+
const visibleTop = Math.max(targetRect.top, containerRect.top);
|
|
3392
|
+
const visibleBottom = Math.min(targetRect.bottom, containerRect.bottom);
|
|
3393
|
+
const shouldListAlignLeft = targetRect.left + this.element.offsetHeight > clientWidth;
|
|
3394
|
+
const orientation = this.orientation ?? (shouldListAlignLeft ? 'left' : 'right');
|
|
3395
|
+
this.changePositionX(orientation, clientWidth, targetRect);
|
|
3396
|
+
const dropdownHeight = this.element.offsetHeight;
|
|
3397
|
+
const shouldListOpenAbove = clientHeight - visibleBottom < dropdownHeight;
|
|
3398
|
+
this.changePositionY({ shouldListOpenAbove, visibleTop, visibleBottom, dropdownHeight });
|
|
3399
|
+
this.element.style.visibility = 'visible';
|
|
3402
3400
|
}
|
|
3403
3401
|
changePositionX(orientation, clientWidth, targetRect) {
|
|
3404
3402
|
switch (orientation) {
|
|
3405
3403
|
case 'right':
|
|
3406
3404
|
this.element.style.left = 'auto';
|
|
3407
|
-
this.
|
|
3405
|
+
this.changePositionRight(targetRect.right, clientWidth);
|
|
3408
3406
|
break;
|
|
3409
3407
|
case 'stretch':
|
|
3410
|
-
this.
|
|
3411
|
-
this.
|
|
3408
|
+
this.changePositionLeft(targetRect.left);
|
|
3409
|
+
this.changePositionRight(targetRect.right, clientWidth);
|
|
3412
3410
|
break;
|
|
3413
3411
|
default:
|
|
3414
3412
|
this.element.style.right = 'auto';
|
|
3415
|
-
this.
|
|
3413
|
+
this.changePositionLeft(targetRect.left);
|
|
3416
3414
|
}
|
|
3417
3415
|
}
|
|
3418
|
-
|
|
3416
|
+
changePositionLeft(left) {
|
|
3417
|
+
this.element.style.left = `${left}px`;
|
|
3418
|
+
const offsetLeft = this.element.getBoundingClientRect().left - left;
|
|
3419
|
+
this.element.style.left = `${left - offsetLeft}px`;
|
|
3420
|
+
}
|
|
3421
|
+
changePositionRight(right, clientWidth) {
|
|
3422
|
+
const position = clientWidth - right;
|
|
3423
|
+
this.element.style.right = `${position}px`;
|
|
3424
|
+
const offsetRight = this.element.getBoundingClientRect().right - right;
|
|
3425
|
+
this.element.style.right = `${position + offsetRight}px`;
|
|
3426
|
+
}
|
|
3427
|
+
changePositionY({ shouldListOpenAbove, visibleTop, visibleBottom, dropdownHeight }) {
|
|
3419
3428
|
const offset = this.SPACE_BETWEEN_TARGET_AND_LIST;
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
}
|
|
3424
|
-
this.element.style.top = `${windowScrollY + visibleBottom + offset}px`;
|
|
3429
|
+
const top = shouldListOpenAbove ? visibleTop - dropdownHeight - offset : visibleBottom + offset;
|
|
3430
|
+
this.element.style.top = `${top}px`;
|
|
3431
|
+
const offsetTop = this.element.getBoundingClientRect().top - top;
|
|
3432
|
+
this.element.style.top = `${top - offsetTop}px`;
|
|
3425
3433
|
}
|
|
3426
3434
|
findScrollableContainer(element) {
|
|
3427
3435
|
let parent = element.parentElement;
|
|
@@ -4298,8 +4306,16 @@ class CuiSelectComponent {
|
|
|
4298
4306
|
const distanceToBottom = viewport.clientHeight - target.bottom - this.SPACE_BETWEEN_BUTTON_AND_OPTIONS;
|
|
4299
4307
|
const left = Math.max(this.VIEWPORT_PADDING, Math.min(target.left, viewport.clientWidth - optionsList.width - this.VIEWPORT_PADDING));
|
|
4300
4308
|
this.isOptionsListAbove = distanceToBottom < optionsList.height && target.top > distanceToBottom;
|
|
4301
|
-
node
|
|
4302
|
-
|
|
4309
|
+
this.changeOptionsListPosition(node, left, this.getOptionsListTop(target, optionsList));
|
|
4310
|
+
}
|
|
4311
|
+
changeOptionsListPosition(node, left, top) {
|
|
4312
|
+
node.style.left = `${left}px`;
|
|
4313
|
+
node.style.top = `${top}px`;
|
|
4314
|
+
const position = node.getBoundingClientRect();
|
|
4315
|
+
const offsetLeft = position.left - left;
|
|
4316
|
+
const offsetTop = position.top - top;
|
|
4317
|
+
node.style.left = `${left - offsetLeft}px`;
|
|
4318
|
+
node.style.top = `${top - offsetTop}px`;
|
|
4303
4319
|
}
|
|
4304
4320
|
getOptionsListTop(target, optionsList) {
|
|
4305
4321
|
if (this.isOptionsListAbove) {
|