@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,350 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
require("core-js/modules/es.symbol.description.js");
|
|
10
|
+
var _ArrowDropDown = _interopRequireDefault(require("@mui/icons-material/ArrowDropDown"));
|
|
11
|
+
var _Clear = _interopRequireDefault(require("@mui/icons-material/Clear"));
|
|
12
|
+
var _material = require("@mui/material");
|
|
13
|
+
var _styles = require("@mui/material/styles");
|
|
14
|
+
var _formik = require("formik");
|
|
15
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
16
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
+
var React = _react;
|
|
18
|
+
var _apperance = require("../../config/apperance");
|
|
19
|
+
var _StyledMuiTextField = _interopRequireDefault(require("../common/StyledMuiTextField"));
|
|
20
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
21
|
+
const _excluded = ["id", "className", "sx", "label", "name", "value", "error", "disabled", "required", "focused", "loading", "fullWidth", "helperText", "readOnly", "options", "onChange", "isOptionEqualToValue", "getOptionLabel", "getOptionValue", "getOptionKey"],
|
|
22
|
+
_excluded2 = ["id", "className", "sx", "label", "name", "value", "error", "disabled", "required", "focused", "loading", "fullWidth", "helperText", "readOnly", "options", "onChange", "getOptionLabel", "getOptionValue", "getOptionKey"],
|
|
23
|
+
_excluded3 = ["formik", "id", "className", "sx", "label", "name", "value", "error", "disabled", "required", "focused", "loading", "fullWidth", "helperText", "readOnly", "options", "onChange", "isOptionEqualToValue", "getOptionLabel", "getOptionValue", "getOptionKey"];
|
|
24
|
+
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); }
|
|
25
|
+
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; }
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
28
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
|
+
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; }
|
|
30
|
+
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; }
|
|
31
|
+
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; }
|
|
32
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
33
|
+
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); }
|
|
34
|
+
const StyledAutocompleteMuiTextField = (0, _styles.styled)( /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_StyledMuiTextField.default, _objectSpread({
|
|
35
|
+
ref: ref
|
|
36
|
+
}, props))))(() => {
|
|
37
|
+
return {
|
|
38
|
+
"& .MuiInputBase-root": {
|
|
39
|
+
padding: 0,
|
|
40
|
+
"&.Mui-error .MuiSvgIcon-root": {
|
|
41
|
+
color: _apperance.palette.error
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"& .MuiAutocomplete-endAdornment .MuiButtonBase-root:hover": {
|
|
45
|
+
backgroundColor: "transparent"
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
});
|
|
49
|
+
const PuiStandardAutocomplete = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
50
|
+
let {
|
|
51
|
+
id,
|
|
52
|
+
className,
|
|
53
|
+
sx,
|
|
54
|
+
label,
|
|
55
|
+
name,
|
|
56
|
+
value,
|
|
57
|
+
error,
|
|
58
|
+
disabled,
|
|
59
|
+
required,
|
|
60
|
+
focused,
|
|
61
|
+
loading,
|
|
62
|
+
fullWidth,
|
|
63
|
+
helperText,
|
|
64
|
+
readOnly,
|
|
65
|
+
options,
|
|
66
|
+
onChange,
|
|
67
|
+
isOptionEqualToValue,
|
|
68
|
+
getOptionLabel,
|
|
69
|
+
getOptionValue,
|
|
70
|
+
getOptionKey
|
|
71
|
+
} = _ref,
|
|
72
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
73
|
+
const handleChange = (event, option) => {
|
|
74
|
+
onChange(option !== null ? getOptionValue(option) : null);
|
|
75
|
+
};
|
|
76
|
+
const inputChangeHandler = (event, newInputValue, reason) => {
|
|
77
|
+
if (reason === "clear") {
|
|
78
|
+
onChange(null);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Autocomplete, _objectSpread({
|
|
82
|
+
ref: ref,
|
|
83
|
+
id: id,
|
|
84
|
+
className: className,
|
|
85
|
+
sx: sx,
|
|
86
|
+
label: label,
|
|
87
|
+
name: name,
|
|
88
|
+
value: value,
|
|
89
|
+
options: options,
|
|
90
|
+
disabled: loading || disabled,
|
|
91
|
+
loading: loading,
|
|
92
|
+
readOnly: readOnly,
|
|
93
|
+
clearText: "",
|
|
94
|
+
closeText: "",
|
|
95
|
+
openText: "",
|
|
96
|
+
fullWidth: fullWidth,
|
|
97
|
+
noOptionsText: "Pas d'options",
|
|
98
|
+
getOptionLabel: getOptionLabel,
|
|
99
|
+
isOptionEqualToValue: isOptionEqualToValue,
|
|
100
|
+
onChange: handleChange,
|
|
101
|
+
clearIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Clear.default, {
|
|
102
|
+
fontSize: "small"
|
|
103
|
+
}),
|
|
104
|
+
onInputChange: inputChangeHandler,
|
|
105
|
+
popupIcon: loading || disabled || readOnly ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_ArrowDropDown.default, {}),
|
|
106
|
+
PaperComponent: _ref2 => {
|
|
107
|
+
let {
|
|
108
|
+
children
|
|
109
|
+
} = _ref2;
|
|
110
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Paper, {
|
|
111
|
+
style: {
|
|
112
|
+
background: "white",
|
|
113
|
+
fontSize: 13
|
|
114
|
+
},
|
|
115
|
+
children: children
|
|
116
|
+
});
|
|
117
|
+
},
|
|
118
|
+
componentsProps: {
|
|
119
|
+
popper: {
|
|
120
|
+
sx: {
|
|
121
|
+
"& .MuiAutocomplete-listbox": {
|
|
122
|
+
paddingY: 0,
|
|
123
|
+
"& .MuiAutocomplete-option:not(:last-child)": {
|
|
124
|
+
borderBottom: "1px solid ".concat(_apperance.palette.gray.light)
|
|
125
|
+
},
|
|
126
|
+
"& .MuiAutocomplete-option": {
|
|
127
|
+
minHeight: "fit-content !important"
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
renderOption: (props, option) => {
|
|
134
|
+
return /*#__PURE__*/(0, _react.createElement)(_material.MenuItem, _objectSpread(_objectSpread({}, props), {}, {
|
|
135
|
+
value: getOptionValue(option),
|
|
136
|
+
key: getOptionKey(option),
|
|
137
|
+
sx: {
|
|
138
|
+
fontSize: 13
|
|
139
|
+
}
|
|
140
|
+
}), getOptionLabel(option));
|
|
141
|
+
},
|
|
142
|
+
renderInput: params => {
|
|
143
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledAutocompleteMuiTextField, _objectSpread(_objectSpread({}, params), {}, {
|
|
144
|
+
required: required,
|
|
145
|
+
focused: focused,
|
|
146
|
+
fullWidth: fullWidth,
|
|
147
|
+
label: label,
|
|
148
|
+
error: error,
|
|
149
|
+
helperText: helperText,
|
|
150
|
+
inputProps: _objectSpread(_objectSpread({}, params.inputProps), {}, {
|
|
151
|
+
name
|
|
152
|
+
}),
|
|
153
|
+
InputProps: _objectSpread(_objectSpread({}, params.InputProps), {}, {
|
|
154
|
+
endAdornment: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
155
|
+
children: [loading && !disabled ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.CircularProgress, {
|
|
156
|
+
size: 16,
|
|
157
|
+
sx: {
|
|
158
|
+
color: _apperance.palette.primary,
|
|
159
|
+
marginRight: "-25px"
|
|
160
|
+
}
|
|
161
|
+
}) : null, params.InputProps.endAdornment]
|
|
162
|
+
})
|
|
163
|
+
})
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
}, rest));
|
|
167
|
+
});
|
|
168
|
+
const PuiFormikAutocomplete = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
169
|
+
let {
|
|
170
|
+
id,
|
|
171
|
+
className,
|
|
172
|
+
sx,
|
|
173
|
+
label,
|
|
174
|
+
name,
|
|
175
|
+
value,
|
|
176
|
+
error,
|
|
177
|
+
disabled,
|
|
178
|
+
required,
|
|
179
|
+
focused,
|
|
180
|
+
loading,
|
|
181
|
+
fullWidth,
|
|
182
|
+
helperText,
|
|
183
|
+
readOnly,
|
|
184
|
+
options,
|
|
185
|
+
onChange,
|
|
186
|
+
getOptionLabel,
|
|
187
|
+
getOptionValue,
|
|
188
|
+
getOptionKey
|
|
189
|
+
} = _ref3,
|
|
190
|
+
rest = _objectWithoutProperties(_ref3, _excluded2);
|
|
191
|
+
const formikContext = (0, _formik.useFormikContext)();
|
|
192
|
+
const [field, meta] = (0, _formik.useField)(name);
|
|
193
|
+
const [selectedOption, setSelectedOption] = React.useState(null);
|
|
194
|
+
const [hasError, setHasError] = React.useState(false);
|
|
195
|
+
const changeHandler = option => {
|
|
196
|
+
formikContext.setFieldValue(name, option !== null ? getOptionValue(option) : "");
|
|
197
|
+
setSelectedOption(option);
|
|
198
|
+
onChange(option);
|
|
199
|
+
};
|
|
200
|
+
React.useEffect(() => {
|
|
201
|
+
setHasError(Boolean(meta) && Boolean(meta.touched) && Boolean(meta.error));
|
|
202
|
+
}, [meta]);
|
|
203
|
+
React.useEffect(() => {
|
|
204
|
+
if ((!Boolean(selectedOption) || getOptionValue(selectedOption) !== value) && value !== undefined && options !== undefined) {
|
|
205
|
+
let option;
|
|
206
|
+
if (typeof value === "object") {
|
|
207
|
+
option = value;
|
|
208
|
+
} else {
|
|
209
|
+
option = options.find(option => String(getOptionValue(option)) === String(value));
|
|
210
|
+
}
|
|
211
|
+
setSelectedOption(option);
|
|
212
|
+
formikContext.setFieldValue(name, getOptionValue(option));
|
|
213
|
+
}
|
|
214
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
215
|
+
}, [value, options]);
|
|
216
|
+
React.useEffect(() => {
|
|
217
|
+
if (!Boolean(field.value)) {
|
|
218
|
+
setSelectedOption(null);
|
|
219
|
+
}
|
|
220
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
221
|
+
}, [field.value]);
|
|
222
|
+
React.useEffect(() => {
|
|
223
|
+
if ((!Boolean(selectedOption) || getOptionValue(selectedOption) !== field.value) && field.value !== undefined && options !== undefined) {
|
|
224
|
+
let option;
|
|
225
|
+
if (typeof field.value === "object") {
|
|
226
|
+
option = field.value;
|
|
227
|
+
} else {
|
|
228
|
+
option = options.find(option => getOptionValue(option) === field.value);
|
|
229
|
+
}
|
|
230
|
+
setSelectedOption(option);
|
|
231
|
+
}
|
|
232
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
233
|
+
}, [field.value, options]);
|
|
234
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardAutocomplete, _objectSpread({
|
|
235
|
+
id: id,
|
|
236
|
+
ref: ref,
|
|
237
|
+
className: className,
|
|
238
|
+
sx: sx,
|
|
239
|
+
label: label,
|
|
240
|
+
name: name,
|
|
241
|
+
value: selectedOption !== null && selectedOption !== void 0 ? selectedOption : null,
|
|
242
|
+
error: error || hasError,
|
|
243
|
+
disabled: disabled,
|
|
244
|
+
required: required,
|
|
245
|
+
focused: focused,
|
|
246
|
+
loading: loading,
|
|
247
|
+
fullWidth: fullWidth,
|
|
248
|
+
helperText: hasError && Boolean(meta.error) ? meta.error : helperText !== null && helperText !== void 0 ? helperText : "",
|
|
249
|
+
readOnly: readOnly,
|
|
250
|
+
options: options,
|
|
251
|
+
onChange: changeHandler,
|
|
252
|
+
getOptionKey: getOptionKey,
|
|
253
|
+
getOptionLabel: getOptionLabel,
|
|
254
|
+
getOptionValue: option => option
|
|
255
|
+
}, rest));
|
|
256
|
+
});
|
|
257
|
+
const PuiAutocomplete = /*#__PURE__*/React.forwardRef((_ref4, ref) => {
|
|
258
|
+
let {
|
|
259
|
+
formik,
|
|
260
|
+
id,
|
|
261
|
+
className,
|
|
262
|
+
sx,
|
|
263
|
+
label,
|
|
264
|
+
name,
|
|
265
|
+
value,
|
|
266
|
+
error,
|
|
267
|
+
disabled,
|
|
268
|
+
required,
|
|
269
|
+
focused,
|
|
270
|
+
loading,
|
|
271
|
+
fullWidth,
|
|
272
|
+
helperText,
|
|
273
|
+
readOnly,
|
|
274
|
+
options,
|
|
275
|
+
onChange,
|
|
276
|
+
isOptionEqualToValue,
|
|
277
|
+
getOptionLabel,
|
|
278
|
+
getOptionValue,
|
|
279
|
+
getOptionKey
|
|
280
|
+
} = _ref4,
|
|
281
|
+
rest = _objectWithoutProperties(_ref4, _excluded3);
|
|
282
|
+
return /*#__PURE__*/React.createElement(formik ? PuiFormikAutocomplete : PuiStandardAutocomplete, _objectSpread({
|
|
283
|
+
ref,
|
|
284
|
+
id,
|
|
285
|
+
className,
|
|
286
|
+
sx,
|
|
287
|
+
label,
|
|
288
|
+
name,
|
|
289
|
+
value,
|
|
290
|
+
error,
|
|
291
|
+
disabled,
|
|
292
|
+
required,
|
|
293
|
+
focused,
|
|
294
|
+
loading,
|
|
295
|
+
fullWidth,
|
|
296
|
+
helperText,
|
|
297
|
+
readOnly,
|
|
298
|
+
options,
|
|
299
|
+
onChange,
|
|
300
|
+
isOptionEqualToValue,
|
|
301
|
+
getOptionLabel,
|
|
302
|
+
getOptionValue,
|
|
303
|
+
getOptionKey
|
|
304
|
+
}, rest), null);
|
|
305
|
+
});
|
|
306
|
+
PuiAutocomplete.propTypes = {
|
|
307
|
+
id: _propTypes.default.string,
|
|
308
|
+
className: _propTypes.default.string,
|
|
309
|
+
sx: _propTypes.default.object,
|
|
310
|
+
label: _propTypes.default.string,
|
|
311
|
+
name: _propTypes.default.string,
|
|
312
|
+
helperText: _propTypes.default.string,
|
|
313
|
+
disabled: _propTypes.default.bool,
|
|
314
|
+
required: _propTypes.default.bool,
|
|
315
|
+
error: _propTypes.default.bool,
|
|
316
|
+
formik: _propTypes.default.bool,
|
|
317
|
+
focused: _propTypes.default.bool,
|
|
318
|
+
loading: _propTypes.default.bool,
|
|
319
|
+
readOnly: _propTypes.default.bool,
|
|
320
|
+
fullWidth: _propTypes.default.bool,
|
|
321
|
+
options: _propTypes.default.array,
|
|
322
|
+
onChange: _propTypes.default.func,
|
|
323
|
+
isOptionEqualToValue: _propTypes.default.func,
|
|
324
|
+
getOptionKey: _propTypes.default.func,
|
|
325
|
+
getOptionValue: _propTypes.default.func,
|
|
326
|
+
getOptionLabel: _propTypes.default.func.isRequired
|
|
327
|
+
};
|
|
328
|
+
PuiAutocomplete.defaultProps = {
|
|
329
|
+
disabled: false,
|
|
330
|
+
loading: false,
|
|
331
|
+
required: false,
|
|
332
|
+
formik: true,
|
|
333
|
+
error: false,
|
|
334
|
+
fullWidth: true,
|
|
335
|
+
readOnly: false,
|
|
336
|
+
options: [],
|
|
337
|
+
getOptionKey: option => {
|
|
338
|
+
if (typeof option === "object") {
|
|
339
|
+
let key = "";
|
|
340
|
+
Object.keys(option).forEach(optionKey => {
|
|
341
|
+
key += "".concat(key.length === 0 ? "" : "-").concat(String(option[optionKey]));
|
|
342
|
+
});
|
|
343
|
+
return key;
|
|
344
|
+
}
|
|
345
|
+
return option;
|
|
346
|
+
},
|
|
347
|
+
getOptionValue: option => option,
|
|
348
|
+
onChange: () => {}
|
|
349
|
+
};
|
|
350
|
+
var _default = exports.default = PuiAutocomplete;
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.weak-map.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
require("core-js/modules/es.json.stringify.js");
|
|
9
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
10
|
+
require("core-js/modules/es.array.includes.js");
|
|
11
|
+
require("core-js/modules/es.string.includes.js");
|
|
12
|
+
require("core-js/modules/es.symbol.description.js");
|
|
13
|
+
var _CheckBoxOutlineBlankRounded = _interopRequireDefault(require("@mui/icons-material/CheckBoxOutlineBlankRounded"));
|
|
14
|
+
var _CheckBoxRounded = _interopRequireDefault(require("@mui/icons-material/CheckBoxRounded"));
|
|
15
|
+
var _material = require("@mui/material");
|
|
16
|
+
var _styles = require("@mui/material/styles");
|
|
17
|
+
var _formik = require("formik");
|
|
18
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
19
|
+
var React = _interopRequireWildcard(require("react"));
|
|
20
|
+
var _apperance = require("../../config/apperance");
|
|
21
|
+
var _PuiIcon = _interopRequireDefault(require("../others/PuiIcon"));
|
|
22
|
+
var _PuiIndication = _interopRequireDefault(require("../typography/PuiIndication"));
|
|
23
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
|
+
const _excluded = ["id", "className", "sx", "name", "value", "label", "checked", "error", "helperText", "disableHelperText", "disabled", "required", "onChange", "asArray"],
|
|
25
|
+
_excluded2 = ["id", "className", "sx", "name", "value", "defaultValue", "label", "error", "disableHelperText", "helperText", "disabled", "checked", "required", "asArray", "onChange"],
|
|
26
|
+
_excluded3 = ["formik", "id", "className", "sx", "name", "value", "defaultValue", "label", "checked", "asArray", "error", "helperText", "disableHelperText", "disabled", "required", "onChange"];
|
|
27
|
+
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); }
|
|
28
|
+
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; }
|
|
29
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
30
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
31
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
32
|
+
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; }
|
|
33
|
+
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; }
|
|
34
|
+
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; }
|
|
35
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
|
|
36
|
+
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); }
|
|
37
|
+
const StyledMuiFormControl = (0, _styles.styled)( /*#__PURE__*/React.forwardRef((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControl, _objectSpread({
|
|
38
|
+
ref: ref
|
|
39
|
+
}, props))))(() => {
|
|
40
|
+
return {
|
|
41
|
+
"&.MuiFormControl-root": {
|
|
42
|
+
"& .MuiCheckbox-root": {
|
|
43
|
+
"& .MuiTouchRipple-root": {
|
|
44
|
+
display: "none"
|
|
45
|
+
},
|
|
46
|
+
"&.Mui-checked .MuiTouchRipple-root": {
|
|
47
|
+
boxSizing: "border-box",
|
|
48
|
+
display: "block",
|
|
49
|
+
position: "absolute",
|
|
50
|
+
width: "20px",
|
|
51
|
+
height: "20px",
|
|
52
|
+
left: "50%",
|
|
53
|
+
top: "50%",
|
|
54
|
+
transform: "translate(-50%,-50%)",
|
|
55
|
+
backgroundColor: _apperance.palette.primary,
|
|
56
|
+
border: "2px ".concat(_apperance.palette.gray.light, " solid"),
|
|
57
|
+
borderRadius: "2px",
|
|
58
|
+
"& *": {
|
|
59
|
+
display: "none"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"& .MuiSvgIcon-root": {
|
|
63
|
+
width: "32px",
|
|
64
|
+
height: "32px"
|
|
65
|
+
},
|
|
66
|
+
"&.Mui-disabled .MuiSvgIcon-root": {
|
|
67
|
+
color: _apperance.palette.gray.dark
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"& .Mui-error .MuiCheckbox-colorPrimary": {
|
|
71
|
+
color: _apperance.palette.error
|
|
72
|
+
},
|
|
73
|
+
"& .Mui-error .Mui-checked .MuiTouchRipple-root": {
|
|
74
|
+
backgroundColor: _apperance.palette.error
|
|
75
|
+
},
|
|
76
|
+
"& .MuiCheckbox-colorPrimary": {
|
|
77
|
+
color: _apperance.palette.primary
|
|
78
|
+
},
|
|
79
|
+
"&.required .MuiInputBase-root": {
|
|
80
|
+
backgroundColor: _apperance.palette.background.required
|
|
81
|
+
},
|
|
82
|
+
"& .MuiFormControlLabel-root": {
|
|
83
|
+
margin: 0,
|
|
84
|
+
"& .MuiTypography-root": {
|
|
85
|
+
fontSize: ".8rem",
|
|
86
|
+
color: _apperance.palette.gray.darker,
|
|
87
|
+
lineSpacing: "-0.03em",
|
|
88
|
+
userSelect: "none",
|
|
89
|
+
fontWeight: "600"
|
|
90
|
+
},
|
|
91
|
+
"&.Mui-error": {
|
|
92
|
+
"& .MuiTypography-root": {
|
|
93
|
+
color: _apperance.palette.error
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
"& .MuiFormHelperText-root": {
|
|
98
|
+
marginTop: "-10px",
|
|
99
|
+
fontWeight: "bold",
|
|
100
|
+
fontSize: ".7rem",
|
|
101
|
+
color: _apperance.palette.gray.darker
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
});
|
|
106
|
+
const PuiStandardCheckbox = /*#__PURE__*/React.forwardRef((_ref, ref) => {
|
|
107
|
+
let {
|
|
108
|
+
id,
|
|
109
|
+
className,
|
|
110
|
+
sx,
|
|
111
|
+
name,
|
|
112
|
+
value,
|
|
113
|
+
label,
|
|
114
|
+
checked,
|
|
115
|
+
error,
|
|
116
|
+
helperText,
|
|
117
|
+
disableHelperText,
|
|
118
|
+
disabled,
|
|
119
|
+
required,
|
|
120
|
+
onChange,
|
|
121
|
+
asArray
|
|
122
|
+
} = _ref,
|
|
123
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
124
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(StyledMuiFormControl, {
|
|
125
|
+
error: error,
|
|
126
|
+
sx: sx,
|
|
127
|
+
id: id,
|
|
128
|
+
className: className,
|
|
129
|
+
disabled: disabled,
|
|
130
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormControlLabel, {
|
|
131
|
+
ref: ref,
|
|
132
|
+
disabled: disabled,
|
|
133
|
+
label: label !== undefined ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
134
|
+
children: [label, required && " *"]
|
|
135
|
+
}) : undefined,
|
|
136
|
+
control: /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Checkbox, _objectSpread({
|
|
137
|
+
name: name,
|
|
138
|
+
checked: checked,
|
|
139
|
+
required: required,
|
|
140
|
+
disabled: disabled,
|
|
141
|
+
value: value !== null && value !== void 0 ? value : true,
|
|
142
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckBoxOutlineBlankRounded.default, {}),
|
|
143
|
+
checkedIcon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_CheckBoxRounded.default, {}),
|
|
144
|
+
onChange: onChange
|
|
145
|
+
}, rest))
|
|
146
|
+
}), !disableHelperText && /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormHelperText, {
|
|
147
|
+
component: "div",
|
|
148
|
+
children: error && Boolean(helperText) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIndication.default, {
|
|
149
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
|
|
150
|
+
type: "danger"
|
|
151
|
+
}),
|
|
152
|
+
color: "error",
|
|
153
|
+
size: "small",
|
|
154
|
+
children: typeof helperText === "object" ? JSON.stringify(helperText) : helperText
|
|
155
|
+
}) : helperText
|
|
156
|
+
})]
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
const PuiFormikCheckbox = /*#__PURE__*/React.forwardRef((_ref2, ref) => {
|
|
160
|
+
var _field$value;
|
|
161
|
+
let {
|
|
162
|
+
id,
|
|
163
|
+
className,
|
|
164
|
+
sx,
|
|
165
|
+
name,
|
|
166
|
+
value,
|
|
167
|
+
defaultValue,
|
|
168
|
+
label,
|
|
169
|
+
error,
|
|
170
|
+
disableHelperText,
|
|
171
|
+
helperText,
|
|
172
|
+
disabled,
|
|
173
|
+
checked,
|
|
174
|
+
required,
|
|
175
|
+
asArray,
|
|
176
|
+
onChange
|
|
177
|
+
} = _ref2,
|
|
178
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
179
|
+
const [field, meta] = (0, _formik.useField)(name);
|
|
180
|
+
const formikContext = (0, _formik.useFormikContext)();
|
|
181
|
+
const [hasError, setHasError] = React.useState(false);
|
|
182
|
+
const changeHandler = (event, hasBeenChecked) => {
|
|
183
|
+
if (checked === undefined) {
|
|
184
|
+
if (asArray || value === undefined) {
|
|
185
|
+
field.onChange(event);
|
|
186
|
+
} else {
|
|
187
|
+
formikContext.setFieldValue(name, hasBeenChecked ? event.target.value : formikContext.initialValues[name]);
|
|
188
|
+
}
|
|
189
|
+
onChange(event);
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
React.useEffect(() => {
|
|
193
|
+
setHasError(Boolean(meta) && Boolean(meta.touched) && Boolean(meta.error));
|
|
194
|
+
}, [meta]);
|
|
195
|
+
React.useEffect(() => {
|
|
196
|
+
if (defaultValue !== undefined && !asArray) {
|
|
197
|
+
formikContext.setFieldValue(name, defaultValue);
|
|
198
|
+
}
|
|
199
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
200
|
+
}, [defaultValue, asArray]);
|
|
201
|
+
React.useEffect(() => {
|
|
202
|
+
if (checked !== undefined) {
|
|
203
|
+
if (checked) {
|
|
204
|
+
if (asArray) {
|
|
205
|
+
if (Array.isArray(field.value) && !field.value.map(checkedValue => JSON.stringify(checkedValue)).includes(JSON.stringify(value))) {
|
|
206
|
+
formikContext.setFieldValue(name, [...field.value, value]);
|
|
207
|
+
} else {
|
|
208
|
+
formikContext.setFieldValue(name, [value]);
|
|
209
|
+
}
|
|
210
|
+
} else {
|
|
211
|
+
formikContext.setFieldValue(name, value);
|
|
212
|
+
}
|
|
213
|
+
} else {
|
|
214
|
+
if (asArray && Array.isArray(field.value) && field.value.map(checkedValue => JSON.stringify(checkedValue)).includes(JSON.stringify(value))) {
|
|
215
|
+
formikContext.setFieldValue(name, field.value.filter(checkedValue => JSON.stringify(checkedValue) !== JSON.stringify(value)));
|
|
216
|
+
} else {
|
|
217
|
+
if (JSON.stringify(field.value) === JSON.stringify(value)) {
|
|
218
|
+
formikContext.setFieldValue(name, formikContext.initialValues[name]);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
224
|
+
}, [checked]);
|
|
225
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardCheckbox, _objectSpread({
|
|
226
|
+
id: id,
|
|
227
|
+
ref: ref,
|
|
228
|
+
className: className,
|
|
229
|
+
sx: sx,
|
|
230
|
+
name: name,
|
|
231
|
+
error: error || hasError,
|
|
232
|
+
helperText: hasError && Boolean(meta.error) ? meta.error : helperText !== null && helperText !== void 0 ? helperText : "",
|
|
233
|
+
value: value,
|
|
234
|
+
label: label,
|
|
235
|
+
disableHelperText: disableHelperText,
|
|
236
|
+
checked: checked !== undefined ? checked : value !== undefined ? !Array.isArray(field.value) && String(field.value) === String(value) || Array.isArray(field.value) && ((_field$value = field.value) === null || _field$value === void 0 ? void 0 : _field$value.includes(String(value))) : Boolean(field.value),
|
|
237
|
+
disabled: disabled,
|
|
238
|
+
required: required,
|
|
239
|
+
onChange: changeHandler
|
|
240
|
+
}, rest));
|
|
241
|
+
});
|
|
242
|
+
const PuiCheckbox = /*#__PURE__*/React.forwardRef((_ref3, ref) => {
|
|
243
|
+
let {
|
|
244
|
+
formik,
|
|
245
|
+
id,
|
|
246
|
+
className,
|
|
247
|
+
sx,
|
|
248
|
+
name,
|
|
249
|
+
value,
|
|
250
|
+
defaultValue,
|
|
251
|
+
label,
|
|
252
|
+
checked,
|
|
253
|
+
asArray,
|
|
254
|
+
error,
|
|
255
|
+
helperText,
|
|
256
|
+
disableHelperText,
|
|
257
|
+
disabled,
|
|
258
|
+
required,
|
|
259
|
+
onChange
|
|
260
|
+
} = _ref3,
|
|
261
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
262
|
+
return /*#__PURE__*/React.createElement(formik ? PuiFormikCheckbox : PuiStandardCheckbox, _objectSpread({
|
|
263
|
+
id,
|
|
264
|
+
ref,
|
|
265
|
+
className,
|
|
266
|
+
sx,
|
|
267
|
+
name,
|
|
268
|
+
value,
|
|
269
|
+
defaultValue,
|
|
270
|
+
label,
|
|
271
|
+
checked,
|
|
272
|
+
asArray,
|
|
273
|
+
error,
|
|
274
|
+
helperText,
|
|
275
|
+
disableHelperText,
|
|
276
|
+
disabled,
|
|
277
|
+
required,
|
|
278
|
+
onChange
|
|
279
|
+
}, rest));
|
|
280
|
+
});
|
|
281
|
+
PuiCheckbox.propTypes = {
|
|
282
|
+
id: _propTypes.default.string,
|
|
283
|
+
className: _propTypes.default.string,
|
|
284
|
+
sx: _propTypes.default.object,
|
|
285
|
+
label: _propTypes.default.any,
|
|
286
|
+
helperText: _propTypes.default.string,
|
|
287
|
+
name: _propTypes.default.string,
|
|
288
|
+
defaultValue: _propTypes.default.any,
|
|
289
|
+
asArray: _propTypes.default.bool,
|
|
290
|
+
error: _propTypes.default.bool,
|
|
291
|
+
formik: _propTypes.default.bool,
|
|
292
|
+
disabled: _propTypes.default.bool,
|
|
293
|
+
disableHelperText: _propTypes.default.bool,
|
|
294
|
+
required: _propTypes.default.bool,
|
|
295
|
+
checked: _propTypes.default.bool,
|
|
296
|
+
onChange: _propTypes.default.func
|
|
297
|
+
};
|
|
298
|
+
PuiCheckbox.defaultProps = {
|
|
299
|
+
error: false,
|
|
300
|
+
formik: true,
|
|
301
|
+
disabled: false,
|
|
302
|
+
asArray: false,
|
|
303
|
+
disableHelperText: false,
|
|
304
|
+
required: false,
|
|
305
|
+
onChange: () => {}
|
|
306
|
+
};
|
|
307
|
+
var _default = exports.default = PuiCheckbox;
|