otimus-library 0.3.46 → 0.3.47

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.
@@ -1020,6 +1020,7 @@ class OcAutocompleteComponent {
1020
1020
  this.inputWidth = 'auto';
1021
1021
  this.overlayRef = null;
1022
1022
  this.dropdownComponentRef = null;
1023
+ this.clickOutListener = null;
1023
1024
  }
1024
1025
  set ocData(value) {
1025
1026
  this._ocData = value;
@@ -1129,18 +1130,25 @@ class OcAutocompleteComponent {
1129
1130
  }, 50);
1130
1131
  }
1131
1132
  closeOnClickOut() {
1132
- this.renderer.listen('window', 'click', (e) => {
1133
- const target = e.target;
1134
- const insideCounterSelect = this.ocType === 'counterSelect' && target.closest('.oc-counter-select');
1135
- const insideDropdown = target.closest('.oc-autocomplete-dropdown-container');
1136
- if (this.input && !insideCounterSelect && !insideDropdown) {
1137
- if (target !== this.input.nativeElement && this.isOptionsShown) {
1138
- this.isOptionsShown = false;
1139
- this.closeOverlay();
1140
- this.findByTyping();
1133
+ if (this.clickOutListener) {
1134
+ this.clickOutListener();
1135
+ this.clickOutListener = null;
1136
+ }
1137
+ setTimeout(() => {
1138
+ this.clickOutListener = this.renderer.listen('window', 'click', (e) => {
1139
+ const target = e.target;
1140
+ const insideCounterSelect = this.ocType === 'counterSelect' && target.closest('.oc-counter-select');
1141
+ const insideDropdown = target.closest('.oc-autocomplete-dropdown-container');
1142
+ const insideInput = this.input?.nativeElement?.contains(target);
1143
+ if (this.input && !insideCounterSelect && !insideDropdown && !insideInput) {
1144
+ if (target !== this.input.nativeElement && this.isOptionsShown) {
1145
+ this.isOptionsShown = false;
1146
+ this.closeOverlay();
1147
+ this.findByTyping();
1148
+ }
1141
1149
  }
1142
- }
1143
- });
1150
+ });
1151
+ }, 0);
1144
1152
  }
1145
1153
  findByTyping() {
1146
1154
  if (!this.ocValue || !this.ocValue?.toString().trim().length) {
@@ -1190,6 +1198,16 @@ class OcAutocompleteComponent {
1190
1198
  .normalize('NFD')
1191
1199
  .replace(/[\u0300-\u036f]/g, ''); // Remove marcas diacríticas
1192
1200
  }
1201
+ open() {
1202
+ if (!this.isOptionsShown) {
1203
+ this.toggleOptions();
1204
+ }
1205
+ }
1206
+ close() {
1207
+ if (this.isOptionsShown) {
1208
+ this.toggleOptions();
1209
+ }
1210
+ }
1193
1211
  toggleOptions() {
1194
1212
  this.closeOnClickOut();
1195
1213
  this.updateInputWidth();
@@ -1205,7 +1223,8 @@ class OcAutocompleteComponent {
1205
1223
  if (!this.input)
1206
1224
  return;
1207
1225
  const inputWidth = this.input.nativeElement.offsetWidth;
1208
- const positionStrategy = this.overlay.position()
1226
+ const positionStrategy = this.overlay
1227
+ .position()
1209
1228
  .flexibleConnectedTo(this.input.nativeElement)
1210
1229
  .withPositions([
1211
1230
  // Primary position: below the input
@@ -1213,15 +1232,15 @@ class OcAutocompleteComponent {
1213
1232
  originX: 'start',
1214
1233
  originY: 'bottom',
1215
1234
  overlayX: 'start',
1216
- overlayY: 'top'
1235
+ overlayY: 'top',
1217
1236
  },
1218
1237
  // Fallback position: above the input
1219
1238
  {
1220
1239
  originX: 'start',
1221
1240
  originY: 'top',
1222
1241
  overlayX: 'start',
1223
- overlayY: 'bottom'
1224
- }
1242
+ overlayY: 'bottom',
1243
+ },
1225
1244
  ])
1226
1245
  .withFlexibleDimensions(false);
1227
1246
  // Create overlay config
@@ -1230,7 +1249,7 @@ class OcAutocompleteComponent {
1230
1249
  width: inputWidth,
1231
1250
  hasBackdrop: true,
1232
1251
  backdropClass: this.ocShowBackdrop ? undefined : 'cdk-overlay-transparent-backdrop',
1233
- scrollStrategy: this.overlay.scrollStrategies.reposition()
1252
+ scrollStrategy: this.overlay.scrollStrategies.reposition(),
1234
1253
  };
1235
1254
  // Create overlay
1236
1255
  this.overlayRef = this.overlay.create(overlayConfig);