@rango-dev/ui 0.39.1-next.8 → 0.39.1-next.9

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 +1 @@
1
- {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAsC,MAAM,OAAO,CAAC;AAgB3D,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,qBAyMjD"}
1
+ {"version":3,"file":"Tabs.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Tabs/Tabs.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,KAAsC,MAAM,OAAO,CAAC;AAgB3D,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,qBA8MjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/ui",
3
- "version": "0.39.1-next.8",
3
+ "version": "0.39.1-next.9",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @rango-dev/ui
2
2
 
3
- Rango UI design system components
3
+ Rango UI design system components.
4
4
 
5
5
  ### Icons
6
6
 
@@ -61,14 +61,12 @@ export function TabsComponent(props: TabsPropTypes) {
61
61
  }
62
62
  };
63
63
 
64
- const updateIndicator = (currentIndex: number) => {
64
+ const updateIndicator = () => {
65
65
  if (tabRef.current && containerRef.current) {
66
66
  const tabRect = tabRef.current.getBoundingClientRect();
67
67
  const containerRect = containerRef.current.getBoundingClientRect();
68
68
  setTabWidth(tabRect.width);
69
- setTransformPosition(
70
- scrollable ? tabRef.current.offsetLeft : currentIndex * tabWidth
71
- );
69
+ setTransformPosition(tabRef.current.offsetLeft);
72
70
  const itemPartiallyVisibleOnLeft = tabRect.left < containerRect.left;
73
71
  const itemPartiallyVisibleOnRight = tabRect.right > containerRect.right;
74
72
 
@@ -96,7 +94,7 @@ export function TabsComponent(props: TabsPropTypes) {
96
94
  }, []);
97
95
 
98
96
  useEffect(() => {
99
- updateIndicator(currentIndex);
97
+ updateIndicator();
100
98
 
101
99
  const updateArrowsVisibility = () => {
102
100
  if (scrollable && containerRef.current) {
@@ -119,20 +117,23 @@ export function TabsComponent(props: TabsPropTypes) {
119
117
  };
120
118
 
121
119
  const resizeHandler: ResizeObserverCallback = (event) => {
122
- if (scrollable && containerRef.current) {
123
- const TOTAL_WIDTH_OF_ARROWS = 64;
124
- updateIndicator(currentIndex);
125
- updateArrowsVisibility();
126
- const element = event[0].target;
127
- if (showArrows) {
128
- const tabsContainerOverflown =
129
- element.scrollWidth - TOTAL_WIDTH_OF_ARROWS > element.clientWidth;
130
- if (!tabsContainerOverflown) {
131
- setShowArrows(false);
132
- }
133
- } else if (element.scrollWidth > element.clientWidth) {
134
- setShowArrows(true);
135
- }
120
+ updateIndicator();
121
+
122
+ if (!containerRef.current || !scrollable || !scrollButtons) {
123
+ return;
124
+ }
125
+
126
+ updateArrowsVisibility();
127
+
128
+ const TOTAL_WIDTH_OF_ARROWS = 64;
129
+ const element = event[0].target;
130
+ const tabsContainerOverflown =
131
+ element.scrollWidth - TOTAL_WIDTH_OF_ARROWS > element.clientWidth;
132
+
133
+ if (showArrows && !tabsContainerOverflown) {
134
+ setShowArrows(false);
135
+ } else if (element.scrollWidth > element.clientWidth) {
136
+ setShowArrows(true);
136
137
  }
137
138
  };
138
139
 
@@ -177,34 +178,38 @@ export function TabsComponent(props: TabsPropTypes) {
177
178
  type={type}
178
179
  borderRadius={borderRadius}
179
180
  scrollable={scrollable}>
180
- {tabItems.map((item, index) => (
181
- <Tooltip
182
- key={item.id}
183
- styles={{ root: { width: '100%' } }}
184
- container={container}
185
- side="bottom"
186
- sideOffset={2}
187
- content={item.tooltip}
188
- open={!item.tooltip ? false : undefined}>
189
- <Tab
190
- className="_tab"
191
- ref={index === currentIndex ? tabRef : null}
192
- type={type}
193
- fullWidth={scrollable ? false : true}
194
- disableRipple={true}
195
- borderRadius={borderRadius}
196
- onClick={() => onChange(item)}
197
- size="small"
198
- isActive={item.id === value}
199
- variant="default">
200
- {item.icon}
201
- {!!item.icon && !!item.title && (
202
- <Divider direction="horizontal" size="2" />
203
- )}
204
- {item.title}
205
- </Tab>
206
- </Tooltip>
207
- ))}
181
+ {tabItems.map((item, index) => {
182
+ const isActive = item.id === value;
183
+ return (
184
+ <Tooltip
185
+ key={item.id}
186
+ styles={{ root: { width: '100%' } }}
187
+ container={container}
188
+ side="bottom"
189
+ sideOffset={2}
190
+ content={item.tooltip}
191
+ open={!item.tooltip ? false : undefined}>
192
+ <Tab
193
+ className="_tab"
194
+ ref={index === currentIndex ? tabRef : null}
195
+ type={type}
196
+ fullWidth={scrollable ? false : true}
197
+ disableRipple={true}
198
+ borderRadius={borderRadius}
199
+ onClick={() => onChange(item)}
200
+ size="small"
201
+ isActive={isActive}
202
+ data-active={isActive}
203
+ variant="default">
204
+ {item.icon}
205
+ {!!item.icon && !!item.title && (
206
+ <Divider direction="horizontal" size="2" />
207
+ )}
208
+ {item.title}
209
+ </Tab>
210
+ </Tooltip>
211
+ );
212
+ })}
208
213
  <BackdropTab
209
214
  type={type}
210
215
  borderRadius={borderRadius}