@keenthemes/ktui 1.0.26 → 1.0.27
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/ktui.js +136 -17
- package/dist/ktui.min.js +1 -1
- package/dist/ktui.min.js.map +1 -1
- package/dist/styles.css +6 -13
- package/examples/modal/remote-select-dropdown.html +166 -0
- package/examples/modal/select-dropdown-container.html +129 -0
- package/examples/select/modal-positioning-test.html +10 -8
- package/lib/cjs/components/modal/modal.js +13 -1
- package/lib/cjs/components/modal/modal.js.map +1 -1
- package/lib/cjs/components/select/dropdown.js +34 -6
- package/lib/cjs/components/select/dropdown.js.map +1 -1
- package/lib/cjs/components/select/select.js +89 -10
- package/lib/cjs/components/select/select.js.map +1 -1
- package/lib/esm/components/modal/modal.js +13 -1
- package/lib/esm/components/modal/modal.js.map +1 -1
- package/lib/esm/components/select/dropdown.js +34 -6
- package/lib/esm/components/select/dropdown.js.map +1 -1
- package/lib/esm/components/select/select.js +89 -10
- package/lib/esm/components/select/select.js.map +1 -1
- package/package.json +1 -1
- package/src/components/modal/modal.ts +15 -1
- package/src/components/select/dropdown.ts +42 -6
- package/src/components/select/select.ts +123 -10
- package/lib/cjs/components/config.js +0 -26
- package/lib/cjs/components/config.js.map +0 -1
- package/lib/cjs/components/config.umd.js +0 -23
- package/lib/cjs/components/config.umd.js.map +0 -1
- package/lib/cjs/components/menu/index.js +0 -6
- package/lib/cjs/components/menu/index.js.map +0 -1
- package/lib/cjs/components/menu/menu.js +0 -1021
- package/lib/cjs/components/menu/menu.js.map +0 -1
- package/lib/cjs/components/menu/types.js +0 -3
- package/lib/cjs/components/menu/types.js.map +0 -1
- package/lib/cjs/components/theme/index.js +0 -6
- package/lib/cjs/components/theme/index.js.map +0 -1
- package/lib/cjs/components/theme/theme.js +0 -147
- package/lib/cjs/components/theme/theme.js.map +0 -1
- package/lib/cjs/components/theme/types.js +0 -3
- package/lib/cjs/components/theme/types.js.map +0 -1
- package/lib/esm/components/config.js +0 -24
- package/lib/esm/components/config.js.map +0 -1
- package/lib/esm/components/config.umd.js +0 -23
- package/lib/esm/components/config.umd.js.map +0 -1
- package/lib/esm/components/menu/index.js +0 -2
- package/lib/esm/components/menu/index.js.map +0 -1
- package/lib/esm/components/menu/menu.js +0 -1018
- package/lib/esm/components/menu/menu.js.map +0 -1
- package/lib/esm/components/menu/types.js +0 -2
- package/lib/esm/components/menu/types.js.map +0 -1
- package/lib/esm/components/theme/index.js +0 -2
- package/lib/esm/components/theme/index.js.map +0 -1
- package/lib/esm/components/theme/theme.js +0 -144
- package/lib/esm/components/theme/theme.js.map +0 -1
- package/lib/esm/components/theme/types.js +0 -2
- package/lib/esm/components/theme/types.js.map +0 -1
- /package/examples/modal/{persistent-test.html → persistent.html} +0 -0
- /package/examples/select/{dark-mode-test.html → dark-mode.html} +0 -0
- /package/examples/select/{dropdowncontainer-test.html → dropdowncontainer.html} +0 -0
- /package/examples/select/{formdata-remote-test.html → formdata-remote.html} +0 -0
- /package/examples/select/{global-config-test.html → global-config.html} +0 -0
|
@@ -311,6 +311,15 @@ export class KTSelect extends KTComponent {
|
|
|
311
311
|
// Initialize options
|
|
312
312
|
this._preSelectOptions(this._element);
|
|
313
313
|
|
|
314
|
+
// Prevent browser auto-selection when placeholder is configured
|
|
315
|
+
if (
|
|
316
|
+
this._config.placeholder &&
|
|
317
|
+
this._state.getSelectedOptions().length === 0 &&
|
|
318
|
+
this._preSelectedValues.length === 0
|
|
319
|
+
) {
|
|
320
|
+
(this._element as HTMLSelectElement).value = '';
|
|
321
|
+
}
|
|
322
|
+
|
|
314
323
|
// Apply pre-selected values captured before remote data was loaded
|
|
315
324
|
if (this._preSelectedValues.length > 0) {
|
|
316
325
|
if (this._config.debug) {
|
|
@@ -638,6 +647,14 @@ export class KTSelect extends KTComponent {
|
|
|
638
647
|
// Initialize options
|
|
639
648
|
this._preSelectOptions(this._element);
|
|
640
649
|
|
|
650
|
+
// Prevent browser auto-selection when placeholder is configured
|
|
651
|
+
if (
|
|
652
|
+
this._config.placeholder &&
|
|
653
|
+
this._state.getSelectedOptions().length === 0
|
|
654
|
+
) {
|
|
655
|
+
(this._element as HTMLSelectElement).value = '';
|
|
656
|
+
}
|
|
657
|
+
|
|
641
658
|
// Apply disabled state if needed
|
|
642
659
|
this._applyInitialDisabledState();
|
|
643
660
|
|
|
@@ -1829,10 +1846,18 @@ export class KTSelect extends KTComponent {
|
|
|
1829
1846
|
|
|
1830
1847
|
/**
|
|
1831
1848
|
* Update the dropdown to sync with native select element changes
|
|
1832
|
-
* For remote selects, refetches data from the server
|
|
1849
|
+
* For remote selects, refetches data from the server and preserves selections
|
|
1833
1850
|
* Optionally accepts new options to replace existing ones (static selects only)
|
|
1834
|
-
*
|
|
1851
|
+
*
|
|
1852
|
+
* @param newOptions Optional array of new options [{value, text}, ...] (static selects only)
|
|
1835
1853
|
* @public
|
|
1854
|
+
* @remarks
|
|
1855
|
+
* - For static selects: rebuilds dropdown from native select or new options
|
|
1856
|
+
* - For remote selects: fetches fresh data, preserves matching selections
|
|
1857
|
+
* - Selections are preserved if their values exist in new remote data
|
|
1858
|
+
* - Selections are cleared if their values don't exist in new data
|
|
1859
|
+
* @fires updated - After update completes successfully
|
|
1860
|
+
* @fires updateError - If remote data fetch fails
|
|
1836
1861
|
*/
|
|
1837
1862
|
public update(newOptions?: Array<{ value: string; text: string }>): void {
|
|
1838
1863
|
// For remote selects, refetch data
|
|
@@ -1840,21 +1865,48 @@ export class KTSelect extends KTComponent {
|
|
|
1840
1865
|
this._remoteModule
|
|
1841
1866
|
.fetchData()
|
|
1842
1867
|
.then((items) => {
|
|
1843
|
-
//
|
|
1868
|
+
// Capture currently selected values before clearing
|
|
1869
|
+
const currentlySelected = this._state.getSelectedOptions();
|
|
1870
|
+
|
|
1871
|
+
// Clear existing options (also captures to _preSelectedValues)
|
|
1844
1872
|
this._clearExistingOptions();
|
|
1845
1873
|
|
|
1846
|
-
//
|
|
1874
|
+
// Get all available values from new remote data
|
|
1875
|
+
const availableValues = items.map((item) => item.id);
|
|
1876
|
+
|
|
1877
|
+
// Filter to only values that exist in new data
|
|
1878
|
+
const validSelections = currentlySelected.filter((value) =>
|
|
1879
|
+
availableValues.includes(value),
|
|
1880
|
+
);
|
|
1881
|
+
|
|
1882
|
+
if (this._config.debug && currentlySelected.length > 0) {
|
|
1883
|
+
console.log(
|
|
1884
|
+
'update(): Preserving selections that exist in new data:',
|
|
1885
|
+
validSelections,
|
|
1886
|
+
);
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
// Add new options from remote data and restore selection state
|
|
1847
1890
|
items.forEach((item) => {
|
|
1848
1891
|
const option = document.createElement('option');
|
|
1849
1892
|
option.value = item.id;
|
|
1850
1893
|
option.textContent = item.title;
|
|
1851
1894
|
if (item.disabled) option.disabled = true;
|
|
1895
|
+
|
|
1896
|
+
// Restore selected attribute for preserved selections
|
|
1897
|
+
if (validSelections.includes(item.id)) {
|
|
1898
|
+
option.selected = true;
|
|
1899
|
+
}
|
|
1900
|
+
|
|
1852
1901
|
this._element.appendChild(option);
|
|
1853
1902
|
});
|
|
1854
1903
|
|
|
1855
1904
|
// Rebuild dropdown
|
|
1856
1905
|
this._rebuildOptionsFromNative();
|
|
1857
1906
|
|
|
1907
|
+
// Sync selection state from native select (now has selected attributes)
|
|
1908
|
+
this._syncSelectionFromNative();
|
|
1909
|
+
|
|
1858
1910
|
// Dispatch updated event
|
|
1859
1911
|
this._dispatchEvent('updated');
|
|
1860
1912
|
this._fireEvent('updated');
|
|
@@ -1905,11 +1957,14 @@ export class KTSelect extends KTComponent {
|
|
|
1905
1957
|
this._dispatchEvent('reloadStart');
|
|
1906
1958
|
this._fireEvent('reloadStart');
|
|
1907
1959
|
|
|
1960
|
+
// Capture currently selected values before clearing
|
|
1961
|
+
const currentlySelected = this._state.getSelectedOptions();
|
|
1962
|
+
|
|
1908
1963
|
// Fetch fresh remote data
|
|
1909
1964
|
return this._remoteModule
|
|
1910
1965
|
.fetchData()
|
|
1911
1966
|
.then((items) => {
|
|
1912
|
-
// Clear existing options
|
|
1967
|
+
// Clear existing options (captures to _preSelectedValues)
|
|
1913
1968
|
this._clearExistingOptions();
|
|
1914
1969
|
|
|
1915
1970
|
// Update state with new items
|
|
@@ -1917,10 +1972,35 @@ export class KTSelect extends KTComponent {
|
|
|
1917
1972
|
// Generate new options HTML
|
|
1918
1973
|
this._generateOptionsHtml(this._element);
|
|
1919
1974
|
|
|
1975
|
+
// Preserve selections by marking matching options as selected
|
|
1976
|
+
const availableValues = items.map((item) =>
|
|
1977
|
+
item.id !== undefined ? String(item.id) : '',
|
|
1978
|
+
);
|
|
1979
|
+
const validSelections = currentlySelected.filter((value) =>
|
|
1980
|
+
availableValues.includes(value),
|
|
1981
|
+
);
|
|
1982
|
+
|
|
1983
|
+
if (this._config.debug && currentlySelected.length > 0) {
|
|
1984
|
+
console.log(
|
|
1985
|
+
'reload(): Preserving selections that exist in new data:',
|
|
1986
|
+
validSelections,
|
|
1987
|
+
);
|
|
1988
|
+
}
|
|
1989
|
+
|
|
1990
|
+
// Mark preserved selections on new options
|
|
1991
|
+
validSelections.forEach((value) => {
|
|
1992
|
+
const option = Array.from(
|
|
1993
|
+
this._element.querySelectorAll('option'),
|
|
1994
|
+
).find((opt) => opt.value === value) as HTMLOptionElement;
|
|
1995
|
+
if (option) {
|
|
1996
|
+
option.selected = true;
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1999
|
+
|
|
1920
2000
|
// Update the dropdown
|
|
1921
2001
|
this._updateDropdownWithNewOptions();
|
|
1922
2002
|
|
|
1923
|
-
// Sync selection state from native select
|
|
2003
|
+
// Sync selection state from native select (now has selected attributes)
|
|
1924
2004
|
this._syncSelectionFromNative();
|
|
1925
2005
|
|
|
1926
2006
|
// Update visual display
|
|
@@ -1951,8 +2031,17 @@ export class KTSelect extends KTComponent {
|
|
|
1951
2031
|
|
|
1952
2032
|
/**
|
|
1953
2033
|
* Refresh the visual display and state without rebuilding options
|
|
1954
|
-
* For remote selects, refetches data from the server
|
|
2034
|
+
* For remote selects, refetches data from the server and preserves selections
|
|
2035
|
+
* that exist in the newly fetched data
|
|
2036
|
+
*
|
|
1955
2037
|
* @public
|
|
2038
|
+
* @remarks
|
|
2039
|
+
* - For static selects: syncs visual state with native select
|
|
2040
|
+
* - For remote selects: fetches fresh data, preserves matching selections
|
|
2041
|
+
* - Selections are preserved if their values exist in new remote data
|
|
2042
|
+
* - Selections are cleared if their values don't exist in new data
|
|
2043
|
+
* @fires refreshed - After refresh completes successfully
|
|
2044
|
+
* @fires refreshError - If remote data fetch fails
|
|
1956
2045
|
*/
|
|
1957
2046
|
public refresh(): void {
|
|
1958
2047
|
// For remote selects, refetch data
|
|
@@ -1960,22 +2049,46 @@ export class KTSelect extends KTComponent {
|
|
|
1960
2049
|
this._remoteModule
|
|
1961
2050
|
.fetchData()
|
|
1962
2051
|
.then((items) => {
|
|
1963
|
-
//
|
|
2052
|
+
// Capture currently selected values before clearing
|
|
2053
|
+
const currentlySelected = this._state.getSelectedOptions();
|
|
2054
|
+
|
|
2055
|
+
// Clear existing options (also captures to _preSelectedValues)
|
|
1964
2056
|
this._clearExistingOptions();
|
|
1965
2057
|
|
|
1966
|
-
//
|
|
2058
|
+
// Get all available values from new remote data
|
|
2059
|
+
const availableValues = items.map((item) => item.id);
|
|
2060
|
+
|
|
2061
|
+
// Filter to only values that exist in new data
|
|
2062
|
+
const validSelections = currentlySelected.filter((value) =>
|
|
2063
|
+
availableValues.includes(value),
|
|
2064
|
+
);
|
|
2065
|
+
|
|
2066
|
+
if (this._config.debug && currentlySelected.length > 0) {
|
|
2067
|
+
console.log(
|
|
2068
|
+
'refresh(): Preserving selections that exist in new data:',
|
|
2069
|
+
validSelections,
|
|
2070
|
+
);
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
// Add new options and restore selection state
|
|
1967
2074
|
items.forEach((item) => {
|
|
1968
2075
|
const option = document.createElement('option');
|
|
1969
2076
|
option.value = item.id;
|
|
1970
2077
|
option.textContent = item.title;
|
|
1971
2078
|
if (item.disabled) option.disabled = true;
|
|
2079
|
+
|
|
2080
|
+
// Restore selected attribute for preserved selections
|
|
2081
|
+
if (validSelections.includes(item.id)) {
|
|
2082
|
+
option.selected = true;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
1972
2085
|
this._element.appendChild(option);
|
|
1973
2086
|
});
|
|
1974
2087
|
|
|
1975
2088
|
// Rebuild dropdown
|
|
1976
2089
|
this._rebuildOptionsFromNative();
|
|
1977
2090
|
|
|
1978
|
-
// Sync selection state
|
|
2091
|
+
// Sync selection state from native select (now has selected attributes)
|
|
1979
2092
|
this._syncSelectionFromNative();
|
|
1980
2093
|
|
|
1981
2094
|
// Reapply ARIA attributes
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/* eslint-disable max-len */
|
|
4
|
-
var KTGlobalComponentsConfig = {
|
|
5
|
-
modal: {
|
|
6
|
-
backdropClass: 'transition-all duration-300',
|
|
7
|
-
},
|
|
8
|
-
drawer: {
|
|
9
|
-
backdropClass: 'transition-all duration-300',
|
|
10
|
-
hiddenClass: 'hidden'
|
|
11
|
-
},
|
|
12
|
-
collapse: {
|
|
13
|
-
hiddenClass: 'hidden',
|
|
14
|
-
},
|
|
15
|
-
dismiss: {
|
|
16
|
-
hiddenClass: 'hidden',
|
|
17
|
-
},
|
|
18
|
-
tabs: {
|
|
19
|
-
hiddenClass: 'hidden',
|
|
20
|
-
},
|
|
21
|
-
accordion: {
|
|
22
|
-
hiddenClass: 'hidden',
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
exports.default = KTGlobalComponentsConfig;
|
|
26
|
-
//# sourceMappingURL=config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/components/config.ts"],"names":[],"mappings":";;AAAA,4BAA4B;AAC5B,IAAM,wBAAwB,GAAG;IAC/B,KAAK,EAAE;QACL,aAAa,EAAE,6BAA6B;KAC7C;IACD,MAAM,EAAE;QACN,aAAa,EAAE,6BAA6B;QAC5C,WAAW,EAAE,QAAQ;KACtB;IACD,QAAQ,EAAE;QACR,WAAW,EAAE,QAAQ;KACtB;IACD,OAAO,EAAE;QACP,WAAW,EAAE,QAAQ;KACtB;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,QAAQ;KACtB;IACD,SAAS,EAAE;QACT,WAAW,EAAE,QAAQ;KACtB;CACF,CAAC;AAEF,kBAAe,wBAAwB,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-len */
|
|
2
|
-
window.KTGlobalComponentsConfig = {
|
|
3
|
-
modal: {
|
|
4
|
-
backdropClass: 'transition-all duration-300',
|
|
5
|
-
},
|
|
6
|
-
drawer: {
|
|
7
|
-
backdropClass: 'transition-all duration-300',
|
|
8
|
-
hiddenClass: 'hidden'
|
|
9
|
-
},
|
|
10
|
-
collapse: {
|
|
11
|
-
hiddenClass: 'hidden',
|
|
12
|
-
},
|
|
13
|
-
dismiss: {
|
|
14
|
-
hiddenClass: 'hidden',
|
|
15
|
-
},
|
|
16
|
-
tabs: {
|
|
17
|
-
hiddenClass: 'hidden',
|
|
18
|
-
},
|
|
19
|
-
accordion: {
|
|
20
|
-
hiddenClass: 'hidden',
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=config.umd.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.umd.js","sourceRoot":"","sources":["../../../src/components/config.umd.js"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,MAAM,CAAC,wBAAwB,GAAG;IAChC,KAAK,EAAE;QACL,aAAa,EAAE,6BAA6B;KAC7C;IACD,MAAM,EAAE;QACN,aAAa,EAAE,6BAA6B;QAC5C,WAAW,EAAE,QAAQ;KACtB;IACD,QAAQ,EAAE;QACR,WAAW,EAAE,QAAQ;KACtB;IACD,OAAO,EAAE;QACP,WAAW,EAAE,QAAQ;KACtB;IACD,IAAI,EAAE;QACJ,WAAW,EAAE,QAAQ;KACtB;IACD,SAAS,EAAE;QACT,WAAW,EAAE,QAAQ;KACtB;CACF,CAAC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.KTMenu = void 0;
|
|
4
|
-
var menu_1 = require("./menu");
|
|
5
|
-
Object.defineProperty(exports, "KTMenu", { enumerable: true, get: function () { return menu_1.KTMenu; } });
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/menu/index.ts"],"names":[],"mappings":";;;AAAA,+BAAgC;AAAvB,8FAAA,MAAM,OAAA"}
|