@patternfly/react-core 4.198.15 → 4.198.16

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 CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 4.198.16 (2022-03-04)
7
+
8
+ **Note:** Version bump only for package @patternfly/react-core
9
+
10
+
11
+
12
+
13
+
6
14
  ## 4.198.15 (2022-03-04)
7
15
 
8
16
  **Note:** Version bump only for package @patternfly/react-core
@@ -15953,78 +15953,6 @@ ul.pf-c-list {
15953
15953
  text-align: var(--pf-c-progress-stepper__step-description--TextAlign);
15954
15954
  }
15955
15955
 
15956
- .pf-c-radio {
15957
- --pf-c-radio--GridGap: var(--pf-global--spacer--xs) var(--pf-global--spacer--sm);
15958
- --pf-c-radio__label--disabled--Color: var(--pf-global--disabled-color--100);
15959
- --pf-c-radio__label--Color: var(--pf-global--Color--100);
15960
- --pf-c-radio__label--FontWeight: var(--pf-global--FontWeight--normal);
15961
- --pf-c-radio__label--FontSize: var(--pf-global--FontSize--md);
15962
- --pf-c-radio__label--LineHeight: var(--pf-global--LineHeight--sm);
15963
- --pf-c-radio__input--Height: var(--pf-c-radio__label--FontSize);
15964
- --pf-c-radio__input--MarginTop: calc(((var(--pf-c-radio__label--FontSize) * var(--pf-c-radio__label--LineHeight)) - var(--pf-c-radio__input--Height)) / 2);
15965
- --pf-c-radio__input--first-child--MarginLeft: 0.0625rem;
15966
- --pf-c-radio__input--last-child--MarginRight: 0.0625rem;
15967
- --pf-c-radio__description--FontSize: var(--pf-global--FontSize--sm);
15968
- --pf-c-radio__description--Color: var(--pf-global--Color--200);
15969
- --pf-c-radio__body--MarginTop: var(--pf-global--spacer--sm);
15970
- display: grid;
15971
- grid-template-columns: auto 1fr;
15972
- grid-gap: var(--pf-c-radio--GridGap);
15973
- align-items: start;
15974
- justify-items: start;
15975
- }
15976
-
15977
- .pf-c-radio.pf-m-standalone {
15978
- --pf-c-radio--GridGap: 0;
15979
- --pf-c-radio__input--Height: auto;
15980
- --pf-c-radio__input--MarginTop: 0;
15981
- display: inline-grid;
15982
- line-height: 1;
15983
- }
15984
-
15985
- .pf-c-radio__label {
15986
- font-size: var(--pf-c-radio__label--FontSize);
15987
- font-weight: var(--pf-c-radio__label--FontWeight);
15988
- line-height: var(--pf-c-radio__label--LineHeight);
15989
- color: var(--pf-c-radio__label--Color);
15990
- }
15991
-
15992
- .pf-c-radio__input {
15993
- height: var(--pf-c-radio__input--Height);
15994
- margin-top: var(--pf-c-radio__input--MarginTop);
15995
- }
15996
-
15997
- .pf-c-radio__input:first-child {
15998
- margin-left: var(--pf-c-radio__input--first-child--MarginLeft);
15999
- }
16000
-
16001
- .pf-c-radio__input:last-child {
16002
- margin-right: var(--pf-c-radio__input--last-child--MarginRight);
16003
- }
16004
-
16005
- .pf-c-radio__description {
16006
- grid-column: 2;
16007
- font-size: var(--pf-c-radio__description--FontSize);
16008
- color: var(--pf-c-radio__description--Color);
16009
- }
16010
-
16011
- .pf-c-radio__body {
16012
- grid-column: 2;
16013
- margin-top: var(--pf-c-radio__body--MarginTop);
16014
- }
16015
-
16016
- label.pf-c-radio, .pf-c-radio__label,
16017
- .pf-c-radio__input {
16018
- cursor: pointer;
16019
- }
16020
-
16021
- .pf-c-radio__label:disabled, .pf-c-radio__label.pf-m-disabled,
16022
- .pf-c-radio__input:disabled,
16023
- .pf-c-radio__input.pf-m-disabled {
16024
- --pf-c-radio__label--Color: var(--pf-c-radio__label--disabled--Color);
16025
- cursor: not-allowed;
16026
- }
16027
-
16028
15956
  .pf-c-search-input {
16029
15957
  --pf-c-search-input__text--before--BorderWidth: var(--pf-global--BorderWidth--sm);
16030
15958
  --pf-c-search-input__text--before--BorderColor: var(--pf-global--BorderColor--300);
@@ -16216,6 +16144,78 @@ label.pf-c-radio, .pf-c-radio__label,
16216
16144
  flex-grow: 1;
16217
16145
  }
16218
16146
 
16147
+ .pf-c-radio {
16148
+ --pf-c-radio--GridGap: var(--pf-global--spacer--xs) var(--pf-global--spacer--sm);
16149
+ --pf-c-radio__label--disabled--Color: var(--pf-global--disabled-color--100);
16150
+ --pf-c-radio__label--Color: var(--pf-global--Color--100);
16151
+ --pf-c-radio__label--FontWeight: var(--pf-global--FontWeight--normal);
16152
+ --pf-c-radio__label--FontSize: var(--pf-global--FontSize--md);
16153
+ --pf-c-radio__label--LineHeight: var(--pf-global--LineHeight--sm);
16154
+ --pf-c-radio__input--Height: var(--pf-c-radio__label--FontSize);
16155
+ --pf-c-radio__input--MarginTop: calc(((var(--pf-c-radio__label--FontSize) * var(--pf-c-radio__label--LineHeight)) - var(--pf-c-radio__input--Height)) / 2);
16156
+ --pf-c-radio__input--first-child--MarginLeft: 0.0625rem;
16157
+ --pf-c-radio__input--last-child--MarginRight: 0.0625rem;
16158
+ --pf-c-radio__description--FontSize: var(--pf-global--FontSize--sm);
16159
+ --pf-c-radio__description--Color: var(--pf-global--Color--200);
16160
+ --pf-c-radio__body--MarginTop: var(--pf-global--spacer--sm);
16161
+ display: grid;
16162
+ grid-template-columns: auto 1fr;
16163
+ grid-gap: var(--pf-c-radio--GridGap);
16164
+ align-items: start;
16165
+ justify-items: start;
16166
+ }
16167
+
16168
+ .pf-c-radio.pf-m-standalone {
16169
+ --pf-c-radio--GridGap: 0;
16170
+ --pf-c-radio__input--Height: auto;
16171
+ --pf-c-radio__input--MarginTop: 0;
16172
+ display: inline-grid;
16173
+ line-height: 1;
16174
+ }
16175
+
16176
+ .pf-c-radio__label {
16177
+ font-size: var(--pf-c-radio__label--FontSize);
16178
+ font-weight: var(--pf-c-radio__label--FontWeight);
16179
+ line-height: var(--pf-c-radio__label--LineHeight);
16180
+ color: var(--pf-c-radio__label--Color);
16181
+ }
16182
+
16183
+ .pf-c-radio__input {
16184
+ height: var(--pf-c-radio__input--Height);
16185
+ margin-top: var(--pf-c-radio__input--MarginTop);
16186
+ }
16187
+
16188
+ .pf-c-radio__input:first-child {
16189
+ margin-left: var(--pf-c-radio__input--first-child--MarginLeft);
16190
+ }
16191
+
16192
+ .pf-c-radio__input:last-child {
16193
+ margin-right: var(--pf-c-radio__input--last-child--MarginRight);
16194
+ }
16195
+
16196
+ .pf-c-radio__description {
16197
+ grid-column: 2;
16198
+ font-size: var(--pf-c-radio__description--FontSize);
16199
+ color: var(--pf-c-radio__description--Color);
16200
+ }
16201
+
16202
+ .pf-c-radio__body {
16203
+ grid-column: 2;
16204
+ margin-top: var(--pf-c-radio__body--MarginTop);
16205
+ }
16206
+
16207
+ label.pf-c-radio, .pf-c-radio__label,
16208
+ .pf-c-radio__input {
16209
+ cursor: pointer;
16210
+ }
16211
+
16212
+ .pf-c-radio__label:disabled, .pf-c-radio__label.pf-m-disabled,
16213
+ .pf-c-radio__input:disabled,
16214
+ .pf-c-radio__input.pf-m-disabled {
16215
+ --pf-c-radio__label--Color: var(--pf-c-radio__label--disabled--Color);
16216
+ cursor: not-allowed;
16217
+ }
16218
+
16219
16219
  .pf-c-select {
16220
16220
  --pf-global--Color--100: var(--pf-global--Color--dark-100);
16221
16221
  --pf-global--Color--200: var(--pf-global--Color--dark-200);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.198.15",
3
+ "version": "4.198.16",
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.49.15",
38
- "@patternfly/react-styles": "^4.48.15",
39
- "@patternfly/react-tokens": "^4.50.15",
37
+ "@patternfly/react-icons": "^4.49.16",
38
+ "@patternfly/react-styles": "^4.48.16",
39
+ "@patternfly/react-tokens": "^4.50.16",
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": "16259ba437f75ad2818da8ff55a1994340971e26"
63
+ "gitHead": "752c9d1a3638f356f2e68f670e79356f03ebea8e"
64
64
  }
@@ -28,31 +28,26 @@ Composable menus currently require consumer keyboard handling and use of our und
28
28
  ### Composable simple dropdown
29
29
 
30
30
  ```ts file="./examples/ComposableSimpleDropdown.tsx"
31
-
32
31
  ```
33
32
 
34
33
  ### Composable actions menu
35
34
 
36
35
  ```ts file="./examples/ComposableActionsMenu.tsx"
37
-
38
36
  ```
39
37
 
40
38
  ### Composable simple select
41
39
 
42
40
  ```ts file="./examples/ComposableSimpleSelect.tsx"
43
-
44
41
  ```
45
42
 
46
43
  ### Composable drilldown menu
47
44
 
48
45
  ```ts isBeta file="./examples/ComposableDrilldownMenu.tsx"
49
-
50
46
  ```
51
47
 
52
48
  ### Composable tree view menu
53
49
 
54
50
  ```ts file="./examples/ComposableTreeViewMenu.tsx"
55
-
56
51
  ```
57
52
 
58
53
  ### Composable flyout
@@ -60,29 +55,29 @@ Composable menus currently require consumer keyboard handling and use of our und
60
55
  The flyout will automatically position to the left or top if it would otherwise go outside the window. The menu must be placed in a container outside the main content like Popper, [Popover](/components/popover) or [Tooltip](/components/tooltip) since it may go over the side nav.
61
56
 
62
57
  ```ts isBeta file="./examples/ComposableFlyout.tsx"
63
-
64
58
  ```
65
59
 
66
60
  ### Composable application launcher
67
61
 
68
62
  ```ts file="./examples/ComposableApplicationLauncher.tsx"
69
-
70
63
  ```
71
64
 
72
65
  ### Composable context selector
73
66
 
74
67
  ```ts file="./examples/ComposableContextSelector.tsx"
75
-
76
68
  ```
77
69
 
78
70
  ### Composable options menu variants
79
71
 
80
72
  ```ts file="./examples/ComposableOptionsMenuVariants.tsx"
81
-
82
73
  ```
83
74
 
84
75
  ### Composable dropdown variants
85
76
 
86
77
  ```ts file="./examples/ComposableDropdwnVariants.tsx"
78
+ ```
79
+
80
+ ### Composable date select
87
81
 
82
+ ```ts file="./examples/ComposableDateSelect.tsx"
88
83
  ```
@@ -0,0 +1,113 @@
1
+ import React from 'react';
2
+ import { MenuToggle, Menu, MenuContent, MenuList, MenuItem, Popper } from '@patternfly/react-core';
3
+
4
+ export const ComposableSimpleDropdown: React.FunctionComponent = () => {
5
+ const [isOpen, setIsOpen] = React.useState(false);
6
+ const toggleRef = React.useRef<HTMLButtonElement>();
7
+ const menuRef = React.useRef<HTMLDivElement>();
8
+ const [selected, setSelected] = React.useState<number>(0);
9
+
10
+ const handleMenuKeys = (event: KeyboardEvent) => {
11
+ if (!isOpen) {
12
+ return;
13
+ }
14
+ if (menuRef.current.contains(event.target as Node) || toggleRef.current.contains(event.target as Node)) {
15
+ if (event.key === 'Escape' || event.key === 'Tab') {
16
+ setIsOpen(!isOpen);
17
+ toggleRef.current.focus();
18
+ }
19
+ }
20
+ };
21
+
22
+ const handleClickOutside = (event: MouseEvent) => {
23
+ if (isOpen && !menuRef.current.contains(event.target as Node)) {
24
+ setIsOpen(false);
25
+ }
26
+ };
27
+
28
+ React.useEffect(() => {
29
+ window.addEventListener('keydown', handleMenuKeys);
30
+ window.addEventListener('click', handleClickOutside);
31
+ return () => {
32
+ window.removeEventListener('keydown', handleMenuKeys);
33
+ window.removeEventListener('click', handleClickOutside);
34
+ };
35
+ }, [isOpen, menuRef]);
36
+
37
+ const onToggleClick = (ev: React.MouseEvent) => {
38
+ ev.stopPropagation(); // Stop handleClickOutside from handling
39
+ setTimeout(() => {
40
+ if (menuRef.current) {
41
+ const firstElement = menuRef.current.querySelector('li > button:not(:disabled)');
42
+ firstElement && (firstElement as HTMLElement).focus();
43
+ }
44
+ }, 0);
45
+ setIsOpen(!isOpen);
46
+ };
47
+
48
+ const monthStrings = [
49
+ 'January',
50
+ 'February',
51
+ 'March',
52
+ 'April',
53
+ 'May',
54
+ 'June',
55
+ 'July',
56
+ 'August',
57
+ 'September',
58
+ 'October',
59
+ 'November',
60
+ 'December'
61
+ ];
62
+
63
+ const dateString = (date: Date) => `${monthStrings[date.getMonth()]} ${date.getDate()}, ${date.getFullYear()}`;
64
+
65
+ const date = new Date();
66
+
67
+ const toggleText = {
68
+ 0: 'Today ',
69
+ 1: 'Yesterday ',
70
+ 2: 'Last 7 days ',
71
+ 3: 'Last 14 days '
72
+ };
73
+
74
+ const dateText = {
75
+ 0: <small className="pf-u-color-200">({dateString(date)})</small>,
76
+ 1: (
77
+ <small className="pf-u-color-200">
78
+ ({dateString(new Date(new Date().setDate(date.getDate() - 1)))} - {dateString(date)})
79
+ </small>
80
+ ),
81
+ 2: (
82
+ <small className="pf-u-color-200">
83
+ ({dateString(new Date(new Date().setDate(date.getDate() - 7)))} - {dateString(date)})
84
+ </small>
85
+ ),
86
+ 3: (
87
+ <small className="pf-u-color-200">
88
+ ({dateString(new Date(new Date().setDate(date.getDate() - 14)))} - {dateString(date)})
89
+ </small>
90
+ )
91
+ };
92
+
93
+ const toggle = (
94
+ <MenuToggle ref={toggleRef} onClick={onToggleClick} isExpanded={isOpen} style={{ minWidth: '250px' }}>
95
+ <span style={{ verticalAlign: 'middle', marginRight: '8px' }}>{toggleText[selected]}</span>
96
+ {dateText[selected]}
97
+ </MenuToggle>
98
+ );
99
+ const menu = (
100
+ // eslint-disable-next-line no-console
101
+ <Menu ref={menuRef} onSelect={(_ev, itemId) => setSelected(itemId as number)} selected={selected}>
102
+ <MenuContent>
103
+ <MenuList>
104
+ <MenuItem itemId={0}>Today</MenuItem>
105
+ <MenuItem itemId={1}>Yesterday</MenuItem>
106
+ <MenuItem itemId={2}>Last 7 days</MenuItem>
107
+ <MenuItem itemId={3}>Last 14 days</MenuItem>
108
+ </MenuList>
109
+ </MenuContent>
110
+ </Menu>
111
+ );
112
+ return <Popper trigger={toggle} popper={menu} isVisible={isOpen} popperMatchesTriggerWidth={false} />;
113
+ };