@datawheel/data-explorer 1.2.0-rc.3 → 1.2.0-rc.5

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/dist/main.mjs +19 -6
  2. package/package.json +1 -1
package/dist/main.mjs CHANGED
@@ -1949,7 +1949,7 @@ function calcMaxMemberCount(lengths) {
1949
1949
  function pickDefaultDrilldowns(dimensions, cube) {
1950
1950
  var _a;
1951
1951
  const levels = [];
1952
- let timeComplete;
1952
+ let timeComplete = void 0;
1953
1953
  let suggestedLevels = [];
1954
1954
  for (const key in cube.annotations) {
1955
1955
  if (key === "suggested_levels") {
@@ -1963,7 +1963,11 @@ function pickDefaultDrilldowns(dimensions, cube) {
1963
1963
  const hierarchyDepth = Math.max(...hierarchy.levels.map((l) => l.depth));
1964
1964
  const levelIndex = dimension.type === "geo" ? hierarchy.levels.length - 1 : 0;
1965
1965
  const defaultLevel = hierarchy.levels[levelIndex];
1966
- if (dimension.type === "time" && dimension.annotations.de_time_complete === "true" && defaultLevel.depth < hierarchyDepth) {
1966
+ const suggestedLevelInHierarchy = hierarchy.levels.find(
1967
+ (level) => suggestedLevels.includes(level.name)
1968
+ );
1969
+ const isSuggestedLevelDeepest = (suggestedLevelInHierarchy == null ? void 0 : suggestedLevelInHierarchy.depth) === hierarchyDepth;
1970
+ if (dimension.type === "time" && dimension.annotations.de_time_complete === "true" && defaultLevel.depth < hierarchyDepth && !isSuggestedLevelDeepest) {
1967
1971
  timeComplete = defaultLevel.name;
1968
1972
  }
1969
1973
  levels.push({ ...defaultLevel, type: dimension.type });
@@ -3899,13 +3903,14 @@ function LevelItem({
3899
3903
  });
3900
3904
  }, [locale, dimension, hierarchy, level, isSubMenu, t]);
3901
3905
  const currentDrilldown = drilldowns[level.name];
3902
- const isOtherHierarchySelected = activeItems.some(
3906
+ const otherHierarchyItems = activeItems.filter(
3903
3907
  (activeItem) => activeItem.dimension === dimension.name && activeItem.hierarchy !== hierarchy.name
3904
3908
  );
3909
+ const isOtherHierarchySelected = otherHierarchyItems.length > 0;
3905
3910
  const cut = cutItems.find((cut2) => cut2.level === level.name);
3906
3911
  const checked = activeItems.map((i) => i.level).includes(level.name);
3907
- const disableUncheck = activeItems.length === 1 && checked;
3908
- const isDisabled = isOtherHierarchySelected && !checked;
3912
+ const disableUncheck = activeItems.length === 1 && checked && !otherHierarchyItems.length;
3913
+ const isDisabled = otherHierarchyItems.length || !checked;
3909
3914
  if (!currentDrilldown) return;
3910
3915
  const paddingLeft = `${5 * depth + 5}px`;
3911
3916
  const properties = currentDrilldown.properties.length ? currentDrilldown.properties : null;
@@ -3916,6 +3921,14 @@ function LevelItem({
3916
3921
  sx: { cursor: "pointer", paddingLeft },
3917
3922
  onChange: () => {
3918
3923
  var _a;
3924
+ if (isOtherHierarchySelected) {
3925
+ otherHierarchyItems.forEach((item) => {
3926
+ actions2.updateDrilldown({
3927
+ ...item,
3928
+ active: false
3929
+ });
3930
+ });
3931
+ }
3919
3932
  actions2.updateDrilldown({
3920
3933
  ...currentDrilldown,
3921
3934
  active: !currentDrilldown.active
@@ -3947,7 +3960,7 @@ function LevelItem({
3947
3960
  checked,
3948
3961
  label,
3949
3962
  size: "xs",
3950
- disabled: isDisabled || disableUncheck
3963
+ disabled: disableUncheck
3951
3964
  }
3952
3965
  ), /* @__PURE__ */ React15__default.createElement(Group, { sx: { flexWrap: "nowrap" } }, /* @__PURE__ */ React15__default.createElement(
3953
3966
  ActionIcon,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawheel/data-explorer",
3
- "version": "1.2.0-rc.3",
3
+ "version": "1.2.0-rc.5",
4
4
  "main": "./dist/main.mjs",
5
5
  "types": "./dist/main.d.mts",
6
6
  "files": [