@portnet/ui 3.0.3 → 3.0.4
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/PuiButton.js +136 -0
- package/dist/components/buttons/PuiIconButton.js +97 -0
- package/dist/components/common/PuiAlertContext.js +13 -0
- package/dist/components/common/StyledMuiButton.js +47 -0
- package/dist/components/common/StyledMuiTextField.js +120 -0
- package/dist/components/inputs/PuiAutocomplete.js +350 -0
- package/dist/components/inputs/PuiCheckbox.js +307 -0
- package/dist/components/inputs/PuiCheckboxGroup.js +213 -0
- package/dist/components/inputs/PuiCheckboxItem.js +161 -0
- package/dist/components/inputs/PuiDateField.js +279 -0
- package/dist/components/inputs/PuiDateTimeField.js +395 -0
- package/dist/components/inputs/PuiFileField.js +264 -0
- package/dist/components/inputs/PuiRadioGroup.js +196 -0
- package/dist/components/inputs/PuiRadioItem.js +99 -0
- package/dist/components/inputs/PuiSelect.js +357 -0
- package/dist/components/inputs/PuiTextField.js +262 -0
- package/dist/components/others/PuiBadge.js +56 -0
- package/dist/components/others/PuiChip.js +149 -0
- package/dist/components/others/PuiDialog.js +101 -0
- package/dist/components/others/PuiFormikForm.js +71 -0
- package/dist/components/others/PuiGrid.js +21 -0
- package/dist/components/others/PuiIcon.js +91 -0
- package/dist/components/others/PuiLoadingBackdrop.js +32 -0
- package/dist/components/others/PuiMainContainer.js +40 -0
- package/dist/components/others/PuiNavigation.js +67 -0
- package/dist/components/others/PuiSection.js +97 -0
- package/dist/components/others/PuiTooltip.js +85 -0
- package/dist/components/providers/PuiAlertProvider.js +132 -0
- package/dist/components/providers/PuiLocalizationProvider.js +32 -0
- package/dist/components/referentiel/common/ReferetielContext.js +13 -0
- package/dist/components/referentiel/common/constants/specificReferentielsApis.js +22 -0
- package/dist/components/referentiel/common/constants/specificReferentielsBaseColumns.js +691 -0
- package/dist/components/referentiel/common/constants/specificReferentielsBaseFilters.js +598 -0
- package/dist/components/referentiel/common/constants/specificReferentielsInitialValues.js +80 -0
- package/dist/components/referentiel/common/constants/specificReferentielsKeys.js +18 -0
- package/dist/components/referentiel/common/constants/specificReferentielsTitles.js +22 -0
- package/dist/components/referentiel/common/constants/specificReferentielsValidationSchemas.js +86 -0
- package/dist/components/referentiel/components/PuiBasePopupReferentielField.js +355 -0
- package/dist/components/referentiel/components/PuiCustomPopupReferentielField.js +180 -0
- package/dist/components/referentiel/components/PuiSimplePopupReferentielField.js +323 -0
- package/dist/components/referentiel/components/PuiSimpleReferentielField.js +201 -0
- package/dist/components/referentiel/components/PuiSpecificReferentielField.js +330 -0
- package/dist/components/referentiel/providers/PuiReferentielProvider.js +65 -0
- package/dist/components/tab/PuiTab.js +25 -0
- package/dist/components/tab/PuiTabs.js +145 -0
- package/dist/components/table/ActionPopover.js +54 -0
- package/dist/components/table/PuiTable.js +446 -0
- package/dist/components/table/PuiTableAction.js +63 -0
- package/dist/components/typography/PuiDefinition.js +42 -0
- package/dist/components/typography/PuiIndication.js +79 -0
- package/dist/components/typography/PuiMainTitle.js +85 -0
- package/dist/components/ui/dialogs/PuiSearchDialog.js +105 -0
- package/dist/components/ui/pages/errors/PuiErrorBasePage.js +73 -0
- package/dist/components/ui/pages/errors/PuiForbiddenErrorPage.js +36 -0
- package/dist/components/ui/pages/errors/PuiNetworkErrorPage.js +36 -0
- package/dist/components/ui/pages/errors/PuiNotFoundErrorPage.js +30 -0
- package/dist/components/ui/pages/errors/PuiServerErrorPage.js +37 -0
- package/dist/components/ui/pages/general/PuiDefaultPage.js +68 -0
- package/dist/components/ui/pages/general/PuiSearchPage.js +201 -0
- package/dist/config/apperance.js +26 -0
- package/dist/config/mapping.js +26 -0
- package/dist/config/referentiel.js +10 -0
- package/dist/general/yupValidationErrors.js +8 -0
- package/dist/hooks/useAlert.js +20 -0
- package/dist/hooks/useAxios.js +23 -0
- package/dist/hooks/useQuery.js +19 -0
- package/dist/index.js +335 -0
- package/package.json +1 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
4
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
var Yup = _interopRequireWildcard(require("yup"));
|
|
10
|
+
var _yupValidationErrors = require("../../../../general/yupValidationErrors");
|
|
11
|
+
var _specificReferentielsKeys = require("./specificReferentielsKeys");
|
|
12
|
+
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); }
|
|
13
|
+
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 && Object.prototype.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; }
|
|
14
|
+
const specificReferentielsValidationSchemas = {
|
|
15
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_LOCALITES]: Yup.object().shape({
|
|
16
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
17
|
+
codePays: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
18
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING)
|
|
19
|
+
}),
|
|
20
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_OPERATEURS_MANUTENTION]: Yup.object().shape({
|
|
21
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
22
|
+
idPort: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
23
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING)
|
|
24
|
+
}),
|
|
25
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_ESCALES]: Yup.object().shape({
|
|
26
|
+
id: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
27
|
+
numVoyage: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
28
|
+
numEscale: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
29
|
+
dateCreationFormatted: Yup.string().typeError(_yupValidationErrors.TYPE_STRING)
|
|
30
|
+
}),
|
|
31
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_OPERATEURS_IMP_EXP]: Yup.object().shape({
|
|
32
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
33
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
34
|
+
codePin: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
35
|
+
ifu: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
36
|
+
ice: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
37
|
+
numeroRc: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
38
|
+
centreRc: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER)
|
|
39
|
+
}),
|
|
40
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_BANQUES]: Yup.object().shape({
|
|
41
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
42
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
43
|
+
codeEDI: Yup.string().typeError(_yupValidationErrors.TYPE_STRING)
|
|
44
|
+
}),
|
|
45
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_TRANSITAIRES]: Yup.object().shape({
|
|
46
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
47
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
48
|
+
ifu: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
49
|
+
ice: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
50
|
+
numeroRc: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
51
|
+
centreRc: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER)
|
|
52
|
+
}),
|
|
53
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_NAVIRES]: Yup.object().shape({
|
|
54
|
+
imo: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
55
|
+
nom: Yup.string().typeError(_yupValidationErrors.TYPE_STRING)
|
|
56
|
+
}),
|
|
57
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_CONSIGNATAIRES]: Yup.object().shape({
|
|
58
|
+
codeEDI: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
59
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
60
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING)
|
|
61
|
+
}),
|
|
62
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_COMPTES_BANCAIRE]: Yup.object().shape({
|
|
63
|
+
rib: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
64
|
+
idBanque: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
65
|
+
mois: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
66
|
+
anne: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER)
|
|
67
|
+
}),
|
|
68
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_GUICHETS]: Yup.object().shape({
|
|
69
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
70
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
71
|
+
adresse: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
72
|
+
idBanque: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
73
|
+
idTypeLocalite: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER)
|
|
74
|
+
}),
|
|
75
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_NOMENCLATURES_DOUANIERES]: Yup.object().shape({
|
|
76
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
77
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
78
|
+
idTypeTitreImportation: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER),
|
|
79
|
+
idTypeTitreExportation: Yup.number().typeError(_yupValidationErrors.TYPE_NUMBER)
|
|
80
|
+
}),
|
|
81
|
+
[_specificReferentielsKeys.SPECIFIC_REFERENTIEL_TEST]: Yup.object().shape({
|
|
82
|
+
code: Yup.string().typeError(_yupValidationErrors.TYPE_STRING),
|
|
83
|
+
description: Yup.string().typeError(_yupValidationErrors.TYPE_STRING)
|
|
84
|
+
})
|
|
85
|
+
};
|
|
86
|
+
var _default = exports.default = specificReferentielsValidationSchemas;
|
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
require("core-js/modules/es.weak-map.js");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
|
+
var _formik = require("formik");
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _PuiTextField = _interopRequireDefault(require("../../inputs/PuiTextField"));
|
|
14
|
+
var _PuiIcon = _interopRequireDefault(require("../../others/PuiIcon"));
|
|
15
|
+
var _PuiTableAction = _interopRequireDefault(require("../../table/PuiTableAction"));
|
|
16
|
+
var _PuiSearchDialog = _interopRequireDefault(require("../../ui/dialogs/PuiSearchDialog"));
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
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); }
|
|
19
|
+
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 && Object.prototype.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; }
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
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; }
|
|
22
|
+
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; }
|
|
23
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
24
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
25
|
+
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); }
|
|
26
|
+
const CommunComponent = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
27
|
+
var _getRenderedValue;
|
|
28
|
+
let {
|
|
29
|
+
id,
|
|
30
|
+
className,
|
|
31
|
+
selectedRow,
|
|
32
|
+
sx,
|
|
33
|
+
title,
|
|
34
|
+
label,
|
|
35
|
+
error,
|
|
36
|
+
disabled,
|
|
37
|
+
loading,
|
|
38
|
+
rowCount,
|
|
39
|
+
rows,
|
|
40
|
+
page,
|
|
41
|
+
pageSize,
|
|
42
|
+
columns,
|
|
43
|
+
required,
|
|
44
|
+
focused,
|
|
45
|
+
fullWidth,
|
|
46
|
+
helperText,
|
|
47
|
+
getRenderedValue,
|
|
48
|
+
tableProps,
|
|
49
|
+
onSelect,
|
|
50
|
+
onPageChange,
|
|
51
|
+
children
|
|
52
|
+
} = _ref;
|
|
53
|
+
const [isDialogOpen, setIsDialogOpen] = React.useState(false);
|
|
54
|
+
const selectHandler = row => {
|
|
55
|
+
setIsDialogOpen(false);
|
|
56
|
+
onSelect(row);
|
|
57
|
+
};
|
|
58
|
+
const tableActions = [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTableAction.default, {
|
|
59
|
+
title: "Choisir",
|
|
60
|
+
onClick: selectHandler,
|
|
61
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
|
|
62
|
+
type: "choisir"
|
|
63
|
+
})
|
|
64
|
+
})];
|
|
65
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
66
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiTextField.default, {
|
|
67
|
+
id: id,
|
|
68
|
+
ref: ref,
|
|
69
|
+
className: className,
|
|
70
|
+
sx: sx,
|
|
71
|
+
formik: false,
|
|
72
|
+
focused: focused,
|
|
73
|
+
required: required,
|
|
74
|
+
disabled: disabled,
|
|
75
|
+
fullWidth: fullWidth,
|
|
76
|
+
value: Boolean(selectedRow) ? (_getRenderedValue = getRenderedValue(selectedRow)) !== null && _getRenderedValue !== void 0 ? _getRenderedValue : "" : "",
|
|
77
|
+
readOnly: true,
|
|
78
|
+
error: error,
|
|
79
|
+
helperText: helperText,
|
|
80
|
+
label: label,
|
|
81
|
+
InputProps: {
|
|
82
|
+
endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
|
|
83
|
+
type: "rechercher",
|
|
84
|
+
size: "small",
|
|
85
|
+
sx: {
|
|
86
|
+
marginRight: "-5px"
|
|
87
|
+
}
|
|
88
|
+
})
|
|
89
|
+
},
|
|
90
|
+
onClick: disabled ? () => {} : () => setIsDialogOpen(true)
|
|
91
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiSearchDialog.default, {
|
|
92
|
+
open: isDialogOpen,
|
|
93
|
+
title: title,
|
|
94
|
+
onClose: () => setIsDialogOpen(false),
|
|
95
|
+
loading: loading,
|
|
96
|
+
rowCount: rowCount,
|
|
97
|
+
rows: rows,
|
|
98
|
+
page: page,
|
|
99
|
+
pageSize: pageSize,
|
|
100
|
+
columns: columns,
|
|
101
|
+
actions: tableActions,
|
|
102
|
+
onPageChange: onPageChange,
|
|
103
|
+
tableProps: _objectSpread({
|
|
104
|
+
paginationMode: "server",
|
|
105
|
+
oneActionOnly: true
|
|
106
|
+
}, tableProps),
|
|
107
|
+
children: children
|
|
108
|
+
})]
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const PuiBaseStandardPopupReferentielField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
112
|
+
let {
|
|
113
|
+
id,
|
|
114
|
+
className,
|
|
115
|
+
sx,
|
|
116
|
+
loading,
|
|
117
|
+
rowCount,
|
|
118
|
+
rows,
|
|
119
|
+
page,
|
|
120
|
+
pageSize,
|
|
121
|
+
columns,
|
|
122
|
+
title,
|
|
123
|
+
label,
|
|
124
|
+
name,
|
|
125
|
+
value,
|
|
126
|
+
error,
|
|
127
|
+
disabled,
|
|
128
|
+
required,
|
|
129
|
+
focused,
|
|
130
|
+
fullWidth,
|
|
131
|
+
helperText,
|
|
132
|
+
tableProps,
|
|
133
|
+
getReturnedValue,
|
|
134
|
+
getRenderedValue,
|
|
135
|
+
onChange,
|
|
136
|
+
onPageChange,
|
|
137
|
+
children
|
|
138
|
+
} = _ref2;
|
|
139
|
+
const [selectedRow, setSelectedRow] = React.useState(null);
|
|
140
|
+
const selectHandler = row => {
|
|
141
|
+
setSelectedRow(row);
|
|
142
|
+
onChange(getReturnedValue(row));
|
|
143
|
+
};
|
|
144
|
+
React.useEffect(() => {
|
|
145
|
+
if (value !== undefined && value !== null) {
|
|
146
|
+
setSelectedRow(value);
|
|
147
|
+
}
|
|
148
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
149
|
+
}, [value]);
|
|
150
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CommunComponent, {
|
|
151
|
+
ref: ref,
|
|
152
|
+
id: id,
|
|
153
|
+
className: className,
|
|
154
|
+
sx: sx,
|
|
155
|
+
selectedRow: selectedRow,
|
|
156
|
+
loading: loading,
|
|
157
|
+
rowCount: rowCount,
|
|
158
|
+
rows: rows,
|
|
159
|
+
page: page,
|
|
160
|
+
pageSize: pageSize,
|
|
161
|
+
columns: columns,
|
|
162
|
+
title: title,
|
|
163
|
+
label: label,
|
|
164
|
+
name: name,
|
|
165
|
+
error: error,
|
|
166
|
+
disabled: disabled,
|
|
167
|
+
required: required,
|
|
168
|
+
focused: focused,
|
|
169
|
+
fullWidth: fullWidth,
|
|
170
|
+
helperText: helperText,
|
|
171
|
+
tableProps: tableProps,
|
|
172
|
+
getRenderedValue: getRenderedValue,
|
|
173
|
+
onSelect: selectHandler,
|
|
174
|
+
onPageChange: onPageChange,
|
|
175
|
+
children: children
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
const PuiBaseFormikPopupReferentielField = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
179
|
+
let {
|
|
180
|
+
id,
|
|
181
|
+
className,
|
|
182
|
+
sx,
|
|
183
|
+
loading,
|
|
184
|
+
rowCount,
|
|
185
|
+
rows,
|
|
186
|
+
page,
|
|
187
|
+
pageSize,
|
|
188
|
+
columns,
|
|
189
|
+
title,
|
|
190
|
+
label,
|
|
191
|
+
name,
|
|
192
|
+
value,
|
|
193
|
+
error,
|
|
194
|
+
disabled,
|
|
195
|
+
required,
|
|
196
|
+
focused,
|
|
197
|
+
fullWidth,
|
|
198
|
+
helperText,
|
|
199
|
+
tableProps,
|
|
200
|
+
getReturnedValue,
|
|
201
|
+
getRenderedValue,
|
|
202
|
+
onChange,
|
|
203
|
+
onPageChange,
|
|
204
|
+
children
|
|
205
|
+
} = _ref3;
|
|
206
|
+
const [field, meta] = (0, _formik.useField)(name);
|
|
207
|
+
const formikContext = (0, _formik.useFormikContext)();
|
|
208
|
+
const [selectedRow, setSelectedRow] = React.useState(null);
|
|
209
|
+
const [hasError, setHasError] = React.useState(false);
|
|
210
|
+
const selectHandler = row => {
|
|
211
|
+
setSelectedRow(row);
|
|
212
|
+
formikContext.setFieldValue(name, getReturnedValue(row));
|
|
213
|
+
onChange(row);
|
|
214
|
+
};
|
|
215
|
+
React.useEffect(() => {
|
|
216
|
+
setHasError(Boolean(meta) && Boolean(meta.touched) && Boolean(meta.error));
|
|
217
|
+
}, [meta]);
|
|
218
|
+
React.useEffect(() => {
|
|
219
|
+
if (value !== undefined && value !== null) {
|
|
220
|
+
formikContext.setFieldValue(name, getReturnedValue(value));
|
|
221
|
+
setSelectedRow(value);
|
|
222
|
+
}
|
|
223
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
224
|
+
}, [value]);
|
|
225
|
+
React.useEffect(() => {
|
|
226
|
+
if (field.value === formikContext.initialValues[name] || field.value === "" || field.value === null || field.value === undefined) {
|
|
227
|
+
setSelectedRow(null);
|
|
228
|
+
}
|
|
229
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
230
|
+
}, [field.value]);
|
|
231
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(CommunComponent, {
|
|
232
|
+
ref: ref,
|
|
233
|
+
id: id,
|
|
234
|
+
className: className,
|
|
235
|
+
sx: sx,
|
|
236
|
+
selectedRow: selectedRow,
|
|
237
|
+
loading: loading,
|
|
238
|
+
rowCount: rowCount,
|
|
239
|
+
rows: rows,
|
|
240
|
+
page: page,
|
|
241
|
+
pageSize: pageSize,
|
|
242
|
+
columns: columns,
|
|
243
|
+
title: title,
|
|
244
|
+
label: label,
|
|
245
|
+
name: name,
|
|
246
|
+
error: error || hasError,
|
|
247
|
+
disabled: disabled,
|
|
248
|
+
required: required,
|
|
249
|
+
focused: focused,
|
|
250
|
+
fullWidth: fullWidth,
|
|
251
|
+
tableProps: tableProps,
|
|
252
|
+
helperText: hasError && Boolean(meta.error) ? meta.error : helperText !== null && helperText !== void 0 ? helperText : "",
|
|
253
|
+
getRenderedValue: getRenderedValue,
|
|
254
|
+
onSelect: selectHandler,
|
|
255
|
+
onPageChange: onPageChange,
|
|
256
|
+
children: children
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
const PuiBasePopupReferentielField = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
260
|
+
let {
|
|
261
|
+
id,
|
|
262
|
+
className,
|
|
263
|
+
sx,
|
|
264
|
+
formik,
|
|
265
|
+
loading,
|
|
266
|
+
rowCount,
|
|
267
|
+
rows,
|
|
268
|
+
page,
|
|
269
|
+
pageSize,
|
|
270
|
+
columns,
|
|
271
|
+
title,
|
|
272
|
+
label,
|
|
273
|
+
name,
|
|
274
|
+
value,
|
|
275
|
+
error,
|
|
276
|
+
disabled,
|
|
277
|
+
required,
|
|
278
|
+
focused,
|
|
279
|
+
fullWidth,
|
|
280
|
+
helperText,
|
|
281
|
+
tableProps,
|
|
282
|
+
getReturnedValue,
|
|
283
|
+
getRenderedValue,
|
|
284
|
+
onChange,
|
|
285
|
+
onPageChange,
|
|
286
|
+
children
|
|
287
|
+
} = _ref4;
|
|
288
|
+
return /*#__PURE__*/React.createElement(formik ? PuiBaseFormikPopupReferentielField : PuiBaseStandardPopupReferentielField, {
|
|
289
|
+
id,
|
|
290
|
+
ref,
|
|
291
|
+
className,
|
|
292
|
+
sx,
|
|
293
|
+
title,
|
|
294
|
+
label,
|
|
295
|
+
loading,
|
|
296
|
+
rowCount,
|
|
297
|
+
rows,
|
|
298
|
+
page,
|
|
299
|
+
pageSize,
|
|
300
|
+
columns,
|
|
301
|
+
name,
|
|
302
|
+
value,
|
|
303
|
+
error,
|
|
304
|
+
disabled,
|
|
305
|
+
required,
|
|
306
|
+
focused,
|
|
307
|
+
fullWidth,
|
|
308
|
+
helperText,
|
|
309
|
+
tableProps,
|
|
310
|
+
onPageChange,
|
|
311
|
+
getRenderedValue,
|
|
312
|
+
getReturnedValue,
|
|
313
|
+
onChange,
|
|
314
|
+
children
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
PuiBasePopupReferentielField.propTypes = {
|
|
318
|
+
id: _propTypes.default.string,
|
|
319
|
+
className: _propTypes.default.string,
|
|
320
|
+
sx: _propTypes.default.object,
|
|
321
|
+
title: _propTypes.default.string.isRequired,
|
|
322
|
+
label: _propTypes.default.string,
|
|
323
|
+
loading: _propTypes.default.bool,
|
|
324
|
+
rowCount: _propTypes.default.number,
|
|
325
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
326
|
+
page: _propTypes.default.number,
|
|
327
|
+
pageSize: _propTypes.default.number,
|
|
328
|
+
columns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
329
|
+
name: _propTypes.default.string,
|
|
330
|
+
formik: _propTypes.default.bool,
|
|
331
|
+
error: _propTypes.default.bool,
|
|
332
|
+
disabled: _propTypes.default.bool,
|
|
333
|
+
required: _propTypes.default.bool,
|
|
334
|
+
focused: _propTypes.default.bool,
|
|
335
|
+
fullWidth: _propTypes.default.bool,
|
|
336
|
+
helperText: _propTypes.default.string,
|
|
337
|
+
tableProps: _propTypes.default.object,
|
|
338
|
+
getRenderedValue: _propTypes.default.func.isRequired,
|
|
339
|
+
getReturnedValue: _propTypes.default.func,
|
|
340
|
+
onChange: _propTypes.default.func,
|
|
341
|
+
onPageChange: _propTypes.default.func
|
|
342
|
+
};
|
|
343
|
+
PuiBasePopupReferentielField.defaultProps = {
|
|
344
|
+
formik: true,
|
|
345
|
+
disabled: false,
|
|
346
|
+
required: false,
|
|
347
|
+
error: false,
|
|
348
|
+
fullWidth: true,
|
|
349
|
+
loading: false,
|
|
350
|
+
tableProps: {},
|
|
351
|
+
getReturnedValue: value => value,
|
|
352
|
+
onChange: () => {},
|
|
353
|
+
onPageChange: () => {}
|
|
354
|
+
};
|
|
355
|
+
var _default = exports.default = PuiBasePopupReferentielField;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
4
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
require("core-js/modules/es.symbol.description.js");
|
|
10
|
+
var _formik = require("formik");
|
|
11
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
12
|
+
var React = _interopRequireWildcard(require("react"));
|
|
13
|
+
var _PuiButton = _interopRequireDefault(require("../../buttons/PuiButton"));
|
|
14
|
+
var _PuiFormikForm = _interopRequireDefault(require("../../others/PuiFormikForm"));
|
|
15
|
+
var _PuiGrid = _interopRequireDefault(require("../../others/PuiGrid"));
|
|
16
|
+
var _PuiIcon = _interopRequireDefault(require("../../others/PuiIcon"));
|
|
17
|
+
var _PuiBasePopupReferentielField = _interopRequireDefault(require("./PuiBasePopupReferentielField"));
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
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); }
|
|
20
|
+
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 && Object.prototype.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; }
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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; }
|
|
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; }
|
|
24
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
25
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
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); }
|
|
27
|
+
const PuiCustomPopupReferentielField = _ref => {
|
|
28
|
+
let {
|
|
29
|
+
id,
|
|
30
|
+
className,
|
|
31
|
+
sx,
|
|
32
|
+
title,
|
|
33
|
+
label,
|
|
34
|
+
formikProps,
|
|
35
|
+
columns,
|
|
36
|
+
name,
|
|
37
|
+
value,
|
|
38
|
+
formik,
|
|
39
|
+
error,
|
|
40
|
+
disabled,
|
|
41
|
+
required,
|
|
42
|
+
focused,
|
|
43
|
+
fullWidth,
|
|
44
|
+
helperText,
|
|
45
|
+
loading,
|
|
46
|
+
rowCount,
|
|
47
|
+
rows,
|
|
48
|
+
page,
|
|
49
|
+
pageSize,
|
|
50
|
+
tableProps,
|
|
51
|
+
getReturnedValue,
|
|
52
|
+
getRenderedValue,
|
|
53
|
+
onPageChange,
|
|
54
|
+
onChange,
|
|
55
|
+
onSubmit,
|
|
56
|
+
children: _children
|
|
57
|
+
} = _ref;
|
|
58
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiBasePopupReferentielField.default, {
|
|
59
|
+
id: id,
|
|
60
|
+
className: className,
|
|
61
|
+
sx: sx,
|
|
62
|
+
name: name,
|
|
63
|
+
formik: formik,
|
|
64
|
+
loading: loading,
|
|
65
|
+
rowCount: rowCount,
|
|
66
|
+
rows: rows,
|
|
67
|
+
page: page,
|
|
68
|
+
pageSize: pageSize,
|
|
69
|
+
columns: columns,
|
|
70
|
+
focused: focused,
|
|
71
|
+
required: required,
|
|
72
|
+
disabled: disabled,
|
|
73
|
+
fullWidth: fullWidth,
|
|
74
|
+
value: value,
|
|
75
|
+
readOnly: true,
|
|
76
|
+
error: error,
|
|
77
|
+
helperText: helperText,
|
|
78
|
+
label: label,
|
|
79
|
+
title: title,
|
|
80
|
+
tableProps: tableProps,
|
|
81
|
+
getReturnedValue: getReturnedValue,
|
|
82
|
+
getRenderedValue: getRenderedValue,
|
|
83
|
+
onPageChange: onPageChange,
|
|
84
|
+
onChange: onChange,
|
|
85
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_formik.Formik, _objectSpread(_objectSpread({}, formikProps), {}, {
|
|
86
|
+
onSubmit: onSubmit,
|
|
87
|
+
children: _ref2 => {
|
|
88
|
+
let {
|
|
89
|
+
resetForm,
|
|
90
|
+
submitForm
|
|
91
|
+
} = _ref2;
|
|
92
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiFormikForm.default, {
|
|
93
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
|
|
94
|
+
container: true,
|
|
95
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
|
|
96
|
+
item: true,
|
|
97
|
+
xs: 12,
|
|
98
|
+
children: _children
|
|
99
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
|
|
100
|
+
item: true,
|
|
101
|
+
xs: 12,
|
|
102
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_PuiGrid.default, {
|
|
103
|
+
container: true,
|
|
104
|
+
justifyContent: "end",
|
|
105
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
|
|
106
|
+
item: true,
|
|
107
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
108
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
|
|
109
|
+
type: "effacer",
|
|
110
|
+
size: "small"
|
|
111
|
+
}),
|
|
112
|
+
onClick: resetForm,
|
|
113
|
+
color: "tertiary",
|
|
114
|
+
children: "Effacer"
|
|
115
|
+
})
|
|
116
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiGrid.default, {
|
|
117
|
+
item: true,
|
|
118
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiButton.default, {
|
|
119
|
+
startIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
|
|
120
|
+
type: "rechercher",
|
|
121
|
+
size: "small"
|
|
122
|
+
}),
|
|
123
|
+
onClick: submitForm,
|
|
124
|
+
loading: loading,
|
|
125
|
+
loadingPosition: "start",
|
|
126
|
+
children: "Rechercher"
|
|
127
|
+
})
|
|
128
|
+
})]
|
|
129
|
+
})
|
|
130
|
+
})]
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}))
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
PuiCustomPopupReferentielField.propTypes = {
|
|
138
|
+
id: _propTypes.default.string,
|
|
139
|
+
className: _propTypes.default.string,
|
|
140
|
+
sx: _propTypes.default.object,
|
|
141
|
+
name: _propTypes.default.string,
|
|
142
|
+
title: _propTypes.default.string.isRequired,
|
|
143
|
+
label: _propTypes.default.string,
|
|
144
|
+
formikProps: _propTypes.default.object,
|
|
145
|
+
loading: _propTypes.default.bool,
|
|
146
|
+
rowCount: _propTypes.default.number,
|
|
147
|
+
rows: _propTypes.default.arrayOf(_propTypes.default.object),
|
|
148
|
+
page: _propTypes.default.number,
|
|
149
|
+
pageSize: _propTypes.default.number,
|
|
150
|
+
columns: _propTypes.default.arrayOf(_propTypes.default.object).isRequired,
|
|
151
|
+
helperText: _propTypes.default.string,
|
|
152
|
+
formik: _propTypes.default.bool,
|
|
153
|
+
disabled: _propTypes.default.bool,
|
|
154
|
+
required: _propTypes.default.bool,
|
|
155
|
+
error: _propTypes.default.bool,
|
|
156
|
+
focused: _propTypes.default.bool,
|
|
157
|
+
fullWidth: _propTypes.default.bool,
|
|
158
|
+
tableProps: _propTypes.default.object,
|
|
159
|
+
getRenderedValue: _propTypes.default.func.isRequired,
|
|
160
|
+
getReturnedValue: _propTypes.default.func,
|
|
161
|
+
onPageChange: _propTypes.default.func.isRequired,
|
|
162
|
+
onChange: _propTypes.default.func,
|
|
163
|
+
onSubmit: _propTypes.default.func.isRequired
|
|
164
|
+
};
|
|
165
|
+
PuiCustomPopupReferentielField.defaultProps = {
|
|
166
|
+
disabled: false,
|
|
167
|
+
required: false,
|
|
168
|
+
error: false,
|
|
169
|
+
formik: true,
|
|
170
|
+
fullWidth: true,
|
|
171
|
+
loading: false,
|
|
172
|
+
formikProps: {
|
|
173
|
+
initialValues: {}
|
|
174
|
+
},
|
|
175
|
+
tableProps: {},
|
|
176
|
+
getReturnedValue: row => row,
|
|
177
|
+
onPageChange: () => {},
|
|
178
|
+
onChange: () => {}
|
|
179
|
+
};
|
|
180
|
+
var _default = exports.default = PuiCustomPopupReferentielField;
|