@gridkitjs/forms-dom 0.0.0-dev-20261206150419 → 0.0.0-dev-20261206170054
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.d.ts +8 -0
- package/dist/index.js +16 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -464,6 +464,13 @@ interface ComboboxOptions {
|
|
|
464
464
|
readonly tabChooses: boolean;
|
|
465
465
|
/** Nothing opens the popup. */
|
|
466
466
|
readonly readOnly: boolean;
|
|
467
|
+
/**
|
|
468
|
+
* Whether there is a popup at all. Without one (a tag input with no
|
|
469
|
+
* suggestions) the control is a plain text box: nothing opens, and no
|
|
470
|
+
* `aria-expanded`, `aria-controls` or `aria-activedescendant` is
|
|
471
|
+
* written. Default true.
|
|
472
|
+
*/
|
|
473
|
+
readonly popup?: boolean | undefined;
|
|
467
474
|
readonly onOpenRequest: (reason: PopupOpenReason, nativeEvent: Event) => void;
|
|
468
475
|
readonly onCloseRequest: (reason: PopupCloseReason, nativeEvent: Event) => void;
|
|
469
476
|
/**
|
|
@@ -498,6 +505,7 @@ interface AttachedCombobox {
|
|
|
498
505
|
* close (`"escape"`), F4 and Alt+↑ too (`"button"`), and so does a press
|
|
499
506
|
* on a select-only control. Tab leaves, choosing the active row first
|
|
500
507
|
* with `tabChooses`, and asks to close (`"blur"`), as leaving does.
|
|
508
|
+
* - Keys an input method is using are left alone.
|
|
501
509
|
* - It listens in the capture phase, so a key it takes is prevented before
|
|
502
510
|
* `attachTextInput` sees it and skips it.
|
|
503
511
|
* - A select-only control calls the controller's `focus` and `blur`,
|
package/dist/index.js
CHANGED
|
@@ -624,6 +624,10 @@ function hasFocus(control) {
|
|
|
624
624
|
const root = control.getRootNode();
|
|
625
625
|
return (root instanceof Document || root instanceof ShadowRoot) && root.activeElement === control;
|
|
626
626
|
}
|
|
627
|
+
function isComposing(event) {
|
|
628
|
+
const legacy = event;
|
|
629
|
+
return event.isComposing || legacy.keyCode === 229;
|
|
630
|
+
}
|
|
627
631
|
function isPrintable(event) {
|
|
628
632
|
return !event.ctrlKey && !event.metaKey && !event.altKey && Array.from(event.key).length === 1;
|
|
629
633
|
}
|
|
@@ -647,6 +651,12 @@ function attachCombobox(control, controller, initialOptions) {
|
|
|
647
651
|
if (!attached) {
|
|
648
652
|
return;
|
|
649
653
|
}
|
|
654
|
+
if (options.popup === false) {
|
|
655
|
+
control.removeAttribute("aria-expanded");
|
|
656
|
+
control.removeAttribute("aria-controls");
|
|
657
|
+
control.removeAttribute("aria-activedescendant");
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
650
660
|
const { listbox } = options;
|
|
651
661
|
control.setAttribute("aria-expanded", String(listbox !== null));
|
|
652
662
|
const listId = listbox?.element.id ?? "";
|
|
@@ -683,7 +693,7 @@ function attachCombobox(control, controller, initialOptions) {
|
|
|
683
693
|
}
|
|
684
694
|
}
|
|
685
695
|
function requestOpen(reason, event) {
|
|
686
|
-
if (!options.readOnly) {
|
|
696
|
+
if (!options.readOnly && options.popup !== false) {
|
|
687
697
|
options.onOpenRequest(reason, event);
|
|
688
698
|
}
|
|
689
699
|
}
|
|
@@ -784,7 +794,7 @@ function attachCombobox(control, controller, initialOptions) {
|
|
|
784
794
|
}
|
|
785
795
|
}
|
|
786
796
|
function onKeyDown(event) {
|
|
787
|
-
if (event.defaultPrevented || event
|
|
797
|
+
if (event.defaultPrevented || isComposing(event)) {
|
|
788
798
|
return;
|
|
789
799
|
}
|
|
790
800
|
if (event.key === "Tab") {
|
|
@@ -2446,7 +2456,7 @@ function attachTextInput(control, controller, initialOptions = {}) {
|
|
|
2446
2456
|
controller.endComposition(event);
|
|
2447
2457
|
render();
|
|
2448
2458
|
}
|
|
2449
|
-
function
|
|
2459
|
+
function isComposing2(event) {
|
|
2450
2460
|
const legacy = event;
|
|
2451
2461
|
return event.isComposing || state.kind === "composing" || legacy.keyCode === 229;
|
|
2452
2462
|
}
|
|
@@ -2454,7 +2464,7 @@ function attachTextInput(control, controller, initialOptions = {}) {
|
|
|
2454
2464
|
return control instanceof HTMLTextAreaElement ? event.ctrlKey || event.metaKey : true;
|
|
2455
2465
|
}
|
|
2456
2466
|
function onKeyDown(event) {
|
|
2457
|
-
if (event.defaultPrevented ||
|
|
2467
|
+
if (event.defaultPrevented || isComposing2(event)) {
|
|
2458
2468
|
return;
|
|
2459
2469
|
}
|
|
2460
2470
|
const modified = event.ctrlKey || event.altKey || event.metaKey;
|
|
@@ -2901,7 +2911,7 @@ function attachSegments(group, controller, initialOptions) {
|
|
|
2901
2911
|
function finish(nativeEvent) {
|
|
2902
2912
|
run({ type: "finish" }, { ...NO_CAUSE, nativeEvent });
|
|
2903
2913
|
}
|
|
2904
|
-
function
|
|
2914
|
+
function isComposing2(event) {
|
|
2905
2915
|
const legacy = event;
|
|
2906
2916
|
return event.isComposing || state.entry.kind === "composing" || legacy.keyCode === 229;
|
|
2907
2917
|
}
|
|
@@ -2975,7 +2985,7 @@ function attachSegments(group, controller, initialOptions) {
|
|
|
2975
2985
|
}
|
|
2976
2986
|
}
|
|
2977
2987
|
function onKeyDown(event) {
|
|
2978
|
-
if (event.defaultPrevented ||
|
|
2988
|
+
if (event.defaultPrevented || isComposing2(event)) {
|
|
2979
2989
|
return;
|
|
2980
2990
|
}
|
|
2981
2991
|
const { target } = event;
|