@lumx/react 4.19.1-alpha.2 → 4.19.1-alpha.4

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
@@ -5318,6 +5318,11 @@ interface CommonTabProps extends HasClassName {
5318
5318
  isActive?: boolean;
5319
5319
  /** Synonym for `isActive` — `'page'` marks the tab as active (WAI-ARIA nav-link convention). */
5320
5320
  'aria-current'?: 'page' | boolean;
5321
+ /**
5322
+ * WAI-ARIA `tab` role, resolved by the framework wrapper from `TabProvider` presence:
5323
+ * `'tab'` inside a provider (classic tab mode), `undefined` outside (nav-link mode).
5324
+ */
5325
+ role?: 'tab';
5321
5326
  /** Whether the component is disabled or not. */
5322
5327
  isDisabled?: boolean;
5323
5328
  /** Label content. */
@@ -5338,8 +5343,6 @@ interface CommonTabProps extends HasClassName {
5338
5343
  tabIndexProp?: string;
5339
5344
  /** Name of the prop used to attach the keypress event (framework-dependent). */
5340
5345
  keyPressProp?: string;
5341
- /** ID applied to the tab button element (for aria-labelledby on the panel). */
5342
- tabId?: string;
5343
5346
  /** ID of the associated tab panel (for aria-controls). */
5344
5347
  tabPanelId?: string;
5345
5348
  /** Icon component injected by the framework wrapper. */
@@ -5358,17 +5361,18 @@ type TabAsProps<E extends TabElement = 'button'> = {
5358
5361
  as?: E;
5359
5362
  } & (E extends 'a' ? HasRequiredLinkHref<'a'> : unknown);
5360
5363
  /**
5361
- * Props of the `Tab` component. Polymorphic on `as`: setting it enters **nav-link mode**,
5362
- * rendering that element instead of a `<button role="tab">`. The `href` conditional's false
5363
- * branch is `unknown` (not a record) to avoid widening `keyof TabProps`.
5364
+ * Props of the `Tab` component. Polymorphic on `as` (element selection only): `as` picks the
5365
+ * rendered element, while **mode is driven by `TabProvider` presence** (via the wrapper-resolved
5366
+ * `role`), not by `as`. The `href` conditional's false branch is `unknown` (not a record) to avoid
5367
+ * widening `keyof TabProps`.
5364
5368
  */
5365
5369
  type TabProps$1<E extends TabElement = 'button'> = CommonTabProps & TabAsProps<E>;
5366
- type TabPropsToOverride = 'as' | 'isAnyDisabled' | 'shouldActivateOnFocus' | 'changeToTab' | 'tabIndex' | 'tabIndexProp' | 'keyPressProp' | 'tabId' | 'tabPanelId' | 'Icon' | 'Text';
5370
+ type TabPropsToOverride = 'as' | 'role' | 'isAnyDisabled' | 'shouldActivateOnFocus' | 'changeToTab' | 'tabIndex' | 'tabIndexProp' | 'keyPressProp' | 'tabPanelId' | 'Icon' | 'Text';
5367
5371
 
5368
5372
  /**
5369
- * Defines the props of the component. Polymorphic on `as`: unset it's a classic
5370
- * `<button role="tab">`; set it (`as="a"` with required `href`, or `as={RouterLink}`) for
5371
- * nav-link mode. The forwarded ref type follows `as`.
5373
+ * Defines the props of the component. Polymorphic on `as` (element selection only): `as` picks the
5374
+ * rendered element (`as="a"` with required `href`, or `as={RouterLink}`), while the mode
5375
+ * (`role="tab"` vs nav-link) is driven by `TabProvider` presence. The forwarded ref type follows `as`.
5372
5376
  */
5373
5377
  type TabProps<E extends ElementType$1 = 'button'> = GenericProps$1 & HasPolymorphicAs$1<E> & HasRequiredLinkHref$1<E> & ReactToJSX<TabProps$1, TabPropsToOverride> & {
5374
5378
  /** Children are not supported. */
@@ -5390,8 +5394,10 @@ type TabProps<E extends ElementType$1 = 'button'> = GenericProps$1 & HasPolymorp
5390
5394
  * Tab component.
5391
5395
  *
5392
5396
  * Implements WAI-ARIA `tab` role {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label}
5397
+ * when rendered inside a `TabProvider`.
5393
5398
  *
5394
- * In nav-link mode (`as` set): plain link, no `role="tab"`/roving tabindex/`changeToTab` dispatch.
5399
+ * Outside a `TabProvider` (nav-link mode): plain link, no `role="tab"`/roving tabindex/`changeToTab`
5400
+ * dispatch — only `aria-current` marks the active item.
5395
5401
  *
5396
5402
  * @param props Component props.
5397
5403
  * @param ref Component ref (type follows `as`).
package/index.js CHANGED
@@ -21013,10 +21013,11 @@ const {
21013
21013
  } = bem(CLASSNAME$6);
21014
21014
 
21015
21015
  /**
21016
- * Tab component. Two modes keyed on `as`: classic (no `as`) implements the WAI-ARIA `tab` role
21016
+ * Tab component. Two modes keyed on `TabProvider` presence (via the wrapper-resolved `role`):
21017
+ * tab mode (`role === 'tab'`, inside a provider) implements the WAI-ARIA `tab` role
21017
21018
  * {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label};
21018
- * nav-link (`as` set) renders plain link semantics (`aria-current`, no tab role/aria), decoupled
21019
- * from the TabProvider.
21019
+ * nav-link mode (no provider) renders plain link semantics (`aria-current`, no tab role/aria).
21020
+ * `as` only selects the rendered element and applies in both modes.
21020
21021
  *
21021
21022
  * @param props Component props.
21022
21023
  * @param ref Component ref.
@@ -21033,6 +21034,7 @@ const Tab$1 = props => {
21033
21034
  id,
21034
21035
  isActive: isActiveProp,
21035
21036
  'aria-current': ariaCurrent,
21037
+ role,
21036
21038
  label,
21037
21039
  handleFocus,
21038
21040
  handleKeyPress,
@@ -21042,7 +21044,6 @@ const Tab$1 = props => {
21042
21044
  changeToTab,
21043
21045
  tabPanelId,
21044
21046
  shouldActivateOnFocus,
21045
- tabId,
21046
21047
  Icon,
21047
21048
  Text,
21048
21049
  ref,
@@ -21050,8 +21051,8 @@ const Tab$1 = props => {
21050
21051
  } = props;
21051
21052
  const isActive = isActiveProp ?? ariaCurrent === 'page';
21052
21053
  let rawClickableProps;
21053
- if (as === 'button') {
21054
- // Mode: WAI-ARIA `tab` role
21054
+ if (role === 'tab') {
21055
+ // Mode: WAI-ARIA `tab` role (inside a TabProvider)
21055
21056
  const changeToCurrentTab = () => {
21056
21057
  if (isAnyDisabled) {
21057
21058
  return;
@@ -21098,7 +21099,7 @@ const Tab$1 = props => {
21098
21099
  return RawClickable({
21099
21100
  ...rawClickableProps,
21100
21101
  as,
21101
- id: tabId,
21102
+ id,
21102
21103
  className: classnames(className, block$6({
21103
21104
  'is-active': isActive,
21104
21105
  'is-disabled': isAnyDisabled
@@ -21119,17 +21120,19 @@ const Tab$1 = props => {
21119
21120
  };
21120
21121
 
21121
21122
  /**
21122
- * Defines the props of the component. Polymorphic on `as`: unset it's a classic
21123
- * `<button role="tab">`; set it (`as="a"` with required `href`, or `as={RouterLink}`) for
21124
- * nav-link mode. The forwarded ref type follows `as`.
21123
+ * Defines the props of the component. Polymorphic on `as` (element selection only): `as` picks the
21124
+ * rendered element (`as="a"` with required `href`, or `as={RouterLink}`), while the mode
21125
+ * (`role="tab"` vs nav-link) is driven by `TabProvider` presence. The forwarded ref type follows `as`.
21125
21126
  */
21126
21127
 
21127
21128
  /**
21128
21129
  * Tab component.
21129
21130
  *
21130
21131
  * Implements WAI-ARIA `tab` role {@see https://www.w3.org/TR/wai-aria-practices-1.1/examples/tabs/tabs-1/tabs.html#rps_label}
21132
+ * when rendered inside a `TabProvider`.
21131
21133
  *
21132
- * In nav-link mode (`as` set): plain link, no `role="tab"`/roving tabindex/`changeToTab` dispatch.
21134
+ * Outside a `TabProvider` (nav-link mode): plain link, no `role="tab"`/roving tabindex/`changeToTab`
21135
+ * dispatch — only `aria-current` marks the active item.
21133
21136
  *
21134
21137
  * @param props Component props.
21135
21138
  * @param ref Component ref (type follows `as`).
@@ -21148,24 +21151,28 @@ const Tab = Object.assign(forwardRefPolymorphic((props, ref) => {
21148
21151
  onKeyPress,
21149
21152
  ...forwardedProps
21150
21153
  } = otherProps;
21151
- const isNavLink = as != 'button';
21152
21154
 
21153
21155
  // Register into the provider (if any) so it can track this tab's index / active state.
21154
21156
  const tabState = useTabProviderContext('tab', id);
21157
+ // In a provider => tab mode (role="tab"); outside => nav-link mode. Mirrors TabList's role.
21158
+ const inProvider = tabState !== undefined;
21155
21159
  const {
21156
21160
  isLazy: _isLazy,
21161
+ tabId,
21157
21162
  ...state
21158
21163
  } = tabState ?? {};
21159
- // Nav-link tabs ignore the provider's active index active state is caller-controlled only.
21160
- const isActive = isNavLink ? propIsActive : propIsActive || state?.isActive;
21164
+ // Without a provider there's no active index, so this collapses to the caller-provided value.
21165
+ const isActive = propIsActive || state?.isActive;
21161
21166
  return Tab$1({
21162
21167
  ...forwardedProps,
21163
- id,
21164
21168
  ...state,
21165
21169
  as,
21170
+ role: inProvider ? 'tab' : undefined,
21166
21171
  Icon,
21167
21172
  Text,
21168
21173
  ref,
21174
+ // Falls back to the caller-provided `id` when there's no TabProvider to generate one.
21175
+ id: tabId || id,
21169
21176
  isActive,
21170
21177
  isAnyDisabled,
21171
21178
  isDisabled: isAnyDisabled,