@capgo/capacitor-sheets 8.0.14 → 8.0.16
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/angular/index.js +68 -12
- package/dist/angular/index.js.map +1 -1
- package/dist/angular/index.mjs +68 -12
- package/dist/angular/index.mjs.map +1 -1
- package/dist/{chunk-AXGC7BLW.mjs → chunk-75SRJO4V.mjs} +69 -13
- package/dist/chunk-75SRJO4V.mjs.map +1 -0
- package/dist/{components-STHKYCFN.mjs → components-6FNKBOX7.mjs} +2 -2
- package/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +69 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/react/index.js +68 -12
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +68 -12
- package/dist/react/index.mjs.map +1 -1
- package/dist/solid/index.js +68 -12
- package/dist/solid/index.js.map +1 -1
- package/dist/solid/index.mjs +68 -12
- package/dist/solid/index.mjs.map +1 -1
- package/dist/svelte/index.js +68 -12
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/index.mjs +68 -12
- package/dist/svelte/index.mjs.map +1 -1
- package/dist/vue/index.js +68 -12
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/index.mjs +68 -12
- package/dist/vue/index.mjs.map +1 -1
- package/docs/screenshots/issue-38-detached-spacing-simulator.webp +0 -0
- package/docs/screenshots/issue-38-keyboard-sheet-simulator.webp +0 -0
- package/docs/screenshots/issue-38-long-sheet-safe-area-simulator.webp +0 -0
- package/docs/screenshots/issue-38-page-from-bottom-simulator.webp +0 -0
- package/docs/screenshots/issue-38-page-right-simulator.webp +0 -0
- package/docs/screenshots/issue-38-persistent-expanded-simulator.webp +0 -0
- package/docs/screenshots/issue-38-persistent-mini-simulator.webp +0 -0
- package/package.json +2 -2
- package/dist/chunk-AXGC7BLW.mjs.map +0 -1
- /package/dist/{components-STHKYCFN.mjs.map → components-6FNKBOX7.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
applySheetOptions,
|
|
25
25
|
getSheetFromElement,
|
|
26
26
|
updateThemeColor
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-75SRJO4V.mjs";
|
|
28
28
|
import {
|
|
29
29
|
CSS,
|
|
30
30
|
injectCapSheetStyles
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
|
|
33
33
|
// src/index.ts
|
|
34
34
|
function initCapSheets() {
|
|
35
|
-
import("./components-
|
|
35
|
+
import("./components-6FNKBOX7.mjs");
|
|
36
36
|
if (typeof document !== "undefined") {
|
|
37
37
|
import("./styles-P4J3AKBN.mjs").then(({ injectCapSheetStyles: injectCapSheetStyles2 }) => injectCapSheetStyles2(document));
|
|
38
38
|
}
|
package/dist/react/index.js
CHANGED
|
@@ -556,6 +556,8 @@ var defaultAnimation = {
|
|
|
556
556
|
contentMove: true
|
|
557
557
|
};
|
|
558
558
|
var stackRegistry = /* @__PURE__ */ new Map();
|
|
559
|
+
var documentLockDepth = /* @__PURE__ */ new WeakMap();
|
|
560
|
+
var documentLockSnapshot = /* @__PURE__ */ new WeakMap();
|
|
559
561
|
function parseNumber(value) {
|
|
560
562
|
if (value === null) return void 0;
|
|
561
563
|
const parsed = Number.parseInt(value, 10);
|
|
@@ -713,8 +715,6 @@ var SheetController = class {
|
|
|
713
715
|
pointerTravel = null;
|
|
714
716
|
connected = false;
|
|
715
717
|
lockedScroll = false;
|
|
716
|
-
previousBodyOverflow = "";
|
|
717
|
-
previousBodyTouchAction = "";
|
|
718
718
|
inertedElements = /* @__PURE__ */ new Map();
|
|
719
719
|
previousFocus = null;
|
|
720
720
|
hasThemeDimmer = false;
|
|
@@ -727,12 +727,20 @@ var SheetController = class {
|
|
|
727
727
|
const visualViewport = this.root.ownerDocument.defaultView?.visualViewport;
|
|
728
728
|
if (!view) return;
|
|
729
729
|
if (!visualViewport || this.options.nativeFocusScrollPrevention === false) {
|
|
730
|
-
|
|
730
|
+
this.setKeyboardOffset("0em");
|
|
731
731
|
return;
|
|
732
732
|
}
|
|
733
733
|
const layoutHeight = this.root.ownerDocument.documentElement.clientHeight;
|
|
734
734
|
const keyboardOffset = Math.max(0, layoutHeight - visualViewport.height - visualViewport.offsetTop);
|
|
735
|
-
|
|
735
|
+
this.setKeyboardOffset(`${toEm(view, keyboardOffset)}em`);
|
|
736
|
+
};
|
|
737
|
+
handleFocusIn = (event) => {
|
|
738
|
+
if (!this.presented || this.options.nativeFocusScrollPrevention === false) return;
|
|
739
|
+
const target = event.target;
|
|
740
|
+
const content = this.parts.content;
|
|
741
|
+
if (!(target instanceof HTMLElement) || !content?.contains(target)) return;
|
|
742
|
+
if (!["input", "select", "textarea"].includes(target.localName) && !target.isContentEditable) return;
|
|
743
|
+
requestAnimationFrame(() => target.scrollIntoView({ block: "nearest", inline: "nearest" }));
|
|
736
744
|
};
|
|
737
745
|
handleDocumentKeyDown = (event) => {
|
|
738
746
|
if (!this.presented) return;
|
|
@@ -949,6 +957,7 @@ var SheetController = class {
|
|
|
949
957
|
this.previousFocus = this.root.ownerDocument.activeElement;
|
|
950
958
|
this.presented = true;
|
|
951
959
|
this.activeDetent = clamp(options.detent ?? this.resolveInitialDetent(), 1, this.detentOffsetsPx.length - 1);
|
|
960
|
+
this.updateDetentState();
|
|
952
961
|
this.updateDomState(true);
|
|
953
962
|
this.lockPage();
|
|
954
963
|
this.applyInert();
|
|
@@ -972,6 +981,7 @@ var SheetController = class {
|
|
|
972
981
|
const previous = this.activeDetent;
|
|
973
982
|
this.presented = false;
|
|
974
983
|
this.activeDetent = 0;
|
|
984
|
+
this.updateDetentState();
|
|
975
985
|
this.setStatus("exiting");
|
|
976
986
|
dispatch(this.root, "cap-sheet-dismiss", this.getTravelEvent());
|
|
977
987
|
await this.animateTo(this.detentOffsetsPx[0] || this.hiddenOffsetPx, {
|
|
@@ -1010,6 +1020,7 @@ var SheetController = class {
|
|
|
1010
1020
|
}
|
|
1011
1021
|
const previous = this.activeDetent;
|
|
1012
1022
|
this.activeDetent = target;
|
|
1023
|
+
this.updateDetentState();
|
|
1013
1024
|
this.setStatus("settling");
|
|
1014
1025
|
await this.animateTo(this.detentOffsetsPx[target] || 0, {
|
|
1015
1026
|
...this.options.steppingAnimationSettings || {},
|
|
@@ -1281,6 +1292,7 @@ var SheetController = class {
|
|
|
1281
1292
|
view.addEventListener("pointermove", this.handlePointerMove, { passive: false });
|
|
1282
1293
|
view.addEventListener("pointerup", this.handlePointerUp);
|
|
1283
1294
|
view.addEventListener("pointercancel", this.handlePointerUp);
|
|
1295
|
+
view.addEventListener("focusin", this.handleFocusIn);
|
|
1284
1296
|
view.addEventListener("wheel", this.handleWheel, { passive: false });
|
|
1285
1297
|
this.viewListenersElement = view;
|
|
1286
1298
|
}
|
|
@@ -1292,6 +1304,7 @@ var SheetController = class {
|
|
|
1292
1304
|
view.removeEventListener("pointermove", this.handlePointerMove);
|
|
1293
1305
|
view.removeEventListener("pointerup", this.handlePointerUp);
|
|
1294
1306
|
view.removeEventListener("pointercancel", this.handlePointerUp);
|
|
1307
|
+
view.removeEventListener("focusin", this.handleFocusIn);
|
|
1295
1308
|
view.removeEventListener("wheel", this.handleWheel);
|
|
1296
1309
|
this.viewListenersElement = null;
|
|
1297
1310
|
}
|
|
@@ -1324,6 +1337,7 @@ var SheetController = class {
|
|
|
1324
1337
|
content.setAttribute("tabindex", content.getAttribute("tabindex") || "-1");
|
|
1325
1338
|
}
|
|
1326
1339
|
this.root.toggleAttribute("presented", presented);
|
|
1340
|
+
this.updateDetentState();
|
|
1327
1341
|
}
|
|
1328
1342
|
linkAccessibleNames() {
|
|
1329
1343
|
if (!this.parts.content) return;
|
|
@@ -1372,24 +1386,60 @@ var SheetController = class {
|
|
|
1372
1386
|
}
|
|
1373
1387
|
lockPage() {
|
|
1374
1388
|
if (this.lockedScroll) return;
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1377
|
-
|
|
1389
|
+
const doc = this.root.ownerDocument;
|
|
1390
|
+
const documentElement = doc.documentElement;
|
|
1391
|
+
const body = doc.body;
|
|
1392
|
+
const depth = documentLockDepth.get(doc) ?? 0;
|
|
1393
|
+
if (depth === 0) {
|
|
1394
|
+
documentLockSnapshot.set(doc, {
|
|
1395
|
+
htmlOverflow: documentElement.style.overflow,
|
|
1396
|
+
htmlTouchAction: documentElement.style.touchAction,
|
|
1397
|
+
bodyOverflow: body.style.overflow,
|
|
1398
|
+
bodyTouchAction: body.style.touchAction
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
documentElement.style.overflow = "hidden";
|
|
1402
|
+
documentElement.style.touchAction = "none";
|
|
1378
1403
|
body.dataset.capSheetScrollLocked = "true";
|
|
1379
1404
|
body.style.overflow = "hidden";
|
|
1380
1405
|
body.style.touchAction = "none";
|
|
1406
|
+
documentLockDepth.set(doc, depth + 1);
|
|
1381
1407
|
this.lockedScroll = true;
|
|
1382
1408
|
}
|
|
1383
1409
|
unlockPage() {
|
|
1384
1410
|
if (!this.lockedScroll) return;
|
|
1385
|
-
const
|
|
1411
|
+
const doc = this.root.ownerDocument;
|
|
1412
|
+
const documentElement = doc.documentElement;
|
|
1413
|
+
const body = doc.body;
|
|
1414
|
+
const depth = Math.max((documentLockDepth.get(doc) ?? 1) - 1, 0);
|
|
1415
|
+
if (depth > 0) {
|
|
1416
|
+
documentLockDepth.set(doc, depth);
|
|
1417
|
+
this.lockedScroll = false;
|
|
1418
|
+
return;
|
|
1419
|
+
}
|
|
1420
|
+
const snapshot = documentLockSnapshot.get(doc);
|
|
1386
1421
|
delete body.dataset.capSheetScrollLocked;
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1422
|
+
documentElement.style.overflow = snapshot?.htmlOverflow ?? "";
|
|
1423
|
+
documentElement.style.touchAction = snapshot?.htmlTouchAction ?? "";
|
|
1424
|
+
body.style.overflow = snapshot?.bodyOverflow ?? "";
|
|
1425
|
+
body.style.touchAction = snapshot?.bodyTouchAction ?? "";
|
|
1426
|
+
documentLockDepth.delete(doc);
|
|
1427
|
+
documentLockSnapshot.delete(doc);
|
|
1391
1428
|
this.lockedScroll = false;
|
|
1392
1429
|
}
|
|
1430
|
+
setKeyboardOffset(value) {
|
|
1431
|
+
const view = this.parts.view;
|
|
1432
|
+
if (!view) return;
|
|
1433
|
+
if (view.style.getPropertyValue("--cap-sheet-keyboard-offset") !== value) {
|
|
1434
|
+
view.style.setProperty("--cap-sheet-keyboard-offset", value);
|
|
1435
|
+
}
|
|
1436
|
+
if (!this.presented) return;
|
|
1437
|
+
requestAnimationFrame(() => {
|
|
1438
|
+
if (!this.presented) return;
|
|
1439
|
+
this.remeasure();
|
|
1440
|
+
this.applyOffset(this.detentOffsetsPx[this.activeDetent] || 0, this.status);
|
|
1441
|
+
});
|
|
1442
|
+
}
|
|
1393
1443
|
applyInert() {
|
|
1394
1444
|
if (this.options.inertOutside === false || !this.parts.view) return;
|
|
1395
1445
|
const body = this.root.ownerDocument.body;
|
|
@@ -1468,6 +1518,12 @@ var SheetController = class {
|
|
|
1468
1518
|
const detail = { activeDetent, previousActiveDetent };
|
|
1469
1519
|
dispatch(this.root, "cap-sheet-active-detent-change", detail);
|
|
1470
1520
|
}
|
|
1521
|
+
updateDetentState() {
|
|
1522
|
+
const activeDetent = String(this.activeDetent);
|
|
1523
|
+
this.root.dataset.activeDetent = activeDetent;
|
|
1524
|
+
if (this.parts.view) this.parts.view.dataset.activeDetent = activeDetent;
|
|
1525
|
+
if (this.parts.content) this.parts.content.dataset.activeDetent = activeDetent;
|
|
1526
|
+
}
|
|
1471
1527
|
registerStack() {
|
|
1472
1528
|
const nextStack = this.options.stack || this.root.closest("cap-sheet-stack")?.id || null;
|
|
1473
1529
|
if (this.stackId === nextStack) return;
|