@samline/drawer 2.0.0 → 2.0.1
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/browser/{components-client-BC8MrVsa.mjs → components-client-CZSt5H60.mjs} +45 -15
- package/dist/{svelte/components-client-BHUFVfXB.js → browser/components-client-DXeaMmfk.js} +45 -15
- package/dist/browser/index.cjs +41 -13
- package/dist/browser/index.js +41 -13
- package/dist/browser/index.mjs +41 -13
- package/dist/{svelte/components-client-BC8MrVsa.mjs → components-client-CZSt5H60.mjs} +45 -15
- package/dist/{browser/components-client-BHUFVfXB.js → components-client-DXeaMmfk.js} +45 -15
- package/dist/index.js +41 -13
- package/dist/index.mjs +41 -13
- package/dist/react/index.js +45 -15
- package/dist/react/index.mjs +45 -15
- package/dist/{components-client-BC8MrVsa.mjs → svelte/components-client-CZSt5H60.mjs} +45 -15
- package/dist/{vue/components-client-BHUFVfXB.js → svelte/components-client-DXeaMmfk.js} +45 -15
- package/dist/svelte/index.js +41 -13
- package/dist/svelte/index.mjs +41 -13
- package/dist/{components-client-BHUFVfXB.js → vue/components-client-DXeaMmfk.js} +45 -15
- package/dist/vue/{components-client-rq_o2zwK.mjs → components-client-DZfql3-W.mjs} +45 -15
- package/dist/vue/index.js +41 -13
- package/dist/vue/index.mjs +41 -13
- package/package.json +1 -1
|
@@ -1311,6 +1311,30 @@ function getNextHandleState({ isDragging, preventCycle, shouldCancelInteraction,
|
|
|
1311
1311
|
};
|
|
1312
1312
|
}
|
|
1313
1313
|
|
|
1314
|
+
function isElementLike(target) {
|
|
1315
|
+
const element = target;
|
|
1316
|
+
return Boolean(element && typeof element.getAttribute === 'function' && typeof element.hasAttribute === 'function' && typeof element.closest === 'function');
|
|
1317
|
+
}
|
|
1318
|
+
function getDragTargetMetadata(target) {
|
|
1319
|
+
var _ref;
|
|
1320
|
+
const targetElement = isElementLike(target) ? target : null;
|
|
1321
|
+
const ancestors = [];
|
|
1322
|
+
let element = targetElement;
|
|
1323
|
+
while(element){
|
|
1324
|
+
ancestors.push({
|
|
1325
|
+
scrollHeight: element.scrollHeight,
|
|
1326
|
+
clientHeight: element.clientHeight,
|
|
1327
|
+
scrollTop: element.scrollTop,
|
|
1328
|
+
role: element.getAttribute('role')
|
|
1329
|
+
});
|
|
1330
|
+
element = element.parentElement;
|
|
1331
|
+
}
|
|
1332
|
+
return {
|
|
1333
|
+
targetTagName: (_ref = targetElement == null ? void 0 : targetElement.tagName) != null ? _ref : '',
|
|
1334
|
+
hasNoDragAttribute: (targetElement == null ? void 0 : targetElement.hasAttribute('data-drawer-no-drag')) || Boolean(targetElement == null ? void 0 : targetElement.closest('[data-drawer-no-drag]')),
|
|
1335
|
+
ancestors
|
|
1336
|
+
};
|
|
1337
|
+
}
|
|
1314
1338
|
function getDragPermission({ targetTagName, hasNoDragAttribute, direction, timeSinceOpenMs, swipeAmount, hasHighlightedText, timeSinceLastPreventedMs, scrollLockTimeout, isDraggingInDirection, ancestors }) {
|
|
1315
1339
|
if (targetTagName === 'SELECT' || hasNoDragAttribute) {
|
|
1316
1340
|
return {
|
|
@@ -1473,6 +1497,24 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
|
|
|
1473
1497
|
noBodyStyles,
|
|
1474
1498
|
autoFocus
|
|
1475
1499
|
});
|
|
1500
|
+
React__default.useEffect(()=>{
|
|
1501
|
+
var _drawerRef_current;
|
|
1502
|
+
if (!isOpen || !modal || autoFocus || typeof document === 'undefined') {
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
const activeElement = document.activeElement;
|
|
1506
|
+
if (!(activeElement instanceof HTMLElement)) {
|
|
1507
|
+
return;
|
|
1508
|
+
}
|
|
1509
|
+
if (((_drawerRef_current = drawerRef.current) == null ? void 0 : _drawerRef_current.contains(activeElement)) || activeElement.closest('[data-drawer]')) {
|
|
1510
|
+
return;
|
|
1511
|
+
}
|
|
1512
|
+
activeElement.blur();
|
|
1513
|
+
}, [
|
|
1514
|
+
autoFocus,
|
|
1515
|
+
isOpen,
|
|
1516
|
+
modal
|
|
1517
|
+
]);
|
|
1476
1518
|
function getScale() {
|
|
1477
1519
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
1478
1520
|
}
|
|
@@ -1496,24 +1538,12 @@ function Root({ open: openProp, onOpenChange, children, onDrag: onDragProp, onRe
|
|
|
1496
1538
|
}
|
|
1497
1539
|
function shouldDrag(el, isDraggingInDirection) {
|
|
1498
1540
|
var _window_getSelection;
|
|
1499
|
-
let element = el;
|
|
1500
1541
|
const swipeAmount = drawerRef.current ? getTranslate(drawerRef.current, direction) : null;
|
|
1501
1542
|
const date = new Date();
|
|
1502
|
-
const ancestors =
|
|
1503
|
-
// Keep climbing up the DOM tree as long as there's a parent
|
|
1504
|
-
while(element){
|
|
1505
|
-
ancestors.push({
|
|
1506
|
-
scrollHeight: element.scrollHeight,
|
|
1507
|
-
clientHeight: element.clientHeight,
|
|
1508
|
-
scrollTop: element.scrollTop,
|
|
1509
|
-
role: element.getAttribute('role')
|
|
1510
|
-
});
|
|
1511
|
-
// Move up to the parent element
|
|
1512
|
-
element = element.parentNode;
|
|
1513
|
-
}
|
|
1543
|
+
const { targetTagName, hasNoDragAttribute, ancestors } = getDragTargetMetadata(el);
|
|
1514
1544
|
const result = getDragPermission({
|
|
1515
|
-
targetTagName
|
|
1516
|
-
hasNoDragAttribute
|
|
1545
|
+
targetTagName,
|
|
1546
|
+
hasNoDragAttribute,
|
|
1517
1547
|
direction,
|
|
1518
1548
|
timeSinceOpenMs: openTime.current ? date.getTime() - openTime.current.getTime() : null,
|
|
1519
1549
|
swipeAmount,
|
package/dist/vue/index.js
CHANGED
|
@@ -27871,6 +27871,31 @@ function getNextHandleState({
|
|
|
27871
27871
|
}
|
|
27872
27872
|
|
|
27873
27873
|
// src/runtime/drag-policy.ts
|
|
27874
|
+
function isElementLike(target) {
|
|
27875
|
+
const element = target;
|
|
27876
|
+
return Boolean(
|
|
27877
|
+
element && typeof element.getAttribute === "function" && typeof element.hasAttribute === "function" && typeof element.closest === "function"
|
|
27878
|
+
);
|
|
27879
|
+
}
|
|
27880
|
+
function getDragTargetMetadata(target) {
|
|
27881
|
+
const targetElement = isElementLike(target) ? target : null;
|
|
27882
|
+
const ancestors = [];
|
|
27883
|
+
let element = targetElement;
|
|
27884
|
+
while (element) {
|
|
27885
|
+
ancestors.push({
|
|
27886
|
+
scrollHeight: element.scrollHeight,
|
|
27887
|
+
clientHeight: element.clientHeight,
|
|
27888
|
+
scrollTop: element.scrollTop,
|
|
27889
|
+
role: element.getAttribute("role")
|
|
27890
|
+
});
|
|
27891
|
+
element = element.parentElement;
|
|
27892
|
+
}
|
|
27893
|
+
return {
|
|
27894
|
+
targetTagName: targetElement?.tagName ?? "",
|
|
27895
|
+
hasNoDragAttribute: targetElement?.hasAttribute("data-drawer-no-drag") || Boolean(targetElement?.closest("[data-drawer-no-drag]")),
|
|
27896
|
+
ancestors
|
|
27897
|
+
};
|
|
27898
|
+
}
|
|
27874
27899
|
function getDragPermission({
|
|
27875
27900
|
targetTagName,
|
|
27876
27901
|
hasNoDragAttribute,
|
|
@@ -28051,6 +28076,19 @@ function Root2({
|
|
|
28051
28076
|
noBodyStyles,
|
|
28052
28077
|
autoFocus
|
|
28053
28078
|
});
|
|
28079
|
+
import_react9.default.useEffect(() => {
|
|
28080
|
+
if (!isOpen || !modal || autoFocus || typeof document === "undefined") {
|
|
28081
|
+
return;
|
|
28082
|
+
}
|
|
28083
|
+
const activeElement = document.activeElement;
|
|
28084
|
+
if (!(activeElement instanceof HTMLElement)) {
|
|
28085
|
+
return;
|
|
28086
|
+
}
|
|
28087
|
+
if (drawerRef.current?.contains(activeElement) || activeElement.closest("[data-drawer]")) {
|
|
28088
|
+
return;
|
|
28089
|
+
}
|
|
28090
|
+
activeElement.blur();
|
|
28091
|
+
}, [autoFocus, isOpen, modal]);
|
|
28054
28092
|
function getScale() {
|
|
28055
28093
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
28056
28094
|
}
|
|
@@ -28068,22 +28106,12 @@ function Root2({
|
|
|
28068
28106
|
pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
|
|
28069
28107
|
}
|
|
28070
28108
|
function shouldDrag(el, isDraggingInDirection) {
|
|
28071
|
-
let element = el;
|
|
28072
28109
|
const swipeAmount = drawerRef.current ? getTranslate(drawerRef.current, direction) : null;
|
|
28073
28110
|
const date = /* @__PURE__ */ new Date();
|
|
28074
|
-
const ancestors =
|
|
28075
|
-
while (element) {
|
|
28076
|
-
ancestors.push({
|
|
28077
|
-
scrollHeight: element.scrollHeight,
|
|
28078
|
-
clientHeight: element.clientHeight,
|
|
28079
|
-
scrollTop: element.scrollTop,
|
|
28080
|
-
role: element.getAttribute("role")
|
|
28081
|
-
});
|
|
28082
|
-
element = element.parentNode;
|
|
28083
|
-
}
|
|
28111
|
+
const { targetTagName, hasNoDragAttribute, ancestors } = getDragTargetMetadata(el);
|
|
28084
28112
|
const result = getDragPermission({
|
|
28085
|
-
targetTagName
|
|
28086
|
-
hasNoDragAttribute
|
|
28113
|
+
targetTagName,
|
|
28114
|
+
hasNoDragAttribute,
|
|
28087
28115
|
direction,
|
|
28088
28116
|
timeSinceOpenMs: openTime.current ? date.getTime() - openTime.current.getTime() : null,
|
|
28089
28117
|
swipeAmount,
|
package/dist/vue/index.mjs
CHANGED
|
@@ -27846,6 +27846,31 @@ function getNextHandleState({
|
|
|
27846
27846
|
}
|
|
27847
27847
|
|
|
27848
27848
|
// src/runtime/drag-policy.ts
|
|
27849
|
+
function isElementLike(target) {
|
|
27850
|
+
const element = target;
|
|
27851
|
+
return Boolean(
|
|
27852
|
+
element && typeof element.getAttribute === "function" && typeof element.hasAttribute === "function" && typeof element.closest === "function"
|
|
27853
|
+
);
|
|
27854
|
+
}
|
|
27855
|
+
function getDragTargetMetadata(target) {
|
|
27856
|
+
const targetElement = isElementLike(target) ? target : null;
|
|
27857
|
+
const ancestors = [];
|
|
27858
|
+
let element = targetElement;
|
|
27859
|
+
while (element) {
|
|
27860
|
+
ancestors.push({
|
|
27861
|
+
scrollHeight: element.scrollHeight,
|
|
27862
|
+
clientHeight: element.clientHeight,
|
|
27863
|
+
scrollTop: element.scrollTop,
|
|
27864
|
+
role: element.getAttribute("role")
|
|
27865
|
+
});
|
|
27866
|
+
element = element.parentElement;
|
|
27867
|
+
}
|
|
27868
|
+
return {
|
|
27869
|
+
targetTagName: targetElement?.tagName ?? "",
|
|
27870
|
+
hasNoDragAttribute: targetElement?.hasAttribute("data-drawer-no-drag") || Boolean(targetElement?.closest("[data-drawer-no-drag]")),
|
|
27871
|
+
ancestors
|
|
27872
|
+
};
|
|
27873
|
+
}
|
|
27849
27874
|
function getDragPermission({
|
|
27850
27875
|
targetTagName,
|
|
27851
27876
|
hasNoDragAttribute,
|
|
@@ -28026,6 +28051,19 @@ function Root2({
|
|
|
28026
28051
|
noBodyStyles,
|
|
28027
28052
|
autoFocus
|
|
28028
28053
|
});
|
|
28054
|
+
import_react9.default.useEffect(() => {
|
|
28055
|
+
if (!isOpen || !modal || autoFocus || typeof document === "undefined") {
|
|
28056
|
+
return;
|
|
28057
|
+
}
|
|
28058
|
+
const activeElement = document.activeElement;
|
|
28059
|
+
if (!(activeElement instanceof HTMLElement)) {
|
|
28060
|
+
return;
|
|
28061
|
+
}
|
|
28062
|
+
if (drawerRef.current?.contains(activeElement) || activeElement.closest("[data-drawer]")) {
|
|
28063
|
+
return;
|
|
28064
|
+
}
|
|
28065
|
+
activeElement.blur();
|
|
28066
|
+
}, [autoFocus, isOpen, modal]);
|
|
28029
28067
|
function getScale() {
|
|
28030
28068
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
28031
28069
|
}
|
|
@@ -28043,22 +28081,12 @@ function Root2({
|
|
|
28043
28081
|
pointerStart.current = isVertical(direction) ? event.pageY : event.pageX;
|
|
28044
28082
|
}
|
|
28045
28083
|
function shouldDrag(el, isDraggingInDirection) {
|
|
28046
|
-
let element = el;
|
|
28047
28084
|
const swipeAmount = drawerRef.current ? getTranslate(drawerRef.current, direction) : null;
|
|
28048
28085
|
const date = /* @__PURE__ */ new Date();
|
|
28049
|
-
const ancestors =
|
|
28050
|
-
while (element) {
|
|
28051
|
-
ancestors.push({
|
|
28052
|
-
scrollHeight: element.scrollHeight,
|
|
28053
|
-
clientHeight: element.clientHeight,
|
|
28054
|
-
scrollTop: element.scrollTop,
|
|
28055
|
-
role: element.getAttribute("role")
|
|
28056
|
-
});
|
|
28057
|
-
element = element.parentNode;
|
|
28058
|
-
}
|
|
28086
|
+
const { targetTagName, hasNoDragAttribute, ancestors } = getDragTargetMetadata(el);
|
|
28059
28087
|
const result = getDragPermission({
|
|
28060
|
-
targetTagName
|
|
28061
|
-
hasNoDragAttribute
|
|
28088
|
+
targetTagName,
|
|
28089
|
+
hasNoDragAttribute,
|
|
28062
28090
|
direction,
|
|
28063
28091
|
timeSinceOpenMs: openTime.current ? date.getTime() - openTime.current.getTime() : null,
|
|
28064
28092
|
swipeAmount,
|