@voltstack/bravais 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -1,47 +1,3 @@
1
1
  # bravais
2
2
 
3
- The VOLT design-system primitives — the shared React visual language used across VoltLabs surfaces (VOLT, Console, Registry).
4
-
5
- ## Install
6
-
7
- ```bash
8
- npm i bravais
9
- ```
10
-
11
- Peer dependencies (provided by the consuming app): `react`, `react-dom`, `react-router-dom`, `@floating-ui/react`, `lucide-react`, `recharts`, `framer-motion`.
12
-
13
- ## Usage
14
-
15
- ```tsx
16
- import { Stack, Row, Text, Heading, Button, TextInput, Card } from 'bravais';
17
- // Once, at your app root:
18
- import 'bravais/styles.css'; // design tokens + utility classes (REQUIRED)
19
- import 'bravais/components.css'; // per-component styles (REQUIRED)
20
-
21
- export const Example = () => (
22
- <Card>
23
- <Stack gap='1'>
24
- <Heading level={2}>Title</Heading>
25
- <Row gap='05'>
26
- <TextInput placeholder='Name' aria-label='Name' />
27
- <Button intent='brand'>Save</Button>
28
- </Row>
29
- </Stack>
30
- </Card>
31
- );
32
- ```
33
-
34
- Layout/typography primitives (`Box`/`Row`/`Stack`/`Grid`/`Text`/`Heading`) map style props to the utility classes shipped in `styles.css`, so that stylesheet is required.
35
-
36
- ## Build
37
-
38
- ```bash
39
- npm run build # tsup -> dist/ (ESM + d.ts + CSS)
40
- ```
41
-
42
- ## Status & follow-ups (0.1.0)
43
-
44
- - **Self-contained:** the primitives, their internal helpers (cn, compose-refs, hooks, FloatingRootContext, types) and the token/utility stylesheets live under `src/`; the build has no dependency on VOLT's source.
45
- - VOLT still ships its own copy of these primitives under `client/src`. **Next step:** point VOLT (and Console/Registry) at this package and delete the in-app copy, so there's a single source of truth.
46
- - App-level wrappers (`AsyncMenuItemWrapper`, `ContextMenuPopover`) are intentionally **not exported** — they depend on the host app's error/toast system. Compose `Popover` + `PopoverMenu` with your own async/error handling.
47
- - Some primitives (`Card`, `Toast`, `Meter`, `ProgressBar`, `Menu`, `Checkbox`, `Radio`) are not yet exercised by VOLT itself; treat as provisional until adopted/visually verified.
3
+ The VOLT design-system primitives.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react from 'react';
2
- import react__default, { ElementType, HTMLAttributes, ReactNode, Ref, ReactElement, ButtonHTMLAttributes, MouseEventHandler, CSSProperties, InputHTMLAttributes, TextareaHTMLAttributes, ChangeEventHandler } from 'react';
2
+ import react__default, { ElementType, HTMLAttributes, ReactNode, Ref, ReactElement, ButtonHTMLAttributes, MouseEventHandler, CSSProperties, InputHTMLAttributes, TextareaHTMLAttributes, ChangeEventHandler, RefObject } from 'react';
3
3
  import { Placement } from '@floating-ui/react';
4
4
 
5
5
  /**
@@ -1315,4 +1315,44 @@ interface VisuallyHiddenProps extends HTMLAttributes<HTMLElement> {
1315
1315
  */
1316
1316
  declare const VisuallyHidden: react.ForwardRefExoticComponent<VisuallyHiddenProps & react.RefAttributes<HTMLElement>>;
1317
1317
 
1318
- export { type AlignItems, AsyncBoundary, type AsyncBoundaryProps, type AsyncBoundaryState, Avatar, AvatarStack, type AvatarUser, BOX_STYLE_KEYS, type BorderToken, Box, type BoxProps, type BoxStyleProps, type BreadcrumbItem, Breadcrumbs, type BreadcrumbsVariant, Button, type ButtonProps, Callout, type CalloutTone, CardWithSlots as Card, CardBody, type CardBodyProps, CardFooter, CardHeader, type CardPadding, type CardProps, type CardSlotProps, type CardVariant, Checkbox, type CheckboxProps, type CheckboxSize, CloseButton, _default as CollapsibleSection, type Column, type ControlSize, CursorTooltip, DashedActionBox, type DashedActionBoxProps, type DashedActionSize, type DashedActionTone, type Display, Divider, type DividerProps, EmptyState, type FlexDirection, type FlexToken, FloatingToolbar, type FloatingToolbarAlign, type FloatingToolbarPlacement, type FloatingToolbarProps, FormField, type FormFieldLayout, type FormFieldProps, type GapToken, Grid, type GridProps, Heading, type HeadingLevel, type HeadingProps, type HeightToken, IconButton, IconFrame, type IconFrameProps, type IconFrameShape, type IconFrameSize, type IconFrameTone, InlineStatus, type InlineStatusProps, type InlineStatusTone, type JustifyContent, KeyValueList, type KeyValueListProps, KeyValueRow, type KeyValueRowProps, LiquidToggle, ListRow, type ListRowProps, Loader, type MarginBottomToken, type MarginTopToken, type MarginXToken, Menu, type MenuItem, type MenuProps, type MenuTriggerRenderProp, Meter, type MeterProps, Modal, NumberInput, type NumberInputProps, type OverflowToken, type PaddingToken, type PaddingXToken, Popover, PopoverMenu, PopoverMenuItem, type PositionToken, ProgressBar, type ProgressBarProps, type ProgressBarSize, Radio, type RadioProps, type RadioSize, type RadiusToken, Row, type RowProps, STATUS_TONE_VARS, type SaveStatus, SaveStatusIndicator, type SaveStatusIndicatorProps, SearchInput, SectionLabel, type SectionLabelProps, type SegmentedTabOption, SegmentedTabs, Select, type SelectOption, type SelectProps, SelectableCard, type SelectableCardProps, type Shape, Skeleton, type SkeletonAnimation, type SkeletonProps, type SkeletonVariant, _default$1 as Slider, type SliderProps, Sparkline, type SparklineProps, Stack, type StackProps, StatCard, type StatCardProps, type StatCardState, type StatCardTone, StatusBadge, type StatusBadgeProps, StatusDot, type StatusDotTone, type StatusTone, type Step, type StepIndicator, type StepTitles, Stepper, Surface, type SurfaceProps, type SurfaceVariant, Tab, type TabProps, Table, TableSortDirection, Tabs, TabsList, type TabsListProps, TabsPanel, type TabsPanelProps, type TabsProps, type TabsSize, Tag, type TagProps, type TagShape, type TagSize, type TagTone, type TagVariant, Text, type TextAlign, TextInput, type TextInputProps, type TextProps, type TextSize, type TextTone, type TextWeight, Textarea, type TextareaProps, ThinkingDots, type ThinkingDotsProps, Timeline, TimelineItem, type TimelineItemProps, type TimelineProps, type TimelineTone, Toast, type ToastProps, type ToastTone, Tooltip, type TooltipPlacement, type TransitionToken, VisuallyHidden, type VisuallyHiddenProps, type WidthToken, buildBoxClasses, buildTypographyClasses, closeModal, openModal, resetModal, splitBoxProps };
1318
+ /** Subscribes to a CSS media query and returns whether it currently matches. */
1319
+ declare const useMedia: (query: string) => boolean;
1320
+
1321
+ declare const usePrefersReducedMotion: () => boolean;
1322
+
1323
+ interface UseStepperOptions<K extends string> {
1324
+ steps: K[];
1325
+ }
1326
+ declare const useStepper: <K extends string>(initialStep: K, options?: UseStepperOptions<K>) => {
1327
+ step: K;
1328
+ goTo: (next: K) => void;
1329
+ reset: () => void;
1330
+ next: () => void;
1331
+ prev: () => void;
1332
+ currentIndex: number;
1333
+ isFirst: boolean;
1334
+ isLast: boolean;
1335
+ };
1336
+
1337
+ interface UseInfiniteScrollOptions {
1338
+ rootRef?: RefObject<HTMLElement | null> | null;
1339
+ hasMore: boolean;
1340
+ isFetchingMore: boolean;
1341
+ onLoadMore?: () => void;
1342
+ }
1343
+ declare const useInfiniteScroll: ({ rootRef, hasMore, isFetchingMore, onLoadMore }: UseInfiniteScrollOptions) => {
1344
+ sentinelRef: RefObject<HTMLDivElement | null>;
1345
+ };
1346
+
1347
+ interface ShortcutOptions {
1348
+ ctrl?: boolean;
1349
+ meta?: boolean;
1350
+ shift?: boolean;
1351
+ alt?: boolean;
1352
+ preventDefault?: boolean;
1353
+ enabled?: boolean;
1354
+ enableOnFormTags?: boolean;
1355
+ }
1356
+ declare const useKeyboardShortcut: (key: string, callback: () => void, options?: ShortcutOptions) => void;
1357
+
1358
+ export { type AlignItems, AsyncBoundary, type AsyncBoundaryProps, type AsyncBoundaryState, Avatar, AvatarStack, type AvatarUser, BOX_STYLE_KEYS, type BorderToken, Box, type BoxProps, type BoxStyleProps, type BreadcrumbItem, Breadcrumbs, type BreadcrumbsVariant, Button, type ButtonProps, Callout, type CalloutTone, CardWithSlots as Card, CardBody, type CardBodyProps, CardFooter, CardHeader, type CardPadding, type CardProps, type CardSlotProps, type CardVariant, Checkbox, type CheckboxProps, type CheckboxSize, CloseButton, _default as CollapsibleSection, type Column, type ControlSize, CursorTooltip, DashedActionBox, type DashedActionBoxProps, type DashedActionSize, type DashedActionTone, type Display, Divider, type DividerProps, EmptyState, type FlexDirection, type FlexToken, FloatingToolbar, type FloatingToolbarAlign, type FloatingToolbarPlacement, type FloatingToolbarProps, FormField, type FormFieldLayout, type FormFieldProps, type GapToken, Grid, type GridProps, Heading, type HeadingLevel, type HeadingProps, type HeightToken, IconButton, IconFrame, type IconFrameProps, type IconFrameShape, type IconFrameSize, type IconFrameTone, InlineStatus, type InlineStatusProps, type InlineStatusTone, type JustifyContent, KeyValueList, type KeyValueListProps, KeyValueRow, type KeyValueRowProps, LiquidToggle, ListRow, type ListRowProps, Loader, type MarginBottomToken, type MarginTopToken, type MarginXToken, Menu, type MenuItem, type MenuProps, type MenuTriggerRenderProp, Meter, type MeterProps, Modal, NumberInput, type NumberInputProps, type OverflowToken, type PaddingToken, type PaddingXToken, Popover, PopoverMenu, PopoverMenuItem, type PositionToken, ProgressBar, type ProgressBarProps, type ProgressBarSize, Radio, type RadioProps, type RadioSize, type RadiusToken, Row, type RowProps, STATUS_TONE_VARS, type SaveStatus, SaveStatusIndicator, type SaveStatusIndicatorProps, SearchInput, SectionLabel, type SectionLabelProps, type SegmentedTabOption, SegmentedTabs, Select, type SelectOption, type SelectProps, SelectableCard, type SelectableCardProps, type Shape, Skeleton, type SkeletonAnimation, type SkeletonProps, type SkeletonVariant, _default$1 as Slider, type SliderProps, Sparkline, type SparklineProps, Stack, type StackProps, StatCard, type StatCardProps, type StatCardState, type StatCardTone, StatusBadge, type StatusBadgeProps, StatusDot, type StatusDotTone, type StatusTone, type Step, type StepIndicator, type StepTitles, Stepper, Surface, type SurfaceProps, type SurfaceVariant, Tab, type TabProps, Table, TableSortDirection, Tabs, TabsList, type TabsListProps, TabsPanel, type TabsPanelProps, type TabsProps, type TabsSize, Tag, type TagProps, type TagShape, type TagSize, type TagTone, type TagVariant, Text, type TextAlign, TextInput, type TextInputProps, type TextProps, type TextSize, type TextTone, type TextWeight, Textarea, type TextareaProps, ThinkingDots, type ThinkingDotsProps, Timeline, TimelineItem, type TimelineItemProps, type TimelineProps, type TimelineTone, Toast, type ToastProps, type ToastTone, Tooltip, type TooltipPlacement, type TransitionToken, VisuallyHidden, type VisuallyHiddenProps, type WidthToken, buildBoxClasses, buildTypographyClasses, closeModal, openModal, resetModal, splitBoxProps, useInfiniteScroll, useKeyboardShortcut, useMedia, usePrefersReducedMotion, useStepper };
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import { X, Search, Minus, Check, ChevronDown, AlertCircle, Plus, Copy, ChevronU
5
5
  import { useFloating, autoUpdate, offset, flip, shift, useClick, useDismiss, useRole, useListNavigation, useTypeahead, useInteractions, FloatingPortal, FloatingFocusManager, size, useHover, useFocus } from '@floating-ui/react';
6
6
  import { motion, AnimatePresence } from 'framer-motion';
7
7
  import { ResponsiveContainer, AreaChart, YAxis, Area } from 'recharts';
8
+ import { useHotkeys } from 'react-hotkeys-hook';
8
9
 
9
10
  // src/shared/presentation/primitives/types.ts
10
11
  var STATUS_TONE_VARS = {
@@ -4711,7 +4712,92 @@ var VisuallyHidden = forwardRef(({
4711
4712
  });
4712
4713
  VisuallyHidden.displayName = "VisuallyHidden";
4713
4714
  var VisuallyHidden_default = VisuallyHidden;
4715
+ var useStepper = (initialStep, options) => {
4716
+ const [step, setStep] = useState(initialStep);
4717
+ const steps = options?.steps;
4718
+ const goTo = useCallback((next2) => setStep(next2), []);
4719
+ const reset = useCallback(() => setStep(initialStep), [initialStep]);
4720
+ const currentIndex = useMemo(() => {
4721
+ if (!steps) return -1;
4722
+ return steps.indexOf(step);
4723
+ }, [steps, step]);
4724
+ const next = useCallback(() => {
4725
+ if (!steps || currentIndex === -1 || currentIndex >= steps.length - 1) return;
4726
+ setStep(steps[currentIndex + 1]);
4727
+ }, [steps, currentIndex]);
4728
+ const prev = useCallback(() => {
4729
+ if (!steps || currentIndex <= 0) return;
4730
+ setStep(steps[currentIndex - 1]);
4731
+ }, [steps, currentIndex]);
4732
+ const isFirst = currentIndex === 0;
4733
+ const isLast = steps ? currentIndex === steps.length - 1 : false;
4734
+ return { step, goTo, reset, next, prev, currentIndex, isFirst, isLast };
4735
+ };
4736
+ var use_stepper_default = useStepper;
4737
+ var useInfiniteScroll = ({ rootRef, hasMore, isFetchingMore, onLoadMore }) => {
4738
+ const sentinelRef = useRef(null);
4739
+ const hasMountedRef = useRef(false);
4740
+ const onLoadMoreRef = useRef(onLoadMore);
4741
+ useEffect(() => {
4742
+ onLoadMoreRef.current = onLoadMore;
4743
+ });
4744
+ useEffect(() => {
4745
+ const timer = setTimeout(() => {
4746
+ hasMountedRef.current = true;
4747
+ }, 100);
4748
+ return () => clearTimeout(timer);
4749
+ }, []);
4750
+ useEffect(() => {
4751
+ const sentinel = sentinelRef.current;
4752
+ if (!sentinel) return;
4753
+ const root = rootRef ? rootRef.current : null;
4754
+ const observer = new IntersectionObserver(
4755
+ (entries) => {
4756
+ const entry = entries[0];
4757
+ if (entry?.isIntersecting && hasMore && !isFetchingMore && hasMountedRef.current) {
4758
+ onLoadMoreRef.current?.();
4759
+ }
4760
+ },
4761
+ { root, rootMargin: "0px 0px 200px 0px", threshold: 0 }
4762
+ );
4763
+ observer.observe(sentinel);
4764
+ return () => observer.disconnect();
4765
+ }, [rootRef, hasMore, isFetchingMore]);
4766
+ return { sentinelRef };
4767
+ };
4768
+ var use_infinite_scroll_default = useInfiniteScroll;
4769
+ var useKeyboardShortcut = (key, callback, options = {}) => {
4770
+ const {
4771
+ ctrl = false,
4772
+ meta = false,
4773
+ shift: shift5 = false,
4774
+ alt = false,
4775
+ preventDefault = true,
4776
+ enabled = true,
4777
+ enableOnFormTags = false
4778
+ } = options;
4779
+ const hotkey = useMemo(() => {
4780
+ const parts = [];
4781
+ if (ctrl) parts.push("ctrl");
4782
+ if (meta) parts.push("meta");
4783
+ if (shift5) parts.push("shift");
4784
+ if (alt) parts.push("alt");
4785
+ parts.push(key.toLowerCase());
4786
+ return parts.join("+");
4787
+ }, [alt, ctrl, key, meta, shift5]);
4788
+ useHotkeys(
4789
+ hotkey,
4790
+ () => callback(),
4791
+ {
4792
+ enabled,
4793
+ enableOnFormTags: enableOnFormTags ? ["INPUT", "TEXTAREA", "SELECT"] : false,
4794
+ preventDefault
4795
+ },
4796
+ [callback]
4797
+ );
4798
+ };
4799
+ var use_keyboard_shortcut_default = useKeyboardShortcut;
4714
4800
 
4715
- export { AsyncBoundary_default as AsyncBoundary, Avatar_default as Avatar, AvatarStack_default as AvatarStack, BOX_STYLE_KEYS, Box_default as Box, Breadcrumbs_default as Breadcrumbs, Button_default as Button, Callout_default as Callout, Card_default as Card, CardBody, CardFooter, CardHeader, Checkbox_default as Checkbox, CloseButton_default as CloseButton, CollapsibleSection_default as CollapsibleSection, CursorTooltip_default as CursorTooltip, DashedActionBox_default as DashedActionBox, Divider_default as Divider, EmptyState_default as EmptyState, FloatingToolbar_default as FloatingToolbar, FormField_default as FormField, Grid_default as Grid, Heading_default as Heading, IconButton_default as IconButton, IconFrame_default as IconFrame, InlineStatus_default as InlineStatus, KeyValueList_default as KeyValueList, KeyValueRow, LiquidToggle_default as LiquidToggle, ListRow_default as ListRow, Loader_default as Loader, Menu_default as Menu, Meter_default as Meter, Modal_default as Modal, NumberInput_default as NumberInput, Popover_default as Popover, PopoverMenu_default as PopoverMenu, PopoverMenuItem_default as PopoverMenuItem, ProgressBar_default as ProgressBar, Radio_default as Radio, Row_default as Row, STATUS_TONE_VARS, SaveStatusIndicator_default as SaveStatusIndicator, SearchInput_default as SearchInput, SectionLabel_default as SectionLabel, SegmentedTabs_default as SegmentedTabs, Select_default as Select, SelectableCard_default as SelectableCard, Skeleton_default as Skeleton, Slider_default as Slider, Sparkline_default as Sparkline, Stack_default as Stack, StatCard_default as StatCard, StatusBadge_default as StatusBadge, StatusDot_default as StatusDot, Stepper_default as Stepper, Surface_default as Surface, Tab, Table_default as Table, TableSortDirection, Tabs_default as Tabs, TabsList, TabsPanel, Tag_default as Tag, Text_default as Text, TextInput_default as TextInput, Textarea_default as Textarea, ThinkingDots_default as ThinkingDots, Timeline_default as Timeline, TimelineItem, Toast_default as Toast, Tooltip_default as Tooltip, VisuallyHidden_default as VisuallyHidden, buildBoxClasses, buildTypographyClasses, closeModal, openModal, resetModal, splitBoxProps };
4801
+ export { AsyncBoundary_default as AsyncBoundary, Avatar_default as Avatar, AvatarStack_default as AvatarStack, BOX_STYLE_KEYS, Box_default as Box, Breadcrumbs_default as Breadcrumbs, Button_default as Button, Callout_default as Callout, Card_default as Card, CardBody, CardFooter, CardHeader, Checkbox_default as Checkbox, CloseButton_default as CloseButton, CollapsibleSection_default as CollapsibleSection, CursorTooltip_default as CursorTooltip, DashedActionBox_default as DashedActionBox, Divider_default as Divider, EmptyState_default as EmptyState, FloatingToolbar_default as FloatingToolbar, FormField_default as FormField, Grid_default as Grid, Heading_default as Heading, IconButton_default as IconButton, IconFrame_default as IconFrame, InlineStatus_default as InlineStatus, KeyValueList_default as KeyValueList, KeyValueRow, LiquidToggle_default as LiquidToggle, ListRow_default as ListRow, Loader_default as Loader, Menu_default as Menu, Meter_default as Meter, Modal_default as Modal, NumberInput_default as NumberInput, Popover_default as Popover, PopoverMenu_default as PopoverMenu, PopoverMenuItem_default as PopoverMenuItem, ProgressBar_default as ProgressBar, Radio_default as Radio, Row_default as Row, STATUS_TONE_VARS, SaveStatusIndicator_default as SaveStatusIndicator, SearchInput_default as SearchInput, SectionLabel_default as SectionLabel, SegmentedTabs_default as SegmentedTabs, Select_default as Select, SelectableCard_default as SelectableCard, Skeleton_default as Skeleton, Slider_default as Slider, Sparkline_default as Sparkline, Stack_default as Stack, StatCard_default as StatCard, StatusBadge_default as StatusBadge, StatusDot_default as StatusDot, Stepper_default as Stepper, Surface_default as Surface, Tab, Table_default as Table, TableSortDirection, Tabs_default as Tabs, TabsList, TabsPanel, Tag_default as Tag, Text_default as Text, TextInput_default as TextInput, Textarea_default as Textarea, ThinkingDots_default as ThinkingDots, Timeline_default as Timeline, TimelineItem, Toast_default as Toast, Tooltip_default as Tooltip, VisuallyHidden_default as VisuallyHidden, buildBoxClasses, buildTypographyClasses, closeModal, openModal, resetModal, splitBoxProps, use_infinite_scroll_default as useInfiniteScroll, use_keyboard_shortcut_default as useKeyboardShortcut, use_media_default as useMedia, usePrefersReducedMotion, use_stepper_default as useStepper };
4716
4802
  //# sourceMappingURL=index.js.map
4717
4803
  //# sourceMappingURL=index.js.map