@capgo/capacitor-sheets 8.0.11 → 8.0.13

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.
Files changed (49) hide show
  1. package/README.md +29 -1
  2. package/dist/angular/index.d.mts +18 -2
  3. package/dist/angular/index.d.ts +18 -2
  4. package/dist/angular/index.js +157 -16
  5. package/dist/angular/index.js.map +1 -1
  6. package/dist/angular/index.mjs +157 -16
  7. package/dist/angular/index.mjs.map +1 -1
  8. package/dist/{chunk-LY2DKBXN.mjs → chunk-7DYTSFX3.mjs} +27 -10
  9. package/dist/chunk-7DYTSFX3.mjs.map +1 -0
  10. package/dist/{chunk-FHGK4I6L.mjs → chunk-AXGC7BLW.mjs} +133 -9
  11. package/dist/chunk-AXGC7BLW.mjs.map +1 -0
  12. package/dist/{components-YSGBN2YD.mjs → components-STHKYCFN.mjs} +3 -3
  13. package/dist/index.d.mts +19 -3
  14. package/dist/index.d.ts +19 -3
  15. package/dist/index.js +158 -17
  16. package/dist/index.js.map +1 -1
  17. package/dist/index.mjs +4 -4
  18. package/dist/index.mjs.map +1 -1
  19. package/dist/react/index.d.mts +23 -2
  20. package/dist/react/index.d.ts +23 -2
  21. package/dist/react/index.js +157 -16
  22. package/dist/react/index.js.map +1 -1
  23. package/dist/react/index.mjs +157 -16
  24. package/dist/react/index.mjs.map +1 -1
  25. package/dist/solid/index.d.mts +23 -2
  26. package/dist/solid/index.d.ts +23 -2
  27. package/dist/solid/index.js +157 -16
  28. package/dist/solid/index.js.map +1 -1
  29. package/dist/solid/index.mjs +157 -16
  30. package/dist/solid/index.mjs.map +1 -1
  31. package/dist/{styles-VAFNQKVC.mjs → styles-P4J3AKBN.mjs} +2 -2
  32. package/dist/svelte/index.d.mts +18 -2
  33. package/dist/svelte/index.d.ts +18 -2
  34. package/dist/svelte/index.js +157 -16
  35. package/dist/svelte/index.js.map +1 -1
  36. package/dist/svelte/index.mjs +157 -16
  37. package/dist/svelte/index.mjs.map +1 -1
  38. package/dist/vue/index.d.mts +18 -2
  39. package/dist/vue/index.d.ts +18 -2
  40. package/dist/vue/index.js +157 -16
  41. package/dist/vue/index.js.map +1 -1
  42. package/dist/vue/index.mjs +157 -16
  43. package/dist/vue/index.mjs.map +1 -1
  44. package/docs/demos/ios-fullscreen-real-demo.webp +0 -0
  45. package/package.json +1 -1
  46. package/dist/chunk-FHGK4I6L.mjs.map +0 -1
  47. package/dist/chunk-LY2DKBXN.mjs.map +0 -1
  48. /package/dist/{components-YSGBN2YD.mjs.map → components-STHKYCFN.mjs.map} +0 -0
  49. /package/dist/{styles-VAFNQKVC.mjs.map → styles-P4J3AKBN.mjs.map} +0 -0
package/dist/index.js CHANGED
@@ -165,6 +165,11 @@ var init_styles = __esm({
165
165
  --cap-sheet-applied-safe-area-bottom: var(--cap-sheet-safe-area-bottom);
166
166
  --cap-sheet-applied-safe-area-left: var(--cap-sheet-safe-area-left);
167
167
  --cap-sheet-applied-safe-area-right: var(--cap-sheet-safe-area-right);
168
+ --cap-sheet-container-offset-top: 0em;
169
+ --cap-sheet-container-offset-bottom: 0em;
170
+ --cap-sheet-container-offset-left: 0em;
171
+ --cap-sheet-container-offset-right: 0em;
172
+ --cap-sheet-keyboard-offset: 0em;
168
173
  }
169
174
 
170
175
  @supports (height: 1dvh) {
@@ -193,10 +198,13 @@ cap-sheet-view {
193
198
  overscroll-behavior: none;
194
199
  contain: layout style;
195
200
  box-sizing: border-box;
196
- padding-block-start: var(--cap-sheet-applied-safe-area-top, 0em);
197
- padding-block-end: calc(var(--cap-sheet-applied-safe-area-bottom, 0em) + var(--cap-sheet-keyboard-offset, 0em));
198
- padding-inline-start: var(--cap-sheet-applied-safe-area-left, 0em);
199
- padding-inline-end: var(--cap-sheet-applied-safe-area-right, 0em);
201
+ padding-top: calc(var(--cap-sheet-applied-safe-area-top, 0em) + var(--cap-sheet-container-offset-top, 0em));
202
+ padding-bottom: calc(
203
+ var(--cap-sheet-applied-safe-area-bottom, 0em) + var(--cap-sheet-container-offset-bottom, 0em) +
204
+ var(--cap-sheet-keyboard-offset, 0em)
205
+ );
206
+ padding-left: calc(var(--cap-sheet-applied-safe-area-left, 0em) + var(--cap-sheet-container-offset-left, 0em));
207
+ padding-right: calc(var(--cap-sheet-applied-safe-area-right, 0em) + var(--cap-sheet-container-offset-right, 0em));
200
208
  }
201
209
 
202
210
  cap-sheet-view[hidden] {
@@ -241,6 +249,7 @@ cap-sheet-backdrop {
241
249
  }
242
250
 
243
251
  cap-sheet-content {
252
+ --cap-sheet-content-border-radius: var(--cap-sheet-radius) var(--cap-sheet-radius) 0 0;
244
253
  box-sizing: border-box;
245
254
  position: relative;
246
255
  display: block;
@@ -248,7 +257,7 @@ cap-sheet-content {
248
257
  max-height: 100%;
249
258
  color: CanvasText;
250
259
  background: var(--cap-sheet-surface);
251
- border-radius: var(--cap-sheet-radius) var(--cap-sheet-radius) 0 0;
260
+ border-radius: var(--cap-sheet-content-border-radius);
252
261
  box-shadow: var(--cap-sheet-shadow), var(--cap-sheet-edge-bleed-shadow, 0 0 0 0 transparent);
253
262
  overflow: auto;
254
263
  overscroll-behavior: contain;
@@ -259,27 +268,35 @@ cap-sheet-content {
259
268
  }
260
269
 
261
270
  cap-sheet-view[content-placement="top"] cap-sheet-content {
262
- border-radius: 0 0 var(--cap-sheet-radius) var(--cap-sheet-radius);
271
+ --cap-sheet-content-border-radius: 0 0 var(--cap-sheet-radius) var(--cap-sheet-radius);
263
272
  }
264
273
 
265
274
  cap-sheet-view[content-placement="left"] cap-sheet-content {
266
275
  width: min(88%, 28em);
267
276
  height: 100%;
268
277
  max-height: 100%;
269
- border-radius: 0 var(--cap-sheet-radius) var(--cap-sheet-radius) 0;
278
+ --cap-sheet-content-border-radius: 0 var(--cap-sheet-radius) var(--cap-sheet-radius) 0;
270
279
  }
271
280
 
272
281
  cap-sheet-view[content-placement="right"] cap-sheet-content {
273
282
  width: min(88%, 28em);
274
283
  height: 100%;
275
284
  max-height: 100%;
276
- border-radius: var(--cap-sheet-radius) 0 0 var(--cap-sheet-radius);
285
+ --cap-sheet-content-border-radius: var(--cap-sheet-radius) 0 0 var(--cap-sheet-radius);
277
286
  }
278
287
 
279
288
  cap-sheet-view[content-placement="center"] cap-sheet-content {
280
289
  width: min(90%, 30em);
281
290
  max-height: min(90%, 42em);
282
- border-radius: var(--cap-sheet-radius);
291
+ --cap-sheet-content-border-radius: var(--cap-sheet-radius);
292
+ }
293
+
294
+ cap-sheet-view[data-detached="true"] cap-sheet-content {
295
+ --cap-sheet-content-border-radius: var(--cap-sheet-detached-radius, var(--cap-sheet-radius));
296
+ }
297
+
298
+ cap-sheet-view[data-detached="true"] cap-sheet-content[data-cap-sheet-bleeds] {
299
+ --cap-sheet-edge-bleed-shadow: 0 0 0 0 transparent;
283
300
  }
284
301
 
285
302
  cap-sheet-bleeding-background {
@@ -557,20 +574,72 @@ function normalizeDetents(value) {
557
574
  if (Array.isArray(value)) return value.filter(Boolean);
558
575
  return parseList(value || null);
559
576
  }
577
+ function normalizeInsetValue(value) {
578
+ return unitlessInsetPattern.test(value) ? `${value}px` : value;
579
+ }
580
+ function parseInset(value) {
581
+ const normalized = value?.trim();
582
+ return normalized ? normalizeInsetValue(normalized) : void 0;
583
+ }
584
+ function formatInsetValue(value) {
585
+ if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : "0em";
586
+ const normalized = value?.trim();
587
+ return normalized ? normalizeInsetValue(normalized) : "0em";
588
+ }
589
+ function explicitInsetForEdge(options, edge) {
590
+ switch (edge) {
591
+ case "top":
592
+ return options.topInset;
593
+ case "bottom":
594
+ return options.bottomInset;
595
+ case "left":
596
+ return options.leftInset;
597
+ case "right":
598
+ return options.rightInset;
599
+ }
600
+ }
601
+ function containerInsetForEdge(options, edge) {
602
+ const values = [options.containerOffset?.[edge], explicitInsetForEdge(options, edge)].map(formatInsetValue).filter((value) => value !== "0em");
603
+ if (values.length === 0) return "0em";
604
+ if (values.length === 1) return values[0];
605
+ return `calc(${values.join(" + ")})`;
606
+ }
607
+ function hasOwnOption(options, key) {
608
+ return Object.prototype.hasOwnProperty.call(options, key);
609
+ }
610
+ function affectsDismissedOffset(options) {
611
+ return hasOwnOption(options, "contentPlacement") || hasOwnOption(options, "tracks") || hasOwnOption(options, "detents") || hasOwnOption(options, "safeArea") || hasOwnOption(options, "topInset") || hasOwnOption(options, "bottomInset") || hasOwnOption(options, "leftInset") || hasOwnOption(options, "rightInset") || hasOwnOption(options, "containerOffset");
612
+ }
560
613
  function parseSafeArea(value) {
561
614
  if (value === null) return void 0;
562
615
  const normalized = value.trim().toLowerCase();
563
- if (!normalized || normalized === "true" || normalized === "auto" || normalized === "all") return "auto";
616
+ if (!normalized || normalized === "auto") return "auto";
617
+ if (normalized === "true" || normalized === "all") return "all";
564
618
  if (normalized === "false" || normalized === "none" || normalized === "off") return "none";
565
619
  const edges = parseList(normalized).filter(
566
620
  (edge) => safeAreaEdges.includes(edge)
567
621
  );
568
622
  return edges.length > 0 ? edges : "auto";
569
623
  }
570
- function resolveSafeAreaEdges(value) {
624
+ function resolveAutoSafeAreaEdges(placement) {
625
+ switch (placement) {
626
+ case "bottom":
627
+ return ["bottom", "left", "right"];
628
+ case "top":
629
+ return ["top", "left", "right"];
630
+ case "left":
631
+ return ["top", "bottom", "left"];
632
+ case "right":
633
+ return ["top", "bottom", "right"];
634
+ case "center":
635
+ return safeAreaEdges;
636
+ }
637
+ }
638
+ function resolveSafeAreaEdges(value, placement) {
571
639
  if (value === false || value === "none") return [];
640
+ if (value === true || value === "all") return safeAreaEdges;
572
641
  if (Array.isArray(value)) return value.filter((edge) => safeAreaEdges.includes(edge));
573
- return safeAreaEdges;
642
+ return resolveAutoSafeAreaEdges(placement);
574
643
  }
575
644
  function readOptionsFromElement(root) {
576
645
  const placement = parsePlacement(root.getAttribute("content-placement"));
@@ -587,6 +656,11 @@ function readOptionsFromElement(root) {
587
656
  sheetRole: root.getAttribute("sheet-role") || defaultOptions.sheetRole,
588
657
  contentPlacement: placement,
589
658
  safeArea: parseSafeArea(root.getAttribute("safe-area")),
659
+ detached: parseBoolean(root.getAttribute("detached"), defaultOptions.detached),
660
+ topInset: parseInset(root.getAttribute("top-inset")),
661
+ bottomInset: parseInset(root.getAttribute("bottom-inset")),
662
+ leftInset: parseInset(root.getAttribute("left-inset")),
663
+ rightInset: parseInset(root.getAttribute("right-inset")),
590
664
  tracks: parseTracks(root.getAttribute("tracks"), placement === "center" ? "bottom" : placement),
591
665
  swipe: parseBoolean(root.getAttribute("swipe"), defaultOptions.swipe),
592
666
  swipeDismissal: parseBoolean(root.getAttribute("swipe-dismissal"), defaultOptions.swipeDismissal),
@@ -637,7 +711,7 @@ function tween(start, end, progress) {
637
711
  const next = startValue + (endValue - startValue) * progress;
638
712
  return `${next}${unit}`;
639
713
  }
640
- var defaultOptions, defaultAnimation, stackRegistry, safeAreaEdges, SheetController;
714
+ var defaultOptions, defaultAnimation, stackRegistry, unitlessInsetPattern, safeAreaEdges, SheetController;
641
715
  var init_sheet_controller = __esm({
642
716
  "src/core/sheet-controller.ts"() {
643
717
  "use strict";
@@ -646,6 +720,7 @@ var init_sheet_controller = __esm({
646
720
  defaultOptions = {
647
721
  contentPlacement: "bottom",
648
722
  sheetRole: "dialog",
723
+ detached: false,
649
724
  safeArea: "auto",
650
725
  swipe: true,
651
726
  swipeDismissal: true,
@@ -667,6 +742,7 @@ var init_sheet_controller = __esm({
667
742
  contentMove: true
668
743
  };
669
744
  stackRegistry = /* @__PURE__ */ new Map();
745
+ unitlessInsetPattern = /^-?(?:\d+(?:\.\d+)?|\.\d+)$/;
670
746
  safeAreaEdges = ["top", "bottom", "left", "right"];
671
747
  SheetController = class {
672
748
  root;
@@ -864,6 +940,11 @@ var init_sheet_controller = __esm({
864
940
  this.parts.content.setAttribute("aria-modal", attributeBoolean(this.options.inertOutside !== false));
865
941
  }
866
942
  this.linkAccessibleNames();
943
+ if (this.connected && !this.presented && this.parts.content && affectsDismissedOffset(options)) {
944
+ this.remeasure();
945
+ this.applyOffset(this.detentOffsetsPx[0] || this.hiddenOffsetPx, this.status);
946
+ this.updateDomState(false);
947
+ }
867
948
  this.registerStack();
868
949
  }
869
950
  /** Register a view, backdrop, content, or semantic part. */
@@ -1018,12 +1099,29 @@ var init_sheet_controller = __esm({
1018
1099
  const sign = trackSign(track);
1019
1100
  const axis = isVerticalTrack(track) ? "y" : "x";
1020
1101
  const rect = content.getBoundingClientRect();
1102
+ const viewRect = view?.getBoundingClientRect();
1021
1103
  const size = axis === "y" ? rect.height : rect.width;
1022
- this.hiddenOffsetPx = Math.max(size, 1) * sign;
1104
+ const transformedX = axis === "x" ? this.currentOffsetPx : 0;
1105
+ const transformedY = axis === "y" ? this.currentOffsetPx : 0;
1106
+ const contentRect = {
1107
+ top: rect.top - transformedY,
1108
+ right: rect.right - transformedX,
1109
+ bottom: rect.bottom - transformedY,
1110
+ left: rect.left - transformedX
1111
+ };
1112
+ let hiddenOffsetPx = Math.max(size, 1) * sign;
1113
+ if (viewRect) {
1114
+ if (track === "top") hiddenOffsetPx = viewRect.top - contentRect.bottom;
1115
+ if (track === "bottom") hiddenOffsetPx = viewRect.bottom - contentRect.top;
1116
+ if (track === "left") hiddenOffsetPx = viewRect.left - contentRect.right;
1117
+ if (track === "right") hiddenOffsetPx = viewRect.right - contentRect.left;
1118
+ }
1119
+ this.hiddenOffsetPx = Math.abs(hiddenOffsetPx) > 1 ? hiddenOffsetPx : sign;
1023
1120
  const detents = normalizeDetents(this.options.detents);
1024
1121
  const offsets = [this.hiddenOffsetPx];
1122
+ const measureContext = content;
1025
1123
  for (const detent of detents) {
1026
- const visible = measureCssLength(detent, content, axis);
1124
+ const visible = measureCssLength(detent, measureContext, axis);
1027
1125
  const offset = Math.max(Math.abs(this.hiddenOffsetPx) - visible, 0) * sign;
1028
1126
  offsets.push(offset);
1029
1127
  }
@@ -1193,13 +1291,17 @@ var init_sheet_controller = __esm({
1193
1291
  applySafeArea() {
1194
1292
  const view = this.parts.view;
1195
1293
  if (!view) return;
1196
- const edges = new Set(resolveSafeAreaEdges(this.options.safeArea));
1294
+ const edges = new Set(
1295
+ resolveSafeAreaEdges(this.options.safeArea, this.options.contentPlacement || defaultOptions.contentPlacement)
1296
+ );
1197
1297
  view.dataset.safeArea = edges.size > 0 ? Array.from(edges).join(" ") : "none";
1298
+ view.dataset.detached = this.options.detached ? "true" : "false";
1198
1299
  for (const edge of safeAreaEdges) {
1199
1300
  view.style.setProperty(
1200
1301
  `--cap-sheet-applied-safe-area-${edge}`,
1201
1302
  edges.has(edge) ? `var(--cap-sheet-safe-area-${edge})` : "0em"
1202
1303
  );
1304
+ view.style.setProperty(`--cap-sheet-container-offset-${edge}`, containerInsetForEdge(this.options, edge));
1203
1305
  }
1204
1306
  }
1205
1307
  addGlobalListeners() {
@@ -1505,12 +1607,17 @@ function readChangedOptionsFromElement(element, name) {
1505
1607
  "default-active-detent": ["defaultActiveDetent"],
1506
1608
  "default-presented": ["defaultPresented"],
1507
1609
  detents: ["detents"],
1610
+ detached: ["detached"],
1508
1611
  "focus-trap": ["focusTrap"],
1509
1612
  "inert-outside": ["inertOutside"],
1510
1613
  "native-edge-swipe-prevention": ["nativeEdgeSwipePrevention"],
1511
1614
  "native-focus-scroll-prevention": ["nativeFocusScrollPrevention"],
1512
1615
  presented: ["presented"],
1513
1616
  "restore-focus": ["restoreFocus"],
1617
+ "top-inset": ["topInset"],
1618
+ "bottom-inset": ["bottomInset"],
1619
+ "left-inset": ["leftInset"],
1620
+ "right-inset": ["rightInset"],
1514
1621
  "safe-area": ["safeArea"],
1515
1622
  "sheet-role": ["sheetRole"],
1516
1623
  stack: ["stack"],
@@ -1527,6 +1634,19 @@ function readChangedOptionsFromElement(element, name) {
1527
1634
  }
1528
1635
  return changed;
1529
1636
  }
1637
+ function formatInsetAttribute(value) {
1638
+ if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
1639
+ const normalized = value.trim();
1640
+ return normalized || void 0;
1641
+ }
1642
+ function combineInsetAttributes(...values) {
1643
+ const parts = values.flatMap((value) => {
1644
+ const attributeValue = value === void 0 ? void 0 : formatInsetAttribute(value);
1645
+ return attributeValue ? [attributeValue] : [];
1646
+ });
1647
+ if (parts.length === 0) return void 0;
1648
+ return parts.length === 1 ? parts[0] : `calc(${parts.join(" + ")})`;
1649
+ }
1530
1650
  function applySheetOptions(element, options) {
1531
1651
  if (options.contentPlacement) element.setAttribute("content-placement", options.contentPlacement);
1532
1652
  if (options.detents !== void 0) {
@@ -1538,7 +1658,6 @@ function applySheetOptions(element, options) {
1538
1658
  }
1539
1659
  if (options.defaultPresented !== void 0)
1540
1660
  element.setAttribute("default-presented", String(options.defaultPresented));
1541
- if (options.presented !== void 0) element.toggleAttribute("presented", options.presented);
1542
1661
  if (options.sheetRole) element.setAttribute("sheet-role", options.sheetRole);
1543
1662
  if (options.safeArea !== void 0) {
1544
1663
  element.setAttribute(
@@ -1549,7 +1668,23 @@ function applySheetOptions(element, options) {
1549
1668
  if (options.stack) element.setAttribute("stack", options.stack);
1550
1669
  if (options.tracks)
1551
1670
  element.setAttribute("tracks", Array.isArray(options.tracks) ? options.tracks.join(" ") : options.tracks);
1671
+ for (const [key, attr, edge] of [
1672
+ ["topInset", "top-inset", "top"],
1673
+ ["bottomInset", "bottom-inset", "bottom"],
1674
+ ["leftInset", "left-inset", "left"],
1675
+ ["rightInset", "right-inset", "right"]
1676
+ ]) {
1677
+ const hasEdgeInset = Object.prototype.hasOwnProperty.call(options, key);
1678
+ const hasContainerOffset = Object.prototype.hasOwnProperty.call(options, "containerOffset");
1679
+ const attributeValue = combineInsetAttributes(options[key], options.containerOffset?.[edge]);
1680
+ if (attributeValue !== void 0) {
1681
+ element.setAttribute(attr, attributeValue);
1682
+ } else if (hasEdgeInset || hasContainerOffset) {
1683
+ element.removeAttribute(attr);
1684
+ }
1685
+ }
1552
1686
  for (const [key, attr] of [
1687
+ ["detached", "detached"],
1553
1688
  ["swipe", "swipe"],
1554
1689
  ["swipeDismissal", "swipe-dismissal"],
1555
1690
  ["swipeOvershoot", "swipe-overshoot"],
@@ -1568,6 +1703,7 @@ function applySheetOptions(element, options) {
1568
1703
  if (options.themeColorDimming !== void 0) {
1569
1704
  element.setAttribute("theme-color-dimming", options.themeColorDimming === false ? "false" : "auto");
1570
1705
  }
1706
+ if (options.presented !== void 0) element.toggleAttribute("presented", options.presented);
1571
1707
  }
1572
1708
  var observed, CapSheet;
1573
1709
  var init_cap_sheet = __esm({
@@ -1584,12 +1720,17 @@ var init_cap_sheet = __esm({
1584
1720
  "default-active-detent",
1585
1721
  "default-presented",
1586
1722
  "detents",
1723
+ "detached",
1587
1724
  "focus-trap",
1588
1725
  "inert-outside",
1589
1726
  "native-edge-swipe-prevention",
1590
1727
  "native-focus-scroll-prevention",
1591
1728
  "presented",
1592
1729
  "restore-focus",
1730
+ "top-inset",
1731
+ "bottom-inset",
1732
+ "left-inset",
1733
+ "right-inset",
1593
1734
  "safe-area",
1594
1735
  "sheet-role",
1595
1736
  "stack",