@datawheel/data-explorer 1.1.6 → 1.1.8
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 +95 -22
- package/package.json +3 -2
package/dist/main.mjs
CHANGED
|
@@ -21,6 +21,7 @@ import { saveElement } from 'd3plus-export';
|
|
|
21
21
|
import { d3plusConfigBuilder } from '@datawheel/vizbuilder/react';
|
|
22
22
|
import { assign } from 'd3plus-common';
|
|
23
23
|
import { BarChart, Geomap, Donut, LinePlot, StackedArea, Treemap } from 'd3plus-react';
|
|
24
|
+
import { useInView } from 'react-intersection-observer';
|
|
24
25
|
|
|
25
26
|
// src/components/DebugView.tsx
|
|
26
27
|
var explorerTranslation = {
|
|
@@ -3685,11 +3686,28 @@ function NumberInputComponent({ text, filter }) {
|
|
|
3685
3686
|
}
|
|
3686
3687
|
var MinMax = ({ filter, hideControls, ...rest }) => {
|
|
3687
3688
|
const actions2 = useActions();
|
|
3689
|
+
const updateUrl = useUpdateUrl();
|
|
3690
|
+
const queryItem = useSelector$1(selectCurrentQueryItem);
|
|
3691
|
+
const debouncedUpdateUrl = useMemo(
|
|
3692
|
+
() => debounce((query) => {
|
|
3693
|
+
updateUrl(query);
|
|
3694
|
+
}, 1e3),
|
|
3695
|
+
[]
|
|
3696
|
+
);
|
|
3697
|
+
useEffect(() => {
|
|
3698
|
+
return () => {
|
|
3699
|
+
debouncedUpdateUrl.cancel();
|
|
3700
|
+
};
|
|
3701
|
+
}, [debouncedUpdateUrl]);
|
|
3688
3702
|
function onInputChangeMinMax(props) {
|
|
3689
3703
|
const { filter: filter2, min: min2, max: max2 } = props;
|
|
3690
3704
|
const conditions = getFiltersConditions(getFilterFn(filter2) || "greaterThan", [Number(min2), Number(max2)]) || {};
|
|
3691
3705
|
const active = Boolean(min2) && Boolean(max2);
|
|
3692
|
-
|
|
3706
|
+
const newFilter = buildFilter({ ...filter2, active, ...conditions });
|
|
3707
|
+
actions2.updateFilter(newFilter);
|
|
3708
|
+
const newQuery = buildQuery(cloneDeep(queryItem));
|
|
3709
|
+
newQuery.params.filters[filter2.key] = newFilter;
|
|
3710
|
+
debouncedUpdateUrl(newQuery);
|
|
3693
3711
|
}
|
|
3694
3712
|
function getFilterValue(condition) {
|
|
3695
3713
|
if (condition) {
|
|
@@ -6325,9 +6343,20 @@ var iconByFormat = {
|
|
|
6325
6343
|
svg: IconVectorTriangle
|
|
6326
6344
|
};
|
|
6327
6345
|
function ChartCard(props) {
|
|
6328
|
-
const { chart, downloadFormats, isFullMode, onFocus, showConfidenceInt } = props;
|
|
6346
|
+
const { chart, downloadFormats, isFullMode, onFocus, showConfidenceInt, height } = props;
|
|
6329
6347
|
const { translate } = useTranslation();
|
|
6330
6348
|
const nodeRef = useRef(null);
|
|
6349
|
+
const { ref: inViewRef, inView } = useInView({ triggerOnce: false, threshold: 0 });
|
|
6350
|
+
const [hasBeenInView, setHasBeenInView] = useState(false);
|
|
6351
|
+
React13__default.useEffect(() => {
|
|
6352
|
+
if (inView && !hasBeenInView) {
|
|
6353
|
+
setHasBeenInView(true);
|
|
6354
|
+
}
|
|
6355
|
+
}, [inView, hasBeenInView]);
|
|
6356
|
+
const setRefs = (el) => {
|
|
6357
|
+
nodeRef.current = el;
|
|
6358
|
+
inViewRef(el);
|
|
6359
|
+
};
|
|
6331
6360
|
const [ChartComponent, config] = useD3plusConfig(chart, {
|
|
6332
6361
|
fullMode: !!isFullMode,
|
|
6333
6362
|
showConfidenceInt: !!showConfidenceInt,
|
|
@@ -6396,9 +6425,9 @@ function ChartCard(props) {
|
|
|
6396
6425
|
isShared ? translate("vizbuilder.share_copied") : translate("vizbuilder.action_share")
|
|
6397
6426
|
);
|
|
6398
6427
|
}, [clipboard, translate, isShared]);
|
|
6399
|
-
const
|
|
6428
|
+
const resolvedHeight = height ? height : isFullMode ? "calc(100vh - 3rem)" : 400;
|
|
6400
6429
|
if (!ChartComponent) return null;
|
|
6401
|
-
return /* @__PURE__ */ React13__default.createElement(Paper, { h:
|
|
6430
|
+
return /* @__PURE__ */ React13__default.createElement(Paper, { h: resolvedHeight, w: "100%", style: { overflow: "hidden" } }, /* @__PURE__ */ React13__default.createElement(ErrorBoundary, null, /* @__PURE__ */ React13__default.createElement(Stack, { spacing: 0, h: resolvedHeight, style: { position: "relative" }, w: "100%" }, /* @__PURE__ */ React13__default.createElement(Group, { position: "center", p: "xs", spacing: "xs", align: "center" }, isFullMode && shareButton, downloadButtons, onFocus && focusButton), /* @__PURE__ */ React13__default.createElement(Box, { style: { flex: "1 1 auto" }, ref: setRefs, pb: "xs", px: "xs" }, ChartComponent && (inView || hasBeenInView) ? /* @__PURE__ */ React13__default.createElement(ChartComponent, { config }) : /* @__PURE__ */ React13__default.createElement("div", { style: { height: "100%", width: "100%" } })))));
|
|
6402
6431
|
}
|
|
6403
6432
|
var getBackground = (node) => {
|
|
6404
6433
|
if (node.nodeType !== Node.ELEMENT_NODE) return "white";
|
|
@@ -6436,6 +6465,42 @@ function Vizbuilder(props) {
|
|
|
6436
6465
|
const queryItem = useSelector$1(selectCurrentQueryItem);
|
|
6437
6466
|
const currentChart = (queryItem == null ? void 0 : queryItem.chart) || "";
|
|
6438
6467
|
const { actions: actions2 } = useSettings();
|
|
6468
|
+
const useStyles6 = createStyles((theme) => ({
|
|
6469
|
+
grid: {
|
|
6470
|
+
padding: theme.spacing.xl,
|
|
6471
|
+
display: "grid",
|
|
6472
|
+
gridAutoRows: "minmax(200px, auto)",
|
|
6473
|
+
gap: theme.spacing.xl,
|
|
6474
|
+
gridTemplateColumns: "1fr 1fr",
|
|
6475
|
+
[theme.fn.smallerThan("md")]: {
|
|
6476
|
+
gridTemplateColumns: "1fr"
|
|
6477
|
+
}
|
|
6478
|
+
},
|
|
6479
|
+
itemLarge: {
|
|
6480
|
+
gridRow: "auto",
|
|
6481
|
+
gridColumn: "auto"
|
|
6482
|
+
},
|
|
6483
|
+
itemSmallTop: {
|
|
6484
|
+
gridRow: "auto",
|
|
6485
|
+
gridColumn: "auto"
|
|
6486
|
+
},
|
|
6487
|
+
itemSmallBottom: {
|
|
6488
|
+
gridRow: "auto",
|
|
6489
|
+
gridColumn: "auto"
|
|
6490
|
+
},
|
|
6491
|
+
// for single chart
|
|
6492
|
+
fill: {
|
|
6493
|
+
gridColumn: "1",
|
|
6494
|
+
gridRow: "1",
|
|
6495
|
+
height: "100%",
|
|
6496
|
+
width: "100%",
|
|
6497
|
+
[theme.fn.largerThan("md")]: {
|
|
6498
|
+
gridColumn: "1 / span 2",
|
|
6499
|
+
gridRow: "1 / span 2"
|
|
6500
|
+
}
|
|
6501
|
+
}
|
|
6502
|
+
}));
|
|
6503
|
+
const { classes, cx } = useStyles6();
|
|
6439
6504
|
const setCurrentChart = useCallback(
|
|
6440
6505
|
(chart) => {
|
|
6441
6506
|
actions2.updateChart(chart);
|
|
@@ -6472,34 +6537,40 @@ function Vizbuilder(props) {
|
|
|
6472
6537
|
if (chartList.length === 0 && !Array.isArray(datasets) && datasets.data.length === 1)
|
|
6473
6538
|
return /* @__PURE__ */ React13__default.createElement(Notice, { status: "one-row" });
|
|
6474
6539
|
if (chartList.length === 0) return /* @__PURE__ */ React13__default.createElement(Notice, { status: "empty" });
|
|
6475
|
-
const isSingleChart = chartList.length === 1;
|
|
6476
6540
|
if (chartList.length > 10) {
|
|
6477
6541
|
chartList = chartList.slice(0, 10);
|
|
6478
6542
|
}
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6488
|
-
|
|
6489
|
-
|
|
6490
|
-
|
|
6543
|
+
const isSingleChart = chartList.length === 1;
|
|
6544
|
+
return /* @__PURE__ */ React13__default.createElement(ErrorBoundary, null, /* @__PURE__ */ React13__default.createElement("div", { className: cx(classes.grid, { [classes.fill]: isSingleChart }) }, chartList.map((chart, idx) => {
|
|
6545
|
+
const pos = idx % 3;
|
|
6546
|
+
let style = {};
|
|
6547
|
+
let className = "";
|
|
6548
|
+
let height;
|
|
6549
|
+
if (isSingleChart) {
|
|
6550
|
+
className = classes.fill;
|
|
6551
|
+
height = 600;
|
|
6552
|
+
} else {
|
|
6553
|
+
if (pos === 0) {
|
|
6554
|
+
className = classes.itemLarge;
|
|
6555
|
+
} else if (pos === 1) {
|
|
6556
|
+
className = classes.itemSmallTop;
|
|
6557
|
+
} else if (pos === 2) {
|
|
6558
|
+
className = classes.itemSmallBottom;
|
|
6559
|
+
}
|
|
6560
|
+
}
|
|
6561
|
+
return /* @__PURE__ */ React13__default.createElement("div", { key: chart.key, className, style }, /* @__PURE__ */ React13__default.createElement(
|
|
6491
6562
|
ChartCard,
|
|
6492
6563
|
{
|
|
6493
|
-
key: chart.key,
|
|
6494
6564
|
chart,
|
|
6495
6565
|
downloadFormats,
|
|
6496
6566
|
measureConfig: getMeasureConfig,
|
|
6497
6567
|
onFocus: () => setCurrentChart(chart.key),
|
|
6498
6568
|
showConfidenceInt,
|
|
6499
|
-
userConfig
|
|
6569
|
+
userConfig,
|
|
6570
|
+
...height ? { height } : {}
|
|
6500
6571
|
}
|
|
6501
|
-
))
|
|
6502
|
-
));
|
|
6572
|
+
));
|
|
6573
|
+
})));
|
|
6503
6574
|
}, [
|
|
6504
6575
|
charts,
|
|
6505
6576
|
datasets,
|
|
@@ -6507,7 +6578,9 @@ function Vizbuilder(props) {
|
|
|
6507
6578
|
getMeasureConfig,
|
|
6508
6579
|
nonIdealState,
|
|
6509
6580
|
showConfidenceInt,
|
|
6510
|
-
userConfig
|
|
6581
|
+
userConfig,
|
|
6582
|
+
classes,
|
|
6583
|
+
cx
|
|
6511
6584
|
]);
|
|
6512
6585
|
const focusContent = useMemo(() => {
|
|
6513
6586
|
const chart = charts[currentChart];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@datawheel/data-explorer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.8",
|
|
4
4
|
"main": "./dist/main.mjs",
|
|
5
5
|
"types": "./dist/main.d.mts",
|
|
6
6
|
"files": [
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
"mantine-react-table": "^1.3.0",
|
|
40
40
|
"match-sorter": "^6.3.4",
|
|
41
41
|
"postcss-modules": "^6.0.0",
|
|
42
|
+
"react-intersection-observer": "^9.16.0",
|
|
42
43
|
"react-redux": "^7.0.0",
|
|
43
44
|
"react-router-dom": "^6.30.0",
|
|
44
45
|
"react-viewport-list": "^3.0.0",
|
|
@@ -47,8 +48,8 @@
|
|
|
47
48
|
"yn": "^5.0.0"
|
|
48
49
|
},
|
|
49
50
|
"peerDependencies": {
|
|
50
|
-
"@emotion/react": "^11.0.0",
|
|
51
51
|
"@datawheel/vizbuilder": "^0.6.0",
|
|
52
|
+
"@emotion/react": "^11.0.0",
|
|
52
53
|
"@mantine/core": "^6.0.0",
|
|
53
54
|
"@mantine/dates": "^6.0.0",
|
|
54
55
|
"@mantine/hooks": "^6.0.0",
|