@datawheel/data-explorer 1.4.1 → 1.4.2
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/main.mjs +83 -18
- package/package.json +1 -1
package/dist/main.mjs
CHANGED
|
@@ -4811,10 +4811,15 @@ function useBuildGraph(locale) {
|
|
|
4811
4811
|
const hide = getAnnotation(item, "hide_in_ui", locale);
|
|
4812
4812
|
if (!yn(hide)) {
|
|
4813
4813
|
graph2.addNode(topic);
|
|
4814
|
-
graph2.addNode(subtopic);
|
|
4815
4814
|
graph2.addNode(name4);
|
|
4816
|
-
|
|
4817
|
-
|
|
4815
|
+
if (subtopic) {
|
|
4816
|
+
const uniqueSubtopic = `${topic} - ${subtopic}`;
|
|
4817
|
+
graph2.addNode(uniqueSubtopic);
|
|
4818
|
+
graph2.addEdge(topic, uniqueSubtopic);
|
|
4819
|
+
graph2.addEdge(uniqueSubtopic, name4);
|
|
4820
|
+
} else {
|
|
4821
|
+
graph2.addEdge(topic, name4);
|
|
4822
|
+
}
|
|
4818
4823
|
if (topic_order) {
|
|
4819
4824
|
graph2.addTopicOrder(topic, topic_order);
|
|
4820
4825
|
}
|
|
@@ -5430,8 +5435,16 @@ function useAccordionValue(key, locale) {
|
|
|
5430
5435
|
const [value, setValue] = useState(null);
|
|
5431
5436
|
useEffect(() => {
|
|
5432
5437
|
if (selectedItem) {
|
|
5433
|
-
const
|
|
5434
|
-
|
|
5438
|
+
const topic = getAnnotation(selectedItem, "topic", locale);
|
|
5439
|
+
const subtopic = getAnnotation(selectedItem, "subtopic", locale);
|
|
5440
|
+
if (key === "subtopic" && subtopic) {
|
|
5441
|
+
setValue(`${key}-${topic} - ${subtopic}`);
|
|
5442
|
+
} else if (key === "topic") {
|
|
5443
|
+
setValue(`${key}-${topic}`);
|
|
5444
|
+
} else {
|
|
5445
|
+
const val = getAnnotation(selectedItem, key, locale);
|
|
5446
|
+
setValue(`${key}-${val}`);
|
|
5447
|
+
}
|
|
5435
5448
|
}
|
|
5436
5449
|
}, [key, selectedItem, locale]);
|
|
5437
5450
|
return { value, setValue };
|
|
@@ -5472,19 +5485,18 @@ function RootAccordions({ items, sortItems, graph, locale, selectedItem, sortLoc
|
|
|
5472
5485
|
const sortItem = sortItems.find(
|
|
5473
5486
|
(topic) => graph.topicOrder[topic] === graph.topicOrder[item]
|
|
5474
5487
|
) || item;
|
|
5475
|
-
return /* @__PURE__ */ React15__default.createElement(Accordion.Item, { value: `topic-${item}`, key: `topic-${item}` }, /* @__PURE__ */ React15__default.createElement(AccordionControl, null, item), /* @__PURE__ */ React15__default.createElement(Accordion.Panel, null, /* @__PURE__ */ React15__default.createElement(
|
|
5476
|
-
|
|
5488
|
+
return /* @__PURE__ */ React15__default.createElement(Accordion.Item, { value: `topic-${item}`, key: `topic-${item}` }, /* @__PURE__ */ React15__default.createElement(AccordionControl, null, item), /* @__PURE__ */ React15__default.createElement(Accordion.Panel, null, /* @__PURE__ */ React15__default.createElement("div", { style: { display: "flex", flexDirection: "column" } }, /* @__PURE__ */ React15__default.createElement(
|
|
5489
|
+
TopicChildren,
|
|
5477
5490
|
{
|
|
5478
5491
|
graph,
|
|
5479
5492
|
parent: item,
|
|
5480
5493
|
sortParent: sortItem,
|
|
5481
5494
|
items: graph.adjList[item],
|
|
5482
|
-
key: item,
|
|
5483
5495
|
locale,
|
|
5484
5496
|
sortLocale,
|
|
5485
5497
|
selectedItem
|
|
5486
5498
|
}
|
|
5487
|
-
)));
|
|
5499
|
+
))));
|
|
5488
5500
|
})
|
|
5489
5501
|
);
|
|
5490
5502
|
}
|
|
@@ -5528,6 +5540,56 @@ function CubeButton({
|
|
|
5528
5540
|
table != null ? table : item
|
|
5529
5541
|
);
|
|
5530
5542
|
}
|
|
5543
|
+
function TopicChildren({
|
|
5544
|
+
items,
|
|
5545
|
+
graph,
|
|
5546
|
+
parent,
|
|
5547
|
+
sortParent,
|
|
5548
|
+
selectedItem,
|
|
5549
|
+
locale,
|
|
5550
|
+
sortLocale
|
|
5551
|
+
}) {
|
|
5552
|
+
const { directCubes, subtopics } = useMemo(() => {
|
|
5553
|
+
const cubes = [];
|
|
5554
|
+
const folders = [];
|
|
5555
|
+
items.forEach((item) => {
|
|
5556
|
+
const cube = graph.items.find((c) => c.name === item);
|
|
5557
|
+
if (cube) {
|
|
5558
|
+
cubes.push(item);
|
|
5559
|
+
} else {
|
|
5560
|
+
folders.push(item);
|
|
5561
|
+
}
|
|
5562
|
+
});
|
|
5563
|
+
return { directCubes: cubes, subtopics: folders };
|
|
5564
|
+
}, [items, graph]);
|
|
5565
|
+
return /* @__PURE__ */ React15__default.createElement(React15__default.Fragment, null, directCubes.sort((a, b) => {
|
|
5566
|
+
const aLabel = graph.getName(a, sortLocale);
|
|
5567
|
+
const bLabel = graph.getName(b, sortLocale);
|
|
5568
|
+
return aLabel.localeCompare(bLabel, sortLocale, { sensitivity: "base" });
|
|
5569
|
+
}).map((cube, index) => /* @__PURE__ */ React15__default.createElement(
|
|
5570
|
+
CubeButton,
|
|
5571
|
+
{
|
|
5572
|
+
key: `direct-${cube}-${index}`,
|
|
5573
|
+
graph,
|
|
5574
|
+
item: cube,
|
|
5575
|
+
locale,
|
|
5576
|
+
sortLocale,
|
|
5577
|
+
selectedItem,
|
|
5578
|
+
parent: ""
|
|
5579
|
+
}
|
|
5580
|
+
)), subtopics.length > 0 && /* @__PURE__ */ React15__default.createElement(
|
|
5581
|
+
SubtopicAccordion,
|
|
5582
|
+
{
|
|
5583
|
+
items: subtopics,
|
|
5584
|
+
graph,
|
|
5585
|
+
parent,
|
|
5586
|
+
sortParent,
|
|
5587
|
+
selectedItem,
|
|
5588
|
+
locale,
|
|
5589
|
+
sortLocale
|
|
5590
|
+
}
|
|
5591
|
+
));
|
|
5592
|
+
}
|
|
5531
5593
|
function SubtopicAccordion({
|
|
5532
5594
|
items,
|
|
5533
5595
|
graph,
|
|
@@ -5565,29 +5627,32 @@ function SubtopicAccordion({
|
|
|
5565
5627
|
})
|
|
5566
5628
|
},
|
|
5567
5629
|
[...items].sort((a, b) => {
|
|
5630
|
+
const aName = a.split(" - ").pop();
|
|
5631
|
+
const bName = b.split(" - ").pop();
|
|
5568
5632
|
const aLabel = graph.items.find(
|
|
5569
|
-
(cube) => getAnnotation(cube, "topic", locale) === parent && getAnnotation(cube, "subtopic", locale) ===
|
|
5633
|
+
(cube) => getAnnotation(cube, "topic", locale) === parent && getAnnotation(cube, "subtopic", locale) === aName
|
|
5570
5634
|
);
|
|
5571
5635
|
const bLabel = graph.items.find(
|
|
5572
|
-
(cube) => getAnnotation(cube, "topic", locale) === parent && getAnnotation(cube, "subtopic", locale) ===
|
|
5636
|
+
(cube) => getAnnotation(cube, "topic", locale) === parent && getAnnotation(cube, "subtopic", locale) === bName
|
|
5573
5637
|
);
|
|
5574
|
-
const aSort = aLabel ? getAnnotation(aLabel, "subtopic", sortLocale) ||
|
|
5575
|
-
const bSort = bLabel ? getAnnotation(bLabel, "subtopic", sortLocale) ||
|
|
5638
|
+
const aSort = (aLabel ? getAnnotation(aLabel, "subtopic", sortLocale) : null) || aName || "";
|
|
5639
|
+
const bSort = (bLabel ? getAnnotation(bLabel, "subtopic", sortLocale) : null) || bName || "";
|
|
5576
5640
|
return aSort.localeCompare(bSort, sortLocale, { sensitivity: "base" });
|
|
5577
5641
|
}).map((item, index) => {
|
|
5578
5642
|
let sortSubtopic = item;
|
|
5643
|
+
const itemName = item.split(" - ").pop();
|
|
5579
5644
|
if (sortParent && item) {
|
|
5580
5645
|
const hasCubeInLocale = graph.items.some(
|
|
5581
|
-
(cube) => getAnnotation(cube, "topic", locale) === parent && getAnnotation(cube, "subtopic", locale) ===
|
|
5646
|
+
(cube) => getAnnotation(cube, "topic", locale) === parent && getAnnotation(cube, "subtopic", locale) === itemName
|
|
5582
5647
|
);
|
|
5583
5648
|
if (hasCubeInLocale) {
|
|
5584
5649
|
const matchingCube = graph.items.find(
|
|
5585
|
-
(cube) => getAnnotation(cube, "topic", sortLocale) === sortParent && getAnnotation(cube, "subtopic", locale) ===
|
|
5650
|
+
(cube) => getAnnotation(cube, "topic", sortLocale) === sortParent && getAnnotation(cube, "subtopic", locale) === itemName
|
|
5586
5651
|
);
|
|
5587
5652
|
if (matchingCube) {
|
|
5588
5653
|
const annotatedSubtopic = getAnnotation(matchingCube, "subtopic", sortLocale);
|
|
5589
5654
|
if (annotatedSubtopic) {
|
|
5590
|
-
sortSubtopic = annotatedSubtopic
|
|
5655
|
+
sortSubtopic = `${sortParent} - ${annotatedSubtopic}`;
|
|
5591
5656
|
}
|
|
5592
5657
|
}
|
|
5593
5658
|
}
|
|
@@ -5600,7 +5665,7 @@ function SubtopicAccordion({
|
|
|
5600
5665
|
const bSort = bLabel ? getAnnotation(bLabel, "table", sortLocale) || b : b;
|
|
5601
5666
|
return aSort.localeCompare(bSort, sortLocale, { sensitivity: "base" });
|
|
5602
5667
|
}) : [];
|
|
5603
|
-
return /* @__PURE__ */ React15__default.createElement(Accordion.Item, { value: `subtopic-${item}`, key: `subtopic-${item}-${index}` }, /* @__PURE__ */ React15__default.createElement(AccordionControl, null, item), /* @__PURE__ */ React15__default.createElement(Accordion.Panel, null, filtered.map((table, index2) => /* @__PURE__ */ React15__default.createElement(
|
|
5668
|
+
return /* @__PURE__ */ React15__default.createElement(Accordion.Item, { value: `subtopic-${item}`, key: `subtopic-${item}-${index}` }, /* @__PURE__ */ React15__default.createElement(AccordionControl, null, item.split(" - ").pop()), /* @__PURE__ */ React15__default.createElement(Accordion.Panel, null, filtered.map((table, index2) => /* @__PURE__ */ React15__default.createElement(
|
|
5604
5669
|
CubeButton,
|
|
5605
5670
|
{
|
|
5606
5671
|
key: index2,
|
|
@@ -5609,7 +5674,7 @@ function SubtopicAccordion({
|
|
|
5609
5674
|
locale,
|
|
5610
5675
|
sortLocale,
|
|
5611
5676
|
selectedItem,
|
|
5612
|
-
parent: item
|
|
5677
|
+
parent: item.split(" - ").pop()
|
|
5613
5678
|
}
|
|
5614
5679
|
))));
|
|
5615
5680
|
})
|