@widergy/energy-ui 2.8.1 → 2.10.0
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/CHANGELOG.md +14 -0
- package/dist/components/UTAutocomplete/index.js +52 -20
- package/dist/components/UTCarousel/components/Slider/component/Slide/index.js +15 -13
- package/dist/components/UTCarousel/components/Slider/layout.js +7 -6
- package/dist/components/UTSidebar/styles.module.scss +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [2.10.0](https://github.com/widergy/energy-ui/compare/v2.9.0...v2.10.0) (2023-10-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* add classes management for slide component ([ec1080e](https://github.com/widergy/energy-ui/commit/ec1080e13a8c05dc6290def2ab6fb60da6608422))
|
|
7
|
+
|
|
8
|
+
# [2.9.0](https://github.com/widergy/energy-ui/compare/v2.8.1...v2.9.0) (2023-10-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* autocomplete - multiple ([#387](https://github.com/widergy/energy-ui/issues/387)) ([4f567e2](https://github.com/widergy/energy-ui/commit/4f567e2e23529cca996d41becde5b473f2c029ad))
|
|
14
|
+
|
|
1
15
|
## [2.8.1](https://github.com/widergy/energy-ui/compare/v2.8.0...v2.8.1) (2023-10-12)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -45,10 +45,6 @@ var UTAutocomplete = function UTAutocomplete(_ref) {
|
|
|
45
45
|
placeholder = _ref.placeholder,
|
|
46
46
|
textFieldProps = _ref.textFieldProps,
|
|
47
47
|
variant = _ref.variant;
|
|
48
|
-
var _useState = (0, _react.useState)(''),
|
|
49
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
50
|
-
componentValue = _useState2[0],
|
|
51
|
-
setComponentValue = _useState2[1];
|
|
52
48
|
var _ref2 = field.configuration || {},
|
|
53
49
|
_ref2$field_options_v = _ref2.field_options_value_key,
|
|
54
50
|
valueKey = _ref2$field_options_v === void 0 ? _constants.DEFAULT_VALUE_KEY : _ref2$field_options_v,
|
|
@@ -57,23 +53,58 @@ var UTAutocomplete = function UTAutocomplete(_ref) {
|
|
|
57
53
|
_ref2$field_options_n = _ref2.field_options_no_results_message,
|
|
58
54
|
noOptionsMessage = _ref2$field_options_n === void 0 ? _constants.INVALID_OPTION : _ref2$field_options_n,
|
|
59
55
|
_ref2$field_options_e = _ref2.field_options_empty_message,
|
|
60
|
-
emptyOptionsLabel = _ref2$field_options_e === void 0 ? _constants.ERROR_EMPTY_OPTIONS : _ref2$field_options_e
|
|
56
|
+
emptyOptionsLabel = _ref2$field_options_e === void 0 ? _constants.ERROR_EMPTY_OPTIONS : _ref2$field_options_e,
|
|
57
|
+
_ref2$multiple = _ref2.multiple,
|
|
58
|
+
multiple = _ref2$multiple === void 0 ? false : _ref2$multiple;
|
|
59
|
+
var initialValue = (0, _react.useMemo)(function () {
|
|
60
|
+
return multiple ? [] : '';
|
|
61
|
+
}, [multiple]);
|
|
62
|
+
var _useState = (0, _react.useState)(initialValue),
|
|
63
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
64
|
+
componentValue = _useState2[0],
|
|
65
|
+
setComponentValue = _useState2[1];
|
|
61
66
|
var textInputLabel = (0, _array.isEmpty)(options) ? emptyOptionsLabel : label;
|
|
62
67
|
var fieldDisabled = disabled || loading || (0, _array.isEmpty)(options);
|
|
63
68
|
var onChange = function onChange(_, values) {
|
|
64
|
-
input.onChange(values === null || values === void 0 ? void 0 : values
|
|
65
|
-
|
|
69
|
+
input.onChange(multiple ? values === null || values === void 0 ? void 0 : values.map(function (val) {
|
|
70
|
+
return val[valueKey];
|
|
71
|
+
}) : values === null || values === void 0 ? void 0 : values[valueKey]);
|
|
72
|
+
if (!values) setComponentValue(initialValue);
|
|
66
73
|
if (field.onChange) field.onChange(values);
|
|
67
74
|
};
|
|
68
75
|
(0, _react.useEffect)(function () {
|
|
69
|
-
setComponentValue(input.value && options ? options.
|
|
76
|
+
setComponentValue(input.value && !(0, _array.isEmpty)(options) ? multiple ? options.filter(function (option) {
|
|
77
|
+
return input.value.some(function (inputValue) {
|
|
78
|
+
return inputValue === option[valueKey];
|
|
79
|
+
});
|
|
80
|
+
}) : options.find(function (option) {
|
|
70
81
|
return option[valueKey] === input.value;
|
|
71
|
-
}) :
|
|
82
|
+
}) : multiple ? [] : '');
|
|
72
83
|
}, [input.value]);
|
|
73
84
|
(0, _react.useEffect)(function () {
|
|
74
|
-
if (options
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
if ((0, _array.isEmpty)(options) || (multiple ? (0, _array.isEmpty)(input.value) : !input.value)) {
|
|
86
|
+
if (multiple && !(0, _array.isEmpty)(componentValue) || componentValue) {
|
|
87
|
+
input.onChange(initialValue);
|
|
88
|
+
setComponentValue(initialValue);
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
var newInputValue = multiple ? input.value.filter(function (inputValue) {
|
|
92
|
+
return options.some(function (option) {
|
|
93
|
+
return inputValue === option[valueKey];
|
|
94
|
+
});
|
|
95
|
+
}) : options.some(function (option) {
|
|
96
|
+
return option[valueKey] === input.value;
|
|
97
|
+
}) ? input.value : '';
|
|
98
|
+
input.onChange(newInputValue);
|
|
99
|
+
var updatedValue = multiple ? options.filter(function (option) {
|
|
100
|
+
return newInputValue.some(function (inputValue) {
|
|
101
|
+
return inputValue === option[valueKey];
|
|
102
|
+
});
|
|
103
|
+
}) : options.find(function (option) {
|
|
104
|
+
return option[valueKey] === newInputValue;
|
|
105
|
+
});
|
|
106
|
+
setComponentValue(updatedValue);
|
|
107
|
+
}
|
|
77
108
|
}, [options]);
|
|
78
109
|
var textInputEndAdornment = loading ? /*#__PURE__*/_react.default.createElement(_CircularProgress.default, {
|
|
79
110
|
className: classes.loadingIcon
|
|
@@ -82,23 +113,24 @@ var UTAutocomplete = function UTAutocomplete(_ref) {
|
|
|
82
113
|
});
|
|
83
114
|
var errorMessage = (0, _form.shouldShowErrors)(meta) && meta.error || '';
|
|
84
115
|
return /*#__PURE__*/_react.default.createElement(_Autocomplete.default, _extends({
|
|
85
|
-
id: field.key,
|
|
86
116
|
clearText: _constants.CLEAR_TEXT,
|
|
87
117
|
closeText: _constants.CLOSE_TEXT,
|
|
88
|
-
|
|
118
|
+
disabled: fieldDisabled,
|
|
119
|
+
getOptionLabel: function getOptionLabel(option) {
|
|
120
|
+
return option[labelKey] || '';
|
|
121
|
+
},
|
|
122
|
+
id: field.key,
|
|
89
123
|
ListboxComponent: _ListBox.default,
|
|
90
124
|
ListboxProps: {
|
|
91
125
|
fixedSizeListProps: fixedSizeListProps
|
|
92
126
|
},
|
|
93
|
-
|
|
94
|
-
return option[labelKey] || '';
|
|
95
|
-
},
|
|
96
|
-
onChange: onChange,
|
|
97
|
-
disabled: fieldDisabled,
|
|
98
|
-
value: componentValue,
|
|
127
|
+
multiple: multiple,
|
|
99
128
|
noOptionsText: noOptionsMessage,
|
|
129
|
+
onChange: onChange,
|
|
130
|
+
openText: _constants.OPEN_TEXT,
|
|
100
131
|
options: options,
|
|
101
132
|
popupIcon: textInputEndAdornment,
|
|
133
|
+
value: componentValue,
|
|
102
134
|
renderInput: function renderInput(params) {
|
|
103
135
|
return /*#__PURE__*/_react.default.createElement(_TextField.default, _extends({}, params, {
|
|
104
136
|
label: textInputLabel,
|
|
@@ -13,14 +13,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
13
13
|
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); }
|
|
14
14
|
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; }
|
|
15
15
|
var Slide = function Slide(_ref) {
|
|
16
|
-
var
|
|
17
|
-
position = _ref.position,
|
|
18
|
-
widthContainer = _ref.widthContainer,
|
|
19
|
-
currentSlide = _ref.currentSlide,
|
|
16
|
+
var animationTime = _ref.animationTime,
|
|
20
17
|
border = _ref.border,
|
|
18
|
+
classes = _ref.classes,
|
|
19
|
+
currentSlide = _ref.currentSlide,
|
|
20
|
+
imgSrc = _ref.imgSrc,
|
|
21
|
+
onClick = _ref.onClick,
|
|
22
|
+
position = _ref.position,
|
|
21
23
|
shouldAnimate = _ref.shouldAnimate,
|
|
22
|
-
|
|
23
|
-
onClick = _ref.onClick;
|
|
24
|
+
widthContainer = _ref.widthContainer;
|
|
24
25
|
var slide = currentSlide === position ? border / 2 : currentSlide === position - 1 ? -border / 4 : currentSlide === position + 1 && border + border / 4;
|
|
25
26
|
return /*#__PURE__*/_react.default.createElement(_UTTouchableWithoutFeedback.default, {
|
|
26
27
|
className: "".concat(_stylesModule.default.imageContainer),
|
|
@@ -35,18 +36,19 @@ var Slide = function Slide(_ref) {
|
|
|
35
36
|
style: {
|
|
36
37
|
backgroundImage: "url(".concat(imgSrc, ")")
|
|
37
38
|
},
|
|
38
|
-
className: _stylesModule.default.image,
|
|
39
|
+
className: "".concat(_stylesModule.default.image, " ").concat(classes === null || classes === void 0 ? void 0 : classes.image),
|
|
39
40
|
draggable: "false"
|
|
40
41
|
}));
|
|
41
42
|
};
|
|
42
43
|
Slide.propTypes = {
|
|
43
|
-
|
|
44
|
-
imgSrc: _propTypes.string,
|
|
45
|
-
widthContainer: _propTypes.number,
|
|
44
|
+
animationTime: _propTypes.number,
|
|
46
45
|
border: _propTypes.number,
|
|
47
|
-
|
|
46
|
+
classes: (0, _propTypes.objectOf)(_propTypes.string),
|
|
48
47
|
currentSlide: _propTypes.number,
|
|
49
|
-
|
|
50
|
-
onClick: _propTypes.func
|
|
48
|
+
imgSrc: _propTypes.string,
|
|
49
|
+
onClick: _propTypes.func,
|
|
50
|
+
position: _propTypes.number,
|
|
51
|
+
shouldAnimate: _propTypes.bool,
|
|
52
|
+
widthContainer: _propTypes.number
|
|
51
53
|
};
|
|
52
54
|
var _default = exports.default = /*#__PURE__*/(0, _react.memo)(Slide);
|
|
@@ -70,15 +70,16 @@ var Slider = /*#__PURE__*/function (_PureComponent) {
|
|
|
70
70
|
draggable: "false"
|
|
71
71
|
}, slideArray.map(function (slide, _index) {
|
|
72
72
|
return /*#__PURE__*/_react.default.createElement(_Slide.default, {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
animationTime: animationTime,
|
|
74
|
+
border: withBorder,
|
|
75
|
+
classes: classes,
|
|
75
76
|
currentSlide: index - 1,
|
|
76
|
-
widthContainer: containerWidth,
|
|
77
77
|
imgSrc: slide.imgSrc,
|
|
78
|
-
|
|
78
|
+
key: "slide-".concat(slide.id || slide.imgSrc),
|
|
79
|
+
onClick: slide.onClick,
|
|
80
|
+
position: _index - 1,
|
|
79
81
|
shouldAnimate: shouldAnimate,
|
|
80
|
-
|
|
81
|
-
onClick: slide.onClick
|
|
82
|
+
widthContainer: containerWidth
|
|
82
83
|
});
|
|
83
84
|
})), legend && legend.position === _constants.INSIDE && /*#__PURE__*/_react.default.createElement("div", {
|
|
84
85
|
className: _stylesModule.default.legendContainer
|