@datawheel/data-explorer 0.3.15 → 0.3.18
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.d.mts +6 -0
- package/dist/main.mjs +34 -20
- package/package.json +1 -1
package/dist/main.d.mts
CHANGED
|
@@ -1120,6 +1120,11 @@ declare function ExplorerComponent<Locale extends string>(props: {
|
|
|
1120
1120
|
* from `measure.annotations.units_of_measurement`, if present.
|
|
1121
1121
|
*/
|
|
1122
1122
|
formatters?: Record<string, Formatter>;
|
|
1123
|
+
/**
|
|
1124
|
+
* Defines an index of formatter functions available for dimension IDs
|
|
1125
|
+
* that are displayed next to the value.
|
|
1126
|
+
* */
|
|
1127
|
+
idFormatters?: Record<string, Formatter>;
|
|
1123
1128
|
/**
|
|
1124
1129
|
* Defines an alternative height for the component structure.
|
|
1125
1130
|
* @default "100vh"
|
|
@@ -1338,6 +1343,7 @@ interface SettingsContextProps {
|
|
|
1338
1343
|
actions: ExplorerBoundActionMap;
|
|
1339
1344
|
defaultMembersFilter: "id" | "name" | "any";
|
|
1340
1345
|
formatters: Record<string, Formatter>;
|
|
1346
|
+
idFormatters: Record<string, Formatter>;
|
|
1341
1347
|
previewLimit: number;
|
|
1342
1348
|
panels: PanelDescriptor[];
|
|
1343
1349
|
paginationConfig: Pagination;
|
package/dist/main.mjs
CHANGED
|
@@ -1797,6 +1797,7 @@ function SettingsProvider(props) {
|
|
|
1797
1797
|
actions: props.actions,
|
|
1798
1798
|
defaultMembersFilter: props.defaultMembersFilter || "id",
|
|
1799
1799
|
formatters: props.formatters || {},
|
|
1800
|
+
idFormatters: props.idFormatters || {},
|
|
1800
1801
|
panels: props.panels,
|
|
1801
1802
|
previewLimit: props.previewLimit || 50,
|
|
1802
1803
|
paginationConfig: (_a = props.pagination) != null ? _a : { rowsLimits: [100, 300, 500, 1e3], defaultLimit: 100 },
|
|
@@ -2407,6 +2408,7 @@ function useFormatter() {
|
|
|
2407
2408
|
const { formatters } = useSettings();
|
|
2408
2409
|
const [formatMap, setFormatMap] = useState({});
|
|
2409
2410
|
const formatterMap = useRef(formatters);
|
|
2411
|
+
console.log(formatterMap, "formatMap");
|
|
2410
2412
|
return useMemo(() => {
|
|
2411
2413
|
return {
|
|
2412
2414
|
currentFormats: formatMap,
|
|
@@ -2454,6 +2456,10 @@ function useFormatter() {
|
|
|
2454
2456
|
}
|
|
2455
2457
|
}, [formatMap]);
|
|
2456
2458
|
}
|
|
2459
|
+
function useidFormatters() {
|
|
2460
|
+
const { idFormatters } = useSettings();
|
|
2461
|
+
return { idFormatters };
|
|
2462
|
+
}
|
|
2457
2463
|
|
|
2458
2464
|
// src/components/CustomActionIcon.tsx
|
|
2459
2465
|
init_esm_shims();
|
|
@@ -3228,26 +3234,26 @@ function Results(props) {
|
|
|
3228
3234
|
}
|
|
3229
3235
|
return /* @__PURE__ */ React19__default.createElement(Box, { px: "sm" }, result);
|
|
3230
3236
|
}
|
|
3231
|
-
var useStyles2 = createStyles((
|
|
3237
|
+
var useStyles2 = createStyles((t) => ({
|
|
3232
3238
|
link: {
|
|
3233
|
-
...
|
|
3239
|
+
...t.fn.focusStyles(),
|
|
3234
3240
|
WebkitTapHighlightColor: "transparent",
|
|
3235
3241
|
outline: 0,
|
|
3236
3242
|
display: "block",
|
|
3237
3243
|
textDecoration: "none",
|
|
3238
|
-
color:
|
|
3239
|
-
padding:
|
|
3244
|
+
color: t.colorScheme === "dark" ? t.white : t.colors.dark[6],
|
|
3245
|
+
padding: t.spacing.xs,
|
|
3240
3246
|
minHeight: rem(20),
|
|
3241
|
-
fontSize:
|
|
3247
|
+
fontSize: t.fontSizes.sm,
|
|
3242
3248
|
whiteSpace: "wrap",
|
|
3243
3249
|
cursor: "pointer",
|
|
3244
3250
|
"&:hover": {
|
|
3245
|
-
backgroundColor:
|
|
3251
|
+
backgroundColor: t.colorScheme === "dark" ? t.colors[t.primaryColor][4] : t.colors[t.primaryColor][4]
|
|
3246
3252
|
}
|
|
3247
3253
|
},
|
|
3248
3254
|
linkActive: {
|
|
3249
|
-
backgroundColor:
|
|
3250
|
-
color:
|
|
3255
|
+
backgroundColor: t.colorScheme === "dark" ? t.colors[t.primaryColor][9] : t.colors[t.primaryColor][5],
|
|
3256
|
+
color: t.colorScheme === "dark" ? t.colors.dark[6] : t.colors.dark[6],
|
|
3251
3257
|
fontWeight: 500
|
|
3252
3258
|
}
|
|
3253
3259
|
}));
|
|
@@ -3429,9 +3435,9 @@ function RootAccordions({ items, graph, locale, selectedItem, onSelectCube }) {
|
|
|
3429
3435
|
fontSize: t.fontSizes.md,
|
|
3430
3436
|
"&[data-active]": {
|
|
3431
3437
|
borderLeft: 6,
|
|
3432
|
-
borderLeftColor: t.
|
|
3438
|
+
borderLeftColor: t.fn.primaryColor(),
|
|
3433
3439
|
borderLeftStyle: "solid",
|
|
3434
|
-
color: t.
|
|
3440
|
+
color: t.fn.primaryColor()
|
|
3435
3441
|
}
|
|
3436
3442
|
},
|
|
3437
3443
|
content: {
|
|
@@ -3480,7 +3486,7 @@ function CubeButton({
|
|
|
3480
3486
|
component: "a",
|
|
3481
3487
|
className: isSelected(selectedItem, getCube(graph.items, item, subtopic, locale)) ? `${classes.link} ${classes.linkActive}` : classes.link,
|
|
3482
3488
|
sx: (t) => ({
|
|
3483
|
-
|
|
3489
|
+
backgroundColor: isSelected(selectedItem, getCube(graph.items, item, subtopic, locale)) ? t.fn.primaryColor() : t.colorScheme === "dark" ? t.colors.dark[6] : t.colors.gray[3],
|
|
3484
3490
|
overflow: "hidden"
|
|
3485
3491
|
}),
|
|
3486
3492
|
onClick: () => onSelectCube(item, subtopic)
|
|
@@ -3500,6 +3506,7 @@ function SubtopicAccordion({
|
|
|
3500
3506
|
return /* @__PURE__ */ React19__default.createElement(
|
|
3501
3507
|
Accordion,
|
|
3502
3508
|
{
|
|
3509
|
+
id: "data-accordion-topic",
|
|
3503
3510
|
value,
|
|
3504
3511
|
onChange: setValue,
|
|
3505
3512
|
key: `subtopic-${parent}`,
|
|
@@ -3522,7 +3529,7 @@ function SubtopicAccordion({
|
|
|
3522
3529
|
}
|
|
3523
3530
|
})
|
|
3524
3531
|
},
|
|
3525
|
-
[...items].map((item, index) => {
|
|
3532
|
+
[...items].sort((a, b) => a.localeCompare(b, locale, { sensitivity: "base" })).map((item, index) => {
|
|
3526
3533
|
const filtered = [...graph.adjList[item]].filter((value2) => value2 !== parent);
|
|
3527
3534
|
return /* @__PURE__ */ React19__default.createElement(Accordion.Item, { value: `subtopic-${item}`, key: `subtopic-${item}-${index}` }, /* @__PURE__ */ React19__default.createElement(AccordionControl, null, item), /* @__PURE__ */ React19__default.createElement(Accordion.Panel, null, filtered.map((table, index2) => /* @__PURE__ */ React19__default.createElement(
|
|
3528
3535
|
CubeButton,
|
|
@@ -3659,7 +3666,6 @@ var ApiAndCsvButtons = (props) => {
|
|
|
3659
3666
|
Button,
|
|
3660
3667
|
{
|
|
3661
3668
|
id: "dex-api-btn",
|
|
3662
|
-
variant: "subtle",
|
|
3663
3669
|
leftIcon: /* @__PURE__ */ React19__default.createElement(IconCopy, { size: 20 }),
|
|
3664
3670
|
sx: { height: 30 },
|
|
3665
3671
|
onClick: copyHandler
|
|
@@ -3677,7 +3683,6 @@ var DownloadQuery = ({ data }) => {
|
|
|
3677
3683
|
/* @__PURE__ */ React19__default.createElement(
|
|
3678
3684
|
ButtonDownload,
|
|
3679
3685
|
{
|
|
3680
|
-
variant: "light",
|
|
3681
3686
|
leftIcon: /* @__PURE__ */ React19__default.createElement(IconDownload, { size: 20 }),
|
|
3682
3687
|
sx: { height: 30 },
|
|
3683
3688
|
key: "download_csv",
|
|
@@ -4053,6 +4058,7 @@ function useTable({
|
|
|
4053
4058
|
}, [pagination]);
|
|
4054
4059
|
const { translate: t } = useTranslation();
|
|
4055
4060
|
const { getFormat, getFormatter } = useFormatter();
|
|
4061
|
+
const { idFormatters } = useidFormatters();
|
|
4056
4062
|
const { sortKey, sortDir } = useSelector$1(selectSortingParams);
|
|
4057
4063
|
const columns = useMemo(() => {
|
|
4058
4064
|
const indexColumn = {
|
|
@@ -4076,7 +4082,10 @@ function useTable({
|
|
|
4076
4082
|
isId
|
|
4077
4083
|
} = column;
|
|
4078
4084
|
const isNumeric = valueType === "number" && columnKey !== "Year";
|
|
4079
|
-
const formatterKey = getFormat(
|
|
4085
|
+
const formatterKey = getFormat(
|
|
4086
|
+
"aggregator" in entity ? entity : columnKey,
|
|
4087
|
+
isNumeric ? "Decimal" : "identity"
|
|
4088
|
+
);
|
|
4080
4089
|
const formatter2 = getFormatter(formatterKey);
|
|
4081
4090
|
const mantineFilterVariantObject = getMantineFilterMultiSelectProps(isId, isNumeric, range);
|
|
4082
4091
|
return {
|
|
@@ -4114,7 +4123,7 @@ function useTable({
|
|
|
4114
4123
|
}
|
|
4115
4124
|
},
|
|
4116
4125
|
getSortIcon(isSorted ? sortDir : false, entityType)
|
|
4117
|
-
))), /* @__PURE__ */ React19__default.createElement(
|
|
4126
|
+
))), showTrashIcon(finalKeys, entityType) && /* @__PURE__ */ React19__default.createElement(
|
|
4118
4127
|
CustomActionIcon_default,
|
|
4119
4128
|
{
|
|
4120
4129
|
label: `At least one ${getEntityText(entityType)} is required.`,
|
|
@@ -4133,8 +4142,11 @@ function useTable({
|
|
|
4133
4142
|
id: entity.name,
|
|
4134
4143
|
dataType: valueType,
|
|
4135
4144
|
accessorFn: (item) => item[columnKey],
|
|
4136
|
-
Cell: isNumeric ? ({ cell }) =>
|
|
4145
|
+
Cell: isNumeric ? ({ cell }) => {
|
|
4146
|
+
return /* @__PURE__ */ React19__default.createElement("span", { style: { display: "block", textAlign: "right" } }, formatter2(cell.getValue(), locale));
|
|
4147
|
+
} : ({ cell, renderedCellValue, row }) => {
|
|
4137
4148
|
const cellId = row.original[`${cell.column.id} ID`];
|
|
4149
|
+
const idFormatter = idFormatters[`${cell.column.id} ID`];
|
|
4138
4150
|
return /* @__PURE__ */ React19__default.createElement(Flex, { justify: "space-between", sx: { width: "100%", maxWidth: 400 }, gap: "sm" }, /* @__PURE__ */ React19__default.createElement(
|
|
4139
4151
|
Text,
|
|
4140
4152
|
{
|
|
@@ -4146,7 +4158,7 @@ function useTable({
|
|
|
4146
4158
|
}
|
|
4147
4159
|
},
|
|
4148
4160
|
renderedCellValue
|
|
4149
|
-
), /* @__PURE__ */ React19__default.createElement(Box, null, cellId && /* @__PURE__ */ React19__default.createElement(Text, { color: "dimmed" }, cellId)));
|
|
4161
|
+
), /* @__PURE__ */ React19__default.createElement(Box, null, cellId && /* @__PURE__ */ React19__default.createElement(Text, { color: "dimmed" }, idFormatter ? idFormatter(cellId) : cellId)));
|
|
4150
4162
|
}
|
|
4151
4163
|
};
|
|
4152
4164
|
});
|
|
@@ -5530,14 +5542,15 @@ function useFormatParams(measures, valueProperty) {
|
|
|
5530
5542
|
const { translate: t } = useTranslation();
|
|
5531
5543
|
const fmt = useFormatter();
|
|
5532
5544
|
return useMemo(() => {
|
|
5533
|
-
const
|
|
5545
|
+
const measure = measures.find((item) => item.name === valueProperty);
|
|
5546
|
+
const formatterKey = fmt.getFormat(measure || valueProperty);
|
|
5534
5547
|
const formatter2 = fmt.getFormatter(formatterKey);
|
|
5535
5548
|
return {
|
|
5536
5549
|
formatExample: formatter2(12345.6789),
|
|
5537
5550
|
formatter: formatter2,
|
|
5538
5551
|
formatterKey,
|
|
5539
5552
|
formatterKeyOptions: [{ label: t("placeholders.none"), value: "undefined" }].concat(
|
|
5540
|
-
fmt.getAvailableFormats(valueProperty).map((key) => ({ label: fmt.getFormatter(key)(12345.6789), value: key }))
|
|
5553
|
+
fmt.getAvailableFormats(measure || valueProperty).map((key) => ({ label: fmt.getFormatter(key)(12345.6789), value: key }))
|
|
5541
5554
|
),
|
|
5542
5555
|
setFormat: fmt.setFormat
|
|
5543
5556
|
};
|
|
@@ -6312,6 +6325,7 @@ function ExplorerComponent(props) {
|
|
|
6312
6325
|
actions: boundActions,
|
|
6313
6326
|
defaultMembersFilter: props.defaultMembersFilter,
|
|
6314
6327
|
formatters: props.formatters,
|
|
6328
|
+
idFormatters: props.idFormatters,
|
|
6315
6329
|
withPermalink: props.withPermalink,
|
|
6316
6330
|
panels,
|
|
6317
6331
|
pagination,
|