@carto/ps-react-ui 4.3.3 → 4.3.5
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 +3 -3
- package/dist/components.js.map +1 -1
- package/dist/{lasso-tool-BwRzEW7k.js → lasso-tool-wFqOD6wk.js} +13 -13
- package/dist/lasso-tool-wFqOD6wk.js.map +1 -0
- package/dist/types/components/common-types.d.ts +41 -0
- package/dist/types/components/types.d.ts +1 -1
- package/dist/types/widgets/echart/echart-ui.d.ts +1 -1
- package/dist/types/widgets/echart/types.d.ts +4 -0
- package/dist/widgets/actions.js +1 -1
- package/dist/widgets/bar.js +1 -1
- package/dist/widgets/category.js +1 -1
- package/dist/widgets/echart.js +96 -85
- package/dist/widgets/echart.js.map +1 -1
- package/dist/widgets/formula.js +1 -1
- package/dist/widgets/histogram.js +1 -1
- package/dist/widgets/markdown.js +1 -1
- package/dist/widgets/pie.js +1 -1
- package/dist/widgets/scatterplot.js +1 -1
- package/dist/widgets/spread.js +1 -1
- package/dist/widgets/table.js +1 -1
- package/dist/widgets/timeseries.js +1 -1
- package/dist/widgets/toolbar-actions.js.map +1 -1
- package/dist/widgets/wrapper.js +1 -1
- package/package.json +8 -3
- package/src/components/basemaps/basemaps.test.tsx +196 -0
- package/src/components/basemaps/basemaps.tsx +128 -0
- package/src/components/basemaps/const.ts +13 -0
- package/src/components/basemaps/group-wrapper.test.tsx +38 -0
- package/src/components/basemaps/group-wrapper.tsx +28 -0
- package/src/components/basemaps/group.test.tsx +52 -0
- package/src/components/basemaps/group.tsx +42 -0
- package/src/components/basemaps/header.test.tsx +54 -0
- package/src/components/basemaps/header.tsx +36 -0
- package/src/components/basemaps/styles.ts +76 -0
- package/src/components/basemaps/types.ts +30 -0
- package/src/components/common-types.ts +1 -0
- package/src/components/geolocation-controls/const.ts +6 -0
- package/src/components/geolocation-controls/geolocation-controls.test.tsx +133 -0
- package/src/components/geolocation-controls/geolocation-controls.tsx +95 -0
- package/src/components/geolocation-controls/types.ts +17 -0
- package/src/components/index.ts +64 -0
- package/src/components/lasso-tool/chip.tsx +37 -0
- package/src/components/lasso-tool/const.tsx +70 -0
- package/src/components/lasso-tool/icons.tsx +91 -0
- package/src/components/lasso-tool/lasso-tool-inline.test.tsx +168 -0
- package/src/components/lasso-tool/lasso-tool-inline.tsx +245 -0
- package/src/components/lasso-tool/lasso-tool.test.tsx +212 -0
- package/src/components/lasso-tool/lasso-tool.tsx +479 -0
- package/src/components/lasso-tool/styles.ts +143 -0
- package/src/components/lasso-tool/types.ts +114 -0
- package/src/components/list-data/list-data-skeleton.test.tsx +10 -0
- package/src/components/list-data/list-data-skeleton.tsx +40 -0
- package/src/components/list-data/list-data.test.tsx +94 -0
- package/src/components/list-data/list-data.tsx +106 -0
- package/src/components/list-data/styles.ts +37 -0
- package/src/components/list-data/types.ts +25 -0
- package/src/components/measurement-tools/const.tsx +108 -0
- package/src/components/measurement-tools/icons.tsx +54 -0
- package/src/components/measurement-tools/measurement-tools.test.tsx +165 -0
- package/src/components/measurement-tools/measurement-tools.tsx +443 -0
- package/src/components/measurement-tools/styles.ts +91 -0
- package/src/components/measurement-tools/types.ts +77 -0
- package/src/components/no-data-alert/no-data-alert.test.tsx +31 -0
- package/src/components/no-data-alert/no-data-alert.tsx +59 -0
- package/src/components/responsive-drawer/responsive-drawer.test.tsx +91 -0
- package/src/components/responsive-drawer/responsive-drawer.tsx +53 -0
- package/src/components/smart-tooltip/smart-tooltip.test.tsx +168 -0
- package/src/components/smart-tooltip/smart-tooltip.tsx +40 -0
- package/src/components/tooltip/tooltip.test.tsx +86 -0
- package/src/components/tooltip/tooltip.tsx +30 -0
- package/src/components/types.ts +1 -0
- package/src/components/zoom-controls/styles.ts +27 -0
- package/src/components/zoom-controls/types.ts +19 -0
- package/src/components/zoom-controls/zoom-controls.test.tsx +101 -0
- package/src/components/zoom-controls/zoom-controls.tsx +114 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-debounce.ts +55 -0
- package/src/hooks/use-skeleton.test.tsx +32 -0
- package/src/hooks/use-skeleton.ts +19 -0
- package/src/hooks/use-widget-ref.ts +33 -0
- package/src/widgets/README.md +277 -0
- package/src/widgets/_shared/chart-config/config-factory.ts +67 -0
- package/src/widgets/_shared/chart-config/csv-modifiers.ts +56 -0
- package/src/widgets/_shared/chart-config/index.ts +21 -0
- package/src/widgets/_shared/chart-config/option-builders.ts +203 -0
- package/src/widgets/_shared/skeleton/index.ts +5 -0
- package/src/widgets/_shared/skeleton/styles.ts +20 -0
- package/src/widgets/actions/change-column/change-column-icon.tsx +10 -0
- package/src/widgets/actions/change-column/change-column.test.tsx +163 -0
- package/src/widgets/actions/change-column/change-column.tsx +141 -0
- package/src/widgets/actions/change-column/sortable-column-item.tsx +49 -0
- package/src/widgets/actions/change-column/types.ts +20 -0
- package/src/widgets/actions/download/download.test.tsx +322 -0
- package/src/widgets/actions/download/download.tsx +118 -0
- package/src/widgets/actions/download/exports.test.tsx +275 -0
- package/src/widgets/actions/download/exports.tsx +103 -0
- package/src/widgets/actions/download/types.ts +21 -0
- package/src/widgets/actions/fullscreen/fullscreen.test.tsx +269 -0
- package/src/widgets/actions/fullscreen/fullscreen.tsx +82 -0
- package/src/widgets/actions/fullscreen/styles.ts +17 -0
- package/src/widgets/actions/fullscreen/types.ts +27 -0
- package/src/widgets/actions/index.ts +51 -0
- package/src/widgets/actions/lock-selection/lock-selection.test.tsx +186 -0
- package/src/widgets/actions/lock-selection/lock-selection.tsx +133 -0
- package/src/widgets/actions/lock-selection/types.ts +41 -0
- package/src/widgets/actions/relative-data/relative-data.test.tsx +267 -0
- package/src/widgets/actions/relative-data/relative-data.tsx +133 -0
- package/src/widgets/actions/relative-data/style.ts +9 -0
- package/src/widgets/actions/relative-data/types.ts +31 -0
- package/src/widgets/actions/relative-data/utils.test.ts +223 -0
- package/src/widgets/actions/relative-data/utils.ts +58 -0
- package/src/widgets/actions/searcher/searcher-toggle.test.tsx +354 -0
- package/src/widgets/actions/searcher/searcher-toggle.tsx +73 -0
- package/src/widgets/actions/searcher/searcher.tsx +205 -0
- package/src/widgets/actions/searcher/types.ts +72 -0
- package/src/widgets/actions/shared/styles.ts +12 -0
- package/src/widgets/actions/stack-toggle/grouped-bar-chart-icon.tsx +14 -0
- package/src/widgets/actions/stack-toggle/stack-toggle.test.tsx +270 -0
- package/src/widgets/actions/stack-toggle/stack-toggle.tsx +146 -0
- package/src/widgets/actions/stack-toggle/types.ts +29 -0
- package/src/widgets/actions/zoom-toggle/index.ts +2 -0
- package/src/widgets/actions/zoom-toggle/style.ts +14 -0
- package/src/widgets/actions/zoom-toggle/types.ts +44 -0
- package/src/widgets/actions/zoom-toggle/zoom-toggle.tsx +186 -0
- package/src/widgets/bar/config.ts +122 -0
- package/src/widgets/bar/index.ts +9 -0
- package/src/widgets/bar/skeleton.tsx +60 -0
- package/src/widgets/bar/style.ts +33 -0
- package/src/widgets/bar/types.ts +16 -0
- package/src/widgets/category/category-ui.test.tsx +399 -0
- package/src/widgets/category/category-ui.tsx +156 -0
- package/src/widgets/category/components/category-bar.tsx +28 -0
- package/src/widgets/category/components/category-legend.tsx +30 -0
- package/src/widgets/category/components/category-row-multi.tsx +50 -0
- package/src/widgets/category/components/category-row-other.tsx +23 -0
- package/src/widgets/category/components/category-row-single.tsx +47 -0
- package/src/widgets/category/components/index.ts +14 -0
- package/src/widgets/category/config.ts +85 -0
- package/src/widgets/category/index.ts +30 -0
- package/src/widgets/category/skeleton.tsx +24 -0
- package/src/widgets/category/style.ts +133 -0
- package/src/widgets/category/types.ts +40 -0
- package/src/widgets/echart/const.ts +1 -0
- package/src/widgets/echart/echart-ui.test.tsx +537 -0
- package/src/widgets/echart/echart-ui.tsx +92 -0
- package/src/widgets/echart/echart.test.tsx +562 -0
- package/src/widgets/echart/echart.tsx +68 -0
- package/src/widgets/echart/index.ts +16 -0
- package/src/widgets/echart/options.ts +53 -0
- package/src/widgets/echart/types.ts +45 -0
- package/src/widgets/echart/utils.ts +169 -0
- package/src/widgets/error/error.test.tsx +331 -0
- package/src/widgets/error/error.tsx +40 -0
- package/src/widgets/error/index.ts +2 -0
- package/src/widgets/error/types.ts +14 -0
- package/src/widgets/formula/components/item.test.tsx +249 -0
- package/src/widgets/formula/components/item.tsx +18 -0
- package/src/widgets/formula/components/prefix.test.tsx +341 -0
- package/src/widgets/formula/components/prefix.tsx +18 -0
- package/src/widgets/formula/components/row.test.tsx +364 -0
- package/src/widgets/formula/components/row.tsx +21 -0
- package/src/widgets/formula/components/series.tsx +34 -0
- package/src/widgets/formula/components/suffix.test.tsx +383 -0
- package/src/widgets/formula/components/suffix.tsx +28 -0
- package/src/widgets/formula/components/value.test.tsx +329 -0
- package/src/widgets/formula/components/value.tsx +29 -0
- package/src/widgets/formula/config.ts +27 -0
- package/src/widgets/formula/formula-ui.test.tsx +399 -0
- package/src/widgets/formula/formula-ui.tsx +27 -0
- package/src/widgets/formula/index.ts +24 -0
- package/src/widgets/formula/serializer.test.tsx +144 -0
- package/src/widgets/formula/serializer.ts +28 -0
- package/src/widgets/formula/skeleton.tsx +10 -0
- package/src/widgets/formula/style.ts +23 -0
- package/src/widgets/formula/types.ts +50 -0
- package/src/widgets/histogram/config.ts +143 -0
- package/src/widgets/histogram/index.ts +8 -0
- package/src/widgets/histogram/skeleton.tsx +52 -0
- package/src/widgets/histogram/style.ts +8 -0
- package/src/widgets/histogram/types.ts +17 -0
- package/src/widgets/index.ts +25 -0
- package/src/widgets/loader/index.ts +4 -0
- package/src/widgets/loader/loader.tsx +70 -0
- package/src/widgets/loader/types.ts +11 -0
- package/src/widgets/loader/utils.test.ts +112 -0
- package/src/widgets/loader/utils.ts +35 -0
- package/src/widgets/markdown/config.ts +18 -0
- package/src/widgets/markdown/index.ts +14 -0
- package/src/widgets/markdown/markdown-ui.test.tsx +341 -0
- package/src/widgets/markdown/markdown-ui.tsx +52 -0
- package/src/widgets/markdown/markdown.tsx +20 -0
- package/src/widgets/markdown/skeleton.tsx +12 -0
- package/src/widgets/markdown/style.ts +28 -0
- package/src/widgets/markdown/types.ts +28 -0
- package/src/widgets/no-data/index.ts +2 -0
- package/src/widgets/no-data/no-data.test.tsx +447 -0
- package/src/widgets/no-data/no-data.tsx +116 -0
- package/src/widgets/no-data/style.ts +18 -0
- package/src/widgets/no-data/types.ts +72 -0
- package/src/widgets/note/index.ts +2 -0
- package/src/widgets/note/note.test.tsx +391 -0
- package/src/widgets/note/note.tsx +114 -0
- package/src/widgets/note/style.ts +29 -0
- package/src/widgets/note/types.ts +9 -0
- package/src/widgets/pie/config.ts +177 -0
- package/src/widgets/pie/index.ts +8 -0
- package/src/widgets/pie/skeleton.tsx +70 -0
- package/src/widgets/pie/style.ts +8 -0
- package/src/widgets/pie/types.ts +16 -0
- package/src/widgets/range/components/range-item.tsx +213 -0
- package/src/widgets/range/config.ts +10 -0
- package/src/widgets/range/index.ts +16 -0
- package/src/widgets/range/range-ui.test.tsx +203 -0
- package/src/widgets/range/range-ui.tsx +11 -0
- package/src/widgets/range/serializer.test.ts +70 -0
- package/src/widgets/range/serializer.ts +27 -0
- package/src/widgets/range/skeleton.tsx +14 -0
- package/src/widgets/range/style.ts +37 -0
- package/src/widgets/range/types.ts +39 -0
- package/src/widgets/scatterplot/config.ts +138 -0
- package/src/widgets/scatterplot/index.ts +8 -0
- package/src/widgets/scatterplot/skeleton.tsx +59 -0
- package/src/widgets/scatterplot/style.ts +21 -0
- package/src/widgets/scatterplot/types.ts +17 -0
- package/src/widgets/selection-summary/index.ts +6 -0
- package/src/widgets/selection-summary/selection-summary.tsx +46 -0
- package/src/widgets/selection-summary/style.ts +10 -0
- package/src/widgets/selection-summary/types.ts +14 -0
- package/src/widgets/skeleton-loader/index.ts +2 -0
- package/src/widgets/skeleton-loader/skeleton-loader.test.tsx +139 -0
- package/src/widgets/skeleton-loader/skeleton-loader.tsx +28 -0
- package/src/widgets/skeleton-loader/types.ts +8 -0
- package/src/widgets/spread/components/max-value.tsx +29 -0
- package/src/widgets/spread/components/min-value.tsx +29 -0
- package/src/widgets/spread/components/separator.tsx +6 -0
- package/src/widgets/spread/config.ts +34 -0
- package/src/widgets/spread/index.ts +23 -0
- package/src/widgets/spread/skeleton.tsx +10 -0
- package/src/widgets/spread/spread-ui.test.tsx +368 -0
- package/src/widgets/spread/spread-ui.tsx +29 -0
- package/src/widgets/spread/style.ts +22 -0
- package/src/widgets/spread/types.ts +47 -0
- package/src/widgets/stores/index.ts +9 -0
- package/src/widgets/stores/types.ts +192 -0
- package/src/widgets/stores/widget-store.test.ts +601 -0
- package/src/widgets/stores/widget-store.ts +239 -0
- package/src/widgets/subheader/index.ts +3 -0
- package/src/widgets/subheader/style.ts +20 -0
- package/src/widgets/subheader/subheader.test.tsx +45 -0
- package/src/widgets/subheader/subheader.tsx +16 -0
- package/src/widgets/subheader/types.ts +11 -0
- package/src/widgets/table/components/cell-header.tsx +58 -0
- package/src/widgets/table/components/cell.tsx +80 -0
- package/src/widgets/table/components/index.ts +4 -0
- package/src/widgets/table/components/pagination-actions.tsx +67 -0
- package/src/widgets/table/components/pagination.tsx +41 -0
- package/src/widgets/table/components/row.tsx +60 -0
- package/src/widgets/table/config.ts +71 -0
- package/src/widgets/table/helpers.test.ts +244 -0
- package/src/widgets/table/helpers.ts +107 -0
- package/src/widgets/table/hooks/index.ts +7 -0
- package/src/widgets/table/hooks/use-pagination.test.ts +294 -0
- package/src/widgets/table/hooks/use-pagination.ts +155 -0
- package/src/widgets/table/hooks/use-selection.test.ts +504 -0
- package/src/widgets/table/hooks/use-selection.ts +189 -0
- package/src/widgets/table/hooks/use-sort.test.ts +296 -0
- package/src/widgets/table/hooks/use-sort.ts +138 -0
- package/src/widgets/table/index.ts +53 -0
- package/src/widgets/table/serializer.ts +54 -0
- package/src/widgets/table/skeleton.tsx +48 -0
- package/src/widgets/table/style.ts +34 -0
- package/src/widgets/table/table-ui.tsx +64 -0
- package/src/widgets/table/types.ts +223 -0
- package/src/widgets/timeseries/config.ts +135 -0
- package/src/widgets/timeseries/index.ts +8 -0
- package/src/widgets/timeseries/skeleton.tsx +55 -0
- package/src/widgets/timeseries/style.ts +36 -0
- package/src/widgets/timeseries/types.ts +17 -0
- package/src/widgets/toolbar-actions/index.ts +6 -0
- package/src/widgets/toolbar-actions/styles.ts +38 -0
- package/src/widgets/toolbar-actions/toolbar-actions.test.tsx +691 -0
- package/src/widgets/toolbar-actions/toolbar-actions.tsx +145 -0
- package/src/widgets/toolbar-actions/types.ts +60 -0
- package/src/widgets/wrapper/components/actions.test.tsx +101 -0
- package/src/widgets/wrapper/components/actions.tsx +30 -0
- package/src/widgets/wrapper/components/options.test.tsx +323 -0
- package/src/widgets/wrapper/components/options.tsx +73 -0
- package/src/widgets/wrapper/components/title.test.tsx +126 -0
- package/src/widgets/wrapper/components/title.tsx +32 -0
- package/src/widgets/wrapper/index.ts +16 -0
- package/src/widgets/wrapper/styles.ts +98 -0
- package/src/widgets/wrapper/types.ts +55 -0
- package/src/widgets/wrapper/wrapper-ui.test.tsx +232 -0
- package/src/widgets/wrapper/wrapper-ui.tsx +57 -0
- package/src/widgets/wrapper/wrapper.test.tsx +365 -0
- package/src/widgets/wrapper/wrapper.tsx +50 -0
- package/dist/lasso-tool-BwRzEW7k.js.map +0 -1
- package/dist/types/common/common.d.ts +0 -3
- package/dist/types/common/index.d.ts +0 -26
- package/dist/types/common/lasso-tools.d.ts +0 -36
- package/dist/types/common/measurement-tools.d.ts +0 -65
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Box, Typography } from '@mui/material'
|
|
2
|
+
import { styles } from '../style'
|
|
3
|
+
import { CategoryBar } from './category-bar'
|
|
4
|
+
import type { CategoryWidgetConfig } from '../types'
|
|
5
|
+
|
|
6
|
+
export interface CategoryRowSingleProps {
|
|
7
|
+
name: string
|
|
8
|
+
value: number
|
|
9
|
+
maxValue: number
|
|
10
|
+
color: string
|
|
11
|
+
formatter: NonNullable<CategoryWidgetConfig['formatter']>
|
|
12
|
+
onClick?: CategoryWidgetConfig['onRowClick']
|
|
13
|
+
selected?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function CategoryRowSingle({
|
|
17
|
+
name,
|
|
18
|
+
value,
|
|
19
|
+
maxValue,
|
|
20
|
+
color,
|
|
21
|
+
formatter,
|
|
22
|
+
onClick,
|
|
23
|
+
selected = true,
|
|
24
|
+
}: CategoryRowSingleProps) {
|
|
25
|
+
const handleClick = onClick
|
|
26
|
+
? () =>
|
|
27
|
+
onClick({
|
|
28
|
+
name,
|
|
29
|
+
})
|
|
30
|
+
: undefined
|
|
31
|
+
const rowStyle = onClick ? styles.rowClickable : styles.row
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Box sx={rowStyle} onClick={handleClick}>
|
|
35
|
+
<Box sx={styles.rowHeader}>
|
|
36
|
+
<Typography sx={styles.rowLabel}>{name}</Typography>
|
|
37
|
+
<Typography sx={styles.rowValue}>{formatter(value)}</Typography>
|
|
38
|
+
</Box>
|
|
39
|
+
<CategoryBar
|
|
40
|
+
value={value}
|
|
41
|
+
maxValue={maxValue}
|
|
42
|
+
color={color}
|
|
43
|
+
selected={selected}
|
|
44
|
+
/>
|
|
45
|
+
</Box>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { CategoryBar } from './category-bar'
|
|
2
|
+
export type { CategoryBarProps } from './category-bar'
|
|
3
|
+
|
|
4
|
+
export { CategoryRowSingle } from './category-row-single'
|
|
5
|
+
export type { CategoryRowSingleProps } from './category-row-single'
|
|
6
|
+
|
|
7
|
+
export { CategoryRowMulti } from './category-row-multi'
|
|
8
|
+
export type { CategoryRowMultiProps } from './category-row-multi'
|
|
9
|
+
|
|
10
|
+
export { CategoryRowOther } from './category-row-other'
|
|
11
|
+
export type { CategoryRowOtherProps } from './category-row-other'
|
|
12
|
+
|
|
13
|
+
export { CategoryLegend } from './category-legend'
|
|
14
|
+
export type { CategoryLegendProps } from './category-legend'
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { downloadToCSV, downloadToPNG, type DownloadItem } from '../actions'
|
|
2
|
+
import type { ConfigProps } from '../loader/types'
|
|
3
|
+
import type {
|
|
4
|
+
CategoryWidgetConfig,
|
|
5
|
+
CategoryWidgetData,
|
|
6
|
+
CategorySeriesConfig,
|
|
7
|
+
CategoryLabels,
|
|
8
|
+
} from './types'
|
|
9
|
+
|
|
10
|
+
export interface CategoryDownloadConfigProps extends ConfigProps {
|
|
11
|
+
series?: CategorySeriesConfig[]
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CategoryConfigProps {
|
|
15
|
+
data?: CategoryWidgetData
|
|
16
|
+
series?: CategorySeriesConfig[]
|
|
17
|
+
formatter?: (value: number) => string
|
|
18
|
+
maxItems?: number
|
|
19
|
+
labels?: CategoryLabels
|
|
20
|
+
max?: number
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function categoryDownloadConfig({
|
|
24
|
+
refUI,
|
|
25
|
+
series,
|
|
26
|
+
}: CategoryDownloadConfigProps): DownloadItem<CategoryWidgetData>[] {
|
|
27
|
+
return [
|
|
28
|
+
{
|
|
29
|
+
...downloadToPNG,
|
|
30
|
+
modifier: () => downloadToPNG.modifier(refUI),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
...downloadToCSV,
|
|
34
|
+
modifier: async (data) => {
|
|
35
|
+
if (!data?.length || data[0]?.length === 0) {
|
|
36
|
+
return downloadToCSV.modifier([])
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// data is CategoryDataItem[][] where data[seriesIndex] contains items for that series
|
|
40
|
+
const seriesCount = data.length
|
|
41
|
+
const grouped = new Map<string, number[]>()
|
|
42
|
+
const nameOrder: string[] = []
|
|
43
|
+
|
|
44
|
+
// Iterate over each series (outer array)
|
|
45
|
+
for (let seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) {
|
|
46
|
+
const seriesData = data[seriesIndex]!
|
|
47
|
+
for (const item of seriesData) {
|
|
48
|
+
let values = grouped.get(item.name)
|
|
49
|
+
if (!values) {
|
|
50
|
+
values = new Array<number>(seriesCount).fill(0)
|
|
51
|
+
grouped.set(item.name, values)
|
|
52
|
+
nameOrder.push(item.name)
|
|
53
|
+
}
|
|
54
|
+
values[seriesIndex] = item.value
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Build rows
|
|
59
|
+
const rows = nameOrder.map((name) => [name, ...grouped.get(name)!])
|
|
60
|
+
|
|
61
|
+
const isMulti = seriesCount > 1
|
|
62
|
+
const headers = isMulti
|
|
63
|
+
? [
|
|
64
|
+
'Category',
|
|
65
|
+
...(series?.map((s: CategorySeriesConfig) => s.name) ??
|
|
66
|
+
Array.from(
|
|
67
|
+
{ length: seriesCount },
|
|
68
|
+
(_, i) => `Series ${i + 1}`,
|
|
69
|
+
)),
|
|
70
|
+
]
|
|
71
|
+
: ['Category', 'Value']
|
|
72
|
+
|
|
73
|
+
return downloadToCSV.modifier([headers, ...rows])
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function categoryConfig(): CategoryWidgetConfig {
|
|
80
|
+
return {
|
|
81
|
+
series: [],
|
|
82
|
+
maxItems: 10,
|
|
83
|
+
max: undefined,
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export { CategoryUI } from './category-ui'
|
|
2
|
+
export { CategorySkeleton } from './skeleton'
|
|
3
|
+
export { categoryConfig, categoryDownloadConfig } from './config'
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
CategoryBar,
|
|
7
|
+
CategoryRowSingle,
|
|
8
|
+
CategoryRowMulti,
|
|
9
|
+
CategoryLegend,
|
|
10
|
+
CategoryRowOther,
|
|
11
|
+
} from './components'
|
|
12
|
+
|
|
13
|
+
export type {
|
|
14
|
+
CategoryBarProps,
|
|
15
|
+
CategoryRowSingleProps,
|
|
16
|
+
CategoryRowMultiProps,
|
|
17
|
+
CategoryLegendProps,
|
|
18
|
+
CategoryRowOtherProps,
|
|
19
|
+
} from './components'
|
|
20
|
+
|
|
21
|
+
export type {
|
|
22
|
+
CategoryUIProps,
|
|
23
|
+
CategoryWidgetData,
|
|
24
|
+
CategoryWidgetState,
|
|
25
|
+
CategoryWidgetConfig,
|
|
26
|
+
CategoryDownloadConfig,
|
|
27
|
+
CategoryDataItem,
|
|
28
|
+
CategorySeriesConfig,
|
|
29
|
+
CategoryLabels,
|
|
30
|
+
} from './types'
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Box, Skeleton } from '@mui/material'
|
|
2
|
+
import { styles } from './style'
|
|
3
|
+
|
|
4
|
+
const widthPatterns = [85, 70, 55, 75, 60]
|
|
5
|
+
|
|
6
|
+
export function CategorySkeleton() {
|
|
7
|
+
return (
|
|
8
|
+
<Box sx={styles.list} aria-label='Category skeleton'>
|
|
9
|
+
{Array.from({ length: 5 }).map((_, index) => (
|
|
10
|
+
<Box key={index} sx={styles.row}>
|
|
11
|
+
<Box sx={styles.rowHeader}>
|
|
12
|
+
<Skeleton width={80} height={16} />
|
|
13
|
+
<Skeleton width={40} height={16} />
|
|
14
|
+
</Box>
|
|
15
|
+
<Skeleton
|
|
16
|
+
variant='rectangular'
|
|
17
|
+
height={4}
|
|
18
|
+
sx={{ borderRadius: 2, width: `${widthPatterns[index]}%` }}
|
|
19
|
+
/>
|
|
20
|
+
</Box>
|
|
21
|
+
))}
|
|
22
|
+
</Box>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import type { SxProps, Theme } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
export const styles = {
|
|
4
|
+
root: {
|
|
5
|
+
display: 'flex',
|
|
6
|
+
flexDirection: 'column',
|
|
7
|
+
position: 'relative',
|
|
8
|
+
},
|
|
9
|
+
list: {
|
|
10
|
+
display: 'flex',
|
|
11
|
+
flexDirection: 'column',
|
|
12
|
+
gap: (theme: Theme) => theme.spacing(1),
|
|
13
|
+
},
|
|
14
|
+
row: {
|
|
15
|
+
display: 'flex',
|
|
16
|
+
flexDirection: 'column',
|
|
17
|
+
gap: (theme: Theme) => theme.spacing(0.5),
|
|
18
|
+
pointerEvents: 'none',
|
|
19
|
+
},
|
|
20
|
+
rowClickable: {
|
|
21
|
+
pointerEvents: 'auto',
|
|
22
|
+
// display: 'flex',
|
|
23
|
+
// flexDirection: 'column',
|
|
24
|
+
// gap: (theme: Theme) => theme.spacing(0.5),
|
|
25
|
+
// cursor: 'pointer',
|
|
26
|
+
// borderRadius: 1,
|
|
27
|
+
// padding: (theme: Theme) => theme.spacing(0.5),
|
|
28
|
+
// margin: (theme: Theme) => theme.spacing(-0.5),
|
|
29
|
+
// transition: 'background-color 0.15s ease-in-out',
|
|
30
|
+
// '&:hover': {
|
|
31
|
+
// backgroundColor: (theme: Theme) => theme.palette.action.hover,
|
|
32
|
+
// },
|
|
33
|
+
},
|
|
34
|
+
rowHeader: {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
justifyContent: 'space-between',
|
|
37
|
+
alignItems: 'center',
|
|
38
|
+
},
|
|
39
|
+
rowLabel: {
|
|
40
|
+
typography: 'body2',
|
|
41
|
+
fontWeight: 'medium',
|
|
42
|
+
color: 'text.primary',
|
|
43
|
+
},
|
|
44
|
+
rowValue: {
|
|
45
|
+
typography: 'body2',
|
|
46
|
+
color: 'text.secondary',
|
|
47
|
+
},
|
|
48
|
+
barContainer: {
|
|
49
|
+
display: 'flex',
|
|
50
|
+
flexDirection: 'column',
|
|
51
|
+
},
|
|
52
|
+
bar: {
|
|
53
|
+
height: 4,
|
|
54
|
+
borderRadius: 2,
|
|
55
|
+
backgroundColor: (theme: Theme) => theme.palette.action.disabledBackground,
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
position: 'relative',
|
|
58
|
+
transition: 'background-color 0.15s ease-in-out',
|
|
59
|
+
cursor: 'pointer',
|
|
60
|
+
'&:hover': {
|
|
61
|
+
backgroundColor: (theme: Theme) => theme.palette.action.hover,
|
|
62
|
+
|
|
63
|
+
'& > div': {
|
|
64
|
+
filter: 'brightness(1.2)',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
barFill: {
|
|
69
|
+
height: '100%',
|
|
70
|
+
borderRadius: 2,
|
|
71
|
+
transition: 'width 0.3s ease-in-out, background-color 0.15s ease-in-out',
|
|
72
|
+
},
|
|
73
|
+
barFillMuted: {
|
|
74
|
+
backgroundColor: (theme: Theme) => theme.palette.action.disabled,
|
|
75
|
+
},
|
|
76
|
+
legend: {
|
|
77
|
+
display: 'flex',
|
|
78
|
+
alignItems: 'center',
|
|
79
|
+
gap: (theme: Theme) => theme.spacing(2),
|
|
80
|
+
flexWrap: 'wrap',
|
|
81
|
+
paddingTop: (theme: Theme) => theme.spacing(2),
|
|
82
|
+
position: 'sticky',
|
|
83
|
+
bottom: 0,
|
|
84
|
+
backgroundColor: 'background.paper',
|
|
85
|
+
borderTop: (theme: Theme) => `1px solid ${theme.palette.divider}`,
|
|
86
|
+
marginTop: (theme: Theme) => theme.spacing(2),
|
|
87
|
+
},
|
|
88
|
+
legendItem: {
|
|
89
|
+
display: 'flex',
|
|
90
|
+
alignItems: 'center',
|
|
91
|
+
gap: (theme: Theme) => theme.spacing(1),
|
|
92
|
+
},
|
|
93
|
+
legendDot: {
|
|
94
|
+
width: 8,
|
|
95
|
+
height: 8,
|
|
96
|
+
borderRadius: '50%',
|
|
97
|
+
},
|
|
98
|
+
legendLabel: {
|
|
99
|
+
typography: 'caption',
|
|
100
|
+
color: 'text.secondary',
|
|
101
|
+
textTransform: 'uppercase',
|
|
102
|
+
fontWeight: 'medium',
|
|
103
|
+
},
|
|
104
|
+
multiBarRow: {
|
|
105
|
+
display: 'flex',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
gap: (theme: Theme) => theme.spacing(1),
|
|
108
|
+
},
|
|
109
|
+
multiBarValue: {
|
|
110
|
+
typography: 'body2',
|
|
111
|
+
color: 'text.secondary',
|
|
112
|
+
minWidth: 48,
|
|
113
|
+
textAlign: 'right',
|
|
114
|
+
},
|
|
115
|
+
multiBarContainer: {
|
|
116
|
+
flex: 1,
|
|
117
|
+
},
|
|
118
|
+
otherRow: {
|
|
119
|
+
display: 'flex',
|
|
120
|
+
justifyContent: 'space-between',
|
|
121
|
+
alignItems: 'center',
|
|
122
|
+
},
|
|
123
|
+
otherLabel: {
|
|
124
|
+
typography: 'body2',
|
|
125
|
+
fontWeight: 'medium',
|
|
126
|
+
color: 'text.secondary',
|
|
127
|
+
fontStyle: 'italic',
|
|
128
|
+
},
|
|
129
|
+
otherCount: {
|
|
130
|
+
typography: 'body2',
|
|
131
|
+
color: 'text.disabled',
|
|
132
|
+
},
|
|
133
|
+
} satisfies Record<string, SxProps<Theme>>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { BaseWidgetState, WidgetsStoreProps } from '../stores/types'
|
|
2
|
+
import type { WrapperState } from '../wrapper/types'
|
|
3
|
+
import type { DownloadItem } from '../actions/download/types'
|
|
4
|
+
|
|
5
|
+
export interface CategoryUIProps {
|
|
6
|
+
id: WidgetsStoreProps['id']
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface CategorySeriesConfig {
|
|
10
|
+
name: string
|
|
11
|
+
color?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface CategoryLabels {
|
|
15
|
+
other?: string
|
|
16
|
+
otherCount?: string
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CategoryDataItem extends Record<string, string | number> {
|
|
20
|
+
name: string
|
|
21
|
+
value: number
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type CategoryWidgetData = CategoryDataItem[][]
|
|
25
|
+
|
|
26
|
+
export type CategoryWidgetState = BaseWidgetState<
|
|
27
|
+
WrapperState<CategoryWidgetConfig> & { data: CategoryWidgetData }
|
|
28
|
+
>
|
|
29
|
+
|
|
30
|
+
export interface CategoryWidgetConfig {
|
|
31
|
+
formatter?: (value: number) => string
|
|
32
|
+
series?: CategorySeriesConfig[]
|
|
33
|
+
maxItems?: number
|
|
34
|
+
labels?: CategoryLabels
|
|
35
|
+
onRowClick?: ({ name }: { name: string }) => void
|
|
36
|
+
selected?: (name: string) => boolean
|
|
37
|
+
max?: number
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type CategoryDownloadConfig = DownloadItem<CategoryWidgetData>[]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DEFAULT_STACK_GROUP = 'stacked'
|