@smilodon/core 1.0.11 → 1.0.13

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/index.umd.js CHANGED
@@ -965,10 +965,18 @@
965
965
  this._hasError = false;
966
966
  this._errorMessage = '';
967
967
  this._boundArrowClick = null;
968
+ console.log('[EnhancedSelect] Constructor called');
969
+ // WORKAROUND: Force display style on host element for Angular compatibility
970
+ // Angular's rendering seems to not apply :host styles correctly in some cases
971
+ this.style.display = 'block';
972
+ this.style.width = '100%';
973
+ console.log('[EnhancedSelect] Forced host display styles');
968
974
  this._shadow = this.attachShadow({ mode: 'open' });
975
+ console.log('[EnhancedSelect] Shadow root attached:', this._shadow);
969
976
  this._uniqueId = `enhanced-select-${Math.random().toString(36).substr(2, 9)}`;
970
977
  // Merge global config with component-level config
971
978
  this._config = selectConfig.getConfig();
979
+ console.log('[EnhancedSelect] Config loaded');
972
980
  // Initialize state
973
981
  this._state = {
974
982
  isOpen: false,
@@ -988,20 +996,34 @@
988
996
  lastNotifiedResultCount: 0,
989
997
  isExpanded: false,
990
998
  };
999
+ console.log('[EnhancedSelect] State initialized');
991
1000
  // Create DOM structure
992
1001
  this._container = this._createContainer();
1002
+ console.log('[EnhancedSelect] Container created:', this._container);
993
1003
  this._inputContainer = this._createInputContainer();
1004
+ console.log('[EnhancedSelect] Input container created');
994
1005
  this._input = this._createInput();
1006
+ console.log('[EnhancedSelect] Input created:', this._input);
995
1007
  this._arrowContainer = this._createArrowContainer();
1008
+ console.log('[EnhancedSelect] Arrow container created');
996
1009
  this._dropdown = this._createDropdown();
1010
+ console.log('[EnhancedSelect] Dropdown created');
997
1011
  this._optionsContainer = this._createOptionsContainer();
1012
+ console.log('[EnhancedSelect] Options container created');
998
1013
  this._liveRegion = this._createLiveRegion();
1014
+ console.log('[EnhancedSelect] Live region created');
999
1015
  this._assembleDOM();
1016
+ console.log('[EnhancedSelect] DOM assembled');
1000
1017
  this._initializeStyles();
1018
+ console.log('[EnhancedSelect] Styles initialized');
1001
1019
  this._attachEventListeners();
1020
+ console.log('[EnhancedSelect] Event listeners attached');
1002
1021
  this._initializeObservers();
1022
+ console.log('[EnhancedSelect] Observers initialized');
1023
+ console.log('[EnhancedSelect] Constructor complete, shadow DOM children:', this._shadow.children.length);
1003
1024
  }
1004
1025
  connectedCallback() {
1026
+ console.log('[EnhancedSelect] connectedCallback called');
1005
1027
  // Load initial data if server-side is enabled
1006
1028
  if (this._config.serverSide.enabled && this._config.serverSide.initialSelectedValues) {
1007
1029
  this._loadInitialSelectedItems();
@@ -1010,6 +1032,7 @@
1010
1032
  if (this._config.callbacks.onOpen) {
1011
1033
  this._config.callbacks.onOpen();
1012
1034
  }
1035
+ console.log('[EnhancedSelect] connectedCallback complete');
1013
1036
  }
1014
1037
  disconnectedCallback() {
1015
1038
  // Cleanup observers
@@ -1107,22 +1130,43 @@
1107
1130
  return container;
1108
1131
  }
1109
1132
  _assembleDOM() {
1133
+ console.log('[EnhancedSelect] _assembleDOM: Starting DOM assembly');
1134
+ console.log('[EnhancedSelect] _assembleDOM: Elements to assemble:', {
1135
+ inputContainer: !!this._inputContainer,
1136
+ input: !!this._input,
1137
+ arrowContainer: !!this._arrowContainer,
1138
+ container: !!this._container,
1139
+ dropdown: !!this._dropdown,
1140
+ optionsContainer: !!this._optionsContainer,
1141
+ shadow: !!this._shadow,
1142
+ liveRegion: !!this._liveRegion
1143
+ });
1110
1144
  this._inputContainer.appendChild(this._input);
1145
+ console.log('[EnhancedSelect] _assembleDOM: Appended input to inputContainer');
1111
1146
  if (this._arrowContainer) {
1112
1147
  this._inputContainer.appendChild(this._arrowContainer);
1148
+ console.log('[EnhancedSelect] _assembleDOM: Appended arrowContainer to inputContainer');
1113
1149
  }
1114
1150
  this._container.appendChild(this._inputContainer);
1151
+ console.log('[EnhancedSelect] _assembleDOM: Appended inputContainer to container');
1115
1152
  this._dropdown.appendChild(this._optionsContainer);
1153
+ console.log('[EnhancedSelect] _assembleDOM: Appended optionsContainer to dropdown');
1116
1154
  this._container.appendChild(this._dropdown);
1155
+ console.log('[EnhancedSelect] _assembleDOM: Appended dropdown to container');
1117
1156
  this._shadow.appendChild(this._container);
1157
+ console.log('[EnhancedSelect] _assembleDOM: Appended container to shadow root');
1118
1158
  if (this._liveRegion) {
1119
1159
  this._shadow.appendChild(this._liveRegion);
1160
+ console.log('[EnhancedSelect] _assembleDOM: Appended liveRegion to shadow root');
1120
1161
  }
1162
+ console.log('[EnhancedSelect] _assembleDOM: Shadow root children count:', this._shadow.children.length);
1163
+ console.log('[EnhancedSelect] _assembleDOM: Shadow root HTML length:', this._shadow.innerHTML.length);
1121
1164
  // Set ARIA relationships
1122
1165
  const listboxId = `${this._uniqueId}-listbox`;
1123
1166
  this._dropdown.id = listboxId;
1124
1167
  this._input.setAttribute('aria-controls', listboxId);
1125
1168
  this._input.setAttribute('aria-owns', listboxId);
1169
+ console.log('[EnhancedSelect] _assembleDOM: Set ARIA relationships with listboxId:', listboxId);
1126
1170
  }
1127
1171
  _initializeStyles() {
1128
1172
  const style = document.createElement('style');
@@ -1279,39 +1323,19 @@
1279
1323
  right: 0;
1280
1324
  margin-top: 4px;
1281
1325
  max-height: 300px;
1282
- display: flex;
1283
- flex-direction: column;
1326
+ overflow: hidden;
1284
1327
  background: var(--select-dropdown-bg, white);
1285
1328
  border: 1px solid var(--select-dropdown-border, #ccc);
1286
1329
  border-radius: var(--select-border-radius, 4px);
1287
1330
  box-shadow: var(--select-dropdown-shadow, 0 4px 6px rgba(0,0,0,0.1));
1288
1331
  z-index: var(--select-dropdown-z-index, 1000);
1289
- transition: max-height 0.3s ease-in-out;
1290
1332
  }
1291
1333
 
1292
1334
  .options-container {
1293
1335
  position: relative;
1336
+ max-height: 300px;
1337
+ overflow: auto;
1294
1338
  transition: opacity 0.2s ease-in-out;
1295
- overflow-y: auto;
1296
- flex: 1;
1297
- }
1298
-
1299
- .expand-toggle {
1300
- padding: 8px;
1301
- text-align: center;
1302
- background: #f9fafb;
1303
- border-top: 1px solid #e5e7eb;
1304
- cursor: pointer;
1305
- font-size: 12px;
1306
- color: #6b7280;
1307
- font-weight: 500;
1308
- transition: background 0.2s;
1309
- flex-shrink: 0;
1310
- }
1311
-
1312
- .expand-toggle:hover {
1313
- background: #f3f4f6;
1314
- color: #374151;
1315
1339
  }
1316
1340
 
1317
1341
  .option {
@@ -1472,7 +1496,11 @@
1472
1496
  min-height: 44px;
1473
1497
  }
1474
1498
  `;
1499
+ console.log('[EnhancedSelect] _initializeStyles: Created style element, content length:', style.textContent?.length || 0);
1500
+ console.log('[EnhancedSelect] _initializeStyles: Appending style to shadow root...');
1475
1501
  this._shadow.appendChild(style);
1502
+ console.log('[EnhancedSelect] _initializeStyles: Style appended, shadow root children:', this._shadow.children.length);
1503
+ console.log('[EnhancedSelect] _initializeStyles: Shadow root has style element:', !!this._shadow.querySelector('style'));
1476
1504
  }
1477
1505
  _attachEventListeners() {
1478
1506
  // Arrow click handler
@@ -1574,13 +1602,6 @@
1574
1602
  return;
1575
1603
  this._state.isOpen = true;
1576
1604
  this._dropdown.style.display = 'block';
1577
- // Set initial height based on expandable config
1578
- if (this._config.expandable.enabled) {
1579
- const height = this._state.isExpanded
1580
- ? (this._config.expandable.expandedHeight || '500px')
1581
- : (this._config.expandable.collapsedHeight || '300px');
1582
- this._dropdown.style.maxHeight = height;
1583
- }
1584
1605
  this._input.setAttribute('aria-expanded', 'true');
1585
1606
  this._updateArrowRotation();
1586
1607
  // Clear search query when opening to show all options
@@ -2055,21 +2076,27 @@
2055
2076
  * Set items to display in the select
2056
2077
  */
2057
2078
  setItems(items) {
2079
+ console.log('[EnhancedSelect] setItems called with', items?.length || 0, 'items');
2080
+ console.log('[EnhancedSelect] Items:', items);
2058
2081
  const previousLength = this._state.loadedItems.length;
2059
2082
  this._state.loadedItems = items;
2060
2083
  // If grouped items exist, flatten them to items
2061
2084
  if (this._state.groupedItems.length > 0) {
2062
2085
  this._state.loadedItems = this._state.groupedItems.flatMap(group => group.options);
2086
+ console.log('[EnhancedSelect] Flattened grouped items to', this._state.loadedItems.length, 'items');
2063
2087
  }
2064
2088
  const newLength = this._state.loadedItems.length;
2089
+ console.log('[EnhancedSelect] State.loadedItems updated:', previousLength, '→', newLength);
2065
2090
  // When infinite scroll is active (preserveScrollPosition = true),
2066
2091
  // we need to maintain scroll position during the update
2067
2092
  if (this._state.preserveScrollPosition && this._dropdown) {
2068
2093
  const targetScrollTop = this._state.lastScrollPosition;
2094
+ console.log('[EnhancedSelect] Preserving scroll position:', targetScrollTop);
2069
2095
  // Only clear loading if we actually got more items
2070
2096
  if (newLength > previousLength) {
2071
2097
  this._state.isBusy = false;
2072
2098
  }
2099
+ console.log('[EnhancedSelect] Calling _renderOptions (with scroll preservation)...');
2073
2100
  this._renderOptions();
2074
2101
  // Restore the exact scrollTop we had before loading
2075
2102
  // so the previously visible items stay in place and
@@ -2089,8 +2116,10 @@
2089
2116
  else {
2090
2117
  // Normal update - just render normally
2091
2118
  this._state.isBusy = false;
2119
+ console.log('[EnhancedSelect] Calling _renderOptions (normal)...');
2092
2120
  this._renderOptions();
2093
2121
  }
2122
+ console.log('[EnhancedSelect] setItems complete');
2094
2123
  }
2095
2124
  /**
2096
2125
  * Set grouped items
@@ -2254,11 +2283,21 @@
2254
2283
  * Render options based on current state
2255
2284
  */
2256
2285
  _renderOptions() {
2286
+ console.log('[EnhancedSelect] _renderOptions called');
2287
+ console.log('[EnhancedSelect] State:', {
2288
+ loadedItems: this._state.loadedItems.length,
2289
+ groupedItems: this._state.groupedItems.length,
2290
+ isOpen: this._state.isOpen,
2291
+ isSearching: this._state.isSearching,
2292
+ searchQuery: this._state.searchQuery,
2293
+ isBusy: this._state.isBusy
2294
+ });
2257
2295
  // Cleanup observer
2258
2296
  if (this._loadMoreTrigger && this._intersectionObserver) {
2259
2297
  this._intersectionObserver.unobserve(this._loadMoreTrigger);
2260
2298
  }
2261
2299
  // Clear options container
2300
+ console.log('[EnhancedSelect] Clearing options container, previous children:', this._optionsContainer.children.length);
2262
2301
  this._optionsContainer.innerHTML = '';
2263
2302
  // Ensure dropdown only contains options container (cleanup legacy direct children)
2264
2303
  // We need to preserve optionsContainer, so we can't just clear dropdown.innerHTML
@@ -2271,6 +2310,7 @@
2271
2310
  // Ensure dropdown is visible if we are rendering options
2272
2311
  if (this._state.isOpen && this._dropdown.style.display === 'none') {
2273
2312
  this._dropdown.style.display = 'block';
2313
+ console.log('[EnhancedSelect] Dropdown display set to block');
2274
2314
  }
2275
2315
  // Show searching state (exclusive state)
2276
2316
  if (this._state.isSearching) {
@@ -2278,6 +2318,7 @@
2278
2318
  searching.className = 'searching-state';
2279
2319
  searching.textContent = 'Searching...';
2280
2320
  this._optionsContainer.appendChild(searching);
2321
+ console.log('[EnhancedSelect] Added searching state');
2281
2322
  return;
2282
2323
  }
2283
2324
  const getValue = this._config.serverSide.getValueFromItem || ((item) => item?.value ?? item);
@@ -2286,6 +2327,7 @@
2286
2327
  const query = this._state.searchQuery.toLowerCase();
2287
2328
  // Handle Grouped Items Rendering (when no search query)
2288
2329
  if (this._state.groupedItems.length > 0 && !query) {
2330
+ console.log('[EnhancedSelect] Rendering grouped items:', this._state.groupedItems.length, 'groups');
2289
2331
  this._state.groupedItems.forEach(group => {
2290
2332
  const header = document.createElement('div');
2291
2333
  header.className = 'group-header';
@@ -2315,6 +2357,7 @@
2315
2357
  }
2316
2358
  else {
2317
2359
  // Normal rendering (flat list or filtered)
2360
+ console.log('[EnhancedSelect] Rendering flat list:', this._state.loadedItems.length, 'items');
2318
2361
  let hasRenderedItems = false;
2319
2362
  this._state.loadedItems.forEach((item, index) => {
2320
2363
  // Apply filter if query exists
@@ -2331,6 +2374,7 @@
2331
2374
  hasRenderedItems = true;
2332
2375
  this._renderSingleOption(item, index, getValue, getLabel);
2333
2376
  });
2377
+ console.log('[EnhancedSelect] Rendered', hasRenderedItems ? 'items' : 'no items');
2334
2378
  if (!hasRenderedItems && !this._state.isBusy) {
2335
2379
  const empty = document.createElement('div');
2336
2380
  empty.className = 'empty-state';
@@ -2341,6 +2385,7 @@
2341
2385
  empty.textContent = 'No options available';
2342
2386
  }
2343
2387
  this._optionsContainer.appendChild(empty);
2388
+ console.log('[EnhancedSelect] Added empty state');
2344
2389
  }
2345
2390
  }
2346
2391
  // Append Busy Indicator if busy
@@ -2358,41 +2403,13 @@
2358
2403
  busyBucket.appendChild(message);
2359
2404
  }
2360
2405
  this._optionsContainer.appendChild(busyBucket);
2406
+ console.log('[EnhancedSelect] Added busy bucket');
2361
2407
  }
2362
2408
  // Append Load More Trigger (Button or Sentinel) if enabled and not busy
2363
2409
  else if ((this._config.loadMore.enabled || this._config.infiniteScroll.enabled) && this._state.loadedItems.length > 0) {
2364
2410
  this._addLoadMoreTrigger();
2365
2411
  }
2366
- // Render Expand Button if enabled
2367
- if (this._config.expandable.enabled) {
2368
- this._renderExpandButton();
2369
- }
2370
- }
2371
- _renderExpandButton() {
2372
- const button = document.createElement('div');
2373
- button.className = 'expand-toggle';
2374
- button.textContent = this._state.isExpanded
2375
- ? (this._config.expandable.collapseLabel || 'Show less')
2376
- : (this._config.expandable.expandLabel || 'Show more');
2377
- button.addEventListener('click', (e) => {
2378
- e.stopPropagation(); // Prevent closing dropdown
2379
- this._toggleExpand();
2380
- });
2381
- this._dropdown.appendChild(button);
2382
- }
2383
- _toggleExpand() {
2384
- this._state.isExpanded = !this._state.isExpanded;
2385
- const height = this._state.isExpanded
2386
- ? (this._config.expandable.expandedHeight || '500px')
2387
- : (this._config.expandable.collapsedHeight || '300px');
2388
- this._dropdown.style.maxHeight = height;
2389
- // Re-render button to update label
2390
- const existingButton = this._dropdown.querySelector('.expand-toggle');
2391
- if (existingButton) {
2392
- existingButton.textContent = this._state.isExpanded
2393
- ? (this._config.expandable.collapseLabel || 'Show less')
2394
- : (this._config.expandable.expandLabel || 'Show more');
2395
- }
2412
+ console.log('[EnhancedSelect] _renderOptions complete, optionsContainer children:', this._optionsContainer.children.length);
2396
2413
  }
2397
2414
  _renderSingleOption(item, index, getValue, getLabel) {
2398
2415
  const option = document.createElement('div');
@@ -2400,6 +2417,7 @@
2400
2417
  option.id = `${this._uniqueId}-option-${index}`;
2401
2418
  const value = getValue(item);
2402
2419
  const label = getLabel(item);
2420
+ console.log('[EnhancedSelect] Rendering option', index, ':', { value, label });
2403
2421
  option.textContent = label;
2404
2422
  option.dataset.value = String(value);
2405
2423
  option.dataset.index = String(index); // Also useful for debugging/selectors
@@ -2416,6 +2434,7 @@
2416
2434
  this._selectOption(index);
2417
2435
  });
2418
2436
  this._optionsContainer.appendChild(option);
2437
+ console.log('[EnhancedSelect] Option', index, 'appended to optionsContainer');
2419
2438
  }
2420
2439
  _addLoadMoreTrigger() {
2421
2440
  const container = document.createElement('div');