@micromag/core 0.3.656 → 0.3.660

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.
Files changed (2) hide show
  1. package/es/index.js +72 -13
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -17,6 +17,7 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
17
17
  import isString from 'lodash/isString';
18
18
  import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
19
19
  import uniq from 'lodash/uniq';
20
+ import { isString as isString$1 } from 'lodash';
20
21
  import isEmpty from 'lodash/isEmpty';
21
22
  import { Tracking as Tracking$1 } from '@folklore/tracking';
22
23
  import PropTypes$1 from 'prop-types';
@@ -1199,8 +1200,8 @@ var FieldsManager = /*#__PURE__*/function (_DefinitionsManager) {
1199
1200
  }]);
1200
1201
  }(DefinitionsManager);
1201
1202
 
1202
- var _excluded$6 = ["medias"],
1203
- _excluded2$2 = ["medias"];
1203
+ var _excluded$7 = ["medias"],
1204
+ _excluded2$3 = ["medias"];
1204
1205
  var MediasParser = /*#__PURE__*/function () {
1205
1206
  function MediasParser(_ref) {
1206
1207
  var fieldsManager = _ref.fieldsManager,
@@ -1219,7 +1220,7 @@ var MediasParser = /*#__PURE__*/function () {
1219
1220
  if (typeof this.parsedThemesCache[storyId] === 'undefined') {
1220
1221
  var _this$toPath = this.toPath(theme),
1221
1222
  themeMedias = _this$toPath.medias,
1222
- newTheme = _objectWithoutProperties(_this$toPath, _excluded$6);
1223
+ newTheme = _objectWithoutProperties(_this$toPath, _excluded$7);
1223
1224
  this.parsedThemesCache[storyId] = {
1224
1225
  themeMedias: themeMedias,
1225
1226
  newTheme: newTheme
@@ -1273,7 +1274,7 @@ var MediasParser = /*#__PURE__*/function () {
1273
1274
  if (theme !== null) {
1274
1275
  var _this$getParsedStoryT = this.getParsedStoryTheme(storyId, theme),
1275
1276
  themeMedias = _this$getParsedStoryT.medias,
1276
- newTheme = _objectWithoutProperties(_this$getParsedStoryT, _excluded2$2);
1277
+ newTheme = _objectWithoutProperties(_this$getParsedStoryT, _excluded2$3);
1277
1278
  return medias !== null || themeMedias !== null ? _objectSpread(_objectSpread({}, story), {}, {
1278
1279
  theme: newTheme,
1279
1280
  components: newComponents,
@@ -1525,7 +1526,7 @@ var ScreensManager = /*#__PURE__*/function (_DefinitionsManager) {
1525
1526
  }]);
1526
1527
  }(DefinitionsManager);
1527
1528
 
1528
- var _excluded$5 = ["fonts"];
1529
+ var _excluded$6 = ["fonts"];
1529
1530
  var FontsParser = /*#__PURE__*/function () {
1530
1531
  function FontsParser(_ref) {
1531
1532
  var fieldsManager = _ref.fieldsManager,
@@ -1574,7 +1575,7 @@ var FontsParser = /*#__PURE__*/function () {
1574
1575
  var _this$parse = this.parse(theme),
1575
1576
  _this$parse$fonts = _this$parse.fonts,
1576
1577
  themeFonts = _this$parse$fonts === void 0 ? [] : _this$parse$fonts,
1577
- newTheme = _objectWithoutProperties(_this$parse, _excluded$5);
1578
+ newTheme = _objectWithoutProperties(_this$parse, _excluded$6);
1578
1579
  return fonts.length > 0 || themeFonts.length > 0 ? _objectSpread(_objectSpread({}, story), {}, {
1579
1580
  theme: newTheme,
1580
1581
  fonts: uniq([].concat(_toConsumableArray(themeFonts), _toConsumableArray(fonts)), 'name')
@@ -1650,7 +1651,7 @@ var FontsParser = /*#__PURE__*/function () {
1650
1651
  }]);
1651
1652
  }();
1652
1653
 
1653
- var _excluded$4 = ["shareIncentive", "callToAction"];
1654
+ var _excluded$5 = ["shareIncentive", "callToAction"];
1654
1655
  /* eslint-disable class-methods-use-this */
1655
1656
  var ShareCall = /*#__PURE__*/function () {
1656
1657
  function ShareCall() {
@@ -1677,7 +1678,7 @@ var ShareCall = /*#__PURE__*/function () {
1677
1678
  shareIncentive = _ref2$shareIncentive === void 0 ? null : _ref2$shareIncentive,
1678
1679
  _ref2$callToAction = _ref2.callToAction,
1679
1680
  callToAction = _ref2$callToAction === void 0 ? null : _ref2$callToAction,
1680
- restScreen = _objectWithoutProperties(_ref2, _excluded$4);
1681
+ restScreen = _objectWithoutProperties(_ref2, _excluded$5);
1681
1682
  var _ref3 = screen || {},
1682
1683
  _ref3$header = _ref3.header,
1683
1684
  header = _ref3$header === void 0 ? null : _ref3$header,
@@ -1705,8 +1706,8 @@ var ShareCall = /*#__PURE__*/function () {
1705
1706
  }]);
1706
1707
  }();
1707
1708
 
1708
- var _excluded$3 = ["answers"],
1709
- _excluded2$1 = ["customAnswerLabel"];
1709
+ var _excluded$4 = ["answers"],
1710
+ _excluded2$2 = ["customAnswerLabel"];
1710
1711
  /* eslint-disable class-methods-use-this */
1711
1712
  var CustomAnswerLabel = /*#__PURE__*/function () {
1712
1713
  function CustomAnswerLabel() {
@@ -1721,7 +1722,7 @@ var CustomAnswerLabel = /*#__PURE__*/function () {
1721
1722
  if (answers === null || answers.length === 0) {
1722
1723
  return false;
1723
1724
  }
1724
- var hasCustomAnswerLabel = answers.some(function () {
1725
+ var hasCustomAnswerLabel = (answers || []).some(function () {
1725
1726
  var answer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1726
1727
  return answer !== null && typeof answer.customAnswerLabel !== 'undefined';
1727
1728
  });
@@ -1736,7 +1737,7 @@ var CustomAnswerLabel = /*#__PURE__*/function () {
1736
1737
  var _ref2 = screen || {},
1737
1738
  _ref2$answers = _ref2.answers,
1738
1739
  answers = _ref2$answers === void 0 ? null : _ref2$answers,
1739
- restScreen = _objectWithoutProperties(_ref2, _excluded$3);
1740
+ restScreen = _objectWithoutProperties(_ref2, _excluded$4);
1740
1741
  return _objectSpread(_objectSpread({}, restScreen), {}, {
1741
1742
  answers: answers.map(function () {
1742
1743
  var answer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
@@ -1745,7 +1746,7 @@ var CustomAnswerLabel = /*#__PURE__*/function () {
1745
1746
  }
1746
1747
  var _ref3 = answer || {},
1747
1748
  customAnswerLabel = _ref3.customAnswerLabel,
1748
- restAnswer = _objectWithoutProperties(_ref3, _excluded2$1);
1749
+ restAnswer = _objectWithoutProperties(_ref3, _excluded2$2);
1749
1750
  return _objectSpread(_objectSpread({}, restAnswer), {}, {
1750
1751
  result: customAnswerLabel
1751
1752
  });
@@ -1755,9 +1756,67 @@ var CustomAnswerLabel = /*#__PURE__*/function () {
1755
1756
  }]);
1756
1757
  }();
1757
1758
 
1759
+ var _excluded$3 = ["items"],
1760
+ _excluded2$1 = ["label", "textStyle"];
1761
+
1762
+ /* eslint-disable class-methods-use-this */
1763
+ var KeypadItemLabel = /*#__PURE__*/function () {
1764
+ function KeypadItemLabel() {
1765
+ _classCallCheck(this, KeypadItemLabel);
1766
+ }
1767
+ return _createClass(KeypadItemLabel, [{
1768
+ key: "test",
1769
+ value: function test(screen) {
1770
+ var _ref = screen || {},
1771
+ _ref$type = _ref.type,
1772
+ type = _ref$type === void 0 ? null : _ref$type,
1773
+ _ref$items = _ref.items,
1774
+ items = _ref$items === void 0 ? null : _ref$items;
1775
+ if (type !== 'keypad' || items === null || items.length === 0) {
1776
+ return false;
1777
+ }
1778
+ var hasStringItemLabel = (items || []).some(function () {
1779
+ var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1780
+ return item !== null && isString$1(item === null || item === void 0 ? void 0 : item.label);
1781
+ });
1782
+ if (!hasStringItemLabel) {
1783
+ return false;
1784
+ }
1785
+ return true;
1786
+ }
1787
+ }, {
1788
+ key: "parse",
1789
+ value: function parse(screen) {
1790
+ var _ref2 = screen || {},
1791
+ _ref2$items = _ref2.items,
1792
+ items = _ref2$items === void 0 ? null : _ref2$items,
1793
+ restScreen = _objectWithoutProperties(_ref2, _excluded$3);
1794
+ return _objectSpread(_objectSpread({}, restScreen), {}, {
1795
+ items: items.map(function () {
1796
+ var item = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1797
+ if (item === null || !isString$1(item === null || item === void 0 ? void 0 : item.label)) {
1798
+ return item;
1799
+ }
1800
+ var _ref3 = item || {},
1801
+ label = _ref3.label,
1802
+ textStyle = _ref3.textStyle,
1803
+ restAnswer = _objectWithoutProperties(_ref3, _excluded2$1);
1804
+ return _objectSpread(_objectSpread({}, restAnswer), {}, {
1805
+ label: {
1806
+ body: label,
1807
+ textStyle: textStyle
1808
+ }
1809
+ });
1810
+ })
1811
+ });
1812
+ }
1813
+ }]);
1814
+ }();
1815
+
1758
1816
  var migrations = /*#__PURE__*/Object.freeze({
1759
1817
  __proto__: null,
1760
1818
  CustomAnswerLabel: CustomAnswerLabel,
1819
+ KeypadItemLabel: KeypadItemLabel,
1761
1820
  ShareCall: ShareCall
1762
1821
  });
1763
1822
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/core",
3
- "version": "0.3.656",
3
+ "version": "0.3.660",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -144,5 +144,5 @@
144
144
  "access": "public",
145
145
  "registry": "https://registry.npmjs.org/"
146
146
  },
147
- "gitHead": "fd956cc4a183b621df124f3f3afbae4af974db27"
147
+ "gitHead": "584698bf4ef786f8fd35853328977554367515d9"
148
148
  }