employee-confirmation-modal 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/README.md ADDED
@@ -0,0 +1,138 @@
1
+ # Employee Confirmation Modal
2
+
3
+ Un composant React modal de confirmation pour la création d'employés, avec support du mode sombre, responsive et accessible.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install employee-confirmation-modal
9
+ ```
10
+
11
+ ## Utilisation
12
+
13
+ ```jsx
14
+ import React, { useState } from 'react';
15
+ import EmployeeConfirmationModal from 'employee-confirmation-modal';
16
+
17
+ function App() {
18
+ const [isModalOpen, setIsModalOpen] = useState(false);
19
+ const [employee, setEmployee] = useState({
20
+ firstName: 'Jean',
21
+ lastName: 'Dupont'
22
+ });
23
+
24
+ return (
25
+ <div>
26
+ <button onClick={() => setIsModalOpen(true)}>
27
+ Créer un employé
28
+ </button>
29
+
30
+ <EmployeeConfirmationModal
31
+ isOpen={isModalOpen}
32
+ onClose={() => setIsModalOpen(false)}
33
+ employee={employee}
34
+ title="Employé créé avec succès !"
35
+ />
36
+ </div>
37
+ );
38
+ }
39
+ ```
40
+
41
+ ## Props
42
+
43
+ | Prop | Type | Défaut | Description |
44
+ |------|------|--------|-------------|
45
+ | `isOpen` | `boolean` | `false` | État d'ouverture du modal |
46
+ | `onClose` | `function` | - | Fonction appelée à la fermeture |
47
+ | `employee` | `object` | `{}` | Données de l'employé `{firstName, lastName}` |
48
+ | `title` | `string` | `"Employé créé avec succès !"` | Titre du modal |
49
+ | `message` | `string` | - | Message personnalisé |
50
+ | `children` | `ReactNode` | - | Contenu personnalisé |
51
+ | `className` | `string` | `''` | Classes CSS additionnelles |
52
+
53
+ ## Fonctionnalités
54
+
55
+ - ✅ **Responsive** : Adapté mobile et desktop
56
+ - ✅ **Mode sombre** : Support automatique avec `:root.dark`
57
+ - ✅ **Accessible** : ARIA labels, navigation clavier
58
+ - ✅ **Animations** : FadeIn et SlideIn fluides
59
+ - ✅ **Fermeture** : Échap, clic overlay, bouton fermer
60
+
61
+ ## Mode sombre
62
+
63
+ Le modal supporte automatiquement le mode sombre. Ajoutez la classe `dark` à votre élément `:root` :
64
+
65
+ ```javascript
66
+ // Activer le mode sombre
67
+ document.documentElement.classList.add('dark');
68
+ ```
69
+
70
+ ## Scripts de développement
71
+
72
+ ```bash
73
+ # Build CommonJS
74
+ npm run build
75
+
76
+ # Build ES Modules
77
+ npm run build:esm
78
+
79
+ # Build les deux versions
80
+ npm run build:all
81
+
82
+ # Nettoyer les builds
83
+ npm run clean
84
+ ```
85
+
86
+ ## Licence
87
+
88
+ MIT
89
+
90
+ ### `npm run build`
91
+
92
+ Builds the app for production to the `build` folder.\
93
+ It correctly bundles React in production mode and optimizes the build for the best performance.
94
+
95
+ The build is minified and the filenames include the hashes.\
96
+ Your app is ready to be deployed!
97
+
98
+ See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
99
+
100
+ ### `npm run eject`
101
+
102
+ **Note: this is a one-way operation. Once you `eject`, you can't go back!**
103
+
104
+ If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
105
+
106
+ Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
107
+
108
+ You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
109
+
110
+ ## Learn More
111
+
112
+ You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
113
+
114
+ To learn React, check out the [React documentation](https://reactjs.org/).
115
+
116
+ ### Code Splitting
117
+
118
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
119
+
120
+ ### Analyzing the Bundle Size
121
+
122
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
123
+
124
+ ### Making a Progressive Web App
125
+
126
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
127
+
128
+ ### Advanced Configuration
129
+
130
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
131
+
132
+ ### Deployment
133
+
134
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
135
+
136
+ ### `npm run build` fails to minify
137
+
138
+ This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
package/esm/App.js ADDED
@@ -0,0 +1,43 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import EmployeeConfirmationModal from './confirmationModal.jsx';
4
+
5
+ // Exemple d'utilisation du modal
6
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
+ function App() {
8
+ const [isModalOpen, setIsModalOpen] = React.useState(false);
9
+ const [employee, setEmployee] = React.useState({
10
+ firstName: 'Jean',
11
+ lastName: 'Dupont'
12
+ });
13
+ const openModal = () => setIsModalOpen(true);
14
+ const closeModal = () => setIsModalOpen(false);
15
+ return /*#__PURE__*/_jsxs("div", {
16
+ style: {
17
+ padding: '20px',
18
+ fontFamily: 'Arial, sans-serif'
19
+ },
20
+ children: [/*#__PURE__*/_jsx("h1", {
21
+ children: "Demo - Modal de Confirmation d'Employ\xE9"
22
+ }), /*#__PURE__*/_jsx("button", {
23
+ onClick: openModal,
24
+ style: {
25
+ backgroundColor: '#4F46E5',
26
+ color: 'white',
27
+ padding: '10px 20px',
28
+ border: 'none',
29
+ borderRadius: '5px',
30
+ cursor: 'pointer',
31
+ fontSize: '16px'
32
+ },
33
+ children: "Cr\xE9er un employ\xE9"
34
+ }), /*#__PURE__*/_jsx(EmployeeConfirmationModal, {
35
+ isOpen: isModalOpen,
36
+ onClose: closeModal,
37
+ employee: employee,
38
+ title: "Employ\xE9 cr\xE9\xE9 avec succ\xE8s !"
39
+ })]
40
+ });
41
+ }
42
+ const root = ReactDOM.createRoot(document.getElementById('root'));
43
+ root.render(/*#__PURE__*/_jsx(App, {}));
@@ -0,0 +1,197 @@
1
+ /* Variables CSS pour la cohérence et la personnalisation */
2
+ :root {
3
+ --modal-overlay-bg: rgba(0, 0, 0, 0.6);
4
+ --modal-content-bg: white;
5
+ --modal-border-color: #d1d5db;
6
+ --modal-text-color: #374151;
7
+ --modal-header-bg: white;
8
+ --modal-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
9
+ --modal-border-radius: 12px;
10
+ --modal-backdrop-blur: 2px;
11
+ }
12
+
13
+ /* Variables pour le mode sombre */
14
+ :root.dark {
15
+ --modal-content-bg: #374151;
16
+ --modal-border-color: #6b7280;
17
+ --modal-text-color: #f3f4f6;
18
+ --modal-header-bg: #1f2937;
19
+ --modal-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
20
+ }
21
+
22
+ /* Overlay du modal */
23
+ .modal-overlay {
24
+ position: fixed;
25
+ top: 0;
26
+ left: 0;
27
+ right: 0;
28
+ bottom: 0;
29
+ background-color: var(--modal-overlay-bg);
30
+ display: flex;
31
+ justify-content: center;
32
+ align-items: center;
33
+ z-index: 1000;
34
+ backdrop-filter: blur(var(--modal-backdrop-blur));
35
+ animation: fadeIn 0.3s ease-out;
36
+ }
37
+
38
+ /* Contenu principal du modal */
39
+ .modal-content {
40
+ background-color: var(--modal-content-bg);
41
+ border-radius: var(--modal-border-radius);
42
+ box-shadow: var(--modal-shadow);
43
+ max-width: 500px;
44
+ width: 90%;
45
+ max-height: 90vh;
46
+ overflow: hidden;
47
+ animation: slideIn 0.3s ease-out;
48
+ border: 1px solid var(--modal-border-color);
49
+ outline: none;
50
+ }
51
+
52
+ /* En-tête du modal */
53
+ .modal-header {
54
+ padding: 1.5rem;
55
+ border-bottom: 1px solid var(--modal-border-color);
56
+ display: flex;
57
+ justify-content: space-between;
58
+ align-items: center;
59
+ background-color: var(--modal-header-bg);
60
+ color: var(--modal-text-color);
61
+ }
62
+
63
+ .modal-header h2 {
64
+ margin: 0;
65
+ font-size: 1.25rem;
66
+ font-weight: 600;
67
+ color: inherit;
68
+ }
69
+
70
+ /* Bouton de fermeture */
71
+ .modal-close {
72
+ background: none;
73
+ border: none;
74
+ font-size: 1.5rem;
75
+ cursor: pointer;
76
+ color: var(--modal-text-color);
77
+ opacity: 0.7;
78
+ transition: all 0.2s ease;
79
+ width: 30px;
80
+ height: 30px;
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ border-radius: 50%;
85
+ line-height: 1;
86
+ }
87
+
88
+ .modal-close:hover {
89
+ opacity: 1;
90
+ background-color: rgba(0, 0, 0, 0.1);
91
+ }
92
+
93
+ :root.dark .modal-close:hover {
94
+ background-color: rgba(255, 255, 255, 0.1);
95
+ }
96
+
97
+ .modal-close:focus {
98
+ outline: 2px solid #3b82f6;
99
+ outline-offset: 2px;
100
+ opacity: 1;
101
+ }
102
+
103
+ /* Corps du modal */
104
+ .modal-body {
105
+ padding: 1.5rem;
106
+ color: var(--modal-text-color);
107
+ }
108
+
109
+ .modal-body p {
110
+ margin: 0;
111
+ line-height: 1.6;
112
+ font-size: 1rem;
113
+ }
114
+
115
+ .modal-body strong {
116
+ font-weight: 600;
117
+ color: inherit;
118
+ }
119
+
120
+ /* Animations */
121
+ @keyframes fadeIn {
122
+ from {
123
+ opacity: 0;
124
+ }
125
+ to {
126
+ opacity: 1;
127
+ }
128
+ }
129
+
130
+ @keyframes slideIn {
131
+ from {
132
+ opacity: 0;
133
+ transform: translateY(-20px) scale(0.95);
134
+ }
135
+ to {
136
+ opacity: 1;
137
+ transform: translateY(0) scale(1);
138
+ }
139
+ }
140
+
141
+ /* Responsive design */
142
+ @media (max-width: 640px) {
143
+ .modal-content {
144
+ width: 95%;
145
+ margin: 1rem;
146
+ max-height: calc(100vh - 2rem);
147
+ }
148
+
149
+ .modal-header {
150
+ padding: 1rem;
151
+ }
152
+
153
+ .modal-header h2 {
154
+ font-size: 1.125rem;
155
+ }
156
+
157
+ .modal-body {
158
+ padding: 1rem;
159
+ }
160
+ }
161
+
162
+ @media (max-width: 480px) {
163
+ .modal-content {
164
+ width: 98%;
165
+ margin: 0.5rem;
166
+ }
167
+
168
+ .modal-header {
169
+ padding: 0.75rem;
170
+ }
171
+
172
+ .modal-body {
173
+ padding: 0.75rem;
174
+ }
175
+ }
176
+
177
+ /* Amélioration de l'accessibilité */
178
+ @media (prefers-reduced-motion: reduce) {
179
+ .modal-overlay,
180
+ .modal-content {
181
+ animation: none;
182
+ }
183
+ }
184
+
185
+ /* Focus visible pour l'accessibilité */
186
+ .modal-content:focus-visible {
187
+ outline: 2px solid #3b82f6;
188
+ outline-offset: -2px;
189
+ }
190
+
191
+ .modal-header {
192
+ padding: 1rem;
193
+ }
194
+
195
+ .modal-body {
196
+ padding: 1rem;
197
+ }
@@ -0,0 +1,88 @@
1
+ import { useEffect } from 'react';
2
+ import './ConfirmationModal.css';
3
+
4
+ /**
5
+ * Modal de confirmation pour création d'employé
6
+ * @param {Object} props
7
+ * @param {boolean} props.isOpen - État d'ouverture du modal
8
+ * @param {Function} props.onClose - Fonction de fermeture
9
+ * @param {Object} props.employee - Données de l'employé créé
10
+ * @param {string} props.title - Titre personnalisé (optionnel)
11
+ * @param {string} props.message - Message personnalisé (optionnel)
12
+ * @param {React.ReactNode} props.children - Contenu personnalisé (optionnel)
13
+ * @param {string} props.className - Classes CSS additionnelles
14
+ */
15
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
16
+ function EmployeeConfirmationModal({
17
+ isOpen = false,
18
+ onClose,
19
+ employee = {},
20
+ title = "Employé créé avec succès !",
21
+ message,
22
+ children,
23
+ className = ''
24
+ }) {
25
+ // Gestion de la touche Échap et scroll
26
+ useEffect(() => {
27
+ const handleEscape = event => {
28
+ if (event.key === 'Escape' && isOpen && onClose) {
29
+ onClose();
30
+ }
31
+ };
32
+ if (isOpen) {
33
+ document.addEventListener('keydown', handleEscape);
34
+ document.body.style.overflow = 'hidden';
35
+
36
+ // Focus sur le modal pour l'accessibilité
37
+ const modalElement = document.querySelector('.modal-content');
38
+ if (modalElement) {
39
+ modalElement.focus();
40
+ }
41
+ }
42
+ return () => {
43
+ document.removeEventListener('keydown', handleEscape);
44
+ document.body.style.overflow = 'unset';
45
+ };
46
+ }, [isOpen, onClose]);
47
+ if (!isOpen) return null;
48
+ const handleOverlayClick = e => {
49
+ if (e.target === e.currentTarget && onClose) {
50
+ onClose();
51
+ }
52
+ };
53
+ return /*#__PURE__*/_jsx("div", {
54
+ className: "modal-overlay",
55
+ onClick: handleOverlayClick,
56
+ role: "dialog",
57
+ "aria-modal": "true",
58
+ "aria-labelledby": "modal-title",
59
+ children: /*#__PURE__*/_jsxs("div", {
60
+ className: `modal-content ${className}`,
61
+ onClick: e => e.stopPropagation(),
62
+ tabIndex: -1,
63
+ children: [/*#__PURE__*/_jsxs("div", {
64
+ className: "modal-header",
65
+ children: [/*#__PURE__*/_jsx("h2", {
66
+ id: "modal-title",
67
+ children: title
68
+ }), /*#__PURE__*/_jsx("button", {
69
+ className: "modal-close",
70
+ onClick: onClose,
71
+ "aria-label": "Fermer le modal",
72
+ type: "button",
73
+ children: "\xD7"
74
+ })]
75
+ }), /*#__PURE__*/_jsx("div", {
76
+ className: "modal-body",
77
+ children: children || /*#__PURE__*/_jsx("p", {
78
+ children: message || /*#__PURE__*/_jsxs(_Fragment, {
79
+ children: ["L'employ\xE9 ", /*#__PURE__*/_jsxs("strong", {
80
+ children: [employee.firstName, " ", employee.lastName]
81
+ }), " a \xE9t\xE9 ajout\xE9 avec succ\xE8s."]
82
+ })
83
+ })
84
+ })]
85
+ })
86
+ });
87
+ }
88
+ export default EmployeeConfirmationModal;
package/esm/index.js ADDED
@@ -0,0 +1,21 @@
1
+ // Export principal
2
+ import EmployeeConfirmationModal from './confirmationModal.jsx';
3
+
4
+ // Export par défaut
5
+ export default EmployeeConfirmationModal;
6
+
7
+ // Export nommé pour compatibilité
8
+ export { EmployeeConfirmationModal };
9
+
10
+ // Export nommé alternatif pour plus de flexibilité
11
+ export { EmployeeConfirmationModal as ConfirmationModal };
12
+
13
+ // Export du CSS (optionnel, pour les bundlers qui le supportent)
14
+ export { default as ConfirmationModalStyles } from './confirmationModal.css';
15
+
16
+ // Compatibilité CommonJS pour les environnements Node.js
17
+ if (typeof module !== 'undefined' && module.exports) {
18
+ module.exports = EmployeeConfirmationModal;
19
+ module.exports.default = EmployeeConfirmationModal;
20
+ module.exports.EmployeeConfirmationModal = EmployeeConfirmationModal;
21
+ }
package/lib/App.js ADDED
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ var _react = _interopRequireDefault(require("react"));
4
+ var _client = _interopRequireDefault(require("react-dom/client"));
5
+ var _confirmationModal = _interopRequireDefault(require("./confirmationModal.jsx"));
6
+ var _jsxRuntime = require("react/jsx-runtime");
7
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
8
+ // Exemple d'utilisation du modal
9
+ function App() {
10
+ const [isModalOpen, setIsModalOpen] = _react.default.useState(false);
11
+ const [employee, setEmployee] = _react.default.useState({
12
+ firstName: 'Jean',
13
+ lastName: 'Dupont'
14
+ });
15
+ const openModal = () => setIsModalOpen(true);
16
+ const closeModal = () => setIsModalOpen(false);
17
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
18
+ style: {
19
+ padding: '20px',
20
+ fontFamily: 'Arial, sans-serif'
21
+ },
22
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
23
+ children: "Demo - Modal de Confirmation d'Employ\xE9"
24
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
25
+ onClick: openModal,
26
+ style: {
27
+ backgroundColor: '#4F46E5',
28
+ color: 'white',
29
+ padding: '10px 20px',
30
+ border: 'none',
31
+ borderRadius: '5px',
32
+ cursor: 'pointer',
33
+ fontSize: '16px'
34
+ },
35
+ children: "Cr\xE9er un employ\xE9"
36
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirmationModal.default, {
37
+ isOpen: isModalOpen,
38
+ onClose: closeModal,
39
+ employee: employee,
40
+ title: "Employ\xE9 cr\xE9\xE9 avec succ\xE8s !"
41
+ })]
42
+ });
43
+ }
44
+ const root = _client.default.createRoot(document.getElementById('root'));
45
+ root.render(/*#__PURE__*/(0, _jsxRuntime.jsx)(App, {}));
@@ -0,0 +1,197 @@
1
+ /* Variables CSS pour la cohérence et la personnalisation */
2
+ :root {
3
+ --modal-overlay-bg: rgba(0, 0, 0, 0.6);
4
+ --modal-content-bg: white;
5
+ --modal-border-color: #d1d5db;
6
+ --modal-text-color: #374151;
7
+ --modal-header-bg: white;
8
+ --modal-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
9
+ --modal-border-radius: 12px;
10
+ --modal-backdrop-blur: 2px;
11
+ }
12
+
13
+ /* Variables pour le mode sombre */
14
+ :root.dark {
15
+ --modal-content-bg: #374151;
16
+ --modal-border-color: #6b7280;
17
+ --modal-text-color: #f3f4f6;
18
+ --modal-header-bg: #1f2937;
19
+ --modal-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
20
+ }
21
+
22
+ /* Overlay du modal */
23
+ .modal-overlay {
24
+ position: fixed;
25
+ top: 0;
26
+ left: 0;
27
+ right: 0;
28
+ bottom: 0;
29
+ background-color: var(--modal-overlay-bg);
30
+ display: flex;
31
+ justify-content: center;
32
+ align-items: center;
33
+ z-index: 1000;
34
+ backdrop-filter: blur(var(--modal-backdrop-blur));
35
+ animation: fadeIn 0.3s ease-out;
36
+ }
37
+
38
+ /* Contenu principal du modal */
39
+ .modal-content {
40
+ background-color: var(--modal-content-bg);
41
+ border-radius: var(--modal-border-radius);
42
+ box-shadow: var(--modal-shadow);
43
+ max-width: 500px;
44
+ width: 90%;
45
+ max-height: 90vh;
46
+ overflow: hidden;
47
+ animation: slideIn 0.3s ease-out;
48
+ border: 1px solid var(--modal-border-color);
49
+ outline: none;
50
+ }
51
+
52
+ /* En-tête du modal */
53
+ .modal-header {
54
+ padding: 1.5rem;
55
+ border-bottom: 1px solid var(--modal-border-color);
56
+ display: flex;
57
+ justify-content: space-between;
58
+ align-items: center;
59
+ background-color: var(--modal-header-bg);
60
+ color: var(--modal-text-color);
61
+ }
62
+
63
+ .modal-header h2 {
64
+ margin: 0;
65
+ font-size: 1.25rem;
66
+ font-weight: 600;
67
+ color: inherit;
68
+ }
69
+
70
+ /* Bouton de fermeture */
71
+ .modal-close {
72
+ background: none;
73
+ border: none;
74
+ font-size: 1.5rem;
75
+ cursor: pointer;
76
+ color: var(--modal-text-color);
77
+ opacity: 0.7;
78
+ transition: all 0.2s ease;
79
+ width: 30px;
80
+ height: 30px;
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ border-radius: 50%;
85
+ line-height: 1;
86
+ }
87
+
88
+ .modal-close:hover {
89
+ opacity: 1;
90
+ background-color: rgba(0, 0, 0, 0.1);
91
+ }
92
+
93
+ :root.dark .modal-close:hover {
94
+ background-color: rgba(255, 255, 255, 0.1);
95
+ }
96
+
97
+ .modal-close:focus {
98
+ outline: 2px solid #3b82f6;
99
+ outline-offset: 2px;
100
+ opacity: 1;
101
+ }
102
+
103
+ /* Corps du modal */
104
+ .modal-body {
105
+ padding: 1.5rem;
106
+ color: var(--modal-text-color);
107
+ }
108
+
109
+ .modal-body p {
110
+ margin: 0;
111
+ line-height: 1.6;
112
+ font-size: 1rem;
113
+ }
114
+
115
+ .modal-body strong {
116
+ font-weight: 600;
117
+ color: inherit;
118
+ }
119
+
120
+ /* Animations */
121
+ @keyframes fadeIn {
122
+ from {
123
+ opacity: 0;
124
+ }
125
+ to {
126
+ opacity: 1;
127
+ }
128
+ }
129
+
130
+ @keyframes slideIn {
131
+ from {
132
+ opacity: 0;
133
+ transform: translateY(-20px) scale(0.95);
134
+ }
135
+ to {
136
+ opacity: 1;
137
+ transform: translateY(0) scale(1);
138
+ }
139
+ }
140
+
141
+ /* Responsive design */
142
+ @media (max-width: 640px) {
143
+ .modal-content {
144
+ width: 95%;
145
+ margin: 1rem;
146
+ max-height: calc(100vh - 2rem);
147
+ }
148
+
149
+ .modal-header {
150
+ padding: 1rem;
151
+ }
152
+
153
+ .modal-header h2 {
154
+ font-size: 1.125rem;
155
+ }
156
+
157
+ .modal-body {
158
+ padding: 1rem;
159
+ }
160
+ }
161
+
162
+ @media (max-width: 480px) {
163
+ .modal-content {
164
+ width: 98%;
165
+ margin: 0.5rem;
166
+ }
167
+
168
+ .modal-header {
169
+ padding: 0.75rem;
170
+ }
171
+
172
+ .modal-body {
173
+ padding: 0.75rem;
174
+ }
175
+ }
176
+
177
+ /* Amélioration de l'accessibilité */
178
+ @media (prefers-reduced-motion: reduce) {
179
+ .modal-overlay,
180
+ .modal-content {
181
+ animation: none;
182
+ }
183
+ }
184
+
185
+ /* Focus visible pour l'accessibilité */
186
+ .modal-content:focus-visible {
187
+ outline: 2px solid #3b82f6;
188
+ outline-offset: -2px;
189
+ }
190
+
191
+ .modal-header {
192
+ padding: 1rem;
193
+ }
194
+
195
+ .modal-body {
196
+ padding: 1rem;
197
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ require("./ConfirmationModal.css");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ /**
11
+ * Modal de confirmation pour création d'employé
12
+ * @param {Object} props
13
+ * @param {boolean} props.isOpen - État d'ouverture du modal
14
+ * @param {Function} props.onClose - Fonction de fermeture
15
+ * @param {Object} props.employee - Données de l'employé créé
16
+ * @param {string} props.title - Titre personnalisé (optionnel)
17
+ * @param {string} props.message - Message personnalisé (optionnel)
18
+ * @param {React.ReactNode} props.children - Contenu personnalisé (optionnel)
19
+ * @param {string} props.className - Classes CSS additionnelles
20
+ */function EmployeeConfirmationModal({
21
+ isOpen = false,
22
+ onClose,
23
+ employee = {},
24
+ title = "Employé créé avec succès !",
25
+ message,
26
+ children,
27
+ className = ''
28
+ }) {
29
+ // Gestion de la touche Échap et scroll
30
+ (0, _react.useEffect)(() => {
31
+ const handleEscape = event => {
32
+ if (event.key === 'Escape' && isOpen && onClose) {
33
+ onClose();
34
+ }
35
+ };
36
+ if (isOpen) {
37
+ document.addEventListener('keydown', handleEscape);
38
+ document.body.style.overflow = 'hidden';
39
+
40
+ // Focus sur le modal pour l'accessibilité
41
+ const modalElement = document.querySelector('.modal-content');
42
+ if (modalElement) {
43
+ modalElement.focus();
44
+ }
45
+ }
46
+ return () => {
47
+ document.removeEventListener('keydown', handleEscape);
48
+ document.body.style.overflow = 'unset';
49
+ };
50
+ }, [isOpen, onClose]);
51
+ if (!isOpen) return null;
52
+ const handleOverlayClick = e => {
53
+ if (e.target === e.currentTarget && onClose) {
54
+ onClose();
55
+ }
56
+ };
57
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
58
+ className: "modal-overlay",
59
+ onClick: handleOverlayClick,
60
+ role: "dialog",
61
+ "aria-modal": "true",
62
+ "aria-labelledby": "modal-title",
63
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
64
+ className: `modal-content ${className}`,
65
+ onClick: e => e.stopPropagation(),
66
+ tabIndex: -1,
67
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
68
+ className: "modal-header",
69
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
70
+ id: "modal-title",
71
+ children: title
72
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
73
+ className: "modal-close",
74
+ onClick: onClose,
75
+ "aria-label": "Fermer le modal",
76
+ type: "button",
77
+ children: "\xD7"
78
+ })]
79
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
80
+ className: "modal-body",
81
+ children: children || /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
82
+ children: message || /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
83
+ children: ["L'employ\xE9 ", /*#__PURE__*/(0, _jsxRuntime.jsxs)("strong", {
84
+ children: [employee.firstName, " ", employee.lastName]
85
+ }), " a \xE9t\xE9 ajout\xE9 avec succ\xE8s."]
86
+ })
87
+ })
88
+ })]
89
+ })
90
+ });
91
+ }
92
+ var _default = exports.default = EmployeeConfirmationModal;
package/lib/index.js ADDED
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "ConfirmationModal", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _confirmationModal.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "ConfirmationModalStyles", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _confirmationModal2.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "EmployeeConfirmationModal", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _confirmationModal.default;
22
+ }
23
+ });
24
+ exports.default = void 0;
25
+ var _confirmationModal = _interopRequireDefault(require("./confirmationModal.jsx"));
26
+ var _confirmationModal2 = _interopRequireDefault(require("./confirmationModal.css"));
27
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
+ // Export principal
29
+ // Export par défaut
30
+ var _default = exports.default = _confirmationModal.default; // Export nommé pour compatibilité
31
+ // Export nommé alternatif pour plus de flexibilité
32
+ // Export du CSS (optionnel, pour les bundlers qui le supportent)
33
+ // Compatibilité CommonJS pour les environnements Node.js
34
+ if (typeof module !== 'undefined' && module.exports) {
35
+ module.exports = _confirmationModal.default;
36
+ module.exports.default = _confirmationModal.default;
37
+ module.exports.EmployeeConfirmationModal = _confirmationModal.default;
38
+ }
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "employee-confirmation-modal",
3
+ "version": "1.0.0",
4
+ "description": "Modal de confirmation React pour création d'employé avec support dark mode et responsive",
5
+ "main": "lib/index.js",
6
+ "module": "esm/index.js",
7
+ "types": "lib/index.d.ts",
8
+ "files": [
9
+ "lib",
10
+ "esm",
11
+ "src"
12
+ ],
13
+ "scripts": {
14
+ "build": "babel src --out-dir lib --copy-files",
15
+ "build:esm": "babel src --out-dir esm --copy-files --env-name esm",
16
+ "build:all": "npm run build && npm run build:esm",
17
+ "prepublishOnly": "npm run build:all",
18
+ "clean": "rimraf lib esm"
19
+ },
20
+ "keywords": [
21
+ "react",
22
+ "modal",
23
+ "confirmation",
24
+ "employee",
25
+ "dark-mode",
26
+ "responsive",
27
+ "accessibility"
28
+ ],
29
+ "author": "Votre Nom",
30
+ "license": "MIT",
31
+ "peerDependencies": {
32
+ "react": ">=16.8.0",
33
+ "react-dom": ">=16.8.0"
34
+ },
35
+ "devDependencies": {
36
+ "@babel/cli": "^7.28.3",
37
+ "@babel/core": "^7.28.5",
38
+ "@babel/preset-env": "^7.28.5",
39
+ "@babel/preset-react": "^7.28.5",
40
+ "rimraf": "^5.0.10"
41
+ },
42
+ "engines": {
43
+ "node": ">=16.0.0"
44
+ },
45
+ "repository": {
46
+ "type": "git",
47
+ "url": "git+https://github.com/votre-username/employee-confirmation-modal.git"
48
+ },
49
+ "bugs": {
50
+ "url": "https://github.com/votre-username/employee-confirmation-modal/issues"
51
+ },
52
+ "homepage": "https://github.com/votre-username/employee-confirmation-modal#readme"
53
+ }
package/src/App.js ADDED
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom/client';
3
+ import EmployeeConfirmationModal from './confirmationModal.jsx';
4
+
5
+ // Exemple d'utilisation du modal
6
+ function App() {
7
+ const [isModalOpen, setIsModalOpen] = React.useState(false);
8
+ const [employee, setEmployee] = React.useState({
9
+ firstName: 'Jean',
10
+ lastName: 'Dupont'
11
+ });
12
+
13
+ const openModal = () => setIsModalOpen(true);
14
+ const closeModal = () => setIsModalOpen(false);
15
+
16
+ return (
17
+ <div style={{ padding: '20px', fontFamily: 'Arial, sans-serif' }}>
18
+ <h1>Demo - Modal de Confirmation d'Employé</h1>
19
+
20
+ <button
21
+ onClick={openModal}
22
+ style={{
23
+ backgroundColor: '#4F46E5',
24
+ color: 'white',
25
+ padding: '10px 20px',
26
+ border: 'none',
27
+ borderRadius: '5px',
28
+ cursor: 'pointer',
29
+ fontSize: '16px'
30
+ }}
31
+ >
32
+ Créer un employé
33
+ </button>
34
+
35
+ <EmployeeConfirmationModal
36
+ isOpen={isModalOpen}
37
+ onClose={closeModal}
38
+ employee={employee}
39
+ title="Employé créé avec succès !"
40
+ />
41
+ </div>
42
+ );
43
+ }
44
+
45
+ const root = ReactDOM.createRoot(document.getElementById('root'));
46
+ root.render(<App />);
@@ -0,0 +1,197 @@
1
+ /* Variables CSS pour la cohérence et la personnalisation */
2
+ :root {
3
+ --modal-overlay-bg: rgba(0, 0, 0, 0.6);
4
+ --modal-content-bg: white;
5
+ --modal-border-color: #d1d5db;
6
+ --modal-text-color: #374151;
7
+ --modal-header-bg: white;
8
+ --modal-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
9
+ --modal-border-radius: 12px;
10
+ --modal-backdrop-blur: 2px;
11
+ }
12
+
13
+ /* Variables pour le mode sombre */
14
+ :root.dark {
15
+ --modal-content-bg: #374151;
16
+ --modal-border-color: #6b7280;
17
+ --modal-text-color: #f3f4f6;
18
+ --modal-header-bg: #1f2937;
19
+ --modal-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
20
+ }
21
+
22
+ /* Overlay du modal */
23
+ .modal-overlay {
24
+ position: fixed;
25
+ top: 0;
26
+ left: 0;
27
+ right: 0;
28
+ bottom: 0;
29
+ background-color: var(--modal-overlay-bg);
30
+ display: flex;
31
+ justify-content: center;
32
+ align-items: center;
33
+ z-index: 1000;
34
+ backdrop-filter: blur(var(--modal-backdrop-blur));
35
+ animation: fadeIn 0.3s ease-out;
36
+ }
37
+
38
+ /* Contenu principal du modal */
39
+ .modal-content {
40
+ background-color: var(--modal-content-bg);
41
+ border-radius: var(--modal-border-radius);
42
+ box-shadow: var(--modal-shadow);
43
+ max-width: 500px;
44
+ width: 90%;
45
+ max-height: 90vh;
46
+ overflow: hidden;
47
+ animation: slideIn 0.3s ease-out;
48
+ border: 1px solid var(--modal-border-color);
49
+ outline: none;
50
+ }
51
+
52
+ /* En-tête du modal */
53
+ .modal-header {
54
+ padding: 1.5rem;
55
+ border-bottom: 1px solid var(--modal-border-color);
56
+ display: flex;
57
+ justify-content: space-between;
58
+ align-items: center;
59
+ background-color: var(--modal-header-bg);
60
+ color: var(--modal-text-color);
61
+ }
62
+
63
+ .modal-header h2 {
64
+ margin: 0;
65
+ font-size: 1.25rem;
66
+ font-weight: 600;
67
+ color: inherit;
68
+ }
69
+
70
+ /* Bouton de fermeture */
71
+ .modal-close {
72
+ background: none;
73
+ border: none;
74
+ font-size: 1.5rem;
75
+ cursor: pointer;
76
+ color: var(--modal-text-color);
77
+ opacity: 0.7;
78
+ transition: all 0.2s ease;
79
+ width: 30px;
80
+ height: 30px;
81
+ display: flex;
82
+ align-items: center;
83
+ justify-content: center;
84
+ border-radius: 50%;
85
+ line-height: 1;
86
+ }
87
+
88
+ .modal-close:hover {
89
+ opacity: 1;
90
+ background-color: rgba(0, 0, 0, 0.1);
91
+ }
92
+
93
+ :root.dark .modal-close:hover {
94
+ background-color: rgba(255, 255, 255, 0.1);
95
+ }
96
+
97
+ .modal-close:focus {
98
+ outline: 2px solid #3b82f6;
99
+ outline-offset: 2px;
100
+ opacity: 1;
101
+ }
102
+
103
+ /* Corps du modal */
104
+ .modal-body {
105
+ padding: 1.5rem;
106
+ color: var(--modal-text-color);
107
+ }
108
+
109
+ .modal-body p {
110
+ margin: 0;
111
+ line-height: 1.6;
112
+ font-size: 1rem;
113
+ }
114
+
115
+ .modal-body strong {
116
+ font-weight: 600;
117
+ color: inherit;
118
+ }
119
+
120
+ /* Animations */
121
+ @keyframes fadeIn {
122
+ from {
123
+ opacity: 0;
124
+ }
125
+ to {
126
+ opacity: 1;
127
+ }
128
+ }
129
+
130
+ @keyframes slideIn {
131
+ from {
132
+ opacity: 0;
133
+ transform: translateY(-20px) scale(0.95);
134
+ }
135
+ to {
136
+ opacity: 1;
137
+ transform: translateY(0) scale(1);
138
+ }
139
+ }
140
+
141
+ /* Responsive design */
142
+ @media (max-width: 640px) {
143
+ .modal-content {
144
+ width: 95%;
145
+ margin: 1rem;
146
+ max-height: calc(100vh - 2rem);
147
+ }
148
+
149
+ .modal-header {
150
+ padding: 1rem;
151
+ }
152
+
153
+ .modal-header h2 {
154
+ font-size: 1.125rem;
155
+ }
156
+
157
+ .modal-body {
158
+ padding: 1rem;
159
+ }
160
+ }
161
+
162
+ @media (max-width: 480px) {
163
+ .modal-content {
164
+ width: 98%;
165
+ margin: 0.5rem;
166
+ }
167
+
168
+ .modal-header {
169
+ padding: 0.75rem;
170
+ }
171
+
172
+ .modal-body {
173
+ padding: 0.75rem;
174
+ }
175
+ }
176
+
177
+ /* Amélioration de l'accessibilité */
178
+ @media (prefers-reduced-motion: reduce) {
179
+ .modal-overlay,
180
+ .modal-content {
181
+ animation: none;
182
+ }
183
+ }
184
+
185
+ /* Focus visible pour l'accessibilité */
186
+ .modal-content:focus-visible {
187
+ outline: 2px solid #3b82f6;
188
+ outline-offset: -2px;
189
+ }
190
+
191
+ .modal-header {
192
+ padding: 1rem;
193
+ }
194
+
195
+ .modal-body {
196
+ padding: 1rem;
197
+ }
@@ -0,0 +1,97 @@
1
+ import { useEffect } from 'react'
2
+ import './ConfirmationModal.css'
3
+
4
+ /**
5
+ * Modal de confirmation pour création d'employé
6
+ * @param {Object} props
7
+ * @param {boolean} props.isOpen - État d'ouverture du modal
8
+ * @param {Function} props.onClose - Fonction de fermeture
9
+ * @param {Object} props.employee - Données de l'employé créé
10
+ * @param {string} props.title - Titre personnalisé (optionnel)
11
+ * @param {string} props.message - Message personnalisé (optionnel)
12
+ * @param {React.ReactNode} props.children - Contenu personnalisé (optionnel)
13
+ * @param {string} props.className - Classes CSS additionnelles
14
+ */
15
+ function EmployeeConfirmationModal({
16
+ isOpen = false,
17
+ onClose,
18
+ employee = {},
19
+ title = "Employé créé avec succès !",
20
+ message,
21
+ children,
22
+ className = ''
23
+ }) {
24
+ // Gestion de la touche Échap et scroll
25
+ useEffect(() => {
26
+ const handleEscape = (event) => {
27
+ if (event.key === 'Escape' && isOpen && onClose) {
28
+ onClose()
29
+ }
30
+ }
31
+
32
+ if (isOpen) {
33
+ document.addEventListener('keydown', handleEscape)
34
+ document.body.style.overflow = 'hidden'
35
+
36
+ // Focus sur le modal pour l'accessibilité
37
+ const modalElement = document.querySelector('.modal-content')
38
+ if (modalElement) {
39
+ modalElement.focus()
40
+ }
41
+ }
42
+
43
+ return () => {
44
+ document.removeEventListener('keydown', handleEscape)
45
+ document.body.style.overflow = 'unset'
46
+ }
47
+ }, [isOpen, onClose])
48
+
49
+ if (!isOpen) return null
50
+
51
+ const handleOverlayClick = (e) => {
52
+ if (e.target === e.currentTarget && onClose) {
53
+ onClose()
54
+ }
55
+ }
56
+
57
+ return (
58
+ <div
59
+ className="modal-overlay"
60
+ onClick={handleOverlayClick}
61
+ role="dialog"
62
+ aria-modal="true"
63
+ aria-labelledby="modal-title"
64
+ >
65
+ <div
66
+ className={`modal-content ${className}`}
67
+ onClick={(e) => e.stopPropagation()}
68
+ tabIndex={-1}
69
+ >
70
+ <div className="modal-header">
71
+ <h2 id="modal-title">{title}</h2>
72
+ <button
73
+ className="modal-close"
74
+ onClick={onClose}
75
+ aria-label="Fermer le modal"
76
+ type="button"
77
+ >
78
+ &times;
79
+ </button>
80
+ </div>
81
+ <div className="modal-body">
82
+ {children || (
83
+ <p>
84
+ {message || (
85
+ <>
86
+ L'employé <strong>{employee.firstName} {employee.lastName}</strong> a été ajouté avec succès.
87
+ </>
88
+ )}
89
+ </p>
90
+ )}
91
+ </div>
92
+ </div>
93
+ </div>
94
+ )
95
+ }
96
+
97
+ export default EmployeeConfirmationModal
package/src/index.js ADDED
@@ -0,0 +1,21 @@
1
+ // Export principal
2
+ import EmployeeConfirmationModal from './confirmationModal.jsx';
3
+
4
+ // Export par défaut
5
+ export default EmployeeConfirmationModal;
6
+
7
+ // Export nommé pour compatibilité
8
+ export { EmployeeConfirmationModal };
9
+
10
+ // Export nommé alternatif pour plus de flexibilité
11
+ export { EmployeeConfirmationModal as ConfirmationModal };
12
+
13
+ // Export du CSS (optionnel, pour les bundlers qui le supportent)
14
+ export { default as ConfirmationModalStyles } from './confirmationModal.css';
15
+
16
+ // Compatibilité CommonJS pour les environnements Node.js
17
+ if (typeof module !== 'undefined' && module.exports) {
18
+ module.exports = EmployeeConfirmationModal;
19
+ module.exports.default = EmployeeConfirmationModal;
20
+ module.exports.EmployeeConfirmationModal = EmployeeConfirmationModal;
21
+ }