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

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.
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;