@lumx/react 4.9.0-next.6 → 4.9.0-next.8

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
@@ -787,7 +787,7 @@ interface ButtonProps extends GenericProps$1, ReactToJSX<ButtonProps$1> {
787
787
  * @param ref Component ref.
788
788
  * @return React element.
789
789
  */
790
- declare const Button: Comp<ButtonProps, HTMLAnchorElement | HTMLButtonElement>;
790
+ declare const Button: Comp<ButtonProps, HTMLButtonElement | HTMLAnchorElement>;
791
791
 
792
792
  interface IconButtonProps$1 extends BaseButtonProps {
793
793
  /**
@@ -2413,7 +2413,7 @@ interface LinkProps extends GenericProps$1, ReactToJSX<LinkProps$1> {
2413
2413
  * @param ref Component ref.
2414
2414
  * @return React element.
2415
2415
  */
2416
- declare const Link: Comp<LinkProps, HTMLAnchorElement | HTMLButtonElement>;
2416
+ declare const Link: Comp<LinkProps, HTMLButtonElement | HTMLAnchorElement>;
2417
2417
 
2418
2418
  /**
2419
2419
  * Defines the props of the component.
@@ -3798,16 +3798,25 @@ declare enum TabListLayout {
3798
3798
  /**
3799
3799
  * Defines the props of the component.
3800
3800
  */
3801
- interface TabListProps extends GenericProps$1, HasTheme$1 {
3801
+ interface TabListProps$1 extends HasClassName, HasTheme {
3802
3802
  /** ARIA label (purpose of the set of tabs). */
3803
3803
  ['aria-label']: string;
3804
3804
  /** Tab list. */
3805
- children: ReactNode;
3805
+ children: JSXElement;
3806
3806
  /** Layout of the tabs in the list. */
3807
3807
  layout?: TabListLayout;
3808
3808
  /** Position of the tabs in the list (requires 'clustered' layout). */
3809
- position?: Alignment$1;
3809
+ position?: Alignment;
3810
+ /** ref to the wrapper element */
3811
+ ref?: CommonRef;
3810
3812
  }
3813
+
3814
+ /**
3815
+ * Defines the props of the component.
3816
+ */
3817
+ interface TabListProps extends GenericProps$1, ReactToJSX<TabListProps$1> {
3818
+ }
3819
+
3811
3820
  /**
3812
3821
  * TabList component.
3813
3822
  *
@@ -3849,6 +3858,10 @@ interface TabProps$1 extends HasClassName {
3849
3858
  changeToTab?: () => void;
3850
3859
  /** Tab index for roving tabindex management. */
3851
3860
  tabIndex?: number;
3861
+ /** Name of the prop used to set tab index (framework-dependent). */
3862
+ tabIndexProp?: string;
3863
+ /** Name of the prop used to attach the keypress event (framework-dependent). */
3864
+ keyPressProp?: string;
3852
3865
  /** ID applied to the tab button element (for aria-labelledby on the panel). */
3853
3866
  tabId?: string;
3854
3867
  /** ID of the associated tab panel (for aria-controls). */
@@ -3860,7 +3873,7 @@ interface TabProps$1 extends HasClassName {
3860
3873
  /** Forward ref to the underlying button element. */
3861
3874
  ref?: CommonRef;
3862
3875
  }
3863
- type TabPropsToOverride = 'isAnyDisabled' | 'shouldActivateOnFocus' | 'changeToTab' | 'tabIndex' | 'tabId' | 'tabPanelId' | 'Icon' | 'Text';
3876
+ type TabPropsToOverride = 'isAnyDisabled' | 'shouldActivateOnFocus' | 'changeToTab' | 'tabIndex' | 'tabIndexProp' | 'keyPressProp' | 'tabId' | 'tabPanelId' | 'Icon' | 'Text';
3864
3877
 
3865
3878
  /**
3866
3879
  * Defines the props of the component.
@@ -3895,13 +3908,30 @@ declare const Tab: Comp<TabProps, HTMLButtonElement>;
3895
3908
  /**
3896
3909
  * Defines the props of the component.
3897
3910
  */
3898
- interface TabPanelProps extends GenericProps$1 {
3899
- /** Native id property */
3900
- id?: string;
3911
+ interface TabPanelProps$1 extends HasClassName {
3901
3912
  /** Whether the tab is active or not. */
3902
3913
  isActive?: boolean;
3914
+ /** Whether the tab is lazy loaded or not */
3915
+ isLazy?: boolean;
3903
3916
  /** Children */
3904
- children?: React.ReactNode;
3917
+ children?: JSXElement;
3918
+ /** ID applied to the tab button element (for aria-labelledby on the panel). */
3919
+ tabId?: string;
3920
+ /** ID of the associated tab panel (for aria-controls). */
3921
+ id?: string;
3922
+ /** Name of the prop used to set tab index (framework-dependent). */
3923
+ tabIndexProp?: string;
3924
+ /** Forward ref to the underlying button element. */
3925
+ ref?: CommonRef;
3926
+ }
3927
+ type TabPanelPropsToOverride = 'tabId' | 'isLazy' | 'tabIndexProp';
3928
+
3929
+ /**
3930
+ * Defines the props of the component.
3931
+ */
3932
+ interface TabPanelProps extends GenericProps$1, ReactToJSX<TabPanelProps$1, TabPanelPropsToOverride> {
3933
+ /** Native id property */
3934
+ id?: string;
3905
3935
  }
3906
3936
  /**
3907
3937
  * TabPanel component.
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Kind as Kind$1, Size as Size$1, ColorPalette as ColorPalette$1, Emphasis as Emphasis$1, ColorVariant, VISUALLY_HIDDEN, Theme as Theme$1, AspectRatio as AspectRatio$1, DOCUMENT, WINDOW, DIALOG_TRANSITION_DURATION, IS_BROWSER as IS_BROWSER$1, Orientation as Orientation$1, Alignment, NOTIFICATION_TRANSITION_DURATION } from '@lumx/core/js/constants';
1
+ import { Kind as Kind$1, Size as Size$1, ColorPalette as ColorPalette$1, Emphasis as Emphasis$1, ColorVariant, VISUALLY_HIDDEN, Theme as Theme$1, AspectRatio as AspectRatio$1, DOCUMENT, WINDOW, DIALOG_TRANSITION_DURATION, IS_BROWSER as IS_BROWSER$1, Orientation as Orientation$1, Alignment as Alignment$1, NOTIFICATION_TRANSITION_DURATION } from '@lumx/core/js/constants';
2
2
  export * from '@lumx/core/js/constants';
3
3
  export * from '@lumx/core/js/types';
4
4
  import * as React from 'react';
@@ -842,6 +842,8 @@ const TOOLTIP_LONG_PRESS_DELAY = {
842
842
  /**
843
843
  * Alignments.
844
844
  */
845
+ const Alignment = {
846
+ left: 'left'};
845
847
  const Theme = {
846
848
  light: 'light',
847
849
  dark: 'dark'
@@ -8013,7 +8015,7 @@ const {
8013
8015
  */
8014
8016
  const DEFAULT_PROPS$O = {
8015
8017
  captionPosition: ImageBlockCaptionPosition.below,
8016
- align: Alignment.left
8018
+ align: Alignment$1.left
8017
8019
  };
8018
8020
 
8019
8021
  /**
@@ -9871,7 +9873,7 @@ const Mosaic = forwardRef((props, ref) => {
9871
9873
  className: element$q('thumbnail'),
9872
9874
  children: [/*#__PURE__*/jsx(Thumbnail, {
9873
9875
  ...thumbnailProps,
9874
- align: align || Alignment.left,
9876
+ align: align || Alignment$1.left,
9875
9877
  image: image,
9876
9878
  theme: theme,
9877
9879
  aspectRatio: AspectRatio$1.free,
@@ -10686,7 +10688,6 @@ const reducer = (state, action) => {
10686
10688
  if (state.activeTabIndex === action.payload) {
10687
10689
  return state;
10688
10690
  }
10689
- // Change active tab index.
10690
10691
  return {
10691
10692
  ...state,
10692
10693
  activeTabIndex: action.payload
@@ -10698,7 +10699,6 @@ const reducer = (state, action) => {
10698
10699
  type,
10699
10700
  id
10700
10701
  } = action.payload;
10701
- // Append tab/tabPanel id in state.
10702
10702
  return {
10703
10703
  ...state,
10704
10704
  ids: {
@@ -10715,7 +10715,6 @@ const reducer = (state, action) => {
10715
10715
  } = action.payload;
10716
10716
  const index = state.ids[type].indexOf(id);
10717
10717
  if (index === -1) return state;
10718
- // Remove tab & tab panel at index.
10719
10718
  const tabIds = [...state.ids.tab];
10720
10719
  tabIds.splice(index, 1);
10721
10720
  const tabPanelIds = [...state.ids.tabPanel];
@@ -10732,7 +10731,9 @@ const reducer = (state, action) => {
10732
10731
  return state;
10733
10732
  }
10734
10733
  };
10734
+
10735
10735
  const TabProviderContext = /*#__PURE__*/createContext(null);
10736
+
10736
10737
  /* eslint-disable react-hooks/rules-of-hooks */
10737
10738
  const useTabProviderContext = (type, originalId) => {
10738
10739
  const context = useContext(TabProviderContext);
@@ -13903,7 +13904,7 @@ const Switch$1 = props => {
13903
13904
  * Component default props.
13904
13905
  */
13905
13906
  const DEFAULT_PROPS$h = {
13906
- position: Alignment.left
13907
+ position: Alignment$1.left
13907
13908
  };
13908
13909
 
13909
13910
  /**
@@ -14462,7 +14463,7 @@ const TABS_CLASSNAME = `lumx-tabs`;
14462
14463
  const {
14463
14464
  block: block$a,
14464
14465
  element: element$6
14465
- } = classNames.bem(TABS_CLASSNAME);
14466
+ } = bem(TABS_CLASSNAME);
14466
14467
  let TabListLayout = /*#__PURE__*/function (TabListLayout) {
14467
14468
  TabListLayout["clustered"] = "clustered";
14468
14469
  TabListLayout["fixed"] = "fixed";
@@ -14495,26 +14496,21 @@ const DEFAULT_PROPS$b = {
14495
14496
  * @param ref Component ref.
14496
14497
  * @return React element.
14497
14498
  */
14498
- const TabList = forwardRef((props, ref) => {
14499
- const defaultTheme = useTheme() || Theme$1.light;
14499
+ const TabList$1 = props => {
14500
14500
  const {
14501
14501
  'aria-label': ariaLabel,
14502
14502
  children,
14503
14503
  className,
14504
14504
  layout = DEFAULT_PROPS$b.layout,
14505
14505
  position = DEFAULT_PROPS$b.position,
14506
- theme = defaultTheme,
14506
+ theme,
14507
+ ref,
14507
14508
  ...forwardedProps
14508
14509
  } = props;
14509
- const tabListRef = React__default.useRef(null);
14510
- useRovingTabIndexContainer({
14511
- containerRef: tabListRef,
14512
- itemSelector: '[role="tab"]'
14513
- });
14514
14510
  return /*#__PURE__*/jsx("div", {
14515
- ref: mergeRefs(ref, tabListRef),
14511
+ ref: ref,
14516
14512
  ...forwardedProps,
14517
- className: classNames.join(className, block$a({
14513
+ className: classnames(className, block$a({
14518
14514
  [`layout-${layout}`]: Boolean(layout),
14519
14515
  [`position-${position}`]: Boolean(position),
14520
14516
  [`theme-${theme}`]: Boolean(theme)
@@ -14526,6 +14522,33 @@ const TabList = forwardRef((props, ref) => {
14526
14522
  children: children
14527
14523
  })
14528
14524
  });
14525
+ };
14526
+
14527
+ /**
14528
+ * TabList component.
14529
+ *
14530
+ * Implements WAI-ARIA `tablist` role {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label}
14531
+ *
14532
+ * @param props Component props.
14533
+ * @param ref Component ref.
14534
+ * @return React element.
14535
+ */
14536
+ const TabList = forwardRef((props, ref) => {
14537
+ const defaultTheme = useTheme() || Theme$1.light;
14538
+ const {
14539
+ theme = defaultTheme,
14540
+ ...forwardedProps
14541
+ } = props;
14542
+ const tabListRef = React__default.useRef(null);
14543
+ useRovingTabIndexContainer({
14544
+ containerRef: tabListRef,
14545
+ itemSelector: '[role="tab"]'
14546
+ });
14547
+ return TabList$1({
14548
+ theme,
14549
+ ref: mergeRefs(ref, tabListRef),
14550
+ ...forwardedProps
14551
+ });
14529
14552
  });
14530
14553
  TabList.displayName = COMPONENT_NAME$7;
14531
14554
  TabList.className = TABS_CLASSNAME;
@@ -14564,12 +14587,15 @@ const Tab$1 = props => {
14564
14587
  icon,
14565
14588
  iconProps = {},
14566
14589
  isAnyDisabled,
14590
+ isDisabled,
14567
14591
  id,
14568
14592
  isActive,
14569
14593
  label,
14570
14594
  handleFocus,
14571
14595
  handleKeyPress,
14572
14596
  tabIndex = -1,
14597
+ tabIndexProp = 'tabIndex',
14598
+ keyPressProp = 'onKeyPress',
14573
14599
  changeToTab,
14574
14600
  tabPanelId,
14575
14601
  shouldActivateOnFocus,
@@ -14608,10 +14634,10 @@ const Tab$1 = props => {
14608
14634
  'is-disabled': isAnyDisabled
14609
14635
  })),
14610
14636
  onClick: changeToCurrentTab,
14611
- onKeyPress: onKeyPress,
14637
+ [keyPressProp]: onKeyPress,
14612
14638
  onFocus: onFocus,
14613
14639
  role: "tab",
14614
- tabIndex: isActive ? 0 : tabIndex,
14640
+ [tabIndexProp]: isActive ? 0 : tabIndex,
14615
14641
  "aria-disabled": isAnyDisabled,
14616
14642
  "aria-selected": isActive,
14617
14643
  "aria-controls": tabPanelId,
@@ -14682,7 +14708,7 @@ const COMPONENT_NAME$5 = 'TabPanel';
14682
14708
  const CLASSNAME$6 = `lumx-tab-panel`;
14683
14709
  const {
14684
14710
  block: block$8
14685
- } = classNames.bem(CLASSNAME$6);
14711
+ } = bem(CLASSNAME$6);
14686
14712
 
14687
14713
  /**
14688
14714
  * Component default props.
@@ -14698,27 +14724,60 @@ const DEFAULT_PROPS$9 = {};
14698
14724
  * @param ref Component ref.
14699
14725
  * @return React element.
14700
14726
  */
14701
- const TabPanel = forwardRef((props, ref) => {
14727
+ const TabPanel$1 = props => {
14702
14728
  const {
14703
14729
  children,
14704
- id,
14705
14730
  className,
14706
- isActive: propIsActive,
14731
+ isActive,
14732
+ id,
14733
+ tabId,
14734
+ isLazy,
14735
+ tabIndexProp = 'tabIndex',
14736
+ ref,
14707
14737
  ...forwardedProps
14708
14738
  } = props;
14709
- const state = useTabProviderContext('tabPanel', id);
14710
- const isActive = propIsActive || state?.isActive;
14711
14739
  return /*#__PURE__*/jsx("div", {
14712
14740
  ref: ref,
14713
14741
  ...forwardedProps,
14714
- id: state?.tabPanelId,
14715
- className: classNames.join(className, block$8({
14742
+ id: id,
14743
+ className: classnames(className, block$8({
14716
14744
  'is-active': isActive
14717
14745
  })),
14718
14746
  role: "tabpanel",
14719
- tabIndex: isActive ? 0 : -1,
14720
- "aria-labelledby": state?.tabId,
14721
- children: (!state?.isLazy || isActive) && children
14747
+ [tabIndexProp]: isActive ? 0 : -1,
14748
+ "aria-labelledby": tabId,
14749
+ children: (!isLazy || isActive) && children
14750
+ });
14751
+ };
14752
+
14753
+ /**
14754
+ * Defines the props of the component.
14755
+ */
14756
+
14757
+ /**
14758
+ * TabPanel component.
14759
+ *
14760
+ * Implements WAI-ARIA `tabpanel` role {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label}
14761
+ *
14762
+ * @param props Component props.
14763
+ * @param ref Component ref.
14764
+ * @return React element.
14765
+ */
14766
+ const TabPanel = forwardRef((props, ref) => {
14767
+ const {
14768
+ id,
14769
+ isActive: propIsActive,
14770
+ ...forwardedProps
14771
+ } = props;
14772
+ const state = useTabProviderContext('tabPanel', id);
14773
+ const isActive = propIsActive || state?.isActive;
14774
+ return TabPanel$1({
14775
+ ref,
14776
+ isActive,
14777
+ id: state?.tabPanelId,
14778
+ isLazy: state?.isLazy,
14779
+ tabId: state?.tabId,
14780
+ ...forwardedProps
14722
14781
  });
14723
14782
  });
14724
14783
  TabPanel.displayName = COMPONENT_NAME$5;