@moda/om 16.3.0 → 17.2.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
@@ -3,6 +3,32 @@
3
3
  All notable changes to this project will be documented in this file. See
4
4
  [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [17.2.0](https://github.com/ModaOperandi/om/compare/v17.1.0...v17.2.0) (2022-08-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * **colorswatch:** add title to the callbacks ([a259d7a](https://github.com/ModaOperandi/om/commit/a259d7a76785dccc30fb6489702e3ab1d5ee0055))
12
+
13
+ # [17.1.0](https://github.com/ModaOperandi/om/compare/v17.0.0...v17.1.0) (2022-08-17)
14
+
15
+
16
+ ### Features
17
+
18
+ * **expandable:** onToggle ([4a63534](https://github.com/ModaOperandi/om/commit/4a635341fab096716b343fbac498f804dc5eed4c))
19
+
20
+ # [17.0.0](https://github.com/ModaOperandi/om/compare/v16.3.0...v17.0.0) (2022-08-17)
21
+
22
+
23
+ ### Features
24
+
25
+ * **expandable:** allow it to be controlled ([#2848](https://github.com/ModaOperandi/om/issues/2848)) ([d7128b6](https://github.com/ModaOperandi/om/commit/d7128b60276da6f155acd4cb5abb910648a3a904))
26
+
27
+
28
+ ### BREAKING CHANGES
29
+
30
+ * **expandable:** 'expanded' will now control the component completely
31
+
6
32
  # [16.3.0](https://github.com/ModaOperandi/om/compare/v16.2.1...v16.3.0) (2022-07-06)
7
33
 
8
34
 
package/dist/index.cjs.js CHANGED
@@ -5991,7 +5991,7 @@ var SKU_COLORS = {
5991
5991
  yellow: '#ffca44'
5992
5992
  };
5993
5993
 
5994
- var _excluded$s = ["className", "size", "color", "backgroundUrl", "focus", "hover", "selected", "soldOut", "onSale", "onClick", "onMouseEnter", "disabled"];
5994
+ var _excluded$s = ["className", "size", "color", "backgroundUrl", "focus", "hover", "selected", "soldOut", "onSale", "onClick", "onMouseEnter", "disabled", "title"];
5995
5995
  var ColorSwatch = function ColorSwatch(_ref) {
5996
5996
  var className = _ref.className,
5997
5997
  size = _ref.size,
@@ -6005,14 +6005,15 @@ var ColorSwatch = function ColorSwatch(_ref) {
6005
6005
  onClick = _ref.onClick,
6006
6006
  onMouseEnter = _ref.onMouseEnter,
6007
6007
  disabled = _ref.disabled,
6008
+ title = _ref.title,
6008
6009
  rest = _objectWithoutProperties(_ref, _excluded$s);
6009
6010
 
6010
6011
  var handleClick = React.useCallback(function (_event) {
6011
- onClick && onClick(color);
6012
- }, [color, onClick]);
6012
+ onClick && onClick(color, title);
6013
+ }, [color, title, onClick]);
6013
6014
  var handleMouseEnter = React.useCallback(function (_event) {
6014
- onMouseEnter && onMouseEnter(color);
6015
- }, [color, onMouseEnter]);
6015
+ onMouseEnter && onMouseEnter(color, title);
6016
+ }, [color, title, onMouseEnter]);
6016
6017
  var backgroundColor = SKU_COLORS[color];
6017
6018
 
6018
6019
  var styles = _objectSpread2({
@@ -6034,7 +6035,8 @@ var ColorSwatch = function ColorSwatch(_ref) {
6034
6035
  }, className),
6035
6036
  onClick: handleClick,
6036
6037
  onMouseEnter: handleMouseEnter,
6037
- disabled: disabled
6038
+ disabled: disabled,
6039
+ title: title
6038
6040
  }, rest), /*#__PURE__*/React__default["default"].createElement("div", {
6039
6041
  className: "ColorSwatch__chip",
6040
6042
  style: styles
@@ -11370,7 +11372,7 @@ var DefinitionList = function DefinitionList(_ref) {
11370
11372
  }, rest), /*#__PURE__*/React__default["default"].createElement("dt", null, term), /*#__PURE__*/React__default["default"].createElement("dd", null, children));
11371
11373
  };
11372
11374
 
11373
- var _excluded$f = ["name", "children", "className", "virtual", "icon", "data-testid", "expanded"];
11375
+ var _excluded$f = ["name", "children", "className", "virtual", "icon", "data-testid", "defaultExpanded", "expanded", "onToggle"];
11374
11376
  var Expandable = function Expandable(_ref) {
11375
11377
  var name = _ref.name,
11376
11378
  children = _ref.children,
@@ -11380,20 +11382,26 @@ var Expandable = function Expandable(_ref) {
11380
11382
  _ref$icon = _ref.icon,
11381
11383
  icon = _ref$icon === void 0 ? 'plus-minus' : _ref$icon,
11382
11384
  dataTestId = _ref['data-testid'],
11383
- _ref$expanded = _ref.expanded,
11384
- __expanded__ = _ref$expanded === void 0 ? false : _ref$expanded,
11385
+ _ref$defaultExpanded = _ref.defaultExpanded,
11386
+ defaultExpanded = _ref$defaultExpanded === void 0 ? false : _ref$defaultExpanded,
11387
+ __expanded__ = _ref.expanded,
11388
+ onToggle = _ref.onToggle,
11385
11389
  rest = _objectWithoutProperties(_ref, _excluded$f);
11386
11390
 
11387
- var _useState = React.useState(__expanded__),
11391
+ var _useState = React.useState(defaultExpanded),
11388
11392
  _useState2 = _slicedToArray(_useState, 2),
11389
11393
  expanded = _useState2[0],
11390
11394
  setExpanded = _useState2[1];
11391
11395
 
11396
+ React.useEffect(function () {
11397
+ if (__expanded__ != null && __expanded__ !== expanded) setExpanded(__expanded__);
11398
+ }, [expanded, __expanded__]);
11392
11399
  var handleClick = React.useCallback(function () {
11393
- return setExpanded(function (expanded) {
11400
+ setExpanded(function (expanded) {
11394
11401
  return !expanded;
11395
11402
  });
11396
- }, []);
11403
+ onToggle === null || onToggle === void 0 ? void 0 : onToggle();
11404
+ }, [onToggle]);
11397
11405
  return /*#__PURE__*/React__default["default"].createElement("div", _extends$1({
11398
11406
  className: classNames('Expandable', {
11399
11407
  'Expandable--expanded': expanded