@portnet/ui 2.0.7 → 2.0.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.
- package/dist/components/buttons/PuiNewUserButton.js +121 -0
- package/dist/components/inputs/PuiSelect.js +14 -2
- package/dist/components/others/PuiChip.js +254 -114
- package/dist/components/table/PuiTable.js +50 -8
- package/dist/components/ui/layout/Header.js +253 -0
- package/dist/components/ui/layout/Layout.js +104 -0
- package/dist/components/ui/layout/Sidebar.js +193 -0
- package/dist/components/ui/layout/index.js +29 -0
- package/dist/index.js +37 -1
- package/package.json +1 -1
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/esnext.iterator.constructor.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 = void 0;
|
|
10
|
+
var _react = _interopRequireDefault(require("react"));
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var _styles = require("@mui/material/styles");
|
|
13
|
+
var _material = require("@mui/material");
|
|
14
|
+
var _iconsMaterial = require("@mui/icons-material");
|
|
15
|
+
var _apperance = require("../../config/apperance");
|
|
16
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
|
+
const _excluded = ["onClick", "label", "size", "iconOnly"]; // Bouton stylisé pour "Nouvel utilisateur"
|
|
18
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
19
|
+
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; }
|
|
20
|
+
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; }
|
|
21
|
+
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; }
|
|
22
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
23
|
+
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); }
|
|
24
|
+
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; }
|
|
25
|
+
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; }
|
|
26
|
+
const StyledButton = (0, _styles.styled)(_material.Button)(_ref => {
|
|
27
|
+
let {
|
|
28
|
+
theme,
|
|
29
|
+
size
|
|
30
|
+
} = _ref;
|
|
31
|
+
return {
|
|
32
|
+
backgroundColor: _apperance.palette.primary,
|
|
33
|
+
color: _apperance.palette.white,
|
|
34
|
+
fontWeight: 500,
|
|
35
|
+
padding: size === 'small' ? '4px 12px' : '8px 16px',
|
|
36
|
+
borderRadius: '4px',
|
|
37
|
+
textTransform: 'none',
|
|
38
|
+
// Pas de majuscules forcées
|
|
39
|
+
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)',
|
|
40
|
+
'&:hover': {
|
|
41
|
+
backgroundColor: "".concat(_apperance.palette.primary, "e0"),
|
|
42
|
+
// Légèrement plus clair au survol
|
|
43
|
+
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.15)'
|
|
44
|
+
},
|
|
45
|
+
'& .MuiButton-startIcon': {
|
|
46
|
+
marginRight: size === 'small' ? '4px' : '8px'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Bouton compact (icône uniquement)
|
|
52
|
+
const CompactButton = (0, _styles.styled)(_material.Button)(_ref2 => {
|
|
53
|
+
let {
|
|
54
|
+
theme
|
|
55
|
+
} = _ref2;
|
|
56
|
+
return {
|
|
57
|
+
backgroundColor: _apperance.palette.primary,
|
|
58
|
+
color: _apperance.palette.white,
|
|
59
|
+
minWidth: '36px',
|
|
60
|
+
width: '36px',
|
|
61
|
+
height: '36px',
|
|
62
|
+
padding: '8px',
|
|
63
|
+
borderRadius: '4px',
|
|
64
|
+
boxShadow: '0 2px 4px rgba(0, 0, 0, 0.1)',
|
|
65
|
+
'&:hover': {
|
|
66
|
+
backgroundColor: "".concat(_apperance.palette.primary, "e0"),
|
|
67
|
+
boxShadow: '0 4px 8px rgba(0, 0, 0, 0.15)'
|
|
68
|
+
},
|
|
69
|
+
'& .MuiSvgIcon-root': {
|
|
70
|
+
fontSize: '1.2rem'
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Composant PuiNewUserButton - Bouton stylisé pour ajouter un nouvel utilisateur
|
|
77
|
+
* @param {Object} props - Propriétés du composant
|
|
78
|
+
* @param {function} props.onClick - Fonction appelée lors du clic sur le bouton
|
|
79
|
+
* @param {string} props.label - Texte du bouton
|
|
80
|
+
* @param {string} props.size - Taille du bouton ('small', 'medium', 'large')
|
|
81
|
+
* @param {boolean} props.iconOnly - Si true, affiche uniquement l'icône
|
|
82
|
+
*/
|
|
83
|
+
const PuiNewUserButton = _ref3 => {
|
|
84
|
+
let {
|
|
85
|
+
onClick,
|
|
86
|
+
label = "Nouvel utilisateur",
|
|
87
|
+
size = 'medium',
|
|
88
|
+
iconOnly = false
|
|
89
|
+
} = _ref3,
|
|
90
|
+
props = _objectWithoutProperties(_ref3, _excluded);
|
|
91
|
+
// Si iconOnly est true, on affiche un bouton compact avec une infobulle
|
|
92
|
+
if (iconOnly) {
|
|
93
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Tooltip, {
|
|
94
|
+
title: label,
|
|
95
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(CompactButton, _objectSpread(_objectSpread({
|
|
96
|
+
variant: "contained",
|
|
97
|
+
onClick: onClick,
|
|
98
|
+
"aria-label": label
|
|
99
|
+
}, props), {}, {
|
|
100
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.Add, {})
|
|
101
|
+
}))
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Sinon, on affiche le bouton standard avec texte et icône
|
|
106
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledButton, _objectSpread(_objectSpread({
|
|
107
|
+
variant: "contained",
|
|
108
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_iconsMaterial.Add, {}),
|
|
109
|
+
onClick: onClick,
|
|
110
|
+
size: size
|
|
111
|
+
}, props), {}, {
|
|
112
|
+
children: label
|
|
113
|
+
}));
|
|
114
|
+
};
|
|
115
|
+
PuiNewUserButton.propTypes = {
|
|
116
|
+
onClick: _propTypes.default.func,
|
|
117
|
+
label: _propTypes.default.string,
|
|
118
|
+
size: _propTypes.default.oneOf(['small', 'medium', 'large']),
|
|
119
|
+
iconOnly: _propTypes.default.bool
|
|
120
|
+
};
|
|
121
|
+
var _default = exports.default = PuiNewUserButton;
|
|
@@ -128,11 +128,23 @@ const StyledMuiFormControl = (0, _styles.styled)(/*#__PURE__*/React.forwardRef((
|
|
|
128
128
|
});
|
|
129
129
|
const LoadingProgress = () => {
|
|
130
130
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
|
|
131
|
-
size:
|
|
131
|
+
size: 20,
|
|
132
|
+
thickness: 4,
|
|
132
133
|
sx: {
|
|
133
134
|
color: _apperance.palette.primary,
|
|
134
135
|
position: "absolute",
|
|
135
|
-
right: "14px"
|
|
136
|
+
right: "14px",
|
|
137
|
+
top: "calc(50% - 10px)",
|
|
138
|
+
opacity: 0.7,
|
|
139
|
+
animation: "spin 1.5s linear infinite",
|
|
140
|
+
"@keyframes spin": {
|
|
141
|
+
"0%": {
|
|
142
|
+
transform: "rotate(0deg)"
|
|
143
|
+
},
|
|
144
|
+
"100%": {
|
|
145
|
+
transform: "rotate(360deg)"
|
|
146
|
+
}
|
|
147
|
+
}
|
|
136
148
|
}
|
|
137
149
|
});
|
|
138
150
|
};
|
|
@@ -1,151 +1,291 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
require("core-js/modules/es.weak-map.js");
|
|
4
|
-
require("core-js/modules/esnext.iterator.constructor.js");
|
|
5
|
-
require("core-js/modules/esnext.iterator.filter.js");
|
|
6
4
|
require("core-js/modules/esnext.iterator.for-each.js");
|
|
7
5
|
require("core-js/modules/web.dom-collections.iterator.js");
|
|
8
6
|
Object.defineProperty(exports, "__esModule", {
|
|
9
7
|
value: true
|
|
10
8
|
});
|
|
11
|
-
exports.default = void 0;
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
exports.default = exports.PuiStatusChip = void 0;
|
|
10
|
+
require("core-js/modules/esnext.iterator.constructor.js");
|
|
11
|
+
require("core-js/modules/esnext.iterator.filter.js");
|
|
12
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
14
13
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
var
|
|
14
|
+
var _antd = require("antd");
|
|
16
15
|
var _apperance = require("../../config/apperance");
|
|
17
|
-
var _PuiTooltip = _interopRequireDefault(require("./PuiTooltip"));
|
|
18
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
-
const _excluded = ["id", "className", "sx", "color", "fullWidth", "children"]
|
|
17
|
+
const _excluded = ["id", "className", "sx", "color", "variant", "size", "fullWidth", "children", "clickable", "onClick", "status"],
|
|
18
|
+
_excluded2 = ["status", "children"]; // Définition des états prédéfinis et leur correspondance de style
|
|
19
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
20
20
|
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); }
|
|
21
21
|
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; }
|
|
22
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
|
-
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; }
|
|
24
|
-
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; }
|
|
25
22
|
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; }
|
|
26
23
|
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; }
|
|
27
24
|
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; }
|
|
28
25
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
29
26
|
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); }
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
27
|
+
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; }
|
|
28
|
+
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; }
|
|
29
|
+
const STATUS_CONFIG = {
|
|
30
|
+
// États génériques
|
|
31
|
+
active: {
|
|
32
|
+
color: 'success',
|
|
33
|
+
label: 'Active'
|
|
34
|
+
},
|
|
35
|
+
inactive: {
|
|
36
|
+
color: 'secondary',
|
|
37
|
+
label: 'Inactive'
|
|
38
|
+
},
|
|
39
|
+
pending: {
|
|
40
|
+
color: 'warning',
|
|
41
|
+
label: 'En attente'
|
|
42
|
+
},
|
|
43
|
+
error: {
|
|
44
|
+
color: 'error',
|
|
45
|
+
label: 'Erreur'
|
|
46
|
+
},
|
|
47
|
+
// États spécifiques
|
|
48
|
+
cancelled: {
|
|
49
|
+
color: 'error',
|
|
50
|
+
label: 'Annulée'
|
|
51
|
+
},
|
|
52
|
+
payed: {
|
|
53
|
+
color: 'success',
|
|
54
|
+
label: 'Réglée'
|
|
55
|
+
},
|
|
56
|
+
pending_payment: {
|
|
57
|
+
color: 'warning',
|
|
58
|
+
label: 'Paiement en attente'
|
|
59
|
+
},
|
|
60
|
+
shipped: {
|
|
61
|
+
color: 'info',
|
|
62
|
+
label: 'Expédiée'
|
|
63
|
+
},
|
|
64
|
+
delivered: {
|
|
65
|
+
color: 'success',
|
|
66
|
+
label: 'Livrée'
|
|
67
|
+
},
|
|
68
|
+
processing: {
|
|
69
|
+
color: 'primary',
|
|
70
|
+
label: 'En traitement'
|
|
71
|
+
},
|
|
72
|
+
refunded: {
|
|
73
|
+
color: 'error',
|
|
74
|
+
label: 'Remboursée'
|
|
75
|
+
},
|
|
76
|
+
onhold: {
|
|
77
|
+
color: 'secondary',
|
|
78
|
+
label: 'En suspens'
|
|
79
|
+
},
|
|
80
|
+
completed: {
|
|
81
|
+
color: 'success',
|
|
82
|
+
label: 'Terminée'
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
// Style CSS pour le composant custom
|
|
87
|
+
const chipStyles = "\n .pui-custom-chip {\n display: inline-block;\n box-sizing: border-box;\n margin: 2px;\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 14px;\n line-height: 1.5;\n font-weight: 500;\n transition: all 0.2s;\n max-width: 100%;\n vertical-align: middle;\n border: 1px solid transparent;\n }\n \n .pui-custom-chip.full-width {\n width: 100%;\n display: block;\n }\n \n .pui-custom-chip.small {\n font-size: 12px;\n padding: 2px 6px;\n }\n \n .pui-custom-chip.medium {\n font-size: 14px;\n padding: 4px 8px;\n }\n \n .pui-custom-chip.large {\n font-size: 16px;\n padding: 6px 10px;\n }\n \n .pui-custom-chip-content {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: normal;\n word-wrap: break-word;\n word-break: break-word;\n width: 100%;\n }\n \n .pui-custom-chip.clickable {\n cursor: pointer;\n }\n \n .pui-custom-chip.clickable:hover {\n opacity: 0.9;\n transform: translateY(-1px);\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n }\n \n /* Styles sp\xE9cifiques pour les statuts */\n .pui-status-chip {\n font-weight: 600;\n padding: 3px 10px;\n border-radius: 12px;\n }\n";
|
|
88
|
+
|
|
89
|
+
// Injection des styles dans le document
|
|
90
|
+
const injectStyles = () => {
|
|
91
|
+
const styleId = 'pui-custom-chip-styles';
|
|
92
|
+
if (!document.getElementById(styleId)) {
|
|
93
|
+
const styleElement = document.createElement('style');
|
|
94
|
+
styleElement.id = styleId;
|
|
95
|
+
styleElement.innerHTML = chipStyles;
|
|
96
|
+
document.head.appendChild(styleElement);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// Suppression des styles lors du démontage
|
|
101
|
+
const removeStyles = () => {
|
|
102
|
+
const styleElement = document.getElementById('pui-custom-chip-styles');
|
|
103
|
+
if (styleElement) {
|
|
104
|
+
document.head.removeChild(styleElement);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
// Configuration des couleurs selon la palette
|
|
109
|
+
const getColorConfig = (color, variant) => {
|
|
110
|
+
var _colorConfigs$color;
|
|
111
|
+
const colorConfigs = {
|
|
112
|
+
primary: {
|
|
113
|
+
filled: {
|
|
114
|
+
color: '#fff',
|
|
115
|
+
backgroundColor: _apperance.palette.primary,
|
|
116
|
+
borderColor: _apperance.palette.primary
|
|
117
|
+
},
|
|
118
|
+
outlined: {
|
|
119
|
+
color: _apperance.palette.primary,
|
|
120
|
+
backgroundColor: 'transparent',
|
|
121
|
+
borderColor: _apperance.palette.primary
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
secondary: {
|
|
125
|
+
filled: {
|
|
126
|
+
color: _apperance.palette.gray.darker,
|
|
127
|
+
backgroundColor: _apperance.palette.secondary,
|
|
128
|
+
borderColor: _apperance.palette.gray.dark
|
|
129
|
+
},
|
|
130
|
+
outlined: {
|
|
131
|
+
color: _apperance.palette.gray.darker,
|
|
132
|
+
backgroundColor: 'transparent',
|
|
133
|
+
borderColor: _apperance.palette.gray.dark
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
info: {
|
|
137
|
+
filled: {
|
|
138
|
+
color: '#fff',
|
|
139
|
+
backgroundColor: _apperance.palette.info,
|
|
140
|
+
borderColor: _apperance.palette.info
|
|
141
|
+
},
|
|
142
|
+
outlined: {
|
|
143
|
+
color: _apperance.palette.info,
|
|
144
|
+
backgroundColor: 'transparent',
|
|
145
|
+
borderColor: _apperance.palette.info
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
success: {
|
|
149
|
+
filled: {
|
|
150
|
+
color: '#fff',
|
|
151
|
+
backgroundColor: _apperance.palette.success,
|
|
152
|
+
borderColor: _apperance.palette.success
|
|
153
|
+
},
|
|
154
|
+
outlined: {
|
|
155
|
+
color: _apperance.palette.success,
|
|
156
|
+
backgroundColor: 'transparent',
|
|
157
|
+
borderColor: _apperance.palette.success
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
warning: {
|
|
161
|
+
filled: {
|
|
162
|
+
color: '#fff',
|
|
163
|
+
backgroundColor: _apperance.palette.warning,
|
|
164
|
+
borderColor: _apperance.palette.warning
|
|
165
|
+
},
|
|
166
|
+
outlined: {
|
|
167
|
+
color: _apperance.palette.warning,
|
|
168
|
+
backgroundColor: 'transparent',
|
|
169
|
+
borderColor: _apperance.palette.warning
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
error: {
|
|
173
|
+
filled: {
|
|
174
|
+
color: '#fff',
|
|
175
|
+
backgroundColor: _apperance.palette.error,
|
|
176
|
+
borderColor: _apperance.palette.error
|
|
177
|
+
},
|
|
178
|
+
outlined: {
|
|
179
|
+
color: _apperance.palette.error,
|
|
180
|
+
backgroundColor: 'transparent',
|
|
181
|
+
borderColor: _apperance.palette.error
|
|
182
|
+
}
|
|
95
183
|
}
|
|
96
184
|
};
|
|
97
|
-
|
|
98
|
-
const getChipByColor = color => {
|
|
99
|
-
switch (color) {
|
|
100
|
-
case "primary":
|
|
101
|
-
default:
|
|
102
|
-
return PrimaryChip;
|
|
103
|
-
case "secondary":
|
|
104
|
-
return SecondaryChip;
|
|
105
|
-
case "success":
|
|
106
|
-
return SuccessChip;
|
|
107
|
-
case "error":
|
|
108
|
-
return ErrorChip;
|
|
109
|
-
case "info":
|
|
110
|
-
return InfoChip;
|
|
111
|
-
case "warning":
|
|
112
|
-
return WarningChip;
|
|
113
|
-
}
|
|
185
|
+
return ((_colorConfigs$color = colorConfigs[color]) === null || _colorConfigs$color === void 0 ? void 0 : _colorConfigs$color[variant]) || colorConfigs.primary.filled;
|
|
114
186
|
};
|
|
115
|
-
const PuiChip = /*#__PURE__*/
|
|
187
|
+
const PuiChip = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
116
188
|
let {
|
|
117
189
|
id,
|
|
118
190
|
className,
|
|
119
191
|
sx,
|
|
120
|
-
color,
|
|
121
|
-
|
|
122
|
-
|
|
192
|
+
color = "primary",
|
|
193
|
+
variant = "filled",
|
|
194
|
+
size = "medium",
|
|
195
|
+
fullWidth = false,
|
|
196
|
+
children,
|
|
197
|
+
clickable = false,
|
|
198
|
+
onClick,
|
|
199
|
+
status // Nouveau prop pour gérer les états prédéfinis
|
|
123
200
|
} = _ref,
|
|
124
201
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
202
|
+
// Injection des styles
|
|
203
|
+
_react.default.useEffect(() => {
|
|
204
|
+
injectStyles();
|
|
205
|
+
return () => removeStyles();
|
|
206
|
+
}, []);
|
|
207
|
+
|
|
208
|
+
// Si un statut est fourni, utiliser sa configuration
|
|
209
|
+
let displayContent = children;
|
|
210
|
+
let statusColor = color;
|
|
211
|
+
if (status && STATUS_CONFIG[status]) {
|
|
212
|
+
const statusConfig = STATUS_CONFIG[status];
|
|
213
|
+
statusColor = statusConfig.color;
|
|
214
|
+
// Si aucun contenu n'est fourni, utiliser le libellé par défaut du statut
|
|
215
|
+
if (!children) {
|
|
216
|
+
displayContent = statusConfig.label;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const colorConfig = getColorConfig(statusColor, variant);
|
|
220
|
+
const shouldShowTooltip = typeof displayContent === 'string' && displayContent.length > 30;
|
|
221
|
+
|
|
222
|
+
// Déterminer les classes CSS
|
|
223
|
+
const chipClasses = ['pui-custom-chip', status ? 'pui-status-chip' : '', size, fullWidth ? 'full-width' : '', clickable ? 'clickable' : '', className || ''].filter(Boolean).join(' ');
|
|
224
|
+
|
|
225
|
+
// Gérer le clic
|
|
226
|
+
const handleClick = e => {
|
|
227
|
+
if (clickable && onClick) {
|
|
228
|
+
onClick(e);
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
// Créer le chip personnalisé
|
|
233
|
+
const chipElement = /*#__PURE__*/(0, _jsxRuntime.jsx)("div", _objectSpread(_objectSpread({
|
|
234
|
+
id: id,
|
|
235
|
+
ref: ref,
|
|
236
|
+
className: chipClasses,
|
|
237
|
+
style: _objectSpread(_objectSpread({}, colorConfig), sx),
|
|
238
|
+
onClick: handleClick,
|
|
239
|
+
"data-status": status || null
|
|
240
|
+
}, rest), {}, {
|
|
241
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
242
|
+
className: "pui-custom-chip-content",
|
|
243
|
+
children: displayContent
|
|
244
|
+
})
|
|
245
|
+
}));
|
|
246
|
+
return shouldShowTooltip ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_antd.Tooltip, {
|
|
247
|
+
title: displayContent,
|
|
248
|
+
placement: "top",
|
|
249
|
+
children: chipElement
|
|
250
|
+
}) : chipElement;
|
|
140
251
|
});
|
|
252
|
+
|
|
253
|
+
// Composant utilitaire simplifié pour afficher un statut
|
|
254
|
+
const PuiStatusChip = exports.PuiStatusChip = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
255
|
+
let {
|
|
256
|
+
status,
|
|
257
|
+
children
|
|
258
|
+
} = _ref2,
|
|
259
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
260
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiChip, _objectSpread(_objectSpread({
|
|
261
|
+
ref: ref,
|
|
262
|
+
status: status,
|
|
263
|
+
variant: "filled"
|
|
264
|
+
}, props), {}, {
|
|
265
|
+
children: children
|
|
266
|
+
}));
|
|
267
|
+
});
|
|
268
|
+
PuiStatusChip.propTypes = {
|
|
269
|
+
status: _propTypes.default.oneOf(Object.keys(STATUS_CONFIG)),
|
|
270
|
+
children: _propTypes.default.node
|
|
271
|
+
};
|
|
141
272
|
PuiChip.propTypes = {
|
|
142
273
|
id: _propTypes.default.string,
|
|
143
274
|
className: _propTypes.default.string,
|
|
144
275
|
sx: _propTypes.default.object,
|
|
276
|
+
color: _propTypes.default.oneOf(["primary", "secondary", "info", "success", "warning", "error"]),
|
|
277
|
+
variant: _propTypes.default.oneOf(["filled", "outlined"]),
|
|
278
|
+
size: _propTypes.default.oneOf(["small", "medium", "large"]),
|
|
145
279
|
fullWidth: _propTypes.default.bool,
|
|
146
|
-
|
|
280
|
+
clickable: _propTypes.default.bool,
|
|
281
|
+
onClick: _propTypes.default.func,
|
|
282
|
+
status: _propTypes.default.oneOf(Object.keys(STATUS_CONFIG))
|
|
147
283
|
};
|
|
148
284
|
PuiChip.defaultProps = {
|
|
149
|
-
color: "primary"
|
|
285
|
+
color: "primary",
|
|
286
|
+
variant: "filled",
|
|
287
|
+
size: "medium",
|
|
288
|
+
fullWidth: false,
|
|
289
|
+
clickable: false
|
|
150
290
|
};
|
|
151
291
|
var _default = exports.default = PuiChip;
|