@capgo/capacitor-sheets 8.0.11 → 8.0.12

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
@@ -121,6 +121,11 @@ var CSS = `
121
121
  --cap-sheet-applied-safe-area-bottom: var(--cap-sheet-safe-area-bottom);
122
122
  --cap-sheet-applied-safe-area-left: var(--cap-sheet-safe-area-left);
123
123
  --cap-sheet-applied-safe-area-right: var(--cap-sheet-safe-area-right);
124
+ --cap-sheet-container-offset-top: 0em;
125
+ --cap-sheet-container-offset-bottom: 0em;
126
+ --cap-sheet-container-offset-left: 0em;
127
+ --cap-sheet-container-offset-right: 0em;
128
+ --cap-sheet-keyboard-offset: 0em;
124
129
  }
125
130
 
126
131
  @supports (height: 1dvh) {
@@ -149,10 +154,13 @@ cap-sheet-view {
149
154
  overscroll-behavior: none;
150
155
  contain: layout style;
151
156
  box-sizing: border-box;
152
- padding-block-start: var(--cap-sheet-applied-safe-area-top, 0em);
153
- padding-block-end: calc(var(--cap-sheet-applied-safe-area-bottom, 0em) + var(--cap-sheet-keyboard-offset, 0em));
154
- padding-inline-start: var(--cap-sheet-applied-safe-area-left, 0em);
155
- padding-inline-end: var(--cap-sheet-applied-safe-area-right, 0em);
157
+ padding-top: calc(var(--cap-sheet-applied-safe-area-top, 0em) + var(--cap-sheet-container-offset-top, 0em));
158
+ padding-bottom: calc(
159
+ var(--cap-sheet-applied-safe-area-bottom, 0em) + var(--cap-sheet-container-offset-bottom, 0em) +
160
+ var(--cap-sheet-keyboard-offset, 0em)
161
+ );
162
+ padding-left: calc(var(--cap-sheet-applied-safe-area-left, 0em) + var(--cap-sheet-container-offset-left, 0em));
163
+ padding-right: calc(var(--cap-sheet-applied-safe-area-right, 0em) + var(--cap-sheet-container-offset-right, 0em));
156
164
  }
157
165
 
158
166
  cap-sheet-view[hidden] {
@@ -197,6 +205,7 @@ cap-sheet-backdrop {
197
205
  }
198
206
 
199
207
  cap-sheet-content {
208
+ --cap-sheet-content-border-radius: var(--cap-sheet-radius) var(--cap-sheet-radius) 0 0;
200
209
  box-sizing: border-box;
201
210
  position: relative;
202
211
  display: block;
@@ -204,7 +213,7 @@ cap-sheet-content {
204
213
  max-height: 100%;
205
214
  color: CanvasText;
206
215
  background: var(--cap-sheet-surface);
207
- border-radius: var(--cap-sheet-radius) var(--cap-sheet-radius) 0 0;
216
+ border-radius: var(--cap-sheet-content-border-radius);
208
217
  box-shadow: var(--cap-sheet-shadow), var(--cap-sheet-edge-bleed-shadow, 0 0 0 0 transparent);
209
218
  overflow: auto;
210
219
  overscroll-behavior: contain;
@@ -215,27 +224,35 @@ cap-sheet-content {
215
224
  }
216
225
 
217
226
  cap-sheet-view[content-placement="top"] cap-sheet-content {
218
- border-radius: 0 0 var(--cap-sheet-radius) var(--cap-sheet-radius);
227
+ --cap-sheet-content-border-radius: 0 0 var(--cap-sheet-radius) var(--cap-sheet-radius);
219
228
  }
220
229
 
221
230
  cap-sheet-view[content-placement="left"] cap-sheet-content {
222
231
  width: min(88%, 28em);
223
232
  height: 100%;
224
233
  max-height: 100%;
225
- border-radius: 0 var(--cap-sheet-radius) var(--cap-sheet-radius) 0;
234
+ --cap-sheet-content-border-radius: 0 var(--cap-sheet-radius) var(--cap-sheet-radius) 0;
226
235
  }
227
236
 
228
237
  cap-sheet-view[content-placement="right"] cap-sheet-content {
229
238
  width: min(88%, 28em);
230
239
  height: 100%;
231
240
  max-height: 100%;
232
- border-radius: var(--cap-sheet-radius) 0 0 var(--cap-sheet-radius);
241
+ --cap-sheet-content-border-radius: var(--cap-sheet-radius) 0 0 var(--cap-sheet-radius);
233
242
  }
234
243
 
235
244
  cap-sheet-view[content-placement="center"] cap-sheet-content {
236
245
  width: min(90%, 30em);
237
246
  max-height: min(90%, 42em);
238
- border-radius: var(--cap-sheet-radius);
247
+ --cap-sheet-content-border-radius: var(--cap-sheet-radius);
248
+ }
249
+
250
+ cap-sheet-view[data-detached="true"] cap-sheet-content {
251
+ --cap-sheet-content-border-radius: var(--cap-sheet-detached-radius, var(--cap-sheet-radius));
252
+ }
253
+
254
+ cap-sheet-view[data-detached="true"] cap-sheet-content[data-cap-sheet-bleeds] {
255
+ --cap-sheet-edge-bleed-shadow: 0 0 0 0 transparent;
239
256
  }
240
257
 
241
258
  cap-sheet-bleeding-background {
@@ -489,6 +506,7 @@ function releaseThemeColorDimmer(documentRef) {
489
506
  var defaultOptions = {
490
507
  contentPlacement: "bottom",
491
508
  sheetRole: "dialog",
509
+ detached: false,
492
510
  safeArea: "auto",
493
511
  swipe: true,
494
512
  swipeDismissal: true,
@@ -519,21 +537,74 @@ function normalizeDetents(value) {
519
537
  if (Array.isArray(value)) return value.filter(Boolean);
520
538
  return parseList(value || null);
521
539
  }
540
+ var unitlessInsetPattern = /^-?(?:\d+(?:\.\d+)?|\.\d+)$/;
541
+ function normalizeInsetValue(value) {
542
+ return unitlessInsetPattern.test(value) ? `${value}px` : value;
543
+ }
544
+ function parseInset(value) {
545
+ const normalized = value?.trim();
546
+ return normalized ? normalizeInsetValue(normalized) : void 0;
547
+ }
548
+ function formatInsetValue(value) {
549
+ if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : "0em";
550
+ const normalized = value?.trim();
551
+ return normalized ? normalizeInsetValue(normalized) : "0em";
552
+ }
553
+ function explicitInsetForEdge(options, edge) {
554
+ switch (edge) {
555
+ case "top":
556
+ return options.topInset;
557
+ case "bottom":
558
+ return options.bottomInset;
559
+ case "left":
560
+ return options.leftInset;
561
+ case "right":
562
+ return options.rightInset;
563
+ }
564
+ }
565
+ function containerInsetForEdge(options, edge) {
566
+ const values = [options.containerOffset?.[edge], explicitInsetForEdge(options, edge)].map(formatInsetValue).filter((value) => value !== "0em");
567
+ if (values.length === 0) return "0em";
568
+ if (values.length === 1) return values[0];
569
+ return `calc(${values.join(" + ")})`;
570
+ }
571
+ function hasOwnOption(options, key) {
572
+ return Object.prototype.hasOwnProperty.call(options, key);
573
+ }
574
+ function affectsDismissedOffset(options) {
575
+ 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");
576
+ }
522
577
  var safeAreaEdges = ["top", "bottom", "left", "right"];
523
578
  function parseSafeArea(value) {
524
579
  if (value === null) return void 0;
525
580
  const normalized = value.trim().toLowerCase();
526
- if (!normalized || normalized === "true" || normalized === "auto" || normalized === "all") return "auto";
581
+ if (!normalized || normalized === "auto") return "auto";
582
+ if (normalized === "true" || normalized === "all") return "all";
527
583
  if (normalized === "false" || normalized === "none" || normalized === "off") return "none";
528
584
  const edges = parseList(normalized).filter(
529
585
  (edge) => safeAreaEdges.includes(edge)
530
586
  );
531
587
  return edges.length > 0 ? edges : "auto";
532
588
  }
533
- function resolveSafeAreaEdges(value) {
589
+ function resolveAutoSafeAreaEdges(placement) {
590
+ switch (placement) {
591
+ case "bottom":
592
+ return ["bottom", "left", "right"];
593
+ case "top":
594
+ return ["top", "left", "right"];
595
+ case "left":
596
+ return ["top", "bottom", "left"];
597
+ case "right":
598
+ return ["top", "bottom", "right"];
599
+ case "center":
600
+ return safeAreaEdges;
601
+ }
602
+ }
603
+ function resolveSafeAreaEdges(value, placement) {
534
604
  if (value === false || value === "none") return [];
605
+ if (value === true || value === "all") return safeAreaEdges;
535
606
  if (Array.isArray(value)) return value.filter((edge) => safeAreaEdges.includes(edge));
536
- return safeAreaEdges;
607
+ return resolveAutoSafeAreaEdges(placement);
537
608
  }
538
609
  function readOptionsFromElement(root) {
539
610
  const placement = parsePlacement(root.getAttribute("content-placement"));
@@ -550,6 +621,11 @@ function readOptionsFromElement(root) {
550
621
  sheetRole: root.getAttribute("sheet-role") || defaultOptions.sheetRole,
551
622
  contentPlacement: placement,
552
623
  safeArea: parseSafeArea(root.getAttribute("safe-area")),
624
+ detached: parseBoolean(root.getAttribute("detached"), defaultOptions.detached),
625
+ topInset: parseInset(root.getAttribute("top-inset")),
626
+ bottomInset: parseInset(root.getAttribute("bottom-inset")),
627
+ leftInset: parseInset(root.getAttribute("left-inset")),
628
+ rightInset: parseInset(root.getAttribute("right-inset")),
553
629
  tracks: parseTracks(root.getAttribute("tracks"), placement === "center" ? "bottom" : placement),
554
630
  swipe: parseBoolean(root.getAttribute("swipe"), defaultOptions.swipe),
555
631
  swipeDismissal: parseBoolean(root.getAttribute("swipe-dismissal"), defaultOptions.swipeDismissal),
@@ -786,6 +862,11 @@ var SheetController = class {
786
862
  this.parts.content.setAttribute("aria-modal", attributeBoolean(this.options.inertOutside !== false));
787
863
  }
788
864
  this.linkAccessibleNames();
865
+ if (this.connected && !this.presented && this.parts.content && affectsDismissedOffset(options)) {
866
+ this.remeasure();
867
+ this.applyOffset(this.detentOffsetsPx[0] || this.hiddenOffsetPx, this.status);
868
+ this.updateDomState(false);
869
+ }
789
870
  this.registerStack();
790
871
  }
791
872
  /** Register a view, backdrop, content, or semantic part. */
@@ -940,12 +1021,29 @@ var SheetController = class {
940
1021
  const sign = trackSign(track);
941
1022
  const axis = isVerticalTrack(track) ? "y" : "x";
942
1023
  const rect = content.getBoundingClientRect();
1024
+ const viewRect = view?.getBoundingClientRect();
943
1025
  const size = axis === "y" ? rect.height : rect.width;
944
- this.hiddenOffsetPx = Math.max(size, 1) * sign;
1026
+ const transformedX = axis === "x" ? this.currentOffsetPx : 0;
1027
+ const transformedY = axis === "y" ? this.currentOffsetPx : 0;
1028
+ const contentRect = {
1029
+ top: rect.top - transformedY,
1030
+ right: rect.right - transformedX,
1031
+ bottom: rect.bottom - transformedY,
1032
+ left: rect.left - transformedX
1033
+ };
1034
+ let hiddenOffsetPx = Math.max(size, 1) * sign;
1035
+ if (viewRect) {
1036
+ if (track === "top") hiddenOffsetPx = viewRect.top - contentRect.bottom;
1037
+ if (track === "bottom") hiddenOffsetPx = viewRect.bottom - contentRect.top;
1038
+ if (track === "left") hiddenOffsetPx = viewRect.left - contentRect.right;
1039
+ if (track === "right") hiddenOffsetPx = viewRect.right - contentRect.left;
1040
+ }
1041
+ this.hiddenOffsetPx = Math.abs(hiddenOffsetPx) > 1 ? hiddenOffsetPx : sign;
945
1042
  const detents = normalizeDetents(this.options.detents);
946
1043
  const offsets = [this.hiddenOffsetPx];
1044
+ const measureContext = content;
947
1045
  for (const detent of detents) {
948
- const visible = measureCssLength(detent, content, axis);
1046
+ const visible = measureCssLength(detent, measureContext, axis);
949
1047
  const offset = Math.max(Math.abs(this.hiddenOffsetPx) - visible, 0) * sign;
950
1048
  offsets.push(offset);
951
1049
  }
@@ -1115,13 +1213,17 @@ var SheetController = class {
1115
1213
  applySafeArea() {
1116
1214
  const view = this.parts.view;
1117
1215
  if (!view) return;
1118
- const edges = new Set(resolveSafeAreaEdges(this.options.safeArea));
1216
+ const edges = new Set(
1217
+ resolveSafeAreaEdges(this.options.safeArea, this.options.contentPlacement || defaultOptions.contentPlacement)
1218
+ );
1119
1219
  view.dataset.safeArea = edges.size > 0 ? Array.from(edges).join(" ") : "none";
1220
+ view.dataset.detached = this.options.detached ? "true" : "false";
1120
1221
  for (const edge of safeAreaEdges) {
1121
1222
  view.style.setProperty(
1122
1223
  `--cap-sheet-applied-safe-area-${edge}`,
1123
1224
  edges.has(edge) ? `var(--cap-sheet-safe-area-${edge})` : "0em"
1124
1225
  );
1226
+ view.style.setProperty(`--cap-sheet-container-offset-${edge}`, containerInsetForEdge(this.options, edge));
1125
1227
  }
1126
1228
  }
1127
1229
  addGlobalListeners() {
@@ -1419,12 +1521,17 @@ var observed = [
1419
1521
  "default-active-detent",
1420
1522
  "default-presented",
1421
1523
  "detents",
1524
+ "detached",
1422
1525
  "focus-trap",
1423
1526
  "inert-outside",
1424
1527
  "native-edge-swipe-prevention",
1425
1528
  "native-focus-scroll-prevention",
1426
1529
  "presented",
1427
1530
  "restore-focus",
1531
+ "top-inset",
1532
+ "bottom-inset",
1533
+ "left-inset",
1534
+ "right-inset",
1428
1535
  "safe-area",
1429
1536
  "sheet-role",
1430
1537
  "stack",
@@ -1539,12 +1646,17 @@ function readChangedOptionsFromElement(element, name) {
1539
1646
  "default-active-detent": ["defaultActiveDetent"],
1540
1647
  "default-presented": ["defaultPresented"],
1541
1648
  detents: ["detents"],
1649
+ detached: ["detached"],
1542
1650
  "focus-trap": ["focusTrap"],
1543
1651
  "inert-outside": ["inertOutside"],
1544
1652
  "native-edge-swipe-prevention": ["nativeEdgeSwipePrevention"],
1545
1653
  "native-focus-scroll-prevention": ["nativeFocusScrollPrevention"],
1546
1654
  presented: ["presented"],
1547
1655
  "restore-focus": ["restoreFocus"],
1656
+ "top-inset": ["topInset"],
1657
+ "bottom-inset": ["bottomInset"],
1658
+ "left-inset": ["leftInset"],
1659
+ "right-inset": ["rightInset"],
1548
1660
  "safe-area": ["safeArea"],
1549
1661
  "sheet-role": ["sheetRole"],
1550
1662
  stack: ["stack"],
@@ -1561,6 +1673,19 @@ function readChangedOptionsFromElement(element, name) {
1561
1673
  }
1562
1674
  return changed;
1563
1675
  }
1676
+ function formatInsetAttribute(value) {
1677
+ if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
1678
+ const normalized = value.trim();
1679
+ return normalized || void 0;
1680
+ }
1681
+ function combineInsetAttributes(...values) {
1682
+ const parts = values.flatMap((value) => {
1683
+ const attributeValue = value === void 0 ? void 0 : formatInsetAttribute(value);
1684
+ return attributeValue ? [attributeValue] : [];
1685
+ });
1686
+ if (parts.length === 0) return void 0;
1687
+ return parts.length === 1 ? parts[0] : `calc(${parts.join(" + ")})`;
1688
+ }
1564
1689
  function applySheetOptions(element, options) {
1565
1690
  if (options.contentPlacement) element.setAttribute("content-placement", options.contentPlacement);
1566
1691
  if (options.detents !== void 0) {
@@ -1572,7 +1697,6 @@ function applySheetOptions(element, options) {
1572
1697
  }
1573
1698
  if (options.defaultPresented !== void 0)
1574
1699
  element.setAttribute("default-presented", String(options.defaultPresented));
1575
- if (options.presented !== void 0) element.toggleAttribute("presented", options.presented);
1576
1700
  if (options.sheetRole) element.setAttribute("sheet-role", options.sheetRole);
1577
1701
  if (options.safeArea !== void 0) {
1578
1702
  element.setAttribute(
@@ -1583,7 +1707,23 @@ function applySheetOptions(element, options) {
1583
1707
  if (options.stack) element.setAttribute("stack", options.stack);
1584
1708
  if (options.tracks)
1585
1709
  element.setAttribute("tracks", Array.isArray(options.tracks) ? options.tracks.join(" ") : options.tracks);
1710
+ for (const [key, attr, edge] of [
1711
+ ["topInset", "top-inset", "top"],
1712
+ ["bottomInset", "bottom-inset", "bottom"],
1713
+ ["leftInset", "left-inset", "left"],
1714
+ ["rightInset", "right-inset", "right"]
1715
+ ]) {
1716
+ const hasEdgeInset = Object.prototype.hasOwnProperty.call(options, key);
1717
+ const hasContainerOffset = Object.prototype.hasOwnProperty.call(options, "containerOffset");
1718
+ const attributeValue = combineInsetAttributes(options[key], options.containerOffset?.[edge]);
1719
+ if (attributeValue !== void 0) {
1720
+ element.setAttribute(attr, attributeValue);
1721
+ } else if (hasEdgeInset || hasContainerOffset) {
1722
+ element.removeAttribute(attr);
1723
+ }
1724
+ }
1586
1725
  for (const [key, attr] of [
1726
+ ["detached", "detached"],
1587
1727
  ["swipe", "swipe"],
1588
1728
  ["swipeDismissal", "swipe-dismissal"],
1589
1729
  ["swipeOvershoot", "swipe-overshoot"],
@@ -1602,6 +1742,7 @@ function applySheetOptions(element, options) {
1602
1742
  if (options.themeColorDimming !== void 0) {
1603
1743
  element.setAttribute("theme-color-dimming", options.themeColorDimming === false ? "false" : "auto");
1604
1744
  }
1745
+ if (options.presented !== void 0) element.toggleAttribute("presented", options.presented);
1605
1746
  }
1606
1747
 
1607
1748
  // src/components/sheet-actions.ts