@patternfly/react-core 4.225.8 → 4.225.11

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.225.8",
3
+ "version": "4.225.11",
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.76.8",
38
- "@patternfly/react-styles": "^4.75.8",
39
- "@patternfly/react-tokens": "^4.77.8",
37
+ "@patternfly/react-icons": "^4.76.11",
38
+ "@patternfly/react-styles": "^4.75.11",
39
+ "@patternfly/react-tokens": "^4.77.11",
40
40
  "focus-trap": "6.9.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.204.1",
46
+ "@patternfly/patternfly": "4.204.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": "ff8f9ebc9ddd58da42246f9b87ea392ef2245285"
63
+ "gitHead": "aaeb37eb17dd5180aaa6ac3548fd4ac52c2a6eb7"
64
64
  }
@@ -64,13 +64,20 @@ const yearFormat = (date: Date) => date.getFullYear();
64
64
 
65
65
  const buildCalendar = (year: number, month: number, weekStart: number, validators: ((date: Date) => boolean)[]) => {
66
66
  const defaultDate = new Date(year, month);
67
+
67
68
  const firstDayOfWeek = new Date(defaultDate);
68
69
  firstDayOfWeek.setDate(firstDayOfWeek.getDate() - firstDayOfWeek.getDay() + weekStart);
70
+
69
71
  // We will show a maximum of 6 weeks like Google calendar
70
72
  // Assume we just want the numbers for now...
71
73
  const calendarWeeks = [];
74
+
75
+ if (firstDayOfWeek.getMonth() === defaultDate.getMonth() && firstDayOfWeek.getDate() !== 1) {
76
+ firstDayOfWeek.setDate(firstDayOfWeek.getDate() - 7);
77
+ }
72
78
  for (let i = 0; i < 6; i++) {
73
79
  const week = [];
80
+
74
81
  for (let j = 0; j < 7; j++) {
75
82
  const date = new Date(firstDayOfWeek);
76
83
  week.push({
@@ -338,7 +345,9 @@ export const CalendarMonth = ({
338
345
  tabIndex={isFocused ? 0 : -1}
339
346
  disabled={!isValid}
340
347
  aria-label={
341
- cellAriaLabel ? cellAriaLabel(date) : `${dayFormatted} ${monthFormatted} ${yearFormatted}`
348
+ cellAriaLabel
349
+ ? cellAriaLabel(date)
350
+ : `${dayFormat(date)} ${monthFormat(date)} ${yearFormat(date)}`
342
351
  }
343
352
  {...(isFocused && { ref: focusRef })}
344
353
  >
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+
3
+ import { render, screen } from '@testing-library/react';
4
+
5
+ import { CalendarMonth } from '../CalendarMonth';
6
+
7
+ test('Renders the first date in a month when a custom weekStart is passed', () => {
8
+ // custom aria label generation function because of bug with default aria label generation
9
+ // can be removed once the bug is fixed
10
+ const formatAria = (date: Date) =>
11
+ `${date.getDate()} ${date.toLocaleDateString(undefined, { month: 'long' })} ${date.getFullYear()}`;
12
+
13
+ render(<CalendarMonth cellAriaLabel={formatAria} weekStart={1} date={new Date(2023, 0)} />);
14
+
15
+ const firstDate = screen.getByRole('button', { name: '1 January 2023' });
16
+ expect(firstDate).toBeVisible();
17
+ });
18
+
19
+ test('Renders the last date in a month when a custom weekStart is passed', () => {
20
+ // custom aria label generation function because of bug with default aria labels
21
+ // can be removed once the bug is fixed
22
+ const formatAria = (date: Date) =>
23
+ `${date.getDate()} ${date.toLocaleDateString(undefined, { month: 'long' })} ${date.getFullYear()}`;
24
+
25
+ render(<CalendarMonth cellAriaLabel={formatAria} weekStart={1} date={new Date(2023, 0)} />);
26
+
27
+ const lastDate = screen.getByRole('button', { name: '31 January 2023' });
28
+ expect(lastDate).toBeVisible();
29
+ });
30
+
31
+ test('Previous month dates have correct month in aria label', () => {
32
+ render(<CalendarMonth date={new Date(2024, 5)} />);
33
+
34
+ const previousMonthDate = screen.getByRole('button', { name: '31 May 2024' });
35
+ expect(previousMonthDate).toBeVisible();
36
+ });
37
+
38
+ test('Next month dates have correct month in aria label', () => {
39
+ render(<CalendarMonth date={new Date(2024, 6)} />);
40
+
41
+ const nextMonthDate = screen.getByRole('button', { name: '1 August 2024' });
42
+ expect(nextMonthDate).toBeVisible();
43
+ });
44
+
45
+ test('Previous year dates have correct year in aria label', () => {
46
+ render(<CalendarMonth date={new Date(2024, 0)} />);
47
+
48
+ const previousYearDate = screen.getByRole('button', { name: '31 December 2023' });
49
+ expect(previousYearDate).toBeVisible();
50
+ });
51
+
52
+ test('Next year dates have correct year in aria label', () => {
53
+ render(<CalendarMonth date={new Date(2024, 11)} />);
54
+
55
+ const nextYearDate = screen.getByRole('button', { name: '1 January 2025' });
56
+ expect(nextYearDate).toBeVisible();
57
+ });
@@ -297,41 +297,39 @@ export class Select extends React.Component<SelectProps & OUIAProps, SelectState
297
297
  this.setState({ viewMoreNextIndex: -1 });
298
298
  }
299
299
 
300
- if (this.props.variant === 'typeahead' || this.props.variant === 'typeaheadmulti') {
301
- const checkUpdatedChildren = (prevChildren: React.ReactElement[], currChildren: React.ReactElement[]) =>
302
- Array.from(prevChildren).some((prevChild: React.ReactElement, index: number) => {
303
- const prevChildProps = prevChild.props;
304
- const currChild = currChildren[index];
305
- const { props: currChildProps } = currChild;
306
-
307
- if (prevChildProps && currChildProps) {
308
- return (
309
- prevChildProps.value !== currChildProps.value ||
310
- prevChildProps.label !== currChildProps.label ||
311
- prevChildProps.isDisabled !== currChildProps.isDisabled ||
312
- prevChildProps.isPlaceholder !== currChildProps.isPlaceholder
313
- );
314
- } else {
315
- return prevChild !== currChild;
316
- }
317
- });
318
-
319
- const hasUpdatedChildren =
320
- prevProps.children.length !== this.props.children.length ||
321
- checkUpdatedChildren(prevProps.children, this.props.children) ||
322
- (this.props.isGrouped &&
323
- Array.from(prevProps.children).some(
324
- (prevChild: React.ReactElement, index: number) =>
325
- prevChild.type === SelectGroup &&
326
- prevChild.props.children &&
327
- this.props.children[index].props.children &&
328
- (prevChild.props.children.length !== this.props.children[index].props.children.length ||
329
- checkUpdatedChildren(prevChild.props.children, this.props.children[index].props.children))
330
- ));
331
-
332
- if (hasUpdatedChildren) {
333
- this.updateTypeAheadFilteredChildren(prevState.typeaheadInputValue || '', null);
334
- }
300
+ const checkUpdatedChildren = (prevChildren: React.ReactElement[], currChildren: React.ReactElement[]) =>
301
+ Array.from(prevChildren).some((prevChild: React.ReactElement, index: number) => {
302
+ const prevChildProps = prevChild.props;
303
+ const currChild = currChildren[index];
304
+ const { props: currChildProps } = currChild;
305
+
306
+ if (prevChildProps && currChildProps) {
307
+ return (
308
+ prevChildProps.value !== currChildProps.value ||
309
+ prevChildProps.label !== currChildProps.label ||
310
+ prevChildProps.isDisabled !== currChildProps.isDisabled ||
311
+ prevChildProps.isPlaceholder !== currChildProps.isPlaceholder
312
+ );
313
+ } else {
314
+ return prevChild !== currChild;
315
+ }
316
+ });
317
+
318
+ const hasUpdatedChildren =
319
+ prevProps.children.length !== this.props.children.length ||
320
+ checkUpdatedChildren(prevProps.children, this.props.children) ||
321
+ (this.props.isGrouped &&
322
+ Array.from(prevProps.children).some(
323
+ (prevChild: React.ReactElement, index: number) =>
324
+ prevChild.type === SelectGroup &&
325
+ prevChild.props.children &&
326
+ this.props.children[index].props.children &&
327
+ (prevChild.props.children.length !== this.props.children[index].props.children.length ||
328
+ checkUpdatedChildren(prevChild.props.children, this.props.children[index].props.children))
329
+ ));
330
+
331
+ if (hasUpdatedChildren) {
332
+ this.updateTypeAheadFilteredChildren(prevState.typeaheadInputValue || '', null);
335
333
  }
336
334
 
337
335
  // for menus with favorites,
@@ -12,7 +12,6 @@ import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-
12
12
  import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
13
13
  import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg';
14
14
  import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
15
- import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
16
15
 
17
16
  ## Demos
18
17
 
@@ -32,13 +31,10 @@ import {
32
31
  BreadcrumbItem,
33
32
  Button,
34
33
  ButtonVariant,
35
- Card,
36
- CardBody,
37
- Drawer,
38
- DrawerContent,
39
- DrawerContentBody,
40
34
  Dropdown,
41
35
  DropdownGroup,
36
+ DropdownPosition,
37
+ DropdownDirection,
42
38
  DropdownToggle,
43
39
  DropdownItem,
44
40
  DropdownSeparator,
@@ -46,8 +42,7 @@ import {
46
42
  EmptyStateBody,
47
43
  EmptyStateIcon,
48
44
  EmptyStatePrimary,
49
- Gallery,
50
- GalleryItem,
45
+ EmptyStateVariant,
51
46
  KebabToggle,
52
47
  Nav,
53
48
  NavItem,
@@ -79,7 +74,6 @@ import {
79
74
  ToolbarGroup,
80
75
  ToolbarContent
81
76
  } from '@patternfly/react-core';
82
- import { css } from '@patternfly/react-styles';
83
77
  import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
84
78
  import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
85
79
  import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
@@ -87,7 +81,7 @@ import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-
87
81
  import BarsIcon from '@patternfly/react-icons/dist/js/icons/bars-icon';
88
82
  import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg';
89
83
  import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
90
- import { Table, TableHeader, TableBody } from '@patternfly/react-table';
84
+ import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
91
85
 
92
86
  class BasicNotificationDrawer extends React.Component {
93
87
  constructor(props) {
@@ -548,13 +542,10 @@ import {
548
542
  BreadcrumbItem,
549
543
  Button,
550
544
  ButtonVariant,
551
- Card,
552
- CardBody,
553
- Drawer,
554
- DrawerContent,
555
- DrawerContentBody,
556
545
  Dropdown,
557
546
  DropdownGroup,
547
+ DropdownPosition,
548
+ DropdownDirection,
558
549
  DropdownToggle,
559
550
  DropdownItem,
560
551
  DropdownSeparator,
@@ -562,8 +553,7 @@ import {
562
553
  EmptyStateBody,
563
554
  EmptyStateIcon,
564
555
  EmptyStatePrimary,
565
- Gallery,
566
- GalleryItem,
556
+ EmptyStateVariant,
567
557
  KebabToggle,
568
558
  Nav,
569
559
  NavItem,
@@ -597,16 +587,14 @@ import {
597
587
  ToolbarGroup,
598
588
  ToolbarContent
599
589
  } from '@patternfly/react-core';
600
- import { css } from '@patternfly/react-styles';
601
590
  import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
602
591
  import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon';
603
- import AttentionBellIcon from '@patternfly/react-icons/dist/esm/icons/attention-bell-icon';
604
592
  import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon';
605
593
  import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon';
594
+ import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon';
606
595
  import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon';
607
596
  import imgBrand from '@patternfly/react-core/src/components/Brand/examples/pfLogo.svg';
608
597
  import imgAvatar from '@patternfly/react-core/src/components/Avatar/examples/avatarImg.svg';
609
- import { Table, TableHeader, TableBody } from '@patternfly/react-table';
610
598
 
611
599
  class GroupedNotificationDrawer extends React.Component {
612
600
  constructor(props) {