@zag-js/combobox 1.0.1 → 1.1.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/index.js +12 -12
- package/dist/index.mjs +12 -12
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -4,10 +4,10 @@ var anatomy$1 = require('@zag-js/anatomy');
|
|
|
4
4
|
var collection$1 = require('@zag-js/collection');
|
|
5
5
|
var domQuery = require('@zag-js/dom-query');
|
|
6
6
|
var popper = require('@zag-js/popper');
|
|
7
|
+
var utils = require('@zag-js/utils');
|
|
7
8
|
var ariaHidden = require('@zag-js/aria-hidden');
|
|
8
9
|
var core = require('@zag-js/core');
|
|
9
10
|
var dismissable = require('@zag-js/dismissable');
|
|
10
|
-
var utils = require('@zag-js/utils');
|
|
11
11
|
var types = require('@zag-js/types');
|
|
12
12
|
|
|
13
13
|
// src/combobox.anatomy.ts
|
|
@@ -87,6 +87,7 @@ function connect(service, normalize) {
|
|
|
87
87
|
function getItemState(props2) {
|
|
88
88
|
const disabled2 = collection2.getItemDisabled(props2.item);
|
|
89
89
|
const value = collection2.getItemValue(props2.item);
|
|
90
|
+
utils.ensure(value, `[zag-js] No value found for item ${JSON.stringify(props2.item)}`);
|
|
90
91
|
return {
|
|
91
92
|
value,
|
|
92
93
|
disabled: Boolean(disabled2 || disabled2),
|
|
@@ -479,7 +480,7 @@ var machine = core.createMachine({
|
|
|
479
480
|
domQuery.clickIfLink(node);
|
|
480
481
|
},
|
|
481
482
|
collection: collection.empty(),
|
|
482
|
-
...
|
|
483
|
+
...props2,
|
|
483
484
|
positioning: {
|
|
484
485
|
placement: "bottom",
|
|
485
486
|
sameWidth: true,
|
|
@@ -1313,21 +1314,20 @@ var machine = core.createMachine({
|
|
|
1313
1314
|
invokeOnClose({ prop }) {
|
|
1314
1315
|
prop("onOpenChange")?.({ open: false });
|
|
1315
1316
|
},
|
|
1316
|
-
highlightFirstItem({ context, prop }) {
|
|
1317
|
-
|
|
1317
|
+
highlightFirstItem({ context, prop, scope }) {
|
|
1318
|
+
const exec = getContentEl(scope) ? queueMicrotask : domQuery.raf;
|
|
1319
|
+
exec(() => {
|
|
1318
1320
|
const value = prop("collection").firstValue;
|
|
1319
|
-
context.set("highlightedValue", value);
|
|
1321
|
+
if (value) context.set("highlightedValue", value);
|
|
1320
1322
|
});
|
|
1321
1323
|
},
|
|
1322
|
-
highlightFirstItemIfNeeded({
|
|
1324
|
+
highlightFirstItemIfNeeded({ computed, action }) {
|
|
1323
1325
|
if (!computed("autoHighlight")) return;
|
|
1324
|
-
|
|
1325
|
-
const value = prop("collection").firstValue;
|
|
1326
|
-
if (value) context.set("highlightedValue", value);
|
|
1327
|
-
});
|
|
1326
|
+
action(["highlightFirstItem"]);
|
|
1328
1327
|
},
|
|
1329
|
-
highlightLastItem({ context, prop }) {
|
|
1330
|
-
|
|
1328
|
+
highlightLastItem({ context, prop, scope }) {
|
|
1329
|
+
const exec = getContentEl(scope) ? queueMicrotask : domQuery.raf;
|
|
1330
|
+
exec(() => {
|
|
1331
1331
|
const value = prop("collection").lastValue;
|
|
1332
1332
|
if (value) context.set("highlightedValue", value);
|
|
1333
1333
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -2,10 +2,10 @@ import { createAnatomy } from '@zag-js/anatomy';
|
|
|
2
2
|
import { ListCollection } from '@zag-js/collection';
|
|
3
3
|
import { clickIfLink, observeChildren, raf, observeAttributes, dataAttr, ariaAttr, isComposingEvent, getEventKey, isLeftClick, isDownloadingEvent, isOpeningInNewTab, isContextMenuEvent, scrollIntoView, query, isAnchorElement } from '@zag-js/dom-query';
|
|
4
4
|
import { getPlacement, getPlacementStyles } from '@zag-js/popper';
|
|
5
|
+
import { match, isBoolean, addOrRemove, remove, createSplitProps, ensure } from '@zag-js/utils';
|
|
5
6
|
import { ariaHidden } from '@zag-js/aria-hidden';
|
|
6
7
|
import { createGuards, createMachine } from '@zag-js/core';
|
|
7
8
|
import { trackDismissableElement } from '@zag-js/dismissable';
|
|
8
|
-
import { compact, match, isBoolean, addOrRemove, remove, createSplitProps } from '@zag-js/utils';
|
|
9
9
|
import { createProps } from '@zag-js/types';
|
|
10
10
|
|
|
11
11
|
// src/combobox.anatomy.ts
|
|
@@ -85,6 +85,7 @@ function connect(service, normalize) {
|
|
|
85
85
|
function getItemState(props2) {
|
|
86
86
|
const disabled2 = collection2.getItemDisabled(props2.item);
|
|
87
87
|
const value = collection2.getItemValue(props2.item);
|
|
88
|
+
ensure(value, `[zag-js] No value found for item ${JSON.stringify(props2.item)}`);
|
|
88
89
|
return {
|
|
89
90
|
value,
|
|
90
91
|
disabled: Boolean(disabled2 || disabled2),
|
|
@@ -477,7 +478,7 @@ var machine = createMachine({
|
|
|
477
478
|
clickIfLink(node);
|
|
478
479
|
},
|
|
479
480
|
collection: collection.empty(),
|
|
480
|
-
...
|
|
481
|
+
...props2,
|
|
481
482
|
positioning: {
|
|
482
483
|
placement: "bottom",
|
|
483
484
|
sameWidth: true,
|
|
@@ -1311,21 +1312,20 @@ var machine = createMachine({
|
|
|
1311
1312
|
invokeOnClose({ prop }) {
|
|
1312
1313
|
prop("onOpenChange")?.({ open: false });
|
|
1313
1314
|
},
|
|
1314
|
-
highlightFirstItem({ context, prop }) {
|
|
1315
|
-
|
|
1315
|
+
highlightFirstItem({ context, prop, scope }) {
|
|
1316
|
+
const exec = getContentEl(scope) ? queueMicrotask : raf;
|
|
1317
|
+
exec(() => {
|
|
1316
1318
|
const value = prop("collection").firstValue;
|
|
1317
|
-
context.set("highlightedValue", value);
|
|
1319
|
+
if (value) context.set("highlightedValue", value);
|
|
1318
1320
|
});
|
|
1319
1321
|
},
|
|
1320
|
-
highlightFirstItemIfNeeded({
|
|
1322
|
+
highlightFirstItemIfNeeded({ computed, action }) {
|
|
1321
1323
|
if (!computed("autoHighlight")) return;
|
|
1322
|
-
|
|
1323
|
-
const value = prop("collection").firstValue;
|
|
1324
|
-
if (value) context.set("highlightedValue", value);
|
|
1325
|
-
});
|
|
1324
|
+
action(["highlightFirstItem"]);
|
|
1326
1325
|
},
|
|
1327
|
-
highlightLastItem({ context, prop }) {
|
|
1328
|
-
|
|
1326
|
+
highlightLastItem({ context, prop, scope }) {
|
|
1327
|
+
const exec = getContentEl(scope) ? queueMicrotask : raf;
|
|
1328
|
+
exec(() => {
|
|
1329
1329
|
const value = prop("collection").lastValue;
|
|
1330
1330
|
if (value) context.set("highlightedValue", value);
|
|
1331
1331
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/combobox",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Core logic for the combobox widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -26,15 +26,15 @@
|
|
|
26
26
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@zag-js/anatomy": "1.0
|
|
30
|
-
"@zag-js/aria-hidden": "1.0
|
|
31
|
-
"@zag-js/collection": "1.0
|
|
32
|
-
"@zag-js/core": "1.0
|
|
33
|
-
"@zag-js/dismissable": "1.0
|
|
34
|
-
"@zag-js/dom-query": "1.0
|
|
35
|
-
"@zag-js/utils": "1.0
|
|
36
|
-
"@zag-js/popper": "1.0
|
|
37
|
-
"@zag-js/types": "1.0
|
|
29
|
+
"@zag-js/anatomy": "1.1.0",
|
|
30
|
+
"@zag-js/aria-hidden": "1.1.0",
|
|
31
|
+
"@zag-js/collection": "1.1.0",
|
|
32
|
+
"@zag-js/core": "1.1.0",
|
|
33
|
+
"@zag-js/dismissable": "1.1.0",
|
|
34
|
+
"@zag-js/dom-query": "1.1.0",
|
|
35
|
+
"@zag-js/utils": "1.1.0",
|
|
36
|
+
"@zag-js/popper": "1.1.0",
|
|
37
|
+
"@zag-js/types": "1.1.0"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"clean-package": "2.2.0"
|