Add settings page for managing forecasting API key and URL via UI

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
jtricerolph 2026-07-20 14:37:36 +00:00
parent cae411eae7
commit 1c411e402e
19809 changed files with 1962608 additions and 97 deletions

View file

@ -0,0 +1,64 @@
var _excluded = ["children"];
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
import * as React from 'react';
import { createContext, useContext, useEffect, useRef } from 'react';
import { addErrorBar, removeErrorBar, replaceErrorBar } from '../state/errorBarSlice';
import { useAppDispatch } from '../state/hooks';
import { useGraphicalItemId } from './RegisterGraphicalItemId';
var initialContextState = {
data: [],
xAxisId: 'xAxis-0',
yAxisId: 'yAxis-0',
dataPointFormatter: () => ({
x: 0,
y: 0,
value: 0
}),
errorBarOffset: 0
};
var ErrorBarContext = /*#__PURE__*/createContext(initialContextState);
export function SetErrorBarContext(props) {
var children = props.children,
rest = _objectWithoutProperties(props, _excluded);
return /*#__PURE__*/React.createElement(ErrorBarContext.Provider, {
value: rest
}, children);
}
export var useErrorBarContext = () => useContext(ErrorBarContext);
export function ReportErrorBarSettings(props) {
var dispatch = useAppDispatch();
var graphicalItemId = useGraphicalItemId();
var prevPropsRef = useRef(null);
useEffect(() => {
if (graphicalItemId == null) {
// ErrorBar outside a graphical item context does not do anything.
return;
}
if (prevPropsRef.current === null) {
dispatch(addErrorBar({
itemId: graphicalItemId,
errorBar: props
}));
} else if (prevPropsRef.current !== props) {
dispatch(replaceErrorBar({
itemId: graphicalItemId,
prev: prevPropsRef.current,
next: props
}));
}
prevPropsRef.current = props;
}, [dispatch, graphicalItemId, props]);
useEffect(() => {
return () => {
if (prevPropsRef.current != null && graphicalItemId != null) {
dispatch(removeErrorBar({
itemId: graphicalItemId,
errorBar: prevPropsRef.current
}));
prevPropsRef.current = null;
}
};
}, [dispatch, graphicalItemId]);
return null;
}

View file

@ -0,0 +1,10 @@
import * as React from 'react';
import { createContext, useContext } from 'react';
var PanoramaContext = /*#__PURE__*/createContext(null);
export var useIsPanorama = () => useContext(PanoramaContext) != null;
export var PanoramaContextProvider = _ref => {
var children = _ref.children;
return /*#__PURE__*/React.createElement(PanoramaContext.Provider, {
value: true
}, children);
};

View file

@ -0,0 +1,16 @@
import * as React from 'react';
import { createContext, useContext } from 'react';
import { useUniqueId } from '../util/useUniqueId';
var GraphicalItemIdContext = /*#__PURE__*/createContext(undefined);
export var RegisterGraphicalItemId = _ref => {
var id = _ref.id,
type = _ref.type,
children = _ref.children;
var resolvedId = useUniqueId("recharts-".concat(type), id);
return /*#__PURE__*/React.createElement(GraphicalItemIdContext.Provider, {
value: resolvedId
}, children(resolvedId));
};
export function useGraphicalItemId() {
return useContext(GraphicalItemIdContext);
}

View file

@ -0,0 +1,5 @@
import { useAppSelector } from '../state/hooks';
export var useAccessibilityLayer = () => {
var _useAppSelector;
return (_useAppSelector = useAppSelector(state => state.rootProps.accessibilityLayer)) !== null && _useAppSelector !== void 0 ? _useAppSelector : true;
};

View file

@ -0,0 +1,2 @@
import { createContext } from 'react';
export var BrushUpdateDispatchContext = /*#__PURE__*/createContext(() => {});

View file

@ -0,0 +1,73 @@
import { useEffect } from 'react';
import { setChartData, setComputedData } from '../state/chartDataSlice';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { useIsPanorama } from './PanoramaContext';
export var ChartDataContextProvider = props => {
var chartData = props.chartData;
var dispatch = useAppDispatch();
var isPanorama = useIsPanorama();
useEffect(() => {
if (isPanorama) {
// Panorama mode reuses data from the main chart, so we must not overwrite it here.
return () => {
// there is nothing to clean up
};
}
dispatch(setChartData(chartData));
return () => {
dispatch(setChartData(undefined));
};
}, [chartData, dispatch, isPanorama]);
return null;
};
export var SetComputedData = props => {
var computedData = props.computedData;
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(setComputedData(computedData));
return () => {
dispatch(setChartData(undefined));
};
}, [computedData, dispatch]);
return null;
};
var selectChartData = state => state.chartData.chartData;
/**
* "data" is the data of the chart - it has no type because this part of recharts is very flexible.
* Basically it's an array of "something" and then there's the dataKey property in various places
* that's meant to pull other things away from the data.
*
* Some charts have `data` defined on the chart root, and they will return the array through this hook.
* For example: <ComposedChart data={data} />.
*
* Other charts, such as Pie, have data defined on individual graphical elements.
* These charts will return `undefined` through this hook, and you need to read the data from children.
* For example: <PieChart><Pie data={data} />
*
* Some charts also allow setting both - data on the parent, and data on the children at the same time!
* However, this particular selector will only return the ones defined on the parent.
*
* @deprecated use one of the other selectors instead - which one, depends on how do you identify the applicable graphical items.
*
* @return data array for some charts and undefined for other
*/
export var useChartData = () => useAppSelector(selectChartData);
var selectDataIndex = state => {
var _state$chartData = state.chartData,
dataStartIndex = _state$chartData.dataStartIndex,
dataEndIndex = _state$chartData.dataEndIndex;
return {
startIndex: dataStartIndex,
endIndex: dataEndIndex
};
};
/**
* startIndex and endIndex are data boundaries, set through Brush.
*
* @return object with startIndex and endIndex
*/
export var useDataIndex = () => {
return useAppSelector(selectDataIndex);
};

View file

@ -0,0 +1,242 @@
import { useEffect } from 'react';
import { useAppDispatch, useAppSelector } from '../state/hooks';
import { setChartSize, setMargin } from '../state/layoutSlice';
import { selectChartOffsetInternal, selectChartViewBox } from '../state/selectors/selectChartOffsetInternal';
import { selectChartHeight, selectChartWidth } from '../state/selectors/containerSelectors';
import { useIsPanorama } from './PanoramaContext';
import { selectBrushDimensions, selectBrushSettings } from '../state/selectors/brushSelectors';
import { useResponsiveContainerContext } from '../component/ResponsiveContainer';
import { isPositiveNumber } from '../util/isWellBehavedNumber';
export function cartesianViewBoxToTrapezoid(box) {
if (!box) {
return undefined;
}
return {
x: box.x,
y: box.y,
upperWidth: 'upperWidth' in box ? box.upperWidth : box.width,
lowerWidth: 'lowerWidth' in box ? box.lowerWidth : box.width,
width: box.width,
height: box.height
};
}
export var useViewBox = () => {
var _useAppSelector;
var panorama = useIsPanorama();
var rootViewBox = useAppSelector(selectChartViewBox);
var brushDimensions = useAppSelector(selectBrushDimensions);
var brushPadding = (_useAppSelector = useAppSelector(selectBrushSettings)) === null || _useAppSelector === void 0 ? void 0 : _useAppSelector.padding;
if (!panorama || !brushDimensions || !brushPadding) {
return rootViewBox;
}
return {
width: brushDimensions.width - brushPadding.left - brushPadding.right,
height: brushDimensions.height - brushPadding.top - brushPadding.bottom,
x: brushPadding.left,
y: brushPadding.top
};
};
var manyComponentsThrowErrorsIfOffsetIsUndefined = {
top: 0,
bottom: 0,
left: 0,
right: 0,
width: 0,
height: 0,
brushBottom: 0
};
/**
* For internal use only. If you want this information, `import { useOffset } from 'recharts'` instead.
*
* Returns the offset of the chart in pixels.
*
* @returns {ChartOffsetInternal} The offset of the chart in pixels, or a default value if not in a chart context.
*/
export var useOffsetInternal = () => {
var _useAppSelector2;
return (_useAppSelector2 = useAppSelector(selectChartOffsetInternal)) !== null && _useAppSelector2 !== void 0 ? _useAppSelector2 : manyComponentsThrowErrorsIfOffsetIsUndefined;
};
/**
* Returns the width of the chart in pixels.
*
* If you are using chart with hardcoded `width` prop, then the width returned will be the same
* as the `width` prop on the main chart element.
*
* If you are using a chart with a `ResponsiveContainer`, the width will be the size of the chart
* as the ResponsiveContainer has decided it would be.
*
* If the chart has any axes or legend, the `width` will be the size of the chart
* including the axes and legend. Meaning: adding axes and legend will not change the width.
*
* The dimensions do not scale, meaning as user zoom in and out, the width number will not change
* as the chart gets visually larger or smaller.
*
* Returns `undefined` if used outside a chart context.
*
* @returns {number | undefined} The width of the chart in pixels, or `undefined` if not in a chart context.
*/
export var useChartWidth = () => {
return useAppSelector(selectChartWidth);
};
/**
* Returns the height of the chart in pixels.
*
* If you are using chart with hardcoded `height` props, then the height returned will be the same
* as the `height` prop on the main chart element.
*
* If you are using a chart with a `ResponsiveContainer`, the height will be the size of the chart
* as the ResponsiveContainer has decided it would be.
*
* If the chart has any axes or legend, the `height` will be the size of the chart
* including the axes and legend. Meaning: adding axes and legend will not change the height.
*
* The dimensions do not scale, meaning as user zoom in and out, the height number will not change
* as the chart gets visually larger or smaller.
*
* Returns `undefined` if used outside a chart context.
*
* @returns {number | undefined} The height of the chart in pixels, or `undefined` if not in a chart context.
*/
export var useChartHeight = () => {
return useAppSelector(selectChartHeight);
};
/**
* Margin is the empty space around the chart. Excludes axes and legend and brushes and the like.
* This is declared by the user in the chart props.
* If you are interested in the space occupied by axes, legend, or brushes,
* use {@link useOffset} instead, which also includes calculated widths and heights of axes and legends.
*
* Returns `undefined` if used outside a chart context.
*
* @returns {Margin | undefined} The margin of the chart in pixels, or `undefined` if not in a chart context.
*/
export var useMargin = () => {
return useAppSelector(state => state.layout.margin);
};
export var selectChartLayout = state => state.layout.layoutType;
/**
* Returns the chart layout as configured by the chart.
*
* Cartesian charts use `horizontal` or `vertical`.
* Polar charts use `centric` or `radial`.
*
* Returns `undefined` if used outside a chart context.
*
* @deprecated this hook mixes cartesian and polar layouts together; prefer to use {@link useCartesianChartLayout} and {@link usePolarChartLayout} instead, which give you better type safety.
*
* @returns {LayoutType | undefined} The chart layout, or `undefined` if not in a chart context.
*
* @since 3.9
*/
export var useChartLayout = () => useAppSelector(selectChartLayout);
/**
* Returns the chart layout only for Cartesian charts.
*
* Returns `horizontal` or `vertical` for Cartesian charts.
* Returns `undefined` for non-Cartesian charts or outside chart context.
*
* @since 3.9
*
* @returns {CartesianLayout | undefined} The Cartesian chart layout, or `undefined`.
*/
export var useCartesianChartLayout = () => {
var layout = useChartLayout();
if (layout === 'horizontal' || layout === 'vertical') {
return layout;
}
return undefined;
};
export var selectPolarChartLayout = state => {
var layout = state.layout.layoutType;
if (layout === 'centric' || layout === 'radial') {
return layout;
}
return undefined;
};
/**
* Returns the chart layout only for Polar charts.
*
* Returns `centric` or `radial` for Polar charts.
* Returns `undefined` for non-Polar charts or outside chart context.
*
* @returns {PolarLayout | undefined} The Polar chart layout, or `undefined`.
*
* @since 3.9
*/
export var usePolarChartLayout = () => {
return useAppSelector(selectPolarChartLayout);
};
/**
* Returns true if the component is rendered inside a chart context.
* Some components may be used both inside and outside of charts,
* and this hook allows them to determine if they are in a chart context or not.
*
* Other selectors may return undefined when used outside a chart context,
* or undefined when inside a chart, but without relevant data.
* This hook provides a more explicit way to check for chart context.
*
* @returns {boolean} True if in chart context, false otherwise.
*/
export var useIsInChartContext = () => {
/*
* All charts provide a layout type in the chart context.
* If we have a layout type, we are in a chart context.
*/
var layout = useChartLayout();
return layout !== undefined;
};
export var ReportChartSize = props => {
var dispatch = useAppDispatch();
/*
* Skip dispatching properties in panorama chart for two reasons:
* 1. The root chart should be deciding on these properties, and
* 2. Brush reads these properties from redux store, and so they must remain stable
* to avoid circular dependency and infinite re-rendering.
*/
var isPanorama = useIsPanorama();
var widthFromProps = props.width,
heightFromProps = props.height;
var responsiveContainerCalculations = useResponsiveContainerContext();
var width = widthFromProps;
var height = heightFromProps;
if (responsiveContainerCalculations) {
/*
* In case we receive width and height from ResponsiveContainer,
* we will always prefer those.
* Only in case ResponsiveContainer does not provide width or height,
* we will fall back to the explicitly provided width and height.
*
* This to me feels backwards - we should allow override by the more specific props on individual charts, right?
* But this is 3.x behaviour, so let's keep it for backwards compatibility.
*
* We can change this in 4.x if we want to.
*/
width = responsiveContainerCalculations.width > 0 ? responsiveContainerCalculations.width : widthFromProps;
height = responsiveContainerCalculations.height > 0 ? responsiveContainerCalculations.height : heightFromProps;
}
useEffect(() => {
if (!isPanorama && isPositiveNumber(width) && isPositiveNumber(height)) {
dispatch(setChartSize({
width,
height
}));
}
}, [dispatch, isPanorama, width, height]);
return null;
};
export var ReportChartMargin = _ref => {
var margin = _ref.margin;
var dispatch = useAppDispatch();
useEffect(() => {
dispatch(setMargin(margin));
}, [dispatch, margin]);
return null;
};

View file

@ -0,0 +1,10 @@
import { useAppSelector } from '../state/hooks';
import { selectLegendPayload } from '../state/selectors/legendSelectors';
/**
* Use this hook in Legend, or anywhere else where you want to read the current Legend items.
* @return all Legend items ready to be rendered
*/
export function useLegendPayload() {
return useAppSelector(selectLegendPayload);
}

View file

@ -0,0 +1,3 @@
import { createContext, useContext } from 'react';
export var LegendPortalContext = /*#__PURE__*/createContext(null);
export var useLegendPortal = () => useContext(LegendPortalContext);

View file

@ -0,0 +1,39 @@
import { useAppDispatch } from '../state/hooks';
import { mouseLeaveItem, setActiveClickItemIndex, setActiveMouseOverItemIndex } from '../state/tooltipSlice';
/**
* Some graphical items choose to provide more information to the tooltip
* and some do not.
*/
export var useMouseEnterItemDispatch = (onMouseEnterFromProps, dataKey, graphicalItemId) => {
var dispatch = useAppDispatch();
return (data, index) => event => {
onMouseEnterFromProps === null || onMouseEnterFromProps === void 0 || onMouseEnterFromProps(data, index, event);
dispatch(setActiveMouseOverItemIndex({
activeIndex: String(index),
activeDataKey: dataKey,
activeCoordinate: data.tooltipPosition,
activeGraphicalItemId: graphicalItemId
}));
};
};
export var useMouseLeaveItemDispatch = onMouseLeaveFromProps => {
var dispatch = useAppDispatch();
return (data, index) => event => {
onMouseLeaveFromProps === null || onMouseLeaveFromProps === void 0 || onMouseLeaveFromProps(data, index, event);
dispatch(mouseLeaveItem());
};
};
export var useMouseClickItemDispatch = (onMouseClickFromProps, dataKey, graphicalItemId) => {
var dispatch = useAppDispatch();
return (data, index) => event => {
onMouseClickFromProps === null || onMouseClickFromProps === void 0 || onMouseClickFromProps(data, index, event);
dispatch(setActiveClickItemIndex({
activeIndex: String(index),
activeDataKey: dataKey,
activeCoordinate: data.tooltipPosition,
activeGraphicalItemId: graphicalItemId
}));
};
};

View file

@ -0,0 +1,3 @@
import { createContext, useContext } from 'react';
export var TooltipPortalContext = /*#__PURE__*/createContext(null);
export var useTooltipPortal = () => useContext(TooltipPortalContext);

View file

@ -0,0 +1,21 @@
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import { useAppSelector } from '../state/hooks';
import { getBandSizeOfAxis } from '../util/ChartUtils';
import { selectTooltipAxis } from '../state/selectors/axisSelectors';
import { selectTooltipAxisScale, selectTooltipAxisTicks } from '../state/selectors/tooltipSelectors';
export var useTooltipAxis = () => useAppSelector(selectTooltipAxis);
export var useTooltipAxisBandSize = () => {
var tooltipAxis = useTooltipAxis();
var tooltipTicks = useAppSelector(selectTooltipAxisTicks);
var tooltipAxisScale = useAppSelector(selectTooltipAxisScale);
if (!tooltipAxis || !tooltipAxisScale) {
return getBandSizeOfAxis(undefined, tooltipTicks);
}
return getBandSizeOfAxis(_objectSpread(_objectSpread({}, tooltipAxis), {}, {
scale: tooltipAxisScale
}), tooltipTicks);
};