@drakkar.software/octospaces-ui 0.3.0 → 0.4.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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { View } from 'react-native';
1
+ import React, { ReactNode } from 'react';
2
+ import { View, StyleProp, ViewStyle } from 'react-native';
3
3
 
4
4
  /**
5
5
  * Theme contract for `@drakkar.software/octospaces-ui`.
@@ -27,6 +27,7 @@ interface Palette {
27
27
  surfaceModal: string;
28
28
  surfaceInput: string;
29
29
  sidebar: string;
30
+ sidebarPanel: string;
30
31
  sidebarActive: string;
31
32
  border: string;
32
33
  borderSubtle: string;
@@ -458,4 +459,354 @@ interface SpacesRailProps {
458
459
  */
459
460
  declare function SpacesRail({ spaces, activeId, onSelect, onAdd, onSelectDms, dmsActive, dmUnread, dmLabel, addLabel, renderIcon, renderTileImage, renderBadge, showLockCorner, renderFoot, useTileDnd, }: SpacesRailProps): React.JSX.Element;
460
461
 
461
- export { type ColorScheme, type DiscoverEntry, DiscoverList, type DiscoverListProps, DiscoverRow, type DiscoverRowProps, DiscoverScreen, type DiscoverScreenProps, type Easing, type Fonts, type LabelTracking, type Layers, type Layout, type Motion, type MotionToken, OctoSpacesThemeProvider, type OctoSpacesThemeProviderProps, type Opacity, type Palette, type Radii, type RailIconName, type RailSpace, type ShadowToken, type Shadows, SpacesRail, type SpacesRailProps, type Spacing, type Swatches, type Theme, type TypeScale, type Typography, avatarTint, filterDiscoverEntries, focusRingStyle, glowShadow, paperBorder, presenceColor, sortDiscoverEntries, statusColor, swatch, useOctoSpacesTheme, verificationColor };
462
+ /**
463
+ * Headless themed sidebar panel shell.
464
+ *
465
+ * Renders the 240–248px wide panel: a background surface (colors.sidebarPanel),
466
+ * a right border (colors.border), an optional header slot, the item list
467
+ * (scrollable by default), and an optional footer slot.
468
+ *
469
+ * All content is delegated to the host via slots — only the chrome (bg, border,
470
+ * width) and the ScrollView wrapper are shared.
471
+ *
472
+ * ```tsx
473
+ * <Sidebar
474
+ * header={
475
+ * <SidebarHeader
476
+ * leading={<SpaceSwitcher variant="sidebar" />}
477
+ * actions={<>
478
+ * <IconButton name="search" ... />
479
+ * <IconButton name="plus" ... />
480
+ * </>}
481
+ * />
482
+ * }
483
+ * contentContainerStyle={{ paddingHorizontal: 8 }}
484
+ * >
485
+ * <WorkObjects ... />
486
+ * </Sidebar>
487
+ * ```
488
+ */
489
+
490
+ interface SidebarProps {
491
+ /** Header slot — render a {@link SidebarHeader} or custom content above the list. */
492
+ header?: React.ReactNode;
493
+ /** Footer slot — pinned below the scroll area. */
494
+ footer?: React.ReactNode;
495
+ /** The item list. Wrapped in a ScrollView unless `scrollable` is `false`. */
496
+ children: React.ReactNode;
497
+ /** Panel width in pixels. Defaults to `theme.layout.sidebarWidth ?? 248`. */
498
+ width?: number;
499
+ /**
500
+ * When `false`, children are rendered in a plain `View` instead of a `ScrollView`.
501
+ * Use when the host manages its own scroll (e.g. multiple independent lists).
502
+ * @default true
503
+ */
504
+ scrollable?: boolean;
505
+ /**
506
+ * Passed to the `ScrollView`'s `contentContainerStyle` (or to the body `View`
507
+ * style when `scrollable` is `false`).
508
+ */
509
+ contentContainerStyle?: StyleProp<ViewStyle>;
510
+ /**
511
+ * Override the panel background color.
512
+ * Defaults to `colors.sidebarPanel` from the injected theme.
513
+ */
514
+ background?: string;
515
+ }
516
+ declare function Sidebar({ header, footer, children, width, scrollable, contentContainerStyle, background, }: SidebarProps): React.JSX.Element;
517
+
518
+ /**
519
+ * Headless themed sidebar header strip.
520
+ *
521
+ * Row 1: a `leading` slot (flex:1, typically a space selector or name) + an
522
+ * optional `actions` row (right-aligned command buttons). An optional `extra`
523
+ * slot below row 1 accepts additional controls (OctoChat uses this for its
524
+ * `ModeSwitcher` + jump-to search bar). An optional bottom hairline divider.
525
+ *
526
+ * ```tsx
527
+ * // OctoVault — space switcher + command icons
528
+ * <SidebarHeader
529
+ * leading={<SpaceSwitcher variant="sidebar" />}
530
+ * actions={<>
531
+ * <IconButton name="search" onPress={openSearch} tooltip="Search" shortcut="⌘K" />
532
+ * <IconButton name="plus" onPress={newPage} tooltip="New page" shortcut="⌘N" />
533
+ * <IconButton name="sidebar" onPress={collapse} tooltip="Hide sidebar" shortcut="⌘\\" />
534
+ * </>}
535
+ * />
536
+ *
537
+ * // OctoChat — space menu + mode switcher + jump-to bar
538
+ * <SidebarHeader
539
+ * leading={<Pressable onPress={onOpenSpaceMenu}>…</Pressable>}
540
+ * extra={<><ModeSwitcher /><JumpToBar /></>}
541
+ * divider
542
+ * />
543
+ * ```
544
+ */
545
+
546
+ interface SidebarHeaderProps {
547
+ /** Leading content (flex:1) — typically the space selector / space name. */
548
+ leading: React.ReactNode;
549
+ /**
550
+ * Right-aligned action buttons row.
551
+ * OctoVault passes its own `IconButton` components here (with tooltips +
552
+ * keyboard shortcuts). For simpler headless consumers use `SidebarActionButton`.
553
+ */
554
+ actions?: React.ReactNode;
555
+ /**
556
+ * Extra slot rendered below the leading+actions row.
557
+ * Use for secondary controls like a mode switcher or a search bar.
558
+ */
559
+ extra?: React.ReactNode;
560
+ /**
561
+ * Render a hairline bottom divider in `colors.borderSubtle`.
562
+ * @default false
563
+ */
564
+ divider?: boolean;
565
+ /**
566
+ * Style applied to the outer container. Use to set host-specific padding,
567
+ * gap, background override, etc.
568
+ */
569
+ style?: StyleProp<ViewStyle>;
570
+ }
571
+ declare function SidebarHeader({ leading, actions, extra, divider, style, }: SidebarHeaderProps): React.JSX.Element;
572
+
573
+ /**
574
+ * Headless themed icon-button primitive for sidebar action slots.
575
+ *
576
+ * Renders a square `Pressable` with hover/press wash from the injected theme.
577
+ * The icon is provided by the host app as a `ReactNode` — this keeps the package
578
+ * free of `@expo/vector-icons`, `Tooltip`, and keyboard-shortcut concerns.
579
+ *
580
+ * Host apps with richer icon buttons (OctoVault's `IconButton` has tooltips,
581
+ * keyboard-shortcut labels, and haptics) can slot those directly into
582
+ * `SidebarHeader.actions` instead — this primitive is for simpler headless
583
+ * consumers.
584
+ *
585
+ * ```tsx
586
+ * <SidebarActionButton
587
+ * icon={<Icon name="search" size={15} color={theme.colors.textSecondary} />}
588
+ * onPress={openSearch}
589
+ * accessibilityLabel="Search"
590
+ * />
591
+ * ```
592
+ */
593
+
594
+ interface SidebarActionButtonProps {
595
+ /** Icon element to render — the host provides the icon component, size, and color. */
596
+ icon: React.ReactNode;
597
+ onPress: () => void;
598
+ accessibilityLabel: string;
599
+ /**
600
+ * Width and height of the pressable target in pixels.
601
+ * @default 32
602
+ */
603
+ size?: number;
604
+ }
605
+ declare function SidebarActionButton({ icon, onPress, accessibilityLabel, size, }: SidebarActionButtonProps): React.JSX.Element;
606
+
607
+ /**
608
+ * Generic themed sidebar navigation row.
609
+ *
610
+ * The headless analog of `DiscoverRow` for the sidebar panel. Suitable for
611
+ * simple link-style rows (explore, threads, pinned, …). Complex item lists
612
+ * (OctoVault's `ObjectTree`, OctoChat's `RoomCategoryList`) use their own row
613
+ * components — this primitive is for straightforward nav items.
614
+ *
615
+ * Active rows are highlighted with `colors.sidebarActive`. Hovered rows receive
616
+ * a subtle `colors.primarySubtle` wash.
617
+ *
618
+ * ```tsx
619
+ * <SidebarItem
620
+ * label="Threads"
621
+ * icon={<Icon name="thread" size={15} color={colors.textSecondary} />}
622
+ * active={threadsActive}
623
+ * onPress={onOpenThreads}
624
+ * />
625
+ * ```
626
+ */
627
+
628
+ interface SidebarItemProps {
629
+ label: string;
630
+ /** Leading icon element — the host provides the icon component. */
631
+ icon?: React.ReactNode;
632
+ /** Highlight the row as the current destination. */
633
+ active?: boolean;
634
+ /** Badge shown at the trailing edge — a number or short string. */
635
+ badge?: number | string;
636
+ onPress: () => void;
637
+ onLongPress?: () => void;
638
+ /** Additional trailing element (e.g. an action button). */
639
+ trailing?: React.ReactNode;
640
+ /**
641
+ * Left indentation level for nested items. Each level adds 16 px.
642
+ * @default 0
643
+ */
644
+ indent?: number;
645
+ }
646
+ declare function SidebarItem({ label, icon, active, badge, onPress, onLongPress, trailing, indent, }: SidebarItemProps): React.JSX.Element;
647
+
648
+ /**
649
+ * Headless themed space-switcher component.
650
+ *
651
+ * Renders a trigger button (active-space avatar + name + chevron) that opens a
652
+ * dropdown listing all spaces with per-row selection, a "join or create" action,
653
+ * optional space settings, and an app-provided footer slot (account section, etc.).
654
+ *
655
+ * The popup container (Popover on desktop, Sheet on mobile) is fully delegated to
656
+ * the host via `renderContainer` so this package stays free of modal dependencies.
657
+ * Avatars and icons are delegated via render-props for the same reason.
658
+ *
659
+ * @example
660
+ * ```tsx
661
+ * // OctoVault — sidebar variant with Popover container
662
+ * <SpaceSwitcher
663
+ * spaces={spaces}
664
+ * activeId={activeId}
665
+ * onSelect={switchSpace}
666
+ * onAdd={() => router.push('/join')}
667
+ * onSettings={() => router.push(`/space/${activeId}`)}
668
+ * variant="sidebar"
669
+ * renderTriggerAvatar={(space, size) => (
670
+ * <Avatar label={space?.short ?? ''} image={space?.image} size={size} />
671
+ * )}
672
+ * renderSpaceAvatar={(space, size) => (
673
+ * <Avatar label={space.short ?? ''} image={space.image} size={size} />
674
+ * )}
675
+ * renderIcon={(name, size, color) => <Icon name={SWITCHER_ICON[name]} size={size} color={color} />}
676
+ * renderContainer={({ isOpen, onClose, anchorRef, children }) => (
677
+ * <>
678
+ * <Popover visible={isOpen} onClose={onClose} anchorRef={anchorRef} placement="bottom-start" width={240}>
679
+ * {children}
680
+ * </Popover>
681
+ * </>
682
+ * )}
683
+ * footerSlot={<AccountSwitcher onRequestClose={...} onViewProfile={...} />}
684
+ * />
685
+ * ```
686
+ */
687
+
688
+ /** Structural space item — no SDK dependency. */
689
+ interface SwitcherSpace {
690
+ id: string;
691
+ name: string;
692
+ /** 2-letter monogram used as avatar fallback. */
693
+ short?: string;
694
+ /** Uploaded space image URI; absent → host renders monogram. */
695
+ image?: string;
696
+ }
697
+ /** Icon name union for the switcher's built-in glyphs. */
698
+ type SwitcherIconName = 'chevron-down' | 'check' | 'plus' | 'gear';
699
+ interface SpaceSwitcherProps {
700
+ spaces: SwitcherSpace[];
701
+ activeId?: string | null;
702
+ /** Called when the user taps a space row. */
703
+ onSelect: (id: string) => void;
704
+ /** "Join or create a space" action. Omit to hide the row. */
705
+ onAdd?: () => void;
706
+ /** Override the add-row label. @default "Join or create a space" */
707
+ addLabel?: string;
708
+ /**
709
+ * "Space settings" action. Only shown when both `onSettings` and `activeId`
710
+ * are provided. Omit to hide.
711
+ */
712
+ onSettings?: () => void;
713
+ /** Override the settings-row label. @default "Space settings" */
714
+ settingsLabel?: string;
715
+ /**
716
+ * Visual variant:
717
+ * - `'sidebar'` — compact left-aligned trigger for the desktop sidebar header.
718
+ * - `'appbar'` — centered trigger for a phone app-bar title area.
719
+ */
720
+ variant: 'sidebar' | 'appbar';
721
+ /**
722
+ * Wraps the dropdown content in the host app's container (Popover / Sheet).
723
+ * Called with `{ isOpen, onClose, anchorRef, children }` — must render
724
+ * children inside an appropriate modal surface.
725
+ */
726
+ renderContainer: (props: {
727
+ isOpen: boolean;
728
+ onClose: () => void;
729
+ anchorRef: React.RefObject<View>;
730
+ children: React.ReactNode;
731
+ }) => React.ReactNode;
732
+ /**
733
+ * Render the active-space avatar inside the trigger button.
734
+ * Receives the active `SwitcherSpace` (or `null` when none) and a pixel size.
735
+ * Omit to render nothing in the avatar slot.
736
+ */
737
+ renderTriggerAvatar?: (space: SwitcherSpace | null, size: number) => React.ReactNode;
738
+ /**
739
+ * Render a space row's leading avatar.
740
+ * Receives the `SwitcherSpace` and a pixel size.
741
+ * Omit to render nothing in the leading slot.
742
+ */
743
+ renderSpaceAvatar?: (space: SwitcherSpace, size: number) => React.ReactNode;
744
+ /**
745
+ * Render an icon glyph. Name is one of `'chevron-down' | 'check' | 'plus' | 'gear'`.
746
+ * Omit to hide chevron, check, and action icons (spaces remain selectable).
747
+ */
748
+ renderIcon?: (name: SwitcherIconName, size: number, color: string) => React.ReactNode;
749
+ /**
750
+ * Footer rendered below the space list + action rows — use for account-switcher
751
+ * sections (with separator if needed). Fully app-owned.
752
+ */
753
+ footerSlot?: React.ReactNode;
754
+ }
755
+ declare function SpaceSwitcher({ spaces, activeId, onSelect, onAdd, addLabel, onSettings, settingsLabel, variant, renderContainer, renderTriggerAvatar, renderSpaceAvatar, renderIcon, footerSlot, }: SpaceSwitcherProps): React.JSX.Element;
756
+
757
+ /**
758
+ * Full-screen scrim overlay that centers its content. Tapping the backdrop, the
759
+ * close button, the Escape key (web) or the hardware back (Android) dismisses it.
760
+ *
761
+ * All interactive chrome (close button, action buttons) is injected via render
762
+ * props so this package remains free of @expo/vector-icons, expo-image, and
763
+ * reanimated. The host app renders its own icon buttons and images.
764
+ *
765
+ * @example
766
+ * ```tsx
767
+ * import { Lightbox } from '@drakkar.software/octospaces-ui';
768
+ *
769
+ * <Lightbox
770
+ * visible={zoomed}
771
+ * onClose={() => setZoomed(false)}
772
+ * renderCloseButton={(onClose) => (
773
+ * <IconButton name="x" color={colors.onScrim} onPress={onClose} />
774
+ * )}
775
+ * renderActions={() => (
776
+ * <IconButton name="share" color={colors.onScrim} onPress={handleShare} />
777
+ * )}
778
+ * >
779
+ * <Image source={{ uri }} style={{ width: w * 0.92, height: h * 0.82 }} />
780
+ * </Lightbox>
781
+ * ```
782
+ */
783
+
784
+ interface LightboxProps {
785
+ visible: boolean;
786
+ onClose: () => void;
787
+ /** Centered content — the host renders the full-size image here. */
788
+ children: ReactNode;
789
+ /** Accessible label for the backdrop tap-to-close. Default: "Close preview". */
790
+ closeLabel?: string;
791
+ /**
792
+ * Render the close affordance pinned to the top-right corner.
793
+ * Receives `onClose` so the button can dismiss the overlay.
794
+ * If omitted, tapping the backdrop or hardware back still closes it.
795
+ */
796
+ renderCloseButton?: (onClose: () => void) => ReactNode;
797
+ /**
798
+ * Render additional action(s) pinned to the bottom-right corner,
799
+ * e.g. a save/share button. Return `null` to show nothing.
800
+ */
801
+ renderActions?: () => ReactNode;
802
+ }
803
+ /**
804
+ * Full-screen scrim overlay that centers its children. Headless: all buttons
805
+ * are injected via render props; the package has no icon or image dependencies.
806
+ *
807
+ * Dismissal: backdrop tap · `renderCloseButton` · hardware back (Android) ·
808
+ * Escape key (web).
809
+ */
810
+ declare function Lightbox({ visible, onClose, children, closeLabel, renderCloseButton, renderActions, }: LightboxProps): React.JSX.Element;
811
+
812
+ export { type ColorScheme, type DiscoverEntry, DiscoverList, type DiscoverListProps, DiscoverRow, type DiscoverRowProps, DiscoverScreen, type DiscoverScreenProps, type Easing, type Fonts, type LabelTracking, type Layers, type Layout, Lightbox, type LightboxProps, type Motion, type MotionToken, OctoSpacesThemeProvider, type OctoSpacesThemeProviderProps, type Opacity, type Palette, type Radii, type RailIconName, type RailSpace, type ShadowToken, type Shadows, Sidebar, SidebarActionButton, type SidebarActionButtonProps, SidebarHeader, type SidebarHeaderProps, SidebarItem, type SidebarItemProps, type SidebarProps, SpaceSwitcher, type SpaceSwitcherProps, SpacesRail, type SpacesRailProps, type Spacing, type Swatches, type SwitcherIconName, type SwitcherSpace, type Theme, type TypeScale, type Typography, avatarTint, filterDiscoverEntries, focusRingStyle, glowShadow, paperBorder, presenceColor, sortDiscoverEntries, statusColor, swatch, useOctoSpacesTheme, verificationColor };