@baseline-ui/core 0.20.1 → 0.22.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
@@ -1,9 +1,9 @@
1
1
  import React, { Key, Dispatch, SetStateAction } from 'react';
2
- import { DraggableCollectionStateOptions, DroppableCollectionStateOptions, Orientation, ListState, SliderStateOptions, ToggleProps, OverlayTriggerProps, OverlayTriggerState, MenuTriggerProps, TooltipTriggerProps, NumberFieldStateOptions, ListProps, SelectStateOptions, Item as Item$1 } from 'react-stately';
2
+ import { DraggableCollectionStateOptions, DroppableCollectionStateOptions, Orientation, ListState, SliderStateOptions, ToggleProps, OverlayTriggerProps, OverlayTriggerState, MenuTriggerProps, TooltipTriggerProps, NumberFieldStateOptions, ListProps, SelectStateOptions, Item as Item$1, Selection as Selection$1, ComboBoxStateOptions } from 'react-stately';
3
3
  import * as react_aria from 'react-aria';
4
- import { DraggableCollectionOptions, DroppableCollectionOptions, AriaListBoxProps, AriaListBoxOptions, OptionAria, AriaButtonProps, AriaSliderProps, AriaSwitchProps, AriaSearchFieldProps, AriaPopoverProps, useOverlayTrigger, AriaMenuProps, AriaMenuTriggerProps, AriaLinkOptions, SeparatorProps as SeparatorProps$1, AriaProgressBarProps, AriaTextFieldProps, AriaTooltipProps, AriaPositionProps, OverlayProps, AriaToggleButtonProps, AriaCheckboxProps, AriaNumberFieldProps, I18nProviderProps as I18nProviderProps$1, LocalizedStrings, useNumberFormatter, useDateFormatter, AriaTagGroupProps, AriaSelectOptions, AriaDialogProps, DropOptions, ClipboardProps, PressProps, AriaRadioGroupProps, AriaModalOverlayProps, Locale } from 'react-aria';
4
+ import { DraggableCollectionOptions, DroppableCollectionOptions, AriaListBoxProps, AriaListBoxOptions, OptionAria, AriaButtonProps, AriaSliderProps, AriaSwitchProps, AriaSearchFieldProps, AriaPopoverProps, useOverlayTrigger, AriaMenuProps, AriaMenuTriggerProps, AriaLinkOptions, SeparatorProps as SeparatorProps$1, AriaProgressBarProps, AriaTextFieldProps, AriaTooltipProps, AriaPositionProps, OverlayProps, AriaToggleButtonProps, AriaCheckboxProps, AriaNumberFieldProps, I18nProviderProps as I18nProviderProps$1, LocalizedStrings, useNumberFormatter, useDateFormatter, AriaTagGroupProps, AriaSelectOptions, AriaDialogProps, DropOptions, ClipboardProps, PressProps, AriaRadioGroupProps, AriaModalOverlayProps, AriaComboBoxOptions, AriaComboBoxProps, Locale } from 'react-aria';
5
5
  export { I18nProviderProps, useCollator, useDateFormatter, useNumberFormatter } from 'react-aria';
6
- import { Node as Node$1, DragItem, AriaLabelingProps } from '@react-types/shared';
6
+ import { Node as Node$1, DragItem, DOMAttributes, AriaLabelingProps, AriaValidationProps } from '@react-types/shared';
7
7
  import { IconProps, SVGRProps } from '@baseline-ui/icons';
8
8
  import { Theme, Sprinkles } from '@baseline-ui/tokens';
9
9
  import { AriaTabListProps } from '@react-types/tabs';
@@ -151,7 +151,7 @@ interface ActionButtonProps extends ActionButtonSharedProps {
151
151
  *
152
152
  * @default primary
153
153
  */
154
- variant?: "primary" | "secondary" | "tertiary" | "ghost" | "popover";
154
+ variant?: "primary" | "secondary" | "tertiary" | "ghost" | "popover" | "toolbar";
155
155
  /** The button's label. */
156
156
  label: React.ReactNode;
157
157
  /** The button's icon before the label. */
@@ -163,7 +163,7 @@ interface ActionButtonProps extends ActionButtonSharedProps {
163
163
  *
164
164
  * @default sm
165
165
  */
166
- size?: "sm" | "md";
166
+ size?: "sm" | "md" | "lg";
167
167
  /** Indicates whether focusing should be prevented on press. */
168
168
  preventFocusOnPress?: boolean;
169
169
  }
@@ -388,8 +388,27 @@ interface MenuProps extends MenuPopoverProps, MenuTriggerProps, Omit<AriaMenuPro
388
388
  * <ActionButton label="Label">
389
389
  * </Menu>
390
390
  * ```
391
+ *
392
+ * @deprecated Use `renderTrigger` instead.
391
393
  */
392
394
  children?: React.ReactNode;
395
+ /**
396
+ * A function that renders the trigger element of the component. The default
397
+ * implementation renders an `ActionButton` component.
398
+ *
399
+ * ```tsx
400
+ * <Menu renderTrigger={({ buttonProps, ref }) => <ActionButton {...buttonProps} label="Label" ref={ref} />
401
+ * ```
402
+ */
403
+ renderTrigger?: (options: {
404
+ buttonProps: ActionButtonProps;
405
+ ref: React.RefObject<HTMLButtonElement>;
406
+ }) => React.ReactNode;
407
+ /**
408
+ * The label of the trigger element. This can be a string, a React node, or a
409
+ * function that accepts a boolean indicating whether the menu is open.
410
+ */
411
+ triggerLabel?: React.ReactNode | ((isOpen: boolean) => React.ReactNode);
393
412
  }
394
413
 
395
414
  declare const Menu: React.ForwardRefExoticComponent<MenuProps & React.RefAttributes<HTMLUListElement>>;
@@ -632,7 +651,7 @@ interface ToggleButtonProps extends StylingProps, Omit<AriaToggleButtonProps, "c
632
651
  *
633
652
  * @default "md"
634
653
  */
635
- size?: "md" | "lg";
654
+ size?: "sm" | "md" | "lg";
636
655
  /** Indicates whether focusing should be prevented on press. */
637
656
  preventFocusOnPress?: boolean;
638
657
  }
@@ -813,6 +832,18 @@ interface SelectProps extends Omit<AriaSelectOptions<ListItem> & SelectStateOpti
813
832
  validationState?: "valid" | "error" | "warning";
814
833
  /** Whether the select component is read only. */
815
834
  isReadOnly?: boolean;
835
+ /**
836
+ * This callback can be used to render the trigger element of the select
837
+ * component. The trigger element is the element that is clicked to open the
838
+ * select menu.
839
+ */
840
+ renderTrigger?: (options: {
841
+ buttonProps: Omit<ActionButtonProps, "variant" | "label">;
842
+ valueProps: DOMAttributes;
843
+ isOpen: boolean;
844
+ selectedValue: ListItem | null;
845
+ ref: React.RefObject<HTMLButtonElement>;
846
+ }) => React.ReactNode;
816
847
  }
817
848
 
818
849
  declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLDivElement>>;
@@ -1685,12 +1716,37 @@ interface ColorPresetInlineInputProps extends Omit<RadioGroupProps, "items" | "d
1685
1716
  declare const ColorPresetInlineInput: React.ForwardRefExoticComponent<ColorPresetInlineInputProps & React.RefAttributes<HTMLDivElement>>;
1686
1717
 
1687
1718
  interface ToolbarProps extends StylingProps, AriaToolbarProps {
1719
+ /** The children of the toolbar. */
1688
1720
  children: React.ReactNode;
1689
1721
  /**
1690
1722
  * Identifies the element (or elements) whose contents or presence are
1691
1723
  * controlled by the current element.
1692
1724
  */
1693
1725
  "aria-controls"?: string;
1726
+ /**
1727
+ * This prop is used to determine if the toolbar should be collapsible. If
1728
+ * true, the buttons in the toolbar will be hidden behind a menu when the
1729
+ * toolbar is too small to display all of the buttons.
1730
+ *
1731
+ * @default false
1732
+ */
1733
+ isCollapsible?: boolean;
1734
+ /**
1735
+ * The props to pass to the Menu component when the toolbar is collapsible.
1736
+ * This prop is only relevant when `isCollapsible` is true.
1737
+ */
1738
+ collapsibleMenuProps?: Omit<MenuProps, "items" | "onAction" | "placement" | "disabledKeys">;
1739
+ /**
1740
+ * The trigger to use for the menu when the toolbar is collapsible. This prop
1741
+ * is only relevant when `isCollapsible` is true.
1742
+ */
1743
+ collapsibleMenuTrigger?: React.ReactNode;
1744
+ /**
1745
+ * A function that renders a spacer element in the collapsible toolbar between
1746
+ * the toolbar buttons and the menu trigger. This prop is only relevant when
1747
+ * `isCollapsible` is true.
1748
+ */
1749
+ renderSpacer?: () => React.ReactNode;
1694
1750
  }
1695
1751
 
1696
1752
  declare const Toolbar: React.ForwardRefExoticComponent<ToolbarProps & React.RefAttributes<HTMLDivElement>>;
@@ -1829,8 +1885,14 @@ interface EditorProps extends StylingProps, AriaLabelingProps {
1829
1885
  * @default 10
1830
1886
  */
1831
1887
  maxMentionableUsersSuggestions?: number;
1832
- /** Footer button represents an array of ActionIconButtonProps. */
1833
- footerButtons?: ActionIconButtonProps[];
1888
+ /** Footer button represents the buttons that are displayed in the footer. */
1889
+ footerButtons?: ({
1890
+ type: "action";
1891
+ props: Omit<ActionIconButtonProps, "size" | "variant">;
1892
+ } | {
1893
+ type: "toggle";
1894
+ props: Omit<ToggleIconButtonProps, "size" | "variant">;
1895
+ })[];
1834
1896
  /** The imperative handle for manipulating editor. */
1835
1897
  editorHandle?: React.RefObject<EditorHandle>;
1836
1898
  /**
@@ -1851,6 +1913,12 @@ interface EditorProps extends StylingProps, AriaLabelingProps {
1851
1913
  * @default false
1852
1914
  */
1853
1915
  autoFocus?: boolean;
1916
+ /**
1917
+ * Whether to save the editor value when `Enter` key is pressed.
1918
+ *
1919
+ * @default false
1920
+ */
1921
+ saveOnEnter?: boolean;
1854
1922
  }
1855
1923
 
1856
1924
  declare const Editor: React.MemoExoticComponent<React.ForwardRefExoticComponent<EditorProps & React.RefAttributes<HTMLDivElement>>>;
@@ -1991,6 +2059,135 @@ interface AudioPlayerProps extends StylingProps, AriaLabelingProps {
1991
2059
 
1992
2060
  declare const AudioPlayer: React.ForwardRefExoticComponent<AudioPlayerProps & React.RefAttributes<HTMLDivElement>>;
1993
2061
 
2062
+ interface ImageGalleryProps extends StylingProps, Omit<ListBoxProps, "items" | "layout" | "grid" | "renderOption" | "renderDropIndicator" | "renderDragPreview" | "UNSAFE_state" | "showSelectedIcon" | "orientation" | "shouldSelectOnPressUp" | "shouldFocusOnHover" | "dropIndicatorClassName" | "dropIndicatorStyle" | "shouldUseVirtualFocus" | "getItems" | "acceptedDragTypes" | "sectionClassName" | "sectionStyle"> {
2063
+ /**
2064
+ * An array of objects containing the image source, alt text, and label for
2065
+ * each image.
2066
+ *
2067
+ * ```tsx
2068
+ * const items = [
2069
+ * {
2070
+ * id: "1",
2071
+ * src: "https://example.com/image1.jpg",
2072
+ * alt: "Image 1",
2073
+ * label: "Image 1",
2074
+ * },
2075
+ * {
2076
+ * id: "2",
2077
+ * src: "https://example.com/image2.jpg",
2078
+ * alt: "Image 2",
2079
+ * label: "Image 2",
2080
+ * },
2081
+ * ];
2082
+ * ```
2083
+ */
2084
+ items: {
2085
+ id: string;
2086
+ src: string;
2087
+ alt?: string;
2088
+ label: string;
2089
+ }[];
2090
+ /**
2091
+ * The size of the images.
2092
+ *
2093
+ * @default "sm"
2094
+ */
2095
+ size?: "sm" | "md";
2096
+ /**
2097
+ * The aspect ratio of the images.
2098
+ *
2099
+ * @default 16 / 9
2100
+ */
2101
+ aspectRatio?: number;
2102
+ /**
2103
+ * The fit of the images.
2104
+ *
2105
+ * @default "cover"
2106
+ */
2107
+ fit?: "contain" | "cover";
2108
+ /** A callback that is called when an image is deleted. */
2109
+ onDelete?: (keys: Selection$1) => void;
2110
+ }
2111
+
2112
+ declare const ImageGallery: React.ForwardRefExoticComponent<ImageGalleryProps & React.RefAttributes<HTMLDivElement>>;
2113
+
2114
+ interface ComboBoxProps extends StylingProps, Omit<AriaComboBoxOptions<ListItem>, "items" | "children" | "inputRef" | "popoverRef" | "listBoxRef" | "buttonRef" | "validationState" | "errorMessage" | "description">, Omit<AriaComboBoxProps<ListItem>, "items" | "children" | "errorMessage" | "description" | "validationState">, Omit<ListBoxProps, "autoFocus" | "onBlur" | "onFocus" | "onSelectionChange" | "selectionBehavior" | "selectionMode" | "selectedKeys" | "defaultSelectedKeys" | "renderDropIndicator" | "renderDragPreview" | "UNSAFE_state" | "dropIndicatorClassName" | "dropIndicatorStyle" | keyof DragAndDropProps>, AriaValidationProps, Omit<ComboBoxStateOptions<ListItem>, "items" | "children" | "errorMessage" | "description" | "validationState" | "selectedKey">, InputMessage {
2115
+ /** ID of the initially selected item */
2116
+ defaultSelectedKey?: string;
2117
+ /**
2118
+ * The state of the combobox input.
2119
+ *
2120
+ * @default valid
2121
+ */
2122
+ validationState?: "valid" | "error" | "warning";
2123
+ /**
2124
+ * The variant of the text input.
2125
+ *
2126
+ * @default primary
2127
+ */
2128
+ variant?: "primary" | "ghost";
2129
+ /**
2130
+ * The position of the label relative to the input.
2131
+ *
2132
+ * @default top
2133
+ */
2134
+ labelPosition?: "top" | "start";
2135
+ /** Whether the input is read only. */
2136
+ readOnly?: boolean;
2137
+ /** The style object to apply to the input element */
2138
+ inputStyle?: React.CSSProperties;
2139
+ /** The class name to apply to the input element */
2140
+ inputClassName?: string;
2141
+ /** Optional label for the toggle button */
2142
+ toggleLabel?: string;
2143
+ /**
2144
+ * The custom render function for the listbox options.
2145
+ *
2146
+ * @param item Node<ListItem>
2147
+ * @param options [OptionAria]()
2148
+ * @param ref React.RefObject<HTMLLIElement>
2149
+ */
2150
+ renderOption?: (item: Node$1<ListItem>, options: OptionAria & {
2151
+ showSelectedIcon?: boolean;
2152
+ _state: ListState<ListItem>;
2153
+ }, ref: React.Ref<HTMLLIElement>) => React.ReactNode;
2154
+ filterItems?: boolean;
2155
+ onInputChange?: (value: string) => void;
2156
+ showIcon?: boolean;
2157
+ /**
2158
+ * The items to render in the listbox. Items have the following shape:
2159
+ *
2160
+ * ```ts
2161
+ * export type ListOption = {
2162
+ * id: string;
2163
+ * label: string;
2164
+ * description?: string;
2165
+ * icon?: React.FC<IconProps>;
2166
+ * };
2167
+ *
2168
+ * export type ListSection = {
2169
+ * id: string;
2170
+ * title?: string;
2171
+ * type: "section";
2172
+ * children: ListOption[];
2173
+ * };
2174
+ *
2175
+ * type ListItem = ListOption | ListSection;
2176
+ * ```
2177
+ */
2178
+ items: ListItem[];
2179
+ /**
2180
+ * Specify which interaction should trigger the dropdown to open
2181
+ *
2182
+ * @default input
2183
+ */
2184
+ menuTrigger?: "manual" | "input" | "focus";
2185
+ /** Custom filter function to use when filtering items. */
2186
+ filter?: ComboBoxStateOptions<ListItem>["defaultFilter"];
2187
+ }
2188
+
2189
+ declare const ComboBox: React.ForwardRefExoticComponent<ComboBoxProps & React.RefAttributes<HTMLDivElement>>;
2190
+
1994
2191
  /**
1995
2192
  * A hook that creates an IntersectionObserver and observes a target element.
1996
2193
  *
@@ -2083,19 +2280,6 @@ interface ResizeObserverOptions {
2083
2280
  * alt: "Placeholder image",
2084
2281
  * });
2085
2282
  * ```;
2086
- *
2087
- * @param {Object} options - The options object.
2088
- * @param {string} options.src - The image source URL.
2089
- * @param {string} options.alt - The image alt text.
2090
- * @returns {Object} An object containing the image loading state and props.
2091
- * @returns {boolean} IsLoaded - Whether the image has loaded.
2092
- * @returns {boolean} HasError - Whether there was an error loading the image.
2093
- * @returns {boolean} IsLoading - Whether the image is currently loading.
2094
- * @returns {Object} ImgProps - The image props to be passed to the `img`
2095
- * element.
2096
- * @returns {string} ImgProps.src - The image source URL, or `undefined` if the
2097
- * image hasn't loaded yet.
2098
- * @returns {string} ImgProps.alt - The image alt text.
2099
2283
  */
2100
2284
  declare function useImage({ src, alt }: {
2101
2285
  src?: string;
@@ -2333,4 +2517,4 @@ declare function useDevice(element?: Element | null | undefined): "tablet" | "de
2333
2517
  */
2334
2518
  declare function usePortalContainer(_portalContainer?: HTMLElement): HTMLElement | undefined;
2335
2519
 
2336
- export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, ActionButton, type ActionButtonProps, ActionIconButton, type ActionIconButtonProps, AlertDialog, type AlertDialogProps, AudioPlayer, type AudioPlayerProps, Avatar, type AvatarProps, type BlockProps, Box, type BoxProps, Checkbox, type CheckboxProps, ColorInput, type ColorInputProps, type ColorPreset, ColorPresetInlineInput, type ColorPresetInlineInputProps, ColorSwatch, type ColorSwatchProps, DateFormat, type DateFormatProps, Dialog, type DialogProps, DialogTitle, type DialogTitleProps, DomNodeRenderer, type DomNodeRendererProps, Drawer, type DrawerProps, Editor, type EditorHandle, type EditorProps, FileUpload, type FileUploadProps, FreehandCanvas, type FreehandCanvasProps, Group, type GroupProps, I18nProvider, type I18nResult, IconColorInputButton, ImageDropZone, type ImageDropZoneProps, InlineAlert, type InlineAlertProps, Link, type LinkProps, ListBox, type ListBoxProps, type ListOption, Markdown, type MarkdownProps, Menu, type MenuItem, type MenuProps, type MessageDescriptor, MessageFormat, type MessageFormatProps, Modal, ModalClose, ModalContent, type ModalContentProps, type ModalProps, ModalTrigger, NumberFormat, type NumberFormatProps, NumberInput, type NumberInputProps, Pagination, type PaginationProps, Popover, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type PopoverTriggerProps, Portal, PortalContainerProvider, type PortalProps, Preview, type PreviewProps, ProgressBar, type ProgressBarProps, ProgressSpinner, type ProgressSpinnerProps, RadioGroup, type RadioGroupProps, Reaction, type ReactionProps, ScrollControlButton, type ScrollControlButtonProps, SearchInput, type SearchInputProps, Select, type SelectProps, Separator, type SeparatorProps, Slider, type SliderProps, type StylingProps, Switch, type SwitchProps, TabItem, type TabItemProps, Tabs, type TabsProps, TagGroup, type TagGroupProps, Text, TextInput, type TextInputProps, type TextProps, ThemeProvider, type ThemeProviderProps, ToggleButton, type ToggleButtonProps, ToggleIconButton, type ToggleIconButtonProps, Toolbar, type ToolbarProps, Tooltip, type TooltipProps, Transform, type TransformProps, Transition, type TransitionProps, defineMessages, isInsideOverlayContent, useDevice, useI18n, useImage, useIntersectionObserver, useIsFirstRender, useLocalStorage, useMutationObserver, usePortalContainer, useResizeObserver, useTextSelection, useUndoRedo, useUserPreferences };
2520
+ export { Accordion, AccordionItem, type AccordionItemProps, type AccordionProps, ActionButton, type ActionButtonProps, ActionIconButton, type ActionIconButtonProps, AlertDialog, type AlertDialogProps, AudioPlayer, type AudioPlayerProps, Avatar, type AvatarProps, type BlockProps, Box, type BoxProps, Checkbox, type CheckboxProps, ColorInput, type ColorInputProps, type ColorPreset, ColorPresetInlineInput, type ColorPresetInlineInputProps, ColorSwatch, type ColorSwatchProps, ComboBox, type ComboBoxProps, DateFormat, type DateFormatProps, Dialog, type DialogProps, DialogTitle, type DialogTitleProps, DomNodeRenderer, type DomNodeRendererProps, Drawer, type DrawerProps, Editor, type EditorHandle, type EditorProps, FileUpload, type FileUploadProps, FreehandCanvas, type FreehandCanvasProps, Group, type GroupProps, I18nProvider, type I18nResult, IconColorInputButton, ImageDropZone, type ImageDropZoneProps, ImageGallery, type ImageGalleryProps, InlineAlert, type InlineAlertProps, Link, type LinkProps, ListBox, type ListBoxProps, type ListOption, Markdown, type MarkdownProps, Menu, type MenuItem, type MenuProps, type MessageDescriptor, MessageFormat, type MessageFormatProps, Modal, ModalClose, ModalContent, type ModalContentProps, type ModalProps, ModalTrigger, NumberFormat, type NumberFormatProps, NumberInput, type NumberInputProps, Pagination, type PaginationProps, Popover, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type PopoverTriggerProps, Portal, PortalContainerProvider, type PortalProps, Preview, type PreviewProps, ProgressBar, type ProgressBarProps, ProgressSpinner, type ProgressSpinnerProps, RadioGroup, type RadioGroupProps, Reaction, type ReactionProps, ScrollControlButton, type ScrollControlButtonProps, SearchInput, type SearchInputProps, Select, type SelectProps, Separator, type SeparatorProps, Slider, type SliderProps, type StylingProps, Switch, type SwitchProps, TabItem, type TabItemProps, Tabs, type TabsProps, TagGroup, type TagGroupProps, Text, TextInput, type TextInputProps, type TextProps, ThemeProvider, type ThemeProviderProps, ToggleButton, type ToggleButtonProps, ToggleIconButton, type ToggleIconButtonProps, Toolbar, type ToolbarProps, Tooltip, type TooltipProps, Transform, type TransformProps, Transition, type TransitionProps, defineMessages, isInsideOverlayContent, useDevice, useI18n, useImage, useIntersectionObserver, useIsFirstRender, useLocalStorage, useMutationObserver, usePortalContainer, useResizeObserver, useTextSelection, useUndoRedo, useUserPreferences };