@datawheel/data-explorer 0.3.17 → 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 +21 -17
- package/dist/main.mjs +28 -19
- package/package.json +2 -2
package/dist/main.d.mts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import React__default, { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
3
2
|
import { MRT_TableInstance, MRT_ColumnDef, MRT_PaginationState, MRT_TableOptions } from 'mantine-react-table';
|
|
4
|
-
import * as _datawheel_use_translation from '@datawheel/use-translation';
|
|
5
3
|
import { TranslationDict, TranslationContextProps } from '@datawheel/use-translation';
|
|
6
4
|
import { CSSObject } from '@mantine/core';
|
|
7
5
|
import { Translation as Translation$1 } from '@datawheel/vizbuilder/react';
|
|
@@ -466,7 +464,7 @@ type Formatter = (value: number | null, locale?: string) => string;
|
|
|
466
464
|
interface PanelDescriptor {
|
|
467
465
|
key: string;
|
|
468
466
|
label: string;
|
|
469
|
-
component:
|
|
467
|
+
component: React.ComponentType<ViewProps>;
|
|
470
468
|
}
|
|
471
469
|
interface ViewProps<TData extends Record<string, any> = Record<string, string | number>> {
|
|
472
470
|
className?: string;
|
|
@@ -480,11 +478,11 @@ interface ViewProps<TData extends Record<string, any> = Record<string, string |
|
|
|
480
478
|
data?: Record<string, string | number>[];
|
|
481
479
|
columns?: MRT_ColumnDef<TData>[];
|
|
482
480
|
pagination?: MRT_PaginationState;
|
|
483
|
-
setPagination?:
|
|
481
|
+
setPagination?: React.Dispatch<React.SetStateAction<MRT_PaginationState>>;
|
|
484
482
|
}
|
|
485
483
|
|
|
486
484
|
/** */
|
|
487
|
-
declare function DebugView(props: ViewProps):
|
|
485
|
+
declare function DebugView(props: ViewProps): React.JSX.Element;
|
|
488
486
|
|
|
489
487
|
declare const explorerTranslation: {
|
|
490
488
|
action_copy: string;
|
|
@@ -1038,15 +1036,15 @@ declare const defaultTranslation: {
|
|
|
1038
1036
|
unselected_items: string;
|
|
1039
1037
|
};
|
|
1040
1038
|
};
|
|
1041
|
-
declare const useTranslation:
|
|
1042
|
-
declare const TranslationConsumer:
|
|
1039
|
+
declare const useTranslation: any;
|
|
1040
|
+
declare const TranslationConsumer: any;
|
|
1043
1041
|
|
|
1044
1042
|
interface ExplorerStepType extends StepType {
|
|
1045
1043
|
actionBefore?: () => void;
|
|
1046
1044
|
}
|
|
1047
1045
|
type TourConfig = {
|
|
1048
1046
|
extraSteps?: ExplorerStepType[];
|
|
1049
|
-
introImage?:
|
|
1047
|
+
introImage?: React.ReactNode;
|
|
1050
1048
|
tourProps?: Partial<TourProps>;
|
|
1051
1049
|
};
|
|
1052
1050
|
interface TourStepsPropsType {
|
|
@@ -1063,7 +1061,7 @@ interface ToolbarConfigType {
|
|
|
1063
1061
|
buttons: ToolBarButtonProps[];
|
|
1064
1062
|
showLabels: Boolean;
|
|
1065
1063
|
}
|
|
1066
|
-
declare function ToolbarButton({ icon, label, onClick }: ToolBarButtonProps):
|
|
1064
|
+
declare function ToolbarButton({ icon, label, onClick }: ToolBarButtonProps): React.JSX.Element;
|
|
1067
1065
|
|
|
1068
1066
|
type Pagination = {
|
|
1069
1067
|
rowsLimits: number[];
|
|
@@ -1122,6 +1120,11 @@ declare function ExplorerComponent<Locale extends string>(props: {
|
|
|
1122
1120
|
* from `measure.annotations.units_of_measurement`, if present.
|
|
1123
1121
|
*/
|
|
1124
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>;
|
|
1125
1128
|
/**
|
|
1126
1129
|
* Defines an alternative height for the component structure.
|
|
1127
1130
|
* @default "100vh"
|
|
@@ -1145,7 +1148,7 @@ declare function ExplorerComponent<Locale extends string>(props: {
|
|
|
1145
1148
|
* the screen that is shown in the results panel when there is no query,
|
|
1146
1149
|
* or a query has been dirtied.
|
|
1147
1150
|
*/
|
|
1148
|
-
splash?:
|
|
1151
|
+
splash?: React.ComponentType<{
|
|
1149
1152
|
translation: TranslationContextProps;
|
|
1150
1153
|
}>;
|
|
1151
1154
|
toolbarConfig?: Partial<ToolbarConfigType>;
|
|
@@ -1180,13 +1183,13 @@ declare function ExplorerComponent<Locale extends string>(props: {
|
|
|
1180
1183
|
* @default false
|
|
1181
1184
|
*/
|
|
1182
1185
|
withPermalink?: boolean;
|
|
1183
|
-
}):
|
|
1186
|
+
}): React.JSX.Element;
|
|
1184
1187
|
declare namespace ExplorerComponent {
|
|
1185
1188
|
var displayName: string;
|
|
1186
1189
|
}
|
|
1187
1190
|
|
|
1188
1191
|
/** */
|
|
1189
|
-
declare function PivotView<TData extends Record<string, unknown>>(props: {} & ViewProps<TData> & MRT_TableOptions<TData>):
|
|
1192
|
+
declare function PivotView<TData extends Record<string, unknown>>(props: {} & ViewProps<TData> & MRT_TableOptions<TData>): React.JSX.Element;
|
|
1190
1193
|
|
|
1191
1194
|
type TData = Record<string, any> & Record<string, string | number>;
|
|
1192
1195
|
type TableView = {
|
|
@@ -1194,7 +1197,7 @@ type TableView = {
|
|
|
1194
1197
|
getColumn(id: string): AnyResultColumn | undefined;
|
|
1195
1198
|
columns: AnyResultColumn[];
|
|
1196
1199
|
} & ViewProps;
|
|
1197
|
-
declare function TableView({ table, result, isError, isLoading, data, pagination, setPagination }: TableView):
|
|
1200
|
+
declare function TableView({ table, result, isError, isLoading, data, pagination, setPagination }: TableView): React.JSX.Element;
|
|
1198
1201
|
declare namespace TableView {
|
|
1199
1202
|
var displayName: string;
|
|
1200
1203
|
}
|
|
@@ -1340,6 +1343,7 @@ interface SettingsContextProps {
|
|
|
1340
1343
|
actions: ExplorerBoundActionMap;
|
|
1341
1344
|
defaultMembersFilter: "id" | "name" | "any";
|
|
1342
1345
|
formatters: Record<string, Formatter>;
|
|
1346
|
+
idFormatters: Record<string, Formatter>;
|
|
1343
1347
|
previewLimit: number;
|
|
1344
1348
|
panels: PanelDescriptor[];
|
|
1345
1349
|
paginationConfig: Pagination;
|
|
@@ -1349,7 +1353,7 @@ interface SettingsContextProps {
|
|
|
1349
1353
|
/**
|
|
1350
1354
|
* A wrapper for the Consumer, for use with class components.
|
|
1351
1355
|
*/
|
|
1352
|
-
declare function SettingsConsumer(props:
|
|
1356
|
+
declare function SettingsConsumer(props: React.ConsumerProps<SettingsContextProps>): React.JSX.Element;
|
|
1353
1357
|
/**
|
|
1354
1358
|
* The React hook associated to the settings context.
|
|
1355
1359
|
*/
|
|
@@ -1359,8 +1363,8 @@ declare function VizbuilderView(props: {
|
|
|
1359
1363
|
cube: TesseractCube;
|
|
1360
1364
|
params: QueryParams;
|
|
1361
1365
|
result: QueryResult;
|
|
1362
|
-
}): false |
|
|
1366
|
+
}): false | React.JSX.Element;
|
|
1363
1367
|
|
|
1364
|
-
declare function TourStep(props: TourStepsPropsType):
|
|
1368
|
+
declare function TourStep(props: TourStepsPropsType): React.JSX.Element;
|
|
1365
1369
|
|
|
1366
1370
|
export { DebugView, ExplorerComponent as Explorer, type ExplorerState, type ExplorerStepType, PivotView, SettingsConsumer, TableView, ToolbarButton, TourStep, TranslationConsumer, type Translation as TranslationDict, type ViewProps, VizbuilderView, reducer as explorerReducer, thunkExtraArg as explorerThunkExtraArg, defaultTranslation as translationDict, useSettings, useTranslation };
|
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 = {
|
|
@@ -4117,7 +4123,7 @@ function useTable({
|
|
|
4117
4123
|
}
|
|
4118
4124
|
},
|
|
4119
4125
|
getSortIcon(isSorted ? sortDir : false, entityType)
|
|
4120
|
-
))), /* @__PURE__ */ React19__default.createElement(
|
|
4126
|
+
))), showTrashIcon(finalKeys, entityType) && /* @__PURE__ */ React19__default.createElement(
|
|
4121
4127
|
CustomActionIcon_default,
|
|
4122
4128
|
{
|
|
4123
4129
|
label: `At least one ${getEntityText(entityType)} is required.`,
|
|
@@ -4137,9 +4143,10 @@ function useTable({
|
|
|
4137
4143
|
dataType: valueType,
|
|
4138
4144
|
accessorFn: (item) => item[columnKey],
|
|
4139
4145
|
Cell: isNumeric ? ({ cell }) => {
|
|
4140
|
-
return /* @__PURE__ */ React19__default.createElement("span", { style: { display: "block", textAlign: "right" } }, formatter2(cell.getValue()));
|
|
4146
|
+
return /* @__PURE__ */ React19__default.createElement("span", { style: { display: "block", textAlign: "right" } }, formatter2(cell.getValue(), locale));
|
|
4141
4147
|
} : ({ cell, renderedCellValue, row }) => {
|
|
4142
4148
|
const cellId = row.original[`${cell.column.id} ID`];
|
|
4149
|
+
const idFormatter = idFormatters[`${cell.column.id} ID`];
|
|
4143
4150
|
return /* @__PURE__ */ React19__default.createElement(Flex, { justify: "space-between", sx: { width: "100%", maxWidth: 400 }, gap: "sm" }, /* @__PURE__ */ React19__default.createElement(
|
|
4144
4151
|
Text,
|
|
4145
4152
|
{
|
|
@@ -4151,7 +4158,7 @@ function useTable({
|
|
|
4151
4158
|
}
|
|
4152
4159
|
},
|
|
4153
4160
|
renderedCellValue
|
|
4154
|
-
), /* @__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)));
|
|
4155
4162
|
}
|
|
4156
4163
|
};
|
|
4157
4164
|
});
|
|
@@ -5535,14 +5542,15 @@ function useFormatParams(measures, valueProperty) {
|
|
|
5535
5542
|
const { translate: t } = useTranslation();
|
|
5536
5543
|
const fmt = useFormatter();
|
|
5537
5544
|
return useMemo(() => {
|
|
5538
|
-
const
|
|
5545
|
+
const measure = measures.find((item) => item.name === valueProperty);
|
|
5546
|
+
const formatterKey = fmt.getFormat(measure || valueProperty);
|
|
5539
5547
|
const formatter2 = fmt.getFormatter(formatterKey);
|
|
5540
5548
|
return {
|
|
5541
5549
|
formatExample: formatter2(12345.6789),
|
|
5542
5550
|
formatter: formatter2,
|
|
5543
5551
|
formatterKey,
|
|
5544
5552
|
formatterKeyOptions: [{ label: t("placeholders.none"), value: "undefined" }].concat(
|
|
5545
|
-
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 }))
|
|
5546
5554
|
),
|
|
5547
5555
|
setFormat: fmt.setFormat
|
|
5548
5556
|
};
|
|
@@ -6317,6 +6325,7 @@ function ExplorerComponent(props) {
|
|
|
6317
6325
|
actions: boundActions,
|
|
6318
6326
|
defaultMembersFilter: props.defaultMembersFilter,
|
|
6319
6327
|
formatters: props.formatters,
|
|
6328
|
+
idFormatters: props.idFormatters,
|
|
6320
6329
|
withPermalink: props.withPermalink,
|
|
6321
6330
|
panels,
|
|
6322
6331
|
pagination,
|
package/package.json
CHANGED