@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.
- package/README.md +29 -1
- package/dist/angular/index.d.mts +18 -2
- package/dist/angular/index.d.ts +18 -2
- package/dist/angular/index.js +157 -16
- package/dist/angular/index.js.map +1 -1
- package/dist/angular/index.mjs +157 -16
- package/dist/angular/index.mjs.map +1 -1
- package/dist/{chunk-LY2DKBXN.mjs → chunk-7DYTSFX3.mjs} +27 -10
- package/dist/chunk-7DYTSFX3.mjs.map +1 -0
- package/dist/{chunk-FHGK4I6L.mjs → chunk-AXGC7BLW.mjs} +133 -9
- package/dist/chunk-AXGC7BLW.mjs.map +1 -0
- package/dist/{components-YSGBN2YD.mjs → components-STHKYCFN.mjs} +3 -3
- package/dist/index.d.mts +19 -3
- package/dist/index.d.ts +19 -3
- package/dist/index.js +158 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +4 -4
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +23 -2
- package/dist/react/index.d.ts +23 -2
- package/dist/react/index.js +157 -16
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +157 -16
- package/dist/react/index.mjs.map +1 -1
- package/dist/solid/index.d.mts +23 -2
- package/dist/solid/index.d.ts +23 -2
- package/dist/solid/index.js +157 -16
- package/dist/solid/index.js.map +1 -1
- package/dist/solid/index.mjs +157 -16
- package/dist/solid/index.mjs.map +1 -1
- package/dist/{styles-VAFNQKVC.mjs → styles-P4J3AKBN.mjs} +2 -2
- package/dist/svelte/index.d.mts +18 -2
- package/dist/svelte/index.d.ts +18 -2
- package/dist/svelte/index.js +157 -16
- package/dist/svelte/index.js.map +1 -1
- package/dist/svelte/index.mjs +157 -16
- package/dist/svelte/index.mjs.map +1 -1
- package/dist/vue/index.d.mts +18 -2
- package/dist/vue/index.d.ts +18 -2
- package/dist/vue/index.js +157 -16
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/index.mjs +157 -16
- package/dist/vue/index.mjs.map +1 -1
- package/docs/demos/ios-fullscreen-real-demo.webp +0 -0
- package/package.json +1 -1
- package/dist/chunk-FHGK4I6L.mjs.map +0 -1
- package/dist/chunk-LY2DKBXN.mjs.map +0 -1
- /package/dist/{components-YSGBN2YD.mjs.map → components-STHKYCFN.mjs.map} +0 -0
- /package/dist/{styles-VAFNQKVC.mjs.map → styles-P4J3AKBN.mjs.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
CSS,
|
|
3
3
|
injectCapSheetStyles
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7DYTSFX3.mjs";
|
|
5
5
|
export {
|
|
6
6
|
CSS as CAP_SHEETS_CSS,
|
|
7
7
|
injectCapSheetStyles
|
|
8
8
|
};
|
|
9
|
-
//# sourceMappingURL=styles-
|
|
9
|
+
//# sourceMappingURL=styles-P4J3AKBN.mjs.map
|
package/dist/svelte/index.d.mts
CHANGED
|
@@ -5,7 +5,11 @@ type SheetTrack = Exclude<SheetPlacement, 'center'>;
|
|
|
5
5
|
/** Viewport edges protected by safe-area insets. */
|
|
6
6
|
type SheetSafeAreaEdge = 'top' | 'bottom' | 'left' | 'right';
|
|
7
7
|
/** Safe-area behavior for Capacitor WebViews and mobile browsers. */
|
|
8
|
-
type SheetSafeAreaMode = boolean | 'auto' | 'none' | SheetSafeAreaEdge[];
|
|
8
|
+
type SheetSafeAreaMode = boolean | 'auto' | 'all' | 'none' | SheetSafeAreaEdge[];
|
|
9
|
+
/** CSS length or pixel number used for sheet container insets. */
|
|
10
|
+
type SheetInsetValue = string | number;
|
|
11
|
+
/** Extra container offsets applied around the sheet viewport. */
|
|
12
|
+
type SheetContainerOffset = Partial<Record<SheetSafeAreaEdge, SheetInsetValue>>;
|
|
9
13
|
/** Runtime travel state emitted by sheet lifecycle events. */
|
|
10
14
|
type SheetTravelStatus = 'idle' | 'entering' | 'exiting' | 'dragging' | 'settling';
|
|
11
15
|
/** Built-in animation presets tuned for mobile WebViews. */
|
|
@@ -49,6 +53,18 @@ interface SheetOptions {
|
|
|
49
53
|
contentPlacement?: SheetPlacement;
|
|
50
54
|
/** Safe-area edges protected by the sheet viewport. Defaults to `auto`. */
|
|
51
55
|
safeArea?: SheetSafeAreaMode;
|
|
56
|
+
/** Render as a floating sheet with detached edge rounding. */
|
|
57
|
+
detached?: boolean;
|
|
58
|
+
/** Extra top inset added to the sheet viewport, equivalent to Gorhom `topInset`. */
|
|
59
|
+
topInset?: SheetInsetValue;
|
|
60
|
+
/** Extra bottom inset added to the sheet viewport, equivalent to Gorhom `bottomInset`. */
|
|
61
|
+
bottomInset?: SheetInsetValue;
|
|
62
|
+
/** Extra left inset added to the sheet viewport. */
|
|
63
|
+
leftInset?: SheetInsetValue;
|
|
64
|
+
/** Extra right inset added to the sheet viewport. */
|
|
65
|
+
rightInset?: SheetInsetValue;
|
|
66
|
+
/** Extra per-edge container offsets, equivalent to Gorhom `containerOffset`. */
|
|
67
|
+
containerOffset?: SheetContainerOffset;
|
|
52
68
|
/** Edge tracks that can dismiss the sheet. */
|
|
53
69
|
tracks?: SheetTrack | SheetTrack[];
|
|
54
70
|
/** Enables pointer, touch, trackpad, and wheel travel gestures. */
|
|
@@ -118,4 +134,4 @@ declare function sheet(node: HTMLElement, options?: SheetActionOptions): SvelteA
|
|
|
118
134
|
/** Configure a `<cap-sheet>` element. */
|
|
119
135
|
declare function setupSheet(element: HTMLElement, options?: SheetActionOptions): () => void;
|
|
120
136
|
|
|
121
|
-
export { type SheetActionOptions, type SheetActiveDetentChangeEvent, type SheetOptions, type SheetPresentedChangeEvent, type SheetSafeAreaEdge, type SheetSafeAreaMode, type SheetTravelEvent, setupSheet, sheet };
|
|
137
|
+
export { type SheetActionOptions, type SheetActiveDetentChangeEvent, type SheetContainerOffset, type SheetInsetValue, type SheetOptions, type SheetPresentedChangeEvent, type SheetSafeAreaEdge, type SheetSafeAreaMode, type SheetTravelEvent, setupSheet, sheet };
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -5,7 +5,11 @@ type SheetTrack = Exclude<SheetPlacement, 'center'>;
|
|
|
5
5
|
/** Viewport edges protected by safe-area insets. */
|
|
6
6
|
type SheetSafeAreaEdge = 'top' | 'bottom' | 'left' | 'right';
|
|
7
7
|
/** Safe-area behavior for Capacitor WebViews and mobile browsers. */
|
|
8
|
-
type SheetSafeAreaMode = boolean | 'auto' | 'none' | SheetSafeAreaEdge[];
|
|
8
|
+
type SheetSafeAreaMode = boolean | 'auto' | 'all' | 'none' | SheetSafeAreaEdge[];
|
|
9
|
+
/** CSS length or pixel number used for sheet container insets. */
|
|
10
|
+
type SheetInsetValue = string | number;
|
|
11
|
+
/** Extra container offsets applied around the sheet viewport. */
|
|
12
|
+
type SheetContainerOffset = Partial<Record<SheetSafeAreaEdge, SheetInsetValue>>;
|
|
9
13
|
/** Runtime travel state emitted by sheet lifecycle events. */
|
|
10
14
|
type SheetTravelStatus = 'idle' | 'entering' | 'exiting' | 'dragging' | 'settling';
|
|
11
15
|
/** Built-in animation presets tuned for mobile WebViews. */
|
|
@@ -49,6 +53,18 @@ interface SheetOptions {
|
|
|
49
53
|
contentPlacement?: SheetPlacement;
|
|
50
54
|
/** Safe-area edges protected by the sheet viewport. Defaults to `auto`. */
|
|
51
55
|
safeArea?: SheetSafeAreaMode;
|
|
56
|
+
/** Render as a floating sheet with detached edge rounding. */
|
|
57
|
+
detached?: boolean;
|
|
58
|
+
/** Extra top inset added to the sheet viewport, equivalent to Gorhom `topInset`. */
|
|
59
|
+
topInset?: SheetInsetValue;
|
|
60
|
+
/** Extra bottom inset added to the sheet viewport, equivalent to Gorhom `bottomInset`. */
|
|
61
|
+
bottomInset?: SheetInsetValue;
|
|
62
|
+
/** Extra left inset added to the sheet viewport. */
|
|
63
|
+
leftInset?: SheetInsetValue;
|
|
64
|
+
/** Extra right inset added to the sheet viewport. */
|
|
65
|
+
rightInset?: SheetInsetValue;
|
|
66
|
+
/** Extra per-edge container offsets, equivalent to Gorhom `containerOffset`. */
|
|
67
|
+
containerOffset?: SheetContainerOffset;
|
|
52
68
|
/** Edge tracks that can dismiss the sheet. */
|
|
53
69
|
tracks?: SheetTrack | SheetTrack[];
|
|
54
70
|
/** Enables pointer, touch, trackpad, and wheel travel gestures. */
|
|
@@ -118,4 +134,4 @@ declare function sheet(node: HTMLElement, options?: SheetActionOptions): SvelteA
|
|
|
118
134
|
/** Configure a `<cap-sheet>` element. */
|
|
119
135
|
declare function setupSheet(element: HTMLElement, options?: SheetActionOptions): () => void;
|
|
120
136
|
|
|
121
|
-
export { type SheetActionOptions, type SheetActiveDetentChangeEvent, type SheetOptions, type SheetPresentedChangeEvent, type SheetSafeAreaEdge, type SheetSafeAreaMode, type SheetTravelEvent, setupSheet, sheet };
|
|
137
|
+
export { type SheetActionOptions, type SheetActiveDetentChangeEvent, type SheetContainerOffset, type SheetInsetValue, type SheetOptions, type SheetPresentedChangeEvent, type SheetSafeAreaEdge, type SheetSafeAreaMode, type SheetTravelEvent, setupSheet, sheet };
|
package/dist/svelte/index.js
CHANGED
|
@@ -148,6 +148,11 @@ var CSS = `
|
|
|
148
148
|
--cap-sheet-applied-safe-area-bottom: var(--cap-sheet-safe-area-bottom);
|
|
149
149
|
--cap-sheet-applied-safe-area-left: var(--cap-sheet-safe-area-left);
|
|
150
150
|
--cap-sheet-applied-safe-area-right: var(--cap-sheet-safe-area-right);
|
|
151
|
+
--cap-sheet-container-offset-top: 0em;
|
|
152
|
+
--cap-sheet-container-offset-bottom: 0em;
|
|
153
|
+
--cap-sheet-container-offset-left: 0em;
|
|
154
|
+
--cap-sheet-container-offset-right: 0em;
|
|
155
|
+
--cap-sheet-keyboard-offset: 0em;
|
|
151
156
|
}
|
|
152
157
|
|
|
153
158
|
@supports (height: 1dvh) {
|
|
@@ -176,10 +181,13 @@ cap-sheet-view {
|
|
|
176
181
|
overscroll-behavior: none;
|
|
177
182
|
contain: layout style;
|
|
178
183
|
box-sizing: border-box;
|
|
179
|
-
padding-
|
|
180
|
-
padding-
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
padding-top: calc(var(--cap-sheet-applied-safe-area-top, 0em) + var(--cap-sheet-container-offset-top, 0em));
|
|
185
|
+
padding-bottom: calc(
|
|
186
|
+
var(--cap-sheet-applied-safe-area-bottom, 0em) + var(--cap-sheet-container-offset-bottom, 0em) +
|
|
187
|
+
var(--cap-sheet-keyboard-offset, 0em)
|
|
188
|
+
);
|
|
189
|
+
padding-left: calc(var(--cap-sheet-applied-safe-area-left, 0em) + var(--cap-sheet-container-offset-left, 0em));
|
|
190
|
+
padding-right: calc(var(--cap-sheet-applied-safe-area-right, 0em) + var(--cap-sheet-container-offset-right, 0em));
|
|
183
191
|
}
|
|
184
192
|
|
|
185
193
|
cap-sheet-view[hidden] {
|
|
@@ -224,6 +232,7 @@ cap-sheet-backdrop {
|
|
|
224
232
|
}
|
|
225
233
|
|
|
226
234
|
cap-sheet-content {
|
|
235
|
+
--cap-sheet-content-border-radius: var(--cap-sheet-radius) var(--cap-sheet-radius) 0 0;
|
|
227
236
|
box-sizing: border-box;
|
|
228
237
|
position: relative;
|
|
229
238
|
display: block;
|
|
@@ -231,7 +240,7 @@ cap-sheet-content {
|
|
|
231
240
|
max-height: 100%;
|
|
232
241
|
color: CanvasText;
|
|
233
242
|
background: var(--cap-sheet-surface);
|
|
234
|
-
border-radius: var(--cap-sheet-
|
|
243
|
+
border-radius: var(--cap-sheet-content-border-radius);
|
|
235
244
|
box-shadow: var(--cap-sheet-shadow), var(--cap-sheet-edge-bleed-shadow, 0 0 0 0 transparent);
|
|
236
245
|
overflow: auto;
|
|
237
246
|
overscroll-behavior: contain;
|
|
@@ -242,27 +251,35 @@ cap-sheet-content {
|
|
|
242
251
|
}
|
|
243
252
|
|
|
244
253
|
cap-sheet-view[content-placement="top"] cap-sheet-content {
|
|
245
|
-
border-radius: 0 0 var(--cap-sheet-radius) var(--cap-sheet-radius);
|
|
254
|
+
--cap-sheet-content-border-radius: 0 0 var(--cap-sheet-radius) var(--cap-sheet-radius);
|
|
246
255
|
}
|
|
247
256
|
|
|
248
257
|
cap-sheet-view[content-placement="left"] cap-sheet-content {
|
|
249
258
|
width: min(88%, 28em);
|
|
250
259
|
height: 100%;
|
|
251
260
|
max-height: 100%;
|
|
252
|
-
border-radius: 0 var(--cap-sheet-radius) var(--cap-sheet-radius) 0;
|
|
261
|
+
--cap-sheet-content-border-radius: 0 var(--cap-sheet-radius) var(--cap-sheet-radius) 0;
|
|
253
262
|
}
|
|
254
263
|
|
|
255
264
|
cap-sheet-view[content-placement="right"] cap-sheet-content {
|
|
256
265
|
width: min(88%, 28em);
|
|
257
266
|
height: 100%;
|
|
258
267
|
max-height: 100%;
|
|
259
|
-
border-radius: var(--cap-sheet-radius) 0 0 var(--cap-sheet-radius);
|
|
268
|
+
--cap-sheet-content-border-radius: var(--cap-sheet-radius) 0 0 var(--cap-sheet-radius);
|
|
260
269
|
}
|
|
261
270
|
|
|
262
271
|
cap-sheet-view[content-placement="center"] cap-sheet-content {
|
|
263
272
|
width: min(90%, 30em);
|
|
264
273
|
max-height: min(90%, 42em);
|
|
265
|
-
border-radius: var(--cap-sheet-radius);
|
|
274
|
+
--cap-sheet-content-border-radius: var(--cap-sheet-radius);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
cap-sheet-view[data-detached="true"] cap-sheet-content {
|
|
278
|
+
--cap-sheet-content-border-radius: var(--cap-sheet-detached-radius, var(--cap-sheet-radius));
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
cap-sheet-view[data-detached="true"] cap-sheet-content[data-cap-sheet-bleeds] {
|
|
282
|
+
--cap-sheet-edge-bleed-shadow: 0 0 0 0 transparent;
|
|
266
283
|
}
|
|
267
284
|
|
|
268
285
|
cap-sheet-bleeding-background {
|
|
@@ -516,6 +533,7 @@ function releaseThemeColorDimmer(documentRef) {
|
|
|
516
533
|
var defaultOptions = {
|
|
517
534
|
contentPlacement: "bottom",
|
|
518
535
|
sheetRole: "dialog",
|
|
536
|
+
detached: false,
|
|
519
537
|
safeArea: "auto",
|
|
520
538
|
swipe: true,
|
|
521
539
|
swipeDismissal: true,
|
|
@@ -546,21 +564,74 @@ function normalizeDetents(value) {
|
|
|
546
564
|
if (Array.isArray(value)) return value.filter(Boolean);
|
|
547
565
|
return parseList(value || null);
|
|
548
566
|
}
|
|
567
|
+
var unitlessInsetPattern = /^-?(?:\d+(?:\.\d+)?|\.\d+)$/;
|
|
568
|
+
function normalizeInsetValue(value) {
|
|
569
|
+
return unitlessInsetPattern.test(value) ? `${value}px` : value;
|
|
570
|
+
}
|
|
571
|
+
function parseInset(value) {
|
|
572
|
+
const normalized = value?.trim();
|
|
573
|
+
return normalized ? normalizeInsetValue(normalized) : void 0;
|
|
574
|
+
}
|
|
575
|
+
function formatInsetValue(value) {
|
|
576
|
+
if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : "0em";
|
|
577
|
+
const normalized = value?.trim();
|
|
578
|
+
return normalized ? normalizeInsetValue(normalized) : "0em";
|
|
579
|
+
}
|
|
580
|
+
function explicitInsetForEdge(options, edge) {
|
|
581
|
+
switch (edge) {
|
|
582
|
+
case "top":
|
|
583
|
+
return options.topInset;
|
|
584
|
+
case "bottom":
|
|
585
|
+
return options.bottomInset;
|
|
586
|
+
case "left":
|
|
587
|
+
return options.leftInset;
|
|
588
|
+
case "right":
|
|
589
|
+
return options.rightInset;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
function containerInsetForEdge(options, edge) {
|
|
593
|
+
const values = [options.containerOffset?.[edge], explicitInsetForEdge(options, edge)].map(formatInsetValue).filter((value) => value !== "0em");
|
|
594
|
+
if (values.length === 0) return "0em";
|
|
595
|
+
if (values.length === 1) return values[0];
|
|
596
|
+
return `calc(${values.join(" + ")})`;
|
|
597
|
+
}
|
|
598
|
+
function hasOwnOption(options, key) {
|
|
599
|
+
return Object.prototype.hasOwnProperty.call(options, key);
|
|
600
|
+
}
|
|
601
|
+
function affectsDismissedOffset(options) {
|
|
602
|
+
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");
|
|
603
|
+
}
|
|
549
604
|
var safeAreaEdges = ["top", "bottom", "left", "right"];
|
|
550
605
|
function parseSafeArea(value) {
|
|
551
606
|
if (value === null) return void 0;
|
|
552
607
|
const normalized = value.trim().toLowerCase();
|
|
553
|
-
if (!normalized || normalized === "
|
|
608
|
+
if (!normalized || normalized === "auto") return "auto";
|
|
609
|
+
if (normalized === "true" || normalized === "all") return "all";
|
|
554
610
|
if (normalized === "false" || normalized === "none" || normalized === "off") return "none";
|
|
555
611
|
const edges = parseList(normalized).filter(
|
|
556
612
|
(edge) => safeAreaEdges.includes(edge)
|
|
557
613
|
);
|
|
558
614
|
return edges.length > 0 ? edges : "auto";
|
|
559
615
|
}
|
|
560
|
-
function
|
|
616
|
+
function resolveAutoSafeAreaEdges(placement) {
|
|
617
|
+
switch (placement) {
|
|
618
|
+
case "bottom":
|
|
619
|
+
return ["bottom", "left", "right"];
|
|
620
|
+
case "top":
|
|
621
|
+
return ["top", "left", "right"];
|
|
622
|
+
case "left":
|
|
623
|
+
return ["top", "bottom", "left"];
|
|
624
|
+
case "right":
|
|
625
|
+
return ["top", "bottom", "right"];
|
|
626
|
+
case "center":
|
|
627
|
+
return safeAreaEdges;
|
|
628
|
+
}
|
|
629
|
+
}
|
|
630
|
+
function resolveSafeAreaEdges(value, placement) {
|
|
561
631
|
if (value === false || value === "none") return [];
|
|
632
|
+
if (value === true || value === "all") return safeAreaEdges;
|
|
562
633
|
if (Array.isArray(value)) return value.filter((edge) => safeAreaEdges.includes(edge));
|
|
563
|
-
return
|
|
634
|
+
return resolveAutoSafeAreaEdges(placement);
|
|
564
635
|
}
|
|
565
636
|
function readOptionsFromElement(root) {
|
|
566
637
|
const placement = parsePlacement(root.getAttribute("content-placement"));
|
|
@@ -577,6 +648,11 @@ function readOptionsFromElement(root) {
|
|
|
577
648
|
sheetRole: root.getAttribute("sheet-role") || defaultOptions.sheetRole,
|
|
578
649
|
contentPlacement: placement,
|
|
579
650
|
safeArea: parseSafeArea(root.getAttribute("safe-area")),
|
|
651
|
+
detached: parseBoolean(root.getAttribute("detached"), defaultOptions.detached),
|
|
652
|
+
topInset: parseInset(root.getAttribute("top-inset")),
|
|
653
|
+
bottomInset: parseInset(root.getAttribute("bottom-inset")),
|
|
654
|
+
leftInset: parseInset(root.getAttribute("left-inset")),
|
|
655
|
+
rightInset: parseInset(root.getAttribute("right-inset")),
|
|
580
656
|
tracks: parseTracks(root.getAttribute("tracks"), placement === "center" ? "bottom" : placement),
|
|
581
657
|
swipe: parseBoolean(root.getAttribute("swipe"), defaultOptions.swipe),
|
|
582
658
|
swipeDismissal: parseBoolean(root.getAttribute("swipe-dismissal"), defaultOptions.swipeDismissal),
|
|
@@ -813,6 +889,11 @@ var SheetController = class {
|
|
|
813
889
|
this.parts.content.setAttribute("aria-modal", attributeBoolean(this.options.inertOutside !== false));
|
|
814
890
|
}
|
|
815
891
|
this.linkAccessibleNames();
|
|
892
|
+
if (this.connected && !this.presented && this.parts.content && affectsDismissedOffset(options)) {
|
|
893
|
+
this.remeasure();
|
|
894
|
+
this.applyOffset(this.detentOffsetsPx[0] || this.hiddenOffsetPx, this.status);
|
|
895
|
+
this.updateDomState(false);
|
|
896
|
+
}
|
|
816
897
|
this.registerStack();
|
|
817
898
|
}
|
|
818
899
|
/** Register a view, backdrop, content, or semantic part. */
|
|
@@ -967,12 +1048,29 @@ var SheetController = class {
|
|
|
967
1048
|
const sign = trackSign(track);
|
|
968
1049
|
const axis = isVerticalTrack(track) ? "y" : "x";
|
|
969
1050
|
const rect = content.getBoundingClientRect();
|
|
1051
|
+
const viewRect = view?.getBoundingClientRect();
|
|
970
1052
|
const size = axis === "y" ? rect.height : rect.width;
|
|
971
|
-
|
|
1053
|
+
const transformedX = axis === "x" ? this.currentOffsetPx : 0;
|
|
1054
|
+
const transformedY = axis === "y" ? this.currentOffsetPx : 0;
|
|
1055
|
+
const contentRect = {
|
|
1056
|
+
top: rect.top - transformedY,
|
|
1057
|
+
right: rect.right - transformedX,
|
|
1058
|
+
bottom: rect.bottom - transformedY,
|
|
1059
|
+
left: rect.left - transformedX
|
|
1060
|
+
};
|
|
1061
|
+
let hiddenOffsetPx = Math.max(size, 1) * sign;
|
|
1062
|
+
if (viewRect) {
|
|
1063
|
+
if (track === "top") hiddenOffsetPx = viewRect.top - contentRect.bottom;
|
|
1064
|
+
if (track === "bottom") hiddenOffsetPx = viewRect.bottom - contentRect.top;
|
|
1065
|
+
if (track === "left") hiddenOffsetPx = viewRect.left - contentRect.right;
|
|
1066
|
+
if (track === "right") hiddenOffsetPx = viewRect.right - contentRect.left;
|
|
1067
|
+
}
|
|
1068
|
+
this.hiddenOffsetPx = Math.abs(hiddenOffsetPx) > 1 ? hiddenOffsetPx : sign;
|
|
972
1069
|
const detents = normalizeDetents(this.options.detents);
|
|
973
1070
|
const offsets = [this.hiddenOffsetPx];
|
|
1071
|
+
const measureContext = content;
|
|
974
1072
|
for (const detent of detents) {
|
|
975
|
-
const visible = measureCssLength(detent,
|
|
1073
|
+
const visible = measureCssLength(detent, measureContext, axis);
|
|
976
1074
|
const offset = Math.max(Math.abs(this.hiddenOffsetPx) - visible, 0) * sign;
|
|
977
1075
|
offsets.push(offset);
|
|
978
1076
|
}
|
|
@@ -1142,13 +1240,17 @@ var SheetController = class {
|
|
|
1142
1240
|
applySafeArea() {
|
|
1143
1241
|
const view = this.parts.view;
|
|
1144
1242
|
if (!view) return;
|
|
1145
|
-
const edges = new Set(
|
|
1243
|
+
const edges = new Set(
|
|
1244
|
+
resolveSafeAreaEdges(this.options.safeArea, this.options.contentPlacement || defaultOptions.contentPlacement)
|
|
1245
|
+
);
|
|
1146
1246
|
view.dataset.safeArea = edges.size > 0 ? Array.from(edges).join(" ") : "none";
|
|
1247
|
+
view.dataset.detached = this.options.detached ? "true" : "false";
|
|
1147
1248
|
for (const edge of safeAreaEdges) {
|
|
1148
1249
|
view.style.setProperty(
|
|
1149
1250
|
`--cap-sheet-applied-safe-area-${edge}`,
|
|
1150
1251
|
edges.has(edge) ? `var(--cap-sheet-safe-area-${edge})` : "0em"
|
|
1151
1252
|
);
|
|
1253
|
+
view.style.setProperty(`--cap-sheet-container-offset-${edge}`, containerInsetForEdge(this.options, edge));
|
|
1152
1254
|
}
|
|
1153
1255
|
}
|
|
1154
1256
|
addGlobalListeners() {
|
|
@@ -1446,12 +1548,17 @@ var observed = [
|
|
|
1446
1548
|
"default-active-detent",
|
|
1447
1549
|
"default-presented",
|
|
1448
1550
|
"detents",
|
|
1551
|
+
"detached",
|
|
1449
1552
|
"focus-trap",
|
|
1450
1553
|
"inert-outside",
|
|
1451
1554
|
"native-edge-swipe-prevention",
|
|
1452
1555
|
"native-focus-scroll-prevention",
|
|
1453
1556
|
"presented",
|
|
1454
1557
|
"restore-focus",
|
|
1558
|
+
"top-inset",
|
|
1559
|
+
"bottom-inset",
|
|
1560
|
+
"left-inset",
|
|
1561
|
+
"right-inset",
|
|
1455
1562
|
"safe-area",
|
|
1456
1563
|
"sheet-role",
|
|
1457
1564
|
"stack",
|
|
@@ -1566,12 +1673,17 @@ function readChangedOptionsFromElement(element, name) {
|
|
|
1566
1673
|
"default-active-detent": ["defaultActiveDetent"],
|
|
1567
1674
|
"default-presented": ["defaultPresented"],
|
|
1568
1675
|
detents: ["detents"],
|
|
1676
|
+
detached: ["detached"],
|
|
1569
1677
|
"focus-trap": ["focusTrap"],
|
|
1570
1678
|
"inert-outside": ["inertOutside"],
|
|
1571
1679
|
"native-edge-swipe-prevention": ["nativeEdgeSwipePrevention"],
|
|
1572
1680
|
"native-focus-scroll-prevention": ["nativeFocusScrollPrevention"],
|
|
1573
1681
|
presented: ["presented"],
|
|
1574
1682
|
"restore-focus": ["restoreFocus"],
|
|
1683
|
+
"top-inset": ["topInset"],
|
|
1684
|
+
"bottom-inset": ["bottomInset"],
|
|
1685
|
+
"left-inset": ["leftInset"],
|
|
1686
|
+
"right-inset": ["rightInset"],
|
|
1575
1687
|
"safe-area": ["safeArea"],
|
|
1576
1688
|
"sheet-role": ["sheetRole"],
|
|
1577
1689
|
stack: ["stack"],
|
|
@@ -1588,6 +1700,19 @@ function readChangedOptionsFromElement(element, name) {
|
|
|
1588
1700
|
}
|
|
1589
1701
|
return changed;
|
|
1590
1702
|
}
|
|
1703
|
+
function formatInsetAttribute(value) {
|
|
1704
|
+
if (typeof value === "number") return Number.isFinite(value) ? `${value}px` : void 0;
|
|
1705
|
+
const normalized = value.trim();
|
|
1706
|
+
return normalized || void 0;
|
|
1707
|
+
}
|
|
1708
|
+
function combineInsetAttributes(...values) {
|
|
1709
|
+
const parts = values.flatMap((value) => {
|
|
1710
|
+
const attributeValue = value === void 0 ? void 0 : formatInsetAttribute(value);
|
|
1711
|
+
return attributeValue ? [attributeValue] : [];
|
|
1712
|
+
});
|
|
1713
|
+
if (parts.length === 0) return void 0;
|
|
1714
|
+
return parts.length === 1 ? parts[0] : `calc(${parts.join(" + ")})`;
|
|
1715
|
+
}
|
|
1591
1716
|
function applySheetOptions(element, options) {
|
|
1592
1717
|
if (options.contentPlacement) element.setAttribute("content-placement", options.contentPlacement);
|
|
1593
1718
|
if (options.detents !== void 0) {
|
|
@@ -1599,7 +1724,6 @@ function applySheetOptions(element, options) {
|
|
|
1599
1724
|
}
|
|
1600
1725
|
if (options.defaultPresented !== void 0)
|
|
1601
1726
|
element.setAttribute("default-presented", String(options.defaultPresented));
|
|
1602
|
-
if (options.presented !== void 0) element.toggleAttribute("presented", options.presented);
|
|
1603
1727
|
if (options.sheetRole) element.setAttribute("sheet-role", options.sheetRole);
|
|
1604
1728
|
if (options.safeArea !== void 0) {
|
|
1605
1729
|
element.setAttribute(
|
|
@@ -1610,7 +1734,23 @@ function applySheetOptions(element, options) {
|
|
|
1610
1734
|
if (options.stack) element.setAttribute("stack", options.stack);
|
|
1611
1735
|
if (options.tracks)
|
|
1612
1736
|
element.setAttribute("tracks", Array.isArray(options.tracks) ? options.tracks.join(" ") : options.tracks);
|
|
1737
|
+
for (const [key, attr, edge] of [
|
|
1738
|
+
["topInset", "top-inset", "top"],
|
|
1739
|
+
["bottomInset", "bottom-inset", "bottom"],
|
|
1740
|
+
["leftInset", "left-inset", "left"],
|
|
1741
|
+
["rightInset", "right-inset", "right"]
|
|
1742
|
+
]) {
|
|
1743
|
+
const hasEdgeInset = Object.prototype.hasOwnProperty.call(options, key);
|
|
1744
|
+
const hasContainerOffset = Object.prototype.hasOwnProperty.call(options, "containerOffset");
|
|
1745
|
+
const attributeValue = combineInsetAttributes(options[key], options.containerOffset?.[edge]);
|
|
1746
|
+
if (attributeValue !== void 0) {
|
|
1747
|
+
element.setAttribute(attr, attributeValue);
|
|
1748
|
+
} else if (hasEdgeInset || hasContainerOffset) {
|
|
1749
|
+
element.removeAttribute(attr);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1613
1752
|
for (const [key, attr] of [
|
|
1753
|
+
["detached", "detached"],
|
|
1614
1754
|
["swipe", "swipe"],
|
|
1615
1755
|
["swipeDismissal", "swipe-dismissal"],
|
|
1616
1756
|
["swipeOvershoot", "swipe-overshoot"],
|
|
@@ -1629,6 +1769,7 @@ function applySheetOptions(element, options) {
|
|
|
1629
1769
|
if (options.themeColorDimming !== void 0) {
|
|
1630
1770
|
element.setAttribute("theme-color-dimming", options.themeColorDimming === false ? "false" : "auto");
|
|
1631
1771
|
}
|
|
1772
|
+
if (options.presented !== void 0) element.toggleAttribute("presented", options.presented);
|
|
1632
1773
|
}
|
|
1633
1774
|
|
|
1634
1775
|
// src/components/sheet-actions.ts
|