@patternfly/react-core 5.1.1-prerelease.17 → 5.1.1-prerelease.19
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 +17 -0
- package/components/package.json +1 -1
- package/deprecated/package.json +1 -1
- package/dist/dynamic/components/AboutModal/package.json +1 -1
- package/dist/dynamic/components/Accordion/package.json +1 -1
- package/dist/dynamic/components/ActionList/package.json +1 -1
- package/dist/dynamic/components/Alert/package.json +1 -1
- package/dist/dynamic/components/Avatar/package.json +1 -1
- package/dist/dynamic/components/BackToTop/package.json +1 -1
- package/dist/dynamic/components/Backdrop/package.json +1 -1
- package/dist/dynamic/components/BackgroundImage/package.json +1 -1
- package/dist/dynamic/components/Badge/package.json +1 -1
- package/dist/dynamic/components/Banner/package.json +1 -1
- package/dist/dynamic/components/Brand/package.json +1 -1
- package/dist/dynamic/components/Breadcrumb/package.json +1 -1
- package/dist/dynamic/components/Button/package.json +1 -1
- package/dist/dynamic/components/CalendarMonth/package.json +1 -1
- package/dist/dynamic/components/Card/package.json +1 -1
- package/dist/dynamic/components/Checkbox/package.json +1 -1
- package/dist/dynamic/components/Chip/package.json +1 -1
- package/dist/dynamic/components/ClipboardCopy/package.json +1 -1
- package/dist/dynamic/components/CodeBlock/package.json +1 -1
- package/dist/dynamic/components/DataList/package.json +1 -1
- package/dist/dynamic/components/DatePicker/package.json +1 -1
- package/dist/dynamic/components/DescriptionList/package.json +1 -1
- package/dist/dynamic/components/Divider/package.json +1 -1
- package/dist/dynamic/components/DragDrop/package.json +1 -1
- package/dist/dynamic/components/Drawer/package.json +1 -1
- package/dist/dynamic/components/Dropdown/package.json +1 -1
- package/dist/dynamic/components/DualListSelector/package.json +1 -1
- package/dist/dynamic/components/EmptyState/package.json +1 -1
- package/dist/dynamic/components/ExpandableSection/package.json +1 -1
- package/dist/dynamic/components/FileUpload/package.json +1 -1
- package/dist/dynamic/components/Form/package.json +1 -1
- package/dist/dynamic/components/FormSelect/package.json +1 -1
- package/dist/dynamic/components/HelperText/package.json +1 -1
- package/dist/dynamic/components/Hint/package.json +1 -1
- package/dist/dynamic/components/Icon/package.json +1 -1
- package/dist/dynamic/components/InputGroup/package.json +1 -1
- package/dist/dynamic/components/JumpLinks/package.json +1 -1
- package/dist/dynamic/components/Label/package.json +1 -1
- package/dist/dynamic/components/List/package.json +1 -1
- package/dist/dynamic/components/LoginPage/package.json +1 -1
- package/dist/dynamic/components/Masthead/package.json +1 -1
- package/dist/dynamic/components/Menu/package.json +1 -1
- package/dist/dynamic/components/MenuToggle/package.json +1 -1
- package/dist/dynamic/components/Modal/package.json +1 -1
- package/dist/dynamic/components/MultipleFileUpload/package.json +1 -1
- package/dist/dynamic/components/Nav/package.json +1 -1
- package/dist/dynamic/components/NotificationBadge/package.json +1 -1
- package/dist/dynamic/components/NotificationDrawer/package.json +1 -1
- package/dist/dynamic/components/NumberInput/package.json +1 -1
- package/dist/dynamic/components/OverflowMenu/package.json +1 -1
- package/dist/dynamic/components/Page/package.json +1 -1
- package/dist/dynamic/components/Pagination/package.json +1 -1
- package/dist/dynamic/components/Panel/package.json +1 -1
- package/dist/dynamic/components/Popover/package.json +1 -1
- package/dist/dynamic/components/Progress/package.json +1 -1
- package/dist/dynamic/components/ProgressStepper/package.json +1 -1
- package/dist/dynamic/components/Radio/package.json +1 -1
- package/dist/dynamic/components/SearchInput/package.json +1 -1
- package/dist/dynamic/components/Select/package.json +1 -1
- package/dist/dynamic/components/Sidebar/package.json +1 -1
- package/dist/dynamic/components/SimpleList/package.json +1 -1
- package/dist/dynamic/components/Skeleton/package.json +1 -1
- package/dist/dynamic/components/SkipToContent/package.json +1 -1
- package/dist/dynamic/components/Slider/package.json +1 -1
- package/dist/dynamic/components/Spinner/package.json +1 -1
- package/dist/dynamic/components/Switch/package.json +1 -1
- package/dist/dynamic/components/Tabs/package.json +1 -1
- package/dist/dynamic/components/Text/package.json +1 -1
- package/dist/dynamic/components/TextArea/package.json +1 -1
- package/dist/dynamic/components/TextInput/package.json +1 -1
- package/dist/dynamic/components/TextInputGroup/package.json +1 -1
- package/dist/dynamic/components/Tile/package.json +1 -1
- package/dist/dynamic/components/TimePicker/package.json +1 -1
- package/dist/dynamic/components/Timestamp/package.json +1 -1
- package/dist/dynamic/components/Title/package.json +1 -1
- package/dist/dynamic/components/ToggleGroup/package.json +1 -1
- package/dist/dynamic/components/Toolbar/package.json +1 -1
- package/dist/dynamic/components/Tooltip/package.json +1 -1
- package/dist/dynamic/components/TreeView/package.json +1 -1
- package/dist/dynamic/components/Truncate/package.json +1 -1
- package/dist/dynamic/components/Wizard/hooks/package.json +1 -1
- package/dist/dynamic/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/ApplicationLauncher/package.json +1 -1
- package/dist/dynamic/deprecated/components/ContextSelector/package.json +1 -1
- package/dist/dynamic/deprecated/components/Dropdown/package.json +1 -1
- package/dist/dynamic/deprecated/components/OptionsMenu/package.json +1 -1
- package/dist/dynamic/deprecated/components/PageHeader/package.json +1 -1
- package/dist/dynamic/deprecated/components/Select/package.json +1 -1
- package/dist/dynamic/deprecated/components/Wizard/package.json +1 -1
- package/dist/dynamic/deprecated/components/package.json +1 -1
- package/dist/dynamic/helpers/FocusTrap/FocusTrap/package.json +1 -1
- package/dist/dynamic/helpers/GenerateId/GenerateId/package.json +1 -1
- package/dist/dynamic/helpers/KeyboardHandler/package.json +1 -1
- package/dist/dynamic/helpers/OUIA/ouia/package.json +1 -1
- package/dist/dynamic/helpers/Popper/Popper/package.json +1 -1
- package/dist/dynamic/helpers/constants/package.json +1 -1
- package/dist/dynamic/helpers/datetimeUtils/package.json +1 -1
- package/dist/dynamic/helpers/favorites/package.json +1 -1
- package/dist/dynamic/helpers/fileUtils/package.json +1 -1
- package/dist/dynamic/helpers/htmlConstants/package.json +1 -1
- package/dist/dynamic/helpers/package.json +1 -1
- package/dist/dynamic/helpers/resizeObserver/package.json +1 -1
- package/dist/dynamic/helpers/typeUtils/package.json +1 -1
- package/dist/dynamic/helpers/useInterval/package.json +1 -1
- package/dist/dynamic/helpers/useIsomorphicLayout/package.json +1 -1
- package/dist/dynamic/helpers/useUnmountEffect/package.json +1 -1
- package/dist/dynamic/helpers/util/package.json +1 -1
- package/dist/dynamic/layouts/Bullseye/package.json +1 -1
- package/dist/dynamic/layouts/Flex/package.json +1 -1
- package/dist/dynamic/layouts/Gallery/package.json +1 -1
- package/dist/dynamic/layouts/Grid/package.json +1 -1
- package/dist/dynamic/layouts/Level/package.json +1 -1
- package/dist/dynamic/layouts/Split/package.json +1 -1
- package/dist/dynamic/layouts/Stack/package.json +1 -1
- package/dist/dynamic/next/components/package.json +1 -1
- package/dist/esm/components/Dropdown/Dropdown.d.ts +3 -1
- package/dist/esm/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/esm/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/esm/components/Menu/MenuContainer.d.ts +1 -1
- package/dist/esm/components/Menu/MenuContainer.d.ts.map +1 -1
- package/dist/esm/components/Select/Select.d.ts +1 -1
- package/dist/esm/components/Select/Select.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.d.ts +11 -6
- package/dist/esm/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/esm/components/Tabs/Tabs.js +35 -16
- package/dist/esm/components/Tabs/Tabs.js.map +1 -1
- package/dist/esm/components/Timestamp/Timestamp.d.ts +4 -0
- package/dist/esm/components/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/esm/components/Timestamp/Timestamp.js +7 -4
- package/dist/esm/components/Timestamp/Timestamp.js.map +1 -1
- package/dist/esm/helpers/Popper/Popper.d.ts +2 -1
- package/dist/esm/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/esm/helpers/Popper/Popper.js +27 -5
- package/dist/esm/helpers/Popper/Popper.js.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.d.ts +3 -1
- package/dist/js/components/Dropdown/Dropdown.d.ts.map +1 -1
- package/dist/js/components/Dropdown/Dropdown.js.map +1 -1
- package/dist/js/components/Menu/MenuContainer.d.ts +1 -1
- package/dist/js/components/Menu/MenuContainer.d.ts.map +1 -1
- package/dist/js/components/Select/Select.d.ts +1 -1
- package/dist/js/components/Select/Select.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.d.ts +11 -6
- package/dist/js/components/Tabs/Tabs.d.ts.map +1 -1
- package/dist/js/components/Tabs/Tabs.js +35 -16
- package/dist/js/components/Tabs/Tabs.js.map +1 -1
- package/dist/js/components/Timestamp/Timestamp.d.ts +4 -0
- package/dist/js/components/Timestamp/Timestamp.d.ts.map +1 -1
- package/dist/js/components/Timestamp/Timestamp.js +7 -4
- package/dist/js/components/Timestamp/Timestamp.js.map +1 -1
- package/dist/js/helpers/Popper/Popper.d.ts +2 -1
- package/dist/js/helpers/Popper/Popper.d.ts.map +1 -1
- package/dist/js/helpers/Popper/Popper.js +29 -6
- package/dist/js/helpers/Popper/Popper.js.map +1 -1
- package/dist/umd/react-core.min.js +3 -3
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +6 -6
- package/src/components/Dropdown/Dropdown.tsx +3 -1
- package/src/components/Menu/MenuContainer.tsx +1 -1
- package/src/components/Select/Select.tsx +1 -1
- package/src/components/Tabs/Tabs.tsx +50 -26
- package/src/components/Timestamp/Timestamp.tsx +12 -3
- package/src/components/Timestamp/__tests__/Timestamp.test.tsx +6 -0
- package/src/components/Timestamp/examples/Timestamp.md +8 -0
- package/src/components/Timestamp/examples/TimestampDefault.tsx +7 -1
- package/src/components/Timestamp/examples/TimestampDefaultTooltip.tsx +1 -1
- package/src/helpers/Popper/Popper.tsx +43 -6
package/helpers/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.1.1-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-helpers","main":"../dist/js/helpers/index.js","module":"../dist/esm/helpers/index.js","typings":"../dist/esm/helpers/index.d.ts","version":"5.1.1-prerelease.18","private":true}
|
package/layouts/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.1.1-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-layouts","main":"../dist/js/layouts/index.js","module":"../dist/esm/layouts/index.js","typings":"../dist/esm/layouts/index.d.ts","version":"5.1.1-prerelease.18","private":true}
|
package/next/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.1.1-prerelease.
|
|
1
|
+
{"name":"@patternfly/react-core-next","main":"../dist/js/next/index.js","module":"../dist/esm/next/index.js","typings":"../dist/esm/next/index.d.ts","version":"5.1.1-prerelease.18","private":true}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@patternfly/react-core",
|
|
3
|
-
"version": "5.1.1-prerelease.
|
|
3
|
+
"version": "5.1.1-prerelease.19",
|
|
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",
|
|
@@ -45,15 +45,15 @@
|
|
|
45
45
|
"subpaths": "node ../../scripts/exportSubpaths.js --config subpaths.config.json"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@patternfly/react-icons": "^5.1.1-prerelease.
|
|
49
|
-
"@patternfly/react-styles": "^5.1.1-prerelease.
|
|
50
|
-
"@patternfly/react-tokens": "^5.1.1-prerelease.
|
|
48
|
+
"@patternfly/react-icons": "^5.1.1-prerelease.7",
|
|
49
|
+
"@patternfly/react-styles": "^5.1.1-prerelease.7",
|
|
50
|
+
"@patternfly/react-tokens": "^5.1.1-prerelease.7",
|
|
51
51
|
"focus-trap": "7.5.2",
|
|
52
52
|
"react-dropzone": "^14.2.3",
|
|
53
53
|
"tslib": "^2.5.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@patternfly/patternfly": "5.1.0-prerelease.
|
|
56
|
+
"@patternfly/patternfly": "5.1.0-prerelease.32",
|
|
57
57
|
"@rollup/plugin-commonjs": "^25.0.0",
|
|
58
58
|
"@rollup/plugin-node-resolve": "^15.0.2",
|
|
59
59
|
"@rollup/plugin-replace": "^5.0.2",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^17 || ^18",
|
|
71
71
|
"react-dom": "^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "262e474df57437fead3a7c4e995a96c68eb8f9ef"
|
|
74
74
|
}
|
|
@@ -8,7 +8,7 @@ export interface DropdownPopperProps {
|
|
|
8
8
|
/** Vertical direction of the popper. If enableFlip is set to true, this will set the initial direction before the popper flips. */
|
|
9
9
|
direction?: 'up' | 'down';
|
|
10
10
|
/** Horizontal position of the popper */
|
|
11
|
-
position?: 'right' | 'left' | 'center';
|
|
11
|
+
position?: 'right' | 'left' | 'center' | 'start' | 'end';
|
|
12
12
|
/** Custom width of the popper. If the value is "trigger", it will set the width to the dropdown toggle's width */
|
|
13
13
|
width?: string | 'trigger';
|
|
14
14
|
/** Minimum width of the popper. If the value is "trigger", it will set the min width to the dropdown toggle's width */
|
|
@@ -17,6 +17,8 @@ export interface DropdownPopperProps {
|
|
|
17
17
|
maxWidth?: string | 'trigger';
|
|
18
18
|
/** Enable to flip the popper when it reaches the boundary */
|
|
19
19
|
enableFlip?: boolean;
|
|
20
|
+
/** The container to append the popper to. Defaults to 'inline'. */
|
|
21
|
+
appendTo?: HTMLElement | (() => HTMLElement) | 'inline';
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export interface DropdownToggleProps {
|
|
@@ -5,7 +5,7 @@ export interface MenuPopperProps {
|
|
|
5
5
|
/** Vertical direction of the popper. If enableFlip is set to true, this will set the initial direction before the popper flips. */
|
|
6
6
|
direction?: 'up' | 'down';
|
|
7
7
|
/** Horizontal position of the popper */
|
|
8
|
-
position?: 'right' | 'left' | 'center';
|
|
8
|
+
position?: 'right' | 'left' | 'center' | 'start' | 'end';
|
|
9
9
|
/** Custom width of the popper. If the value is "trigger", it will set the width to the dropdown toggle's width */
|
|
10
10
|
width?: string | 'trigger';
|
|
11
11
|
/** Minimum width of the popper. If the value is "trigger", it will set the min width to the dropdown toggle's width */
|
|
@@ -8,7 +8,7 @@ export interface SelectPopperProps {
|
|
|
8
8
|
/** Vertical direction of the popper. If enableFlip is set to true, this will set the initial direction before the popper flips. */
|
|
9
9
|
direction?: 'up' | 'down';
|
|
10
10
|
/** Horizontal position of the popper */
|
|
11
|
-
position?: 'right' | 'left' | 'center';
|
|
11
|
+
position?: 'right' | 'left' | 'center' | 'start' | 'end';
|
|
12
12
|
/** Custom width of the popper. If the value is "trigger", it will set the width to the select toggle's width */
|
|
13
13
|
width?: string | 'trigger';
|
|
14
14
|
/** Minimum width of the popper. If the value is "trigger", it will set the min width to the select toggle's width */
|
|
@@ -63,10 +63,14 @@ export interface TabsProps extends Omit<React.HTMLProps<HTMLElement | HTMLDivEle
|
|
|
63
63
|
isVertical?: boolean;
|
|
64
64
|
/** Disables border bottom tab styling on tabs. Defaults to false. To remove the bottom border, set this prop to true. */
|
|
65
65
|
hasNoBorderBottom?: boolean;
|
|
66
|
-
/** Aria-label for the left scroll button */
|
|
66
|
+
/** @deprecated Please use backScrollAriaLabel. Aria-label for the left scroll button */
|
|
67
67
|
leftScrollAriaLabel?: string;
|
|
68
|
-
/** Aria-label for the right scroll button */
|
|
68
|
+
/** @deprecated Please use forwardScrollAriaLabel. Aria-label for the right scroll button */
|
|
69
69
|
rightScrollAriaLabel?: string;
|
|
70
|
+
/** Aria-label for the back scroll button */
|
|
71
|
+
backScrollAriaLabel?: string;
|
|
72
|
+
/** Aria-label for the forward scroll button */
|
|
73
|
+
forwardScrollAriaLabel?: string;
|
|
70
74
|
/** Determines what tag is used around the tabs. Use "nav" to define the tabs inside a navigation region */
|
|
71
75
|
component?: 'div' | 'nav';
|
|
72
76
|
/** Provides an accessible label for the tabs. Labels should be unique for each set of tabs that are present on a page. When component is set to nav, this prop should be defined to differentiate the tabs from other navigation regions on the page. */
|
|
@@ -127,8 +131,8 @@ interface TabsState {
|
|
|
127
131
|
* shown and rendering must be stopped after they stop being shown to preserve CSS transitions.
|
|
128
132
|
*/
|
|
129
133
|
renderScrollButtons: boolean;
|
|
130
|
-
|
|
131
|
-
|
|
134
|
+
disableBackScrollButton: boolean;
|
|
135
|
+
disableForwardScrollButton: boolean;
|
|
132
136
|
shownKeys: (string | number)[];
|
|
133
137
|
uncontrolledActiveKey: number | string;
|
|
134
138
|
uncontrolledIsExpandedLocal: boolean;
|
|
@@ -140,14 +144,15 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
140
144
|
static displayName = 'Tabs';
|
|
141
145
|
tabList = React.createRef<HTMLUListElement>();
|
|
142
146
|
leftScrollButtonRef = React.createRef<HTMLButtonElement>();
|
|
147
|
+
private direction = 'ltr';
|
|
143
148
|
constructor(props: TabsProps) {
|
|
144
149
|
super(props);
|
|
145
150
|
this.state = {
|
|
146
151
|
enableScrollButtons: false,
|
|
147
152
|
showScrollButtons: false,
|
|
148
153
|
renderScrollButtons: false,
|
|
149
|
-
|
|
150
|
-
|
|
154
|
+
disableBackScrollButton: true,
|
|
155
|
+
disableForwardScrollButton: true,
|
|
151
156
|
shownKeys: this.props.defaultActiveKey !== undefined ? [this.props.defaultActiveKey] : [this.props.activeKey], // only for mountOnEnter case
|
|
152
157
|
uncontrolledActiveKey: this.props.defaultActiveKey,
|
|
153
158
|
uncontrolledIsExpandedLocal: this.props.defaultIsExpanded,
|
|
@@ -177,7 +182,9 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
177
182
|
isBox: false,
|
|
178
183
|
hasNoBorderBottom: false,
|
|
179
184
|
leftScrollAriaLabel: 'Scroll left',
|
|
185
|
+
backScrollAriaLabel: 'Scroll back',
|
|
180
186
|
rightScrollAriaLabel: 'Scroll right',
|
|
187
|
+
forwardScrollAriaLabel: 'Scroll forward',
|
|
181
188
|
component: TabsComponent.div,
|
|
182
189
|
mountOnEnter: false,
|
|
183
190
|
unmountOnExit: false,
|
|
@@ -232,8 +239,8 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
232
239
|
clearTimeout(this.scrollTimeout);
|
|
233
240
|
this.scrollTimeout = setTimeout(() => {
|
|
234
241
|
const container = this.tabList.current;
|
|
235
|
-
let
|
|
236
|
-
let
|
|
242
|
+
let disableBackScrollButton = true;
|
|
243
|
+
let disableForwardScrollButton = true;
|
|
237
244
|
let enableScrollButtons = false;
|
|
238
245
|
let overflowingTabCount = 0;
|
|
239
246
|
|
|
@@ -246,8 +253,8 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
246
253
|
|
|
247
254
|
enableScrollButtons = overflowOnLeft || overflowOnRight;
|
|
248
255
|
|
|
249
|
-
|
|
250
|
-
|
|
256
|
+
disableBackScrollButton = !overflowOnLeft;
|
|
257
|
+
disableForwardScrollButton = !overflowOnRight;
|
|
251
258
|
}
|
|
252
259
|
|
|
253
260
|
if (isOverflowHorizontal) {
|
|
@@ -256,14 +263,14 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
256
263
|
|
|
257
264
|
this.setState({
|
|
258
265
|
enableScrollButtons,
|
|
259
|
-
|
|
260
|
-
|
|
266
|
+
disableBackScrollButton,
|
|
267
|
+
disableForwardScrollButton,
|
|
261
268
|
overflowingTabCount
|
|
262
269
|
});
|
|
263
270
|
}, 100);
|
|
264
271
|
};
|
|
265
272
|
|
|
266
|
-
|
|
273
|
+
scrollBack = () => {
|
|
267
274
|
// find first Element that is fully in view on the left, then scroll to the element before it
|
|
268
275
|
if (this.tabList.current) {
|
|
269
276
|
const container = this.tabList.current;
|
|
@@ -278,12 +285,18 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
278
285
|
}
|
|
279
286
|
}
|
|
280
287
|
if (lastElementOutOfView) {
|
|
281
|
-
|
|
288
|
+
if (this.direction === 'ltr') {
|
|
289
|
+
// LTR scrolls left to go back
|
|
290
|
+
container.scrollLeft -= lastElementOutOfView.scrollWidth;
|
|
291
|
+
} else {
|
|
292
|
+
// RTL scrolls right to go back
|
|
293
|
+
container.scrollLeft += lastElementOutOfView.scrollWidth;
|
|
294
|
+
}
|
|
282
295
|
}
|
|
283
296
|
}
|
|
284
297
|
};
|
|
285
298
|
|
|
286
|
-
|
|
299
|
+
scrollForward = () => {
|
|
287
300
|
// find last Element that is fully in view on the right, then scroll to the element after it
|
|
288
301
|
if (this.tabList.current) {
|
|
289
302
|
const container = this.tabList.current as any;
|
|
@@ -297,7 +310,13 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
297
310
|
}
|
|
298
311
|
}
|
|
299
312
|
if (firstElementOutOfView) {
|
|
300
|
-
|
|
313
|
+
if (this.direction === 'ltr') {
|
|
314
|
+
// LTR scrolls right to go forward
|
|
315
|
+
container.scrollLeft += firstElementOutOfView.scrollWidth;
|
|
316
|
+
} else {
|
|
317
|
+
// RTL scrolls left to go forward
|
|
318
|
+
container.scrollLeft -= firstElementOutOfView.scrollWidth;
|
|
319
|
+
}
|
|
301
320
|
}
|
|
302
321
|
}
|
|
303
322
|
};
|
|
@@ -314,6 +333,7 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
314
333
|
if (canUseDOM) {
|
|
315
334
|
window.addEventListener('resize', this.handleScrollButtons, false);
|
|
316
335
|
}
|
|
336
|
+
this.direction = getComputedStyle(this.tabList.current).getPropertyValue('direction');
|
|
317
337
|
// call the handle resize function to check if scroll buttons should be shown
|
|
318
338
|
this.handleScrollButtons();
|
|
319
339
|
}
|
|
@@ -360,6 +380,8 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
360
380
|
} else if (prevState.enableScrollButtons && !enableScrollButtons) {
|
|
361
381
|
this.setState({ showScrollButtons: false });
|
|
362
382
|
}
|
|
383
|
+
|
|
384
|
+
this.direction = getComputedStyle(this.tabList.current).getPropertyValue('direction');
|
|
363
385
|
}
|
|
364
386
|
|
|
365
387
|
render() {
|
|
@@ -376,6 +398,8 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
376
398
|
hasNoBorderBottom,
|
|
377
399
|
leftScrollAriaLabel,
|
|
378
400
|
rightScrollAriaLabel,
|
|
401
|
+
backScrollAriaLabel,
|
|
402
|
+
forwardScrollAriaLabel,
|
|
379
403
|
'aria-label': ariaLabel,
|
|
380
404
|
component,
|
|
381
405
|
ouiaId,
|
|
@@ -400,8 +424,8 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
400
424
|
const {
|
|
401
425
|
showScrollButtons,
|
|
402
426
|
renderScrollButtons,
|
|
403
|
-
|
|
404
|
-
|
|
427
|
+
disableBackScrollButton,
|
|
428
|
+
disableForwardScrollButton,
|
|
405
429
|
shownKeys,
|
|
406
430
|
uncontrolledActiveKey,
|
|
407
431
|
uncontrolledIsExpandedLocal,
|
|
@@ -497,10 +521,10 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
497
521
|
<button
|
|
498
522
|
type="button"
|
|
499
523
|
className={css(styles.tabsScrollButton, isSecondary && buttonStyles.modifiers.secondary)}
|
|
500
|
-
aria-label={leftScrollAriaLabel}
|
|
501
|
-
onClick={this.
|
|
502
|
-
disabled={
|
|
503
|
-
aria-hidden={
|
|
524
|
+
aria-label={backScrollAriaLabel || leftScrollAriaLabel}
|
|
525
|
+
onClick={this.scrollBack}
|
|
526
|
+
disabled={disableBackScrollButton}
|
|
527
|
+
aria-hidden={disableBackScrollButton}
|
|
504
528
|
ref={this.leftScrollButtonRef}
|
|
505
529
|
>
|
|
506
530
|
<AngleLeftIcon />
|
|
@@ -514,10 +538,10 @@ class Tabs extends React.Component<TabsProps, TabsState> {
|
|
|
514
538
|
<button
|
|
515
539
|
type="button"
|
|
516
540
|
className={css(styles.tabsScrollButton, isSecondary && buttonStyles.modifiers.secondary)}
|
|
517
|
-
aria-label={rightScrollAriaLabel}
|
|
518
|
-
onClick={this.
|
|
519
|
-
disabled={
|
|
520
|
-
aria-hidden={
|
|
541
|
+
aria-label={forwardScrollAriaLabel || rightScrollAriaLabel}
|
|
542
|
+
onClick={this.scrollForward}
|
|
543
|
+
disabled={disableForwardScrollButton}
|
|
544
|
+
aria-hidden={disableForwardScrollButton}
|
|
521
545
|
>
|
|
522
546
|
<AngleRightIcon />
|
|
523
547
|
</button>
|
|
@@ -64,6 +64,10 @@ export interface TimestampProps extends React.HTMLProps<HTMLSpanElement> {
|
|
|
64
64
|
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl#Locale_identification_and_negotiation
|
|
65
65
|
*/
|
|
66
66
|
locale?: string;
|
|
67
|
+
/** Flag indicating whether the default content should be displayed as a UTC string
|
|
68
|
+
* instead of a local string.
|
|
69
|
+
*/
|
|
70
|
+
shouldDisplayUTC?: boolean;
|
|
67
71
|
/** Determines the format of the displayed time in the timestamp and UTC tooltip. Examples:
|
|
68
72
|
* "Full" => 11:25:00 AM Eastern Daylight Time
|
|
69
73
|
* "Long" => 11:25:00 AM EDT
|
|
@@ -84,6 +88,7 @@ export const Timestamp: React.FunctionComponent<TimestampProps> = ({
|
|
|
84
88
|
displaySuffix = '',
|
|
85
89
|
is12Hour,
|
|
86
90
|
locale,
|
|
91
|
+
shouldDisplayUTC,
|
|
87
92
|
timeFormat,
|
|
88
93
|
tooltip,
|
|
89
94
|
...props
|
|
@@ -117,7 +122,6 @@ export const Timestamp: React.FunctionComponent<TimestampProps> = ({
|
|
|
117
122
|
...formatOptions,
|
|
118
123
|
...(hasTimeFormat && { timeStyle: timeFormat })
|
|
119
124
|
});
|
|
120
|
-
const defaultDisplay = `${dateAsLocaleString}${displaySuffix ? ' ' + displaySuffix : ''}`;
|
|
121
125
|
|
|
122
126
|
const utcTimeFormat = timeFormat !== 'short' ? 'medium' : 'short';
|
|
123
127
|
const convertToUTCString = (date: Date) => new Date(date).toUTCString().slice(0, -3);
|
|
@@ -125,8 +129,13 @@ export const Timestamp: React.FunctionComponent<TimestampProps> = ({
|
|
|
125
129
|
...formatOptions,
|
|
126
130
|
...(hasTimeFormat && { timeStyle: utcTimeFormat })
|
|
127
131
|
});
|
|
128
|
-
const
|
|
132
|
+
const defaultUTCSuffix = timeFormat === 'full' ? 'Coordinated Universal Time' : 'UTC';
|
|
133
|
+
const createUTCContent = (customSuffix: string) =>
|
|
134
|
+
`${utcDateString} ${customSuffix ? customSuffix : defaultUTCSuffix}`;
|
|
129
135
|
|
|
136
|
+
const defaultDisplay = shouldDisplayUTC
|
|
137
|
+
? createUTCContent(displaySuffix)
|
|
138
|
+
: `${dateAsLocaleString}${displaySuffix ? ' ' + displaySuffix : ''}`;
|
|
130
139
|
const { dateTime, ...propsWithoutDateTime } = props;
|
|
131
140
|
|
|
132
141
|
const timestamp = (
|
|
@@ -143,7 +152,7 @@ export const Timestamp: React.FunctionComponent<TimestampProps> = ({
|
|
|
143
152
|
|
|
144
153
|
return tooltip ? (
|
|
145
154
|
<Tooltip
|
|
146
|
-
content={tooltip.variant === TimestampTooltipVariant.default ?
|
|
155
|
+
content={tooltip.variant === TimestampTooltipVariant.default ? createUTCContent(tooltip.suffix) : tooltip.content}
|
|
147
156
|
{...tooltip.tooltipProps}
|
|
148
157
|
>
|
|
149
158
|
{timestamp}
|
|
@@ -55,6 +55,12 @@ test('Renders passed in date with default formatting', () => {
|
|
|
55
55
|
expect(screen.getByText('1/1/2022, 12:00:00 AM')).toBeInTheDocument();
|
|
56
56
|
});
|
|
57
57
|
|
|
58
|
+
test('Renders passed in date as UTC when shouldDisplayUTC is true', () => {
|
|
59
|
+
render(<Timestamp shouldDisplayUTC date={new Date(2022, 0, 1)} />);
|
|
60
|
+
|
|
61
|
+
expect(screen.getByText('1/1/2022, 5:00:00 AM UTC')).toBeInTheDocument();
|
|
62
|
+
});
|
|
63
|
+
|
|
58
64
|
test('Renders with correct datetime attribute when date is passed in', () => {
|
|
59
65
|
const passedDate = new Date(2022, 0, 1);
|
|
60
66
|
render(<Timestamp date={passedDate} />);
|
|
@@ -12,7 +12,10 @@ beta: true
|
|
|
12
12
|
|
|
13
13
|
By default, a timestamp will display the current date and time based on the current locale if the `date` prop is not passed in.
|
|
14
14
|
|
|
15
|
+
Passing the `shouldDisplayUTC` property will display the UTC date and time instead of the current or passed in locale.
|
|
16
|
+
|
|
15
17
|
```ts file="./TimestampDefault.tsx"
|
|
18
|
+
|
|
16
19
|
```
|
|
17
20
|
|
|
18
21
|
### Basic formats
|
|
@@ -22,6 +25,7 @@ The format of the displayed content can be customized by passing in the `dateFor
|
|
|
22
25
|
You can also pass in the `displaySuffix` prop to display a custom suffix at the end of the displayed content. This will not override a timezone that is already displayed from the applied time format.
|
|
23
26
|
|
|
24
27
|
```ts file="./TimestampBasicFormats.tsx"
|
|
28
|
+
|
|
25
29
|
```
|
|
26
30
|
|
|
27
31
|
### Custom format
|
|
@@ -29,6 +33,7 @@ You can also pass in the `displaySuffix` prop to display a custom suffix at the
|
|
|
29
33
|
The format of the displayed content can be further customized by passing in the `customFormat` prop. Read [datetime format options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options) for a list of options that can be passed in.
|
|
30
34
|
|
|
31
35
|
```ts file="./TimestampCustomFormat.tsx"
|
|
36
|
+
|
|
32
37
|
```
|
|
33
38
|
|
|
34
39
|
### Default tooltip
|
|
@@ -38,6 +43,7 @@ To render a tooltip that displays the timestamp content as a UTC time, you can p
|
|
|
38
43
|
You can customize the suffix of this default tooltip variant by passing in `suffix` to the `tooltip` prop.
|
|
39
44
|
|
|
40
45
|
```ts file="./TimestampDefaultTooltip.tsx"
|
|
46
|
+
|
|
41
47
|
```
|
|
42
48
|
|
|
43
49
|
### Custom content
|
|
@@ -47,6 +53,7 @@ To display custom content, such as a relative time or prefacing text, you can pa
|
|
|
47
53
|
When also rendering a default tooltip with the `tooltip` prop, you can pass in the `dateFormat` and/or `timeFormat` props to customize the tooltip content without affecting the custom timestamp content.
|
|
48
54
|
|
|
49
55
|
```ts file="TimestampCustomContent.tsx"
|
|
56
|
+
|
|
50
57
|
```
|
|
51
58
|
|
|
52
59
|
### Custom tooltip
|
|
@@ -54,4 +61,5 @@ When also rendering a default tooltip with the `tooltip` prop, you can pass in t
|
|
|
54
61
|
By passing in `variant="custom"` and `content` to the `tooltip` prop, you can display custom content within the timestamp's tooltip.
|
|
55
62
|
|
|
56
63
|
```ts file="TimestampCustomTooltip.tsx"
|
|
64
|
+
|
|
57
65
|
```
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Timestamp } from '@patternfly/react-core';
|
|
3
3
|
|
|
4
|
-
export const TimestampDefault: React.FunctionComponent = () =>
|
|
4
|
+
export const TimestampDefault: React.FunctionComponent = () => (
|
|
5
|
+
<>
|
|
6
|
+
<Timestamp />
|
|
7
|
+
<br />
|
|
8
|
+
<Timestamp shouldDisplayUTC />
|
|
9
|
+
</>
|
|
10
|
+
);
|
|
@@ -11,7 +11,7 @@ export const TimestampDefaultTooltip: React.FunctionComponent = () => {
|
|
|
11
11
|
<br />
|
|
12
12
|
<Timestamp
|
|
13
13
|
date={currentDate}
|
|
14
|
-
tooltip={{ variant: TimestampTooltipVariant.default, suffix: 'Coordinated Universal Time' }}
|
|
14
|
+
tooltip={{ variant: TimestampTooltipVariant.default, suffix: 'Coordinated Universal Time (UTC)' }}
|
|
15
15
|
/>
|
|
16
16
|
</>
|
|
17
17
|
);
|
|
@@ -45,6 +45,21 @@ const getOppositePlacement = (placement: Placement): any =>
|
|
|
45
45
|
export const getOpacityTransition = (animationDuration: number) =>
|
|
46
46
|
`opacity ${animationDuration}ms cubic-bezier(.54, 1.5, .38, 1.11)`;
|
|
47
47
|
|
|
48
|
+
export const getLanguageDirection = (targetElement: HTMLElement) => {
|
|
49
|
+
const defaultDirection = 'ltr';
|
|
50
|
+
let direction = defaultDirection;
|
|
51
|
+
|
|
52
|
+
if (targetElement) {
|
|
53
|
+
direction = getComputedStyle(targetElement).getPropertyValue('direction');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (['ltr', 'rtl'].includes(direction)) {
|
|
57
|
+
return direction as 'ltr' | 'rtl';
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return defaultDirection;
|
|
61
|
+
};
|
|
62
|
+
|
|
48
63
|
export interface PopperProps {
|
|
49
64
|
/**
|
|
50
65
|
* Trigger reference element to which the popper is relatively placed to.
|
|
@@ -66,7 +81,7 @@ export interface PopperProps {
|
|
|
66
81
|
/** popper direction */
|
|
67
82
|
direction?: 'up' | 'down';
|
|
68
83
|
/** popper position */
|
|
69
|
-
position?: 'right' | 'left' | 'center';
|
|
84
|
+
position?: 'right' | 'left' | 'center' | 'start' | 'end';
|
|
70
85
|
/** Instead of direction and position can set the placement of the popper */
|
|
71
86
|
placement?: Placement;
|
|
72
87
|
/** Custom width of the popper. If the value is "trigger", it will set the width to the trigger element's width */
|
|
@@ -177,7 +192,7 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
|
|
|
177
192
|
trigger,
|
|
178
193
|
popper,
|
|
179
194
|
direction = 'down',
|
|
180
|
-
position = '
|
|
195
|
+
position = 'start',
|
|
181
196
|
placement,
|
|
182
197
|
width,
|
|
183
198
|
minWidth = 'trigger',
|
|
@@ -226,6 +241,28 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
|
|
|
226
241
|
const refOrTrigger = refElement || triggerElement;
|
|
227
242
|
const showPopper = isVisible || internalIsVisible;
|
|
228
243
|
|
|
244
|
+
const triggerParent = ((triggerRef as React.RefObject<any>)?.current || triggerElement)?.parentElement;
|
|
245
|
+
const languageDirection = getLanguageDirection(triggerParent);
|
|
246
|
+
|
|
247
|
+
const internalPosition = React.useMemo<'left' | 'right' | 'center'>(() => {
|
|
248
|
+
const fixedPositions = { left: 'left', right: 'right', center: 'center' };
|
|
249
|
+
|
|
250
|
+
const positionMap = {
|
|
251
|
+
ltr: {
|
|
252
|
+
start: 'left',
|
|
253
|
+
end: 'right',
|
|
254
|
+
...fixedPositions
|
|
255
|
+
},
|
|
256
|
+
rtl: {
|
|
257
|
+
start: 'right',
|
|
258
|
+
end: 'left',
|
|
259
|
+
...fixedPositions
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
return positionMap[languageDirection][position] as 'left' | 'right' | 'center';
|
|
264
|
+
}, [position, languageDirection]);
|
|
265
|
+
|
|
229
266
|
const onDocumentClickCallback = React.useCallback(
|
|
230
267
|
(event: MouseEvent) => onDocumentClick(event, refOrTrigger, popperElement),
|
|
231
268
|
[showPopper, triggerElement, refElement, popperElement, onDocumentClick]
|
|
@@ -333,15 +370,15 @@ export const Popper: React.FunctionComponent<PopperProps> = ({
|
|
|
333
370
|
return placement;
|
|
334
371
|
}
|
|
335
372
|
let convertedPlacement = direction === 'up' ? 'top' : 'bottom';
|
|
336
|
-
if (
|
|
337
|
-
convertedPlacement = `${convertedPlacement}-${
|
|
373
|
+
if (internalPosition !== 'center') {
|
|
374
|
+
convertedPlacement = `${convertedPlacement}-${internalPosition === 'right' ? 'end' : 'start'}`;
|
|
338
375
|
}
|
|
339
376
|
return convertedPlacement as Placement;
|
|
340
377
|
};
|
|
341
|
-
const getPlacementMemo = React.useMemo(getPlacement, [direction,
|
|
378
|
+
const getPlacementMemo = React.useMemo(getPlacement, [direction, internalPosition, placement]);
|
|
342
379
|
const getOppositePlacementMemo = React.useMemo(
|
|
343
380
|
() => getOppositePlacement(getPlacement()),
|
|
344
|
-
[direction,
|
|
381
|
+
[direction, internalPosition, placement]
|
|
345
382
|
);
|
|
346
383
|
|
|
347
384
|
const widthMods: Modifier<'widthMods', {}> = React.useMemo(
|