@widergy/energy-ui 3.0.0 → 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,17 @@
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
+
8
+ ## [3.0.1](https://github.com/widergy/energy-ui/compare/v3.0.0...v3.0.1) (2023-11-22)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * minor fix in carousel ([#395](https://github.com/widergy/energy-ui/issues/395)) ([c403296](https://github.com/widergy/energy-ui/commit/c403296f421e7ced5a55148d805556374ff76eef))
14
+
1
15
  # [3.0.0](https://github.com/widergy/energy-ui/compare/v2.11.0...v3.0.0) (2023-11-11)
2
16
 
3
17
 
@@ -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: [...menuItems].map(_ref4 => {
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
- onRedirect(menuItemRoute);
138
+ handleClickOptions(menuItemOptions, menuItemRoute, menuItemId);
122
139
  }
123
140
  };
124
141
  })
125
- });else onRedirect(route);
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
  };
@@ -21,24 +21,6 @@ function _toPrimitive(input, hint) { if (typeof input !== "object" || input ===
21
21
  class SliderContainer extends _react.PureComponent {
22
22
  constructor(props) {
23
23
  super(props);
24
- _defineProperty(this, "handleMouseDown", (0, _helperFunctions.throttle)(event => {
25
- this.containerRef.current.addEventListener('mousemove', this.handleMouseMove);
26
- window.addEventListener('mouseup', this.handleEventUp);
27
- return this.setState({
28
- initialPosition: event.clientX,
29
- shouldAnimate: false,
30
- timeMove: new Date().getTime()
31
- });
32
- }, this.state.timeAnimation));
33
- _defineProperty(this, "handleTouchDown", (0, _helperFunctions.throttle)(event => {
34
- this.containerRef.current.addEventListener('touchmove', this.handleTouchMove);
35
- window.addEventListener('touchend', this.handleEventUp);
36
- return this.setState({
37
- initialPosition: event.changedTouches[event.changedTouches.length - 1].clientX,
38
- shouldAnimate: false,
39
- timeMove: new Date().getTime()
40
- });
41
- }, this.state.timeAnimation));
42
24
  _defineProperty(this, "updateImgArray", () => {
43
25
  const firstSlide = this.props.slides[0];
44
26
  const lastSlide = this.props.slides[this.props.slides.length - 1];
@@ -173,8 +155,8 @@ class SliderContainer extends _react.PureComponent {
173
155
  this.setState({
174
156
  slideArray: arr
175
157
  });
176
- this.containerRef.current.addEventListener('touchstart', this.handleTouchDown);
177
- this.containerRef.current.addEventListener('mousedown', this.handleMouseDown);
158
+ this.containerRef.current.addEventListener('touchstart', this.handleTouchDown.bind(this));
159
+ this.containerRef.current.addEventListener('mousedown', this.handleMouseDown.bind(this));
178
160
  this.updateContainerWidth();
179
161
  window.addEventListener('resize', this.updateContainerWidth);
180
162
  if (this.props.autoPlay) setInterval(() => this.handleNextSlide(), this.props.autoPlayDelay);
@@ -196,6 +178,28 @@ class SliderContainer extends _react.PureComponent {
196
178
  window.removeEventListener('resize', this.updateContainerWidth);
197
179
  window.removeEventListener('touchend', this.handleEventUp);
198
180
  }
181
+ handleMouseDown() {
182
+ return (0, _helperFunctions.throttle)(event => {
183
+ this.containerRef.current.addEventListener('mousemove', this.handleMouseMove);
184
+ window.addEventListener('mouseup', this.handleEventUp);
185
+ return this.setState({
186
+ initialPosition: event.clientX,
187
+ shouldAnimate: false,
188
+ timeMove: new Date().getTime()
189
+ });
190
+ }, this.state.timeAnimation);
191
+ }
192
+ handleTouchDown() {
193
+ (0, _helperFunctions.throttle)(event => {
194
+ this.containerRef.current.addEventListener('touchmove', this.handleTouchMove);
195
+ window.addEventListener('touchend', this.handleEventUp);
196
+ return this.setState({
197
+ initialPosition: event.changedTouches[event.changedTouches.length - 1].clientX,
198
+ shouldAnimate: false,
199
+ timeMove: new Date().getTime()
200
+ });
201
+ }, this.state.timeAnimation);
202
+ }
199
203
  render() {
200
204
  const {
201
205
  shouldAnimate,
@@ -22,9 +22,9 @@ const ActionButton = _ref => {
22
22
  isHidden,
23
23
  buttonProps
24
24
  } = _ref;
25
- return /*#__PURE__*/(0, _react.isValidElement)(button) ? /*#__PURE__*/(0, _react.cloneElement)(button, {
25
+ return /*#__PURE__*/(0, _react.isValidElement)(button) ? ( /*#__PURE__*/(0, _react.cloneElement)(button, {
26
26
  className: "".concat(button.props.className, " ").concat(isHidden && _stylesModule.default.hiddenButton)
27
- }) : /*#__PURE__*/_react.default.createElement(_UTButton.default, _extends({
27
+ })) : /*#__PURE__*/_react.default.createElement(_UTButton.default, _extends({
28
28
  disabled: button.disabled,
29
29
  hideTextOnResponsive: true,
30
30
  onClick: button.onClick
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widergy/energy-ui",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Widergy Web Components",
5
5
  "author": "widergy",
6
6
  "license": "MIT",