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