@bonprix-ds/react-dialog 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 CHANGED
@@ -1,62 +1,3 @@
1
- import { default as default_2 } from 'react';
2
- import { ReactNode } from 'react';
3
-
4
- declare const Dialog: {
5
- (props: DialogProps): default_2.JSX.Element;
6
- displayName: string;
7
- Title: {
8
- ({ children }: DialogTitleProps): default_2.JSX.Element;
9
- displayName: string;
10
- };
11
- Content: {
12
- ({ children }: DialogContentProps): default_2.JSX.Element;
13
- displayName: string;
14
- };
15
- ButtonSection: {
16
- ({ children }: DialogButtonSectionProps): default_2.JSX.Element;
17
- displayName: string;
18
- };
19
- PrimaryButton: {
20
- <C extends default_2.ElementType>({ children, component, ...props }: {
21
- children: string;
22
- component?: C | undefined;
23
- } & Omit<default_2.ComponentProps<C>, "component">): default_2.JSX.Element;
24
- displayName: string;
25
- };
26
- SecondaryButton: {
27
- <C extends default_2.ElementType>({ children, component, ...props }: {
28
- children: string;
29
- component?: C | undefined;
30
- } & Omit<default_2.ComponentProps<C>, "component">): default_2.JSX.Element;
31
- displayName: string;
32
- };
33
- };
34
- export default Dialog;
35
-
36
- export declare interface DialogButtonSectionProps {
37
- /** Primary and secondary buttons should be placed inside this section. */
38
- children: ReactNode;
39
- }
40
-
41
- export declare interface DialogContentProps {
42
- /** The content to display in the dialog. */
43
- children: ReactNode;
44
- }
45
-
46
- export declare interface DialogProps {
47
- /** Controls the visibility of the dialog. Should be used in conjunction with `onClose`. */
48
- isOpen: boolean;
49
- /** Here, all of the subcomponents should be placed. */
50
- children: ReactNode;
51
- /** Callback function that is called when the dialog is supposed to be closed. Should be used in conjunction with `isOpen` property. */
52
- onClose: () => void;
53
- /** The z-index of the dialog. */
54
- zIndex?: number;
55
- }
56
-
57
- export declare interface DialogTitleProps {
58
- /** The title to display in the dialog. */
59
- children: string;
60
- }
61
-
62
- export { }
1
+ export { default } from "./src/Dialog";
2
+ export type { Props as DialogProps } from "./src/Dialog";
3
+ export type { DialogButtonSectionProps, DialogContentProps, DialogTitleProps } from "./src/DialogRoot";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ /* Radix prepends focus guards to `body` while a dialog is open. Chromium saves the scroll anchor of a page that is
2
+ left as an `nth-child` path, which the guards shift, so going back would restore the scroll position of another
3
+ element. Without an anchor, Chromium restores the plain scroll offset. Keyed to the guards rather than to the
4
+ open state, so it holds through the closing animation and across every copy of the package on the page. */
5
+ :root:has(> body > [data-radix-focus-guard]) {
6
+ overflow-anchor: none;
7
+ }
@@ -0,0 +1,34 @@
1
+ import React from "react";
2
+ import { type Props } from "./DialogRoot";
3
+ export type { Props } from "./DialogRoot";
4
+ declare const Dialog: {
5
+ (props: Props): React.JSX.Element;
6
+ displayName: string;
7
+ Title: {
8
+ ({ children }: import("./DialogRoot").DialogTitleProps): React.JSX.Element;
9
+ displayName: string;
10
+ };
11
+ Content: {
12
+ ({ children }: import("./DialogRoot").DialogContentProps): React.JSX.Element;
13
+ displayName: string;
14
+ };
15
+ ButtonSection: {
16
+ ({ children }: import("./DialogRoot").DialogButtonSectionProps): React.JSX.Element;
17
+ displayName: string;
18
+ };
19
+ PrimaryButton: {
20
+ <C extends React.ElementType>({ children, component, ...props }: {
21
+ children: string;
22
+ component?: C | undefined;
23
+ } & Omit<React.ComponentProps<C>, "component">): React.JSX.Element;
24
+ displayName: string;
25
+ };
26
+ SecondaryButton: {
27
+ <C extends React.ElementType>({ children, component, ...props }: {
28
+ children: string;
29
+ component?: C | undefined;
30
+ } & Omit<React.ComponentProps<C>, "component">): React.JSX.Element;
31
+ displayName: string;
32
+ };
33
+ };
34
+ export default Dialog;
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.js","names":[],"sources":["../../src/Dialog.tsx"],"sourcesContent":["import React from \"react\";\n\nimport DialogRoot, { ButtonSection, Content, PrimaryButton, SecondaryButton, Title, type Props } from \"./DialogRoot\";\n\nexport type { Props } from \"./DialogRoot\";\n\nconst Dialog = (props: Props) => <DialogRoot {...props} />;\n\nDialog.displayName = \"Dialog\";\n\nDialog.Title = Title;\nDialog.Content = Content;\nDialog.ButtonSection = ButtonSection;\nDialog.PrimaryButton = PrimaryButton;\nDialog.SecondaryButton = SecondaryButton;\n\nexport default Dialog;\n"],"mappings":";;;;AAMA,IAAM,KAAU,MAAiB,kBAAC,GAAD,EAAY,GAAI,EAAQ,CAAA;AAEzD,EAAO,cAAc,UAErB,EAAO,QAAQ,GACf,EAAO,UAAU,GACjB,EAAO,gBAAgB,GACvB,EAAO,gBAAgB,GACvB,EAAO,kBAAkB"}
1
+ {"version":3,"file":"Dialog.js","names":["DialogRoot","Dialog","props","Title","Content","ButtonSection","PrimaryButton","SecondaryButton"],"sources":["../../src/Dialog.tsx"],"sourcesContent":["import React from \"react\";\n\nimport DialogRoot, { ButtonSection, Content, PrimaryButton, SecondaryButton, Title, type Props } from \"./DialogRoot\";\n\nexport type { Props } from \"./DialogRoot\";\n\nconst Dialog = (props: Props) => <DialogRoot {...props} />;\n\nDialog.displayName = \"Dialog\";\n\nDialog.Title = Title;\nDialog.Content = Content;\nDialog.ButtonSection = ButtonSection;\nDialog.PrimaryButton = PrimaryButton;\nDialog.SecondaryButton = SecondaryButton;\n\nexport default Dialog;\n"],"mappings":";;;;AAMA,IAAMC,KAAU,MAAiB,kBAACD,GAAD,EAAY,GAAIE,EAAQ,CAAA;AAEzD,EAAO,cAAc,UAErB,EAAO,QAAQC,GACf,EAAO,UAAUC,GACjB,EAAO,gBAAgBC,GACvB,EAAO,gBAAgBC,GACvB,EAAO,kBAAkBC"}
@@ -0,0 +1,72 @@
1
+ import React, { ComponentProps, ElementType, ReactNode } from "react";
2
+ import "./Dialog.css";
3
+ interface BaseProps {
4
+ /** Here, all of the subcomponents should be placed. */
5
+ children: ReactNode;
6
+ /** Callback function that is called when the dialog is supposed to be closed. Should be used in conjunction with `open` property. */
7
+ onClose: () => void;
8
+ /** The z-index of the dialog. */
9
+ zIndex?: number;
10
+ /** Optional image slot that gets rendered left to (desktop) or above (mobile) the `children`. */
11
+ image?: ReactNode;
12
+ /** Additional CSS classes for the wrapper element around `image`, not the image itself. Useful to specify height and tweak layout. */
13
+ imageWrapperClassName?: string;
14
+ }
15
+ type OpenProps = BaseProps & {
16
+ /** Controls the visibility of the dialog. Should be used in conjunction with `onClose`. */
17
+ open: boolean;
18
+ /** @deprecated [is-open-prop] Use `open` instead. */
19
+ isOpen?: never;
20
+ };
21
+ type DeprecatedOpenProps = BaseProps & {
22
+ open?: never;
23
+ /**
24
+ * Controls the visibility of the dialog. Should be used in conjunction with `onClose`.
25
+ * @deprecated [is-open-prop] Use `open` instead.
26
+ */
27
+ isOpen: boolean;
28
+ };
29
+ export type Props = DeprecatedOpenProps | OpenProps;
30
+ export interface DialogTitleProps {
31
+ /** The title to display in the dialog. */
32
+ children: string;
33
+ }
34
+ export interface DialogContentProps {
35
+ /** The content to display in the dialog. */
36
+ children: ReactNode;
37
+ }
38
+ export interface DialogButtonSectionProps {
39
+ /** Primary and secondary buttons should be placed inside this section. */
40
+ children: ReactNode;
41
+ }
42
+ type DialogButtonProps<C extends ElementType> = {
43
+ /** The button text to render. */
44
+ children: string;
45
+ /** The semantic component to render the Button. Preferrably `"button"`. Native props will be passed to this component. */
46
+ component?: C;
47
+ } & Omit<ComponentProps<C>, "component">;
48
+ declare const DialogRoot: {
49
+ ({ open, isOpen, onClose, zIndex, children, image, imageWrapperClassName }: Props): React.JSX.Element;
50
+ displayName: string;
51
+ };
52
+ export declare const Title: {
53
+ ({ children }: DialogTitleProps): React.JSX.Element;
54
+ displayName: string;
55
+ };
56
+ export declare const Content: {
57
+ ({ children }: DialogContentProps): React.JSX.Element;
58
+ displayName: string;
59
+ };
60
+ export declare const ButtonSection: {
61
+ ({ children }: DialogButtonSectionProps): React.JSX.Element;
62
+ displayName: string;
63
+ };
64
+ export declare const PrimaryButton: {
65
+ <C extends ElementType>({ children, component, ...props }: DialogButtonProps<C>): React.JSX.Element;
66
+ displayName: string;
67
+ };
68
+ export declare const SecondaryButton: {
69
+ <C extends ElementType>({ children, component, ...props }: DialogButtonProps<C>): React.JSX.Element;
70
+ displayName: string;
71
+ };
72
+ export default DialogRoot;
@@ -1,68 +1,122 @@
1
1
  "use client";
2
2
  import "react";
3
- import e from "@bonprix-ds/react-button";
4
- import t from "@bonprix-ds/react-overlay";
5
- import { useInnerOpen as n } from "@bonprix-ds/utils";
6
- import { tv as r } from "tailwind-variants";
7
- import * as i from "@radix-ui/react-dialog";
8
- import { jsx as a } from "react/jsx-runtime";
3
+ import * as e from "@radix-ui/react-dialog";
4
+ import { twMerge as t } from "tailwind-merge";
5
+ import { tv as n } from "tailwind-variants";
6
+ import { backdrop as r, fadeAnimation as i } from "@bonprix-ds/internal-components";
7
+ import a from "@bonprix-ds/react-button";
8
+ import o from "@bonprix-ds/react-icon-button";
9
+ import { ZIndexContext as s, useInnerOpen as c, usePrefersReducedMotion as l } from "@bonprix-ds/utils";
10
+ import { warnDeprecated as u } from "@bonprix-ds/utils/deprecation";
11
+ import "#styles";
12
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
9
13
  //#region src/DialogRoot.tsx
10
- var o = r({ slots: {
11
- title: "typography-bonprix-h4 text-clr-primary px-10",
12
- wrapper: "flex flex-col gap-5 h-full",
13
- scrollArea: "px-10 h-full scroll-area relative",
14
- contentWrapper: "flex flex-col overflow-hidden",
15
- buttonSection: "px-10 flex justify-center flex-wrap gap-3"
16
- } }), s = ({ isOpen: e, onClose: r, zIndex: i, children: s }) => {
17
- let { wrapper: c } = o(), { innerOpen: l } = n(e);
18
- return /* @__PURE__ */ a(t, {
19
- isOpen: l,
20
- onClose: r,
21
- zIndex: i,
22
- isDialog: !0,
23
- componentName: "dialog",
24
- children: /* @__PURE__ */ a("div", {
25
- className: c(),
26
- children: s
27
- })
14
+ var p = n({
15
+ slots: {
16
+ modal: [
17
+ "preflight fixed start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2",
18
+ "h-fit min-h-[12.375rem] w-[37.5rem] max-w-[calc(100vw-2.5rem)] l:w-[67.5rem]",
19
+ "max-h-[calc(100dvh-var(--app-safe-area-inset-bottom,2.5rem)*2)]",
20
+ "box-border grid grid-rows-1 justify-items-center"
21
+ ],
22
+ imageBox: "flex h-full w-full",
23
+ contentBox: "relative box-border flex w-full max-w-[37.5rem] flex-col bg-clr-bg-modal py-7",
24
+ title: "typography-bonprix-h4 px-7 text-clr-primary",
25
+ closeButtonWrapper: "absolute end-1 top-1",
26
+ wrapper: "flex h-full flex-col gap-5",
27
+ scrollArea: "scroll-area relative h-full px-7",
28
+ contentWrapper: "flex flex-col overflow-hidden",
29
+ buttonSection: "flex flex-col gap-3 px-7"
30
+ },
31
+ variants: {
32
+ image: { true: { modal: "grid-cols-1 grid-rows-2 l:grid-cols-2 l:grid-rows-1" } },
33
+ prefersReducedMotion: { false: { modal: [i()] } }
34
+ }
35
+ }), m = ({ open: n, isOpen: i, onClose: a, zIndex: m = 2, children: h, image: g, imageWrapperClassName: _ = "" }) => {
36
+ i !== void 0 && u("is-open-prop");
37
+ let { wrapper: v } = p(), { innerOpen: y } = c(n ?? i ?? !1), { modal: b, imageBox: x, contentBox: S, closeButtonWrapper: C } = p({
38
+ prefersReducedMotion: l(),
39
+ image: !!g
28
40
  });
29
- }, c = ({ children: e }) => {
30
- let { title: t } = o();
31
- return /* @__PURE__ */ a(i.Title, {
32
- className: t(),
33
- children: e
41
+ return /* @__PURE__ */ d(e.Root, {
42
+ open: y,
43
+ children: /* @__PURE__ */ f(e.Portal, { children: [/* @__PURE__ */ d(e.Overlay, {
44
+ className: r(),
45
+ onClick: a,
46
+ style: { zIndex: m - 1 }
47
+ }), /* @__PURE__ */ d(e.Content, {
48
+ className: b(),
49
+ style: { zIndex: m },
50
+ "data-bpds": "dialog",
51
+ "aria-modal": "true",
52
+ children: /* @__PURE__ */ f(s.Provider, {
53
+ value: m,
54
+ children: [g && /* @__PURE__ */ d("div", {
55
+ className: t(x(), _),
56
+ style: { zIndex: m },
57
+ children: g
58
+ }), /* @__PURE__ */ f("div", {
59
+ className: S(),
60
+ style: { zIndex: m },
61
+ children: [
62
+ /* @__PURE__ */ d(e.Close, {
63
+ asChild: !0,
64
+ children: /* @__PURE__ */ d("div", {
65
+ className: C(),
66
+ children: /* @__PURE__ */ d(o, {
67
+ variant: "tertiary",
68
+ icon: "closer",
69
+ size: "small",
70
+ label: "Schließen",
71
+ onClick: a
72
+ })
73
+ })
74
+ }),
75
+ /* @__PURE__ */ d(e.Description, { className: "sr-only" }),
76
+ /* @__PURE__ */ d("div", {
77
+ className: v(),
78
+ children: h
79
+ })
80
+ ]
81
+ })]
82
+ })
83
+ })] })
84
+ });
85
+ }, h = ({ children: t }) => {
86
+ let { title: n } = p();
87
+ return /* @__PURE__ */ d(e.Title, {
88
+ className: n(),
89
+ children: t
34
90
  });
35
- }, l = ({ children: e }) => {
36
- let { scrollArea: t, contentWrapper: n } = o();
37
- return /* @__PURE__ */ a("div", {
91
+ }, g = ({ children: e }) => {
92
+ let { scrollArea: t, contentWrapper: n } = p();
93
+ return /* @__PURE__ */ d("div", {
38
94
  className: t(),
39
- children: /* @__PURE__ */ a("div", {
95
+ children: /* @__PURE__ */ d("div", {
40
96
  className: n(),
41
97
  children: e
42
98
  })
43
99
  });
44
- }, u = ({ children: e }) => {
45
- let { buttonSection: t } = o();
46
- return /* @__PURE__ */ a("div", {
100
+ }, _ = ({ children: e }) => {
101
+ let { buttonSection: t } = p();
102
+ return /* @__PURE__ */ d("div", {
47
103
  className: t(),
48
104
  children: e
49
105
  });
50
- }, d = ({ children: t, component: n = "button", ...r }) => /* @__PURE__ */ a(e, {
51
- component: n,
52
- ...r,
53
- contentWidth: !0,
106
+ }, v = ({ children: e, component: t = "button", ...n }) => /* @__PURE__ */ d(a, {
107
+ component: t,
108
+ ...n,
54
109
  size: "large",
55
- children: t
56
- }), f = ({ children: t, component: n = "button", ...r }) => /* @__PURE__ */ a(e, {
57
- component: n,
58
- ...r,
59
- contentWidth: !0,
110
+ children: e
111
+ }), y = ({ children: e, component: t = "button", ...n }) => /* @__PURE__ */ d(a, {
112
+ component: t,
113
+ ...n,
60
114
  variant: "secondary",
61
115
  size: "large",
62
- children: t
116
+ children: e
63
117
  });
64
- s.displayName = "Dialog", c.displayName = "Dialog.Title", l.displayName = "Dialog.Content", u.displayName = "Dialog.ButtonSection", d.displayName = "Dialog.PrimaryButton", f.displayName = "Dialog.SecondaryButton";
118
+ m.displayName = "Dialog", h.displayName = "Dialog.Title", g.displayName = "Dialog.Content", _.displayName = "Dialog.ButtonSection", v.displayName = "Dialog.PrimaryButton", y.displayName = "Dialog.SecondaryButton";
65
119
  //#endregion
66
- export { u as ButtonSection, l as Content, d as PrimaryButton, f as SecondaryButton, c as Title, s as default };
120
+ export { _ as ButtonSection, g as Content, v as PrimaryButton, y as SecondaryButton, h as Title, m as default };
67
121
 
68
122
  //# sourceMappingURL=DialogRoot.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"DialogRoot.js","names":[],"sources":["../../src/DialogRoot.tsx"],"sourcesContent":["\"use client\";\n\nimport Button from \"@bonprix-ds/react-button\";\nimport Overlay from \"@bonprix-ds/react-overlay\";\nimport { useInnerOpen } from \"@bonprix-ds/utils\";\nimport React, { ComponentProps, ElementType, ReactNode } from \"react\";\nimport { tv } from \"tailwind-variants\";\nimport * as DialogPrimitive from \"@radix-ui/react-dialog\";\n\nconst generateClasses = tv({\n slots: {\n title: \"typography-bonprix-h4 text-clr-primary px-10\",\n wrapper: \"flex flex-col gap-5 h-full\",\n scrollArea: \"px-10 h-full scroll-area relative\",\n contentWrapper: \"flex flex-col overflow-hidden\",\n buttonSection: \"px-10 flex justify-center flex-wrap gap-3\",\n },\n});\n\nexport interface Props {\n /** Controls the visibility of the dialog. Should be used in conjunction with `onClose`. */\n isOpen: boolean;\n /** Here, all of the subcomponents should be placed. */\n children: ReactNode;\n /** Callback function that is called when the dialog is supposed to be closed. Should be used in conjunction with `isOpen` property. */\n onClose: () => void;\n /** The z-index of the dialog. */\n zIndex?: number;\n}\n\nexport interface DialogTitleProps {\n /** The title to display in the dialog. */\n children: string;\n}\n\nexport interface DialogContentProps {\n /** The content to display in the dialog. */\n children: ReactNode;\n}\n\nexport interface DialogButtonSectionProps {\n /** Primary and secondary buttons should be placed inside this section. */\n children: ReactNode;\n}\n\ntype DialogButtonProps<C extends ElementType> = {\n /** The button text to render. */\n children: string;\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>, \"component\">;\n\nconst DialogRoot = ({ isOpen, onClose, zIndex, children }: Props) => {\n const { wrapper } = generateClasses();\n const { innerOpen } = useInnerOpen(isOpen);\n\n return (\n <Overlay isOpen={innerOpen} onClose={onClose} zIndex={zIndex} isDialog componentName=\"dialog\">\n <div className={wrapper()}>{children}</div>\n </Overlay>\n );\n};\n\nexport const Title = ({ children }: DialogTitleProps) => {\n const { title } = generateClasses();\n\n return <DialogPrimitive.Title className={title()}>{children}</DialogPrimitive.Title>;\n};\n\nexport const Content = ({ children }: DialogContentProps) => {\n const { scrollArea, contentWrapper } = generateClasses();\n\n return (\n <div className={scrollArea()}>\n <div className={contentWrapper()}>{children}</div>\n </div>\n );\n};\n\nexport const ButtonSection = ({ children }: DialogButtonSectionProps) => {\n const { buttonSection } = generateClasses();\n\n return <div className={buttonSection()}>{children}</div>;\n};\n\nexport const PrimaryButton = <C extends ElementType>({ children, component = \"button\" as C, ...props }: DialogButtonProps<C>) => {\n const Component: ElementType = component;\n return (\n <Button component={Component} {...props} contentWidth size=\"large\">\n {children}\n </Button>\n );\n};\n\nexport const SecondaryButton = <C extends ElementType>({ children, component = \"button\" as C, ...props }: DialogButtonProps<C>) => {\n const Component: ElementType = component;\n return (\n <Button component={Component} {...props} contentWidth variant=\"secondary\" size=\"large\">\n {children}\n </Button>\n );\n};\n\nDialogRoot.displayName = \"Dialog\";\n\nTitle.displayName = \"Dialog.Title\";\n\nContent.displayName = \"Dialog.Content\";\n\nButtonSection.displayName = \"Dialog.ButtonSection\";\n\nPrimaryButton.displayName = \"Dialog.PrimaryButton\";\n\nSecondaryButton.displayName = \"Dialog.SecondaryButton\";\n\nexport default DialogRoot;\n"],"mappings":";;;;;;;;;AASA,IAAM,IAAkB,EAAG,EACzB,OAAO;CACL,OAAO;CACP,SAAS;CACT,YAAY;CACZ,gBAAgB;CAChB,eAAe;AACjB,EACF,CAAC,GAmCK,KAAc,EAAE,WAAQ,YAAS,WAAQ,kBAAsB;CACnE,IAAM,EAAE,eAAY,EAAgB,GAC9B,EAAE,iBAAc,EAAa,CAAM;CAEzC,OACE,kBAAC,GAAD;EAAS,QAAQ;EAAoB;EAAiB;EAAQ,UAAA;EAAS,eAAc;EACnF,UAAA,kBAAC,OAAD;GAAK,WAAW,EAAQ;GAAI;EAAc,CAAA;CACnC,CAAA;AAEb,GAEa,KAAS,EAAE,kBAAiC;CACvD,IAAM,EAAE,aAAU,EAAgB;CAElC,OAAO,kBAAC,EAAgB,OAAjB;EAAuB,WAAW,EAAM;EAAI;CAAgC,CAAA;AACrF,GAEa,KAAW,EAAE,kBAAmC;CAC3D,IAAM,EAAE,eAAY,sBAAmB,EAAgB;CAEvD,OACE,kBAAC,OAAD;EAAK,WAAW,EAAW;EACzB,UAAA,kBAAC,OAAD;GAAK,WAAW,EAAe;GAAI;EAAc,CAAA;CAC9C,CAAA;AAET,GAEa,KAAiB,EAAE,kBAAyC;CACvE,IAAM,EAAE,qBAAkB,EAAgB;CAE1C,OAAO,kBAAC,OAAD;EAAK,WAAW,EAAc;EAAI;CAAc,CAAA;AACzD,GAEa,KAAwC,EAAE,aAAU,eAAY,UAAe,GAAG,QAG3F,kBAAC,GAAD;CAAmB;CAAW,GAAI;CAAO,cAAA;CAAa,MAAK;CACxD;AACK,CAAA,GAIC,KAA0C,EAAE,aAAU,eAAY,UAAe,GAAG,QAG7F,kBAAC,GAAD;CAAmB;CAAW,GAAI;CAAO,cAAA;CAAa,SAAQ;CAAY,MAAK;CAC5E;AACK,CAAA;AAIZ,EAAW,cAAc,UAEzB,EAAM,cAAc,gBAEpB,EAAQ,cAAc,kBAEtB,EAAc,cAAc,wBAE5B,EAAc,cAAc,wBAE5B,EAAgB,cAAc"}
1
+ {"version":3,"file":"DialogRoot.js","names":["Component","DialogPrimitive","Button","IconButton","generateClasses","tv","fadeAnimation","DialogRoot","isOpen","warnDeprecated","useInnerOpen","open","usePrefersReducedMotion","image","innerOpen","backdrop","onClose","zIndex","modal","ZIndexContext","twMerge","imageBox","imageWrapperClassName","contentBox","closeButtonWrapper","wrapper","Title","title","Content","scrollArea","contentWrapper","ButtonSection","buttonSection","PrimaryButton","props","SecondaryButton"],"sources":["../../src/DialogRoot.tsx"],"sourcesContent":["\"use client\";\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 } from \"@bonprix-ds/internal-components\";\nimport Button from \"@bonprix-ds/react-button\";\nimport IconButton from \"@bonprix-ds/react-icon-button\";\nimport { usePrefersReducedMotion, ZIndexContext } from \"@bonprix-ds/utils\";\nimport { useInnerOpen } from \"@bonprix-ds/utils\";\nimport { warnDeprecated } from \"@bonprix-ds/utils/deprecation\";\n\nimport \"./Dialog.css\";\n\nconst generateClasses = tv({\n slots: {\n modal: [\n \"preflight fixed start-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2\", // Fixed position and centering\n \"h-fit min-h-[12.375rem] w-[37.5rem] max-w-[calc(100vw-2.5rem)] l:w-[67.5rem]\", // Size considering spacing to screen edges\n \"max-h-[calc(100dvh-var(--app-safe-area-inset-bottom,2.5rem)*2)]\",\n \"box-border grid grid-rows-1 justify-items-center\",\n ],\n imageBox: \"flex h-full w-full\",\n contentBox: \"relative box-border flex w-full max-w-[37.5rem] flex-col bg-clr-bg-modal py-7\",\n title: \"typography-bonprix-h4 px-7 text-clr-primary\",\n closeButtonWrapper: \"absolute end-1 top-1\",\n wrapper: \"flex h-full flex-col gap-5\",\n scrollArea: \"scroll-area relative h-full px-7\",\n contentWrapper: \"flex flex-col overflow-hidden\",\n buttonSection: \"flex flex-col gap-3 px-7\",\n },\n variants: {\n image: {\n true: {\n modal: \"grid-cols-1 grid-rows-2 l:grid-cols-2 l:grid-rows-1\",\n },\n },\n prefersReducedMotion: {\n false: {\n modal: [fadeAnimation()],\n },\n },\n },\n});\n\ninterface BaseProps {\n /** Here, all of the subcomponents should be placed. */\n children: ReactNode;\n /** Callback function that is called when the dialog is supposed to be closed. Should be used in conjunction with `open` property. */\n onClose: () => void;\n /** The z-index of the dialog. */\n zIndex?: number;\n /** Optional image slot that gets rendered left to (desktop) or above (mobile) the `children`. */\n image?: ReactNode;\n /** Additional CSS classes for the wrapper element around `image`, not the image itself. Useful to specify height and tweak layout. */\n imageWrapperClassName?: string;\n}\n\ntype OpenProps = BaseProps & {\n /** Controls the visibility of the dialog. Should be used in conjunction with `onClose`. */\n open: boolean;\n /** @deprecated [is-open-prop] Use `open` instead. */\n isOpen?: never;\n};\n\ntype DeprecatedOpenProps = BaseProps & {\n open?: never;\n /**\n * Controls the visibility of the dialog. Should be used in conjunction with `onClose`.\n * @deprecated [is-open-prop] Use `open` instead.\n */\n isOpen: boolean;\n};\n\nexport type Props = DeprecatedOpenProps | OpenProps;\n\nexport interface DialogTitleProps {\n /** The title to display in the dialog. */\n children: string;\n}\n\nexport interface DialogContentProps {\n /** The content to display in the dialog. */\n children: ReactNode;\n}\n\nexport interface DialogButtonSectionProps {\n /** Primary and secondary buttons should be placed inside this section. */\n children: ReactNode;\n}\n\ntype DialogButtonProps<C extends ElementType> = {\n /** The button text to render. */\n children: string;\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>, \"component\">;\n\nconst DialogRoot = ({ open, isOpen, onClose, zIndex = 2, children, image, imageWrapperClassName = \"\" }: Props) => {\n if (isOpen !== undefined) warnDeprecated(\"is-open-prop\");\n const { wrapper } = generateClasses();\n const { innerOpen } = useInnerOpen(open ?? isOpen ?? false);\n\n const prefersReducedMotion = usePrefersReducedMotion();\n\n const { modal, imageBox, contentBox, closeButtonWrapper } = generateClasses({ prefersReducedMotion, image: !!image });\n const closeLabel = \"Schließen\";\n\n return (\n <DialogPrimitive.Root open={innerOpen}>\n <DialogPrimitive.Portal>\n <DialogPrimitive.Overlay className={backdrop()} onClick={onClose} style={{ zIndex: zIndex - 1 }} />\n <DialogPrimitive.Content className={modal()} style={{ zIndex }} data-bpds=\"dialog\" aria-modal=\"true\">\n <ZIndexContext.Provider value={zIndex}>\n {image && (\n <div className={twMerge(imageBox(), imageWrapperClassName)} style={{ zIndex }}>\n {image}\n </div>\n )}\n <div className={contentBox()} style={{ zIndex }}>\n <DialogPrimitive.Close asChild>\n <div className={closeButtonWrapper()}>\n <IconButton variant=\"tertiary\" icon=\"closer\" size=\"small\" label={closeLabel} onClick={onClose} />\n </div>\n </DialogPrimitive.Close>\n <DialogPrimitive.Description className=\"sr-only\"></DialogPrimitive.Description>\n <div className={wrapper()}>{children}</div>\n </div>\n </ZIndexContext.Provider>\n </DialogPrimitive.Content>\n </DialogPrimitive.Portal>\n </DialogPrimitive.Root>\n );\n};\n\nexport const Title = ({ children }: DialogTitleProps) => {\n const { title } = generateClasses();\n\n return <DialogPrimitive.Title className={title()}>{children}</DialogPrimitive.Title>;\n};\n\nexport const Content = ({ children }: DialogContentProps) => {\n const { scrollArea, contentWrapper } = generateClasses();\n\n return (\n <div className={scrollArea()}>\n <div className={contentWrapper()}>{children}</div>\n </div>\n );\n};\n\nexport const ButtonSection = ({ children }: DialogButtonSectionProps) => {\n const { buttonSection } = generateClasses();\n\n return <div className={buttonSection()}>{children}</div>;\n};\n\nexport const PrimaryButton = <C extends ElementType>({ children, component = \"button\" as C, ...props }: DialogButtonProps<C>) => {\n const Component: ElementType = component;\n return (\n <Button component={Component} {...props} size=\"large\">\n {children}\n </Button>\n );\n};\n\nexport const SecondaryButton = <C extends ElementType>({ children, component = \"button\" as C, ...props }: DialogButtonProps<C>) => {\n const Component: ElementType = component;\n return (\n <Button component={Component} {...props} variant=\"secondary\" size=\"large\">\n {children}\n </Button>\n );\n};\n\nDialogRoot.displayName = \"Dialog\";\nTitle.displayName = \"Dialog.Title\";\nContent.displayName = \"Dialog.Content\";\nButtonSection.displayName = \"Dialog.ButtonSection\";\nPrimaryButton.displayName = \"Dialog.PrimaryButton\";\nSecondaryButton.displayName = \"Dialog.SecondaryButton\";\n\nexport default DialogRoot;\n"],"mappings":"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"}
package/dist/styles.js ADDED
@@ -0,0 +1 @@
1
+ import "./src/Dialog.css";
package/package.json CHANGED
@@ -1,14 +1,34 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-dialog",
3
- "version": "1.0.1",
3
+ "version": "1.1.0",
4
4
  "description": "Dialog 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/dialog"
9
12
  },
13
+ "files": [
14
+ "dist",
15
+ "!dist/tsconfig.tsbuildinfo",
16
+ "!dist/vite.config.d.ts",
17
+ "!dist/**/*.test.d.ts"
18
+ ],
19
+ "type": "module",
20
+ "sideEffects": [
21
+ "**/*.css",
22
+ "./dist/styles.js"
23
+ ],
10
24
  "module": "./dist/index.js",
11
- "sideEffects": false,
25
+ "types": "./dist/index.d.ts",
26
+ "imports": {
27
+ "#styles": {
28
+ "browser": "./dist/styles.js",
29
+ "default": "./dist/no-styles.js"
30
+ }
31
+ },
12
32
  "exports": {
13
33
  ".": {
14
34
  "import": "./dist/index.js",
@@ -16,37 +36,31 @@
16
36
  "default": "./dist/index.js"
17
37
  }
18
38
  },
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/dialog"
39
+ "publishConfig": {
40
+ "access": "public",
41
+ "provenance": true
30
42
  },
31
43
  "dependencies": {
32
44
  "@radix-ui/react-dialog": "1.1.23",
33
- "@bonprix-ds/react-button": "1.1.0",
34
- "@bonprix-ds/react-overlay": "1.0.1",
35
- "@bonprix-ds/utils": "0.2.2"
45
+ "tailwind-merge": "2.6.1",
46
+ "@bonprix-ds/internal-components": "0.2.2",
47
+ "@bonprix-ds/react-button": "1.1.2",
48
+ "@bonprix-ds/react-icon-button": "1.2.2",
49
+ "@bonprix-ds/utils": "0.3.0"
50
+ },
51
+ "devDependencies": {
52
+ "@testing-library/dom": "10.4.2",
53
+ "@testing-library/react": "16.3.3",
54
+ "@types/react": "19.3.0",
55
+ "vite": "8.3.2",
56
+ "vitest": "4.1.11",
57
+ "@bonprix-ds/vite-config": "0.0.0"
36
58
  },
37
59
  "peerDependencies": {
38
- "react": "^19.0.0",
39
- "react-dom": "^19.0.0",
60
+ "react": "^19",
61
+ "react-dom": "^19",
40
62
  "tailwind-variants": "0.3.1"
41
63
  },
42
- "devDependencies": {
43
- "vite": "8.2.2",
44
- "@types/react": "19.2.18",
45
- "@vitejs/plugin-react": "6.1.1",
46
- "rollup-preserve-directives": "1.1.3",
47
- "unplugin-dts": "1.1.0",
48
- "@microsoft/api-extractor": "7.59.1"
49
- },
50
64
  "scripts": {
51
65
  "build": "vite build"
52
66
  }