@patternfly/react-core 4.183.2 → 4.183.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.183.2",
3
+ "version": "4.183.6",
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,9 +34,9 @@
34
34
  "generate": "node scripts/copyStyles.js"
35
35
  },
36
36
  "dependencies": {
37
- "@patternfly/react-icons": "^4.34.2",
38
- "@patternfly/react-styles": "^4.33.2",
39
- "@patternfly/react-tokens": "^4.35.2",
37
+ "@patternfly/react-icons": "^4.34.6",
38
+ "@patternfly/react-styles": "^4.33.6",
39
+ "@patternfly/react-tokens": "^4.35.6",
40
40
  "focus-trap": "6.2.2",
41
41
  "react-dropzone": "9.0.0",
42
42
  "tippy.js": "5.1.2",
@@ -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": "3227da5a80f1a78cf7f547c543a17f1a88e351c3"
63
+ "gitHead": "d48d11c5afd7cfb804d1b2df77378f0cf0142881"
64
64
  }
@@ -137,7 +137,7 @@ export const JumpLinks: React.FunctionComponent<JumpLinksProps> = ({
137
137
  }
138
138
  }
139
139
  });
140
- }, [scrollItems, hasScrollSpy, scrollableElement]);
140
+ }, [scrollItems, hasScrollSpy, scrollableElement, offset]);
141
141
 
142
142
  React.useEffect(() => {
143
143
  scrollableElement = document.querySelector(scrollableSelector) as HTMLElement;
@@ -5,6 +5,7 @@ import { css } from '@patternfly/react-styles';
5
5
  import { SliderStep } from './SliderStep';
6
6
  import { InputGroup, InputGroupText } from '../InputGroup';
7
7
  import { TextInput } from '../TextInput';
8
+ import { Tooltip } from '../Tooltip';
8
9
 
9
10
  export interface SliderStepObject {
10
11
  /** Value of the step. This value is a percentage of the slider where the tick is drawn. */
@@ -44,6 +45,8 @@ export interface SliderProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onCh
44
45
  inputAriaLabel?: string;
45
46
  /* Aria label for the thumb */
46
47
  thumbAriaLabel?: string;
48
+ /* Adds a tooltip over the thumb containing the current value */
49
+ hasTooltipOverThumb?: boolean;
47
50
  /** Label that is place after the input field */
48
51
  inputLabel?: string | number;
49
52
  /** Position of the input */
@@ -73,6 +76,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
73
76
  inputLabel,
74
77
  inputAriaLabel = 'Slider value input',
75
78
  thumbAriaLabel = 'Value',
79
+ hasTooltipOverThumb = false,
76
80
  inputPosition = 'right',
77
81
  onChange,
78
82
  leftActions,
@@ -141,7 +145,9 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
141
145
  return matchingStep.label;
142
146
  }
143
147
  }
144
- return localValue.toString();
148
+ // For continuous steps default to showing 2 decimals in tooltip
149
+ // Consider making it configurable via a property
150
+ return Number(Number(localValue).toFixed(2)).toString();
145
151
  };
146
152
 
147
153
  const handleThumbDragEnd = () => {
@@ -209,12 +215,12 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
209
215
 
210
216
  thumbRef.current.style.setProperty('--pf-c-slider--value', `${newPercentage}%`);
211
217
  // convert percentage to value
212
- const newValue = (newPercentage * (max - min)) / 100 + min;
218
+ const newValue = Math.round(((newPercentage * (max - min)) / 100 + min) * 100) / 100;
213
219
  setValue(newValue);
214
220
 
215
221
  if (!customSteps) {
216
222
  // snap to new value if not custom steps
217
- snapValue = Math.round((newValue - min) / step) * step + min;
223
+ snapValue = Math.round((Math.round((newValue - min) / step) * step + min) * 100) / 100;
218
224
  thumbRef.current.style.setProperty('--pf-c-slider--value', `${snapValue}%`);
219
225
  setValue(snapValue);
220
226
  }
@@ -344,6 +350,25 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
344
350
  return builtSteps;
345
351
  };
346
352
 
353
+ const thumbComponent = (
354
+ <div
355
+ className={css(styles.sliderThumb)}
356
+ ref={thumbRef}
357
+ tabIndex={isDisabled ? -1 : 0}
358
+ role="slider"
359
+ aria-valuemin={customSteps ? customSteps[0].value : min}
360
+ aria-valuemax={customSteps ? customSteps[customSteps.length - 1].value : max}
361
+ aria-valuenow={localValue}
362
+ aria-valuetext={findAriaTextValue()}
363
+ aria-label={thumbAriaLabel}
364
+ aria-disabled={isDisabled}
365
+ onMouseDown={!isDisabled ? handleMouseDown : null}
366
+ onTouchStart={!isDisabled ? handleTouchStart : null}
367
+ onKeyDown={!isDisabled ? handleThumbKeys : null}
368
+ onClick={!isDisabled ? onThumbClick : null}
369
+ />
370
+ );
371
+
347
372
  return (
348
373
  <div
349
374
  className={css(styles.slider, className, isDisabled && styles.modifiers.disabled)}
@@ -379,22 +404,13 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
379
404
  {buildSteps()}
380
405
  </div>
381
406
  )}
382
- <div
383
- className={css(styles.sliderThumb)}
384
- ref={thumbRef}
385
- tabIndex={isDisabled ? -1 : 0}
386
- role="slider"
387
- aria-valuemin={customSteps ? customSteps[0].value : min}
388
- aria-valuemax={customSteps ? customSteps[customSteps.length - 1].value : max}
389
- aria-valuenow={localValue}
390
- aria-valuetext={findAriaTextValue()}
391
- aria-label={thumbAriaLabel}
392
- aria-disabled={isDisabled}
393
- onMouseDown={!isDisabled ? handleMouseDown : null}
394
- onTouchStart={!isDisabled ? handleTouchStart : null}
395
- onKeyDown={!isDisabled ? handleThumbKeys : null}
396
- onClick={!isDisabled ? onThumbClick : null}
397
- />
407
+ {hasTooltipOverThumb ? (
408
+ <Tooltip entryDelay={0} content={findAriaTextValue()}>
409
+ {thumbComponent}
410
+ </Tooltip>
411
+ ) : (
412
+ thumbComponent
413
+ )}
398
414
  {isInputVisible && inputPosition === 'aboveThumb' && (
399
415
  <div className={css(styles.sliderValue, styles.modifiers.floating)}>{displayInput()}</div>
400
416
  )}
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { mount } from 'enzyme';
2
+ import { mount, shallow } from 'enzyme';
3
3
  import { Slider } from '../Slider';
4
4
  import { Button } from '../../Button';
5
5
 
@@ -69,4 +69,9 @@ describe('slider', () => {
69
69
  const view = mount(<Slider value={50} isDisabled />);
70
70
  expect(view).toMatchSnapshot();
71
71
  });
72
+
73
+ test('renders slider with tooltip on thumb', () => {
74
+ const view = shallow(<Slider value={50} hasTooltipOverThumb />);
75
+ expect(view).toMatchSnapshot();
76
+ });
72
77
  });
@@ -1194,3 +1194,69 @@ exports[`slider renders slider with input actions 1`] = `
1194
1194
  </div>
1195
1195
  </Slider>
1196
1196
  `;
1197
+
1198
+ exports[`slider renders slider with tooltip on thumb 1`] = `
1199
+ <div
1200
+ className="pf-c-slider"
1201
+ style={
1202
+ Object {
1203
+ "--pf-c-slider--value": "50%",
1204
+ "--pf-c-slider__value--c-form-control--width-chars": 1,
1205
+ }
1206
+ }
1207
+ >
1208
+ <div
1209
+ className="pf-c-slider__main"
1210
+ >
1211
+ <div
1212
+ className="pf-c-slider__rail"
1213
+ onClick={[Function]}
1214
+ >
1215
+ <div
1216
+ className="pf-c-slider__rail-track"
1217
+ />
1218
+ </div>
1219
+ <div
1220
+ aria-hidden="true"
1221
+ className="pf-c-slider__steps"
1222
+ >
1223
+ <SliderStep
1224
+ isActive={true}
1225
+ isLabelHidden={false}
1226
+ isTickHidden={true}
1227
+ key="0"
1228
+ label="0"
1229
+ value={0}
1230
+ />
1231
+ <SliderStep
1232
+ isActive={false}
1233
+ isLabelHidden={false}
1234
+ isTickHidden={true}
1235
+ key="100"
1236
+ label="100"
1237
+ value={100}
1238
+ />
1239
+ </div>
1240
+ <Tooltip
1241
+ content="50"
1242
+ entryDelay={0}
1243
+ >
1244
+ <div
1245
+ aria-disabled={false}
1246
+ aria-label="Value"
1247
+ aria-valuemax={100}
1248
+ aria-valuemin={0}
1249
+ aria-valuenow={50}
1250
+ aria-valuetext="50"
1251
+ className="pf-c-slider__thumb"
1252
+ onClick={[Function]}
1253
+ onKeyDown={[Function]}
1254
+ onMouseDown={[Function]}
1255
+ onTouchStart={[Function]}
1256
+ role="slider"
1257
+ tabIndex={0}
1258
+ />
1259
+ </Tooltip>
1260
+ </div>
1261
+ </div>
1262
+ `;
@@ -134,12 +134,13 @@ class DiscreteInput extends React.Component {
134
134
 
135
135
  ```js
136
136
  import React from 'react';
137
- import { Slider, Text, TextVariants } from '@patternfly/react-core';
137
+ import { Checkbox, Slider, Text, TextVariants } from '@patternfly/react-core';
138
138
 
139
139
  class ContinuousInput extends React.Component {
140
140
  constructor(props) {
141
141
  super(props);
142
142
  this.state = {
143
+ hasTooltipOverThumb: false,
143
144
  value: 50,
144
145
  valueCustom: 50
145
146
  };
@@ -160,14 +161,24 @@ class ContinuousInput extends React.Component {
160
161
  render() {
161
162
  return (
162
163
  <>
163
- <Text component={TextVariants.h3}>Slider value is: {this.state.value.toFixed(2)}</Text>
164
- <Slider value={this.state.value} onChange={this.onChange} />
164
+ <Checkbox
165
+ id="thumb-has-tooltip"
166
+ label="hasTooltipOverThumb"
167
+ isChecked={this.state.hasTooltipOverThumb}
168
+ onChange={hasTooltipOverThumb => this.setState({ hasTooltipOverThumb })}
169
+ style={{ marginBottom: 20 }} />
170
+ <Text component={TextVariants.h3}>Slider Value is: {this.state.value}</Text>
171
+ <Slider
172
+ hasTooltipOverThumb={this.state.hasTooltipOverThumb}
173
+ value={this.state.value}
174
+ onChange={this.onChange} />
165
175
  <br />
166
- <Text component={TextVariants.h3}>Slider value is: {this.state.valueCustom.toFixed(2)}</Text>
176
+ <Text component={TextVariants.h3}>Slider value is: {this.state.valueCustom}</Text>
167
177
  <Slider
168
178
  onChange={this.onChangeCustom}
169
179
  value={this.state.valueCustom}
170
180
  areCustomStepsContinuous
181
+ hasTooltipOverThumb={this.state.hasTooltipOverThumb}
171
182
  customSteps={[
172
183
  { value: 0, label: '0%' },
173
184
  { value: 100, label: '100%' }
@@ -195,15 +195,15 @@ test('should render secondary tabs', () => {
195
195
  <Tab id="secondary tab1" eventKey={10} title={<TabTitleText>"Secondary Tab item 1"</TabTitleText>}>
196
196
  Secondary Tab 1 section
197
197
  </Tab>
198
- <Tab id="secondary tab2" eventKey={11} title={<TabTitleText>"Secondary Tab item 2"</TabTitleText>}>>
198
+ <Tab id="secondary tab2" eventKey={11} title={<TabTitleText>"Secondary Tab item 2"</TabTitleText>}>
199
199
  Secondary Tab 2 section
200
200
  </Tab>
201
- <Tab id="secondary tab3" eventKey={12} title={<TabTitleText>"Secondary Tab item 3"</TabTitleText>}>>
201
+ <Tab id="secondary tab3" eventKey={12} title={<TabTitleText>"Secondary Tab item 3"</TabTitleText>}>
202
202
  Secondary Tab 3 section
203
203
  </Tab>
204
204
  </Tabs>
205
205
  </Tab>
206
- <Tab id="tab2" eventKey={1} title={<TabTitleText>"Tab item 2"</TabTitleText>}>>
206
+ <Tab id="tab2" eventKey={1} title={<TabTitleText>"Tab item 2"</TabTitleText>}>
207
207
  Tab 2 section
208
208
  </Tab>
209
209
  <Tab id="tab3" eventKey={2} title={<TabTitleText>"Tab item 3"</TabTitleText>}>
@@ -1077,7 +1077,7 @@ Array [
1077
1077
  role="tabpanel"
1078
1078
  tabindex="0"
1079
1079
  >
1080
- &gt; Secondary Tab 2 section
1080
+ Secondary Tab 2 section
1081
1081
  </section>
1082
1082
  <section
1083
1083
  aria-labelledby="pf-tab-12-secondary tab3"
@@ -1089,7 +1089,7 @@ Array [
1089
1089
  role="tabpanel"
1090
1090
  tabindex="0"
1091
1091
  >
1092
- &gt; Secondary Tab 3 section
1092
+ Secondary Tab 3 section
1093
1093
  </section>
1094
1094
  </section>,
1095
1095
  <section
@@ -1102,7 +1102,7 @@ Array [
1102
1102
  role="tabpanel"
1103
1103
  tabindex="0"
1104
1104
  >
1105
- &gt; Tab 2 section
1105
+ Tab 2 section
1106
1106
  </section>,
1107
1107
  <section
1108
1108
  aria-labelledby="pf-tab-2-tab3"
@@ -15,7 +15,7 @@ JumpLinks has a scrollspy built-in to make your implementation easier. When impl
15
15
 
16
16
  ### Scrollspy with subsections
17
17
 
18
- This demo expands on the previous to show the JumpLinks in a vertical layout with subsections. It scrolls the [Page](/components/page)'s `mainContainerId` with an `offset` of 76px for the masthead. The headings are given a tab index to allow the jump links to focus them.
18
+ This demo expands on the previous to show the JumpLinks in a vertical layout with subsections. It scrolls the [Page](/components/page)'s `mainContainerId` with an `offset` calculated based on the height of the masthead and the nav list when it appears above the content. The headings are given a tab index to allow the jump links to focus on them.
19
19
 
20
20
  ```js isFullscreen
21
21
  import React from 'react';
@@ -30,7 +30,8 @@ import {
30
30
  SidebarPanel,
31
31
  Switch,
32
32
  Title,
33
- TextContent
33
+ TextContent,
34
+ getResizeObserver
34
35
  } from '@patternfly/react-core';
35
36
  import DashboardWrapper from './examples/DashboardWrapper';
36
37
 
@@ -38,6 +39,23 @@ ScrollspyH2 = () => {
38
39
  const headings = [1, 2, 3, 4, 5];
39
40
 
40
41
  const [isVertical, setIsVertical] = React.useState(true);
42
+ const [offsetHeight, setOffsetHeight] = React.useState(10);
43
+
44
+ // Update offset based on the masthead and jump links nav heights.
45
+ React.useEffect(() => {
46
+ const masthead = document.getElementsByClassName('pf-c-masthead')[0];
47
+ const offsetForPadding = 10;
48
+
49
+ getResizeObserver(masthead, () => {
50
+ if (isVertical) {
51
+ setOffsetHeight(masthead.offsetHeight + offsetForPadding);
52
+ } else {
53
+ // Append jump links nav height to the masthead height when value exists.
54
+ const jumpLinksHeaderHeight = document.getElementsByClassName('pf-m-sticky')[0].offsetHeight;
55
+ jumpLinksHeaderHeight && setOffsetHeight(masthead.offsetHeight + jumpLinksHeaderHeight + offsetForPadding);
56
+ }
57
+ });
58
+ }, [isVertical]);
41
59
 
42
60
  return (
43
61
  <DashboardWrapper breadcrumb={null} mainContainerId="scrollable-element">
@@ -62,8 +80,8 @@ ScrollspyH2 = () => {
62
80
  isCentered={!isVertical}
63
81
  label="Jump to section"
64
82
  scrollableSelector="#scrollable-element"
65
- offset={76} // for masthead
66
- expandable={{ default: 'expandable', md: 'nonExpandable' }}
83
+ offset={offsetHeight}
84
+ expandable={{ default: isVertical ? 'expandable' : 'nonExpandable', md: 'nonExpandable' }}
67
85
  isExpanded
68
86
  >
69
87
  {headings.map(i => (
package/src/demos/Tabs.md CHANGED
@@ -6,6 +6,11 @@ section: components
6
6
  import DashboardWrapper from './examples/DashboardWrapper';
7
7
  import CheckCircleIcon from '@patternfly/react-icons/dist/js/icons/check-circle-icon';
8
8
  import InfoCircleIcon from '@patternfly/react-icons/dist/js/icons/info-circle-icon';
9
+ import CodeIcon from '@patternfly/react-icons/dist/esm/icons/code-icon';
10
+ import CodeBranchIcon from '@patternfly/react-icons/dist/esm/icons/code-branch-icon';
11
+ import CubeIcon from '@patternfly/react-icons/dist/esm/icons/cube-icon';
12
+ import FilterIcon from '@patternfly/react-icons/dist/esm/icons/filter-icon';
13
+ import SortAmountDownIcon from '@patternfly/react-icons/dist/esm/icons/sort-amount-down-icon';
9
14
 
10
15
  ## Demos
11
16
 
@@ -440,4 +445,8 @@ TabsOpenWithSecondaryTabsDemo = () => {
440
445
 
441
446
  ### Nested tabs
442
447
  ```js isFullscreen file="./Tabs/NestedTabsDemo.js"
443
- ```
448
+ ```
449
+
450
+ ### Tables and tabs
451
+ ```js isFullscreen file="./examples/Tabs/TabsAndTable.tsx"
452
+ ```