@bonprix-ds/react-modal 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,17 +1,2 @@
1
- import { default as default_2 } from 'react';
2
-
3
- declare const Modal: ({ children, isOpen, onClose, zIndex }: ModalProps) => default_2.JSX.Element | null;
4
- export default Modal;
5
-
6
- export declare interface ModalProps {
7
- /** Toggles the visibility of the modal. Should be used in conjunction with the `onClose` property. */
8
- isOpen: boolean;
9
- /** The content to be displayed inside the modal. */
10
- children?: default_2.ReactNode;
11
- /** Callback function to be called when the modal is closed. Should be used in conjunction with the `isOpen` property. */
12
- onClose?: () => void;
13
- /** The z-index of the modal. */
14
- zIndex?: number;
15
- }
16
-
17
- export { }
1
+ export { default } from "./src/Modal";
2
+ export type { Props as ModalProps } from "./src/Modal";
@@ -0,0 +1,13 @@
1
+ import React from "react";
2
+ export interface Props {
3
+ /** Toggles the visibility of the modal. Should be used in conjunction with the `onClose` property. */
4
+ isOpen: boolean;
5
+ /** The content to be displayed inside the modal. */
6
+ children?: React.ReactNode;
7
+ /** Callback function to be called when the modal is closed. Should be used in conjunction with the `isOpen` property. */
8
+ onClose?: () => void;
9
+ /** The z-index of the modal. */
10
+ zIndex?: number;
11
+ }
12
+ declare const Modal: ({ children, isOpen, onClose, zIndex }: Props) => React.JSX.Element | null;
13
+ export default Modal;
package/dist/src/Modal.js CHANGED
@@ -1,25 +1,25 @@
1
1
  "use client";
2
2
  import e from "./useAnimation.js";
3
- import { backdrop as t, fadeAnimation as n } from "@bonprix-ds/internal-components";
4
- import { useIsClient as r, usePrefersReducedMotion as i } from "@bonprix-ds/utils";
5
3
  import "react";
6
- import { createPortal as a } from "react-dom";
7
- import { tv as o } from "tailwind-variants";
4
+ import { createPortal as t } from "react-dom";
5
+ import { tv as n } from "tailwind-variants";
6
+ import { backdrop as r, fadeAnimation as i } from "@bonprix-ds/internal-components";
7
+ import { useIsClient as a, usePrefersReducedMotion as o } from "@bonprix-ds/utils";
8
8
  import { Fragment as s, jsx as c } from "react/jsx-runtime";
9
9
  //#region src/Modal.tsx
10
- var l = o({
11
- slots: { backdrop: t() },
12
- variants: { prefersReducedMotion: { false: { backdrop: n() } } }
13
- }), u = ({ children: t, isOpen: n, onClose: o = () => null, zIndex: u = 1 }) => {
14
- let { backdrop: d } = l({ prefersReducedMotion: i() }), { shouldRender: f, handleAnimationEnd: p } = e(n);
15
- return r() ? /* @__PURE__ */ c(s, { children: a(f ? /* @__PURE__ */ c("div", {
10
+ var l = n({
11
+ slots: { backdrop: r() },
12
+ 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
16
  className: d(),
17
- onClick: o,
18
- "data-state": n ? "open" : "closed",
17
+ onClick: i,
18
+ "data-state": r ? "open" : "closed",
19
19
  onAnimationEnd: p,
20
20
  style: { zIndex: u },
21
21
  "data-bpds": "modal",
22
- children: t
22
+ children: n
23
23
  }) : null, document.body) }) : null;
24
24
  };
25
25
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"Modal.js","names":[],"sources":["../../src/Modal.tsx"],"sourcesContent":["\"use client\";\n\nimport { backdrop, fadeAnimation } from \"@bonprix-ds/internal-components\";\nimport { useIsClient, usePrefersReducedMotion } from \"@bonprix-ds/utils\";\nimport React from \"react\";\nimport { createPortal } from \"react-dom\";\nimport { tv } from \"tailwind-variants\";\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":";;;;;;;;;AAUA,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":[],"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"}
@@ -0,0 +1,5 @@
1
+ declare const useAnimation: (prop: boolean) => {
2
+ shouldRender: boolean;
3
+ handleAnimationEnd: () => void;
4
+ };
5
+ export default useAnimation;
@@ -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 // eslint-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":[],"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"}
package/package.json CHANGED
@@ -1,14 +1,25 @@
1
1
  {
2
2
  "name": "@bonprix-ds/react-modal",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Modal 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/modal"
9
12
  },
10
- "module": "./dist/index.js",
13
+ "files": [
14
+ "dist",
15
+ "!dist/tsconfig.tsbuildinfo",
16
+ "!dist/vite.config.d.ts",
17
+ "!dist/**/*.test.d.ts"
18
+ ],
19
+ "type": "module",
11
20
  "sideEffects": false,
21
+ "module": "./dist/index.js",
22
+ "types": "./dist/index.d.ts",
12
23
  "exports": {
13
24
  ".": {
14
25
  "import": "./dist/index.js",
@@ -16,38 +27,28 @@
16
27
  "default": "./dist/index.js"
17
28
  }
18
29
  },
19
- "types": "./dist/index.d.ts",
20
- "files": [
21
- "dist"
22
- ],
23
- "keywords": [],
24
- "author": "",
25
- "license": "UNLICENSED",
26
- "repository": {
27
- "type": "git",
28
- "url": "git+https://github.com/bonprix/design-system.git",
29
- "directory": "packages/react/modal"
30
+ "publishConfig": {
31
+ "access": "public",
32
+ "provenance": true
30
33
  },
31
34
  "dependencies": {
32
- "@bonprix-ds/internal-components": "0.1.5",
33
- "@bonprix-ds/utils": "0.2.1"
34
- },
35
- "peerDependencies": {
36
- "react": "^19.0.0",
37
- "react-dom": "^19.0.0",
38
- "tailwind-variants": "0.3.1"
35
+ "@bonprix-ds/internal-components": "0.2.1",
36
+ "@bonprix-ds/utils": "0.2.2"
39
37
  },
40
38
  "devDependencies": {
41
- "vite": "8.2.2",
42
- "vitest": "4.1.11",
43
- "@testing-library/dom": "10.4.1",
39
+ "@testing-library/dom": "10.4.2",
44
40
  "@testing-library/react": "16.3.3",
45
- "@types/react": "19.2.18",
46
- "@types/react-dom": "19.2.5",
41
+ "@types/react": "19.3.0",
42
+ "@types/react-dom": "19.3.0",
47
43
  "@vitejs/plugin-react": "6.1.1",
48
44
  "rollup-preserve-directives": "1.1.3",
49
- "unplugin-dts": "1.0.3",
50
- "@microsoft/api-extractor": "7.59.0"
45
+ "vite": "8.3.0",
46
+ "vitest": "4.1.11"
47
+ },
48
+ "peerDependencies": {
49
+ "react": "^19.3.0",
50
+ "react-dom": "^19.3.0",
51
+ "tailwind-variants": "0.3.1"
51
52
  },
52
53
  "scripts": {
53
54
  "build": "vite build"