@bonprix-ds/react-bottom-sheet 1.2.2 → 1.3.1

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 CHANGED
@@ -1,2 +1 @@
1
- import e from "./src/BottomSheet.js";
2
- export { e as default };
1
+ export { default } from "./src/BottomSheet.js";
@@ -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
- //#region src/BottomSheet.tsx
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
- //#region src/BottomSheetContext.ts
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":";;;AAaA,IAAMA,IAAqBC,EAAuC;CAChE,iBAAiB;CACjB,gBAAgB,KAAA;CAChB,eAAe;CACf,cAAc;CACd,aAAa;AACf,CAAC"}
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;
@@ -2,7 +2,7 @@
2
2
  import e from "./BottomSheetContext.js";
3
3
  import t from "./useConsumeBottomSheet.js";
4
4
  import n from "./useCreateBottomSheet.js";
5
- import r from "./useKeepScrollPositionOnPageHide.js";
5
+ import r from "./useKeepScrollPositionOnLeave.js";
6
6
  import { useEffect as i, useRef as a } from "react";
7
7
  import * as o from "@radix-ui/react-dialog";
8
8
  import { Sheet as s } from "react-modal-sheet";
@@ -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, useInnerOpen as h, usePrefersReducedMotion as g } from "@bonprix-ds/utils";
15
- import { warnDeprecated as _ } from "@bonprix-ds/utils/deprecation";
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 v, jsxs as y } from "react/jsx-runtime";
18
- //#region src/BottomSheetRoot.tsx
19
- var b = c({
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,68 @@ var b = c({
37
37
  false: { scrollArea: "px-4" },
38
38
  true: ""
39
39
  } }
40
- }), x = ({ children: t, open: c, isOpen: l, onClose: u, onBack: d, zIndex: f = 9999, ref: p }) => {
41
- l !== void 0 && _("is-open-prop");
42
- let x = g(), { root: S, container: C, dragHandleContainer: w, dragHandle: T, content: E, contentWrapper: D, backdrop: O } = b(), { isShown: k, scrollRef: A, scrollPosition: j } = n({ open: c ?? l ?? !1 }), M = j === "middle" || j === "bottom", { innerOpen: N } = h(k);
43
- r(N);
44
- let P = a(null);
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), L = r(I), R = a(null), { returnFocus: z } = h(I, R);
45
43
  return i(() => {
46
- N || (P.current?.focus(), P.current = null);
47
- }, [N]), /* @__PURE__ */ v(o.Root, {
48
- open: N,
44
+ I || z();
45
+ }, [I, z]), /* @__PURE__ */ y(o.Root, {
46
+ open: I,
49
47
  onOpenChange: (e) => {
50
48
  e || u();
51
49
  },
52
- children: /* @__PURE__ */ y(s, {
53
- isOpen: N,
50
+ children: /* @__PURE__ */ b(s, {
51
+ isOpen: I,
54
52
  onClose: u,
55
- className: S(),
53
+ className: T(),
56
54
  detent: "content",
57
55
  "data-bpds": "bottom-sheet",
58
- prefersReducedMotion: x,
56
+ prefersReducedMotion: w,
57
+ disableScrollLocking: L,
59
58
  style: {
60
59
  pointerEvents: void 0,
61
- visibility: N ? "visible" : "hidden",
60
+ visibility: I ? "visible" : "hidden",
62
61
  zIndex: f
63
62
  },
64
63
  avoidKeyboard: !1,
65
- children: [/* @__PURE__ */ v(o.Content, {
64
+ children: [/* @__PURE__ */ y(o.Content, {
65
+ ref: R,
66
66
  forceMount: !0,
67
67
  asChild: !0,
68
68
  "aria-modal": !0,
69
69
  "aria-describedby": void 0,
70
70
  tabIndex: -1,
71
71
  onOpenAutoFocus: (e) => {
72
- e.preventDefault(), P.current = document.activeElement, e.target.focus();
72
+ e.preventDefault(), e.target.focus();
73
73
  },
74
- onCloseAutoFocus: (e) => e.preventDefault(),
75
- children: /* @__PURE__ */ y(s.Container, {
76
- className: C(),
74
+ children: /* @__PURE__ */ b(s.Container, {
75
+ className: E(),
77
76
  ref: p,
78
- children: [/* @__PURE__ */ v(s.Header, {
77
+ children: [/* @__PURE__ */ y(s.Header, {
79
78
  unstyled: !0,
80
- className: w(),
81
- children: /* @__PURE__ */ v(s.DragIndicator, {
79
+ className: D(),
80
+ children: /* @__PURE__ */ y(s.DragIndicator, {
82
81
  unstyled: !0,
83
- className: T()
82
+ className: O()
84
83
  })
85
- }), /* @__PURE__ */ v(m.Provider, {
84
+ }), /* @__PURE__ */ y(m.Provider, {
86
85
  value: f,
87
- children: /* @__PURE__ */ v(e.Provider, {
86
+ children: /* @__PURE__ */ y(e.Provider, {
88
87
  value: {
89
- scrollRef: A,
90
- scrollPosition: j,
88
+ scrollRef: N,
89
+ scrollPosition: P,
91
90
  onClose: u,
92
91
  onBack: d,
93
- disableDrag: M
92
+ disableDrag: F,
93
+ closeButtonLabel: S,
94
+ backButtonLabel: C
94
95
  },
95
- children: /* @__PURE__ */ v(s.Content, {
96
- className: E(),
96
+ children: /* @__PURE__ */ y(s.Content, {
97
+ className: k(),
97
98
  disableScroll: !0,
98
- disableDrag: M,
99
- children: /* @__PURE__ */ v("div", {
100
- className: D(),
99
+ disableDrag: F,
100
+ children: /* @__PURE__ */ y("div", {
101
+ className: A(),
101
102
  style: { paddingBottom: "max(var(--keyboard-inset-height, 0rem), var(--app-safe-area-inset-bottom, 1rem))" },
102
103
  children: t
103
104
  })
@@ -105,49 +106,49 @@ var b = c({
105
106
  })
106
107
  })]
107
108
  })
108
- }), /* @__PURE__ */ v(s.Backdrop, { className: O() })]
109
+ }), /* @__PURE__ */ y(s.Backdrop, { className: j() })]
109
110
  })
110
111
  });
111
- }, S = ({ children: e, subline: n, level: r = "h3" }) => {
112
- let { onBack: i, onClose: a } = t(), { header: s, titleAndIcons: c } = b();
113
- return /* @__PURE__ */ y("div", {
114
- className: s(),
115
- children: [/* @__PURE__ */ y("div", {
116
- className: c(),
112
+ }, C = ({ children: e, subline: n, level: r = "h3" }) => {
113
+ let { onBack: i, onClose: a, closeButtonLabel: s, backButtonLabel: c } = t(), { header: l, titleAndIcons: u } = x();
114
+ return /* @__PURE__ */ b("div", {
115
+ className: l(),
116
+ children: [/* @__PURE__ */ b("div", {
117
+ className: u(),
117
118
  children: [
118
- i && /* @__PURE__ */ v(d, {
119
+ i && /* @__PURE__ */ y(d, {
119
120
  onClick: i,
120
- icon: /* @__PURE__ */ v(f, {}),
121
- label: "Zurück",
121
+ icon: /* @__PURE__ */ y(f, {}),
122
+ label: c,
122
123
  variant: "tertiary",
123
124
  size: "small"
124
125
  }),
125
- /* @__PURE__ */ v(o.Title, {
126
+ /* @__PURE__ */ y(o.Title, {
126
127
  asChild: !0,
127
- children: /* @__PURE__ */ v("div", {
128
+ children: /* @__PURE__ */ y("div", {
128
129
  className: "grow",
129
- children: /* @__PURE__ */ v(r, {
130
+ children: /* @__PURE__ */ y(r, {
130
131
  className: "typography-bonprix-h6 my-0 line-clamp-2 text-start text-clr-on-bg-high",
131
132
  children: e
132
133
  })
133
134
  })
134
135
  }),
135
- /* @__PURE__ */ v(d, {
136
+ /* @__PURE__ */ y(d, {
136
137
  onClick: a,
137
- icon: /* @__PURE__ */ v(p, {}),
138
- label: "Schließen",
138
+ icon: /* @__PURE__ */ y(p, {}),
139
+ label: s,
139
140
  variant: "tertiary",
140
141
  size: "small"
141
142
  })
142
143
  ]
143
- }), n && /* @__PURE__ */ v("p", {
144
+ }), n && /* @__PURE__ */ y("p", {
144
145
  className: "typography-body1 my-0 text-start text-clr-on-bg-high",
145
146
  children: n
146
147
  })]
147
148
  });
148
- }, C = ({ children: e, disableHorizontalPadding: n = !1 }) => {
149
- let { scrollRef: r, disableDrag: i } = t(), { scrollArea: a } = b({ disableHorizontalPadding: n });
150
- return /* @__PURE__ */ v("div", {
149
+ }, w = ({ children: e, disableHorizontalPadding: n = !1 }) => {
150
+ let { scrollRef: r, disableDrag: i } = t(), { scrollArea: a } = x({ disableHorizontalPadding: n });
151
+ return /* @__PURE__ */ y("div", {
151
152
  ref: r,
152
153
  className: a(),
153
154
  style: { touchAction: i ? "auto" : "pan-down" },
@@ -155,14 +156,14 @@ var b = c({
155
156
  tabIndex: 0,
156
157
  children: e
157
158
  });
158
- }, w = ({ children: e }) => /* @__PURE__ */ v("div", {
159
+ }, T = ({ children: e }) => /* @__PURE__ */ y("div", {
159
160
  className: "button-section flex w-full shrink-0 touch-pan-down flex-col gap-3 px-4 pt-4",
160
161
  children: e
161
- }), T = ({ children: e, icon: n, iconPosition: r, loading: i, component: a = "button", ...o }) => {
162
+ }), E = ({ children: e, icon: n, iconPosition: r, loading: i, component: a = "button", ...o }) => {
162
163
  let s = a, { onClick: c, ...l } = o, { onClose: d } = t(), f = (e) => {
163
164
  c?.(e), d();
164
165
  };
165
- return /* @__PURE__ */ v(u, {
166
+ return /* @__PURE__ */ y(u, {
166
167
  component: s,
167
168
  ...l,
168
169
  variant: "primary",
@@ -173,9 +174,9 @@ var b = c({
173
174
  loading: i,
174
175
  children: e
175
176
  });
176
- }, E = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...a }) => {
177
+ }, D = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...a }) => {
177
178
  let o = i, { onClose: s } = t();
178
- return /* @__PURE__ */ v(u, {
179
+ return /* @__PURE__ */ y(u, {
179
180
  component: o,
180
181
  ...a,
181
182
  variant: "secondary",
@@ -186,8 +187,7 @@ var b = c({
186
187
  children: e
187
188
  });
188
189
  };
189
- x.displayName = "BottomSheet";
190
- //#endregion
191
- export { w as ButtonSection, C as Content, T as PrimaryButton, E as SecondaryButton, S as Title, x as default };
190
+ S.displayName = "BottomSheet";
191
+ export { T as ButtonSection, w as Content, E as PrimaryButton, D as SecondaryButton, C as Title, S as default };
192
192
 
193
193
  //# 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;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,GAmFKC,KAAmB,EAAE,aAAU,SAAM,WAAQ,YAAS,WAAQ,YAAS,MAAM,aAAiB;CAClG,AAAIC,MAAW,KAAA,KAAWC,EAAe,cAAc;CACvD,IAAMC,IAAuBC,EAAwB,GAC/C,EAAE,SAAM,cAAW,wBAAqB,eAAY,YAAS,mBAAgB,gBAAaP,EAAgB,GAC1G,EAAE,YAAS,cAAW,sBAAmBL,EAAqB,EAAE,MAAMa,KAAQJ,KAAU,GAAM,CAAC,GAI/FK,IAAcC,MAAmB,YAAYA,MAAmB,UAEhE,EAAE,iBAAcC,EAAaC,CAAO;CAC1C,EAAgCC,CAAS;CAEzC,IAAMC,IAA2BC,EAA2B,IAAI;CAwBhE,OAVAC,QAAgB;EACd,AAAIH,MACJC,EAAyB,SAAS,MAAM,GACxC,EAAyB,UAAU;CACrC,GAAG,CAACD,CAAS,CAAC,GAOZ,kBAAChB,EAAgB,MAAjB;EAAsB,MAAMgB;EAAW,eALf,MAAsB;GAC9C,AAAKI,KAAUC,EAAQ;EACzB;EAII,UAAA,kBAACC,GAAD;GACE,QAAQN;GACC;GACT,WAAWO,EAAK;GAChB,QAAO;GACP,aAAU;GACY;GACtB,OAAO;IAEL,eAAe,KAAA;IAEf,YAAYP,IAAY,YAAY;IAC5B;GACV;GACA,eAAe;GAdjB,UAAA,CAiBE,kBA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AD;EAAQ,WAAW8C;EAAW,GAAID;EAAO,SAAQ;EAAY,SAASzB;EAAe;EAAoB;EAAc,MAAK;EACzH;CACK,CAAA;AAEZ;AAEA,EAAgB,cAAc"}
1
+ {"version":3,"file":"BottomSheetRoot.js","names":["BottomSheetContext","useConsumeBottomSheet","useCreateBottomSheet","useKeepScrollPositionOnLeave","DialogPrimitive","Button","IconButton","generateClasses","tv","backdrop","BottomSheetRoot","isOpen","warnDeprecated","prefersReducedMotion","usePrefersReducedMotion","open","disableDrag","scrollPosition","useInnerOpen","isShown","disableScrollLocking","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, { type ComponentProps, type ElementType, MouseEvent, type ReactNode, type RefObject, useEffect, useRef } 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 useKeepScrollPositionOnLeave from \"./useKeepScrollPositionOnLeave\";\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 const disableScrollLocking = useKeepScrollPositionOnLeave(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 disableScrollLocking={disableScrollLocking}\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: 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,EA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BAAC,KAAD;GAAG,WAAU;GAAwD,UAAAA;EAAW,CAAA,CACzF;;AAET,GAEaC,KAAW,EAAE,aAAU,8BAA2B,SAA+B;CAC5F,IAAM,EAAE,WAAWC,GAAc,mBAAgBjD,EAAsB,GACjE,EAAE,kBAAeM,EAAgB,EAAE,4BAAyB,CAAC;CACnE,OACE,kBAAC,OAAD;EACE,KAAK2C;EACL,WAAWC,EAAW;EAItB,OAAO,EAAE,aAAanC,IAAc,SAAS,WAAW;EACxD,wCAAsCoC;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,eAAYtD,EAAsB,GACpC0D,KAAe,MAAsB;EAGzC,AADAC,IAAU7B,CAAK,GACfH,EAAQ;CACV;CACA,OACE,kBAACvB,GAAD;EACE,WAAWmD;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,eAAYxD,EAAsB;CAC1C,OACE,kBAACI,GAAD;EAAQ,WAAWmD;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
- //#region src/useConsumeBottomSheet.ts
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
- //#region src/useCreateBottomSheet.ts
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
@@ -0,0 +1,2 @@
1
+ declare const useKeepScrollPositionOnLeave: (isOpen: boolean) => boolean;
2
+ export default useKeepScrollPositionOnLeave;
@@ -0,0 +1,23 @@
1
+ import { useEffect as e, useState as t } from "react";
2
+ import { flushSync as n } from "react-dom";
3
+ // src/useKeepScrollPositionOnLeave.ts
4
+ var r = (r) => {
5
+ let [i, a] = t(!1);
6
+ return e(() => {
7
+ if (!r) return;
8
+ let e = () => n(() => a(!0)), t = () => a(!1), i = ({ navigationType: e, destination: t }) => {
9
+ if (!(e === "push" && t.sameDocument) || new URL(t.url).pathname === window.location.pathname) return;
10
+ let n = -parseFloat(document.body.style.marginTop);
11
+ n > 0 && (document.body.style.marginTop = "", window.scrollTo({
12
+ top: n,
13
+ behavior: "instant"
14
+ }));
15
+ };
16
+ return window.addEventListener("pagehide", e), window.addEventListener("pageshow", t), window.navigation?.addEventListener("navigate", i), () => {
17
+ window.removeEventListener("pagehide", e), window.removeEventListener("pageshow", t), window.navigation?.removeEventListener("navigate", i);
18
+ };
19
+ }, [r]), i;
20
+ };
21
+ export { r as default };
22
+
23
+ //# sourceMappingURL=useKeepScrollPositionOnLeave.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useKeepScrollPositionOnLeave.js","names":["useKeepScrollPositionOnLeave","isPageHidden","setIsPageHidden","useState","useEffect","isOpen","hide","flushSync","show","takeShiftOffBeforePush","navigationType","destination","scrollY"],"sources":["../../src/useKeepScrollPositionOnLeave.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\nimport { flushSync } from \"react-dom\";\n\n// On iOS, react-modal-sheet locks the page by scrolling it to the top and shifting `body` up by a negative\n// `margin-top`. The browser saves a page's scroll position as the page is left, so a page that is left in that state\n// is saved at the top, and going back would land there. A page is left in one of two ways:\n//\n// - The browser loads another page, which fires `pagehide`. While the page is hidden, the returned flag turns the\n// lock off through `disableScrollLocking`, so that react-modal-sheet undoes it itself. `flushSync`, because a\n// hidden page may never run another task.\n// - A client-side router pushes a history entry in the same document, which fires `navigate`. Next.js pushes from\n// inside a React commit, where the sheet can neither re-render nor schedule an update, so the shift is taken off by\n// hand, and react-modal-sheet takes off the rest once the sheet closes. A push that keeps the path, as for a sheet\n// that closes on back, leaves the lock on. So does a native link, which fires `navigate` long before `pagehide`:\n// the page stays locked until it is hidden.\n//\n// The shift is read back from `body`'s inline `margin-top`, which is why react-modal-sheet's version is pinned:\n// \"react-modal-sheet still shifts the page on iOS the way useKeepScrollPositionOnLeave reads it\" in\n// BottomSheet.browser.test.tsx fails as soon as an update changes that.\nconst useKeepScrollPositionOnLeave = (isOpen: boolean) => {\n const [isPageHidden, setIsPageHidden] = useState(false);\n\n useEffect(() => {\n if (!isOpen) return;\n\n const hide = () => flushSync(() => setIsPageHidden(true));\n const show = () => setIsPageHidden(false);\n\n const takeShiftOffBeforePush = ({ navigationType, destination }: NavigateEvent) => {\n const isClientSidePush = navigationType === \"push\" && destination.sameDocument;\n if (!isClientSidePush || new URL(destination.url).pathname === window.location.pathname) return;\n\n const scrollY = -parseFloat(document.body.style.marginTop);\n if (!(scrollY > 0)) return;\n\n document.body.style.marginTop = \"\";\n window.scrollTo({ top: scrollY, behavior: \"instant\" });\n };\n\n window.addEventListener(\"pagehide\", hide);\n window.addEventListener(\"pageshow\", show);\n window.navigation?.addEventListener(\"navigate\", takeShiftOffBeforePush);\n\n return () => {\n window.removeEventListener(\"pagehide\", hide);\n window.removeEventListener(\"pageshow\", show);\n window.navigation?.removeEventListener(\"navigate\", takeShiftOffBeforePush);\n };\n }, [isOpen]);\n\n return isPageHidden;\n};\n\nexport default useKeepScrollPositionOnLeave;\n"],"mappings":";;;AAmBA,IAAMA,KAAgC,MAAoB;CACxD,IAAM,CAACC,GAAcC,KAAmBC,EAAS,EAAK;CA8BtD,OA5BAC,QAAgB;EACd,IAAI,CAACC,GAAQ;EAEb,IAAMC,UAAaC,QAAgBL,EAAgB,EAAI,CAAC,GAClDM,UAAaN,EAAgB,EAAK,GAElCO,KAA0B,EAAE,mBAAgB,qBAAiC;GAEjF,IAAI,EADqBC,MAAmB,UAAUC,EAAY,iBACzC,IAAI,IAAIA,EAAY,GAAG,CAAC,CAAC,aAAa,OAAO,SAAS,UAAU;GAEzF,IAAMC,IAAU,CAAC,WAAW,SAAS,KAAK,MAAM,SAAS;GACzD,AAAMA,IAAU,MAEhB,SAAS,KAAK,MAAM,YAAY,IAChC,OAAO,SAAS;IAAE,KAAKA;IAAS,UAAU;GAAU,CAAC;EACvD;EAMA,OAJA,OAAO,iBAAiB,YAAYN,CAAI,GACxC,OAAO,iBAAiB,YAAYE,CAAI,GACxC,OAAO,YAAY,iBAAiB,YAAYC,CAAsB,SAEzD;GAGX,AAFA,OAAO,oBAAoB,YAAYH,CAAI,GAC3C,OAAO,oBAAoB,YAAYE,CAAI,GAC3C,OAAO,YAAY,oBAAoB,YAAYC,CAAsB;EAC3E;CACF,GAAG,CAACJ,CAAM,CAAC,GAEJJ;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-bottom-sheet",
3
- "version": "1.2.2",
3
+ "version": "1.3.1",
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
- "@radix-ui/react-dialog": "1.1.23",
45
- "react-modal-sheet": "5.6.0",
46
- "@bonprix-ds/internal-components": "0.2.5",
47
- "@bonprix-ds/react-button": "1.1.5",
48
- "@bonprix-ds/react-icon": "1.3.2",
49
- "@bonprix-ds/react-icon-button": "1.2.5",
50
- "@bonprix-ds/utils": "0.5.0"
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.3",
57
- "vitest": "5.0.5",
58
- "@bonprix-ds/vite-config": "0.0.0"
57
+ "vite": "8.3.7",
58
+ "vitest": "5.1.0"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "react": "^19",
@@ -1,2 +0,0 @@
1
- declare const useKeepScrollPositionOnPageHide: (isEnabled: boolean) => void;
2
- export default useKeepScrollPositionOnPageHide;
@@ -1,26 +0,0 @@
1
- import { useEffect as e } from "react";
2
- //#region src/useKeepScrollPositionOnPageHide.ts
3
- var t = (e) => e.stopImmediatePropagation(), n = (n) => {
4
- e(() => {
5
- if (!n) return;
6
- let e, r = () => {
7
- let n = -parseFloat(document.body.style.marginTop);
8
- n > 0 && (e = n, window.addEventListener("scroll", t, { capture: !0 }), document.body.style.marginTop = "", document.documentElement.style.overflow = "", window.scrollTo({
9
- top: n,
10
- behavior: "instant"
11
- }));
12
- }, i = (n) => {
13
- n.persisted && e !== void 0 && (window.removeEventListener("scroll", t, { capture: !0 }), document.documentElement.style.overflow = "hidden", document.body.style.marginTop = `-${e}px`, window.scrollTo({
14
- top: 0,
15
- behavior: "instant"
16
- }), e = void 0);
17
- };
18
- return window.addEventListener("pagehide", r), window.addEventListener("pageshow", i), () => {
19
- window.removeEventListener("pagehide", r), window.removeEventListener("pageshow", i), window.removeEventListener("scroll", t, { capture: !0 });
20
- };
21
- }, [n]);
22
- };
23
- //#endregion
24
- export { n as default };
25
-
26
- //# sourceMappingURL=useKeepScrollPositionOnPageHide.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useKeepScrollPositionOnPageHide.js","names":["keepScrollEventsFromTheLock","event","useKeepScrollPositionOnPageHide","isEnabled","lockedScrollY","unlock","scrollY","lockAgain"],"sources":["../../src/useKeepScrollPositionOnPageHide.ts"],"sourcesContent":["import { useEffect } from \"react\";\n\n// The page's scroll event targets `document`, so a capturing listener on `window` runs before react-modal-sheet's\n// own listener on `window`, which scrolls the page back to the top on every scroll while the lock is on. Stopping\n// the event there withholds it from every scroll listener on the page, not just the lock's - which is harmless only\n// because it is in place solely between `pagehide` and `pageshow`, while nothing on the page can be seen.\nconst keepScrollEventsFromTheLock = (event: Event) => event.stopImmediatePropagation();\n\n// On iOS, react-modal-sheet locks the page by scrolling it to the top and shifting `body` up by a negative\n// `margin-top`. A page that is left in that state is saved with its scroll position at the top, so going back\n// would land there. The lock is lifted while the page is hidden, and put back if it returns from the bfcache.\n// The shift is read back from `body`'s inline `margin-top`, which only the lock sets while the sheet is open.\n//\n// All of this mirrors react-modal-sheet's private `preventScrollMobileSafari`, which is why its version is pinned.\n// \"react-modal-sheet still locks the page on iOS the way this hook undoes it\" in BottomSheet.browser.test.tsx runs\n// against the real library and fails as soon as an update changes the lock - check this hook before bumping it.\nconst useKeepScrollPositionOnPageHide = (isEnabled: boolean) => {\n useEffect(() => {\n if (!isEnabled) return;\n\n let lockedScrollY: number | undefined;\n\n const unlock = () => {\n const scrollY = -parseFloat(document.body.style.marginTop);\n if (!(scrollY > 0)) return;\n\n lockedScrollY = scrollY;\n window.addEventListener(\"scroll\", keepScrollEventsFromTheLock, { capture: true });\n document.body.style.marginTop = \"\";\n document.documentElement.style.overflow = \"\";\n window.scrollTo({ top: scrollY, behavior: \"instant\" });\n };\n\n const lockAgain = (event: PageTransitionEvent) => {\n if (!event.persisted || lockedScrollY === undefined) return;\n\n window.removeEventListener(\"scroll\", keepScrollEventsFromTheLock, { capture: true });\n document.documentElement.style.overflow = \"hidden\";\n document.body.style.marginTop = `-${lockedScrollY}px`;\n window.scrollTo({ top: 0, behavior: \"instant\" });\n lockedScrollY = undefined;\n };\n\n window.addEventListener(\"pagehide\", unlock);\n window.addEventListener(\"pageshow\", lockAgain);\n\n return () => {\n window.removeEventListener(\"pagehide\", unlock);\n window.removeEventListener(\"pageshow\", lockAgain);\n window.removeEventListener(\"scroll\", keepScrollEventsFromTheLock, { capture: true });\n };\n }, [isEnabled]);\n};\n\nexport default useKeepScrollPositionOnPageHide;\n"],"mappings":";;AAMA,IAAMA,KAA+B,MAAiBC,EAAM,yBAAyB,GAU/EC,KAAmC,MAAuB;CAC9D,QAAgB;EACd,IAAI,CAACC,GAAW;EAEhB,IAAIC,GAEEC,UAAe;GACnB,IAAMC,IAAU,CAAC,WAAW,SAAS,KAAK,MAAM,SAAS;GACzD,AAAMA,IAAU,MAEhB,IAAgBA,GAChB,OAAO,iBAAiB,UAAUN,GAA6B,EAAE,SAAS,GAAK,CAAC,GAChF,SAAS,KAAK,MAAM,YAAY,IAChC,SAAS,gBAAgB,MAAM,WAAW,IAC1C,OAAO,SAAS;IAAE,KAAKM;IAAS,UAAU;GAAU,CAAC;EACvD,GAEMC,KAAa,MAA+B;GAChD,AAAKN,EAAM,aAAaG,MAAkB,KAAA,MAE1C,OAAO,oBAAoB,UAAUJ,GAA6B,EAAE,SAAS,GAAK,CAAC,GACnF,SAAS,gBAAgB,MAAM,WAAW,UAC1C,SAAS,KAAK,MAAM,YAAY,IAAII,EAAc,KAClD,OAAO,SAAS;IAAE,KAAK;IAAG,UAAU;GAAU,CAAC,GAC/C,IAAgB,KAAA;EAClB;EAKA,OAHA,OAAO,iBAAiB,YAAYC,CAAM,GAC1C,OAAO,iBAAiB,YAAYE,CAAS,SAEhC;GAGX,AAFA,OAAO,oBAAoB,YAAYF,CAAM,GAC7C,OAAO,oBAAoB,YAAYE,CAAS,GAChD,OAAO,oBAAoB,UAAUP,GAA6B,EAAE,SAAS,GAAK,CAAC;EACrF;CACF,GAAG,CAACG,CAAS,CAAC;AAChB"}