@box/blueprint-web 6.32.1 → 6.32.3

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.
@@ -1,9 +1,7 @@
1
1
  import { jsxs, jsx } from 'react/jsx-runtime';
2
2
  import { Tab } from '@ariakit/react';
3
3
  import clsx from 'clsx';
4
- import { forwardRef, useRef } from 'react';
5
- import { useEnhancedEffect } from '../../utils/useEnhancedEffect.js';
6
- import { useTabsWidthContext } from './tabs-width-context.js';
4
+ import { forwardRef } from 'react';
7
5
  import styles from './tabs.module.js';
8
6
 
9
7
  const ContentSwitchTab = /*#__PURE__*/forwardRef(function Tab$1(props, ref) {
@@ -12,29 +10,12 @@ const ContentSwitchTab = /*#__PURE__*/forwardRef(function Tab$1(props, ref) {
12
10
  children,
13
11
  ...rest
14
12
  } = props;
15
- const widthSetterRef = useRef(null);
16
- const {
17
- minTabWidth,
18
- addTabWidth
19
- } = useTabsWidthContext();
20
- useEnhancedEffect(() => {
21
- const tabElement = widthSetterRef.current;
22
- if (!tabElement) {
23
- return;
24
- }
25
- const tabWidth = tabElement.getBoundingClientRect().width;
26
- addTabWidth(tabWidth);
27
- }, [addTabWidth]);
28
13
  return jsxs(Tab, {
29
14
  ...rest,
30
15
  ref: ref,
31
16
  className: clsx(styles.contentSwitchTab, className),
32
17
  children: [children, jsx("span", {
33
- ref: widthSetterRef,
34
18
  className: styles.hiddenWidthSetter,
35
- style: {
36
- minWidth: minTabWidth
37
- },
38
19
  children: children
39
20
  })]
40
21
  });
@@ -1,17 +1,14 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { TabProvider } from '@ariakit/react';
3
- import { TabsWidthProvider } from './tabs-width-context.js';
4
3
 
5
4
  const Tabs = props => {
6
5
  const {
7
6
  children
8
7
  } = props;
9
- return jsx(TabsWidthProvider, {
10
- children: jsx(TabProvider, {
11
- selectOnMove: false,
12
- ...props,
13
- children: children
14
- })
8
+ return jsx(TabProvider, {
9
+ selectOnMove: false,
10
+ ...props,
11
+ children: children
15
12
  });
16
13
  };
17
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/blueprint-web",
3
- "version": "6.32.1",
3
+ "version": "6.32.3",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -57,7 +57,7 @@
57
57
  "devDependencies": {
58
58
  "@box/storybook-utils": "^0.0.6"
59
59
  },
60
- "gitHead": "25214c832bd6a2d554534298fc76f4e07e19ab4f",
60
+ "gitHead": "446007aaf0d040195648a9588cd76e6ca1d261e8",
61
61
  "module": "lib-esm/index.js",
62
62
  "main": "lib-esm/index.js",
63
63
  "exports": {
@@ -1,17 +0,0 @@
1
- import { type ReactNode } from 'react';
2
- export interface TabsWidthContextData {
3
- /**
4
- * Minimum width of each rendered tab, derived from a tab with the longest label with minimal paddings.
5
- */
6
- minTabWidth: number;
7
- /**
8
- * Register width of a tab in context.
9
- */
10
- addTabWidth: (width: number) => void;
11
- }
12
- export interface TabsWidthContextProps {
13
- children: ReactNode;
14
- }
15
- export declare const TabsWidthContext: import("react").Context<TabsWidthContextData | undefined>;
16
- export declare const useTabsWidthContext: () => TabsWidthContextData;
17
- export declare const TabsWidthProvider: (props: TabsWidthContextProps) => JSX.Element;
@@ -1,31 +0,0 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { useContext, useState, useCallback, useMemo, createContext } from 'react';
3
-
4
- const TabsWidthContext = /*#__PURE__*/createContext(undefined);
5
- const useTabsWidthContext = () => {
6
- const tabsWidthContextData = useContext(TabsWidthContext);
7
- if (!tabsWidthContextData) {
8
- throw new Error('Tabs subcomponents must be wrapped in Tabs component.');
9
- }
10
- return tabsWidthContextData;
11
- };
12
- const TabsWidthProvider = props => {
13
- const {
14
- children
15
- } = props;
16
- const [tabWidths, setTabWidths] = useState([]);
17
- const minTabWidth = Math.max(...tabWidths);
18
- const addTabWidth = useCallback(width => {
19
- setTabWidths(prev => [...prev, width]);
20
- }, []);
21
- const store = useMemo(() => ({
22
- minTabWidth,
23
- addTabWidth
24
- }), [minTabWidth, addTabWidth]);
25
- return jsx(TabsWidthContext.Provider, {
26
- value: store,
27
- children: children
28
- });
29
- };
30
-
31
- export { TabsWidthContext, TabsWidthProvider, useTabsWidthContext };