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

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, HTMLButtonElement | HTMLAnchorElement>;
790
+ declare const Button: Comp<ButtonProps, HTMLAnchorElement | HTMLButtonElement>;
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, HTMLButtonElement | HTMLAnchorElement>;
2416
+ declare const Link: Comp<LinkProps, HTMLAnchorElement | HTMLButtonElement>;
2417
2417
 
2418
2418
  /**
2419
2419
  * Defines the props of the component.
@@ -3822,7 +3822,50 @@ declare const TabList: Comp<TabListProps, HTMLDivElement>;
3822
3822
  /**
3823
3823
  * Defines the props of the component.
3824
3824
  */
3825
- interface TabProps extends GenericProps$1 {
3825
+ interface TabProps$1 extends HasClassName {
3826
+ /** Children are not supported. */
3827
+ children?: never;
3828
+ /** Icon (SVG path). */
3829
+ icon?: IconProps$1['icon'];
3830
+ /** Icon component properties. */
3831
+ iconProps?: Omit<IconProps$1, 'icon'>;
3832
+ /** Native id property. */
3833
+ id?: string;
3834
+ /** Whether the tab is active or not. */
3835
+ isActive?: boolean;
3836
+ /** Whether the component is disabled or not. */
3837
+ isDisabled?: boolean;
3838
+ /** Label content. */
3839
+ label: string | JSXElement;
3840
+ /** Whether any tab in the list is disabled (used to block interaction). */
3841
+ isAnyDisabled?: boolean;
3842
+ /** Whether the tab should become active when it receives focus (automatic activation pattern). */
3843
+ shouldActivateOnFocus?: boolean;
3844
+ /** Focus event handler injected by TabList. */
3845
+ handleFocus?: (event: any) => void;
3846
+ /** Keypress event handler injected by TabList. */
3847
+ handleKeyPress?: (event: any) => void;
3848
+ /** Callback to activate this tab, injected by TabList. */
3849
+ changeToTab?: () => void;
3850
+ /** Tab index for roving tabindex management. */
3851
+ tabIndex?: number;
3852
+ /** ID applied to the tab button element (for aria-labelledby on the panel). */
3853
+ tabId?: string;
3854
+ /** ID of the associated tab panel (for aria-controls). */
3855
+ tabPanelId?: string;
3856
+ /** Icon component injected by the framework wrapper. */
3857
+ Icon: any;
3858
+ /** Text component injected by the framework wrapper. */
3859
+ Text: any;
3860
+ /** Forward ref to the underlying button element. */
3861
+ ref?: CommonRef;
3862
+ }
3863
+ type TabPropsToOverride = 'isAnyDisabled' | 'shouldActivateOnFocus' | 'changeToTab' | 'tabIndex' | 'tabId' | 'tabPanelId' | 'Icon' | 'Text';
3864
+
3865
+ /**
3866
+ * Defines the props of the component.
3867
+ */
3868
+ interface TabProps extends GenericProps$1, ReactToJSX<TabProps$1, TabPropsToOverride> {
3826
3869
  /** Children are not supported. */
3827
3870
  children?: never;
3828
3871
  /** Icon (SVG path). */
package/index.js CHANGED
@@ -10889,6 +10889,26 @@ function createActiveItemState(callbacks, signal, initialItem) {
10889
10889
  };
10890
10890
  }
10891
10891
 
10892
+ /**
10893
+ * Create a TreeWalker that iterates over elements matching a CSS selector
10894
+ * within a container.
10895
+ *
10896
+ * Uses `NodeFilter.SHOW_ELEMENT` and accepts nodes that match the given
10897
+ * selector, skipping everything else. The returned walker can be used with
10898
+ * `nextNode()` / `previousNode()` for lazy, sequential DOM traversal.
10899
+ *
10900
+ * @param container The root element to walk within.
10901
+ * @param selector CSS selector that items must match.
10902
+ * @returns A TreeWalker scoped to the container and filtered by the selector.
10903
+ */
10904
+ function createSelectorTreeWalker(container, selector) {
10905
+ return document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
10906
+ acceptNode(node) {
10907
+ return node.matches(selector) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
10908
+ }
10909
+ });
10910
+ }
10911
+
10892
10912
  /**
10893
10913
  * Create a focus navigation controller for a 1D list.
10894
10914
  *
@@ -10918,11 +10938,7 @@ function createListFocusNavigation(options, callbacks, signal) {
10918
10938
  */
10919
10939
  function createItemWalker(enabledOnly = true) {
10920
10940
  const selector = enabledOnly ? enabledItemSelector : itemSelector;
10921
- return document.createTreeWalker(container, NodeFilter.SHOW_ELEMENT, {
10922
- acceptNode(node) {
10923
- return node.matches(selector) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
10924
- }
10925
- });
10941
+ return createSelectorTreeWalker(container, selector);
10926
10942
  }
10927
10943
 
10928
10944
  /** Find the first enabled item in the container. */
@@ -14520,18 +14536,18 @@ TabList.defaultProps = DEFAULT_PROPS$b;
14520
14536
  */
14521
14537
  const COMPONENT_NAME$6 = 'Tab';
14522
14538
 
14539
+ /**
14540
+ * Component default props.
14541
+ */
14542
+ const DEFAULT_PROPS$a = {};
14543
+
14523
14544
  /**
14524
14545
  * Component default class name and class prefix.
14525
14546
  */
14526
14547
  const CLASSNAME$7 = `${TABS_CLASSNAME}__link`;
14527
14548
  const {
14528
14549
  block: block$9
14529
- } = classNames.bem(CLASSNAME$7);
14530
-
14531
- /**
14532
- * Component default props.
14533
- */
14534
- const DEFAULT_PROPS$a = {};
14550
+ } = bem(CLASSNAME$7);
14535
14551
 
14536
14552
  /**
14537
14553
  * Tab component.
@@ -14542,64 +14558,66 @@ const DEFAULT_PROPS$a = {};
14542
14558
  * @param ref Component ref.
14543
14559
  * @return React element.
14544
14560
  */
14545
- const Tab = forwardRef((props, ref) => {
14546
- const {
14547
- isAnyDisabled,
14548
- otherProps
14549
- } = useDisableStateProps(props);
14561
+ const Tab$1 = props => {
14550
14562
  const {
14551
14563
  className,
14552
14564
  icon,
14553
14565
  iconProps = {},
14566
+ isAnyDisabled,
14554
14567
  id,
14555
- isActive: propIsActive,
14568
+ isActive,
14556
14569
  label,
14557
- onFocus,
14558
- onKeyPress,
14570
+ handleFocus,
14571
+ handleKeyPress,
14559
14572
  tabIndex = -1,
14573
+ changeToTab,
14574
+ tabPanelId,
14575
+ shouldActivateOnFocus,
14576
+ tabId,
14577
+ Icon,
14578
+ Text,
14579
+ ref,
14560
14580
  ...forwardedProps
14561
- } = otherProps;
14562
- const state = useTabProviderContext('tab', id);
14563
- const isActive = propIsActive || state?.isActive;
14564
- const changeToCurrentTab = useCallback(() => {
14581
+ } = props;
14582
+ const changeToCurrentTab = () => {
14565
14583
  if (isAnyDisabled) {
14566
14584
  return;
14567
14585
  }
14568
- state?.changeToTab();
14569
- }, [isAnyDisabled, state]);
14570
- const handleFocus = useCallback(event => {
14571
- onFocus?.(event);
14572
- if (state?.shouldActivateOnFocus) {
14586
+ changeToTab?.();
14587
+ };
14588
+ const onFocus = event => {
14589
+ handleFocus?.(event);
14590
+ if (shouldActivateOnFocus) {
14573
14591
  changeToCurrentTab();
14574
14592
  }
14575
- }, [changeToCurrentTab, onFocus, state?.shouldActivateOnFocus]);
14576
- const handleKeyPress = useCallback(event => {
14577
- onKeyPress?.(event);
14593
+ };
14594
+ const onKeyPress = event => {
14595
+ handleKeyPress?.(event);
14578
14596
  if (event.key !== 'Enter' || isAnyDisabled) {
14579
14597
  return;
14580
14598
  }
14581
14599
  changeToCurrentTab();
14582
- }, [changeToCurrentTab, isAnyDisabled, onKeyPress]);
14600
+ };
14583
14601
  return /*#__PURE__*/jsxs("button", {
14584
14602
  ref: ref,
14585
14603
  ...forwardedProps,
14586
14604
  type: "button",
14587
- id: state?.tabId,
14588
- className: classNames.join(className, block$9({
14605
+ id: tabId,
14606
+ className: classnames(className, block$9({
14589
14607
  'is-active': isActive,
14590
14608
  'is-disabled': isAnyDisabled
14591
14609
  })),
14592
14610
  onClick: changeToCurrentTab,
14593
- onKeyPress: handleKeyPress,
14594
- onFocus: handleFocus,
14611
+ onKeyPress: onKeyPress,
14612
+ onFocus: onFocus,
14595
14613
  role: "tab",
14596
14614
  tabIndex: isActive ? 0 : tabIndex,
14597
14615
  "aria-disabled": isAnyDisabled,
14598
14616
  "aria-selected": isActive,
14599
- "aria-controls": state?.tabPanelId,
14617
+ "aria-controls": tabPanelId,
14600
14618
  children: [icon && /*#__PURE__*/jsx(Icon, {
14601
14619
  icon: icon,
14602
- size: Size$1.xs,
14620
+ size: Size.xs,
14603
14621
  ...iconProps
14604
14622
  }), label && /*#__PURE__*/jsx(Text, {
14605
14623
  as: "span",
@@ -14607,6 +14625,47 @@ const Tab = forwardRef((props, ref) => {
14607
14625
  children: label
14608
14626
  })]
14609
14627
  });
14628
+ };
14629
+
14630
+ /**
14631
+ * Defines the props of the component.
14632
+ */
14633
+
14634
+ /**
14635
+ * Tab component.
14636
+ *
14637
+ * Implements WAI-ARIA `tab` role {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label}
14638
+ *
14639
+ * @param props Component props.
14640
+ * @param ref Component ref.
14641
+ * @return React element.
14642
+ */
14643
+ const Tab = forwardRef((props, ref) => {
14644
+ const {
14645
+ isAnyDisabled,
14646
+ otherProps
14647
+ } = useDisableStateProps(props);
14648
+ const {
14649
+ isActive: propIsActive,
14650
+ id,
14651
+ onFocus,
14652
+ onKeyPress,
14653
+ ...forwardedProps
14654
+ } = otherProps;
14655
+ const state = useTabProviderContext('tab', id);
14656
+ const isActive = propIsActive || state?.isActive;
14657
+ return Tab$1({
14658
+ id,
14659
+ ...state,
14660
+ Icon,
14661
+ Text,
14662
+ ref,
14663
+ isActive,
14664
+ isAnyDisabled,
14665
+ handleFocus: onFocus,
14666
+ handleKeyPress: onKeyPress,
14667
+ ...forwardedProps
14668
+ });
14610
14669
  });
14611
14670
  Tab.displayName = COMPONENT_NAME$6;
14612
14671
  Tab.className = CLASSNAME$7;