@keenmate/web-multiselect 2.0.0-rc07 → 2.0.0-rc08
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/README.md +13 -7
- package/custom-elements.json +41 -1
- package/dist/index.d.ts +81 -0
- package/dist/multiselect.js +420 -352
- package/dist/multiselect.umd.js +8 -8
- package/docs/usage.md +23 -0
- package/package.json +1 -1
- package/web-types.json +6 -1
package/docs/usage.md
CHANGED
|
@@ -219,6 +219,29 @@ multiselect.beforeDeselectCallback = (option, selectedOptions) => {
|
|
|
219
219
|
if (option.value === 'item1') return false;
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
+
// Keyboard hook — runs on every keydown BEFORE the built-in handling.
|
|
223
|
+
// Return true to mark the key fully handled (you own preventDefault; the
|
|
224
|
+
// component runs none of its own logic for it); return false/undefined to
|
|
225
|
+
// fall through to the defaults. `ctx.controller` mirrors the built-in actions.
|
|
226
|
+
multiselect.keydownCallback = (ctx) => {
|
|
227
|
+
// Vim-style navigation. Returning true means you own the key — call
|
|
228
|
+
// preventDefault() so a printable key like 'j' isn't also typed into search.
|
|
229
|
+
if (ctx.key === 'j') { ctx.event.preventDefault(); ctx.controller.focusNext(); return true; }
|
|
230
|
+
if (ctx.key === 'k') { ctx.event.preventDefault(); ctx.controller.focusPrevious(); return true; }
|
|
231
|
+
// Ctrl+A → select all currently-filtered options (selectValue is a no-op if
|
|
232
|
+
// already selected — so it's a true "select all", not a toggle/invert)
|
|
233
|
+
if ((ctx.event.ctrlKey || ctx.event.metaKey) && ctx.key === 'a') {
|
|
234
|
+
ctx.event.preventDefault();
|
|
235
|
+
ctx.filteredOptions.forEach(o => ctx.controller.selectValue(o.value));
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
// ctx also exposes: event, key, isOpen, presentation, searchTerm,
|
|
239
|
+
// focusedIndex, focusedOption, filteredOptions, selectedValues.
|
|
240
|
+
// controller: focusNext/Previous/First/Last, focusPageUp/Down,
|
|
241
|
+
// focusNextMatch/PreviousMatch, focusIndex, toggleFocused, toggleValue,
|
|
242
|
+
// selectValue, deselectValue, open, close, setSearch, clearSearch.
|
|
243
|
+
};
|
|
244
|
+
|
|
222
245
|
// Event handler properties. Since v2 these are real listeners: each receives
|
|
223
246
|
// the same CustomEvent addEventListener('select', ...) would get, so read the
|
|
224
247
|
// payload off `e.detail` — NOT as a bare argument.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@keenmate/web-multiselect",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc08",
|
|
4
4
|
"description": "Lightweight multiselect web component with typeahead search, rich content support, and excellent keyboard navigation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/multiselect.umd.js",
|
package/web-types.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json",
|
|
3
3
|
"name": "@keenmate/web-multiselect",
|
|
4
|
-
"version": "2.0.0-
|
|
4
|
+
"version": "2.0.0-rc08",
|
|
5
5
|
"description-markup": "markdown",
|
|
6
6
|
"contributions": {
|
|
7
7
|
"html": {
|
|
@@ -1028,6 +1028,11 @@
|
|
|
1028
1028
|
"name": "addNewCallback",
|
|
1029
1029
|
"description": "Create a new option from the typed text.",
|
|
1030
1030
|
"type": "(value: string) => unknown | Promise<unknown>"
|
|
1031
|
+
},
|
|
1032
|
+
{
|
|
1033
|
+
"name": "keydownCallback",
|
|
1034
|
+
"description": "Intercept keydown before built-in handling; return true to suppress the default. Gets the event, current state, and an imperative controller.",
|
|
1035
|
+
"type": "(context: MultiSelectKeydownContext) => boolean | void"
|
|
1031
1036
|
}
|
|
1032
1037
|
],
|
|
1033
1038
|
"events": [
|