@bonprix-ds/react-bottom-sheet 1.2.1 → 1.3.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/index.js +1 -2
- package/dist/src/BottomSheet.js +1 -2
- package/dist/src/BottomSheetContext.d.ts +2 -0
- package/dist/src/BottomSheetContext.js +4 -3
- package/dist/src/BottomSheetContext.js.map +1 -1
- package/dist/src/BottomSheetRoot.d.ts +8 -2
- package/dist/src/BottomSheetRoot.js +66 -65
- package/dist/src/BottomSheetRoot.js.map +1 -1
- package/dist/src/useConsumeBottomSheet.js +1 -2
- package/dist/src/useCreateBottomSheet.js +1 -2
- package/dist/src/useKeepScrollPositionOnPageHide.js +1 -2
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { e as default };
|
|
1
|
+
export { default } from "./src/BottomSheet.js";
|
package/dist/src/BottomSheet.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import e, { ButtonSection as t, Content as n, PrimaryButton as r, SecondaryButton as i, Title as a } from "./BottomSheetRoot.js";
|
|
2
2
|
import "react";
|
|
3
3
|
import { jsx as o } from "react/jsx-runtime";
|
|
4
|
-
|
|
4
|
+
// src/BottomSheet.tsx
|
|
5
5
|
var s = (t) => /* @__PURE__ */ o(e, { ...t });
|
|
6
6
|
s.displayName = "BottomSheet", s.Title = a, s.Content = n, s.ButtonSection = t, s.PrimaryButton = r, s.SecondaryButton = i;
|
|
7
|
-
//#endregion
|
|
8
7
|
export { s as default };
|
|
9
8
|
|
|
10
9
|
//# sourceMappingURL=BottomSheet.js.map
|
|
@@ -5,6 +5,8 @@ export interface BottomSheetContextProps {
|
|
|
5
5
|
onClose: () => void;
|
|
6
6
|
onBack?: () => void;
|
|
7
7
|
disableDrag: boolean;
|
|
8
|
+
closeButtonLabel: string;
|
|
9
|
+
backButtonLabel: string;
|
|
8
10
|
}
|
|
9
11
|
declare const BottomSheetContext: import("react").Context<BottomSheetContextProps>;
|
|
10
12
|
export default BottomSheetContext;
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext as e } from "react";
|
|
3
|
-
|
|
3
|
+
// src/BottomSheetContext.ts
|
|
4
4
|
var t = e({
|
|
5
5
|
scrollRef: () => null,
|
|
6
6
|
scrollPosition: void 0,
|
|
7
7
|
onClose: () => null,
|
|
8
8
|
onBack: () => null,
|
|
9
|
-
disableDrag: !1
|
|
9
|
+
disableDrag: !1,
|
|
10
|
+
closeButtonLabel: "Schließen",
|
|
11
|
+
backButtonLabel: "Zurück"
|
|
10
12
|
});
|
|
11
|
-
//#endregion
|
|
12
13
|
export { t as default };
|
|
13
14
|
|
|
14
15
|
//# sourceMappingURL=BottomSheetContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetContext.js","names":["BottomSheetContext","createContext"],"sources":["../../src/BottomSheetContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { useScrollPosition } from \"react-modal-sheet\";\n\nexport interface BottomSheetContextProps {\n scrollRef: ReturnType<typeof useScrollPosition>[\"scrollRef\"];\n scrollPosition: ReturnType<typeof useScrollPosition>[\"scrollPosition\"];\n onClose: () => void;\n onBack?: () => void;\n disableDrag: boolean;\n}\n\nconst BottomSheetContext = createContext<BottomSheetContextProps>({\n scrollRef: () => null,\n scrollPosition: undefined,\n onClose: () => null,\n onBack: () => null,\n disableDrag: false,\n});\n\nexport default BottomSheetContext;\n"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"BottomSheetContext.js","names":["BottomSheetContext","createContext"],"sources":["../../src/BottomSheetContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\nimport { useScrollPosition } from \"react-modal-sheet\";\n\nexport interface BottomSheetContextProps {\n scrollRef: ReturnType<typeof useScrollPosition>[\"scrollRef\"];\n scrollPosition: ReturnType<typeof useScrollPosition>[\"scrollPosition\"];\n onClose: () => void;\n onBack?: () => void;\n disableDrag: boolean;\n closeButtonLabel: string;\n backButtonLabel: string;\n}\n\nconst BottomSheetContext = createContext<BottomSheetContextProps>({\n scrollRef: () => null,\n scrollPosition: undefined,\n onClose: () => null,\n onBack: () => null,\n disableDrag: false,\n closeButtonLabel: \"Schließen\",\n backButtonLabel: \"Zurück\",\n});\n\nexport default BottomSheetContext;\n"],"mappings":";;;AAeA,IAAMA,IAAqBC,EAAuC;CAChE,iBAAiB;CACjB,gBAAgB,KAAA;CAChB,eAAe;CACf,cAAc;CACd,aAAa;CACb,kBAAkB;CAClB,iBAAiB;AACnB,CAAC"}
|
|
@@ -14,12 +14,18 @@ interface SheetProps {
|
|
|
14
14
|
* - Click on "close" icon button in the upper-right corner
|
|
15
15
|
* - Click on any button (PrimaryButton or SecondaryButton)
|
|
16
16
|
*
|
|
17
|
-
* Should be used in conjunction with `open`.
|
|
17
|
+
* Should be used in conjunction with `open`.
|
|
18
|
+
*
|
|
19
|
+
* Once the sheet has closed, focus returns to the element that had it before the sheet opened. */
|
|
18
20
|
onClose: () => void;
|
|
19
21
|
/** Callback to execute when clicking back icon. */
|
|
20
22
|
onBack?: () => void;
|
|
21
23
|
/** The z-index of the sheet.. */
|
|
22
24
|
zIndex?: number;
|
|
25
|
+
/** The accessible name of the close button. */
|
|
26
|
+
closeButtonLabel?: string;
|
|
27
|
+
/** The accessible name of the back button. */
|
|
28
|
+
backButtonLabel?: string;
|
|
23
29
|
}
|
|
24
30
|
type OpenProps = SheetProps & {
|
|
25
31
|
/** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */
|
|
@@ -74,7 +80,7 @@ export type Props = (DeprecatedOpenProps | OpenProps) & {
|
|
|
74
80
|
ref?: RefObject<HTMLDivElement>;
|
|
75
81
|
};
|
|
76
82
|
declare const BottomSheetRoot: {
|
|
77
|
-
({ children, open, isOpen, onClose, onBack, zIndex, ref }: Props): React.JSX.Element;
|
|
83
|
+
({ children, open, isOpen, onClose, onBack, zIndex, ref, closeButtonLabel, backButtonLabel, }: Props): React.JSX.Element;
|
|
78
84
|
displayName: string;
|
|
79
85
|
};
|
|
80
86
|
export default BottomSheetRoot;
|
|
@@ -11,12 +11,12 @@ import { backdrop as l } from "@bonprix-ds/internal-components";
|
|
|
11
11
|
import u from "@bonprix-ds/react-button";
|
|
12
12
|
import d from "@bonprix-ds/react-icon-button";
|
|
13
13
|
import { ArrowLeftIcon as f, CloserIcon as p } from "@bonprix-ds/react-icon/icons";
|
|
14
|
-
import { ZIndexContext as m,
|
|
15
|
-
import { warnDeprecated as
|
|
14
|
+
import { ZIndexContext as m, useFocusReturn as h, useInnerOpen as g, usePrefersReducedMotion as _ } from "@bonprix-ds/utils";
|
|
15
|
+
import { warnDeprecated as v } from "@bonprix-ds/utils/deprecation";
|
|
16
16
|
import "#styles";
|
|
17
|
-
import { jsx as
|
|
18
|
-
|
|
19
|
-
var
|
|
17
|
+
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
18
|
+
// src/BottomSheetRoot.tsx
|
|
19
|
+
var x = c({
|
|
20
20
|
slots: {
|
|
21
21
|
root: "preflight block",
|
|
22
22
|
container: "max-h-[calc(100%-4rem)] rounded-none bg-clr-bg-modal shadow-none outline-none",
|
|
@@ -37,67 +37,69 @@ var b = c({
|
|
|
37
37
|
false: { scrollArea: "px-4" },
|
|
38
38
|
true: ""
|
|
39
39
|
} }
|
|
40
|
-
}),
|
|
41
|
-
l !== void 0 &&
|
|
42
|
-
let
|
|
43
|
-
r(
|
|
44
|
-
let
|
|
40
|
+
}), S = ({ children: t, open: c, isOpen: l, onClose: u, onBack: d, zIndex: f = 9999, ref: p, closeButtonLabel: S = "Schließen", backButtonLabel: C = "Zurück" }) => {
|
|
41
|
+
l !== void 0 && v("is-open-prop");
|
|
42
|
+
let w = _(), { root: T, container: E, dragHandleContainer: D, dragHandle: O, content: k, contentWrapper: A, backdrop: j } = x(), { isShown: M, scrollRef: N, scrollPosition: P } = n({ open: c ?? l ?? !1 }), F = P === "middle" || P === "bottom", { innerOpen: I } = g(M);
|
|
43
|
+
r(I);
|
|
44
|
+
let L = a(null), { returnFocus: R } = h(I, L);
|
|
45
45
|
return i(() => {
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
open:
|
|
46
|
+
I || R();
|
|
47
|
+
}, [I, R]), /* @__PURE__ */ y(o.Root, {
|
|
48
|
+
open: I,
|
|
49
49
|
onOpenChange: (e) => {
|
|
50
50
|
e || u();
|
|
51
51
|
},
|
|
52
|
-
children: /* @__PURE__ */
|
|
53
|
-
isOpen:
|
|
52
|
+
children: /* @__PURE__ */ b(s, {
|
|
53
|
+
isOpen: I,
|
|
54
54
|
onClose: u,
|
|
55
|
-
className:
|
|
55
|
+
className: T(),
|
|
56
56
|
detent: "content",
|
|
57
57
|
"data-bpds": "bottom-sheet",
|
|
58
|
-
prefersReducedMotion:
|
|
58
|
+
prefersReducedMotion: w,
|
|
59
59
|
style: {
|
|
60
60
|
pointerEvents: void 0,
|
|
61
|
-
visibility:
|
|
61
|
+
visibility: I ? "visible" : "hidden",
|
|
62
62
|
zIndex: f
|
|
63
63
|
},
|
|
64
64
|
avoidKeyboard: !1,
|
|
65
|
-
children: [/* @__PURE__ */
|
|
65
|
+
children: [/* @__PURE__ */ y(o.Content, {
|
|
66
|
+
ref: L,
|
|
66
67
|
forceMount: !0,
|
|
67
68
|
asChild: !0,
|
|
68
69
|
"aria-modal": !0,
|
|
69
70
|
"aria-describedby": void 0,
|
|
70
71
|
tabIndex: -1,
|
|
71
72
|
onOpenAutoFocus: (e) => {
|
|
72
|
-
e.preventDefault(),
|
|
73
|
+
e.preventDefault(), e.target.focus();
|
|
73
74
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
className: C(),
|
|
75
|
+
children: /* @__PURE__ */ b(s.Container, {
|
|
76
|
+
className: E(),
|
|
77
77
|
ref: p,
|
|
78
|
-
children: [/* @__PURE__ */
|
|
78
|
+
children: [/* @__PURE__ */ y(s.Header, {
|
|
79
79
|
unstyled: !0,
|
|
80
|
-
className:
|
|
81
|
-
children: /* @__PURE__ */
|
|
80
|
+
className: D(),
|
|
81
|
+
children: /* @__PURE__ */ y(s.DragIndicator, {
|
|
82
82
|
unstyled: !0,
|
|
83
|
-
className:
|
|
83
|
+
className: O()
|
|
84
84
|
})
|
|
85
|
-
}), /* @__PURE__ */
|
|
85
|
+
}), /* @__PURE__ */ y(m.Provider, {
|
|
86
86
|
value: f,
|
|
87
|
-
children: /* @__PURE__ */
|
|
87
|
+
children: /* @__PURE__ */ y(e.Provider, {
|
|
88
88
|
value: {
|
|
89
|
-
scrollRef:
|
|
90
|
-
scrollPosition:
|
|
89
|
+
scrollRef: N,
|
|
90
|
+
scrollPosition: P,
|
|
91
91
|
onClose: u,
|
|
92
92
|
onBack: d,
|
|
93
|
-
disableDrag:
|
|
93
|
+
disableDrag: F,
|
|
94
|
+
closeButtonLabel: S,
|
|
95
|
+
backButtonLabel: C
|
|
94
96
|
},
|
|
95
|
-
children: /* @__PURE__ */
|
|
96
|
-
className:
|
|
97
|
+
children: /* @__PURE__ */ y(s.Content, {
|
|
98
|
+
className: k(),
|
|
97
99
|
disableScroll: !0,
|
|
98
|
-
disableDrag:
|
|
99
|
-
children: /* @__PURE__ */
|
|
100
|
-
className:
|
|
100
|
+
disableDrag: F,
|
|
101
|
+
children: /* @__PURE__ */ y("div", {
|
|
102
|
+
className: A(),
|
|
101
103
|
style: { paddingBottom: "max(var(--keyboard-inset-height, 0rem), var(--app-safe-area-inset-bottom, 1rem))" },
|
|
102
104
|
children: t
|
|
103
105
|
})
|
|
@@ -105,49 +107,49 @@ var b = c({
|
|
|
105
107
|
})
|
|
106
108
|
})]
|
|
107
109
|
})
|
|
108
|
-
}), /* @__PURE__ */
|
|
110
|
+
}), /* @__PURE__ */ y(s.Backdrop, { className: j() })]
|
|
109
111
|
})
|
|
110
112
|
});
|
|
111
|
-
},
|
|
112
|
-
let { onBack: i, onClose: a } = t(), { header:
|
|
113
|
-
return /* @__PURE__ */
|
|
114
|
-
className:
|
|
115
|
-
children: [/* @__PURE__ */
|
|
116
|
-
className:
|
|
113
|
+
}, C = ({ children: e, subline: n, level: r = "h3" }) => {
|
|
114
|
+
let { onBack: i, onClose: a, closeButtonLabel: s, backButtonLabel: c } = t(), { header: l, titleAndIcons: u } = x();
|
|
115
|
+
return /* @__PURE__ */ b("div", {
|
|
116
|
+
className: l(),
|
|
117
|
+
children: [/* @__PURE__ */ b("div", {
|
|
118
|
+
className: u(),
|
|
117
119
|
children: [
|
|
118
|
-
i && /* @__PURE__ */
|
|
120
|
+
i && /* @__PURE__ */ y(d, {
|
|
119
121
|
onClick: i,
|
|
120
|
-
icon: /* @__PURE__ */
|
|
121
|
-
label:
|
|
122
|
+
icon: /* @__PURE__ */ y(f, {}),
|
|
123
|
+
label: c,
|
|
122
124
|
variant: "tertiary",
|
|
123
125
|
size: "small"
|
|
124
126
|
}),
|
|
125
|
-
/* @__PURE__ */
|
|
127
|
+
/* @__PURE__ */ y(o.Title, {
|
|
126
128
|
asChild: !0,
|
|
127
|
-
children: /* @__PURE__ */
|
|
129
|
+
children: /* @__PURE__ */ y("div", {
|
|
128
130
|
className: "grow",
|
|
129
|
-
children: /* @__PURE__ */
|
|
131
|
+
children: /* @__PURE__ */ y(r, {
|
|
130
132
|
className: "typography-bonprix-h6 my-0 line-clamp-2 text-start text-clr-on-bg-high",
|
|
131
133
|
children: e
|
|
132
134
|
})
|
|
133
135
|
})
|
|
134
136
|
}),
|
|
135
|
-
/* @__PURE__ */
|
|
137
|
+
/* @__PURE__ */ y(d, {
|
|
136
138
|
onClick: a,
|
|
137
|
-
icon: /* @__PURE__ */
|
|
138
|
-
label:
|
|
139
|
+
icon: /* @__PURE__ */ y(p, {}),
|
|
140
|
+
label: s,
|
|
139
141
|
variant: "tertiary",
|
|
140
142
|
size: "small"
|
|
141
143
|
})
|
|
142
144
|
]
|
|
143
|
-
}), n && /* @__PURE__ */
|
|
145
|
+
}), n && /* @__PURE__ */ y("p", {
|
|
144
146
|
className: "typography-body1 my-0 text-start text-clr-on-bg-high",
|
|
145
147
|
children: n
|
|
146
148
|
})]
|
|
147
149
|
});
|
|
148
|
-
},
|
|
149
|
-
let { scrollRef: r, disableDrag: i } = t(), { scrollArea: a } =
|
|
150
|
-
return /* @__PURE__ */
|
|
150
|
+
}, w = ({ children: e, disableHorizontalPadding: n = !1 }) => {
|
|
151
|
+
let { scrollRef: r, disableDrag: i } = t(), { scrollArea: a } = x({ disableHorizontalPadding: n });
|
|
152
|
+
return /* @__PURE__ */ y("div", {
|
|
151
153
|
ref: r,
|
|
152
154
|
className: a(),
|
|
153
155
|
style: { touchAction: i ? "auto" : "pan-down" },
|
|
@@ -155,14 +157,14 @@ var b = c({
|
|
|
155
157
|
tabIndex: 0,
|
|
156
158
|
children: e
|
|
157
159
|
});
|
|
158
|
-
},
|
|
160
|
+
}, T = ({ children: e }) => /* @__PURE__ */ y("div", {
|
|
159
161
|
className: "button-section flex w-full shrink-0 touch-pan-down flex-col gap-3 px-4 pt-4",
|
|
160
162
|
children: e
|
|
161
|
-
}),
|
|
163
|
+
}), E = ({ children: e, icon: n, iconPosition: r, loading: i, component: a = "button", ...o }) => {
|
|
162
164
|
let s = a, { onClick: c, ...l } = o, { onClose: d } = t(), f = (e) => {
|
|
163
165
|
c?.(e), d();
|
|
164
166
|
};
|
|
165
|
-
return /* @__PURE__ */
|
|
167
|
+
return /* @__PURE__ */ y(u, {
|
|
166
168
|
component: s,
|
|
167
169
|
...l,
|
|
168
170
|
variant: "primary",
|
|
@@ -173,9 +175,9 @@ var b = c({
|
|
|
173
175
|
loading: i,
|
|
174
176
|
children: e
|
|
175
177
|
});
|
|
176
|
-
},
|
|
178
|
+
}, D = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...a }) => {
|
|
177
179
|
let o = i, { onClose: s } = t();
|
|
178
|
-
return /* @__PURE__ */
|
|
180
|
+
return /* @__PURE__ */ y(u, {
|
|
179
181
|
component: o,
|
|
180
182
|
...a,
|
|
181
183
|
variant: "secondary",
|
|
@@ -186,8 +188,7 @@ var b = c({
|
|
|
186
188
|
children: e
|
|
187
189
|
});
|
|
188
190
|
};
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
export { w as ButtonSection, C as Content, T as PrimaryButton, E as SecondaryButton, S as Title, x as default };
|
|
191
|
+
S.displayName = "BottomSheet";
|
|
192
|
+
export { T as ButtonSection, w as Content, E as PrimaryButton, D as SecondaryButton, C as Title, S as default };
|
|
192
193
|
|
|
193
194
|
//# sourceMappingURL=BottomSheetRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BottomSheetRoot.js","names":["BottomSheetContext","useConsumeBottomSheet","useCreateBottomSheet","useKeepScrollPositionOnPageHide","DialogPrimitive","Button","IconButton","generateClasses","tv","backdrop","BottomSheetRoot","isOpen","warnDeprecated","prefersReducedMotion","usePrefersReducedMotion","open","disableDrag","scrollPosition","useInnerOpen","isShown","innerOpen","elementFocusedBeforeOpen","useRef","useEffect","nextOpen","onClose","Sheet","root","event","container","dragHandleContainer","dragHandle","ZIndexContext","zIndex","content","contentWrapper","Title","Level","header","titleAndIcons","onBack","ArrowLeftIcon","CloserIcon","subline","Content","setScrollRef","scrollArea","disableHorizontalPadding","ButtonSection","PrimaryButton","props","Component","component","otherProps","handleClick","onClick","SecondaryButton"],"sources":["../../src/BottomSheetRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport React, { useEffect, useRef, type ComponentProps, type ElementType, type ReactNode, type RefObject } from \"react\";\nimport { Sheet } from \"react-modal-sheet\";\nimport { tv } from \"tailwind-variants\";\n\nimport { backdrop } from \"@bonprix-ds/internal-components\";\nimport Button from \"@bonprix-ds/react-button\";\nimport { type IconOrElement } from \"@bonprix-ds/react-icon\";\nimport IconButton from \"@bonprix-ds/react-icon-button\";\nimport { ArrowLeftIcon, CloserIcon } from \"@bonprix-ds/react-icon/icons\";\nimport { TitleLevel, useInnerOpen, usePrefersReducedMotion, ZIndexContext } from \"@bonprix-ds/utils\";\nimport { warnDeprecated } from \"@bonprix-ds/utils/deprecation\";\n\nimport BottomSheetContext from \"./BottomSheetContext\";\nimport useConsumeBottomSheet from \"./useConsumeBottomSheet\";\nimport useCreateBottomSheet from \"./useCreateBottomSheet\";\nimport useKeepScrollPositionOnPageHide from \"./useKeepScrollPositionOnPageHide\";\n\nimport \"./BottomSheet.css\";\n\nconst generateClasses = tv({\n slots: {\n root: \"preflight block\",\n container: \"max-h-[calc(100%-4rem)] rounded-none bg-clr-bg-modal shadow-none outline-none\",\n header: \"px-4 py-3\",\n titleAndIcons: \"flex touch-pan-down items-center gap-2\",\n contentWrapper: \"flex w-full flex-col\",\n content: [\n \"typography-body1 text-clr-primary\",\n // scroller must be a flexbox to fix scrollbar\n // scroller needs some padding to not cut off the focus-ring\n \"*:-mx-0.5 *:flex *:px-0.5\",\n // scroller must set min-h-0 in order to make scrolling work inside our flex context\n \"*:min-h-0\",\n ],\n dragHandleContainer: \"flex h-6 shrink-0 items-center justify-center\",\n dragHandle: \"h-1 w-8 rounded-full bg-clr-on-bg-low\",\n backdrop: backdrop(),\n scrollArea: \"scroll-area relative\",\n },\n variants: {\n disableHorizontalPadding: {\n false: { scrollArea: \"px-4\" },\n true: \"\",\n },\n },\n});\n\ninterface SheetProps {\n /** All of the subcomponents should be placed inside this property. */\n children: ReactNode;\n /** Callback function, that is triggered when the sheet is attempted to be closed.\n *\n * It will be called in following cases:\n * - Click on backdrop\n * - Press of the `Escape` key\n * - Swipe down to close\n * - Click on \"close\" icon button in the upper-right corner\n * - Click on any button (PrimaryButton or SecondaryButton)\n *\n * Should be used in conjunction with `open`. */\n onClose: () => void;\n /** Callback to execute when clicking back icon. */\n onBack?: () => void;\n /** The z-index of the sheet.. */\n zIndex?: number;\n}\n\ntype OpenProps = SheetProps & {\n /** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */\n open: boolean;\n /** @deprecated [is-open-prop] Use `open` instead. */\n isOpen?: never;\n};\n\ntype DeprecatedOpenProps = SheetProps & {\n open?: never;\n /**\n * Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property.\n * @deprecated [is-open-prop] Use `open` instead.\n */\n isOpen: boolean;\n};\n\nexport interface SheetTitleProps {\n /** The text content. */\n children: string;\n /** An optional subline that is displayed right below the title. */\n subline?: string;\n /** The heading level for the title. */\n level?: TitleLevel;\n}\n\nexport interface SheetButtonSectionProps {\n /** Primary and secondary buttons should be placed inside this section. */\n children: ReactNode;\n}\n\nexport interface SheetContentProps {\n /** The content of the content section. */\n children: ReactNode;\n /** If `true`, the horizontal padding around the content will be removed. */\n disableHorizontalPadding?: boolean;\n}\n\nexport interface SheetButtonBaseProps {\n /** The label of the button. */\n children: string;\n /** If used, an icon will be additionally shown. The value is either a name of one icon from our icon set or an inline `<svg>` element. */\n icon?: IconOrElement;\n /** The position of the icon relative to the content. */\n iconPosition?: \"start\" | \"end\";\n}\n\nexport type SheetButtonProps<C extends ElementType> = SheetButtonBaseProps & {\n /** The semantic component to render the Button. Preferrably `\"button\"`. Native props will be passed to this component. */\n component?: C;\n} & Omit<ComponentProps<C>, keyof SheetButtonBaseProps | \"component\">;\n\ntype SheetPrimaryButtonProps<C extends ElementType> = SheetButtonProps<C> & {\n /** If `true`, a loading spinner will be shown instead of the content. */\n loading?: boolean;\n};\n\nexport type Props = (DeprecatedOpenProps | OpenProps) & {\n /** A reference to the root element of the sheet. */\n ref?: RefObject<HTMLDivElement>;\n};\n\nconst BottomSheetRoot = ({ children, open, isOpen, onClose, onBack, zIndex = 9999, ref }: Props) => {\n if (isOpen !== undefined) warnDeprecated(\"is-open-prop\");\n const prefersReducedMotion = usePrefersReducedMotion();\n const { root, container, dragHandleContainer, dragHandle, content, contentWrapper, backdrop } = generateClasses();\n const { isShown, scrollRef, scrollPosition } = useCreateBottomSheet({ open: open ?? isOpen ?? false });\n\n // When \"middle\" or \"bottom\", dragging is disabled to allow for regular scrolling.\n // When at \"top\", we need to enable drag to close. When `undefined`, the element is not scrollable and can be dragged, too.\n const disableDrag = scrollPosition === \"middle\" || scrollPosition === \"bottom\";\n\n const { innerOpen } = useInnerOpen(isShown);\n useKeepScrollPositionOnPageHide(innerOpen);\n\n const elementFocusedBeforeOpen = useRef<HTMLElement | null>(null);\n\n // Radix hands focus back to `Dialog.Trigger` on close, and this sheet has none: it is opened through `open`.\n // Both ends are taken over here so that the sheet itself is focused and the element that opened it gets focus back.\n const focusSheet = (event: Event) => {\n event.preventDefault();\n elementFocusedBeforeOpen.current = document.activeElement as HTMLElement | null;\n (event.target as HTMLElement).focus();\n };\n\n // Radix restores focus when its focus scope unmounts, which `forceMount` defers until react-modal-sheet has\n // animated the sheet away - and never at all where that animation does not settle. Closing is the reliable signal.\n const keepFocusWhereItIs = (event: Event) => event.preventDefault();\n\n useEffect(() => {\n if (innerOpen) return;\n elementFocusedBeforeOpen.current?.focus();\n elementFocusedBeforeOpen.current = null;\n }, [innerOpen]);\n\n const handleOpenChange = (nextOpen: boolean) => {\n if (!nextOpen) onClose();\n };\n\n return (\n <DialogPrimitive.Root open={innerOpen} onOpenChange={handleOpenChange}>\n <Sheet\n isOpen={innerOpen}\n onClose={onClose}\n className={root()}\n detent=\"content\"\n data-bpds=\"bottom-sheet\"\n prefersReducedMotion={prefersReducedMotion}\n style={{\n // We remove `pointer-events` handling from the library because it interfers with a lot of things like opened Selects that wouldn't close etc.\n pointerEvents: undefined,\n // When removing react-modal-sheet's pointerEvents handling, we need to adjust visibility because we can no longer rely on `pointer-events: none` being set on the wrapper that spans the whole page even when closed.\n visibility: innerOpen ? \"visible\" : \"hidden\",\n zIndex: zIndex,\n }}\n avoidKeyboard={false}\n >\n {/* `forceMount` leaves the mounting to the sheet, whose state machine keeps the container around for the closing animation. */}\n <DialogPrimitive.Content\n forceMount\n asChild\n aria-modal\n aria-describedby={undefined}\n tabIndex={-1}\n onOpenAutoFocus={focusSheet}\n onCloseAutoFocus={keepFocusWhereItIs}\n >\n <Sheet.Container className={container()} ref={ref}>\n <Sheet.Header unstyled className={dragHandleContainer()}>\n <Sheet.DragIndicator unstyled className={dragHandle()} />\n </Sheet.Header>\n <ZIndexContext.Provider value={zIndex}>\n <BottomSheetContext.Provider value={{ scrollRef, scrollPosition, onClose, onBack, disableDrag }}>\n <Sheet.Content\n className={content()}\n // disable default scrolling\n disableScroll\n // Dragging is still managed by `Sheet.Content` so we control it here\n disableDrag={disableDrag}\n >\n <div\n className={contentWrapper()}\n // Apply keyboard height as padding bottom to keep content above the keyboard\n style={{ paddingBottom: \"max(var(--keyboard-inset-height, 0rem), var(--app-safe-area-inset-bottom, 1rem))\" }}\n >\n {children}\n </div>\n </Sheet.Content>\n </BottomSheetContext.Provider>\n </ZIndexContext.Provider>\n </Sheet.Container>\n </DialogPrimitive.Content>\n {/* TODO: Deactivate the animation, when the user prefers reduced motion: https://github.com/Temzasse/react-modal-sheet/issues/227 */}\n {/* The backdrop carries no handler of its own: Radix dismisses the dialog on a press outside of its content. */}\n <Sheet.Backdrop className={backdrop()} />\n </Sheet>\n </DialogPrimitive.Root>\n );\n};\n\nexport default BottomSheetRoot;\n\nexport const Title = ({ children, subline, level: Level = \"h3\" }: SheetTitleProps) => {\n const { onBack, onClose } = useConsumeBottomSheet();\n const { header, titleAndIcons } = generateClasses();\n return (\n <div className={header()}>\n <div className={titleAndIcons()}>\n {onBack && <IconButton onClick={onBack} icon={<ArrowLeftIcon />} label=\"Zurück\" variant=\"tertiary\" size=\"small\" />}\n <DialogPrimitive.Title asChild>\n <div className=\"grow\">\n <Level className=\"typography-bonprix-h6 my-0 line-clamp-2 text-start text-clr-on-bg-high\">{children}</Level>\n </div>\n </DialogPrimitive.Title>\n <IconButton onClick={onClose} icon={<CloserIcon />} label=\"Schließen\" variant=\"tertiary\" size=\"small\" />\n </div>\n {subline && <p className=\"typography-body1 my-0 text-start text-clr-on-bg-high\">{subline}</p>}\n </div>\n );\n};\n\nexport const Content = ({ children, disableHorizontalPadding = false }: SheetContentProps) => {\n const { scrollRef: setScrollRef, disableDrag } = useConsumeBottomSheet();\n const { scrollArea } = generateClasses({ disableHorizontalPadding });\n return (\n <div\n ref={setScrollRef}\n className={scrollArea()}\n // react-modal-sheet writes this same property imperatively, but only once it has measured the element as\n // scrollable - and it bails before doing so on every open where that measurement is not ready yet, which\n // leaves the browser free to claim the downward swipe and cancel the drag. Setting it here closes that gap.\n style={{ touchAction: disableDrag ? \"auto\" : \"pan-down\" }}\n data-bpds-disable-horizontal-padding={disableHorizontalPadding}\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\nexport const ButtonSection = ({ children }: SheetButtonSectionProps) => {\n return <div className=\"button-section flex w-full shrink-0 touch-pan-down flex-col gap-3 px-4 pt-4\">{children}</div>;\n};\n\nexport const PrimaryButton = <C extends ElementType>({\n children,\n icon,\n iconPosition,\n loading,\n component = \"button\" as C,\n ...props\n}: SheetPrimaryButtonProps<C>) => {\n const Component: ElementType = component;\n const { onClick, ...otherProps } = props;\n const { onClose } = useConsumeBottomSheet();\n const handleClick = (event: React.MouseEvent) => {\n // oxlint-disable-next-line @typescript-eslint/no-unsafe-call\n onClick?.(event);\n onClose();\n };\n return (\n <Button\n component={Component}\n {...otherProps}\n variant=\"primary\"\n onClick={handleClick}\n icon={icon}\n iconPosition={iconPosition}\n size=\"large\"\n loading={loading}\n >\n {children}\n </Button>\n );\n};\n\nexport const SecondaryButton = <C extends ElementType>({\n children,\n icon,\n iconPosition,\n component = \"button\" as C,\n ...props\n}: SheetButtonProps<C>) => {\n const Component: ElementType = component;\n const { onClose } = useConsumeBottomSheet();\n return (\n <Button component={Component} {...props} variant=\"secondary\" onClick={onClose} icon={icon} iconPosition={iconPosition} size=\"large\">\n {children}\n </Button>\n );\n};\n\nBottomSheetRoot.displayName = \"BottomSheet\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,IAAMO,IAAkBC,EAAG;CACzB,OAAO;EACL,MAAM;EAC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ext","useConsumeBottomSheet","useCreateBottomSheet","useKeepScrollPositionOnPageHide","DialogPrimitive","Button","IconButton","generateClasses","tv","backdrop","BottomSheetRoot","isOpen","warnDeprecated","prefersReducedMotion","usePrefersReducedMotion","open","disableDrag","scrollPosition","useInnerOpen","isShown","innerOpen","contentRef","useRef","useFocusReturn","useEffect","returnFocus","nextOpen","onClose","Sheet","root","event","container","dragHandleContainer","dragHandle","ZIndexContext","zIndex","content","contentWrapper","Title","Level","header","titleAndIcons","onBack","ArrowLeftIcon","backButtonLabel","CloserIcon","closeButtonLabel","subline","Content","setScrollRef","scrollArea","disableHorizontalPadding","ButtonSection","PrimaryButton","props","Component","component","otherProps","handleClick","onClick","SecondaryButton"],"sources":["../../src/BottomSheetRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport React, { useEffect, useRef, type ComponentProps, type ElementType, type ReactNode, type RefObject } from \"react\";\nimport { Sheet } from \"react-modal-sheet\";\nimport { tv } from \"tailwind-variants\";\n\nimport { backdrop } from \"@bonprix-ds/internal-components\";\nimport Button from \"@bonprix-ds/react-button\";\nimport { type IconOrElement } from \"@bonprix-ds/react-icon\";\nimport IconButton from \"@bonprix-ds/react-icon-button\";\nimport { ArrowLeftIcon, CloserIcon } from \"@bonprix-ds/react-icon/icons\";\nimport { TitleLevel, useFocusReturn, useInnerOpen, usePrefersReducedMotion, ZIndexContext } from \"@bonprix-ds/utils\";\nimport { warnDeprecated } from \"@bonprix-ds/utils/deprecation\";\n\nimport BottomSheetContext from \"./BottomSheetContext\";\nimport useConsumeBottomSheet from \"./useConsumeBottomSheet\";\nimport useCreateBottomSheet from \"./useCreateBottomSheet\";\nimport useKeepScrollPositionOnPageHide from \"./useKeepScrollPositionOnPageHide\";\n\nimport \"./BottomSheet.css\";\n\nconst generateClasses = tv({\n slots: {\n root: \"preflight block\",\n container: \"max-h-[calc(100%-4rem)] rounded-none bg-clr-bg-modal shadow-none outline-none\",\n header: \"px-4 py-3\",\n titleAndIcons: \"flex touch-pan-down items-center gap-2\",\n contentWrapper: \"flex w-full flex-col\",\n content: [\n \"typography-body1 text-clr-primary\",\n // scroller must be a flexbox to fix scrollbar\n // scroller needs some padding to not cut off the focus-ring\n \"*:-mx-0.5 *:flex *:px-0.5\",\n // scroller must set min-h-0 in order to make scrolling work inside our flex context\n \"*:min-h-0\",\n ],\n dragHandleContainer: \"flex h-6 shrink-0 items-center justify-center\",\n dragHandle: \"h-1 w-8 rounded-full bg-clr-on-bg-low\",\n backdrop: backdrop(),\n scrollArea: \"scroll-area relative\",\n },\n variants: {\n disableHorizontalPadding: {\n false: { scrollArea: \"px-4\" },\n true: \"\",\n },\n },\n});\n\ninterface SheetProps {\n /** All of the subcomponents should be placed inside this property. */\n children: ReactNode;\n /** Callback function, that is triggered when the sheet is attempted to be closed.\n *\n * It will be called in following cases:\n * - Click on backdrop\n * - Press of the `Escape` key\n * - Swipe down to close\n * - Click on \"close\" icon button in the upper-right corner\n * - Click on any button (PrimaryButton or SecondaryButton)\n *\n * Should be used in conjunction with `open`.\n *\n * Once the sheet has closed, focus returns to the element that had it before the sheet opened. */\n onClose: () => void;\n /** Callback to execute when clicking back icon. */\n onBack?: () => void;\n /** The z-index of the sheet.. */\n zIndex?: number;\n /** The accessible name of the close button. */\n closeButtonLabel?: string;\n /** The accessible name of the back button. */\n backButtonLabel?: string;\n}\n\ntype OpenProps = SheetProps & {\n /** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */\n open: boolean;\n /** @deprecated [is-open-prop] Use `open` instead. */\n isOpen?: never;\n};\n\ntype DeprecatedOpenProps = SheetProps & {\n open?: never;\n /**\n * Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property.\n * @deprecated [is-open-prop] Use `open` instead.\n */\n isOpen: boolean;\n};\n\nexport interface SheetTitleProps {\n /** The text content. */\n children: string;\n /** An optional subline that is displayed right below the title. */\n subline?: string;\n /** The heading level for the title. */\n level?: TitleLevel;\n}\n\nexport interface SheetButtonSectionProps {\n /** Primary and secondary buttons should be placed inside this section. */\n children: ReactNode;\n}\n\nexport interface SheetContentProps {\n /** The content of the content section. */\n children: ReactNode;\n /** If `true`, the horizontal padding around the content will be removed. */\n disableHorizontalPadding?: boolean;\n}\n\nexport interface SheetButtonBaseProps {\n /** The label of the button. */\n children: string;\n /** If used, an icon will be additionally shown. The value is either a name of one icon from our icon set or an inline `<svg>` element. */\n icon?: IconOrElement;\n /** The position of the icon relative to the content. */\n iconPosition?: \"start\" | \"end\";\n}\n\nexport type SheetButtonProps<C extends ElementType> = SheetButtonBaseProps & {\n /** The semantic component to render the Button. Preferrably `\"button\"`. Native props will be passed to this component. */\n component?: C;\n} & Omit<ComponentProps<C>, keyof SheetButtonBaseProps | \"component\">;\n\ntype SheetPrimaryButtonProps<C extends ElementType> = SheetButtonProps<C> & {\n /** If `true`, a loading spinner will be shown instead of the content. */\n loading?: boolean;\n};\n\nexport type Props = (DeprecatedOpenProps | OpenProps) & {\n /** A reference to the root element of the sheet. */\n ref?: RefObject<HTMLDivElement>;\n};\n\nconst BottomSheetRoot = ({\n children,\n open,\n isOpen,\n onClose,\n onBack,\n zIndex = 9999,\n ref,\n closeButtonLabel = \"Schließen\",\n backButtonLabel = \"Zurück\",\n}: Props) => {\n if (isOpen !== undefined) warnDeprecated(\"is-open-prop\");\n const prefersReducedMotion = usePrefersReducedMotion();\n const { root, container, dragHandleContainer, dragHandle, content, contentWrapper, backdrop } = generateClasses();\n const { isShown, scrollRef, scrollPosition } = useCreateBottomSheet({ open: open ?? isOpen ?? false });\n\n // When \"middle\" or \"bottom\", dragging is disabled to allow for regular scrolling.\n // When at \"top\", we need to enable drag to close. When `undefined`, the element is not scrollable and can be dragged, too.\n const disableDrag = scrollPosition === \"middle\" || scrollPosition === \"bottom\";\n\n const { innerOpen } = useInnerOpen(isShown);\n useKeepScrollPositionOnPageHide(innerOpen);\n\n const contentRef = useRef<HTMLDivElement>(null);\n const { returnFocus } = useFocusReturn(innerOpen, contentRef);\n\n // Radix's `onCloseAutoFocus` waits until react-modal-sheet has animated the sheet away under `forceMount` - and never\n // fires where that animation does not settle. Closing is the reliable signal.\n useEffect(() => {\n if (!innerOpen) returnFocus();\n }, [innerOpen, returnFocus]);\n\n const focusSheet = (event: Event) => {\n event.preventDefault();\n (event.target as HTMLElement).focus();\n };\n\n const handleOpenChange = (nextOpen: boolean) => {\n if (!nextOpen) onClose();\n };\n\n return (\n <DialogPrimitive.Root open={innerOpen} onOpenChange={handleOpenChange}>\n <Sheet\n isOpen={innerOpen}\n onClose={onClose}\n className={root()}\n detent=\"content\"\n data-bpds=\"bottom-sheet\"\n prefersReducedMotion={prefersReducedMotion}\n style={{\n // We remove `pointer-events` handling from the library because it interfers with a lot of things like opened Selects that wouldn't close etc.\n pointerEvents: undefined,\n // When removing react-modal-sheet's pointerEvents handling, we need to adjust visibility because we can no longer rely on `pointer-events: none` being set on the wrapper that spans the whole page even when closed.\n visibility: innerOpen ? \"visible\" : \"hidden\",\n zIndex: zIndex,\n }}\n avoidKeyboard={false}\n >\n {/* `forceMount` leaves the mounting to the sheet, whose state machine keeps the container around for the closing animation. */}\n <DialogPrimitive.Content\n ref={contentRef}\n forceMount\n asChild\n aria-modal\n aria-describedby={undefined}\n tabIndex={-1}\n onOpenAutoFocus={focusSheet}\n >\n <Sheet.Container className={container()} ref={ref}>\n <Sheet.Header unstyled className={dragHandleContainer()}>\n <Sheet.DragIndicator unstyled className={dragHandle()} />\n </Sheet.Header>\n <ZIndexContext.Provider value={zIndex}>\n <BottomSheetContext.Provider\n value={{ scrollRef, scrollPosition, onClose, onBack, disableDrag, closeButtonLabel, backButtonLabel }}\n >\n <Sheet.Content\n className={content()}\n // disable default scrolling\n disableScroll\n // Dragging is still managed by `Sheet.Content` so we control it here\n disableDrag={disableDrag}\n >\n <div\n className={contentWrapper()}\n // Apply keyboard height as padding bottom to keep content above the keyboard\n style={{ paddingBottom: \"max(var(--keyboard-inset-height, 0rem), var(--app-safe-area-inset-bottom, 1rem))\" }}\n >\n {children}\n </div>\n </Sheet.Content>\n </BottomSheetContext.Provider>\n </ZIndexContext.Provider>\n </Sheet.Container>\n </DialogPrimitive.Content>\n {/* TODO: Deactivate the animation, when the user prefers reduced motion: https://github.com/Temzasse/react-modal-sheet/issues/227 */}\n {/* The backdrop carries no handler of its own: Radix dismisses the dialog on a press outside of its content. */}\n <Sheet.Backdrop className={backdrop()} />\n </Sheet>\n </DialogPrimitive.Root>\n );\n};\n\nexport default BottomSheetRoot;\n\nexport const Title = ({ children, subline, level: Level = \"h3\" }: SheetTitleProps) => {\n const { onBack, onClose, closeButtonLabel, backButtonLabel } = useConsumeBottomSheet();\n const { header, titleAndIcons } = generateClasses();\n return (\n <div className={header()}>\n <div className={titleAndIcons()}>\n {onBack && <IconButton onClick={onBack} icon={<ArrowLeftIcon />} label={backButtonLabel} variant=\"tertiary\" size=\"small\" />}\n <DialogPrimitive.Title asChild>\n <div className=\"grow\">\n <Level className=\"typography-bonprix-h6 my-0 line-clamp-2 text-start text-clr-on-bg-high\">{children}</Level>\n </div>\n </DialogPrimitive.Title>\n <IconButton onClick={onClose} icon={<CloserIcon />} label={closeButtonLabel} variant=\"tertiary\" size=\"small\" />\n </div>\n {subline && <p className=\"typography-body1 my-0 text-start text-clr-on-bg-high\">{subline}</p>}\n </div>\n );\n};\n\nexport const Content = ({ children, disableHorizontalPadding = false }: SheetContentProps) => {\n const { scrollRef: setScrollRef, disableDrag } = useConsumeBottomSheet();\n const { scrollArea } = generateClasses({ disableHorizontalPadding });\n return (\n <div\n ref={setScrollRef}\n className={scrollArea()}\n // react-modal-sheet writes this same property imperatively, but only once it has measured the element as\n // scrollable - and it bails before doing so on every open where that measurement is not ready yet, which\n // leaves the browser free to claim the downward swipe and cancel the drag. Setting it here closes that gap.\n style={{ touchAction: disableDrag ? \"auto\" : \"pan-down\" }}\n data-bpds-disable-horizontal-padding={disableHorizontalPadding}\n tabIndex={0}\n >\n {children}\n </div>\n );\n};\n\nexport const ButtonSection = ({ children }: SheetButtonSectionProps) => {\n return <div className=\"button-section flex w-full shrink-0 touch-pan-down flex-col gap-3 px-4 pt-4\">{children}</div>;\n};\n\nexport const PrimaryButton = <C extends ElementType>({\n children,\n icon,\n iconPosition,\n loading,\n component = \"button\" as C,\n ...props\n}: SheetPrimaryButtonProps<C>) => {\n const Component: ElementType = component;\n const { onClick, ...otherProps } = props;\n const { onClose } = useConsumeBottomSheet();\n const handleClick = (event: React.MouseEvent) => {\n // oxlint-disable-next-line @typescript-eslint/no-unsafe-call\n onClick?.(event);\n onClose();\n };\n return (\n <Button\n component={Component}\n {...otherProps}\n variant=\"primary\"\n onClick={handleClick}\n icon={icon}\n iconPosition={iconPosition}\n size=\"large\"\n loading={loading}\n >\n {children}\n </Button>\n );\n};\n\nexport const SecondaryButton = <C extends ElementType>({\n children,\n icon,\n iconPosition,\n component = \"button\" as C,\n ...props\n}: SheetButtonProps<C>) => {\n const Component: ElementType = component;\n const { onClose } = useConsumeBottomSheet();\n return (\n <Button component={Component} {...props} variant=\"secondary\" onClick={onClose} icon={icon} iconPosition={iconPosition} size=\"large\">\n {children}\n </Button>\n );\n};\n\nBottomSheetRoot.displayName = \"BottomSheet\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsBA,IAAMO,IAAkBC,EAAG;CACzB,OAAO;EACL,MAAM;EACN,WAAW;EACX,QAAQ;EACR,eAAe;EACf,gBAAgB;EAChB,SAAS;GACP;GAGA;GAEA;EACF;EACA,qBAAqB;EACrB,YAAY;EACZ,UAAUC,EAAS;EACnB,YAAY;CACd;CACA,UAAU,EACR,0BAA0B;EACxB,OAAO,EAAE,YAAY,OAAO;EAC5B,MAAM;CACR,EACF;AACF,CAAC,GAyFKC,KAAmB,EACvB,aACA,SACA,WACA,YACA,WACA,YAAS,MACT,QACA,sBAAmB,aACnB,qBAAkB,eACP;CACX,AAAIC,MAAW,KAAA,KAAWC,EAAe,cAAc;CACvD,IAAMC,IAAuBC,EAAwB,GAC/C,EA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E,KAAK0C;EACL,WAAWC,EAAW;EAItB,OAAO,EAAE,aAAalC,IAAc,SAAS,WAAW;EACxD,wCAAsCmC;EACtC,UAAU;EAET;CACE,CAAA;AAET,GAEaC,KAAiB,EAAE,kBACvB,kBAAC,OAAD;CAAK,WAAU;CAA+E;AAAc,CAAA,GAGxGC,KAAwC,EACnD,aACA,SACA,iBACA,YACA,eAAY,UACZ,GAAGC,QAC6B;CAChC,IAAMC,IAAyBC,GACzB,EAAE,YAAS,GAAGC,MAAeH,GAC7B,EAAE,eAAYrD,EAAsB,GACpCyD,KAAe,MAA4B;EAG/C,AADAC,IAAU7B,CAAK,GACfH,EAAQ;CACV;CACA,OACE,kBAACtB,GAAD;EACE,WAAWkD;EACX,GAAIE;EACJ,SAAQ;EACR,SAASC;EACH;EACQ;EACd,MAAK;EACI;EAER;CACK,CAAA;AAEZ,GAEaE,KAA0C,EACrD,aACA,SACA,iBACA,eAAY,UACZ,GAAGN,QACsB;CACzB,IAAMC,IAAyBC,GACzB,EAAE,eAAYvD,EAAsB;CAC1C,OACE,kBAACI,GAAD;EAAQ,WAAWkD;EAAW,GAAID;EAAO,SAAQ;EAAY,SAAS3B;EAAe;EAAoB;EAAc,MAAK;EACzH;CACK,CAAA;AAEZ;AAEA,EAAgB,cAAc"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import e from "./BottomSheetContext.js";
|
|
2
2
|
import { useContext as t } from "react";
|
|
3
|
-
|
|
3
|
+
// src/useConsumeBottomSheet.ts
|
|
4
4
|
var n = () => t(e);
|
|
5
|
-
//#endregion
|
|
6
5
|
export { n as default };
|
|
7
6
|
|
|
8
7
|
//# sourceMappingURL=useConsumeBottomSheet.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useEffect as e } from "react";
|
|
2
2
|
import { useScrollPosition as t, useVirtualKeyboard as n } from "react-modal-sheet";
|
|
3
3
|
import { useBreakpointBetween as r } from "@bonprix-ds/utils";
|
|
4
|
-
|
|
4
|
+
// src/useCreateBottomSheet.ts
|
|
5
5
|
var i = ({ open: i }) => {
|
|
6
6
|
let a = r("s", "m") && i, { scrollRef: o, scrollPosition: s } = t({ isEnabled: a });
|
|
7
7
|
return n({ isEnabled: i }), e(() => {
|
|
@@ -12,7 +12,6 @@ var i = ({ open: i }) => {
|
|
|
12
12
|
scrollPosition: s
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
|
-
//#endregion
|
|
16
15
|
export { i as default };
|
|
17
16
|
|
|
18
17
|
//# sourceMappingURL=useCreateBottomSheet.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect as e } from "react";
|
|
2
|
-
|
|
2
|
+
// src/useKeepScrollPositionOnPageHide.ts
|
|
3
3
|
var t = (e) => e.stopImmediatePropagation(), n = (n) => {
|
|
4
4
|
e(() => {
|
|
5
5
|
if (!n) return;
|
|
@@ -20,7 +20,6 @@ var t = (e) => e.stopImmediatePropagation(), n = (n) => {
|
|
|
20
20
|
};
|
|
21
21
|
}, [n]);
|
|
22
22
|
};
|
|
23
|
-
//#endregion
|
|
24
23
|
export { n as default };
|
|
25
24
|
|
|
26
25
|
//# sourceMappingURL=useKeepScrollPositionOnPageHide.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonprix-ds/react-bottom-sheet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "BottomSheet component, implemented in React, for the Bonprix Design System.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -41,21 +41,21 @@
|
|
|
41
41
|
"provenance": true
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@
|
|
45
|
-
"react-
|
|
46
|
-
"@bonprix-ds/
|
|
47
|
-
"@bonprix-ds/react-button": "1.
|
|
48
|
-
"@bonprix-ds/
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
44
|
+
"@bonprix-ds/internal-components": "0.2.6",
|
|
45
|
+
"@bonprix-ds/react-button": "1.1.6",
|
|
46
|
+
"@bonprix-ds/react-icon": "1.3.3",
|
|
47
|
+
"@bonprix-ds/react-icon-button": "1.2.6",
|
|
48
|
+
"@bonprix-ds/utils": "0.6.0",
|
|
49
|
+
"@radix-ui/react-dialog": "1.3.1",
|
|
50
|
+
"react-modal-sheet": "5.6.0"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
+
"@bonprix-ds/vite-config": "0.0.0",
|
|
53
54
|
"@testing-library/dom": "10.4.2",
|
|
54
55
|
"@testing-library/react": "16.3.3",
|
|
55
56
|
"@types/react": "19.3.0",
|
|
56
|
-
"vite": "8.3.
|
|
57
|
-
"vitest": "5.0.5"
|
|
58
|
-
"@bonprix-ds/vite-config": "0.0.0"
|
|
57
|
+
"vite": "8.3.5",
|
|
58
|
+
"vitest": "5.0.5"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
61
|
"react": "^19",
|