@spatika/react 1.0.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/AccentRule.d.ts +6 -0
- package/dist/composites/AccentRule.d.ts.map +1 -0
- package/dist/composites/AccentRule.js +6 -0
- package/dist/composites/AvailabilityBadge.d.ts +9 -0
- package/dist/composites/AvailabilityBadge.d.ts.map +1 -0
- package/dist/composites/AvailabilityBadge.js +9 -0
- 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/CareerCard.d.ts +20 -0
- package/dist/composites/CareerCard.d.ts.map +1 -0
- package/dist/composites/CareerCard.js +17 -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/ContactLink.d.ts +15 -0
- package/dist/composites/ContactLink.d.ts.map +1 -0
- package/dist/composites/ContactLink.js +8 -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/DisplayHeading.d.ts +9 -0
- package/dist/composites/DisplayHeading.d.ts.map +1 -0
- package/dist/composites/DisplayHeading.js +6 -0
- 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/FloatChip.d.ts +15 -0
- package/dist/composites/FloatChip.d.ts.map +1 -0
- package/dist/composites/FloatChip.js +7 -0
- package/dist/composites/GradientText.d.ts +11 -0
- package/dist/composites/GradientText.d.ts.map +1 -0
- package/dist/composites/GradientText.js +6 -0
- package/dist/composites/IconTile.d.ts +10 -0
- package/dist/composites/IconTile.d.ts.map +1 -0
- package/dist/composites/IconTile.js +7 -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/MetaChip.d.ts +9 -0
- package/dist/composites/MetaChip.d.ts.map +1 -0
- package/dist/composites/MetaChip.js +6 -0
- package/dist/composites/PresenceDot.d.ts +10 -0
- package/dist/composites/PresenceDot.d.ts.map +1 -0
- package/dist/composites/PresenceDot.js +10 -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/ProjectCard.d.ts +12 -0
- package/dist/composites/ProjectCard.d.ts.map +1 -0
- package/dist/composites/ProjectCard.js +9 -0
- 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/SectionHeading.d.ts +16 -0
- package/dist/composites/SectionHeading.d.ts.map +1 -0
- package/dist/composites/SectionHeading.js +12 -0
- package/dist/composites/SiteFooter.d.ts +18 -0
- package/dist/composites/SiteFooter.d.ts.map +1 -0
- package/dist/composites/SiteFooter.js +15 -0
- package/dist/composites/SiteNav.d.ts +25 -0
- package/dist/composites/SiteNav.d.ts.map +1 -0
- package/dist/composites/SiteNav.js +44 -0
- package/dist/composites/StatCard.d.ts +7 -1
- package/dist/composites/StatCard.d.ts.map +1 -1
- package/dist/composites/StatCard.js +5 -2
- package/dist/composites/StatusDot.d.ts +1 -1
- package/dist/composites/Tag.d.ts +11 -0
- package/dist/composites/Tag.d.ts.map +1 -0
- package/dist/composites/Tag.js +33 -0
- package/dist/composites/Wordmark.d.ts +19 -0
- package/dist/composites/Wordmark.d.ts.map +1 -0
- package/dist/composites/Wordmark.js +15 -0
- 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 +83 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +74 -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/Button.d.ts +4 -4
- package/dist/primitives/Button.d.ts.map +1 -1
- package/dist/primitives/Button.js +2 -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 +30 -5
- package/skills/spatika-ui/SKILL.md +96 -0
- package/src/composites/AccentRule.tsx +12 -0
- package/src/composites/AvailabilityBadge.tsx +32 -0
- package/src/composites/Card.tsx +51 -1
- package/src/composites/CareerCard.tsx +111 -0
- package/src/composites/ChartDataGrid.test.tsx +57 -0
- package/src/composites/ChartDataGrid.tsx +196 -0
- package/src/composites/ContactLink.tsx +66 -0
- package/src/composites/CoverHero.test.tsx +38 -0
- package/src/composites/CoverHero.tsx +29 -22
- package/src/composites/DisplayHeading.tsx +27 -0
- 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/FloatChip.tsx +63 -0
- package/src/composites/GradientText.tsx +31 -0
- package/src/composites/IconTile.tsx +33 -0
- package/src/composites/MapChart.test.tsx +39 -0
- package/src/composites/MapChart.tsx +130 -0
- package/src/composites/MetaChip.tsx +24 -0
- package/src/composites/PresenceDot.tsx +42 -0
- package/src/composites/ProfileHero.test.tsx +33 -0
- package/src/composites/ProfileHero.tsx +96 -79
- package/src/composites/ProjectCard.tsx +65 -0
- package/src/composites/ScatterWebGL.test.tsx +25 -0
- package/src/composites/ScatterWebGL.tsx +79 -0
- package/src/composites/SectionHeading.tsx +61 -0
- package/src/composites/SiteFooter.test.tsx +37 -0
- package/src/composites/SiteFooter.tsx +79 -0
- package/src/composites/SiteNav.test.tsx +46 -0
- package/src/composites/SiteNav.tsx +150 -0
- package/src/composites/StatCard.test.tsx +30 -0
- package/src/composites/StatCard.tsx +36 -1
- package/src/composites/Tag.tsx +50 -0
- package/src/composites/Wordmark.test.tsx +23 -0
- package/src/composites/Wordmark.tsx +46 -0
- 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 +192 -0
- 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 +300 -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/Button.tsx +3 -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
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Check, ChevronsUpDown, X } from "lucide-react";
|
|
3
|
+
import { useControllableState } from "../lib/use-controllable-state";
|
|
4
|
+
import { useDismissable } from "../lib/use-dismissable";
|
|
5
|
+
import { cn } from "../lib/cn";
|
|
6
|
+
import { Input } from "./Input";
|
|
7
|
+
import { Label } from "./Label";
|
|
8
|
+
|
|
9
|
+
export type AutocompleteOption = {
|
|
10
|
+
label: string;
|
|
11
|
+
value: string;
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function normalizeOptions(options: Array<string | AutocompleteOption>): AutocompleteOption[] {
|
|
16
|
+
return options.map((option) =>
|
|
17
|
+
typeof option === "string" ? { label: option, value: option } : option,
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export type AutocompleteProps = Omit<
|
|
22
|
+
React.ComponentPropsWithoutRef<"div">,
|
|
23
|
+
"onChange" | "defaultValue"
|
|
24
|
+
> & {
|
|
25
|
+
options: Array<string | AutocompleteOption>;
|
|
26
|
+
value?: string | string[] | null;
|
|
27
|
+
defaultValue?: string | string[] | null;
|
|
28
|
+
onChange?: (value: string | string[] | null, option?: AutocompleteOption | AutocompleteOption[] | null) => void;
|
|
29
|
+
multiple?: boolean;
|
|
30
|
+
freeSolo?: boolean;
|
|
31
|
+
label?: React.ReactNode;
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
disabled?: boolean;
|
|
34
|
+
fullWidth?: boolean;
|
|
35
|
+
noOptionsText?: string;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
function asList(value: string | string[] | null | undefined): string[] {
|
|
39
|
+
if (value == null || value === "") return [];
|
|
40
|
+
return Array.isArray(value) ? value : [value];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Filterable combobox. Supports single, multiple, and free-solo entry.
|
|
45
|
+
*/
|
|
46
|
+
function Autocomplete({
|
|
47
|
+
options: optionsProp,
|
|
48
|
+
value: valueProp,
|
|
49
|
+
defaultValue,
|
|
50
|
+
onChange,
|
|
51
|
+
multiple = false,
|
|
52
|
+
freeSolo = false,
|
|
53
|
+
label,
|
|
54
|
+
placeholder = "Search…",
|
|
55
|
+
disabled,
|
|
56
|
+
fullWidth,
|
|
57
|
+
noOptionsText = "No options",
|
|
58
|
+
className,
|
|
59
|
+
id,
|
|
60
|
+
...props
|
|
61
|
+
}: AutocompleteProps) {
|
|
62
|
+
const autoId = React.useId();
|
|
63
|
+
const fieldId = id ?? autoId;
|
|
64
|
+
const options = React.useMemo(() => normalizeOptions(optionsProp), [optionsProp]);
|
|
65
|
+
const [value, setValue] = useControllableState<string | string[] | null>({
|
|
66
|
+
prop: valueProp,
|
|
67
|
+
defaultProp: defaultValue ?? (multiple ? [] : null),
|
|
68
|
+
onChange: (next) => {
|
|
69
|
+
const list = asList(next);
|
|
70
|
+
const matched = options.filter((opt) => list.includes(opt.value));
|
|
71
|
+
onChange?.(next, multiple ? matched : (matched[0] ?? null));
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const selected = asList(value);
|
|
75
|
+
const [query, setQuery] = React.useState("");
|
|
76
|
+
const [open, setOpen] = React.useState(false);
|
|
77
|
+
const [highlight, setHighlight] = React.useState(0);
|
|
78
|
+
const rootRef = React.useRef<HTMLDivElement | null>(null);
|
|
79
|
+
const listRef = React.useRef<HTMLDivElement | null>(null);
|
|
80
|
+
|
|
81
|
+
const filtered = options.filter((opt) => {
|
|
82
|
+
if (multiple && selected.includes(opt.value) && !query) return true;
|
|
83
|
+
return opt.label.toLowerCase().includes(query.toLowerCase());
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
useDismissable({
|
|
87
|
+
enabled: open,
|
|
88
|
+
onDismiss: () => setOpen(false),
|
|
89
|
+
refs: [rootRef, listRef],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const commit = (next: string) => {
|
|
93
|
+
if (disabled) return;
|
|
94
|
+
if (multiple) {
|
|
95
|
+
const list = selected.includes(next)
|
|
96
|
+
? selected.filter((item) => item !== next)
|
|
97
|
+
: [...selected, next];
|
|
98
|
+
setValue(list);
|
|
99
|
+
setQuery("");
|
|
100
|
+
} else {
|
|
101
|
+
setValue(next);
|
|
102
|
+
setQuery("");
|
|
103
|
+
setOpen(false);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const display = multiple
|
|
108
|
+
? query
|
|
109
|
+
: open
|
|
110
|
+
? query
|
|
111
|
+
: (options.find((opt) => opt.value === selected[0])?.label ?? selected[0] ?? "");
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div
|
|
115
|
+
ref={rootRef}
|
|
116
|
+
data-slot="autocomplete"
|
|
117
|
+
className={cn("relative", fullWidth && "w-full", className)}
|
|
118
|
+
{...props}
|
|
119
|
+
>
|
|
120
|
+
{label ? <Label htmlFor={fieldId}>{label}</Label> : null}
|
|
121
|
+
<div
|
|
122
|
+
className={cn(
|
|
123
|
+
"mt-1.5 flex min-h-9 flex-wrap items-center gap-1 rounded-md border border-input bg-input-background px-2 py-1",
|
|
124
|
+
"focus-within:border-ring focus-within:ring-ring/50 focus-within:ring-[3px]",
|
|
125
|
+
disabled && "opacity-50",
|
|
126
|
+
)}
|
|
127
|
+
>
|
|
128
|
+
{multiple
|
|
129
|
+
? selected.map((item) => {
|
|
130
|
+
const opt = options.find((option) => option.value === item);
|
|
131
|
+
return (
|
|
132
|
+
<span
|
|
133
|
+
key={item}
|
|
134
|
+
className="inline-flex items-center gap-1 rounded-full border border-border/50 bg-muted/50 px-2 py-0.5 text-xs font-bold"
|
|
135
|
+
>
|
|
136
|
+
{opt?.label ?? item}
|
|
137
|
+
<button
|
|
138
|
+
type="button"
|
|
139
|
+
aria-label={`Remove ${opt?.label ?? item}`}
|
|
140
|
+
className="text-muted-foreground hover:text-foreground"
|
|
141
|
+
onClick={() => commit(item)}
|
|
142
|
+
>
|
|
143
|
+
<X className="size-3" />
|
|
144
|
+
</button>
|
|
145
|
+
</span>
|
|
146
|
+
);
|
|
147
|
+
})
|
|
148
|
+
: null}
|
|
149
|
+
<Input
|
|
150
|
+
id={fieldId}
|
|
151
|
+
disabled={disabled}
|
|
152
|
+
role="combobox"
|
|
153
|
+
aria-expanded={open}
|
|
154
|
+
aria-autocomplete="list"
|
|
155
|
+
placeholder={selected.length && multiple ? undefined : placeholder}
|
|
156
|
+
value={multiple ? query : display}
|
|
157
|
+
className="h-7 min-w-16 flex-1 border-0 bg-transparent px-1 shadow-none focus-visible:ring-0"
|
|
158
|
+
onFocus={() => {
|
|
159
|
+
setOpen(true);
|
|
160
|
+
if (!multiple) {
|
|
161
|
+
const current =
|
|
162
|
+
options.find((opt) => opt.value === selected[0])?.label ?? selected[0] ?? "";
|
|
163
|
+
setQuery(current);
|
|
164
|
+
}
|
|
165
|
+
}}
|
|
166
|
+
onChange={(event) => {
|
|
167
|
+
setQuery(event.target.value);
|
|
168
|
+
setOpen(true);
|
|
169
|
+
setHighlight(0);
|
|
170
|
+
if (!multiple && !freeSolo) {
|
|
171
|
+
/* keep typing local until a selection is committed */
|
|
172
|
+
}
|
|
173
|
+
}}
|
|
174
|
+
onKeyDown={(event) => {
|
|
175
|
+
if (event.key === "ArrowDown") {
|
|
176
|
+
event.preventDefault();
|
|
177
|
+
setOpen(true);
|
|
178
|
+
setHighlight((index) => Math.min(filtered.length - 1, index + 1));
|
|
179
|
+
} else if (event.key === "ArrowUp") {
|
|
180
|
+
event.preventDefault();
|
|
181
|
+
setHighlight((index) => Math.max(0, index - 1));
|
|
182
|
+
} else if (event.key === "Enter") {
|
|
183
|
+
event.preventDefault();
|
|
184
|
+
const hit = filtered[highlight];
|
|
185
|
+
if (hit) commit(hit.value);
|
|
186
|
+
else if (freeSolo && query.trim()) commit(query.trim());
|
|
187
|
+
} else if (event.key === "Escape") {
|
|
188
|
+
setOpen(false);
|
|
189
|
+
} else if (event.key === "Backspace" && multiple && !query && selected.length) {
|
|
190
|
+
commit(selected[selected.length - 1]!);
|
|
191
|
+
}
|
|
192
|
+
}}
|
|
193
|
+
/>
|
|
194
|
+
<ChevronsUpDown className="size-3.5 shrink-0 text-muted-foreground" />
|
|
195
|
+
</div>
|
|
196
|
+
{open ? (
|
|
197
|
+
<div
|
|
198
|
+
ref={listRef}
|
|
199
|
+
role="listbox"
|
|
200
|
+
data-slot="autocomplete-list"
|
|
201
|
+
className="glass-menu absolute z-50 mt-1 max-h-60 w-full overflow-auto rounded-xl border border-border/50 p-1 shadow-xl"
|
|
202
|
+
>
|
|
203
|
+
{filtered.length === 0 ? (
|
|
204
|
+
<div className="px-3 py-2 text-sm text-muted-foreground">{noOptionsText}</div>
|
|
205
|
+
) : (
|
|
206
|
+
filtered.map((opt, index) => {
|
|
207
|
+
const active = selected.includes(opt.value);
|
|
208
|
+
return (
|
|
209
|
+
<button
|
|
210
|
+
key={opt.value}
|
|
211
|
+
type="button"
|
|
212
|
+
role="option"
|
|
213
|
+
aria-selected={active}
|
|
214
|
+
disabled={opt.disabled}
|
|
215
|
+
className={cn(
|
|
216
|
+
"flex w-full items-center justify-between rounded-lg px-3 py-2 text-left text-sm font-medium",
|
|
217
|
+
index === highlight ? "bg-muted/60" : "hover:bg-muted/40",
|
|
218
|
+
opt.disabled && "opacity-40",
|
|
219
|
+
)}
|
|
220
|
+
onMouseEnter={() => setHighlight(index)}
|
|
221
|
+
onClick={() => commit(opt.value)}
|
|
222
|
+
>
|
|
223
|
+
{opt.label}
|
|
224
|
+
{active ? <Check className="size-3.5 text-primary" /> : null}
|
|
225
|
+
</button>
|
|
226
|
+
);
|
|
227
|
+
})
|
|
228
|
+
)}
|
|
229
|
+
</div>
|
|
230
|
+
) : null}
|
|
231
|
+
</div>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
Autocomplete.displayName = "Autocomplete";
|
|
235
|
+
|
|
236
|
+
export { Autocomplete };
|
|
@@ -137,4 +137,55 @@ function InitialsAvatar({
|
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
export
|
|
140
|
+
export type AvatarGroupProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
141
|
+
max?: number;
|
|
142
|
+
total?: number;
|
|
143
|
+
spacing?: "sm" | "md" | "lg";
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const spacingClass = {
|
|
147
|
+
sm: "-space-x-1",
|
|
148
|
+
md: "-space-x-2",
|
|
149
|
+
lg: "-space-x-3",
|
|
150
|
+
} as const;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Overlapping avatar stack with an overflow count.
|
|
154
|
+
*/
|
|
155
|
+
function AvatarGroup({
|
|
156
|
+
max = 5,
|
|
157
|
+
total,
|
|
158
|
+
spacing = "md",
|
|
159
|
+
className,
|
|
160
|
+
children,
|
|
161
|
+
...props
|
|
162
|
+
}: AvatarGroupProps) {
|
|
163
|
+
const avatars = React.Children.toArray(children);
|
|
164
|
+
const extra = Math.max(0, (total ?? avatars.length) - max);
|
|
165
|
+
const shown = extra > 0 ? avatars.slice(0, max) : avatars;
|
|
166
|
+
|
|
167
|
+
return (
|
|
168
|
+
<div
|
|
169
|
+
data-slot="avatar-group"
|
|
170
|
+
className={cn(
|
|
171
|
+
"flex items-center [&_[data-slot=avatar]]:ring-2 [&_[data-slot=avatar]]:ring-background",
|
|
172
|
+
spacingClass[spacing],
|
|
173
|
+
className,
|
|
174
|
+
)}
|
|
175
|
+
{...props}
|
|
176
|
+
>
|
|
177
|
+
{shown}
|
|
178
|
+
{extra > 0 ? (
|
|
179
|
+
<span
|
|
180
|
+
data-slot="avatar-group-surplus"
|
|
181
|
+
className="relative z-[1] flex size-10 shrink-0 items-center justify-center rounded-full border-2 border-background bg-muted text-xs font-bold text-muted-foreground"
|
|
182
|
+
>
|
|
183
|
+
+{extra}
|
|
184
|
+
</span>
|
|
185
|
+
) : null}
|
|
186
|
+
</div>
|
|
187
|
+
);
|
|
188
|
+
}
|
|
189
|
+
AvatarGroup.displayName = "AvatarGroup";
|
|
190
|
+
|
|
191
|
+
export { Avatar, AvatarImage, AvatarFallback, InitialsAvatar, AvatarGroup };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Portal } from "../lib/portal";
|
|
3
|
+
import { cn } from "../lib/cn";
|
|
4
|
+
import { OVERLAY_Z_INDEX, fixedLayerStyle } from "../lib/overlay-stack";
|
|
5
|
+
|
|
6
|
+
export type BackdropProps = React.ComponentPropsWithoutRef<"div"> & {
|
|
7
|
+
open?: boolean;
|
|
8
|
+
/** Skip the dimmed fill — useful as a click-catcher. */
|
|
9
|
+
invisible?: boolean;
|
|
10
|
+
/** Render in-place instead of portaling to document.body. */
|
|
11
|
+
contained?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Full-viewport dimmer, typically paired with a modal or speed dial.
|
|
16
|
+
*/
|
|
17
|
+
function Backdrop({
|
|
18
|
+
open = false,
|
|
19
|
+
invisible = false,
|
|
20
|
+
contained = false,
|
|
21
|
+
className,
|
|
22
|
+
style,
|
|
23
|
+
children,
|
|
24
|
+
...props
|
|
25
|
+
}: BackdropProps) {
|
|
26
|
+
if (!open) return null;
|
|
27
|
+
|
|
28
|
+
const node = (
|
|
29
|
+
<div
|
|
30
|
+
data-slot="backdrop"
|
|
31
|
+
className={cn(
|
|
32
|
+
contained ? "absolute inset-0" : "fixed inset-0",
|
|
33
|
+
!invisible && "bg-[color-mix(in_srgb,var(--foreground)_28%,transparent)]",
|
|
34
|
+
className,
|
|
35
|
+
)}
|
|
36
|
+
style={contained ? style : { ...fixedLayerStyle(OVERLAY_Z_INDEX.modal), ...style }}
|
|
37
|
+
{...props}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (contained) return node;
|
|
44
|
+
return <Portal>{node}</Portal>;
|
|
45
|
+
}
|
|
46
|
+
Backdrop.displayName = "Backdrop";
|
|
47
|
+
|
|
48
|
+
export { Backdrop };
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useControllableState } from "../lib/use-controllable-state";
|
|
3
|
+
import { cn } from "../lib/cn";
|
|
4
|
+
|
|
5
|
+
type BottomNavContextValue = {
|
|
6
|
+
value?: string;
|
|
7
|
+
setValue: (value: string) => void;
|
|
8
|
+
showLabels: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const BottomNavContext = React.createContext<BottomNavContextValue | null>(null);
|
|
12
|
+
|
|
13
|
+
export type BottomNavigationProps = Omit<
|
|
14
|
+
React.ComponentPropsWithoutRef<"div">,
|
|
15
|
+
"onChange" | "defaultValue"
|
|
16
|
+
> & {
|
|
17
|
+
value?: string;
|
|
18
|
+
defaultValue?: string;
|
|
19
|
+
onChange?: (event: React.SyntheticEvent, value: string) => void;
|
|
20
|
+
showLabels?: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
function BottomNavigation({
|
|
24
|
+
value: valueProp,
|
|
25
|
+
defaultValue,
|
|
26
|
+
onChange,
|
|
27
|
+
showLabels = true,
|
|
28
|
+
className,
|
|
29
|
+
...props
|
|
30
|
+
}: BottomNavigationProps) {
|
|
31
|
+
const [value, setValue] = useControllableState({
|
|
32
|
+
prop: valueProp,
|
|
33
|
+
defaultProp: defaultValue,
|
|
34
|
+
onChange: (next) => {
|
|
35
|
+
if (next == null) return;
|
|
36
|
+
onChange?.({} as React.SyntheticEvent, next);
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<BottomNavContext.Provider
|
|
42
|
+
value={{ value, setValue: (next) => setValue(next), showLabels }}
|
|
43
|
+
>
|
|
44
|
+
<div
|
|
45
|
+
role="navigation"
|
|
46
|
+
data-slot="bottom-navigation"
|
|
47
|
+
className={cn(
|
|
48
|
+
"glass-tabbar flex w-full items-stretch justify-around rounded-2xl border border-border/40 px-2 py-1",
|
|
49
|
+
className,
|
|
50
|
+
)}
|
|
51
|
+
{...props}
|
|
52
|
+
/>
|
|
53
|
+
</BottomNavContext.Provider>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
BottomNavigation.displayName = "BottomNavigation";
|
|
57
|
+
|
|
58
|
+
export type BottomNavigationActionProps = React.ComponentPropsWithoutRef<"button"> & {
|
|
59
|
+
value: string;
|
|
60
|
+
label?: React.ReactNode;
|
|
61
|
+
icon?: React.ReactNode;
|
|
62
|
+
showLabel?: boolean;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
function BottomNavigationAction({
|
|
66
|
+
value,
|
|
67
|
+
label,
|
|
68
|
+
icon,
|
|
69
|
+
showLabel,
|
|
70
|
+
className,
|
|
71
|
+
onClick,
|
|
72
|
+
...props
|
|
73
|
+
}: BottomNavigationActionProps) {
|
|
74
|
+
const ctx = React.useContext(BottomNavContext);
|
|
75
|
+
const selected = ctx?.value === value;
|
|
76
|
+
const labels = showLabel ?? ctx?.showLabels ?? true;
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<button
|
|
80
|
+
type="button"
|
|
81
|
+
data-slot="bottom-navigation-action"
|
|
82
|
+
data-selected={selected ? "" : undefined}
|
|
83
|
+
aria-current={selected ? "page" : undefined}
|
|
84
|
+
className={cn(
|
|
85
|
+
"flex min-h-11 flex-1 flex-col items-center justify-center gap-0.5 rounded-xl px-2 py-1.5 text-[10px] font-bold outline-none transition-colors",
|
|
86
|
+
selected ? "text-primary" : "text-muted-foreground hover:text-foreground",
|
|
87
|
+
className,
|
|
88
|
+
)}
|
|
89
|
+
onClick={(event) => {
|
|
90
|
+
onClick?.(event);
|
|
91
|
+
if (!event.defaultPrevented) ctx?.setValue(value);
|
|
92
|
+
}}
|
|
93
|
+
{...props}
|
|
94
|
+
>
|
|
95
|
+
<span className="[&_svg]:size-5">{icon}</span>
|
|
96
|
+
{labels ? <span>{label}</span> : null}
|
|
97
|
+
</button>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
BottomNavigationAction.displayName = "BottomNavigationAction";
|
|
101
|
+
|
|
102
|
+
export { BottomNavigation, BottomNavigationAction };
|
|
@@ -18,11 +18,14 @@ const buttonVariants = cva(
|
|
|
18
18
|
link: "text-primary underline-offset-4 hover:underline",
|
|
19
19
|
glass:
|
|
20
20
|
"glass border-border/50 text-foreground hover:border-primary/30 hover:text-primary",
|
|
21
|
+
gradient:
|
|
22
|
+
"rounded-full bg-gradient-to-r from-primary to-[color-mix(in_srgb,var(--primary)_72%,var(--chart-2))] text-primary-foreground shadow-[0_10px_32px_color-mix(in_srgb,var(--primary)_38%,transparent)] hover:brightness-105 hover:-translate-y-0.5 hover:shadow-[0_14px_40px_color-mix(in_srgb,var(--chart-3)_22%,transparent)]",
|
|
21
23
|
},
|
|
22
24
|
size: {
|
|
23
25
|
default: "h-9 px-4 py-2 has-[>svg]:px-3",
|
|
24
26
|
sm: "h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",
|
|
25
27
|
lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
|
|
28
|
+
xl: "h-auto rounded-full px-8 py-4 text-[15px] font-bold has-[>svg]:px-7",
|
|
26
29
|
/** Mobile-first ≥44px touch target */
|
|
27
30
|
touch: "min-h-11 h-11 rounded-md px-5 has-[>svg]:px-4",
|
|
28
31
|
icon: "size-9 rounded-md",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { Slot } from "../lib/slot";
|
|
3
|
+
import { cn } from "../lib/cn";
|
|
4
|
+
|
|
5
|
+
export type ButtonBaseProps = React.ComponentPropsWithoutRef<"button"> & {
|
|
6
|
+
asChild?: boolean;
|
|
7
|
+
focusRipple?: boolean;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Unstyled pressable — MUI ButtonBase analogue. Use Button / IconButton for styled actions.
|
|
12
|
+
*/
|
|
13
|
+
const ButtonBase = React.forwardRef<HTMLButtonElement, ButtonBaseProps>(
|
|
14
|
+
({ className, asChild = false, focusRipple: _focusRipple, ...props }, ref) => {
|
|
15
|
+
const Comp = asChild ? Slot : "button";
|
|
16
|
+
return (
|
|
17
|
+
<Comp
|
|
18
|
+
ref={ref}
|
|
19
|
+
type={asChild ? undefined : "button"}
|
|
20
|
+
data-slot="button-base"
|
|
21
|
+
className={cn(
|
|
22
|
+
"inline-flex cursor-pointer items-center justify-center outline-none select-none",
|
|
23
|
+
"focus-visible:ring-ring/50 focus-visible:ring-[3px] disabled:pointer-events-none disabled:opacity-50",
|
|
24
|
+
"active:scale-[0.98]",
|
|
25
|
+
className,
|
|
26
|
+
)}
|
|
27
|
+
{...props}
|
|
28
|
+
/>
|
|
29
|
+
);
|
|
30
|
+
},
|
|
31
|
+
);
|
|
32
|
+
ButtonBase.displayName = "ButtonBase";
|
|
33
|
+
|
|
34
|
+
export { ButtonBase };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import { cn } from "../lib/cn";
|
|
4
|
+
import { buttonVariants } from "./Button";
|
|
5
|
+
|
|
6
|
+
const buttonGroupVariants = cva("inline-flex isolate", {
|
|
7
|
+
variants: {
|
|
8
|
+
orientation: {
|
|
9
|
+
horizontal: "flex-row",
|
|
10
|
+
vertical: "flex-col",
|
|
11
|
+
},
|
|
12
|
+
fullWidth: {
|
|
13
|
+
true: "flex w-full",
|
|
14
|
+
false: "",
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
defaultVariants: {
|
|
18
|
+
orientation: "horizontal",
|
|
19
|
+
fullWidth: false,
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export type ButtonGroupProps = React.ComponentPropsWithoutRef<"div"> &
|
|
24
|
+
VariantProps<typeof buttonGroupVariants> & {
|
|
25
|
+
variant?: VariantProps<typeof buttonVariants>["variant"];
|
|
26
|
+
size?: VariantProps<typeof buttonVariants>["size"];
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Connected cluster of buttons — first/last corners stay rounded.
|
|
32
|
+
*/
|
|
33
|
+
const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
34
|
+
(
|
|
35
|
+
{
|
|
36
|
+
className,
|
|
37
|
+
orientation = "horizontal",
|
|
38
|
+
fullWidth = false,
|
|
39
|
+
variant,
|
|
40
|
+
size,
|
|
41
|
+
disabled,
|
|
42
|
+
children,
|
|
43
|
+
...props
|
|
44
|
+
},
|
|
45
|
+
ref,
|
|
46
|
+
) => {
|
|
47
|
+
const items = React.Children.toArray(children);
|
|
48
|
+
const vertical = orientation === "vertical";
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<div
|
|
52
|
+
ref={ref}
|
|
53
|
+
role="group"
|
|
54
|
+
data-slot="button-group"
|
|
55
|
+
data-orientation={orientation}
|
|
56
|
+
className={cn(buttonGroupVariants({ orientation, fullWidth }), className)}
|
|
57
|
+
{...props}
|
|
58
|
+
>
|
|
59
|
+
{items.map((child, index) => {
|
|
60
|
+
if (!React.isValidElement<{
|
|
61
|
+
className?: string;
|
|
62
|
+
disabled?: boolean;
|
|
63
|
+
variant?: ButtonGroupProps["variant"];
|
|
64
|
+
size?: ButtonGroupProps["size"];
|
|
65
|
+
}>(child)) {
|
|
66
|
+
return child;
|
|
67
|
+
}
|
|
68
|
+
const first = index === 0;
|
|
69
|
+
const last = index === items.length - 1;
|
|
70
|
+
return React.cloneElement(child, {
|
|
71
|
+
disabled: disabled || child.props.disabled,
|
|
72
|
+
variant: child.props.variant ?? variant ?? undefined,
|
|
73
|
+
size: child.props.size ?? size ?? undefined,
|
|
74
|
+
className: cn(
|
|
75
|
+
child.props.className,
|
|
76
|
+
"focus-visible:z-10",
|
|
77
|
+
vertical
|
|
78
|
+
? cn(!first && "-mt-px rounded-t-none", !last && "rounded-b-none")
|
|
79
|
+
: cn(!first && "-ml-px rounded-l-none", !last && "rounded-r-none"),
|
|
80
|
+
fullWidth && "flex-1",
|
|
81
|
+
),
|
|
82
|
+
});
|
|
83
|
+
})}
|
|
84
|
+
</div>
|
|
85
|
+
);
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
ButtonGroup.displayName = "ButtonGroup";
|
|
89
|
+
|
|
90
|
+
export { ButtonGroup, buttonGroupVariants };
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { cn } from "../lib/cn";
|
|
3
|
+
|
|
4
|
+
export type CircularProgressProps = React.ComponentPropsWithoutRef<"span"> & {
|
|
5
|
+
variant?: "indeterminate" | "determinate";
|
|
6
|
+
value?: number;
|
|
7
|
+
size?: number;
|
|
8
|
+
thickness?: number;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Circular indicator. Indeterminate spins; determinate fills an SVG track.
|
|
13
|
+
*/
|
|
14
|
+
function CircularProgress({
|
|
15
|
+
variant = "indeterminate",
|
|
16
|
+
value = 0,
|
|
17
|
+
size = 40,
|
|
18
|
+
thickness = 4,
|
|
19
|
+
className,
|
|
20
|
+
...props
|
|
21
|
+
}: CircularProgressProps) {
|
|
22
|
+
const pct = Math.min(100, Math.max(0, value));
|
|
23
|
+
const radius = (size - thickness) / 2;
|
|
24
|
+
const circumference = 2 * Math.PI * radius;
|
|
25
|
+
const offset = circumference - (pct / 100) * circumference;
|
|
26
|
+
|
|
27
|
+
if (variant === "indeterminate") {
|
|
28
|
+
return (
|
|
29
|
+
<span
|
|
30
|
+
role="progressbar"
|
|
31
|
+
aria-label="Loading"
|
|
32
|
+
data-slot="circular-progress"
|
|
33
|
+
className={cn("inline-flex text-primary", className)}
|
|
34
|
+
{...props}
|
|
35
|
+
>
|
|
36
|
+
<svg
|
|
37
|
+
className="animate-spin"
|
|
38
|
+
width={size}
|
|
39
|
+
height={size}
|
|
40
|
+
viewBox={`0 0 ${size} ${size}`}
|
|
41
|
+
>
|
|
42
|
+
<circle
|
|
43
|
+
cx={size / 2}
|
|
44
|
+
cy={size / 2}
|
|
45
|
+
r={radius}
|
|
46
|
+
fill="none"
|
|
47
|
+
stroke="currentColor"
|
|
48
|
+
strokeOpacity={0.2}
|
|
49
|
+
strokeWidth={thickness}
|
|
50
|
+
/>
|
|
51
|
+
<circle
|
|
52
|
+
cx={size / 2}
|
|
53
|
+
cy={size / 2}
|
|
54
|
+
r={radius}
|
|
55
|
+
fill="none"
|
|
56
|
+
stroke="currentColor"
|
|
57
|
+
strokeWidth={thickness}
|
|
58
|
+
strokeLinecap="round"
|
|
59
|
+
strokeDasharray={`${circumference * 0.25} ${circumference}`}
|
|
60
|
+
/>
|
|
61
|
+
</svg>
|
|
62
|
+
</span>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<span
|
|
68
|
+
role="progressbar"
|
|
69
|
+
aria-valuemin={0}
|
|
70
|
+
aria-valuemax={100}
|
|
71
|
+
aria-valuenow={pct}
|
|
72
|
+
data-slot="circular-progress"
|
|
73
|
+
className={cn("inline-flex text-primary", className)}
|
|
74
|
+
{...props}
|
|
75
|
+
>
|
|
76
|
+
<svg width={size} height={size} viewBox={`0 0 ${size} ${size}`} className="-rotate-90">
|
|
77
|
+
<circle
|
|
78
|
+
cx={size / 2}
|
|
79
|
+
cy={size / 2}
|
|
80
|
+
r={radius}
|
|
81
|
+
fill="none"
|
|
82
|
+
stroke="currentColor"
|
|
83
|
+
strokeOpacity={0.2}
|
|
84
|
+
strokeWidth={thickness}
|
|
85
|
+
/>
|
|
86
|
+
<circle
|
|
87
|
+
cx={size / 2}
|
|
88
|
+
cy={size / 2}
|
|
89
|
+
r={radius}
|
|
90
|
+
fill="none"
|
|
91
|
+
stroke="currentColor"
|
|
92
|
+
strokeWidth={thickness}
|
|
93
|
+
strokeLinecap="round"
|
|
94
|
+
strokeDasharray={circumference}
|
|
95
|
+
strokeDashoffset={offset}
|
|
96
|
+
className="transition-[stroke-dashoffset] duration-300"
|
|
97
|
+
/>
|
|
98
|
+
</svg>
|
|
99
|
+
</span>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
CircularProgress.displayName = "CircularProgress";
|
|
103
|
+
|
|
104
|
+
export { CircularProgress };
|