@patternfly/react-core 4.175.16 → 4.175.17
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 +11 -0
- package/dist/esm/components/Slider/Slider.d.ts.map +1 -1
- package/dist/esm/components/Slider/Slider.js +9 -6
- package/dist/esm/components/Slider/Slider.js.map +1 -1
- package/dist/js/components/Slider/Slider.d.ts.map +1 -1
- package/dist/js/components/Slider/Slider.js +9 -6
- package/dist/js/components/Slider/Slider.js.map +1 -1
- package/dist/umd/react-core.js +9 -6
- package/dist/umd/react-core.min.css +69 -69
- package/dist/umd/react-core.min.js +1 -1
- package/package.json +5 -5
- package/src/components/Slider/Slider.tsx +9 -6
- package/src/components/Slider/examples/Slider.md +27 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "4.175.
|
|
3
|
+
"version": "4.175.17",
|
|
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.26.
|
|
38
|
-
"@patternfly/react-styles": "^4.25.
|
|
39
|
-
"@patternfly/react-tokens": "^4.27.
|
|
37
|
+
"@patternfly/react-icons": "^4.26.17",
|
|
38
|
+
"@patternfly/react-styles": "^4.25.17",
|
|
39
|
+
"@patternfly/react-tokens": "^4.27.17",
|
|
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": "
|
|
63
|
+
"gitHead": "a090a90f5628375cca96aed412316b34a7f92e50"
|
|
64
64
|
}
|
|
@@ -221,15 +221,18 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
|
|
|
221
221
|
|
|
222
222
|
/* If custom steps are discrete, snap to closest step value */
|
|
223
223
|
if (!areCustomStepsContinuous && customSteps) {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
let percentage = newPercentage;
|
|
225
|
+
if (customSteps[customSteps.length - 1].value !== 100) {
|
|
226
|
+
const numSteps = customSteps.length - 1;
|
|
227
|
+
const percentagePerStep = 100 / numSteps;
|
|
228
|
+
percentage = newPercentage / percentagePerStep;
|
|
229
|
+
}
|
|
230
|
+
const stepIndex = customSteps.findIndex(stepObj => stepObj.value >= percentage);
|
|
231
|
+
if (customSteps[stepIndex].value === percentage) {
|
|
229
232
|
snapValue = customSteps[stepIndex].value;
|
|
230
233
|
} else {
|
|
231
234
|
const midpoint = (customSteps[stepIndex].value + customSteps[stepIndex - 1].value) / 2;
|
|
232
|
-
if (midpoint >
|
|
235
|
+
if (midpoint > percentage) {
|
|
233
236
|
snapValue = customSteps[stepIndex - 1].value;
|
|
234
237
|
} else {
|
|
235
238
|
snapValue = customSteps[stepIndex].value;
|
|
@@ -29,6 +29,7 @@ class DiscreteInput extends React.Component {
|
|
|
29
29
|
value3: 25,
|
|
30
30
|
value4: 50,
|
|
31
31
|
value5: 50,
|
|
32
|
+
value6: 3
|
|
32
33
|
};
|
|
33
34
|
|
|
34
35
|
this.steps = [
|
|
@@ -43,6 +44,15 @@ class DiscreteInput extends React.Component {
|
|
|
43
44
|
{ value: 100, label: '8' }
|
|
44
45
|
];
|
|
45
46
|
|
|
47
|
+
this.stepsDiscreteWithMax = [
|
|
48
|
+
{ value: 0, label: "A" },
|
|
49
|
+
{ value: 1, label: "B" },
|
|
50
|
+
{ value: 2, label: "C" },
|
|
51
|
+
{ value: 3, label: "D" },
|
|
52
|
+
{ value: 4, label: "E" },
|
|
53
|
+
{ value: 5, label: "F" }
|
|
54
|
+
];
|
|
55
|
+
|
|
46
56
|
this.onChange = value => {
|
|
47
57
|
this.setState({
|
|
48
58
|
value1: value
|
|
@@ -72,6 +82,12 @@ class DiscreteInput extends React.Component {
|
|
|
72
82
|
value5: value
|
|
73
83
|
});
|
|
74
84
|
};
|
|
85
|
+
|
|
86
|
+
this.onChange6 = value => {
|
|
87
|
+
this.setState({
|
|
88
|
+
value6: value
|
|
89
|
+
});
|
|
90
|
+
};
|
|
75
91
|
}
|
|
76
92
|
|
|
77
93
|
render() {
|
|
@@ -97,6 +113,17 @@ class DiscreteInput extends React.Component {
|
|
|
97
113
|
<Text component={TextVariants.h3}>Slider value is: {Math.floor(this.state.value5)}</Text>
|
|
98
114
|
<Text component={TextVariants.small}>(min = -25, max = 75, step = 10, boundaries shown, ticks not shown) </Text>
|
|
99
115
|
<Slider value={this.state.value5} onChange={this.onChange5} min={-25} max={75} step={10} />
|
|
116
|
+
<br />
|
|
117
|
+
<Text component={TextVariants.h3}>Slider value is: {Math.floor(this.state.value6)}</Text>
|
|
118
|
+
<Text component={TextVariants.small}>(max = 5, custom steps) </Text>
|
|
119
|
+
<Slider
|
|
120
|
+
value={this.state.value6}
|
|
121
|
+
showTicks
|
|
122
|
+
max={5}
|
|
123
|
+
customSteps={this.stepsDiscreteWithMax}
|
|
124
|
+
onChange={this.onChange6}
|
|
125
|
+
/>
|
|
126
|
+
<br />
|
|
100
127
|
</>
|
|
101
128
|
);
|
|
102
129
|
}
|