@widergy/energy-ui 3.0.1 → 3.1.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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.1.0](https://github.com/widergy/energy-ui/compare/v3.0.1...v3.1.0) (2023-11-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* added optional callback + id to breadcrumbs ([#376](https://github.com/widergy/energy-ui/issues/376)) ([8affe4d](https://github.com/widergy/energy-ui/commit/8affe4d138f7d1f6ffc6e3c4603487d1d739ca5d))
|
|
7
|
+
|
|
1
8
|
## [3.0.1](https://github.com/widergy/energy-ui/compare/v3.0.0...v3.0.1) (2023-11-22)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -30,6 +30,7 @@ const UTBreadcrumbs = _ref => {
|
|
|
30
30
|
firstItemOverflow = false,
|
|
31
31
|
menuProps = {},
|
|
32
32
|
onRedirect,
|
|
33
|
+
onSetAction,
|
|
33
34
|
separator = _constants.DEFAULT_SEPARATOR
|
|
34
35
|
} = _ref;
|
|
35
36
|
const classes = (0, _react.useMemo)(() => (0, _classesUtils.mergeClasses)(themeClasses, classNames), [classNames]);
|
|
@@ -94,6 +95,18 @@ const UTBreadcrumbs = _ref => {
|
|
|
94
95
|
anchor: null,
|
|
95
96
|
items: []
|
|
96
97
|
});
|
|
98
|
+
const handleClickOptions = (options, route, id) => {
|
|
99
|
+
const indexOfCurrentBreadcrumb = breadcrumbs.findIndex(breadcrumb => breadcrumb.id === id);
|
|
100
|
+
if (indexOfCurrentBreadcrumb !== breadcrumbs.length - 1) {
|
|
101
|
+
if (options.setAction) {
|
|
102
|
+
onSetAction(options.setAction, options.params);
|
|
103
|
+
}
|
|
104
|
+
if (options.updatedBreadcrumbs) {
|
|
105
|
+
options.updatedBreadcrumbs(breadcrumbs.slice(0, indexOfCurrentBreadcrumb + 1));
|
|
106
|
+
}
|
|
107
|
+
onRedirect(route);
|
|
108
|
+
}
|
|
109
|
+
};
|
|
97
110
|
return /*#__PURE__*/_react.default.createElement("div", {
|
|
98
111
|
className: _stylesModule.default.breadcrumbs,
|
|
99
112
|
ref: containerRef
|
|
@@ -103,26 +116,30 @@ const UTBreadcrumbs = _ref => {
|
|
|
103
116
|
itemClassName,
|
|
104
117
|
label,
|
|
105
118
|
menuItems,
|
|
106
|
-
route
|
|
119
|
+
route,
|
|
120
|
+
options = {},
|
|
121
|
+
id = crypto.randomUUID()
|
|
107
122
|
} = _ref3;
|
|
108
123
|
const handleClick = event => {
|
|
109
124
|
if (menuItems) setMenu({
|
|
110
125
|
anchor: event.currentTarget,
|
|
111
|
-
items:
|
|
126
|
+
items: menuItems.map(_ref4 => {
|
|
112
127
|
let {
|
|
113
128
|
label: menuItemLabel,
|
|
114
|
-
route: menuItemRoute
|
|
129
|
+
route: menuItemRoute,
|
|
130
|
+
options: menuItemOptions,
|
|
131
|
+
id: menuItemId
|
|
115
132
|
} = _ref4;
|
|
116
133
|
return {
|
|
117
134
|
label: menuItemLabel,
|
|
118
135
|
onClick: () => {
|
|
119
136
|
setContent(breadcrumbs);
|
|
120
137
|
handleCloseMenu();
|
|
121
|
-
|
|
138
|
+
handleClickOptions(menuItemOptions, menuItemRoute, menuItemId);
|
|
122
139
|
}
|
|
123
140
|
};
|
|
124
141
|
})
|
|
125
|
-
});else
|
|
142
|
+
});else handleClickOptions(options, route, id);
|
|
126
143
|
};
|
|
127
144
|
const isLast = index === content.length - 1;
|
|
128
145
|
const overflowControl = index === 0 && firstItemOverflow;
|
|
@@ -166,6 +183,7 @@ UTBreadcrumbs.propTypes = {
|
|
|
166
183
|
elipsisWidthEstimate: _propTypes.number,
|
|
167
184
|
firstItemOverflow: _propTypes.bool,
|
|
168
185
|
onRedirect: _propTypes.func,
|
|
186
|
+
onSetAction: _propTypes.func,
|
|
169
187
|
menuProps: _propTypes.object,
|
|
170
188
|
separator: _propTypes.string
|
|
171
189
|
};
|