@bonprix-ds/react-bottom-sheet 1.0.1 → 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,86 +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
- export 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
- export 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
- export declare interface SheetButtonSectionProps {
44
- /** Primary and secondary buttons should be placed inside this section. */
45
- children: ReactNode;
46
- }
47
-
48
- export 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
- * - Press of the `Escape` key
65
- * - Swipe down to close
66
- * - Click on "close" icon button in the upper-right corner
67
- * - Click on any button (PrimaryButton or SecondaryButton)
68
- *
69
- * Should be used in conjunction with `isOpen`. */
70
- onClose: () => void;
71
- /** Callback to execute when clicking back icon. */
72
- onBack?: () => void;
73
- /** The z-index of the sheet.. */
74
- zIndex?: number;
75
- }
76
-
77
- export declare interface SheetTitleProps {
78
- /** The text content. */
79
- children: string;
80
- /** An optional subline that is displayed right below the title. */
81
- subline?: string;
82
- /** The heading level for the title. */
83
- level?: TitleLevel;
84
- }
85
-
86
- 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;
@@ -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;
@@ -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;
@@ -3,17 +3,17 @@ import e from "./BottomSheetContext.js";
3
3
  import t from "./useConsumeBottomSheet.js";
4
4
  import n from "./useCreateBottomSheet.js";
5
5
  import { useEffect as r, useRef as i } from "react";
6
- import { backdrop as a } from "@bonprix-ds/internal-components";
7
- import o from "@bonprix-ds/react-button";
8
- import s from "@bonprix-ds/react-icon-button";
9
- import c from "@bonprix-ds/react-typography";
10
- import { ZIndexContext as l, useInnerOpen as u, usePrefersReducedMotion as d } from "@bonprix-ds/utils";
11
- import { Sheet as f } from "react-modal-sheet";
12
- import { tv as p } from "tailwind-variants";
13
- import * as m from "@radix-ui/react-dialog";
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
14
  import { jsx as h, jsxs as g } from "react/jsx-runtime";
15
15
  //#region src/BottomSheetRoot.tsx
16
- var _ = p({
16
+ var _ = s({
17
17
  slots: {
18
18
  root: "preflight block",
19
19
  container: "shadow-none rounded-none bg-clr-bg-modal max-h-[calc(100%-4rem)] outline-none",
@@ -27,25 +27,25 @@ var _ = p({
27
27
  ],
28
28
  dragHandleContainer: "h-6 flex justify-center items-center shrink-0",
29
29
  dragHandle: "h-1 w-8 rounded-full bg-clr-on-bg-low",
30
- backdrop: a(),
30
+ backdrop: c(),
31
31
  scrollArea: "scroll-area relative"
32
32
  },
33
33
  variants: { disableHorizontalPadding: {
34
34
  false: { scrollArea: "px-4" },
35
35
  true: ""
36
36
  } }
37
- }), v = ({ children: t, isOpen: a, onClose: o, onBack: s, zIndex: c = 9999, ref: p }) => {
38
- let v = d(), { root: y, container: b, dragHandleContainer: x, dragHandle: S, content: C, contentWrapper: w, backdrop: T } = _(), { isShown: E, scrollRef: D, scrollPosition: O } = n({ isOpen: a }), k = O === "middle" || O === "bottom", { innerOpen: A } = u(E), j = i(null);
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
39
  return r(() => {
40
40
  A || (j.current?.focus(), j.current = null);
41
- }, [A]), /* @__PURE__ */ h(m.Root, {
41
+ }, [A]), /* @__PURE__ */ h(a.Root, {
42
42
  open: A,
43
43
  onOpenChange: (e) => {
44
- e || o();
44
+ e || c();
45
45
  },
46
- children: /* @__PURE__ */ g(f, {
46
+ children: /* @__PURE__ */ g(o, {
47
47
  isOpen: A,
48
- onClose: o,
48
+ onClose: c,
49
49
  className: y(),
50
50
  detent: "content",
51
51
  "data-bpds": "bottom-sheet",
@@ -53,10 +53,10 @@ var _ = p({
53
53
  style: {
54
54
  pointerEvents: void 0,
55
55
  visibility: A ? "visible" : "hidden",
56
- zIndex: c
56
+ zIndex: u
57
57
  },
58
58
  avoidKeyboard: !1,
59
- children: [/* @__PURE__ */ h(m.Content, {
59
+ children: [/* @__PURE__ */ h(a.Content, {
60
60
  forceMount: !0,
61
61
  asChild: !0,
62
62
  "aria-modal": !0,
@@ -66,27 +66,27 @@ var _ = p({
66
66
  e.preventDefault(), j.current = document.activeElement, e.target.focus();
67
67
  },
68
68
  onCloseAutoFocus: (e) => e.preventDefault(),
69
- children: /* @__PURE__ */ g(f.Container, {
69
+ children: /* @__PURE__ */ g(o.Container, {
70
70
  className: b(),
71
- ref: p,
72
- children: [/* @__PURE__ */ h(f.Header, {
71
+ ref: d,
72
+ children: [/* @__PURE__ */ h(o.Header, {
73
73
  unstyled: !0,
74
74
  className: x(),
75
- children: /* @__PURE__ */ h(f.DragIndicator, {
75
+ children: /* @__PURE__ */ h(o.DragIndicator, {
76
76
  unstyled: !0,
77
77
  className: S()
78
78
  })
79
- }), /* @__PURE__ */ h(l.Provider, {
80
- value: c,
79
+ }), /* @__PURE__ */ h(f.Provider, {
80
+ value: u,
81
81
  children: /* @__PURE__ */ h(e.Provider, {
82
82
  value: {
83
83
  scrollRef: D,
84
84
  scrollPosition: O,
85
- onClose: o,
86
- onBack: s,
85
+ onClose: c,
86
+ onBack: l,
87
87
  disableDrag: k
88
88
  },
89
- children: /* @__PURE__ */ h(f.Content, {
89
+ children: /* @__PURE__ */ h(o.Content, {
90
90
  className: C(),
91
91
  disableScroll: !0,
92
92
  disableDrag: k,
@@ -99,28 +99,28 @@ var _ = p({
99
99
  })
100
100
  })]
101
101
  })
102
- }), /* @__PURE__ */ h(f.Backdrop, { className: T() })]
102
+ }), /* @__PURE__ */ h(o.Backdrop, { className: T() })]
103
103
  })
104
104
  });
105
105
  }, y = ({ children: e, subline: n, level: r = "h3" }) => {
106
- let { onBack: i, onClose: a } = t(), { header: o, titleAndIcons: l } = _();
106
+ let { onBack: i, onClose: o } = t(), { header: s, titleAndIcons: c } = _();
107
107
  return /* @__PURE__ */ g("div", {
108
- className: o(),
108
+ className: s(),
109
109
  children: [/* @__PURE__ */ g("div", {
110
- className: l(),
110
+ className: c(),
111
111
  children: [
112
- i && /* @__PURE__ */ h(s, {
112
+ i && /* @__PURE__ */ h(u, {
113
113
  onClick: i,
114
114
  icon: "arrow-left",
115
115
  label: "Zurück",
116
116
  variant: "tertiary",
117
117
  size: "small"
118
118
  }),
119
- /* @__PURE__ */ h(m.Title, {
119
+ /* @__PURE__ */ h(a.Title, {
120
120
  asChild: !0,
121
121
  children: /* @__PURE__ */ h("div", {
122
122
  className: "grow",
123
- children: /* @__PURE__ */ h(c, {
123
+ children: /* @__PURE__ */ h(d, {
124
124
  variant: "bonprix-h6",
125
125
  component: r,
126
126
  className: "line-clamp-2",
@@ -128,15 +128,15 @@ var _ = p({
128
128
  })
129
129
  })
130
130
  }),
131
- /* @__PURE__ */ h(s, {
132
- onClick: a,
131
+ /* @__PURE__ */ h(u, {
132
+ onClick: o,
133
133
  icon: "closer",
134
134
  label: "Schließen",
135
135
  variant: "tertiary",
136
136
  size: "small"
137
137
  })
138
138
  ]
139
- }), n && /* @__PURE__ */ h(c, { children: n })]
139
+ }), n && /* @__PURE__ */ h(d, { children: n })]
140
140
  });
141
141
  }, b = ({ children: e, disableHorizontalPadding: n = !1 }) => {
142
142
  let { scrollRef: r, disableDrag: i } = t(), { scrollArea: a } = _({ disableHorizontalPadding: n });
@@ -151,12 +151,12 @@ var _ = p({
151
151
  }, x = ({ children: e }) => /* @__PURE__ */ h("div", {
152
152
  className: "button-section w-full flex flex-col gap-3 px-4 pt-4 shrink-0 touch-pan-down",
153
153
  children: e
154
- }), S = ({ children: e, icon: n, iconPosition: r, loading: i, component: a = "button", ...s }) => {
155
- let c = a, { onClick: l, ...u } = s, { onClose: d } = t(), f = (e) => {
156
- 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();
157
157
  };
158
- return /* @__PURE__ */ h(o, {
159
- component: c,
158
+ return /* @__PURE__ */ h(l, {
159
+ component: s,
160
160
  ...u,
161
161
  variant: "primary",
162
162
  onClick: f,
@@ -167,12 +167,12 @@ var _ = p({
167
167
  children: e
168
168
  });
169
169
  }, C = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...a }) => {
170
- let s = i, { onClose: c } = t();
171
- return /* @__PURE__ */ h(o, {
172
- component: s,
170
+ let o = i, { onClose: s } = t();
171
+ return /* @__PURE__ */ h(l, {
172
+ component: o,
173
173
  ...a,
174
174
  variant: "secondary",
175
- onClick: c,
175
+ onClick: s,
176
176
  icon: n,
177
177
  iconPosition: r,
178
178
  size: "large",
@@ -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, { useEffect, useRef, type ComponentProps, type ElementType, type ReactNode, type RefObject } from \"react\";\nimport { Sheet } from \"react-modal-sheet\";\nimport { tv } from \"tailwind-variants\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\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 // 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":";;;;;;;;;;;;;;;AAiBA,IAAM,IAAkB,EAAG;CACzB,OAAO;EACL,MAAM;EACN,WAAW;EACX,QAAQ;EACR,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A2B,SAA+B;CAC5F,IAAM,EAAE,WAAW,GAAc,mBAAgB,EAAsB,GACjE,EAAE,kBAAe,EAAgB,EAAE,4BAAyB,CAAC;CACnE,OACE,kBAAC,OAAD;EACE,KAAK;EACL,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":[],"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,OAAO,EAAE,YAAY,OAAO;EAC5B,MAAM;CACR,EACF;AACF,CAAC,GAqEK,KAAmB,EAAE,aAAU,WAAQ,YAAS,WAAQ,YAAS,MAAM,aAAiB;CAC5F,IAAM,IAAuB,EAAwB,GAC/C,EAAE,SAAM,cAAW,wBAAqB,eAAY,YAAS,mBAAgB,gBAAa,EAAgB,GAC1G,EAAE,YAAS,cAAW,sBAAmB,EAAqB,EAAE,UAAO,CAAC,GAIxE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AAe,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.1",
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,43 +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": {
32
35
  "@radix-ui/react-dialog": "1.1.23",
33
36
  "react-modal-sheet": "5.6.0",
34
- "@bonprix-ds/internal-components": "0.2.0",
35
- "@bonprix-ds/react-button": "1.1.0",
36
- "@bonprix-ds/react-icon": "1.2.0",
37
- "@bonprix-ds/react-icon-button": "1.2.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",
38
41
  "@bonprix-ds/react-typography": "1.0.4",
39
42
  "@bonprix-ds/utils": "0.2.2"
40
43
  },
41
- "peerDependencies": {
42
- "react": "^19.0.0",
43
- "react-dom": "^19.0.0",
44
- "tailwind-variants": "0.3.1"
45
- },
46
44
  "devDependencies": {
47
- "vite": "8.2.2",
48
- "vitest": "4.1.11",
49
45
  "@testing-library/dom": "10.4.2",
50
46
  "@testing-library/react": "16.3.3",
51
- "@types/react": "19.2.18",
47
+ "@types/react": "19.3.0",
52
48
  "@vitejs/plugin-react": "6.1.1",
53
49
  "rollup-preserve-directives": "1.1.3",
54
- "unplugin-dts": "1.1.0",
55
- "@microsoft/api-extractor": "7.59.1"
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"
56
57
  },
57
58
  "scripts": {
58
59
  "build": "vite build"