@bonprix-ds/react-dialog 1.0.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 +62 -0
- package/dist/index.js +2 -0
- package/dist/src/Dialog.js +10 -0
- package/dist/src/Dialog.js.map +1 -0
- package/dist/src/DialogRoot.js +68 -0
- package/dist/src/DialogRoot.js.map +1 -0
- package/package.json +53 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
declare interface DialogButtonSectionProps {
|
|
37
|
+
/** Primary and secondary buttons should be placed inside this section. */
|
|
38
|
+
children: ReactNode;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
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
|
+
declare interface DialogTitleProps {
|
|
58
|
+
/** The title to display in the dialog. */
|
|
59
|
+
children: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import e, { ButtonSection as t, Content as n, PrimaryButton as r, SecondaryButton as i, Title as a } from "./DialogRoot.js";
|
|
2
|
+
import "react";
|
|
3
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
4
|
+
//#region src/Dialog.tsx
|
|
5
|
+
var s = (t) => /* @__PURE__ */ o(e, { ...t });
|
|
6
|
+
s.displayName = "Dialog", s.Title = a, s.Content = n, s.ButtonSection = t, s.PrimaryButton = r, s.SecondaryButton = i;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { s as default };
|
|
9
|
+
|
|
10
|
+
//# sourceMappingURL=Dialog.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use client";
|
|
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";
|
|
9
|
+
//#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
|
+
})
|
|
28
|
+
});
|
|
29
|
+
}, c = ({ children: e }) => {
|
|
30
|
+
let { title: t } = o();
|
|
31
|
+
return /* @__PURE__ */ a(i.Title, {
|
|
32
|
+
className: t(),
|
|
33
|
+
children: e
|
|
34
|
+
});
|
|
35
|
+
}, l = ({ children: e }) => {
|
|
36
|
+
let { scrollArea: t, contentWrapper: n } = o();
|
|
37
|
+
return /* @__PURE__ */ a("div", {
|
|
38
|
+
className: t(),
|
|
39
|
+
children: /* @__PURE__ */ a("div", {
|
|
40
|
+
className: n(),
|
|
41
|
+
children: e
|
|
42
|
+
})
|
|
43
|
+
});
|
|
44
|
+
}, u = ({ children: e }) => {
|
|
45
|
+
let { buttonSection: t } = o();
|
|
46
|
+
return /* @__PURE__ */ a("div", {
|
|
47
|
+
className: t(),
|
|
48
|
+
children: e
|
|
49
|
+
});
|
|
50
|
+
}, d = ({ children: t, component: n = "button", ...r }) => /* @__PURE__ */ a(e, {
|
|
51
|
+
component: n,
|
|
52
|
+
...r,
|
|
53
|
+
contentWidth: !0,
|
|
54
|
+
size: "large",
|
|
55
|
+
children: t
|
|
56
|
+
}), f = ({ children: t, component: n = "button", ...r }) => /* @__PURE__ */ a(e, {
|
|
57
|
+
component: n,
|
|
58
|
+
...r,
|
|
59
|
+
contentWidth: !0,
|
|
60
|
+
variant: "secondary",
|
|
61
|
+
size: "large",
|
|
62
|
+
children: t
|
|
63
|
+
});
|
|
64
|
+
s.displayName = "Dialog", c.displayName = "Dialog.Title", l.displayName = "Dialog.Content", u.displayName = "Dialog.ButtonSection", d.displayName = "Dialog.PrimaryButton", f.displayName = "Dialog.SecondaryButton";
|
|
65
|
+
//#endregion
|
|
66
|
+
export { u as ButtonSection, l as Content, d as PrimaryButton, f as SecondaryButton, c as Title, s as default };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=DialogRoot.js.map
|
|
@@ -0,0 +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"}
|
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bonprix-ds/react-dialog",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Dialog component, implemented in React, for the Bonprix Design System.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public",
|
|
8
|
+
"provenance": true
|
|
9
|
+
},
|
|
10
|
+
"module": "./dist/index.js",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"default": "./dist/index.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
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"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@radix-ui/react-dialog": "1.1.23",
|
|
33
|
+
"@bonprix-ds/react-button": "1.0.0",
|
|
34
|
+
"@bonprix-ds/react-overlay": "1.0.0",
|
|
35
|
+
"@bonprix-ds/utils": "0.2.1"
|
|
36
|
+
},
|
|
37
|
+
"peerDependencies": {
|
|
38
|
+
"react": "^19.0.0",
|
|
39
|
+
"react-dom": "^19.0.0",
|
|
40
|
+
"tailwind-variants": "0.3.1"
|
|
41
|
+
},
|
|
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.0.3",
|
|
48
|
+
"@microsoft/api-extractor": "7.59.0"
|
|
49
|
+
},
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "vite build"
|
|
52
|
+
}
|
|
53
|
+
}
|