@lumx/react 3.7.0 → 3.7.1-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.
@@ -309,5 +309,13 @@ declare const ThumbnailVariant: {
309
309
  readonly rounded: "rounded";
310
310
  };
311
311
  type ThumbnailVariant = ValueOf<typeof ThumbnailVariant>;
312
+ /**
313
+ * Thumbnail object fit.
314
+ */
315
+ declare const ThumbnailObjectFit: {
316
+ readonly cover: "cover";
317
+ readonly contain: "contain";
318
+ };
319
+ type ThumbnailObjectFit = ValueOf<typeof ThumbnailObjectFit>;
312
320
 
313
- 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, WhiteSpace as W, HorizontalAlignment as a, ColorPalette as b, VerticalAlignment as c, ColorVariant as d, TextElement as e, HeadingElement as f, AspectRatio as g, FocusPoint as h, ThumbnailSize as i, ThumbnailVariant as j, HasClassName as k, HasAriaLabelOrLabelledBy as l, ComponentRef as m, GlobalSize as n, TypographyInterface as o, Color as p, Theme as q, TypographyTitleCustom as r, TypographyCustom as s, Callback as t, ThumbnailAspectRatio as u };
321
+ 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, WhiteSpace as W, HorizontalAlignment as a, ColorPalette as b, VerticalAlignment as c, ColorVariant as d, TextElement as e, HeadingElement as f, AspectRatio as g, FocusPoint as h, ThumbnailObjectFit as i, ThumbnailSize as j, ThumbnailVariant as k, HasClassName as l, HasAriaLabelOrLabelledBy as m, ComponentRef as n, GlobalSize as o, TypographyInterface as p, Color as q, Theme as r, TypographyTitleCustom as s, TypographyCustom as t, Callback as u, ThumbnailAspectRatio as v };
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 ColorPalette, E as Emphasis, V as ValueOf, A as Alignment, c as VerticalAlignment, O as Orientation, d as ColorVariant, T as Typography, e as TextElement, W as WhiteSpace, f as HeadingElement, g as AspectRatio, F as Falsy, h as FocusPoint, i as ThumbnailSize, j as ThumbnailVariant, k as HasClassName, l as HasAriaLabelOrLabelledBy, m as ComponentRef, n as GlobalSize, o as TypographyInterface } from './_internal/types.js';
3
- export { A as Alignment, g as AspectRatio, t as Callback, p as Color, b as ColorPalette, d as ColorVariant, E as Emphasis, h as FocusPoint, G as GenericProps, n as GlobalSize, f as HeadingElement, a as HorizontalAlignment, K as Kind, O as Orientation, S as Size, e as TextElement, q as Theme, u as ThumbnailAspectRatio, i as ThumbnailSize, j as ThumbnailVariant, T as Typography, s as TypographyCustom, o as TypographyInterface, r as TypographyTitleCustom, c as VerticalAlignment, W as WhiteSpace } 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, A as Alignment, c as VerticalAlignment, O as Orientation, d as ColorVariant, T as Typography, e as TextElement, W as WhiteSpace, f as HeadingElement, g as AspectRatio, F as Falsy, h as FocusPoint, i as ThumbnailObjectFit, j as ThumbnailSize, k as ThumbnailVariant, l as HasClassName, m as HasAriaLabelOrLabelledBy, n as ComponentRef, o as GlobalSize, p as TypographyInterface } from './_internal/types.js';
3
+ export { A as Alignment, g as AspectRatio, u as Callback, q as Color, b as ColorPalette, d as ColorVariant, E as Emphasis, h as FocusPoint, G as GenericProps, o as GlobalSize, f as HeadingElement, a as HorizontalAlignment, K as Kind, O as Orientation, S as Size, e as TextElement, r as Theme, v as ThumbnailAspectRatio, i as ThumbnailObjectFit, j as ThumbnailSize, k as ThumbnailVariant, T as Typography, t as TypographyCustom, p as TypographyInterface, s as TypographyTitleCustom, c as VerticalAlignment, W as WhiteSpace } from './_internal/types.js';
4
4
 
5
5
  interface AlertDialogProps extends Omit<DialogProps, 'header' | 'footer'> {
6
6
  /** Message variant. */
@@ -929,7 +929,9 @@ interface FlagProps extends GenericProps, HasTheme {
929
929
  /** Icon to use before the label. */
930
930
  icon?: string;
931
931
  /** Text label of the flag. */
932
- label: string;
932
+ label: React.ReactNode;
933
+ /** Enable text truncate on overflow */
934
+ truncate?: boolean;
933
935
  }
934
936
  /**
935
937
  * Flag component.
@@ -1293,6 +1295,8 @@ interface ThumbnailProps extends GenericProps, HasTheme {
1293
1295
  imgRef?: Ref<HTMLImageElement>;
1294
1296
  /** Set to true to force the display of the loading skeleton. */
1295
1297
  isLoading?: boolean;
1298
+ /** Set how the image should fit when its aspect ratio is constrained */
1299
+ objectFit?: ThumbnailObjectFit;
1296
1300
  /** Size variant of the component. */
1297
1301
  size?: ThumbnailSize;
1298
1302
  /** Image loading mode. */
@@ -1385,6 +1389,10 @@ interface InlineListProps extends GenericProps {
1385
1389
  * Typography variant.
1386
1390
  */
1387
1391
  typography?: Typography;
1392
+ /**
1393
+ * Activate line wrap on overflow.
1394
+ */
1395
+ wrap?: boolean;
1388
1396
  }
1389
1397
  /**
1390
1398
  * InlineList component.
@@ -1732,7 +1740,7 @@ declare const Navigation: React.ForwardRefExoticComponent<(Omit<React.ClassAttri
1732
1740
  as?: E | undefined;
1733
1741
  } & HasTheme & HasClassName & {
1734
1742
  icon?: string | undefined;
1735
- label: React.ReactNode; /** Content of the navigation. These components should be of type NavigationItem to be rendered */
1743
+ label: React.ReactNode;
1736
1744
  isCurrentPage?: boolean | undefined;
1737
1745
  } & (E extends "a" ? {
1738
1746
  href: string;
package/index.js CHANGED
@@ -6938,7 +6938,7 @@ ExpansionPanel.displayName = COMPONENT_NAME$n;
6938
6938
  ExpansionPanel.className = CLASSNAME$k;
6939
6939
  ExpansionPanel.defaultProps = DEFAULT_PROPS$i;
6940
6940
 
6941
- const _excluded$p = ["label", "icon", "color", "className", "theme"];
6941
+ const _excluded$p = ["label", "icon", "color", "className", "theme", "truncate"];
6942
6942
  const COMPONENT_NAME$o = 'Flag';
6943
6943
  const CLASSNAME$l = getRootClassName(COMPONENT_NAME$o);
6944
6944
  const DEFAULT_PROPS$j = {
@@ -6958,21 +6958,27 @@ const Flag = /*#__PURE__*/forwardRef((props, ref) => {
6958
6958
  icon,
6959
6959
  color,
6960
6960
  className,
6961
- theme
6961
+ theme,
6962
+ truncate
6962
6963
  } = props,
6963
6964
  forwardedProps = _objectWithoutProperties(props, _excluded$p);
6964
6965
  const flagColor = color || (theme === Theme.light ? ColorPalette.dark : ColorPalette.light);
6966
+ const isTruncated = !!truncate;
6965
6967
  return /*#__PURE__*/React.createElement("div", _extends({}, forwardedProps, {
6966
6968
  className: classnames(className, handleBasicClasses({
6967
6969
  prefix: CLASSNAME$l,
6968
- color: flagColor
6970
+ color: flagColor,
6971
+ isTruncated
6969
6972
  })),
6970
6973
  ref: ref
6971
6974
  }), icon && /*#__PURE__*/React.createElement(Icon, {
6972
6975
  icon: icon,
6973
6976
  size: Size.xxs,
6974
6977
  className: `${CLASSNAME$l}__icon`
6975
- }), /*#__PURE__*/React.createElement("span", {
6978
+ }), /*#__PURE__*/React.createElement(Text, {
6979
+ as: "span",
6980
+ truncate: isTruncated,
6981
+ typography: "overline",
6976
6982
  className: `${CLASSNAME$l}__label`
6977
6983
  }, label));
6978
6984
  });
@@ -7137,6 +7143,50 @@ const GenericBlock = Object.assign(BaseGenericBlock, {
7137
7143
  */
7138
7144
  const GenericBlockGapSize = pick(Size, ['tiny', 'regular', 'medium', 'big', 'huge']);
7139
7145
 
7146
+ /** Empty object */
7147
+
7148
+ const DEFAULT_VALUE = {};
7149
+
7150
+ /**
7151
+ * Tooltip react context simply used as a marker to know when parent react node have a tooltip
7152
+ */
7153
+ const TooltipContext = /*#__PURE__*/React.createContext(undefined);
7154
+ const TooltipContextProvider = _ref => {
7155
+ let {
7156
+ children
7157
+ } = _ref;
7158
+ return /*#__PURE__*/React.createElement(TooltipContext.Provider, {
7159
+ value: DEFAULT_VALUE
7160
+ }, children);
7161
+ };
7162
+ const useTooltipContext = () => React.useContext(TooltipContext);
7163
+
7164
+ /**
7165
+ * Compute a tooltip label based on a label element `innerText` if the text overflows.
7166
+ *
7167
+ * Warning: only works on first render, does not update on label element resize.
7168
+ */
7169
+ const useOverflowTooltipLabel = () => {
7170
+ const parentTooltip = useTooltipContext();
7171
+ const [tooltipLabel, setTooltipLabel] = React.useState(undefined);
7172
+ const labelRef = React.useCallback(labelElement => {
7173
+ if (!labelElement || !!parentTooltip) {
7174
+ // Skip if label element is unknown
7175
+ // Skip if the parent has a tooltip
7176
+ return;
7177
+ }
7178
+
7179
+ // Label overflowing
7180
+ if (labelElement.offsetWidth < labelElement.scrollWidth) {
7181
+ setTooltipLabel(labelElement.innerText);
7182
+ }
7183
+ }, [parentTooltip]);
7184
+ return {
7185
+ labelRef,
7186
+ tooltipLabel
7187
+ };
7188
+ };
7189
+
7140
7190
  const _excluded$s = ["as", "children", "className", "color", "colorVariant", "noWrap", "typography", "truncate", "whiteSpace", "style"];
7141
7191
 
7142
7192
  /**
@@ -7197,13 +7247,18 @@ const Text = /*#__PURE__*/forwardRef((props, ref) => {
7197
7247
  const whiteSpaceStyle = !noWrap && !(isTruncated && !isTruncatedMultiline) && whiteSpace && {
7198
7248
  '--lumx-text-white-space': whiteSpace
7199
7249
  };
7250
+ const {
7251
+ tooltipLabel,
7252
+ labelRef
7253
+ } = useOverflowTooltipLabel();
7200
7254
  return /*#__PURE__*/React.createElement(Component, _extends({
7201
- ref: ref,
7255
+ ref: useMergeRefs(ref, labelRef),
7202
7256
  className: classnames(className, handleBasicClasses({
7203
7257
  prefix: CLASSNAME$o,
7204
7258
  isTruncated: isTruncated && !isTruncatedMultiline,
7205
7259
  isTruncatedMultiline
7206
7260
  }), typographyClass, colorClass, noWrap && `${CLASSNAME$o}--no-wrap`),
7261
+ title: tooltipLabel,
7207
7262
  style: _objectSpread2(_objectSpread2(_objectSpread2({}, truncateLinesStyle), whiteSpaceStyle), style)
7208
7263
  }, forwardedProps), children && Children.toArray(children).map((child, index) => {
7209
7264
  // Force wrap spaces around icons to make sure they are never stuck against text.
@@ -7686,7 +7741,7 @@ ImageBlock.displayName = COMPONENT_NAME$x;
7686
7741
  ImageBlock.className = CLASSNAME$u;
7687
7742
  ImageBlock.defaultProps = DEFAULT_PROPS$q;
7688
7743
 
7689
- const _excluded$z = ["className", "color", "colorVariant", "typography", "children"];
7744
+ const _excluded$z = ["className", "color", "colorVariant", "typography", "children", "wrap"];
7690
7745
 
7691
7746
  /**
7692
7747
  * Defines the props of the component.
@@ -7720,7 +7775,8 @@ const InlineList = /*#__PURE__*/forwardRef((props, ref) => {
7720
7775
  color,
7721
7776
  colorVariant,
7722
7777
  typography,
7723
- children
7778
+ children,
7779
+ wrap
7724
7780
  } = props,
7725
7781
  forwardedProps = _objectWithoutProperties(props, _excluded$z);
7726
7782
  const fontColorClassName = color && getFontColorClassName(color, colorVariant);
@@ -7730,7 +7786,7 @@ const InlineList = /*#__PURE__*/forwardRef((props, ref) => {
7730
7786
  // eslint-disable-next-line jsx-a11y/no-redundant-roles
7731
7787
  React.createElement("ul", _extends({}, forwardedProps, {
7732
7788
  ref: ref,
7733
- className: classnames(className, CLASSNAME$v, fontColorClassName, typographyClassName)
7789
+ className: classnames(className, CLASSNAME$v, wrap && `${CLASSNAME$v}--wrap`, fontColorClassName, typographyClassName)
7734
7790
  // Lists with removed bullet style can lose their a11y list role on some browsers
7735
7791
  ,
7736
7792
  role: "list"
@@ -8507,8 +8563,10 @@ const NavigationItem = Object.assign(forwardRefPolymorphic((props, ref) => {
8507
8563
  } = props,
8508
8564
  forwardedProps = _objectWithoutProperties(props, _excluded$J);
8509
8565
  const theme = useContext(ThemeContext);
8510
- const [labelElement, setLabelElement] = useState(null);
8511
- const tooltipLabel = typeof label === 'string' && labelElement && labelElement.offsetWidth < labelElement.scrollWidth ? label : null;
8566
+ const {
8567
+ tooltipLabel,
8568
+ labelRef
8569
+ } = useOverflowTooltipLabel();
8512
8570
  const buttonProps = Element === 'button' ? {
8513
8571
  type: 'button'
8514
8572
  } : {};
@@ -8536,7 +8594,7 @@ const NavigationItem = Object.assign(forwardRefPolymorphic((props, ref) => {
8536
8594
  as: "span",
8537
8595
  truncate: true,
8538
8596
  className: `${CLASSNAME$F}__label`,
8539
- ref: setLabelElement
8597
+ ref: labelRef
8540
8598
  }, label))));
8541
8599
  }), {
8542
8600
  displayName: COMPONENT_NAME$I,
@@ -12761,7 +12819,7 @@ const useFocusPointStyle = (_ref2, element, isLoaded) => {
12761
12819
  return style;
12762
12820
  };
12763
12821
 
12764
- const _excluded$1m = ["align", "alt", "aspectRatio", "badge", "className", "crossOrigin", "fallback", "fillHeight", "focusPoint", "image", "imgProps", "imgRef", "isLoading", "loading", "size", "theme", "variant", "linkProps", "linkAs"];
12822
+ const _excluded$1m = ["align", "alt", "aspectRatio", "badge", "className", "crossOrigin", "fallback", "fillHeight", "focusPoint", "image", "imgProps", "imgRef", "isLoading", "objectFit", "loading", "size", "theme", "variant", "linkProps", "linkAs"];
12765
12823
 
12766
12824
  /**
12767
12825
  * Defines the props of the component.
@@ -12810,6 +12868,7 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
12810
12868
  imgProps,
12811
12869
  imgRef: propImgRef,
12812
12870
  isLoading: isLoadingProp,
12871
+ objectFit,
12813
12872
  loading,
12814
12873
  size,
12815
12874
  theme,
@@ -12865,6 +12924,7 @@ const Thumbnail = /*#__PURE__*/forwardRef((props, ref) => {
12865
12924
  hasIconErrorFallback,
12866
12925
  hasCustomErrorFallback,
12867
12926
  isLoading,
12927
+ objectFit,
12868
12928
  hasBadge: !!badge
12869
12929
  }), fillHeight && `${CLASSNAME$1e}--fill-height`)
12870
12930
  }), /*#__PURE__*/React.createElement("span", {
@@ -12922,6 +12982,13 @@ const ThumbnailVariant = {
12922
12982
  squared: 'squared',
12923
12983
  rounded: 'rounded'
12924
12984
  };
12985
+ /**
12986
+ * Thumbnail object fit.
12987
+ */
12988
+ const ThumbnailObjectFit = {
12989
+ cover: 'cover',
12990
+ contain: 'contain'
12991
+ };
12925
12992
 
12926
12993
  const _excluded$1n = ["after", "before", "className", "label"];
12927
12994
 
@@ -13229,7 +13296,7 @@ const Tooltip = /*#__PURE__*/forwardRef((props, ref) => {
13229
13296
  } = useTooltipOpen(delay, anchorElement);
13230
13297
  const isOpen = isActivated || forceOpen;
13231
13298
  const wrappedChildren = useInjectTooltipRef(children, setAnchorElement, isOpen, id, label);
13232
- return /*#__PURE__*/React.createElement(React.Fragment, null, wrappedChildren, isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
13299
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(TooltipContextProvider, null, wrappedChildren), isOpen && /*#__PURE__*/createPortal( /*#__PURE__*/React.createElement("div", _extends({
13233
13300
  ref: mergeRefs(ref, setPopperElement, onPopperMount)
13234
13301
  }, forwardedProps, {
13235
13302
  id: id,
@@ -13498,5 +13565,5 @@ UserBlock.displayName = COMPONENT_NAME$1l;
13498
13565
  UserBlock.className = CLASSNAME$1i;
13499
13566
  UserBlock.defaultProps = DEFAULT_PROPS$13;
13500
13567
 
13501
- export { AlertDialog, Alignment, AspectRatio, Autocomplete, AutocompleteMultiple, Avatar, Badge, Button, ButtonEmphasis, ButtonGroup, Checkbox, Chip, ChipGroup, ColorPalette, ColorVariant, CommentBlock, CommentBlockVariant, DatePicker, DatePickerControlled, DatePickerField, Dialog, Divider, DragHandle, Dropdown, Emphasis, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, InlineList, InputHelper, InputLabel, Kind, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSubheader, Message, Mosaic, Navigation, Notification, Orientation, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, Select, SelectMultiple, SelectMultipleField, SelectVariant, SideNavigation, SideNavigationItem, Size, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, Theme, Thumbnail, ThumbnailAspectRatio, ThumbnailVariant, Toolbar, Tooltip, Typography, TypographyCustom, TypographyInterface, TypographyTitleCustom, Uploader, UploaderVariant, UserBlock, WhiteSpace, clamp, isClickable, useFocusPointStyle, useHeadingLevel };
13568
+ export { AlertDialog, Alignment, AspectRatio, Autocomplete, AutocompleteMultiple, Avatar, Badge, Button, ButtonEmphasis, ButtonGroup, Checkbox, Chip, ChipGroup, ColorPalette, ColorVariant, CommentBlock, CommentBlockVariant, DatePicker, DatePickerControlled, DatePickerField, Dialog, Divider, DragHandle, Dropdown, Emphasis, ExpansionPanel, Flag, FlexBox, GenericBlock, GenericBlockGapSize, Grid, GridColumn, GridItem, Heading, HeadingLevelProvider, Icon, IconButton, ImageBlock, ImageBlockCaptionPosition, InlineList, InputHelper, InputLabel, Kind, Lightbox, Link, LinkPreview, List, ListDivider, ListItem, ListSubheader, Message, Mosaic, Navigation, Notification, Orientation, Placement, Popover, PopoverDialog, PostBlock, Progress, ProgressCircular, ProgressLinear, ProgressTracker, ProgressTrackerProvider, ProgressTrackerStep, ProgressTrackerStepPanel, ProgressVariant, RadioButton, RadioGroup, Select, SelectMultiple, SelectMultipleField, SelectVariant, SideNavigation, SideNavigationItem, Size, SkeletonCircle, SkeletonRectangle, SkeletonRectangleVariant, SkeletonTypography, Slider, Slides, Slideshow, SlideshowControls, SlideshowItem, Switch, Tab, TabList, TabListLayout, TabPanel, TabProvider, Table, TableBody, TableCell, TableCellVariant, TableHeader, TableRow, Text, TextField, ThOrder, Theme, Thumbnail, ThumbnailAspectRatio, ThumbnailObjectFit, ThumbnailVariant, Toolbar, Tooltip, Typography, TypographyCustom, TypographyInterface, TypographyTitleCustom, Uploader, UploaderVariant, UserBlock, WhiteSpace, clamp, isClickable, useFocusPointStyle, useHeadingLevel };
13502
13569
  //# sourceMappingURL=index.js.map