@surdeddd/bottom-sheet 0.4.1 → 0.6.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/{BottomSheetEngine-L05jGZvU.d.ts → BottomSheetEngine-BHjKFtnM.d.ts} +2 -0
- package/dist/{BottomSheetEngine-BJrH7qY3.d.cts → BottomSheetEngine-CqiCz64W.d.cts} +2 -0
- package/dist/element.cjs +111 -12
- 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 +111 -12
- package/dist/index.cjs +91 -8
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +91 -8
- 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 +1 -1
- package/dist/preact.d.ts +1 -1
- package/dist/qwik.cjs +94 -10
- package/dist/qwik.d.cts +2 -2
- package/dist/qwik.d.ts +2 -2
- package/dist/qwik.js +94 -10
- package/dist/react.cjs +151 -10
- package/dist/react.d.cts +9 -2
- package/dist/react.d.ts +9 -2
- package/dist/react.js +151 -10
- package/dist/solid.cjs +122 -18
- package/dist/solid.d.cts +3 -0
- package/dist/solid.d.ts +3 -0
- package/dist/solid.js +124 -20
- package/dist/solid.source.jsx +100 -12
- package/dist/styles.css +17 -0
- package/dist/svelte-core.cjs +137 -9
- package/dist/svelte-core.js +137 -9
- package/dist/svelte-src/BottomSheet.svelte +5 -3
- package/dist/svelte.cjs +189 -46
- package/dist/svelte.d.cts +1 -0
- package/dist/svelte.d.ts +1 -0
- package/dist/svelte.js +189 -46
- package/dist/vue.cjs +176 -32
- package/dist/vue.js +176 -32
- package/package.json +1 -1
package/dist/qwik.cjs
CHANGED
|
@@ -2898,11 +2898,54 @@ var BottomSheetEngine = class {
|
|
|
2898
2898
|
this.updateAriaSlider();
|
|
2899
2899
|
}
|
|
2900
2900
|
}
|
|
2901
|
+
contentTargets() {
|
|
2902
|
+
const scroller = this.scrollContainer;
|
|
2903
|
+
if (!scroller) return [];
|
|
2904
|
+
const hasSlot = typeof HTMLSlotElement !== "undefined";
|
|
2905
|
+
const out = [];
|
|
2906
|
+
for (const child of Array.from(scroller.children)) {
|
|
2907
|
+
if (hasSlot && child instanceof HTMLSlotElement) {
|
|
2908
|
+
for (const el of child.assignedElements()) out.push(el);
|
|
2909
|
+
} else {
|
|
2910
|
+
out.push(child);
|
|
2911
|
+
}
|
|
2912
|
+
}
|
|
2913
|
+
return out;
|
|
2914
|
+
}
|
|
2915
|
+
measureContentExtent(vertical) {
|
|
2916
|
+
const content = this.scrollContainer;
|
|
2917
|
+
if (!content) return 0;
|
|
2918
|
+
const targets = this.contentTargets();
|
|
2919
|
+
if (targets.length === 0) {
|
|
2920
|
+
return vertical ? content.scrollHeight : content.scrollWidth;
|
|
2921
|
+
}
|
|
2922
|
+
let min = Infinity;
|
|
2923
|
+
let max = -Infinity;
|
|
2924
|
+
for (const el of targets) {
|
|
2925
|
+
const r = el.getBoundingClientRect();
|
|
2926
|
+
if (vertical) {
|
|
2927
|
+
if (r.top < min) min = r.top;
|
|
2928
|
+
if (r.bottom > max) max = r.bottom;
|
|
2929
|
+
} else {
|
|
2930
|
+
if (r.left < min) min = r.left;
|
|
2931
|
+
if (r.right > max) max = r.right;
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
if (!isFinite(min) || !isFinite(max) || max <= min) {
|
|
2935
|
+
return vertical ? content.scrollHeight : content.scrollWidth;
|
|
2936
|
+
}
|
|
2937
|
+
let pad = 0;
|
|
2938
|
+
if (typeof getComputedStyle !== "undefined") {
|
|
2939
|
+
const cs = getComputedStyle(content);
|
|
2940
|
+
pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
|
|
2941
|
+
}
|
|
2942
|
+
return max - min + pad;
|
|
2943
|
+
}
|
|
2901
2944
|
measureFitSize() {
|
|
2902
2945
|
const vertical = layoutAxis(this.mode) === "height";
|
|
2903
2946
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2904
2947
|
const content = this.scrollContainer;
|
|
2905
|
-
const natural = content ? handleSize + (vertical
|
|
2948
|
+
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2906
2949
|
if (typeof window === "undefined") return natural;
|
|
2907
2950
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2908
2951
|
return viewport > 0 ? Math.min(natural, viewport) : natural;
|
|
@@ -2911,22 +2954,62 @@ var BottomSheetEngine = class {
|
|
|
2911
2954
|
if (typeof ResizeObserver === "undefined") return;
|
|
2912
2955
|
if (!this.snapPointsRaw.some((p) => p.size === "fit" || p.size === "content"))
|
|
2913
2956
|
return;
|
|
2914
|
-
const targets = [this.handle];
|
|
2915
|
-
if (this.scrollContainer && this.scrollContainer !== this.handle) {
|
|
2916
|
-
targets.push(this.scrollContainer);
|
|
2917
|
-
}
|
|
2918
2957
|
let raf = 0;
|
|
2919
|
-
const
|
|
2958
|
+
const schedule = () => {
|
|
2920
2959
|
if (raf) return;
|
|
2921
2960
|
raf = requestAnimationFrame(() => {
|
|
2922
2961
|
raf = 0;
|
|
2923
2962
|
if (this.destroyed || this.gesture?.isDragging) return;
|
|
2924
2963
|
this.recompute();
|
|
2925
2964
|
});
|
|
2926
|
-
}
|
|
2927
|
-
|
|
2965
|
+
};
|
|
2966
|
+
const ro = new ResizeObserver(schedule);
|
|
2967
|
+
ro.observe(this.handle);
|
|
2968
|
+
const scroller = this.scrollContainer;
|
|
2969
|
+
const observed = /* @__PURE__ */ new Set();
|
|
2970
|
+
const slots = /* @__PURE__ */ new Set();
|
|
2971
|
+
const hasSlot = typeof HTMLSlotElement !== "undefined";
|
|
2972
|
+
const onSlotChange = () => resync();
|
|
2973
|
+
const trackSlots = () => {
|
|
2974
|
+
if (!scroller || !hasSlot) return;
|
|
2975
|
+
for (const child of Array.from(scroller.children)) {
|
|
2976
|
+
if (child instanceof HTMLSlotElement && !slots.has(child)) {
|
|
2977
|
+
child.addEventListener("slotchange", onSlotChange);
|
|
2978
|
+
slots.add(child);
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
};
|
|
2982
|
+
const resync = () => {
|
|
2983
|
+
trackSlots();
|
|
2984
|
+
const targets = this.contentTargets();
|
|
2985
|
+
for (const el of observed) {
|
|
2986
|
+
if (!targets.includes(el)) {
|
|
2987
|
+
ro.unobserve(el);
|
|
2988
|
+
observed.delete(el);
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
for (const el of targets) {
|
|
2992
|
+
if (!observed.has(el)) {
|
|
2993
|
+
ro.observe(el);
|
|
2994
|
+
observed.add(el);
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
schedule();
|
|
2998
|
+
};
|
|
2999
|
+
let mo;
|
|
3000
|
+
if (scroller) {
|
|
3001
|
+
resync();
|
|
3002
|
+
if (typeof MutationObserver !== "undefined") {
|
|
3003
|
+
mo = new MutationObserver(resync);
|
|
3004
|
+
mo.observe(scroller, { childList: true });
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
2928
3007
|
this.teardowns.add(() => {
|
|
2929
3008
|
ro.disconnect();
|
|
3009
|
+
mo?.disconnect();
|
|
3010
|
+
for (const slot of slots) {
|
|
3011
|
+
slot.removeEventListener("slotchange", onSlotChange);
|
|
3012
|
+
}
|
|
2930
3013
|
if (raf) cancelAnimationFrame(raf);
|
|
2931
3014
|
});
|
|
2932
3015
|
}
|
|
@@ -3454,11 +3537,12 @@ var BottomSheet = qwik.component$((props) => {
|
|
|
3454
3537
|
ref: handleRef,
|
|
3455
3538
|
role: "slider",
|
|
3456
3539
|
tabIndex: 0,
|
|
3457
|
-
"aria-label": "Resize sheet"
|
|
3458
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, { name: "header" })
|
|
3540
|
+
"aria-label": "Resize sheet"
|
|
3459
3541
|
}
|
|
3460
3542
|
),
|
|
3543
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { class: "bs-header", children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, { name: "header" }) }),
|
|
3461
3544
|
/* @__PURE__ */ jsxRuntime.jsx("div", { class: "bs-content", ref: contentRef, children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {}) }),
|
|
3545
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { class: "bs-footer", children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, { name: "footer" }) }),
|
|
3462
3546
|
/* @__PURE__ */ jsxRuntime.jsx("span", { class: "bs-sr-only", role: "status", "aria-live": "polite", children: state.activeId })
|
|
3463
3547
|
]
|
|
3464
3548
|
}
|
package/dist/qwik.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _builder_io_qwik from '@builder.io/qwik';
|
|
2
2
|
import { QRL } from '@builder.io/qwik';
|
|
3
|
-
import { a as SnapPointDef, b as SheetMode, E as EngineState } from './BottomSheetEngine-
|
|
4
|
-
export { c as EngineOptions, d as SnapPoint } from './BottomSheetEngine-
|
|
3
|
+
import { a as SnapPointDef, b as SheetMode, E as EngineState } from './BottomSheetEngine-CqiCz64W.cjs';
|
|
4
|
+
export { c as EngineOptions, d as SnapPoint } from './BottomSheetEngine-CqiCz64W.cjs';
|
|
5
5
|
import './transform-jVfAikE9.cjs';
|
|
6
6
|
|
|
7
7
|
type BottomSheetProps<TId extends string = string> = {
|
package/dist/qwik.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _builder_io_qwik from '@builder.io/qwik';
|
|
2
2
|
import { QRL } from '@builder.io/qwik';
|
|
3
|
-
import { a as SnapPointDef, b as SheetMode, E as EngineState } from './BottomSheetEngine-
|
|
4
|
-
export { c as EngineOptions, d as SnapPoint } from './BottomSheetEngine-
|
|
3
|
+
import { a as SnapPointDef, b as SheetMode, E as EngineState } from './BottomSheetEngine-BHjKFtnM.js';
|
|
4
|
+
export { c as EngineOptions, d as SnapPoint } from './BottomSheetEngine-BHjKFtnM.js';
|
|
5
5
|
import './transform-jVfAikE9.js';
|
|
6
6
|
|
|
7
7
|
type BottomSheetProps<TId extends string = string> = {
|
package/dist/qwik.js
CHANGED
|
@@ -2896,11 +2896,54 @@ var BottomSheetEngine = class {
|
|
|
2896
2896
|
this.updateAriaSlider();
|
|
2897
2897
|
}
|
|
2898
2898
|
}
|
|
2899
|
+
contentTargets() {
|
|
2900
|
+
const scroller = this.scrollContainer;
|
|
2901
|
+
if (!scroller) return [];
|
|
2902
|
+
const hasSlot = typeof HTMLSlotElement !== "undefined";
|
|
2903
|
+
const out = [];
|
|
2904
|
+
for (const child of Array.from(scroller.children)) {
|
|
2905
|
+
if (hasSlot && child instanceof HTMLSlotElement) {
|
|
2906
|
+
for (const el of child.assignedElements()) out.push(el);
|
|
2907
|
+
} else {
|
|
2908
|
+
out.push(child);
|
|
2909
|
+
}
|
|
2910
|
+
}
|
|
2911
|
+
return out;
|
|
2912
|
+
}
|
|
2913
|
+
measureContentExtent(vertical) {
|
|
2914
|
+
const content = this.scrollContainer;
|
|
2915
|
+
if (!content) return 0;
|
|
2916
|
+
const targets = this.contentTargets();
|
|
2917
|
+
if (targets.length === 0) {
|
|
2918
|
+
return vertical ? content.scrollHeight : content.scrollWidth;
|
|
2919
|
+
}
|
|
2920
|
+
let min = Infinity;
|
|
2921
|
+
let max = -Infinity;
|
|
2922
|
+
for (const el of targets) {
|
|
2923
|
+
const r = el.getBoundingClientRect();
|
|
2924
|
+
if (vertical) {
|
|
2925
|
+
if (r.top < min) min = r.top;
|
|
2926
|
+
if (r.bottom > max) max = r.bottom;
|
|
2927
|
+
} else {
|
|
2928
|
+
if (r.left < min) min = r.left;
|
|
2929
|
+
if (r.right > max) max = r.right;
|
|
2930
|
+
}
|
|
2931
|
+
}
|
|
2932
|
+
if (!isFinite(min) || !isFinite(max) || max <= min) {
|
|
2933
|
+
return vertical ? content.scrollHeight : content.scrollWidth;
|
|
2934
|
+
}
|
|
2935
|
+
let pad = 0;
|
|
2936
|
+
if (typeof getComputedStyle !== "undefined") {
|
|
2937
|
+
const cs = getComputedStyle(content);
|
|
2938
|
+
pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
|
|
2939
|
+
}
|
|
2940
|
+
return max - min + pad;
|
|
2941
|
+
}
|
|
2899
2942
|
measureFitSize() {
|
|
2900
2943
|
const vertical = layoutAxis(this.mode) === "height";
|
|
2901
2944
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2902
2945
|
const content = this.scrollContainer;
|
|
2903
|
-
const natural = content ? handleSize + (vertical
|
|
2946
|
+
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2904
2947
|
if (typeof window === "undefined") return natural;
|
|
2905
2948
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2906
2949
|
return viewport > 0 ? Math.min(natural, viewport) : natural;
|
|
@@ -2909,22 +2952,62 @@ var BottomSheetEngine = class {
|
|
|
2909
2952
|
if (typeof ResizeObserver === "undefined") return;
|
|
2910
2953
|
if (!this.snapPointsRaw.some((p) => p.size === "fit" || p.size === "content"))
|
|
2911
2954
|
return;
|
|
2912
|
-
const targets = [this.handle];
|
|
2913
|
-
if (this.scrollContainer && this.scrollContainer !== this.handle) {
|
|
2914
|
-
targets.push(this.scrollContainer);
|
|
2915
|
-
}
|
|
2916
2955
|
let raf = 0;
|
|
2917
|
-
const
|
|
2956
|
+
const schedule = () => {
|
|
2918
2957
|
if (raf) return;
|
|
2919
2958
|
raf = requestAnimationFrame(() => {
|
|
2920
2959
|
raf = 0;
|
|
2921
2960
|
if (this.destroyed || this.gesture?.isDragging) return;
|
|
2922
2961
|
this.recompute();
|
|
2923
2962
|
});
|
|
2924
|
-
}
|
|
2925
|
-
|
|
2963
|
+
};
|
|
2964
|
+
const ro = new ResizeObserver(schedule);
|
|
2965
|
+
ro.observe(this.handle);
|
|
2966
|
+
const scroller = this.scrollContainer;
|
|
2967
|
+
const observed = /* @__PURE__ */ new Set();
|
|
2968
|
+
const slots = /* @__PURE__ */ new Set();
|
|
2969
|
+
const hasSlot = typeof HTMLSlotElement !== "undefined";
|
|
2970
|
+
const onSlotChange = () => resync();
|
|
2971
|
+
const trackSlots = () => {
|
|
2972
|
+
if (!scroller || !hasSlot) return;
|
|
2973
|
+
for (const child of Array.from(scroller.children)) {
|
|
2974
|
+
if (child instanceof HTMLSlotElement && !slots.has(child)) {
|
|
2975
|
+
child.addEventListener("slotchange", onSlotChange);
|
|
2976
|
+
slots.add(child);
|
|
2977
|
+
}
|
|
2978
|
+
}
|
|
2979
|
+
};
|
|
2980
|
+
const resync = () => {
|
|
2981
|
+
trackSlots();
|
|
2982
|
+
const targets = this.contentTargets();
|
|
2983
|
+
for (const el of observed) {
|
|
2984
|
+
if (!targets.includes(el)) {
|
|
2985
|
+
ro.unobserve(el);
|
|
2986
|
+
observed.delete(el);
|
|
2987
|
+
}
|
|
2988
|
+
}
|
|
2989
|
+
for (const el of targets) {
|
|
2990
|
+
if (!observed.has(el)) {
|
|
2991
|
+
ro.observe(el);
|
|
2992
|
+
observed.add(el);
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
schedule();
|
|
2996
|
+
};
|
|
2997
|
+
let mo;
|
|
2998
|
+
if (scroller) {
|
|
2999
|
+
resync();
|
|
3000
|
+
if (typeof MutationObserver !== "undefined") {
|
|
3001
|
+
mo = new MutationObserver(resync);
|
|
3002
|
+
mo.observe(scroller, { childList: true });
|
|
3003
|
+
}
|
|
3004
|
+
}
|
|
2926
3005
|
this.teardowns.add(() => {
|
|
2927
3006
|
ro.disconnect();
|
|
3007
|
+
mo?.disconnect();
|
|
3008
|
+
for (const slot of slots) {
|
|
3009
|
+
slot.removeEventListener("slotchange", onSlotChange);
|
|
3010
|
+
}
|
|
2928
3011
|
if (raf) cancelAnimationFrame(raf);
|
|
2929
3012
|
});
|
|
2930
3013
|
}
|
|
@@ -3452,11 +3535,12 @@ var BottomSheet = component$((props) => {
|
|
|
3452
3535
|
ref: handleRef,
|
|
3453
3536
|
role: "slider",
|
|
3454
3537
|
tabIndex: 0,
|
|
3455
|
-
"aria-label": "Resize sheet"
|
|
3456
|
-
children: /* @__PURE__ */ jsx(Slot, { name: "header" })
|
|
3538
|
+
"aria-label": "Resize sheet"
|
|
3457
3539
|
}
|
|
3458
3540
|
),
|
|
3541
|
+
/* @__PURE__ */ jsx("div", { class: "bs-header", children: /* @__PURE__ */ jsx(Slot, { name: "header" }) }),
|
|
3459
3542
|
/* @__PURE__ */ jsx("div", { class: "bs-content", ref: contentRef, children: /* @__PURE__ */ jsx(Slot, {}) }),
|
|
3543
|
+
/* @__PURE__ */ jsx("div", { class: "bs-footer", children: /* @__PURE__ */ jsx(Slot, { name: "footer" }) }),
|
|
3460
3544
|
/* @__PURE__ */ jsx("span", { class: "bs-sr-only", role: "status", "aria-live": "polite", children: state.activeId })
|
|
3461
3545
|
]
|
|
3462
3546
|
}
|
package/dist/react.cjs
CHANGED
|
@@ -2905,11 +2905,54 @@ var BottomSheetEngine = class {
|
|
|
2905
2905
|
this.updateAriaSlider();
|
|
2906
2906
|
}
|
|
2907
2907
|
}
|
|
2908
|
+
contentTargets() {
|
|
2909
|
+
const scroller = this.scrollContainer;
|
|
2910
|
+
if (!scroller) return [];
|
|
2911
|
+
const hasSlot = typeof HTMLSlotElement !== "undefined";
|
|
2912
|
+
const out = [];
|
|
2913
|
+
for (const child of Array.from(scroller.children)) {
|
|
2914
|
+
if (hasSlot && child instanceof HTMLSlotElement) {
|
|
2915
|
+
for (const el of child.assignedElements()) out.push(el);
|
|
2916
|
+
} else {
|
|
2917
|
+
out.push(child);
|
|
2918
|
+
}
|
|
2919
|
+
}
|
|
2920
|
+
return out;
|
|
2921
|
+
}
|
|
2922
|
+
measureContentExtent(vertical) {
|
|
2923
|
+
const content = this.scrollContainer;
|
|
2924
|
+
if (!content) return 0;
|
|
2925
|
+
const targets = this.contentTargets();
|
|
2926
|
+
if (targets.length === 0) {
|
|
2927
|
+
return vertical ? content.scrollHeight : content.scrollWidth;
|
|
2928
|
+
}
|
|
2929
|
+
let min = Infinity;
|
|
2930
|
+
let max = -Infinity;
|
|
2931
|
+
for (const el of targets) {
|
|
2932
|
+
const r = el.getBoundingClientRect();
|
|
2933
|
+
if (vertical) {
|
|
2934
|
+
if (r.top < min) min = r.top;
|
|
2935
|
+
if (r.bottom > max) max = r.bottom;
|
|
2936
|
+
} else {
|
|
2937
|
+
if (r.left < min) min = r.left;
|
|
2938
|
+
if (r.right > max) max = r.right;
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
if (!isFinite(min) || !isFinite(max) || max <= min) {
|
|
2942
|
+
return vertical ? content.scrollHeight : content.scrollWidth;
|
|
2943
|
+
}
|
|
2944
|
+
let pad = 0;
|
|
2945
|
+
if (typeof getComputedStyle !== "undefined") {
|
|
2946
|
+
const cs = getComputedStyle(content);
|
|
2947
|
+
pad = vertical ? (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0) : (parseFloat(cs.paddingLeft) || 0) + (parseFloat(cs.paddingRight) || 0);
|
|
2948
|
+
}
|
|
2949
|
+
return max - min + pad;
|
|
2950
|
+
}
|
|
2908
2951
|
measureFitSize() {
|
|
2909
2952
|
const vertical = layoutAxis(this.mode) === "height";
|
|
2910
2953
|
const handleSize = vertical ? this.handle.offsetHeight : this.handle.offsetWidth;
|
|
2911
2954
|
const content = this.scrollContainer;
|
|
2912
|
-
const natural = content ? handleSize + (vertical
|
|
2955
|
+
const natural = content ? handleSize + this.measureContentExtent(vertical) : handleSize;
|
|
2913
2956
|
if (typeof window === "undefined") return natural;
|
|
2914
2957
|
const viewport = vertical ? window.innerHeight : window.innerWidth;
|
|
2915
2958
|
return viewport > 0 ? Math.min(natural, viewport) : natural;
|
|
@@ -2918,22 +2961,62 @@ var BottomSheetEngine = class {
|
|
|
2918
2961
|
if (typeof ResizeObserver === "undefined") return;
|
|
2919
2962
|
if (!this.snapPointsRaw.some((p) => p.size === "fit" || p.size === "content"))
|
|
2920
2963
|
return;
|
|
2921
|
-
const targets = [this.handle];
|
|
2922
|
-
if (this.scrollContainer && this.scrollContainer !== this.handle) {
|
|
2923
|
-
targets.push(this.scrollContainer);
|
|
2924
|
-
}
|
|
2925
2964
|
let raf = 0;
|
|
2926
|
-
const
|
|
2965
|
+
const schedule = () => {
|
|
2927
2966
|
if (raf) return;
|
|
2928
2967
|
raf = requestAnimationFrame(() => {
|
|
2929
2968
|
raf = 0;
|
|
2930
2969
|
if (this.destroyed || this.gesture?.isDragging) return;
|
|
2931
2970
|
this.recompute();
|
|
2932
2971
|
});
|
|
2933
|
-
}
|
|
2934
|
-
|
|
2972
|
+
};
|
|
2973
|
+
const ro = new ResizeObserver(schedule);
|
|
2974
|
+
ro.observe(this.handle);
|
|
2975
|
+
const scroller = this.scrollContainer;
|
|
2976
|
+
const observed = /* @__PURE__ */ new Set();
|
|
2977
|
+
const slots = /* @__PURE__ */ new Set();
|
|
2978
|
+
const hasSlot = typeof HTMLSlotElement !== "undefined";
|
|
2979
|
+
const onSlotChange = () => resync();
|
|
2980
|
+
const trackSlots = () => {
|
|
2981
|
+
if (!scroller || !hasSlot) return;
|
|
2982
|
+
for (const child of Array.from(scroller.children)) {
|
|
2983
|
+
if (child instanceof HTMLSlotElement && !slots.has(child)) {
|
|
2984
|
+
child.addEventListener("slotchange", onSlotChange);
|
|
2985
|
+
slots.add(child);
|
|
2986
|
+
}
|
|
2987
|
+
}
|
|
2988
|
+
};
|
|
2989
|
+
const resync = () => {
|
|
2990
|
+
trackSlots();
|
|
2991
|
+
const targets = this.contentTargets();
|
|
2992
|
+
for (const el of observed) {
|
|
2993
|
+
if (!targets.includes(el)) {
|
|
2994
|
+
ro.unobserve(el);
|
|
2995
|
+
observed.delete(el);
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
for (const el of targets) {
|
|
2999
|
+
if (!observed.has(el)) {
|
|
3000
|
+
ro.observe(el);
|
|
3001
|
+
observed.add(el);
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
schedule();
|
|
3005
|
+
};
|
|
3006
|
+
let mo;
|
|
3007
|
+
if (scroller) {
|
|
3008
|
+
resync();
|
|
3009
|
+
if (typeof MutationObserver !== "undefined") {
|
|
3010
|
+
mo = new MutationObserver(resync);
|
|
3011
|
+
mo.observe(scroller, { childList: true });
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
2935
3014
|
this.teardowns.add(() => {
|
|
2936
3015
|
ro.disconnect();
|
|
3016
|
+
mo?.disconnect();
|
|
3017
|
+
for (const slot of slots) {
|
|
3018
|
+
slot.removeEventListener("slotchange", onSlotChange);
|
|
3019
|
+
}
|
|
2937
3020
|
if (raf) cancelAnimationFrame(raf);
|
|
2938
3021
|
});
|
|
2939
3022
|
}
|
|
@@ -3354,6 +3437,38 @@ var BottomSheetEngine = class {
|
|
|
3354
3437
|
}
|
|
3355
3438
|
};
|
|
3356
3439
|
|
|
3440
|
+
// src/core/features/teleport.ts
|
|
3441
|
+
var resolveTeleportTarget = (target) => {
|
|
3442
|
+
if (!target) return null;
|
|
3443
|
+
if (typeof target !== "string") return target;
|
|
3444
|
+
if (typeof document === "undefined") return null;
|
|
3445
|
+
if (target === "body") return document.body;
|
|
3446
|
+
return document.querySelector(target);
|
|
3447
|
+
};
|
|
3448
|
+
var teleportElements = (els, target) => {
|
|
3449
|
+
const records = [];
|
|
3450
|
+
for (const el of els) {
|
|
3451
|
+
if (!el || el.parentNode === target) continue;
|
|
3452
|
+
records.push({ el, parent: el.parentNode, next: el.nextSibling });
|
|
3453
|
+
target.appendChild(el);
|
|
3454
|
+
}
|
|
3455
|
+
return () => {
|
|
3456
|
+
for (let i = records.length - 1; i >= 0; i--) {
|
|
3457
|
+
const { el, parent, next } = records[i];
|
|
3458
|
+
if (parent && parent.isConnected) {
|
|
3459
|
+
const before = next && next.parentNode === parent ? next : null;
|
|
3460
|
+
try {
|
|
3461
|
+
parent.insertBefore(el, before);
|
|
3462
|
+
} catch {
|
|
3463
|
+
el.parentNode?.removeChild(el);
|
|
3464
|
+
}
|
|
3465
|
+
} else {
|
|
3466
|
+
el.parentNode?.removeChild(el);
|
|
3467
|
+
}
|
|
3468
|
+
}
|
|
3469
|
+
};
|
|
3470
|
+
};
|
|
3471
|
+
|
|
3357
3472
|
// src/react/useBottomSheet.ts
|
|
3358
3473
|
var useIsomorphicLayoutEffect = typeof window !== "undefined" ? react.useLayoutEffect : react.useEffect;
|
|
3359
3474
|
var SSR_STATE = Object.freeze({
|
|
@@ -3387,6 +3502,17 @@ function useBottomSheet(opts) {
|
|
|
3387
3502
|
scrim: screenRef.current ?? void 0
|
|
3388
3503
|
});
|
|
3389
3504
|
engineRef.current = engine;
|
|
3505
|
+
const target = resolveTeleportTarget(optsRef.current.teleportTo);
|
|
3506
|
+
const restoreTeleport = target ? teleportElements(
|
|
3507
|
+
[backdropRef.current, screenRef.current, sheetRef.current],
|
|
3508
|
+
target
|
|
3509
|
+
) : null;
|
|
3510
|
+
if (optsRef.current.backdropColor !== void 0) {
|
|
3511
|
+
engine.setScrimColor(optsRef.current.backdropColor);
|
|
3512
|
+
}
|
|
3513
|
+
if (optsRef.current.backdropOpacity !== void 0) {
|
|
3514
|
+
engine.setBackdropRange([0, optsRef.current.backdropOpacity]);
|
|
3515
|
+
}
|
|
3390
3516
|
cachedSnapshotRef.current = { ...engine.state };
|
|
3391
3517
|
setMounted((n) => n + 1);
|
|
3392
3518
|
const refresh = () => {
|
|
@@ -3418,6 +3544,7 @@ function useBottomSheet(opts) {
|
|
|
3418
3544
|
];
|
|
3419
3545
|
return () => {
|
|
3420
3546
|
offs.forEach((off) => off());
|
|
3547
|
+
restoreTeleport?.();
|
|
3421
3548
|
engine.destroy();
|
|
3422
3549
|
engineRef.current = null;
|
|
3423
3550
|
cachedSnapshotRef.current = SSR_STATE;
|
|
@@ -3433,6 +3560,18 @@ function useBottomSheet(opts) {
|
|
|
3433
3560
|
const ids = opts.allowed ? Array.from(opts.allowed) : opts.snapPoints.map((p) => p.id);
|
|
3434
3561
|
engineRef.current.setAllowed(ids);
|
|
3435
3562
|
}, [allowedKey, snapKey]);
|
|
3563
|
+
react.useEffect(() => {
|
|
3564
|
+
if (!engineRef.current) return;
|
|
3565
|
+
if (opts.backdropColor !== void 0) {
|
|
3566
|
+
engineRef.current.setScrimColor(opts.backdropColor);
|
|
3567
|
+
}
|
|
3568
|
+
}, [opts.backdropColor]);
|
|
3569
|
+
react.useEffect(() => {
|
|
3570
|
+
if (!engineRef.current) return;
|
|
3571
|
+
if (opts.backdropOpacity !== void 0) {
|
|
3572
|
+
engineRef.current.setBackdropRange([0, opts.backdropOpacity]);
|
|
3573
|
+
}
|
|
3574
|
+
}, [opts.backdropOpacity]);
|
|
3436
3575
|
const subscribe = react.useCallback((fn) => {
|
|
3437
3576
|
subscribersRef.current.add(fn);
|
|
3438
3577
|
return () => subscribersRef.current.delete(fn);
|
|
@@ -3532,6 +3671,7 @@ var BottomSheet = react.forwardRef(
|
|
|
3532
3671
|
className = "",
|
|
3533
3672
|
style,
|
|
3534
3673
|
header,
|
|
3674
|
+
footer,
|
|
3535
3675
|
children,
|
|
3536
3676
|
leftButton,
|
|
3537
3677
|
rightButton,
|
|
@@ -3719,10 +3859,10 @@ var BottomSheet = react.forwardRef(
|
|
|
3719
3859
|
className: "bs-handle",
|
|
3720
3860
|
role: "slider",
|
|
3721
3861
|
tabIndex: 0,
|
|
3722
|
-
"aria-label": "Resize sheet"
|
|
3723
|
-
children: typeof header === "function" ? header(state) : header
|
|
3862
|
+
"aria-label": "Resize sheet"
|
|
3724
3863
|
}
|
|
3725
3864
|
),
|
|
3865
|
+
header != null && header !== false && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bs-header", children: typeof header === "function" ? header(state) : header }),
|
|
3726
3866
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3727
3867
|
"div",
|
|
3728
3868
|
{
|
|
@@ -3734,6 +3874,7 @@ var BottomSheet = react.forwardRef(
|
|
|
3734
3874
|
children
|
|
3735
3875
|
}
|
|
3736
3876
|
),
|
|
3877
|
+
footer != null && footer !== false && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bs-footer", children: typeof footer === "function" ? footer(state) : footer }),
|
|
3737
3878
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "bs-sr-only", role: "status", "aria-live": "polite", children: announce })
|
|
3738
3879
|
]
|
|
3739
3880
|
}
|
package/dist/react.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as EngineOptions, E as EngineState, A as AnchorOptions, S as ScrimStagesOptions, p as ScrimStageDef, e as SheetEventMap, C as CloseReason, q as ScrimUpdate, m as ScrimOverlayOptions, B as BottomSheetEngine, a as SnapPointDef, b as SheetMode } from './BottomSheetEngine-
|
|
2
|
-
export { d as SnapPoint } from './BottomSheetEngine-
|
|
1
|
+
import { c as EngineOptions, E as EngineState, A as AnchorOptions, S as ScrimStagesOptions, p as ScrimStageDef, e as SheetEventMap, C as CloseReason, q as ScrimUpdate, m as ScrimOverlayOptions, B as BottomSheetEngine, a as SnapPointDef, b as SheetMode } from './BottomSheetEngine-CqiCz64W.cjs';
|
|
2
|
+
export { d as SnapPoint } from './BottomSheetEngine-CqiCz64W.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';
|
|
@@ -23,6 +23,7 @@ type BottomSheetProps = EngineOptionsForProps & {
|
|
|
23
23
|
className?: string;
|
|
24
24
|
style?: CSSProperties;
|
|
25
25
|
header?: HeaderProp;
|
|
26
|
+
footer?: HeaderProp;
|
|
26
27
|
children?: ReactNode;
|
|
27
28
|
leftButton?: ReactNode;
|
|
28
29
|
rightButton?: ReactNode;
|
|
@@ -65,6 +66,7 @@ declare const BottomSheet: react.ForwardRefExoticComponent<EngineOptionsForProps
|
|
|
65
66
|
className?: string;
|
|
66
67
|
style?: CSSProperties;
|
|
67
68
|
header?: HeaderProp;
|
|
69
|
+
footer?: HeaderProp;
|
|
68
70
|
children?: ReactNode;
|
|
69
71
|
leftButton?: ReactNode;
|
|
70
72
|
rightButton?: ReactNode;
|
|
@@ -82,6 +84,8 @@ declare const BottomSheet: react.ForwardRefExoticComponent<EngineOptionsForProps
|
|
|
82
84
|
noSSR?: boolean;
|
|
83
85
|
} & react.RefAttributes<BottomSheetHandle<string>>>;
|
|
84
86
|
|
|
87
|
+
type TeleportTarget = HTMLElement | string | null | undefined;
|
|
88
|
+
|
|
85
89
|
type UseBottomSheetRefs = {
|
|
86
90
|
sheetRef: React.RefObject<HTMLElement | null>;
|
|
87
91
|
handleRef: React.RefObject<HTMLElement | null>;
|
|
@@ -111,6 +115,9 @@ type HookOpts<TId extends string> = Omit<EngineOptions, "element" | "handle" | "
|
|
|
111
115
|
snapPoints: SnapPointDef<TId>[] | ReadonlyArray<SnapPointDef<TId>>;
|
|
112
116
|
allowed?: TId[] | ReadonlyArray<TId>;
|
|
113
117
|
initial?: TId;
|
|
118
|
+
teleportTo?: TeleportTarget;
|
|
119
|
+
backdropColor?: string;
|
|
120
|
+
backdropOpacity?: number;
|
|
114
121
|
onSnap?: (id: TId) => void;
|
|
115
122
|
onBeforeClose?: (payload: SheetEventMap["before-close"]) => void;
|
|
116
123
|
onOpened?: (id: TId) => void;
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as EngineOptions, E as EngineState, A as AnchorOptions, S as ScrimStagesOptions, p as ScrimStageDef, e as SheetEventMap, C as CloseReason, q as ScrimUpdate, m as ScrimOverlayOptions, B as BottomSheetEngine, a as SnapPointDef, b as SheetMode } from './BottomSheetEngine-
|
|
2
|
-
export { d as SnapPoint } from './BottomSheetEngine-
|
|
1
|
+
import { c as EngineOptions, E as EngineState, A as AnchorOptions, S as ScrimStagesOptions, p as ScrimStageDef, e as SheetEventMap, C as CloseReason, q as ScrimUpdate, m as ScrimOverlayOptions, B as BottomSheetEngine, a as SnapPointDef, b as SheetMode } from './BottomSheetEngine-BHjKFtnM.js';
|
|
2
|
+
export { d as SnapPoint } from './BottomSheetEngine-BHjKFtnM.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';
|
|
@@ -23,6 +23,7 @@ type BottomSheetProps = EngineOptionsForProps & {
|
|
|
23
23
|
className?: string;
|
|
24
24
|
style?: CSSProperties;
|
|
25
25
|
header?: HeaderProp;
|
|
26
|
+
footer?: HeaderProp;
|
|
26
27
|
children?: ReactNode;
|
|
27
28
|
leftButton?: ReactNode;
|
|
28
29
|
rightButton?: ReactNode;
|
|
@@ -65,6 +66,7 @@ declare const BottomSheet: react.ForwardRefExoticComponent<EngineOptionsForProps
|
|
|
65
66
|
className?: string;
|
|
66
67
|
style?: CSSProperties;
|
|
67
68
|
header?: HeaderProp;
|
|
69
|
+
footer?: HeaderProp;
|
|
68
70
|
children?: ReactNode;
|
|
69
71
|
leftButton?: ReactNode;
|
|
70
72
|
rightButton?: ReactNode;
|
|
@@ -82,6 +84,8 @@ declare const BottomSheet: react.ForwardRefExoticComponent<EngineOptionsForProps
|
|
|
82
84
|
noSSR?: boolean;
|
|
83
85
|
} & react.RefAttributes<BottomSheetHandle<string>>>;
|
|
84
86
|
|
|
87
|
+
type TeleportTarget = HTMLElement | string | null | undefined;
|
|
88
|
+
|
|
85
89
|
type UseBottomSheetRefs = {
|
|
86
90
|
sheetRef: React.RefObject<HTMLElement | null>;
|
|
87
91
|
handleRef: React.RefObject<HTMLElement | null>;
|
|
@@ -111,6 +115,9 @@ type HookOpts<TId extends string> = Omit<EngineOptions, "element" | "handle" | "
|
|
|
111
115
|
snapPoints: SnapPointDef<TId>[] | ReadonlyArray<SnapPointDef<TId>>;
|
|
112
116
|
allowed?: TId[] | ReadonlyArray<TId>;
|
|
113
117
|
initial?: TId;
|
|
118
|
+
teleportTo?: TeleportTarget;
|
|
119
|
+
backdropColor?: string;
|
|
120
|
+
backdropOpacity?: number;
|
|
114
121
|
onSnap?: (id: TId) => void;
|
|
115
122
|
onBeforeClose?: (payload: SheetEventMap["before-close"]) => void;
|
|
116
123
|
onOpened?: (id: TId) => void;
|