@plurix/ecom-components 1.20.6 → 1.20.8
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,6 +1,6 @@
|
|
|
1
1
|
import { ReactNode, Dispatch, SetStateAction } from 'react';
|
|
2
2
|
|
|
3
|
-
interface ModalProps {
|
|
3
|
+
export interface ModalProps {
|
|
4
4
|
isOpen: boolean;
|
|
5
5
|
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
|
6
6
|
children: ReactNode;
|
|
@@ -11,6 +11,11 @@ interface ModalProps {
|
|
|
11
11
|
Footer?: ReactNode;
|
|
12
12
|
hideHeader?: boolean;
|
|
13
13
|
PreContent?: ReactNode;
|
|
14
|
+
/** Fecha o modal com a tecla Esc. Default: true. */
|
|
15
|
+
closeOnEsc?: boolean;
|
|
16
|
+
/** Mantém o foco do teclado dentro do modal enquanto aberto. Default: true. */
|
|
17
|
+
trapFocus?: boolean;
|
|
18
|
+
/** Texto acessível do botão de fechar. Default: 'Fechar'. */
|
|
19
|
+
closeButtonLabel?: string;
|
|
14
20
|
}
|
|
15
21
|
export declare const Modal: (props: ModalProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
16
|
-
export {};
|
|
@@ -1,62 +1,151 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var j = Object.defineProperty, B = Object.defineProperties;
|
|
2
|
+
var K = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var v = Object.getOwnPropertySymbols;
|
|
4
|
+
var T = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var N = (r, t, o) => t in r ? j(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o, R = (r, t) => {
|
|
6
|
+
for (var o in t || (t = {}))
|
|
7
|
+
T.call(t, o) && N(r, o, t[o]);
|
|
8
|
+
if (v)
|
|
9
|
+
for (var o of v(t))
|
|
10
|
+
$.call(t, o) && N(r, o, t[o]);
|
|
11
|
+
return r;
|
|
12
|
+
}, F = (r, t) => B(r, K(t));
|
|
13
|
+
import { jsx as i, jsxs as E } from "react/jsx-runtime";
|
|
14
|
+
import { useRef as m, useId as M, useEffect as w } from "react";
|
|
15
|
+
import { ArrowIcon as W } from "../../assets/svgs/ArrowIcon.js";
|
|
16
|
+
import { CloseIcon as _ } from "../../assets/svgs/CloseIcon.js";
|
|
17
|
+
import { HAS_WINDOW as H } from "../../constants/index.js";
|
|
18
|
+
/* empty css */const q = [
|
|
19
|
+
"a[href]",
|
|
20
|
+
"button:not([disabled])",
|
|
21
|
+
"input:not([disabled])",
|
|
22
|
+
"select:not([disabled])",
|
|
23
|
+
"textarea:not([disabled])",
|
|
24
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
25
|
+
].join(","), X = (r) => {
|
|
7
26
|
const {
|
|
8
|
-
isOpen:
|
|
9
|
-
setIsOpen:
|
|
10
|
-
children:
|
|
11
|
-
className:
|
|
12
|
-
title:
|
|
13
|
-
titleAction:
|
|
14
|
-
hasTitleArrow:
|
|
15
|
-
Footer:
|
|
16
|
-
hideHeader:
|
|
17
|
-
PreContent:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
isOpen: t,
|
|
28
|
+
setIsOpen: o,
|
|
29
|
+
children: O,
|
|
30
|
+
className: S,
|
|
31
|
+
title: f,
|
|
32
|
+
titleAction: L,
|
|
33
|
+
hasTitleArrow: D,
|
|
34
|
+
Footer: g,
|
|
35
|
+
hideHeader: d,
|
|
36
|
+
PreContent: x,
|
|
37
|
+
closeOnEsc: A = !0,
|
|
38
|
+
trapFocus: s = !0,
|
|
39
|
+
closeButtonLabel: I = "Fechar"
|
|
40
|
+
} = r, h = m(null), b = m(null), u = m(null), C = m(null), p = `modal-title-${M()}`, y = () => o == null ? void 0 : o(!1);
|
|
41
|
+
return w(() => {
|
|
42
|
+
if (H)
|
|
43
|
+
return t ? window.document.body.classList.add("no-scroll") : window.document.body.classList.remove("no-scroll"), () => {
|
|
22
44
|
window.document.body.classList.remove("no-scroll");
|
|
23
45
|
};
|
|
24
|
-
}, [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
46
|
+
}, [t]), w(() => {
|
|
47
|
+
if (b.current && h.current) {
|
|
48
|
+
const n = d ? 0 : 56;
|
|
49
|
+
h.current.style.maxHeight = `calc(100% - ${n}px - ${b.current.offsetHeight}px)`;
|
|
50
|
+
}
|
|
51
|
+
const c = (n) => {
|
|
52
|
+
var e;
|
|
53
|
+
u.current && (n == null ? void 0 : n.target) instanceof Node && !((e = u.current) != null && e.contains(n == null ? void 0 : n.target)) && y();
|
|
29
54
|
};
|
|
30
|
-
return
|
|
55
|
+
return t ? document.addEventListener("mousedown", c) : document.removeEventListener("mousedown", c), () => {
|
|
31
56
|
document.removeEventListener("mousedown", c);
|
|
32
57
|
};
|
|
33
|
-
}, [
|
|
58
|
+
}, [t, d]), w(() => {
|
|
59
|
+
if (!t || !H)
|
|
60
|
+
return;
|
|
61
|
+
C.current = document.activeElement;
|
|
62
|
+
const c = () => {
|
|
63
|
+
var e, l;
|
|
64
|
+
return Array.from(
|
|
65
|
+
(l = (e = u.current) == null ? void 0 : e.querySelectorAll(q)) != null ? l : []
|
|
66
|
+
).filter(
|
|
67
|
+
(a) => !a.hasAttribute("hidden") && a.getAttribute("aria-hidden") !== "true"
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
if (s) {
|
|
71
|
+
const [e] = c();
|
|
72
|
+
e == null || e.focus();
|
|
73
|
+
}
|
|
74
|
+
const n = (e) => {
|
|
75
|
+
if (A && e.key === "Escape") {
|
|
76
|
+
y();
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (!s || e.key !== "Tab")
|
|
80
|
+
return;
|
|
81
|
+
const l = c();
|
|
82
|
+
if (l.length === 0)
|
|
83
|
+
return;
|
|
84
|
+
const a = l[0], k = l[l.length - 1];
|
|
85
|
+
if (e.shiftKey && document.activeElement === a) {
|
|
86
|
+
e.preventDefault(), k.focus();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
!e.shiftKey && document.activeElement === k && (e.preventDefault(), a.focus());
|
|
90
|
+
};
|
|
91
|
+
return document.addEventListener("keydown", n), () => {
|
|
92
|
+
var e, l;
|
|
93
|
+
document.removeEventListener("keydown", n), s && ((l = (e = C.current) == null ? void 0 : e.focus) == null || l.call(e));
|
|
94
|
+
};
|
|
95
|
+
}, [t, A, s]), t ? /* @__PURE__ */ i(
|
|
34
96
|
"div",
|
|
35
97
|
{
|
|
36
98
|
id: "modal-container",
|
|
37
99
|
"data-testid": "modal-container",
|
|
38
|
-
className:
|
|
39
|
-
children: /* @__PURE__ */
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
100
|
+
className: S,
|
|
101
|
+
children: /* @__PURE__ */ i("div", { id: "modal-content-container", children: /* @__PURE__ */ E(
|
|
102
|
+
"div",
|
|
103
|
+
F(R({
|
|
104
|
+
id: "modal-content",
|
|
105
|
+
ref: u,
|
|
106
|
+
role: "dialog",
|
|
107
|
+
"aria-modal": "true"
|
|
108
|
+
}, d ? { "aria-label": f } : { "aria-labelledby": p }), {
|
|
109
|
+
children: [
|
|
110
|
+
!d && /* @__PURE__ */ E("header", { children: [
|
|
111
|
+
L ? /* @__PURE__ */ E(
|
|
112
|
+
"button",
|
|
113
|
+
{
|
|
114
|
+
id: p,
|
|
115
|
+
onClick: L,
|
|
116
|
+
className: "modal-title",
|
|
117
|
+
children: [
|
|
118
|
+
D && /* @__PURE__ */ i(
|
|
119
|
+
W,
|
|
120
|
+
{
|
|
121
|
+
rotate: "Left",
|
|
122
|
+
color: "var(--color-support-links)"
|
|
123
|
+
}
|
|
124
|
+
),
|
|
125
|
+
f
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
) : /* @__PURE__ */ i("h2", { id: p, className: "modal-title", children: f }),
|
|
129
|
+
/* @__PURE__ */ i(
|
|
130
|
+
"button",
|
|
131
|
+
{
|
|
132
|
+
onClick: y,
|
|
133
|
+
className: "modal-close",
|
|
134
|
+
type: "button",
|
|
135
|
+
"aria-label": I,
|
|
136
|
+
children: /* @__PURE__ */ i(_, { color: "var(--color-main)" })
|
|
137
|
+
}
|
|
138
|
+
)
|
|
139
|
+
] }),
|
|
140
|
+
!!x && x,
|
|
141
|
+
/* @__PURE__ */ i("div", { ref: h, children: O }),
|
|
142
|
+
g && /* @__PURE__ */ i("footer", { className: "modal-footer", ref: b, children: g })
|
|
143
|
+
]
|
|
144
|
+
})
|
|
145
|
+
) })
|
|
57
146
|
}
|
|
58
147
|
) : null;
|
|
59
148
|
};
|
|
60
149
|
export {
|
|
61
|
-
|
|
150
|
+
X as Modal
|
|
62
151
|
};
|
package/package.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@plurix/ecom-components",
|
|
3
|
-
"author": "Plurix",
|
|
4
|
-
"private": false,
|
|
5
|
-
"version": "1.20.
|
|
6
|
-
"type": "module",
|
|
7
|
-
"main": "dist/main.js",
|
|
8
|
-
"types": "dist/main.d.ts",
|
|
9
|
-
"files": [
|
|
10
|
-
"dist"
|
|
11
|
-
],
|
|
12
|
-
"repository": {
|
|
13
|
-
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/plurix-ecommerce/ecom-components.git"
|
|
15
|
-
},
|
|
16
|
-
"sideEffects": [
|
|
17
|
-
"**/*.css"
|
|
18
|
-
],
|
|
19
|
-
"scripts": {
|
|
20
|
-
"dev": "vite",
|
|
21
|
-
"build": "tsc --p ./tsconfig-build.json && vite build",
|
|
22
|
-
"format": "prettier --write .",
|
|
23
|
-
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
24
|
-
"prepare": "husky install",
|
|
25
|
-
"preview": "vite preview",
|
|
26
|
-
"test": "jest"
|
|
27
|
-
},
|
|
28
|
-
"peerDependencies": {
|
|
29
|
-
"react": "^18.2.0",
|
|
30
|
-
"react-dom": "^18.2.0"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@babel/preset-env": "^7.24.5",
|
|
34
|
-
"@babel/preset-react": "^7.24.1",
|
|
35
|
-
"@commitlint/cli": "^17.4.2",
|
|
36
|
-
"@commitlint/config-conventional": "^17.4.2",
|
|
37
|
-
"@jest/globals": "^29.7.0",
|
|
38
|
-
"@testing-library/jest-dom": "^6.4.5",
|
|
39
|
-
"@testing-library/react": "^15.0.7",
|
|
40
|
-
"@types/jest": "^29.5.12",
|
|
41
|
-
"@types/node": "^20.11.30",
|
|
42
|
-
"@types/react": "^18.2.71",
|
|
43
|
-
"@types/react-dom": "^18.2.22",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
45
|
-
"@typescript-eslint/parser": "^6.21.0",
|
|
46
|
-
"@vitejs/plugin-react": "^4.2.1",
|
|
47
|
-
"eslint": "^8.57.0",
|
|
48
|
-
"eslint-plugin-react-hooks": "^4.6.0",
|
|
49
|
-
"eslint-plugin-react-refresh": "^0.4.6",
|
|
50
|
-
"glob": "^10.3.10",
|
|
51
|
-
"husky": "^9.0.11",
|
|
52
|
-
"identity-obj-proxy": "^3.0.0",
|
|
53
|
-
"jest": "^29.7.0",
|
|
54
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
55
|
-
"jest-svg-transformer": "^1.0.0",
|
|
56
|
-
"prettier": "^2.2.1",
|
|
57
|
-
"react": "^18.2.0",
|
|
58
|
-
"react-dom": "^18.2.0",
|
|
59
|
-
"rollup-plugin-delete": "^2.0.0",
|
|
60
|
-
"ts-jest": "^29.1.2",
|
|
61
|
-
"typescript": "^5.4.3",
|
|
62
|
-
"vite": "^4.5.3",
|
|
63
|
-
"vite-plugin-dts": "^3.7.3",
|
|
64
|
-
"vite-plugin-lib-inject-css": "^2.0.1"
|
|
65
|
-
},
|
|
66
|
-
"dependencies": {
|
|
67
|
-
"axios": "^1.7.4"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@plurix/ecom-components",
|
|
3
|
+
"author": "Plurix",
|
|
4
|
+
"private": false,
|
|
5
|
+
"version": "1.20.8",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "dist/main.js",
|
|
8
|
+
"types": "dist/main.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist"
|
|
11
|
+
],
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/plurix-ecommerce/ecom-components.git"
|
|
15
|
+
},
|
|
16
|
+
"sideEffects": [
|
|
17
|
+
"**/*.css"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"dev": "vite",
|
|
21
|
+
"build": "tsc --p ./tsconfig-build.json && vite build",
|
|
22
|
+
"format": "prettier --write .",
|
|
23
|
+
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
|
|
24
|
+
"prepare": "husky install",
|
|
25
|
+
"preview": "vite preview",
|
|
26
|
+
"test": "jest"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"react": "^18.2.0",
|
|
30
|
+
"react-dom": "^18.2.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@babel/preset-env": "^7.24.5",
|
|
34
|
+
"@babel/preset-react": "^7.24.1",
|
|
35
|
+
"@commitlint/cli": "^17.4.2",
|
|
36
|
+
"@commitlint/config-conventional": "^17.4.2",
|
|
37
|
+
"@jest/globals": "^29.7.0",
|
|
38
|
+
"@testing-library/jest-dom": "^6.4.5",
|
|
39
|
+
"@testing-library/react": "^15.0.7",
|
|
40
|
+
"@types/jest": "^29.5.12",
|
|
41
|
+
"@types/node": "^20.11.30",
|
|
42
|
+
"@types/react": "^18.2.71",
|
|
43
|
+
"@types/react-dom": "^18.2.22",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
45
|
+
"@typescript-eslint/parser": "^6.21.0",
|
|
46
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
47
|
+
"eslint": "^8.57.0",
|
|
48
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
49
|
+
"eslint-plugin-react-refresh": "^0.4.6",
|
|
50
|
+
"glob": "^10.3.10",
|
|
51
|
+
"husky": "^9.0.11",
|
|
52
|
+
"identity-obj-proxy": "^3.0.0",
|
|
53
|
+
"jest": "^29.7.0",
|
|
54
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
55
|
+
"jest-svg-transformer": "^1.0.0",
|
|
56
|
+
"prettier": "^2.2.1",
|
|
57
|
+
"react": "^18.2.0",
|
|
58
|
+
"react-dom": "^18.2.0",
|
|
59
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
60
|
+
"ts-jest": "^29.1.2",
|
|
61
|
+
"typescript": "^5.4.3",
|
|
62
|
+
"vite": "^4.5.3",
|
|
63
|
+
"vite-plugin-dts": "^3.7.3",
|
|
64
|
+
"vite-plugin-lib-inject-css": "^2.0.1"
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"axios": "^1.7.4"
|
|
68
|
+
}
|
|
69
|
+
}
|