@bonprix-ds/react-bottom-sheet 1.0.2 → 1.2.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /* Radix prepends focus guards to `body` while a dialog is open. Chromium saves the scroll anchor of a page that is
2
+ left as an `nth-child` path, which the guards shift, so going back would restore the scroll position of another
3
+ element. Without an anchor, Chromium restores the plain scroll offset. Keyed to the guards rather than to the
4
+ open state, so it holds through the closing animation and across every copy of the package on the page. */
5
+ :root:has(> body > [data-radix-focus-guard]) {
6
+ overflow-anchor: none;
7
+ }
@@ -4,7 +4,7 @@ export type { Props, SheetButtonBaseProps, SheetButtonProps, SheetButtonSectionP
4
4
  declare const BottomSheet: {
5
5
  (props: Props): React.JSX.Element;
6
6
  displayName: string;
7
- Title: ({ children, subline, level }: import("./BottomSheetRoot").SheetTitleProps) => React.JSX.Element;
7
+ Title: ({ children, subline, level: Level }: import("./BottomSheetRoot").SheetTitleProps) => React.JSX.Element;
8
8
  Content: ({ children, disableHorizontalPadding }: import("./BottomSheetRoot").SheetContentProps) => React.JSX.Element;
9
9
  ButtonSection: ({ children }: import("./BottomSheetRoot").SheetButtonSectionProps) => React.JSX.Element;
10
10
  PrimaryButton: <C extends React.ElementType>({ children, icon, iconPosition, loading, component, ...props }: import("./BottomSheetRoot").SheetButtonBaseProps & {
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheet.js","names":[],"sources":["../../src/BottomSheet.tsx"],"sourcesContent":["import React from \"react\";\n\nimport BottomSheetRoot, { ButtonSection, Content, PrimaryButton, SecondaryButton, Title, type Props } from \"./BottomSheetRoot\";\n\nexport type {\n Props,\n SheetButtonBaseProps,\n SheetButtonProps,\n SheetButtonSectionProps,\n SheetContentProps,\n SheetTitleProps,\n} from \"./BottomSheetRoot\";\n\nconst BottomSheet = (props: Props) => <BottomSheetRoot {...props} />;\n\nBottomSheet.displayName = \"BottomSheet\";\n\nBottomSheet.Title = Title;\nBottomSheet.Content = Content;\nBottomSheet.ButtonSection = ButtonSection;\nBottomSheet.PrimaryButton = PrimaryButton;\nBottomSheet.SecondaryButton = SecondaryButton;\n\nexport default BottomSheet;\n"],"mappings":";;;;AAaA,IAAM,KAAe,MAAiB,kBAAC,GAAD,EAAiB,GAAI,EAAQ,CAAA;AAEnE,EAAY,cAAc,eAE1B,EAAY,QAAQ,GACpB,EAAY,UAAU,GACtB,EAAY,gBAAgB,GAC5B,EAAY,gBAAgB,GAC5B,EAAY,kBAAkB"}
1
+ {"version":3,"file":"BottomSheet.js","names":["BottomSheetRoot","BottomSheet","props","Title","Content","ButtonSection","PrimaryButton","SecondaryButton"],"sources":["../../src/BottomSheet.tsx"],"sourcesContent":["import React from \"react\";\n\nimport BottomSheetRoot, { ButtonSection, Content, PrimaryButton, SecondaryButton, Title, type Props } from \"./BottomSheetRoot\";\n\nexport type {\n Props,\n SheetButtonBaseProps,\n SheetButtonProps,\n SheetButtonSectionProps,\n SheetContentProps,\n SheetTitleProps,\n} from \"./BottomSheetRoot\";\n\nconst BottomSheet = (props: Props) => <BottomSheetRoot {...props} />;\n\nBottomSheet.displayName = \"BottomSheet\";\n\nBottomSheet.Title = Title;\nBottomSheet.Content = Content;\nBottomSheet.ButtonSection = ButtonSection;\nBottomSheet.PrimaryButton = PrimaryButton;\nBottomSheet.SecondaryButton = SecondaryButton;\n\nexport default BottomSheet;\n"],"mappings":";;;;AAaA,IAAMC,KAAe,MAAiB,kBAACD,GAAD,EAAiB,GAAIE,EAAQ,CAAA;AAEnE,EAAY,cAAc,eAE1B,EAAY,QAAQC,GACpB,EAAY,UAAUC,GACtB,EAAY,gBAAgBC,GAC5B,EAAY,gBAAgBC,GAC5B,EAAY,kBAAkBC"}
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheetContext.js","names":[],"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,IAAM,IAAqB,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}\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,11 +1,10 @@
1
1
  import React, { type ComponentProps, type ElementType, type ReactNode, type RefObject } from "react";
2
- import { type IconType } from "@bonprix-ds/react-icon";
2
+ import { type IconOrElement } from "@bonprix-ds/react-icon";
3
3
  import { TitleLevel } from "@bonprix-ds/utils";
4
+ import "./BottomSheet.css";
4
5
  interface SheetProps {
5
6
  /** All of the subcomponents should be placed inside this property. */
6
7
  children: ReactNode;
7
- /** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */
8
- isOpen: boolean;
9
8
  /** Callback function, that is triggered when the sheet is attempted to be closed.
10
9
  *
11
10
  * It will be called in following cases:
@@ -15,13 +14,27 @@ interface SheetProps {
15
14
  * - Click on "close" icon button in the upper-right corner
16
15
  * - Click on any button (PrimaryButton or SecondaryButton)
17
16
  *
18
- * Should be used in conjunction with `isOpen`. */
17
+ * Should be used in conjunction with `open`. */
19
18
  onClose: () => void;
20
19
  /** Callback to execute when clicking back icon. */
21
20
  onBack?: () => void;
22
21
  /** The z-index of the sheet.. */
23
22
  zIndex?: number;
24
23
  }
24
+ type OpenProps = SheetProps & {
25
+ /** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */
26
+ open: boolean;
27
+ /** @deprecated [is-open-prop] Use `open` instead. */
28
+ isOpen?: never;
29
+ };
30
+ type DeprecatedOpenProps = SheetProps & {
31
+ open?: never;
32
+ /**
33
+ * Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property.
34
+ * @deprecated [is-open-prop] Use `open` instead.
35
+ */
36
+ isOpen: boolean;
37
+ };
25
38
  export interface SheetTitleProps {
26
39
  /** The text content. */
27
40
  children: string;
@@ -43,8 +56,8 @@ export interface SheetContentProps {
43
56
  export interface SheetButtonBaseProps {
44
57
  /** The label of the button. */
45
58
  children: string;
46
- /** If used, an icon will be additionally shown. The value is a name of one icon from our icon set. */
47
- icon?: IconType;
59
+ /** 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. */
60
+ icon?: IconOrElement;
48
61
  /** The position of the icon relative to the content. */
49
62
  iconPosition?: "start" | "end";
50
63
  }
@@ -56,16 +69,16 @@ type SheetPrimaryButtonProps<C extends ElementType> = SheetButtonProps<C> & {
56
69
  /** If `true`, a loading spinner will be shown instead of the content. */
57
70
  loading?: boolean;
58
71
  };
59
- export interface Props extends SheetProps {
72
+ export type Props = (DeprecatedOpenProps | OpenProps) & {
60
73
  /** A reference to the root element of the sheet. */
61
74
  ref?: RefObject<HTMLDivElement>;
62
- }
75
+ };
63
76
  declare const BottomSheetRoot: {
64
- ({ children, isOpen, onClose, onBack, zIndex, ref }: Props): React.JSX.Element;
77
+ ({ children, open, isOpen, onClose, onBack, zIndex, ref }: Props): React.JSX.Element;
65
78
  displayName: string;
66
79
  };
67
80
  export default BottomSheetRoot;
68
- export declare const Title: ({ children, subline, level }: SheetTitleProps) => React.JSX.Element;
81
+ export declare const Title: ({ children, subline, level: Level }: SheetTitleProps) => React.JSX.Element;
69
82
  export declare const Content: ({ children, disableHorizontalPadding }: SheetContentProps) => React.JSX.Element;
70
83
  export declare const ButtonSection: ({ children }: SheetButtonSectionProps) => React.JSX.Element;
71
84
  export declare const PrimaryButton: <C extends ElementType>({ children, icon, iconPosition, loading, component, ...props }: SheetPrimaryButtonProps<C>) => React.JSX.Element;
@@ -2,96 +2,102 @@
2
2
  import e from "./BottomSheetContext.js";
3
3
  import t from "./useConsumeBottomSheet.js";
4
4
  import n from "./useCreateBottomSheet.js";
5
- import { useEffect as r, useRef as i } from "react";
6
- import * as a from "@radix-ui/react-dialog";
7
- import { Sheet as o } from "react-modal-sheet";
8
- import { tv as s } from "tailwind-variants";
9
- import { backdrop as c } from "@bonprix-ds/internal-components";
10
- import l from "@bonprix-ds/react-button";
11
- import u from "@bonprix-ds/react-icon-button";
12
- import d from "@bonprix-ds/react-typography";
13
- import { ZIndexContext as f, useInnerOpen as p, usePrefersReducedMotion as m } from "@bonprix-ds/utils";
14
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
5
+ import r from "./useKeepScrollPositionOnPageHide.js";
6
+ import { useEffect as i, useRef as a } from "react";
7
+ import * as o from "@radix-ui/react-dialog";
8
+ import { Sheet as s } from "react-modal-sheet";
9
+ import { tv as c } from "tailwind-variants";
10
+ import { backdrop as l } from "@bonprix-ds/internal-components";
11
+ import u from "@bonprix-ds/react-button";
12
+ import d from "@bonprix-ds/react-icon-button";
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";
16
+ import "#styles";
17
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
15
18
  //#region src/BottomSheetRoot.tsx
16
- var _ = s({
19
+ var b = c({
17
20
  slots: {
18
21
  root: "preflight block",
19
- container: "shadow-none rounded-none bg-clr-bg-modal max-h-[calc(100%-4rem)] outline-none",
22
+ container: "max-h-[calc(100%-4rem)] rounded-none bg-clr-bg-modal shadow-none outline-none",
20
23
  header: "px-4 py-3",
21
- titleAndIcons: "flex gap-2 items-center touch-pan-down",
22
- contentWrapper: "flex flex-col w-full",
24
+ titleAndIcons: "flex touch-pan-down items-center gap-2",
25
+ contentWrapper: "flex w-full flex-col",
23
26
  content: [
24
27
  "typography-body1 text-clr-primary",
25
- "*:flex *:-mx-0.5 *:px-0.5",
28
+ "*:-mx-0.5 *:flex *:px-0.5",
26
29
  "*:min-h-0"
27
30
  ],
28
- dragHandleContainer: "h-6 flex justify-center items-center shrink-0",
31
+ dragHandleContainer: "flex h-6 shrink-0 items-center justify-center",
29
32
  dragHandle: "h-1 w-8 rounded-full bg-clr-on-bg-low",
30
- backdrop: c(),
33
+ backdrop: l(),
31
34
  scrollArea: "scroll-area relative"
32
35
  },
33
36
  variants: { disableHorizontalPadding: {
34
37
  false: { scrollArea: "px-4" },
35
38
  true: ""
36
39
  } }
37
- }), v = ({ children: t, isOpen: s, onClose: c, onBack: l, zIndex: u = 9999, ref: d }) => {
38
- let v = m(), { root: y, container: b, dragHandleContainer: x, dragHandle: S, content: C, contentWrapper: w, backdrop: T } = _(), { isShown: E, scrollRef: D, scrollPosition: O } = n({ isOpen: s }), k = O === "middle" || O === "bottom", { innerOpen: A } = p(E), j = i(null);
39
- return r(() => {
40
- A || (j.current?.focus(), j.current = null);
41
- }, [A]), /* @__PURE__ */ h(a.Root, {
42
- open: A,
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);
45
+ return i(() => {
46
+ N || (P.current?.focus(), P.current = null);
47
+ }, [N]), /* @__PURE__ */ v(o.Root, {
48
+ open: N,
43
49
  onOpenChange: (e) => {
44
- e || c();
50
+ e || u();
45
51
  },
46
- children: /* @__PURE__ */ g(o, {
47
- isOpen: A,
48
- onClose: c,
49
- className: y(),
52
+ children: /* @__PURE__ */ y(s, {
53
+ isOpen: N,
54
+ onClose: u,
55
+ className: S(),
50
56
  detent: "content",
51
57
  "data-bpds": "bottom-sheet",
52
- prefersReducedMotion: v,
58
+ prefersReducedMotion: x,
53
59
  style: {
54
60
  pointerEvents: void 0,
55
- visibility: A ? "visible" : "hidden",
56
- zIndex: u
61
+ visibility: N ? "visible" : "hidden",
62
+ zIndex: f
57
63
  },
58
64
  avoidKeyboard: !1,
59
- children: [/* @__PURE__ */ h(a.Content, {
65
+ children: [/* @__PURE__ */ v(o.Content, {
60
66
  forceMount: !0,
61
67
  asChild: !0,
62
68
  "aria-modal": !0,
63
69
  "aria-describedby": void 0,
64
70
  tabIndex: -1,
65
71
  onOpenAutoFocus: (e) => {
66
- e.preventDefault(), j.current = document.activeElement, e.target.focus();
72
+ e.preventDefault(), P.current = document.activeElement, e.target.focus();
67
73
  },
68
74
  onCloseAutoFocus: (e) => e.preventDefault(),
69
- children: /* @__PURE__ */ g(o.Container, {
70
- className: b(),
71
- ref: d,
72
- children: [/* @__PURE__ */ h(o.Header, {
75
+ children: /* @__PURE__ */ y(s.Container, {
76
+ className: C(),
77
+ ref: p,
78
+ children: [/* @__PURE__ */ v(s.Header, {
73
79
  unstyled: !0,
74
- className: x(),
75
- children: /* @__PURE__ */ h(o.DragIndicator, {
80
+ className: w(),
81
+ children: /* @__PURE__ */ v(s.DragIndicator, {
76
82
  unstyled: !0,
77
- className: S()
83
+ className: T()
78
84
  })
79
- }), /* @__PURE__ */ h(f.Provider, {
80
- value: u,
81
- children: /* @__PURE__ */ h(e.Provider, {
85
+ }), /* @__PURE__ */ v(m.Provider, {
86
+ value: f,
87
+ children: /* @__PURE__ */ v(e.Provider, {
82
88
  value: {
83
- scrollRef: D,
84
- scrollPosition: O,
85
- onClose: c,
86
- onBack: l,
87
- disableDrag: k
89
+ scrollRef: A,
90
+ scrollPosition: j,
91
+ onClose: u,
92
+ onBack: d,
93
+ disableDrag: M
88
94
  },
89
- children: /* @__PURE__ */ h(o.Content, {
90
- className: C(),
95
+ children: /* @__PURE__ */ v(s.Content, {
96
+ className: E(),
91
97
  disableScroll: !0,
92
- disableDrag: k,
93
- children: /* @__PURE__ */ h("div", {
94
- className: w(),
98
+ disableDrag: M,
99
+ children: /* @__PURE__ */ v("div", {
100
+ className: D(),
95
101
  style: { paddingBottom: "max(var(--keyboard-inset-height, 0rem), var(--app-safe-area-inset-bottom, 1rem))" },
96
102
  children: t
97
103
  })
@@ -99,48 +105,49 @@ var _ = s({
99
105
  })
100
106
  })]
101
107
  })
102
- }), /* @__PURE__ */ h(o.Backdrop, { className: T() })]
108
+ }), /* @__PURE__ */ v(s.Backdrop, { className: O() })]
103
109
  })
104
110
  });
105
- }, y = ({ children: e, subline: n, level: r = "h3" }) => {
106
- let { onBack: i, onClose: o } = t(), { header: s, titleAndIcons: c } = _();
107
- return /* @__PURE__ */ g("div", {
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", {
108
114
  className: s(),
109
- children: [/* @__PURE__ */ g("div", {
115
+ children: [/* @__PURE__ */ y("div", {
110
116
  className: c(),
111
117
  children: [
112
- i && /* @__PURE__ */ h(u, {
118
+ i && /* @__PURE__ */ v(d, {
113
119
  onClick: i,
114
- icon: "arrow-left",
120
+ icon: /* @__PURE__ */ v(f, {}),
115
121
  label: "Zurück",
116
122
  variant: "tertiary",
117
123
  size: "small"
118
124
  }),
119
- /* @__PURE__ */ h(a.Title, {
125
+ /* @__PURE__ */ v(o.Title, {
120
126
  asChild: !0,
121
- children: /* @__PURE__ */ h("div", {
127
+ children: /* @__PURE__ */ v("div", {
122
128
  className: "grow",
123
- children: /* @__PURE__ */ h(d, {
124
- variant: "bonprix-h6",
125
- component: r,
126
- className: "line-clamp-2",
129
+ children: /* @__PURE__ */ v(r, {
130
+ className: "typography-bonprix-h6 my-0 line-clamp-2 text-start text-clr-on-bg-high",
127
131
  children: e
128
132
  })
129
133
  })
130
134
  }),
131
- /* @__PURE__ */ h(u, {
132
- onClick: o,
133
- icon: "closer",
135
+ /* @__PURE__ */ v(d, {
136
+ onClick: a,
137
+ icon: /* @__PURE__ */ v(p, {}),
134
138
  label: "Schließen",
135
139
  variant: "tertiary",
136
140
  size: "small"
137
141
  })
138
142
  ]
139
- }), n && /* @__PURE__ */ h(d, { children: n })]
143
+ }), n && /* @__PURE__ */ v("p", {
144
+ className: "typography-body1 my-0 text-start text-clr-on-bg-high",
145
+ children: n
146
+ })]
140
147
  });
141
- }, b = ({ children: e, disableHorizontalPadding: n = !1 }) => {
142
- let { scrollRef: r, disableDrag: i } = t(), { scrollArea: a } = _({ disableHorizontalPadding: n });
143
- return /* @__PURE__ */ h("div", {
148
+ }, C = ({ children: e, disableHorizontalPadding: n = !1 }) => {
149
+ let { scrollRef: r, disableDrag: i } = t(), { scrollArea: a } = b({ disableHorizontalPadding: n });
150
+ return /* @__PURE__ */ v("div", {
144
151
  ref: r,
145
152
  className: a(),
146
153
  style: { touchAction: i ? "auto" : "pan-down" },
@@ -148,16 +155,16 @@ var _ = s({
148
155
  tabIndex: 0,
149
156
  children: e
150
157
  });
151
- }, x = ({ children: e }) => /* @__PURE__ */ h("div", {
152
- className: "button-section w-full flex flex-col gap-3 px-4 pt-4 shrink-0 touch-pan-down",
158
+ }, w = ({ children: e }) => /* @__PURE__ */ v("div", {
159
+ className: "button-section flex w-full shrink-0 touch-pan-down flex-col gap-3 px-4 pt-4",
153
160
  children: e
154
- }), S = ({ children: e, icon: n, iconPosition: r, loading: i, component: a = "button", ...o }) => {
155
- let s = a, { onClick: c, ...u } = o, { onClose: d } = t(), f = (e) => {
161
+ }), T = ({ children: e, icon: n, iconPosition: r, loading: i, component: a = "button", ...o }) => {
162
+ let s = a, { onClick: c, ...l } = o, { onClose: d } = t(), f = (e) => {
156
163
  c?.(e), d();
157
164
  };
158
- return /* @__PURE__ */ h(l, {
165
+ return /* @__PURE__ */ v(u, {
159
166
  component: s,
160
- ...u,
167
+ ...l,
161
168
  variant: "primary",
162
169
  onClick: f,
163
170
  icon: n,
@@ -166,9 +173,9 @@ var _ = s({
166
173
  loading: i,
167
174
  children: e
168
175
  });
169
- }, C = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...a }) => {
176
+ }, E = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...a }) => {
170
177
  let o = i, { onClose: s } = t();
171
- return /* @__PURE__ */ h(l, {
178
+ return /* @__PURE__ */ v(u, {
172
179
  component: o,
173
180
  ...a,
174
181
  variant: "secondary",
@@ -179,8 +186,8 @@ var _ = s({
179
186
  children: e
180
187
  });
181
188
  };
182
- v.displayName = "BottomSheet";
189
+ x.displayName = "BottomSheet";
183
190
  //#endregion
184
- export { x as ButtonSection, b as Content, S as PrimaryButton, C as SecondaryButton, y as Title, v as default };
191
+ export { w as ButtonSection, C as Content, T as PrimaryButton, E as SecondaryButton, S as Title, x as default };
185
192
 
186
193
  //# sourceMappingURL=BottomSheetRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheetRoot.js","names":[],"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 IconType } from \"@bonprix-ds/react-icon\";\nimport IconButton from \"@bonprix-ds/react-icon-button\";\nimport Typography from \"@bonprix-ds/react-typography\";\nimport { TitleLevel, useInnerOpen, usePrefersReducedMotion, ZIndexContext } from \"@bonprix-ds/utils\";\n\nimport BottomSheetContext from \"./BottomSheetContext\";\nimport useConsumeBottomSheet from \"./useConsumeBottomSheet\";\nimport useCreateBottomSheet from \"./useCreateBottomSheet\";\n\nconst generateClasses = tv({\n slots: {\n root: \"preflight block\",\n container: \"shadow-none rounded-none bg-clr-bg-modal max-h-[calc(100%-4rem)] outline-none\",\n header: \"px-4 py-3\",\n titleAndIcons: \"flex gap-2 items-center touch-pan-down\",\n contentWrapper: \"flex flex-col w-full\",\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 \"*:flex *:-mx-0.5 *: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: \"h-6 flex justify-center items-center shrink-0\",\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 /** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */\n isOpen: boolean;\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 `isOpen`. */\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\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 a name of one icon from our icon set. */\n icon?: IconType;\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 interface Props extends SheetProps {\n /** A reference to the root element of the sheet. */\n ref?: RefObject<HTMLDivElement>;\n}\n\nconst BottomSheetRoot = ({ children, isOpen, onClose, onBack, zIndex = 9999, ref }: Props) => {\n const prefersReducedMotion = usePrefersReducedMotion();\n const { root, container, dragHandleContainer, dragHandle, content, contentWrapper, backdrop } = generateClasses();\n const { isShown, scrollRef, scrollPosition } = useCreateBottomSheet({ isOpen });\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\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 `isOpen`.\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 = (open: boolean) => {\n if (!open) 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 = \"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=\"arrow-left\" label=\"Zurück\" variant=\"tertiary\" size=\"small\" />}\n <DialogPrimitive.Title asChild>\n <div className=\"grow\">\n <Typography variant=\"bonprix-h6\" component={level} className=\"line-clamp-2\">\n {children}\n </Typography>\n </div>\n </DialogPrimitive.Title>\n <IconButton onClick={onClose} icon=\"closer\" label=\"Schließen\" variant=\"tertiary\" size=\"small\" />\n </div>\n {subline && <Typography>{subline}</Typography>}\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 w-full flex flex-col gap-3 px-4 pt-4 shrink-0 touch-pan-down\">{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":";;;;;;;;;;;;;;;AAkBA,IAAM,IAAkB,EAAG;CACzB,OAAO;EACL,MAAM;EACN,WAAW;EACX,QAAQ;EACR,eAAe;EACf,gBAAgB;EAChB,SAAS;GACP;GAGA;GAEA;EACF;EACA,qBAAqB;EACrB,YAAY;EACZ,UAAU,EAAS;EACnB,YAAY;CACd;CACA,UAAU,EACR,0BAA0B;EACxB,O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,WAAW,EAAW;EAItB,OAAO,EAAE,aAAa,IAAc,SAAS,WAAW;EACxD,wCAAsC;EACtC,UAAU;EAET;CACE,CAAA;AAET,GAEa,KAAiB,EAAE,kBACvB,kBAAC,OAAD;CAAK,WAAU;CAA+E;AAAc,CAAA,GAGxG,KAAwC,EACnD,aACA,SACA,iBACA,YACA,eAAY,UACZ,GAAG,QAC6B;CAChC,IAAM,IAAyB,GACzB,EAAE,YAAS,GAAG,MAAe,GAC7B,EAAE,eAAY,EAAsB,GACpC,KAAe,MAA4B;EAG/C,AADA,IAAU,CAAK,GACf,EAAQ;CACV;CACA,OACE,kBAAC,GAAD;EACE,WAAW;EACX,GAAI;EACJ,SAAQ;EACR,SAAS;EACH;EACQ;EACd,MAAK;EACI;EAER;CACK,CAAA;AAEZ,GAEa,KAA0C,EACrD,aACA,SACA,iBACA,eAAY,UACZ,GAAG,QACsB;CACzB,IAAM,IAAyB,GACzB,EAAE,eAAY,EAAsB;CAC1C,OACE,kBAAC,GAAD;EAAQ,WAAW;EAAW,GAAI;EAAO,SAAQ;EAAY,SAAS;EAAe;EAAoB;EAAc,MAAK;EACzH;CACK,CAAA;AAEZ;AAEA,EAAgB,cAAc"}
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,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EACI;EAER;CACK,CAAA;AAEZ,GAEaE,KAA0C,EACrD,aACA,SACA,iBACA,eAAY,UACZ,GAAGN,QACsB;CACzB,IAAMC,IAAyBC,GACzB,EAAE,eAAYnD,EAAsB;CAC1C,OACE,kBAACI,GAAD;EAAQ,WAAW8C;EAAW,GAAID;EAAO,SAAQ;EAAY,SAASzB;EAAe;EAAoB;EAAc,MAAK;EACzH;CACK,CAAA;AAEZ;AAEA,EAAgB,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"useConsumeBottomSheet.js","names":[],"sources":["../../src/useConsumeBottomSheet.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport BottomSheetContext from \"./BottomSheetContext\";\n\nconst useConsumeBottomSheet = () => {\n return useContext(BottomSheetContext);\n};\n\nexport default useConsumeBottomSheet;\n"],"mappings":";;;AAIA,IAAM,UACG,EAAW,CAAkB"}
1
+ {"version":3,"file":"useConsumeBottomSheet.js","names":["BottomSheetContext","useConsumeBottomSheet","useContext"],"sources":["../../src/useConsumeBottomSheet.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport BottomSheetContext from \"./BottomSheetContext\";\n\nconst useConsumeBottomSheet = () => {\n return useContext(BottomSheetContext);\n};\n\nexport default useConsumeBottomSheet;\n"],"mappings":";;;AAIA,IAAMC,UACGC,EAAWF,CAAkB"}
@@ -1,7 +1,7 @@
1
1
  interface UseBottomSheetProps {
2
- isOpen: boolean;
2
+ open: boolean;
3
3
  }
4
- declare const useCreateBottomSheet: ({ isOpen }: UseBottomSheetProps) => {
4
+ declare const useCreateBottomSheet: ({ open }: UseBottomSheetProps) => {
5
5
  isShown: boolean;
6
6
  scrollRef: (element: HTMLElement | null) => void;
7
7
  scrollPosition: "top" | "bottom" | "middle" | undefined;
@@ -2,7 +2,7 @@ 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
  //#region src/useCreateBottomSheet.ts
5
- var i = ({ isOpen: i }) => {
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(() => {
8
8
  i ? document.dispatchEvent(new CustomEvent("app:enableSwipeToRefresh", { detail: { enable: !1 } })) : document.dispatchEvent(new CustomEvent("app:enableSwipeToRefresh", { detail: { enable: !0 } }));
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateBottomSheet.js","names":[],"sources":["../../src/useCreateBottomSheet.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useScrollPosition, useVirtualKeyboard } from \"react-modal-sheet\";\n\nimport { useBreakpointBetween } from \"@bonprix-ds/utils\";\n\ninterface UseBottomSheetProps {\n isOpen: boolean;\n}\n\nconst useCreateBottomSheet = ({ isOpen }: UseBottomSheetProps) => {\n const isSmallScreen = useBreakpointBetween(\"s\", \"m\");\n const isShown = isSmallScreen && isOpen;\n\n const { scrollRef, scrollPosition } = useScrollPosition({\n isEnabled: isShown,\n });\n\n useVirtualKeyboard({ isEnabled: isOpen });\n\n // Disable swipe-to-refresh for the app: // https://bonprix.atlassian.net/wiki/spaces/App/pages/368706073/Javascript\n useEffect(() => {\n if (isOpen) {\n document.dispatchEvent(new CustomEvent(\"app:enableSwipeToRefresh\", { detail: { enable: false } }));\n } else {\n document.dispatchEvent(new CustomEvent(\"app:enableSwipeToRefresh\", { detail: { enable: true } }));\n }\n }, [isOpen]);\n\n return {\n isShown,\n scrollRef,\n scrollPosition,\n };\n};\n\nexport default useCreateBottomSheet;\n"],"mappings":";;;;AASA,IAAM,KAAwB,EAAE,gBAAkC;CAEhE,IAAM,IADgB,EAAqB,KAAK,GAChC,KAAiB,GAE3B,EAAE,cAAW,sBAAmB,EAAkB,EACtD,WAAW,EACb,CAAC;CAaD,OAXA,EAAmB,EAAE,WAAW,EAAO,CAAC,GAGxC,QAAgB;EACd,AAAI,IACF,SAAS,cAAc,IAAI,YAAY,4BAA4B,EAAE,QAAQ,EAAE,QAAQ,GAAM,EAAE,CAAC,CAAC,IAEjG,SAAS,cAAc,IAAI,YAAY,4BAA4B,EAAE,QAAQ,EAAE,QAAQ,GAAK,EAAE,CAAC,CAAC;CAEpG,GAAG,CAAC,CAAM,CAAC,GAEJ;EACL;EACA;EACA;CACF;AACF"}
1
+ {"version":3,"file":"useCreateBottomSheet.js","names":["useCreateBottomSheet","isShown","useBreakpointBetween","open","useScrollPosition","useVirtualKeyboard","useEffect"],"sources":["../../src/useCreateBottomSheet.ts"],"sourcesContent":["import { useEffect } from \"react\";\nimport { useScrollPosition, useVirtualKeyboard } from \"react-modal-sheet\";\n\nimport { useBreakpointBetween } from \"@bonprix-ds/utils\";\n\ninterface UseBottomSheetProps {\n open: boolean;\n}\n\nconst useCreateBottomSheet = ({ open }: UseBottomSheetProps) => {\n const isSmallScreen = useBreakpointBetween(\"s\", \"m\");\n const isShown = isSmallScreen && open;\n\n const { scrollRef, scrollPosition } = useScrollPosition({\n isEnabled: isShown,\n });\n\n useVirtualKeyboard({ isEnabled: open });\n\n // Disable swipe-to-refresh for the app: // https://bonprix.atlassian.net/wiki/spaces/App/pages/368706073/Javascript\n useEffect(() => {\n if (open) {\n document.dispatchEvent(new CustomEvent(\"app:enableSwipeToRefresh\", { detail: { enable: false } }));\n } else {\n document.dispatchEvent(new CustomEvent(\"app:enableSwipeToRefresh\", { detail: { enable: true } }));\n }\n }, [open]);\n\n return {\n isShown,\n scrollRef,\n scrollPosition,\n };\n};\n\nexport default useCreateBottomSheet;\n"],"mappings":";;;;AASA,IAAMA,KAAwB,EAAE,cAAgC;CAE9D,IAAMC,IADgBC,EAAqB,KAAK,GAChC,KAAiBC,GAE3B,EAAE,cAAW,sBAAmBC,EAAkB,EACtD,WAAWH,EACb,CAAC;CAaD,OAXAI,EAAmB,EAAE,WAAWF,EAAK,CAAC,GAGtCG,QAAgB;EACd,AAAIH,IACF,SAAS,cAAc,IAAI,YAAY,4BAA4B,EAAE,QAAQ,EAAE,QAAQ,GAAM,EAAE,CAAC,CAAC,IAEjG,SAAS,cAAc,IAAI,YAAY,4BAA4B,EAAE,QAAQ,EAAE,QAAQ,GAAK,EAAE,CAAC,CAAC;CAEpG,GAAG,CAACA,CAAI,CAAC,GAEF;EACL;EACA;EACA;CACF;AACF"}
@@ -0,0 +1,2 @@
1
+ declare const useKeepScrollPositionOnPageHide: (isEnabled: boolean) => void;
2
+ export default useKeepScrollPositionOnPageHide;
@@ -0,0 +1,26 @@
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
@@ -0,0 +1 @@
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"}
package/dist/styles.js ADDED
@@ -0,0 +1 @@
1
+ import "./src/BottomSheet.css";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-bottom-sheet",
3
- "version": "1.0.2",
3
+ "version": "1.2.0",
4
4
  "description": "BottomSheet component, implemented in React, for the Bonprix Design System.",
5
5
  "keywords": [],
6
6
  "license": "UNLICENSED",
@@ -17,9 +17,18 @@
17
17
  "!dist/**/*.test.d.ts"
18
18
  ],
19
19
  "type": "module",
20
- "sideEffects": false,
20
+ "sideEffects": [
21
+ "**/*.css",
22
+ "./dist/styles.js"
23
+ ],
21
24
  "module": "./dist/index.js",
22
25
  "types": "./dist/index.d.ts",
26
+ "imports": {
27
+ "#styles": {
28
+ "browser": "./dist/styles.js",
29
+ "default": "./dist/no-styles.js"
30
+ }
31
+ },
23
32
  "exports": {
24
33
  ".": {
25
34
  "import": "./dist/index.js",
@@ -34,25 +43,23 @@
34
43
  "dependencies": {
35
44
  "@radix-ui/react-dialog": "1.1.23",
36
45
  "react-modal-sheet": "5.6.0",
37
- "@bonprix-ds/internal-components": "0.2.1",
38
- "@bonprix-ds/react-button": "1.1.1",
39
- "@bonprix-ds/react-icon": "1.2.1",
40
- "@bonprix-ds/react-icon-button": "1.2.1",
41
- "@bonprix-ds/react-typography": "1.0.4",
42
- "@bonprix-ds/utils": "0.2.2"
46
+ "@bonprix-ds/internal-components": "0.2.3",
47
+ "@bonprix-ds/react-button": "1.1.3",
48
+ "@bonprix-ds/react-icon": "1.3.0",
49
+ "@bonprix-ds/react-icon-button": "1.2.3",
50
+ "@bonprix-ds/utils": "0.4.0"
43
51
  },
44
52
  "devDependencies": {
45
53
  "@testing-library/dom": "10.4.2",
46
54
  "@testing-library/react": "16.3.3",
47
55
  "@types/react": "19.3.0",
48
- "@vitejs/plugin-react": "6.1.1",
49
- "rollup-preserve-directives": "1.1.3",
50
- "vite": "8.3.0",
51
- "vitest": "4.1.11"
56
+ "vite": "8.3.2",
57
+ "vitest": "4.1.11",
58
+ "@bonprix-ds/vite-config": "0.0.0"
52
59
  },
53
60
  "peerDependencies": {
54
- "react": "^19.3.0",
55
- "react-dom": "^19.3.0",
61
+ "react": "^19",
62
+ "react-dom": "^19",
56
63
  "tailwind-variants": "0.3.1"
57
64
  },
58
65
  "scripts": {