barua-ui 0.4.2 → 0.5.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/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ReactNode, ButtonHTMLAttributes, AnchorHTMLAttributes, InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes, HTMLAttributes, DialogHTMLAttributes, SVGProps, ElementType, TableHTMLAttributes, ImgHTMLAttributes } from 'react';
2
+ import { ReactNode, ButtonHTMLAttributes, AnchorHTMLAttributes, InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes, HTMLAttributes, DialogHTMLAttributes, SVGProps, ElementType, TableHTMLAttributes, ImgHTMLAttributes, RefObject } from 'react';
3
3
 
4
4
  type BaruaTheme = "auto" | "light" | "dark";
5
5
  type BaruaAccent = "blue" | "indigo" | "purple" | "pink" | "teal" | "green";
@@ -1184,7 +1184,49 @@ interface ContextMenuTargetProps extends HTMLAttributes<HTMLElement> {
1184
1184
  /** Right-click, or long-press, opens the named menu at the pointer. */
1185
1185
  declare const ContextMenuTarget: react.ForwardRefExoticComponent<ContextMenuTargetProps & react.RefAttributes<HTMLElement>>;
1186
1186
 
1187
+ type ScrollGeometry = {
1188
+ x: number;
1189
+ y: number;
1190
+ width: number;
1191
+ height: number;
1192
+ contentWidth: number;
1193
+ contentHeight: number;
1194
+ /** 0 at the start, 1 at the end; 0 when there is nothing to scroll. */
1195
+ progressX: number;
1196
+ progressY: number;
1197
+ };
1198
+ /**
1199
+ * onScrollGeometryChange. Pass a ref to a scroll container, or nothing for
1200
+ * the page. Reads are coalesced to one per frame.
1201
+ */
1202
+ declare function useScrollGeometry(ref?: RefObject<HTMLElement | null>, onChange?: (geometry: ScrollGeometry) => void): ScrollGeometry | null;
1203
+ /** onScrollVisibilityChange: true once this much of the element is on screen. */
1204
+ declare function useVisible(ref: RefObject<Element | null>, { threshold }?: {
1205
+ threshold?: number;
1206
+ }): boolean;
1207
+ type SnapPosition = {
1208
+ /** The id of the child in view, or null when it has none. */
1209
+ id: string | null;
1210
+ index: number;
1211
+ /** Scroll to a child by id or index. */
1212
+ to: (target: string | number) => void;
1213
+ };
1214
+ /** scrollPosition(id:): which snap child a scrolling container is showing. */
1215
+ declare function useSnapPosition(ref: RefObject<HTMLElement | null>): SnapPosition;
1216
+ type HapticKind = "selection" | "impact" | "success" | "warning" | "error";
1217
+ /**
1218
+ * sensoryFeedback. Android vibrates; iPhone Safari has no vibration API but
1219
+ * plays the system haptic when a switch toggles, so one is toggled off
1220
+ * screen. Returns false where nothing could be felt.
1221
+ */
1222
+ declare function haptic(kind?: HapticKind): boolean;
1223
+ /**
1224
+ * customizationID: state that survives a reload, under a key. Shares its
1225
+ * storage with barua.js's data-b-persist, so the two can hand over.
1226
+ */
1227
+ declare function usePersistedState<T>(key: string, initial: T): [T, (value: T | ((prev: T) => T)) => void];
1228
+
1187
1229
  /** Join class names, skipping falsy values. */
1188
1230
  declare function cn(...parts: Array<string | false | null | undefined>): string;
1189
1231
 
1190
- export { Accordion, Account, type AccountProps, AccountSwitcher, ActionSheet, type ActionSheetAction, Alert, AlertDialog, type AlertDialogAction, type AlertProps, AppGrid, AppTile, AreaChart, AsyncImage, type AsyncImageProps, Audio, Auth, AuthCard, type AuthCardProps, Avatar, AvatarGroup, type AvatarProps, Axis, type AxisProps, BackButton, Badge, type BadgeProps, Banner, type BannerProps, Bars, type BarsProps, type BaruaAccent, BaruaProvider, type BaruaProviderProps, type BaruaTheme, Bento, Billboard, BillboardActions, BillboardArt, BillboardBody, BillboardLede, BillboardScrim, BillboardTitle, type BlockProps, BottomNav, BottomNavItem, BottomSheet, Breadcrumbs, BulkActions, Button, ButtonGroup, type ButtonGroupProps, ButtonLink, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant, Calendar, CalendarDay, type CalendarDayProps, CalendarGrid, CalendarHeader, CalendarMonth, CalendarView, CalendarViewCell, CalendarViewHead, CalendarWeekday, Callout, Card, CardBody, CardEyebrow, CardFooter, CardGrid, CardHeader, type CardProps, CardRail, CardSubtitle, CardTitle, Carousel, CarouselDots, CarouselSlide, CarouselTrack, Chapter, type ChapterProps, Chart, ChartTip, Checkbox, type CheckboxProps, Chip, type ChipProps, CircularProgress, type CircularProgressProps, CodeBlock, type CodeBlockProps, Columns, type ColumnsProps, Combobox, ComboboxEmpty, ComboboxList, ComboboxOption, type ComboboxOptionProps, CommandCenter, CommandCenterLabel, CommandCenterStatus, CommandCenterTile, CommandFooter, CommandGroupLabel, CommandInput, CommandItem, type CommandItemProps, CommandList, CommandPalette, type CommandPaletteProps, Container, type ContainerProps, ContextMenuTarget, type ContextMenuTargetProps, CountUp, type CountUpProps, type Crumb, Dashboard, DataGrid, DatePicker, DescriptionList, type DescriptionListProps, Disclosure, type DisclosureProps, Divider, type DividerProps, Dock, DockItem, DockTray, Donut, type DonutProps, type DonutSlice, DragHandle, Drawer, DrawerBody, DrawerHeader, type DrawerProps, Dropdown, type DropdownProps, Dropzone, type DropzoneProps, EmptyState, ErrorText, Event, type EventProps, Fab, type FabProps, FeatureRow, type FeatureRowProps, Feed, Field, type FieldProps, Fieldset, Figure, type FigureProps, FileBrowser, FileGrid, FileTile, type FileTileProps, FilterBar, FilterChip, type FilterChipProps, FitText, type FitTextProps, Footnote, Footnotes, Form, FormActions, FormRow, FormSection, type FormSectionProps, Gallery, Gantt, GanttBar, GanttRow, Gauge, type GaugeProps, GlassContainer, GlassInteractive, Grid, GridLines, type GridProps, GroupBox, Grow, HStack, Heatmap, Help, Hero, type HeroProps, HoverCard, HoverCardHost, Icon, type IconName, type IconProps, IconTile, type IconTileProps, ImageLens, ImageViewer, ImageViewerBar, Input, InputGroup, type InputGroupProps, type InputProps, Inspector, Kanban, KanbanColumn, type KanbanColumnProps, KanbanList, Kbd, Label, type LabelProps, Labeled, Landing, Legend, type LegendItem, type LegendProps, Lightbox, type LightboxProps, LineChart, LinearGauge, Link, LinkGroup, LiquidToggle, type LiquidToggleProps, List, ListFooter, ListHeader, ListItem, type ListItemProps, type ListProps, Log, MarketingNav, MarketingNavBrand, MarketingNavLinks, MediaPlaceholder, Menu, MenuBar, MenuBarItem, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, MenuSeparator, Modal, type ModalProps, type NavLinkProps, Notification, Onboarding, OnboardingFeature, type OnboardingFeatureProps, OnboardingHero, Optional, OtpInput, type OtpInputProps, Overline, Pagination, PaginationEllipsis, PaginationItem, type PaginationItemProps, type PaginationProps, PillNav, Popover, type PopoverProps, Poster, PosterFacts, PosterFrame, PosterGrid, PosterInitial, PosterMeta, PosterTitle, Progress, type ProgressProps, PromoBand, type PromoBandProps, Quote, type QuoteProps, RadarChart, Radio, Rail, RailItem, type RailProps, Range, type RangeProps, Resizable, ResizeHandle, Result, type ResultProps, Reveal, type RevealProps, type RevealVariant, SafeArea, ScatterChart, ScrollArea, type ScrollAreaProps, SearchField, SearchResult, type SearchResultProps, SearchResults, Section, Segmented, type SegmentedOption, Select, SelectionCount, Share, Sheet, Sidebar, SidebarGroup, SidebarHeading, SidebarItem, type SidebarItemProps, type SidebarProps, SiteFooter, SiteFooterGroup, SiteFooterGroups, SiteFooterHeading, SiteFooterLegal, Skeleton, SkipLink, Slider, SortControl, Spacer, Span, type SpanProps, Sparkline, type SparklineProps, SpecStrip, Spinner, Split, SplitButton, type SplitButtonProps, Stack, type StackProps, Stage, Stat, StatusBar, StatusBarItem, StatusDot, type Step, StepperInput, type StepperInputProps, Steps, type StepsProps, StoryCard, Swatch, Swatches, Switch, type SwitchProps, SysPage, type SysPageProps, type TabItem, TabPanel, Table, TableNum, type TableProps, TableSortHeader, TableWrap, Tabs, Tag, Task, TaskList, type TaskProps, TaskRow, Text, type TextProps, type TextRole, Textarea, ThemeScript, Thumb, type ThumbProps, Timeline, type TimelineEntry, type TimelineProps, Tip, type ToastOptions, ToastProvider, type ToastVariant, ToggleButton, type ToggleButtonProps, Toolbar, Tooltip, TopNav, TopNavBrand, TopNavLink, TopNavLinks, Tree, TreeItem, type TreeItemProps, Upload, UploadItem, type UploadItemProps, UploadPreview, UploadPreviews, VStack, Video, Wall, Waveform, Web, Workspace, WorkspaceMain, block, buttonClasses, cn, iconNames, useBaruaTheme, useToast };
1232
+ export { Accordion, Account, type AccountProps, AccountSwitcher, ActionSheet, type ActionSheetAction, Alert, AlertDialog, type AlertDialogAction, type AlertProps, AppGrid, AppTile, AreaChart, AsyncImage, type AsyncImageProps, Audio, Auth, AuthCard, type AuthCardProps, Avatar, AvatarGroup, type AvatarProps, Axis, type AxisProps, BackButton, Badge, type BadgeProps, Banner, type BannerProps, Bars, type BarsProps, type BaruaAccent, BaruaProvider, type BaruaProviderProps, type BaruaTheme, Bento, Billboard, BillboardActions, BillboardArt, BillboardBody, BillboardLede, BillboardScrim, BillboardTitle, type BlockProps, BottomNav, BottomNavItem, BottomSheet, Breadcrumbs, BulkActions, Button, ButtonGroup, type ButtonGroupProps, ButtonLink, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant, Calendar, CalendarDay, type CalendarDayProps, CalendarGrid, CalendarHeader, CalendarMonth, CalendarView, CalendarViewCell, CalendarViewHead, CalendarWeekday, Callout, Card, CardBody, CardEyebrow, CardFooter, CardGrid, CardHeader, type CardProps, CardRail, CardSubtitle, CardTitle, Carousel, CarouselDots, CarouselSlide, CarouselTrack, Chapter, type ChapterProps, Chart, ChartTip, Checkbox, type CheckboxProps, Chip, type ChipProps, CircularProgress, type CircularProgressProps, CodeBlock, type CodeBlockProps, Columns, type ColumnsProps, Combobox, ComboboxEmpty, ComboboxList, ComboboxOption, type ComboboxOptionProps, CommandCenter, CommandCenterLabel, CommandCenterStatus, CommandCenterTile, CommandFooter, CommandGroupLabel, CommandInput, CommandItem, type CommandItemProps, CommandList, CommandPalette, type CommandPaletteProps, Container, type ContainerProps, ContextMenuTarget, type ContextMenuTargetProps, CountUp, type CountUpProps, type Crumb, Dashboard, DataGrid, DatePicker, DescriptionList, type DescriptionListProps, Disclosure, type DisclosureProps, Divider, type DividerProps, Dock, DockItem, DockTray, Donut, type DonutProps, type DonutSlice, DragHandle, Drawer, DrawerBody, DrawerHeader, type DrawerProps, Dropdown, type DropdownProps, Dropzone, type DropzoneProps, EmptyState, ErrorText, Event, type EventProps, Fab, type FabProps, FeatureRow, type FeatureRowProps, Feed, Field, type FieldProps, Fieldset, Figure, type FigureProps, FileBrowser, FileGrid, FileTile, type FileTileProps, FilterBar, FilterChip, type FilterChipProps, FitText, type FitTextProps, Footnote, Footnotes, Form, FormActions, FormRow, FormSection, type FormSectionProps, Gallery, Gantt, GanttBar, GanttRow, Gauge, type GaugeProps, GlassContainer, GlassInteractive, Grid, GridLines, type GridProps, GroupBox, Grow, HStack, type HapticKind, Heatmap, Help, Hero, type HeroProps, HoverCard, HoverCardHost, Icon, type IconName, type IconProps, IconTile, type IconTileProps, ImageLens, ImageViewer, ImageViewerBar, Input, InputGroup, type InputGroupProps, type InputProps, Inspector, Kanban, KanbanColumn, type KanbanColumnProps, KanbanList, Kbd, Label, type LabelProps, Labeled, Landing, Legend, type LegendItem, type LegendProps, Lightbox, type LightboxProps, LineChart, LinearGauge, Link, LinkGroup, LiquidToggle, type LiquidToggleProps, List, ListFooter, ListHeader, ListItem, type ListItemProps, type ListProps, Log, MarketingNav, MarketingNavBrand, MarketingNavLinks, MediaPlaceholder, Menu, MenuBar, MenuBarItem, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, MenuSeparator, Modal, type ModalProps, type NavLinkProps, Notification, Onboarding, OnboardingFeature, type OnboardingFeatureProps, OnboardingHero, Optional, OtpInput, type OtpInputProps, Overline, Pagination, PaginationEllipsis, PaginationItem, type PaginationItemProps, type PaginationProps, PillNav, Popover, type PopoverProps, Poster, PosterFacts, PosterFrame, PosterGrid, PosterInitial, PosterMeta, PosterTitle, Progress, type ProgressProps, PromoBand, type PromoBandProps, Quote, type QuoteProps, RadarChart, Radio, Rail, RailItem, type RailProps, Range, type RangeProps, Resizable, ResizeHandle, Result, type ResultProps, Reveal, type RevealProps, type RevealVariant, SafeArea, ScatterChart, ScrollArea, type ScrollAreaProps, type ScrollGeometry, SearchField, SearchResult, type SearchResultProps, SearchResults, Section, Segmented, type SegmentedOption, Select, SelectionCount, Share, Sheet, Sidebar, SidebarGroup, SidebarHeading, SidebarItem, type SidebarItemProps, type SidebarProps, SiteFooter, SiteFooterGroup, SiteFooterGroups, SiteFooterHeading, SiteFooterLegal, Skeleton, SkipLink, Slider, type SnapPosition, SortControl, Spacer, Span, type SpanProps, Sparkline, type SparklineProps, SpecStrip, Spinner, Split, SplitButton, type SplitButtonProps, Stack, type StackProps, Stage, Stat, StatusBar, StatusBarItem, StatusDot, type Step, StepperInput, type StepperInputProps, Steps, type StepsProps, StoryCard, Swatch, Swatches, Switch, type SwitchProps, SysPage, type SysPageProps, type TabItem, TabPanel, Table, TableNum, type TableProps, TableSortHeader, TableWrap, Tabs, Tag, Task, TaskList, type TaskProps, TaskRow, Text, type TextProps, type TextRole, Textarea, ThemeScript, Thumb, type ThumbProps, Timeline, type TimelineEntry, type TimelineProps, Tip, type ToastOptions, ToastProvider, type ToastVariant, ToggleButton, type ToggleButtonProps, Toolbar, Tooltip, TopNav, TopNavBrand, TopNavLink, TopNavLinks, Tree, TreeItem, type TreeItemProps, Upload, UploadItem, type UploadItemProps, UploadPreview, UploadPreviews, VStack, Video, Wall, Waveform, Web, Workspace, WorkspaceMain, block, buttonClasses, cn, haptic, iconNames, useBaruaTheme, usePersistedState, useScrollGeometry, useSnapPosition, useToast, useVisible };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import { ReactNode, ButtonHTMLAttributes, AnchorHTMLAttributes, InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes, HTMLAttributes, DialogHTMLAttributes, SVGProps, ElementType, TableHTMLAttributes, ImgHTMLAttributes } from 'react';
2
+ import { ReactNode, ButtonHTMLAttributes, AnchorHTMLAttributes, InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes, HTMLAttributes, DialogHTMLAttributes, SVGProps, ElementType, TableHTMLAttributes, ImgHTMLAttributes, RefObject } from 'react';
3
3
 
4
4
  type BaruaTheme = "auto" | "light" | "dark";
5
5
  type BaruaAccent = "blue" | "indigo" | "purple" | "pink" | "teal" | "green";
@@ -1184,7 +1184,49 @@ interface ContextMenuTargetProps extends HTMLAttributes<HTMLElement> {
1184
1184
  /** Right-click, or long-press, opens the named menu at the pointer. */
1185
1185
  declare const ContextMenuTarget: react.ForwardRefExoticComponent<ContextMenuTargetProps & react.RefAttributes<HTMLElement>>;
1186
1186
 
1187
+ type ScrollGeometry = {
1188
+ x: number;
1189
+ y: number;
1190
+ width: number;
1191
+ height: number;
1192
+ contentWidth: number;
1193
+ contentHeight: number;
1194
+ /** 0 at the start, 1 at the end; 0 when there is nothing to scroll. */
1195
+ progressX: number;
1196
+ progressY: number;
1197
+ };
1198
+ /**
1199
+ * onScrollGeometryChange. Pass a ref to a scroll container, or nothing for
1200
+ * the page. Reads are coalesced to one per frame.
1201
+ */
1202
+ declare function useScrollGeometry(ref?: RefObject<HTMLElement | null>, onChange?: (geometry: ScrollGeometry) => void): ScrollGeometry | null;
1203
+ /** onScrollVisibilityChange: true once this much of the element is on screen. */
1204
+ declare function useVisible(ref: RefObject<Element | null>, { threshold }?: {
1205
+ threshold?: number;
1206
+ }): boolean;
1207
+ type SnapPosition = {
1208
+ /** The id of the child in view, or null when it has none. */
1209
+ id: string | null;
1210
+ index: number;
1211
+ /** Scroll to a child by id or index. */
1212
+ to: (target: string | number) => void;
1213
+ };
1214
+ /** scrollPosition(id:): which snap child a scrolling container is showing. */
1215
+ declare function useSnapPosition(ref: RefObject<HTMLElement | null>): SnapPosition;
1216
+ type HapticKind = "selection" | "impact" | "success" | "warning" | "error";
1217
+ /**
1218
+ * sensoryFeedback. Android vibrates; iPhone Safari has no vibration API but
1219
+ * plays the system haptic when a switch toggles, so one is toggled off
1220
+ * screen. Returns false where nothing could be felt.
1221
+ */
1222
+ declare function haptic(kind?: HapticKind): boolean;
1223
+ /**
1224
+ * customizationID: state that survives a reload, under a key. Shares its
1225
+ * storage with barua.js's data-b-persist, so the two can hand over.
1226
+ */
1227
+ declare function usePersistedState<T>(key: string, initial: T): [T, (value: T | ((prev: T) => T)) => void];
1228
+
1187
1229
  /** Join class names, skipping falsy values. */
1188
1230
  declare function cn(...parts: Array<string | false | null | undefined>): string;
1189
1231
 
1190
- export { Accordion, Account, type AccountProps, AccountSwitcher, ActionSheet, type ActionSheetAction, Alert, AlertDialog, type AlertDialogAction, type AlertProps, AppGrid, AppTile, AreaChart, AsyncImage, type AsyncImageProps, Audio, Auth, AuthCard, type AuthCardProps, Avatar, AvatarGroup, type AvatarProps, Axis, type AxisProps, BackButton, Badge, type BadgeProps, Banner, type BannerProps, Bars, type BarsProps, type BaruaAccent, BaruaProvider, type BaruaProviderProps, type BaruaTheme, Bento, Billboard, BillboardActions, BillboardArt, BillboardBody, BillboardLede, BillboardScrim, BillboardTitle, type BlockProps, BottomNav, BottomNavItem, BottomSheet, Breadcrumbs, BulkActions, Button, ButtonGroup, type ButtonGroupProps, ButtonLink, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant, Calendar, CalendarDay, type CalendarDayProps, CalendarGrid, CalendarHeader, CalendarMonth, CalendarView, CalendarViewCell, CalendarViewHead, CalendarWeekday, Callout, Card, CardBody, CardEyebrow, CardFooter, CardGrid, CardHeader, type CardProps, CardRail, CardSubtitle, CardTitle, Carousel, CarouselDots, CarouselSlide, CarouselTrack, Chapter, type ChapterProps, Chart, ChartTip, Checkbox, type CheckboxProps, Chip, type ChipProps, CircularProgress, type CircularProgressProps, CodeBlock, type CodeBlockProps, Columns, type ColumnsProps, Combobox, ComboboxEmpty, ComboboxList, ComboboxOption, type ComboboxOptionProps, CommandCenter, CommandCenterLabel, CommandCenterStatus, CommandCenterTile, CommandFooter, CommandGroupLabel, CommandInput, CommandItem, type CommandItemProps, CommandList, CommandPalette, type CommandPaletteProps, Container, type ContainerProps, ContextMenuTarget, type ContextMenuTargetProps, CountUp, type CountUpProps, type Crumb, Dashboard, DataGrid, DatePicker, DescriptionList, type DescriptionListProps, Disclosure, type DisclosureProps, Divider, type DividerProps, Dock, DockItem, DockTray, Donut, type DonutProps, type DonutSlice, DragHandle, Drawer, DrawerBody, DrawerHeader, type DrawerProps, Dropdown, type DropdownProps, Dropzone, type DropzoneProps, EmptyState, ErrorText, Event, type EventProps, Fab, type FabProps, FeatureRow, type FeatureRowProps, Feed, Field, type FieldProps, Fieldset, Figure, type FigureProps, FileBrowser, FileGrid, FileTile, type FileTileProps, FilterBar, FilterChip, type FilterChipProps, FitText, type FitTextProps, Footnote, Footnotes, Form, FormActions, FormRow, FormSection, type FormSectionProps, Gallery, Gantt, GanttBar, GanttRow, Gauge, type GaugeProps, GlassContainer, GlassInteractive, Grid, GridLines, type GridProps, GroupBox, Grow, HStack, Heatmap, Help, Hero, type HeroProps, HoverCard, HoverCardHost, Icon, type IconName, type IconProps, IconTile, type IconTileProps, ImageLens, ImageViewer, ImageViewerBar, Input, InputGroup, type InputGroupProps, type InputProps, Inspector, Kanban, KanbanColumn, type KanbanColumnProps, KanbanList, Kbd, Label, type LabelProps, Labeled, Landing, Legend, type LegendItem, type LegendProps, Lightbox, type LightboxProps, LineChart, LinearGauge, Link, LinkGroup, LiquidToggle, type LiquidToggleProps, List, ListFooter, ListHeader, ListItem, type ListItemProps, type ListProps, Log, MarketingNav, MarketingNavBrand, MarketingNavLinks, MediaPlaceholder, Menu, MenuBar, MenuBarItem, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, MenuSeparator, Modal, type ModalProps, type NavLinkProps, Notification, Onboarding, OnboardingFeature, type OnboardingFeatureProps, OnboardingHero, Optional, OtpInput, type OtpInputProps, Overline, Pagination, PaginationEllipsis, PaginationItem, type PaginationItemProps, type PaginationProps, PillNav, Popover, type PopoverProps, Poster, PosterFacts, PosterFrame, PosterGrid, PosterInitial, PosterMeta, PosterTitle, Progress, type ProgressProps, PromoBand, type PromoBandProps, Quote, type QuoteProps, RadarChart, Radio, Rail, RailItem, type RailProps, Range, type RangeProps, Resizable, ResizeHandle, Result, type ResultProps, Reveal, type RevealProps, type RevealVariant, SafeArea, ScatterChart, ScrollArea, type ScrollAreaProps, SearchField, SearchResult, type SearchResultProps, SearchResults, Section, Segmented, type SegmentedOption, Select, SelectionCount, Share, Sheet, Sidebar, SidebarGroup, SidebarHeading, SidebarItem, type SidebarItemProps, type SidebarProps, SiteFooter, SiteFooterGroup, SiteFooterGroups, SiteFooterHeading, SiteFooterLegal, Skeleton, SkipLink, Slider, SortControl, Spacer, Span, type SpanProps, Sparkline, type SparklineProps, SpecStrip, Spinner, Split, SplitButton, type SplitButtonProps, Stack, type StackProps, Stage, Stat, StatusBar, StatusBarItem, StatusDot, type Step, StepperInput, type StepperInputProps, Steps, type StepsProps, StoryCard, Swatch, Swatches, Switch, type SwitchProps, SysPage, type SysPageProps, type TabItem, TabPanel, Table, TableNum, type TableProps, TableSortHeader, TableWrap, Tabs, Tag, Task, TaskList, type TaskProps, TaskRow, Text, type TextProps, type TextRole, Textarea, ThemeScript, Thumb, type ThumbProps, Timeline, type TimelineEntry, type TimelineProps, Tip, type ToastOptions, ToastProvider, type ToastVariant, ToggleButton, type ToggleButtonProps, Toolbar, Tooltip, TopNav, TopNavBrand, TopNavLink, TopNavLinks, Tree, TreeItem, type TreeItemProps, Upload, UploadItem, type UploadItemProps, UploadPreview, UploadPreviews, VStack, Video, Wall, Waveform, Web, Workspace, WorkspaceMain, block, buttonClasses, cn, iconNames, useBaruaTheme, useToast };
1232
+ export { Accordion, Account, type AccountProps, AccountSwitcher, ActionSheet, type ActionSheetAction, Alert, AlertDialog, type AlertDialogAction, type AlertProps, AppGrid, AppTile, AreaChart, AsyncImage, type AsyncImageProps, Audio, Auth, AuthCard, type AuthCardProps, Avatar, AvatarGroup, type AvatarProps, Axis, type AxisProps, BackButton, Badge, type BadgeProps, Banner, type BannerProps, Bars, type BarsProps, type BaruaAccent, BaruaProvider, type BaruaProviderProps, type BaruaTheme, Bento, Billboard, BillboardActions, BillboardArt, BillboardBody, BillboardLede, BillboardScrim, BillboardTitle, type BlockProps, BottomNav, BottomNavItem, BottomSheet, Breadcrumbs, BulkActions, Button, ButtonGroup, type ButtonGroupProps, ButtonLink, type ButtonLinkProps, type ButtonProps, type ButtonSize, type ButtonVariant, Calendar, CalendarDay, type CalendarDayProps, CalendarGrid, CalendarHeader, CalendarMonth, CalendarView, CalendarViewCell, CalendarViewHead, CalendarWeekday, Callout, Card, CardBody, CardEyebrow, CardFooter, CardGrid, CardHeader, type CardProps, CardRail, CardSubtitle, CardTitle, Carousel, CarouselDots, CarouselSlide, CarouselTrack, Chapter, type ChapterProps, Chart, ChartTip, Checkbox, type CheckboxProps, Chip, type ChipProps, CircularProgress, type CircularProgressProps, CodeBlock, type CodeBlockProps, Columns, type ColumnsProps, Combobox, ComboboxEmpty, ComboboxList, ComboboxOption, type ComboboxOptionProps, CommandCenter, CommandCenterLabel, CommandCenterStatus, CommandCenterTile, CommandFooter, CommandGroupLabel, CommandInput, CommandItem, type CommandItemProps, CommandList, CommandPalette, type CommandPaletteProps, Container, type ContainerProps, ContextMenuTarget, type ContextMenuTargetProps, CountUp, type CountUpProps, type Crumb, Dashboard, DataGrid, DatePicker, DescriptionList, type DescriptionListProps, Disclosure, type DisclosureProps, Divider, type DividerProps, Dock, DockItem, DockTray, Donut, type DonutProps, type DonutSlice, DragHandle, Drawer, DrawerBody, DrawerHeader, type DrawerProps, Dropdown, type DropdownProps, Dropzone, type DropzoneProps, EmptyState, ErrorText, Event, type EventProps, Fab, type FabProps, FeatureRow, type FeatureRowProps, Feed, Field, type FieldProps, Fieldset, Figure, type FigureProps, FileBrowser, FileGrid, FileTile, type FileTileProps, FilterBar, FilterChip, type FilterChipProps, FitText, type FitTextProps, Footnote, Footnotes, Form, FormActions, FormRow, FormSection, type FormSectionProps, Gallery, Gantt, GanttBar, GanttRow, Gauge, type GaugeProps, GlassContainer, GlassInteractive, Grid, GridLines, type GridProps, GroupBox, Grow, HStack, type HapticKind, Heatmap, Help, Hero, type HeroProps, HoverCard, HoverCardHost, Icon, type IconName, type IconProps, IconTile, type IconTileProps, ImageLens, ImageViewer, ImageViewerBar, Input, InputGroup, type InputGroupProps, type InputProps, Inspector, Kanban, KanbanColumn, type KanbanColumnProps, KanbanList, Kbd, Label, type LabelProps, Labeled, Landing, Legend, type LegendItem, type LegendProps, Lightbox, type LightboxProps, LineChart, LinearGauge, Link, LinkGroup, LiquidToggle, type LiquidToggleProps, List, ListFooter, ListHeader, ListItem, type ListItemProps, type ListProps, Log, MarketingNav, MarketingNavBrand, MarketingNavLinks, MediaPlaceholder, Menu, MenuBar, MenuBarItem, MenuItem, type MenuItemProps, MenuLabel, type MenuProps, MenuSeparator, Modal, type ModalProps, type NavLinkProps, Notification, Onboarding, OnboardingFeature, type OnboardingFeatureProps, OnboardingHero, Optional, OtpInput, type OtpInputProps, Overline, Pagination, PaginationEllipsis, PaginationItem, type PaginationItemProps, type PaginationProps, PillNav, Popover, type PopoverProps, Poster, PosterFacts, PosterFrame, PosterGrid, PosterInitial, PosterMeta, PosterTitle, Progress, type ProgressProps, PromoBand, type PromoBandProps, Quote, type QuoteProps, RadarChart, Radio, Rail, RailItem, type RailProps, Range, type RangeProps, Resizable, ResizeHandle, Result, type ResultProps, Reveal, type RevealProps, type RevealVariant, SafeArea, ScatterChart, ScrollArea, type ScrollAreaProps, type ScrollGeometry, SearchField, SearchResult, type SearchResultProps, SearchResults, Section, Segmented, type SegmentedOption, Select, SelectionCount, Share, Sheet, Sidebar, SidebarGroup, SidebarHeading, SidebarItem, type SidebarItemProps, type SidebarProps, SiteFooter, SiteFooterGroup, SiteFooterGroups, SiteFooterHeading, SiteFooterLegal, Skeleton, SkipLink, Slider, type SnapPosition, SortControl, Spacer, Span, type SpanProps, Sparkline, type SparklineProps, SpecStrip, Spinner, Split, SplitButton, type SplitButtonProps, Stack, type StackProps, Stage, Stat, StatusBar, StatusBarItem, StatusDot, type Step, StepperInput, type StepperInputProps, Steps, type StepsProps, StoryCard, Swatch, Swatches, Switch, type SwitchProps, SysPage, type SysPageProps, type TabItem, TabPanel, Table, TableNum, type TableProps, TableSortHeader, TableWrap, Tabs, Tag, Task, TaskList, type TaskProps, TaskRow, Text, type TextProps, type TextRole, Textarea, ThemeScript, Thumb, type ThumbProps, Timeline, type TimelineEntry, type TimelineProps, Tip, type ToastOptions, ToastProvider, type ToastVariant, ToggleButton, type ToggleButtonProps, Toolbar, Tooltip, TopNav, TopNavBrand, TopNavLink, TopNavLinks, Tree, TreeItem, type TreeItemProps, Upload, UploadItem, type UploadItemProps, UploadPreview, UploadPreviews, VStack, Video, Wall, Waveform, Web, Workspace, WorkspaceMain, block, buttonClasses, cn, haptic, iconNames, useBaruaTheme, usePersistedState, useScrollGeometry, useSnapPosition, useToast, useVisible };
package/dist/index.js CHANGED
@@ -2312,6 +2312,194 @@ var ContextMenuTarget = forwardRef17(
2312
2312
  return /* @__PURE__ */ jsx21(Component, { ref, "data-b-contextmenu": menu, ...rest, children });
2313
2313
  }
2314
2314
  );
2315
+
2316
+ // src/scroll.tsx
2317
+ import { useCallback as useCallback2, useEffect as useEffect5, useState as useState3 } from "react";
2318
+ function readGeometry(el) {
2319
+ const page = !el || el === document.documentElement || el === document.body;
2320
+ const box = page ? document.documentElement : el;
2321
+ const x = page ? window.scrollX : el.scrollLeft;
2322
+ const y = page ? window.scrollY : el.scrollTop;
2323
+ const width = box.clientWidth, height = box.clientHeight;
2324
+ const contentWidth = box.scrollWidth, contentHeight = box.scrollHeight;
2325
+ return {
2326
+ x,
2327
+ y,
2328
+ width,
2329
+ height,
2330
+ contentWidth,
2331
+ contentHeight,
2332
+ progressX: contentWidth > width ? Math.min(1, x / (contentWidth - width)) : 0,
2333
+ progressY: contentHeight > height ? Math.min(1, y / (contentHeight - height)) : 0
2334
+ };
2335
+ }
2336
+ function useScrollGeometry(ref, onChange) {
2337
+ const [geometry, setGeometry] = useState3(null);
2338
+ useEffect5(() => {
2339
+ const el = ref?.current ?? null;
2340
+ const page = !el || el === document.documentElement || el === document.body;
2341
+ const target = page ? window : el;
2342
+ let queued = false;
2343
+ const flush = () => {
2344
+ queued = false;
2345
+ const g = readGeometry(el);
2346
+ setGeometry(g);
2347
+ onChange?.(g);
2348
+ };
2349
+ const on = () => {
2350
+ if (!queued) {
2351
+ queued = true;
2352
+ requestAnimationFrame(flush);
2353
+ }
2354
+ };
2355
+ target.addEventListener("scroll", on, { passive: true });
2356
+ const ro = !page && "ResizeObserver" in window ? new ResizeObserver(on) : null;
2357
+ if (ro && el) ro.observe(el);
2358
+ else window.addEventListener("resize", on);
2359
+ flush();
2360
+ return () => {
2361
+ target.removeEventListener("scroll", on);
2362
+ if (ro) ro.disconnect();
2363
+ else window.removeEventListener("resize", on);
2364
+ };
2365
+ }, [ref?.current]);
2366
+ return geometry;
2367
+ }
2368
+ function useVisible(ref, { threshold = 0.5 } = {}) {
2369
+ const [visible, setVisible] = useState3(false);
2370
+ useEffect5(() => {
2371
+ const el = ref.current;
2372
+ if (!el) return;
2373
+ if (!("IntersectionObserver" in window)) {
2374
+ setVisible(true);
2375
+ return;
2376
+ }
2377
+ const io = new IntersectionObserver(
2378
+ (entries) => {
2379
+ for (const entry of entries) {
2380
+ setVisible(threshold === 0 ? entry.isIntersecting : entry.intersectionRatio >= threshold);
2381
+ }
2382
+ },
2383
+ { threshold: threshold === 0 ? [0] : [0, threshold] }
2384
+ );
2385
+ io.observe(el);
2386
+ return () => io.disconnect();
2387
+ }, [ref.current, threshold]);
2388
+ return visible;
2389
+ }
2390
+ function useSnapPosition(ref) {
2391
+ const [current, setCurrent] = useState3({ id: null, index: -1 });
2392
+ const items = useCallback2(() => ref.current ? Array.from(ref.current.children).filter((c) => !c.hidden) : [], [ref]);
2393
+ useEffect5(() => {
2394
+ const box = ref.current;
2395
+ if (!box) return;
2396
+ const announce = (el) => {
2397
+ if (!el) return;
2398
+ const list = items();
2399
+ const index = list.indexOf(el);
2400
+ if (index >= 0) setCurrent({ id: el.id || null, index });
2401
+ };
2402
+ const nearest = () => {
2403
+ const list = items();
2404
+ const horizontal = box.scrollWidth > box.clientWidth;
2405
+ const origin = box.getBoundingClientRect();
2406
+ let best = null, distance = Infinity;
2407
+ for (const c of list) {
2408
+ const r = c.getBoundingClientRect();
2409
+ const d = Math.abs(horizontal ? r.left - origin.left : r.top - origin.top);
2410
+ if (d < distance) {
2411
+ distance = d;
2412
+ best = c;
2413
+ }
2414
+ }
2415
+ return best;
2416
+ };
2417
+ let timer;
2418
+ const native = "onscrollsnapchange" in box;
2419
+ const onSnap = (e) => {
2420
+ const ev = e;
2421
+ announce(ev.snapTargetInline || ev.snapTargetBlock);
2422
+ };
2423
+ const settle = () => {
2424
+ clearTimeout(timer);
2425
+ timer = setTimeout(() => announce(nearest()), 90);
2426
+ };
2427
+ if (native) box.addEventListener("scrollsnapchange", onSnap);
2428
+ else box.addEventListener("onscrollend" in box ? "scrollend" : "scroll", settle, { passive: true });
2429
+ announce(nearest());
2430
+ return () => {
2431
+ box.removeEventListener("scrollsnapchange", onSnap);
2432
+ box.removeEventListener("scrollend", settle);
2433
+ box.removeEventListener("scroll", settle);
2434
+ clearTimeout(timer);
2435
+ };
2436
+ }, [ref.current]);
2437
+ const to = useCallback2(
2438
+ (target) => {
2439
+ const list = items();
2440
+ const el = typeof target === "number" ? list[target] : list.find((c) => c.id === target);
2441
+ el?.scrollIntoView({ behavior: "smooth", block: "nearest", inline: "start" });
2442
+ },
2443
+ [items]
2444
+ );
2445
+ return { ...current, to };
2446
+ }
2447
+ var HAPTICS = {
2448
+ selection: [8],
2449
+ impact: [16],
2450
+ success: [10, 30, 20],
2451
+ warning: [25, 40, 25],
2452
+ error: [40, 30, 40, 30, 60]
2453
+ };
2454
+ function haptic(kind = "selection") {
2455
+ if (typeof navigator === "undefined") return false;
2456
+ if (typeof navigator.vibrate === "function") {
2457
+ navigator.vibrate(HAPTICS[kind]);
2458
+ return true;
2459
+ }
2460
+ if (/iphone|ipad|ipod/i.test(navigator.userAgent)) {
2461
+ let sw = document.getElementById("b-haptic-switch");
2462
+ if (!sw) {
2463
+ sw = document.createElement("input");
2464
+ sw.type = "checkbox";
2465
+ sw.id = "b-haptic-switch";
2466
+ sw.tabIndex = -1;
2467
+ sw.setAttribute("switch", "");
2468
+ sw.setAttribute("aria-hidden", "true");
2469
+ sw.style.cssText = "position:fixed;inset:auto auto 0 0;width:1px;height:1px;opacity:0;pointer-events:none";
2470
+ document.body.appendChild(sw);
2471
+ }
2472
+ sw.click();
2473
+ return true;
2474
+ }
2475
+ return false;
2476
+ }
2477
+ var PERSIST = "barua-persist:";
2478
+ function usePersistedState(key, initial) {
2479
+ const [value, setValue] = useState3(() => {
2480
+ if (typeof window === "undefined") return initial;
2481
+ try {
2482
+ const raw = localStorage.getItem(PERSIST + key);
2483
+ return raw === null ? initial : JSON.parse(raw);
2484
+ } catch {
2485
+ return initial;
2486
+ }
2487
+ });
2488
+ const set = useCallback2(
2489
+ (next) => {
2490
+ setValue((prev) => {
2491
+ const resolved = typeof next === "function" ? next(prev) : next;
2492
+ try {
2493
+ localStorage.setItem(PERSIST + key, JSON.stringify(resolved));
2494
+ } catch {
2495
+ }
2496
+ return resolved;
2497
+ });
2498
+ },
2499
+ [key]
2500
+ );
2501
+ return [value, set];
2502
+ }
2315
2503
  export {
2316
2504
  Accordion,
2317
2505
  Account,
@@ -2606,8 +2794,13 @@ export {
2606
2794
  block,
2607
2795
  buttonClasses,
2608
2796
  cn,
2797
+ haptic,
2609
2798
  iconNames,
2610
2799
  useBaruaTheme,
2611
- useToast
2800
+ usePersistedState,
2801
+ useScrollGeometry,
2802
+ useSnapPosition,
2803
+ useToast,
2804
+ useVisible
2612
2805
  };
2613
2806
  //# sourceMappingURL=index.js.map