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