@patternfly/react-core 4.202.18 → 4.202.21

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.
Files changed (56) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/dist/esm/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
  3. package/dist/esm/components/CalendarMonth/CalendarMonth.js +12 -4
  4. package/dist/esm/components/CalendarMonth/CalendarMonth.js.map +1 -1
  5. package/dist/esm/components/NumberInput/NumberInput.d.ts +2 -0
  6. package/dist/esm/components/NumberInput/NumberInput.d.ts.map +1 -1
  7. package/dist/esm/components/NumberInput/NumberInput.js +2 -2
  8. package/dist/esm/components/NumberInput/NumberInput.js.map +1 -1
  9. package/dist/js/components/CalendarMonth/CalendarMonth.d.ts.map +1 -1
  10. package/dist/js/components/CalendarMonth/CalendarMonth.js +12 -4
  11. package/dist/js/components/CalendarMonth/CalendarMonth.js.map +1 -1
  12. package/dist/js/components/NumberInput/NumberInput.d.ts +2 -0
  13. package/dist/js/components/NumberInput/NumberInput.d.ts.map +1 -1
  14. package/dist/js/components/NumberInput/NumberInput.js +2 -2
  15. package/dist/js/components/NumberInput/NumberInput.js.map +1 -1
  16. package/dist/umd/react-core.css +4 -2
  17. package/dist/umd/react-core.js +14 -6
  18. package/dist/umd/react-core.min.css +4 -2
  19. package/dist/umd/react-core.min.js +2 -2
  20. package/package.json +6 -6
  21. package/src/components/CalendarMonth/CalendarMonth.tsx +10 -4
  22. package/src/components/CalendarMonth/examples/CalendarMonth.md +9 -0
  23. package/src/components/CalendarMonth/examples/CalendarMonthDateRange.tsx +10 -0
  24. package/src/components/DatePicker/examples/DatePicker.md +8 -121
  25. package/src/components/DatePicker/examples/DatePickerAmerican.tsx +19 -0
  26. package/src/components/DatePicker/examples/DatePickerBasic.tsx +11 -0
  27. package/src/components/DatePicker/examples/DatePickerControlled.tsx +13 -0
  28. package/src/components/DatePicker/examples/DatePickerControlledCalendar.tsx +17 -0
  29. package/src/components/DatePicker/examples/DatePickerFrench.tsx +26 -0
  30. package/src/components/DatePicker/examples/DatePickerHelperText.tsx +6 -0
  31. package/src/components/DatePicker/examples/DatePickerMinMax.tsx +17 -0
  32. package/src/components/DescriptionList/examples/DescriptionList.md +22 -930
  33. package/src/components/DescriptionList/examples/DescriptionListAutoFitBasic.tsx +40 -0
  34. package/src/components/DescriptionList/examples/DescriptionListAutoFitMinWidthModified.tsx +40 -0
  35. package/src/components/DescriptionList/examples/DescriptionListAutoFitMinWidthResponsive.tsx +40 -0
  36. package/src/components/DescriptionList/examples/DescriptionListBasic.tsx +40 -0
  37. package/src/components/DescriptionList/examples/DescriptionListColumnFill.tsx +42 -0
  38. package/src/components/DescriptionList/examples/DescriptionListCompact.tsx +40 -0
  39. package/src/components/DescriptionList/examples/DescriptionListCompactHorizontal.tsx +40 -0
  40. package/src/components/DescriptionList/examples/DescriptionListDefaultAutoColumn.tsx +40 -0
  41. package/src/components/DescriptionList/examples/DescriptionListDefaultInlineGrid.tsx +40 -0
  42. package/src/components/DescriptionList/examples/DescriptionListDefaultResponsiveColumns.tsx +40 -0
  43. package/src/components/DescriptionList/examples/DescriptionListDefaultThreeColLg.tsx +40 -0
  44. package/src/components/DescriptionList/examples/DescriptionListDefaultTwoCol.tsx +44 -0
  45. package/src/components/DescriptionList/examples/DescriptionListFluidHorizontal.tsx +40 -0
  46. package/src/components/DescriptionList/examples/DescriptionListHorizontal.tsx +40 -0
  47. package/src/components/DescriptionList/examples/DescriptionListHorizontalAutoColumn.tsx +40 -0
  48. package/src/components/DescriptionList/examples/DescriptionListHorizontalCustomTermWidth.tsx +50 -0
  49. package/src/components/DescriptionList/examples/DescriptionListHorizontalResponsiveColumns.tsx +40 -0
  50. package/src/components/DescriptionList/examples/DescriptionListHorizontalThreeColLg.tsx +40 -0
  51. package/src/components/DescriptionList/examples/DescriptionListHorizontalTwoCol.tsx +40 -0
  52. package/src/components/DescriptionList/examples/DescriptionListIconsOnTerms.tsx +45 -0
  53. package/src/components/DescriptionList/examples/DescriptionListResponsiveHoriVertGroup.tsx +48 -0
  54. package/src/components/DescriptionList/examples/DescriptionListWithTermHelpText.tsx +62 -0
  55. package/src/components/NumberInput/NumberInput.tsx +4 -0
  56. package/src/components/NumberInput/examples/NumberInput.md +8 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.202.18",
3
+ "version": "4.202.21",
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.53.18",
38
- "@patternfly/react-styles": "^4.52.18",
39
- "@patternfly/react-tokens": "^4.54.18",
37
+ "@patternfly/react-icons": "^4.53.21",
38
+ "@patternfly/react-styles": "^4.52.21",
39
+ "@patternfly/react-tokens": "^4.54.21",
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.185.1",
46
+ "@patternfly/patternfly": "4.185.2",
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": "fd2bf430267635cb2473b40153f591fa853b47ad"
63
+ "gitHead": "15786a5112cf09f6bdbc95b067918cf24ec74ba0"
64
64
  }
@@ -113,7 +113,11 @@ export const CalendarMonth = ({
113
113
  // eslint-disable-next-line prefer-const
114
114
  let [focusedDate, setFocusedDate] = React.useState(new Date(dateProp));
115
115
  if (!isValidDate(focusedDate)) {
116
- focusedDate = today;
116
+ if (isValidDate(rangeStart)) {
117
+ focusedDate = rangeStart;
118
+ } else {
119
+ focusedDate = today;
120
+ }
117
121
  }
118
122
  const [hoveredDate, setHoveredDate] = React.useState(new Date(focusedDate));
119
123
  const focusRef = React.useRef<HTMLButtonElement>();
@@ -279,13 +283,15 @@ export const CalendarMonth = ({
279
283
  const isSelected = isValidDate(dateProp) && isSameDate(date, dateProp);
280
284
  const isFocused = isSameDate(date, focusedDate);
281
285
  const isAdjacentMonth = date.getMonth() !== focusedDate.getMonth();
286
+ const isRangeStart = isValidDate(rangeStart) && isSameDate(date, rangeStart);
282
287
  let isInRange = false;
283
- let isRangeStart = false;
284
288
  let isRangeEnd = false;
285
- if (isValidDate(rangeStart) && isHoveredDateValid) {
289
+ if (isValidDate(rangeStart) && isValidDate(dateProp)) {
290
+ isInRange = date > rangeStart && date < dateProp;
291
+ isRangeEnd = isSameDate(date, dateProp);
292
+ } else if (isValidDate(rangeStart) && isHoveredDateValid) {
286
293
  if (hoveredDate > rangeStart || isSameDate(hoveredDate, rangeStart)) {
287
294
  isInRange = date > rangeStart && date < hoveredDate;
288
- isRangeStart = isSameDate(date, rangeStart);
289
295
  isRangeEnd = isSameDate(date, hoveredDate);
290
296
  }
291
297
  // Don't handle focused dates before start dates for now.
@@ -17,3 +17,12 @@ beta: true
17
17
 
18
18
  ```ts file="./CalendarMonthSelectableDate.tsx"
19
19
  ```
20
+
21
+ ### Date range
22
+
23
+ In this example, there are 2 dates selected: a range start date (via the `rangeStart` prop) and a range end date (via the `date` prop). Additionally, any dates prior to the range start date are disabled by passing in an array of functions to the `validators` prop. In this case a single function is passed in, which checks whether a date is greater than or equal to the range start date.
24
+
25
+ For this example, these dates are static and cannot be updated. For an interactive demo, see our [Date picker demos](https://www.patternfly.org/v4/components/date-picker/react-demos).
26
+
27
+ ```ts file="./CalendarMonthDateRange.tsx"
28
+ ```
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { CalendarMonth } from '@patternfly/react-core';
3
+
4
+ export const CalendarMonthDateRange: React.FunctionComponent = () => {
5
+ const startDate = new Date(2020, 10, 11);
6
+ const endDate = new Date(2020, 10, 24);
7
+ const disablePreStartDates = (date: Date) => date >= startDate;
8
+
9
+ return <CalendarMonth validators={[disablePreStartDates]} date={endDate} rangeStart={startDate} />;
10
+ };
@@ -7,151 +7,38 @@ beta: true
7
7
  ---
8
8
 
9
9
  ## Examples
10
+
10
11
  ### Basic
11
- ```js
12
- import React from 'react';
13
- import { DatePicker } from '@patternfly/react-core';
14
12
 
15
- <DatePicker
16
- onBlur={(str, date) => console.log('onBlur', str, date)}
17
- onChange={(str, date) => console.log('onChange', str, date)}
18
- />
13
+ ```ts file="./DatePickerBasic.tsx"
19
14
  ```
20
15
 
21
16
  ### American format
22
- ```js
23
- import React from 'react';
24
- import { DatePicker } from '@patternfly/react-core';
25
-
26
- AmericanFormat = () => {
27
- const dateFormat = date => date.toLocaleDateString('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g,'-');
28
- const dateParse = date => {
29
- const split = date.split('-');
30
- if (split.length !== 3) {
31
- return new Date();
32
- }
33
- let month = split[0];
34
- let day = split[1];
35
- let year = split[2];
36
- return new Date(`${year.padStart(4, '0')}-${month.padStart(2, '0')}-${day.padStart(2, '0')}T00:00:00`);
37
- };
38
17
 
39
- return (
40
- <DatePicker
41
- value="03-05-2020"
42
- placeholder="MM-DD-YYYY"
43
- dateFormat={dateFormat}
44
- dateParse={dateParse}
45
- />
46
- );
47
- }
18
+ ```ts file="./DatePickerAmerican.tsx"
48
19
  ```
49
20
 
50
21
  ### Helper text
51
- ```js
52
- import React from 'react';
53
- import { DatePicker } from '@patternfly/react-core';
54
22
 
55
- <DatePicker value="2020-03-05" helperText="Select a date." />
23
+ ```ts file="./DatePickerHelperText.tsx"
56
24
  ```
57
25
 
58
26
  ### Min and max date
59
- ```js
60
- import React from 'react';
61
- import { DatePicker } from '@patternfly/react-core';
62
27
 
63
- MinMaxDate = () => {
64
- const minDate = new Date(2020, 2, 16);
65
- const maxDate = new Date(2020, 2, 20);
66
- const rangeValidator = date => {
67
- if (date < minDate) {
68
- return 'Date is before the allowable range.';
69
- }
70
- else if (date > maxDate) {
71
- return 'Date is after the allowable range.';
72
- }
73
-
74
- return '';
75
- };
76
- return <DatePicker value="2020-03-17" validators={[rangeValidator]} />;
77
- }
28
+ ```ts file="./DatePickerMinMax.tsx"
78
29
  ```
79
30
 
80
31
  ### French
81
32
 
82
- ```js
83
- import React from 'react';
84
- import { DatePicker, Weekday } from '@patternfly/react-core';
85
-
86
- FrenchMinMaxDate = () => {
87
- const minDate = new Date(2020, 2, 16);
88
- const maxDate = new Date(2020, 2, 20);
89
- const rangeValidator = date => {
90
- if (date < minDate) {
91
- return 'Cette date est antérieure à la première date valide.';
92
- }
93
- else if (date > maxDate) {
94
- return 'Cette date est postérieure à la dernière date valide.';
95
- }
96
-
97
- return '';
98
- };
99
- return (
100
- <DatePicker
101
- value="2020-03-17"
102
- validators={[rangeValidator]}
103
- placeholder="aaaa-mm-jj"
104
- invalidFormatText="Cette date est invalide."
105
- locale="fr"
106
- weekStart={Weekday.Monday}
107
- />
108
- );
109
- }
33
+ ```ts file="./DatePickerFrench.tsx"
110
34
  ```
111
35
 
112
36
  ### Controlled
113
37
 
114
- ```js
115
- import React from 'react';
116
- import { Button, DatePicker } from '@patternfly/react-core';
117
-
118
- ControlledDate = () => {
119
- const initialValue = '2020-03-17';
120
- const [value, setValue] = React.useState(initialValue);
121
- return (
122
- <React.Fragment>
123
- <Button onClick={() => setValue(initialValue)}>
124
- Reset date
125
- </Button>
126
- <DatePicker
127
- value={value}
128
- onChange={value => setValue(value)}
129
- />
130
- </React.Fragment>
131
- );
132
- }
38
+ ```ts file="./DatePickerControlled.tsx"
133
39
  ```
134
40
 
135
41
  ### Controlling the date picker calendar state
136
42
 
137
- ```js
138
- import React from 'react';
139
- import { Button, DatePicker } from '@patternfly/react-core';
140
-
141
- ControllingDatePicker = () => {
142
- const dateRef = React.useRef(null);
143
- const onClick = () => {
144
- if (dateRef.current) {
145
- dateRef.current.toggleCalendar()
146
- }
147
- };
148
- return (
149
- <React.Fragment>
150
- <Button onClick={onClick}>
151
- Toggle calendar
152
- </Button>
153
- <DatePicker ref={ dateRef } />
154
- </React.Fragment>
155
- );
156
- }
43
+ ```ts file="./DatePickerControlledCalendar.tsx"
157
44
  ```
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import { DatePicker } from '@patternfly/react-core';
3
+
4
+ export const DatePickerAmerican: React.FunctionComponent = () => {
5
+ const dateFormat = (date: Date) =>
6
+ date.toLocaleDateString('en-US', { year: 'numeric', month: '2-digit', day: '2-digit' }).replace(/\//g, '-');
7
+ const dateParse = (date: string) => {
8
+ const split = date.split('-');
9
+ if (split.length !== 3) {
10
+ return new Date();
11
+ }
12
+ const month = split[0];
13
+ const day = split[1];
14
+ const year = split[2];
15
+ return new Date(`${year.padStart(4, '0')}-${month.padStart(2, '0')}-${day.padStart(2, '0')}T00:00:00`);
16
+ };
17
+
18
+ return <DatePicker value="03-05-2020" placeholder="MM-DD-YYYY" dateFormat={dateFormat} dateParse={dateParse} />;
19
+ };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { DatePicker } from '@patternfly/react-core';
3
+
4
+ export const DatePickerBasic: React.FunctionComponent = () => (
5
+ <DatePicker
6
+ // eslint-disable-next-line no-console
7
+ onBlur={(str, date) => console.log('onBlur', str, date)}
8
+ // eslint-disable-next-line no-console
9
+ onChange={(str, date) => console.log('onChange', str, date)}
10
+ />
11
+ );
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import { Button, DatePicker } from '@patternfly/react-core';
3
+
4
+ export const DatePickerControlled: React.FunctionComponent = () => {
5
+ const initialValue = '2020-03-17';
6
+ const [value, setValue] = React.useState(initialValue);
7
+ return (
8
+ <React.Fragment>
9
+ <Button onClick={() => setValue(initialValue)}>Reset date</Button>
10
+ <DatePicker value={value} onChange={value => setValue(value)} />
11
+ </React.Fragment>
12
+ );
13
+ };
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { Button, DatePicker } from '@patternfly/react-core';
3
+
4
+ export const DatePickerControlledCalendar: React.FunctionComponent = () => {
5
+ const dateRef = React.useRef(null);
6
+ const onClick = () => {
7
+ if (dateRef.current) {
8
+ dateRef.current.toggleCalendar();
9
+ }
10
+ };
11
+ return (
12
+ <React.Fragment>
13
+ <Button onClick={onClick}>Toggle calendar</Button>
14
+ <DatePicker ref={dateRef} />
15
+ </React.Fragment>
16
+ );
17
+ };
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import { DatePicker, Weekday } from '@patternfly/react-core';
3
+
4
+ export const DatePickerFrench: React.FunctionComponent = () => {
5
+ const minDate = new Date(2020, 2, 16);
6
+ const maxDate = new Date(2020, 2, 20);
7
+ const rangeValidator = (date: Date) => {
8
+ if (date < minDate) {
9
+ return 'Cette date est antérieure à la première date valide.';
10
+ } else if (date > maxDate) {
11
+ return 'Cette date est postérieure à la dernière date valide.';
12
+ }
13
+
14
+ return '';
15
+ };
16
+ return (
17
+ <DatePicker
18
+ value="2020-03-17"
19
+ validators={[rangeValidator]}
20
+ placeholder="aaaa-mm-jj"
21
+ invalidFormatText="Cette date est invalide."
22
+ locale="fr"
23
+ weekStart={Weekday.Monday}
24
+ />
25
+ );
26
+ };
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { DatePicker } from '@patternfly/react-core';
3
+
4
+ export const DatePickerHelperText: React.FunctionComponent = () => (
5
+ <DatePicker value="2020-03-05" helperText="Select a date." />
6
+ );
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { DatePicker } from '@patternfly/react-core';
3
+
4
+ export const DatePickerMinMax: React.FunctionComponent = () => {
5
+ const minDate = new Date(2020, 2, 16);
6
+ const maxDate = new Date(2020, 2, 20);
7
+ const rangeValidator = (date: Date) => {
8
+ if (date < minDate) {
9
+ return 'Date is before the allowable range.';
10
+ } else if (date > maxDate) {
11
+ return 'Date is after the allowable range.';
12
+ }
13
+
14
+ return '';
15
+ };
16
+ return <DatePicker value="2020-03-17" validators={[rangeValidator]} />;
17
+ };