ng-tailwind 5.0.18 → 5.0.20
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/esm2020/components/ngt-select/ngt-select.component.mjs +19 -8
- package/esm2020/helpers/promise/promise-helper.mjs +4 -0
- package/fesm2015/ng-tailwind.mjs +35 -19
- package/fesm2015/ng-tailwind.mjs.map +1 -1
- package/fesm2020/ng-tailwind.mjs +21 -7
- package/fesm2020/ng-tailwind.mjs.map +1 -1
- package/helpers/promise/promise-helper.d.ts +1 -0
- package/package.json +1 -1
package/fesm2020/ng-tailwind.mjs
CHANGED
|
@@ -3028,6 +3028,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
|
|
|
3028
3028
|
args: [{ selector: '[ngt-select-header]' }]
|
|
3029
3029
|
}], ctorParameters: function () { return [{ type: i0.TemplateRef }]; } });
|
|
3030
3030
|
|
|
3031
|
+
function delay(ms) {
|
|
3032
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
3033
|
+
}
|
|
3034
|
+
|
|
3031
3035
|
class NgtSelectComponent extends NgtBaseNgModel {
|
|
3032
3036
|
constructor(ngtStylizableDirective, formContainer, ngtTranslateService, injector, ngtHttp, changeDetector, ngtForm, ngtSection, ngtModal) {
|
|
3033
3037
|
super();
|
|
@@ -3077,7 +3081,6 @@ class NgtSelectComponent extends NgtBaseNgModel {
|
|
|
3077
3081
|
this.onClear = new EventEmitter();
|
|
3078
3082
|
this.onClose = new EventEmitter();
|
|
3079
3083
|
this.nativeName = uuid();
|
|
3080
|
-
this.ngSelectItems = [];
|
|
3081
3084
|
this.componentReady = false;
|
|
3082
3085
|
this.originalPerPage = 15;
|
|
3083
3086
|
this.subscriptions = [];
|
|
@@ -3190,9 +3193,10 @@ class NgtSelectComponent extends NgtBaseNgModel {
|
|
|
3190
3193
|
this.destroySubscriptions();
|
|
3191
3194
|
}
|
|
3192
3195
|
onOpen() {
|
|
3193
|
-
const
|
|
3194
|
-
if (this.dropdownPosition == 'auto' &&
|
|
3195
|
-
|
|
3196
|
+
const parentElements = document.querySelectorAll('#ngtSelectParentContainer');
|
|
3197
|
+
if (this.dropdownPosition == 'auto' && parentElements?.length) {
|
|
3198
|
+
const parentContainer = parentElements[parentElements.length - 1];
|
|
3199
|
+
this.calculateDropdownPosition(parentContainer);
|
|
3196
3200
|
}
|
|
3197
3201
|
}
|
|
3198
3202
|
removeItem(event, item) {
|
|
@@ -3321,17 +3325,27 @@ class NgtSelectComponent extends NgtBaseNgModel {
|
|
|
3321
3325
|
disabled() {
|
|
3322
3326
|
return this.isDisabled || this.isDisabledByParent();
|
|
3323
3327
|
}
|
|
3324
|
-
calculateDropdownPosition(
|
|
3328
|
+
async calculateDropdownPosition(parentContainer) {
|
|
3329
|
+
while (!this.componentReady || this.loading || this.ngSelectComponent.showNoItemsFound()) {
|
|
3330
|
+
await delay(200);
|
|
3331
|
+
if (this.ngSelectComponent.showNoItemsFound() && !this.loading && this.componentReady) {
|
|
3332
|
+
break;
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
this.changeDetector.detectChanges();
|
|
3325
3336
|
setTimeout(() => {
|
|
3326
3337
|
const ngSelectElement = this.ngSelectComponent.element;
|
|
3327
3338
|
const ngSelectHeight = ngSelectElement.offsetHeight;
|
|
3328
3339
|
const ngSelectYPosition = ngSelectElement.getBoundingClientRect().y;
|
|
3329
3340
|
const dropdownHeight = this.ngSelectComponent.dropdownPanel.contentElementRef.nativeElement.offsetHeight;
|
|
3330
3341
|
const openedSelectHeight = ngSelectHeight + dropdownHeight;
|
|
3331
|
-
const parentYPosition =
|
|
3342
|
+
const parentYPosition = parentContainer.getBoundingClientRect().y;
|
|
3332
3343
|
const ngSelectYPositionInsideParent = ngSelectYPosition - parentYPosition;
|
|
3333
3344
|
const openedSelectTotalHeight = openedSelectHeight + ngSelectYPositionInsideParent;
|
|
3334
|
-
const
|
|
3345
|
+
const parentContainerHeight = parentContainer.clientHeight;
|
|
3346
|
+
const fitsOnTop = openedSelectHeight < ngSelectYPositionInsideParent;
|
|
3347
|
+
const fitsOnBottom = openedSelectTotalHeight < parentContainerHeight;
|
|
3348
|
+
const dropdownPosition = !fitsOnBottom && fitsOnTop
|
|
3335
3349
|
? 'top'
|
|
3336
3350
|
: 'bottom';
|
|
3337
3351
|
this.ngSelectComponent.dropdownPanel['_currentPosition'] = dropdownPosition;
|