@micromag/core 0.3.61 → 0.3.64

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/es/contexts.js CHANGED
@@ -492,7 +492,7 @@ var propTypes$b = {
492
492
  customFonts: PropTypes$1.fonts
493
493
  };
494
494
  var defaultProps$b = {
495
- systemFonts: ['Arial', 'Courier', 'Georgia', 'Times New Roman', 'Verdana'],
495
+ systemFonts: ['Arial', 'Courier New', 'Georgia', 'Times New Roman', 'Verdana'],
496
496
  customFonts: null
497
497
  };
498
498
  var FontsProvider = function FontsProvider(_ref4) {
package/es/index.js CHANGED
@@ -23,6 +23,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
23
23
  import 'slugify';
24
24
  import uniqBy from 'lodash/uniqBy';
25
25
  import _typeof from '@babel/runtime/helpers/typeof';
26
+ import isEmpty from 'lodash/isEmpty';
26
27
  import uniq from 'lodash/uniq';
27
28
  import { Tracking as Tracking$1 } from '@folklore/tracking';
28
29
 
@@ -1157,7 +1158,7 @@ var FieldsManager = /*#__PURE__*/function (_DefinitionsManager) {
1157
1158
  return FieldsManager;
1158
1159
  }(DefinitionsManager);
1159
1160
 
1160
- var _excluded$2 = ["medias"];
1161
+ var _excluded$3 = ["medias"];
1161
1162
 
1162
1163
  var MediasParser = /*#__PURE__*/function () {
1163
1164
  function MediasParser(_ref) {
@@ -1225,7 +1226,7 @@ var MediasParser = /*#__PURE__*/function () {
1225
1226
  if (theme !== null) {
1226
1227
  var _this$toPath = this.toPath(theme),
1227
1228
  themeMedias = _this$toPath.medias,
1228
- newTheme = _objectWithoutProperties(_this$toPath, _excluded$2);
1229
+ newTheme = _objectWithoutProperties(_this$toPath, _excluded$3);
1229
1230
 
1230
1231
  return medias !== null || themeMedias !== null ? _objectSpread(_objectSpread({}, story), {}, {
1231
1232
  theme: newTheme,
@@ -1474,6 +1475,8 @@ var ScreensManager = /*#__PURE__*/function (_DefinitionsManager) {
1474
1475
  return ScreensManager;
1475
1476
  }(DefinitionsManager);
1476
1477
 
1478
+ var _excluded$2 = ["textStyle", "color", "boxStyle"];
1479
+
1477
1480
  var ThemeParser = /*#__PURE__*/function () {
1478
1481
  function ThemeParser(_ref) {
1479
1482
  var screensManager = _ref.screensManager;
@@ -1526,7 +1529,9 @@ var ThemeParser = /*#__PURE__*/function () {
1526
1529
  _theme$colors = theme.colors,
1527
1530
  themeColors = _theme$colors === void 0 ? {} : _theme$colors,
1528
1531
  _theme$textStyles = theme.textStyles,
1529
- themeTextStyles = _theme$textStyles === void 0 ? null : _theme$textStyles;
1532
+ themeTextStyles = _theme$textStyles === void 0 ? null : _theme$textStyles,
1533
+ _theme$boxStyles = theme.boxStyles,
1534
+ themeBoxStyles = _theme$boxStyles === void 0 ? null : _theme$boxStyles;
1530
1535
  var newComponents = components.reduce(function (currentComponents, screen, index) {
1531
1536
  var type = screen.type;
1532
1537
 
@@ -1534,7 +1539,7 @@ var ThemeParser = /*#__PURE__*/function () {
1534
1539
  definition = _this$getDefinitionBy.definition,
1535
1540
  themeScreen = _this$getDefinitionBy.themeScreen;
1536
1541
 
1537
- var newScreen = _this.parseScreen(definition, screen, themeScreen, themeBackground, themeColors, themeTextStyles); // Only switch screen if it has changed
1542
+ var newScreen = _this.parseScreen(definition, screen, themeScreen, themeBackground, themeColors, themeTextStyles, themeBoxStyles); // Only switch screen if it has changed
1538
1543
 
1539
1544
 
1540
1545
  return newScreen !== screen || themeScreen !== null ? [].concat(_toConsumableArray(currentComponents.slice(0, index)), [_objectSpread(_objectSpread({}, themeScreen), newScreen)], _toConsumableArray(currentComponents.slice(index + 1))) : currentComponents;
@@ -1545,7 +1550,7 @@ var ThemeParser = /*#__PURE__*/function () {
1545
1550
  }
1546
1551
  }, {
1547
1552
  key: "parseScreen",
1548
- value: function parseScreen(definition, value, themeValue, themeBackground, themeColors, themeTextSyle) {
1553
+ value: function parseScreen(definition, value, themeValue, themeBackground, themeColors, themeTextStyles, themeBoxStyles) {
1549
1554
  var _this2 = this;
1550
1555
 
1551
1556
  var _definition$fields = definition.fields,
@@ -1565,7 +1570,7 @@ var ThemeParser = /*#__PURE__*/function () {
1565
1570
  var fieldValue = value[key];
1566
1571
  var fieldThemeValue = newThemeValue !== null ? newThemeValue[key] || null : null;
1567
1572
 
1568
- var newFieldValue = _this2.parseField(key, fieldDefinition, fieldValue, fieldThemeValue, themeColors, themeTextSyle); // Only switch field if it has changed
1573
+ var newFieldValue = _this2.parseField(key, fieldDefinition, fieldValue, fieldThemeValue, themeColors, themeTextStyles, themeBoxStyles); // Only switch field if it has changed
1569
1574
 
1570
1575
 
1571
1576
  return newFieldValue !== fieldValue ? _objectSpread(_objectSpread({}, currentValue), {}, _defineProperty({}, key, newFieldValue)) : currentValue;
@@ -1575,23 +1580,36 @@ var ThemeParser = /*#__PURE__*/function () {
1575
1580
 
1576
1581
  }, {
1577
1582
  key: "parseField",
1578
- value: function parseField(key, definition, value, themeValue, themeColors, themeTextStyles) {
1583
+ value: function parseField(key, definition, value, themeValue, themeColors, themeTextStyles, themeBoxStyles) {
1579
1584
  var _definition$theme = definition.theme,
1580
- fieldTheme = _definition$theme === void 0 ? {} : _definition$theme; // @TODO very sloow
1585
+ fieldTheme = _definition$theme === void 0 ? null : _definition$theme; // Early return
1586
+
1587
+ if (fieldTheme === null || !isObject(fieldTheme)) {
1588
+ return value;
1589
+ } // @TODO very sloow
1590
+
1581
1591
 
1582
1592
  if (isArray(value)) {
1583
1593
  var newFieldValue = value.map(function (innerField) {
1584
1594
  return innerField !== null ? Object.keys(innerField).reduce(function (newInnerField, innerFieldName) {
1595
+ // Early return
1596
+ if (!isObject(innerField[innerFieldName])) {
1597
+ return newInnerField;
1598
+ }
1599
+
1585
1600
  var _ref3 = fieldTheme[innerFieldName] || {},
1586
1601
  _ref3$textStyle = _ref3.textStyle,
1587
1602
  innerFieldTextStyle = _ref3$textStyle === void 0 ? null : _ref3$textStyle,
1588
1603
  _ref3$color = _ref3.color,
1589
- innerFieldColor = _ref3$color === void 0 ? null : _ref3$color; // Early return
1604
+ innerFieldColor = _ref3$color === void 0 ? null : _ref3$color,
1605
+ _ref3$boxStyle = _ref3.boxStyle,
1606
+ innerFieldBoxStyle = _ref3$boxStyle === void 0 ? null : _ref3$boxStyle; // Early return, no theme
1590
1607
 
1591
1608
 
1592
- if (!isObject(innerField[innerFieldName])) {
1609
+ if (innerFieldTextStyle === null && innerFieldColor === null && innerFieldBoxStyle === null) {
1593
1610
  return newInnerField;
1594
- } // Color
1611
+ } // TODO: replace this with the recursive parseValue...
1612
+ // Color
1595
1613
 
1596
1614
 
1597
1615
  var colorValue = innerFieldColor !== null ? {
@@ -1601,23 +1619,65 @@ var ThemeParser = /*#__PURE__*/function () {
1601
1619
  var textStyleValue = innerFieldTextStyle !== null ? {
1602
1620
  textStyle: _objectSpread(_objectSpread({}, innerFieldTextStyle !== null && themeTextStyles !== null ? themeTextStyles[innerFieldTextStyle] || null : null), innerField[innerFieldName].textStyle || null)
1603
1621
  } : null;
1622
+ var boxStyleValue = innerFieldBoxStyle !== null ? {
1623
+ boxStyle: _objectSpread(_objectSpread({}, innerFieldBoxStyle !== null && themeBoxStyles !== null ? themeBoxStyles[innerFieldBoxStyle] || null : null), innerField[innerFieldName].boxStyle || null)
1624
+ } : null;
1604
1625
 
1605
- if (colorValue === null && textStyleValue === null) {
1626
+ if (colorValue === null && textStyleValue === null && boxStyleValue === null) {
1606
1627
  return newInnerField;
1607
1628
  }
1608
1629
 
1609
- return _objectSpread(_objectSpread({}, newInnerField), {}, _defineProperty({}, innerFieldName, _objectSpread(_objectSpread(_objectSpread({}, colorValue), innerField[innerFieldName]), textStyleValue)));
1630
+ return _objectSpread(_objectSpread({}, newInnerField), {}, _defineProperty({}, innerFieldName, _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, colorValue), innerField[innerFieldName]), textStyleValue), boxStyleValue)));
1610
1631
  }, innerField) : innerField;
1611
1632
  });
1612
1633
  return newFieldValue;
1613
1634
  }
1614
1635
 
1615
- if (isObject(value) && !isArray(value)) {
1636
+ if (isObject(value)) {
1637
+ return this.parseValue(value, fieldTheme, themeValue, themeColors, themeTextStyles, themeBoxStyles);
1638
+ }
1639
+
1640
+ return value;
1641
+ } // eslint-disable-next-line class-methods-use-this
1642
+
1643
+ }, {
1644
+ key: "parseValue",
1645
+ value: function parseValue(initialValue, fieldTheme, themeValue, themeColors, themeTextStyles, themeBoxStyles) {
1646
+ var _this3 = this;
1647
+
1648
+ if (isObject(initialValue) || isObject(fieldTheme)) {
1649
+ var value = initialValue || null;
1650
+
1616
1651
  var _ref4 = fieldTheme || {},
1617
1652
  _ref4$textStyle = _ref4.textStyle,
1618
1653
  fieldTextStyleName = _ref4$textStyle === void 0 ? null : _ref4$textStyle,
1619
1654
  _ref4$color = _ref4.color,
1620
- fieldColorName = _ref4$color === void 0 ? null : _ref4$color; // Color
1655
+ fieldColorName = _ref4$color === void 0 ? null : _ref4$color,
1656
+ _ref4$boxStyle = _ref4.boxStyle,
1657
+ fieldBoxStyleName = _ref4$boxStyle === void 0 ? null : _ref4$boxStyle,
1658
+ otherProps = _objectWithoutProperties(_ref4, _excluded$2);
1659
+
1660
+ if (fieldTextStyleName === null && fieldColorName === null && fieldBoxStyleName === null && isEmpty(otherProps) && !isObject(fieldTheme)) {
1661
+ return value;
1662
+ }
1663
+
1664
+ var complexValue = null;
1665
+
1666
+ if (!isEmpty(otherProps)) {
1667
+ complexValue = Object.keys(fieldTheme).reduce(function (newObject, key) {
1668
+ var innerValue = value !== null ? value[key] || null : null;
1669
+
1670
+ var newValue = _this3.parseValue(innerValue, fieldTheme[key], themeValue, themeColors, themeTextStyles, themeBoxStyles);
1671
+
1672
+ return _objectSpread(_objectSpread({}, newObject), newValue !== null ? _defineProperty({}, key, newValue) : null);
1673
+ }, {});
1674
+ }
1675
+
1676
+ var _ref6 = value || {},
1677
+ _ref6$textStyle = _ref6.textStyle,
1678
+ valueTextStyle = _ref6$textStyle === void 0 ? null : _ref6$textStyle,
1679
+ _ref6$boxStyle = _ref6.boxStyle,
1680
+ valueBoxStyle = _ref6$boxStyle === void 0 ? null : _ref6$boxStyle; // Color
1621
1681
 
1622
1682
 
1623
1683
  var fieldColor = fieldColorName !== null && themeColors !== null ? themeColors[fieldColorName] || null : null;
@@ -1628,13 +1688,19 @@ var ThemeParser = /*#__PURE__*/function () {
1628
1688
  var fieldTextStyle = fieldTextStyleName !== null && themeTextStyles !== null ? themeTextStyles[fieldTextStyleName] || null : null;
1629
1689
  var fieldThemeComponentTextStyle = themeValue !== null ? themeValue.textStyle || null : null;
1630
1690
  var textStyleValue = fieldTextStyle !== null || fieldThemeComponentTextStyle !== null ? {
1631
- textStyle: _objectSpread(_objectSpread(_objectSpread({}, fieldTextStyle), fieldThemeComponentTextStyle), value.textStyle || null)
1691
+ textStyle: _objectSpread(_objectSpread(_objectSpread({}, fieldTextStyle), fieldThemeComponentTextStyle), valueTextStyle || null)
1692
+ } : null; // Box style
1693
+
1694
+ var fieldBoxStyle = fieldBoxStyleName !== null && themeBoxStyles !== null ? themeBoxStyles[fieldBoxStyleName] || null : null;
1695
+ var fieldThemeComponentBoxStyle = themeValue !== null ? themeValue.boxStyle || null : null;
1696
+ var boxStyleValue = fieldBoxStyle !== null || fieldThemeComponentBoxStyle !== null ? {
1697
+ boxStyle: _objectSpread(_objectSpread(_objectSpread({}, fieldBoxStyle), fieldThemeComponentBoxStyle), valueBoxStyle || null)
1632
1698
  } : null; // Only change value if something is overrided
1633
1699
 
1634
- return colorValue !== null || themeValue !== null || textStyleValue !== null ? _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, colorValue), themeValue), value), textStyleValue) : value;
1700
+ return colorValue !== null || themeValue !== null || textStyleValue !== null || boxStyleValue !== null || complexValue !== null ? _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, colorValue), themeValue), value), boxStyleValue), textStyleValue), complexValue) : value;
1635
1701
  }
1636
1702
 
1637
- return value;
1703
+ return initialValue;
1638
1704
  }
1639
1705
  }]);
1640
1706
 
package/es/utils.js CHANGED
@@ -430,7 +430,8 @@ var getStyleFromBox = function getStyleFromBox(value) {
430
430
  backgroundColor = _value$backgroundColo === void 0 ? null : _value$backgroundColo,
431
431
  _value$borderRadius = value.borderRadius,
432
432
  borderRadius = _value$borderRadius === void 0 ? null : _value$borderRadius,
433
- padding = value.padding,
433
+ _value$padding = value.padding,
434
+ paddingValue = _value$padding === void 0 ? null : _value$padding,
434
435
  _value$borderWidth = value.borderWidth,
435
436
  borderWidth = _value$borderWidth === void 0 ? null : _value$borderWidth,
436
437
  _value$borderStyle = value.borderStyle,
@@ -442,9 +443,28 @@ var getStyleFromBox = function getStyleFromBox(value) {
442
443
  style: borderStyle,
443
444
  color: borderColor
444
445
  };
446
+
447
+ var _ref = isObject(paddingValue) ? paddingValue : {
448
+ padding: paddingValue
449
+ },
450
+ _ref$top = _ref.top,
451
+ paddingTop = _ref$top === void 0 ? null : _ref$top,
452
+ _ref$right = _ref.right,
453
+ paddingRight = _ref$right === void 0 ? null : _ref$right,
454
+ _ref$bottom = _ref.bottom,
455
+ paddingBottom = _ref$bottom === void 0 ? null : _ref$bottom,
456
+ _ref$left = _ref.left,
457
+ paddingLeft = _ref$left === void 0 ? null : _ref$left,
458
+ _ref$padding = _ref.padding,
459
+ padding = _ref$padding === void 0 ? null : _ref$padding;
460
+
445
461
  return _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, getStyleFromColor(backgroundColor, 'backgroundColor')), borderRadius !== null ? {
446
462
  borderRadius: borderRadius
447
463
  } : null), getStyleFromBorder(border)), {}, {
464
+ paddingTop: paddingTop,
465
+ paddingRight: paddingRight,
466
+ paddingBottom: paddingBottom,
467
+ paddingLeft: paddingLeft,
448
468
  padding: padding
449
469
  });
450
470
  };
package/lib/contexts.js CHANGED
@@ -527,7 +527,7 @@ var propTypes$b = {
527
527
  customFonts: core.PropTypes.fonts
528
528
  };
529
529
  var defaultProps$b = {
530
- systemFonts: ['Arial', 'Courier', 'Georgia', 'Times New Roman', 'Verdana'],
530
+ systemFonts: ['Arial', 'Courier New', 'Georgia', 'Times New Roman', 'Verdana'],
531
531
  customFonts: null
532
532
  };
533
533
  var FontsProvider = function FontsProvider(_ref4) {
package/lib/index.js CHANGED
@@ -27,6 +27,7 @@ var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
27
27
  require('slugify');
28
28
  var uniqBy = require('lodash/uniqBy');
29
29
  var _typeof = require('@babel/runtime/helpers/typeof');
30
+ var isEmpty = require('lodash/isEmpty');
30
31
  var uniq = require('lodash/uniq');
31
32
  var tracking = require('@folklore/tracking');
32
33
 
@@ -50,6 +51,7 @@ var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultLegacy(_obje
50
51
  var _slicedToArray__default = /*#__PURE__*/_interopDefaultLegacy(_slicedToArray);
51
52
  var uniqBy__default = /*#__PURE__*/_interopDefaultLegacy(uniqBy);
52
53
  var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
54
+ var isEmpty__default = /*#__PURE__*/_interopDefaultLegacy(isEmpty);
53
55
  var uniq__default = /*#__PURE__*/_interopDefaultLegacy(uniq);
54
56
 
55
57
  /**
@@ -1183,7 +1185,7 @@ var FieldsManager = /*#__PURE__*/function (_DefinitionsManager) {
1183
1185
  return FieldsManager;
1184
1186
  }(DefinitionsManager);
1185
1187
 
1186
- var _excluded$2 = ["medias"];
1188
+ var _excluded$3 = ["medias"];
1187
1189
 
1188
1190
  var MediasParser = /*#__PURE__*/function () {
1189
1191
  function MediasParser(_ref) {
@@ -1251,7 +1253,7 @@ var MediasParser = /*#__PURE__*/function () {
1251
1253
  if (theme !== null) {
1252
1254
  var _this$toPath = this.toPath(theme),
1253
1255
  themeMedias = _this$toPath.medias,
1254
- newTheme = _objectWithoutProperties__default["default"](_this$toPath, _excluded$2);
1256
+ newTheme = _objectWithoutProperties__default["default"](_this$toPath, _excluded$3);
1255
1257
 
1256
1258
  return medias !== null || themeMedias !== null ? _objectSpread__default["default"](_objectSpread__default["default"]({}, story), {}, {
1257
1259
  theme: newTheme,
@@ -1500,6 +1502,8 @@ var ScreensManager = /*#__PURE__*/function (_DefinitionsManager) {
1500
1502
  return ScreensManager;
1501
1503
  }(DefinitionsManager);
1502
1504
 
1505
+ var _excluded$2 = ["textStyle", "color", "boxStyle"];
1506
+
1503
1507
  var ThemeParser = /*#__PURE__*/function () {
1504
1508
  function ThemeParser(_ref) {
1505
1509
  var screensManager = _ref.screensManager;
@@ -1552,7 +1556,9 @@ var ThemeParser = /*#__PURE__*/function () {
1552
1556
  _theme$colors = theme.colors,
1553
1557
  themeColors = _theme$colors === void 0 ? {} : _theme$colors,
1554
1558
  _theme$textStyles = theme.textStyles,
1555
- themeTextStyles = _theme$textStyles === void 0 ? null : _theme$textStyles;
1559
+ themeTextStyles = _theme$textStyles === void 0 ? null : _theme$textStyles,
1560
+ _theme$boxStyles = theme.boxStyles,
1561
+ themeBoxStyles = _theme$boxStyles === void 0 ? null : _theme$boxStyles;
1556
1562
  var newComponents = components.reduce(function (currentComponents, screen, index) {
1557
1563
  var type = screen.type;
1558
1564
 
@@ -1560,7 +1566,7 @@ var ThemeParser = /*#__PURE__*/function () {
1560
1566
  definition = _this$getDefinitionBy.definition,
1561
1567
  themeScreen = _this$getDefinitionBy.themeScreen;
1562
1568
 
1563
- var newScreen = _this.parseScreen(definition, screen, themeScreen, themeBackground, themeColors, themeTextStyles); // Only switch screen if it has changed
1569
+ var newScreen = _this.parseScreen(definition, screen, themeScreen, themeBackground, themeColors, themeTextStyles, themeBoxStyles); // Only switch screen if it has changed
1564
1570
 
1565
1571
 
1566
1572
  return newScreen !== screen || themeScreen !== null ? [].concat(_toConsumableArray__default["default"](currentComponents.slice(0, index)), [_objectSpread__default["default"](_objectSpread__default["default"]({}, themeScreen), newScreen)], _toConsumableArray__default["default"](currentComponents.slice(index + 1))) : currentComponents;
@@ -1571,7 +1577,7 @@ var ThemeParser = /*#__PURE__*/function () {
1571
1577
  }
1572
1578
  }, {
1573
1579
  key: "parseScreen",
1574
- value: function parseScreen(definition, value, themeValue, themeBackground, themeColors, themeTextSyle) {
1580
+ value: function parseScreen(definition, value, themeValue, themeBackground, themeColors, themeTextStyles, themeBoxStyles) {
1575
1581
  var _this2 = this;
1576
1582
 
1577
1583
  var _definition$fields = definition.fields,
@@ -1591,7 +1597,7 @@ var ThemeParser = /*#__PURE__*/function () {
1591
1597
  var fieldValue = value[key];
1592
1598
  var fieldThemeValue = newThemeValue !== null ? newThemeValue[key] || null : null;
1593
1599
 
1594
- var newFieldValue = _this2.parseField(key, fieldDefinition, fieldValue, fieldThemeValue, themeColors, themeTextSyle); // Only switch field if it has changed
1600
+ var newFieldValue = _this2.parseField(key, fieldDefinition, fieldValue, fieldThemeValue, themeColors, themeTextStyles, themeBoxStyles); // Only switch field if it has changed
1595
1601
 
1596
1602
 
1597
1603
  return newFieldValue !== fieldValue ? _objectSpread__default["default"](_objectSpread__default["default"]({}, currentValue), {}, _defineProperty__default["default"]({}, key, newFieldValue)) : currentValue;
@@ -1601,23 +1607,36 @@ var ThemeParser = /*#__PURE__*/function () {
1601
1607
 
1602
1608
  }, {
1603
1609
  key: "parseField",
1604
- value: function parseField(key, definition, value, themeValue, themeColors, themeTextStyles) {
1610
+ value: function parseField(key, definition, value, themeValue, themeColors, themeTextStyles, themeBoxStyles) {
1605
1611
  var _definition$theme = definition.theme,
1606
- fieldTheme = _definition$theme === void 0 ? {} : _definition$theme; // @TODO very sloow
1612
+ fieldTheme = _definition$theme === void 0 ? null : _definition$theme; // Early return
1613
+
1614
+ if (fieldTheme === null || !isObject__default["default"](fieldTheme)) {
1615
+ return value;
1616
+ } // @TODO very sloow
1617
+
1607
1618
 
1608
1619
  if (isArray__default["default"](value)) {
1609
1620
  var newFieldValue = value.map(function (innerField) {
1610
1621
  return innerField !== null ? Object.keys(innerField).reduce(function (newInnerField, innerFieldName) {
1622
+ // Early return
1623
+ if (!isObject__default["default"](innerField[innerFieldName])) {
1624
+ return newInnerField;
1625
+ }
1626
+
1611
1627
  var _ref3 = fieldTheme[innerFieldName] || {},
1612
1628
  _ref3$textStyle = _ref3.textStyle,
1613
1629
  innerFieldTextStyle = _ref3$textStyle === void 0 ? null : _ref3$textStyle,
1614
1630
  _ref3$color = _ref3.color,
1615
- innerFieldColor = _ref3$color === void 0 ? null : _ref3$color; // Early return
1631
+ innerFieldColor = _ref3$color === void 0 ? null : _ref3$color,
1632
+ _ref3$boxStyle = _ref3.boxStyle,
1633
+ innerFieldBoxStyle = _ref3$boxStyle === void 0 ? null : _ref3$boxStyle; // Early return, no theme
1616
1634
 
1617
1635
 
1618
- if (!isObject__default["default"](innerField[innerFieldName])) {
1636
+ if (innerFieldTextStyle === null && innerFieldColor === null && innerFieldBoxStyle === null) {
1619
1637
  return newInnerField;
1620
- } // Color
1638
+ } // TODO: replace this with the recursive parseValue...
1639
+ // Color
1621
1640
 
1622
1641
 
1623
1642
  var colorValue = innerFieldColor !== null ? {
@@ -1627,23 +1646,65 @@ var ThemeParser = /*#__PURE__*/function () {
1627
1646
  var textStyleValue = innerFieldTextStyle !== null ? {
1628
1647
  textStyle: _objectSpread__default["default"](_objectSpread__default["default"]({}, innerFieldTextStyle !== null && themeTextStyles !== null ? themeTextStyles[innerFieldTextStyle] || null : null), innerField[innerFieldName].textStyle || null)
1629
1648
  } : null;
1649
+ var boxStyleValue = innerFieldBoxStyle !== null ? {
1650
+ boxStyle: _objectSpread__default["default"](_objectSpread__default["default"]({}, innerFieldBoxStyle !== null && themeBoxStyles !== null ? themeBoxStyles[innerFieldBoxStyle] || null : null), innerField[innerFieldName].boxStyle || null)
1651
+ } : null;
1630
1652
 
1631
- if (colorValue === null && textStyleValue === null) {
1653
+ if (colorValue === null && textStyleValue === null && boxStyleValue === null) {
1632
1654
  return newInnerField;
1633
1655
  }
1634
1656
 
1635
- return _objectSpread__default["default"](_objectSpread__default["default"]({}, newInnerField), {}, _defineProperty__default["default"]({}, innerFieldName, _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, colorValue), innerField[innerFieldName]), textStyleValue)));
1657
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, newInnerField), {}, _defineProperty__default["default"]({}, innerFieldName, _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, colorValue), innerField[innerFieldName]), textStyleValue), boxStyleValue)));
1636
1658
  }, innerField) : innerField;
1637
1659
  });
1638
1660
  return newFieldValue;
1639
1661
  }
1640
1662
 
1641
- if (isObject__default["default"](value) && !isArray__default["default"](value)) {
1663
+ if (isObject__default["default"](value)) {
1664
+ return this.parseValue(value, fieldTheme, themeValue, themeColors, themeTextStyles, themeBoxStyles);
1665
+ }
1666
+
1667
+ return value;
1668
+ } // eslint-disable-next-line class-methods-use-this
1669
+
1670
+ }, {
1671
+ key: "parseValue",
1672
+ value: function parseValue(initialValue, fieldTheme, themeValue, themeColors, themeTextStyles, themeBoxStyles) {
1673
+ var _this3 = this;
1674
+
1675
+ if (isObject__default["default"](initialValue) || isObject__default["default"](fieldTheme)) {
1676
+ var value = initialValue || null;
1677
+
1642
1678
  var _ref4 = fieldTheme || {},
1643
1679
  _ref4$textStyle = _ref4.textStyle,
1644
1680
  fieldTextStyleName = _ref4$textStyle === void 0 ? null : _ref4$textStyle,
1645
1681
  _ref4$color = _ref4.color,
1646
- fieldColorName = _ref4$color === void 0 ? null : _ref4$color; // Color
1682
+ fieldColorName = _ref4$color === void 0 ? null : _ref4$color,
1683
+ _ref4$boxStyle = _ref4.boxStyle,
1684
+ fieldBoxStyleName = _ref4$boxStyle === void 0 ? null : _ref4$boxStyle,
1685
+ otherProps = _objectWithoutProperties__default["default"](_ref4, _excluded$2);
1686
+
1687
+ if (fieldTextStyleName === null && fieldColorName === null && fieldBoxStyleName === null && isEmpty__default["default"](otherProps) && !isObject__default["default"](fieldTheme)) {
1688
+ return value;
1689
+ }
1690
+
1691
+ var complexValue = null;
1692
+
1693
+ if (!isEmpty__default["default"](otherProps)) {
1694
+ complexValue = Object.keys(fieldTheme).reduce(function (newObject, key) {
1695
+ var innerValue = value !== null ? value[key] || null : null;
1696
+
1697
+ var newValue = _this3.parseValue(innerValue, fieldTheme[key], themeValue, themeColors, themeTextStyles, themeBoxStyles);
1698
+
1699
+ return _objectSpread__default["default"](_objectSpread__default["default"]({}, newObject), newValue !== null ? _defineProperty__default["default"]({}, key, newValue) : null);
1700
+ }, {});
1701
+ }
1702
+
1703
+ var _ref6 = value || {},
1704
+ _ref6$textStyle = _ref6.textStyle,
1705
+ valueTextStyle = _ref6$textStyle === void 0 ? null : _ref6$textStyle,
1706
+ _ref6$boxStyle = _ref6.boxStyle,
1707
+ valueBoxStyle = _ref6$boxStyle === void 0 ? null : _ref6$boxStyle; // Color
1647
1708
 
1648
1709
 
1649
1710
  var fieldColor = fieldColorName !== null && themeColors !== null ? themeColors[fieldColorName] || null : null;
@@ -1654,13 +1715,19 @@ var ThemeParser = /*#__PURE__*/function () {
1654
1715
  var fieldTextStyle = fieldTextStyleName !== null && themeTextStyles !== null ? themeTextStyles[fieldTextStyleName] || null : null;
1655
1716
  var fieldThemeComponentTextStyle = themeValue !== null ? themeValue.textStyle || null : null;
1656
1717
  var textStyleValue = fieldTextStyle !== null || fieldThemeComponentTextStyle !== null ? {
1657
- textStyle: _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, fieldTextStyle), fieldThemeComponentTextStyle), value.textStyle || null)
1718
+ textStyle: _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, fieldTextStyle), fieldThemeComponentTextStyle), valueTextStyle || null)
1719
+ } : null; // Box style
1720
+
1721
+ var fieldBoxStyle = fieldBoxStyleName !== null && themeBoxStyles !== null ? themeBoxStyles[fieldBoxStyleName] || null : null;
1722
+ var fieldThemeComponentBoxStyle = themeValue !== null ? themeValue.boxStyle || null : null;
1723
+ var boxStyleValue = fieldBoxStyle !== null || fieldThemeComponentBoxStyle !== null ? {
1724
+ boxStyle: _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, fieldBoxStyle), fieldThemeComponentBoxStyle), valueBoxStyle || null)
1658
1725
  } : null; // Only change value if something is overrided
1659
1726
 
1660
- return colorValue !== null || themeValue !== null || textStyleValue !== null ? _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, colorValue), themeValue), value), textStyleValue) : value;
1727
+ return colorValue !== null || themeValue !== null || textStyleValue !== null || boxStyleValue !== null || complexValue !== null ? _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, colorValue), themeValue), value), boxStyleValue), textStyleValue), complexValue) : value;
1661
1728
  }
1662
1729
 
1663
- return value;
1730
+ return initialValue;
1664
1731
  }
1665
1732
  }]);
1666
1733
 
package/lib/utils.js CHANGED
@@ -447,7 +447,8 @@ var getStyleFromBox = function getStyleFromBox(value) {
447
447
  backgroundColor = _value$backgroundColo === void 0 ? null : _value$backgroundColo,
448
448
  _value$borderRadius = value.borderRadius,
449
449
  borderRadius = _value$borderRadius === void 0 ? null : _value$borderRadius,
450
- padding = value.padding,
450
+ _value$padding = value.padding,
451
+ paddingValue = _value$padding === void 0 ? null : _value$padding,
451
452
  _value$borderWidth = value.borderWidth,
452
453
  borderWidth = _value$borderWidth === void 0 ? null : _value$borderWidth,
453
454
  _value$borderStyle = value.borderStyle,
@@ -459,9 +460,28 @@ var getStyleFromBox = function getStyleFromBox(value) {
459
460
  style: borderStyle,
460
461
  color: borderColor
461
462
  };
463
+
464
+ var _ref = isObject__default["default"](paddingValue) ? paddingValue : {
465
+ padding: paddingValue
466
+ },
467
+ _ref$top = _ref.top,
468
+ paddingTop = _ref$top === void 0 ? null : _ref$top,
469
+ _ref$right = _ref.right,
470
+ paddingRight = _ref$right === void 0 ? null : _ref$right,
471
+ _ref$bottom = _ref.bottom,
472
+ paddingBottom = _ref$bottom === void 0 ? null : _ref$bottom,
473
+ _ref$left = _ref.left,
474
+ paddingLeft = _ref$left === void 0 ? null : _ref$left,
475
+ _ref$padding = _ref.padding,
476
+ padding = _ref$padding === void 0 ? null : _ref$padding;
477
+
462
478
  return _objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"](_objectSpread__default["default"]({}, getStyleFromColor(backgroundColor, 'backgroundColor')), borderRadius !== null ? {
463
479
  borderRadius: borderRadius
464
480
  } : null), getStyleFromBorder(border)), {}, {
481
+ paddingTop: paddingTop,
482
+ paddingRight: paddingRight,
483
+ paddingBottom: paddingBottom,
484
+ paddingLeft: paddingLeft,
465
485
  padding: padding
466
486
  });
467
487
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/core",
3
- "version": "0.3.61",
3
+ "version": "0.3.64",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -132,5 +132,5 @@
132
132
  "publishConfig": {
133
133
  "access": "public"
134
134
  },
135
- "gitHead": "d6066e12f37c8516f07172ea225667d28dca6434"
135
+ "gitHead": "b0da130454a8615d3fd00a3d380f438863b35334"
136
136
  }