@patternfly/react-core 5.1.1-prerelease.17 → 5.1.1-prerelease.18
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 +11 -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/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/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 +2 -2
- package/helpers/package.json +1 -1
- package/layouts/package.json +1 -1
- package/next/package.json +1 -1
- package/package.json +2 -2
- 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/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.17","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.17","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.17","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.18",
|
|
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",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"react": "^17 || ^18",
|
|
71
71
|
"react-dom": "^17 || ^18"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "2fa883df95ae47f12e4d5f90b6e184cbeca868a7"
|
|
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 */
|
|
@@ -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(
|