@patternfly/react-core 4.183.0 → 4.183.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/CHANGELOG.md +35 -0
- package/dist/esm/components/Slider/Slider.d.ts +1 -0
- package/dist/esm/components/Slider/Slider.d.ts.map +1 -1
- package/dist/esm/components/Slider/Slider.js +9 -5
- package/dist/esm/components/Slider/Slider.js.map +1 -1
- package/dist/js/components/Slider/Slider.d.ts +1 -0
- package/dist/js/components/Slider/Slider.d.ts.map +1 -1
- package/dist/js/components/Slider/Slider.js +9 -5
- package/dist/js/components/Slider/Slider.js.map +1 -1
- package/dist/umd/react-core.css +266 -218
- package/dist/umd/react-core.js +11 -5
- package/dist/umd/react-core.min.css +48 -0
- package/dist/umd/react-core.min.js +2 -2
- package/package.json +6 -6
- package/src/components/Slider/Slider.tsx +35 -19
- package/src/components/Slider/_tests_/Slider.test.tsx +6 -1
- package/src/components/Slider/_tests_/__snapshots__/Slider.test.tsx.snap +66 -0
- package/src/components/Slider/examples/Slider.md +15 -4
- package/src/components/Tabs/__tests__/Tabs.test.tsx +3 -3
- package/src/components/Tabs/__tests__/__snapshots__/Tabs.test.tsx.snap +3 -3
- package/src/demos/Tabs.md +10 -1
- package/src/demos/examples/Tabs/TabsAndTable.tsx +432 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.183.
|
|
3
|
+
"version": "4.183.4",
|
|
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.34.
|
|
38
|
-
"@patternfly/react-styles": "^4.33.
|
|
39
|
-
"@patternfly/react-tokens": "^4.35.
|
|
37
|
+
"@patternfly/react-icons": "^4.34.4",
|
|
38
|
+
"@patternfly/react-styles": "^4.33.4",
|
|
39
|
+
"@patternfly/react-tokens": "^4.35.4",
|
|
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.165.1",
|
|
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": "c3d126fe3f5b45d8a0c24ae7e2268d55529dd8fe"
|
|
64
64
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
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
|
-
<
|
|
164
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1105
|
+
Tab 2 section
|
|
1106
1106
|
</section>,
|
|
1107
1107
|
<section
|
|
1108
1108
|
aria-labelledby="pf-tab-2-tab3"
|
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
|
+
```
|