@samline/drawer 2.0.5 → 2.0.7
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-B8ZDZqhE.js} +27 -13
- package/dist/browser/{components-client-BnT3P9Or.mjs → components-client-LPOAyYIW.mjs} +27 -13
- package/dist/browser/index.cjs +46 -13
- package/dist/browser/index.js +46 -13
- package/dist/browser/index.mjs +46 -13
- package/dist/{browser/components-client-D4tSixHM.js → components-client-B8ZDZqhE.js} +27 -13
- package/dist/{svelte/components-client-BnT3P9Or.mjs → components-client-LPOAyYIW.mjs} +27 -13
- package/dist/index.js +46 -13
- package/dist/index.mjs +46 -13
- package/dist/react/index.js +48 -13
- package/dist/react/index.mjs +48 -13
- package/dist/{vue/components-client-D4tSixHM.js → svelte/components-client-B8ZDZqhE.js} +27 -13
- package/dist/{components-client-BnT3P9Or.mjs → svelte/components-client-LPOAyYIW.mjs} +27 -13
- package/dist/svelte/index.js +46 -13
- package/dist/svelte/index.mjs +46 -13
- package/dist/{components-client-D4tSixHM.js → vue/components-client-B8ZDZqhE.js} +27 -13
- package/dist/vue/{components-client-CvNPHVej.mjs → components-client-BlpMZJqu.mjs} +27 -13
- package/dist/vue/index.js +46 -13
- package/dist/vue/index.mjs +46 -13
- package/package.json +1 -1
package/dist/vue/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,
|
|
@@ -28076,6 +28077,23 @@ function Root2({
|
|
|
28076
28077
|
const drawerHeightRef = import_react9.default.useRef(drawerRef.current?.getBoundingClientRect().height || 0);
|
|
28077
28078
|
const drawerWidthRef = import_react9.default.useRef(drawerRef.current?.getBoundingClientRect().width || 0);
|
|
28078
28079
|
const initialDrawerHeight = import_react9.default.useRef(0);
|
|
28080
|
+
const releaseHiddenFocusBeforeOpen2 = import_react9.default.useCallback(() => {
|
|
28081
|
+
if (!modal || autoFocus || typeof document === "undefined") {
|
|
28082
|
+
return;
|
|
28083
|
+
}
|
|
28084
|
+
const activeElement = document.activeElement;
|
|
28085
|
+
if (!activeElement || activeElement === document.body) {
|
|
28086
|
+
return;
|
|
28087
|
+
}
|
|
28088
|
+
const activeElementNode = activeElement;
|
|
28089
|
+
if (drawerRef.current?.contains(activeElementNode) || activeElementNode.closest?.("[data-drawer]")) {
|
|
28090
|
+
return;
|
|
28091
|
+
}
|
|
28092
|
+
if (typeof activeElementNode.blur !== "function") {
|
|
28093
|
+
return;
|
|
28094
|
+
}
|
|
28095
|
+
activeElementNode.blur();
|
|
28096
|
+
}, [autoFocus, modal]);
|
|
28079
28097
|
const onSnapPointChange = import_react9.default.useCallback((activeSnapPointIndex2) => {
|
|
28080
28098
|
if (snapPoints && activeSnapPointIndex2 === snapPointsOffset.length - 1) openTime.current = /* @__PURE__ */ new Date();
|
|
28081
28099
|
}, []);
|
|
@@ -28134,19 +28152,12 @@ function Root2({
|
|
|
28134
28152
|
noBodyStyles,
|
|
28135
28153
|
autoFocus
|
|
28136
28154
|
});
|
|
28137
|
-
|
|
28138
|
-
if (!isOpen
|
|
28139
|
-
return;
|
|
28140
|
-
}
|
|
28141
|
-
const activeElement = document.activeElement;
|
|
28142
|
-
if (!(activeElement instanceof HTMLElement)) {
|
|
28143
|
-
return;
|
|
28144
|
-
}
|
|
28145
|
-
if (drawerRef.current?.contains(activeElement) || activeElement.closest("[data-drawer]")) {
|
|
28155
|
+
useSafeLayoutEffect(() => {
|
|
28156
|
+
if (!isOpen) {
|
|
28146
28157
|
return;
|
|
28147
28158
|
}
|
|
28148
|
-
|
|
28149
|
-
}, [
|
|
28159
|
+
releaseHiddenFocusBeforeOpen2();
|
|
28160
|
+
}, [isOpen, releaseHiddenFocusBeforeOpen2]);
|
|
28150
28161
|
function getScale() {
|
|
28151
28162
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
28152
28163
|
}
|
|
@@ -28530,6 +28541,7 @@ function Root2({
|
|
|
28530
28541
|
onOpenChange: (open) => {
|
|
28531
28542
|
if (!dismissible && !open) return;
|
|
28532
28543
|
if (open) {
|
|
28544
|
+
releaseHiddenFocusBeforeOpen2();
|
|
28533
28545
|
setHasBeenOpened(true);
|
|
28534
28546
|
} else {
|
|
28535
28547
|
closeDrawer2(true);
|
|
@@ -28883,7 +28895,7 @@ var VISUALLY_HIDDEN_STYLE = {
|
|
|
28883
28895
|
whiteSpace: "nowrap",
|
|
28884
28896
|
border: 0
|
|
28885
28897
|
};
|
|
28886
|
-
var
|
|
28898
|
+
var useSafeLayoutEffect2 = typeof window === "undefined" ? import_react10.default.useEffect : import_react10.default.useLayoutEffect;
|
|
28887
28899
|
function toReactDrawerProps(options, open, onOpenChange, internalOnDragChange, internalOnReleaseChange) {
|
|
28888
28900
|
const { id: _id, parentId: _parentId, onDragChange, onReleaseChange, ...drawerOptions } = options;
|
|
28889
28901
|
const baseProps = {
|
|
@@ -28917,7 +28929,7 @@ function VanillaNode({
|
|
|
28917
28929
|
dataAttribute
|
|
28918
28930
|
}) {
|
|
28919
28931
|
const ref = import_react10.default.useRef(null);
|
|
28920
|
-
|
|
28932
|
+
useSafeLayoutEffect2(() => {
|
|
28921
28933
|
const element = ref.current;
|
|
28922
28934
|
if (!element) {
|
|
28923
28935
|
return;
|
|
@@ -29123,6 +29135,7 @@ function openAncestorChain(parentId) {
|
|
|
29123
29135
|
openAncestorChain(nextParentId);
|
|
29124
29136
|
}
|
|
29125
29137
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
29138
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
29126
29139
|
parentRuntime.controller.setOpen(true);
|
|
29127
29140
|
notifyOpenStateChange(parentRuntime, true);
|
|
29128
29141
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -29142,6 +29155,7 @@ function bindTriggerElement(runtime) {
|
|
|
29142
29155
|
}
|
|
29143
29156
|
const triggerElement = runtime.options.triggerElement;
|
|
29144
29157
|
const handleClick = () => {
|
|
29158
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29145
29159
|
runtime.controller.setOpen(true);
|
|
29146
29160
|
renderVanillaDrawer(runtime.id);
|
|
29147
29161
|
};
|
|
@@ -29177,6 +29191,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
29177
29191
|
function canUseDOM3() {
|
|
29178
29192
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
29179
29193
|
}
|
|
29194
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
29195
|
+
if (!canUseDOM3() || options.modal === false || options.autoFocus) {
|
|
29196
|
+
return;
|
|
29197
|
+
}
|
|
29198
|
+
const activeElement = document.activeElement;
|
|
29199
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== "function") {
|
|
29200
|
+
return;
|
|
29201
|
+
}
|
|
29202
|
+
activeElement.blur();
|
|
29203
|
+
}
|
|
29180
29204
|
function getRuntimeDrawerElement(runtime) {
|
|
29181
29205
|
if (!runtime.element) {
|
|
29182
29206
|
return null;
|
|
@@ -29230,6 +29254,9 @@ function renderVanillaDrawer(id) {
|
|
|
29230
29254
|
open: snapshot.state.isOpen,
|
|
29231
29255
|
onOpenChange: (open) => {
|
|
29232
29256
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29257
|
+
if (open) {
|
|
29258
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29259
|
+
}
|
|
29233
29260
|
runtime.controller.setOpen(open);
|
|
29234
29261
|
if (previousOpen !== open) {
|
|
29235
29262
|
notifyOpenStateChange(runtime, open);
|
|
@@ -29276,6 +29303,9 @@ function buildVanillaController(id) {
|
|
|
29276
29303
|
if (!runtime) {
|
|
29277
29304
|
return createDrawer({ id, open }).getSnapshot();
|
|
29278
29305
|
}
|
|
29306
|
+
if (open) {
|
|
29307
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29308
|
+
}
|
|
29279
29309
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29280
29310
|
const snapshot = runtime.controller.setOpen(open);
|
|
29281
29311
|
if (previousOpen !== open) {
|
|
@@ -29346,6 +29376,9 @@ function createDrawer(options = {}) {
|
|
|
29346
29376
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
29347
29377
|
}
|
|
29348
29378
|
}
|
|
29379
|
+
if (nextOptions.open && !previousOpen) {
|
|
29380
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
29381
|
+
}
|
|
29349
29382
|
renderVanillaDrawer(id);
|
|
29350
29383
|
if (nextOptions.parentId && nextOptions.open) {
|
|
29351
29384
|
openAncestorChain(nextOptions.parentId);
|
package/dist/vue/index.mjs
CHANGED
|
@@ -27966,6 +27966,7 @@ function getDragPermission({
|
|
|
27966
27966
|
}
|
|
27967
27967
|
|
|
27968
27968
|
// src/react/components.tsx
|
|
27969
|
+
var useSafeLayoutEffect = typeof window === "undefined" ? import_react9.default.useEffect : import_react9.default.useLayoutEffect;
|
|
27969
27970
|
function Root2({
|
|
27970
27971
|
open: openProp,
|
|
27971
27972
|
onOpenChange,
|
|
@@ -28051,6 +28052,23 @@ function Root2({
|
|
|
28051
28052
|
const drawerHeightRef = import_react9.default.useRef(drawerRef.current?.getBoundingClientRect().height || 0);
|
|
28052
28053
|
const drawerWidthRef = import_react9.default.useRef(drawerRef.current?.getBoundingClientRect().width || 0);
|
|
28053
28054
|
const initialDrawerHeight = import_react9.default.useRef(0);
|
|
28055
|
+
const releaseHiddenFocusBeforeOpen2 = import_react9.default.useCallback(() => {
|
|
28056
|
+
if (!modal || autoFocus || typeof document === "undefined") {
|
|
28057
|
+
return;
|
|
28058
|
+
}
|
|
28059
|
+
const activeElement = document.activeElement;
|
|
28060
|
+
if (!activeElement || activeElement === document.body) {
|
|
28061
|
+
return;
|
|
28062
|
+
}
|
|
28063
|
+
const activeElementNode = activeElement;
|
|
28064
|
+
if (drawerRef.current?.contains(activeElementNode) || activeElementNode.closest?.("[data-drawer]")) {
|
|
28065
|
+
return;
|
|
28066
|
+
}
|
|
28067
|
+
if (typeof activeElementNode.blur !== "function") {
|
|
28068
|
+
return;
|
|
28069
|
+
}
|
|
28070
|
+
activeElementNode.blur();
|
|
28071
|
+
}, [autoFocus, modal]);
|
|
28054
28072
|
const onSnapPointChange = import_react9.default.useCallback((activeSnapPointIndex2) => {
|
|
28055
28073
|
if (snapPoints && activeSnapPointIndex2 === snapPointsOffset.length - 1) openTime.current = /* @__PURE__ */ new Date();
|
|
28056
28074
|
}, []);
|
|
@@ -28109,19 +28127,12 @@ function Root2({
|
|
|
28109
28127
|
noBodyStyles,
|
|
28110
28128
|
autoFocus
|
|
28111
28129
|
});
|
|
28112
|
-
|
|
28113
|
-
if (!isOpen
|
|
28114
|
-
return;
|
|
28115
|
-
}
|
|
28116
|
-
const activeElement = document.activeElement;
|
|
28117
|
-
if (!(activeElement instanceof HTMLElement)) {
|
|
28118
|
-
return;
|
|
28119
|
-
}
|
|
28120
|
-
if (drawerRef.current?.contains(activeElement) || activeElement.closest("[data-drawer]")) {
|
|
28130
|
+
useSafeLayoutEffect(() => {
|
|
28131
|
+
if (!isOpen) {
|
|
28121
28132
|
return;
|
|
28122
28133
|
}
|
|
28123
|
-
|
|
28124
|
-
}, [
|
|
28134
|
+
releaseHiddenFocusBeforeOpen2();
|
|
28135
|
+
}, [isOpen, releaseHiddenFocusBeforeOpen2]);
|
|
28125
28136
|
function getScale() {
|
|
28126
28137
|
return (window.innerWidth - WINDOW_TOP_OFFSET) / window.innerWidth;
|
|
28127
28138
|
}
|
|
@@ -28505,6 +28516,7 @@ function Root2({
|
|
|
28505
28516
|
onOpenChange: (open) => {
|
|
28506
28517
|
if (!dismissible && !open) return;
|
|
28507
28518
|
if (open) {
|
|
28519
|
+
releaseHiddenFocusBeforeOpen2();
|
|
28508
28520
|
setHasBeenOpened(true);
|
|
28509
28521
|
} else {
|
|
28510
28522
|
closeDrawer2(true);
|
|
@@ -28858,7 +28870,7 @@ var VISUALLY_HIDDEN_STYLE = {
|
|
|
28858
28870
|
whiteSpace: "nowrap",
|
|
28859
28871
|
border: 0
|
|
28860
28872
|
};
|
|
28861
|
-
var
|
|
28873
|
+
var useSafeLayoutEffect2 = typeof window === "undefined" ? import_react10.default.useEffect : import_react10.default.useLayoutEffect;
|
|
28862
28874
|
function toReactDrawerProps(options, open, onOpenChange, internalOnDragChange, internalOnReleaseChange) {
|
|
28863
28875
|
const { id: _id, parentId: _parentId, onDragChange, onReleaseChange, ...drawerOptions } = options;
|
|
28864
28876
|
const baseProps = {
|
|
@@ -28892,7 +28904,7 @@ function VanillaNode({
|
|
|
28892
28904
|
dataAttribute
|
|
28893
28905
|
}) {
|
|
28894
28906
|
const ref = import_react10.default.useRef(null);
|
|
28895
|
-
|
|
28907
|
+
useSafeLayoutEffect2(() => {
|
|
28896
28908
|
const element = ref.current;
|
|
28897
28909
|
if (!element) {
|
|
28898
28910
|
return;
|
|
@@ -29098,6 +29110,7 @@ function openAncestorChain(parentId) {
|
|
|
29098
29110
|
openAncestorChain(nextParentId);
|
|
29099
29111
|
}
|
|
29100
29112
|
if (!parentRuntime.controller.getSnapshot().state.isOpen) {
|
|
29113
|
+
releaseHiddenFocusBeforeOpen(parentRuntime.options);
|
|
29101
29114
|
parentRuntime.controller.setOpen(true);
|
|
29102
29115
|
notifyOpenStateChange(parentRuntime, true);
|
|
29103
29116
|
renderVanillaDrawer(parentRuntime.id);
|
|
@@ -29117,6 +29130,7 @@ function bindTriggerElement(runtime) {
|
|
|
29117
29130
|
}
|
|
29118
29131
|
const triggerElement = runtime.options.triggerElement;
|
|
29119
29132
|
const handleClick = () => {
|
|
29133
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29120
29134
|
runtime.controller.setOpen(true);
|
|
29121
29135
|
renderVanillaDrawer(runtime.id);
|
|
29122
29136
|
};
|
|
@@ -29152,6 +29166,16 @@ function notifyOpenStateChange(runtime, open) {
|
|
|
29152
29166
|
function canUseDOM3() {
|
|
29153
29167
|
return typeof window !== "undefined" && typeof document !== "undefined";
|
|
29154
29168
|
}
|
|
29169
|
+
function releaseHiddenFocusBeforeOpen(options) {
|
|
29170
|
+
if (!canUseDOM3() || options.modal === false || options.autoFocus) {
|
|
29171
|
+
return;
|
|
29172
|
+
}
|
|
29173
|
+
const activeElement = document.activeElement;
|
|
29174
|
+
if (!activeElement || activeElement === document.body || typeof activeElement.blur !== "function") {
|
|
29175
|
+
return;
|
|
29176
|
+
}
|
|
29177
|
+
activeElement.blur();
|
|
29178
|
+
}
|
|
29155
29179
|
function getRuntimeDrawerElement(runtime) {
|
|
29156
29180
|
if (!runtime.element) {
|
|
29157
29181
|
return null;
|
|
@@ -29205,6 +29229,9 @@ function renderVanillaDrawer(id) {
|
|
|
29205
29229
|
open: snapshot.state.isOpen,
|
|
29206
29230
|
onOpenChange: (open) => {
|
|
29207
29231
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29232
|
+
if (open) {
|
|
29233
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29234
|
+
}
|
|
29208
29235
|
runtime.controller.setOpen(open);
|
|
29209
29236
|
if (previousOpen !== open) {
|
|
29210
29237
|
notifyOpenStateChange(runtime, open);
|
|
@@ -29251,6 +29278,9 @@ function buildVanillaController(id) {
|
|
|
29251
29278
|
if (!runtime) {
|
|
29252
29279
|
return createDrawer({ id, open }).getSnapshot();
|
|
29253
29280
|
}
|
|
29281
|
+
if (open) {
|
|
29282
|
+
releaseHiddenFocusBeforeOpen(runtime.options);
|
|
29283
|
+
}
|
|
29254
29284
|
const previousOpen = runtime.controller.getSnapshot().state.isOpen;
|
|
29255
29285
|
const snapshot = runtime.controller.setOpen(open);
|
|
29256
29286
|
if (previousOpen !== open) {
|
|
@@ -29321,6 +29351,9 @@ function createDrawer(options = {}) {
|
|
|
29321
29351
|
notifyOpenStateChange(existing, snapshot.state.isOpen);
|
|
29322
29352
|
}
|
|
29323
29353
|
}
|
|
29354
|
+
if (nextOptions.open && !previousOpen) {
|
|
29355
|
+
releaseHiddenFocusBeforeOpen(nextOptions);
|
|
29356
|
+
}
|
|
29324
29357
|
renderVanillaDrawer(id);
|
|
29325
29358
|
if (nextOptions.parentId && nextOptions.open) {
|
|
29326
29359
|
openAncestorChain(nextOptions.parentId);
|