@micromag/viewer 0.3.20 → 0.3.21

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/index.js CHANGED
@@ -1055,16 +1055,22 @@ var ViewerMenu = function ViewerMenu(_ref) {
1055
1055
  screenType = _ref2$type === void 0 ? null : _ref2$type;
1056
1056
 
1057
1057
  var items = useMemo(function () {
1058
- return screens.filter(function (_ref3) {
1059
- var _ref3$parentId = _ref3.parentId,
1060
- parentId = _ref3$parentId === void 0 ? null : _ref3$parentId;
1061
- return parentId === null;
1062
- }).map(function (it) {
1058
+ return screens.map(function (it) {
1059
+ var children = screens.filter(function (s) {
1060
+ return s.parentId === it.id;
1061
+ });
1063
1062
  return {
1064
1063
  screen: it,
1065
1064
  screenId: it.id,
1066
- current: screenId === it.id
1065
+ current: screenId === it.id || (children.find(function (c) {
1066
+ return c.id === screenId;
1067
+ }) || null) !== null,
1068
+ visible: ((it === null || it === void 0 ? void 0 : it.parentId) || null) === null
1067
1069
  };
1070
+ }).filter(function (_ref3) {
1071
+ var _ref3$visible = _ref3.visible,
1072
+ visible = _ref3$visible === void 0 ? true : _ref3$visible;
1073
+ return visible;
1068
1074
  });
1069
1075
  }, [screens, screenId]);
1070
1076
  var trackEvent = useTrackEvent();
package/lib/index.js CHANGED
@@ -1073,16 +1073,22 @@ var ViewerMenu = function ViewerMenu(_ref) {
1073
1073
  screenType = _ref2$type === void 0 ? null : _ref2$type;
1074
1074
 
1075
1075
  var items = React.useMemo(function () {
1076
- return screens.filter(function (_ref3) {
1077
- var _ref3$parentId = _ref3.parentId,
1078
- parentId = _ref3$parentId === void 0 ? null : _ref3$parentId;
1079
- return parentId === null;
1080
- }).map(function (it) {
1076
+ return screens.map(function (it) {
1077
+ var children = screens.filter(function (s) {
1078
+ return s.parentId === it.id;
1079
+ });
1081
1080
  return {
1082
1081
  screen: it,
1083
1082
  screenId: it.id,
1084
- current: screenId === it.id
1083
+ current: screenId === it.id || (children.find(function (c) {
1084
+ return c.id === screenId;
1085
+ }) || null) !== null,
1086
+ visible: ((it === null || it === void 0 ? void 0 : it.parentId) || null) === null
1085
1087
  };
1088
+ }).filter(function (_ref3) {
1089
+ var _ref3$visible = _ref3.visible,
1090
+ visible = _ref3$visible === void 0 ? true : _ref3$visible;
1091
+ return visible;
1086
1092
  });
1087
1093
  }, [screens, screenId]);
1088
1094
  var trackEvent = hooks.useTrackEvent();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/viewer",
3
- "version": "0.3.20",
3
+ "version": "0.3.21",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "b7cde2045021ba116088cada89ff492e95634fee"
84
+ "gitHead": "57f9263c0bfc31056a1d1822979da8938292f309"
85
85
  }