@portnet/ui 0.0.29 → 0.0.31
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.
|
@@ -15,7 +15,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
15
15
|
var _PuiButton = _interopRequireDefault(require("../buttons/PuiButton"));
|
|
16
16
|
var _StyledMuiTextField = _interopRequireDefault(require("../common/StyledMuiTextField"));
|
|
17
17
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
-
const _excluded = ["id", "className", "sx", "name", "label", "buttonText", "error", "disabled", "helperText", "focused", "fullWidth", "InputProps", "required", "accept", "multiple", "formatValue", "onChange"],
|
|
18
|
+
const _excluded = ["id", "className", "sx", "name", "label", "fileDescription", "buttonText", "error", "disabled", "helperText", "focused", "fullWidth", "InputProps", "required", "accept", "multiple", "formatValue", "onChange"],
|
|
19
19
|
_excluded2 = ["id", "className", "sx", "name", "label", "buttonText", "error", "helperText", "disabled", "focused", "fullWidth", "InputProps", "required", "accept", "multiple", "formatValue", "onChange"],
|
|
20
20
|
_excluded3 = ["formik", "id", "className", "sx", "name", "label", "buttonText", "error", "disabled", "helperText", "focused", "fullWidth", "InputProps", "required", "accept", "multiple", "formatValue", "onChange"];
|
|
21
21
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -52,6 +52,7 @@ const PuiStandardFileField = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
52
52
|
sx,
|
|
53
53
|
name,
|
|
54
54
|
label,
|
|
55
|
+
fileDescription,
|
|
55
56
|
buttonText,
|
|
56
57
|
error,
|
|
57
58
|
disabled,
|
|
@@ -67,14 +68,14 @@ const PuiStandardFileField = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
67
68
|
} = _ref,
|
|
68
69
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
69
70
|
const fileInputRef = React.useRef();
|
|
70
|
-
const [
|
|
71
|
+
const [innerFileDescription, setInnerFileDecription] = React.useState("");
|
|
71
72
|
const fileChangeHandler = async event => {
|
|
72
73
|
const files = event.target.files;
|
|
73
74
|
const filesCount = files.length;
|
|
74
75
|
if (filesCount > 1) {
|
|
75
|
-
|
|
76
|
+
setInnerFileDecription("".concat(filesCount, " Fichiers charg\xE9es"));
|
|
76
77
|
} else {
|
|
77
|
-
|
|
78
|
+
setInnerFileDecription(files[0].name);
|
|
78
79
|
}
|
|
79
80
|
onChange(files);
|
|
80
81
|
};
|
|
@@ -85,7 +86,7 @@ const PuiStandardFileField = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
|
85
86
|
className: className,
|
|
86
87
|
sx: sx,
|
|
87
88
|
label: label,
|
|
88
|
-
value: fileDescription,
|
|
89
|
+
value: fileDescription !== null && fileDescription !== void 0 ? fileDescription : innerFileDescription,
|
|
89
90
|
required: required,
|
|
90
91
|
disabled: disabled,
|
|
91
92
|
type: "text",
|
|
@@ -139,16 +140,29 @@ const PuiFormikFileField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
139
140
|
onChange
|
|
140
141
|
} = _ref2,
|
|
141
142
|
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
142
|
-
const [, meta] = (0, _formik.useField)(name);
|
|
143
|
+
const [field, meta] = (0, _formik.useField)(name);
|
|
143
144
|
const [hasError, setHasError] = React.useState(false);
|
|
145
|
+
const [fileDescription, setFileDecription] = React.useState("");
|
|
144
146
|
const formikContext = (0, _formik.useFormikContext)();
|
|
145
147
|
const handleChange = files => {
|
|
148
|
+
const filesCount = files.length;
|
|
149
|
+
if (filesCount > 1) {
|
|
150
|
+
setFileDecription("".concat(filesCount, " Fichiers charg\xE9es"));
|
|
151
|
+
} else {
|
|
152
|
+
setFileDecription(files[0].name);
|
|
153
|
+
}
|
|
146
154
|
formikContext.setFieldValue(name, formatValue(files));
|
|
147
155
|
onChange(files);
|
|
148
156
|
};
|
|
149
157
|
React.useEffect(() => {
|
|
150
158
|
setHasError(Boolean(name) && Boolean(meta) && Boolean(meta.touched) && Boolean(meta.error));
|
|
151
159
|
}, [name, meta]);
|
|
160
|
+
React.useEffect(() => {
|
|
161
|
+
if (!Boolean(field)) {
|
|
162
|
+
setFileDecription("");
|
|
163
|
+
}
|
|
164
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
165
|
+
}, [field.value]);
|
|
152
166
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardFileField, _objectSpread({
|
|
153
167
|
id: id,
|
|
154
168
|
ref: ref,
|
|
@@ -156,6 +170,7 @@ const PuiFormikFileField = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
|
156
170
|
sx: sx,
|
|
157
171
|
name: name,
|
|
158
172
|
label: label,
|
|
173
|
+
fileDescription: fileDescription,
|
|
159
174
|
buttonText: buttonText,
|
|
160
175
|
disabled: disabled,
|
|
161
176
|
error: error || hasError,
|
|
@@ -19,6 +19,7 @@ const PuiDefaultPage = _ref => {
|
|
|
19
19
|
topNav,
|
|
20
20
|
bottomNav,
|
|
21
21
|
loading,
|
|
22
|
+
show,
|
|
22
23
|
retour,
|
|
23
24
|
onRetour,
|
|
24
25
|
children
|
|
@@ -28,20 +29,22 @@ const PuiDefaultPage = _ref => {
|
|
|
28
29
|
title: title,
|
|
29
30
|
icon: titleIcon,
|
|
30
31
|
trace: trace
|
|
31
|
-
}),
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
}), show && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
33
|
+
children: [Boolean(topNav) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiNavigation.default, {
|
|
34
|
+
onRetour: onRetour,
|
|
35
|
+
retour: retour,
|
|
36
|
+
sx: {
|
|
37
|
+
marginBottom: 2
|
|
38
|
+
},
|
|
39
|
+
children: navActions
|
|
40
|
+
}), children, Boolean(bottomNav) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiNavigation.default, {
|
|
41
|
+
onRetour: onRetour,
|
|
42
|
+
retour: retour,
|
|
43
|
+
sx: {
|
|
44
|
+
marginTop: 2
|
|
45
|
+
},
|
|
46
|
+
children: navActions
|
|
47
|
+
})]
|
|
45
48
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiLoadingBackdrop.default, {
|
|
46
49
|
open: loading
|
|
47
50
|
})]
|
|
@@ -59,7 +62,8 @@ PuiDefaultPage.propTypes = {
|
|
|
59
62
|
onRetour: _propTypes.default.func
|
|
60
63
|
};
|
|
61
64
|
PuiDefaultPage.defaultProps = {
|
|
62
|
-
loading: false
|
|
65
|
+
loading: false,
|
|
66
|
+
show: true
|
|
63
67
|
};
|
|
64
68
|
var _default = PuiDefaultPage;
|
|
65
69
|
exports.default = _default;
|