@surdeddd/bottom-sheet 0.9.0 → 0.10.0
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 +108 -66
- package/dist/{BottomSheetEngine-CBRcBwV-.d.ts → BottomSheetEngine-DRjCU73e.d.ts} +6 -5
- package/dist/{BottomSheetEngine-BcyruNP1.d.cts → BottomSheetEngine-DzsIwD28.d.cts} +6 -5
- package/dist/element.cjs +161 -99
- package/dist/element.d.cts +1 -1
- package/dist/element.d.ts +1 -1
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +161 -99
- package/dist/index.cjs +155 -115
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +155 -115
- package/dist/integrations/formik.d.cts +1 -1
- package/dist/integrations/formik.d.ts +1 -1
- package/dist/integrations/react-hook-form.d.cts +1 -1
- package/dist/integrations/react-hook-form.d.ts +1 -1
- package/dist/overlay.cjs +34 -25
- package/dist/overlay.d.cts +3 -0
- package/dist/overlay.d.ts +3 -0
- package/dist/overlay.js +34 -25
- package/dist/preact.d.cts +2 -1
- package/dist/preact.d.ts +2 -1
- package/dist/qwik.cjs +179 -93
- package/dist/qwik.d.cts +11 -2
- package/dist/qwik.d.ts +11 -2
- package/dist/qwik.js +179 -93
- package/dist/react.cjs +266 -181
- package/dist/react.d.cts +26 -4
- package/dist/react.d.ts +26 -4
- package/dist/react.js +266 -181
- package/dist/solid.cjs +145 -92
- package/dist/solid.d.cts +14 -4
- package/dist/solid.d.ts +14 -4
- package/dist/solid.js +145 -92
- package/dist/solid.source.jsx +145 -92
- package/dist/styles.css +17 -1
- package/dist/svelte-core.cjs +128 -90
- package/dist/svelte-core.js +128 -90
- package/dist/svelte-src/BottomSheet.svelte +6 -0
- package/dist/svelte.cjs +130 -90
- package/dist/svelte.d.cts +2 -0
- package/dist/svelte.d.ts +2 -0
- package/dist/svelte.js +130 -90
- package/dist/teleport-7uYNiEAT.d.cts +3 -0
- package/dist/teleport-7uYNiEAT.d.ts +3 -0
- package/dist/vue.cjs +136 -91
- package/dist/vue.d.cts +3 -1
- package/dist/vue.d.ts +3 -1
- package/dist/vue.js +136 -91
- package/package.json +6 -6
package/dist/solid.cjs
CHANGED
|
@@ -186,11 +186,18 @@ var resolveSnap = (point, mode, measureFit) => {
|
|
|
186
186
|
return Math.max(0, el.getBoundingClientRect().width);
|
|
187
187
|
};
|
|
188
188
|
|
|
189
|
+
// src/core/primitives/devWarn.ts
|
|
190
|
+
function devWarn(...args) {
|
|
191
|
+
if (typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" && typeof console !== "undefined") {
|
|
192
|
+
console.warn(...args);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
189
196
|
// src/core/primitives/snap-points.ts
|
|
190
197
|
var resolveSnapList = (points, mode, measureFit) => points.map((p) => {
|
|
191
198
|
const raw = resolveSnap(p.size, mode, measureFit);
|
|
192
199
|
if (!Number.isFinite(raw) || raw < 0) {
|
|
193
|
-
|
|
200
|
+
devWarn(
|
|
194
201
|
`[BottomSheet] snap "${p.id}" resolved to invalid size (${String(p.size)} \u2192 ${raw}); clamped to 0.`
|
|
195
202
|
);
|
|
196
203
|
return { id: p.id, size: 0 };
|
|
@@ -202,7 +209,7 @@ var auditVhUsage = (points) => {
|
|
|
202
209
|
for (const p of points) {
|
|
203
210
|
if (typeof p.size !== "string") continue;
|
|
204
211
|
if (!VH_NOT_DVH.test(p.size)) continue;
|
|
205
|
-
|
|
212
|
+
devWarn(
|
|
206
213
|
`[BottomSheet] snap "${p.id}" uses "vh" \u2014 prefer "dvh" on mobile (iOS Safari URL bar makes vh unstable). See https://web.dev/blog/viewport-units`
|
|
207
214
|
);
|
|
208
215
|
}
|
|
@@ -256,6 +263,26 @@ var findDragSettleTarget = (input) => {
|
|
|
256
263
|
);
|
|
257
264
|
};
|
|
258
265
|
|
|
266
|
+
// src/core/primitives/cancelable-emit.ts
|
|
267
|
+
function emitCancelable(emit, base, warnLabel) {
|
|
268
|
+
let cancelled = false;
|
|
269
|
+
let frozen = false;
|
|
270
|
+
emit({
|
|
271
|
+
...base,
|
|
272
|
+
cancel: () => {
|
|
273
|
+
if (frozen) {
|
|
274
|
+
devWarn(
|
|
275
|
+
`[BottomSheet] ${warnLabel}.cancel() called asynchronously \u2014 ignored. cancel() must be invoked synchronously inside the listener.`
|
|
276
|
+
);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
cancelled = true;
|
|
280
|
+
}
|
|
281
|
+
});
|
|
282
|
+
frozen = true;
|
|
283
|
+
return cancelled;
|
|
284
|
+
}
|
|
285
|
+
|
|
259
286
|
// src/core/primitives/snap-resolver.ts
|
|
260
287
|
var SnapResolver = class {
|
|
261
288
|
constructor(raw, allowed, mode, measureFit, onMaxAxisSizeChange) {
|
|
@@ -400,7 +427,9 @@ function notifyLinkedSheets(sheets, self) {
|
|
|
400
427
|
try {
|
|
401
428
|
if (linked.state.size === 0) continue;
|
|
402
429
|
const ids = linked.getAllowedIds();
|
|
403
|
-
const
|
|
430
|
+
const resolved = linked.getResolvedSnaps();
|
|
431
|
+
const sizeOf = (id) => resolved.find((s) => s.id === id)?.size ?? 0;
|
|
432
|
+
const target = ids.find((id) => sizeOf(id) > 0);
|
|
404
433
|
if (target && target !== linked.state.activeId) {
|
|
405
434
|
void linked.snapTo(target);
|
|
406
435
|
}
|
|
@@ -617,11 +646,15 @@ function installVisualViewport(deps) {
|
|
|
617
646
|
if (clamp < deps.getMaxAxisSize()) {
|
|
618
647
|
deps.setMaxAxisSize(clamp);
|
|
619
648
|
}
|
|
649
|
+
const wasAnimating = deps.isAnimating?.() ?? false;
|
|
650
|
+
deps.cancelInFlight();
|
|
651
|
+
deps.newCycle();
|
|
620
652
|
const max = deps.getMaxAxisSize();
|
|
621
653
|
deps.setSize(Math.min(deps.getSize(), max));
|
|
622
654
|
const current = deps.resolveActiveSnap();
|
|
623
655
|
if (current && !deps.isDragging()) {
|
|
624
656
|
deps.applySize(Math.min(current.size, max));
|
|
657
|
+
if (wasAnimating) deps.resyncAfterCancel?.();
|
|
625
658
|
} else {
|
|
626
659
|
deps.applySize(deps.getSize());
|
|
627
660
|
}
|
|
@@ -762,6 +795,54 @@ function installFitObserver(deps) {
|
|
|
762
795
|
};
|
|
763
796
|
}
|
|
764
797
|
|
|
798
|
+
// src/core/features/max-height-controller.ts
|
|
799
|
+
function createMaxHeightController(deps) {
|
|
800
|
+
let maxHeightCap;
|
|
801
|
+
let maxHeightRaw;
|
|
802
|
+
const resolveCap = () => {
|
|
803
|
+
const raw = maxHeightRaw;
|
|
804
|
+
if (raw === void 0) {
|
|
805
|
+
maxHeightCap = void 0;
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
if (typeof raw === "number") {
|
|
809
|
+
maxHeightCap = raw;
|
|
810
|
+
return;
|
|
811
|
+
}
|
|
812
|
+
if (typeof window === "undefined") return;
|
|
813
|
+
const measured = resolveSnap(raw, deps.mode);
|
|
814
|
+
maxHeightCap = measured > 0 ? measured : void 0;
|
|
815
|
+
};
|
|
816
|
+
const clampTo = () => {
|
|
817
|
+
if (maxHeightCap === void 0) return;
|
|
818
|
+
if (deps.getMaxAxisSize() > maxHeightCap) {
|
|
819
|
+
deps.setMaxAxisSize(maxHeightCap);
|
|
820
|
+
}
|
|
821
|
+
};
|
|
822
|
+
return {
|
|
823
|
+
setRadius(r) {
|
|
824
|
+
deps.element.style.setProperty(
|
|
825
|
+
"--bs-radius",
|
|
826
|
+
typeof r === "number" ? `${r}px` : r
|
|
827
|
+
);
|
|
828
|
+
},
|
|
829
|
+
setMaxHeight(h) {
|
|
830
|
+
const value = typeof h === "number" ? `${h}px` : h;
|
|
831
|
+
const axis = layoutAxis(deps.mode);
|
|
832
|
+
deps.element.style.setProperty(
|
|
833
|
+
axis === "height" ? "max-height" : "max-width",
|
|
834
|
+
value
|
|
835
|
+
);
|
|
836
|
+
maxHeightRaw = h;
|
|
837
|
+
resolveCap();
|
|
838
|
+
deps.recompute();
|
|
839
|
+
},
|
|
840
|
+
resolveCap,
|
|
841
|
+
clampTo,
|
|
842
|
+
getCap: () => maxHeightCap
|
|
843
|
+
};
|
|
844
|
+
}
|
|
845
|
+
|
|
765
846
|
// src/core/features/fit-measurement.ts
|
|
766
847
|
var measureSheetNatural = (element, content, vertical) => {
|
|
767
848
|
if (!content) {
|
|
@@ -893,13 +974,6 @@ var WriteSentinel = class {
|
|
|
893
974
|
}
|
|
894
975
|
};
|
|
895
976
|
|
|
896
|
-
// src/core/primitives/devWarn.ts
|
|
897
|
-
function devWarn(...args) {
|
|
898
|
-
if (typeof process !== "undefined" && process.env && process.env.NODE_ENV !== "production" && typeof console !== "undefined") {
|
|
899
|
-
console.warn(...args);
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
|
|
903
977
|
// src/core/primitives/overlay-position.ts
|
|
904
978
|
function resolveSheetAnchoredStyle(mode, position, inset) {
|
|
905
979
|
const sizeOffset = `calc(var(--bs-size, 0px) + ${inset})`;
|
|
@@ -2545,8 +2619,7 @@ var BottomSheetEngine = class {
|
|
|
2545
2619
|
__publicField(this, "disableCloseFlag");
|
|
2546
2620
|
__publicField(this, "disableDragFlag");
|
|
2547
2621
|
__publicField(this, "closeOnRouteChange");
|
|
2548
|
-
__publicField(this, "
|
|
2549
|
-
__publicField(this, "maxHeightRaw");
|
|
2622
|
+
__publicField(this, "maxHeight");
|
|
2550
2623
|
__publicField(this, "snapPointsRaw");
|
|
2551
2624
|
__publicField(this, "snaps");
|
|
2552
2625
|
__publicField(this, "activeId");
|
|
@@ -2657,11 +2730,20 @@ var BottomSheetEngine = class {
|
|
|
2657
2730
|
auditVhUsage(this.snapPointsRaw);
|
|
2658
2731
|
this.auditDuplicateSnapIds(this.snapPointsRaw);
|
|
2659
2732
|
this.rootEl = this.element.closest(".bs-root");
|
|
2733
|
+
this.maxHeight = createMaxHeightController({
|
|
2734
|
+
element: this.element,
|
|
2735
|
+
mode: this.mode,
|
|
2736
|
+
getMaxAxisSize: () => this.snaps.getMaxAxisSize(),
|
|
2737
|
+
setMaxAxisSize: (size) => {
|
|
2738
|
+
this.snaps.setMaxAxisSize(size);
|
|
2739
|
+
},
|
|
2740
|
+
recompute: () => this.recompute()
|
|
2741
|
+
});
|
|
2660
2742
|
this.fitDeps = {
|
|
2661
2743
|
element: this.element,
|
|
2662
2744
|
scrollContainer: this.scrollContainer,
|
|
2663
2745
|
mode: this.mode,
|
|
2664
|
-
getMaxHeightCap: () => this.
|
|
2746
|
+
getMaxHeightCap: () => this.maxHeight.getCap()
|
|
2665
2747
|
};
|
|
2666
2748
|
this.snaps = new SnapResolver(
|
|
2667
2749
|
this.snapPointsRaw,
|
|
@@ -2772,7 +2854,7 @@ var BottomSheetEngine = class {
|
|
|
2772
2854
|
}
|
|
2773
2855
|
use(plugin) {
|
|
2774
2856
|
if (this.destroyed) {
|
|
2775
|
-
|
|
2857
|
+
devWarn(
|
|
2776
2858
|
`[BottomSheet] use("${plugin.name}") called on destroyed engine \u2014 ignored.`
|
|
2777
2859
|
);
|
|
2778
2860
|
return this;
|
|
@@ -2814,6 +2896,9 @@ var BottomSheetEngine = class {
|
|
|
2814
2896
|
getAllowedIds() {
|
|
2815
2897
|
return this.snaps.getAllowedIds().slice();
|
|
2816
2898
|
}
|
|
2899
|
+
getResolvedSnaps() {
|
|
2900
|
+
return this.snaps.getResolvedSnaps();
|
|
2901
|
+
}
|
|
2817
2902
|
async snapTo(id, velocityOrOpts = 0, _skipBeforeSnap = false) {
|
|
2818
2903
|
if (this.destroyed) return;
|
|
2819
2904
|
const opts = typeof velocityOrOpts === "object" ? velocityOrOpts : { velocity: velocityOrOpts };
|
|
@@ -2822,11 +2907,11 @@ var BottomSheetEngine = class {
|
|
|
2822
2907
|
if (externalSignal?.aborted) return;
|
|
2823
2908
|
const target = this.snaps.findById(id);
|
|
2824
2909
|
if (!target) {
|
|
2825
|
-
|
|
2910
|
+
devWarn(`[BottomSheet] unknown snap id: ${id}`);
|
|
2826
2911
|
return;
|
|
2827
2912
|
}
|
|
2828
2913
|
if (!this.snaps.getAllowedIds().includes(id)) {
|
|
2829
|
-
|
|
2914
|
+
devWarn(`[BottomSheet] snap "${id}" is not in allowed list`);
|
|
2830
2915
|
return;
|
|
2831
2916
|
}
|
|
2832
2917
|
if (!_skipBeforeSnap && this.emitBeforeSnap(target, this.activeId)) {
|
|
@@ -2958,42 +3043,11 @@ var BottomSheetEngine = class {
|
|
|
2958
3043
|
}
|
|
2959
3044
|
setRadius(r) {
|
|
2960
3045
|
if (this.destroyed) return;
|
|
2961
|
-
this.
|
|
2962
|
-
"--bs-radius",
|
|
2963
|
-
typeof r === "number" ? `${r}px` : r
|
|
2964
|
-
);
|
|
3046
|
+
this.maxHeight.setRadius(r);
|
|
2965
3047
|
}
|
|
2966
3048
|
setMaxHeight(h) {
|
|
2967
3049
|
if (this.destroyed) return;
|
|
2968
|
-
|
|
2969
|
-
const axis = layoutAxis(this.mode);
|
|
2970
|
-
this.element.style.setProperty(
|
|
2971
|
-
axis === "height" ? "max-height" : "max-width",
|
|
2972
|
-
value
|
|
2973
|
-
);
|
|
2974
|
-
this.maxHeightRaw = h;
|
|
2975
|
-
this.resolveMaxHeightCap();
|
|
2976
|
-
this.recompute();
|
|
2977
|
-
}
|
|
2978
|
-
resolveMaxHeightCap() {
|
|
2979
|
-
const raw = this.maxHeightRaw;
|
|
2980
|
-
if (raw === void 0) {
|
|
2981
|
-
this.maxHeightCap = void 0;
|
|
2982
|
-
return;
|
|
2983
|
-
}
|
|
2984
|
-
if (typeof raw === "number") {
|
|
2985
|
-
this.maxHeightCap = raw;
|
|
2986
|
-
return;
|
|
2987
|
-
}
|
|
2988
|
-
if (typeof window === "undefined") return;
|
|
2989
|
-
const measured = resolveSnap(raw, this.mode);
|
|
2990
|
-
this.maxHeightCap = measured > 0 ? measured : void 0;
|
|
2991
|
-
}
|
|
2992
|
-
clampToMaxHeight() {
|
|
2993
|
-
if (this.maxHeightCap === void 0) return;
|
|
2994
|
-
if (this.snaps.getMaxAxisSize() > this.maxHeightCap) {
|
|
2995
|
-
this.snaps.setMaxAxisSize(this.maxHeightCap);
|
|
2996
|
-
}
|
|
3050
|
+
this.maxHeight.setMaxHeight(h);
|
|
2997
3051
|
}
|
|
2998
3052
|
setAllowed(ids, snap) {
|
|
2999
3053
|
if (this.destroyed) return;
|
|
@@ -3081,7 +3135,7 @@ var BottomSheetEngine = class {
|
|
|
3081
3135
|
};
|
|
3082
3136
|
const host = this.screenComponent?.parentElement;
|
|
3083
3137
|
if (!host) {
|
|
3084
|
-
|
|
3138
|
+
devWarn(
|
|
3085
3139
|
"[BottomSheet] setScrimStages: no scrim element mounted \u2014 pass `scrim` to the engine first."
|
|
3086
3140
|
);
|
|
3087
3141
|
return () => {
|
|
@@ -3131,9 +3185,9 @@ var BottomSheetEngine = class {
|
|
|
3131
3185
|
}
|
|
3132
3186
|
recompute() {
|
|
3133
3187
|
if (this.destroyed) return;
|
|
3134
|
-
this.
|
|
3188
|
+
this.maxHeight.resolveCap();
|
|
3135
3189
|
this.snaps.recompute();
|
|
3136
|
-
this.
|
|
3190
|
+
this.maxHeight.clampTo();
|
|
3137
3191
|
this.scrim.invalidateOpacityCache();
|
|
3138
3192
|
if (this.gesture?.isDragging) return;
|
|
3139
3193
|
const current = this.snaps.findById(this.activeId);
|
|
@@ -3183,42 +3237,18 @@ var BottomSheetEngine = class {
|
|
|
3183
3237
|
return this.currentAbort.signal;
|
|
3184
3238
|
}
|
|
3185
3239
|
emitBeforeSnap(target, previousId) {
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
previousId,
|
|
3192
|
-
cancel: () => {
|
|
3193
|
-
if (frozen) {
|
|
3194
|
-
console.warn(
|
|
3195
|
-
"[BottomSheet] before-snap.cancel() called asynchronously \u2014 ignored. cancel() must be invoked synchronously inside the listener."
|
|
3196
|
-
);
|
|
3197
|
-
return;
|
|
3198
|
-
}
|
|
3199
|
-
cancelled = true;
|
|
3200
|
-
}
|
|
3201
|
-
});
|
|
3202
|
-
frozen = true;
|
|
3203
|
-
return cancelled;
|
|
3240
|
+
return emitCancelable(
|
|
3241
|
+
(payload) => this.emit("before-snap", payload),
|
|
3242
|
+
{ id: target.id, size: target.size, previousId },
|
|
3243
|
+
"before-snap"
|
|
3244
|
+
);
|
|
3204
3245
|
}
|
|
3205
3246
|
emitBeforeClose(reason) {
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
if (frozen) {
|
|
3212
|
-
console.warn(
|
|
3213
|
-
"[BottomSheet] before-close.cancel() called asynchronously \u2014 ignored. cancel() must be invoked synchronously inside the listener."
|
|
3214
|
-
);
|
|
3215
|
-
return;
|
|
3216
|
-
}
|
|
3217
|
-
cancelled = true;
|
|
3218
|
-
}
|
|
3219
|
-
});
|
|
3220
|
-
frozen = true;
|
|
3221
|
-
return cancelled;
|
|
3247
|
+
return emitCancelable(
|
|
3248
|
+
(payload) => this.emit("before-close", payload),
|
|
3249
|
+
{ reason },
|
|
3250
|
+
"before-close"
|
|
3251
|
+
);
|
|
3222
3252
|
}
|
|
3223
3253
|
applyAutoAriaLabelledBy() {
|
|
3224
3254
|
if (typeof document === "undefined") return;
|
|
@@ -3233,16 +3263,16 @@ var BottomSheetEngine = class {
|
|
|
3233
3263
|
this.element.setAttribute("aria-labelledby", titled.id);
|
|
3234
3264
|
}
|
|
3235
3265
|
recomputeSnaps() {
|
|
3236
|
-
this.
|
|
3266
|
+
this.maxHeight.resolveCap();
|
|
3237
3267
|
this.snaps.setRaw(this.snapPointsRaw);
|
|
3238
|
-
this.
|
|
3268
|
+
this.maxHeight.clampTo();
|
|
3239
3269
|
this.scrim.invalidateOpacityCache();
|
|
3240
3270
|
}
|
|
3241
3271
|
auditDuplicateSnapIds(points) {
|
|
3242
3272
|
const seen = /* @__PURE__ */ new Set();
|
|
3243
3273
|
for (const p of points) {
|
|
3244
3274
|
if (seen.has(p.id)) {
|
|
3245
|
-
|
|
3275
|
+
devWarn(
|
|
3246
3276
|
`[BottomSheet] duplicate snap id "${p.id}" \u2014 only the first occurrence is reachable.`
|
|
3247
3277
|
);
|
|
3248
3278
|
}
|
|
@@ -3409,7 +3439,15 @@ var BottomSheetEngine = class {
|
|
|
3409
3439
|
setSize: (size) => {
|
|
3410
3440
|
this.size = size;
|
|
3411
3441
|
},
|
|
3412
|
-
applySize: (size) => this.applySize(size)
|
|
3442
|
+
applySize: (size) => this.applySize(size),
|
|
3443
|
+
cancelInFlight: () => {
|
|
3444
|
+
this.animation.cancel();
|
|
3445
|
+
},
|
|
3446
|
+
newCycle: () => {
|
|
3447
|
+
this.newCycle();
|
|
3448
|
+
},
|
|
3449
|
+
isAnimating: () => this.animation.isAnimating,
|
|
3450
|
+
resyncAfterCancel: () => this.resyncAfterResize()
|
|
3413
3451
|
}));
|
|
3414
3452
|
}
|
|
3415
3453
|
this.teardowns.add(installSliderKeyboard({
|
|
@@ -3675,8 +3713,23 @@ var BottomSheet = (props) => {
|
|
|
3675
3713
|
props.onSnap?.(payload.id);
|
|
3676
3714
|
});
|
|
3677
3715
|
engine.on("before-snap", (payload) => props.onBeforeSnap?.(payload));
|
|
3678
|
-
engine.on("
|
|
3679
|
-
engine.on("
|
|
3716
|
+
engine.on("before-close", (payload) => props.onBeforeClose?.(payload));
|
|
3717
|
+
engine.on("open", (payload) => props.onOpen?.(payload.id));
|
|
3718
|
+
engine.on("close", () => props.onClose?.());
|
|
3719
|
+
engine.on("opened", (payload) => props.onOpened?.(payload.id));
|
|
3720
|
+
engine.on("closed", () => props.onClosed?.());
|
|
3721
|
+
engine.on("dragstart", (payload) => {
|
|
3722
|
+
sync();
|
|
3723
|
+
props.onDragStart?.(payload);
|
|
3724
|
+
});
|
|
3725
|
+
engine.on("dragend", (payload) => {
|
|
3726
|
+
sync();
|
|
3727
|
+
props.onDragEnd?.(payload);
|
|
3728
|
+
});
|
|
3729
|
+
if (props.onDrag) engine.on("drag", (payload) => props.onDrag?.(payload));
|
|
3730
|
+
if (props.onProgress) {
|
|
3731
|
+
engine.on("progress", (payload) => props.onProgress?.(payload));
|
|
3732
|
+
}
|
|
3680
3733
|
if (props.backdrop !== false && props.closeOnBackdrop !== false && backdropEl) {
|
|
3681
3734
|
const onBackdropClick = () => {
|
|
3682
3735
|
if (engine?.canDismiss()) void engine.close("backdrop");
|
package/dist/solid.d.cts
CHANGED
|
@@ -202,8 +202,7 @@ declare class BottomSheetEngine {
|
|
|
202
202
|
private disableCloseFlag;
|
|
203
203
|
private disableDragFlag;
|
|
204
204
|
private closeOnRouteChange;
|
|
205
|
-
private
|
|
206
|
-
private maxHeightRaw;
|
|
205
|
+
private maxHeight;
|
|
207
206
|
private snapPointsRaw;
|
|
208
207
|
private snaps;
|
|
209
208
|
private activeId;
|
|
@@ -239,6 +238,10 @@ declare class BottomSheetEngine {
|
|
|
239
238
|
use(plugin: Plugin): this;
|
|
240
239
|
setLinkedSheets(sheets: BottomSheetEngine[]): void;
|
|
241
240
|
getAllowedIds(): string[];
|
|
241
|
+
getResolvedSnaps(): readonly {
|
|
242
|
+
id: string;
|
|
243
|
+
size: number;
|
|
244
|
+
}[];
|
|
242
245
|
snapTo(id: string, velocityOrOpts?: number | {
|
|
243
246
|
velocity?: number;
|
|
244
247
|
signal?: AbortSignal;
|
|
@@ -262,8 +265,6 @@ declare class BottomSheetEngine {
|
|
|
262
265
|
collapse(): Promise<void>;
|
|
263
266
|
setRadius(r: string | number): void;
|
|
264
267
|
setMaxHeight(h: string | number): void;
|
|
265
|
-
private resolveMaxHeightCap;
|
|
266
|
-
private clampToMaxHeight;
|
|
267
268
|
setAllowed(ids: string[], snap?: string): void;
|
|
268
269
|
setBackdropRange(range: [number, number]): void;
|
|
269
270
|
setScreenRange(range: [number, number]): void;
|
|
@@ -344,6 +345,15 @@ type BottomSheetProps<TId extends string = string> = {
|
|
|
344
345
|
ariaLabel?: string;
|
|
345
346
|
onSnap?: (id: TId) => void;
|
|
346
347
|
onBeforeSnap?: (payload: SheetEventMap["before-snap"]) => void;
|
|
348
|
+
onBeforeClose?: (payload: SheetEventMap["before-close"]) => void;
|
|
349
|
+
onOpen?: (id: TId) => void;
|
|
350
|
+
onClose?: () => void;
|
|
351
|
+
onOpened?: (id: TId) => void;
|
|
352
|
+
onClosed?: () => void;
|
|
353
|
+
onDragStart?: (payload: SheetEventMap["dragstart"]) => void;
|
|
354
|
+
onDragEnd?: (payload: SheetEventMap["dragend"]) => void;
|
|
355
|
+
onDrag?: (payload: SheetEventMap["drag"]) => void;
|
|
356
|
+
onProgress?: (payload: SheetEventMap["progress"]) => void;
|
|
347
357
|
onChange?: (state: EngineState & {
|
|
348
358
|
activeId: TId;
|
|
349
359
|
}) => void;
|
package/dist/solid.d.ts
CHANGED
|
@@ -202,8 +202,7 @@ declare class BottomSheetEngine {
|
|
|
202
202
|
private disableCloseFlag;
|
|
203
203
|
private disableDragFlag;
|
|
204
204
|
private closeOnRouteChange;
|
|
205
|
-
private
|
|
206
|
-
private maxHeightRaw;
|
|
205
|
+
private maxHeight;
|
|
207
206
|
private snapPointsRaw;
|
|
208
207
|
private snaps;
|
|
209
208
|
private activeId;
|
|
@@ -239,6 +238,10 @@ declare class BottomSheetEngine {
|
|
|
239
238
|
use(plugin: Plugin): this;
|
|
240
239
|
setLinkedSheets(sheets: BottomSheetEngine[]): void;
|
|
241
240
|
getAllowedIds(): string[];
|
|
241
|
+
getResolvedSnaps(): readonly {
|
|
242
|
+
id: string;
|
|
243
|
+
size: number;
|
|
244
|
+
}[];
|
|
242
245
|
snapTo(id: string, velocityOrOpts?: number | {
|
|
243
246
|
velocity?: number;
|
|
244
247
|
signal?: AbortSignal;
|
|
@@ -262,8 +265,6 @@ declare class BottomSheetEngine {
|
|
|
262
265
|
collapse(): Promise<void>;
|
|
263
266
|
setRadius(r: string | number): void;
|
|
264
267
|
setMaxHeight(h: string | number): void;
|
|
265
|
-
private resolveMaxHeightCap;
|
|
266
|
-
private clampToMaxHeight;
|
|
267
268
|
setAllowed(ids: string[], snap?: string): void;
|
|
268
269
|
setBackdropRange(range: [number, number]): void;
|
|
269
270
|
setScreenRange(range: [number, number]): void;
|
|
@@ -344,6 +345,15 @@ type BottomSheetProps<TId extends string = string> = {
|
|
|
344
345
|
ariaLabel?: string;
|
|
345
346
|
onSnap?: (id: TId) => void;
|
|
346
347
|
onBeforeSnap?: (payload: SheetEventMap["before-snap"]) => void;
|
|
348
|
+
onBeforeClose?: (payload: SheetEventMap["before-close"]) => void;
|
|
349
|
+
onOpen?: (id: TId) => void;
|
|
350
|
+
onClose?: () => void;
|
|
351
|
+
onOpened?: (id: TId) => void;
|
|
352
|
+
onClosed?: () => void;
|
|
353
|
+
onDragStart?: (payload: SheetEventMap["dragstart"]) => void;
|
|
354
|
+
onDragEnd?: (payload: SheetEventMap["dragend"]) => void;
|
|
355
|
+
onDrag?: (payload: SheetEventMap["drag"]) => void;
|
|
356
|
+
onProgress?: (payload: SheetEventMap["progress"]) => void;
|
|
347
357
|
onChange?: (state: EngineState & {
|
|
348
358
|
activeId: TId;
|
|
349
359
|
}) => void;
|