@patternfly/react-core 4.189.1 → 4.189.5
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/CHANGELOG.md +35 -0
- package/dist/esm/components/Tabs/Tabs.d.ts +2 -0
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +24 -18
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/helpers/util.d.ts +2 -1
- package/dist/esm/helpers/util.d.ts.map +1 -1
- package/dist/esm/helpers/util.js +5 -4
- package/dist/esm/helpers/util.js.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +2 -0
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +24 -18
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/helpers/util.d.ts +2 -1
- package/dist/js/helpers/util.d.ts.map +1 -1
- package/dist/js/helpers/util.js +5 -4
- package/dist/js/helpers/util.js.map +1 -1
- package/dist/umd/react-core.css +18 -0
- package/dist/umd/react-core.js +30 -22
- package/dist/umd/react-core.min.css +18 -0
- package/dist/umd/react-core.min.js +3 -3
- package/package.json +6 -6
- package/src/components/Tabs/Tabs.tsx +25 -18
- package/src/helpers/util.ts +10 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.189.
|
|
3
|
+
"version": "4.189.5",
|
|
4
4
|
"description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
|
|
5
5
|
"main": "dist/js/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -34,16 +34,16 @@
|
|
|
34
34
|
"generate": "node scripts/copyStyles.js"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@patternfly/react-icons": "^4.40.
|
|
38
|
-
"@patternfly/react-styles": "^4.39.
|
|
39
|
-
"@patternfly/react-tokens": "^4.41.
|
|
37
|
+
"@patternfly/react-icons": "^4.40.5",
|
|
38
|
+
"@patternfly/react-styles": "^4.39.5",
|
|
39
|
+
"@patternfly/react-tokens": "^4.41.5",
|
|
40
40
|
"focus-trap": "6.2.2",
|
|
41
41
|
"react-dropzone": "9.0.0",
|
|
42
42
|
"tippy.js": "5.1.2",
|
|
43
43
|
"tslib": "^2.0.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@patternfly/patternfly": "4.
|
|
46
|
+
"@patternfly/patternfly": "4.167.0",
|
|
47
47
|
"@rollup/plugin-commonjs": "^21.0.0",
|
|
48
48
|
"@rollup/plugin-node-resolve": "^13.0.0",
|
|
49
49
|
"@rollup/plugin-replace": "^3.0.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0",
|
|
61
61
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "01c8b913108c70fcddb6ee6d7bdf523dffc620b7"
|
|
64
64
|
}
|
|
@@ -129,6 +129,8 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
129
129
|
}
|
|
130
130
|
}
|
|
131
131
|
|
|
132
|
+
scrollTimeout: NodeJS.Timeout = null;
|
|
133
|
+
|
|
132
134
|
static defaultProps: PickOptional<TabsProps> = {
|
|
133
135
|
activeKey: 0,
|
|
134
136
|
onSelect: () => undefined as any,
|
|
@@ -182,28 +184,32 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
handleScrollButtons = () => {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
// add debounce to the scroll event
|
|
188
|
+
clearTimeout(this.scrollTimeout);
|
|
189
|
+
this.scrollTimeout = setTimeout(() => {
|
|
190
|
+
const container = this.tabList.current;
|
|
191
|
+
let disableLeftScrollButton = true;
|
|
192
|
+
let disableRightScrollButton = true;
|
|
193
|
+
let showScrollButtons = false;
|
|
189
194
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
195
|
+
if (container && !this.props.isVertical) {
|
|
196
|
+
// get first element and check if it is in view
|
|
197
|
+
const overflowOnLeft = !isElementInView(container, container.firstChild as HTMLElement, false);
|
|
193
198
|
|
|
194
|
-
|
|
195
|
-
|
|
199
|
+
// get last element and check if it is in view
|
|
200
|
+
const overflowOnRight = !isElementInView(container, container.lastChild as HTMLElement, false);
|
|
196
201
|
|
|
197
|
-
|
|
202
|
+
showScrollButtons = overflowOnLeft || overflowOnRight;
|
|
198
203
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
204
|
+
disableLeftScrollButton = !overflowOnLeft;
|
|
205
|
+
disableRightScrollButton = !overflowOnRight;
|
|
206
|
+
}
|
|
207
|
+
this.setState({
|
|
208
|
+
showScrollButtons,
|
|
209
|
+
disableLeftScrollButton,
|
|
210
|
+
disableRightScrollButton
|
|
211
|
+
});
|
|
212
|
+
}, 100);
|
|
207
213
|
};
|
|
208
214
|
|
|
209
215
|
scrollLeft = () => {
|
|
@@ -261,6 +267,7 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
261
267
|
window.removeEventListener('resize', this.handleScrollButtons, false);
|
|
262
268
|
}
|
|
263
269
|
}
|
|
270
|
+
clearTimeout(this.scrollTimeout);
|
|
264
271
|
}
|
|
265
272
|
|
|
266
273
|
componentDidUpdate(prevProps: TabsProps) {
|
package/src/helpers/util.ts
CHANGED
|
@@ -39,24 +39,30 @@ export function debounce(this: any, func: (...args: any[]) => any, wait: number)
|
|
|
39
39
|
* @param {HTMLElement} container The container to check if the element is in view of.
|
|
40
40
|
* @param {HTMLElement} element The element to check if it is view
|
|
41
41
|
* @param {boolean} partial true if partial view is allowed
|
|
42
|
+
* @param {boolean} strict true if strict mode is set, never consider the container width and element width
|
|
42
43
|
*
|
|
43
44
|
* @returns { boolean } True if the component is in View.
|
|
44
45
|
*/
|
|
45
|
-
export function isElementInView(
|
|
46
|
+
export function isElementInView(
|
|
47
|
+
container: HTMLElement,
|
|
48
|
+
element: HTMLElement,
|
|
49
|
+
partial: boolean,
|
|
50
|
+
strict: boolean = false
|
|
51
|
+
): boolean {
|
|
46
52
|
if (!container || !element) {
|
|
47
53
|
return false;
|
|
48
54
|
}
|
|
49
55
|
const containerBounds = container.getBoundingClientRect();
|
|
50
56
|
const elementBounds = element.getBoundingClientRect();
|
|
51
|
-
const containerBoundsLeft = Math.
|
|
57
|
+
const containerBoundsLeft = Math.ceil(containerBounds.left);
|
|
52
58
|
const containerBoundsRight = Math.floor(containerBounds.right);
|
|
53
|
-
const elementBoundsLeft = Math.
|
|
59
|
+
const elementBoundsLeft = Math.ceil(elementBounds.left);
|
|
54
60
|
const elementBoundsRight = Math.floor(elementBounds.right);
|
|
55
61
|
|
|
56
62
|
// Check if in view
|
|
57
63
|
const isTotallyInView = elementBoundsLeft >= containerBoundsLeft && elementBoundsRight <= containerBoundsRight;
|
|
58
64
|
const isPartiallyInView =
|
|
59
|
-
partial &&
|
|
65
|
+
(partial || (!strict && containerBounds.width < elementBounds.width)) &&
|
|
60
66
|
((elementBoundsLeft < containerBoundsLeft && elementBoundsRight > containerBoundsLeft) ||
|
|
61
67
|
(elementBoundsRight > containerBoundsRight && elementBoundsLeft < containerBoundsRight));
|
|
62
68
|
|