@nsaa/core 0.1.0-alpha.4 → 0.1.0-alpha.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/button/button.js +1 -0
- package/dist/date-range-picker/date-range-picker.d.ts +55 -0
- package/dist/date-range-picker/date-range-picker.js +359 -0
- package/dist/date-range-picker/index.d.ts +4 -0
- package/dist/date-range-picker/presets.d.ts +25 -0
- package/dist/date-range-picker/presets.js +115 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.js +11 -4
- package/dist/lib/dev.js +14 -0
- package/dist/meter/index.d.ts +3 -0
- package/dist/meter/meter.d.ts +33 -0
- package/dist/meter/meter.js +145 -0
- package/dist/money/index.d.ts +3 -0
- package/dist/money/money.d.ts +28 -0
- package/dist/money/money.js +77 -0
- package/dist/progress/index.d.ts +3 -0
- package/dist/progress/progress.d.ts +8 -0
- package/dist/progress/progress.js +43 -0
- package/dist/sidebar/index.d.ts +3 -0
- package/dist/sidebar/sidebar.d.ts +66 -0
- package/dist/sidebar/sidebar.js +449 -0
- package/dist/sidebar/use-mobile.js +13 -0
- package/dist/sources/date-range-picker.css +29 -0
- package/dist/sources/meter.css +3 -0
- package/dist/sources/money.css +3 -0
- package/dist/sources/progress.css +3 -0
- package/dist/sources/sidebar.css +32 -0
- package/dist/sources/stat.css +4 -0
- package/dist/stat/index.d.ts +3 -0
- package/dist/stat/stat.d.ts +47 -0
- package/dist/stat/stat.js +161 -0
- package/dist/tokens/dist/motion.js +19 -1
- package/dist/toolbar/toolbar-item.js +1 -1
- package/dist/toolbar/toolbar.js +1 -1
- package/package.json +2 -2
- package/src/feel.css +104 -3
package/dist/index.js
CHANGED
|
@@ -22,8 +22,11 @@ import { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxColl
|
|
|
22
22
|
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger } from "./dialog/dialog.js";
|
|
23
23
|
import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut } from "./command/command.js";
|
|
24
24
|
import { ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger } from "./context-menu/context-menu.js";
|
|
25
|
-
import { DirectionProvider } from "./direction.js";
|
|
26
25
|
import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerSwipeHandle, DrawerTitle, DrawerTrigger } from "./drawer/drawer.js";
|
|
26
|
+
import { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger } from "./popover/popover.js";
|
|
27
|
+
import { localeWeekStart, matchPreset, presets, todayIn } from "./date-range-picker/presets.js";
|
|
28
|
+
import { DateRangePicker } from "./date-range-picker/date-range-picker.js";
|
|
29
|
+
import { DirectionProvider } from "./direction.js";
|
|
27
30
|
import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger } from "./dropdown-menu/dropdown-menu.js";
|
|
28
31
|
import { Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, useEmptyIllustration } from "./empty/empty.js";
|
|
29
32
|
import { Label } from "./label/label.js";
|
|
@@ -32,20 +35,24 @@ import { Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLab
|
|
|
32
35
|
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from "./input-otp/input-otp.js";
|
|
33
36
|
import { Kbd, KbdGroup } from "./kbd/kbd.js";
|
|
34
37
|
import { IconSwap } from "./lib/icon-swap.js";
|
|
38
|
+
import { Meter, MeterIndicator, MeterLabel, MeterLegend, MeterSegment, MeterTrack, MeterValue } from "./meter/meter.js";
|
|
39
|
+
import { Money, formatMoney } from "./money/money.js";
|
|
35
40
|
import { NativeSelect, NativeSelectOptGroup, NativeSelectOption } from "./native-select/native-select.js";
|
|
36
41
|
import { Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious } from "./pagination/pagination.js";
|
|
37
|
-
import {
|
|
42
|
+
import { Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue } from "./progress/progress.js";
|
|
38
43
|
import { RadioGroup, RadioGroupItem } from "./radio-group/radio-group.js";
|
|
39
44
|
import { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue } from "./select/select.js";
|
|
40
45
|
import { Skeleton, SkeletonContent } from "./skeleton/skeleton.js";
|
|
46
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip/tooltip.js";
|
|
47
|
+
import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar } from "./sidebar/sidebar.js";
|
|
41
48
|
import { Slider } from "./slider/slider.js";
|
|
42
49
|
import { lazyUisfxPlayer } from "./sound/lazy-uisfx.js";
|
|
50
|
+
import { Stat, StatAction, StatChange, StatDescription, StatGroup, StatIcon, StatLabel, StatValue } from "./stat/stat.js";
|
|
43
51
|
import { Switch } from "./switch/switch.js";
|
|
44
52
|
import { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from "./table/table.js";
|
|
45
53
|
import { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants } from "./tabs/tabs.js";
|
|
46
54
|
import { Toast, ToastAction, ToastClose, ToastContent, ToastDescription, ToastPortal, ToastProvider, ToastTitle, ToastViewport, Toaster, createToastManager, toast, useToastManager } from "./toast/toast.js";
|
|
47
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./tooltip/tooltip.js";
|
|
48
55
|
import { ToggleGroup } from "./toggle-group/toggle-group.js";
|
|
49
56
|
import { Toolbar } from "./toolbar/toolbar.js";
|
|
50
57
|
import "./lib/track-input-modality.js";
|
|
51
|
-
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertClose, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertLink, AlertLinks, AlertTitle, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DirectionProvider, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerSwipeHandle, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, IconSwap, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Kbd, KbdGroup, Label, LoaderProvider, NativeSelect, NativeSelectOptGroup, NativeSelectOption, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, RadioGroup, RadioGroupItem, SOUND_MAP, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Skeleton, SkeletonContent, Slider, SoundProvider, Spinner, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, ToastAction, ToastClose, ToastContent, ToastDescription, ToastPortal, ToastProvider, ToastTitle, ToastViewport, Toaster, ToggleGroup, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, createToastManager, lazyUisfxPlayer, registerLoader, registerLoaders, tabsListVariants, toast, useComboboxAnchor, useEmptyIllustration, useSound, useToastManager };
|
|
58
|
+
export { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Alert, AlertAction, AlertClose, AlertDescription, AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogOverlay, AlertDialogPortal, AlertDialogTitle, AlertDialogTrigger, AlertLink, AlertLinks, AlertTitle, Avatar, AvatarBadge, AvatarFallback, AvatarGroup, AvatarGroupCount, AvatarImage, Badge, Button, Calendar, CalendarDayButton, Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, Checkbox, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxCollection, ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxInput, ComboboxItem, ComboboxLabel, ComboboxList, ComboboxSeparator, ComboboxTrigger, ComboboxValue, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, ContextMenu, ContextMenuCheckboxItem, ContextMenuContent, ContextMenuGroup, ContextMenuItem, ContextMenuLabel, ContextMenuPortal, ContextMenuRadioGroup, ContextMenuRadioItem, ContextMenuSeparator, ContextMenuShortcut, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, DateRangePicker, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DirectionProvider, Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerOverlay, DrawerPortal, DrawerSwipeHandle, DrawerTitle, DrawerTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, Empty, EmptyContent, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle, Field, FieldContent, FieldDescription, FieldError, FieldGroup, FieldLabel, FieldLegend, FieldSeparator, FieldSet, FieldTitle, IconSwap, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot, Kbd, KbdGroup, Label, LoaderProvider, Meter, MeterIndicator, MeterLabel, MeterLegend, MeterSegment, MeterTrack, MeterValue, Money, NativeSelect, NativeSelectOptGroup, NativeSelectOption, Pagination, PaginationContent, PaginationEllipsis, PaginationItem, PaginationLink, PaginationNext, PaginationPrevious, Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger, Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue, RadioGroup, RadioGroupItem, SOUND_MAP, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, Separator, Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, Skeleton, SkeletonContent, Slider, SoundProvider, Spinner, Stat, StatAction, StatChange, StatDescription, StatGroup, StatIcon, StatLabel, StatValue, Switch, Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Toast, ToastAction, ToastClose, ToastContent, ToastDescription, ToastPortal, ToastProvider, ToastTitle, ToastViewport, Toaster, ToggleGroup, Toolbar, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, badgeVariants, buttonVariants, cn, createToastManager, formatMoney, lazyUisfxPlayer, localeWeekStart, matchPreset, presets, registerLoader, registerLoaders, tabsListVariants, toast, todayIn, useComboboxAnchor, useEmptyIllustration, useSidebar, useSound, useToastManager };
|
package/dist/lib/dev.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
// src/lib/dev.ts
|
|
3
|
+
/**
|
|
4
|
+
* True outside production builds. Bundlers replace `process.env.NODE_ENV` statically; where
|
|
5
|
+
* nothing defines `process` (e.g. raw ESM in a browser) dev warnings are simply skipped.
|
|
6
|
+
*/
|
|
7
|
+
function isDev() {
|
|
8
|
+
try {
|
|
9
|
+
return true;
|
|
10
|
+
} catch {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export { isDev };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
|
|
2
|
+
import { Meter, MeterIndicator, MeterLabel, MeterLegend, MeterProps, MeterSegment, MeterSegmentProps, MeterTrack, MeterValue } from "./meter.js";
|
|
3
|
+
export { Meter, MeterIndicator, MeterLabel, MeterLegend, type MeterProps, MeterSegment, type MeterSegmentProps, MeterTrack, MeterValue };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Meter } from "@base-ui/react/meter";
|
|
4
|
+
type MeterVariant = "default" | "success" | "warning" | "destructive" | "info";
|
|
5
|
+
type ChartColor = "chart-1" | "chart-2" | "chart-3" | "chart-4" | "chart-5";
|
|
6
|
+
type MeterSegmentProps = Omit<React.ComponentProps<"div">, "color"> & {
|
|
7
|
+
/** This part's amount, on the Meter's `min`–`max` scale. */
|
|
8
|
+
value: number;
|
|
9
|
+
/** Its name, in the legend and the track's text alternative. */
|
|
10
|
+
label: string;
|
|
11
|
+
/** A status colour. Ignored when `color` is set. */
|
|
12
|
+
variant?: MeterVariant;
|
|
13
|
+
/** A chart colour token (`chart-1` … `chart-5`). */
|
|
14
|
+
color?: ChartColor;
|
|
15
|
+
};
|
|
16
|
+
type MeterProps = Omit<Meter.Root.Props, "value"> & {
|
|
17
|
+
/** The amount. Leave it out when MeterSegment children give the parts. */
|
|
18
|
+
value?: number;
|
|
19
|
+
/** The fill colour: default (brand), success, warning, destructive or info. */
|
|
20
|
+
variant?: MeterVariant;
|
|
21
|
+
/** Track height: default 8 px, sm 4 px. */
|
|
22
|
+
size?: "default" | "sm";
|
|
23
|
+
};
|
|
24
|
+
declare function Meter$1({ className, children, value, min, max, variant, size, getAriaValueText, ...props }: MeterProps): React.JSX.Element;
|
|
25
|
+
declare function MeterTrack({ className, children, ...props }: Meter.Track.Props): React.JSX.Element;
|
|
26
|
+
declare function MeterIndicator({ className, ...props }: Meter.Indicator.Props): React.JSX.Element;
|
|
27
|
+
/** One part of a segmented track. Parts under 2% keep 2 px so they stay visible. */
|
|
28
|
+
declare function MeterSegment({ className, value, label, variant, color, style, ...props }: MeterSegmentProps): React.JSX.Element;
|
|
29
|
+
/** Lists each segment with a swatch, its label and its share. */
|
|
30
|
+
declare function MeterLegend({ className, ...props }: React.ComponentProps<"ul">): React.JSX.Element;
|
|
31
|
+
declare function MeterLabel({ className, ...props }: Meter.Label.Props): React.JSX.Element;
|
|
32
|
+
declare function MeterValue({ className, ...props }: Meter.Value.Props): React.JSX.Element;
|
|
33
|
+
export { Meter$1 as Meter, MeterIndicator, MeterLabel, MeterLegend, type MeterProps, MeterSegment, type MeterSegmentProps, MeterTrack, MeterValue };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
import { Meter } from "@base-ui/react/meter";
|
|
6
|
+
// src/meter/meter.tsx
|
|
7
|
+
const FILL = {
|
|
8
|
+
default: "bg-(--nsaa-color-brand-foreground)",
|
|
9
|
+
success: "bg-(--nsaa-color-positive-foreground)",
|
|
10
|
+
warning: "bg-(--nsaa-color-warning-foreground)",
|
|
11
|
+
destructive: "bg-(--nsaa-color-danger-foreground)",
|
|
12
|
+
info: "bg-(--nsaa-color-info-foreground)",
|
|
13
|
+
"chart-1": "bg-chart-1",
|
|
14
|
+
"chart-2": "bg-chart-2",
|
|
15
|
+
"chart-3": "bg-chart-3",
|
|
16
|
+
"chart-4": "bg-chart-4",
|
|
17
|
+
"chart-5": "bg-chart-5"
|
|
18
|
+
};
|
|
19
|
+
const MeterContext = React.createContext({
|
|
20
|
+
variant: "default",
|
|
21
|
+
size: "default",
|
|
22
|
+
min: 0,
|
|
23
|
+
max: 100,
|
|
24
|
+
segments: [],
|
|
25
|
+
format: new Intl.NumberFormat(void 0, {
|
|
26
|
+
style: "percent",
|
|
27
|
+
maximumFractionDigits: 0
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
/** Segments are read from the Meter's children (MeterTrack > MeterSegment), so the legend and the
|
|
31
|
+
text alternative need no registration pass. */
|
|
32
|
+
function collectSegments(children) {
|
|
33
|
+
const found = [];
|
|
34
|
+
React.Children.forEach(children, (child) => {
|
|
35
|
+
if (!React.isValidElement(child)) return;
|
|
36
|
+
if (child.type === MeterSegment) found.push(child.props);
|
|
37
|
+
else if (child.type === MeterTrack) found.push(...collectSegments(child.props.children));
|
|
38
|
+
});
|
|
39
|
+
return found;
|
|
40
|
+
}
|
|
41
|
+
function hasTrack(children) {
|
|
42
|
+
return React.Children.toArray(children).some((child) => React.isValidElement(child) && child.type === MeterTrack);
|
|
43
|
+
}
|
|
44
|
+
function Meter$1({ className, children, value, min = 0, max = 100, variant = "default", size = "default", getAriaValueText, ...props }) {
|
|
45
|
+
const segments = collectSegments(children);
|
|
46
|
+
const format = React.useMemo(() => new Intl.NumberFormat(void 0, {
|
|
47
|
+
style: "percent",
|
|
48
|
+
maximumFractionDigits: 0
|
|
49
|
+
}), []);
|
|
50
|
+
const share = (v) => format.format((v - (segments.length ? 0 : min)) / (max - min));
|
|
51
|
+
const total = segments.length ? segments.reduce((sum, s) => sum + s.value, min) : value ?? min;
|
|
52
|
+
const segmentText = segments.length ? segments.map((s) => `${s.label} ${share(s.value)}`).join(", ") : void 0;
|
|
53
|
+
return /* @__PURE__ */ jsx(MeterContext.Provider, {
|
|
54
|
+
value: {
|
|
55
|
+
variant,
|
|
56
|
+
size,
|
|
57
|
+
min,
|
|
58
|
+
max,
|
|
59
|
+
segments,
|
|
60
|
+
format
|
|
61
|
+
},
|
|
62
|
+
children: /* @__PURE__ */ jsxs(Meter.Root, {
|
|
63
|
+
value: total,
|
|
64
|
+
min,
|
|
65
|
+
max,
|
|
66
|
+
"data-slot": "meter",
|
|
67
|
+
"data-size": size,
|
|
68
|
+
getAriaValueText: segmentText ? () => segmentText : getAriaValueText,
|
|
69
|
+
className: cn("flex flex-wrap gap-x-3 gap-y-2", className),
|
|
70
|
+
...props,
|
|
71
|
+
children: [children, !hasTrack(children) && /* @__PURE__ */ jsx(MeterTrack, { children: /* @__PURE__ */ jsx(MeterIndicator, {}) })]
|
|
72
|
+
})
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
function MeterTrack({ className, children, ...props }) {
|
|
76
|
+
const { size, segments } = React.useContext(MeterContext);
|
|
77
|
+
return /* @__PURE__ */ jsx(Meter.Track, {
|
|
78
|
+
"data-slot": "meter-track",
|
|
79
|
+
className: cn("relative flex w-full items-center overflow-hidden rounded-full bg-muted", size === "sm" ? "h-1" : "h-2", segments.length > 0 && "gap-0.5 bg-transparent", className),
|
|
80
|
+
...props,
|
|
81
|
+
children
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function MeterIndicator({ className, ...props }) {
|
|
85
|
+
const { variant } = React.useContext(MeterContext);
|
|
86
|
+
return /* @__PURE__ */ jsx(Meter.Indicator, {
|
|
87
|
+
"data-slot": "meter-indicator",
|
|
88
|
+
className: cn("h-full rounded-full", FILL[variant], className),
|
|
89
|
+
...props
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/** One part of a segmented track. Parts under 2% keep 2 px so they stay visible. */
|
|
93
|
+
function MeterSegment({ className, value, label, variant, color, style, ...props }) {
|
|
94
|
+
const { min, max } = React.useContext(MeterContext);
|
|
95
|
+
return /* @__PURE__ */ jsx("div", {
|
|
96
|
+
"data-slot": "meter-segment",
|
|
97
|
+
"aria-hidden": "true",
|
|
98
|
+
"data-label": label,
|
|
99
|
+
className: cn("h-full min-w-0.5 rounded-full", FILL[color ?? variant ?? "chart-1"], className),
|
|
100
|
+
style: {
|
|
101
|
+
flexBasis: `${(value - min) / (max - min) * 100}%`,
|
|
102
|
+
...style
|
|
103
|
+
},
|
|
104
|
+
...props
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Lists each segment with a swatch, its label and its share. */
|
|
108
|
+
function MeterLegend({ className, ...props }) {
|
|
109
|
+
const { segments, min, max, format } = React.useContext(MeterContext);
|
|
110
|
+
return /* @__PURE__ */ jsx("ul", {
|
|
111
|
+
"data-slot": "meter-legend",
|
|
112
|
+
className: cn("flex w-full flex-wrap gap-x-4 gap-y-1 text-sm", className),
|
|
113
|
+
...props,
|
|
114
|
+
children: segments.map((segment) => /* @__PURE__ */ jsxs("li", {
|
|
115
|
+
"data-slot": "meter-legend-item",
|
|
116
|
+
className: "inline-flex items-center gap-1.5",
|
|
117
|
+
children: [
|
|
118
|
+
/* @__PURE__ */ jsx("span", {
|
|
119
|
+
"aria-hidden": "true",
|
|
120
|
+
className: cn("size-2 shrink-0 rounded-full", FILL[segment.color ?? segment.variant ?? "chart-1"])
|
|
121
|
+
}),
|
|
122
|
+
/* @__PURE__ */ jsx("span", { children: segment.label }),
|
|
123
|
+
/* @__PURE__ */ jsx("span", {
|
|
124
|
+
className: "text-muted-foreground tabular-nums",
|
|
125
|
+
children: format.format((segment.value - min) / (max - min))
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
}, segment.label))
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
function MeterLabel({ className, ...props }) {
|
|
132
|
+
return /* @__PURE__ */ jsx(Meter.Label, {
|
|
133
|
+
"data-slot": "meter-label",
|
|
134
|
+
className: cn("text-sm font-medium", className),
|
|
135
|
+
...props
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function MeterValue({ className, ...props }) {
|
|
139
|
+
return /* @__PURE__ */ jsx(Meter.Value, {
|
|
140
|
+
"data-slot": "meter-value",
|
|
141
|
+
className: cn("ms-auto text-sm text-muted-foreground tabular-nums", className),
|
|
142
|
+
...props
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
export { Meter$1 as Meter, MeterIndicator, MeterLabel, MeterLegend, MeterSegment, MeterTrack, MeterValue };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
type MoneyOptions = {
|
|
4
|
+
/** ISO 4217 code, such as `GHS` or `USD`. */
|
|
5
|
+
currency: string;
|
|
6
|
+
/** BCP 47 locale. Defaults to the document's `lang`, then the runtime's locale. */
|
|
7
|
+
locale?: string;
|
|
8
|
+
/** `minor` (default): `value` is an integer in minor units (pesewas, cents). `major`: a decimal amount. */
|
|
9
|
+
unit?: "minor" | "major";
|
|
10
|
+
/** How the currency shows: `symbol` (default), `narrowSymbol`, `code`, or `none` (digits only). */
|
|
11
|
+
currencyDisplay?: "symbol" | "narrowSymbol" | "code" | "none";
|
|
12
|
+
/** `standard` (default) or `compact` (GH₵12.3M). */
|
|
13
|
+
notation?: "standard" | "compact";
|
|
14
|
+
/** When the sign shows: `auto` (default), `always` or `exceptZero`. */
|
|
15
|
+
signDisplay?: "auto" | "always" | "exceptZero";
|
|
16
|
+
/** Negative amounts: `minus` (default, a true minus sign) or `parentheses` (accounting). */
|
|
17
|
+
negative?: "minus" | "parentheses";
|
|
18
|
+
};
|
|
19
|
+
/** The same string `<Money>` shows, for CSV, titles and charts. */
|
|
20
|
+
declare function formatMoney(value: number, options: MoneyOptions): string;
|
|
21
|
+
type MoneyProps = Omit<React.ComponentProps<"span">, "children"> & MoneyOptions & {
|
|
22
|
+
/** The amount: minor units unless `unit="major"`. */
|
|
23
|
+
value: number;
|
|
24
|
+
/** `auto`: negative amounts take the danger colour, positive ones with `signDisplay="always"` the positive colour. The sign always shows, so colour is never the only signal. */
|
|
25
|
+
tone?: "none" | "auto";
|
|
26
|
+
};
|
|
27
|
+
declare function Money({ value, currency, locale, unit, currencyDisplay, notation, signDisplay, negative, tone, className, ...props }: MoneyProps): React.JSX.Element;
|
|
28
|
+
export { Money, type MoneyOptions, type MoneyProps, formatMoney };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
// src/money/money.tsx
|
|
5
|
+
const MINUS = "−";
|
|
6
|
+
function resolveLocale(locale) {
|
|
7
|
+
if (locale) return locale;
|
|
8
|
+
if (typeof document !== "undefined" && document.documentElement.lang) return document.documentElement.lang;
|
|
9
|
+
}
|
|
10
|
+
/** The currency's own decimals (2 for GHS and USD, 0 for JPY), from Intl. */
|
|
11
|
+
function fractionDigits(currency) {
|
|
12
|
+
return new Intl.NumberFormat("en", {
|
|
13
|
+
style: "currency",
|
|
14
|
+
currency
|
|
15
|
+
}).resolvedOptions().maximumFractionDigits;
|
|
16
|
+
}
|
|
17
|
+
function moneyParts(value, options) {
|
|
18
|
+
const { currency, unit = "minor", currencyDisplay = "symbol", notation = "standard", signDisplay = "auto", negative = "minus" } = options;
|
|
19
|
+
const amount = unit === "minor" ? value / 10 ** fractionDigits(currency) : value;
|
|
20
|
+
return new Intl.NumberFormat(resolveLocale(options.locale), {
|
|
21
|
+
style: "currency",
|
|
22
|
+
currency,
|
|
23
|
+
currencyDisplay: currencyDisplay === "none" ? "symbol" : currencyDisplay,
|
|
24
|
+
currencySign: negative === "parentheses" ? "accounting" : "standard",
|
|
25
|
+
notation,
|
|
26
|
+
signDisplay
|
|
27
|
+
}).formatToParts(amount).filter((part) => !(currencyDisplay === "none" && part.type === "currency")).map((part) => part.type === "minusSign" ? {
|
|
28
|
+
...part,
|
|
29
|
+
value: MINUS
|
|
30
|
+
} : part);
|
|
31
|
+
}
|
|
32
|
+
/** The same string `<Money>` shows, for CSV, titles and charts. */
|
|
33
|
+
function formatMoney(value, options) {
|
|
34
|
+
return moneyParts(value, options).map((part) => part.value).join("").trim();
|
|
35
|
+
}
|
|
36
|
+
function Money({ value, currency, locale, unit, currencyDisplay, notation, signDisplay, negative, tone = "none", className, ...props }) {
|
|
37
|
+
const options = {
|
|
38
|
+
currency,
|
|
39
|
+
locale,
|
|
40
|
+
unit,
|
|
41
|
+
currencyDisplay,
|
|
42
|
+
notation,
|
|
43
|
+
signDisplay,
|
|
44
|
+
negative
|
|
45
|
+
};
|
|
46
|
+
const parts = moneyParts(value, options);
|
|
47
|
+
const spoken = negative === "parentheses" && value < 0 ? formatMoney(value, {
|
|
48
|
+
...options,
|
|
49
|
+
negative: "minus"
|
|
50
|
+
}) : null;
|
|
51
|
+
const runs = [];
|
|
52
|
+
for (const part of parts) {
|
|
53
|
+
const symbol = part.type === "currency";
|
|
54
|
+
const last = runs.at(-1);
|
|
55
|
+
if (last && last.symbol === symbol && !symbol) last.text += part.value;
|
|
56
|
+
else runs.push({
|
|
57
|
+
symbol,
|
|
58
|
+
text: part.value
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
62
|
+
"data-slot": "money",
|
|
63
|
+
className: cn("whitespace-nowrap tabular-nums lining-nums", tone === "auto" ? value < 0 ? "text-(--nsaa-color-danger-foreground)" : value > 0 && signDisplay === "always" ? "text-(--nsaa-color-positive-foreground)" : void 0 : void 0, className),
|
|
64
|
+
...props,
|
|
65
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
66
|
+
"aria-hidden": spoken ? true : void 0,
|
|
67
|
+
children: runs.map((run, index) => /* @__PURE__ */ jsx("span", {
|
|
68
|
+
"data-slot": run.symbol ? "money-symbol" : "money-amount",
|
|
69
|
+
children: run.text
|
|
70
|
+
}, index))
|
|
71
|
+
}), spoken && /* @__PURE__ */ jsx("span", {
|
|
72
|
+
className: "sr-only",
|
|
73
|
+
children: spoken
|
|
74
|
+
})]
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export { Money, formatMoney };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
|
|
2
|
+
import { Progress } from "@base-ui/react/progress";
|
|
3
|
+
declare function Progress$1({ className, children, value, ...props }: Progress.Root.Props): import("react").JSX.Element;
|
|
4
|
+
declare function ProgressTrack({ className, ...props }: Progress.Track.Props): import("react").JSX.Element;
|
|
5
|
+
declare function ProgressIndicator({ className, ...props }: Progress.Indicator.Props): import("react").JSX.Element;
|
|
6
|
+
declare function ProgressLabel({ className, ...props }: Progress.Label.Props): import("react").JSX.Element;
|
|
7
|
+
declare function ProgressValue({ className, ...props }: Progress.Value.Props): import("react").JSX.Element;
|
|
8
|
+
export { Progress$1 as Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Progress } from "@base-ui/react/progress";
|
|
5
|
+
// src/progress/progress.tsx
|
|
6
|
+
function Progress$1({ className, children, value, ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsxs(Progress.Root, {
|
|
8
|
+
value,
|
|
9
|
+
"data-slot": "progress",
|
|
10
|
+
className: cn("flex flex-wrap gap-3", className),
|
|
11
|
+
...props,
|
|
12
|
+
children: [children, /* @__PURE__ */ jsx(ProgressTrack, { children: /* @__PURE__ */ jsx(ProgressIndicator, {}) })]
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
function ProgressTrack({ className, ...props }) {
|
|
16
|
+
return /* @__PURE__ */ jsx(Progress.Track, {
|
|
17
|
+
className: cn("relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted", className),
|
|
18
|
+
"data-slot": "progress-track",
|
|
19
|
+
...props
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function ProgressIndicator({ className, ...props }) {
|
|
23
|
+
return /* @__PURE__ */ jsx(Progress.Indicator, {
|
|
24
|
+
"data-slot": "progress-indicator",
|
|
25
|
+
className: cn("h-full bg-primary transition-all", className),
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function ProgressLabel({ className, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx(Progress.Label, {
|
|
31
|
+
className: cn("text-sm font-medium", className),
|
|
32
|
+
"data-slot": "progress-label",
|
|
33
|
+
...props
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function ProgressValue({ className, ...props }) {
|
|
37
|
+
return /* @__PURE__ */ jsx(Progress.Value, {
|
|
38
|
+
className: cn("ml-auto text-sm text-muted-foreground tabular-nums", className),
|
|
39
|
+
"data-slot": "progress-value",
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
export { Progress$1 as Progress, ProgressIndicator, ProgressLabel, ProgressTrack, ProgressValue };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
|
|
2
|
+
import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar } from "./sidebar.js";
|
|
3
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
|
|
2
|
+
import { Button } from "../button/button.js";
|
|
3
|
+
import { Input } from "../input/input.js";
|
|
4
|
+
import { Separator } from "../separator/separator.js";
|
|
5
|
+
import { TooltipContent } from "../tooltip/tooltip.js";
|
|
6
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
7
|
+
import { VariantProps } from "class-variance-authority";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
type SidebarContextProps = {
|
|
10
|
+
state: "expanded" | "collapsed";
|
|
11
|
+
open: boolean;
|
|
12
|
+
setOpen: (open: boolean) => void;
|
|
13
|
+
openMobile: boolean;
|
|
14
|
+
setOpenMobile: (open: boolean) => void;
|
|
15
|
+
isMobile: boolean;
|
|
16
|
+
toggleSidebar: () => void;
|
|
17
|
+
};
|
|
18
|
+
declare function useSidebar(): SidebarContextProps;
|
|
19
|
+
declare function SidebarProvider({ defaultOpen, open: openProp, onOpenChange: setOpenProp, className, style, children, ...props }: React.ComponentProps<"div"> & {
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
open?: boolean;
|
|
22
|
+
onOpenChange?: (open: boolean) => void;
|
|
23
|
+
}): React.JSX.Element;
|
|
24
|
+
declare function Sidebar({ side, variant, collapsible, className, children, dir, "aria-label": ariaLabel, ...props }: React.ComponentProps<"div"> & {
|
|
25
|
+
side?: "left" | "right";
|
|
26
|
+
variant?: "sidebar" | "floating" | "inset";
|
|
27
|
+
collapsible?: "offcanvas" | "icon" | "none";
|
|
28
|
+
}): React.JSX.Element;
|
|
29
|
+
declare function SidebarTrigger({ className, onClick, ...props }: React.ComponentProps<typeof Button>): React.JSX.Element;
|
|
30
|
+
declare function SidebarRail({ className, ...props }: React.ComponentProps<"button">): React.JSX.Element;
|
|
31
|
+
/** The page beside the sidebar: a `main` landmark. Pass `render={<div />}` when the page already has
|
|
32
|
+
one (a demo, or a sidebar inside a page section). */
|
|
33
|
+
declare function SidebarInset({ className, render, ...props }: useRender.ComponentProps<"main">): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
34
|
+
declare function SidebarInput({ className, ...props }: React.ComponentProps<typeof Input>): React.JSX.Element;
|
|
35
|
+
declare function SidebarHeader({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
36
|
+
declare function SidebarFooter({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
37
|
+
declare function SidebarSeparator({ className, ...props }: React.ComponentProps<typeof Separator>): React.JSX.Element;
|
|
38
|
+
declare function SidebarContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
39
|
+
declare function SidebarGroup({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
40
|
+
declare function SidebarGroupLabel({ className, render, id: idProp, ...props }: useRender.ComponentProps<"div"> & React.ComponentProps<"div">): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
41
|
+
declare function SidebarGroupAction({ className, render, ...props }: useRender.ComponentProps<"button"> & React.ComponentProps<"button">): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
42
|
+
declare function SidebarGroupContent({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
43
|
+
declare function SidebarMenu({ className, ...props }: React.ComponentProps<"ul">): React.JSX.Element;
|
|
44
|
+
declare function SidebarMenuItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
|
|
45
|
+
declare const sidebarMenuButtonVariants: (props?: ({
|
|
46
|
+
variant?: "default" | "outline" | null | undefined;
|
|
47
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
48
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
49
|
+
declare function SidebarMenuButton({ render, isActive, variant, size, tooltip, className, ref, ...props }: useRender.ComponentProps<"button"> & React.ComponentProps<"button"> & {
|
|
50
|
+
isActive?: boolean;
|
|
51
|
+
tooltip?: string | React.ComponentProps<typeof TooltipContent>;
|
|
52
|
+
} & VariantProps<typeof sidebarMenuButtonVariants>): React.JSX.Element;
|
|
53
|
+
declare function SidebarMenuAction({ className, render, showOnHover, ...props }: useRender.ComponentProps<"button"> & React.ComponentProps<"button"> & {
|
|
54
|
+
showOnHover?: boolean;
|
|
55
|
+
}): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
56
|
+
declare function SidebarMenuBadge({ className, ...props }: React.ComponentProps<"div">): React.JSX.Element;
|
|
57
|
+
declare function SidebarMenuSkeleton({ className, showIcon, ...props }: React.ComponentProps<"div"> & {
|
|
58
|
+
showIcon?: boolean;
|
|
59
|
+
}): React.JSX.Element;
|
|
60
|
+
declare function SidebarMenuSub({ className, ...props }: React.ComponentProps<"ul">): React.JSX.Element;
|
|
61
|
+
declare function SidebarMenuSubItem({ className, ...props }: React.ComponentProps<"li">): React.JSX.Element;
|
|
62
|
+
declare function SidebarMenuSubButton({ render, size, isActive, className, ...props }: useRender.ComponentProps<"a"> & React.ComponentProps<"a"> & {
|
|
63
|
+
size?: "sm" | "md";
|
|
64
|
+
isActive?: boolean;
|
|
65
|
+
}): React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
66
|
+
export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupAction, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInput, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSkeleton, SidebarMenuSub, SidebarMenuSubButton, SidebarMenuSubItem, SidebarProvider, SidebarRail, SidebarSeparator, SidebarTrigger, useSidebar };
|