@bonprix-ds/react-bottom-sheet 1.0.0 → 1.0.2

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.d.ts CHANGED
@@ -1,85 +1,2 @@
1
- import { ComponentProps } from 'react';
2
- import { default as default_2 } from 'react';
3
- import { ElementType } from 'react';
4
- import { IconType } from '@bonprix-ds/react-icon';
5
- import { ReactNode } from 'react';
6
- import { RefObject } from 'react';
7
- import { TitleLevel } from '@bonprix-ds/utils';
8
-
9
- declare const BottomSheet: {
10
- (props: BottomSheetProps): default_2.JSX.Element;
11
- displayName: string;
12
- Title: ({ children, subline, level }: SheetTitleProps) => default_2.JSX.Element;
13
- Content: ({ children, disableHorizontalPadding }: SheetContentProps) => default_2.JSX.Element;
14
- ButtonSection: ({ children }: SheetButtonSectionProps) => default_2.JSX.Element;
15
- PrimaryButton: <C extends default_2.ElementType>({ children, icon, iconPosition, loading, component, ...props }: SheetButtonBaseProps & {
16
- component?: C | undefined;
17
- } & Omit<default_2.ComponentProps<C>, keyof SheetButtonBaseProps | "component"> & {
18
- loading?: boolean;
19
- }) => default_2.JSX.Element;
20
- SecondaryButton: <C extends default_2.ElementType>({ children, icon, iconPosition, component, ...props }: SheetButtonProps<C>) => default_2.JSX.Element;
21
- };
22
- export default BottomSheet;
23
-
24
- export declare interface BottomSheetProps extends SheetProps {
25
- /** A reference to the root element of the sheet. */
26
- ref?: RefObject<HTMLDivElement>;
27
- }
28
-
29
- declare interface SheetButtonBaseProps {
30
- /** The label of the button. */
31
- children: string;
32
- /** If used, an icon will be additionally shown. The value is a name of one icon from our icon set. */
33
- icon?: IconType;
34
- /** The position of the icon relative to the content. */
35
- iconPosition?: "start" | "end";
36
- }
37
-
38
- declare type SheetButtonProps<C extends ElementType> = SheetButtonBaseProps & {
39
- /** The semantic component to render the Button. Preferrably `"button"`. Native props will be passed to this component. */
40
- component?: C;
41
- } & Omit<ComponentProps<C>, keyof SheetButtonBaseProps | "component">;
42
-
43
- declare interface SheetButtonSectionProps {
44
- /** Primary and secondary buttons should be placed inside this section. */
45
- children: ReactNode;
46
- }
47
-
48
- declare interface SheetContentProps {
49
- /** The content of the content section. */
50
- children: ReactNode;
51
- /** If `true`, the horizontal padding around the content will be removed. */
52
- disableHorizontalPadding?: boolean;
53
- }
54
-
55
- declare interface SheetProps {
56
- /** All of the subcomponents should be placed inside this property. */
57
- children: ReactNode;
58
- /** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */
59
- isOpen: boolean;
60
- /** Callback function, that is triggered when the sheet is attempted to be closed.
61
- *
62
- * It will be called in following cases:
63
- * - Click on backdrop
64
- * - Swipe down to close
65
- * - Click on "close" icon button in the upper-right corner
66
- * - Click on any button (PrimaryButton or SecondaryButton)
67
- *
68
- * Should be used in conjunction with `isOpen`. */
69
- onClose: () => void;
70
- /** Callback to execute when clicking back icon. */
71
- onBack?: () => void;
72
- /** The z-index of the sheet.. */
73
- zIndex?: number;
74
- }
75
-
76
- declare interface SheetTitleProps {
77
- /** The text content. */
78
- children: string;
79
- /** An optional subline that is displayed right below the title. */
80
- subline?: string;
81
- /** The heading level for the title. */
82
- level?: TitleLevel;
83
- }
84
-
85
- export { }
1
+ export { default } from "./src/BottomSheet";
2
+ export type { Props as BottomSheetProps, SheetButtonBaseProps, SheetButtonProps, SheetButtonSectionProps, SheetContentProps, SheetTitleProps, } from "./src/BottomSheet";
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { type Props } from "./BottomSheetRoot";
3
+ export type { Props, SheetButtonBaseProps, SheetButtonProps, SheetButtonSectionProps, SheetContentProps, SheetTitleProps, } from "./BottomSheetRoot";
4
+ declare const BottomSheet: {
5
+ (props: Props): React.JSX.Element;
6
+ displayName: string;
7
+ Title: ({ children, subline, level }: import("./BottomSheetRoot").SheetTitleProps) => React.JSX.Element;
8
+ Content: ({ children, disableHorizontalPadding }: import("./BottomSheetRoot").SheetContentProps) => React.JSX.Element;
9
+ ButtonSection: ({ children }: import("./BottomSheetRoot").SheetButtonSectionProps) => React.JSX.Element;
10
+ PrimaryButton: <C extends React.ElementType>({ children, icon, iconPosition, loading, component, ...props }: import("./BottomSheetRoot").SheetButtonBaseProps & {
11
+ component?: C | undefined;
12
+ } & Omit<React.ComponentProps<C>, keyof import("./BottomSheetRoot").SheetButtonBaseProps | "component"> & {
13
+ loading?: boolean;
14
+ }) => React.JSX.Element;
15
+ SecondaryButton: <C extends React.ElementType>({ children, icon, iconPosition, component, ...props }: import("./BottomSheetRoot").SheetButtonProps<C>) => React.JSX.Element;
16
+ };
17
+ export default BottomSheet;
@@ -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 { Props, SheetButtonProps } 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":";;;;AAMA,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":[],"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"}
@@ -0,0 +1,10 @@
1
+ import { useScrollPosition } from "react-modal-sheet";
2
+ export interface BottomSheetContextProps {
3
+ scrollRef: ReturnType<typeof useScrollPosition>["scrollRef"];
4
+ scrollPosition: ReturnType<typeof useScrollPosition>["scrollPosition"];
5
+ onClose: () => void;
6
+ onBack?: () => void;
7
+ disableDrag: boolean;
8
+ }
9
+ declare const BottomSheetContext: import("react").Context<BottomSheetContextProps>;
10
+ export default BottomSheetContext;
@@ -5,7 +5,8 @@ var t = e({
5
5
  scrollRef: () => null,
6
6
  scrollPosition: void 0,
7
7
  onClose: () => null,
8
- onBack: () => null
8
+ onBack: () => null,
9
+ disableDrag: !1
9
10
  });
10
11
  //#endregion
11
12
  export { t as default };
@@ -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 titleId?: string;\n}\n\nconst BottomSheetContext = createContext<BottomSheetContextProps>({\n scrollRef: () => null,\n scrollPosition: undefined,\n onClose: () => null,\n onBack: () => null,\n});\n\nexport default BottomSheetContext;\n"],"mappings":";;;AAaA,IAAM,IAAqB,EAAuC;CAChE,iBAAiB;CACjB,gBAAgB,KAAA;CAChB,eAAe;CACf,cAAc;AAChB,CAAC"}
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"}
@@ -0,0 +1,72 @@
1
+ import React, { type ComponentProps, type ElementType, type ReactNode, type RefObject } from "react";
2
+ import { type IconType } from "@bonprix-ds/react-icon";
3
+ import { TitleLevel } from "@bonprix-ds/utils";
4
+ interface SheetProps {
5
+ /** All of the subcomponents should be placed inside this property. */
6
+ children: ReactNode;
7
+ /** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */
8
+ isOpen: boolean;
9
+ /** Callback function, that is triggered when the sheet is attempted to be closed.
10
+ *
11
+ * It will be called in following cases:
12
+ * - Click on backdrop
13
+ * - Press of the `Escape` key
14
+ * - Swipe down to close
15
+ * - Click on "close" icon button in the upper-right corner
16
+ * - Click on any button (PrimaryButton or SecondaryButton)
17
+ *
18
+ * Should be used in conjunction with `isOpen`. */
19
+ onClose: () => void;
20
+ /** Callback to execute when clicking back icon. */
21
+ onBack?: () => void;
22
+ /** The z-index of the sheet.. */
23
+ zIndex?: number;
24
+ }
25
+ export interface SheetTitleProps {
26
+ /** The text content. */
27
+ children: string;
28
+ /** An optional subline that is displayed right below the title. */
29
+ subline?: string;
30
+ /** The heading level for the title. */
31
+ level?: TitleLevel;
32
+ }
33
+ export interface SheetButtonSectionProps {
34
+ /** Primary and secondary buttons should be placed inside this section. */
35
+ children: ReactNode;
36
+ }
37
+ export interface SheetContentProps {
38
+ /** The content of the content section. */
39
+ children: ReactNode;
40
+ /** If `true`, the horizontal padding around the content will be removed. */
41
+ disableHorizontalPadding?: boolean;
42
+ }
43
+ export interface SheetButtonBaseProps {
44
+ /** The label of the button. */
45
+ 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;
48
+ /** The position of the icon relative to the content. */
49
+ iconPosition?: "start" | "end";
50
+ }
51
+ export type SheetButtonProps<C extends ElementType> = SheetButtonBaseProps & {
52
+ /** The semantic component to render the Button. Preferrably `"button"`. Native props will be passed to this component. */
53
+ component?: C;
54
+ } & Omit<ComponentProps<C>, keyof SheetButtonBaseProps | "component">;
55
+ type SheetPrimaryButtonProps<C extends ElementType> = SheetButtonProps<C> & {
56
+ /** If `true`, a loading spinner will be shown instead of the content. */
57
+ loading?: boolean;
58
+ };
59
+ export interface Props extends SheetProps {
60
+ /** A reference to the root element of the sheet. */
61
+ ref?: RefObject<HTMLDivElement>;
62
+ }
63
+ declare const BottomSheetRoot: {
64
+ ({ children, isOpen, onClose, onBack, zIndex, ref }: Props): React.JSX.Element;
65
+ displayName: string;
66
+ };
67
+ export default BottomSheetRoot;
68
+ export declare const Title: ({ children, subline, level }: SheetTitleProps) => React.JSX.Element;
69
+ export declare const Content: ({ children, disableHorizontalPadding }: SheetContentProps) => React.JSX.Element;
70
+ export declare const ButtonSection: ({ children }: SheetButtonSectionProps) => React.JSX.Element;
71
+ export declare const PrimaryButton: <C extends ElementType>({ children, icon, iconPosition, loading, component, ...props }: SheetPrimaryButtonProps<C>) => React.JSX.Element;
72
+ export declare const SecondaryButton: <C extends ElementType>({ children, icon, iconPosition, component, ...props }: SheetButtonProps<C>) => React.JSX.Element;
@@ -2,20 +2,21 @@
2
2
  import e from "./BottomSheetContext.js";
3
3
  import t from "./useConsumeBottomSheet.js";
4
4
  import n from "./useCreateBottomSheet.js";
5
- import { useId as r } from "react";
6
- import { backdrop as i } from "@bonprix-ds/internal-components";
7
- import a from "@bonprix-ds/react-button";
8
- import o from "@bonprix-ds/react-icon-button";
9
- import s from "@bonprix-ds/react-typography";
10
- import { ZIndexContext as c, useInnerOpen as l, usePrefersReducedMotion as u } from "@bonprix-ds/utils";
11
- import { Sheet as d } from "react-modal-sheet";
12
- import { tv as f } from "tailwind-variants";
13
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
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";
14
15
  //#region src/BottomSheetRoot.tsx
15
- var h = f({
16
+ var _ = s({
16
17
  slots: {
17
18
  root: "preflight block",
18
- container: "shadow-none rounded-none bg-clr-bg-modal max-h-[calc(100%-4rem)]",
19
+ container: "shadow-none rounded-none bg-clr-bg-modal max-h-[calc(100%-4rem)] outline-none",
19
20
  header: "px-4 py-3",
20
21
  titleAndIcons: "flex gap-2 items-center touch-pan-down",
21
22
  contentWrapper: "flex flex-col w-full",
@@ -26,119 +27,136 @@ var h = f({
26
27
  ],
27
28
  dragHandleContainer: "h-6 flex justify-center items-center shrink-0",
28
29
  dragHandle: "h-1 w-8 rounded-full bg-clr-on-bg-low",
29
- backdrop: i(),
30
+ backdrop: c(),
30
31
  scrollArea: "scroll-area relative"
31
32
  },
32
33
  variants: { disableHorizontalPadding: {
33
34
  false: { scrollArea: "px-4" },
34
35
  true: ""
35
36
  } }
36
- }), g = ({ children: t, isOpen: i, onClose: a, onBack: o, zIndex: s = 9999, ref: f }) => {
37
- let g = u(), { root: _, container: v, dragHandleContainer: y, dragHandle: b, content: x, contentWrapper: S, backdrop: C } = h(), { isShown: w, scrollRef: T, scrollPosition: E } = n({ isOpen: i }), D = E === "middle" || E === "bottom", { innerOpen: O } = l(w), k = r();
38
- return /* @__PURE__ */ m(d, {
39
- isOpen: O,
40
- onClose: a,
41
- className: _(),
42
- detent: "content",
43
- "data-bpds": "bottom-sheet",
44
- prefersReducedMotion: g,
45
- style: {
46
- "--touch-action": D ? "initial" : "pan-down",
47
- pointerEvents: void 0,
48
- visibility: O ? "visible" : "hidden",
49
- zIndex: s
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,
43
+ onOpenChange: (e) => {
44
+ e || c();
50
45
  },
51
- role: "dialog",
52
- avoidKeyboard: !1,
53
- "aria-labelledby": k,
54
- children: [/* @__PURE__ */ m(d.Container, {
55
- className: v(),
56
- ref: f,
57
- style: { pointerEvents: void 0 },
58
- children: [/* @__PURE__ */ p(d.Header, {
59
- unstyled: !0,
60
- className: y(),
61
- children: /* @__PURE__ */ p(d.DragIndicator, {
62
- unstyled: !0,
63
- className: b()
64
- })
65
- }), /* @__PURE__ */ p(c.Provider, {
66
- value: s,
67
- children: /* @__PURE__ */ p(e.Provider, {
68
- value: {
69
- scrollRef: T,
70
- scrollPosition: E,
71
- onClose: a,
72
- onBack: o,
73
- titleId: k
74
- },
75
- children: /* @__PURE__ */ p(d.Content, {
46
+ children: /* @__PURE__ */ g(o, {
47
+ isOpen: A,
48
+ onClose: c,
49
+ className: y(),
50
+ detent: "content",
51
+ "data-bpds": "bottom-sheet",
52
+ prefersReducedMotion: v,
53
+ style: {
54
+ pointerEvents: void 0,
55
+ visibility: A ? "visible" : "hidden",
56
+ zIndex: u
57
+ },
58
+ avoidKeyboard: !1,
59
+ children: [/* @__PURE__ */ h(a.Content, {
60
+ forceMount: !0,
61
+ asChild: !0,
62
+ "aria-modal": !0,
63
+ "aria-describedby": void 0,
64
+ tabIndex: -1,
65
+ onOpenAutoFocus: (e) => {
66
+ e.preventDefault(), j.current = document.activeElement, e.target.focus();
67
+ },
68
+ onCloseAutoFocus: (e) => e.preventDefault(),
69
+ children: /* @__PURE__ */ g(o.Container, {
70
+ className: b(),
71
+ ref: d,
72
+ children: [/* @__PURE__ */ h(o.Header, {
73
+ unstyled: !0,
76
74
  className: x(),
77
- disableScroll: !0,
78
- disableDrag: D,
79
- children: /* @__PURE__ */ p("div", {
80
- className: S(),
81
- style: { paddingBottom: "max(var(--keyboard-inset-height, 0rem), var(--app-safe-area-inset-bottom, 1rem))" },
82
- children: t
75
+ children: /* @__PURE__ */ h(o.DragIndicator, {
76
+ unstyled: !0,
77
+ className: S()
83
78
  })
84
- })
79
+ }), /* @__PURE__ */ h(f.Provider, {
80
+ value: u,
81
+ children: /* @__PURE__ */ h(e.Provider, {
82
+ value: {
83
+ scrollRef: D,
84
+ scrollPosition: O,
85
+ onClose: c,
86
+ onBack: l,
87
+ disableDrag: k
88
+ },
89
+ children: /* @__PURE__ */ h(o.Content, {
90
+ className: C(),
91
+ disableScroll: !0,
92
+ disableDrag: k,
93
+ children: /* @__PURE__ */ h("div", {
94
+ className: w(),
95
+ style: { paddingBottom: "max(var(--keyboard-inset-height, 0rem), var(--app-safe-area-inset-bottom, 1rem))" },
96
+ children: t
97
+ })
98
+ })
99
+ })
100
+ })]
85
101
  })
86
- })]
87
- }), /* @__PURE__ */ p(d.Backdrop, {
88
- "aria-label": "Bottom Sheet schließen",
89
- onTap: a,
90
- className: C()
91
- })]
102
+ }), /* @__PURE__ */ h(o.Backdrop, { className: T() })]
103
+ })
92
104
  });
93
- }, _ = ({ children: e, subline: n, level: r = "h3" }) => {
94
- let { onBack: i, onClose: a, titleId: c } = t(), { header: l, titleAndIcons: u } = h();
95
- return /* @__PURE__ */ m("div", {
96
- className: l(),
97
- children: [/* @__PURE__ */ m("div", {
98
- className: u(),
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", {
108
+ className: s(),
109
+ children: [/* @__PURE__ */ g("div", {
110
+ className: c(),
99
111
  children: [
100
- i && /* @__PURE__ */ p(o, {
112
+ i && /* @__PURE__ */ h(u, {
101
113
  onClick: i,
102
114
  icon: "arrow-left",
103
115
  label: "Zurück",
104
116
  variant: "tertiary",
105
117
  size: "small"
106
118
  }),
107
- /* @__PURE__ */ p(s, {
108
- variant: "bonprix-h6",
109
- component: r,
110
- className: "grow line-clamp-2",
111
- id: c,
112
- children: e
119
+ /* @__PURE__ */ h(a.Title, {
120
+ asChild: !0,
121
+ children: /* @__PURE__ */ h("div", {
122
+ className: "grow",
123
+ children: /* @__PURE__ */ h(d, {
124
+ variant: "bonprix-h6",
125
+ component: r,
126
+ className: "line-clamp-2",
127
+ children: e
128
+ })
129
+ })
113
130
  }),
114
- /* @__PURE__ */ p(o, {
115
- onClick: a,
131
+ /* @__PURE__ */ h(u, {
132
+ onClick: o,
116
133
  icon: "closer",
117
134
  label: "Schließen",
118
135
  variant: "tertiary",
119
136
  size: "small"
120
137
  })
121
138
  ]
122
- }), n && /* @__PURE__ */ p(s, { children: n })]
139
+ }), n && /* @__PURE__ */ h(d, { children: n })]
123
140
  });
124
- }, v = ({ children: e, disableHorizontalPadding: n = !1 }) => {
125
- let { scrollRef: r } = t(), { scrollArea: i } = h({ disableHorizontalPadding: n });
126
- return /* @__PURE__ */ p("div", {
141
+ }, b = ({ children: e, disableHorizontalPadding: n = !1 }) => {
142
+ let { scrollRef: r, disableDrag: i } = t(), { scrollArea: a } = _({ disableHorizontalPadding: n });
143
+ return /* @__PURE__ */ h("div", {
127
144
  ref: r,
128
- className: i(),
145
+ className: a(),
146
+ style: { touchAction: i ? "auto" : "pan-down" },
129
147
  "data-bpds-disable-horizontal-padding": n,
130
148
  tabIndex: 0,
131
149
  children: e
132
150
  });
133
- }, y = ({ children: e }) => /* @__PURE__ */ p("div", {
151
+ }, x = ({ children: e }) => /* @__PURE__ */ h("div", {
134
152
  className: "button-section w-full flex flex-col gap-3 px-4 pt-4 shrink-0 touch-pan-down",
135
153
  children: e
136
- }), b = ({ children: e, icon: n, iconPosition: r, loading: i, component: o = "button", ...s }) => {
137
- let c = o, { onClick: l, ...u } = s, { onClose: d } = t(), f = (e) => {
138
- l?.(e), d();
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) => {
156
+ c?.(e), d();
139
157
  };
140
- return /* @__PURE__ */ p(a, {
141
- component: c,
158
+ return /* @__PURE__ */ h(l, {
159
+ component: s,
142
160
  ...u,
143
161
  variant: "primary",
144
162
  onClick: f,
@@ -148,21 +166,21 @@ var h = f({
148
166
  loading: i,
149
167
  children: e
150
168
  });
151
- }, x = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...o }) => {
152
- let s = i, { onClose: c } = t();
153
- return /* @__PURE__ */ p(a, {
154
- component: s,
155
- ...o,
169
+ }, C = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...a }) => {
170
+ let o = i, { onClose: s } = t();
171
+ return /* @__PURE__ */ h(l, {
172
+ component: o,
173
+ ...a,
156
174
  variant: "secondary",
157
- onClick: c,
175
+ onClick: s,
158
176
  icon: n,
159
177
  iconPosition: r,
160
178
  size: "large",
161
179
  children: e
162
180
  });
163
181
  };
164
- g.displayName = "BottomSheet";
182
+ v.displayName = "BottomSheet";
165
183
  //#endregion
166
- export { y as ButtonSection, v as Content, b as PrimaryButton, x as SecondaryButton, _ as Title, g as default };
184
+ export { x as ButtonSection, b as Content, S as PrimaryButton, C as SecondaryButton, y as Title, v as default };
167
185
 
168
186
  //# sourceMappingURL=BottomSheetRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BottomSheetRoot.js","names":[],"sources":["../../src/BottomSheetRoot.tsx"],"sourcesContent":["\"use client\";\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\";\nimport React, { ComponentProps, ElementType, ReactNode, RefObject, useId } from \"react\";\nimport { Sheet } from \"react-modal-sheet\";\nimport { tv } from \"tailwind-variants\";\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)]\",\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 * - 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 // TODO: add aria-modal = true once we implemented the dialog pattern fully and i.e. manage the focus\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 titleId = useId();\n\n return (\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 // @ts-expect-error setting custom properties is not recognized by React.CSSProperties\n // This is consumed by the inner ScrollArea to fix drag to close.\n \"--touch-action\": disableDrag ? \"initial\" : \"pan-down\",\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 role=\"dialog\"\n avoidKeyboard={false}\n aria-labelledby={titleId}\n >\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 <Sheet.Container className={container()} ref={ref} style={{ pointerEvents: undefined }}>\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, titleId }}>\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 {/* TODO: Deactivate the animation, when the user prefers reduced motion: https://github.com/Temzasse/react-modal-sheet/issues/227 */}\n <Sheet.Backdrop aria-label=\"Bottom Sheet schließen\" onTap={onClose} className={backdrop()} />\n </Sheet>\n );\n};\n\nexport default BottomSheetRoot;\n\nexport const Title = ({ children, subline, level = \"h3\" }: SheetTitleProps) => {\n const { onBack, onClose, titleId } = 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 <Typography variant=\"bonprix-h6\" component={level} className=\"grow line-clamp-2\" id={titleId}>\n {children}\n </Typography>\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 } = useConsumeBottomSheet();\n const { scrollArea } = generateClasses({ disableHorizontalPadding });\n return (\n <div ref={setScrollRef} className={scrollArea()} data-bpds-disable-horizontal-padding={disableHorizontalPadding} tabIndex={0}>\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 // eslint-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":";;;;;;;;;;;;;;AAgBA,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,OAAO,EAAE,YAAY,OAAO;EAC5B,MAAM;CACR,EACF;AACF,CAAC,GAoEK,KAAmB,EAAE,aAAU,WAAQ,YAAS,WAAQ,YAAS,MAAM,aAAiB;CAE5F,IAAM,IAAuB,EAAwB,GAC/C,EAAE,SAAM,cAAW,wBAAqB,eAAY,YAAS,mBAAgB,gBAAa,EAAgB,GAC1G,EAAE,YAAS,cAAW,sBAAmB,EAAqB,EAAE,UAAO,CAAC,GAIxE,IAAc,MAAmB,YAAY,MAAmB,UAEhE,EAAE,iBAAc,EAAa,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cesContent":["\"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,OAAO,EAA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AAW;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"}
@@ -0,0 +1,2 @@
1
+ declare const useConsumeBottomSheet: () => import("./BottomSheetContext").BottomSheetContextProps;
2
+ export default useConsumeBottomSheet;
@@ -0,0 +1,9 @@
1
+ interface UseBottomSheetProps {
2
+ isOpen: boolean;
3
+ }
4
+ declare const useCreateBottomSheet: ({ isOpen }: UseBottomSheetProps) => {
5
+ isShown: boolean;
6
+ scrollRef: (element: HTMLElement | null) => void;
7
+ scrollPosition: "top" | "bottom" | "middle" | undefined;
8
+ };
9
+ export default useCreateBottomSheet;
@@ -1,10 +1,10 @@
1
1
  import { useEffect as e } from "react";
2
- import { useBreakpointBetween as t } from "@bonprix-ds/utils";
3
- import { useScrollPosition as n, useVirtualKeyboard as r } from "react-modal-sheet";
2
+ import { useScrollPosition as t, useVirtualKeyboard as n } from "react-modal-sheet";
3
+ import { useBreakpointBetween as r } from "@bonprix-ds/utils";
4
4
  //#region src/useCreateBottomSheet.ts
5
5
  var i = ({ isOpen: i }) => {
6
- let a = t("s", "m") && i, { scrollRef: o, scrollPosition: s } = n({ isEnabled: a });
7
- return r({ isEnabled: i }), e(() => {
6
+ let a = r("s", "m") && i, { scrollRef: o, scrollPosition: s } = t({ isEnabled: a });
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 } }));
9
9
  }, [i]), {
10
10
  isShown: a,
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateBottomSheet.js","names":[],"sources":["../../src/useCreateBottomSheet.ts"],"sourcesContent":["import { useBreakpointBetween } from \"@bonprix-ds/utils\";\nimport { useEffect } from \"react\";\nimport { useScrollPosition, useVirtualKeyboard } from \"react-modal-sheet\";\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":";;;;AAQA,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":[],"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"}
package/package.json CHANGED
@@ -1,14 +1,25 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-bottom-sheet",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "BottomSheet component, implemented in React, for the Bonprix Design System.",
5
- "type": "module",
6
- "publishConfig": {
7
- "access": "public",
8
- "provenance": true
5
+ "keywords": [],
6
+ "license": "UNLICENSED",
7
+ "author": "",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/bonprix/design-system.git",
11
+ "directory": "packages/react/bottom-sheet"
9
12
  },
10
- "module": "./dist/index.js",
13
+ "files": [
14
+ "dist",
15
+ "!dist/tsconfig.tsbuildinfo",
16
+ "!dist/vite.config.d.ts",
17
+ "!dist/**/*.test.d.ts"
18
+ ],
19
+ "type": "module",
11
20
  "sideEffects": false,
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
12
23
  "exports": {
13
24
  ".": {
14
25
  "import": "./dist/index.js",
@@ -16,42 +27,33 @@
16
27
  "default": "./dist/index.js"
17
28
  }
18
29
  },
19
- "types": "./dist/index.d.ts",
20
- "files": [
21
- "dist"
22
- ],
23
- "keywords": [],
24
- "author": "",
25
- "license": "UNLICENSED",
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/bonprix/design-system.git",
29
- "directory": "packages/react/bottom-sheet"
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "provenance": true
30
33
  },
31
34
  "dependencies": {
35
+ "@radix-ui/react-dialog": "1.1.23",
32
36
  "react-modal-sheet": "5.6.0",
33
- "@bonprix-ds/internal-components": "0.1.5",
34
- "@bonprix-ds/react-icon": "1.1.3",
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",
35
41
  "@bonprix-ds/react-typography": "1.0.4",
36
- "@bonprix-ds/react-button": "1.0.0",
37
- "@bonprix-ds/react-icon-button": "1.1.5",
38
- "@bonprix-ds/utils": "0.2.1"
39
- },
40
- "peerDependencies": {
41
- "react": "^19.0.0",
42
- "react-dom": "^19.0.0",
43
- "tailwind-variants": "0.3.1"
42
+ "@bonprix-ds/utils": "0.2.2"
44
43
  },
45
44
  "devDependencies": {
46
- "vite": "8.2.2",
47
- "vitest": "4.1.11",
48
- "@testing-library/dom": "10.4.1",
45
+ "@testing-library/dom": "10.4.2",
49
46
  "@testing-library/react": "16.3.3",
50
- "@types/react": "19.2.18",
47
+ "@types/react": "19.3.0",
51
48
  "@vitejs/plugin-react": "6.1.1",
52
49
  "rollup-preserve-directives": "1.1.3",
53
- "unplugin-dts": "1.0.3",
54
- "@microsoft/api-extractor": "7.59.0"
50
+ "vite": "8.3.0",
51
+ "vitest": "4.1.11"
52
+ },
53
+ "peerDependencies": {
54
+ "react": "^19.3.0",
55
+ "react-dom": "^19.3.0",
56
+ "tailwind-variants": "0.3.1"
55
57
  },
56
58
  "scripts": {
57
59
  "build": "vite build"