@portnet/ui 0.0.18
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/README.md +70 -0
- package/dist/components/buttons/PuiButton.js +133 -0
- package/dist/components/buttons/PuiIconButton.js +94 -0
- package/dist/components/common/PuiAlertContext.js +11 -0
- package/dist/components/common/StyledMuiButton.js +45 -0
- package/dist/components/common/StyledMuiTextField.js +109 -0
- package/dist/components/inputs/PuiAutocomplete.js +338 -0
- package/dist/components/inputs/PuiCheckbox.js +264 -0
- package/dist/components/inputs/PuiCheckboxGroup.js +216 -0
- package/dist/components/inputs/PuiCheckboxItem.js +158 -0
- package/dist/components/inputs/PuiDateField.js +259 -0
- package/dist/components/inputs/PuiFileField.js +244 -0
- package/dist/components/inputs/PuiSelect.js +349 -0
- package/dist/components/inputs/PuiTextField.js +256 -0
- package/dist/components/others/PuiBadge.js +57 -0
- package/dist/components/others/PuiChip.js +145 -0
- package/dist/components/others/PuiDialog.js +100 -0
- package/dist/components/others/PuiFormikForm.js +57 -0
- package/dist/components/others/PuiGrid.js +22 -0
- package/dist/components/others/PuiIcon.js +88 -0
- package/dist/components/others/PuiLoadingBackdrop.js +33 -0
- package/dist/components/others/PuiMainContainer.js +37 -0
- package/dist/components/others/PuiNavigation.js +64 -0
- package/dist/components/others/PuiSection.js +94 -0
- package/dist/components/others/PuiTooltip.js +85 -0
- package/dist/components/providers/PuiAlertProvider.js +117 -0
- package/dist/components/referentiel/common/ReferetielContext.js +11 -0
- package/dist/components/referentiel/components/PuiSimplePopupReferentielField.js +306 -0
- package/dist/components/referentiel/components/PuiSimpleReferentielField.js +190 -0
- package/dist/components/referentiel/components/PuiSpecificReferentielField.js +302 -0
- package/dist/components/referentiel/components/constants/specificReferentielsApis.js +17 -0
- package/dist/components/referentiel/components/constants/specificReferentielsBaseColumns.js +337 -0
- package/dist/components/referentiel/components/constants/specificReferentielsBaseFilters.js +325 -0
- package/dist/components/referentiel/components/constants/specificReferentielsInitialValues.js +48 -0
- package/dist/components/referentiel/components/constants/specificReferentielsKeys.js +18 -0
- package/dist/components/referentiel/components/constants/specificReferentielsTitles.js +17 -0
- package/dist/components/referentiel/components/constants/specificReferentielsValidationSchemas.js +53 -0
- package/dist/components/referentiel/components/general/PuiPopupReferentielBase.js +303 -0
- package/dist/components/referentiel/providers/PuiReferentielProvider.js +56 -0
- package/dist/components/tab/PuiTab.js +26 -0
- package/dist/components/tab/PuiTabs.js +137 -0
- package/dist/components/table/PuiTable.js +352 -0
- package/dist/components/table/PuiTableAction.js +63 -0
- package/dist/components/typography/PuiDefinition.js +43 -0
- package/dist/components/typography/PuiIndication.js +76 -0
- package/dist/components/typography/PuiMainTitle.js +82 -0
- package/dist/components/ui/dialogs/PuiSearchDialog.js +96 -0
- package/dist/components/ui/pages/errors/PuiErrorBasePage.js +70 -0
- package/dist/components/ui/pages/errors/PuiNetworkErrorPage.js +37 -0
- package/dist/components/ui/pages/errors/PuiNotFoundErrorPage.js +31 -0
- package/dist/components/ui/pages/errors/PuiServerErrorPage.js +38 -0
- package/dist/components/ui/pages/general/PuiDefaultPage.js +65 -0
- package/dist/components/ui/pages/general/PuiSearchPage.js +161 -0
- package/dist/config/apperance.js +26 -0
- package/dist/config/mapping.js +28 -0
- package/dist/config/referentiel.js +11 -0
- package/dist/general/yupValidationErrors.js +10 -0
- package/dist/hooks/useAlert.js +17 -0
- package/dist/hooks/useAxios.js +22 -0
- package/dist/hooks/useQuery.js +20 -0
- package/dist/index.js +293 -0
- package/package.json +93 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = exports.PuiStandardCheckboxGroupContext = exports.PuiFormikCheckboxGroupContext = exports.PuiCheckboxGroupContext = void 0;
|
|
8
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
9
|
+
require("core-js/modules/es.array.includes.js");
|
|
10
|
+
require("core-js/modules/es.string.includes.js");
|
|
11
|
+
var _material = require("@mui/material");
|
|
12
|
+
var _formik = require("formik");
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var _apperance = require("../../config/apperance");
|
|
16
|
+
var _PuiIcon = _interopRequireDefault(require("../others/PuiIcon"));
|
|
17
|
+
var _PuiIndication = _interopRequireDefault(require("../typography/PuiIndication"));
|
|
18
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
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; }
|
|
23
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
24
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
25
|
+
const PuiStandardCheckboxGroupContext = /*#__PURE__*/_react.default.createContext(null);
|
|
26
|
+
exports.PuiStandardCheckboxGroupContext = PuiStandardCheckboxGroupContext;
|
|
27
|
+
const PuiFormikCheckboxGroupContext = /*#__PURE__*/_react.default.createContext(null);
|
|
28
|
+
exports.PuiFormikCheckboxGroupContext = PuiFormikCheckboxGroupContext;
|
|
29
|
+
const PuiCheckboxGroupContext = /*#__PURE__*/_react.default.createContext(null);
|
|
30
|
+
exports.PuiCheckboxGroupContext = PuiCheckboxGroupContext;
|
|
31
|
+
const PuiStandardCheckboxGroup = _ref => {
|
|
32
|
+
let {
|
|
33
|
+
id,
|
|
34
|
+
className,
|
|
35
|
+
sx,
|
|
36
|
+
name,
|
|
37
|
+
error,
|
|
38
|
+
disabled,
|
|
39
|
+
helperText,
|
|
40
|
+
onChange,
|
|
41
|
+
children
|
|
42
|
+
} = _ref;
|
|
43
|
+
const [, setValues] = _react.default.useState({});
|
|
44
|
+
const changeHandler = function changeHandler(checkboxId, value, isChecked) {
|
|
45
|
+
let executeOnChange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
46
|
+
setValues(oldValues => {
|
|
47
|
+
let newValues = {};
|
|
48
|
+
const oldValuesKeys = Object.keys(oldValues);
|
|
49
|
+
if (!isChecked) {
|
|
50
|
+
if (oldValuesKeys.includes(checkboxId)) {
|
|
51
|
+
oldValuesKeys.forEach(key => {
|
|
52
|
+
if (key !== checkboxId) {
|
|
53
|
+
newValues[key] = oldValues[key];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
newValues = _objectSpread({}, oldValues);
|
|
58
|
+
}
|
|
59
|
+
} else {
|
|
60
|
+
newValues = _objectSpread(_objectSpread({}, oldValues), {}, {
|
|
61
|
+
[checkboxId]: value
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
if (executeOnChange) {
|
|
65
|
+
onChange(Object.values(newValues));
|
|
66
|
+
}
|
|
67
|
+
return newValues;
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardCheckboxGroupContext.Provider, {
|
|
71
|
+
value: {
|
|
72
|
+
name,
|
|
73
|
+
error,
|
|
74
|
+
disabled,
|
|
75
|
+
changeHandler
|
|
76
|
+
},
|
|
77
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.FormGroup, {
|
|
78
|
+
id: id,
|
|
79
|
+
className: className,
|
|
80
|
+
sx: sx,
|
|
81
|
+
children: [children, /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormHelperText, {
|
|
82
|
+
component: "div",
|
|
83
|
+
sx: {
|
|
84
|
+
marginLeft: 3,
|
|
85
|
+
fontWeight: "bold",
|
|
86
|
+
fontSize: ".7rem",
|
|
87
|
+
color: _apperance.palette.gray.darker
|
|
88
|
+
},
|
|
89
|
+
children: error && Boolean(helperText) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIndication.default, {
|
|
90
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
|
|
91
|
+
type: "danger"
|
|
92
|
+
}),
|
|
93
|
+
color: "error",
|
|
94
|
+
size: "small",
|
|
95
|
+
children: helperText
|
|
96
|
+
}) : helperText
|
|
97
|
+
})]
|
|
98
|
+
})
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const CustomHelperText = _ref2 => {
|
|
102
|
+
let {
|
|
103
|
+
error,
|
|
104
|
+
helperText
|
|
105
|
+
} = _ref2;
|
|
106
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_material.FormHelperText, {
|
|
107
|
+
component: "div",
|
|
108
|
+
sx: {
|
|
109
|
+
marginLeft: 3,
|
|
110
|
+
fontWeight: "bold",
|
|
111
|
+
fontSize: ".7rem",
|
|
112
|
+
color: _apperance.palette.gray.darker
|
|
113
|
+
},
|
|
114
|
+
children: error && Boolean(helperText) ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIndication.default, {
|
|
115
|
+
icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiIcon.default, {
|
|
116
|
+
type: "danger"
|
|
117
|
+
}),
|
|
118
|
+
color: "error",
|
|
119
|
+
size: "small",
|
|
120
|
+
children: helperText
|
|
121
|
+
}) : helperText
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
const PuiFormikCheckboxGroup = _ref3 => {
|
|
125
|
+
let {
|
|
126
|
+
id,
|
|
127
|
+
className,
|
|
128
|
+
sx,
|
|
129
|
+
name,
|
|
130
|
+
error,
|
|
131
|
+
disabled,
|
|
132
|
+
helperText,
|
|
133
|
+
onChange,
|
|
134
|
+
children
|
|
135
|
+
} = _ref3;
|
|
136
|
+
const [isComponentMounted, setIsComponentMounted] = _react.default.useState(false);
|
|
137
|
+
const [field, meta] = (0, _formik.useField)(name);
|
|
138
|
+
const [hasError, setHasError] = _react.default.useState(false);
|
|
139
|
+
_react.default.useEffect(() => {
|
|
140
|
+
setHasError(Boolean(meta) && Boolean(meta.touched) && Boolean(meta.error));
|
|
141
|
+
}, [meta]);
|
|
142
|
+
_react.default.useEffect(() => {
|
|
143
|
+
if (isComponentMounted) {
|
|
144
|
+
onChange(field.value);
|
|
145
|
+
}
|
|
146
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
147
|
+
}, [field.value]);
|
|
148
|
+
_react.default.useEffect(() => {
|
|
149
|
+
setIsComponentMounted(true);
|
|
150
|
+
}, []);
|
|
151
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiFormikCheckboxGroupContext.Provider, {
|
|
152
|
+
value: {
|
|
153
|
+
name,
|
|
154
|
+
error: error || hasError,
|
|
155
|
+
disabled
|
|
156
|
+
},
|
|
157
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.FormGroup, {
|
|
158
|
+
id: id,
|
|
159
|
+
className: className,
|
|
160
|
+
sx: sx,
|
|
161
|
+
children: [children, /*#__PURE__*/(0, _jsxRuntime.jsx)(CustomHelperText, {
|
|
162
|
+
error: error || hasError,
|
|
163
|
+
helperText: hasError && Boolean(meta.error) ? meta.error : helperText !== null && helperText !== void 0 ? helperText : ""
|
|
164
|
+
})]
|
|
165
|
+
})
|
|
166
|
+
});
|
|
167
|
+
};
|
|
168
|
+
const PuiCheckboxGroup = /*#__PURE__*/_react.default.forwardRef((_ref4, ref) => {
|
|
169
|
+
let {
|
|
170
|
+
formik,
|
|
171
|
+
id,
|
|
172
|
+
className,
|
|
173
|
+
sx,
|
|
174
|
+
name,
|
|
175
|
+
error,
|
|
176
|
+
disabled,
|
|
177
|
+
helperText,
|
|
178
|
+
onChange,
|
|
179
|
+
children
|
|
180
|
+
} = _ref4;
|
|
181
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiCheckboxGroupContext.Provider, {
|
|
182
|
+
value: {
|
|
183
|
+
formik
|
|
184
|
+
},
|
|
185
|
+
children: /*#__PURE__*/_react.default.createElement(formik ? PuiFormikCheckboxGroup : PuiStandardCheckboxGroup, {
|
|
186
|
+
ref,
|
|
187
|
+
id,
|
|
188
|
+
className,
|
|
189
|
+
sx,
|
|
190
|
+
name,
|
|
191
|
+
error,
|
|
192
|
+
disabled,
|
|
193
|
+
helperText,
|
|
194
|
+
onChange
|
|
195
|
+
}, children)
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
PuiCheckboxGroup.propTypes = {
|
|
199
|
+
id: _propTypes.default.string,
|
|
200
|
+
className: _propTypes.default.string,
|
|
201
|
+
sx: _propTypes.default.object,
|
|
202
|
+
name: _propTypes.default.string,
|
|
203
|
+
error: _propTypes.default.bool,
|
|
204
|
+
formik: _propTypes.default.bool,
|
|
205
|
+
helperText: _propTypes.default.string,
|
|
206
|
+
disabled: _propTypes.default.bool,
|
|
207
|
+
onChange: _propTypes.default.func
|
|
208
|
+
};
|
|
209
|
+
PuiCheckboxGroup.defaultProps = {
|
|
210
|
+
error: false,
|
|
211
|
+
formik: false,
|
|
212
|
+
disabled: false,
|
|
213
|
+
onChange: () => {}
|
|
214
|
+
};
|
|
215
|
+
var _default = PuiCheckboxGroup;
|
|
216
|
+
exports.default = _default;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
require("core-js/modules/es.symbol.description.js");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
|
+
var _react = _interopRequireDefault(require("react"));
|
|
10
|
+
var _PuiCheckbox = _interopRequireDefault(require("./PuiCheckbox"));
|
|
11
|
+
var _PuiCheckboxGroup = require("./PuiCheckboxGroup");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
const _excluded = ["id", "className", "sx", "value", "label", "error", "checked", "disabled", "required", "onChange"],
|
|
14
|
+
_excluded2 = ["id", "className", "sx", "value", "label", "error", "disabled", "required", "onChange"],
|
|
15
|
+
_excluded3 = ["id", "className", "sx", "value", "label", "error", "checked", "disabled", "required", "onChange"];
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
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; }
|
|
20
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
21
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
const PuiStandardCheckboxItem = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
25
|
+
let {
|
|
26
|
+
id,
|
|
27
|
+
className,
|
|
28
|
+
sx,
|
|
29
|
+
value,
|
|
30
|
+
label,
|
|
31
|
+
error: innerError,
|
|
32
|
+
checked,
|
|
33
|
+
disabled: innerDisabled,
|
|
34
|
+
required,
|
|
35
|
+
onChange
|
|
36
|
+
} = _ref,
|
|
37
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
38
|
+
const {
|
|
39
|
+
name,
|
|
40
|
+
error,
|
|
41
|
+
disabled,
|
|
42
|
+
changeHandler
|
|
43
|
+
} = _react.default.useContext(_PuiCheckboxGroup.PuiStandardCheckboxGroupContext);
|
|
44
|
+
const checkboxId = _react.default.useId();
|
|
45
|
+
const innerChangeHandler = (event, hasBeenChecked) => {
|
|
46
|
+
if (checked === undefined) {
|
|
47
|
+
changeHandler(checkboxId, value, event.target.checked);
|
|
48
|
+
onChange(event, hasBeenChecked);
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
_react.default.useEffect(() => {
|
|
52
|
+
if (checked) {
|
|
53
|
+
changeHandler(checkboxId, value, checked, false);
|
|
54
|
+
}
|
|
55
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
56
|
+
}, [checked]);
|
|
57
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiCheckbox.default, _objectSpread({
|
|
58
|
+
id: id,
|
|
59
|
+
ref: ref,
|
|
60
|
+
className: className,
|
|
61
|
+
name: name,
|
|
62
|
+
error: error || innerError,
|
|
63
|
+
sx: sx,
|
|
64
|
+
disableHelperText: true,
|
|
65
|
+
value: value,
|
|
66
|
+
label: label,
|
|
67
|
+
checked: checked,
|
|
68
|
+
disabled: innerDisabled || disabled,
|
|
69
|
+
required: required,
|
|
70
|
+
onChange: innerChangeHandler
|
|
71
|
+
}, rest));
|
|
72
|
+
});
|
|
73
|
+
const PuiFormikCheckboxItem = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
74
|
+
let {
|
|
75
|
+
id,
|
|
76
|
+
className,
|
|
77
|
+
sx,
|
|
78
|
+
value,
|
|
79
|
+
label,
|
|
80
|
+
error: innerError,
|
|
81
|
+
disabled: innerDisabled,
|
|
82
|
+
required,
|
|
83
|
+
onChange
|
|
84
|
+
} = _ref2,
|
|
85
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
86
|
+
const {
|
|
87
|
+
name,
|
|
88
|
+
error,
|
|
89
|
+
disabled
|
|
90
|
+
} = _react.default.useContext(_PuiCheckboxGroup.PuiFormikCheckboxGroupContext);
|
|
91
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_PuiCheckbox.default, _objectSpread({
|
|
92
|
+
formik: true,
|
|
93
|
+
id: id,
|
|
94
|
+
ref: ref,
|
|
95
|
+
asArray: true,
|
|
96
|
+
disableHelperText: true,
|
|
97
|
+
className: className,
|
|
98
|
+
name: name,
|
|
99
|
+
error: error || innerError,
|
|
100
|
+
sx: sx,
|
|
101
|
+
value: value,
|
|
102
|
+
label: label,
|
|
103
|
+
disabled: innerDisabled || disabled,
|
|
104
|
+
required: required,
|
|
105
|
+
onChange: onChange
|
|
106
|
+
}, rest));
|
|
107
|
+
});
|
|
108
|
+
const PuiCheckboxItem = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
109
|
+
let {
|
|
110
|
+
id,
|
|
111
|
+
className,
|
|
112
|
+
sx,
|
|
113
|
+
value,
|
|
114
|
+
label,
|
|
115
|
+
error,
|
|
116
|
+
checked,
|
|
117
|
+
disabled,
|
|
118
|
+
required,
|
|
119
|
+
onChange
|
|
120
|
+
} = _ref3,
|
|
121
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
122
|
+
const {
|
|
123
|
+
formik
|
|
124
|
+
} = _react.default.useContext(_PuiCheckboxGroup.PuiCheckboxGroupContext);
|
|
125
|
+
return /*#__PURE__*/_react.default.createElement(formik ? PuiFormikCheckboxItem : PuiStandardCheckboxItem, _objectSpread({
|
|
126
|
+
ref,
|
|
127
|
+
id,
|
|
128
|
+
className,
|
|
129
|
+
sx,
|
|
130
|
+
value,
|
|
131
|
+
label,
|
|
132
|
+
error,
|
|
133
|
+
checked,
|
|
134
|
+
disabled,
|
|
135
|
+
required,
|
|
136
|
+
onChange
|
|
137
|
+
}, rest));
|
|
138
|
+
});
|
|
139
|
+
PuiCheckboxItem.propTypes = {
|
|
140
|
+
id: _propTypes.default.string,
|
|
141
|
+
className: _propTypes.default.string,
|
|
142
|
+
sx: _propTypes.default.object,
|
|
143
|
+
value: _propTypes.default.any.isRequired,
|
|
144
|
+
label: _propTypes.default.string.isRequired,
|
|
145
|
+
error: _propTypes.default.bool,
|
|
146
|
+
checked: _propTypes.default.bool,
|
|
147
|
+
disabled: _propTypes.default.bool,
|
|
148
|
+
required: _propTypes.default.bool,
|
|
149
|
+
onChange: _propTypes.default.func
|
|
150
|
+
};
|
|
151
|
+
PuiCheckboxItem.defaultProps = {
|
|
152
|
+
error: false,
|
|
153
|
+
disabled: false,
|
|
154
|
+
required: false,
|
|
155
|
+
onChange: () => {}
|
|
156
|
+
};
|
|
157
|
+
var _default = PuiCheckboxItem;
|
|
158
|
+
exports.default = _default;
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
require("core-js/modules/web.dom-collections.iterator.js");
|
|
8
|
+
require("core-js/modules/es.symbol.description.js");
|
|
9
|
+
var _styles = require("@mui/material/styles");
|
|
10
|
+
var _DesktopDatePicker = require("@mui/x-date-pickers/DesktopDatePicker");
|
|
11
|
+
var _formik = require("formik");
|
|
12
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
13
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
+
var _react = _interopRequireDefault(require("react"));
|
|
15
|
+
var _apperance = require("../../config/apperance");
|
|
16
|
+
var _StyledMuiTextField = _interopRequireDefault(require("../common/StyledMuiTextField"));
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
const _excluded = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
|
|
19
|
+
_excluded2 = ["id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"],
|
|
20
|
+
_excluded3 = ["formik", "id", "className", "sx", "label", "name", "required", "value", "minDate", "maxDate", "inputFormat", "format", "disablePast", "disableFuture", "error", "readOnly", "fullWidth", "disabled", "helperText", "onChange", "onBlur"];
|
|
21
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
22
|
+
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; }
|
|
23
|
+
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; }
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
|
+
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; }
|
|
27
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
28
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
29
|
+
const StyledDateMuiTextField = (0, _styles.styled)( /*#__PURE__*/_react.default.forwardRef((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_StyledMuiTextField.default, _objectSpread({
|
|
30
|
+
ref: ref
|
|
31
|
+
}, props))))(() => {
|
|
32
|
+
return {
|
|
33
|
+
"&.MuiFormControl-root": {
|
|
34
|
+
display: "block",
|
|
35
|
+
"& .MuiInputAdornment-root .MuiButtonBase-root": {
|
|
36
|
+
padding: "6px",
|
|
37
|
+
marginRight: "-8px",
|
|
38
|
+
"& .MuiSvgIcon-root": {
|
|
39
|
+
width: "16px",
|
|
40
|
+
height: "16px"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
const PuiStandardDateField = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
|
|
47
|
+
let {
|
|
48
|
+
id,
|
|
49
|
+
className,
|
|
50
|
+
sx,
|
|
51
|
+
label,
|
|
52
|
+
name,
|
|
53
|
+
required,
|
|
54
|
+
value,
|
|
55
|
+
minDate,
|
|
56
|
+
maxDate,
|
|
57
|
+
inputFormat,
|
|
58
|
+
format,
|
|
59
|
+
disablePast,
|
|
60
|
+
disableFuture,
|
|
61
|
+
error,
|
|
62
|
+
readOnly,
|
|
63
|
+
fullWidth,
|
|
64
|
+
disabled,
|
|
65
|
+
helperText,
|
|
66
|
+
onChange,
|
|
67
|
+
onBlur
|
|
68
|
+
} = _ref,
|
|
69
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
70
|
+
const handleChange = value => {
|
|
71
|
+
const formattedValue = format ? value.format(format) : value.toISOString();
|
|
72
|
+
onChange(formattedValue);
|
|
73
|
+
};
|
|
74
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_DesktopDatePicker.DesktopDatePicker, _objectSpread({
|
|
75
|
+
ref: ref,
|
|
76
|
+
sx: sx,
|
|
77
|
+
label: label,
|
|
78
|
+
inputFormat: inputFormat,
|
|
79
|
+
value: value,
|
|
80
|
+
onChange: handleChange,
|
|
81
|
+
disablePast: disablePast,
|
|
82
|
+
disableFuture: disableFuture,
|
|
83
|
+
disabled: disabled,
|
|
84
|
+
maxDate: maxDate,
|
|
85
|
+
minDate: minDate,
|
|
86
|
+
readOnly: readOnly,
|
|
87
|
+
PopperProps: {
|
|
88
|
+
sx: {
|
|
89
|
+
"& .MuiButtonBase-root.Mui-selected, & .MuiButtonBase-root.Mui-selected:focus, & .MuiButtonBase-root.Mui-selected:hover": {
|
|
90
|
+
backgroundColor: _apperance.palette.primary
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
renderInput: params => /*#__PURE__*/(0, _jsxRuntime.jsx)(StyledDateMuiTextField, _objectSpread(_objectSpread({
|
|
95
|
+
id: id,
|
|
96
|
+
className: className,
|
|
97
|
+
name: name,
|
|
98
|
+
required: required,
|
|
99
|
+
fullWidth: fullWidth,
|
|
100
|
+
onBlur: onBlur,
|
|
101
|
+
helperText: helperText
|
|
102
|
+
}, params), {}, {
|
|
103
|
+
error: params.error || error
|
|
104
|
+
}))
|
|
105
|
+
}, rest));
|
|
106
|
+
});
|
|
107
|
+
const PuiFormikDateField = /*#__PURE__*/_react.default.forwardRef((_ref2, ref) => {
|
|
108
|
+
let {
|
|
109
|
+
id,
|
|
110
|
+
className,
|
|
111
|
+
sx,
|
|
112
|
+
label,
|
|
113
|
+
name,
|
|
114
|
+
required,
|
|
115
|
+
value,
|
|
116
|
+
minDate,
|
|
117
|
+
maxDate,
|
|
118
|
+
inputFormat,
|
|
119
|
+
format,
|
|
120
|
+
disablePast,
|
|
121
|
+
disableFuture,
|
|
122
|
+
error,
|
|
123
|
+
readOnly,
|
|
124
|
+
fullWidth,
|
|
125
|
+
disabled,
|
|
126
|
+
helperText,
|
|
127
|
+
onChange,
|
|
128
|
+
onBlur
|
|
129
|
+
} = _ref2,
|
|
130
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
131
|
+
const [field, meta] = (0, _formik.useField)(name);
|
|
132
|
+
const formikContext = (0, _formik.useFormikContext)();
|
|
133
|
+
const [hasError, setHasError] = _react.default.useState(false);
|
|
134
|
+
const handleChange = value => {
|
|
135
|
+
formikContext.setFieldValue(name, value);
|
|
136
|
+
onChange(value);
|
|
137
|
+
};
|
|
138
|
+
const handleBlur = event => {
|
|
139
|
+
onBlur(event);
|
|
140
|
+
field.onBlur(event);
|
|
141
|
+
};
|
|
142
|
+
_react.default.useEffect(() => {
|
|
143
|
+
setHasError(Boolean(meta) && Boolean(meta.touched) && Boolean(meta.error));
|
|
144
|
+
}, [meta]);
|
|
145
|
+
_react.default.useEffect(() => {
|
|
146
|
+
if (Boolean(value)) {
|
|
147
|
+
formikContext.setFieldValue(name, value);
|
|
148
|
+
}
|
|
149
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
150
|
+
}, [value]);
|
|
151
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(PuiStandardDateField, _objectSpread({
|
|
152
|
+
id: id,
|
|
153
|
+
ref: ref,
|
|
154
|
+
className: className,
|
|
155
|
+
sx: sx,
|
|
156
|
+
label: label,
|
|
157
|
+
name: name,
|
|
158
|
+
required: required,
|
|
159
|
+
value: Boolean(field.value) ? format ? (0, _moment.default)(field.value, format) : (0, _moment.default)(field.value) : null,
|
|
160
|
+
format: format,
|
|
161
|
+
minDate: minDate,
|
|
162
|
+
inputFormat: inputFormat,
|
|
163
|
+
disableFuture: disableFuture,
|
|
164
|
+
disablePast: disablePast,
|
|
165
|
+
error: error || hasError,
|
|
166
|
+
readOnly: readOnly,
|
|
167
|
+
fullWidth: fullWidth,
|
|
168
|
+
disabled: disabled,
|
|
169
|
+
helperText: hasError && Boolean(meta.error) ? meta.error : helperText !== null && helperText !== void 0 ? helperText : "",
|
|
170
|
+
onChange: handleChange,
|
|
171
|
+
onBlur: handleBlur
|
|
172
|
+
}, rest));
|
|
173
|
+
});
|
|
174
|
+
const PuiDateField = /*#__PURE__*/_react.default.forwardRef((_ref3, ref) => {
|
|
175
|
+
let {
|
|
176
|
+
formik,
|
|
177
|
+
id,
|
|
178
|
+
className,
|
|
179
|
+
sx,
|
|
180
|
+
label,
|
|
181
|
+
name,
|
|
182
|
+
required,
|
|
183
|
+
value,
|
|
184
|
+
minDate,
|
|
185
|
+
maxDate,
|
|
186
|
+
inputFormat,
|
|
187
|
+
format,
|
|
188
|
+
disablePast,
|
|
189
|
+
disableFuture,
|
|
190
|
+
error,
|
|
191
|
+
readOnly,
|
|
192
|
+
fullWidth,
|
|
193
|
+
disabled,
|
|
194
|
+
helperText,
|
|
195
|
+
onChange,
|
|
196
|
+
onBlur
|
|
197
|
+
} = _ref3,
|
|
198
|
+
rest = _objectWithoutProperties(_ref3, _excluded3);
|
|
199
|
+
return /*#__PURE__*/_react.default.createElement(formik ? PuiFormikDateField : PuiStandardDateField, _objectSpread({
|
|
200
|
+
ref,
|
|
201
|
+
id,
|
|
202
|
+
className,
|
|
203
|
+
sx,
|
|
204
|
+
label,
|
|
205
|
+
name,
|
|
206
|
+
required,
|
|
207
|
+
value,
|
|
208
|
+
minDate,
|
|
209
|
+
maxDate,
|
|
210
|
+
inputFormat,
|
|
211
|
+
format,
|
|
212
|
+
disablePast,
|
|
213
|
+
disableFuture,
|
|
214
|
+
error,
|
|
215
|
+
readOnly,
|
|
216
|
+
fullWidth,
|
|
217
|
+
disabled,
|
|
218
|
+
helperText,
|
|
219
|
+
onChange,
|
|
220
|
+
onBlur
|
|
221
|
+
}, rest));
|
|
222
|
+
});
|
|
223
|
+
PuiDateField.propTypes = {
|
|
224
|
+
id: _propTypes.default.string,
|
|
225
|
+
className: _propTypes.default.string,
|
|
226
|
+
sx: _propTypes.default.object,
|
|
227
|
+
label: _propTypes.default.string,
|
|
228
|
+
name: _propTypes.default.string,
|
|
229
|
+
helperText: _propTypes.default.string,
|
|
230
|
+
inputFormat: _propTypes.default.string,
|
|
231
|
+
format: _propTypes.default.string,
|
|
232
|
+
minDate: _propTypes.default.string,
|
|
233
|
+
maxDate: _propTypes.default.string,
|
|
234
|
+
formik: _propTypes.default.bool,
|
|
235
|
+
disabled: _propTypes.default.bool,
|
|
236
|
+
required: _propTypes.default.bool,
|
|
237
|
+
error: _propTypes.default.bool,
|
|
238
|
+
disablePast: _propTypes.default.bool,
|
|
239
|
+
disableFuture: _propTypes.default.bool,
|
|
240
|
+
readOnly: _propTypes.default.bool,
|
|
241
|
+
fullWidth: _propTypes.default.bool,
|
|
242
|
+
onChange: _propTypes.default.func,
|
|
243
|
+
onBlur: _propTypes.default.func
|
|
244
|
+
};
|
|
245
|
+
PuiDateField.defaultProps = {
|
|
246
|
+
inputFormat: "DD/MM/YYYY",
|
|
247
|
+
formik: false,
|
|
248
|
+
disabled: false,
|
|
249
|
+
required: false,
|
|
250
|
+
error: false,
|
|
251
|
+
fullWidth: false,
|
|
252
|
+
readOnly: false,
|
|
253
|
+
disablePast: false,
|
|
254
|
+
disableFuture: false,
|
|
255
|
+
onChange: () => {},
|
|
256
|
+
onBlur: () => {}
|
|
257
|
+
};
|
|
258
|
+
var _default = PuiDateField;
|
|
259
|
+
exports.default = _default;
|