@smilodon/core 1.0.10 → 1.0.12

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
@@ -869,6 +869,13 @@
869
869
  preloadAdjacent: true,
870
870
  scrollRestoration: 'auto',
871
871
  },
872
+ expandable: {
873
+ enabled: false,
874
+ collapsedHeight: '300px',
875
+ expandedHeight: '500px',
876
+ expandLabel: 'Show more',
877
+ collapseLabel: 'Show less',
878
+ },
872
879
  callbacks: {},
873
880
  enabled: true,
874
881
  searchable: false,
@@ -958,10 +965,13 @@
958
965
  this._hasError = false;
959
966
  this._errorMessage = '';
960
967
  this._boundArrowClick = null;
968
+ console.log('[EnhancedSelect] Constructor called');
961
969
  this._shadow = this.attachShadow({ mode: 'open' });
970
+ console.log('[EnhancedSelect] Shadow root attached:', this._shadow);
962
971
  this._uniqueId = `enhanced-select-${Math.random().toString(36).substr(2, 9)}`;
963
972
  // Merge global config with component-level config
964
973
  this._config = selectConfig.getConfig();
974
+ console.log('[EnhancedSelect] Config loaded');
965
975
  // Initialize state
966
976
  this._state = {
967
977
  isOpen: false,
@@ -979,21 +989,36 @@
979
989
  lastScrollPosition: 0,
980
990
  lastNotifiedQuery: null,
981
991
  lastNotifiedResultCount: 0,
992
+ isExpanded: false,
982
993
  };
994
+ console.log('[EnhancedSelect] State initialized');
983
995
  // Create DOM structure
984
996
  this._container = this._createContainer();
997
+ console.log('[EnhancedSelect] Container created:', this._container);
985
998
  this._inputContainer = this._createInputContainer();
999
+ console.log('[EnhancedSelect] Input container created');
986
1000
  this._input = this._createInput();
1001
+ console.log('[EnhancedSelect] Input created:', this._input);
987
1002
  this._arrowContainer = this._createArrowContainer();
1003
+ console.log('[EnhancedSelect] Arrow container created');
988
1004
  this._dropdown = this._createDropdown();
1005
+ console.log('[EnhancedSelect] Dropdown created');
989
1006
  this._optionsContainer = this._createOptionsContainer();
1007
+ console.log('[EnhancedSelect] Options container created');
990
1008
  this._liveRegion = this._createLiveRegion();
1009
+ console.log('[EnhancedSelect] Live region created');
991
1010
  this._assembleDOM();
1011
+ console.log('[EnhancedSelect] DOM assembled');
992
1012
  this._initializeStyles();
1013
+ console.log('[EnhancedSelect] Styles initialized');
993
1014
  this._attachEventListeners();
1015
+ console.log('[EnhancedSelect] Event listeners attached');
994
1016
  this._initializeObservers();
1017
+ console.log('[EnhancedSelect] Observers initialized');
1018
+ console.log('[EnhancedSelect] Constructor complete, shadow DOM children:', this._shadow.children.length);
995
1019
  }
996
1020
  connectedCallback() {
1021
+ console.log('[EnhancedSelect] connectedCallback called');
997
1022
  // Load initial data if server-side is enabled
998
1023
  if (this._config.serverSide.enabled && this._config.serverSide.initialSelectedValues) {
999
1024
  this._loadInitialSelectedItems();
@@ -1002,6 +1027,7 @@
1002
1027
  if (this._config.callbacks.onOpen) {
1003
1028
  this._config.callbacks.onOpen();
1004
1029
  }
1030
+ console.log('[EnhancedSelect] connectedCallback complete');
1005
1031
  }
1006
1032
  disconnectedCallback() {
1007
1033
  // Cleanup observers
@@ -1099,22 +1125,43 @@
1099
1125
  return container;
1100
1126
  }
1101
1127
  _assembleDOM() {
1128
+ console.log('[EnhancedSelect] _assembleDOM: Starting DOM assembly');
1129
+ console.log('[EnhancedSelect] _assembleDOM: Elements to assemble:', {
1130
+ inputContainer: !!this._inputContainer,
1131
+ input: !!this._input,
1132
+ arrowContainer: !!this._arrowContainer,
1133
+ container: !!this._container,
1134
+ dropdown: !!this._dropdown,
1135
+ optionsContainer: !!this._optionsContainer,
1136
+ shadow: !!this._shadow,
1137
+ liveRegion: !!this._liveRegion
1138
+ });
1102
1139
  this._inputContainer.appendChild(this._input);
1140
+ console.log('[EnhancedSelect] _assembleDOM: Appended input to inputContainer');
1103
1141
  if (this._arrowContainer) {
1104
1142
  this._inputContainer.appendChild(this._arrowContainer);
1143
+ console.log('[EnhancedSelect] _assembleDOM: Appended arrowContainer to inputContainer');
1105
1144
  }
1106
1145
  this._container.appendChild(this._inputContainer);
1146
+ console.log('[EnhancedSelect] _assembleDOM: Appended inputContainer to container');
1107
1147
  this._dropdown.appendChild(this._optionsContainer);
1148
+ console.log('[EnhancedSelect] _assembleDOM: Appended optionsContainer to dropdown');
1108
1149
  this._container.appendChild(this._dropdown);
1150
+ console.log('[EnhancedSelect] _assembleDOM: Appended dropdown to container');
1109
1151
  this._shadow.appendChild(this._container);
1152
+ console.log('[EnhancedSelect] _assembleDOM: Appended container to shadow root');
1110
1153
  if (this._liveRegion) {
1111
1154
  this._shadow.appendChild(this._liveRegion);
1155
+ console.log('[EnhancedSelect] _assembleDOM: Appended liveRegion to shadow root');
1112
1156
  }
1157
+ console.log('[EnhancedSelect] _assembleDOM: Shadow root children count:', this._shadow.children.length);
1158
+ console.log('[EnhancedSelect] _assembleDOM: Shadow root HTML length:', this._shadow.innerHTML.length);
1113
1159
  // Set ARIA relationships
1114
1160
  const listboxId = `${this._uniqueId}-listbox`;
1115
1161
  this._dropdown.id = listboxId;
1116
1162
  this._input.setAttribute('aria-controls', listboxId);
1117
1163
  this._input.setAttribute('aria-owns', listboxId);
1164
+ console.log('[EnhancedSelect] _assembleDOM: Set ARIA relationships with listboxId:', listboxId);
1118
1165
  }
1119
1166
  _initializeStyles() {
1120
1167
  const style = document.createElement('style');
@@ -1271,7 +1318,7 @@
1271
1318
  right: 0;
1272
1319
  margin-top: 4px;
1273
1320
  max-height: 300px;
1274
- overflow-y: auto;
1321
+ overflow: hidden;
1275
1322
  background: var(--select-dropdown-bg, white);
1276
1323
  border: 1px solid var(--select-dropdown-border, #ccc);
1277
1324
  border-radius: var(--select-border-radius, 4px);
@@ -1281,6 +1328,8 @@
1281
1328
 
1282
1329
  .options-container {
1283
1330
  position: relative;
1331
+ max-height: 300px;
1332
+ overflow: auto;
1284
1333
  transition: opacity 0.2s ease-in-out;
1285
1334
  }
1286
1335
 
@@ -1442,7 +1491,11 @@
1442
1491
  min-height: 44px;
1443
1492
  }
1444
1493
  `;
1494
+ console.log('[EnhancedSelect] _initializeStyles: Created style element, content length:', style.textContent?.length || 0);
1495
+ console.log('[EnhancedSelect] _initializeStyles: Appending style to shadow root...');
1445
1496
  this._shadow.appendChild(style);
1497
+ console.log('[EnhancedSelect] _initializeStyles: Style appended, shadow root children:', this._shadow.children.length);
1498
+ console.log('[EnhancedSelect] _initializeStyles: Shadow root has style element:', !!this._shadow.querySelector('style'));
1446
1499
  }
1447
1500
  _attachEventListeners() {
1448
1501
  // Arrow click handler
@@ -2018,21 +2071,27 @@
2018
2071
  * Set items to display in the select
2019
2072
  */
2020
2073
  setItems(items) {
2074
+ console.log('[EnhancedSelect] setItems called with', items?.length || 0, 'items');
2075
+ console.log('[EnhancedSelect] Items:', items);
2021
2076
  const previousLength = this._state.loadedItems.length;
2022
2077
  this._state.loadedItems = items;
2023
2078
  // If grouped items exist, flatten them to items
2024
2079
  if (this._state.groupedItems.length > 0) {
2025
2080
  this._state.loadedItems = this._state.groupedItems.flatMap(group => group.options);
2081
+ console.log('[EnhancedSelect] Flattened grouped items to', this._state.loadedItems.length, 'items');
2026
2082
  }
2027
2083
  const newLength = this._state.loadedItems.length;
2084
+ console.log('[EnhancedSelect] State.loadedItems updated:', previousLength, '→', newLength);
2028
2085
  // When infinite scroll is active (preserveScrollPosition = true),
2029
2086
  // we need to maintain scroll position during the update
2030
2087
  if (this._state.preserveScrollPosition && this._dropdown) {
2031
2088
  const targetScrollTop = this._state.lastScrollPosition;
2089
+ console.log('[EnhancedSelect] Preserving scroll position:', targetScrollTop);
2032
2090
  // Only clear loading if we actually got more items
2033
2091
  if (newLength > previousLength) {
2034
2092
  this._state.isBusy = false;
2035
2093
  }
2094
+ console.log('[EnhancedSelect] Calling _renderOptions (with scroll preservation)...');
2036
2095
  this._renderOptions();
2037
2096
  // Restore the exact scrollTop we had before loading
2038
2097
  // so the previously visible items stay in place and
@@ -2052,8 +2111,10 @@
2052
2111
  else {
2053
2112
  // Normal update - just render normally
2054
2113
  this._state.isBusy = false;
2114
+ console.log('[EnhancedSelect] Calling _renderOptions (normal)...');
2055
2115
  this._renderOptions();
2056
2116
  }
2117
+ console.log('[EnhancedSelect] setItems complete');
2057
2118
  }
2058
2119
  /**
2059
2120
  * Set grouped items
@@ -2217,11 +2278,21 @@
2217
2278
  * Render options based on current state
2218
2279
  */
2219
2280
  _renderOptions() {
2281
+ console.log('[EnhancedSelect] _renderOptions called');
2282
+ console.log('[EnhancedSelect] State:', {
2283
+ loadedItems: this._state.loadedItems.length,
2284
+ groupedItems: this._state.groupedItems.length,
2285
+ isOpen: this._state.isOpen,
2286
+ isSearching: this._state.isSearching,
2287
+ searchQuery: this._state.searchQuery,
2288
+ isBusy: this._state.isBusy
2289
+ });
2220
2290
  // Cleanup observer
2221
2291
  if (this._loadMoreTrigger && this._intersectionObserver) {
2222
2292
  this._intersectionObserver.unobserve(this._loadMoreTrigger);
2223
2293
  }
2224
2294
  // Clear options container
2295
+ console.log('[EnhancedSelect] Clearing options container, previous children:', this._optionsContainer.children.length);
2225
2296
  this._optionsContainer.innerHTML = '';
2226
2297
  // Ensure dropdown only contains options container (cleanup legacy direct children)
2227
2298
  // We need to preserve optionsContainer, so we can't just clear dropdown.innerHTML
@@ -2234,6 +2305,7 @@
2234
2305
  // Ensure dropdown is visible if we are rendering options
2235
2306
  if (this._state.isOpen && this._dropdown.style.display === 'none') {
2236
2307
  this._dropdown.style.display = 'block';
2308
+ console.log('[EnhancedSelect] Dropdown display set to block');
2237
2309
  }
2238
2310
  // Show searching state (exclusive state)
2239
2311
  if (this._state.isSearching) {
@@ -2241,6 +2313,7 @@
2241
2313
  searching.className = 'searching-state';
2242
2314
  searching.textContent = 'Searching...';
2243
2315
  this._optionsContainer.appendChild(searching);
2316
+ console.log('[EnhancedSelect] Added searching state');
2244
2317
  return;
2245
2318
  }
2246
2319
  const getValue = this._config.serverSide.getValueFromItem || ((item) => item?.value ?? item);
@@ -2249,6 +2322,7 @@
2249
2322
  const query = this._state.searchQuery.toLowerCase();
2250
2323
  // Handle Grouped Items Rendering (when no search query)
2251
2324
  if (this._state.groupedItems.length > 0 && !query) {
2325
+ console.log('[EnhancedSelect] Rendering grouped items:', this._state.groupedItems.length, 'groups');
2252
2326
  this._state.groupedItems.forEach(group => {
2253
2327
  const header = document.createElement('div');
2254
2328
  header.className = 'group-header';
@@ -2278,6 +2352,7 @@
2278
2352
  }
2279
2353
  else {
2280
2354
  // Normal rendering (flat list or filtered)
2355
+ console.log('[EnhancedSelect] Rendering flat list:', this._state.loadedItems.length, 'items');
2281
2356
  let hasRenderedItems = false;
2282
2357
  this._state.loadedItems.forEach((item, index) => {
2283
2358
  // Apply filter if query exists
@@ -2294,6 +2369,7 @@
2294
2369
  hasRenderedItems = true;
2295
2370
  this._renderSingleOption(item, index, getValue, getLabel);
2296
2371
  });
2372
+ console.log('[EnhancedSelect] Rendered', hasRenderedItems ? 'items' : 'no items');
2297
2373
  if (!hasRenderedItems && !this._state.isBusy) {
2298
2374
  const empty = document.createElement('div');
2299
2375
  empty.className = 'empty-state';
@@ -2304,6 +2380,7 @@
2304
2380
  empty.textContent = 'No options available';
2305
2381
  }
2306
2382
  this._optionsContainer.appendChild(empty);
2383
+ console.log('[EnhancedSelect] Added empty state');
2307
2384
  }
2308
2385
  }
2309
2386
  // Append Busy Indicator if busy
@@ -2321,11 +2398,13 @@
2321
2398
  busyBucket.appendChild(message);
2322
2399
  }
2323
2400
  this._optionsContainer.appendChild(busyBucket);
2401
+ console.log('[EnhancedSelect] Added busy bucket');
2324
2402
  }
2325
2403
  // Append Load More Trigger (Button or Sentinel) if enabled and not busy
2326
2404
  else if ((this._config.loadMore.enabled || this._config.infiniteScroll.enabled) && this._state.loadedItems.length > 0) {
2327
2405
  this._addLoadMoreTrigger();
2328
2406
  }
2407
+ console.log('[EnhancedSelect] _renderOptions complete, optionsContainer children:', this._optionsContainer.children.length);
2329
2408
  }
2330
2409
  _renderSingleOption(item, index, getValue, getLabel) {
2331
2410
  const option = document.createElement('div');
@@ -2333,6 +2412,7 @@
2333
2412
  option.id = `${this._uniqueId}-option-${index}`;
2334
2413
  const value = getValue(item);
2335
2414
  const label = getLabel(item);
2415
+ console.log('[EnhancedSelect] Rendering option', index, ':', { value, label });
2336
2416
  option.textContent = label;
2337
2417
  option.dataset.value = String(value);
2338
2418
  option.dataset.index = String(index); // Also useful for debugging/selectors
@@ -2349,6 +2429,7 @@
2349
2429
  this._selectOption(index);
2350
2430
  });
2351
2431
  this._optionsContainer.appendChild(option);
2432
+ console.log('[EnhancedSelect] Option', index, 'appended to optionsContainer');
2352
2433
  }
2353
2434
  _addLoadMoreTrigger() {
2354
2435
  const container = document.createElement('div');