@patternfly/react-core 4.219.0 → 4.219.1

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.219.0",
3
+ "version": "4.219.1",
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.70.0",
38
- "@patternfly/react-styles": "^4.69.0",
39
- "@patternfly/react-tokens": "^4.71.0",
37
+ "@patternfly/react-icons": "^4.70.1",
38
+ "@patternfly/react-styles": "^4.69.1",
39
+ "@patternfly/react-tokens": "^4.71.1",
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": "35dea6aaa7ed4c6f49ae0d3ee6644dda3efb2889"
63
+ "gitHead": "7a00f2e2733a593e840464c786f7096e004d02f1"
64
64
  }
@@ -5,6 +5,8 @@ cssPrefix: pf-c-expandable-section
5
5
  propComponents: ['ExpandableSection', 'ExpandableSectionToggle']
6
6
  ---
7
7
 
8
+ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
9
+
8
10
  ## Examples
9
11
 
10
12
  ### Basic
@@ -178,3 +180,48 @@ class SimpleExpandableSection extends React.Component {
178
180
  }
179
181
  }
180
182
  ```
183
+
184
+ ### With custom toggle content
185
+
186
+ By using the `toggleContent` prop, you can pass in content other than a simple string such as an icon or a badge. When passing in custom content in this way, you should not pass in any interactive element such as a button.
187
+
188
+ ```js
189
+ import React from "react";
190
+ import { ExpandableSection, Badge } from "@patternfly/react-core";
191
+ import CheckCircleIcon from "@patternfly/react-icons/dist/esm/icons/check-circle-icon";
192
+
193
+ class CustomExpandableSection extends React.Component {
194
+ constructor(props) {
195
+ super(props);
196
+ this.state = {
197
+ isExpanded: false
198
+ };
199
+ this.onToggle = (isExpanded) => {
200
+ this.setState({
201
+ isExpanded
202
+ });
203
+ };
204
+ }
205
+
206
+ render() {
207
+ const { isExpanded } = this.state;
208
+ return (
209
+ <ExpandableSection
210
+ toggleContent={
211
+ <div>
212
+ <span>You can also use icons </span>
213
+ <CheckCircleIcon />
214
+ <span> or badges </span>
215
+ <Badge isRead={true}>4</Badge>
216
+ <span> !</span>
217
+ </div>
218
+ }
219
+ onToggle={this.onToggle}
220
+ isExpanded={isExpanded}
221
+ >
222
+ This content is visible only when the component is expanded.
223
+ </ExpandableSection>
224
+ );
225
+ }
226
+ }
227
+ ```
@@ -37,7 +37,7 @@ export const ModalBoxTitle: React.FunctionComponent<ModalBoxTitleProps> = ({
37
37
  titleLabel = '',
38
38
  ...props
39
39
  }: ModalBoxTitleProps) => {
40
- const [isTooltipVisible, setIsTooltipVisible] = React.useState(false);
40
+ const [hasTooltip, setHasTooltip] = React.useState(false);
41
41
  const h1 = React.useRef<HTMLHeadingElement>();
42
42
  const label = titleLabel || (isVariantIcon(titleIconVariant) ? `${capitalize(titleIconVariant)} alert:` : titleLabel);
43
43
  const variantIcons = {
@@ -50,7 +50,7 @@ export const ModalBoxTitle: React.FunctionComponent<ModalBoxTitleProps> = ({
50
50
  const CustomIcon = !isVariantIcon(titleIconVariant) && titleIconVariant;
51
51
 
52
52
  useIsomorphicLayoutEffect(() => {
53
- setIsTooltipVisible(h1.current && h1.current.offsetWidth < h1.current.scrollWidth);
53
+ setHasTooltip(h1.current && h1.current.offsetWidth < h1.current.scrollWidth);
54
54
  }, []);
55
55
 
56
56
  const content = (
@@ -70,12 +70,6 @@ export const ModalBoxTitle: React.FunctionComponent<ModalBoxTitleProps> = ({
70
70
  </h1>
71
71
  );
72
72
 
73
- return isTooltipVisible ? (
74
- <Tooltip content={title} isVisible>
75
- {content}
76
- </Tooltip>
77
- ) : (
78
- content
79
- );
73
+ return hasTooltip ? <Tooltip content={title}>{content}</Tooltip> : content;
80
74
  };
81
75
  ModalBoxTitle.displayName = 'ModalBoxTitle';
@@ -235,9 +235,7 @@ export const Slider: React.FunctionComponent<SliderProps> = ({
235
235
  if (!areCustomStepsContinuous && customSteps) {
236
236
  let percentage = newPercentage;
237
237
  if (customSteps[customSteps.length - 1].value !== 100) {
238
- const numSteps = customSteps.length - 1;
239
- const percentagePerStep = 100 / numSteps;
240
- percentage = newPercentage / percentagePerStep;
238
+ percentage = (newPercentage * (max - min)) / 100 + min;
241
239
  }
242
240
  const stepIndex = customSteps.findIndex(stepObj => stepObj.value >= percentage);
243
241
  if (customSteps[stepIndex].value === percentage) {
@@ -29,7 +29,8 @@ class DiscreteInput extends React.Component {
29
29
  value3: 25,
30
30
  value4: 50,
31
31
  value5: 50,
32
- value6: 3
32
+ value6: 3,
33
+ value7: 25
33
34
  };
34
35
 
35
36
  this.steps = [
@@ -53,6 +54,15 @@ class DiscreteInput extends React.Component {
53
54
  { value: 5, label: "F" }
54
55
  ];
55
56
 
57
+ this.stepsDiscreteNoLinearWithMaxMin = [
58
+ { value: 12, label: '12' },
59
+ { value: 15, label: '15' },
60
+ { value: 25, label: '25' },
61
+ { value: 54, label: '54' },
62
+ { value: 67, label: '67' },
63
+ { value: 86, label: '86' }
64
+ ];
65
+
56
66
  this.onChange = value => {
57
67
  this.setState({
58
68
  value1: value
@@ -88,6 +98,12 @@ class DiscreteInput extends React.Component {
88
98
  value6: value
89
99
  });
90
100
  };
101
+
102
+ this.onChange7 = value => {
103
+ this.setState({
104
+ value7: value
105
+ });
106
+ };
91
107
  }
92
108
 
93
109
  render() {
@@ -123,7 +139,18 @@ class DiscreteInput extends React.Component {
123
139
  customSteps={this.stepsDiscreteWithMax}
124
140
  onChange={this.onChange6}
125
141
  />
126
- <br />
142
+ <br />
143
+ <Text component={TextVariants.h3}>Slider value is: {Math.floor(this.state.value7)}</Text>
144
+ <Text component={TextVariants.small}>(min = 12, max = 86, custom steps with non linear data) </Text>
145
+ <Slider
146
+ value={this.state.value7}
147
+ showTicks
148
+ customSteps={this.stepsDiscreteNoLinearWithMaxMin}
149
+ onChange={this.onChange7}
150
+ min={12}
151
+ max={86}
152
+ />
153
+ <br />
127
154
  </>
128
155
  );
129
156
  }