@carto/ps-react-ui 4.4.1 → 4.4.3
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/components.js.map +1 -1
- package/dist/download-config-Dqu78h2a.js +57 -0
- package/dist/download-config-Dqu78h2a.js.map +1 -0
- package/dist/error-CEkRPccv.js.map +1 -1
- package/dist/exports-Cr43OCul.js.map +1 -1
- package/dist/formatter-B9Bxn1k7.js +6 -0
- package/dist/formatter-B9Bxn1k7.js.map +1 -0
- package/dist/lasso-tool-BYbxrJ-7.js.map +1 -1
- package/dist/note-t51drNe0.js.map +1 -1
- package/dist/options-D9wflre6.js.map +1 -1
- package/dist/row-DTCV0Ocm.js.map +1 -1
- package/dist/series-CYNOu2Ju.js.map +1 -1
- package/dist/smart-tooltip-D4vwQpFf.js.map +1 -1
- package/dist/styles-Y8q7Jff3.js +118 -0
- package/dist/styles-Y8q7Jff3.js.map +1 -0
- package/dist/tooltip-BDnrRKrp.js.map +1 -1
- package/dist/types/components/basemaps/basemaps.d.ts +20 -0
- package/dist/types/components/geolocation-controls/geolocation-controls.d.ts +11 -0
- package/dist/types/components/lasso-tool/lasso-tool-inline.d.ts +17 -0
- package/dist/types/components/lasso-tool/lasso-tool.d.ts +21 -0
- package/dist/types/components/list-data/list-data.d.ts +16 -0
- package/dist/types/components/measurement-tools/measurement-tools.d.ts +20 -0
- package/dist/types/components/smart-tooltip/smart-tooltip.d.ts +17 -0
- package/dist/types/components/tooltip/tooltip.d.ts +13 -0
- package/dist/types/components/zoom-controls/zoom-controls.d.ts +16 -0
- package/dist/types/hooks/use-widget-ref.d.ts +4 -4
- package/dist/types/widgets/actions/brush-toggle/types.d.ts +8 -2
- package/dist/types/widgets/actions/download/download.d.ts +11 -0
- package/dist/types/widgets/actions/download/exports.d.ts +15 -0
- package/dist/types/widgets/actions/fullscreen/fullscreen.d.ts +13 -0
- package/dist/types/widgets/actions/index.d.ts +1 -1
- package/dist/types/widgets/actions/relative-data/relative-data.d.ts +1 -0
- package/dist/types/widgets/bar/config.d.ts +8 -4
- package/dist/types/widgets/category/category-ui.d.ts +3 -0
- package/dist/types/widgets/category/components/category-bar.d.ts +3 -0
- package/dist/types/widgets/category/components/category-legend.d.ts +3 -0
- package/dist/types/widgets/category/components/category-row-multi.d.ts +5 -1
- package/dist/types/widgets/category/components/category-row-other.d.ts +3 -0
- package/dist/types/widgets/category/components/category-row-single.d.ts +5 -1
- package/dist/types/widgets/category/config.d.ts +11 -0
- package/dist/types/widgets/category/types.d.ts +1 -0
- package/dist/types/widgets/echart/echart-ui.d.ts +7 -0
- package/dist/types/widgets/echart/echart.d.ts +6 -0
- package/dist/types/widgets/echart/options.d.ts +7 -0
- package/dist/types/widgets/echart/types.d.ts +3 -0
- package/dist/types/widgets/echart/utils.d.ts +41 -0
- package/dist/types/widgets/error/error.d.ts +10 -0
- package/dist/types/widgets/formula/components/item.d.ts +3 -0
- package/dist/types/widgets/formula/components/prefix.d.ts +3 -0
- package/dist/types/widgets/formula/components/row.d.ts +3 -0
- package/dist/types/widgets/formula/components/series.d.ts +3 -0
- package/dist/types/widgets/formula/components/suffix.d.ts +3 -0
- package/dist/types/widgets/formula/components/value.d.ts +3 -0
- package/dist/types/widgets/formula/config.d.ts +11 -0
- package/dist/types/widgets/formula/formula-ui.d.ts +3 -0
- package/dist/types/widgets/histogram/config.d.ts +18 -2
- package/dist/types/widgets/histogram/index.d.ts +2 -1
- package/dist/types/widgets/histogram/types.d.ts +6 -3
- package/dist/types/widgets/loader/loader.d.ts +22 -0
- package/dist/types/widgets/loader/utils.d.ts +26 -3
- package/dist/types/widgets/markdown/config.d.ts +10 -0
- package/dist/types/widgets/markdown/markdown-ui.d.ts +7 -0
- package/dist/types/widgets/markdown/markdown.d.ts +3 -0
- package/dist/types/widgets/note/note.d.ts +10 -0
- package/dist/types/widgets/pie/config.d.ts +8 -4
- package/dist/types/widgets/range/components/range-item.d.ts +3 -0
- package/dist/types/widgets/range/config.d.ts +5 -0
- package/dist/types/widgets/range/range-ui.d.ts +3 -0
- package/dist/types/widgets/scatterplot/config.d.ts +7 -3
- package/dist/types/widgets/selection-summary/selection-summary.d.ts +11 -0
- package/dist/types/widgets/skeleton-loader/skeleton-loader.d.ts +10 -0
- package/dist/types/widgets/spread/components/max-value.d.ts +3 -0
- package/dist/types/widgets/spread/components/min-value.d.ts +3 -0
- package/dist/types/widgets/spread/components/separator.d.ts +3 -0
- package/dist/types/widgets/spread/config.d.ts +11 -0
- package/dist/types/widgets/spread/spread-ui.d.ts +3 -0
- package/dist/types/widgets/stores/types.d.ts +2 -0
- package/dist/types/widgets/subheader/subheader.d.ts +11 -0
- package/dist/types/widgets/table/config.d.ts +8 -3
- package/dist/types/widgets/table/hooks/use-pagination.d.ts +11 -3
- package/dist/types/widgets/table/hooks/use-selection.d.ts +11 -2
- package/dist/types/widgets/table/hooks/use-sort.d.ts +11 -3
- package/dist/types/widgets/timeseries/config.d.ts +8 -4
- package/dist/types/widgets/utils/chart-config/download-config.d.ts +3 -0
- package/dist/types/widgets/{_shared → utils}/chart-config/index.d.ts +2 -0
- package/dist/types/widgets/{_shared → utils}/chart-config/option-builders.d.ts +14 -9
- package/dist/types/widgets/utils/formatter.d.ts +2 -0
- package/dist/types/widgets/utils/index.d.ts +7 -0
- package/dist/types/widgets/wrapper/components/actions.d.ts +3 -0
- package/dist/types/widgets/wrapper/components/options.d.ts +3 -0
- package/dist/types/widgets/wrapper/components/title.d.ts +3 -0
- package/dist/types/widgets/wrapper/wrapper-ui.d.ts +14 -0
- package/dist/types/widgets/wrapper/wrapper.d.ts +14 -0
- package/dist/use-widget-ref-wtFLDFCD.js.map +1 -1
- package/dist/utils-BOhInag6.js.map +1 -1
- package/dist/widgets/actions.js +720 -681
- package/dist/widgets/actions.js.map +1 -1
- package/dist/widgets/bar.js +78 -92
- package/dist/widgets/bar.js.map +1 -1
- package/dist/widgets/category.js +206 -197
- package/dist/widgets/category.js.map +1 -1
- package/dist/widgets/echart.js.map +1 -1
- package/dist/widgets/formula.js +54 -54
- package/dist/widgets/formula.js.map +1 -1
- package/dist/widgets/histogram.js +106 -86
- package/dist/widgets/histogram.js.map +1 -1
- package/dist/widgets/loader.js.map +1 -1
- package/dist/widgets/markdown.js.map +1 -1
- package/dist/widgets/pie.js +147 -112
- package/dist/widgets/pie.js.map +1 -1
- package/dist/widgets/range.js +23 -22
- package/dist/widgets/range.js.map +1 -1
- package/dist/widgets/scatterplot.js +46 -60
- package/dist/widgets/scatterplot.js.map +1 -1
- package/dist/widgets/selection-summary.js.map +1 -1
- package/dist/widgets/skeleton-loader.js.map +1 -1
- package/dist/widgets/spread.js +40 -41
- package/dist/widgets/spread.js.map +1 -1
- package/dist/widgets/subheader.js.map +1 -1
- package/dist/widgets/table.js.map +1 -1
- package/dist/widgets/timeseries.js +51 -65
- package/dist/widgets/timeseries.js.map +1 -1
- package/dist/widgets/toolbar-actions.js +101 -6693
- package/dist/widgets/toolbar-actions.js.map +1 -1
- package/dist/widgets/utils.js +33 -0
- package/dist/widgets/utils.js.map +1 -0
- package/dist/widgets/wrapper.js.map +1 -1
- package/package.json +9 -4
- package/src/components/basemaps/basemaps.tsx +20 -0
- package/src/components/geolocation-controls/geolocation-controls.tsx +11 -0
- package/src/components/lasso-tool/lasso-tool-inline.tsx +17 -0
- package/src/components/lasso-tool/lasso-tool.tsx +21 -0
- package/src/components/list-data/list-data.tsx +16 -0
- package/src/components/measurement-tools/measurement-tools.tsx +20 -0
- package/src/components/smart-tooltip/smart-tooltip.tsx +17 -0
- package/src/components/tooltip/tooltip.tsx +13 -0
- package/src/components/zoom-controls/zoom-controls.tsx +16 -0
- package/src/hooks/use-widget-ref.ts +4 -4
- package/src/widgets/README.md +13 -13
- package/src/widgets/actions/brush-toggle/brush-toggle.tsx +42 -47
- package/src/widgets/actions/brush-toggle/types.ts +8 -2
- package/src/widgets/actions/download/download.tsx +11 -0
- package/src/widgets/actions/download/exports.tsx +15 -0
- package/src/widgets/actions/fullscreen/fullscreen.tsx +13 -0
- package/src/widgets/actions/index.ts +1 -0
- package/src/widgets/actions/relative-data/relative-data.test.tsx +62 -1
- package/src/widgets/actions/relative-data/relative-data.tsx +62 -39
- package/src/widgets/bar/config.ts +34 -34
- package/src/widgets/bar/style.ts +1 -1
- package/src/widgets/category/category-ui.tsx +12 -2
- package/src/widgets/category/components/category-bar.tsx +3 -0
- package/src/widgets/category/components/category-legend.tsx +3 -0
- package/src/widgets/category/components/category-row-multi.tsx +9 -2
- package/src/widgets/category/components/category-row-other.tsx +3 -0
- package/src/widgets/category/components/category-row-single.tsx +8 -1
- package/src/widgets/category/config.ts +11 -0
- package/src/widgets/category/types.ts +1 -0
- package/src/widgets/echart/echart-ui.tsx +7 -0
- package/src/widgets/echart/echart.tsx +6 -0
- package/src/widgets/echart/options.ts +7 -0
- package/src/widgets/echart/types.ts +3 -0
- package/src/widgets/echart/utils.ts +41 -0
- package/src/widgets/error/error.tsx +10 -0
- package/src/widgets/formula/components/item.tsx +3 -0
- package/src/widgets/formula/components/prefix.tsx +3 -0
- package/src/widgets/formula/components/row.tsx +3 -0
- package/src/widgets/formula/components/series.tsx +3 -0
- package/src/widgets/formula/components/suffix.tsx +3 -0
- package/src/widgets/formula/components/value.tsx +4 -2
- package/src/widgets/formula/config.ts +11 -0
- package/src/widgets/formula/formula-ui.tsx +3 -0
- package/src/widgets/histogram/config.ts +93 -21
- package/src/widgets/histogram/index.ts +6 -1
- package/src/widgets/histogram/style.ts +1 -1
- package/src/widgets/histogram/types.ts +9 -3
- package/src/widgets/loader/loader.tsx +22 -0
- package/src/widgets/loader/utils.ts +26 -3
- package/src/widgets/markdown/config.ts +10 -0
- package/src/widgets/markdown/markdown-ui.tsx +7 -0
- package/src/widgets/markdown/markdown.tsx +3 -0
- package/src/widgets/note/note.tsx +10 -0
- package/src/widgets/pie/config.ts +100 -33
- package/src/widgets/pie/style.ts +1 -1
- package/src/widgets/range/components/range-item.tsx +5 -2
- package/src/widgets/range/config.ts +5 -0
- package/src/widgets/range/range-ui.tsx +3 -0
- package/src/widgets/scatterplot/config.ts +19 -23
- package/src/widgets/scatterplot/style.ts +1 -1
- package/src/widgets/selection-summary/selection-summary.tsx +11 -0
- package/src/widgets/skeleton-loader/skeleton-loader.tsx +10 -0
- package/src/widgets/spread/components/max-value.tsx +4 -2
- package/src/widgets/spread/components/min-value.tsx +4 -2
- package/src/widgets/spread/components/separator.tsx +3 -0
- package/src/widgets/spread/config.ts +11 -0
- package/src/widgets/spread/spread-ui.tsx +3 -0
- package/src/widgets/stores/types.ts +2 -0
- package/src/widgets/subheader/subheader.tsx +11 -0
- package/src/widgets/table/config.ts +8 -3
- package/src/widgets/table/hooks/use-pagination.ts +11 -3
- package/src/widgets/table/hooks/use-selection.ts +11 -2
- package/src/widgets/table/hooks/use-sort.ts +11 -3
- package/src/widgets/timeseries/config.ts +32 -33
- package/src/widgets/timeseries/style.ts +1 -1
- package/src/widgets/utils/chart-config/download-config.ts +22 -0
- package/src/widgets/{_shared → utils}/chart-config/index.ts +4 -0
- package/src/widgets/{_shared → utils}/chart-config/option-builders.ts +23 -13
- package/src/widgets/utils/formatter.ts +2 -0
- package/src/widgets/utils/index.ts +26 -0
- package/src/widgets/wrapper/components/actions.tsx +3 -0
- package/src/widgets/wrapper/components/options.tsx +3 -0
- package/src/widgets/wrapper/components/title.tsx +3 -0
- package/src/widgets/wrapper/wrapper-ui.tsx +14 -0
- package/src/widgets/wrapper/wrapper.tsx +14 -0
- package/dist/styles-CAroD5Rc.js +0 -123
- package/dist/styles-CAroD5Rc.js.map +0 -1
- /package/dist/types/widgets/{_shared → utils}/chart-config/config-factory.d.ts +0 -0
- /package/dist/types/widgets/{_shared → utils}/chart-config/csv-modifiers.d.ts +0 -0
- /package/dist/types/widgets/{_shared → utils}/chart-config/option-builders.test.d.ts +0 -0
- /package/dist/types/widgets/{_shared → utils}/skeleton/index.d.ts +0 -0
- /package/dist/types/widgets/{_shared → utils}/skeleton/styles.d.ts +0 -0
- /package/src/widgets/{_shared → utils}/chart-config/config-factory.ts +0 -0
- /package/src/widgets/{_shared → utils}/chart-config/csv-modifiers.ts +0 -0
- /package/src/widgets/{_shared → utils}/chart-config/option-builders.test.ts +0 -0
- /package/src/widgets/{_shared → utils}/skeleton/index.ts +0 -0
- /package/src/widgets/{_shared → utils}/skeleton/styles.ts +0 -0
|
@@ -7,6 +7,9 @@ export interface CategoryRowOtherProps {
|
|
|
7
7
|
otherCountLabel?: string
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Renders an "Other" summary row indicating how many additional categories are hidden beyond `maxItems`.
|
|
12
|
+
*/
|
|
10
13
|
export function CategoryRowOther({
|
|
11
14
|
hiddenCount,
|
|
12
15
|
otherLabel = 'Other',
|
|
@@ -9,16 +9,21 @@ export interface CategoryRowSingleProps {
|
|
|
9
9
|
maxValue: number
|
|
10
10
|
color: string
|
|
11
11
|
formatter: NonNullable<CategoryWidgetConfig['formatter']>
|
|
12
|
+
labelFormatter?: CategoryWidgetConfig['labelFormatter']
|
|
12
13
|
onClick?: CategoryWidgetConfig['onRowClick']
|
|
13
14
|
selected?: boolean
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
/**
|
|
18
|
+
* Renders a single-series category row with a label, formatted value, and proportional bar.
|
|
19
|
+
*/
|
|
16
20
|
export function CategoryRowSingle({
|
|
17
21
|
name,
|
|
18
22
|
value,
|
|
19
23
|
maxValue,
|
|
20
24
|
color,
|
|
21
25
|
formatter,
|
|
26
|
+
labelFormatter,
|
|
22
27
|
onClick,
|
|
23
28
|
selected = true,
|
|
24
29
|
}: CategoryRowSingleProps) {
|
|
@@ -33,7 +38,9 @@ export function CategoryRowSingle({
|
|
|
33
38
|
return (
|
|
34
39
|
<Box sx={rowStyle} onClick={handleClick}>
|
|
35
40
|
<Box sx={styles.rowHeader}>
|
|
36
|
-
<Typography sx={styles.rowLabel}>
|
|
41
|
+
<Typography sx={styles.rowLabel}>
|
|
42
|
+
{labelFormatter ? labelFormatter(name) : name}
|
|
43
|
+
</Typography>
|
|
37
44
|
<Typography sx={styles.rowValue}>{formatter(value)}</Typography>
|
|
38
45
|
</Box>
|
|
39
46
|
<CategoryBar
|
|
@@ -10,6 +10,12 @@ interface CategoryDownloadConfigProps extends ConfigProps {
|
|
|
10
10
|
series?: CategorySeriesConfig[]
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Creates download configuration for category widgets, supporting PNG (screenshot) and CSV (data) exports. CSV output groups values by category across multiple series.
|
|
15
|
+
*
|
|
16
|
+
* @param props - Configuration with `refUI` reference and optional `series` for CSV column headers.
|
|
17
|
+
* @returns Array of download items for use with the Download action.
|
|
18
|
+
*/
|
|
13
19
|
export function categoryDownloadConfig({
|
|
14
20
|
refUI,
|
|
15
21
|
series,
|
|
@@ -66,6 +72,11 @@ export function categoryDownloadConfig({
|
|
|
66
72
|
]
|
|
67
73
|
}
|
|
68
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Returns the default configuration for category list widgets, including empty series and a default `maxItems` of 10.
|
|
77
|
+
*
|
|
78
|
+
* @returns Default category widget config.
|
|
79
|
+
*/
|
|
69
80
|
export function categoryConfig(): CategoryWidgetConfig {
|
|
70
81
|
return {
|
|
71
82
|
series: [],
|
|
@@ -29,6 +29,7 @@ export type CategoryWidgetState = BaseWidgetState<
|
|
|
29
29
|
|
|
30
30
|
export interface CategoryWidgetConfig {
|
|
31
31
|
formatter?: (value: number) => string
|
|
32
|
+
labelFormatter?: (value: string | number) => string | number
|
|
32
33
|
series?: CategorySeriesConfig[]
|
|
33
34
|
maxItems?: number
|
|
34
35
|
labels?: CategoryLabels
|
|
@@ -3,6 +3,13 @@ import * as echarts from 'echarts'
|
|
|
3
3
|
import type { EchartUIProps } from './types'
|
|
4
4
|
import { useWidgetRef } from '../../hooks'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Presentational component that initializes and manages an Apache ECharts instance.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* Handles chart lifecycle (init, dispose), option updates, resize observation, and event listener management.
|
|
11
|
+
* Uses SVG renderer with a default height of 304px.
|
|
12
|
+
*/
|
|
6
13
|
export function EchartUI(props: EchartUIProps) {
|
|
7
14
|
const { id, ref, init, option, className, style, onEvents } = props
|
|
8
15
|
|
|
@@ -9,6 +9,12 @@ import { useWidgetStore } from '../stores/widget-store'
|
|
|
9
9
|
import { useShallow } from 'zustand/shallow'
|
|
10
10
|
import { useMemo } from 'react'
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Stateful EChart widget component that reads data and options from the widget store and renders an ECharts chart.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Transforms widget data into ECharts dataset format and delegates rendering to {@link EchartUI}.
|
|
17
|
+
*/
|
|
12
18
|
export function Echart(props: EchartProps) {
|
|
13
19
|
const id = useWidgetStore(
|
|
14
20
|
useShallow((state) => state.getWidget<EchartWidgetState>(props.id)?.id),
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { EchartOptionsProps, EchartWidgetOptionProps } from './types'
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Returns the shared base ECharts options used across all EChart-based widgets (bar, pie, histogram, etc.).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Configures grid spacing, tooltip styling, legend, axis pointer, and the default color palette
|
|
8
|
+
* derived from the MUI theme.
|
|
9
|
+
*/
|
|
3
10
|
export function getCommonOptions({
|
|
4
11
|
theme,
|
|
5
12
|
}: EchartWidgetOptionProps<unknown>): EchartOptionsProps {
|
|
@@ -33,10 +33,13 @@ export interface EchartWidgetOptionProps<D> {
|
|
|
33
33
|
data?: D
|
|
34
34
|
theme: typeof CartoTheme
|
|
35
35
|
formatter?: (value: number) => string
|
|
36
|
+
labelFormatter?: (value: string | number) => string | number
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export interface EchartWidgetProps {
|
|
39
40
|
type: string
|
|
40
41
|
option: EchartUIProps['option']
|
|
41
42
|
onEvents?: EchartUIProps['onEvents']
|
|
43
|
+
formatter?: (value: number) => string
|
|
44
|
+
labelFormatter?: (value: string | number) => string | number
|
|
42
45
|
}
|
|
@@ -3,6 +3,27 @@ import type { EchartOptionsProps } from './types'
|
|
|
3
3
|
import type { Theme } from '@mui/material'
|
|
4
4
|
import { DEFAULT_STACK_GROUP } from './const'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Deep-merges two ECharts option objects with smart handling for `color`, `axisLabel`, and `series` keys.
|
|
8
|
+
*
|
|
9
|
+
* @param optionA - Base ECharts options.
|
|
10
|
+
* @param optionB - Override ECharts options to merge on top.
|
|
11
|
+
* @param customMergeFn - Optional function returning a custom merge strategy per key.
|
|
12
|
+
* @returns The merged ECharts options object.
|
|
13
|
+
*
|
|
14
|
+
* @remarks
|
|
15
|
+
* - `color` arrays are replaced entirely (not concatenated).
|
|
16
|
+
* - `axisLabel` formatters are composed so the base formatter can suppress values by returning `''`.
|
|
17
|
+
* - `series` arrays are merged element-by-element rather than concatenated.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const option = mergeEchartWidgetConfig(props.option, {
|
|
22
|
+
* series: [{ barWidth: '60%', itemStyle: { borderRadius: [4, 4, 0, 0] } }],
|
|
23
|
+
* tooltip: { trigger: 'axis' },
|
|
24
|
+
* })
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
6
27
|
export function mergeEchartWidgetConfig<T extends EchartOptionsProps>(
|
|
7
28
|
optionA: T | undefined,
|
|
8
29
|
optionB: T | undefined,
|
|
@@ -53,6 +74,14 @@ export function mergeEchartWidgetConfig<T extends EchartOptionsProps>(
|
|
|
53
74
|
}) as T
|
|
54
75
|
}
|
|
55
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Generates ECharts `dataZoom` configuration for interactive zoom and pan on chart axes.
|
|
79
|
+
*
|
|
80
|
+
* @param range - Initial visible range as `{ start, end }` percentages (0-100). Defaults to full range.
|
|
81
|
+
* @param options - Zoom behavior options including axis sliders, inside zoom, and formatter.
|
|
82
|
+
* @param theme - Optional MUI theme for styled slider handles and backgrounds.
|
|
83
|
+
* @returns An object containing the `dataZoom` array configuration.
|
|
84
|
+
*/
|
|
56
85
|
export function getEChartZoomConfig(
|
|
57
86
|
{ start, end }: { start: number; end: number } = { start: 0, end: 100 },
|
|
58
87
|
{
|
|
@@ -179,6 +208,12 @@ function getEChartZoomSliderStyles(theme: Theme) {
|
|
|
179
208
|
} as const
|
|
180
209
|
}
|
|
181
210
|
|
|
211
|
+
/**
|
|
212
|
+
* Generates ECharts `brush` configuration for interactive data selection on charts.
|
|
213
|
+
*
|
|
214
|
+
* @param options - Brush options including type, mode, and target axis index.
|
|
215
|
+
* @returns An object containing the `brush` configuration.
|
|
216
|
+
*/
|
|
182
217
|
export function getEChartBrushConfig(
|
|
183
218
|
{ brushType = 'lineX', brushMode = 'single', xAxisIndex = 0 } = {} as {
|
|
184
219
|
brushType?: string
|
|
@@ -198,6 +233,12 @@ export function getEChartBrushConfig(
|
|
|
198
233
|
}
|
|
199
234
|
}
|
|
200
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Returns an ECharts `stack` configuration to group series into a stacked layout.
|
|
238
|
+
*
|
|
239
|
+
* @param stackGroup - The stack group identifier. Defaults to the library's default group.
|
|
240
|
+
* @returns An object with the `stack` property set to the group name.
|
|
241
|
+
*/
|
|
201
242
|
export function getEChartStackConfig(stackGroup: string = DEFAULT_STACK_GROUP) {
|
|
202
243
|
return { stack: stackGroup }
|
|
203
244
|
}
|
|
@@ -3,6 +3,16 @@ import { useWidgetStore } from '../stores/widget-store'
|
|
|
3
3
|
import { useShallow } from 'zustand/shallow'
|
|
4
4
|
import type { WidgetErrorProps } from './types'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Displays an error alert when a widget encounters an error during data loading. Reads error state from the widget store and hides errors during loading/fetching to prevent flashing.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* <WidgetError id="my-widget">
|
|
12
|
+
* <WidgetContent />
|
|
13
|
+
* </WidgetError>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
6
16
|
export function WidgetError({
|
|
7
17
|
id,
|
|
8
18
|
children,
|
|
@@ -2,6 +2,9 @@ import { Typography } from '@mui/material'
|
|
|
2
2
|
import type { ItemProps } from '../types'
|
|
3
3
|
import { styles } from '../style'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Base typography wrapper used by formula sub-components (Value, Prefix, Suffix) to render styled text.
|
|
7
|
+
*/
|
|
5
8
|
export function Item(props: ItemProps) {
|
|
6
9
|
return (
|
|
7
10
|
<Typography
|
|
@@ -3,6 +3,9 @@ import { useWidgetStore } from '../../stores/widget-store'
|
|
|
3
3
|
import { Item } from './item'
|
|
4
4
|
import { useShallow } from 'zustand/shallow'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Renders the prefix content (e.g., currency symbol) before a formula value, if defined in the data item.
|
|
8
|
+
*/
|
|
6
9
|
export function Prefix({ id, index = 0, ...props }: ValueProps) {
|
|
7
10
|
const prefix = useWidgetStore(
|
|
8
11
|
useShallow(
|
|
@@ -4,6 +4,9 @@ import type { FormulaWidgetState, RowProps } from '../types'
|
|
|
4
4
|
import { useWidgetStore } from '../../stores/widget-store'
|
|
5
5
|
import { useShallow } from 'zustand/shallow'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Iterates over the widget's data items and renders a row for each one using render props.
|
|
9
|
+
*/
|
|
7
10
|
export function Row(props: RowProps) {
|
|
8
11
|
const data = useWidgetStore(
|
|
9
12
|
useShallow((state) => state.getWidget<FormulaWidgetState>(props.id)?.data),
|
|
@@ -3,6 +3,9 @@ import type { FormulaWidgetState, ValueProps } from '../types'
|
|
|
3
3
|
import { useWidgetStore } from '../../stores/widget-store'
|
|
4
4
|
import { useShallow } from 'zustand/shallow'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Renders a colored avatar badge showing the first letter of the series name for multi-value formula widgets.
|
|
8
|
+
*/
|
|
6
9
|
export function Series({ id, index = 0 }: Pick<ValueProps, 'id' | 'index'>) {
|
|
7
10
|
const serie = useWidgetStore(
|
|
8
11
|
useShallow(
|
|
@@ -4,6 +4,9 @@ import { Item } from './item'
|
|
|
4
4
|
import type { Theme } from '@mui/material'
|
|
5
5
|
import { useShallow } from 'zustand/shallow'
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Renders the suffix content (e.g., unit label) after a formula value, if defined in the data item.
|
|
9
|
+
*/
|
|
7
10
|
export function Suffix({ id, index = 0, ...props }: ValueProps) {
|
|
8
11
|
const suffix = useWidgetStore(
|
|
9
12
|
useShallow(
|
|
@@ -2,9 +2,11 @@ import { type FormulaWidgetState, type ValueProps } from '../types'
|
|
|
2
2
|
import { useWidgetStore } from '../../stores/widget-store'
|
|
3
3
|
import { Item } from './item'
|
|
4
4
|
import { useShallow } from 'zustand/shallow'
|
|
5
|
+
import { defaultFormatter } from '../../utils/formatter'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Displays the formatted numeric value for a formula widget data item, applying the widget's formatter and color.
|
|
9
|
+
*/
|
|
8
10
|
export function Value({ id, index = 0, ...props }: ValueProps) {
|
|
9
11
|
const value = useWidgetStore(
|
|
10
12
|
useShallow(
|
|
@@ -2,6 +2,12 @@ import { downloadToCSV, downloadToPNG } from '../actions'
|
|
|
2
2
|
import type { ConfigProps } from '../loader/types'
|
|
3
3
|
import type { FormulaDownloadConfig, FormulaWidgetConfig } from './types'
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Creates download configuration for formula widgets, supporting PNG (screenshot) and CSV (data) exports.
|
|
7
|
+
*
|
|
8
|
+
* @param props - Configuration with `refUI` reference for PNG export.
|
|
9
|
+
* @returns Array of download items for use with the Download action.
|
|
10
|
+
*/
|
|
5
11
|
export function formulaDownloadConfig({
|
|
6
12
|
refUI,
|
|
7
13
|
}: ConfigProps): FormulaDownloadConfig {
|
|
@@ -20,6 +26,11 @@ export function formulaDownloadConfig({
|
|
|
20
26
|
]
|
|
21
27
|
}
|
|
22
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Returns the default configuration for formula (single or multiple numeric value) widgets.
|
|
31
|
+
*
|
|
32
|
+
* @returns Default formula widget config with empty series.
|
|
33
|
+
*/
|
|
23
34
|
export function formulaConfig(): FormulaWidgetConfig {
|
|
24
35
|
return {
|
|
25
36
|
series: [],
|
|
@@ -7,6 +7,9 @@ import { Series } from './components/series'
|
|
|
7
7
|
import { useWidgetRef } from '../../hooks'
|
|
8
8
|
import { Box } from '@mui/material'
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Renders a formula widget displaying one or more KPI values with optional prefixes, suffixes, and series indicators.
|
|
12
|
+
*/
|
|
10
13
|
export function FormulaUI(props: FormulaUIProps) {
|
|
11
14
|
const { ref } = useWidgetRef(props.id)
|
|
12
15
|
|
|
@@ -3,25 +3,55 @@ import {
|
|
|
3
3
|
mergeEchartWidgetConfig,
|
|
4
4
|
type EchartOptionsProps,
|
|
5
5
|
} from '../echart'
|
|
6
|
-
import type {
|
|
7
|
-
HistogramConfig,
|
|
8
|
-
HistogramWidgetConfig,
|
|
9
|
-
HistogramWidgetData,
|
|
10
|
-
} from './types'
|
|
6
|
+
import type { HistogramConfig, HistogramWidgetConfig } from './types'
|
|
11
7
|
import {
|
|
12
|
-
flattenObjectArrayToCSV,
|
|
13
8
|
buildLegendConfig,
|
|
14
9
|
buildGridConfig,
|
|
15
10
|
createTooltipPositioner,
|
|
16
11
|
createTooltipFormatter,
|
|
17
12
|
niceNum,
|
|
18
|
-
} from '../
|
|
13
|
+
} from '../utils/chart-config'
|
|
19
14
|
import { downloadToCSV, downloadToPNG, type DownloadItem } from '../actions'
|
|
20
15
|
import type { ConfigProps } from '../loader/types'
|
|
21
16
|
|
|
17
|
+
export interface HistogramDownloadConfigProps extends ConfigProps {
|
|
18
|
+
ticks: number[]
|
|
19
|
+
labelFormatter?: (value: string | number) => string | number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function histogramDataToCSV(
|
|
23
|
+
data: number[][],
|
|
24
|
+
ticks: number[],
|
|
25
|
+
labelFormatter?: (value: string | number) => string | number,
|
|
26
|
+
): string[][] {
|
|
27
|
+
if (!data?.length || data[0]?.length === 0) return []
|
|
28
|
+
|
|
29
|
+
const dataLength = data[0]?.length ?? 0
|
|
30
|
+
const labels = createAxisLabels(dataLength, ticks, labelFormatter)
|
|
31
|
+
const seriesCount = data.length
|
|
32
|
+
const isMulti = seriesCount > 1
|
|
33
|
+
|
|
34
|
+
const headers = isMulti
|
|
35
|
+
? [
|
|
36
|
+
'Bin',
|
|
37
|
+
...Array.from({ length: seriesCount }, (_, i) => `Series ${i + 1}`),
|
|
38
|
+
]
|
|
39
|
+
: ['Bin', 'Value']
|
|
40
|
+
|
|
41
|
+
return [
|
|
42
|
+
headers,
|
|
43
|
+
...labels.map((label, i) => [
|
|
44
|
+
label,
|
|
45
|
+
...data.map((series) => String(series[i] ?? 0)),
|
|
46
|
+
]),
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
|
|
22
50
|
export function histogramDownloadConfig({
|
|
23
51
|
refUI,
|
|
24
|
-
|
|
52
|
+
ticks,
|
|
53
|
+
labelFormatter,
|
|
54
|
+
}: HistogramDownloadConfigProps): DownloadItem<number[][]>[] {
|
|
25
55
|
return [
|
|
26
56
|
{
|
|
27
57
|
...downloadToPNG,
|
|
@@ -29,34 +59,78 @@ export function histogramDownloadConfig({
|
|
|
29
59
|
},
|
|
30
60
|
{
|
|
31
61
|
...downloadToCSV,
|
|
32
|
-
modifier: async (data) =>
|
|
33
|
-
|
|
34
|
-
return downloadToCSV.modifier(rows)
|
|
35
|
-
},
|
|
62
|
+
modifier: async (data) =>
|
|
63
|
+
downloadToCSV.modifier(histogramDataToCSV(data, ticks, labelFormatter)),
|
|
36
64
|
},
|
|
37
65
|
]
|
|
38
66
|
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Creates formatted axis labels from tick boundaries.
|
|
70
|
+
*
|
|
71
|
+
* @param dataLength - Number of data points (determines number of labels).
|
|
72
|
+
* @param ticks - Bin boundaries. If `ticks.length === dataLength + 1`, all
|
|
73
|
+
* bins are ranges. If `ticks.length === dataLength`, the last bin is
|
|
74
|
+
* open-ended (`+`). A last tick of `Infinity` also produces `+`.
|
|
75
|
+
* @param labelFormatter - Optional formatter applied to each individual tick
|
|
76
|
+
* value when building the bin range label.
|
|
77
|
+
*/
|
|
78
|
+
function createAxisLabels(
|
|
79
|
+
dataLength: number,
|
|
80
|
+
ticks: number[],
|
|
81
|
+
labelFormatter?: (value: string | number) => string | number,
|
|
82
|
+
): string[] {
|
|
83
|
+
const fmt = (v: number) =>
|
|
84
|
+
labelFormatter ? String(labelFormatter(v)) : String(v)
|
|
85
|
+
|
|
86
|
+
return Array.from({ length: dataLength }, (_, i) => {
|
|
87
|
+
const low = ticks[i] ?? i
|
|
88
|
+
const high = ticks[i + 1]
|
|
89
|
+
return high !== undefined && isFinite(high)
|
|
90
|
+
? `${fmt(low)}-${fmt(high)}`
|
|
91
|
+
: `${fmt(low)}+`
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Generates ECharts configuration for distribution histogram widgets with
|
|
97
|
+
* adjacent bars (minimal gap) and axis formatting styled with the CARTO theme.
|
|
98
|
+
*
|
|
99
|
+
* Accepts raw `number[][]` data and `ticks` boundaries. The ticks and
|
|
100
|
+
* `labelFormatter` are used to create the x-axis category labels; the raw
|
|
101
|
+
* numeric data is embedded directly in each series.
|
|
102
|
+
*
|
|
103
|
+
* @param props - Histogram configuration including raw data, ticks, and theme.
|
|
104
|
+
* @returns Widget config with ECharts option object.
|
|
105
|
+
*/
|
|
39
106
|
export function histogramConfig(props: HistogramConfig): HistogramWidgetConfig {
|
|
40
107
|
return {
|
|
41
108
|
type: 'histogram',
|
|
42
109
|
option: mergeEchartWidgetConfig(getCommonOptions(props), getOption(props)),
|
|
110
|
+
formatter: props.formatter,
|
|
43
111
|
}
|
|
44
112
|
}
|
|
113
|
+
|
|
45
114
|
function getOption({
|
|
46
115
|
data = [],
|
|
116
|
+
ticks,
|
|
47
117
|
theme,
|
|
48
118
|
formatter,
|
|
119
|
+
labelFormatter,
|
|
49
120
|
}: HistogramConfig): EchartOptionsProps {
|
|
50
121
|
const hasLegend = (data?.length ?? 0) > 1
|
|
122
|
+
const dataLength = data[0]?.length ?? 0
|
|
123
|
+
const axisLabels = createAxisLabels(dataLength, ticks, labelFormatter)
|
|
51
124
|
|
|
52
125
|
let niceMin = 0
|
|
53
126
|
let niceMax = 1
|
|
54
127
|
|
|
55
128
|
return {
|
|
56
|
-
legend: buildLegendConfig(hasLegend),
|
|
129
|
+
legend: buildLegendConfig({ hasLegend }),
|
|
57
130
|
grid: buildGridConfig(hasLegend, theme),
|
|
58
131
|
xAxis: {
|
|
59
132
|
type: 'category',
|
|
133
|
+
data: axisLabels,
|
|
60
134
|
axisLine: {
|
|
61
135
|
show: false,
|
|
62
136
|
},
|
|
@@ -126,14 +200,12 @@ function getOption({
|
|
|
126
200
|
tooltip: {
|
|
127
201
|
position: createTooltipPositioner(theme),
|
|
128
202
|
formatter: createTooltipFormatter((item) => {
|
|
129
|
-
const
|
|
130
|
-
const index = item.dimensionNames?.[item.encode?.y?.at(0) ?? 1]
|
|
131
|
-
const _value = value[index ?? '']
|
|
203
|
+
const _value = item.value as number
|
|
132
204
|
|
|
133
205
|
const formattedValue =
|
|
134
206
|
typeof _value === 'number' && formatter
|
|
135
207
|
? formatter(_value)
|
|
136
|
-
: (_value ?? '')
|
|
208
|
+
: String(_value ?? '')
|
|
137
209
|
|
|
138
210
|
const marker = typeof item.marker === 'string' ? item.marker : ''
|
|
139
211
|
const seriesName = item.seriesName ? `${item.seriesName}: ` : ''
|
|
@@ -142,11 +214,11 @@ function getOption({
|
|
|
142
214
|
return { name, seriesName, marker, value: formattedValue }
|
|
143
215
|
}),
|
|
144
216
|
},
|
|
145
|
-
series: data.map((
|
|
146
|
-
datasetIndex: index,
|
|
217
|
+
series: data.map((seriesData: number[]) => ({
|
|
147
218
|
type: 'bar',
|
|
148
|
-
|
|
149
|
-
|
|
219
|
+
data: seriesData,
|
|
220
|
+
barGap: '1%',
|
|
221
|
+
barCategoryGap: '1%',
|
|
150
222
|
emphasis: {
|
|
151
223
|
focus: 'series',
|
|
152
224
|
},
|
|
@@ -4,5 +4,10 @@ export type {
|
|
|
4
4
|
HistogramWidgetData,
|
|
5
5
|
HistogramWidgetState,
|
|
6
6
|
} from './types'
|
|
7
|
-
export {
|
|
7
|
+
export type { HistogramDownloadConfigProps } from './config'
|
|
8
|
+
export {
|
|
9
|
+
histogramConfig,
|
|
10
|
+
histogramDataToCSV,
|
|
11
|
+
histogramDownloadConfig,
|
|
12
|
+
} from './config'
|
|
8
13
|
export { HistogramSkeleton } from './skeleton'
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { EchartWidgetState } from '../echart'
|
|
2
2
|
import type {
|
|
3
3
|
EchartWidgetOptionProps,
|
|
4
4
|
EchartWidgetProps,
|
|
5
5
|
} from '../echart/types'
|
|
6
6
|
import type { ConfigProps } from '../loader'
|
|
7
7
|
|
|
8
|
-
export type HistogramWidgetData =
|
|
8
|
+
export type HistogramWidgetData = number[][]
|
|
9
9
|
|
|
10
10
|
export type HistogramWidgetState = EchartWidgetState
|
|
11
11
|
|
|
@@ -14,4 +14,10 @@ export type HistogramWidgetConfig = EchartWidgetProps & {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export type HistogramConfig = ConfigProps &
|
|
17
|
-
|
|
17
|
+
Pick<
|
|
18
|
+
EchartWidgetOptionProps<unknown>,
|
|
19
|
+
'theme' | 'formatter' | 'labelFormatter'
|
|
20
|
+
> & {
|
|
21
|
+
data?: number[][]
|
|
22
|
+
ticks: number[]
|
|
23
|
+
}
|
|
@@ -3,6 +3,28 @@ import type { WidgetLoaderProps } from './types'
|
|
|
3
3
|
import { useWidgetStore } from '../stores/widget-store'
|
|
4
4
|
import type { WrapperState } from '../wrapper'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Foundation component for all widgets that manages state initialization, synchronization with the widget store, and data transformation pipeline execution.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* The WidgetLoader is stateless -- it manages data flow but does not render any UI. Always wrap it with WidgetWrapper for consistent widget appearance.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <WidgetLoader
|
|
15
|
+
* id="sales-chart"
|
|
16
|
+
* type="bar"
|
|
17
|
+
* data={data}
|
|
18
|
+
* isLoading={false}
|
|
19
|
+
* isFetching={false}
|
|
20
|
+
* config={barConfig({ data })}
|
|
21
|
+
* >
|
|
22
|
+
* <WidgetWrapper id="sales-chart" title="Sales">
|
|
23
|
+
* <Echart id="sales-chart" />
|
|
24
|
+
* </WidgetWrapper>
|
|
25
|
+
* </WidgetLoader>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
6
28
|
export function WidgetLoader<T extends object = Record<string, unknown>>(
|
|
7
29
|
props: WidgetLoaderProps<T>,
|
|
8
30
|
) {
|
|
@@ -9,9 +9,21 @@ export type ConfigOrFn<TConfig, TData = unknown> =
|
|
|
9
9
|
| ((baseConfig: TConfig, data: TData) => Partial<TConfig>)
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
|
-
* Resolves a config that may be either
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Resolves a widget config that may be either a partial object or a function receiving the computed base config and data. If it is a function, calls it with `baseConfig` and `data`; otherwise returns the value as-is.
|
|
13
|
+
*
|
|
14
|
+
* @param config - The config object or function to resolve.
|
|
15
|
+
* @param baseConfig - The computed base configuration.
|
|
16
|
+
* @param data - The widget data.
|
|
17
|
+
* @returns Resolved partial config, or undefined.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* const resolved = resolveConfig(
|
|
22
|
+
* (base, data) => ({ maxItems: base.maxItems + 5 }),
|
|
23
|
+
* baseConfig,
|
|
24
|
+
* widgetData,
|
|
25
|
+
* )
|
|
26
|
+
* ```
|
|
15
27
|
*/
|
|
16
28
|
export function resolveConfig<TConfig, TData>(
|
|
17
29
|
config: ConfigOrFn<TConfig, TData> | undefined,
|
|
@@ -24,6 +36,17 @@ export function resolveConfig<TConfig, TData>(
|
|
|
24
36
|
return config
|
|
25
37
|
}
|
|
26
38
|
|
|
39
|
+
/**
|
|
40
|
+
* Deep-merges two partial widget config objects using `deepmerge`, with arrays replaced rather than concatenated.
|
|
41
|
+
*
|
|
42
|
+
* @param options - A tuple of two partial configs to merge (base and override).
|
|
43
|
+
* @returns The merged config object.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```tsx
|
|
47
|
+
* const finalConfig = mergeWidgetConfig(baseConfig, resolvedConfig)
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
27
50
|
export function mergeWidgetConfig<T>(
|
|
28
51
|
...options: [Partial<T> | undefined, Partial<T> | undefined]
|
|
29
52
|
): T {
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { downloadToCSV, type DownloadItem } from '../actions'
|
|
2
2
|
import type { MarkdownWidgetConfig, MarkdownWidgetData } from './types'
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Creates download configuration for markdown widgets, supporting CSV export of text content. Does not require `refUI` since it only exports text.
|
|
6
|
+
*
|
|
7
|
+
* @returns Array of download items for use with the Download action.
|
|
8
|
+
*/
|
|
4
9
|
export function markdownDownloadConfig(): DownloadItem<MarkdownWidgetData>[] {
|
|
5
10
|
return [
|
|
6
11
|
{
|
|
@@ -13,6 +18,11 @@ export function markdownDownloadConfig(): DownloadItem<MarkdownWidgetData>[] {
|
|
|
13
18
|
]
|
|
14
19
|
}
|
|
15
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Returns the default configuration for markdown content display widgets.
|
|
23
|
+
*
|
|
24
|
+
* @returns Default markdown widget config (empty object).
|
|
25
|
+
*/
|
|
16
26
|
export function markdownConfig(): MarkdownWidgetConfig {
|
|
17
27
|
return {}
|
|
18
28
|
}
|
|
@@ -38,6 +38,13 @@ const COMPONENTS: Components = {
|
|
|
38
38
|
li: ({ children }) => <ListItem sx={styles.li}>{children}</ListItem>,
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Presentational component that renders a Markdown string as MUI-styled HTML using react-markdown.
|
|
43
|
+
*
|
|
44
|
+
* @remarks
|
|
45
|
+
* Maps Markdown elements (headings, paragraphs, links, lists) to MUI Typography and Link components.
|
|
46
|
+
* Custom component overrides can be passed via the `overrides` prop.
|
|
47
|
+
*/
|
|
41
48
|
export function MarkdownUI({ children, overrides }: MarkdownComponentProps) {
|
|
42
49
|
return (
|
|
43
50
|
<ReactMarkdown
|