@smilodon/core 1.4.1 → 1.4.2
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 +103 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +103 -10
- 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 +103 -10
- 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 +7 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1829,6 +1829,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
1829
1829
|
this._pendingSearchRenderMark = false;
|
|
1830
1830
|
this._rangeAnchorIndex = null;
|
|
1831
1831
|
this._customOptionBoundElements = new WeakSet();
|
|
1832
|
+
this._mirrorGlobalStylesForCustomOptions = false;
|
|
1833
|
+
this._globalStylesObserver = null;
|
|
1834
|
+
this._globalStylesContainer = null;
|
|
1832
1835
|
this._shadow = this.attachShadow({ mode: 'open' });
|
|
1833
1836
|
this._uniqueId = `enhanced-select-${Math.random().toString(36).substr(2, 9)}`;
|
|
1834
1837
|
this._rendererHelpers = this._buildRendererHelpers();
|
|
@@ -1873,6 +1876,9 @@ class EnhancedSelect extends HTMLElement {
|
|
|
1873
1876
|
// Must be done in connectedCallback when element is attached to DOM
|
|
1874
1877
|
this.style.display = 'block';
|
|
1875
1878
|
this.style.width = '100%';
|
|
1879
|
+
if (this._optionRenderer) {
|
|
1880
|
+
this._setGlobalStylesMirroring(true);
|
|
1881
|
+
}
|
|
1876
1882
|
// Load initial data if server-side is enabled
|
|
1877
1883
|
if (this._config.serverSide.enabled && this._config.serverSide.initialSelectedValues) {
|
|
1878
1884
|
this._loadInitialSelectedItems();
|
|
@@ -1896,6 +1902,92 @@ class EnhancedSelect extends HTMLElement {
|
|
|
1896
1902
|
if (this._boundArrowClick && this._arrowContainer) {
|
|
1897
1903
|
this._arrowContainer.removeEventListener('click', this._boundArrowClick);
|
|
1898
1904
|
}
|
|
1905
|
+
this._teardownGlobalStylesMirroring();
|
|
1906
|
+
}
|
|
1907
|
+
_setGlobalStylesMirroring(enabled) {
|
|
1908
|
+
if (this._mirrorGlobalStylesForCustomOptions === enabled) {
|
|
1909
|
+
if (enabled) {
|
|
1910
|
+
this._mirrorDocumentStylesIntoShadow();
|
|
1911
|
+
}
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
this._mirrorGlobalStylesForCustomOptions = enabled;
|
|
1915
|
+
if (enabled) {
|
|
1916
|
+
this._setupGlobalStylesMirroring();
|
|
1917
|
+
}
|
|
1918
|
+
else {
|
|
1919
|
+
this._teardownGlobalStylesMirroring();
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
_setupGlobalStylesMirroring() {
|
|
1923
|
+
if (typeof document === 'undefined')
|
|
1924
|
+
return;
|
|
1925
|
+
if (!this._mirrorGlobalStylesForCustomOptions)
|
|
1926
|
+
return;
|
|
1927
|
+
this._mirrorDocumentStylesIntoShadow();
|
|
1928
|
+
if (this._globalStylesObserver)
|
|
1929
|
+
return;
|
|
1930
|
+
this._globalStylesObserver = new MutationObserver(() => {
|
|
1931
|
+
this._mirrorDocumentStylesIntoShadow();
|
|
1932
|
+
});
|
|
1933
|
+
this._globalStylesObserver.observe(document.head, {
|
|
1934
|
+
childList: true,
|
|
1935
|
+
subtree: true,
|
|
1936
|
+
attributes: true,
|
|
1937
|
+
characterData: true,
|
|
1938
|
+
});
|
|
1939
|
+
}
|
|
1940
|
+
_teardownGlobalStylesMirroring() {
|
|
1941
|
+
if (this._globalStylesObserver) {
|
|
1942
|
+
this._globalStylesObserver.disconnect();
|
|
1943
|
+
this._globalStylesObserver = null;
|
|
1944
|
+
}
|
|
1945
|
+
if (this._globalStylesContainer) {
|
|
1946
|
+
this._globalStylesContainer.remove();
|
|
1947
|
+
this._globalStylesContainer = null;
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
_mirrorDocumentStylesIntoShadow() {
|
|
1951
|
+
if (typeof document === 'undefined')
|
|
1952
|
+
return;
|
|
1953
|
+
if (!this._mirrorGlobalStylesForCustomOptions)
|
|
1954
|
+
return;
|
|
1955
|
+
if (!this._globalStylesContainer) {
|
|
1956
|
+
this._globalStylesContainer = document.createElement('div');
|
|
1957
|
+
this._globalStylesContainer.setAttribute('data-smilodon-global-styles', '');
|
|
1958
|
+
this._shadow.appendChild(this._globalStylesContainer);
|
|
1959
|
+
}
|
|
1960
|
+
const container = this._globalStylesContainer;
|
|
1961
|
+
container.innerHTML = '';
|
|
1962
|
+
const styleNodes = Array.from(document.querySelectorAll('style,link[rel="stylesheet"]'));
|
|
1963
|
+
styleNodes.forEach((node, index) => {
|
|
1964
|
+
if (node instanceof HTMLStyleElement) {
|
|
1965
|
+
const clonedStyle = document.createElement('style');
|
|
1966
|
+
clonedStyle.setAttribute('data-smilodon-global-style', String(index));
|
|
1967
|
+
clonedStyle.textContent = node.textContent || '';
|
|
1968
|
+
container.appendChild(clonedStyle);
|
|
1969
|
+
return;
|
|
1970
|
+
}
|
|
1971
|
+
if (node instanceof HTMLLinkElement && node.href) {
|
|
1972
|
+
const clonedLink = document.createElement('link');
|
|
1973
|
+
clonedLink.rel = 'stylesheet';
|
|
1974
|
+
clonedLink.href = node.href;
|
|
1975
|
+
if (node.media)
|
|
1976
|
+
clonedLink.media = node.media;
|
|
1977
|
+
if (node.crossOrigin)
|
|
1978
|
+
clonedLink.crossOrigin = node.crossOrigin;
|
|
1979
|
+
if (node.referrerPolicy)
|
|
1980
|
+
clonedLink.referrerPolicy = node.referrerPolicy;
|
|
1981
|
+
if (node.integrity)
|
|
1982
|
+
clonedLink.integrity = node.integrity;
|
|
1983
|
+
if (node.type)
|
|
1984
|
+
clonedLink.type = node.type;
|
|
1985
|
+
if (node.nonce)
|
|
1986
|
+
clonedLink.nonce = node.nonce;
|
|
1987
|
+
clonedLink.setAttribute('data-smilodon-global-link', String(index));
|
|
1988
|
+
container.appendChild(clonedLink);
|
|
1989
|
+
}
|
|
1990
|
+
});
|
|
1899
1991
|
}
|
|
1900
1992
|
_createContainer() {
|
|
1901
1993
|
const container = document.createElement('div');
|
|
@@ -2026,15 +2118,15 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2026
2118
|
max-height: var(--select-input-max-height, 160px);
|
|
2027
2119
|
overflow-y: var(--select-input-overflow-y, auto);
|
|
2028
2120
|
align-content: flex-start;
|
|
2029
|
-
background: var(--select-input-bg, white);
|
|
2030
|
-
border: var(--select-input-border, 1px solid #d1d5db);
|
|
2121
|
+
background: var(--select-input-bg, var(--select-bg, white));
|
|
2122
|
+
border: var(--select-input-border, 1px solid var(--select-border-color, #d1d5db));
|
|
2031
2123
|
border-radius: var(--select-input-border-radius, 6px);
|
|
2032
2124
|
box-sizing: border-box;
|
|
2033
2125
|
transition: all 0.2s ease;
|
|
2034
2126
|
}
|
|
2035
2127
|
|
|
2036
2128
|
.input-container:focus-within {
|
|
2037
|
-
border-color: var(--select-input-focus-border, #667eea);
|
|
2129
|
+
border-color: var(--select-input-focus-border, var(--select-border-focus-color, #667eea));
|
|
2038
2130
|
box-shadow: var(--select-input-focus-shadow, 0 0 0 3px rgba(102, 126, 234, 0.1));
|
|
2039
2131
|
}
|
|
2040
2132
|
|
|
@@ -2104,7 +2196,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2104
2196
|
border: none;
|
|
2105
2197
|
font-size: var(--select-input-font-size, 14px);
|
|
2106
2198
|
line-height: var(--select-input-line-height, 1.5);
|
|
2107
|
-
color: var(--select-input-color, #1f2937);
|
|
2199
|
+
color: var(--select-input-color, var(--select-text-color, #1f2937));
|
|
2108
2200
|
background: transparent;
|
|
2109
2201
|
box-sizing: border-box;
|
|
2110
2202
|
outline: none;
|
|
@@ -2112,7 +2204,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2112
2204
|
}
|
|
2113
2205
|
|
|
2114
2206
|
.select-input::placeholder {
|
|
2115
|
-
color: var(--select-input-placeholder-color, #9ca3af);
|
|
2207
|
+
color: var(--select-input-placeholder-color, var(--select-placeholder-color, #9ca3af));
|
|
2116
2208
|
}
|
|
2117
2209
|
|
|
2118
2210
|
.selection-badge {
|
|
@@ -2173,8 +2265,8 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2173
2265
|
margin-top: var(--select-dropdown-margin-top, 4px);
|
|
2174
2266
|
max-height: var(--select-dropdown-max-height, 300px);
|
|
2175
2267
|
overflow: hidden;
|
|
2176
|
-
background: var(--select-dropdown-bg, white);
|
|
2177
|
-
border: var(--select-dropdown-border,
|
|
2268
|
+
background: var(--select-dropdown-bg, var(--select-bg, white));
|
|
2269
|
+
border: 1px solid var(--select-dropdown-border, #ccc);
|
|
2178
2270
|
border-radius: var(--select-dropdown-border-radius, 4px);
|
|
2179
2271
|
box-shadow: var(--select-dropdown-shadow, 0 4px 6px rgba(0,0,0,0.1));
|
|
2180
2272
|
z-index: var(--select-dropdown-z-index, 1000);
|
|
@@ -2185,14 +2277,14 @@ class EnhancedSelect extends HTMLElement {
|
|
|
2185
2277
|
max-height: var(--select-options-max-height, 300px);
|
|
2186
2278
|
overflow: auto;
|
|
2187
2279
|
transition: opacity 0.2s ease-in-out;
|
|
2188
|
-
background: var(--select-options-bg, white);
|
|
2280
|
+
background: var(--select-options-bg, var(--select-dropdown-bg, var(--select-bg, white)));
|
|
2189
2281
|
}
|
|
2190
2282
|
|
|
2191
2283
|
.option {
|
|
2192
2284
|
padding: var(--select-option-padding, 8px 12px);
|
|
2193
2285
|
cursor: pointer;
|
|
2194
|
-
color: var(--select-option-color, #1f2937);
|
|
2195
|
-
background: var(--select-option-bg, white);
|
|
2286
|
+
color: var(--select-option-color, var(--select-text-color, #1f2937));
|
|
2287
|
+
background: var(--select-option-bg, var(--select-dropdown-bg, var(--select-bg, white)));
|
|
2196
2288
|
transition: var(--select-option-transition, background-color 0.15s ease);
|
|
2197
2289
|
user-select: none;
|
|
2198
2290
|
font-size: var(--select-option-font-size, 14px);
|
|
@@ -3221,6 +3313,7 @@ class EnhancedSelect extends HTMLElement {
|
|
|
3221
3313
|
}
|
|
3222
3314
|
set optionRenderer(renderer) {
|
|
3223
3315
|
this._optionRenderer = renderer;
|
|
3316
|
+
this._setGlobalStylesMirroring(Boolean(renderer));
|
|
3224
3317
|
this._renderOptions();
|
|
3225
3318
|
}
|
|
3226
3319
|
/**
|