@bonprix-ds/react-modal 1.0.2 → 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.
@@ -1,4 +1,5 @@
1
1
  import React from "react";
2
+ /** @deprecated [modal-component] Use Dialog, SideSheet or BottomSheet instead. */
2
3
  export interface Props {
3
4
  /** Toggles the visibility of the modal. Should be used in conjunction with the `onClose` property. */
4
5
  isOpen: boolean;
@@ -9,5 +10,6 @@ export interface Props {
9
10
  /** The z-index of the modal. */
10
11
  zIndex?: number;
11
12
  }
13
+ /** @deprecated [modal-component] Use Dialog, SideSheet or BottomSheet instead. */
12
14
  declare const Modal: ({ children, isOpen, onClose, zIndex }: Props) => React.JSX.Element | null;
13
15
  export default Modal;
package/dist/src/Modal.js CHANGED
@@ -5,24 +5,26 @@ import { createPortal as t } from "react-dom";
5
5
  import { tv as n } from "tailwind-variants";
6
6
  import { backdrop as r, fadeAnimation as i } from "@bonprix-ds/internal-components";
7
7
  import { useIsClient as a, usePrefersReducedMotion as o } from "@bonprix-ds/utils";
8
- import { Fragment as s, jsx as c } from "react/jsx-runtime";
8
+ import { warnDeprecated as s } from "@bonprix-ds/utils/deprecation";
9
+ import { Fragment as c, jsx as l } from "react/jsx-runtime";
9
10
  //#region src/Modal.tsx
10
- var l = n({
11
+ var u = n({
11
12
  slots: { backdrop: r() },
12
13
  variants: { prefersReducedMotion: { false: { backdrop: i() } } }
13
- }), u = ({ children: n, isOpen: r, onClose: i = () => null, zIndex: u = 1 }) => {
14
- let { backdrop: d } = l({ prefersReducedMotion: o() }), { shouldRender: f, handleAnimationEnd: p } = e(r);
15
- return a() ? /* @__PURE__ */ c(s, { children: t(f ? /* @__PURE__ */ c("div", {
16
- className: d(),
14
+ }), d = ({ children: n, isOpen: r, onClose: i = () => null, zIndex: d = 1 }) => {
15
+ s("modal-component");
16
+ let { backdrop: f } = u({ prefersReducedMotion: o() }), { shouldRender: p, handleAnimationEnd: m } = e(r);
17
+ return a() ? /* @__PURE__ */ l(c, { children: t(p ? /* @__PURE__ */ l("div", {
18
+ className: f(),
17
19
  onClick: i,
18
20
  "data-state": r ? "open" : "closed",
19
- onAnimationEnd: p,
20
- style: { zIndex: u },
21
+ onAnimationEnd: m,
22
+ style: { zIndex: d },
21
23
  "data-bpds": "modal",
22
24
  children: n
23
25
  }) : null, document.body) }) : null;
24
26
  };
25
27
  //#endregion
26
- export { u as default };
28
+ export { d as default };
27
29
 
28
30
  //# sourceMappingURL=Modal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","names":[],"sources":["../../src/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { tv } from \"tailwind-variants\";\n\nimport { backdrop, fadeAnimation } from \"@bonprix-ds/internal-components\";\nimport { useIsClient, usePrefersReducedMotion } from \"@bonprix-ds/utils\";\n\nimport useAnimation from \"./useAnimation\";\n\nconst generateClasses = tv({\n slots: {\n backdrop: backdrop(),\n },\n variants: {\n prefersReducedMotion: {\n false: {\n backdrop: fadeAnimation(),\n },\n },\n },\n});\n\nexport interface Props {\n /** Toggles the visibility of the modal. Should be used in conjunction with the `onClose` property. */\n isOpen: boolean;\n /** The content to be displayed inside the modal. */\n children?: React.ReactNode;\n /** Callback function to be called when the modal is closed. Should be used in conjunction with the `isOpen` property. */\n onClose?: () => void;\n /** The z-index of the modal. */\n zIndex?: number;\n}\n\nconst Modal = ({ children, isOpen, onClose = () => null, zIndex = 1 }: Props) => {\n const prefersReducedMotion = usePrefersReducedMotion();\n const { backdrop } = generateClasses({ prefersReducedMotion });\n const { shouldRender, handleAnimationEnd } = useAnimation(isOpen);\n\n const isClient = useIsClient();\n if (!isClient) return null;\n\n return (\n <>\n {createPortal(\n shouldRender ? (\n <div\n className={backdrop()}\n onClick={onClose}\n data-state={isOpen ? \"open\" : \"closed\"}\n onAnimationEnd={handleAnimationEnd}\n style={{ zIndex }}\n data-bpds=\"modal\"\n >\n {children}\n </div>\n ) : null,\n document.body,\n )}\n </>\n );\n};\n\nexport default Modal;\n"],"mappings":";;;;;;;;;AAWA,IAAM,IAAkB,EAAG;CACzB,OAAO,EACL,UAAU,EAAS,EACrB;CACA,UAAU,EACR,sBAAsB,EACpB,OAAO,EACL,UAAU,EAAc,EAC1B,EACF,EACF;AACF,CAAC,GAaK,KAAS,EAAE,aAAU,WAAQ,mBAAgB,MAAM,YAAS,QAAe;CAE/E,IAAM,EAAE,gBAAa,EAAgB,EAAE,sBADV,EACU,EAAqB,CAAC,GACvD,EAAE,iBAAc,0BAAuB,EAAa,CAAM;CAKhE,OAHiB,EACZ,IAGH,kBAAA,GAAA,EAAA,UACG,EACC,IACE,kBAAC,OAAD;EACE,WAAW,EAAS;EACpB,SAAS;EACT,cAAY,IAAS,SAAS;EAC9B,gBAAgB;EAChB,OAAO,EAAE,UAAO;EAChB,aAAU;EAET;CACE,CAAA,IACH,MACJ,SAAS,IACX,EACA,CAAA,IAnBkB;AAqBxB"}
1
+ {"version":3,"file":"Modal.js","names":["_Fragment","useAnimation","generateClasses","tv","backdrop","fadeAnimation","Modal","usePrefersReducedMotion","isOpen","useIsClient","Fragment","createPortal","shouldRender","onClose","handleAnimationEnd"],"sources":["../../src/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { tv } from \"tailwind-variants\";\n\nimport { backdrop, fadeAnimation } from \"@bonprix-ds/internal-components\";\nimport { useIsClient, usePrefersReducedMotion } from \"@bonprix-ds/utils\";\nimport { warnDeprecated } from \"@bonprix-ds/utils/deprecation\";\n\nimport useAnimation from \"./useAnimation\";\n\nconst generateClasses = tv({\n slots: {\n backdrop: backdrop(),\n },\n variants: {\n prefersReducedMotion: {\n false: {\n backdrop: fadeAnimation(),\n },\n },\n },\n});\n\n/** @deprecated [modal-component] Use Dialog, SideSheet or BottomSheet instead. */\nexport interface Props {\n /** Toggles the visibility of the modal. Should be used in conjunction with the `onClose` property. */\n isOpen: boolean;\n /** The content to be displayed inside the modal. */\n children?: React.ReactNode;\n /** Callback function to be called when the modal is closed. Should be used in conjunction with the `isOpen` property. */\n onClose?: () => void;\n /** The z-index of the modal. */\n zIndex?: number;\n}\n\n/** @deprecated [modal-component] Use Dialog, SideSheet or BottomSheet instead. */\nconst Modal = ({ children, isOpen, onClose = () => null, zIndex = 1 }: Props) => {\n warnDeprecated(\"modal-component\");\n\n const prefersReducedMotion = usePrefersReducedMotion();\n const { backdrop } = generateClasses({ prefersReducedMotion });\n const { shouldRender, handleAnimationEnd } = useAnimation(isOpen);\n\n const isClient = useIsClient();\n if (!isClient) return null;\n\n return (\n <>\n {createPortal(\n shouldRender ? (\n <div\n className={backdrop()}\n onClick={onClose}\n data-state={isOpen ? \"open\" : \"closed\"}\n onAnimationEnd={handleAnimationEnd}\n style={{ zIndex }}\n data-bpds=\"modal\"\n >\n {children}\n </div>\n ) : null,\n document.body,\n )}\n </>\n );\n};\n\nexport default Modal;\n"],"mappings":";;;;;;;;;;AAYA,IAAME,IAAkBC,EAAG;CACzB,OAAO,EACL,UAAUC,EAAS,EACrB;CACA,UAAU,EACR,sBAAsB,EACpB,OAAO,EACL,UAAUC,EAAc,EAC1B,EACF,EACF;AACF,CAAC,GAeKC,KAAS,EAAE,aAAU,WAAQ,mBAAgB,MAAM,YAAS,QAAe;CAC/E,EAAe,iBAAiB;CAGhC,IAAM,EAAE,gBAAaJ,EAAgB,EAAE,sBADVK,EACU,EAAqB,CAAC,GACvD,EAAE,iBAAc,0BAAuBN,EAAaO,CAAM;CAKhE,OAHiBC,EACZ,IAGH,kBAAAT,GAAA,EAAA,UACGW,EACCC,IACE,kBAAC,OAAD;EACE,WAAWR,EAAS;EACpB,SAASS;EACT,cAAYL,IAAS,SAAS;EAC9B,gBAAgBM;EAChB,OAAO,EAAE,UAAO;EAChB,aAAU;EAET;CACE,CAAA,IACH,MACJ,SAAS,IACX,EACA,CAAA,IAnBkB;AAqBxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useAnimation.js","names":[],"sources":["../../src/useAnimation.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nconst useAnimation = (prop: boolean) => {\n const [shouldRender, setShouldRender] = useState(prop);\n\n useEffect(() => {\n if (prop) {\n // oxlint-disable-next-line react-hooks/set-state-in-effect\n setShouldRender(true);\n }\n }, [prop]);\n\n const handleAnimationEnd = () => {\n if (!prop) {\n setShouldRender(false);\n }\n };\n\n return { shouldRender, handleAnimationEnd };\n};\n\nexport default useAnimation;\n"],"mappings":";;AAEA,IAAM,KAAgB,MAAkB;CACtC,IAAM,CAAC,GAAc,KAAmB,EAAS,CAAI;CAerD,OAbA,QAAgB;EACd,AAAI,KAEF,EAAgB,EAAI;CAExB,GAAG,CAAC,CAAI,CAAC,GAQF;EAAE;EAAc,0BANU;GAC/B,AAAK,KACH,EAAgB,EAAK;EAEzB;CAE0C;AAC5C"}
1
+ {"version":3,"file":"useAnimation.js","names":["useAnimation","shouldRender","setShouldRender","useState","prop","useEffect"],"sources":["../../src/useAnimation.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nconst useAnimation = (prop: boolean) => {\n const [shouldRender, setShouldRender] = useState(prop);\n\n useEffect(() => {\n if (prop) {\n // oxlint-disable-next-line react-hooks/set-state-in-effect\n setShouldRender(true);\n }\n }, [prop]);\n\n const handleAnimationEnd = () => {\n if (!prop) {\n setShouldRender(false);\n }\n };\n\n return { shouldRender, handleAnimationEnd };\n};\n\nexport default useAnimation;\n"],"mappings":";;AAEA,IAAMA,KAAgB,MAAkB;CACtC,IAAM,CAACC,GAAcC,KAAmBC,EAASC,CAAI;CAerD,OAbAC,QAAgB;EACd,AAAID,KAEFF,EAAgB,EAAI;CAExB,GAAG,CAACE,CAAI,CAAC,GAQF;EAAE;EAAc,0BANU;GAC/B,AAAKA,KACHF,EAAgB,EAAK;EAEzB;CAE0C;AAC5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-modal",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "Modal component, implemented in React, for the Bonprix Design System.",
5
5
  "keywords": [],
6
6
  "license": "UNLICENSED",
@@ -32,22 +32,21 @@
32
32
  "provenance": true
33
33
  },
34
34
  "dependencies": {
35
- "@bonprix-ds/internal-components": "0.2.1",
36
- "@bonprix-ds/utils": "0.2.2"
35
+ "@bonprix-ds/internal-components": "0.2.2",
36
+ "@bonprix-ds/utils": "0.3.0"
37
37
  },
38
38
  "devDependencies": {
39
39
  "@testing-library/dom": "10.4.2",
40
40
  "@testing-library/react": "16.3.3",
41
41
  "@types/react": "19.3.0",
42
42
  "@types/react-dom": "19.3.0",
43
- "@vitejs/plugin-react": "6.1.1",
44
- "rollup-preserve-directives": "1.1.3",
45
- "vite": "8.3.0",
46
- "vitest": "4.1.11"
43
+ "vite": "8.3.2",
44
+ "vitest": "4.1.11",
45
+ "@bonprix-ds/vite-config": "0.0.0"
47
46
  },
48
47
  "peerDependencies": {
49
- "react": "^19.3.0",
50
- "react-dom": "^19.3.0",
48
+ "react": "^19",
49
+ "react-dom": "^19",
51
50
  "tailwind-variants": "0.3.1"
52
51
  },
53
52
  "scripts": {