@petrarca/sonnet-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.ts CHANGED
@@ -50,6 +50,49 @@ interface ButtonProps$1 extends React$1.ButtonHTMLAttributes<HTMLButtonElement>,
50
50
  }
51
51
  declare const Button: React$1.ForwardRefExoticComponent<ButtonProps$1 & React$1.RefAttributes<HTMLButtonElement>>;
52
52
 
53
+ /**
54
+ * IconButton -- a compact, square icon-only button with an accessible label
55
+ * and a tooltip. The house standard for inline affordances (rename, delete,
56
+ * edit) and small toolbar actions across the Sonnet apps.
57
+ *
58
+ * - `variant` defaults to "ghost" (borderless, for inline/hover-reveal rows).
59
+ * Use "outline" for standalone toolbar buttons.
60
+ * - `tone="destructive"` tints the hover state red (e.g. delete).
61
+ * - The `label` is both the tooltip text and the aria-label, so the button is
62
+ * always accessible without visible text.
63
+ * - Do not size the icon yourself: the underlying Button forces child SVGs to
64
+ * `size-4` (16px), so pass a bare `<Icon />` (no h-/w- class).
65
+ * - `revealOnHover` applies the house row-action convention: the button is
66
+ * hidden at rest and revealed when the row is hovered or the button is
67
+ * keyboard-focused; a disabled action stays faintly visible (opacity-30)
68
+ * rather than hidden. The row must set the `group/row` class for this.
69
+ *
70
+ * Usage:
71
+ * <IconButton label="Delete" tone="destructive" onClick={...}>
72
+ * <Trash2 />
73
+ * </IconButton>
74
+ *
75
+ * // row-action (parent row has className="... group/row"):
76
+ * <IconButton label="Edit" revealOnHover onClick={...}><Pencil /></IconButton>
77
+ */
78
+ interface IconButtonProps extends Omit<ButtonProps$1, "size" | "children" | "aria-label"> {
79
+ /** Tooltip text and accessible label. */
80
+ label: string;
81
+ /** The icon to render. */
82
+ children: React$1.ReactNode;
83
+ /** Hover tone. "destructive" tints hover red. Default "default". */
84
+ tone?: "default" | "destructive";
85
+ /** Tooltip side. */
86
+ tooltipSide?: "top" | "right" | "bottom" | "left";
87
+ /**
88
+ * Row-action reveal: hidden at rest, shown on row hover (`group/row`) or
89
+ * keyboard focus. Disabled buttons stay at opacity-30 instead of hidden, so
90
+ * the affordance reads as "present but unavailable". Default false.
91
+ */
92
+ revealOnHover?: boolean;
93
+ }
94
+ declare const IconButton: React$1.ForwardRefExoticComponent<IconButtonProps & React$1.RefAttributes<HTMLButtonElement>>;
95
+
53
96
  declare const Card: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
54
97
  declare const CardHeader: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
55
98
  declare const CardTitle: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
@@ -413,6 +456,12 @@ interface TabsListProps extends React$1.ComponentPropsWithoutRef<typeof TabsPrim
413
456
  declare const TabsList: React$1.ForwardRefExoticComponent<TabsListProps & React$1.RefAttributes<HTMLDivElement>>;
414
457
  declare const TabsTrigger: React$1.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React$1.RefAttributes<HTMLButtonElement>, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
415
458
  declare const TabsContent: React$1.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsContentProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
459
+ /**
460
+ * TabsSeparator -- a thin, non-interactive vertical divider placed inside a
461
+ * TabsList to visually group related triggers (e.g. preview tabs vs. source
462
+ * tabs). Presentational only; not part of the roving-tabindex order.
463
+ */
464
+ declare const TabsSeparator: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
416
465
 
417
466
  declare const Textarea: React$1.ForwardRefExoticComponent<Omit<React$1.DetailedHTMLProps<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, HTMLTextAreaElement>, "ref"> & React$1.RefAttributes<HTMLTextAreaElement>>;
418
467
 
@@ -623,6 +672,23 @@ declare function createRenderer<TRow = Record<string, unknown>>(render: (row: TR
623
672
  * Extractable to @petrarca/sonnet-ui.
624
673
  */
625
674
 
675
+ /** How a row's detail (onRowClick) is opened. */
676
+ type RowActivation = "click" | "double-click";
677
+ /**
678
+ * Props of EntityTable that can be defaulted app-wide via SonnetConfigProvider.
679
+ * Behavioral, non-data props only.
680
+ */
681
+ interface EntityTableConfigurable {
682
+ rowActivation: RowActivation;
683
+ showChevron: boolean;
684
+ }
685
+ declare module "@petrarca/sonnet-core" {
686
+ interface SonnetComponentDefaults {
687
+ EntityTable?: {
688
+ defaultProps?: Partial<EntityTableConfigurable>;
689
+ };
690
+ }
691
+ }
626
692
  /** Declarative row action rendered as a button in a trailing "Actions" column. */
627
693
  interface RowAction<TRow> {
628
694
  label: string;
@@ -646,6 +712,30 @@ interface EntityTableProps<TRow extends RowData> {
646
712
  isFiltered?: boolean;
647
713
  emptyMessage?: string;
648
714
  onRowClick?: (row: TRow) => void;
715
+ /**
716
+ * How onRowClick (open detail) is triggered. Resolved against app-wide
717
+ * config (SonnetConfigProvider) then the built-in default "click".
718
+ *
719
+ * "click" -- single-click on a row opens detail (default,
720
+ * preserves existing behavior). The chevron is a
721
+ * non-interactive affordance.
722
+ * "double-click" -- single-click sets the active row (and fires
723
+ * onActiveRowChange); double-click, or clicking the
724
+ * trailing chevron button, opens detail.
725
+ */
726
+ rowActivation?: RowActivation;
727
+ /**
728
+ * Fired when the active (single-selected) row changes. Only meaningful when
729
+ * rowActivation is "double-click" and selectionMode is off. null when the
730
+ * active row is cleared.
731
+ */
732
+ onActiveRowChange?: (row: TRow | null) => void;
733
+ /**
734
+ * Whether to show the trailing chevron column. Resolved against app-wide
735
+ * config then a built-in default of "show when onRowClick is set". In
736
+ * "double-click" mode the chevron is an interactive button that opens detail.
737
+ */
738
+ showChevron?: boolean;
649
739
  selectionMode?: boolean;
650
740
  onSelectionChange?: (selectedRows: TRow[]) => void;
651
741
  pagination?: PaginationState;
@@ -744,6 +834,13 @@ interface EntitySelectProps {
744
834
  minChars?: number;
745
835
  /** Currently selected value (controlled). */
746
836
  value?: string | null;
837
+ /**
838
+ * The option for the current value, supplying its label. Use when the
839
+ * selected value is set before any options have loaded (e.g. an edit form
840
+ * in typeahead/explicit mode) so the trigger can render the label without
841
+ * fetching the full list. Must match `value`; ignored otherwise.
842
+ */
843
+ selectedOption?: EntityOption | null;
747
844
  /** Called when the selection changes. */
748
845
  onChange?: (value: string | null) => void;
749
846
  /** Called when the selection changes, passing the full option (value + label). */
@@ -760,6 +857,12 @@ interface EntitySelectProps {
760
857
  emptyMessage?: string;
761
858
  /** Whether the field is required (shows asterisk). */
762
859
  required?: boolean;
860
+ /**
861
+ * Show a clear (X) affordance that resets the selection to null when a value
862
+ * is set. Use for optional entity references (e.g. an assignment that can be
863
+ * removed). Ignored when required or disabled.
864
+ */
865
+ clearable?: boolean;
763
866
  /** Whether the select is disabled. */
764
867
  disabled?: boolean;
765
868
  /** Description text below the label. */
@@ -1087,4 +1190,4 @@ type Props = {
1087
1190
  */
1088
1191
  declare function ClipboardMenu({ onAddItem }: Props): react_jsx_runtime.JSX.Element;
1089
1192
 
1090
- export { Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, Button, CELL_RENDERERS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CellRenderer, type CellRendererProps, Checkbox, ClipboardButton, ClipboardItemComponent as ClipboardItem, ClipboardMenu, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EntitySelect, type EntitySelectProps, EntityTable, type EntityTableProps, EntityTree, type EntityTreeHandle, type EntityTreeProps, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Popover, PopoverContent, PopoverTrigger, PropertyList, type PropertyListLayout, type PropertyListProps, PropertyValue, type PropertyValueProps, ResizeHandle, type ResizeHandleProps, type ResolvedColumn, type RowAction, ScrollArea, ScrollBar, SearchInput, type SearchMode, Separator, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetTitle, SheetTrigger, SimpleGroup, SimpleStack, SimpleTooltip, Skeleton, Spinner, Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperList, StepperNext, StepperPrev, type StepperProps, StepperSeparator, StepperTitle, StepperTrigger, type TableUiSchema, Tabs, TabsContent, TabsList, TabsTrigger, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TreeNode, TreeView, type TreeViewHandle, type TreeViewProps, badgeVariants, buttonVariants, createRenderer, useStore as useStepper };
1193
+ export { Alert, AlertDescription, AlertTitle, Avatar, AvatarFallback, AvatarImage, Badge, type BadgeProps, Button, CELL_RENDERERS, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type CellRenderer, type CellRendererProps, Checkbox, ClipboardButton, ClipboardItemComponent as ClipboardItem, ClipboardMenu, Collapsible, CollapsibleContent, CollapsibleTrigger, Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuGroup, DropdownMenuItem, DropdownMenuLabel, DropdownMenuPortal, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, EntitySelect, type EntitySelectProps, EntityTable, type EntityTableProps, EntityTree, type EntityTreeHandle, type EntityTreeProps, IconButton, type IconButtonProps, Input, InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, Label, Popover, PopoverContent, PopoverTrigger, PropertyList, type PropertyListLayout, type PropertyListProps, PropertyValue, type PropertyValueProps, ResizeHandle, type ResizeHandleProps, type ResolvedColumn, type RowAction, ScrollArea, ScrollBar, SearchInput, type SearchMode, Separator, Sheet, SheetBody, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetOverlay, SheetTitle, SheetTrigger, SimpleGroup, SimpleStack, SimpleTooltip, Skeleton, Spinner, Stepper, StepperContent, StepperDescription, StepperIndicator, StepperItem, StepperList, StepperNext, StepperPrev, type StepperProps, StepperSeparator, StepperTitle, StepperTrigger, type TableUiSchema, Tabs, TabsContent, TabsList, TabsSeparator, TabsTrigger, Textarea, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, type TreeNode, TreeView, type TreeViewHandle, type TreeViewProps, badgeVariants, buttonVariants, createRenderer, useStore as useStepper };