@spatika/react 1.1.0 → 1.2.0
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/AGENTS.md +71 -0
- package/README.md +4 -3
- package/dist/composites/Card.d.ts +7 -1
- package/dist/composites/Card.d.ts.map +1 -1
- package/dist/composites/Card.js +10 -0
- package/dist/composites/ChartDataGrid.d.ts +33 -0
- package/dist/composites/ChartDataGrid.d.ts.map +1 -0
- package/dist/composites/ChartDataGrid.js +77 -0
- package/dist/composites/CoverHero.d.ts +1 -1
- package/dist/composites/CoverHero.d.ts.map +1 -1
- package/dist/composites/CoverHero.js +2 -2
- package/dist/composites/EntityMediaCard.d.ts +1 -1
- package/dist/composites/EntityMediaCard.d.ts.map +1 -1
- package/dist/composites/EntityMediaCard.js +12 -4
- package/dist/composites/EventCalendar.d.ts +35 -0
- package/dist/composites/EventCalendar.d.ts.map +1 -0
- package/dist/composites/EventCalendar.js +339 -0
- package/dist/composites/EventEditor.d.ts +22 -0
- package/dist/composites/EventEditor.d.ts.map +1 -0
- package/dist/composites/EventEditor.js +86 -0
- package/dist/composites/EventTimeline.d.ts +24 -0
- package/dist/composites/EventTimeline.d.ts.map +1 -0
- package/dist/composites/EventTimeline.js +184 -0
- package/dist/composites/MapChart.d.ts +24 -0
- package/dist/composites/MapChart.d.ts.map +1 -0
- package/dist/composites/MapChart.js +58 -0
- package/dist/composites/ProfileHero.d.ts +6 -4
- package/dist/composites/ProfileHero.d.ts.map +1 -1
- package/dist/composites/ProfileHero.js +8 -8
- package/dist/composites/ScatterWebGL.d.ts +22 -0
- package/dist/composites/ScatterWebGL.d.ts.map +1 -0
- package/dist/composites/ScatterWebGL.js +45 -0
- package/dist/composites/SiteFooter.d.ts +1 -1
- package/dist/composites/SiteFooter.js +1 -1
- package/dist/composites/SiteNav.d.ts +7 -2
- package/dist/composites/SiteNav.d.ts.map +1 -1
- package/dist/composites/SiteNav.js +9 -5
- package/dist/composites/StatCard.d.ts +2 -1
- package/dist/composites/StatCard.d.ts.map +1 -1
- package/dist/composites/StatCard.js +3 -3
- package/dist/composites/StatusDot.d.ts +1 -1
- package/dist/composites/Wordmark.d.ts +2 -2
- package/dist/composites/Wordmark.d.ts.map +1 -1
- package/dist/composites/cartesian-charts.d.ts +138 -0
- package/dist/composites/cartesian-charts.d.ts.map +1 -0
- package/dist/composites/cartesian-charts.js +401 -0
- package/dist/composites/chart-composition.d.ts +139 -0
- package/dist/composites/chart-composition.d.ts.map +1 -0
- package/dist/composites/chart-composition.js +486 -0
- package/dist/composites/chart-ui.d.ts +83 -0
- package/dist/composites/chart-ui.d.ts.map +1 -0
- package/dist/composites/chart-ui.js +108 -0
- package/dist/composites/charts-3d.d.ts +37 -0
- package/dist/composites/charts-3d.d.ts.map +1 -0
- package/dist/composites/charts-3d.js +121 -0
- package/dist/composites/flow-charts.d.ts +89 -0
- package/dist/composites/flow-charts.d.ts.map +1 -0
- package/dist/composites/flow-charts.js +186 -0
- package/dist/composites/radial-charts.d.ts +109 -0
- package/dist/composites/radial-charts.d.ts.map +1 -0
- package/dist/composites/radial-charts.js +176 -0
- package/dist/composites/scheduler-ui.d.ts +43 -0
- package/dist/composites/scheduler-ui.d.ts.map +1 -0
- package/dist/composites/scheduler-ui.js +71 -0
- package/dist/index.d.ts +67 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +57 -7
- package/dist/lib/chart-export.d.ts +10 -0
- package/dist/lib/chart-export.d.ts.map +1 -0
- package/dist/lib/chart-export.js +102 -0
- package/dist/lib/charts.d.ts +235 -0
- package/dist/lib/charts.d.ts.map +1 -0
- package/dist/lib/charts.js +744 -0
- package/dist/lib/geo.d.ts +39 -0
- package/dist/lib/geo.d.ts.map +1 -0
- package/dist/lib/geo.js +101 -0
- package/dist/lib/iso.d.ts +21 -0
- package/dist/lib/iso.d.ts.map +1 -0
- package/dist/lib/iso.js +56 -0
- package/dist/lib/rrule.d.ts +20 -0
- package/dist/lib/rrule.d.ts.map +1 -0
- package/dist/lib/rrule.js +236 -0
- package/dist/lib/scheduler.d.ts +152 -0
- package/dist/lib/scheduler.d.ts.map +1 -0
- package/dist/lib/scheduler.js +501 -0
- package/dist/lib/webgl-scatter.d.ts +44 -0
- package/dist/lib/webgl-scatter.d.ts.map +1 -0
- package/dist/lib/webgl-scatter.js +185 -0
- package/dist/primitives/Accordion.d.ts +44 -20
- package/dist/primitives/Accordion.d.ts.map +1 -1
- package/dist/primitives/Accordion.js +82 -22
- package/dist/primitives/AppBar.d.ts +13 -0
- package/dist/primitives/AppBar.d.ts.map +1 -0
- package/dist/primitives/AppBar.js +27 -0
- package/dist/primitives/Autocomplete.d.ts +28 -0
- package/dist/primitives/Autocomplete.d.ts.map +1 -0
- package/dist/primitives/Autocomplete.js +118 -0
- package/dist/primitives/Avatar.d.ts +13 -1
- package/dist/primitives/Avatar.d.ts.map +1 -1
- package/dist/primitives/Avatar.js +17 -2
- package/dist/primitives/Backdrop.d.ts +17 -0
- package/dist/primitives/Backdrop.d.ts.map +1 -0
- package/dist/primitives/Backdrop.js +17 -0
- package/dist/primitives/BottomNavigation.d.ts +23 -0
- package/dist/primitives/BottomNavigation.d.ts.map +1 -0
- package/dist/primitives/BottomNavigation.js +30 -0
- package/dist/primitives/ButtonBase.d.ts +14 -0
- package/dist/primitives/ButtonBase.d.ts.map +1 -0
- package/dist/primitives/ButtonBase.js +13 -0
- package/dist/primitives/ButtonGroup.d.ts +25 -0
- package/dist/primitives/ButtonGroup.d.ts.map +1 -0
- package/dist/primitives/ButtonGroup.js +44 -0
- package/dist/primitives/CircularProgress.d.ts +16 -0
- package/dist/primitives/CircularProgress.d.ts.map +1 -0
- package/dist/primitives/CircularProgress.js +17 -0
- package/dist/primitives/ClickAwayListener.d.ts +16 -0
- package/dist/primitives/ClickAwayListener.d.ts.map +1 -0
- package/dist/primitives/ClickAwayListener.js +33 -0
- package/dist/primitives/Collapse.d.ts +19 -0
- package/dist/primitives/Collapse.d.ts.map +1 -0
- package/dist/primitives/Collapse.js +14 -0
- package/dist/primitives/Container.d.ts +13 -0
- package/dist/primitives/Container.d.ts.map +1 -0
- package/dist/primitives/Container.js +26 -0
- package/dist/primitives/Fab.d.ts +22 -0
- package/dist/primitives/Fab.d.ts.map +1 -0
- package/dist/primitives/Fab.js +42 -0
- package/dist/primitives/FormControl.d.ts +27 -0
- package/dist/primitives/FormControl.d.ts.map +1 -0
- package/dist/primitives/FormControl.js +24 -0
- package/dist/primitives/FormControlLabel.d.ts +18 -0
- package/dist/primitives/FormControlLabel.d.ts.map +1 -0
- package/dist/primitives/FormControlLabel.js +19 -0
- package/dist/primitives/Grid.d.ts +32 -0
- package/dist/primitives/Grid.d.ts.map +1 -0
- package/dist/primitives/Grid.js +50 -0
- package/dist/primitives/IconButton.d.ts +22 -0
- package/dist/primitives/IconButton.d.ts.map +1 -0
- package/dist/primitives/IconButton.js +39 -0
- package/dist/primitives/ImageList.d.ts +31 -0
- package/dist/primitives/ImageList.d.ts.map +1 -0
- package/dist/primitives/ImageList.js +33 -0
- package/dist/primitives/InputAdornment.d.ts +28 -0
- package/dist/primitives/InputAdornment.d.ts.map +1 -0
- package/dist/primitives/InputAdornment.js +13 -0
- package/dist/primitives/Link.d.ts +17 -0
- package/dist/primitives/Link.d.ts.map +1 -0
- package/dist/primitives/Link.js +29 -0
- package/dist/primitives/List.d.ts +41 -0
- package/dist/primitives/List.d.ts.map +1 -0
- package/dist/primitives/List.js +22 -0
- package/dist/primitives/Masonry.d.ts +14 -0
- package/dist/primitives/Masonry.d.ts.map +1 -0
- package/dist/primitives/Masonry.js +15 -0
- package/dist/primitives/Menu.d.ts +28 -0
- package/dist/primitives/Menu.d.ts.map +1 -0
- package/dist/primitives/Menu.js +54 -0
- package/dist/primitives/MobileStepper.d.ts +15 -0
- package/dist/primitives/MobileStepper.d.ts.map +1 -0
- package/dist/primitives/MobileStepper.js +8 -0
- package/dist/primitives/Modal.d.ts +18 -0
- package/dist/primitives/Modal.d.ts.map +1 -0
- package/dist/primitives/Modal.js +29 -0
- package/dist/primitives/NoSsr.d.ts +15 -0
- package/dist/primitives/NoSsr.d.ts.map +1 -0
- package/dist/primitives/NoSsr.js +19 -0
- package/dist/primitives/Paper.d.ts +22 -0
- package/dist/primitives/Paper.d.ts.map +1 -0
- package/dist/primitives/Paper.js +33 -0
- package/dist/primitives/Progress.d.ts +6 -2
- package/dist/primitives/Progress.d.ts.map +1 -1
- package/dist/primitives/Progress.js +8 -3
- package/dist/primitives/Snackbar.d.ts +23 -0
- package/dist/primitives/Snackbar.d.ts.map +1 -0
- package/dist/primitives/Snackbar.js +33 -0
- package/dist/primitives/SpeedDial.d.ts +26 -0
- package/dist/primitives/SpeedDial.d.ts.map +1 -0
- package/dist/primitives/SpeedDial.js +26 -0
- package/dist/primitives/Stack.d.ts +15 -0
- package/dist/primitives/Stack.d.ts.map +1 -0
- package/dist/primitives/Stack.js +45 -0
- package/dist/primitives/StarRating.d.ts +19 -1
- package/dist/primitives/StarRating.d.ts.map +1 -1
- package/dist/primitives/StarRating.js +36 -6
- package/dist/primitives/Stepper.d.ts +36 -0
- package/dist/primitives/Stepper.d.ts.map +1 -0
- package/dist/primitives/Stepper.js +53 -0
- package/dist/primitives/TablePagination.d.ts +16 -0
- package/dist/primitives/TablePagination.d.ts.map +1 -0
- package/dist/primitives/TablePagination.js +12 -0
- package/dist/primitives/TextField.d.ts +24 -0
- package/dist/primitives/TextField.d.ts.map +1 -0
- package/dist/primitives/TextField.js +19 -0
- package/dist/primitives/TextareaAutosize.d.ts +11 -0
- package/dist/primitives/TextareaAutosize.d.ts.map +1 -0
- package/dist/primitives/TextareaAutosize.js +26 -0
- package/dist/primitives/ToggleButton.d.ts +28 -0
- package/dist/primitives/ToggleButton.d.ts.map +1 -0
- package/dist/primitives/ToggleButton.js +56 -0
- package/dist/primitives/TransferList.d.ts +21 -0
- package/dist/primitives/TransferList.d.ts.map +1 -0
- package/dist/primitives/TransferList.js +40 -0
- package/dist/primitives/Typography.d.ts +23 -0
- package/dist/primitives/Typography.d.ts.map +1 -0
- package/dist/primitives/Typography.js +69 -0
- package/dist/primitives/transitions.d.ts +29 -0
- package/dist/primitives/transitions.d.ts.map +1 -0
- package/dist/primitives/transitions.js +52 -0
- package/package.json +28 -4
- package/skills/spatika-ui/SKILL.md +96 -0
- package/src/composites/Card.tsx +51 -1
- package/src/composites/ChartDataGrid.test.tsx +57 -0
- package/src/composites/ChartDataGrid.tsx +196 -0
- package/src/composites/CoverHero.test.tsx +38 -0
- package/src/composites/CoverHero.tsx +29 -22
- package/src/composites/EntityMediaCard.test.tsx +58 -0
- package/src/composites/EntityMediaCard.tsx +31 -13
- package/src/composites/EventCalendar.tsx +928 -0
- package/src/composites/EventEditor.tsx +268 -0
- package/src/composites/EventTimeline.tsx +357 -0
- package/src/composites/MapChart.test.tsx +39 -0
- package/src/composites/MapChart.tsx +130 -0
- package/src/composites/ProfileHero.test.tsx +33 -0
- package/src/composites/ProfileHero.tsx +96 -79
- package/src/composites/ScatterWebGL.test.tsx +25 -0
- package/src/composites/ScatterWebGL.tsx +79 -0
- package/src/composites/SiteFooter.test.tsx +37 -0
- package/src/composites/SiteFooter.tsx +1 -1
- package/src/composites/SiteNav.test.tsx +46 -0
- package/src/composites/SiteNav.tsx +14 -4
- package/src/composites/StatCard.test.tsx +30 -0
- package/src/composites/StatCard.tsx +4 -0
- package/src/composites/Wordmark.test.tsx +23 -0
- package/src/composites/Wordmark.tsx +2 -2
- package/src/composites/cartesian-charts.test.tsx +52 -0
- package/src/composites/cartesian-charts.tsx +1287 -0
- package/src/composites/chart-composition.test.tsx +53 -0
- package/src/composites/chart-composition.tsx +898 -0
- package/src/composites/chart-ui.tsx +328 -0
- package/src/composites/charts-3d.test.tsx +25 -0
- package/src/composites/charts-3d.tsx +318 -0
- package/src/composites/charts.test.tsx +254 -0
- package/src/composites/chrome.test.tsx +29 -0
- package/src/composites/flow-charts.test.tsx +79 -0
- package/src/composites/flow-charts.tsx +607 -0
- package/src/composites/marketing.test.tsx +38 -34
- package/src/composites/radial-charts.test.tsx +74 -0
- package/src/composites/radial-charts.tsx +617 -0
- package/src/composites/scheduler-ui.tsx +304 -0
- package/src/composites/scheduler.test.tsx +194 -0
- package/src/index.test.ts +22 -0
- package/src/index.ts +277 -5
- package/src/lib/chart-export.test.ts +20 -0
- package/src/lib/chart-export.ts +99 -0
- package/src/lib/charts-platform.test.ts +93 -0
- package/src/lib/charts.test.ts +132 -0
- package/src/lib/charts.ts +1021 -0
- package/src/lib/geo.test.ts +42 -0
- package/src/lib/geo.ts +138 -0
- package/src/lib/iso.test.ts +22 -0
- package/src/lib/iso.ts +102 -0
- package/src/lib/rrule.test.ts +53 -0
- package/src/lib/rrule.ts +281 -0
- package/src/lib/scheduler.test.ts +186 -0
- package/src/lib/scheduler.ts +688 -0
- package/src/lib/tokens.test.ts +2 -2
- package/src/lib/webgl-scatter.test.ts +36 -0
- package/src/lib/webgl-scatter.ts +230 -0
- package/src/primitives/Accordion.tsx +218 -63
- package/src/primitives/AppBar.tsx +39 -0
- package/src/primitives/Autocomplete.tsx +236 -0
- package/src/primitives/Avatar.tsx +52 -1
- package/src/primitives/Backdrop.tsx +48 -0
- package/src/primitives/BottomNavigation.tsx +102 -0
- package/src/primitives/ButtonBase.tsx +34 -0
- package/src/primitives/ButtonGroup.tsx +90 -0
- package/src/primitives/CircularProgress.tsx +104 -0
- package/src/primitives/ClickAwayListener.tsx +46 -0
- package/src/primitives/Collapse.tsx +39 -0
- package/src/primitives/Container.tsx +40 -0
- package/src/primitives/Fab.tsx +62 -0
- package/src/primitives/FormControl.tsx +90 -0
- package/src/primitives/FormControlLabel.tsx +51 -0
- package/src/primitives/Grid.tsx +101 -0
- package/src/primitives/IconButton.tsx +59 -0
- package/src/primitives/ImageList.test.tsx +48 -0
- package/src/primitives/ImageList.tsx +112 -0
- package/src/primitives/InputAdornment.tsx +86 -0
- package/src/primitives/Link.tsx +48 -0
- package/src/primitives/List.tsx +121 -0
- package/src/primitives/Masonry.tsx +32 -0
- package/src/primitives/Menu.tsx +112 -0
- package/src/primitives/MobileStepper.tsx +64 -0
- package/src/primitives/Modal.tsx +70 -0
- package/src/primitives/NoSsr.tsx +28 -0
- package/src/primitives/Paper.tsx +55 -0
- package/src/primitives/Progress.tsx +25 -7
- package/src/primitives/Snackbar.tsx +83 -0
- package/src/primitives/SpeedDial.tsx +110 -0
- package/src/primitives/Stack.tsx +88 -0
- package/src/primitives/StarRating.tsx +87 -28
- package/src/primitives/Stepper.tsx +184 -0
- package/src/primitives/TablePagination.tsx +58 -0
- package/src/primitives/TextField.tsx +105 -0
- package/src/primitives/TextareaAutosize.tsx +49 -0
- package/src/primitives/ToggleButton.tsx +148 -0
- package/src/primitives/TransferList.tsx +110 -0
- package/src/primitives/Typography.tsx +90 -0
- package/src/primitives/mui-more.test.tsx +76 -0
- package/src/primitives/mui.test.tsx +134 -0
- package/src/primitives/transitions.tsx +120 -0
package/src/index.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* import "@spatika/tokens/styles.css";
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
export {
|
|
10
|
+
export { Portal, type PortalProps } from "./lib/portal";
|
|
11
11
|
export {
|
|
12
12
|
OVERLAY_Z_INDEX,
|
|
13
13
|
fixedLayerStyle,
|
|
@@ -90,14 +90,113 @@ export { Badge, badgeVariants } from "./primitives/Badge";
|
|
|
90
90
|
export { Input } from "./primitives/Input";
|
|
91
91
|
export { Textarea } from "./primitives/Textarea";
|
|
92
92
|
export { Label } from "./primitives/Label";
|
|
93
|
-
export { Separator } from "./primitives/Separator";
|
|
93
|
+
export { Separator, Separator as Divider } from "./primitives/Separator";
|
|
94
94
|
export { Skeleton } from "./primitives/Skeleton";
|
|
95
95
|
export { Checkbox } from "./primitives/Checkbox";
|
|
96
96
|
export { Switch } from "./primitives/Switch";
|
|
97
97
|
export { RadioGroup, RadioGroupItem } from "./primitives/RadioGroup";
|
|
98
|
-
export { Progress } from "./primitives/Progress";
|
|
98
|
+
export { Progress, LinearProgress, type ProgressProps } from "./primitives/Progress";
|
|
99
|
+
export { CircularProgress, type CircularProgressProps } from "./primitives/CircularProgress";
|
|
99
100
|
export { Slider } from "./primitives/Slider";
|
|
100
|
-
export {
|
|
101
|
+
export {
|
|
102
|
+
Avatar,
|
|
103
|
+
AvatarImage,
|
|
104
|
+
AvatarFallback,
|
|
105
|
+
InitialsAvatar,
|
|
106
|
+
AvatarGroup,
|
|
107
|
+
type AvatarGroupProps,
|
|
108
|
+
} from "./primitives/Avatar";
|
|
109
|
+
export { ButtonGroup, buttonGroupVariants, type ButtonGroupProps } from "./primitives/ButtonGroup";
|
|
110
|
+
export { Fab, fabVariants, type FabProps } from "./primitives/Fab";
|
|
111
|
+
export { IconButton, iconButtonVariants, type IconButtonProps } from "./primitives/IconButton";
|
|
112
|
+
export { Link, linkVariants, type LinkProps } from "./primitives/Link";
|
|
113
|
+
export { Backdrop, type BackdropProps } from "./primitives/Backdrop";
|
|
114
|
+
export { Collapse, type CollapseProps } from "./primitives/Collapse";
|
|
115
|
+
export { ClickAwayListener, type ClickAwayListenerProps } from "./primitives/ClickAwayListener";
|
|
116
|
+
export { Typography, typographyVariants, type TypographyProps } from "./primitives/Typography";
|
|
117
|
+
export { Paper, paperVariants, type PaperProps } from "./primitives/Paper";
|
|
118
|
+
export { Stack, type StackProps } from "./primitives/Stack";
|
|
119
|
+
export { Container, containerVariants, type ContainerProps } from "./primitives/Container";
|
|
120
|
+
export {
|
|
121
|
+
List,
|
|
122
|
+
ListItem,
|
|
123
|
+
ListItemButton,
|
|
124
|
+
ListItemIcon,
|
|
125
|
+
ListItemText,
|
|
126
|
+
ListSubheader,
|
|
127
|
+
type ListProps,
|
|
128
|
+
type ListItemProps,
|
|
129
|
+
type ListItemButtonProps,
|
|
130
|
+
type ListItemTextProps,
|
|
131
|
+
} from "./primitives/List";
|
|
132
|
+
export {
|
|
133
|
+
Stepper,
|
|
134
|
+
Step,
|
|
135
|
+
StepLabel,
|
|
136
|
+
StepContent,
|
|
137
|
+
StepConnector,
|
|
138
|
+
type StepperProps,
|
|
139
|
+
type StepProps,
|
|
140
|
+
type StepLabelProps,
|
|
141
|
+
} from "./primitives/Stepper";
|
|
142
|
+
export {
|
|
143
|
+
ToggleButton,
|
|
144
|
+
ToggleButtonGroup,
|
|
145
|
+
toggleButtonVariants,
|
|
146
|
+
type ToggleButtonProps,
|
|
147
|
+
type ToggleButtonGroupProps,
|
|
148
|
+
} from "./primitives/ToggleButton";
|
|
149
|
+
export { TextField, type TextFieldProps } from "./primitives/TextField";
|
|
150
|
+
export { Autocomplete, type AutocompleteProps, type AutocompleteOption } from "./primitives/Autocomplete";
|
|
151
|
+
export { FormControlLabel, type FormControlLabelProps } from "./primitives/FormControlLabel";
|
|
152
|
+
export {
|
|
153
|
+
FormControl,
|
|
154
|
+
FormLabel,
|
|
155
|
+
FormHelperText,
|
|
156
|
+
FormGroup,
|
|
157
|
+
type FormControlProps,
|
|
158
|
+
} from "./primitives/FormControl";
|
|
159
|
+
export {
|
|
160
|
+
InputAdornment,
|
|
161
|
+
OutlinedInput,
|
|
162
|
+
FilledInput,
|
|
163
|
+
type InputAdornmentProps,
|
|
164
|
+
type OutlinedInputProps,
|
|
165
|
+
} from "./primitives/InputAdornment";
|
|
166
|
+
export { Box, Grid, type BoxProps, type GridProps } from "./primitives/Grid";
|
|
167
|
+
export {
|
|
168
|
+
ImageList,
|
|
169
|
+
ImageListItem,
|
|
170
|
+
ImageListItemBar,
|
|
171
|
+
type ImageListProps,
|
|
172
|
+
type ImageListItemProps,
|
|
173
|
+
type ImageListItemBarProps,
|
|
174
|
+
} from "./primitives/ImageList";
|
|
175
|
+
export { Rating, StarRating, type RatingProps } from "./primitives/StarRating";
|
|
176
|
+
export { Snackbar, SnackbarContent, type SnackbarProps } from "./primitives/Snackbar";
|
|
177
|
+
export { MobileStepper, type MobileStepperProps } from "./primitives/MobileStepper";
|
|
178
|
+
export { Modal, type ModalProps } from "./primitives/Modal";
|
|
179
|
+
export { Fade, Grow, Slide, Zoom, type TransitionProps, type SlideProps } from "./primitives/transitions";
|
|
180
|
+
export { AppBar, appBarVariants, type AppBarProps } from "./primitives/AppBar";
|
|
181
|
+
export {
|
|
182
|
+
BottomNavigation,
|
|
183
|
+
BottomNavigationAction,
|
|
184
|
+
type BottomNavigationProps,
|
|
185
|
+
type BottomNavigationActionProps,
|
|
186
|
+
} from "./primitives/BottomNavigation";
|
|
187
|
+
export { Masonry, type MasonryProps } from "./primitives/Masonry";
|
|
188
|
+
export { Menu, MenuList, MenuItem, MenuAnchor, type MenuProps, type MenuItemProps } from "./primitives/Menu";
|
|
189
|
+
export { TransferList, type TransferListProps } from "./primitives/TransferList";
|
|
190
|
+
export { ButtonBase, type ButtonBaseProps } from "./primitives/ButtonBase";
|
|
191
|
+
export { NoSsr, type NoSsrProps } from "./primitives/NoSsr";
|
|
192
|
+
export { TextareaAutosize, type TextareaAutosizeProps } from "./primitives/TextareaAutosize";
|
|
193
|
+
export { TablePagination, type TablePaginationProps } from "./primitives/TablePagination";
|
|
194
|
+
export {
|
|
195
|
+
SpeedDial,
|
|
196
|
+
SpeedDialAction,
|
|
197
|
+
type SpeedDialProps,
|
|
198
|
+
type SpeedDialActionProps,
|
|
199
|
+
} from "./primitives/SpeedDial";
|
|
101
200
|
export {
|
|
102
201
|
Select,
|
|
103
202
|
SelectContent,
|
|
@@ -186,8 +285,14 @@ export {
|
|
|
186
285
|
AccordionItem,
|
|
187
286
|
AccordionTrigger,
|
|
188
287
|
AccordionContent,
|
|
288
|
+
AccordionActions,
|
|
289
|
+
AccordionSummary,
|
|
290
|
+
AccordionDetails,
|
|
291
|
+
type AccordionProps,
|
|
292
|
+
type AccordionItemProps,
|
|
293
|
+
type AccordionTriggerProps,
|
|
294
|
+
type AccordionContentProps,
|
|
189
295
|
} from "./primitives/Accordion";
|
|
190
|
-
export { StarRating } from "./primitives/StarRating";
|
|
191
296
|
|
|
192
297
|
export { GlassCard, glassCardVariants, type GlassCardProps } from "./composites/GlassCard";
|
|
193
298
|
export { SurfaceCard, surfaceCardVariants, type SurfaceCardProps } from "./composites/SurfaceCard";
|
|
@@ -243,6 +348,8 @@ export {
|
|
|
243
348
|
CardDescription,
|
|
244
349
|
CardContent,
|
|
245
350
|
CardFooter,
|
|
351
|
+
CardActionArea,
|
|
352
|
+
CardMedia,
|
|
246
353
|
type CardProps,
|
|
247
354
|
} from "./composites/Card";
|
|
248
355
|
export { AppHeader, type AppHeaderProps } from "./composites/AppHeader";
|
|
@@ -376,3 +483,168 @@ export {
|
|
|
376
483
|
DataTableToolbar,
|
|
377
484
|
type DataTableToolbarProps,
|
|
378
485
|
} from "./composites/DataTableToolbar";
|
|
486
|
+
export {
|
|
487
|
+
EventCalendar,
|
|
488
|
+
type EventCalendarProps,
|
|
489
|
+
} from "./composites/EventCalendar";
|
|
490
|
+
export {
|
|
491
|
+
EventTimeline,
|
|
492
|
+
type EventTimelineProps,
|
|
493
|
+
} from "./composites/EventTimeline";
|
|
494
|
+
export {
|
|
495
|
+
EventEditor,
|
|
496
|
+
type EventEditorDraft,
|
|
497
|
+
} from "./composites/EventEditor";
|
|
498
|
+
export {
|
|
499
|
+
DEFAULT_SCHEDULER_PREFERENCES,
|
|
500
|
+
SCHEDULER_COLOR_TONES,
|
|
501
|
+
} from "./lib/scheduler";
|
|
502
|
+
export type {
|
|
503
|
+
CalendarView,
|
|
504
|
+
SchedulerColorTone,
|
|
505
|
+
SchedulerEvent,
|
|
506
|
+
SchedulerPreferences,
|
|
507
|
+
SchedulerResource,
|
|
508
|
+
TimelineScale,
|
|
509
|
+
} from "./lib/scheduler";
|
|
510
|
+
export {
|
|
511
|
+
CHART_COLOR_VARS,
|
|
512
|
+
chartColor,
|
|
513
|
+
formatChartNumber,
|
|
514
|
+
seriesDataFromDataset,
|
|
515
|
+
axisDataFromDataset,
|
|
516
|
+
clampZoom,
|
|
517
|
+
DEFAULT_ZOOM,
|
|
518
|
+
} from "./lib/charts";
|
|
519
|
+
export type {
|
|
520
|
+
ChartAxisConfig,
|
|
521
|
+
ChartCurve,
|
|
522
|
+
ChartDataset,
|
|
523
|
+
ChartInteraction,
|
|
524
|
+
ChartMargin,
|
|
525
|
+
ChartZoom,
|
|
526
|
+
HighlightScope,
|
|
527
|
+
SankeyLink,
|
|
528
|
+
SankeyNode,
|
|
529
|
+
TreeNode,
|
|
530
|
+
} from "./lib/charts";
|
|
531
|
+
export { serializeChartSvg, exportChart, downloadChartSvg, downloadChartPng } from "./lib/chart-export";
|
|
532
|
+
export {
|
|
533
|
+
ChartContainer,
|
|
534
|
+
ChartSurface,
|
|
535
|
+
ChartsGrid,
|
|
536
|
+
ChartsXAxis,
|
|
537
|
+
ChartsYAxis,
|
|
538
|
+
ChartsLegend,
|
|
539
|
+
ChartsToolbar,
|
|
540
|
+
ChartsBrush,
|
|
541
|
+
BarPlot,
|
|
542
|
+
LinePlot,
|
|
543
|
+
AreaPlot,
|
|
544
|
+
ScatterPlot,
|
|
545
|
+
useChartContext,
|
|
546
|
+
} from "./composites/chart-composition";
|
|
547
|
+
export type {
|
|
548
|
+
ChartContainerProps,
|
|
549
|
+
ComposedSeries,
|
|
550
|
+
ComposedSeriesType,
|
|
551
|
+
HighlightedItem,
|
|
552
|
+
} from "./composites/chart-composition";
|
|
553
|
+
export {
|
|
554
|
+
AreaChart,
|
|
555
|
+
BarChart,
|
|
556
|
+
BoxPlotChart,
|
|
557
|
+
BubbleChart,
|
|
558
|
+
CandlestickChart,
|
|
559
|
+
LineChart,
|
|
560
|
+
OhlcChart,
|
|
561
|
+
RangeAreaChart,
|
|
562
|
+
RangeBarChart,
|
|
563
|
+
ScatterChart,
|
|
564
|
+
SparkLineChart,
|
|
565
|
+
WaterfallChart,
|
|
566
|
+
} from "./composites/cartesian-charts";
|
|
567
|
+
export type {
|
|
568
|
+
BarChartProps,
|
|
569
|
+
BoxPlotChartProps,
|
|
570
|
+
CandleDatum,
|
|
571
|
+
CandlestickChartProps,
|
|
572
|
+
CartesianChartProps,
|
|
573
|
+
LineChartProps,
|
|
574
|
+
NumericSeries,
|
|
575
|
+
RangeAreaChartProps,
|
|
576
|
+
RangeBarChartProps,
|
|
577
|
+
RangeSeries,
|
|
578
|
+
ScatterChartProps,
|
|
579
|
+
ScatterPoint,
|
|
580
|
+
ScatterRenderer,
|
|
581
|
+
ScatterSeries,
|
|
582
|
+
SparkLineChartProps,
|
|
583
|
+
WaterfallChartProps,
|
|
584
|
+
} from "./composites/cartesian-charts";
|
|
585
|
+
export {
|
|
586
|
+
Gauge,
|
|
587
|
+
LinearGauge,
|
|
588
|
+
PieChart,
|
|
589
|
+
PolarLineChart,
|
|
590
|
+
RadarChart,
|
|
591
|
+
RadialBarChart,
|
|
592
|
+
RadialLineChart,
|
|
593
|
+
} from "./composites/radial-charts";
|
|
594
|
+
export type {
|
|
595
|
+
GaugeProps,
|
|
596
|
+
GaugeSection,
|
|
597
|
+
LinearGaugeProps,
|
|
598
|
+
PieChartProps,
|
|
599
|
+
PieDatum,
|
|
600
|
+
PieSeries,
|
|
601
|
+
RadarChartProps,
|
|
602
|
+
RadarSeries,
|
|
603
|
+
RadialBarChartProps,
|
|
604
|
+
RadialLineChartProps,
|
|
605
|
+
} from "./composites/radial-charts";
|
|
606
|
+
export {
|
|
607
|
+
ChordChart,
|
|
608
|
+
FunnelChart,
|
|
609
|
+
Heatmap,
|
|
610
|
+
PyramidChart,
|
|
611
|
+
SankeyChart,
|
|
612
|
+
SunburstChart,
|
|
613
|
+
Treemap,
|
|
614
|
+
} from "./composites/flow-charts";
|
|
615
|
+
export type {
|
|
616
|
+
ChordChartProps,
|
|
617
|
+
FunnelChartProps,
|
|
618
|
+
FunnelDatum,
|
|
619
|
+
FunnelLabelPosition,
|
|
620
|
+
FunnelSeries,
|
|
621
|
+
HeatDatum,
|
|
622
|
+
HeatmapProps,
|
|
623
|
+
SankeyChartProps,
|
|
624
|
+
SunburstChartProps,
|
|
625
|
+
TreemapProps,
|
|
626
|
+
} from "./composites/flow-charts";
|
|
627
|
+
export { MapChart } from "./composites/MapChart";
|
|
628
|
+
export type { MapChartProps, MapShapeDatum } from "./composites/MapChart";
|
|
629
|
+
export { BarChart3D, PieChart3D } from "./composites/charts-3d";
|
|
630
|
+
export type { BarChart3DProps, PieChart3DProps } from "./composites/charts-3d";
|
|
631
|
+
export { ChartDataGrid, renderChartCell } from "./composites/ChartDataGrid";
|
|
632
|
+
export type {
|
|
633
|
+
ChartDataGridProps,
|
|
634
|
+
ChartDataGridRow,
|
|
635
|
+
ChartGridColumn,
|
|
636
|
+
ChartGridColumnType,
|
|
637
|
+
} from "./composites/ChartDataGrid";
|
|
638
|
+
export {
|
|
639
|
+
mercator,
|
|
640
|
+
equirectangular,
|
|
641
|
+
geoPath,
|
|
642
|
+
fitFeatures,
|
|
643
|
+
featureId,
|
|
644
|
+
} from "./lib/geo";
|
|
645
|
+
export type {
|
|
646
|
+
GeoJsonFeature,
|
|
647
|
+
GeoJsonFeatureCollection,
|
|
648
|
+
GeoJsonGeometry,
|
|
649
|
+
GeoProjectionKind,
|
|
650
|
+
} from "./lib/geo";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { serializeChartSvg } from "./chart-export";
|
|
3
|
+
|
|
4
|
+
describe("chart export", () => {
|
|
5
|
+
it("serializes an SVG with an XML header", () => {
|
|
6
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
7
|
+
svg.setAttribute("width", "120");
|
|
8
|
+
svg.setAttribute("height", "80");
|
|
9
|
+
const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
10
|
+
rect.setAttribute("width", "120");
|
|
11
|
+
rect.setAttribute("height", "80");
|
|
12
|
+
rect.setAttribute("fill", "var(--chart-1)");
|
|
13
|
+
svg.appendChild(rect);
|
|
14
|
+
document.body.appendChild(svg);
|
|
15
|
+
const xml = serializeChartSvg(svg);
|
|
16
|
+
expect(xml).toContain("<?xml");
|
|
17
|
+
expect(xml).toContain("<svg");
|
|
18
|
+
svg.remove();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Serialize a live chart SVG and download SVG / PNG.
|
|
3
|
+
* Computed CSS (theme variables) is baked in so the file looks the same outside the app.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
function bakeComputedStyles(live: SVGSVGElement, clone: SVGSVGElement) {
|
|
7
|
+
const liveNodes = [live, ...Array.from(live.querySelectorAll("*"))];
|
|
8
|
+
const cloneNodes = [clone, ...Array.from(clone.querySelectorAll("*"))];
|
|
9
|
+
for (let i = 0; i < liveNodes.length; i++) {
|
|
10
|
+
const source = liveNodes[i];
|
|
11
|
+
const target = cloneNodes[i] as SVGElement | undefined;
|
|
12
|
+
if (!source || !target || !(source instanceof Element)) continue;
|
|
13
|
+
const style = getComputedStyle(source);
|
|
14
|
+
if (style.fill && style.fill !== "none") target.setAttribute("fill", style.fill);
|
|
15
|
+
if (style.stroke && style.stroke !== "none") target.setAttribute("stroke", style.stroke);
|
|
16
|
+
if (style.strokeWidth) target.setAttribute("stroke-width", style.strokeWidth);
|
|
17
|
+
if (style.opacity && style.opacity !== "1") target.setAttribute("opacity", style.opacity);
|
|
18
|
+
if (style.fontSize) target.setAttribute("font-size", style.fontSize);
|
|
19
|
+
if (style.fontWeight) target.setAttribute("font-weight", style.fontWeight);
|
|
20
|
+
if (style.fontFamily) target.setAttribute("font-family", style.fontFamily);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function serializeChartSvg(svg: SVGSVGElement): string {
|
|
25
|
+
const clone = svg.cloneNode(true) as SVGSVGElement;
|
|
26
|
+
clone.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
27
|
+
clone.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
|
|
28
|
+
if (!clone.getAttribute("viewBox")) {
|
|
29
|
+
const width = svg.clientWidth || Number(svg.getAttribute("width")) || 320;
|
|
30
|
+
const height = svg.clientHeight || Number(svg.getAttribute("height")) || 240;
|
|
31
|
+
clone.setAttribute("viewBox", `0 0 ${width} ${height}`);
|
|
32
|
+
}
|
|
33
|
+
bakeComputedStyles(svg, clone);
|
|
34
|
+
return `<?xml version="1.0" encoding="UTF-8"?>${new XMLSerializer().serializeToString(clone)}`;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function triggerDownload(blob: Blob, filename: string) {
|
|
38
|
+
const href = URL.createObjectURL(blob);
|
|
39
|
+
const link = document.createElement("a");
|
|
40
|
+
link.href = href;
|
|
41
|
+
link.download = filename;
|
|
42
|
+
link.rel = "noopener";
|
|
43
|
+
document.body.appendChild(link);
|
|
44
|
+
link.click();
|
|
45
|
+
link.remove();
|
|
46
|
+
window.setTimeout(() => URL.revokeObjectURL(href), 1_000);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function downloadChartSvg(svg: SVGSVGElement, filename = "chart.svg") {
|
|
50
|
+
const blob = new Blob([serializeChartSvg(svg)], { type: "image/svg+xml;charset=utf-8" });
|
|
51
|
+
triggerDownload(blob, filename);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export async function chartSvgToPngBlob(svg: SVGSVGElement): Promise<Blob> {
|
|
55
|
+
const xml = serializeChartSvg(svg);
|
|
56
|
+
const width = Math.max(1, svg.clientWidth || Number(svg.getAttribute("width")) || 320);
|
|
57
|
+
const height = Math.max(1, svg.clientHeight || Number(svg.getAttribute("height")) || 240);
|
|
58
|
+
const blob = new Blob([xml], { type: "image/svg+xml;charset=utf-8" });
|
|
59
|
+
const url = URL.createObjectURL(blob);
|
|
60
|
+
try {
|
|
61
|
+
const image = await new Promise<HTMLImageElement>((resolve, reject) => {
|
|
62
|
+
const img = new Image();
|
|
63
|
+
img.onload = () => resolve(img);
|
|
64
|
+
img.onerror = () => reject(new Error("Failed to rasterize chart SVG"));
|
|
65
|
+
img.src = url;
|
|
66
|
+
});
|
|
67
|
+
const canvas = document.createElement("canvas");
|
|
68
|
+
canvas.width = Math.round(width * 2);
|
|
69
|
+
canvas.height = Math.round(height * 2);
|
|
70
|
+
const ctx = canvas.getContext("2d");
|
|
71
|
+
if (!ctx) throw new Error("Canvas is unavailable");
|
|
72
|
+
const surface = svg.parentElement;
|
|
73
|
+
ctx.fillStyle = surface ? getComputedStyle(surface).backgroundColor || "#ffffff" : "#ffffff";
|
|
74
|
+
if (ctx.fillStyle === "rgba(0, 0, 0, 0)" || ctx.fillStyle === "transparent") ctx.fillStyle = "#ffffff";
|
|
75
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
76
|
+
ctx.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
77
|
+
const png = await new Promise<Blob>((resolve, reject) => {
|
|
78
|
+
canvas.toBlob((next) => (next ? resolve(next) : reject(new Error("PNG export failed"))), "image/png");
|
|
79
|
+
});
|
|
80
|
+
return png;
|
|
81
|
+
} finally {
|
|
82
|
+
URL.revokeObjectURL(url);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export async function downloadChartPng(svg: SVGSVGElement, filename = "chart.png") {
|
|
87
|
+
const blob = await chartSvgToPngBlob(svg);
|
|
88
|
+
triggerDownload(blob, filename);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export async function exportChart(
|
|
92
|
+
svg: SVGSVGElement | null | undefined,
|
|
93
|
+
format: "svg" | "png",
|
|
94
|
+
filename?: string,
|
|
95
|
+
) {
|
|
96
|
+
if (!svg) return;
|
|
97
|
+
if (format === "svg") downloadChartSvg(svg, filename ?? "chart.svg");
|
|
98
|
+
else await downloadChartPng(svg, filename ?? "chart.png");
|
|
99
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { featureId, fitFeatures, geoPath, mercator } from "./geo";
|
|
3
|
+
import { ellipseSlicePath, isoBoxFaces, isoPoint } from "./iso";
|
|
4
|
+
import {
|
|
5
|
+
nearestScatterHit,
|
|
6
|
+
parseCssColor,
|
|
7
|
+
shouldUseWebGL,
|
|
8
|
+
WEBGL_AUTO_THRESHOLD,
|
|
9
|
+
} from "./webgl-scatter";
|
|
10
|
+
|
|
11
|
+
describe("geo", () => {
|
|
12
|
+
it("projects the equator to the mercator midpoint", () => {
|
|
13
|
+
const [x, y] = mercator([0, 0]);
|
|
14
|
+
expect(x).toBeCloseTo(0.5);
|
|
15
|
+
expect(y).toBeCloseTo(0.5);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("builds a closed polygon path fitted to a viewport", () => {
|
|
19
|
+
const features = [
|
|
20
|
+
{
|
|
21
|
+
type: "Feature" as const,
|
|
22
|
+
id: "box",
|
|
23
|
+
properties: { name: "Box" },
|
|
24
|
+
geometry: {
|
|
25
|
+
type: "Polygon" as const,
|
|
26
|
+
coordinates: [
|
|
27
|
+
[
|
|
28
|
+
[0, 0],
|
|
29
|
+
[10, 0],
|
|
30
|
+
[10, 10],
|
|
31
|
+
[0, 10],
|
|
32
|
+
[0, 0],
|
|
33
|
+
],
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
const project = fitFeatures(features, 200, 100, 10);
|
|
39
|
+
const d = geoPath(features[0]!.geometry, project);
|
|
40
|
+
expect(d.startsWith("M")).toBe(true);
|
|
41
|
+
expect(d.includes("Z")).toBe(true);
|
|
42
|
+
expect(featureId(features[0]!)).toBe("box");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
describe("iso", () => {
|
|
47
|
+
it("projects isometric points with y up", () => {
|
|
48
|
+
const origin = isoPoint(0, 0, 0, 40, 80);
|
|
49
|
+
const raised = isoPoint(0, 10, 0, 40, 80);
|
|
50
|
+
expect(raised.y).toBeLessThan(origin.y);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("emits three faces for a box", () => {
|
|
54
|
+
const faces = isoBoxFaces(0, 0, 0, 10, 20, 8, 40, 80);
|
|
55
|
+
expect(faces.front.startsWith("M")).toBe(true);
|
|
56
|
+
expect(faces.top).not.toEqual(faces.front);
|
|
57
|
+
expect(faces.side).not.toEqual(faces.top);
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it("draws an elliptical pie slice", () => {
|
|
61
|
+
const d = ellipseSlicePath(50, 40, 30, 12, 0, 90);
|
|
62
|
+
expect(d.includes("A30 12")).toBe(true);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe("webgl scatter helpers", () => {
|
|
67
|
+
it("parses hex and rgb colors", () => {
|
|
68
|
+
expect(parseCssColor("#ff0000")).toEqual([1, 0, 0, 1]);
|
|
69
|
+
expect(parseCssColor("rgb(0, 128, 255)")).toEqual([0, 128 / 255, 1, 1]);
|
|
70
|
+
expect(parseCssColor("not-a-color")).toBeNull();
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("selects webgl for auto clouds above the threshold", () => {
|
|
74
|
+
expect(shouldUseWebGL("svg", 10_000)).toBe(false);
|
|
75
|
+
expect(shouldUseWebGL("webgl", 3)).toBe(true);
|
|
76
|
+
expect(shouldUseWebGL("auto", WEBGL_AUTO_THRESHOLD)).toBe(true);
|
|
77
|
+
expect(shouldUseWebGL("auto", 10)).toBe(false);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it("finds the nearest point within the hit radius", () => {
|
|
81
|
+
const hit = nearestScatterHit(
|
|
82
|
+
[
|
|
83
|
+
{ x: 10, y: 10, r: 4, seriesIndex: 0, pointIndex: 0 },
|
|
84
|
+
{ x: 40, y: 40, r: 4, seriesIndex: 1, pointIndex: 2 },
|
|
85
|
+
],
|
|
86
|
+
41,
|
|
87
|
+
39,
|
|
88
|
+
);
|
|
89
|
+
expect(hit?.seriesIndex).toBe(1);
|
|
90
|
+
expect(hit?.pointIndex).toBe(2);
|
|
91
|
+
expect(nearestScatterHit([{ x: 0, y: 0, r: 2, seriesIndex: 0, pointIndex: 0 }], 80, 80)).toBeNull();
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
arcPath,
|
|
4
|
+
axisDataFromDataset,
|
|
5
|
+
boxPlotStats,
|
|
6
|
+
chartColor,
|
|
7
|
+
extent,
|
|
8
|
+
formatChartNumber,
|
|
9
|
+
funnelLayout,
|
|
10
|
+
linePath,
|
|
11
|
+
niceTicks,
|
|
12
|
+
pieSlices,
|
|
13
|
+
seriesDataFromDataset,
|
|
14
|
+
stackSeries,
|
|
15
|
+
squarify,
|
|
16
|
+
waterfallBars,
|
|
17
|
+
wheelZoom,
|
|
18
|
+
} from "./charts";
|
|
19
|
+
|
|
20
|
+
describe("chart math", () => {
|
|
21
|
+
it("builds nice ticks across a domain", () => {
|
|
22
|
+
const ticks = niceTicks(0, 100, 5);
|
|
23
|
+
expect(ticks[0]).toBe(0);
|
|
24
|
+
expect(ticks[ticks.length - 1]).toBeGreaterThanOrEqual(100);
|
|
25
|
+
expect(ticks.length).toBeGreaterThan(2);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("stacks positive and negative series independently", () => {
|
|
29
|
+
const stacked = stackSeries([
|
|
30
|
+
[2, -1],
|
|
31
|
+
[3, -2],
|
|
32
|
+
]);
|
|
33
|
+
expect(stacked[0]![0]).toEqual({ start: 0, end: 2 });
|
|
34
|
+
expect(stacked[1]![0]).toEqual({ start: 2, end: 5 });
|
|
35
|
+
expect(stacked[0]![1]).toEqual({ start: 0, end: -1 });
|
|
36
|
+
expect(stacked[1]![1]).toEqual({ start: -1, end: -3 });
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it("lays out pie slices that sum to a full turn", () => {
|
|
40
|
+
const slices = pieSlices([1, 1, 2], {
|
|
41
|
+
cx: 50,
|
|
42
|
+
cy: 50,
|
|
43
|
+
innerRadius: 10,
|
|
44
|
+
outerRadius: 40,
|
|
45
|
+
});
|
|
46
|
+
expect(slices).toHaveLength(3);
|
|
47
|
+
expect(slices[2]!.percent).toBeCloseTo(0.5);
|
|
48
|
+
expect(slices.every((slice) => slice.path.length > 0)).toBe(true);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("draws linear and monotone line paths", () => {
|
|
52
|
+
const pts = [
|
|
53
|
+
{ x: 0, y: 10 },
|
|
54
|
+
{ x: 10, y: 0 },
|
|
55
|
+
{ x: 20, y: 8 },
|
|
56
|
+
];
|
|
57
|
+
expect(linePath(pts, "linear")).toContain("L");
|
|
58
|
+
expect(linePath(pts, "monotone")).toContain("C");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("computes box-plot fences and outliers", () => {
|
|
62
|
+
const stats = boxPlotStats([1, 2, 3, 4, 5, 100]);
|
|
63
|
+
expect(stats.median).toBe(3.5);
|
|
64
|
+
expect(stats.outliers).toEqual([100]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("builds waterfall running totals", () => {
|
|
68
|
+
const bars = waterfallBars([100, 20, -30, null]);
|
|
69
|
+
expect(bars[3]).toEqual({ index: 3, start: 0, end: 90, value: 90, total: true });
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("packs a treemap that fills the viewport", () => {
|
|
73
|
+
const rects = squarify(
|
|
74
|
+
[
|
|
75
|
+
{ label: "A", value: 6 },
|
|
76
|
+
{ label: "B", value: 4 },
|
|
77
|
+
],
|
|
78
|
+
0,
|
|
79
|
+
0,
|
|
80
|
+
100,
|
|
81
|
+
50,
|
|
82
|
+
);
|
|
83
|
+
const area = rects.reduce((sum, rect) => sum + rect.w * rect.h, 0);
|
|
84
|
+
expect(area).toBeCloseTo(5000, 0);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("lays out funnel rows from wide to narrow", () => {
|
|
88
|
+
const rows = funnelLayout(
|
|
89
|
+
[
|
|
90
|
+
{ label: "A", value: 10 },
|
|
91
|
+
{ label: "B", value: 5 },
|
|
92
|
+
],
|
|
93
|
+
100,
|
|
94
|
+
80,
|
|
95
|
+
);
|
|
96
|
+
expect(rows[0]!.topRight - rows[0]!.topLeft).toBeGreaterThan(rows[1]!.topRight - rows[1]!.topLeft);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("shares a max so comparison funnels stay on the same scale", () => {
|
|
100
|
+
const inner = funnelLayout([{ label: "A", value: 50 }], 100, 40, 6, 100);
|
|
101
|
+
const outer = funnelLayout([{ label: "A", value: 100 }], 100, 40, 6, 100);
|
|
102
|
+
expect(outer[0]!.topRight - outer[0]!.topLeft).toBe(100);
|
|
103
|
+
expect(inner[0]!.topRight - inner[0]!.topLeft).toBe(50);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("zooms a window around an anchor", () => {
|
|
107
|
+
const next = wheelZoom({ x: [0, 1] }, 0.5, 0.5);
|
|
108
|
+
expect(next.x[1] - next.x[0]).toBeCloseTo(0.5);
|
|
109
|
+
expect(next.x[0]).toBeGreaterThan(0);
|
|
110
|
+
expect(next.x[1]).toBeLessThan(1);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it("reads series from a dataset", () => {
|
|
114
|
+
const dataset = [
|
|
115
|
+
{ month: "Jan", views: 10 },
|
|
116
|
+
{ month: "Feb", views: 20 },
|
|
117
|
+
];
|
|
118
|
+
expect(seriesDataFromDataset(dataset, "views")).toEqual([10, 20]);
|
|
119
|
+
expect(axisDataFromDataset(dataset, "month")).toEqual(["Jan", "Feb"]);
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("formats compact numbers and cycles chart colors", () => {
|
|
123
|
+
expect(formatChartNumber(1500)).toBe("1.5k");
|
|
124
|
+
expect(chartColor(0)).toBe("var(--chart-1)");
|
|
125
|
+
expect(chartColor(5)).toBe("var(--chart-1)");
|
|
126
|
+
expect(extent([3, 3])).not.toEqual([3, 3]);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it("splits a full-circle arc into two sweeps", () => {
|
|
130
|
+
expect(arcPath(0, 0, 0, 10, 0, 360).split("A").length).toBeGreaterThan(2);
|
|
131
|
+
});
|
|
132
|
+
});
|