@samline/drawer 2.0.5 → 2.0.6
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 +1 -0
- package/dist/{svelte/components-client-D4tSixHM.js → browser/components-client-CJuQ5vtW.js} +9 -4
- package/dist/browser/{components-client-BnT3P9Or.mjs → components-client-tfLTRxPH.mjs} +9 -4
- package/dist/browser/index.cjs +32 -6
- package/dist/browser/index.js +32 -6
- package/dist/browser/index.mjs +32 -6
- package/dist/{browser/components-client-D4tSixHM.js → components-client-CJuQ5vtW.js} +9 -4
- package/dist/{svelte/components-client-BnT3P9Or.mjs → components-client-tfLTRxPH.mjs} +9 -4
- package/dist/index.js +32 -6
- package/dist/index.mjs +32 -6
- package/dist/react/index.js +30 -4
- package/dist/react/index.mjs +30 -4
- package/dist/{vue/components-client-D4tSixHM.js → svelte/components-client-CJuQ5vtW.js} +9 -4
- package/dist/{components-client-BnT3P9Or.mjs → svelte/components-client-tfLTRxPH.mjs} +9 -4
- package/dist/svelte/index.js +32 -6
- package/dist/svelte/index.mjs +32 -6
- package/dist/{components-client-D4tSixHM.js → vue/components-client-CJuQ5vtW.js} +9 -4
- package/dist/vue/{components-client-CvNPHVej.mjs → components-client-DSM2G8ef.mjs} +9 -4
- package/dist/vue/index.js +32 -6
- package/dist/vue/index.mjs +32 -6
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -27963,6 +27963,7 @@ function getDragPermission({
|
|
|
27963
27963
|
}
|
|
27964
27964
|
|
|
27965
27965
|
// src/react/components.tsx
|
|
27966
|
+
var useSafeLayoutEffect = typeof window === "undefined" ? import_react9.default.useEffect : import_react9.default.useLayoutEffect;
|
|
27966
27967
|
function Root2({
|
|
27967
27968
|
open: openProp,
|
|
27968
27969
|
onOpenChange,
|
|
@@ -28106,18 +28107,22 @@ function Root2({
|
|
|
28106
28107
|
noBodyStyles,
|
|
28107
28108
|
autoFocus
|
|
28108
28109
|
});
|
|
28109
|
-
|
|
28110
|
+
useSafeLayoutEffect(() => {
|
|
28110
28111
|
if (!isOpen || !modal || autoFocus || typeof document === "undefined") {
|
|
28111
28112
|
return;
|
|
28112
28113
|
}
|
|
28113
28114
|
const activeElement = document.activeElement;
|
|
28114
|
-
if (!
|
|
28115
|
+
if (!activeElement || activeElement === document.body) {
|
|
28116
|
+
return;
|
|
28117
|
+
}
|
|
28118
|
+
const activeElementNode = activeElement;
|
|
28119
|
+
if (drawerRef.current?.contains(activeElementNode) || activeElementNode.closest?.("[data-drawer]")) {
|
|
28115
28120
|
return;
|
|
28116
28121
|
}
|
|
28117
|
-
if (
|
|
28122
|
+
if (typeof activeElementNode.blur !== "function") {
|
|
28118
28123
|
return;
|
|
28119
28124
|
}
|
|
28120
|
-
|
|
28125
|
+
activeElementNode.blur();
|
|
28121
28126
|
}, [autoFocus, isOpen, modal]);
|
|
28122
28127
|
function getScale() {
|
|
28123
28128
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
@@ -28855,7 +28860,7 @@ var VISUALLY_HIDDEN_STYLE = {
|
|
|
28855
28860
|
whiteSpace: "nowrap",
|
|
28856
28861
|
border: 0
|
|
28857
28862
|
};
|
|
28858
|
-
var
|
|
28863
|
+
var useSafeLayoutEffect2 = typeof window === "undefined" ? import_react10.default.useEffect : import_react10.default.useLayoutEffect;
|
|
28859
28864
|
function toReactDrawerProps(options, open, onOpenChange, internalOnDragChange, internalOnReleaseChange) {
|
|
28860
28865
|
const { id: _id, parentId: _parentId, onDragChange, onReleaseChange, ...drawerOptions } = options;
|
|
28861
28866
|
const baseProps = {
|
|
@@ -28889,7 +28894,7 @@ function VanillaNode({
|
|
|
28889
28894
|
dataAttribute
|
|
28890
28895
|
}) {
|
|
28891
28896
|
const ref = import_react10.default.useRef(null);
|
|
28892
|
-
|
|
28897
|
+
useSafeLayoutEffect2(() => {
|
|
28893
28898
|
const element = ref.current;
|
|
28894
28899
|
if (!element) {
|
|
28895
28900
|
return;
|
|
@@ -29095,6 +29100,7 @@ function openAncestorChain(parentId) {
|
|
|
29095
29100
|
openAncestorChain(nextParentId);
|
|
29096
29101
|
}
|
|
29097
29102
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
29103
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
29098
29104
|
parentRuntime.controller.setOpen(true);
|
|
29099
29105
|
notifyOpenStateChange(parentRuntime, true);
|
|
29100
29106
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -29114,6 +29120,7 @@ function bindTriggerElement(runtime) {
|
|
|
29114
29120
|
}
|
|
29115
29121
|
const triggerElement = runtime.options.triggerElement;
|
|
29116
29122
|
const handleClick = () => {
|
|
29123
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29117
29124
|
runtime.controller.setOpen(true);
|
|
29118
29125
|
renderVanillaDrawer(runtime.id);
|
|
29119
29126
|
};
|
|
@@ -29149,6 +29156,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
29149
29156
|
function canUseDOM3() {
|
|
29150
29157
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
29151
29158
|
}
|
|
29159
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
29160
|
+
if (!canUseDOM3() || options.modal === false || options.autoFocus) {
|
|
29161
|
+
return;
|
|
29162
|
+
}
|
|
29163
|
+
const activeElement = document.activeElement;
|
|
29164
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== "function") {
|
|
29165
|
+
return;
|
|
29166
|
+
}
|
|
29167
|
+
activeElement.blur();
|
|
29168
|
+
}
|
|
29152
29169
|
function getRuntimeDrawerElement(runtime) {
|
|
29153
29170
|
if (!runtime.element) {
|
|
29154
29171
|
return null;
|
|
@@ -29202,6 +29219,9 @@ function renderVanillaDrawer(id) {
|
|
|
29202
29219
|
open: snapshot.state.isOpen,
|
|
29203
29220
|
onOpenChange: (open) => {
|
|
29204
29221
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29222
|
+
if (open) {
|
|
29223
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29224
|
+
}
|
|
29205
29225
|
runtime.controller.setOpen(open);
|
|
29206
29226
|
if (previousOpen !== open) {
|
|
29207
29227
|
notifyOpenStateChange(runtime, open);
|
|
@@ -29248,6 +29268,9 @@ function buildVanillaController(id) {
|
|
|
29248
29268
|
if (!runtime) {
|
|
29249
29269
|
return createDrawer({ id, open }).getSnapshot();
|
|
29250
29270
|
}
|
|
29271
|
+
if (open) {
|
|
29272
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29273
|
+
}
|
|
29251
29274
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29252
29275
|
const snapshot = runtime.controller.setOpen(open);
|
|
29253
29276
|
if (previousOpen !== open) {
|
|
@@ -29318,6 +29341,9 @@ function createDrawer(options = {}) {
|
|
|
29318
29341
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
29319
29342
|
}
|
|
29320
29343
|
}
|
|
29344
|
+
if (nextOptions.open && !previousOpen) {
|
|
29345
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
29346
|
+
}
|
|
29321
29347
|
renderVanillaDrawer(id);
|
|
29322
29348
|
if (nextOptions.parentId && nextOptions.open) {
|
|
29323
29349
|
openAncestorChain(nextOptions.parentId);
|
package/dist/react/index.js
CHANGED
|
@@ -1473,6 +1473,7 @@ function getDragPermission({ targetTagName, hasNoDragAttribute, direction, timeS
|
|
|
1473
1473
|
};
|
|
1474
1474
|
}
|
|
1475
1475
|
|
|
1476
|
+
const useSafeLayoutEffect$1 = typeof window === 'undefined' ? React__namespace.default.useEffect : React__namespace.default.useLayoutEffect;
|
|
1476
1477
|
function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = 'bottom', defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
|
|
1477
1478
|
var _drawerRef_current, _drawerRef_current1;
|
|
1478
1479
|
const animationEndTimeoutRef = React__namespace.default.useRef(null);
|
|
@@ -1580,19 +1581,23 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
|
|
|
1580
1581
|
noBodyStyles,
|
|
1581
1582
|
autoFocus
|
|
1582
1583
|
});
|
|
1583
|
-
|
|
1584
|
+
useSafeLayoutEffect$1(()=>{
|
|
1584
1585
|
var _drawerRef_current;
|
|
1585
1586
|
if (!isOpen || !modal || autoFocus || typeof document === 'undefined') {
|
|
1586
1587
|
return;
|
|
1587
1588
|
}
|
|
1588
1589
|
const activeElement = document.activeElement;
|
|
1589
|
-
if (!
|
|
1590
|
+
if (!activeElement || activeElement === document.body) {
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
const activeElementNode = activeElement;
|
|
1594
|
+
if (((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.contains(activeElementNode)) || (activeElementNode.closest == null ? void 0 : activeElementNode.closest.call(activeElementNode, '[data-drawer]'))) {
|
|
1590
1595
|
return;
|
|
1591
1596
|
}
|
|
1592
|
-
if (
|
|
1597
|
+
if (typeof activeElementNode.blur !== 'function') {
|
|
1593
1598
|
return;
|
|
1594
1599
|
}
|
|
1595
|
-
|
|
1600
|
+
activeElementNode.blur();
|
|
1596
1601
|
}, [
|
|
1597
1602
|
autoFocus,
|
|
1598
1603
|
isOpen,
|
|
@@ -2599,6 +2604,7 @@ function openAncestorChain(parentId) {
|
|
|
2599
2604
|
openAncestorChain(nextParentId);
|
|
2600
2605
|
}
|
|
2601
2606
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
2607
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
2602
2608
|
parentRuntime.controller.setOpen(true);
|
|
2603
2609
|
notifyOpenStateChange(parentRuntime, true);
|
|
2604
2610
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -2618,6 +2624,7 @@ function bindTriggerElement(runtime) {
|
|
|
2618
2624
|
}
|
|
2619
2625
|
const triggerElement = runtime.options.triggerElement;
|
|
2620
2626
|
const handleClick = ()=>{
|
|
2627
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
2621
2628
|
runtime.controller.setOpen(true);
|
|
2622
2629
|
renderVanillaDrawer(runtime.id);
|
|
2623
2630
|
};
|
|
@@ -2653,6 +2660,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
2653
2660
|
function canUseDOM() {
|
|
2654
2661
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2655
2662
|
}
|
|
2663
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
2664
|
+
if (!canUseDOM() || options.modal === false || options.autoFocus) {
|
|
2665
|
+
return;
|
|
2666
|
+
}
|
|
2667
|
+
const activeElement = document.activeElement;
|
|
2668
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== 'function') {
|
|
2669
|
+
return;
|
|
2670
|
+
}
|
|
2671
|
+
activeElement.blur();
|
|
2672
|
+
}
|
|
2656
2673
|
function getRuntimeDrawerElement(runtime) {
|
|
2657
2674
|
if (!runtime.element) {
|
|
2658
2675
|
return null;
|
|
@@ -2703,6 +2720,9 @@ function renderVanillaDrawer(id) {
|
|
|
2703
2720
|
open: snapshot.state.isOpen,
|
|
2704
2721
|
onOpenChange: (open)=>{
|
|
2705
2722
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
2723
|
+
if (open) {
|
|
2724
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
2725
|
+
}
|
|
2706
2726
|
runtime.controller.setOpen(open);
|
|
2707
2727
|
if (previousOpen !== open) {
|
|
2708
2728
|
notifyOpenStateChange(runtime, open);
|
|
@@ -2755,6 +2775,9 @@ function buildVanillaController(id) {
|
|
|
2755
2775
|
open
|
|
2756
2776
|
}).getSnapshot();
|
|
2757
2777
|
}
|
|
2778
|
+
if (open) {
|
|
2779
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
2780
|
+
}
|
|
2758
2781
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
2759
2782
|
const snapshot = runtime.controller.setOpen(open);
|
|
2760
2783
|
if (previousOpen !== open) {
|
|
@@ -2848,6 +2871,9 @@ function createDrawer(options = {}) {
|
|
|
2848
2871
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
2849
2872
|
}
|
|
2850
2873
|
}
|
|
2874
|
+
if (nextOptions.open && !previousOpen) {
|
|
2875
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
2876
|
+
}
|
|
2851
2877
|
renderVanillaDrawer(id);
|
|
2852
2878
|
if (nextOptions.parentId && nextOptions.open) {
|
|
2853
2879
|
openAncestorChain(nextOptions.parentId);
|
package/dist/react/index.mjs
CHANGED
|
@@ -1451,6 +1451,7 @@ function getDragPermission({ targetTagName, hasNoDragAttribute, direction, timeS
|
|
|
1451
1451
|
};
|
|
1452
1452
|
}
|
|
1453
1453
|
|
|
1454
|
+
const useSafeLayoutEffect$1 = typeof window === 'undefined' ? React__default.useEffect : React__default.useLayoutEffect;
|
|
1454
1455
|
function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = 'bottom', defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
|
|
1455
1456
|
var _drawerRef_current, _drawerRef_current1;
|
|
1456
1457
|
const animationEndTimeoutRef = React__default.useRef(null);
|
|
@@ -1558,19 +1559,23 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
|
|
|
1558
1559
|
noBodyStyles,
|
|
1559
1560
|
autoFocus
|
|
1560
1561
|
});
|
|
1561
|
-
|
|
1562
|
+
useSafeLayoutEffect$1(()=>{
|
|
1562
1563
|
var _drawerRef_current;
|
|
1563
1564
|
if (!isOpen || !modal || autoFocus || typeof document === 'undefined') {
|
|
1564
1565
|
return;
|
|
1565
1566
|
}
|
|
1566
1567
|
const activeElement = document.activeElement;
|
|
1567
|
-
if (!
|
|
1568
|
+
if (!activeElement || activeElement === document.body) {
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
const activeElementNode = activeElement;
|
|
1572
|
+
if (((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.contains(activeElementNode)) || (activeElementNode.closest == null ? void 0 : activeElementNode.closest.call(activeElementNode, '[data-drawer]'))) {
|
|
1568
1573
|
return;
|
|
1569
1574
|
}
|
|
1570
|
-
if (
|
|
1575
|
+
if (typeof activeElementNode.blur !== 'function') {
|
|
1571
1576
|
return;
|
|
1572
1577
|
}
|
|
1573
|
-
|
|
1578
|
+
activeElementNode.blur();
|
|
1574
1579
|
}, [
|
|
1575
1580
|
autoFocus,
|
|
1576
1581
|
isOpen,
|
|
@@ -2577,6 +2582,7 @@ function openAncestorChain(parentId) {
|
|
|
2577
2582
|
openAncestorChain(nextParentId);
|
|
2578
2583
|
}
|
|
2579
2584
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
2585
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
2580
2586
|
parentRuntime.controller.setOpen(true);
|
|
2581
2587
|
notifyOpenStateChange(parentRuntime, true);
|
|
2582
2588
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -2596,6 +2602,7 @@ function bindTriggerElement(runtime) {
|
|
|
2596
2602
|
}
|
|
2597
2603
|
const triggerElement = runtime.options.triggerElement;
|
|
2598
2604
|
const handleClick = ()=>{
|
|
2605
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
2599
2606
|
runtime.controller.setOpen(true);
|
|
2600
2607
|
renderVanillaDrawer(runtime.id);
|
|
2601
2608
|
};
|
|
@@ -2631,6 +2638,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
2631
2638
|
function canUseDOM() {
|
|
2632
2639
|
return typeof window !== 'undefined' && typeof document !== 'undefined';
|
|
2633
2640
|
}
|
|
2641
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
2642
|
+
if (!canUseDOM() || options.modal === false || options.autoFocus) {
|
|
2643
|
+
return;
|
|
2644
|
+
}
|
|
2645
|
+
const activeElement = document.activeElement;
|
|
2646
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== 'function') {
|
|
2647
|
+
return;
|
|
2648
|
+
}
|
|
2649
|
+
activeElement.blur();
|
|
2650
|
+
}
|
|
2634
2651
|
function getRuntimeDrawerElement(runtime) {
|
|
2635
2652
|
if (!runtime.element) {
|
|
2636
2653
|
return null;
|
|
@@ -2681,6 +2698,9 @@ function renderVanillaDrawer(id) {
|
|
|
2681
2698
|
open: snapshot.state.isOpen,
|
|
2682
2699
|
onOpenChange: (open)=>{
|
|
2683
2700
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
2701
|
+
if (open) {
|
|
2702
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
2703
|
+
}
|
|
2684
2704
|
runtime.controller.setOpen(open);
|
|
2685
2705
|
if (previousOpen !== open) {
|
|
2686
2706
|
notifyOpenStateChange(runtime, open);
|
|
@@ -2733,6 +2753,9 @@ function buildVanillaController(id) {
|
|
|
2733
2753
|
open
|
|
2734
2754
|
}).getSnapshot();
|
|
2735
2755
|
}
|
|
2756
|
+
if (open) {
|
|
2757
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
2758
|
+
}
|
|
2736
2759
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
2737
2760
|
const snapshot = runtime.controller.setOpen(open);
|
|
2738
2761
|
if (previousOpen !== open) {
|
|
@@ -2826,6 +2849,9 @@ function createDrawer(options = {}) {
|
|
|
2826
2849
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
2827
2850
|
}
|
|
2828
2851
|
}
|
|
2852
|
+
if (nextOptions.open && !previousOpen) {
|
|
2853
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
2854
|
+
}
|
|
2829
2855
|
renderVanillaDrawer(id);
|
|
2830
2856
|
if (nextOptions.parentId && nextOptions.open) {
|
|
2831
2857
|
openAncestorChain(nextOptions.parentId);
|
|
@@ -1470,6 +1470,7 @@ function getDragPermission({ targetTagName, hasNoDragAttribute, direction, timeS
|
|
|
1470
1470
|
};
|
|
1471
1471
|
}
|
|
1472
1472
|
|
|
1473
|
+
const useSafeLayoutEffect = typeof window === 'undefined' ? React__namespace.default.useEffect : React__namespace.default.useLayoutEffect;
|
|
1473
1474
|
function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = 'bottom', defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
|
|
1474
1475
|
var _drawerRef_current, _drawerRef_current1;
|
|
1475
1476
|
const animationEndTimeoutRef = React__namespace.default.useRef(null);
|
|
@@ -1577,19 +1578,23 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
|
|
|
1577
1578
|
noBodyStyles,
|
|
1578
1579
|
autoFocus
|
|
1579
1580
|
});
|
|
1580
|
-
|
|
1581
|
+
useSafeLayoutEffect(()=>{
|
|
1581
1582
|
var _drawerRef_current;
|
|
1582
1583
|
if (!isOpen || !modal || autoFocus || typeof document === 'undefined') {
|
|
1583
1584
|
return;
|
|
1584
1585
|
}
|
|
1585
1586
|
const activeElement = document.activeElement;
|
|
1586
|
-
if (!
|
|
1587
|
+
if (!activeElement || activeElement === document.body) {
|
|
1588
|
+
return;
|
|
1589
|
+
}
|
|
1590
|
+
const activeElementNode = activeElement;
|
|
1591
|
+
if (((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.contains(activeElementNode)) || (activeElementNode.closest == null ? void 0 : activeElementNode.closest.call(activeElementNode, '[data-drawer]'))) {
|
|
1587
1592
|
return;
|
|
1588
1593
|
}
|
|
1589
|
-
if (
|
|
1594
|
+
if (typeof activeElementNode.blur !== 'function') {
|
|
1590
1595
|
return;
|
|
1591
1596
|
}
|
|
1592
|
-
|
|
1597
|
+
activeElementNode.blur();
|
|
1593
1598
|
}, [
|
|
1594
1599
|
autoFocus,
|
|
1595
1600
|
isOpen,
|
|
@@ -1450,6 +1450,7 @@ function getDragPermission({ targetTagName, hasNoDragAttribute, direction, timeS
|
|
|
1450
1450
|
};
|
|
1451
1451
|
}
|
|
1452
1452
|
|
|
1453
|
+
const useSafeLayoutEffect = typeof window === 'undefined' ? React__default.useEffect : React__default.useLayoutEffect;
|
|
1453
1454
|
function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = 'bottom', defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
|
|
1454
1455
|
var _drawerRef_current, _drawerRef_current1;
|
|
1455
1456
|
const animationEndTimeoutRef = React__default.useRef(null);
|
|
@@ -1557,19 +1558,23 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
|
|
|
1557
1558
|
noBodyStyles,
|
|
1558
1559
|
autoFocus
|
|
1559
1560
|
});
|
|
1560
|
-
|
|
1561
|
+
useSafeLayoutEffect(()=>{
|
|
1561
1562
|
var _drawerRef_current;
|
|
1562
1563
|
if (!isOpen || !modal || autoFocus || typeof document === 'undefined') {
|
|
1563
1564
|
return;
|
|
1564
1565
|
}
|
|
1565
1566
|
const activeElement = document.activeElement;
|
|
1566
|
-
if (!
|
|
1567
|
+
if (!activeElement || activeElement === document.body) {
|
|
1568
|
+
return;
|
|
1569
|
+
}
|
|
1570
|
+
const activeElementNode = activeElement;
|
|
1571
|
+
if (((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.contains(activeElementNode)) || (activeElementNode.closest == null ? void 0 : activeElementNode.closest.call(activeElementNode, '[data-drawer]'))) {
|
|
1567
1572
|
return;
|
|
1568
1573
|
}
|
|
1569
|
-
if (
|
|
1574
|
+
if (typeof activeElementNode.blur !== 'function') {
|
|
1570
1575
|
return;
|
|
1571
1576
|
}
|
|
1572
|
-
|
|
1577
|
+
activeElementNode.blur();
|
|
1573
1578
|
}, [
|
|
1574
1579
|
autoFocus,
|
|
1575
1580
|
isOpen,
|
package/dist/svelte/index.js
CHANGED
|
@@ -27991,6 +27991,7 @@ function getDragPermission({
|
|
|
27991
27991
|
}
|
|
27992
27992
|
|
|
27993
27993
|
// src/react/components.tsx
|
|
27994
|
+
var useSafeLayoutEffect = typeof window === "undefined" ? import_react9.default.useEffect : import_react9.default.useLayoutEffect;
|
|
27994
27995
|
function Root2({
|
|
27995
27996
|
open: openProp,
|
|
27996
27997
|
onOpenChange,
|
|
@@ -28134,18 +28135,22 @@ function Root2({
|
|
|
28134
28135
|
noBodyStyles,
|
|
28135
28136
|
autoFocus
|
|
28136
28137
|
});
|
|
28137
|
-
|
|
28138
|
+
useSafeLayoutEffect(() => {
|
|
28138
28139
|
if (!isOpen || !modal || autoFocus || typeof document === "undefined") {
|
|
28139
28140
|
return;
|
|
28140
28141
|
}
|
|
28141
28142
|
const activeElement = document.activeElement;
|
|
28142
|
-
if (!
|
|
28143
|
+
if (!activeElement || activeElement === document.body) {
|
|
28144
|
+
return;
|
|
28145
|
+
}
|
|
28146
|
+
const activeElementNode = activeElement;
|
|
28147
|
+
if (drawerRef.current?.contains(activeElementNode) || activeElementNode.closest?.("[data-drawer]")) {
|
|
28143
28148
|
return;
|
|
28144
28149
|
}
|
|
28145
|
-
if (
|
|
28150
|
+
if (typeof activeElementNode.blur !== "function") {
|
|
28146
28151
|
return;
|
|
28147
28152
|
}
|
|
28148
|
-
|
|
28153
|
+
activeElementNode.blur();
|
|
28149
28154
|
}, [autoFocus, isOpen, modal]);
|
|
28150
28155
|
function getScale() {
|
|
28151
28156
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
@@ -28883,7 +28888,7 @@ var VISUALLY_HIDDEN_STYLE = {
|
|
|
28883
28888
|
whiteSpace: "nowrap",
|
|
28884
28889
|
border: 0
|
|
28885
28890
|
};
|
|
28886
|
-
var
|
|
28891
|
+
var useSafeLayoutEffect2 = typeof window === "undefined" ? import_react10.default.useEffect : import_react10.default.useLayoutEffect;
|
|
28887
28892
|
function toReactDrawerProps(options, open, onOpenChange, internalOnDragChange, internalOnReleaseChange) {
|
|
28888
28893
|
const { id: _id, parentId: _parentId, onDragChange, onReleaseChange, ...drawerOptions } = options;
|
|
28889
28894
|
const baseProps = {
|
|
@@ -28917,7 +28922,7 @@ function VanillaNode({
|
|
|
28917
28922
|
dataAttribute
|
|
28918
28923
|
}) {
|
|
28919
28924
|
const ref = import_react10.default.useRef(null);
|
|
28920
|
-
|
|
28925
|
+
useSafeLayoutEffect2(() => {
|
|
28921
28926
|
const element = ref.current;
|
|
28922
28927
|
if (!element) {
|
|
28923
28928
|
return;
|
|
@@ -29123,6 +29128,7 @@ function openAncestorChain(parentId) {
|
|
|
29123
29128
|
openAncestorChain(nextParentId);
|
|
29124
29129
|
}
|
|
29125
29130
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
29131
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
29126
29132
|
parentRuntime.controller.setOpen(true);
|
|
29127
29133
|
notifyOpenStateChange(parentRuntime, true);
|
|
29128
29134
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -29142,6 +29148,7 @@ function bindTriggerElement(runtime) {
|
|
|
29142
29148
|
}
|
|
29143
29149
|
const triggerElement = runtime.options.triggerElement;
|
|
29144
29150
|
const handleClick = () => {
|
|
29151
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29145
29152
|
runtime.controller.setOpen(true);
|
|
29146
29153
|
renderVanillaDrawer(runtime.id);
|
|
29147
29154
|
};
|
|
@@ -29177,6 +29184,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
29177
29184
|
function canUseDOM3() {
|
|
29178
29185
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
29179
29186
|
}
|
|
29187
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
29188
|
+
if (!canUseDOM3() || options.modal === false || options.autoFocus) {
|
|
29189
|
+
return;
|
|
29190
|
+
}
|
|
29191
|
+
const activeElement = document.activeElement;
|
|
29192
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== "function") {
|
|
29193
|
+
return;
|
|
29194
|
+
}
|
|
29195
|
+
activeElement.blur();
|
|
29196
|
+
}
|
|
29180
29197
|
function getRuntimeDrawerElement(runtime) {
|
|
29181
29198
|
if (!runtime.element) {
|
|
29182
29199
|
return null;
|
|
@@ -29230,6 +29247,9 @@ function renderVanillaDrawer(id) {
|
|
|
29230
29247
|
open: snapshot.state.isOpen,
|
|
29231
29248
|
onOpenChange: (open) => {
|
|
29232
29249
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29250
|
+
if (open) {
|
|
29251
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29252
|
+
}
|
|
29233
29253
|
runtime.controller.setOpen(open);
|
|
29234
29254
|
if (previousOpen !== open) {
|
|
29235
29255
|
notifyOpenStateChange(runtime, open);
|
|
@@ -29276,6 +29296,9 @@ function buildVanillaController(id) {
|
|
|
29276
29296
|
if (!runtime) {
|
|
29277
29297
|
return createDrawer({ id, open }).getSnapshot();
|
|
29278
29298
|
}
|
|
29299
|
+
if (open) {
|
|
29300
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29301
|
+
}
|
|
29279
29302
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29280
29303
|
const snapshot = runtime.controller.setOpen(open);
|
|
29281
29304
|
if (previousOpen !== open) {
|
|
@@ -29346,6 +29369,9 @@ function createDrawer(options = {}) {
|
|
|
29346
29369
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
29347
29370
|
}
|
|
29348
29371
|
}
|
|
29372
|
+
if (nextOptions.open && !previousOpen) {
|
|
29373
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
29374
|
+
}
|
|
29349
29375
|
renderVanillaDrawer(id);
|
|
29350
29376
|
if (nextOptions.parentId && nextOptions.open) {
|
|
29351
29377
|
openAncestorChain(nextOptions.parentId);
|
package/dist/svelte/index.mjs
CHANGED
|
@@ -27963,6 +27963,7 @@ function getDragPermission({
|
|
|
27963
27963
|
}
|
|
27964
27964
|
|
|
27965
27965
|
// src/react/components.tsx
|
|
27966
|
+
var useSafeLayoutEffect = typeof window === "undefined" ? import_react9.default.useEffect : import_react9.default.useLayoutEffect;
|
|
27966
27967
|
function Root2({
|
|
27967
27968
|
open: openProp,
|
|
27968
27969
|
onOpenChange,
|
|
@@ -28106,18 +28107,22 @@ function Root2({
|
|
|
28106
28107
|
noBodyStyles,
|
|
28107
28108
|
autoFocus
|
|
28108
28109
|
});
|
|
28109
|
-
|
|
28110
|
+
useSafeLayoutEffect(() => {
|
|
28110
28111
|
if (!isOpen || !modal || autoFocus || typeof document === "undefined") {
|
|
28111
28112
|
return;
|
|
28112
28113
|
}
|
|
28113
28114
|
const activeElement = document.activeElement;
|
|
28114
|
-
if (!
|
|
28115
|
+
if (!activeElement || activeElement === document.body) {
|
|
28116
|
+
return;
|
|
28117
|
+
}
|
|
28118
|
+
const activeElementNode = activeElement;
|
|
28119
|
+
if (drawerRef.current?.contains(activeElementNode) || activeElementNode.closest?.("[data-drawer]")) {
|
|
28115
28120
|
return;
|
|
28116
28121
|
}
|
|
28117
|
-
if (
|
|
28122
|
+
if (typeof activeElementNode.blur !== "function") {
|
|
28118
28123
|
return;
|
|
28119
28124
|
}
|
|
28120
|
-
|
|
28125
|
+
activeElementNode.blur();
|
|
28121
28126
|
}, [autoFocus, isOpen, modal]);
|
|
28122
28127
|
function getScale() {
|
|
28123
28128
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
@@ -28855,7 +28860,7 @@ var VISUALLY_HIDDEN_STYLE = {
|
|
|
28855
28860
|
whiteSpace: "nowrap",
|
|
28856
28861
|
border: 0
|
|
28857
28862
|
};
|
|
28858
|
-
var
|
|
28863
|
+
var useSafeLayoutEffect2 = typeof window === "undefined" ? import_react10.default.useEffect : import_react10.default.useLayoutEffect;
|
|
28859
28864
|
function toReactDrawerProps(options, open, onOpenChange, internalOnDragChange, internalOnReleaseChange) {
|
|
28860
28865
|
const { id: _id, parentId: _parentId, onDragChange, onReleaseChange, ...drawerOptions } = options;
|
|
28861
28866
|
const baseProps = {
|
|
@@ -28889,7 +28894,7 @@ function VanillaNode({
|
|
|
28889
28894
|
dataAttribute
|
|
28890
28895
|
}) {
|
|
28891
28896
|
const ref = import_react10.default.useRef(null);
|
|
28892
|
-
|
|
28897
|
+
useSafeLayoutEffect2(() => {
|
|
28893
28898
|
const element = ref.current;
|
|
28894
28899
|
if (!element) {
|
|
28895
28900
|
return;
|
|
@@ -29095,6 +29100,7 @@ function openAncestorChain(parentId) {
|
|
|
29095
29100
|
openAncestorChain(nextParentId);
|
|
29096
29101
|
}
|
|
29097
29102
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
29103
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
29098
29104
|
parentRuntime.controller.setOpen(true);
|
|
29099
29105
|
notifyOpenStateChange(parentRuntime, true);
|
|
29100
29106
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -29114,6 +29120,7 @@ function bindTriggerElement(runtime) {
|
|
|
29114
29120
|
}
|
|
29115
29121
|
const triggerElement = runtime.options.triggerElement;
|
|
29116
29122
|
const handleClick = () => {
|
|
29123
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29117
29124
|
runtime.controller.setOpen(true);
|
|
29118
29125
|
renderVanillaDrawer(runtime.id);
|
|
29119
29126
|
};
|
|
@@ -29149,6 +29156,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
29149
29156
|
function canUseDOM3() {
|
|
29150
29157
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
29151
29158
|
}
|
|
29159
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
29160
|
+
if (!canUseDOM3() || options.modal === false || options.autoFocus) {
|
|
29161
|
+
return;
|
|
29162
|
+
}
|
|
29163
|
+
const activeElement = document.activeElement;
|
|
29164
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== "function") {
|
|
29165
|
+
return;
|
|
29166
|
+
}
|
|
29167
|
+
activeElement.blur();
|
|
29168
|
+
}
|
|
29152
29169
|
function getRuntimeDrawerElement(runtime) {
|
|
29153
29170
|
if (!runtime.element) {
|
|
29154
29171
|
return null;
|
|
@@ -29202,6 +29219,9 @@ function renderVanillaDrawer(id) {
|
|
|
29202
29219
|
open: snapshot.state.isOpen,
|
|
29203
29220
|
onOpenChange: (open) => {
|
|
29204
29221
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29222
|
+
if (open) {
|
|
29223
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29224
|
+
}
|
|
29205
29225
|
runtime.controller.setOpen(open);
|
|
29206
29226
|
if (previousOpen !== open) {
|
|
29207
29227
|
notifyOpenStateChange(runtime, open);
|
|
@@ -29248,6 +29268,9 @@ function buildVanillaController(id) {
|
|
|
29248
29268
|
if (!runtime) {
|
|
29249
29269
|
return createDrawer({ id, open }).getSnapshot();
|
|
29250
29270
|
}
|
|
29271
|
+
if (open) {
|
|
29272
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29273
|
+
}
|
|
29251
29274
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29252
29275
|
const snapshot = runtime.controller.setOpen(open);
|
|
29253
29276
|
if (previousOpen !== open) {
|
|
@@ -29318,6 +29341,9 @@ function createDrawer(options = {}) {
|
|
|
29318
29341
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
29319
29342
|
}
|
|
29320
29343
|
}
|
|
29344
|
+
if (nextOptions.open && !previousOpen) {
|
|
29345
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
29346
|
+
}
|
|
29321
29347
|
renderVanillaDrawer(id);
|
|
29322
29348
|
if (nextOptions.parentId && nextOptions.open) {
|
|
29323
29349
|
openAncestorChain(nextOptions.parentId);
|
|
@@ -1470,6 +1470,7 @@ function getDragPermission({ targetTagName, hasNoDragAttribute, direction, timeS
|
|
|
1470
1470
|
};
|
|
1471
1471
|
}
|
|
1472
1472
|
|
|
1473
|
+
const useSafeLayoutEffect = typeof window === 'undefined' ? React__namespace.default.useEffect : React__namespace.default.useLayoutEffect;
|
|
1473
1474
|
function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRelease: onReleaseProp, snapPoints, shouldScaleBackground = false, setBackgroundColorOnScale = true, closeThreshold = CLOSE_THRESHOLD, scrollLockTimeout = SCROLL_LOCK_TIMEOUT, dismissible = true, handleOnly = false, fadeFromIndex = snapPoints && snapPoints.length - 1, activeSnapPoint: activeSnapPointProp, setActiveSnapPoint: setActiveSnapPointProp, fixed, modal = true, onClose, nested, noBodyStyles = false, direction = 'bottom', defaultOpen = false, disablePreventScroll = true, snapToSequentialPoint = false, preventScrollRestoration = false, repositionInputs = true, onAnimationEnd, container, autoFocus = false }) {
|
|
1474
1475
|
var _drawerRef_current, _drawerRef_current1;
|
|
1475
1476
|
const animationEndTimeoutRef = React__namespace.default.useRef(null);
|
|
@@ -1577,19 +1578,23 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
|
|
|
1577
1578
|
noBodyStyles,
|
|
1578
1579
|
autoFocus
|
|
1579
1580
|
});
|
|
1580
|
-
|
|
1581
|
+
useSafeLayoutEffect(()=>{
|
|
1581
1582
|
var _drawerRef_current;
|
|
1582
1583
|
if (!isOpen || !modal || autoFocus || typeof document === 'undefined') {
|
|
1583
1584
|
return;
|
|
1584
1585
|
}
|
|
1585
1586
|
const activeElement = document.activeElement;
|
|
1586
|
-
if (!
|
|
1587
|
+
if (!activeElement || activeElement === document.body) {
|
|
1588
|
+
return;
|
|
1589
|
+
}
|
|
1590
|
+
const activeElementNode = activeElement;
|
|
1591
|
+
if (((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.contains(activeElementNode)) || (activeElementNode.closest == null ? void 0 : activeElementNode.closest.call(activeElementNode, '[data-drawer]'))) {
|
|
1587
1592
|
return;
|
|
1588
1593
|
}
|
|
1589
|
-
if (
|
|
1594
|
+
if (typeof activeElementNode.blur !== 'function') {
|
|
1590
1595
|
return;
|
|
1591
1596
|
}
|
|
1592
|
-
|
|
1597
|
+
activeElementNode.blur();
|
|
1593
1598
|
}, [
|
|
1594
1599
|
autoFocus,
|
|
1595
1600
|
isOpen,
|