@portnet/ui 2.0.8 → 3.0.1

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.
Files changed (76) hide show
  1. package/package.json +1 -4
  2. package/dist/components/buttons/PuiButton.js +0 -146
  3. package/dist/components/buttons/PuiIconButton.js +0 -99
  4. package/dist/components/buttons/PuiNewUserButton.js +0 -121
  5. package/dist/components/common/PuiAlertContext.js +0 -13
  6. package/dist/components/common/StyledMuiButton.js +0 -49
  7. package/dist/components/common/StyledMuiTextField.js +0 -157
  8. package/dist/components/inputs/PuiAutocomplete.js +0 -353
  9. package/dist/components/inputs/PuiCheckbox.js +0 -310
  10. package/dist/components/inputs/PuiCheckboxGroup.js +0 -215
  11. package/dist/components/inputs/PuiCheckboxItem.js +0 -163
  12. package/dist/components/inputs/PuiDateField.js +0 -281
  13. package/dist/components/inputs/PuiDateTimeField.js +0 -397
  14. package/dist/components/inputs/PuiFileField.js +0 -338
  15. package/dist/components/inputs/PuiRadioGroup.js +0 -198
  16. package/dist/components/inputs/PuiRadioItem.js +0 -101
  17. package/dist/components/inputs/PuiSelect.js +0 -425
  18. package/dist/components/inputs/PuiTextField.js +0 -264
  19. package/dist/components/others/PuiBadge.js +0 -58
  20. package/dist/components/others/PuiChip.js +0 -291
  21. package/dist/components/others/PuiDialog.js +0 -112
  22. package/dist/components/others/PuiFormikForm.js +0 -71
  23. package/dist/components/others/PuiGrid.js +0 -23
  24. package/dist/components/others/PuiIcon.js +0 -93
  25. package/dist/components/others/PuiLoadingBackdrop.js +0 -32
  26. package/dist/components/others/PuiMainContainer.js +0 -42
  27. package/dist/components/others/PuiNavigation.js +0 -69
  28. package/dist/components/others/PuiSection.js +0 -99
  29. package/dist/components/others/PuiTooltip.js +0 -87
  30. package/dist/components/providers/PuiAlertProvider.js +0 -135
  31. package/dist/components/providers/PuiLocalizationProvider.js +0 -34
  32. package/dist/components/referentiel/common/ReferetielContext.js +0 -13
  33. package/dist/components/referentiel/common/constants/specificReferentielsApis.js +0 -22
  34. package/dist/components/referentiel/common/constants/specificReferentielsBaseColumns.js +0 -691
  35. package/dist/components/referentiel/common/constants/specificReferentielsBaseFilters.js +0 -598
  36. package/dist/components/referentiel/common/constants/specificReferentielsInitialValues.js +0 -80
  37. package/dist/components/referentiel/common/constants/specificReferentielsKeys.js +0 -18
  38. package/dist/components/referentiel/common/constants/specificReferentielsTitles.js +0 -22
  39. package/dist/components/referentiel/common/constants/specificReferentielsValidationSchemas.js +0 -86
  40. package/dist/components/referentiel/components/PuiBasePopupReferentielField.js +0 -357
  41. package/dist/components/referentiel/components/PuiCustomPopupReferentielField.js +0 -182
  42. package/dist/components/referentiel/components/PuiSimplePopupReferentielField.js +0 -326
  43. package/dist/components/referentiel/components/PuiSimpleReferentielField.js +0 -204
  44. package/dist/components/referentiel/components/PuiSpecificReferentielField.js +0 -328
  45. package/dist/components/referentiel/providers/PuiReferentielProvider.js +0 -67
  46. package/dist/components/tab/PuiTab.js +0 -25
  47. package/dist/components/tab/PuiTabs.js +0 -149
  48. package/dist/components/table/ActionPopover.js +0 -56
  49. package/dist/components/table/PuiTable.js +0 -688
  50. package/dist/components/table/PuiTableAction.js +0 -65
  51. package/dist/components/typography/PuiDefinition.js +0 -42
  52. package/dist/components/typography/PuiIndication.js +0 -81
  53. package/dist/components/typography/PuiMainTitle.js +0 -88
  54. package/dist/components/ui/dialogs/PuiSearchDialog.js +0 -255
  55. package/dist/components/ui/layout/Header.js +0 -253
  56. package/dist/components/ui/layout/Layout.js +0 -104
  57. package/dist/components/ui/layout/Sidebar.js +0 -193
  58. package/dist/components/ui/layout/index.js +0 -29
  59. package/dist/components/ui/pages/errors/PuiErrorBasePage.js +0 -73
  60. package/dist/components/ui/pages/errors/PuiForbiddenErrorPage.js +0 -36
  61. package/dist/components/ui/pages/errors/PuiNetworkErrorPage.js +0 -36
  62. package/dist/components/ui/pages/errors/PuiNotFoundErrorPage.js +0 -30
  63. package/dist/components/ui/pages/errors/PuiServerErrorPage.js +0 -37
  64. package/dist/components/ui/pages/general/PuiDefaultPage.js +0 -68
  65. package/dist/components/ui/pages/general/PuiSearchPage.js +0 -436
  66. package/dist/config/ThemeProvider.js +0 -32
  67. package/dist/config/apperance.js +0 -26
  68. package/dist/config/mapping.js +0 -26
  69. package/dist/config/referentiel.js +0 -10
  70. package/dist/config/styleUtils.js +0 -135
  71. package/dist/config/theme.js +0 -183
  72. package/dist/general/yupValidationErrors.js +0 -8
  73. package/dist/hooks/useAlert.js +0 -20
  74. package/dist/hooks/useAxios.js +0 -25
  75. package/dist/hooks/useQuery.js +0 -21
  76. package/dist/index.js +0 -434
@@ -1,688 +0,0 @@
1
- "use strict";
2
-
3
- require("core-js/modules/es.weak-map.js");
4
- require("core-js/modules/esnext.iterator.filter.js");
5
- require("core-js/modules/esnext.iterator.for-each.js");
6
- Object.defineProperty(exports, "__esModule", {
7
- value: true
8
- });
9
- exports.default = exports.PuiTableHeader = void 0;
10
- require("core-js/modules/es.array.includes.js");
11
- require("core-js/modules/es.regexp.to-string.js");
12
- require("core-js/modules/es.string.includes.js");
13
- require("core-js/modules/esnext.iterator.constructor.js");
14
- require("core-js/modules/esnext.iterator.map.js");
15
- require("core-js/modules/web.dom-collections.iterator.js");
16
- var _propTypes = _interopRequireDefault(require("prop-types"));
17
- var React = _interopRequireWildcard(require("react"));
18
- var _apperance = require("../../config/apperance");
19
- var _PuiTooltip = _interopRequireDefault(require("../others/PuiTooltip"));
20
- var _antd = require("antd");
21
- var _icons = require("@ant-design/icons");
22
- var _jsxRuntime = require("react/jsx-runtime");
23
- const _excluded = ["field", "headerName", "width", "renderCell", "sortable", "align"],
24
- _excluded2 = ["id", "className", "sx", "elevate", "rows", "rowCount", "columns", "paginationMode", "page", "pageSize", "checkboxSelection", "loading", "load", "stripped", "actions", "oneActionOnly", "onSelect", "onPageChange", "onPageSizeChange", "stickyColumns", "pinnedColumns", "getRowId", "onSelectionModelChange", "selectionModel", "onRowClick", "highlightHoveredRow", "stickyHeader", "hideFooter", "hideFooterPagination", "components", "componentsProps", "getRowClassName", "onActionClick", "rowHeight"];
25
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
26
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
27
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
28
- function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
29
- function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
30
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
31
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
32
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
33
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
34
- function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Styles personnalisés pour le tableau
35
- const tableCustomStyles = "\n /* Styles g\xE9n\xE9raux du tableau - inspir\xE9 du design de r\xE9f\xE9rence */\n .pui-table {\n border-radius: 8px;\n overflow: hidden;\n box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);\n background-color: #ffffff;\n }\n \n .pui-table .ant-table {\n border-radius: 8px;\n }\n \n /* En-t\xEAtes de colonnes */\n .pui-table .ant-table-thead > tr > th {\n background-color: #f9fafb;\n color: #374151;\n font-weight: 600;\n font-size: 0.875rem;\n padding: 12px 16px;\n border-bottom: 1px solid #e5e7eb;\n transition: background-color 0.2s;\n }\n \n .pui-table .ant-table-thead > tr > th:hover {\n background-color: #f3f4f6;\n }\n \n /* Cellules du tableau */\n .pui-table .ant-table-tbody > tr > td {\n padding: 12px 16px;\n border-bottom: 1px solid #f3f4f6;\n color: #111827;\n font-size: 0.875rem;\n transition: background-color 0.2s ease;\n white-space: normal !important;\n word-wrap: break-word !important;\n word-break: break-word !important;\n max-width: 300px;\n overflow: visible;\n line-height: 1.5;\n }\n \n /* Lignes altern\xE9es */\n .pui-table .ant-table-tbody > tr:nth-child(even) > td {\n background-color: #f9fafb;\n }\n \n .pui-table .ant-table-tbody > tr:nth-child(odd) > td {\n background-color: #ffffff;\n }\n \n /* Effet de survol */\n .pui-table .ant-table-tbody > tr:hover > td {\n background-color: #f3f4f6 !important;\n }\n \n /* Styles des lignes s\xE9lectionn\xE9es */\n .pui-table .ant-table-tbody > tr.ant-table-row-selected > td {\n background-color: rgba(59, 130, 246, 0.05);\n }\n \n .pui-table .ant-table-tbody > tr.ant-table-row-selected:hover > td {\n background-color: rgba(59, 130, 246, 0.1) !important;\n }\n \n /* Styles des statuts */\n .pui-table .status-badge {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n padding: 2px 8px;\n border-radius: 9999px;\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1.5;\n }\n \n .pui-table .status-badge.cancelled {\n background-color: #fee2e2;\n color: #b91c1c;\n }\n \n .pui-table .status-badge.delivered {\n background-color: #dcfce7;\n color: #15803d;\n }\n \n .pui-table .status-badge.ready {\n background-color: #e0f2fe;\n color: #0369a1;\n }\n \n .pui-table .status-badge.on-the-way {\n background-color: #fef3c7;\n color: #92400e;\n }\n \n /* Pagination */\n .pui-table-pagination {\n padding: 12px 16px;\n border-top: 1px solid #f3f4f6;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n \n .pui-table-pagination .ant-pagination {\n margin: 0;\n }\n \n .pui-table-pagination .ant-pagination-item,\n .pui-table-pagination .ant-pagination-prev button,\n .pui-table-pagination .ant-pagination-next button {\n border-radius: 6px;\n border: 1px solid #e5e7eb;\n height: 32px;\n min-width: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n }\n \n .pui-table-pagination .ant-pagination-item:hover,\n .pui-table-pagination .ant-pagination-prev:hover button,\n .pui-table-pagination .ant-pagination-next:hover button {\n border-color: #d1d5db;\n color: #4b5563;\n }\n \n .pui-table-pagination .ant-pagination-item-active {\n background-color: #3b82f6;\n border-color: #3b82f6;\n }\n \n .pui-table-pagination .ant-pagination-item-active a {\n color: white;\n }\n \n .pui-table-pagination .ant-pagination-item-active:hover {\n background-color: #2563eb;\n border-color: #2563eb;\n }\n \n /* Styles pour la colonne d'actions */\n .pui-table .actions-column {\n white-space: nowrap !important;\n overflow: visible !important;\n }\n \n .pui-table .action-button {\n padding: 4px 8px !important;\n margin: 0 2px !important;\n min-width: auto !important;\n height: 28px !important;\n line-height: 20px !important;\n transition: all 0.2s !important;\n }\n \n .pui-table .action-button:hover {\n background-color: rgba(24, 144, 255, 0.1) !important;\n color: #1890ff !important;\n }\n \n /* Bouton Cr\xE9er */\n .pui-create-button {\n background-color: #3b82f6;\n color: white;\n border: none;\n border-radius: 6px;\n padding: 8px 16px;\n font-weight: 500;\n display: flex;\n align-items: center;\n gap: 8px;\n transition: all 0.2s;\n }\n \n .pui-create-button:hover {\n background-color: #2563eb;\n }\n \n /* Titre de la page */\n .pui-table-title {\n font-size: 1.5rem;\n font-weight: 600;\n color: #111827;\n margin-bottom: 16px;\n }\n";
36
-
37
- // Injection des styles dans le document
38
- const injectStyles = () => {
39
- const styleId = 'pui-table-custom-styles';
40
-
41
- // Vérifie si les styles existent déjà
42
- if (!document.getElementById(styleId)) {
43
- const styleElement = document.createElement('style');
44
- styleElement.id = styleId;
45
- styleElement.innerHTML = tableCustomStyles;
46
- document.head.appendChild(styleElement);
47
- }
48
- };
49
-
50
- // Suppression des styles lors du démontage
51
- const removeStyles = () => {
52
- const styleElement = document.getElementById('pui-table-custom-styles');
53
- if (styleElement) {
54
- document.head.removeChild(styleElement);
55
- }
56
- };
57
-
58
- // Composant pour les boutons d'action
59
- const TableActions = _ref => {
60
- let {
61
- row,
62
- actions
63
- } = _ref;
64
- // Empêcher la propagation des événements au niveau du conteneur
65
- const handleContainerClick = e => {
66
- e.preventDefault();
67
- e.stopPropagation();
68
- };
69
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Space, {
70
- size: "small",
71
- onClick: handleContainerClick // Arrêter la propagation au niveau du conteneur
72
- ,
73
- onMouseDown: handleContainerClick // Capturer également les événements mousedown
74
- ,
75
- style: {
76
- display: 'inline-flex'
77
- },
78
- children: actions.map((action, index) => {
79
- // Si l'action a une condition et que la condition n'est pas remplie, ne pas afficher le bouton
80
- if (action.condition && !action.condition(row)) {
81
- return null;
82
- }
83
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
84
- title: action.tooltip || action.label,
85
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
86
- type: "text",
87
- icon: action.icon,
88
- onClick: e => {
89
- // Empêcher la propagation et le comportement par défaut
90
- e.preventDefault();
91
- e.stopPropagation();
92
- // Appeler la fonction onClick de l'action
93
- if (typeof action.onClick === 'function') {
94
- action.onClick(row);
95
- } else if (typeof action.action === 'function') {
96
- // Pour la rétrocompatibilité
97
- action.action(row);
98
- }
99
- },
100
- onMouseDown: e => {
101
- // Empêcher également la propagation des événements mousedown
102
- e.preventDefault();
103
- e.stopPropagation();
104
- },
105
- className: "action-button",
106
- "aria-label": action.label
107
- })
108
- }, index);
109
- })
110
- });
111
- };
112
-
113
- // Personnalisation des éléments vides
114
- const customRenderEmpty = () => /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
115
- style: {
116
- textAlign: 'center',
117
- padding: '20px 0'
118
- },
119
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("p", {
120
- children: "Aucune donn\xE9e \xE0 afficher"
121
- })
122
- });
123
-
124
- // Fonction pour rendre les badges de statut
125
- const renderStatusBadge = status => {
126
- if (!status) return null;
127
- const statusText = status.toString().toLowerCase();
128
- let className = 'status-badge';
129
- if (statusText.includes('cancel')) {
130
- className += ' cancelled';
131
- } else if (statusText.includes('deliver')) {
132
- className += ' delivered';
133
- } else if (statusText.includes('ready')) {
134
- className += ' ready';
135
- } else if (statusText.includes('way') || statusText.includes('progress')) {
136
- className += ' on-the-way';
137
- }
138
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
139
- className: className,
140
- children: status
141
- });
142
- };
143
-
144
- // Fonction pour transformer les colonnes et ajouter le rendu des badges de statut
145
- const transformColumns = columns => {
146
- return columns.map(column => {
147
- var _newColumn$title;
148
- const newColumn = _objectSpread({}, column);
149
-
150
- // Si c'est une colonne de statut, ajouter le rendu personnalisé
151
- if (newColumn.dataIndex === 'status' || newColumn.key === 'status' || ((_newColumn$title = newColumn.title) === null || _newColumn$title === void 0 ? void 0 : _newColumn$title.toString().toLowerCase()) === 'status') {
152
- newColumn.render = text => renderStatusBadge(text);
153
- }
154
-
155
- // Ajouter d'autres transformations si nécessaire
156
-
157
- return newColumn;
158
- });
159
- };
160
-
161
- // Convertir les colonnes du format DataGrid au format Ant Design
162
- const convertColumns = (columns, onActionClick, actions) => {
163
- if (!columns) return [];
164
- const antColumns = columns.map(column => {
165
- const {
166
- field,
167
- headerName,
168
- width,
169
- renderCell,
170
- sortable,
171
- align
172
- } = column,
173
- rest = _objectWithoutProperties(column, _excluded);
174
-
175
- // Fonction de rendu par défaut pour gérer les textes longs
176
- const defaultRender = (text, record) => {
177
- if (text === null || text === undefined) return "-";
178
- const textStr = String(text);
179
- const shouldShowTooltip = textStr.length > 30;
180
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
181
- title: shouldShowTooltip ? textStr : "",
182
- placement: "topLeft",
183
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
184
- style: {
185
- whiteSpace: 'normal',
186
- wordWrap: 'break-word',
187
- wordBreak: 'break-word',
188
- overflow: 'hidden',
189
- textOverflow: 'ellipsis',
190
- lineHeight: '1.5',
191
- maxHeight: '4.5em',
192
- // Environ 3 lignes
193
- display: '-webkit-box',
194
- WebkitLineClamp: 3,
195
- WebkitBoxOrient: 'vertical'
196
- },
197
- children: textStr
198
- })
199
- });
200
- };
201
- return _objectSpread({
202
- title: headerName,
203
- dataIndex: field,
204
- key: field,
205
- width,
206
- sorter: sortable,
207
- align: align || 'left',
208
- render: renderCell ? (text, record) => renderCell({
209
- row: record,
210
- value: text
211
- }) : defaultRender
212
- }, rest);
213
- });
214
-
215
- // Ajouter une colonne d'actions si des actions sont fournies
216
- if (actions && actions.length > 0) {
217
- antColumns.push({
218
- title: 'Actions',
219
- key: 'actions',
220
- width: 100,
221
- align: 'center',
222
- render: (_, record) => /*#__PURE__*/(0, _jsxRuntime.jsx)(TableActions, {
223
- row: record,
224
- actions: actions
225
- }),
226
- // Empêcher le tri sur la colonne d'actions
227
- sorter: false,
228
- // Empêcher le filtrage sur la colonne d'actions
229
- filterable: false
230
- });
231
- }
232
-
233
- // Appliquer les transformations pour les badges de statut et autres styles
234
- return transformColumns(antColumns);
235
- };
236
-
237
- // Composant de pagination ergonomique personnalisé
238
- const PuiTablePagination = _ref2 => {
239
- let {
240
- current,
241
- pageSize,
242
- total,
243
- onChange
244
- } = _ref2;
245
- // Calculer le nombre total de pages
246
- const totalPages = Math.ceil(total / pageSize);
247
-
248
- // Calculer la plage d'éléments affichés
249
- const startItem = (current - 1) * pageSize + 1;
250
- const endItem = Math.min(current * pageSize, total);
251
-
252
- // Fonction pour aller à la page précédente
253
- const goToPrevPage = () => {
254
- if (current > 1) {
255
- onChange(current - 1, pageSize);
256
- }
257
- };
258
-
259
- // Fonction pour aller à la page suivante
260
- const goToNextPage = () => {
261
- if (current < totalPages) {
262
- onChange(current + 1, pageSize);
263
- }
264
- };
265
-
266
- // Fonction pour générer les numéros de page à afficher
267
- const getPageNumbers = () => {
268
- const pages = [];
269
- const maxVisiblePages = 5; // Nombre maximum de pages visibles
270
-
271
- // Toujours afficher la première page
272
- pages.push(1);
273
-
274
- // Calculer la plage de pages à afficher
275
- let startPage = Math.max(2, current - Math.floor(maxVisiblePages / 2));
276
- let endPage = Math.min(totalPages - 1, startPage + maxVisiblePages - 3);
277
-
278
- // Ajuster la plage si nécessaire
279
- if (endPage < startPage) {
280
- endPage = startPage;
281
- }
282
-
283
- // Ajouter des ellipses si nécessaire
284
- if (startPage > 2) {
285
- pages.push('ellipsis1');
286
- }
287
-
288
- // Ajouter les pages intermédiaires
289
- for (let i = startPage; i <= endPage; i++) {
290
- pages.push(i);
291
- }
292
-
293
- // Ajouter des ellipses si nécessaire
294
- if (endPage < totalPages - 1) {
295
- pages.push('ellipsis2');
296
- }
297
-
298
- // Toujours afficher la dernière page si elle existe
299
- if (totalPages > 1) {
300
- pages.push(totalPages);
301
- }
302
- return pages;
303
- };
304
-
305
- // Style pour les boutons de pagination
306
- const buttonStyle = {
307
- display: 'flex',
308
- alignItems: 'center',
309
- justifyContent: 'center',
310
- width: '32px',
311
- height: '32px',
312
- margin: '0 4px',
313
- borderRadius: '4px',
314
- border: '1px solid #d9d9d9',
315
- backgroundColor: '#fff',
316
- cursor: 'pointer',
317
- transition: 'all 0.2s',
318
- color: '#666',
319
- fontWeight: 'normal',
320
- fontSize: '14px',
321
- lineHeight: '32px',
322
- userSelect: 'none'
323
- };
324
-
325
- // Style pour le bouton de page active
326
- const activeButtonStyle = _objectSpread(_objectSpread({}, buttonStyle), {}, {
327
- backgroundColor: '#1890ff',
328
- borderColor: '#1890ff',
329
- color: '#fff',
330
- fontWeight: 'bold'
331
- });
332
-
333
- // Style pour les boutons désactivés
334
- const disabledButtonStyle = _objectSpread(_objectSpread({}, buttonStyle), {}, {
335
- cursor: 'not-allowed',
336
- color: '#d9d9d9',
337
- backgroundColor: '#f5f5f5'
338
- });
339
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
340
- style: {
341
- display: 'flex',
342
- alignItems: 'center',
343
- justifyContent: 'space-between'
344
- },
345
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
346
- style: {
347
- fontSize: '14px',
348
- color: '#666'
349
- },
350
- children: ["Affichage de ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
351
- children: startItem
352
- }), " \xE0 ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
353
- children: endItem
354
- }), " sur ", /*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
355
- children: total
356
- }), " \xE9l\xE9ments"]
357
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
358
- style: {
359
- display: 'flex',
360
- alignItems: 'center'
361
- },
362
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
363
- style: current === 1 ? disabledButtonStyle : buttonStyle,
364
- onClick: current === 1 ? undefined : goToPrevPage,
365
- title: "Page pr\xE9c\xE9dente",
366
- children: "<"
367
- }), getPageNumbers().map((page, index) => {
368
- if (page === 'ellipsis1' || page === 'ellipsis2') {
369
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
370
- style: _objectSpread(_objectSpread({}, buttonStyle), {}, {
371
- border: 'none',
372
- cursor: 'default'
373
- }),
374
- children: "..."
375
- }, page);
376
- }
377
- return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
378
- style: page === current ? activeButtonStyle : buttonStyle,
379
- onClick: () => page !== current && onChange(page, pageSize),
380
- children: page
381
- }, page);
382
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
383
- style: current === totalPages ? disabledButtonStyle : buttonStyle,
384
- onClick: current === totalPages ? undefined : goToNextPage,
385
- title: "Page suivante",
386
- children: ">"
387
- })]
388
- })]
389
- });
390
- };
391
-
392
- // Composant principal PuiTable avec Ant Design
393
- const PuiTable = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
394
- let {
395
- id,
396
- className,
397
- sx,
398
- elevate,
399
- rows,
400
- rowCount,
401
- columns,
402
- paginationMode,
403
- page,
404
- pageSize,
405
- checkboxSelection,
406
- loading,
407
- load,
408
- stripped,
409
- actions,
410
- oneActionOnly,
411
- onSelect,
412
- onPageChange,
413
- onPageSizeChange,
414
- stickyColumns = [],
415
- pinnedColumns,
416
- getRowId,
417
- onSelectionModelChange,
418
- selectionModel,
419
- onRowClick,
420
- highlightHoveredRow,
421
- stickyHeader,
422
- hideFooter,
423
- hideFooterPagination,
424
- components,
425
- componentsProps,
426
- getRowClassName,
427
- onActionClick,
428
- rowHeight = 'auto'
429
- } = _ref3,
430
- rest = _objectWithoutProperties(_ref3, _excluded2);
431
- // Convertir les colonnes au format Ant Design
432
- const antColumns = React.useMemo(() => convertColumns(columns, onActionClick, actions), [columns, onActionClick, actions]);
433
-
434
- // Gérer la sélection
435
- const [selectedRowKeys, setSelectedRowKeys] = React.useState([]);
436
- const onSelectChange = newSelectedRowKeys => {
437
- setSelectedRowKeys(newSelectedRowKeys);
438
- if (onSelect) {
439
- onSelect(newSelectedRowKeys);
440
- }
441
- };
442
-
443
- // Configuration des lignes sélectionnables
444
- const rowSelection = checkboxSelection ? {
445
- selectedRowKeys,
446
- onChange: onSelectChange
447
- } : undefined;
448
-
449
- // Gérer le changement de page
450
- const handlePageChange = (newPage, newPageSize) => {
451
- if (onPageChange) {
452
- // Ant Design utilise une pagination 1-indexed, mais nous gardons notre convention 0-indexed
453
- onPageChange(newPage - 1);
454
- }
455
- if (onPageSizeChange && pageSize !== newPageSize) {
456
- onPageSizeChange(newPageSize);
457
- }
458
- };
459
-
460
- // Configurer les colonnes sticky
461
- const configuredColumns = React.useMemo(() => {
462
- if (!stickyColumns || stickyColumns.length === 0) return antColumns;
463
- return antColumns.map(column => {
464
- if (stickyColumns.includes(column.dataIndex) || stickyColumns.includes(column.key)) {
465
- return _objectSpread(_objectSpread({}, column), {}, {
466
- fixed: 'left'
467
- });
468
- }
469
- return column;
470
- });
471
- }, [antColumns, stickyColumns]);
472
-
473
- // Style du tableau
474
- const tableStyle = _objectSpread(_objectSpread({
475
- fontSize: '0.85em'
476
- }, elevate ? {
477
- boxShadow: '0 2px 8px rgba(0,0,0,0.07)'
478
- } : {}), sx || {});
479
-
480
- // Style pour les lignes du tableau
481
- const rowStyle = {
482
- height: rowHeight,
483
- minHeight: rowHeight === 'auto' ? '60px' : rowHeight
484
- };
485
-
486
- // Injection des styles CSS personnalisés
487
- React.useEffect(() => {
488
- injectStyles();
489
- return () => removeStyles();
490
- }, []);
491
-
492
- // Mettre à jour les lignes sélectionnées lorsque selectionModel change
493
- React.useEffect(() => {
494
- if (selectionModel) {
495
- setSelectedRowKeys(selectionModel);
496
- }
497
- }, [selectionModel]);
498
-
499
- // Gérer le changement de sélection
500
- const handleSelectionChange = newSelectedRowKeys => {
501
- setSelectedRowKeys(newSelectedRowKeys);
502
- if (onSelectionModelChange) {
503
- onSelectionModelChange(newSelectedRowKeys);
504
- }
505
- };
506
-
507
- // Gérer le clic sur une ligne
508
- const handleRowClick = record => {
509
- if (onRowClick) {
510
- onRowClick(record);
511
- }
512
- };
513
-
514
- // Obtenir les propriétés de ligne (pour les événements et les classes)
515
- const getRowProps = record => {
516
- const rowId = getRowId ? getRowId(record) : record.id;
517
- const isSelected = selectedRowKeys.includes(rowId);
518
- return {
519
- onClick: e => {
520
- // Ne déclencher le clic sur la ligne que si l'événement n'a pas été arrêté par un enfant
521
- if (!e.isPropagationStopped() && onRowClick) {
522
- onRowClick(record);
523
- }
524
- },
525
- className: "".concat(getRowClassName ? getRowClassName(record) : '', " ").concat(isSelected ? 'ant-table-row-selected' : ''),
526
- style: {
527
- cursor: onRowClick ? 'pointer' : 'default'
528
- }
529
- };
530
- };
531
-
532
- // Calculer le nombre total de pages
533
- const totalPages = Math.ceil(rowCount / pageSize);
534
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.ConfigProvider, {
535
- theme: {
536
- components: {
537
- Table: {
538
- headerBg: '#f9fafb',
539
- headerColor: '#374151',
540
- borderColor: '#f3f4f6',
541
- rowHoverBg: '#f3f4f6'
542
- }
543
- }
544
- },
545
- children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_antd.Spin, {
546
- spinning: loading || load,
547
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Table, _objectSpread({
548
- ref: ref,
549
- id: id,
550
- className: "pui-table ".concat(className || '', " ").concat(stripped ? 'table-stripped' : ''),
551
- columns: configuredColumns,
552
- dataSource: rows.map(row => _objectSpread(_objectSpread({}, row), {}, {
553
- key: row.id || row.key || Math.random().toString(36).substr(2, 9)
554
- })),
555
- pagination: false,
556
- rowSelection: rowSelection,
557
- size: "small",
558
- bordered: true,
559
- style: tableStyle,
560
- scroll: {
561
- x: 'max-content'
562
- },
563
- rowClassName: (record, index) => {
564
- let className = index % 2 === 0 ? 'ant-table-row-light' : 'ant-table-row-dark';
565
- if (record.isEditing) className += ' ant-table-row-editing';
566
- return className;
567
- },
568
- onRow: record => _objectSpread(_objectSpread({}, getRowProps(record)), {}, {
569
- style: rowStyle
570
- })
571
- }, rest)), !hideFooter && !hideFooterPagination && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
572
- className: "pui-table-pagination",
573
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiTablePagination, {
574
- current: page + 1,
575
- pageSize: pageSize,
576
- total: rowCount,
577
- onChange: (newPage, newPageSize) => {
578
- if (newPageSize !== pageSize) {
579
- onPageSizeChange && onPageSizeChange(newPageSize);
580
- } else {
581
- onPageChange && onPageChange(newPage - 1);
582
- }
583
- }
584
- })
585
- })]
586
- })
587
- });
588
- });
589
- PuiTable.propTypes = {
590
- id: _propTypes.default.string,
591
- className: _propTypes.default.string,
592
- sx: _propTypes.default.object,
593
- elevate: _propTypes.default.bool,
594
- stripped: _propTypes.default.bool,
595
- oneActionOnly: _propTypes.default.bool,
596
- rows: _propTypes.default.arrayOf(_propTypes.default.object),
597
- rowCount: _propTypes.default.number,
598
- columns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
599
- page: _propTypes.default.number,
600
- pageSize: _propTypes.default.number,
601
- actions: _propTypes.default.arrayOf(_propTypes.default.shape({
602
- title: _propTypes.default.string,
603
- icon: _propTypes.default.element,
604
- action: _propTypes.default.func.isRequired
605
- })),
606
- checkboxSelection: _propTypes.default.bool,
607
- paginationMode: _propTypes.default.oneOf(["client", "server", "none"]),
608
- loading: _propTypes.default.bool,
609
- load: _propTypes.default.bool,
610
- onSelect: _propTypes.default.func,
611
- onPageChange: _propTypes.default.func,
612
- onPageSizeChange: _propTypes.default.func,
613
- stickyColumns: _propTypes.default.arrayOf(_propTypes.default.string),
614
- pinnedColumns: _propTypes.default.object,
615
- getRowId: _propTypes.default.func,
616
- onSelectionModelChange: _propTypes.default.func,
617
- selectionModel: _propTypes.default.array,
618
- onRowClick: _propTypes.default.func,
619
- highlightHoveredRow: _propTypes.default.bool,
620
- stickyHeader: _propTypes.default.bool,
621
- hideFooter: _propTypes.default.bool,
622
- hideFooterPagination: _propTypes.default.bool,
623
- components: _propTypes.default.object,
624
- componentsProps: _propTypes.default.object,
625
- getRowClassName: _propTypes.default.func,
626
- onActionClick: _propTypes.default.func,
627
- rowHeight: _propTypes.default.string
628
- };
629
- PuiTable.defaultProps = {
630
- oneActionOnly: false,
631
- elevate: true,
632
- pageSize: 5,
633
- page: 0,
634
- paginationMode: "client",
635
- stripped: false,
636
- actions: [],
637
- stickyColumns: [],
638
- rows: [],
639
- getRowId: null,
640
- onSelectionModelChange: null,
641
- selectionModel: null,
642
- onRowClick: null,
643
- highlightHoveredRow: false,
644
- stickyHeader: false,
645
- hideFooter: false,
646
- hideFooterPagination: false,
647
- components: null,
648
- componentsProps: null,
649
- getRowClassName: null,
650
- onActionClick: null,
651
- rowHeight: 'auto',
652
- loading: false,
653
- load: false
654
- };
655
-
656
- // Composant pour l'en-tête de la table avec titre et bouton de création
657
- const PuiTableHeader = _ref4 => {
658
- let {
659
- title,
660
- onCreateClick,
661
- createButtonText = "Create"
662
- } = _ref4;
663
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
664
- style: {
665
- display: 'flex',
666
- justifyContent: 'space-between',
667
- alignItems: 'center',
668
- marginBottom: '16px'
669
- },
670
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h1", {
671
- className: "pui-table-title",
672
- children: title
673
- }), onCreateClick && /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Button, {
674
- type: "primary",
675
- onClick: onCreateClick,
676
- className: "pui-create-button",
677
- icon: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
678
- style: {
679
- marginRight: '4px'
680
- },
681
- children: "+"
682
- }),
683
- children: createButtonText
684
- })]
685
- });
686
- };
687
- exports.PuiTableHeader = PuiTableHeader;
688
- var _default = exports.default = PuiTable;