@surdeddd/bottom-sheet 0.21.2 → 0.22.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 +32 -0
- package/dist/{BottomSheetCore-CK_mq14p.d.ts → BottomSheetCore-9i-Uh6T3.d.ts} +4 -1
- package/dist/{BottomSheetCore-BHv6LPmS.d.cts → BottomSheetCore-CQStdVy2.d.cts} +4 -1
- package/dist/{BottomSheetEngine-mmFzIK1Z.d.cts → BottomSheetEngine-CsQWHLNb.d.cts} +1 -1
- package/dist/{BottomSheetEngine-wLn6Q2kA.d.ts → BottomSheetEngine-Dn6h-7gF.d.ts} +1 -1
- package/dist/core.cjs +9 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +9 -1
- package/dist/debug.d.cts +1 -1
- package/dist/debug.d.ts +1 -1
- package/dist/default-features-C3cilcW9.d.ts +11 -0
- package/dist/default-features-DkG9aho0.d.cts +11 -0
- package/dist/element.cjs +84 -4
- package/dist/element.d.cts +2 -2
- package/dist/element.d.ts +2 -2
- package/dist/element.iife.global.js +2 -2
- package/dist/element.js +84 -4
- package/dist/features.cjs +65 -1
- package/dist/features.d.cts +5 -10
- package/dist/features.d.ts +5 -10
- package/dist/features.js +65 -2
- package/dist/{index-juAyT76E.d.cts → index-CVGC5B5D.d.cts} +1 -1
- package/dist/{index-CWKv1Xy4.d.ts → index-CnsJQZp2.d.ts} +1 -1
- package/dist/index.cjs +73 -2
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +73 -2
- 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/preact.d.cts +2 -2
- package/dist/preact.d.ts +2 -2
- package/dist/qwik-lib/index.qwik.cjs +67 -2
- package/dist/qwik-lib/index.qwik.mjs +67 -2
- package/dist/qwik.cjs +74 -2
- package/dist/qwik.d.cts +3 -2
- package/dist/qwik.d.ts +3 -2
- package/dist/qwik.js +74 -2
- package/dist/react.cjs +73 -2
- package/dist/react.d.cts +3 -3
- package/dist/react.d.ts +3 -3
- package/dist/react.js +73 -2
- package/dist/solid.cjs +74 -2
- package/dist/solid.d.cts +4 -0
- package/dist/solid.d.ts +4 -0
- package/dist/solid.js +74 -2
- package/dist/solid.source.jsx +74 -2
- package/dist/styles.css +11 -0
- package/dist/svelte-core.cjs +73 -2
- package/dist/svelte-core.js +73 -2
- package/dist/svelte-src/BottomSheet.svelte +3 -0
- package/dist/svelte.cjs +74 -2
- package/dist/svelte.d.cts +1 -0
- package/dist/svelte.d.ts +1 -0
- package/dist/svelte.js +74 -2
- package/dist/vue.cjs +77 -2
- package/dist/vue.js +77 -2
- package/dist/webgl.d.cts +1 -1
- package/dist/webgl.d.ts +1 -1
- package/package.json +9 -9
package/dist/react.cjs
CHANGED
|
@@ -2614,6 +2614,7 @@ var BottomSheetCore = class {
|
|
|
2614
2614
|
__publicField(this, "lifecycle");
|
|
2615
2615
|
__publicField(this, "closeOnBack");
|
|
2616
2616
|
__publicField(this, "routedTo");
|
|
2617
|
+
__publicField(this, "fitContentToSnap");
|
|
2617
2618
|
__publicField(this, "persistent");
|
|
2618
2619
|
__publicField(this, "disableCloseFlag");
|
|
2619
2620
|
__publicField(this, "disableDragFlag");
|
|
@@ -2727,6 +2728,7 @@ var BottomSheetCore = class {
|
|
|
2727
2728
|
);
|
|
2728
2729
|
this.closeOnBack = resolved.closeOnBack;
|
|
2729
2730
|
this.routedTo = opts.routedTo;
|
|
2731
|
+
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2730
2732
|
this.persistent = resolved.persistent;
|
|
2731
2733
|
this.disableCloseFlag = resolved.disableClose;
|
|
2732
2734
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2828,7 +2830,8 @@ var BottomSheetCore = class {
|
|
|
2828
2830
|
closeOnBack: this.closeOnBack,
|
|
2829
2831
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2830
2832
|
persistKey: this.persistKey,
|
|
2831
|
-
autoCollapseAfter
|
|
2833
|
+
autoCollapseAfter,
|
|
2834
|
+
fitContentToSnap: this.fitContentToSnap
|
|
2832
2835
|
},
|
|
2833
2836
|
isDestroyed: () => this.destroyed,
|
|
2834
2837
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -2880,6 +2883,11 @@ var BottomSheetCore = class {
|
|
|
2880
2883
|
"[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
|
|
2881
2884
|
);
|
|
2882
2885
|
}
|
|
2886
|
+
if (this.fitContentToSnap && !names.has("content-fit")) {
|
|
2887
|
+
devWarn(
|
|
2888
|
+
"[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
|
|
2889
|
+
);
|
|
2890
|
+
}
|
|
2883
2891
|
if (this.persistKey && !names.has("persist")) {
|
|
2884
2892
|
devWarn(
|
|
2885
2893
|
"[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
|
|
@@ -4237,6 +4245,68 @@ function visualViewportFeature() {
|
|
|
4237
4245
|
};
|
|
4238
4246
|
}
|
|
4239
4247
|
|
|
4248
|
+
// src/core/features/content-fit.ts
|
|
4249
|
+
var INSET_VAR = "--bs-content-inset";
|
|
4250
|
+
var FIT_ATTR = "data-bs-fit-content";
|
|
4251
|
+
function contentFitFeature() {
|
|
4252
|
+
return {
|
|
4253
|
+
name: "content-fit",
|
|
4254
|
+
install: (ctx) => {
|
|
4255
|
+
const scroller = ctx.scrollContainer;
|
|
4256
|
+
if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
|
|
4257
|
+
return;
|
|
4258
|
+
}
|
|
4259
|
+
const sheet = ctx.element;
|
|
4260
|
+
let inset = 0;
|
|
4261
|
+
let unpaddedMax = -1;
|
|
4262
|
+
let top = 0;
|
|
4263
|
+
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4264
|
+
const follow = (size) => {
|
|
4265
|
+
if (unpaddedMax < 0) {
|
|
4266
|
+
unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
|
|
4267
|
+
top = scroller.scrollTop;
|
|
4268
|
+
}
|
|
4269
|
+
const limit = Math.max(0, unpaddedMax + hiddenAt(size));
|
|
4270
|
+
if (top > limit) {
|
|
4271
|
+
if (scroller.scrollTop > limit) scroller.scrollTop = limit;
|
|
4272
|
+
top = limit;
|
|
4273
|
+
}
|
|
4274
|
+
};
|
|
4275
|
+
const settle = () => {
|
|
4276
|
+
if (ctx.isDestroyed()) return;
|
|
4277
|
+
const size = ctx.getSize();
|
|
4278
|
+
unpaddedMax = -1;
|
|
4279
|
+
follow(size);
|
|
4280
|
+
inset = hiddenAt(size);
|
|
4281
|
+
sheet.style.setProperty(INSET_VAR, `${inset}px`);
|
|
4282
|
+
unpaddedMax = -1;
|
|
4283
|
+
};
|
|
4284
|
+
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4285
|
+
const whenIdle = () => {
|
|
4286
|
+
if (!moving()) settle();
|
|
4287
|
+
};
|
|
4288
|
+
sheet.setAttribute(FIT_ATTR, "");
|
|
4289
|
+
settle();
|
|
4290
|
+
const offProgress = ctx.on(
|
|
4291
|
+
"progress",
|
|
4292
|
+
(p) => moving() ? follow(p.size) : settle()
|
|
4293
|
+
);
|
|
4294
|
+
const offSnap = ctx.on("snap", settle);
|
|
4295
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4296
|
+
observer?.observe(document.documentElement);
|
|
4297
|
+
window.addEventListener("orientationchange", whenIdle);
|
|
4298
|
+
return () => {
|
|
4299
|
+
offProgress();
|
|
4300
|
+
offSnap();
|
|
4301
|
+
observer?.disconnect();
|
|
4302
|
+
window.removeEventListener("orientationchange", whenIdle);
|
|
4303
|
+
sheet.removeAttribute(FIT_ATTR);
|
|
4304
|
+
sheet.style.removeProperty(INSET_VAR);
|
|
4305
|
+
};
|
|
4306
|
+
}
|
|
4307
|
+
};
|
|
4308
|
+
}
|
|
4309
|
+
|
|
4240
4310
|
// src/core/default-features.ts
|
|
4241
4311
|
function defaultEngineFeatures() {
|
|
4242
4312
|
return [
|
|
@@ -4244,7 +4314,8 @@ function defaultEngineFeatures() {
|
|
|
4244
4314
|
visualViewportFeature(),
|
|
4245
4315
|
persistFeature(),
|
|
4246
4316
|
autoCollapseFeature(),
|
|
4247
|
-
routeFeature()
|
|
4317
|
+
routeFeature(),
|
|
4318
|
+
contentFitFeature()
|
|
4248
4319
|
];
|
|
4249
4320
|
}
|
|
4250
4321
|
|
package/dist/react.d.cts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { g as EngineOptions, d as EngineState, A as AnchorOptions, i as ScrimStagesOptions, u as ScrimStageDef, S as SheetEventMap, C as CloseReason, v as ScrimUpdate, r as ScrimOverlayOptions, e as SnapPointDef, f as SheetMode } from './BottomSheetCore-CQStdVy2.cjs';
|
|
2
|
+
export { h as SnapPoint } from './BottomSheetCore-CQStdVy2.cjs';
|
|
3
3
|
import { OverlayOptions, OverlayState, Overlay as OverlayEngine } from './overlay.cjs';
|
|
4
4
|
export { OverlayEdge } from './overlay.cjs';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { CSSProperties, ReactNode } from 'react';
|
|
7
|
-
import { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
7
|
+
import { B as BottomSheetEngine } from './BottomSheetEngine-CsQWHLNb.cjs';
|
|
8
8
|
import { T as TeleportTarget } from './teleport-7uYNiEAT.cjs';
|
|
9
9
|
import './transform-jVfAikE9.cjs';
|
|
10
10
|
|
package/dist/react.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { g as EngineOptions, d as EngineState, A as AnchorOptions, i as ScrimStagesOptions, u as ScrimStageDef, S as SheetEventMap, C as CloseReason, v as ScrimUpdate, r as ScrimOverlayOptions, e as SnapPointDef, f as SheetMode } from './BottomSheetCore-9i-Uh6T3.js';
|
|
2
|
+
export { h as SnapPoint } from './BottomSheetCore-9i-Uh6T3.js';
|
|
3
3
|
import { OverlayOptions, OverlayState, Overlay as OverlayEngine } from './overlay.js';
|
|
4
4
|
export { OverlayEdge } from './overlay.js';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import { CSSProperties, ReactNode } from 'react';
|
|
7
|
-
import { B as BottomSheetEngine } from './BottomSheetEngine-
|
|
7
|
+
import { B as BottomSheetEngine } from './BottomSheetEngine-Dn6h-7gF.js';
|
|
8
8
|
import { T as TeleportTarget } from './teleport-7uYNiEAT.js';
|
|
9
9
|
import './transform-jVfAikE9.js';
|
|
10
10
|
|
package/dist/react.js
CHANGED
|
@@ -2612,6 +2612,7 @@ var BottomSheetCore = class {
|
|
|
2612
2612
|
__publicField(this, "lifecycle");
|
|
2613
2613
|
__publicField(this, "closeOnBack");
|
|
2614
2614
|
__publicField(this, "routedTo");
|
|
2615
|
+
__publicField(this, "fitContentToSnap");
|
|
2615
2616
|
__publicField(this, "persistent");
|
|
2616
2617
|
__publicField(this, "disableCloseFlag");
|
|
2617
2618
|
__publicField(this, "disableDragFlag");
|
|
@@ -2725,6 +2726,7 @@ var BottomSheetCore = class {
|
|
|
2725
2726
|
);
|
|
2726
2727
|
this.closeOnBack = resolved.closeOnBack;
|
|
2727
2728
|
this.routedTo = opts.routedTo;
|
|
2729
|
+
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2728
2730
|
this.persistent = resolved.persistent;
|
|
2729
2731
|
this.disableCloseFlag = resolved.disableClose;
|
|
2730
2732
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2826,7 +2828,8 @@ var BottomSheetCore = class {
|
|
|
2826
2828
|
closeOnBack: this.closeOnBack,
|
|
2827
2829
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2828
2830
|
persistKey: this.persistKey,
|
|
2829
|
-
autoCollapseAfter
|
|
2831
|
+
autoCollapseAfter,
|
|
2832
|
+
fitContentToSnap: this.fitContentToSnap
|
|
2830
2833
|
},
|
|
2831
2834
|
isDestroyed: () => this.destroyed,
|
|
2832
2835
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -2878,6 +2881,11 @@ var BottomSheetCore = class {
|
|
|
2878
2881
|
"[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
|
|
2879
2882
|
);
|
|
2880
2883
|
}
|
|
2884
|
+
if (this.fitContentToSnap && !names.has("content-fit")) {
|
|
2885
|
+
devWarn(
|
|
2886
|
+
"[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
|
|
2887
|
+
);
|
|
2888
|
+
}
|
|
2881
2889
|
if (this.persistKey && !names.has("persist")) {
|
|
2882
2890
|
devWarn(
|
|
2883
2891
|
"[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
|
|
@@ -4235,6 +4243,68 @@ function visualViewportFeature() {
|
|
|
4235
4243
|
};
|
|
4236
4244
|
}
|
|
4237
4245
|
|
|
4246
|
+
// src/core/features/content-fit.ts
|
|
4247
|
+
var INSET_VAR = "--bs-content-inset";
|
|
4248
|
+
var FIT_ATTR = "data-bs-fit-content";
|
|
4249
|
+
function contentFitFeature() {
|
|
4250
|
+
return {
|
|
4251
|
+
name: "content-fit",
|
|
4252
|
+
install: (ctx) => {
|
|
4253
|
+
const scroller = ctx.scrollContainer;
|
|
4254
|
+
if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
|
|
4255
|
+
return;
|
|
4256
|
+
}
|
|
4257
|
+
const sheet = ctx.element;
|
|
4258
|
+
let inset = 0;
|
|
4259
|
+
let unpaddedMax = -1;
|
|
4260
|
+
let top = 0;
|
|
4261
|
+
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4262
|
+
const follow = (size) => {
|
|
4263
|
+
if (unpaddedMax < 0) {
|
|
4264
|
+
unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
|
|
4265
|
+
top = scroller.scrollTop;
|
|
4266
|
+
}
|
|
4267
|
+
const limit = Math.max(0, unpaddedMax + hiddenAt(size));
|
|
4268
|
+
if (top > limit) {
|
|
4269
|
+
if (scroller.scrollTop > limit) scroller.scrollTop = limit;
|
|
4270
|
+
top = limit;
|
|
4271
|
+
}
|
|
4272
|
+
};
|
|
4273
|
+
const settle = () => {
|
|
4274
|
+
if (ctx.isDestroyed()) return;
|
|
4275
|
+
const size = ctx.getSize();
|
|
4276
|
+
unpaddedMax = -1;
|
|
4277
|
+
follow(size);
|
|
4278
|
+
inset = hiddenAt(size);
|
|
4279
|
+
sheet.style.setProperty(INSET_VAR, `${inset}px`);
|
|
4280
|
+
unpaddedMax = -1;
|
|
4281
|
+
};
|
|
4282
|
+
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4283
|
+
const whenIdle = () => {
|
|
4284
|
+
if (!moving()) settle();
|
|
4285
|
+
};
|
|
4286
|
+
sheet.setAttribute(FIT_ATTR, "");
|
|
4287
|
+
settle();
|
|
4288
|
+
const offProgress = ctx.on(
|
|
4289
|
+
"progress",
|
|
4290
|
+
(p) => moving() ? follow(p.size) : settle()
|
|
4291
|
+
);
|
|
4292
|
+
const offSnap = ctx.on("snap", settle);
|
|
4293
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4294
|
+
observer?.observe(document.documentElement);
|
|
4295
|
+
window.addEventListener("orientationchange", whenIdle);
|
|
4296
|
+
return () => {
|
|
4297
|
+
offProgress();
|
|
4298
|
+
offSnap();
|
|
4299
|
+
observer?.disconnect();
|
|
4300
|
+
window.removeEventListener("orientationchange", whenIdle);
|
|
4301
|
+
sheet.removeAttribute(FIT_ATTR);
|
|
4302
|
+
sheet.style.removeProperty(INSET_VAR);
|
|
4303
|
+
};
|
|
4304
|
+
}
|
|
4305
|
+
};
|
|
4306
|
+
}
|
|
4307
|
+
|
|
4238
4308
|
// src/core/default-features.ts
|
|
4239
4309
|
function defaultEngineFeatures() {
|
|
4240
4310
|
return [
|
|
@@ -4242,7 +4312,8 @@ function defaultEngineFeatures() {
|
|
|
4242
4312
|
visualViewportFeature(),
|
|
4243
4313
|
persistFeature(),
|
|
4244
4314
|
autoCollapseFeature(),
|
|
4245
|
-
routeFeature()
|
|
4315
|
+
routeFeature(),
|
|
4316
|
+
contentFitFeature()
|
|
4246
4317
|
];
|
|
4247
4318
|
}
|
|
4248
4319
|
|
package/dist/solid.cjs
CHANGED
|
@@ -2607,6 +2607,7 @@ var BottomSheetCore = class {
|
|
|
2607
2607
|
__publicField(this, "lifecycle");
|
|
2608
2608
|
__publicField(this, "closeOnBack");
|
|
2609
2609
|
__publicField(this, "routedTo");
|
|
2610
|
+
__publicField(this, "fitContentToSnap");
|
|
2610
2611
|
__publicField(this, "persistent");
|
|
2611
2612
|
__publicField(this, "disableCloseFlag");
|
|
2612
2613
|
__publicField(this, "disableDragFlag");
|
|
@@ -2720,6 +2721,7 @@ var BottomSheetCore = class {
|
|
|
2720
2721
|
);
|
|
2721
2722
|
this.closeOnBack = resolved.closeOnBack;
|
|
2722
2723
|
this.routedTo = opts.routedTo;
|
|
2724
|
+
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2723
2725
|
this.persistent = resolved.persistent;
|
|
2724
2726
|
this.disableCloseFlag = resolved.disableClose;
|
|
2725
2727
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2821,7 +2823,8 @@ var BottomSheetCore = class {
|
|
|
2821
2823
|
closeOnBack: this.closeOnBack,
|
|
2822
2824
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2823
2825
|
persistKey: this.persistKey,
|
|
2824
|
-
autoCollapseAfter
|
|
2826
|
+
autoCollapseAfter,
|
|
2827
|
+
fitContentToSnap: this.fitContentToSnap
|
|
2825
2828
|
},
|
|
2826
2829
|
isDestroyed: () => this.destroyed,
|
|
2827
2830
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -2873,6 +2876,11 @@ var BottomSheetCore = class {
|
|
|
2873
2876
|
"[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
|
|
2874
2877
|
);
|
|
2875
2878
|
}
|
|
2879
|
+
if (this.fitContentToSnap && !names.has("content-fit")) {
|
|
2880
|
+
devWarn(
|
|
2881
|
+
"[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
|
|
2882
|
+
);
|
|
2883
|
+
}
|
|
2876
2884
|
if (this.persistKey && !names.has("persist")) {
|
|
2877
2885
|
devWarn(
|
|
2878
2886
|
"[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
|
|
@@ -4230,6 +4238,68 @@ function visualViewportFeature() {
|
|
|
4230
4238
|
};
|
|
4231
4239
|
}
|
|
4232
4240
|
|
|
4241
|
+
// src/core/features/content-fit.ts
|
|
4242
|
+
var INSET_VAR = "--bs-content-inset";
|
|
4243
|
+
var FIT_ATTR = "data-bs-fit-content";
|
|
4244
|
+
function contentFitFeature() {
|
|
4245
|
+
return {
|
|
4246
|
+
name: "content-fit",
|
|
4247
|
+
install: (ctx) => {
|
|
4248
|
+
const scroller = ctx.scrollContainer;
|
|
4249
|
+
if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
|
|
4250
|
+
return;
|
|
4251
|
+
}
|
|
4252
|
+
const sheet = ctx.element;
|
|
4253
|
+
let inset = 0;
|
|
4254
|
+
let unpaddedMax = -1;
|
|
4255
|
+
let top = 0;
|
|
4256
|
+
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4257
|
+
const follow = (size) => {
|
|
4258
|
+
if (unpaddedMax < 0) {
|
|
4259
|
+
unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
|
|
4260
|
+
top = scroller.scrollTop;
|
|
4261
|
+
}
|
|
4262
|
+
const limit = Math.max(0, unpaddedMax + hiddenAt(size));
|
|
4263
|
+
if (top > limit) {
|
|
4264
|
+
if (scroller.scrollTop > limit) scroller.scrollTop = limit;
|
|
4265
|
+
top = limit;
|
|
4266
|
+
}
|
|
4267
|
+
};
|
|
4268
|
+
const settle = () => {
|
|
4269
|
+
if (ctx.isDestroyed()) return;
|
|
4270
|
+
const size = ctx.getSize();
|
|
4271
|
+
unpaddedMax = -1;
|
|
4272
|
+
follow(size);
|
|
4273
|
+
inset = hiddenAt(size);
|
|
4274
|
+
sheet.style.setProperty(INSET_VAR, `${inset}px`);
|
|
4275
|
+
unpaddedMax = -1;
|
|
4276
|
+
};
|
|
4277
|
+
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4278
|
+
const whenIdle = () => {
|
|
4279
|
+
if (!moving()) settle();
|
|
4280
|
+
};
|
|
4281
|
+
sheet.setAttribute(FIT_ATTR, "");
|
|
4282
|
+
settle();
|
|
4283
|
+
const offProgress = ctx.on(
|
|
4284
|
+
"progress",
|
|
4285
|
+
(p) => moving() ? follow(p.size) : settle()
|
|
4286
|
+
);
|
|
4287
|
+
const offSnap = ctx.on("snap", settle);
|
|
4288
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4289
|
+
observer?.observe(document.documentElement);
|
|
4290
|
+
window.addEventListener("orientationchange", whenIdle);
|
|
4291
|
+
return () => {
|
|
4292
|
+
offProgress();
|
|
4293
|
+
offSnap();
|
|
4294
|
+
observer?.disconnect();
|
|
4295
|
+
window.removeEventListener("orientationchange", whenIdle);
|
|
4296
|
+
sheet.removeAttribute(FIT_ATTR);
|
|
4297
|
+
sheet.style.removeProperty(INSET_VAR);
|
|
4298
|
+
};
|
|
4299
|
+
}
|
|
4300
|
+
};
|
|
4301
|
+
}
|
|
4302
|
+
|
|
4233
4303
|
// src/core/default-features.ts
|
|
4234
4304
|
function defaultEngineFeatures() {
|
|
4235
4305
|
return [
|
|
@@ -4237,7 +4307,8 @@ function defaultEngineFeatures() {
|
|
|
4237
4307
|
visualViewportFeature(),
|
|
4238
4308
|
persistFeature(),
|
|
4239
4309
|
autoCollapseFeature(),
|
|
4240
|
-
routeFeature()
|
|
4310
|
+
routeFeature(),
|
|
4311
|
+
contentFitFeature()
|
|
4241
4312
|
];
|
|
4242
4313
|
}
|
|
4243
4314
|
|
|
@@ -4333,6 +4404,7 @@ var BottomSheet = (props) => {
|
|
|
4333
4404
|
disableDrag: props.disableDrag,
|
|
4334
4405
|
dragFrom: props.dragFrom,
|
|
4335
4406
|
dragFromContent: props.dragFromContent,
|
|
4407
|
+
fitContentToSnap: props.fitContentToSnap,
|
|
4336
4408
|
closeOnRouteChange: props.closeOnRouteChange,
|
|
4337
4409
|
stackEffect: props.stackEffect,
|
|
4338
4410
|
returnFocusTo: props.returnFocusTo
|
package/dist/solid.d.cts
CHANGED
|
@@ -94,6 +94,7 @@ type EngineOptions = {
|
|
|
94
94
|
dragThreshold?: number;
|
|
95
95
|
dragFrom?: DragFrom;
|
|
96
96
|
dragFromContent?: boolean;
|
|
97
|
+
fitContentToSnap?: boolean;
|
|
97
98
|
rubberBand?: boolean;
|
|
98
99
|
backdropRange?: [number, number];
|
|
99
100
|
screenRange?: [number, number];
|
|
@@ -140,6 +141,7 @@ type EngineFeatureOptions = {
|
|
|
140
141
|
closeOnRouteChange: boolean;
|
|
141
142
|
persistKey?: string;
|
|
142
143
|
autoCollapseAfter?: number;
|
|
144
|
+
fitContentToSnap: boolean;
|
|
143
145
|
};
|
|
144
146
|
type EngineFeatureContext = {
|
|
145
147
|
element: HTMLElement;
|
|
@@ -262,6 +264,7 @@ declare class BottomSheetCore {
|
|
|
262
264
|
private lifecycle;
|
|
263
265
|
private closeOnBack;
|
|
264
266
|
private routedTo;
|
|
267
|
+
private fitContentToSnap;
|
|
265
268
|
private persistent;
|
|
266
269
|
private disableCloseFlag;
|
|
267
270
|
private disableDragFlag;
|
|
@@ -432,6 +435,7 @@ type BottomSheetProps<TId extends string = string> = {
|
|
|
432
435
|
disableDrag?: boolean;
|
|
433
436
|
dragFrom?: EngineOptions["dragFrom"];
|
|
434
437
|
dragFromContent?: boolean;
|
|
438
|
+
fitContentToSnap?: boolean;
|
|
435
439
|
closeOnRouteChange?: boolean;
|
|
436
440
|
stackEffect?: boolean;
|
|
437
441
|
teleport?: boolean;
|
package/dist/solid.d.ts
CHANGED
|
@@ -94,6 +94,7 @@ type EngineOptions = {
|
|
|
94
94
|
dragThreshold?: number;
|
|
95
95
|
dragFrom?: DragFrom;
|
|
96
96
|
dragFromContent?: boolean;
|
|
97
|
+
fitContentToSnap?: boolean;
|
|
97
98
|
rubberBand?: boolean;
|
|
98
99
|
backdropRange?: [number, number];
|
|
99
100
|
screenRange?: [number, number];
|
|
@@ -140,6 +141,7 @@ type EngineFeatureOptions = {
|
|
|
140
141
|
closeOnRouteChange: boolean;
|
|
141
142
|
persistKey?: string;
|
|
142
143
|
autoCollapseAfter?: number;
|
|
144
|
+
fitContentToSnap: boolean;
|
|
143
145
|
};
|
|
144
146
|
type EngineFeatureContext = {
|
|
145
147
|
element: HTMLElement;
|
|
@@ -262,6 +264,7 @@ declare class BottomSheetCore {
|
|
|
262
264
|
private lifecycle;
|
|
263
265
|
private closeOnBack;
|
|
264
266
|
private routedTo;
|
|
267
|
+
private fitContentToSnap;
|
|
265
268
|
private persistent;
|
|
266
269
|
private disableCloseFlag;
|
|
267
270
|
private disableDragFlag;
|
|
@@ -432,6 +435,7 @@ type BottomSheetProps<TId extends string = string> = {
|
|
|
432
435
|
disableDrag?: boolean;
|
|
433
436
|
dragFrom?: EngineOptions["dragFrom"];
|
|
434
437
|
dragFromContent?: boolean;
|
|
438
|
+
fitContentToSnap?: boolean;
|
|
435
439
|
closeOnRouteChange?: boolean;
|
|
436
440
|
stackEffect?: boolean;
|
|
437
441
|
teleport?: boolean;
|
package/dist/solid.js
CHANGED
|
@@ -2605,6 +2605,7 @@ var BottomSheetCore = class {
|
|
|
2605
2605
|
__publicField(this, "lifecycle");
|
|
2606
2606
|
__publicField(this, "closeOnBack");
|
|
2607
2607
|
__publicField(this, "routedTo");
|
|
2608
|
+
__publicField(this, "fitContentToSnap");
|
|
2608
2609
|
__publicField(this, "persistent");
|
|
2609
2610
|
__publicField(this, "disableCloseFlag");
|
|
2610
2611
|
__publicField(this, "disableDragFlag");
|
|
@@ -2718,6 +2719,7 @@ var BottomSheetCore = class {
|
|
|
2718
2719
|
);
|
|
2719
2720
|
this.closeOnBack = resolved.closeOnBack;
|
|
2720
2721
|
this.routedTo = opts.routedTo;
|
|
2722
|
+
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2721
2723
|
this.persistent = resolved.persistent;
|
|
2722
2724
|
this.disableCloseFlag = resolved.disableClose;
|
|
2723
2725
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2819,7 +2821,8 @@ var BottomSheetCore = class {
|
|
|
2819
2821
|
closeOnBack: this.closeOnBack,
|
|
2820
2822
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2821
2823
|
persistKey: this.persistKey,
|
|
2822
|
-
autoCollapseAfter
|
|
2824
|
+
autoCollapseAfter,
|
|
2825
|
+
fitContentToSnap: this.fitContentToSnap
|
|
2823
2826
|
},
|
|
2824
2827
|
isDestroyed: () => this.destroyed,
|
|
2825
2828
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -2871,6 +2874,11 @@ var BottomSheetCore = class {
|
|
|
2871
2874
|
"[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
|
|
2872
2875
|
);
|
|
2873
2876
|
}
|
|
2877
|
+
if (this.fitContentToSnap && !names.has("content-fit")) {
|
|
2878
|
+
devWarn(
|
|
2879
|
+
"[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
|
|
2880
|
+
);
|
|
2881
|
+
}
|
|
2874
2882
|
if (this.persistKey && !names.has("persist")) {
|
|
2875
2883
|
devWarn(
|
|
2876
2884
|
"[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
|
|
@@ -4228,6 +4236,68 @@ function visualViewportFeature() {
|
|
|
4228
4236
|
};
|
|
4229
4237
|
}
|
|
4230
4238
|
|
|
4239
|
+
// src/core/features/content-fit.ts
|
|
4240
|
+
var INSET_VAR = "--bs-content-inset";
|
|
4241
|
+
var FIT_ATTR = "data-bs-fit-content";
|
|
4242
|
+
function contentFitFeature() {
|
|
4243
|
+
return {
|
|
4244
|
+
name: "content-fit",
|
|
4245
|
+
install: (ctx) => {
|
|
4246
|
+
const scroller = ctx.scrollContainer;
|
|
4247
|
+
if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
|
|
4248
|
+
return;
|
|
4249
|
+
}
|
|
4250
|
+
const sheet = ctx.element;
|
|
4251
|
+
let inset = 0;
|
|
4252
|
+
let unpaddedMax = -1;
|
|
4253
|
+
let top = 0;
|
|
4254
|
+
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4255
|
+
const follow = (size) => {
|
|
4256
|
+
if (unpaddedMax < 0) {
|
|
4257
|
+
unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
|
|
4258
|
+
top = scroller.scrollTop;
|
|
4259
|
+
}
|
|
4260
|
+
const limit = Math.max(0, unpaddedMax + hiddenAt(size));
|
|
4261
|
+
if (top > limit) {
|
|
4262
|
+
if (scroller.scrollTop > limit) scroller.scrollTop = limit;
|
|
4263
|
+
top = limit;
|
|
4264
|
+
}
|
|
4265
|
+
};
|
|
4266
|
+
const settle = () => {
|
|
4267
|
+
if (ctx.isDestroyed()) return;
|
|
4268
|
+
const size = ctx.getSize();
|
|
4269
|
+
unpaddedMax = -1;
|
|
4270
|
+
follow(size);
|
|
4271
|
+
inset = hiddenAt(size);
|
|
4272
|
+
sheet.style.setProperty(INSET_VAR, `${inset}px`);
|
|
4273
|
+
unpaddedMax = -1;
|
|
4274
|
+
};
|
|
4275
|
+
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4276
|
+
const whenIdle = () => {
|
|
4277
|
+
if (!moving()) settle();
|
|
4278
|
+
};
|
|
4279
|
+
sheet.setAttribute(FIT_ATTR, "");
|
|
4280
|
+
settle();
|
|
4281
|
+
const offProgress = ctx.on(
|
|
4282
|
+
"progress",
|
|
4283
|
+
(p) => moving() ? follow(p.size) : settle()
|
|
4284
|
+
);
|
|
4285
|
+
const offSnap = ctx.on("snap", settle);
|
|
4286
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4287
|
+
observer?.observe(document.documentElement);
|
|
4288
|
+
window.addEventListener("orientationchange", whenIdle);
|
|
4289
|
+
return () => {
|
|
4290
|
+
offProgress();
|
|
4291
|
+
offSnap();
|
|
4292
|
+
observer?.disconnect();
|
|
4293
|
+
window.removeEventListener("orientationchange", whenIdle);
|
|
4294
|
+
sheet.removeAttribute(FIT_ATTR);
|
|
4295
|
+
sheet.style.removeProperty(INSET_VAR);
|
|
4296
|
+
};
|
|
4297
|
+
}
|
|
4298
|
+
};
|
|
4299
|
+
}
|
|
4300
|
+
|
|
4231
4301
|
// src/core/default-features.ts
|
|
4232
4302
|
function defaultEngineFeatures() {
|
|
4233
4303
|
return [
|
|
@@ -4235,7 +4305,8 @@ function defaultEngineFeatures() {
|
|
|
4235
4305
|
visualViewportFeature(),
|
|
4236
4306
|
persistFeature(),
|
|
4237
4307
|
autoCollapseFeature(),
|
|
4238
|
-
routeFeature()
|
|
4308
|
+
routeFeature(),
|
|
4309
|
+
contentFitFeature()
|
|
4239
4310
|
];
|
|
4240
4311
|
}
|
|
4241
4312
|
|
|
@@ -4331,6 +4402,7 @@ var BottomSheet = (props) => {
|
|
|
4331
4402
|
disableDrag: props.disableDrag,
|
|
4332
4403
|
dragFrom: props.dragFrom,
|
|
4333
4404
|
dragFromContent: props.dragFromContent,
|
|
4405
|
+
fitContentToSnap: props.fitContentToSnap,
|
|
4334
4406
|
closeOnRouteChange: props.closeOnRouteChange,
|
|
4335
4407
|
stackEffect: props.stackEffect,
|
|
4336
4408
|
returnFocusTo: props.returnFocusTo
|
package/dist/solid.source.jsx
CHANGED
|
@@ -2606,6 +2606,7 @@ var BottomSheetCore = class {
|
|
|
2606
2606
|
lifecycle;
|
|
2607
2607
|
closeOnBack;
|
|
2608
2608
|
routedTo;
|
|
2609
|
+
fitContentToSnap;
|
|
2609
2610
|
persistent;
|
|
2610
2611
|
disableCloseFlag;
|
|
2611
2612
|
disableDragFlag;
|
|
@@ -2720,6 +2721,7 @@ var BottomSheetCore = class {
|
|
|
2720
2721
|
);
|
|
2721
2722
|
this.closeOnBack = resolved.closeOnBack;
|
|
2722
2723
|
this.routedTo = opts.routedTo;
|
|
2724
|
+
this.fitContentToSnap = opts.fitContentToSnap === true;
|
|
2723
2725
|
this.persistent = resolved.persistent;
|
|
2724
2726
|
this.disableCloseFlag = resolved.disableClose;
|
|
2725
2727
|
this.disableDragFlag = resolved.disableDrag;
|
|
@@ -2821,7 +2823,8 @@ var BottomSheetCore = class {
|
|
|
2821
2823
|
closeOnBack: this.closeOnBack,
|
|
2822
2824
|
closeOnRouteChange: this.closeOnRouteChange,
|
|
2823
2825
|
persistKey: this.persistKey,
|
|
2824
|
-
autoCollapseAfter
|
|
2826
|
+
autoCollapseAfter,
|
|
2827
|
+
fitContentToSnap: this.fitContentToSnap
|
|
2825
2828
|
},
|
|
2826
2829
|
isDestroyed: () => this.destroyed,
|
|
2827
2830
|
isDragging: () => this.isDraggingAny(),
|
|
@@ -2873,6 +2876,11 @@ var BottomSheetCore = class {
|
|
|
2873
2876
|
"[BottomSheet] closeOnBack/routedTo/closeOnRouteChange need routeFeature() \u2014 option ignored"
|
|
2874
2877
|
);
|
|
2875
2878
|
}
|
|
2879
|
+
if (this.fitContentToSnap && !names.has("content-fit")) {
|
|
2880
|
+
devWarn(
|
|
2881
|
+
"[BottomSheet] fitContentToSnap needs contentFitFeature() \u2014 option ignored"
|
|
2882
|
+
);
|
|
2883
|
+
}
|
|
2876
2884
|
if (this.persistKey && !names.has("persist")) {
|
|
2877
2885
|
devWarn(
|
|
2878
2886
|
"[BottomSheet] persistKey needs persistFeature() \u2014 snaps will not be saved"
|
|
@@ -4230,6 +4238,68 @@ function visualViewportFeature() {
|
|
|
4230
4238
|
};
|
|
4231
4239
|
}
|
|
4232
4240
|
|
|
4241
|
+
// src/core/features/content-fit.ts
|
|
4242
|
+
var INSET_VAR = "--bs-content-inset";
|
|
4243
|
+
var FIT_ATTR = "data-bs-fit-content";
|
|
4244
|
+
function contentFitFeature() {
|
|
4245
|
+
return {
|
|
4246
|
+
name: "content-fit",
|
|
4247
|
+
install: (ctx) => {
|
|
4248
|
+
const scroller = ctx.scrollContainer;
|
|
4249
|
+
if (!ctx.options.fitContentToSnap || !scroller || typeof window === "undefined") {
|
|
4250
|
+
return;
|
|
4251
|
+
}
|
|
4252
|
+
const sheet = ctx.element;
|
|
4253
|
+
let inset = 0;
|
|
4254
|
+
let unpaddedMax = -1;
|
|
4255
|
+
let top = 0;
|
|
4256
|
+
const hiddenAt = (size) => sheet.dataset.mode === "bottom" ? Math.max(0, ctx.getMaxAxisSize() - size) : 0;
|
|
4257
|
+
const follow = (size) => {
|
|
4258
|
+
if (unpaddedMax < 0) {
|
|
4259
|
+
unpaddedMax = scroller.scrollHeight - scroller.clientHeight - inset;
|
|
4260
|
+
top = scroller.scrollTop;
|
|
4261
|
+
}
|
|
4262
|
+
const limit = Math.max(0, unpaddedMax + hiddenAt(size));
|
|
4263
|
+
if (top > limit) {
|
|
4264
|
+
if (scroller.scrollTop > limit) scroller.scrollTop = limit;
|
|
4265
|
+
top = limit;
|
|
4266
|
+
}
|
|
4267
|
+
};
|
|
4268
|
+
const settle = () => {
|
|
4269
|
+
if (ctx.isDestroyed()) return;
|
|
4270
|
+
const size = ctx.getSize();
|
|
4271
|
+
unpaddedMax = -1;
|
|
4272
|
+
follow(size);
|
|
4273
|
+
inset = hiddenAt(size);
|
|
4274
|
+
sheet.style.setProperty(INSET_VAR, `${inset}px`);
|
|
4275
|
+
unpaddedMax = -1;
|
|
4276
|
+
};
|
|
4277
|
+
const moving = () => ctx.isAnimating() || ctx.isDragging();
|
|
4278
|
+
const whenIdle = () => {
|
|
4279
|
+
if (!moving()) settle();
|
|
4280
|
+
};
|
|
4281
|
+
sheet.setAttribute(FIT_ATTR, "");
|
|
4282
|
+
settle();
|
|
4283
|
+
const offProgress = ctx.on(
|
|
4284
|
+
"progress",
|
|
4285
|
+
(p) => moving() ? follow(p.size) : settle()
|
|
4286
|
+
);
|
|
4287
|
+
const offSnap = ctx.on("snap", settle);
|
|
4288
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(whenIdle);
|
|
4289
|
+
observer?.observe(document.documentElement);
|
|
4290
|
+
window.addEventListener("orientationchange", whenIdle);
|
|
4291
|
+
return () => {
|
|
4292
|
+
offProgress();
|
|
4293
|
+
offSnap();
|
|
4294
|
+
observer?.disconnect();
|
|
4295
|
+
window.removeEventListener("orientationchange", whenIdle);
|
|
4296
|
+
sheet.removeAttribute(FIT_ATTR);
|
|
4297
|
+
sheet.style.removeProperty(INSET_VAR);
|
|
4298
|
+
};
|
|
4299
|
+
}
|
|
4300
|
+
};
|
|
4301
|
+
}
|
|
4302
|
+
|
|
4233
4303
|
// src/core/default-features.ts
|
|
4234
4304
|
function defaultEngineFeatures() {
|
|
4235
4305
|
return [
|
|
@@ -4237,7 +4307,8 @@ function defaultEngineFeatures() {
|
|
|
4237
4307
|
visualViewportFeature(),
|
|
4238
4308
|
persistFeature(),
|
|
4239
4309
|
autoCollapseFeature(),
|
|
4240
|
-
routeFeature()
|
|
4310
|
+
routeFeature(),
|
|
4311
|
+
contentFitFeature()
|
|
4241
4312
|
];
|
|
4242
4313
|
}
|
|
4243
4314
|
|
|
@@ -4327,6 +4398,7 @@ var BottomSheet = (props) => {
|
|
|
4327
4398
|
disableDrag: props.disableDrag,
|
|
4328
4399
|
dragFrom: props.dragFrom,
|
|
4329
4400
|
dragFromContent: props.dragFromContent,
|
|
4401
|
+
fitContentToSnap: props.fitContentToSnap,
|
|
4330
4402
|
closeOnRouteChange: props.closeOnRouteChange,
|
|
4331
4403
|
stackEffect: props.stackEffect,
|
|
4332
4404
|
returnFocusTo: props.returnFocusTo
|