@bonprix-ds/react-side-sheet 1.0.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -86
- package/dist/no-styles.js +1 -0
- package/dist/src/SideSheet.css +8 -0
- package/dist/src/SideSheet.d.ts +17 -0
- package/dist/src/SideSheet.js.map +1 -1
- package/dist/src/SideSheetContext.d.ts +6 -0
- package/dist/src/SideSheetContext.js.map +1 -1
- package/dist/src/SideSheetRoot.d.ts +86 -0
- package/dist/src/SideSheetRoot.js +70 -68
- package/dist/src/SideSheetRoot.js.map +1 -1
- package/dist/src/useConsumeSideSheet.d.ts +2 -0
- package/dist/src/useConsumeSideSheet.js.map +1 -1
- package/dist/styles.js +1 -0
- package/package.json +43 -35
package/dist/index.d.ts
CHANGED
|
@@ -1,86 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { ElementType } from 'react';
|
|
4
|
-
import { IconType } from '@bonprix-ds/react-icon';
|
|
5
|
-
import { ReactNode } from 'react';
|
|
6
|
-
import { TitleLevel } from '@bonprix-ds/utils';
|
|
7
|
-
|
|
8
|
-
export declare interface SheetButtonBaseProps {
|
|
9
|
-
/** The label of the button. */
|
|
10
|
-
children: string;
|
|
11
|
-
/** If used, an icon will be additionally shown. The value is a name of one icon from our icon set. */
|
|
12
|
-
icon?: IconType;
|
|
13
|
-
/** The position of the icon relative to the content. */
|
|
14
|
-
iconPosition?: "start" | "end";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export declare type SheetButtonProps<C extends ElementType> = SheetButtonBaseProps & {
|
|
18
|
-
/** The semantic component to render the Button. Preferrably `"button"`. Native props will be passed to this component. */
|
|
19
|
-
component?: C;
|
|
20
|
-
} & Omit<ComponentProps<C>, keyof SheetButtonBaseProps | "component">;
|
|
21
|
-
|
|
22
|
-
export declare interface SheetButtonSectionProps {
|
|
23
|
-
/** Primary and secondary buttons should be placed inside this section. */
|
|
24
|
-
children: ReactNode;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export declare interface SheetContentProps {
|
|
28
|
-
/** The content of the content section. */
|
|
29
|
-
children: ReactNode;
|
|
30
|
-
/** If `true`, the horizontal padding around the content will be removed. */
|
|
31
|
-
disableHorizontalPadding?: boolean;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare interface SheetProps {
|
|
35
|
-
/** All of the subcomponents should be placed inside this property. */
|
|
36
|
-
children: ReactNode;
|
|
37
|
-
/** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */
|
|
38
|
-
isOpen: boolean;
|
|
39
|
-
/** Callback function, that is triggered when the sheet is attempted to be closed.
|
|
40
|
-
*
|
|
41
|
-
* It will be called in following cases:
|
|
42
|
-
* - Click on backdrop
|
|
43
|
-
* - Swipe down to close
|
|
44
|
-
* - Click on "close" icon button in the upper-right corner
|
|
45
|
-
* - Click on any button (PrimaryButton or SecondaryButton)
|
|
46
|
-
*
|
|
47
|
-
* Should be used in conjunction with `isOpen`. */
|
|
48
|
-
onClose: () => void;
|
|
49
|
-
/** Callback to execute when clicking back icon. */
|
|
50
|
-
onBack?: () => void;
|
|
51
|
-
/** The z-index of the sheet.. */
|
|
52
|
-
zIndex?: number;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export declare interface SheetTitleProps {
|
|
56
|
-
/** The text content. */
|
|
57
|
-
children: string;
|
|
58
|
-
/** An optional subline that is displayed right below the title. */
|
|
59
|
-
subline?: string;
|
|
60
|
-
/** The heading level for the title. */
|
|
61
|
-
level?: TitleLevel;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
declare const SideSheet: {
|
|
65
|
-
(props: SideSheetProps): default_2.JSX.Element;
|
|
66
|
-
displayName: string;
|
|
67
|
-
Title: ({ children, subline, level }: SheetTitleProps) => default_2.JSX.Element;
|
|
68
|
-
Content: ({ children, disableHorizontalPadding }: SheetContentProps) => default_2.JSX.Element;
|
|
69
|
-
ButtonSection: ({ children }: SheetButtonSectionProps) => default_2.JSX.Element;
|
|
70
|
-
PrimaryButton: <C extends default_2.ElementType>({ children, icon, iconPosition, loading, component, ...props }: SheetButtonBaseProps & {
|
|
71
|
-
component?: C | undefined;
|
|
72
|
-
} & Omit<default_2.ComponentProps<C>, keyof SheetButtonBaseProps | "component"> & {
|
|
73
|
-
loading?: boolean;
|
|
74
|
-
}) => default_2.JSX.Element;
|
|
75
|
-
SecondaryButton: <C extends default_2.ElementType>({ children, icon, iconPosition, component, ...props }: SheetButtonProps<C>) => default_2.JSX.Element;
|
|
76
|
-
};
|
|
77
|
-
export default SideSheet;
|
|
78
|
-
|
|
79
|
-
export declare interface SideSheetProps extends SheetProps {
|
|
80
|
-
/** When set to false, interaction with outside elements will be disabled and only dialog content will be visible to screen readers. */
|
|
81
|
-
modeless?: boolean;
|
|
82
|
-
/** Makes the Sheet of 400px fixed or able to expand up to 600px depending on the content */
|
|
83
|
-
hasDynamicWidth?: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export { }
|
|
1
|
+
export { default } from "./src/SideSheet";
|
|
2
|
+
export type { Props as SideSheetProps, SheetButtonBaseProps, SheetButtonProps, SheetButtonSectionProps, SheetContentProps, SheetTitleProps, } from "./src/SideSheet";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/SideSheet.css
CHANGED
|
@@ -8,3 +8,11 @@
|
|
|
8
8
|
flex-direction: row !important;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
+
|
|
12
|
+
/* Radix prepends focus guards to `body` while a dialog is open. Chromium saves the scroll anchor of a page that is
|
|
13
|
+
left as an `nth-child` path, which the guards shift, so going back would restore the scroll position of another
|
|
14
|
+
element. Without an anchor, Chromium restores the plain scroll offset. Keyed to the guards rather than to the
|
|
15
|
+
open state, so it holds through the closing animation and across every copy of the package on the page. */
|
|
16
|
+
:root:has(> body > [data-radix-focus-guard]) {
|
|
17
|
+
overflow-anchor: none;
|
|
18
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type Props } from "./SideSheetRoot";
|
|
3
|
+
export type { Props, SheetButtonBaseProps, SheetButtonProps, SheetButtonSectionProps, SheetContentProps, SheetTitleProps, } from "./SideSheetRoot";
|
|
4
|
+
declare const SideSheet: {
|
|
5
|
+
(props: Props): React.JSX.Element;
|
|
6
|
+
displayName: string;
|
|
7
|
+
Title: ({ children, subline, level: Level }: import("./SideSheetRoot").SheetTitleProps) => React.JSX.Element;
|
|
8
|
+
Content: ({ children, disableHorizontalPadding }: import("./SideSheetRoot").SheetContentProps) => React.JSX.Element;
|
|
9
|
+
ButtonSection: ({ children }: import("./SideSheetRoot").SheetButtonSectionProps) => React.JSX.Element;
|
|
10
|
+
PrimaryButton: <C extends React.ElementType>({ children, icon, iconPosition, loading, component, ...props }: import("./SideSheetRoot").SheetButtonBaseProps & {
|
|
11
|
+
component?: C | undefined;
|
|
12
|
+
} & Omit<React.ComponentProps<C>, keyof import("./SideSheetRoot").SheetButtonBaseProps | "component"> & {
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
}) => React.JSX.Element;
|
|
15
|
+
SecondaryButton: <C extends React.ElementType>({ children, icon, iconPosition, component, ...props }: import("./SideSheetRoot").SheetButtonProps<C>) => React.JSX.Element;
|
|
16
|
+
};
|
|
17
|
+
export default SideSheet;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideSheet.js","names":[],"sources":["../../src/SideSheet.tsx"],"sourcesContent":["import React from \"react\";\n\nimport SideSheetRoot, { ButtonSection, Content, PrimaryButton, SecondaryButton, Title, type Props } from \"./SideSheetRoot\";\n\nexport type {\n Props,\n SheetButtonBaseProps,\n SheetButtonProps,\n SheetButtonSectionProps,\n SheetContentProps,\n SheetTitleProps,\n} from \"./SideSheetRoot\";\n\nconst SideSheet = (props: Props) => <SideSheetRoot {...props} />;\n\nSideSheet.displayName = \"SideSheet\";\n\nSideSheet.Title = Title;\nSideSheet.Content = Content;\nSideSheet.ButtonSection = ButtonSection;\nSideSheet.PrimaryButton = PrimaryButton;\nSideSheet.SecondaryButton = SecondaryButton;\n\nexport default SideSheet;\n"],"mappings":";;;;AAaA,
|
|
1
|
+
{"version":3,"file":"SideSheet.js","names":["SideSheetRoot","SideSheet","props","Title","Content","ButtonSection","PrimaryButton","SecondaryButton"],"sources":["../../src/SideSheet.tsx"],"sourcesContent":["import React from \"react\";\n\nimport SideSheetRoot, { ButtonSection, Content, PrimaryButton, SecondaryButton, Title, type Props } from \"./SideSheetRoot\";\n\nexport type {\n Props,\n SheetButtonBaseProps,\n SheetButtonProps,\n SheetButtonSectionProps,\n SheetContentProps,\n SheetTitleProps,\n} from \"./SideSheetRoot\";\n\nconst SideSheet = (props: Props) => <SideSheetRoot {...props} />;\n\nSideSheet.displayName = \"SideSheet\";\n\nSideSheet.Title = Title;\nSideSheet.Content = Content;\nSideSheet.ButtonSection = ButtonSection;\nSideSheet.PrimaryButton = PrimaryButton;\nSideSheet.SecondaryButton = SecondaryButton;\n\nexport default SideSheet;\n"],"mappings":";;;;AAaA,IAAMC,KAAa,MAAiB,kBAACD,GAAD,EAAe,GAAIE,EAAQ,CAAA;AAE/D,EAAU,cAAc,aAExB,EAAU,QAAQC,GAClB,EAAU,UAAUC,GACpB,EAAU,gBAAgBC,GAC1B,EAAU,gBAAgBC,GAC1B,EAAU,kBAAkBC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideSheetContext.js","names":[],"sources":["../../src/SideSheetContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\nexport interface SideSheetContextProps {\n onClose: () => void;\n onBack?: () => void;\n}\n\nconst SideSheetContext = createContext<SideSheetContextProps>({\n onClose: () => null,\n onBack: () => null,\n});\n\nexport default SideSheetContext;\n"],"mappings":";;;AASA,
|
|
1
|
+
{"version":3,"file":"SideSheetContext.js","names":["SideSheetContext","createContext"],"sources":["../../src/SideSheetContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext } from \"react\";\n\nexport interface SideSheetContextProps {\n onClose: () => void;\n onBack?: () => void;\n}\n\nconst SideSheetContext = createContext<SideSheetContextProps>({\n onClose: () => null,\n onBack: () => null,\n});\n\nexport default SideSheetContext;\n"],"mappings":";;;AASA,IAAMA,IAAmBC,EAAqC;CAC5D,eAAe;CACf,cAAc;AAChB,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React, { ComponentProps, ElementType, ReactNode } from "react";
|
|
2
|
+
import type { IconType } from "@bonprix-ds/react-icon";
|
|
3
|
+
import { TitleLevel } from "@bonprix-ds/utils";
|
|
4
|
+
import "./SideSheet.css";
|
|
5
|
+
interface SheetProps {
|
|
6
|
+
/** All of the subcomponents should be placed inside this property. */
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
/** Callback function, that is triggered when the sheet is attempted to be closed.
|
|
9
|
+
*
|
|
10
|
+
* It will be called in following cases:
|
|
11
|
+
* - Click on backdrop
|
|
12
|
+
* - Swipe down to close
|
|
13
|
+
* - Click on "close" icon button in the upper-right corner
|
|
14
|
+
* - Click on any button (PrimaryButton or SecondaryButton)
|
|
15
|
+
*
|
|
16
|
+
* Should be used in conjunction with `open`. */
|
|
17
|
+
onClose: () => void;
|
|
18
|
+
/** Callback to execute when clicking back icon. */
|
|
19
|
+
onBack?: () => void;
|
|
20
|
+
/** The z-index of the sheet.. */
|
|
21
|
+
zIndex?: number;
|
|
22
|
+
}
|
|
23
|
+
type OpenProps = SheetProps & {
|
|
24
|
+
/** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */
|
|
25
|
+
open: boolean;
|
|
26
|
+
/** @deprecated [is-open-prop] Use `open` instead. */
|
|
27
|
+
isOpen?: never;
|
|
28
|
+
};
|
|
29
|
+
type DeprecatedOpenProps = SheetProps & {
|
|
30
|
+
open?: never;
|
|
31
|
+
/**
|
|
32
|
+
* Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property.
|
|
33
|
+
* @deprecated [is-open-prop] Use `open` instead.
|
|
34
|
+
*/
|
|
35
|
+
isOpen: boolean;
|
|
36
|
+
};
|
|
37
|
+
export interface SheetTitleProps {
|
|
38
|
+
/** The text content. */
|
|
39
|
+
children: string;
|
|
40
|
+
/** An optional subline that is displayed right below the title. */
|
|
41
|
+
subline?: string;
|
|
42
|
+
/** The heading level for the title. */
|
|
43
|
+
level?: TitleLevel;
|
|
44
|
+
}
|
|
45
|
+
export interface SheetButtonSectionProps {
|
|
46
|
+
/** Primary and secondary buttons should be placed inside this section. */
|
|
47
|
+
children: ReactNode;
|
|
48
|
+
}
|
|
49
|
+
export interface SheetContentProps {
|
|
50
|
+
/** The content of the content section. */
|
|
51
|
+
children: ReactNode;
|
|
52
|
+
/** If `true`, the horizontal padding around the content will be removed. */
|
|
53
|
+
disableHorizontalPadding?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface SheetButtonBaseProps {
|
|
56
|
+
/** The label of the button. */
|
|
57
|
+
children: string;
|
|
58
|
+
/** If used, an icon will be additionally shown. The value is a name of one icon from our icon set. */
|
|
59
|
+
icon?: IconType;
|
|
60
|
+
/** The position of the icon relative to the content. */
|
|
61
|
+
iconPosition?: "start" | "end";
|
|
62
|
+
}
|
|
63
|
+
export type SheetButtonProps<C extends ElementType> = SheetButtonBaseProps & {
|
|
64
|
+
/** The semantic component to render the Button. Preferrably `"button"`. Native props will be passed to this component. */
|
|
65
|
+
component?: C;
|
|
66
|
+
} & Omit<ComponentProps<C>, keyof SheetButtonBaseProps | "component">;
|
|
67
|
+
type SheetPrimaryButtonProps<C extends ElementType> = SheetButtonProps<C> & {
|
|
68
|
+
/** If `true`, a loading spinner will be shown instead of the content. */
|
|
69
|
+
loading?: boolean;
|
|
70
|
+
};
|
|
71
|
+
export type Props = (DeprecatedOpenProps | OpenProps) & {
|
|
72
|
+
/** When set to false, interaction with outside elements will be disabled and only dialog content will be visible to screen readers. */
|
|
73
|
+
modeless?: boolean;
|
|
74
|
+
/** Makes the Sheet of 400px fixed or able to expand up to 600px depending on the content */
|
|
75
|
+
hasDynamicWidth?: boolean;
|
|
76
|
+
};
|
|
77
|
+
declare const SideSheetRoot: {
|
|
78
|
+
({ children, open, isOpen, modeless, onClose, onBack, zIndex, hasDynamicWidth }: Props): React.JSX.Element | undefined;
|
|
79
|
+
displayName: string;
|
|
80
|
+
};
|
|
81
|
+
export declare const Title: ({ children, subline, level: Level }: SheetTitleProps) => React.JSX.Element;
|
|
82
|
+
export declare const Content: ({ children, disableHorizontalPadding }: SheetContentProps) => React.JSX.Element;
|
|
83
|
+
export declare const ButtonSection: ({ children }: SheetButtonSectionProps) => React.JSX.Element;
|
|
84
|
+
export declare const PrimaryButton: <C extends ElementType>({ children, icon, iconPosition, loading, component, ...props }: SheetPrimaryButtonProps<C>) => React.JSX.Element;
|
|
85
|
+
export declare const SecondaryButton: <C extends ElementType>({ children, icon, iconPosition, component, ...props }: SheetButtonProps<C>) => React.JSX.Element;
|
|
86
|
+
export default SideSheetRoot;
|
|
@@ -2,110 +2,109 @@
|
|
|
2
2
|
import e from "./SideSheetContext.js";
|
|
3
3
|
import t from "./useConsumeSideSheet.js";
|
|
4
4
|
import "react";
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import s from "@bonprix-ds/
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import
|
|
13
|
-
import "
|
|
5
|
+
import * as n from "@radix-ui/react-dialog";
|
|
6
|
+
import { twMerge as r } from "tailwind-merge";
|
|
7
|
+
import { tv as i } from "tailwind-variants";
|
|
8
|
+
import { backdrop as a, fadeAnimation as o, slideAnimation as s } from "@bonprix-ds/internal-components";
|
|
9
|
+
import c from "@bonprix-ds/react-button";
|
|
10
|
+
import l from "@bonprix-ds/react-icon-button";
|
|
11
|
+
import { ZIndexContext as u, useBreakpointDown as d, useInnerOpen as f, usePrefersReducedMotion as p } from "@bonprix-ds/utils";
|
|
12
|
+
import { warnDeprecated as m } from "@bonprix-ds/utils/deprecation";
|
|
13
|
+
import "#styles";
|
|
14
14
|
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
15
15
|
//#region src/SideSheetRoot.tsx
|
|
16
|
-
var _ =
|
|
16
|
+
var _ = i({
|
|
17
17
|
slots: {
|
|
18
|
-
modal: "preflight fixed h-dvh flex
|
|
18
|
+
modal: "preflight fixed -end-100 top-0 flex h-dvh flex-col bg-clr-bg-modal outline-none",
|
|
19
19
|
header: "px-4 py-6",
|
|
20
|
-
titleAndIcons: "flex gap-2
|
|
21
|
-
scrollArea: "
|
|
22
|
-
buttonSection: "w-full
|
|
23
|
-
backdrop:
|
|
24
|
-
contentWrapper: "
|
|
20
|
+
titleAndIcons: "flex items-center gap-2",
|
|
21
|
+
scrollArea: "scroll-area relative h-full",
|
|
22
|
+
buttonSection: "flex w-full shrink-0 flex-col gap-3 px-4 pt-6",
|
|
23
|
+
backdrop: a(),
|
|
24
|
+
contentWrapper: "typography-body1 flex w-full grow flex-col overflow-hidden pb-6 text-clr-primary"
|
|
25
25
|
},
|
|
26
26
|
variants: {
|
|
27
27
|
disableHorizontalPadding: { false: { scrollArea: "px-4" } },
|
|
28
28
|
prefersReducedMotion: {
|
|
29
29
|
false: {
|
|
30
|
-
modal:
|
|
31
|
-
backdrop:
|
|
30
|
+
modal: s(),
|
|
31
|
+
backdrop: o()
|
|
32
32
|
},
|
|
33
33
|
true: { modal: "end-0" }
|
|
34
34
|
},
|
|
35
35
|
hasDynamicWidth: {
|
|
36
36
|
false: { modal: "w-100" },
|
|
37
|
-
true: { modal: "min-w-100
|
|
37
|
+
true: { modal: "w-fit min-w-100 max-w-150" }
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
}), v = ({ children: t, isOpen:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
40
|
+
}), v = ({ children: t, open: r, isOpen: i, modeless: a = !1, onClose: o, onBack: s, zIndex: c = 9999, hasDynamicWidth: l = !1 }) => {
|
|
41
|
+
i !== void 0 && m("is-open-prop");
|
|
42
|
+
let v = p(), y = d("m"), { modal: b, backdrop: x, contentWrapper: S } = _({
|
|
43
|
+
hasDynamicWidth: l,
|
|
44
|
+
prefersReducedMotion: v
|
|
45
|
+
}), { innerOpen: C } = f(r ?? i ?? !1);
|
|
46
|
+
return y ? void 0 : /* @__PURE__ */ h(n.Root, {
|
|
47
|
+
open: C,
|
|
48
|
+
modal: !a,
|
|
49
|
+
children: /* @__PURE__ */ g(n.Portal, { children: [/* @__PURE__ */ h(n.Overlay, {
|
|
50
|
+
className: x(),
|
|
51
|
+
onClick: o,
|
|
52
|
+
style: { zIndex: c }
|
|
53
|
+
}), /* @__PURE__ */ h(n.Content, {
|
|
54
|
+
className: b(),
|
|
55
|
+
style: { zIndex: c },
|
|
55
56
|
"aria-describedby": void 0,
|
|
56
57
|
onOpenAutoFocus: (e) => {
|
|
57
58
|
e.preventDefault(), e.target.focus();
|
|
58
59
|
},
|
|
59
60
|
tabIndex: -1,
|
|
60
61
|
"data-bpds": "side-sheet",
|
|
61
|
-
"data-bpds-modeless":
|
|
62
|
-
"data-bpds-has-dynamic-width":
|
|
63
|
-
"aria-modal": !
|
|
64
|
-
children: /* @__PURE__ */ h(
|
|
65
|
-
value:
|
|
62
|
+
"data-bpds-modeless": a,
|
|
63
|
+
"data-bpds-has-dynamic-width": l,
|
|
64
|
+
"aria-modal": !a,
|
|
65
|
+
children: /* @__PURE__ */ h(u.Provider, {
|
|
66
|
+
value: c,
|
|
66
67
|
children: /* @__PURE__ */ h(e.Provider, {
|
|
67
68
|
value: {
|
|
68
|
-
onClose:
|
|
69
|
-
onBack:
|
|
69
|
+
onClose: o,
|
|
70
|
+
onBack: s
|
|
70
71
|
},
|
|
71
72
|
children: /* @__PURE__ */ h("div", {
|
|
72
|
-
className:
|
|
73
|
+
className: S(),
|
|
73
74
|
children: t
|
|
74
75
|
})
|
|
75
76
|
})
|
|
76
77
|
})
|
|
77
78
|
})] })
|
|
78
79
|
});
|
|
79
|
-
}, y = ({ children: e, subline:
|
|
80
|
-
let { onBack:
|
|
80
|
+
}, y = ({ children: e, subline: r, level: i = "h3" }) => {
|
|
81
|
+
let { onBack: a, onClose: o } = t(), { header: s, titleAndIcons: c } = _();
|
|
81
82
|
return /* @__PURE__ */ g("div", {
|
|
82
|
-
className:
|
|
83
|
+
className: s(),
|
|
83
84
|
children: [/* @__PURE__ */ g("div", {
|
|
84
|
-
className:
|
|
85
|
+
className: c(),
|
|
85
86
|
children: [
|
|
86
|
-
|
|
87
|
-
onClick:
|
|
87
|
+
a && /* @__PURE__ */ h(l, {
|
|
88
|
+
onClick: a,
|
|
88
89
|
icon: "arrow-left",
|
|
89
90
|
label: "Zurück",
|
|
90
91
|
variant: "tertiary",
|
|
91
92
|
size: "small"
|
|
92
93
|
}),
|
|
93
|
-
/* @__PURE__ */ h(
|
|
94
|
+
/* @__PURE__ */ h(n.Title, {
|
|
94
95
|
asChild: !0,
|
|
95
96
|
children: /* @__PURE__ */ h("div", {
|
|
96
97
|
className: "grow",
|
|
97
|
-
children: /* @__PURE__ */ h(
|
|
98
|
-
|
|
99
|
-
component: r,
|
|
100
|
-
className: "line-clamp-2",
|
|
98
|
+
children: /* @__PURE__ */ h(i, {
|
|
99
|
+
className: "typography-bonprix-h6 my-0 line-clamp-2 text-start text-clr-on-bg-high",
|
|
101
100
|
children: e
|
|
102
101
|
})
|
|
103
102
|
})
|
|
104
103
|
}),
|
|
105
|
-
/* @__PURE__ */ h(
|
|
104
|
+
/* @__PURE__ */ h(n.Close, {
|
|
106
105
|
asChild: !0,
|
|
107
|
-
children: /* @__PURE__ */ h(
|
|
108
|
-
onClick:
|
|
106
|
+
children: /* @__PURE__ */ h(l, {
|
|
107
|
+
onClick: o,
|
|
109
108
|
icon: "closer",
|
|
110
109
|
label: "Schließen",
|
|
111
110
|
variant: "tertiary",
|
|
@@ -113,7 +112,10 @@ var _ = p({
|
|
|
113
112
|
})
|
|
114
113
|
})
|
|
115
114
|
]
|
|
116
|
-
}),
|
|
115
|
+
}), r && /* @__PURE__ */ h("p", {
|
|
116
|
+
className: "typography-body1 my-0 text-start text-clr-on-bg-high",
|
|
117
|
+
children: r
|
|
118
|
+
})]
|
|
117
119
|
});
|
|
118
120
|
}, b = ({ children: e, disableHorizontalPadding: t = !1 }) => {
|
|
119
121
|
let { scrollArea: n } = _({ disableHorizontalPadding: t });
|
|
@@ -127,15 +129,15 @@ var _ = p({
|
|
|
127
129
|
return /* @__PURE__ */ h("div", {
|
|
128
130
|
className: "button-section-container",
|
|
129
131
|
children: /* @__PURE__ */ h("div", {
|
|
130
|
-
className:
|
|
132
|
+
className: r(t(), "button-section"),
|
|
131
133
|
children: e
|
|
132
134
|
})
|
|
133
135
|
});
|
|
134
|
-
}, S = ({ children: e, icon: n, iconPosition: r, loading: i, component:
|
|
135
|
-
let { onClick:
|
|
136
|
-
|
|
136
|
+
}, S = ({ children: e, icon: n, iconPosition: r, loading: i, component: a = "button", ...o }) => {
|
|
137
|
+
let { onClick: s, ...l } = o, u = a, { onClose: d } = t(), f = (e) => {
|
|
138
|
+
s?.(e), d();
|
|
137
139
|
};
|
|
138
|
-
return /* @__PURE__ */ h(
|
|
140
|
+
return /* @__PURE__ */ h(c, {
|
|
139
141
|
component: u,
|
|
140
142
|
...l,
|
|
141
143
|
variant: "primary",
|
|
@@ -146,14 +148,14 @@ var _ = p({
|
|
|
146
148
|
loading: i,
|
|
147
149
|
children: e
|
|
148
150
|
});
|
|
149
|
-
}, C = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...
|
|
150
|
-
let
|
|
151
|
-
return /* @__PURE__ */ h(
|
|
152
|
-
component:
|
|
153
|
-
...
|
|
151
|
+
}, C = ({ children: e, icon: n, iconPosition: r, component: i = "button", ...a }) => {
|
|
152
|
+
let o = i, { onClose: s } = t();
|
|
153
|
+
return /* @__PURE__ */ h(c, {
|
|
154
|
+
component: o,
|
|
155
|
+
...a,
|
|
154
156
|
variant: "secondary",
|
|
155
157
|
type: "button",
|
|
156
|
-
onClick:
|
|
158
|
+
onClick: s,
|
|
157
159
|
icon: n,
|
|
158
160
|
iconPosition: r,
|
|
159
161
|
size: "large",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SideSheetRoot.js","names":[],"sources":["../../src/SideSheetRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport { backdrop, fadeAnimation, slideAnimation } 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, useBreakpointDown, useInnerOpen, usePrefersReducedMotion, ZIndexContext } from \"@bonprix-ds/utils\";\nimport { twMerge } from \"tailwind-merge\";\nimport React, { ComponentProps, ElementType, ReactNode } from \"react\";\nimport { tv } from \"tailwind-variants\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\n\nimport SideSheetContext from \"./SideSheetContext\";\nimport useConsumeSideSheet from \"./useConsumeSideSheet\";\n\nimport \"./SideSheet.css\";\n\nconst generateClasses = tv({\n slots: {\n modal: \"preflight fixed h-dvh flex flex-col bg-clr-bg-modal -end-100 top-0 outline-none\",\n header: \"px-4 py-6\",\n titleAndIcons: \"flex gap-2 items-center\",\n scrollArea: \"h-full scroll-area relative\",\n buttonSection: \"w-full flex flex-col gap-3 px-4 pt-6 shrink-0\",\n backdrop: backdrop(),\n contentWrapper: \"flex flex-col w-full grow typography-body1 text-clr-primary pb-6 overflow-hidden\",\n },\n variants: {\n disableHorizontalPadding: {\n false: { scrollArea: \"px-4\" },\n },\n prefersReducedMotion: {\n false: {\n modal: slideAnimation(),\n backdrop: fadeAnimation(),\n },\n true: {\n modal: \"end-0\",\n },\n },\n hasDynamicWidth: {\n false: {\n modal: \"w-100\",\n },\n true: {\n modal: \"min-w-100 w-fit max-w-150\",\n },\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 /** When set to false, interaction with outside elements will be disabled and only dialog content will be visible to screen readers. */\n modeless?: boolean;\n /** Makes the Sheet of 400px fixed or able to expand up to 600px depending on the content */\n hasDynamicWidth?: boolean;\n}\n\nconst SideSheetRoot = ({ children, isOpen, modeless = false, onClose, onBack, zIndex = 9999, hasDynamicWidth = false }: Props) => {\n const prefersReducedMotion = usePrefersReducedMotion();\n const isMobile = useBreakpointDown(\"m\");\n const { modal: modalClass, backdrop, contentWrapper } = generateClasses({ hasDynamicWidth, prefersReducedMotion });\n\n const { innerOpen } = useInnerOpen(isOpen);\n\n if (isMobile) return;\n\n const shiftFocusProgrammatically = (event: Event) => {\n event.preventDefault();\n const target = event.target as HTMLElement;\n target.focus();\n };\n\n return (\n <DialogPrimitive.Root open={innerOpen} modal={!modeless}>\n <DialogPrimitive.Portal>\n <DialogPrimitive.Overlay className={backdrop()} onClick={onClose} style={{ zIndex }} />\n <DialogPrimitive.Content\n className={modalClass()}\n style={{ zIndex }}\n aria-describedby={undefined}\n onOpenAutoFocus={shiftFocusProgrammatically}\n tabIndex={-1}\n data-bpds=\"side-sheet\"\n data-bpds-modeless={modeless}\n data-bpds-has-dynamic-width={hasDynamicWidth}\n aria-modal={!modeless}\n >\n <ZIndexContext.Provider value={zIndex}>\n <SideSheetContext.Provider value={{ onClose, onBack }}>\n <div className={contentWrapper()}>{children}</div>\n </SideSheetContext.Provider>\n </ZIndexContext.Provider>\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n </DialogPrimitive.Root>\n );\n};\n\nexport const Title = ({ children, subline, level = \"h3\" }: SheetTitleProps) => {\n const { onBack, onClose } = useConsumeSideSheet();\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 <DialogPrimitive.Close asChild>\n <IconButton onClick={onClose} icon=\"closer\" label=\"Schließen\" variant=\"tertiary\" size=\"small\" />\n </DialogPrimitive.Close>\n </div>\n {subline && <Typography>{subline}</Typography>}\n </div>\n );\n};\n\nexport const Content = ({ children, disableHorizontalPadding = false }: SheetContentProps) => {\n const { scrollArea } = generateClasses({ disableHorizontalPadding });\n return (\n <div className={scrollArea()} data-bpds-disable-horizontal-padding={disableHorizontalPadding}>\n {children}\n </div>\n );\n};\n\nexport const ButtonSection = ({ children }: SheetButtonSectionProps) => {\n const { buttonSection } = generateClasses();\n return (\n <div className=\"button-section-container\">\n <div className={twMerge(buttonSection(), \"button-section\")}>{children}</div>\n </div>\n );\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 { onClick, ...otherProps } = props;\n const Component: ElementType = component;\n const { onClose } = useConsumeSideSheet();\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\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 } = useConsumeSideSheet();\n return (\n <Button\n component={Component}\n {...props}\n variant=\"secondary\"\n type=\"button\"\n onClick={onClose}\n icon={icon}\n iconPosition={iconPosition}\n size=\"large\"\n >\n {children}\n </Button>\n );\n};\n\nSideSheetRoot.displayName = \"SideSheet\";\n\nexport default SideSheetRoot;\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAM,IAAkB,EAAG;CACzB,OAAO;EACL,OAAO;EACP,QAAQ;EACR,eAAe;EACf,YAAY;EACZ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,EAAE,eAAY,EAAoB,GAClC,KAAe,MAA+C;EAGlE,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,EAAoB;CACxC,OACE,kBAAC,GAAD;EACE,WAAW;EACX,GAAI;EACJ,SAAQ;EACR,MAAK;EACL,SAAS;EACH;EACQ;EACd,MAAK;EAEJ;CACK,CAAA;AAEZ;AAEA,EAAc,cAAc"}
|
|
1
|
+
{"version":3,"file":"SideSheetRoot.js","names":["SideSheetContext","useConsumeSideSheet","DialogPrimitive","Button","IconButton","generateClasses","tv","backdrop","slideAnimation","fadeAnimation","SideSheetRoot","isOpen","warnDeprecated","prefersReducedMotion","usePrefersReducedMotion","isMobile","useBreakpointDown","modalClass","useInnerOpen","open","innerOpen","modeless","onClose","event","hasDynamicWidth","ZIndexContext","zIndex","contentWrapper","Title","Level","header","titleAndIcons","onBack","subline","Content","scrollArea","disableHorizontalPadding","ButtonSection","twMerge","buttonSection","PrimaryButton","props","otherProps","Component","component","handleClick","onClick","SecondaryButton"],"sources":["../../src/SideSheetRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\nimport React, { ComponentProps, ElementType, ReactNode } from \"react\";\nimport { twMerge } from \"tailwind-merge\";\nimport { tv } from \"tailwind-variants\";\n\nimport { backdrop, fadeAnimation, slideAnimation } 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 { TitleLevel, useBreakpointDown, useInnerOpen, usePrefersReducedMotion, ZIndexContext } from \"@bonprix-ds/utils\";\nimport { warnDeprecated } from \"@bonprix-ds/utils/deprecation\";\n\nimport SideSheetContext from \"./SideSheetContext\";\nimport useConsumeSideSheet from \"./useConsumeSideSheet\";\n\nimport \"./SideSheet.css\";\n\nconst generateClasses = tv({\n slots: {\n modal: \"preflight fixed -end-100 top-0 flex h-dvh flex-col bg-clr-bg-modal outline-none\",\n header: \"px-4 py-6\",\n titleAndIcons: \"flex items-center gap-2\",\n scrollArea: \"scroll-area relative h-full\",\n buttonSection: \"flex w-full shrink-0 flex-col gap-3 px-4 pt-6\",\n backdrop: backdrop(),\n contentWrapper: \"typography-body1 flex w-full grow flex-col overflow-hidden pb-6 text-clr-primary\",\n },\n variants: {\n disableHorizontalPadding: {\n false: { scrollArea: \"px-4\" },\n },\n prefersReducedMotion: {\n false: {\n modal: slideAnimation(),\n backdrop: fadeAnimation(),\n },\n true: {\n modal: \"end-0\",\n },\n },\n hasDynamicWidth: {\n false: {\n modal: \"w-100\",\n },\n true: {\n modal: \"w-fit min-w-100 max-w-150\",\n },\n },\n },\n});\n\ninterface SheetProps {\n /** All of the subcomponents should be placed inside this property. */\n children: ReactNode;\n /** Callback function, that is triggered when the sheet is attempted to be closed.\n *\n * It will be called in following cases:\n * - Click on backdrop\n * - Swipe down to close\n * - Click on \"close\" icon button in the upper-right corner\n * - Click on any button (PrimaryButton or SecondaryButton)\n *\n * Should be used in conjunction with `open`. */\n onClose: () => void;\n /** Callback to execute when clicking back icon. */\n onBack?: () => void;\n /** The z-index of the sheet.. */\n zIndex?: number;\n}\n\ntype OpenProps = SheetProps & {\n /** Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property. */\n open: boolean;\n /** @deprecated [is-open-prop] Use `open` instead. */\n isOpen?: never;\n};\n\ntype DeprecatedOpenProps = SheetProps & {\n open?: never;\n /**\n * Toggles the visibility of the sheet. Should be used in conjunction with the `onClose` property.\n * @deprecated [is-open-prop] Use `open` instead.\n */\n isOpen: boolean;\n};\n\nexport interface SheetTitleProps {\n /** The text content. */\n children: string;\n /** An optional subline that is displayed right below the title. */\n subline?: string;\n /** The heading level for the title. */\n level?: TitleLevel;\n}\n\nexport interface SheetButtonSectionProps {\n /** Primary and secondary buttons should be placed inside this section. */\n children: ReactNode;\n}\n\nexport interface SheetContentProps {\n /** The content of the content section. */\n children: ReactNode;\n /** If `true`, the horizontal padding around the content will be removed. */\n disableHorizontalPadding?: boolean;\n}\n\nexport interface SheetButtonBaseProps {\n /** The label of the button. */\n children: string;\n /** If used, an icon will be additionally shown. The value is 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 type Props = (DeprecatedOpenProps | OpenProps) & {\n /** When set to false, interaction with outside elements will be disabled and only dialog content will be visible to screen readers. */\n modeless?: boolean;\n /** Makes the Sheet of 400px fixed or able to expand up to 600px depending on the content */\n hasDynamicWidth?: boolean;\n};\n\nconst SideSheetRoot = ({ children, open, isOpen, modeless = false, onClose, onBack, zIndex = 9999, hasDynamicWidth = false }: Props) => {\n if (isOpen !== undefined) warnDeprecated(\"is-open-prop\");\n const prefersReducedMotion = usePrefersReducedMotion();\n const isMobile = useBreakpointDown(\"m\");\n const { modal: modalClass, backdrop, contentWrapper } = generateClasses({ hasDynamicWidth, prefersReducedMotion });\n\n const { innerOpen } = useInnerOpen(open ?? isOpen ?? false);\n\n if (isMobile) return;\n\n const shiftFocusProgrammatically = (event: Event) => {\n event.preventDefault();\n const target = event.target as HTMLElement;\n target.focus();\n };\n\n return (\n <DialogPrimitive.Root open={innerOpen} modal={!modeless}>\n <DialogPrimitive.Portal>\n <DialogPrimitive.Overlay className={backdrop()} onClick={onClose} style={{ zIndex }} />\n <DialogPrimitive.Content\n className={modalClass()}\n style={{ zIndex }}\n aria-describedby={undefined}\n onOpenAutoFocus={shiftFocusProgrammatically}\n tabIndex={-1}\n data-bpds=\"side-sheet\"\n data-bpds-modeless={modeless}\n data-bpds-has-dynamic-width={hasDynamicWidth}\n aria-modal={!modeless}\n >\n <ZIndexContext.Provider value={zIndex}>\n <SideSheetContext.Provider value={{ onClose, onBack }}>\n <div className={contentWrapper()}>{children}</div>\n </SideSheetContext.Provider>\n </ZIndexContext.Provider>\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n </DialogPrimitive.Root>\n );\n};\n\nexport const Title = ({ children, subline, level: Level = \"h3\" }: SheetTitleProps) => {\n const { onBack, onClose } = useConsumeSideSheet();\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 <Level className=\"typography-bonprix-h6 my-0 line-clamp-2 text-start text-clr-on-bg-high\">{children}</Level>\n </div>\n </DialogPrimitive.Title>\n <DialogPrimitive.Close asChild>\n <IconButton onClick={onClose} icon=\"closer\" label=\"Schließen\" variant=\"tertiary\" size=\"small\" />\n </DialogPrimitive.Close>\n </div>\n {subline && <p className=\"typography-body1 my-0 text-start text-clr-on-bg-high\">{subline}</p>}\n </div>\n );\n};\n\nexport const Content = ({ children, disableHorizontalPadding = false }: SheetContentProps) => {\n const { scrollArea } = generateClasses({ disableHorizontalPadding });\n return (\n <div className={scrollArea()} data-bpds-disable-horizontal-padding={disableHorizontalPadding}>\n {children}\n </div>\n );\n};\n\nexport const ButtonSection = ({ children }: SheetButtonSectionProps) => {\n const { buttonSection } = generateClasses();\n return (\n <div className=\"button-section-container\">\n <div className={twMerge(buttonSection(), \"button-section\")}>{children}</div>\n </div>\n );\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 { onClick, ...otherProps } = props;\n const Component: ElementType = component;\n const { onClose } = useConsumeSideSheet();\n const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\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 } = useConsumeSideSheet();\n return (\n <Button\n component={Component}\n {...props}\n variant=\"secondary\"\n type=\"button\"\n onClick={onClose}\n icon={icon}\n iconPosition={iconPosition}\n size=\"large\"\n >\n {children}\n </Button>\n );\n};\n\nSideSheetRoot.displayName = \"SideSheet\";\n\nexport default SideSheetRoot;\n"],"mappings":";;;;;;;;;;;;;;;AAmBA,IAAMK,IAAkBC,EAAG;CACzB,OAAO;EACL,OAAO;EACP,QAAQ;EACR,eAAe;EACf,YAAY;EACZ,eAAe;EACf,UAAUC,EAAS;EACnB,gBAAgB;CAClB;CACA,UAAU;EACR,0BAA0B,EACxB,OAAO,EAAE,YAAY,OAAO,EAC9B;EACA,sBAAsB;GACpB,OAAO;IACL,OAAOC,EAAe;IACtB,UAAUC,EAAc;GAC1B;GACA,MAAM,EACJ,OAAO,QACT;EACF;EACA,iBAAiB;GACf,OAAO,EACL,OAAO,QACT;GACA,MAAM,EACJ,OAAO,4BACT;EACF;CACF;AACF,CAAC,GAoFKC,KAAiB,EAAE,aAAU,SAAM,WAAQ,cAAW,IAAO,YAAS,WAAQ,YAAS,MAAM,qBAAkB,SAAmB;CACtI,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AGN,QACsB;CACzB,IAAME,IAAyBC,GACzB,EAAE,eAAY3C,EAAoB;CACxC,OACE,kBAACE,GAAD;EACE,WAAWwC;EACX,GAAIF;EACJ,SAAQ;EACR,MAAK;EACL,SAASnB;EACH;EACQ;EACd,MAAK;EAEJ;CACK,CAAA;AAEZ;AAEA,EAAc,cAAc"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConsumeSideSheet.js","names":[],"sources":["../../src/useConsumeSideSheet.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport SideSheetContext from \"./SideSheetContext\";\n\nconst useConsumeSideSheet = () => {\n return useContext(SideSheetContext);\n};\n\nexport default useConsumeSideSheet;\n"],"mappings":";;;AAIA,
|
|
1
|
+
{"version":3,"file":"useConsumeSideSheet.js","names":["SideSheetContext","useConsumeSideSheet","useContext"],"sources":["../../src/useConsumeSideSheet.ts"],"sourcesContent":["import { useContext } from \"react\";\n\nimport SideSheetContext from \"./SideSheetContext\";\n\nconst useConsumeSideSheet = () => {\n return useContext(SideSheetContext);\n};\n\nexport default useConsumeSideSheet;\n"],"mappings":";;;AAIA,IAAMC,UACGC,EAAWF,CAAgB"}
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "./src/SideSheet.css";
|
package/package.json
CHANGED
|
@@ -1,16 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bonprix-ds/react-side-sheet",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "SideSheet component, implemented in React, for the Bonprix Design System.",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
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/side-sheet"
|
|
9
12
|
},
|
|
10
|
-
"
|
|
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": [
|
|
12
|
-
"**/*.css"
|
|
21
|
+
"**/*.css",
|
|
22
|
+
"./dist/styles.js"
|
|
13
23
|
],
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"imports": {
|
|
27
|
+
"#styles": {
|
|
28
|
+
"browser": "./dist/styles.js",
|
|
29
|
+
"default": "./dist/no-styles.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
14
32
|
"exports": {
|
|
15
33
|
".": {
|
|
16
34
|
"import": "./dist/index.js",
|
|
@@ -18,42 +36,32 @@
|
|
|
18
36
|
"default": "./dist/index.js"
|
|
19
37
|
}
|
|
20
38
|
},
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
],
|
|
25
|
-
"keywords": [],
|
|
26
|
-
"author": "",
|
|
27
|
-
"license": "UNLICENSED",
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "git+https://github.com/bonprix/design-system.git",
|
|
31
|
-
"directory": "packages/react/side-sheet"
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public",
|
|
41
|
+
"provenance": true
|
|
32
42
|
},
|
|
33
43
|
"dependencies": {
|
|
34
44
|
"@radix-ui/react-dialog": "1.1.23",
|
|
35
45
|
"tailwind-merge": "2.6.1",
|
|
36
|
-
"@bonprix-ds/internal-components": "0.2.
|
|
37
|
-
"@bonprix-ds/react-
|
|
38
|
-
"@bonprix-ds/react-
|
|
39
|
-
"@bonprix-ds/react-icon-button": "1.2.
|
|
40
|
-
"@bonprix-ds/
|
|
41
|
-
"@bonprix-ds/utils": "0.2.2"
|
|
42
|
-
},
|
|
43
|
-
"peerDependencies": {
|
|
44
|
-
"react": "^19.0.0",
|
|
45
|
-
"react-dom": "^19.0.0",
|
|
46
|
-
"tailwind-variants": "0.3.1"
|
|
46
|
+
"@bonprix-ds/internal-components": "0.2.2",
|
|
47
|
+
"@bonprix-ds/react-icon": "1.2.2",
|
|
48
|
+
"@bonprix-ds/react-button": "1.1.2",
|
|
49
|
+
"@bonprix-ds/react-icon-button": "1.2.2",
|
|
50
|
+
"@bonprix-ds/utils": "0.3.0"
|
|
47
51
|
},
|
|
48
52
|
"devDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"@microsoft/api-extractor": "7.59.1",
|
|
53
|
+
"@testing-library/dom": "10.4.2",
|
|
54
|
+
"@testing-library/react": "16.3.3",
|
|
55
|
+
"@types/react": "19.3.0",
|
|
56
|
+
"vite": "8.3.2",
|
|
57
|
+
"vitest": "4.1.11",
|
|
55
58
|
"@bonprix-ds/vite-config": "0.0.0"
|
|
56
59
|
},
|
|
60
|
+
"peerDependencies": {
|
|
61
|
+
"react": "^19",
|
|
62
|
+
"react-dom": "^19",
|
|
63
|
+
"tailwind-variants": "0.3.1"
|
|
64
|
+
},
|
|
57
65
|
"scripts": {
|
|
58
66
|
"build": "vite build"
|
|
59
67
|
}
|