@zag-js/combobox 1.39.1 → 1.41.0
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/combobox.connect.js +7 -4
- package/dist/combobox.connect.mjs +8 -5
- package/package.json +11 -11
package/dist/combobox.connect.js
CHANGED
|
@@ -51,9 +51,11 @@ function connect(service, normalize) {
|
|
|
51
51
|
const focused = state.hasTag("focused");
|
|
52
52
|
const composite = prop("composite");
|
|
53
53
|
const highlightedValue = context.get("highlightedValue");
|
|
54
|
+
const currentPlacement = context.get("currentPlacement");
|
|
55
|
+
const currentPlacementSide = currentPlacement ? (0, import_popper.getPlacementSide)(currentPlacement) : void 0;
|
|
54
56
|
const popperStyles = (0, import_popper.getPlacementStyles)({
|
|
55
57
|
...prop("positioning"),
|
|
56
|
-
placement:
|
|
58
|
+
placement: currentPlacement
|
|
57
59
|
});
|
|
58
60
|
function getItemState(props) {
|
|
59
61
|
const itemDisabled = collection.getItemDisabled(props.item);
|
|
@@ -238,10 +240,10 @@ function connect(service, normalize) {
|
|
|
238
240
|
},
|
|
239
241
|
Enter(event3) {
|
|
240
242
|
send({ type: "INPUT.ENTER", keypress, src: "item-select" });
|
|
241
|
-
const submittable = computed("isCustomValue") && prop("allowCustomValue");
|
|
242
243
|
const hasHighlight = highlightedValue != null;
|
|
243
244
|
const alwaysSubmit = prop("alwaysSubmitOnEnter");
|
|
244
|
-
|
|
245
|
+
const willBeRejected = computed("isCustomValue") && !prop("allowCustomValue");
|
|
246
|
+
if (open && !alwaysSubmit && (hasHighlight || willBeRejected)) {
|
|
245
247
|
event3.preventDefault();
|
|
246
248
|
}
|
|
247
249
|
if (highlightedValue == null) return;
|
|
@@ -326,7 +328,8 @@ function connect(service, normalize) {
|
|
|
326
328
|
tabIndex: -1,
|
|
327
329
|
hidden: !open,
|
|
328
330
|
"data-state": open ? "open" : "closed",
|
|
329
|
-
"data-placement":
|
|
331
|
+
"data-placement": currentPlacement,
|
|
332
|
+
"data-side": currentPlacementSide,
|
|
330
333
|
"aria-labelledby": dom.getLabelId(scope),
|
|
331
334
|
"aria-multiselectable": prop("multiple") && composite ? true : void 0,
|
|
332
335
|
"data-empty": (0, import_dom_query.dataAttr)(collection.size === 0),
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
isLeftClick,
|
|
11
11
|
isOpeningInNewTab
|
|
12
12
|
} from "@zag-js/dom-query";
|
|
13
|
-
import { getPlacementStyles } from "@zag-js/popper";
|
|
13
|
+
import { getPlacementSide, getPlacementStyles } from "@zag-js/popper";
|
|
14
14
|
import { ensure } from "@zag-js/utils";
|
|
15
15
|
import { parts } from "./combobox.anatomy.mjs";
|
|
16
16
|
import * as dom from "./combobox.dom.mjs";
|
|
@@ -27,9 +27,11 @@ function connect(service, normalize) {
|
|
|
27
27
|
const focused = state.hasTag("focused");
|
|
28
28
|
const composite = prop("composite");
|
|
29
29
|
const highlightedValue = context.get("highlightedValue");
|
|
30
|
+
const currentPlacement = context.get("currentPlacement");
|
|
31
|
+
const currentPlacementSide = currentPlacement ? getPlacementSide(currentPlacement) : void 0;
|
|
30
32
|
const popperStyles = getPlacementStyles({
|
|
31
33
|
...prop("positioning"),
|
|
32
|
-
placement:
|
|
34
|
+
placement: currentPlacement
|
|
33
35
|
});
|
|
34
36
|
function getItemState(props) {
|
|
35
37
|
const itemDisabled = collection.getItemDisabled(props.item);
|
|
@@ -214,10 +216,10 @@ function connect(service, normalize) {
|
|
|
214
216
|
},
|
|
215
217
|
Enter(event3) {
|
|
216
218
|
send({ type: "INPUT.ENTER", keypress, src: "item-select" });
|
|
217
|
-
const submittable = computed("isCustomValue") && prop("allowCustomValue");
|
|
218
219
|
const hasHighlight = highlightedValue != null;
|
|
219
220
|
const alwaysSubmit = prop("alwaysSubmitOnEnter");
|
|
220
|
-
|
|
221
|
+
const willBeRejected = computed("isCustomValue") && !prop("allowCustomValue");
|
|
222
|
+
if (open && !alwaysSubmit && (hasHighlight || willBeRejected)) {
|
|
221
223
|
event3.preventDefault();
|
|
222
224
|
}
|
|
223
225
|
if (highlightedValue == null) return;
|
|
@@ -302,7 +304,8 @@ function connect(service, normalize) {
|
|
|
302
304
|
tabIndex: -1,
|
|
303
305
|
hidden: !open,
|
|
304
306
|
"data-state": open ? "open" : "closed",
|
|
305
|
-
"data-placement":
|
|
307
|
+
"data-placement": currentPlacement,
|
|
308
|
+
"data-side": currentPlacementSide,
|
|
306
309
|
"aria-labelledby": dom.getLabelId(scope),
|
|
307
310
|
"aria-multiselectable": prop("multiple") && composite ? true : void 0,
|
|
308
311
|
"data-empty": dataAttr(collection.size === 0),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/combobox",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.41.0",
|
|
4
4
|
"description": "Core logic for the combobox widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zag-js/
|
|
30
|
-
"@zag-js/
|
|
31
|
-
"@zag-js/dismissable": "1.
|
|
32
|
-
"@zag-js/dom-query": "1.
|
|
33
|
-
"@zag-js/
|
|
34
|
-
"@zag-js/
|
|
35
|
-
"@zag-js/
|
|
36
|
-
"@zag-js/
|
|
37
|
-
"@zag-js/utils": "1.
|
|
38
|
-
"@zag-js/
|
|
29
|
+
"@zag-js/anatomy": "1.41.0",
|
|
30
|
+
"@zag-js/core": "1.41.0",
|
|
31
|
+
"@zag-js/dismissable": "1.41.0",
|
|
32
|
+
"@zag-js/dom-query": "1.41.0",
|
|
33
|
+
"@zag-js/collection": "1.41.0",
|
|
34
|
+
"@zag-js/focus-visible": "1.41.0",
|
|
35
|
+
"@zag-js/live-region": "1.41.0",
|
|
36
|
+
"@zag-js/popper": "1.41.0",
|
|
37
|
+
"@zag-js/utils": "1.41.0",
|
|
38
|
+
"@zag-js/types": "1.41.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"clean-package": "2.2.0"
|