@zag-js/color-picker 1.46.0 → 1.47.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.
|
@@ -398,6 +398,7 @@ var machine = (0, import_core.createMachine)({
|
|
|
398
398
|
type: "popover",
|
|
399
399
|
exclude: dom.getTriggerEl(scope),
|
|
400
400
|
defer: true,
|
|
401
|
+
getRootNode: scope.getRootNode,
|
|
401
402
|
layerStyleTargets: [() => dom.getPositionerEl(scope)],
|
|
402
403
|
onInteractOutside(event) {
|
|
403
404
|
prop("onInteractOutside")?.(event);
|
|
@@ -406,8 +407,8 @@ var machine = (0, import_core.createMachine)({
|
|
|
406
407
|
},
|
|
407
408
|
onPointerDownOutside: prop("onPointerDownOutside"),
|
|
408
409
|
onFocusOutside: prop("onFocusOutside"),
|
|
409
|
-
onDismiss() {
|
|
410
|
-
send({ type: "INTERACT_OUTSIDE" });
|
|
410
|
+
onDismiss(event) {
|
|
411
|
+
send({ type: "INTERACT_OUTSIDE", focusVisible: event?.type === "keydown" });
|
|
411
412
|
}
|
|
412
413
|
});
|
|
413
414
|
},
|
|
@@ -598,9 +599,12 @@ var machine = (0, import_core.createMachine)({
|
|
|
598
599
|
element.focus({ preventScroll: true });
|
|
599
600
|
});
|
|
600
601
|
},
|
|
601
|
-
setReturnFocus({ scope }) {
|
|
602
|
+
setReturnFocus({ scope, event }) {
|
|
603
|
+
const contentEl = dom.getContentEl(scope);
|
|
604
|
+
const focusOptions = getReturnFocusOptions(event);
|
|
602
605
|
(0, import_dom_query.raf)(() => {
|
|
603
|
-
|
|
606
|
+
if ((0, import_dom_query.isFocusOutside)(scope.getActiveElement(), [contentEl])) return;
|
|
607
|
+
dom.getTriggerEl(scope)?.focus(focusOptions);
|
|
604
608
|
});
|
|
605
609
|
},
|
|
606
610
|
syncFormatSelectElement({ context, scope }) {
|
|
@@ -640,6 +644,10 @@ function syncFormatSelect(scope, format) {
|
|
|
640
644
|
if (!selectEl) return;
|
|
641
645
|
(0, import_dom_query.raf)(() => (0, import_dom_query.setElementValue)(selectEl, format));
|
|
642
646
|
}
|
|
647
|
+
function getReturnFocusOptions(event) {
|
|
648
|
+
const focusVisible = event.focusVisible ?? event.previousEvent?.focusVisible;
|
|
649
|
+
return focusVisible ? { preventScroll: true, focusVisible: true } : { preventScroll: true };
|
|
650
|
+
}
|
|
643
651
|
// Annotate the CommonJS export names for ESM import in node:
|
|
644
652
|
0 && (module.exports = {
|
|
645
653
|
machine
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
disableTextSelection,
|
|
7
7
|
dispatchInputValueEvent,
|
|
8
8
|
getInitialFocus,
|
|
9
|
+
isFocusOutside,
|
|
9
10
|
raf,
|
|
10
11
|
setElementValue,
|
|
11
12
|
trackFormControl,
|
|
@@ -372,6 +373,7 @@ var machine = createMachine({
|
|
|
372
373
|
type: "popover",
|
|
373
374
|
exclude: dom.getTriggerEl(scope),
|
|
374
375
|
defer: true,
|
|
376
|
+
getRootNode: scope.getRootNode,
|
|
375
377
|
layerStyleTargets: [() => dom.getPositionerEl(scope)],
|
|
376
378
|
onInteractOutside(event) {
|
|
377
379
|
prop("onInteractOutside")?.(event);
|
|
@@ -380,8 +382,8 @@ var machine = createMachine({
|
|
|
380
382
|
},
|
|
381
383
|
onPointerDownOutside: prop("onPointerDownOutside"),
|
|
382
384
|
onFocusOutside: prop("onFocusOutside"),
|
|
383
|
-
onDismiss() {
|
|
384
|
-
send({ type: "INTERACT_OUTSIDE" });
|
|
385
|
+
onDismiss(event) {
|
|
386
|
+
send({ type: "INTERACT_OUTSIDE", focusVisible: event?.type === "keydown" });
|
|
385
387
|
}
|
|
386
388
|
});
|
|
387
389
|
},
|
|
@@ -572,9 +574,12 @@ var machine = createMachine({
|
|
|
572
574
|
element.focus({ preventScroll: true });
|
|
573
575
|
});
|
|
574
576
|
},
|
|
575
|
-
setReturnFocus({ scope }) {
|
|
577
|
+
setReturnFocus({ scope, event }) {
|
|
578
|
+
const contentEl = dom.getContentEl(scope);
|
|
579
|
+
const focusOptions = getReturnFocusOptions(event);
|
|
576
580
|
raf(() => {
|
|
577
|
-
|
|
581
|
+
if (isFocusOutside(scope.getActiveElement(), [contentEl])) return;
|
|
582
|
+
dom.getTriggerEl(scope)?.focus(focusOptions);
|
|
578
583
|
});
|
|
579
584
|
},
|
|
580
585
|
syncFormatSelectElement({ context, scope }) {
|
|
@@ -614,6 +619,10 @@ function syncFormatSelect(scope, format) {
|
|
|
614
619
|
if (!selectEl) return;
|
|
615
620
|
raf(() => setElementValue(selectEl, format));
|
|
616
621
|
}
|
|
622
|
+
function getReturnFocusOptions(event) {
|
|
623
|
+
const focusVisible = event.focusVisible ?? event.previousEvent?.focusVisible;
|
|
624
|
+
return focusVisible ? { preventScroll: true, focusVisible: true } : { preventScroll: true };
|
|
625
|
+
}
|
|
617
626
|
export {
|
|
618
627
|
machine
|
|
619
628
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zag-js/color-picker",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.47.0",
|
|
4
4
|
"description": "Core logic for the color-picker widget implemented as a state machine",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"js",
|
|
@@ -30,14 +30,14 @@
|
|
|
30
30
|
"url": "https://github.com/chakra-ui/zag/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@zag-js/core": "1.
|
|
34
|
-
"@zag-js/anatomy": "1.
|
|
35
|
-
"@zag-js/dom-query": "1.
|
|
36
|
-
"@zag-js/dismissable": "1.
|
|
37
|
-
"@zag-js/utils": "1.
|
|
38
|
-
"@zag-js/color-utils": "1.
|
|
39
|
-
"@zag-js/popper": "1.
|
|
40
|
-
"@zag-js/types": "1.
|
|
33
|
+
"@zag-js/core": "1.47.0",
|
|
34
|
+
"@zag-js/anatomy": "1.47.0",
|
|
35
|
+
"@zag-js/dom-query": "1.47.0",
|
|
36
|
+
"@zag-js/dismissable": "1.47.0",
|
|
37
|
+
"@zag-js/utils": "1.47.0",
|
|
38
|
+
"@zag-js/color-utils": "1.47.0",
|
|
39
|
+
"@zag-js/popper": "1.47.0",
|
|
40
|
+
"@zag-js/types": "1.47.0"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"clean-package": "2.2.0"
|