@lumx/react 4.9.0-next.10 → 4.9.0-next.12

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/index.d.ts CHANGED
@@ -2458,7 +2458,7 @@ declare const Dropdown: Comp<DropdownProps, HTMLDivElement>;
2458
2458
  /**
2459
2459
  * Defines the props of the component.
2460
2460
  */
2461
- interface ExpansionPanelProps extends GenericProps$1, HasCloseMode$1, HasTheme$1 {
2461
+ interface ExpansionPanelProps$1 extends HasClassName, HasCloseMode, HasTheme {
2462
2462
  /** Whether the expansion panel has a background. */
2463
2463
  hasBackground?: boolean;
2464
2464
  /** Whether the header has a divider. */
@@ -2467,6 +2467,41 @@ interface ExpansionPanelProps extends GenericProps$1, HasCloseMode$1, HasTheme$1
2467
2467
  isOpen?: boolean;
2468
2468
  /** Label text (overwritten if a `<header>` is provided in the children). */
2469
2469
  label?: string;
2470
+ /** On open callback. */
2471
+ handleOpen?: (event: any) => void;
2472
+ /** On close callback. */
2473
+ handleClose?: (event: any) => void;
2474
+ /** Props to pass to the toggle button (minus those already set by the ExpansionPanel props). */
2475
+ toggleButtonProps: any;
2476
+ /** On toggle open or close callback. */
2477
+ handleToggleOpen?(shouldOpen: boolean, event: any): void;
2478
+ /** Children */
2479
+ children?: JSXElement;
2480
+ /** Ref forwarded to the root `<section>` element. */
2481
+ ref?: CommonRef;
2482
+ /** Ref forwarded to the collapsible wrapper `<div>`. */
2483
+ wrapperRef?: CommonRef;
2484
+ /** Props spread onto the header content `<div>` (e.g. `aria-*`, `data-*`). */
2485
+ headerProps: GenericProps;
2486
+ /** Content rendered inside the header content area. */
2487
+ headerContent?: JSXElement;
2488
+ /** Optional drag handle element rendered at the start of the header. */
2489
+ dragHandle?: JSXElement;
2490
+ /** Content rendered inside the collapsible content area. */
2491
+ content?: JSXElement;
2492
+ /** Optional footer element rendered below the content. */
2493
+ footer?: JSXElement;
2494
+ /** IconButton component injected by the framework wrapper (React or Vue). */
2495
+ IconButton: any;
2496
+ /** Whether the children should remain mounted (visible in the DOM) while the panel is closed. */
2497
+ isChildrenVisible?: boolean;
2498
+ }
2499
+ type ExpansionPanelPropsToOverride = 'handleOpen' | 'handleClose' | 'toggleButtonProps' | 'handleToggleOpen' | 'wrapperRef' | 'headerProps' | 'headerContent' | 'dragHandle' | 'content' | 'IconButton' | 'isChildrenVisible' | 'footer';
2500
+
2501
+ /**
2502
+ * Defines the props of the component.
2503
+ */
2504
+ interface ExpansionPanelProps extends GenericProps$1, ReactToJSX<ExpansionPanelProps$1, ExpansionPanelPropsToOverride> {
2470
2505
  /** On open callback. */
2471
2506
  onOpen?: (event: React__default.MouseEvent) => void;
2472
2507
  /** On close callback. */
@@ -2475,8 +2510,6 @@ interface ExpansionPanelProps extends GenericProps$1, HasCloseMode$1, HasTheme$1
2475
2510
  toggleButtonProps: Pick<IconButtonProps, 'label'> & Omit<IconButtonProps, 'label' | 'onClick' | 'icon' | 'emphasis' | 'color'>;
2476
2511
  /** On toggle open or close callback. */
2477
2512
  onToggleOpen?(shouldOpen: boolean, event: React__default.MouseEvent): void;
2478
- /** Children */
2479
- children?: React__default.ReactNode;
2480
2513
  }
2481
2514
  /**
2482
2515
  * ExpansionPanel component.
@@ -2997,20 +3030,32 @@ interface ThumbnailProps extends GenericProps$1, ReactToJSX<ThumbnailProps$1, 'l
2997
3030
  */
2998
3031
  declare const Thumbnail: Comp<ThumbnailProps, HTMLElement>;
2999
3032
 
3000
- type ForwardedTextProps = Omit<TextProps, 'as' | 'typography' | 'color' | 'colorVariant'>;
3001
- type ImageCaptionMetadata = {
3033
+ type ImageCaptionMetadata$1 = {
3002
3034
  /** Image title to display in the caption. */
3003
3035
  title?: string;
3004
3036
  /** Props to pass to the title. */
3005
- titleProps?: ForwardedTextProps;
3006
- /** Image description. Can be either a string, or sanitized html. */
3007
- description?: string | {
3037
+ titleProps?: GenericProps;
3038
+ /** Image description. Can be either a string, ReactNode, or sanitized html object. */
3039
+ description?: JSXElement | {
3008
3040
  __html: string;
3009
3041
  };
3010
3042
  /** Props to pass to the title. */
3011
- descriptionProps?: ForwardedTextProps;
3043
+ descriptionProps?: GenericProps;
3012
3044
  /** Tag content. */
3013
- tags?: ReactNode;
3045
+ tags?: JSXElement;
3046
+ /** Caption custom CSS style. */
3047
+ captionStyle?: GenericProps;
3048
+ FlexBox: any;
3049
+ Text: any;
3050
+ };
3051
+ type ImageCaptionPropsToOverride = 'FlexBox' | 'Text' | 'titleProps' | 'descriptionProps' | 'captionStyle';
3052
+
3053
+ type ForwardedTextProps = Omit<TextProps, 'as' | 'typography' | 'color' | 'colorVariant'>;
3054
+ type ImageCaptionMetadata = Omit<ImageCaptionMetadata$1, ImageCaptionPropsToOverride> & {
3055
+ /** Props to pass to the title. */
3056
+ titleProps?: ForwardedTextProps;
3057
+ /** Props to pass to the title. */
3058
+ descriptionProps?: ForwardedTextProps;
3014
3059
  /** Caption custom CSS style. */
3015
3060
  captionStyle?: CSSProperties;
3016
3061
  };
package/index.js CHANGED
@@ -11647,7 +11647,7 @@ const CLASSNAME$P = 'lumx-expansion-panel';
11647
11647
  const {
11648
11648
  block: block$G,
11649
11649
  element: element$x
11650
- } = classNames.bem(CLASSNAME$P);
11650
+ } = bem(CLASSNAME$P);
11651
11651
 
11652
11652
  /**
11653
11653
  * Component default props.
@@ -11655,9 +11655,6 @@ const {
11655
11655
  const DEFAULT_PROPS$L = {
11656
11656
  closeMode: 'unmount'
11657
11657
  };
11658
- const isDragHandle = isComponent(DragHandle);
11659
- const isHeader = isComponent('header');
11660
- const isFooter = isComponent('footer');
11661
11658
 
11662
11659
  /**
11663
11660
  * ExpansionPanel component.
@@ -11666,48 +11663,45 @@ const isFooter = isComponent('footer');
11666
11663
  * @param ref Component ref.
11667
11664
  * @return React element.
11668
11665
  */
11669
- const ExpansionPanel = forwardRef((props, ref) => {
11670
- const defaultTheme = useTheme() || Theme$1.light;
11666
+ const ExpansionPanel$1 = props => {
11671
11667
  const {
11672
11668
  className,
11673
- closeMode = DEFAULT_PROPS$L.closeMode,
11674
11669
  children: anyChildren,
11675
11670
  hasBackground,
11671
+ ref,
11676
11672
  hasHeaderDivider,
11677
11673
  isOpen,
11678
11674
  label,
11679
- onClose,
11680
- onOpen,
11681
- onToggleOpen,
11682
- theme = defaultTheme,
11675
+ handleClose,
11676
+ handleOpen,
11677
+ handleToggleOpen,
11678
+ theme,
11683
11679
  toggleButtonProps,
11680
+ headerProps,
11681
+ headerContent,
11682
+ dragHandle,
11683
+ wrapperRef,
11684
+ content,
11685
+ isChildrenVisible,
11686
+ IconButton,
11687
+ footer,
11688
+ closeMode,
11684
11689
  ...forwardedProps
11685
11690
  } = props;
11686
- const children = Children.toArray(anyChildren);
11687
-
11688
- // Partition children by types.
11689
- const [[dragHandle], [header], [footer], content] = partitionMulti(children, [isDragHandle, isHeader, isFooter]);
11690
-
11691
- // Either take the header in children or create one with the label.
11692
- const headerProps = /*#__PURE__*/React__default.isValidElement(header) ? header.props : {};
11693
- const headerContent = !isEmpty(headerProps.children) ? headerProps.children : /*#__PURE__*/jsx("span", {
11694
- className: element$x('label'),
11695
- children: label
11696
- });
11697
11691
  const toggleOpen = event => {
11698
11692
  const shouldOpen = !isOpen;
11699
- if (onOpen && shouldOpen) {
11700
- onOpen(event);
11693
+ if (handleOpen && shouldOpen) {
11694
+ handleOpen(event);
11701
11695
  }
11702
- if (onClose && !shouldOpen) {
11703
- onClose(event);
11696
+ if (handleClose && !shouldOpen) {
11697
+ handleClose(event);
11704
11698
  }
11705
- if (onToggleOpen) {
11706
- onToggleOpen(shouldOpen, event);
11699
+ if (handleToggleOpen) {
11700
+ handleToggleOpen(shouldOpen, event);
11707
11701
  }
11708
11702
  };
11709
- const color = theme === Theme$1.dark ? ColorPalette$1.light : ColorPalette$1.dark;
11710
- const rootClassName = classNames.join(className, block$G({
11703
+ const color = theme === Theme.dark ? ColorPalette.light : ColorPalette.dark;
11704
+ const rootClassName = classnames(className, block$G({
11711
11705
  'has-background': hasBackground,
11712
11706
  'has-header': Boolean(!isEmpty(headerProps.children)),
11713
11707
  'has-header-divider': hasHeaderDivider,
@@ -11716,35 +11710,6 @@ const ExpansionPanel = forwardRef((props, ref) => {
11716
11710
  'is-open': isOpen,
11717
11711
  [`theme-${theme}`]: Boolean(theme)
11718
11712
  }));
11719
- const wrapperRef = useRef(null);
11720
-
11721
- // Children stay visible while the open/close transition is running
11722
- const [isChildrenVisible, setChildrenVisible] = React__default.useState(isOpen);
11723
- const isOpenRef = React__default.useRef(isOpen);
11724
- React__default.useEffect(() => {
11725
- if (isOpen || closeMode === 'hide') {
11726
- setChildrenVisible(true);
11727
- } else if (!IS_BROWSER$1) {
11728
- // Outside a browser we can't wait for the transition
11729
- setChildrenVisible(false);
11730
- }
11731
- isOpenRef.current = isOpen;
11732
- }, [closeMode, isOpen]);
11733
-
11734
- // Change children's visibility on the transition end
11735
- React__default.useEffect(() => {
11736
- const {
11737
- current: wrapper
11738
- } = wrapperRef;
11739
- if (!IS_BROWSER$1 || !wrapper) {
11740
- return undefined;
11741
- }
11742
- const onTransitionEnd = () => {
11743
- setChildrenVisible(isOpenRef.current || closeMode === 'hide');
11744
- };
11745
- wrapper.addEventListener('transitionend', onTransitionEnd);
11746
- return () => wrapper.removeEventListener('transitionend', onTransitionEnd);
11747
- }, [closeMode]);
11748
11713
  return /*#__PURE__*/jsxs("section", {
11749
11714
  ref: ref,
11750
11715
  ...forwardedProps,
@@ -11764,7 +11729,7 @@ const ExpansionPanel = forwardRef((props, ref) => {
11764
11729
  children: /*#__PURE__*/jsx(IconButton, {
11765
11730
  ...toggleButtonProps,
11766
11731
  color: color,
11767
- emphasis: Emphasis$1.low,
11732
+ emphasis: Emphasis.low,
11768
11733
  icon: isOpen ? mdiChevronUp : mdiChevronDown,
11769
11734
  "aria-expanded": isOpen || 'false'
11770
11735
  })
@@ -11784,6 +11749,92 @@ const ExpansionPanel = forwardRef((props, ref) => {
11784
11749
  })
11785
11750
  })]
11786
11751
  });
11752
+ };
11753
+
11754
+ const isDragHandle = isComponent(DragHandle);
11755
+ const isHeader = isComponent('header');
11756
+ const isFooter = isComponent('footer');
11757
+
11758
+ /**
11759
+ * ExpansionPanel component.
11760
+ *
11761
+ * @param props Component props.
11762
+ * @param ref Component ref.
11763
+ * @return React element.
11764
+ */
11765
+ const ExpansionPanel = forwardRef((props, ref) => {
11766
+ const defaultTheme = useTheme() || Theme$1.light;
11767
+ const {
11768
+ closeMode = DEFAULT_PROPS$L.closeMode,
11769
+ children: anyChildren,
11770
+ isOpen,
11771
+ label,
11772
+ onClose,
11773
+ onOpen,
11774
+ onToggleOpen,
11775
+ theme = defaultTheme,
11776
+ ...forwardedProps
11777
+ } = props;
11778
+ const children = Children.toArray(anyChildren);
11779
+
11780
+ // Partition children by types.
11781
+ const [[dragHandle], [header], [footer], content] = partitionMulti(children, [isDragHandle, isHeader, isFooter]);
11782
+
11783
+ // Either take the header in children or create one with the label.
11784
+ const headerProps = /*#__PURE__*/React__default.isValidElement(header) ? header.props : {};
11785
+ const headerContent = !isEmpty(headerProps.children) ? headerProps.children : /*#__PURE__*/jsx("span", {
11786
+ className: element$x('label'),
11787
+ children: label
11788
+ });
11789
+ const wrapperRef = useRef(null);
11790
+
11791
+ // Children stay visible while the open/close transition is running
11792
+ const [isChildrenVisible, setChildrenVisible] = React__default.useState(isOpen);
11793
+ const isOpenRef = React__default.useRef(isOpen);
11794
+ React__default.useEffect(() => {
11795
+ if (isOpen || closeMode === 'hide') {
11796
+ setChildrenVisible(true);
11797
+ } else if (!IS_BROWSER$1) {
11798
+ // Outside a browser we can't wait for the transition
11799
+ setChildrenVisible(false);
11800
+ }
11801
+ isOpenRef.current = isOpen;
11802
+ }, [closeMode, isOpen]);
11803
+
11804
+ // Change children's visibility on the transition end
11805
+ React__default.useEffect(() => {
11806
+ const {
11807
+ current: wrapper
11808
+ } = wrapperRef;
11809
+ if (!IS_BROWSER$1 || !wrapper) {
11810
+ return undefined;
11811
+ }
11812
+ const onTransitionEnd = () => {
11813
+ setChildrenVisible(isOpenRef.current || closeMode === 'hide');
11814
+ };
11815
+ wrapper.addEventListener('transitionend', onTransitionEnd);
11816
+ return () => wrapper.removeEventListener('transitionend', onTransitionEnd);
11817
+ }, [closeMode]);
11818
+ return ExpansionPanel$1({
11819
+ content,
11820
+ dragHandle,
11821
+ footer,
11822
+ headerContent,
11823
+ ref,
11824
+ headerProps,
11825
+ wrapperRef,
11826
+ IconButton,
11827
+ isOpen,
11828
+ handleClose: onClose,
11829
+ handleToggleOpen: onToggleOpen,
11830
+ handleOpen: onOpen,
11831
+ theme,
11832
+ isChildrenVisible,
11833
+ children,
11834
+ closeMode,
11835
+ label,
11836
+ ...forwardedProps
11837
+ });
11787
11838
  });
11788
11839
  ExpansionPanel.displayName = COMPONENT_NAME$O;
11789
11840
  ExpansionPanel.className = CLASSNAME$P;
@@ -12263,11 +12314,10 @@ Icon.className = Icon$1.className;
12263
12314
  Icon.defaultProps = Icon$1.defaultProps;
12264
12315
 
12265
12316
  /** Internal component used to render image captions */
12266
- const ImageCaption = props => {
12267
- const defaultTheme = useTheme();
12317
+ const ImageCaption$1 = props => {
12268
12318
  const {
12269
12319
  baseClassName,
12270
- theme = defaultTheme,
12320
+ theme,
12271
12321
  as = 'figcaption',
12272
12322
  title,
12273
12323
  titleProps,
@@ -12276,7 +12326,9 @@ const ImageCaption = props => {
12276
12326
  tags,
12277
12327
  captionStyle,
12278
12328
  align,
12279
- truncate
12329
+ truncate,
12330
+ FlexBox,
12331
+ Text
12280
12332
  } = props;
12281
12333
  if (!title && !description && !tags) return null;
12282
12334
  const titleColor = {
@@ -12286,16 +12338,9 @@ const ImageCaption = props => {
12286
12338
  color: theme === 'dark' ? 'light' : 'dark',
12287
12339
  colorVariant: 'L2'
12288
12340
  };
12289
-
12290
- // Display description as string or HTML
12291
- const descriptionContent = typeof description === 'string' ? {
12292
- children: description
12293
- } : {
12294
- dangerouslySetInnerHTML: description
12295
- };
12296
12341
  return /*#__PURE__*/jsxs(FlexBox, {
12297
12342
  as: as,
12298
- className: classNames.join(baseClassName && `${baseClassName}__wrapper`),
12343
+ className: classnames(baseClassName && `${baseClassName}__wrapper`),
12299
12344
  style: captionStyle,
12300
12345
  orientation: "vertical",
12301
12346
  vAlign: align,
@@ -12303,25 +12348,31 @@ const ImageCaption = props => {
12303
12348
  gap: "regular",
12304
12349
  children: [(title || description) && /*#__PURE__*/jsxs(Text, {
12305
12350
  as: "p",
12306
- className: classNames.join(baseClassName && `${baseClassName}__caption`),
12351
+ className: classnames(baseClassName && `${baseClassName}__caption`),
12307
12352
  truncate: truncate,
12308
12353
  ...baseColor,
12309
12354
  children: [title && /*#__PURE__*/jsx(Text, {
12310
12355
  ...titleProps,
12311
12356
  as: "span",
12312
- className: classNames.join(titleProps?.className, baseClassName && `${baseClassName}__title`),
12357
+ className: classnames(titleProps?.className, baseClassName && `${baseClassName}__title`),
12313
12358
  typography: "subtitle1",
12314
12359
  ...titleColor,
12315
12360
  children: title
12316
- }), ' ', description && /*#__PURE__*/jsx(Text, {
12361
+ }), ' ', description && (typeof description === 'object' && '__html' in description ? /*#__PURE__*/jsx(Text, {
12317
12362
  ...descriptionProps,
12318
12363
  as: "span",
12319
- className: classNames.join(descriptionProps?.className, baseClassName && `${baseClassName}__description`),
12364
+ className: classnames(descriptionProps?.className, baseClassName && `${baseClassName}__description`),
12320
12365
  typography: "body1",
12321
- ...descriptionContent
12322
- })]
12366
+ dangerouslySetInnerHTML: description
12367
+ }) : /*#__PURE__*/jsx(Text, {
12368
+ ...descriptionProps,
12369
+ as: "span",
12370
+ className: classnames(descriptionProps?.className, baseClassName && `${baseClassName}__description`),
12371
+ typography: "body1",
12372
+ children: description
12373
+ }))]
12323
12374
  }), tags && /*#__PURE__*/jsx(FlexBox, {
12324
- className: classNames.join(baseClassName && `${baseClassName}__tags`),
12375
+ className: classnames(baseClassName && `${baseClassName}__tags`),
12325
12376
  orientation: "horizontal",
12326
12377
  vAlign: align,
12327
12378
  children: tags
@@ -12329,6 +12380,21 @@ const ImageCaption = props => {
12329
12380
  });
12330
12381
  };
12331
12382
 
12383
+ /** Internal component used to render image captions */
12384
+ const ImageCaption = props => {
12385
+ const defaultTheme = useTheme();
12386
+ const {
12387
+ theme = defaultTheme,
12388
+ ...forwardedProps
12389
+ } = props;
12390
+ return ImageCaption$1({
12391
+ FlexBox,
12392
+ Text,
12393
+ theme,
12394
+ ...forwardedProps
12395
+ });
12396
+ };
12397
+
12332
12398
  const ImageBlockCaptionPosition = {
12333
12399
  below: 'below',
12334
12400
  over: 'over'