@surdeddd/bottom-sheet 0.7.0 → 0.8.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/dist/vue.js CHANGED
@@ -2357,6 +2357,7 @@ var BottomSheetEngine = class {
2357
2357
  __publicField(this, "progressWriteSentinel", new WriteSentinel());
2358
2358
  __publicField(this, "isTopSheet", true);
2359
2359
  __publicField(this, "opening", false);
2360
+ __publicField(this, "allowOvershoot", false);
2360
2361
  __publicField(this, "progressPayload", {
2361
2362
  value: 0,
2362
2363
  size: 0
@@ -2909,40 +2910,32 @@ var BottomSheetEngine = class {
2909
2910
  }
2910
2911
  return out;
2911
2912
  }
2912
- measureContentExtent(vertical) {
2913
+ measureSheetNatural(vertical) {
2914
+ const el = this.element;
2913
2915
  const content = this.scrollContainer;
2914
- if (!content) return 0;
2915
- const targets = this.contentTargets();
2916
- if (targets.length === 0) {
2917
- return vertical ? content.scrollHeight : content.scrollWidth;
2916
+ if (!content) {
2917
+ return vertical ? el.offsetHeight : el.offsetWidth;
2918
2918
  }
2919
- let min = Infinity;
2920
- let max = -Infinity;
2921
- for (const el of targets) {
2922
- const r = el.getBoundingClientRect();
2923
- if (vertical) {
2924
- if (r.top < min) min = r.top;
2925
- if (r.bottom > max) max = r.bottom;
2926
- } else {
2927
- if (r.left < min) min = r.left;
2928
- if (r.right > max) max = r.right;
2929
- }
2930
- }
2931
- if (!isFinite(min) || !isFinite(max) || max <= min) {
2932
- return vertical ? content.scrollHeight : content.scrollWidth;
2933
- }
2934
- let pad = 0;
2935
- if (typeof getComputedStyle !== "undefined") {
2936
- const cs = getComputedStyle(content);
2937
- pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
2938
- }
2939
- return max - min + pad;
2919
+ const axis = vertical ? "height" : "width";
2920
+ const sheetStyle = el.style;
2921
+ const cs = content.style;
2922
+ const prevSheet = sheetStyle[axis];
2923
+ const prevFlex = cs.flex;
2924
+ const prevContent = vertical ? cs.height : cs.width;
2925
+ sheetStyle[axis] = "auto";
2926
+ cs.flex = "none";
2927
+ if (vertical) cs.height = "auto";
2928
+ else cs.width = "auto";
2929
+ const natural = vertical ? el.offsetHeight : el.offsetWidth;
2930
+ sheetStyle[axis] = prevSheet;
2931
+ cs.flex = prevFlex;
2932
+ if (vertical) cs.height = prevContent;
2933
+ else cs.width = prevContent;
2934
+ return natural;
2940
2935
  }
2941
2936
  measureFitSize() {
2942
2937
  const vertical = layoutAxis(this.mode) === "height";
2943
- const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
2944
- const content = this.scrollContainer;
2945
- const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
2938
+ const natural = this.measureSheetNatural(vertical);
2946
2939
  const capped = this.maxHeightCap !== void 0 ? Math.min(natural, this.maxHeightCap) : natural;
2947
2940
  if (typeof window === "undefined") return capped;
2948
2941
  const viewport = vertical ? window.innerHeight : window.innerWidth;
@@ -3028,6 +3021,10 @@ var BottomSheetEngine = class {
3028
3021
  this.backdrop.style.opacity = "";
3029
3022
  this.backdrop.style.pointerEvents = "";
3030
3023
  }
3024
+ if (this.anchorHost) {
3025
+ this.anchorHost.style.removeProperty("--bs-size");
3026
+ this.anchorHost.style.removeProperty("--bs-progress");
3027
+ }
3031
3028
  if (this.screenComponent) {
3032
3029
  this.screenComponent.style.opacity = "";
3033
3030
  this.screenComponent.style.display = "";
@@ -3039,6 +3036,7 @@ var BottomSheetEngine = class {
3039
3036
  this.bus.emit(event, payload);
3040
3037
  }
3041
3038
  newCycle() {
3039
+ this.allowOvershoot = false;
3042
3040
  this.currentAbort.abort();
3043
3041
  this.currentAbort = new AbortController();
3044
3042
  return this.currentAbort.signal;
@@ -3104,6 +3102,7 @@ var BottomSheetEngine = class {
3104
3102
  seen.add(p.id);
3105
3103
  }
3106
3104
  this.snaps.setRaw(this.snapPointsRaw);
3105
+ this.clampToMaxHeight();
3107
3106
  this.scrim.invalidateOpacityCache();
3108
3107
  }
3109
3108
  getAllowedRange() {
@@ -3310,9 +3309,13 @@ var BottomSheetEngine = class {
3310
3309
  this.opening = true;
3311
3310
  sheetStack.promote(this.id);
3312
3311
  }
3313
- void this.animation.animateTo(target.size, velocity).then(() => {
3314
- this.opening = false;
3312
+ const settleCap = this.snaps.getMaxAxisSize();
3313
+ const settleSize = settleCap > 0 ? Math.min(target.size, settleCap) : target.size;
3314
+ this.allowOvershoot = true;
3315
+ void this.animation.animateTo(settleSize, velocity).then(() => {
3315
3316
  if (signal.aborted) return;
3317
+ this.allowOvershoot = false;
3318
+ this.opening = false;
3316
3319
  this.scrollCache.restore(target.id, previousSize, target.size);
3317
3320
  this.updateAriaSlider();
3318
3321
  this.emit("snap", {
@@ -3344,7 +3347,7 @@ var BottomSheetEngine = class {
3344
3347
  }
3345
3348
  applySize(size) {
3346
3349
  const cap = this.snaps.getMaxAxisSize();
3347
- const clamped = cap > 0 && size > cap && !this.gesture?.isDragging ? cap : size;
3350
+ const clamped = cap > 0 && size > cap && !this.gesture?.isDragging && !this.allowOvershoot ? cap : size;
3348
3351
  this.size = clamped;
3349
3352
  const offset = cap - clamped;
3350
3353
  const style = this.element.style;
@@ -3937,11 +3940,6 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
3937
3940
  const mode = props.mode ?? "bottom";
3938
3941
  return mode === "bottom" || mode === "top";
3939
3942
  });
3940
- const allowedIds = computed(() => props.allowed ?? props.snapPoints.map((p) => p.id));
3941
- const activeIdx = computed(() => {
3942
- const idx = allowedIds.value.indexOf(state.activeId);
3943
- return idx === -1 ? 0 : idx;
3944
- });
3945
3943
  const ariaModal = computed(() => props.focusTrap === true);
3946
3944
  __expose({
3947
3945
  snapTo,
@@ -4011,8 +4009,6 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
4011
4009
  anchorsKey,
4012
4010
  applyStages,
4013
4011
  isVerticalAxis,
4014
- allowedIds,
4015
- activeIdx,
4016
4012
  ariaModal
4017
4013
  };
4018
4014
  Object.defineProperty(__returned__, "__isScriptSetup", {
@@ -4034,12 +4030,7 @@ var _hoisted_3 = [
4034
4030
  "aria-modal",
4035
4031
  "aria-label"
4036
4032
  ];
4037
- var _hoisted_4 = [
4038
- "aria-orientation",
4039
- "aria-valuemax",
4040
- "aria-valuenow",
4041
- "aria-valuetext"
4042
- ];
4033
+ var _hoisted_4 = ["aria-orientation"];
4043
4034
  var _hoisted_5 = {
4044
4035
  key: 0,
4045
4036
  class: "bs-header"
@@ -4102,10 +4093,6 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
4102
4093
  role: "slider",
4103
4094
  tabindex: "0",
4104
4095
  "aria-orientation": $setup.isVerticalAxis ? "vertical" : "horizontal",
4105
- "aria-valuemin": "0",
4106
- "aria-valuemax": Math.max(0, $setup.allowedIds.length - 1),
4107
- "aria-valuenow": $setup.activeIdx,
4108
- "aria-valuetext": $setup.state.activeId,
4109
4096
  "aria-label": "Resize sheet"
4110
4097
  }, null, 8, _hoisted_4),
4111
4098
  _ctx.$slots.header ? (openBlock(), createElementBlock("div", _hoisted_5, [renderSlot(_ctx.$slots, "header", { state: $setup.state })])) : createCommentVNode("v-if", true),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@surdeddd/bottom-sheet",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Universal, headless bottom sheet — framework-agnostic core with React, Vue 3, Svelte, Solid, Qwik, Preact, Lit and Custom Element adapters. Pointer Events, snap points, momentum, a11y, SSR-safe.",
5
5
  "type": "module",
6
6
  "license": "MIT",