@commonsku/styles 1.16.1 → 1.16.3

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/dist/index.js CHANGED
@@ -1328,16 +1328,18 @@ var themeOptions = {
1328
1328
  },
1329
1329
  };
1330
1330
  function getColor(color, def) {
1331
+ var _a;
1331
1332
  if (!color) {
1332
1333
  return '';
1333
1334
  }
1334
- return ___default.get(colors, color, ___default.get(colors, def || '', def));
1335
+ return (_a = ___default.get(colors, color, ___default.get(colors, def || '', def))) !== null && _a !== void 0 ? _a : '';
1335
1336
  }
1336
1337
  function getFontStyle(value, def) {
1338
+ var _a;
1337
1339
  if (!value) {
1338
1340
  return '';
1339
1341
  }
1340
- return ___default.get(fontStyles, value, ___default.get(fontStyles, def || '', def));
1342
+ return (_a = ___default.get(fontStyles, value, ___default.get(fontStyles, def || '', def))) !== null && _a !== void 0 ? _a : '';
1341
1343
  }
1342
1344
  function getThemeColor(props, color, fallbackColor) {
1343
1345
  return getThemeProperty(props, 'colors', color, fallbackColor);
@@ -1353,6 +1355,7 @@ function getThemeFontFamily(props, fallbackValue) {
1353
1355
  return getThemeProperty(props, 'fontFamily', fallbackValue);
1354
1356
  }
1355
1357
  function getThemeProperty(props, prop, value, fallbackValue) {
1358
+ var _a, _b;
1356
1359
  if (___default.get(props, "theme.".concat(prop), null)) {
1357
1360
  if (___default.isObject(props.theme[prop]) && ___default.get(props.theme, "".concat(prop, ".").concat(value), null)) {
1358
1361
  return ___default.get(props.theme, "".concat(prop, ".").concat(value), null);
@@ -1362,7 +1365,7 @@ function getThemeProperty(props, prop, value, fallbackValue) {
1362
1365
  }
1363
1366
  }
1364
1367
  else if (___default.get(themeOptions, "".concat(prop, ".").concat(value), null)) {
1365
- return ___default.get(themeOptions, "".concat(prop, ".").concat(value), null);
1368
+ return (_a = ___default.get(themeOptions, "".concat(prop, ".").concat(value))) !== null && _a !== void 0 ? _a : '';
1366
1369
  }
1367
1370
  switch (prop) {
1368
1371
  case 'fontStyles':
@@ -1372,7 +1375,7 @@ function getThemeProperty(props, prop, value, fallbackValue) {
1372
1375
  case 'colors':
1373
1376
  return getColor(value, fallbackValue);
1374
1377
  case 'fontFamily':
1375
- return ___default.get(themeOptions.fontFamilies, "".concat(value, ".fontFamily"), fallbackValue || themeOptions.fontFamily);
1378
+ return (_b = ___default.get(themeOptions.fontFamilies, "".concat(value, ".fontFamily"), fallbackValue || themeOptions.fontFamily)) !== null && _b !== void 0 ? _b : '';
1376
1379
  default:
1377
1380
  return '';
1378
1381
  }
@@ -3742,8 +3745,8 @@ var Tabs = /** @class */ (function (_super) {
3742
3745
  var sameTabs = prevProps.tabs.length !== this.props.tabs.length
3743
3746
  || (prevProps.tabs.length === this.props.tabs.length
3744
3747
  && prevProps.tabs.every(function (e, i) {
3745
- return e.label === _this.props.tabs[i].label
3746
- && (e.onClick || "null").toString() === (_this.props.tabs[i].onClick || 'null').toString();
3748
+ return !_.isString(e.label) || (e.label === _this.props.tabs[i].label
3749
+ && (e.onClick || "null").toString() === (_this.props.tabs[i].onClick || 'null').toString());
3747
3750
  }));
3748
3751
  if (!sameTabs) {
3749
3752
  this.setState({
@@ -3753,17 +3756,17 @@ var Tabs = /** @class */ (function (_super) {
3753
3756
  };
3754
3757
  Tabs.prototype.render = function () {
3755
3758
  var _this = this;
3756
- var _a = this.props, tabs = _a.tabs, size = _a.size;
3759
+ var _a = this.props, tabs = _a.tabs, size = _a.size, props = __rest(_a, ["tabs", "size"]);
3757
3760
  var selectedTab = this.getTab(tabs, this.state.selectedTabIndex);
3758
- return React__default.createElement("div", null,
3759
- React__default.createElement(TabBar, { padded: this.props.padded === true }, tabs.map(function (tab, index) { return React__default.createElement(Tab, { key: index, size: size, selected: index === _this.state.selectedTabIndex, onClick: function () {
3761
+ return React__default.createElement("div", __assign({}, props),
3762
+ React__default.createElement(TabBar, { padded: this.props.padded === true }, tabs.map(function (tab, index) { return React__default.createElement(Tab, { key: index, size: size, className: index === _this.state.selectedTabIndex ? 'selected' : '', selected: index === _this.state.selectedTabIndex, onClick: function (e) {
3760
3763
  _this.setState({ selectedTabIndex: index });
3761
3764
  var callback = tabs[index].onClick;
3762
3765
  if (callback) {
3763
- callback();
3766
+ callback(e);
3764
3767
  }
3765
3768
  } }, tab.label); })),
3766
- ___default.get(selectedTab, ['content'], ''));
3769
+ _.get(selectedTab, ['content'], ''));
3767
3770
  };
3768
3771
  return Tabs;
3769
3772
  }(React.Component));
@@ -4356,10 +4359,10 @@ var getContentStyle = function (width, rootElem, buttonElem) {
4356
4359
  return {};
4357
4360
  };
4358
4361
  var Dropdown = function (_a) {
4359
- var items = _a.items, _b = _a.children, children = _b === void 0 ? undefined : _b, underlined = _a.underlined, primary = _a.primary, text = _a.text, icon = _a.icon, _c = _a.openMenu, openMenu = _c === void 0 ? false : _c, onToggleMenu = _a.onToggleMenu, mouseLeaveCallback = _a.mouseLeaveCallback, size = _a.size, _d = _a.style, style = _d === void 0 ? {} : _d, buttonVariant = _a.buttonVariant, _e = _a.width, width = _e === void 0 ? 160 : _e, _f = _a.bordered, bordered = _f === void 0 ? false : _f, _g = _a.hideOnMouseLeave, hideOnMouseLeave = _g === void 0 ? true : _g, props = __rest(_a, ["items", "children", "underlined", "primary", "text", "icon", "openMenu", "onToggleMenu", "mouseLeaveCallback", "size", "style", "buttonVariant", "width", "bordered", "hideOnMouseLeave"]);
4362
+ var items = _a.items, _b = _a.children, children = _b === void 0 ? undefined : _b, underlined = _a.underlined, primary = _a.primary, text = _a.text, icon = _a.icon, _c = _a.openMenu, openMenu = _c === void 0 ? false : _c, onToggleMenu = _a.onToggleMenu, mouseLeaveCallback = _a.mouseLeaveCallback, size = _a.size, _d = _a.style, style = _d === void 0 ? {} : _d, buttonVariant = _a.buttonVariant, _e = _a.buttonProps, buttonProps = _e === void 0 ? {} : _e, _f = _a.width, width = _f === void 0 ? 160 : _f, _g = _a.bordered, bordered = _g === void 0 ? false : _g, _h = _a.hideOnMouseLeave, hideOnMouseLeave = _h === void 0 ? true : _h, props = __rest(_a, ["items", "children", "underlined", "primary", "text", "icon", "openMenu", "onToggleMenu", "mouseLeaveCallback", "size", "style", "buttonVariant", "buttonProps", "width", "bordered", "hideOnMouseLeave"]);
4360
4363
  var rootRef = React.useRef(null);
4361
4364
  var buttonRef = React.useRef(null);
4362
- var _h = React.useState(openMenu), showMenu = _h[0], setShowMenu = _h[1];
4365
+ var _j = React.useState(openMenu), showMenu = _j[0], setShowMenu = _j[1];
4363
4366
  var iconProps = {
4364
4367
  color: getColor(primary ? 'primary100' : 'white'),
4365
4368
  style: { verticalAlign: 'middle', transitionDuration: '.3s', transform: 'rotate(' + (showMenu ? 0 : 180) + 'deg)' },
@@ -4401,16 +4404,17 @@ var Dropdown = function (_a) {
4401
4404
  icon ?
4402
4405
  React__default.createElement("span", { onClick: function () { return handleToggleMenu(!showMenu); } }, icon)
4403
4406
  :
4404
- React__default.createElement(Button, { size: size, cta: Boolean(!primary), variant: buttonVariant, onClick: function () { return handleToggleMenu(!showMenu); }, ref: buttonRef },
4407
+ React__default.createElement(Button, __assign({ size: size, cta: Boolean(!primary), variant: buttonVariant, onClick: function () { return handleToggleMenu(!showMenu); }, ref: buttonRef }, buttonProps),
4405
4408
  text ? text : "Actions",
4406
4409
  " ",
4407
4410
  React__default.createElement(ChevronIcon, __assign({ direction: "up" }, iconProps))),
4408
4411
  showMenu && React__default.createElement(DropDownContent, { style: contentStyle, underlined: underlined, primary: primary, width: width, bordered: bordered },
4409
- items && items.map(function (item, i) {
4410
- return item && React__default.createElement(DropdownItem, __assign({ key: 'dropdown-item-' + i }, item.props, { primary: primary, underlined: item.props && item.props.underlined ? item.props.underlined : underlined, onClick: function () {
4412
+ items && _.filter(items).map(function (_a, i) {
4413
+ var onClick = _a.onClick, content = _a.content, legecyProps = _a.props, itemProps = __rest(_a, ["onClick", "content", "props"]);
4414
+ return React__default.createElement(DropdownItem, __assign({ key: 'dropdown-item-' + i, underlined: underlined }, legecyProps, { primary: primary, onClick: function (e) {
4411
4415
  setShowMenu(false);
4412
- item.onClick && item.onClick();
4413
- } }), item.content);
4416
+ onClick && onClick(e);
4417
+ } }, itemProps), content);
4414
4418
  }),
4415
4419
  children ? children : null))));
4416
4420
  };