@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,114 @@
|
|
|
1
|
+
import type { Box, ChipProps, Paper, TooltipProps } from '@mui/material'
|
|
2
|
+
import type { ComponentProps, ComponentType } from 'react'
|
|
3
|
+
import type {
|
|
4
|
+
LassoToolsMode,
|
|
5
|
+
LassoToolsModes,
|
|
6
|
+
LassoToolOptionsMode,
|
|
7
|
+
LassoToolsModesMapping,
|
|
8
|
+
} from '../types'
|
|
9
|
+
|
|
10
|
+
export interface LassoToolsData {
|
|
11
|
+
id: string
|
|
12
|
+
label: string
|
|
13
|
+
visible?: boolean
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface LassoToolsComponentBaseProps<M extends string = LassoToolsMode> {
|
|
17
|
+
enabled: boolean
|
|
18
|
+
modes: Partial<LassoToolsModes<M>>
|
|
19
|
+
modesMapping: LassoToolsModesMapping<M>
|
|
20
|
+
values: LassoToolsData[]
|
|
21
|
+
labels?: {
|
|
22
|
+
action?: {
|
|
23
|
+
tooltip?: {
|
|
24
|
+
active?: string
|
|
25
|
+
inactive?: string
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
chip?: {
|
|
29
|
+
tooltip?: {
|
|
30
|
+
active?: string
|
|
31
|
+
inactive?: string
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
options?: {
|
|
35
|
+
mode?: {
|
|
36
|
+
title?: string
|
|
37
|
+
options?: LassoToolOptionsMode<LassoToolsMode>
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
noData?: {
|
|
41
|
+
title?: string
|
|
42
|
+
description?: string
|
|
43
|
+
}
|
|
44
|
+
actions: {
|
|
45
|
+
toggleAll?: {
|
|
46
|
+
active?: string
|
|
47
|
+
inactive?: string
|
|
48
|
+
}
|
|
49
|
+
deleteAll?: string
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
chipProps?: {
|
|
53
|
+
TooltipProps?: Omit<TooltipProps, 'title'>
|
|
54
|
+
ChipsProps?: Omit<ChipProps, 'label' | 'onDelete'>
|
|
55
|
+
}
|
|
56
|
+
modeSelected?: M | null
|
|
57
|
+
onChangeMode: (mode: M) => void
|
|
58
|
+
onChipToggle: (id: LassoToolsData['id'], data: boolean) => void
|
|
59
|
+
onDelete: (id: LassoToolsData['id']) => void
|
|
60
|
+
onAllChipToggle: () => void
|
|
61
|
+
onAllDelete: () => void
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface LassoToolsComponentProps<M extends string = LassoToolsMode>
|
|
65
|
+
extends LassoToolsComponentBaseProps<M> {
|
|
66
|
+
actionProps?: {
|
|
67
|
+
TooltipProps?: Omit<TooltipProps, 'title'>
|
|
68
|
+
}
|
|
69
|
+
PaperProps?: ComponentProps<typeof Paper>
|
|
70
|
+
onActionToggle: (data: boolean) => void
|
|
71
|
+
ChipsSlot?: ComponentType<
|
|
72
|
+
Partial<
|
|
73
|
+
Omit<
|
|
74
|
+
LassoToolsComponentProps,
|
|
75
|
+
'ChipsSlot' | 'ActionsSlot' | 'OptionsSlot' | 'SecondaryActionsSlot'
|
|
76
|
+
>
|
|
77
|
+
>
|
|
78
|
+
> | null
|
|
79
|
+
ActionSlot?: ComponentType<
|
|
80
|
+
Partial<
|
|
81
|
+
Omit<
|
|
82
|
+
LassoToolsComponentProps,
|
|
83
|
+
'ChipsSlot' | 'ActionsSlot' | 'OptionsSlot' | 'SecondaryActionsSlot'
|
|
84
|
+
>
|
|
85
|
+
>
|
|
86
|
+
> | null
|
|
87
|
+
OptionsSlot?: ComponentType<
|
|
88
|
+
Partial<
|
|
89
|
+
Omit<
|
|
90
|
+
LassoToolsComponentProps,
|
|
91
|
+
'ChipsSlot' | 'ActionsSlot' | 'OptionsSlot' | 'SecondaryActionsSlot'
|
|
92
|
+
>
|
|
93
|
+
> &
|
|
94
|
+
OptionsChildrenProps
|
|
95
|
+
> | null
|
|
96
|
+
SecondaryActionsSlot?: ComponentType<
|
|
97
|
+
Partial<
|
|
98
|
+
Omit<
|
|
99
|
+
LassoToolsComponentProps,
|
|
100
|
+
'ChipsSlot' | 'ActionsSlot' | 'OptionsSlot' | 'SecondaryActionsSlot'
|
|
101
|
+
>
|
|
102
|
+
>
|
|
103
|
+
> | null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface LassoToolsInlineComponentProps<
|
|
107
|
+
M extends string = LassoToolsMode,
|
|
108
|
+
> extends LassoToolsComponentBaseProps<M> {
|
|
109
|
+
BoxProps?: ComponentProps<typeof Box>
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface OptionsChildrenProps {
|
|
113
|
+
onClose: () => void
|
|
114
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest'
|
|
2
|
+
import { render } from '@testing-library/react'
|
|
3
|
+
import { ListDataSkeleton } from './list-data-skeleton'
|
|
4
|
+
|
|
5
|
+
describe('ListDataUI Skeleton', () => {
|
|
6
|
+
test('renders correctly', () => {
|
|
7
|
+
const { getByLabelText } = render(<ListDataSkeleton />)
|
|
8
|
+
expect(getByLabelText('List Data skeleton')).toBeTruthy()
|
|
9
|
+
})
|
|
10
|
+
})
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Box, Grid, Skeleton } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
interface ListDataSkeletonProps {
|
|
4
|
+
length?: number
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function ListDataSkeleton({ length = 5 }: ListDataSkeletonProps) {
|
|
8
|
+
return (
|
|
9
|
+
<Box aria-label='List Data skeleton'>
|
|
10
|
+
{new Array(length).fill(null).map((_, idx) => (
|
|
11
|
+
<Grid key={idx} container spacing={1}>
|
|
12
|
+
<Grid
|
|
13
|
+
container
|
|
14
|
+
item
|
|
15
|
+
direction='row'
|
|
16
|
+
justifyContent='space-between'
|
|
17
|
+
alignItems='center'
|
|
18
|
+
>
|
|
19
|
+
<Skeleton width={isOdd(idx) ? 72 : 48} height={20} />
|
|
20
|
+
<Skeleton width={48} height={8} />
|
|
21
|
+
</Grid>
|
|
22
|
+
|
|
23
|
+
<Skeleton
|
|
24
|
+
sx={{
|
|
25
|
+
height: ({ spacing }) => spacing(0.5),
|
|
26
|
+
marginTop: ({ spacing }) => spacing(1.25),
|
|
27
|
+
marginBottom: ({ spacing }) => spacing(1.75),
|
|
28
|
+
width: '100%',
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
</Grid>
|
|
32
|
+
))}
|
|
33
|
+
</Box>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Aux
|
|
38
|
+
function isOdd(num: number) {
|
|
39
|
+
return num % 2 === 1
|
|
40
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { describe, expect, test, vi } from 'vitest'
|
|
2
|
+
import { render, within } from '@testing-library/react'
|
|
3
|
+
import userEvent from '@testing-library/user-event'
|
|
4
|
+
import { ListDataUI } from './list-data'
|
|
5
|
+
|
|
6
|
+
describe('ListDataUI', () => {
|
|
7
|
+
const data = [
|
|
8
|
+
{ id: '1', label: 'Population', value: '8.4M' },
|
|
9
|
+
{ id: '2', label: 'Median Age', value: '32 years' },
|
|
10
|
+
{ id: '3', label: 'GDP', value: '$1.2T' },
|
|
11
|
+
{ id: '4', label: 'Life Expectancy', value: '78.5 years' },
|
|
12
|
+
{ id: '5', label: 'Population Density', value: '345/km²' },
|
|
13
|
+
]
|
|
14
|
+
|
|
15
|
+
test('renders correctly', () => {
|
|
16
|
+
const { container } = render(<ListDataUI data={data} />)
|
|
17
|
+
|
|
18
|
+
const rows = within(container).getAllByRole('listitem')
|
|
19
|
+
expect(rows).toHaveLength(5)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
test('renders skeleton when loading', () => {
|
|
23
|
+
const { getByLabelText } = render(<ListDataUI data={data} isLoading />)
|
|
24
|
+
expect(getByLabelText('List Data skeleton')).toBeTruthy()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('with maxItems', async () => {
|
|
28
|
+
const { container } = render(<ListDataUI data={data} maxItems={3} />)
|
|
29
|
+
|
|
30
|
+
const rows = within(container).getAllByRole('listitem')
|
|
31
|
+
expect(rows).toHaveLength(3)
|
|
32
|
+
|
|
33
|
+
const showMoreButton = within(container).getByText('Show More')
|
|
34
|
+
expect(showMoreButton).toBeTruthy()
|
|
35
|
+
await userEvent.click(showMoreButton)
|
|
36
|
+
|
|
37
|
+
const updatedRows = within(container).getAllByRole('listitem')
|
|
38
|
+
expect(updatedRows).toHaveLength(5)
|
|
39
|
+
|
|
40
|
+
const showLessButton = within(container).getByText('Show Less')
|
|
41
|
+
expect(showLessButton).toBeTruthy()
|
|
42
|
+
await userEvent.click(showLessButton)
|
|
43
|
+
|
|
44
|
+
const finalRows = within(container).getAllByRole('listitem')
|
|
45
|
+
expect(finalRows).toHaveLength(3)
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
test('with disabled items', () => {
|
|
49
|
+
const disabledData = data.map((item) => ({ ...item, disabled: true }))
|
|
50
|
+
const { container } = render(<ListDataUI data={disabledData} />)
|
|
51
|
+
|
|
52
|
+
const rows = within(container).getAllByRole('listitem')
|
|
53
|
+
|
|
54
|
+
for (const row of rows) {
|
|
55
|
+
const computedStyle = window.getComputedStyle(row)
|
|
56
|
+
expect(computedStyle.pointerEvents).toBe('none')
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
test('with custom expand button labels', async () => {
|
|
61
|
+
const { container } = render(
|
|
62
|
+
<ListDataUI
|
|
63
|
+
data={data}
|
|
64
|
+
maxItems={3}
|
|
65
|
+
labels={{ showMore: 'More', showLess: 'Less' }}
|
|
66
|
+
/>,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
const moreButton = within(container).getByText('More')
|
|
70
|
+
expect(moreButton).toBeTruthy()
|
|
71
|
+
await userEvent.click(moreButton)
|
|
72
|
+
|
|
73
|
+
const lessButton = within(container).getByText('Less')
|
|
74
|
+
expect(lessButton).toBeTruthy()
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
test('with item click handler', async () => {
|
|
78
|
+
const mockOnItemClick = vi.fn()
|
|
79
|
+
|
|
80
|
+
const { container } = render(
|
|
81
|
+
<ListDataUI data={data} onItemClick={mockOnItemClick} />,
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
const rows = within(container).getAllByRole('listitem')
|
|
85
|
+
|
|
86
|
+
for (const [idx, row] of rows.entries()) {
|
|
87
|
+
await userEvent.click(row)
|
|
88
|
+
|
|
89
|
+
const foundItem = data.find((item) => item.id === data[idx]?.id)
|
|
90
|
+
expect(mockOnItemClick).toHaveBeenCalledWith(foundItem)
|
|
91
|
+
mockOnItemClick.mockClear()
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
})
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useState, useMemo, type JSX } from 'react'
|
|
2
|
+
import { Box, Button, Grid, ListItem, List, ListItemText } from '@mui/material'
|
|
3
|
+
import { ListDataSkeleton } from './list-data-skeleton'
|
|
4
|
+
import { NoDataAlert } from '../no-data-alert/no-data-alert'
|
|
5
|
+
import { useSkeleton } from '../../hooks/use-skeleton'
|
|
6
|
+
import type { ListDataProps } from './types'
|
|
7
|
+
import { styles } from './styles'
|
|
8
|
+
import { SmartTooltip } from '../smart-tooltip/smart-tooltip'
|
|
9
|
+
|
|
10
|
+
const DEFAULT_LABELS = {
|
|
11
|
+
showMore: 'Show More',
|
|
12
|
+
showLess: 'Show Less',
|
|
13
|
+
} as const
|
|
14
|
+
|
|
15
|
+
export function ListDataUI({
|
|
16
|
+
data = [],
|
|
17
|
+
isLoading = false,
|
|
18
|
+
maxItems = 5,
|
|
19
|
+
labels = DEFAULT_LABELS,
|
|
20
|
+
showDivider = true,
|
|
21
|
+
selectedItemId,
|
|
22
|
+
tooltipProps,
|
|
23
|
+
onExpand,
|
|
24
|
+
onItemClick,
|
|
25
|
+
}: ListDataProps): JSX.Element {
|
|
26
|
+
const [showAll, setShowAll] = useState(false)
|
|
27
|
+
|
|
28
|
+
const showSkeleton = useSkeleton(isLoading)
|
|
29
|
+
|
|
30
|
+
const items = useMemo(() => {
|
|
31
|
+
return showAll ? data : data.slice(0, maxItems)
|
|
32
|
+
}, [data, maxItems, showAll])
|
|
33
|
+
|
|
34
|
+
const handleToggle = () => {
|
|
35
|
+
setShowAll(!showAll)
|
|
36
|
+
onExpand?.(showAll)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (showSkeleton) {
|
|
40
|
+
return <ListDataSkeleton length={maxItems} />
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (items.length === 0) {
|
|
44
|
+
return <NoDataAlert />
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<List id='expandable-list' role='list'>
|
|
50
|
+
{items.map((item, idx) => (
|
|
51
|
+
<SmartTooltip<HTMLLIElement>
|
|
52
|
+
// Default tooltip props
|
|
53
|
+
followCursor={false}
|
|
54
|
+
key={`list-item-${idx}`}
|
|
55
|
+
placement='top'
|
|
56
|
+
arrow
|
|
57
|
+
title={item.tooltipTitle}
|
|
58
|
+
enterDelay={10}
|
|
59
|
+
// Custom tooltip props
|
|
60
|
+
{...tooltipProps}
|
|
61
|
+
>
|
|
62
|
+
{({ ref }) => (
|
|
63
|
+
<ListItem
|
|
64
|
+
ref={ref}
|
|
65
|
+
role='listitem'
|
|
66
|
+
sx={{
|
|
67
|
+
...(showDivider && styles.showDivider),
|
|
68
|
+
...(onItemClick && styles.clickable),
|
|
69
|
+
...(selectedItemId === item.id && styles.selected),
|
|
70
|
+
...(item.disabled && styles.disabled),
|
|
71
|
+
}}
|
|
72
|
+
onClick={() => {
|
|
73
|
+
if (item.disabled) return
|
|
74
|
+
onItemClick?.(item)
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
<Grid container alignItems='center'>
|
|
78
|
+
<Grid item xs={8}>
|
|
79
|
+
<ListItemText primary={item.label} sx={styles.label} />
|
|
80
|
+
</Grid>
|
|
81
|
+
<Grid item xs={4}>
|
|
82
|
+
<ListItemText primary={item.value} sx={styles.value} />
|
|
83
|
+
</Grid>
|
|
84
|
+
</Grid>
|
|
85
|
+
</ListItem>
|
|
86
|
+
)}
|
|
87
|
+
</SmartTooltip>
|
|
88
|
+
))}
|
|
89
|
+
</List>
|
|
90
|
+
|
|
91
|
+
{data.length > maxItems && (
|
|
92
|
+
<Box my={2}>
|
|
93
|
+
<Button
|
|
94
|
+
onClick={handleToggle}
|
|
95
|
+
variant='text'
|
|
96
|
+
color='primary'
|
|
97
|
+
aria-expanded={showAll}
|
|
98
|
+
aria-controls='expandable-list'
|
|
99
|
+
>
|
|
100
|
+
{showAll ? labels.showLess : labels.showMore}
|
|
101
|
+
</Button>
|
|
102
|
+
</Box>
|
|
103
|
+
)}
|
|
104
|
+
</>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type SxProps, type Theme } from '@mui/material'
|
|
2
|
+
|
|
3
|
+
const ellipsed = {
|
|
4
|
+
overflow: 'hidden',
|
|
5
|
+
textOverflow: 'ellipsis',
|
|
6
|
+
whiteSpace: 'nowrap',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const styles = {
|
|
10
|
+
label: {
|
|
11
|
+
'& .MuiListItemText-primary': {
|
|
12
|
+
...ellipsed,
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
value: {
|
|
16
|
+
'& .MuiListItemText-primary': {
|
|
17
|
+
...ellipsed,
|
|
18
|
+
textAlign: 'right',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
clickable: {
|
|
22
|
+
cursor: 'pointer',
|
|
23
|
+
'&:hover': {
|
|
24
|
+
backgroundColor: ({ palette }) => palette.action.hover,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
showDivider: {
|
|
28
|
+
borderBottom: ({ palette }) => `1px solid ${palette.divider}`,
|
|
29
|
+
},
|
|
30
|
+
selected: {
|
|
31
|
+
backgroundColor: ({ palette }) => palette.action.selected,
|
|
32
|
+
},
|
|
33
|
+
disabled: {
|
|
34
|
+
opacity: 0.5,
|
|
35
|
+
pointerEvents: 'none',
|
|
36
|
+
},
|
|
37
|
+
} satisfies Record<string, SxProps<Theme>>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TooltipProps } from '@mui/material'
|
|
2
|
+
import type { ReactElement } from 'react'
|
|
3
|
+
|
|
4
|
+
export interface DataItem {
|
|
5
|
+
id: string | number
|
|
6
|
+
label: string | ReactElement
|
|
7
|
+
value: string | ReactElement
|
|
8
|
+
disabled?: boolean
|
|
9
|
+
tooltipTitle?: string
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ListDataProps {
|
|
13
|
+
data: DataItem[]
|
|
14
|
+
isLoading?: boolean
|
|
15
|
+
maxItems?: number
|
|
16
|
+
labels?: {
|
|
17
|
+
showMore: string
|
|
18
|
+
showLess: string
|
|
19
|
+
}
|
|
20
|
+
showDivider?: boolean
|
|
21
|
+
selectedItemId?: string | number
|
|
22
|
+
tooltipProps?: Omit<TooltipProps, 'title' | 'children'>
|
|
23
|
+
onExpand?: (isExpanded: boolean) => void
|
|
24
|
+
onItemClick?: (item: DataItem) => void
|
|
25
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import type { RequiredDeep } from 'type-fest'
|
|
2
|
+
import type {
|
|
3
|
+
MeasurementMode,
|
|
4
|
+
MeasurementModesMapping,
|
|
5
|
+
MeasurementUnitsMapping,
|
|
6
|
+
} from '../types'
|
|
7
|
+
import type { MeasurementToolsComponentProps } from './types'
|
|
8
|
+
import { RulerIcon, BufferIcon, AreaIcon } from './icons'
|
|
9
|
+
|
|
10
|
+
export const DEFAULT_MEASUREMENT_TOOLS_LABELS: NonNullable<
|
|
11
|
+
RequiredDeep<MeasurementToolsComponentProps['labels']>
|
|
12
|
+
> = {
|
|
13
|
+
action: {
|
|
14
|
+
tooltip: {
|
|
15
|
+
active: 'Click on the map to start measuring',
|
|
16
|
+
inactive: 'Click on the map to start measuring',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
chip: {
|
|
20
|
+
tooltip: {
|
|
21
|
+
active: 'Hide measure',
|
|
22
|
+
inactive: 'Show measure',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
options: {
|
|
26
|
+
mode: {
|
|
27
|
+
title: 'Choose a measuring tool',
|
|
28
|
+
options: {
|
|
29
|
+
distance: 'Measure distance',
|
|
30
|
+
buffer: 'Buffer distance',
|
|
31
|
+
area: 'Area',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
units: {
|
|
35
|
+
title: 'Unit of measurement',
|
|
36
|
+
modal: {
|
|
37
|
+
title: 'Map Measurement Unit',
|
|
38
|
+
subtitle: 'Select the unit of measurement for your measurements',
|
|
39
|
+
apply: 'Save',
|
|
40
|
+
options: {
|
|
41
|
+
metric: {
|
|
42
|
+
title: 'Meters and Kilometers',
|
|
43
|
+
options: {
|
|
44
|
+
'm-km': 'Auto',
|
|
45
|
+
kilometer: 'Kilometers',
|
|
46
|
+
meter: 'Meter',
|
|
47
|
+
centimeter: 'Centimeter',
|
|
48
|
+
milimeter: 'Milimeter',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
imperial: {
|
|
52
|
+
title: 'Feet and Miles',
|
|
53
|
+
options: {
|
|
54
|
+
'ft-mi': 'Auto',
|
|
55
|
+
mile: 'Mile',
|
|
56
|
+
feet: 'Feet',
|
|
57
|
+
yard: 'Yard',
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
} as const
|
|
65
|
+
|
|
66
|
+
export const DEFAULT_MEASUREMENT_TOOLS_UNITS_MAPPING: MeasurementUnitsMapping =
|
|
67
|
+
{
|
|
68
|
+
'm-km': {
|
|
69
|
+
short: 'm-km',
|
|
70
|
+
},
|
|
71
|
+
kilometer: {
|
|
72
|
+
short: 'km',
|
|
73
|
+
},
|
|
74
|
+
meter: {
|
|
75
|
+
short: 'm',
|
|
76
|
+
},
|
|
77
|
+
centimeter: {
|
|
78
|
+
short: 'cm',
|
|
79
|
+
},
|
|
80
|
+
milimeter: {
|
|
81
|
+
short: 'mm',
|
|
82
|
+
},
|
|
83
|
+
'ft-mi': {
|
|
84
|
+
short: 'ft-mi',
|
|
85
|
+
},
|
|
86
|
+
mile: {
|
|
87
|
+
short: 'mi',
|
|
88
|
+
},
|
|
89
|
+
yard: {
|
|
90
|
+
short: 'yd',
|
|
91
|
+
},
|
|
92
|
+
feet: {
|
|
93
|
+
short: 'ft',
|
|
94
|
+
},
|
|
95
|
+
} as const
|
|
96
|
+
|
|
97
|
+
export const DEFAULT_MEASUREMENT_TOOLS_MODES_MAPPING: MeasurementModesMapping<MeasurementMode> =
|
|
98
|
+
{
|
|
99
|
+
distance: {
|
|
100
|
+
icon: <RulerIcon />,
|
|
101
|
+
},
|
|
102
|
+
buffer: {
|
|
103
|
+
icon: <BufferIcon />,
|
|
104
|
+
},
|
|
105
|
+
area: {
|
|
106
|
+
icon: <AreaIcon />,
|
|
107
|
+
},
|
|
108
|
+
} as const
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { SVGProps } from 'react'
|
|
2
|
+
|
|
3
|
+
export function RulerIcon(props: SVGProps<SVGSVGElement>) {
|
|
4
|
+
return (
|
|
5
|
+
<svg
|
|
6
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
7
|
+
viewBox='0 0 18 18'
|
|
8
|
+
fill='currentColor'
|
|
9
|
+
{...props}
|
|
10
|
+
>
|
|
11
|
+
<path
|
|
12
|
+
fill='currentColor'
|
|
13
|
+
d='M3 13.5c-.413 0-.766-.147-1.06-.44A1.445 1.445 0 0 1 1.5 12V6c0-.412.147-.766.44-1.06.294-.293.647-.44 1.06-.44h12c.412 0 .766.147 1.06.44.293.294.44.647.44 1.06v6c0 .412-.147.766-.44 1.06-.294.293-.647.44-1.06.44H3ZM3 12h12V6h-2.25v3h-1.5V6h-1.5v3h-1.5V6h-1.5v3h-1.5V6H3v6Z'
|
|
14
|
+
/>
|
|
15
|
+
</svg>
|
|
16
|
+
)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function BufferIcon(props: SVGProps<SVGSVGElement>) {
|
|
20
|
+
return (
|
|
21
|
+
<svg
|
|
22
|
+
fill='none'
|
|
23
|
+
xmlns='http://www.w3.org/2000/svg'
|
|
24
|
+
viewBox='0 0 18 18'
|
|
25
|
+
{...props}
|
|
26
|
+
>
|
|
27
|
+
<path
|
|
28
|
+
fill='currentColor'
|
|
29
|
+
fillRule='evenodd'
|
|
30
|
+
d='M9 1.5a7.5 7.5 0 1 1 0 15 7.5 7.5 0 0 1 0-15ZM9 3a6 6 0 1 0 0 12A6 6 0 0 0 9 3Zm0 4.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3Z'
|
|
31
|
+
clipRule='evenodd'
|
|
32
|
+
/>
|
|
33
|
+
</svg>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function AreaIcon(props: SVGProps<SVGSVGElement>) {
|
|
38
|
+
return (
|
|
39
|
+
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 18 18' {...props}>
|
|
40
|
+
<path
|
|
41
|
+
fill='currentColor'
|
|
42
|
+
fillRule='evenodd'
|
|
43
|
+
d='M4.5 13.5v-9h9v9h-9Zm.75-8.25h7.5v7.5h-7.5v-7.5Z'
|
|
44
|
+
clipRule='evenodd'
|
|
45
|
+
/>
|
|
46
|
+
<path
|
|
47
|
+
fill='#2C3032'
|
|
48
|
+
fillRule='evenodd'
|
|
49
|
+
d='M1.5 3A1.5 1.5 0 0 1 3 1.5h12A1.5 1.5 0 0 1 16.5 3v12a1.5 1.5 0 0 1-1.5 1.5H3A1.5 1.5 0 0 1 1.5 15V3ZM3 3h12v12H3V3Z'
|
|
50
|
+
clipRule='evenodd'
|
|
51
|
+
/>
|
|
52
|
+
</svg>
|
|
53
|
+
)
|
|
54
|
+
}
|