@smilodon/core 1.0.11 → 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.cjs +74 -60
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +74 -60
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +74 -60
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/components/enhanced-select.d.ts +0 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -961,10 +961,13 @@ class EnhancedSelect extends HTMLElement {
|
|
|
961
961
|
this._hasError = false;
|
|
962
962
|
this._errorMessage = '';
|
|
963
963
|
this._boundArrowClick = null;
|
|
964
|
+
console.log('[EnhancedSelect] Constructor called');
|
|
964
965
|
this._shadow = this.attachShadow({ mode: 'open' });
|
|
966
|
+
console.log('[EnhancedSelect] Shadow root attached:', this._shadow);
|
|
965
967
|
this._uniqueId = `enhanced-select-${Math.random().toString(36).substr(2, 9)}`;
|
|
966
968
|
// Merge global config with component-level config
|
|
967
969
|
this._config = selectConfig.getConfig();
|
|
970
|
+
console.log('[EnhancedSelect] Config loaded');
|
|
968
971
|
// Initialize state
|
|
969
972
|
this._state = {
|
|
970
973
|
isOpen: false,
|
|
@@ -984,20 +987,34 @@ class EnhancedSelect extends HTMLElement {
|
|
|
984
987
|
lastNotifiedResultCount: 0,
|
|
985
988
|
isExpanded: false,
|
|
986
989
|
};
|
|
990
|
+
console.log('[EnhancedSelect] State initialized');
|
|
987
991
|
// Create DOM structure
|
|
988
992
|
this._container = this._createContainer();
|
|
993
|
+
console.log('[EnhancedSelect] Container created:', this._container);
|
|
989
994
|
this._inputContainer = this._createInputContainer();
|
|
995
|
+
console.log('[EnhancedSelect] Input container created');
|
|
990
996
|
this._input = this._createInput();
|
|
997
|
+
console.log('[EnhancedSelect] Input created:', this._input);
|
|
991
998
|
this._arrowContainer = this._createArrowContainer();
|
|
999
|
+
console.log('[EnhancedSelect] Arrow container created');
|
|
992
1000
|
this._dropdown = this._createDropdown();
|
|
1001
|
+
console.log('[EnhancedSelect] Dropdown created');
|
|
993
1002
|
this._optionsContainer = this._createOptionsContainer();
|
|
1003
|
+
console.log('[EnhancedSelect] Options container created');
|
|
994
1004
|
this._liveRegion = this._createLiveRegion();
|
|
1005
|
+
console.log('[EnhancedSelect] Live region created');
|
|
995
1006
|
this._assembleDOM();
|
|
1007
|
+
console.log('[EnhancedSelect] DOM assembled');
|
|
996
1008
|
this._initializeStyles();
|
|
1009
|
+
console.log('[EnhancedSelect] Styles initialized');
|
|
997
1010
|
this._attachEventListeners();
|
|
1011
|
+
console.log('[EnhancedSelect] Event listeners attached');
|
|
998
1012
|
this._initializeObservers();
|
|
1013
|
+
console.log('[EnhancedSelect] Observers initialized');
|
|
1014
|
+
console.log('[EnhancedSelect] Constructor complete, shadow DOM children:', this._shadow.children.length);
|
|
999
1015
|
}
|
|
1000
1016
|
connectedCallback() {
|
|
1017
|
+
console.log('[EnhancedSelect] connectedCallback called');
|
|
1001
1018
|
// Load initial data if server-side is enabled
|
|
1002
1019
|
if (this._config.serverSide.enabled && this._config.serverSide.initialSelectedValues) {
|
|
1003
1020
|
this._loadInitialSelectedItems();
|
|
@@ -1006,6 +1023,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
1006
1023
|
if (this._config.callbacks.onOpen) {
|
|
1007
1024
|
this._config.callbacks.onOpen();
|
|
1008
1025
|
}
|
|
1026
|
+
console.log('[EnhancedSelect] connectedCallback complete');
|
|
1009
1027
|
}
|
|
1010
1028
|
disconnectedCallback() {
|
|
1011
1029
|
// Cleanup observers
|
|
@@ -1103,22 +1121,43 @@ class EnhancedSelect extends HTMLElement {
|
|
|
1103
1121
|
return container;
|
|
1104
1122
|
}
|
|
1105
1123
|
_assembleDOM() {
|
|
1124
|
+
console.log('[EnhancedSelect] _assembleDOM: Starting DOM assembly');
|
|
1125
|
+
console.log('[EnhancedSelect] _assembleDOM: Elements to assemble:', {
|
|
1126
|
+
inputContainer: !!this._inputContainer,
|
|
1127
|
+
input: !!this._input,
|
|
1128
|
+
arrowContainer: !!this._arrowContainer,
|
|
1129
|
+
container: !!this._container,
|
|
1130
|
+
dropdown: !!this._dropdown,
|
|
1131
|
+
optionsContainer: !!this._optionsContainer,
|
|
1132
|
+
shadow: !!this._shadow,
|
|
1133
|
+
liveRegion: !!this._liveRegion
|
|
1134
|
+
});
|
|
1106
1135
|
this._inputContainer.appendChild(this._input);
|
|
1136
|
+
console.log('[EnhancedSelect] _assembleDOM: Appended input to inputContainer');
|
|
1107
1137
|
if (this._arrowContainer) {
|
|
1108
1138
|
this._inputContainer.appendChild(this._arrowContainer);
|
|
1139
|
+
console.log('[EnhancedSelect] _assembleDOM: Appended arrowContainer to inputContainer');
|
|
1109
1140
|
}
|
|
1110
1141
|
this._container.appendChild(this._inputContainer);
|
|
1142
|
+
console.log('[EnhancedSelect] _assembleDOM: Appended inputContainer to container');
|
|
1111
1143
|
this._dropdown.appendChild(this._optionsContainer);
|
|
1144
|
+
console.log('[EnhancedSelect] _assembleDOM: Appended optionsContainer to dropdown');
|
|
1112
1145
|
this._container.appendChild(this._dropdown);
|
|
1146
|
+
console.log('[EnhancedSelect] _assembleDOM: Appended dropdown to container');
|
|
1113
1147
|
this._shadow.appendChild(this._container);
|
|
1148
|
+
console.log('[EnhancedSelect] _assembleDOM: Appended container to shadow root');
|
|
1114
1149
|
if (this._liveRegion) {
|
|
1115
1150
|
this._shadow.appendChild(this._liveRegion);
|
|
1151
|
+
console.log('[EnhancedSelect] _assembleDOM: Appended liveRegion to shadow root');
|
|
1116
1152
|
}
|
|
1153
|
+
console.log('[EnhancedSelect] _assembleDOM: Shadow root children count:', this._shadow.children.length);
|
|
1154
|
+
console.log('[EnhancedSelect] _assembleDOM: Shadow root HTML length:', this._shadow.innerHTML.length);
|
|
1117
1155
|
// Set ARIA relationships
|
|
1118
1156
|
const listboxId = `${this._uniqueId}-listbox`;
|
|
1119
1157
|
this._dropdown.id = listboxId;
|
|
1120
1158
|
this._input.setAttribute('aria-controls', listboxId);
|
|
1121
1159
|
this._input.setAttribute('aria-owns', listboxId);
|
|
1160
|
+
console.log('[EnhancedSelect] _assembleDOM: Set ARIA relationships with listboxId:', listboxId);
|
|
1122
1161
|
}
|
|
1123
1162
|
_initializeStyles() {
|
|
1124
1163
|
const style = document.createElement('style');
|
|
@@ -1275,39 +1314,19 @@ class EnhancedSelect extends HTMLElement {
|
|
|
1275
1314
|
right: 0;
|
|
1276
1315
|
margin-top: 4px;
|
|
1277
1316
|
max-height: 300px;
|
|
1278
|
-
|
|
1279
|
-
flex-direction: column;
|
|
1317
|
+
overflow: hidden;
|
|
1280
1318
|
background: var(--select-dropdown-bg, white);
|
|
1281
1319
|
border: 1px solid var(--select-dropdown-border, #ccc);
|
|
1282
1320
|
border-radius: var(--select-border-radius, 4px);
|
|
1283
1321
|
box-shadow: var(--select-dropdown-shadow, 0 4px 6px rgba(0,0,0,0.1));
|
|
1284
1322
|
z-index: var(--select-dropdown-z-index, 1000);
|
|
1285
|
-
transition: max-height 0.3s ease-in-out;
|
|
1286
1323
|
}
|
|
1287
1324
|
|
|
1288
1325
|
.options-container {
|
|
1289
1326
|
position: relative;
|
|
1327
|
+
max-height: 300px;
|
|
1328
|
+
overflow: auto;
|
|
1290
1329
|
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
1330
|
}
|
|
1312
1331
|
|
|
1313
1332
|
.option {
|
|
@@ -1468,7 +1487,11 @@ class EnhancedSelect extends HTMLElement {
|
|
|
1468
1487
|
min-height: 44px;
|
|
1469
1488
|
}
|
|
1470
1489
|
`;
|
|
1490
|
+
console.log('[EnhancedSelect] _initializeStyles: Created style element, content length:', style.textContent?.length || 0);
|
|
1491
|
+
console.log('[EnhancedSelect] _initializeStyles: Appending style to shadow root...');
|
|
1471
1492
|
this._shadow.appendChild(style);
|
|
1493
|
+
console.log('[EnhancedSelect] _initializeStyles: Style appended, shadow root children:', this._shadow.children.length);
|
|
1494
|
+
console.log('[EnhancedSelect] _initializeStyles: Shadow root has style element:', !!this._shadow.querySelector('style'));
|
|
1472
1495
|
}
|
|
1473
1496
|
_attachEventListeners() {
|
|
1474
1497
|
// Arrow click handler
|
|
@@ -1570,13 +1593,6 @@ class EnhancedSelect extends HTMLElement {
|
|
|
1570
1593
|
return;
|
|
1571
1594
|
this._state.isOpen = true;
|
|
1572
1595
|
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
1596
|
this._input.setAttribute('aria-expanded', 'true');
|
|
1581
1597
|
this._updateArrowRotation();
|
|
1582
1598
|
// Clear search query when opening to show all options
|
|
@@ -2051,21 +2067,27 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2051
2067
|
* Set items to display in the select
|
|
2052
2068
|
*/
|
|
2053
2069
|
setItems(items) {
|
|
2070
|
+
console.log('[EnhancedSelect] setItems called with', items?.length || 0, 'items');
|
|
2071
|
+
console.log('[EnhancedSelect] Items:', items);
|
|
2054
2072
|
const previousLength = this._state.loadedItems.length;
|
|
2055
2073
|
this._state.loadedItems = items;
|
|
2056
2074
|
// If grouped items exist, flatten them to items
|
|
2057
2075
|
if (this._state.groupedItems.length > 0) {
|
|
2058
2076
|
this._state.loadedItems = this._state.groupedItems.flatMap(group => group.options);
|
|
2077
|
+
console.log('[EnhancedSelect] Flattened grouped items to', this._state.loadedItems.length, 'items');
|
|
2059
2078
|
}
|
|
2060
2079
|
const newLength = this._state.loadedItems.length;
|
|
2080
|
+
console.log('[EnhancedSelect] State.loadedItems updated:', previousLength, '→', newLength);
|
|
2061
2081
|
// When infinite scroll is active (preserveScrollPosition = true),
|
|
2062
2082
|
// we need to maintain scroll position during the update
|
|
2063
2083
|
if (this._state.preserveScrollPosition && this._dropdown) {
|
|
2064
2084
|
const targetScrollTop = this._state.lastScrollPosition;
|
|
2085
|
+
console.log('[EnhancedSelect] Preserving scroll position:', targetScrollTop);
|
|
2065
2086
|
// Only clear loading if we actually got more items
|
|
2066
2087
|
if (newLength > previousLength) {
|
|
2067
2088
|
this._state.isBusy = false;
|
|
2068
2089
|
}
|
|
2090
|
+
console.log('[EnhancedSelect] Calling _renderOptions (with scroll preservation)...');
|
|
2069
2091
|
this._renderOptions();
|
|
2070
2092
|
// Restore the exact scrollTop we had before loading
|
|
2071
2093
|
// so the previously visible items stay in place and
|
|
@@ -2085,8 +2107,10 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2085
2107
|
else {
|
|
2086
2108
|
// Normal update - just render normally
|
|
2087
2109
|
this._state.isBusy = false;
|
|
2110
|
+
console.log('[EnhancedSelect] Calling _renderOptions (normal)...');
|
|
2088
2111
|
this._renderOptions();
|
|
2089
2112
|
}
|
|
2113
|
+
console.log('[EnhancedSelect] setItems complete');
|
|
2090
2114
|
}
|
|
2091
2115
|
/**
|
|
2092
2116
|
* Set grouped items
|
|
@@ -2250,11 +2274,21 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2250
2274
|
* Render options based on current state
|
|
2251
2275
|
*/
|
|
2252
2276
|
_renderOptions() {
|
|
2277
|
+
console.log('[EnhancedSelect] _renderOptions called');
|
|
2278
|
+
console.log('[EnhancedSelect] State:', {
|
|
2279
|
+
loadedItems: this._state.loadedItems.length,
|
|
2280
|
+
groupedItems: this._state.groupedItems.length,
|
|
2281
|
+
isOpen: this._state.isOpen,
|
|
2282
|
+
isSearching: this._state.isSearching,
|
|
2283
|
+
searchQuery: this._state.searchQuery,
|
|
2284
|
+
isBusy: this._state.isBusy
|
|
2285
|
+
});
|
|
2253
2286
|
// Cleanup observer
|
|
2254
2287
|
if (this._loadMoreTrigger && this._intersectionObserver) {
|
|
2255
2288
|
this._intersectionObserver.unobserve(this._loadMoreTrigger);
|
|
2256
2289
|
}
|
|
2257
2290
|
// Clear options container
|
|
2291
|
+
console.log('[EnhancedSelect] Clearing options container, previous children:', this._optionsContainer.children.length);
|
|
2258
2292
|
this._optionsContainer.innerHTML = '';
|
|
2259
2293
|
// Ensure dropdown only contains options container (cleanup legacy direct children)
|
|
2260
2294
|
// We need to preserve optionsContainer, so we can't just clear dropdown.innerHTML
|
|
@@ -2267,6 +2301,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2267
2301
|
// Ensure dropdown is visible if we are rendering options
|
|
2268
2302
|
if (this._state.isOpen && this._dropdown.style.display === 'none') {
|
|
2269
2303
|
this._dropdown.style.display = 'block';
|
|
2304
|
+
console.log('[EnhancedSelect] Dropdown display set to block');
|
|
2270
2305
|
}
|
|
2271
2306
|
// Show searching state (exclusive state)
|
|
2272
2307
|
if (this._state.isSearching) {
|
|
@@ -2274,6 +2309,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2274
2309
|
searching.className = 'searching-state';
|
|
2275
2310
|
searching.textContent = 'Searching...';
|
|
2276
2311
|
this._optionsContainer.appendChild(searching);
|
|
2312
|
+
console.log('[EnhancedSelect] Added searching state');
|
|
2277
2313
|
return;
|
|
2278
2314
|
}
|
|
2279
2315
|
const getValue = this._config.serverSide.getValueFromItem || ((item) => item?.value ?? item);
|
|
@@ -2282,6 +2318,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2282
2318
|
const query = this._state.searchQuery.toLowerCase();
|
|
2283
2319
|
// Handle Grouped Items Rendering (when no search query)
|
|
2284
2320
|
if (this._state.groupedItems.length > 0 && !query) {
|
|
2321
|
+
console.log('[EnhancedSelect] Rendering grouped items:', this._state.groupedItems.length, 'groups');
|
|
2285
2322
|
this._state.groupedItems.forEach(group => {
|
|
2286
2323
|
const header = document.createElement('div');
|
|
2287
2324
|
header.className = 'group-header';
|
|
@@ -2311,6 +2348,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2311
2348
|
}
|
|
2312
2349
|
else {
|
|
2313
2350
|
// Normal rendering (flat list or filtered)
|
|
2351
|
+
console.log('[EnhancedSelect] Rendering flat list:', this._state.loadedItems.length, 'items');
|
|
2314
2352
|
let hasRenderedItems = false;
|
|
2315
2353
|
this._state.loadedItems.forEach((item, index) => {
|
|
2316
2354
|
// Apply filter if query exists
|
|
@@ -2327,6 +2365,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2327
2365
|
hasRenderedItems = true;
|
|
2328
2366
|
this._renderSingleOption(item, index, getValue, getLabel);
|
|
2329
2367
|
});
|
|
2368
|
+
console.log('[EnhancedSelect] Rendered', hasRenderedItems ? 'items' : 'no items');
|
|
2330
2369
|
if (!hasRenderedItems && !this._state.isBusy) {
|
|
2331
2370
|
const empty = document.createElement('div');
|
|
2332
2371
|
empty.className = 'empty-state';
|
|
@@ -2337,6 +2376,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2337
2376
|
empty.textContent = 'No options available';
|
|
2338
2377
|
}
|
|
2339
2378
|
this._optionsContainer.appendChild(empty);
|
|
2379
|
+
console.log('[EnhancedSelect] Added empty state');
|
|
2340
2380
|
}
|
|
2341
2381
|
}
|
|
2342
2382
|
// Append Busy Indicator if busy
|
|
@@ -2354,41 +2394,13 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2354
2394
|
busyBucket.appendChild(message);
|
|
2355
2395
|
}
|
|
2356
2396
|
this._optionsContainer.appendChild(busyBucket);
|
|
2397
|
+
console.log('[EnhancedSelect] Added busy bucket');
|
|
2357
2398
|
}
|
|
2358
2399
|
// Append Load More Trigger (Button or Sentinel) if enabled and not busy
|
|
2359
2400
|
else if ((this._config.loadMore.enabled || this._config.infiniteScroll.enabled) && this._state.loadedItems.length > 0) {
|
|
2360
2401
|
this._addLoadMoreTrigger();
|
|
2361
2402
|
}
|
|
2362
|
-
|
|
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
|
-
}
|
|
2403
|
+
console.log('[EnhancedSelect] _renderOptions complete, optionsContainer children:', this._optionsContainer.children.length);
|
|
2392
2404
|
}
|
|
2393
2405
|
_renderSingleOption(item, index, getValue, getLabel) {
|
|
2394
2406
|
const option = document.createElement('div');
|
|
@@ -2396,6 +2408,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2396
2408
|
option.id = `${this._uniqueId}-option-${index}`;
|
|
2397
2409
|
const value = getValue(item);
|
|
2398
2410
|
const label = getLabel(item);
|
|
2411
|
+
console.log('[EnhancedSelect] Rendering option', index, ':', { value, label });
|
|
2399
2412
|
option.textContent = label;
|
|
2400
2413
|
option.dataset.value = String(value);
|
|
2401
2414
|
option.dataset.index = String(index); // Also useful for debugging/selectors
|
|
@@ -2412,6 +2425,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2412
2425
|
this._selectOption(index);
|
|
2413
2426
|
});
|
|
2414
2427
|
this._optionsContainer.appendChild(option);
|
|
2428
|
+
console.log('[EnhancedSelect] Option', index, 'appended to optionsContainer');
|
|
2415
2429
|
}
|
|
2416
2430
|
_addLoadMoreTrigger() {
|
|
2417
2431
|
const container = document.createElement('div');
|