@lumx/react 3.0.5 → 3.0.6-alpha.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.
@@ -48,6 +48,23 @@ declare type Callback = () => void;
48
48
  * (excluding `NaN` as it can't be distinguished from `number`)
49
49
  */
50
50
  declare type Falsy = false | undefined | null | 0 | '';
51
+ /**
52
+ * Require either `aria-label` or `arial-labelledby` prop.
53
+ * If none are set, the order will prioritize `aria-labelledby` over `aria-label` as it
54
+ * needs a visible element.
55
+ */
56
+ declare type HasAriaLabelOrLabelledBy<T = string | undefined> = T extends string ? {
57
+ /**
58
+ * The id of the element to use as title of the dialog. Can be within or out of the dialog.
59
+ * Although it is not recommended, aria-label can be used instead if no visible element is available.
60
+ */
61
+ 'aria-labelledby': T;
62
+ /** The label of the dialog. */
63
+ 'aria-label'?: undefined;
64
+ } : {
65
+ 'aria-label': string;
66
+ 'aria-labelledby'?: undefined;
67
+ };
51
68
 
52
69
  /**
53
70
  * Alignments.
@@ -82,7 +99,6 @@ declare const ColorPalette: {
82
99
  readonly grey: "grey";
83
100
  };
84
101
  declare type ColorPalette = ValueOf<typeof ColorPalette>;
85
- declare type Color = ColorPalette | string;
86
102
  /**
87
103
  * See SCSS variable $lumx-color-variants
88
104
  */
@@ -268,4 +284,4 @@ declare const ThumbnailVariant: {
268
284
  };
269
285
  declare type ThumbnailVariant = ValueOf<typeof ThumbnailVariant>;
270
286
 
271
- export { Alignment as A, Comp as C, Emphasis as E, Falsy as F, GenericProps as G, HasTheme as H, Kind as K, Orientation as O, Size as S, Typography as T, ValueOf as V, HorizontalAlignment as a, Color as b, Callback as c, ColorPalette as d, VerticalAlignment as e, ColorVariant as f, TextElement as g, HeadingElement as h, AspectRatio as i, FocusPoint as j, ThumbnailSize as k, ThumbnailVariant as l, GlobalSize as m, TypographyInterface as n, Theme as o, TypographyTitleCustom as p, TypographyCustom as q, ThumbnailAspectRatio as r };
287
+ export { Alignment as A, Comp as C, Emphasis as E, Falsy as F, GenericProps as G, HasTheme as H, Kind as K, Orientation as O, Size as S, Typography as T, ValueOf as V, HorizontalAlignment as a, ColorPalette as b, Callback as c, VerticalAlignment as d, ColorVariant as e, TextElement as f, HeadingElement as g, AspectRatio as h, FocusPoint as i, ThumbnailSize as j, ThumbnailVariant as k, HasAriaLabelOrLabelledBy as l, GlobalSize as m, TypographyInterface as n, Theme as o, TypographyTitleCustom as p, TypographyCustom as q, ThumbnailAspectRatio as r };
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import React, { ReactNode, SyntheticEvent, ReactElement, MouseEventHandler, KeyboardEventHandler, AriaAttributes, DetailedHTMLProps, ButtonHTMLAttributes, InputHTMLAttributes, Ref, RefObject, ImgHTMLAttributes, CSSProperties, SetStateAction, Key } from 'react';
2
- import { K as Kind, C as Comp, G as GenericProps, H as HasTheme, a as HorizontalAlignment, S as Size, b as Color, E as Emphasis, V as ValueOf, c as Callback, d as ColorPalette, A as Alignment, e as VerticalAlignment, O as Orientation, f as ColorVariant, T as Typography, g as TextElement, h as HeadingElement, i as AspectRatio, F as Falsy, j as FocusPoint, k as ThumbnailSize, l as ThumbnailVariant, m as GlobalSize, n as TypographyInterface } from './_internal/types.js';
3
- export { A as Alignment, i as AspectRatio, c as Callback, b as Color, d as ColorPalette, f as ColorVariant, E as Emphasis, j as FocusPoint, G as GenericProps, m as GlobalSize, h as HeadingElement, a as HorizontalAlignment, K as Kind, O as Orientation, S as Size, g as TextElement, o as Theme, r as ThumbnailAspectRatio, k as ThumbnailSize, l as ThumbnailVariant, T as Typography, q as TypographyCustom, n as TypographyInterface, p as TypographyTitleCustom, e as VerticalAlignment } from './_internal/types.js';
2
+ import { K as Kind, C as Comp, G as GenericProps, H as HasTheme, a as HorizontalAlignment, S as Size, b as ColorPalette, E as Emphasis, V as ValueOf, c as Callback, A as Alignment, d as VerticalAlignment, O as Orientation, e as ColorVariant, T as Typography, f as TextElement, g as HeadingElement, h as AspectRatio, F as Falsy, i as FocusPoint, j as ThumbnailSize, k as ThumbnailVariant, l as HasAriaLabelOrLabelledBy, m as GlobalSize, n as TypographyInterface } from './_internal/types.js';
3
+ export { A as Alignment, h as AspectRatio, c as Callback, b as ColorPalette, e as ColorVariant, E as Emphasis, i as FocusPoint, G as GenericProps, m as GlobalSize, g as HeadingElement, a as HorizontalAlignment, K as Kind, O as Orientation, S as Size, f as TextElement, o as Theme, r as ThumbnailAspectRatio, j as ThumbnailSize, k as ThumbnailVariant, T as Typography, q as TypographyCustom, n as TypographyInterface, p as TypographyTitleCustom, d as VerticalAlignment } from './_internal/types.js';
4
4
 
5
5
  interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
6
6
  /** Message variant. */
@@ -63,10 +63,13 @@ interface AutocompleteProps extends GenericProps, HasTheme {
63
63
  */
64
64
  placement?: Placement;
65
65
  /**
66
- * Whether the dropdown should fit to the anchor width or not.
66
+ * Manage dropdown width:
67
+ * - `maxWidth`: dropdown not bigger than anchor
68
+ * - `minWidth` or `true`: dropdown not smaller than anchor
69
+ * - `width`: dropdown equal to the anchor.
67
70
  * @see {@link DropdownProps#fitToAnchorWidth}
68
71
  */
69
- fitToAnchorWidth?: boolean;
72
+ fitToAnchorWidth?: DropdownProps['fitToAnchorWidth'];
70
73
  /**
71
74
  * The error related to the component.
72
75
  * @see {@link TextFieldProps#error}
@@ -182,7 +185,7 @@ interface AutocompleteProps extends GenericProps, HasTheme {
182
185
  * Only the props not managed by the Autocomplete can be set.
183
186
  * @see {@link TextFieldProps}
184
187
  */
185
- textFieldProps?: TextFieldProps;
188
+ textFieldProps?: Partial<TextFieldProps>;
186
189
  }
187
190
  /**
188
191
  * Autocomplete component.
@@ -258,7 +261,7 @@ interface BadgeProps extends GenericProps {
258
261
  /** Badge content. */
259
262
  children?: ReactNode;
260
263
  /** Color variant. */
261
- color?: Color;
264
+ color?: ColorPalette;
262
265
  }
263
266
  /**
264
267
  * Badge component.
@@ -276,7 +279,7 @@ declare type HTMLButtonProps = DetailedHTMLProps<ButtonHTMLAttributes<HTMLButton
276
279
  declare type ButtonSize = Extract<Size, 's' | 'm'>;
277
280
  interface BaseButtonProps extends GenericProps, Pick<AriaAttributes, 'aria-expanded' | 'aria-haspopup' | 'aria-pressed' | 'aria-label'>, HasTheme {
278
281
  /** Color variant. */
279
- color?: Color;
282
+ color?: ColorPalette;
280
283
  /** Emphasis variant. */
281
284
  emphasis?: Emphasis;
282
285
  /** Whether or not the button has a background color in low emphasis. */
@@ -423,7 +426,7 @@ interface ChipProps extends GenericProps, HasTheme {
423
426
  /** A component to be rendered before the content. */
424
427
  before?: ReactNode;
425
428
  /** Color variant. */
426
- color?: Color;
429
+ color?: ColorPalette;
427
430
  /** Whether the component is clickable or not. */
428
431
  isClickable?: boolean;
429
432
  /** Whether the component is disabled or not. */
@@ -717,6 +720,12 @@ interface Offset {
717
720
  * Popover elevation index.
718
721
  */
719
722
  declare type Elevation = 1 | 2 | 3 | 4 | 5;
723
+ declare const AnchorWidthOptions: {
724
+ readonly MAX_WIDTH: "maxWidth";
725
+ readonly MIN_WIDTH: "minWidth";
726
+ readonly WIDTH: "width";
727
+ };
728
+ declare type AnchorWidthOption = ValueOf<typeof AnchorWidthOptions>;
720
729
  /**
721
730
  * Defines the props of the component.
722
731
  */
@@ -733,8 +742,13 @@ interface PopoverProps extends GenericProps {
733
742
  closeOnEscape?: boolean;
734
743
  /** Shadow elevation. */
735
744
  elevation?: Elevation;
736
- /** Whether the dropdown should fit to the anchor width (if dropdown is smaller). */
737
- fitToAnchorWidth?: boolean;
745
+ /**
746
+ * Manage popover width:
747
+ * - `maxWidth`: popover not bigger than anchor
748
+ * - `minWidth` or `true`: popover not smaller than anchor
749
+ * - `width`: popover equal to the anchor.
750
+ */
751
+ fitToAnchorWidth?: AnchorWidthOption | boolean;
738
752
  /** Shrink popover if even after flipping there is not enough space. */
739
753
  fitWithinViewportHeight?: boolean;
740
754
  /** Element to focus when opening the popover. */
@@ -757,6 +771,8 @@ interface PopoverProps extends GenericProps {
757
771
  zIndex?: number;
758
772
  /** On close callback (on click away or Escape pressed). */
759
773
  onClose?(): void;
774
+ /** Whether the popover should trap the focus within itself. Default to false. */
775
+ withFocusTrap?: boolean;
760
776
  }
761
777
  /**
762
778
  * Popover component.
@@ -793,10 +809,13 @@ interface DropdownProps extends GenericProps {
793
809
  */
794
810
  closeOnEscape?: boolean;
795
811
  /**
796
- * Whether the dropdown should fit to the anchor width (if dropdown is smaller) or not.
812
+ * Manage dropdown width:
813
+ * - `maxWidth`: dropdown not bigger than anchor
814
+ * - `minWidth` or `true`: dropdown not smaller than anchor
815
+ * - `width`: dropdown equal to the anchor.
797
816
  * @see {@link PopoverProps#fitToAnchorWidth}
798
817
  */
799
- fitToAnchorWidth?: boolean;
818
+ fitToAnchorWidth?: PopoverProps['fitToAnchorWidth'];
800
819
  /**
801
820
  * Whether the dropdown should shrink to fit within the viewport height or not.
802
821
  * @see {@link PopoverProps#fitWithinViewportHeight}
@@ -1159,7 +1178,7 @@ declare type IconSizes = Extract<Size, 'xxs' | 'xs' | 's' | 'm' | 'l' | 'xl' | '
1159
1178
  */
1160
1179
  interface IconProps extends GenericProps, HasTheme {
1161
1180
  /** Color variant. */
1162
- color?: Color;
1181
+ color?: ColorPalette;
1163
1182
  /** Lightened or darkened variant of the selected icon color. */
1164
1183
  colorVariant?: ColorVariant;
1165
1184
  /** Whether the icon has a shape. */
@@ -1384,7 +1403,7 @@ declare type HTMLAnchorProps = React.DetailedHTMLProps<React.AnchorHTMLAttribute
1384
1403
  */
1385
1404
  interface LinkProps extends GenericProps {
1386
1405
  /** Color variant. */
1387
- color?: Color;
1406
+ color?: ColorPalette;
1388
1407
  /** Lightened or darkened variant of the selected icon color. */
1389
1408
  colorVariant?: ColorVariant;
1390
1409
  /** Link href. */
@@ -1623,6 +1642,20 @@ interface NotificationProps extends GenericProps, HasTheme {
1623
1642
  */
1624
1643
  declare const Notification: Comp<NotificationProps, HTMLDivElement>;
1625
1644
 
1645
+ /**
1646
+ * PopoverDialog props.
1647
+ * The PopoverDialog has the same props as the Popover but requires an accessible label.
1648
+ */
1649
+ declare type PopoverDialogProps = PopoverProps & HasAriaLabelOrLabelledBy;
1650
+ /**
1651
+ * PopoverDialog component.
1652
+ * Defines a popover that acts like a dialog
1653
+ * * Has a dialog aria role
1654
+ * * Sets a focus trap within the popover
1655
+ * * Closes on click away and escape.
1656
+ */
1657
+ declare const PopoverDialog: Comp<PopoverDialogProps, HTMLDivElement>;
1658
+
1626
1659
  /**
1627
1660
  * Defines the props of the component.
1628
1661
  */
@@ -2693,4 +2726,4 @@ interface UserBlockProps extends GenericProps, HasTheme {
2693
2726
  */
2694
2727
  declare const UserBlock: Comp<UserBlockProps, HTMLDivElement>;
2695
2728
 
2696
- export { AlertDialog, AlertDialogProps, Autocomplete, AutocompleteMultiple, AutocompleteMultipleProps, AutocompleteProps, Avatar, AvatarProps, AvatarSize, Badge, BadgeProps, BaseButtonProps, Button, ButtonEmphasis, ButtonGroup, ButtonGroupProps, ButtonProps, ButtonSize, Checkbox, CheckboxProps, Chip, ChipGroup, ChipGroupProps, ChipProps, CommentBlock, CommentBlockProps, CommentBlockVariant, DatePicker, DatePickerControlled, DatePickerControlledProps, DatePickerField, DatePickerFieldProps, DatePickerProps, Dialog, DialogProps, DialogSizes, Divider, DividerProps, DragHandle, DragHandleProps, Dropdown, DropdownProps, Elevation, ExpansionPanel, ExpansionPanelProps, Flag, FlagProps, FlexBox, FlexBoxProps, FlexHorizontalAlignment, FlexVerticalAlignment, GapSize, GenericBlock, GenericBlockGapSize, GenericBlockProps, Grid, GridItem, GridItemProps, GridProps, Heading, HeadingLevelProvider, HeadingLevelProviderProps, HeadingProps, Icon, IconButton, IconButtonProps, IconProps, IconSizes, ImageBlock, ImageBlockCaptionPosition, ImageBlockProps, ImageBlockSize, InlineList, InlineListProps, InputHelper, InputHelperProps, InputLabel, InputLabelProps, Lightbox, LightboxProps, Link, LinkPreview, LinkPreviewProps, LinkProps, List, ListDivider, ListDividerProps, ListItem, ListItemProps, ListItemSize, ListProps, ListSubheader, ListSubheaderProps, MarginAutoAlignment, Message, MessageProps, Mosaic, MosaicProps, Notification, NotificationProps, Offset, Placement, Popover, PopoverProps, PostBlock, PostBlockProps, Progress, ProgressProps, ProgressTracker, ProgressTrackerProps, ProgressTrackerProvider, ProgressTrackerProviderProps, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressTrackerStepPanelProps, ProgressTrackerStepProps, ProgressVariant, RadioButton, RadioButtonProps, RadioGroup, RadioGroupProps, Select, SelectMultiple, SelectMultipleField, SelectMultipleProps, SelectProps, SelectVariant, SideNavigation, SideNavigationItem, SideNavigationItemProps, SideNavigationProps, SkeletonCircle, SkeletonCircleProps, SkeletonRectangle, SkeletonRectangleProps, SkeletonRectangleVariant, SkeletonTypography, SkeletonTypographyProps, Slider, SliderProps, Slides, SlidesProps, Slideshow, SlideshowControls, SlideshowControlsProps, SlideshowItem, SlideshowItemProps, SlideshowProps, Switch, SwitchProps, Tab, TabList, TabListLayout, TabListProps, TabPanel, TabPanelProps, TabProps, TabProvider, TabProviderProps, Table, TableBody, TableBodyProps, TableCell, TableCellProps, TableCellVariant, TableHeader, TableHeaderProps, TableProps, TableRow, TableRowProps, Text, TextField, TextFieldProps, TextProps, ThOrder, Thumbnail, ThumbnailProps, Toolbar, ToolbarProps, Tooltip, TooltipPlacement, TooltipProps, Uploader, UploaderProps, UploaderSize, UploaderVariant, UserBlock, UserBlockProps, UserBlockSize, clamp, isClickable, useFocusPointStyle, useHeadingLevel };
2729
+ export { AlertDialog, AlertDialogProps, Autocomplete, AutocompleteMultiple, AutocompleteMultipleProps, AutocompleteProps, Avatar, AvatarProps, AvatarSize, Badge, BadgeProps, BaseButtonProps, Button, ButtonEmphasis, ButtonGroup, ButtonGroupProps, ButtonProps, ButtonSize, Checkbox, CheckboxProps, Chip, ChipGroup, ChipGroupProps, ChipProps, CommentBlock, CommentBlockProps, CommentBlockVariant, DatePicker, DatePickerControlled, DatePickerControlledProps, DatePickerField, DatePickerFieldProps, DatePickerProps, Dialog, DialogProps, DialogSizes, Divider, DividerProps, DragHandle, DragHandleProps, Dropdown, DropdownProps, Elevation, ExpansionPanel, ExpansionPanelProps, Flag, FlagProps, FlexBox, FlexBoxProps, FlexHorizontalAlignment, FlexVerticalAlignment, GapSize, GenericBlock, GenericBlockGapSize, GenericBlockProps, Grid, GridItem, GridItemProps, GridProps, Heading, HeadingLevelProvider, HeadingLevelProviderProps, HeadingProps, Icon, IconButton, IconButtonProps, IconProps, IconSizes, ImageBlock, ImageBlockCaptionPosition, ImageBlockProps, ImageBlockSize, InlineList, InlineListProps, InputHelper, InputHelperProps, InputLabel, InputLabelProps, Lightbox, LightboxProps, Link, LinkPreview, LinkPreviewProps, LinkProps, List, ListDivider, ListDividerProps, ListItem, ListItemProps, ListItemSize, ListProps, ListSubheader, ListSubheaderProps, MarginAutoAlignment, Message, MessageProps, Mosaic, MosaicProps, Notification, NotificationProps, Offset, Placement, Popover, PopoverDialog, PopoverDialogProps, PopoverProps, PostBlock, PostBlockProps, Progress, ProgressProps, ProgressTracker, ProgressTrackerProps, ProgressTrackerProvider, ProgressTrackerProviderProps, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressTrackerStepPanelProps, ProgressTrackerStepProps, ProgressVariant, RadioButton, RadioButtonProps, RadioGroup, RadioGroupProps, Select, SelectMultiple, SelectMultipleField, SelectMultipleProps, SelectProps, SelectVariant, SideNavigation, SideNavigationItem, SideNavigationItemProps, SideNavigationProps, SkeletonCircle, SkeletonCircleProps, SkeletonRectangle, SkeletonRectangleProps, SkeletonRectangleVariant, SkeletonTypography, SkeletonTypographyProps, Slider, SliderProps, Slides, SlidesProps, Slideshow, SlideshowControls, SlideshowControlsProps, SlideshowItem, SlideshowItemProps, SlideshowProps, Switch, SwitchProps, Tab, TabList, TabListLayout, TabListProps, TabPanel, TabPanelProps, TabProps, TabProvider, TabProviderProps, Table, TableBody, TableBodyProps, TableCell, TableCellProps, TableCellVariant, TableHeader, TableHeaderProps, TableProps, TableRow, TableRowProps, Text, TextField, TextFieldProps, TextProps, ThOrder, Thumbnail, ThumbnailProps, Toolbar, ToolbarProps, Tooltip, TooltipPlacement, TooltipProps, Uploader, UploaderProps, UploaderSize, UploaderVariant, UserBlock, UserBlockProps, UserBlockSize, clamp, isClickable, useFocusPointStyle, useHeadingLevel };