@doist/reactist 11.6.0 → 12.0.1
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/dist/reactist.cjs.development.js +1335 -1493
- package/dist/reactist.cjs.development.js.map +1 -1
- package/dist/reactist.cjs.production.min.js +1 -1
- package/dist/reactist.cjs.production.min.js.map +1 -1
- package/es/_virtual/_rollupPluginBabelHelpers.js +18 -21
- package/es/_virtual/_rollupPluginBabelHelpers.js.map +1 -1
- package/es/components/checkbox/checkbox.js +7 -9
- package/es/components/checkbox/checkbox.js.map +1 -1
- package/es/components/color-picker/color-picker.js +24 -28
- package/es/components/color-picker/color-picker.js.map +1 -1
- package/es/components/deprecated-button/deprecated-button.js +16 -18
- package/es/components/deprecated-button/deprecated-button.js.map +1 -1
- package/es/components/deprecated-loading/deprecated-loading.js +7 -10
- package/es/components/deprecated-loading/deprecated-loading.js.map +1 -1
- package/es/components/deprecated-modal/deprecated-modal.js +69 -101
- package/es/components/deprecated-modal/deprecated-modal.js.map +1 -1
- package/es/components/deprecated-modal/index.js +4 -4
- package/es/components/deprecated-modal/index.js.map +1 -1
- package/es/components/dropdown/dropdown.js +86 -85
- package/es/components/dropdown/dropdown.js.map +1 -1
- package/es/components/icons/CloseIcon.svg.js +9 -11
- package/es/components/icons/CloseIcon.svg.js.map +1 -1
- package/es/components/input/input.js +4 -3
- package/es/components/input/input.js.map +1 -1
- package/es/components/key-capturer/key-capturer.js +22 -19
- package/es/components/key-capturer/key-capturer.js.map +1 -1
- package/es/components/keyboard-shortcut/keyboard-shortcut.js +20 -26
- package/es/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/es/components/menu/menu.js +112 -142
- package/es/components/menu/menu.js.map +1 -1
- package/es/components/notification/notification.js +32 -32
- package/es/components/notification/notification.js.map +1 -1
- package/es/components/popover/popover.js +85 -91
- package/es/components/popover/popover.js.map +1 -1
- package/es/components/popover/positioning-utils.js +49 -65
- package/es/components/popover/positioning-utils.js.map +1 -1
- package/es/components/progress-bar/progress-bar.js +8 -8
- package/es/components/progress-bar/progress-bar.js.map +1 -1
- package/es/components/select/select.js +20 -25
- package/es/components/select/select.js.map +1 -1
- package/es/components/time/time-utils.js +30 -47
- package/es/components/time/time-utils.js.map +1 -1
- package/es/components/time/time.js +43 -56
- package/es/components/time/time.js.map +1 -1
- package/es/components/tooltip/tooltip.js +43 -46
- package/es/components/tooltip/tooltip.js.map +1 -1
- package/es/hooks/use-previous/use-previous.js +2 -2
- package/es/hooks/use-previous/use-previous.js.map +1 -1
- package/es/new-components/alert/alert.js +7 -6
- package/es/new-components/alert/alert.js.map +1 -1
- package/es/new-components/avatar/avatar.js +19 -18
- package/es/new-components/avatar/avatar.js.map +1 -1
- package/es/new-components/avatar/utils.js +12 -9
- package/es/new-components/avatar/utils.js.map +1 -1
- package/es/new-components/base-button/base-button.js +25 -29
- package/es/new-components/base-button/base-button.js.map +1 -1
- package/es/new-components/base-field/base-field.js +20 -18
- package/es/new-components/base-field/base-field.js.map +1 -1
- package/es/new-components/box/box.js +51 -52
- package/es/new-components/box/box.js.map +1 -1
- package/es/new-components/button/button.js +13 -15
- package/es/new-components/button/button.js.map +1 -1
- package/es/new-components/button-link/button-link.js +13 -15
- package/es/new-components/button-link/button-link.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-field.js +25 -33
- package/es/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/es/new-components/checkbox-field/checkbox-icon.js +21 -19
- package/es/new-components/checkbox-field/checkbox-icon.js.map +1 -1
- package/es/new-components/columns/columns.js +24 -27
- package/es/new-components/columns/columns.js.map +1 -1
- package/es/new-components/common-helpers.js +3 -3
- package/es/new-components/common-helpers.js.map +1 -1
- package/es/new-components/divider/divider.js +7 -6
- package/es/new-components/divider/divider.js.map +1 -1
- package/es/new-components/heading/heading.js +17 -17
- package/es/new-components/heading/heading.js.map +1 -1
- package/es/new-components/hidden/hidden.js +14 -13
- package/es/new-components/hidden/hidden.js.map +1 -1
- package/es/new-components/hidden-visually/hidden-visually.js +3 -2
- package/es/new-components/hidden-visually/hidden-visually.js.map +1 -1
- package/es/new-components/icons/alert-icon.js +13 -11
- package/es/new-components/icons/alert-icon.js.map +1 -1
- package/es/new-components/icons/close-icon.js +2 -1
- package/es/new-components/icons/close-icon.js.map +1 -1
- package/es/new-components/icons/password-hidden-icon.js +2 -1
- package/es/new-components/icons/password-hidden-icon.js.map +1 -1
- package/es/new-components/icons/password-visible-icon.js +2 -1
- package/es/new-components/icons/password-visible-icon.js.map +1 -1
- package/es/new-components/inline/inline.js +15 -19
- package/es/new-components/inline/inline.js.map +1 -1
- package/es/new-components/loading/loading.js +11 -10
- package/es/new-components/loading/loading.js.map +1 -1
- package/es/new-components/modal/modal.js +60 -64
- package/es/new-components/modal/modal.js.map +1 -1
- package/es/new-components/notice/notice.js +5 -4
- package/es/new-components/notice/notice.js.map +1 -1
- package/es/new-components/password-field/password-field.js +40 -46
- package/es/new-components/password-field/password-field.js.map +1 -1
- package/es/new-components/responsive-props.js +5 -5
- package/es/new-components/responsive-props.js.map +1 -1
- package/es/new-components/select-field/select-field.js +23 -23
- package/es/new-components/select-field/select-field.js.map +1 -1
- package/es/new-components/spinner/spinner.js +3 -3
- package/es/new-components/spinner/spinner.js.map +1 -1
- package/es/new-components/stack/stack.js +18 -22
- package/es/new-components/stack/stack.js.map +1 -1
- package/es/new-components/switch-field/switch-field.js +31 -41
- package/es/new-components/switch-field/switch-field.js.map +1 -1
- package/es/new-components/tabs/tabs.js +92 -78
- package/es/new-components/tabs/tabs.js.map +1 -1
- package/es/new-components/tabs/tabs.module.css.js +1 -1
- package/es/new-components/text/text.js +16 -17
- package/es/new-components/text/text.js.map +1 -1
- package/es/new-components/text-area/text-area.js +14 -14
- package/es/new-components/text-area/text-area.js.map +1 -1
- package/es/new-components/text-field/text-field.js +21 -22
- package/es/new-components/text-field/text-field.js.map +1 -1
- package/es/new-components/text-link/text-link.js +10 -10
- package/es/new-components/text-link/text-link.js.map +1 -1
- package/es/utils/polymorphism.js.map +1 -1
- package/lib/_virtual/_rollupPluginBabelHelpers.js +1 -1
- package/lib/components/checkbox/checkbox.js +1 -1
- package/lib/components/checkbox/checkbox.js.map +1 -1
- package/lib/components/color-picker/color-picker.js +1 -1
- package/lib/components/color-picker/color-picker.js.map +1 -1
- package/lib/components/deprecated-button/deprecated-button.d.ts +3 -3
- package/lib/components/deprecated-button/deprecated-button.js +1 -1
- package/lib/components/deprecated-button/deprecated-button.js.map +1 -1
- package/lib/components/deprecated-loading/deprecated-loading.js +1 -1
- package/lib/components/deprecated-loading/deprecated-loading.js.map +1 -1
- package/lib/components/deprecated-modal/deprecated-modal.d.ts +2 -2
- package/lib/components/deprecated-modal/deprecated-modal.js +1 -1
- package/lib/components/deprecated-modal/deprecated-modal.js.map +1 -1
- package/lib/components/deprecated-modal/index.js.map +1 -1
- package/lib/components/dropdown/dropdown.d.ts +5 -2
- package/lib/components/dropdown/dropdown.js +1 -1
- package/lib/components/dropdown/dropdown.js.map +1 -1
- package/lib/components/icons/CloseIcon.svg.js +1 -1
- package/lib/components/icons/CloseIcon.svg.js.map +1 -1
- package/lib/components/input/input.js +1 -1
- package/lib/components/input/input.js.map +1 -1
- package/lib/components/key-capturer/key-capturer.d.ts +1 -1
- package/lib/components/key-capturer/key-capturer.js +1 -1
- package/lib/components/key-capturer/key-capturer.js.map +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js +1 -1
- package/lib/components/keyboard-shortcut/keyboard-shortcut.js.map +1 -1
- package/lib/components/menu/menu.d.ts +7 -7
- package/lib/components/menu/menu.js +1 -1
- package/lib/components/menu/menu.js.map +1 -1
- package/lib/components/notification/notification.js +1 -1
- package/lib/components/notification/notification.js.map +1 -1
- package/lib/components/popover/popover.d.ts +1 -1
- package/lib/components/popover/popover.js +1 -1
- package/lib/components/popover/popover.js.map +1 -1
- package/lib/components/popover/positioning-utils.js +1 -1
- package/lib/components/popover/positioning-utils.js.map +1 -1
- package/lib/components/progress-bar/progress-bar.js +1 -1
- package/lib/components/progress-bar/progress-bar.js.map +1 -1
- package/lib/components/select/select.js +1 -1
- package/lib/components/select/select.js.map +1 -1
- package/lib/components/time/time-utils.js +1 -1
- package/lib/components/time/time-utils.js.map +1 -1
- package/lib/components/time/time.js +1 -1
- package/lib/components/time/time.js.map +1 -1
- package/lib/components/tooltip/index.d.ts +1 -2
- package/lib/components/tooltip/tooltip.d.ts +3 -3
- package/lib/components/tooltip/tooltip.js +1 -1
- package/lib/components/tooltip/tooltip.js.map +1 -1
- package/lib/hooks/use-previous/use-previous.js +1 -1
- package/lib/hooks/use-previous/use-previous.js.map +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/new-components/alert/alert.d.ts +1 -1
- package/lib/new-components/alert/alert.js +1 -1
- package/lib/new-components/alert/alert.js.map +1 -1
- package/lib/new-components/avatar/avatar.js +1 -1
- package/lib/new-components/avatar/avatar.js.map +1 -1
- package/lib/new-components/avatar/utils.d.ts +1 -1
- package/lib/new-components/avatar/utils.js +1 -1
- package/lib/new-components/avatar/utils.js.map +1 -1
- package/lib/new-components/base-button/base-button.js +1 -1
- package/lib/new-components/base-button/base-button.js.map +1 -1
- package/lib/new-components/base-field/base-field.d.ts +1 -1
- package/lib/new-components/base-field/base-field.js +1 -1
- package/lib/new-components/base-field/base-field.js.map +1 -1
- package/lib/new-components/box/box.js +1 -1
- package/lib/new-components/box/box.js.map +1 -1
- package/lib/new-components/button/button.d.ts +1 -58
- package/lib/new-components/button/button.js +1 -1
- package/lib/new-components/button/button.js.map +1 -1
- package/lib/new-components/button-link/button-link.js +1 -1
- package/lib/new-components/button-link/button-link.js.map +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.d.ts +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-field.js.map +1 -1
- package/lib/new-components/checkbox-field/checkbox-icon.js +1 -1
- package/lib/new-components/checkbox-field/checkbox-icon.js.map +1 -1
- package/lib/new-components/columns/columns.js +1 -1
- package/lib/new-components/columns/columns.js.map +1 -1
- package/lib/new-components/common-helpers.js +1 -1
- package/lib/new-components/common-helpers.js.map +1 -1
- package/lib/new-components/common-types.d.ts +1 -1
- package/lib/new-components/divider/divider.js +1 -1
- package/lib/new-components/divider/divider.js.map +1 -1
- package/lib/new-components/heading/heading.d.ts +2 -2
- package/lib/new-components/heading/heading.js +1 -1
- package/lib/new-components/heading/heading.js.map +1 -1
- package/lib/new-components/hidden/hidden.js +1 -1
- package/lib/new-components/hidden/hidden.js.map +1 -1
- package/lib/new-components/hidden-visually/hidden-visually.js +1 -1
- package/lib/new-components/hidden-visually/hidden-visually.js.map +1 -1
- package/lib/new-components/icons/alert-icon.d.ts +1 -1
- package/lib/new-components/icons/alert-icon.js +1 -1
- package/lib/new-components/icons/alert-icon.js.map +1 -1
- package/lib/new-components/icons/close-icon.js +1 -1
- package/lib/new-components/icons/close-icon.js.map +1 -1
- package/lib/new-components/icons/password-hidden-icon.js +1 -1
- package/lib/new-components/icons/password-hidden-icon.js.map +1 -1
- package/lib/new-components/icons/password-visible-icon.js +1 -1
- package/lib/new-components/icons/password-visible-icon.js.map +1 -1
- package/lib/new-components/inline/inline.js +1 -1
- package/lib/new-components/inline/inline.js.map +1 -1
- package/lib/new-components/loading/loading.js +1 -1
- package/lib/new-components/loading/loading.js.map +1 -1
- package/lib/new-components/modal/modal.js +1 -1
- package/lib/new-components/modal/modal.js.map +1 -1
- package/lib/new-components/notice/notice.d.ts +1 -1
- package/lib/new-components/notice/notice.js +1 -1
- package/lib/new-components/notice/notice.js.map +1 -1
- package/lib/new-components/password-field/password-field.d.ts +1 -1
- package/lib/new-components/password-field/password-field.js +1 -1
- package/lib/new-components/password-field/password-field.js.map +1 -1
- package/lib/new-components/responsive-props.d.ts +1 -1
- package/lib/new-components/responsive-props.js +1 -1
- package/lib/new-components/responsive-props.js.map +1 -1
- package/lib/new-components/select-field/select-field.d.ts +1 -1
- package/lib/new-components/select-field/select-field.js +1 -1
- package/lib/new-components/select-field/select-field.js.map +1 -1
- package/lib/new-components/spinner/spinner.js +1 -1
- package/lib/new-components/spinner/spinner.js.map +1 -1
- package/lib/new-components/stack/stack.js +1 -1
- package/lib/new-components/stack/stack.js.map +1 -1
- package/lib/new-components/switch-field/switch-field.d.ts +1 -1
- package/lib/new-components/switch-field/switch-field.js +1 -1
- package/lib/new-components/switch-field/switch-field.js.map +1 -1
- package/lib/new-components/tabs/tabs.d.ts +13 -3
- package/lib/new-components/tabs/tabs.js +1 -1
- package/lib/new-components/tabs/tabs.js.map +1 -1
- package/lib/new-components/tabs/tabs.module.css.js +1 -1
- package/lib/new-components/test-helpers.d.ts +4 -3
- package/lib/new-components/text/text.js +1 -1
- package/lib/new-components/text/text.js.map +1 -1
- package/lib/new-components/text-area/text-area.js +1 -1
- package/lib/new-components/text-area/text-area.js.map +1 -1
- package/lib/new-components/text-field/text-field.d.ts +1 -1
- package/lib/new-components/text-field/text-field.js +1 -1
- package/lib/new-components/text-field/text-field.js.map +1 -1
- package/lib/new-components/text-link/text-link.js +1 -1
- package/lib/new-components/text-link/text-link.js.map +1 -1
- package/lib/utils/polymorphism.js.map +1 -1
- package/package.json +45 -38
- package/styles/menu.css +1 -1
- package/styles/reactist.css +2 -2
- package/styles/tabs.css +1 -1
- package/styles/tabs.module.css.css +1 -1
|
@@ -1,57 +1,57 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { objectWithoutProperties as _objectWithoutProperties, objectSpread2 as _objectSpread2 } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
4
|
import CloseIcon from '../icons/CloseIcon.svg.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
const _excluded = ["id", "icon", "title", "subtitle", "children", "customCloseButton", "onClick", "onClose", "closeAltText", "className", "aria-live"];
|
|
7
7
|
|
|
8
8
|
function Notification(_ref) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
rest =
|
|
9
|
+
let {
|
|
10
|
+
id,
|
|
11
|
+
icon,
|
|
12
|
+
title,
|
|
13
|
+
subtitle,
|
|
14
|
+
children,
|
|
15
|
+
customCloseButton,
|
|
16
|
+
onClick,
|
|
17
|
+
onClose,
|
|
18
|
+
closeAltText = 'Close',
|
|
19
|
+
className,
|
|
20
|
+
'aria-live': ariaLive = 'polite'
|
|
21
|
+
} = _ref,
|
|
22
|
+
rest = _objectWithoutProperties(_ref, _excluded);
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
const titleId = title ? id + "-title" : null;
|
|
25
|
+
const titleIdAttribute = titleId ? {
|
|
26
26
|
id: titleId
|
|
27
27
|
} : null;
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
const subtitleId = subtitle ? id + "-subtitle" : null;
|
|
29
|
+
const subtitleIdAttribute = subtitleId ? {
|
|
30
30
|
id: subtitleId
|
|
31
31
|
} : null;
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const contentId = children ? id + "-content" : null;
|
|
33
|
+
const contentIdAttribute = children ? {
|
|
34
34
|
id: id + "-content"
|
|
35
35
|
} : null;
|
|
36
|
-
|
|
36
|
+
const ariaLabelledBy = contentId ? {
|
|
37
37
|
'aria-labelledby': contentId
|
|
38
38
|
} : titleId ? {
|
|
39
39
|
'aria-labelledby': titleId
|
|
40
40
|
} : null;
|
|
41
|
-
|
|
41
|
+
const ariaDescribedBy = subtitleId && !children ? {
|
|
42
42
|
'aria-describedby': subtitleId
|
|
43
43
|
} : null;
|
|
44
|
-
|
|
44
|
+
const notificationContent = /*#__PURE__*/React__default.createElement("div", _objectSpread2({
|
|
45
45
|
className: "reactist-notification__content"
|
|
46
|
-
}, contentIdAttribute), children
|
|
46
|
+
}, contentIdAttribute), children != null ? children : /*#__PURE__*/React__default.createElement(React__default.Fragment, null, title ? /*#__PURE__*/React__default.createElement("h3", _objectSpread2({
|
|
47
47
|
className: "reactist-notification__title"
|
|
48
|
-
}, titleIdAttribute), title) : null, subtitle ? /*#__PURE__*/React__default.createElement("p",
|
|
48
|
+
}, titleIdAttribute), title) : null, subtitle ? /*#__PURE__*/React__default.createElement("p", _objectSpread2({
|
|
49
49
|
className: "reactist-notification__subtitle"
|
|
50
50
|
}, subtitleIdAttribute), subtitle) : null));
|
|
51
|
-
|
|
51
|
+
const notificationBody = /*#__PURE__*/React__default.createElement("div", {
|
|
52
52
|
className: "reactist-notification__icon-content-group"
|
|
53
|
-
}, icon
|
|
54
|
-
return /*#__PURE__*/React__default.createElement("div",
|
|
53
|
+
}, icon != null ? icon : null, notificationContent);
|
|
54
|
+
return /*#__PURE__*/React__default.createElement("div", _objectSpread2(_objectSpread2(_objectSpread2({
|
|
55
55
|
id: id,
|
|
56
56
|
role: "alert",
|
|
57
57
|
className: classNames('reactist-notification', className, {
|
|
@@ -59,14 +59,14 @@ function Notification(_ref) {
|
|
|
59
59
|
'reactist-notification--with-close-button': Boolean(onClose)
|
|
60
60
|
}),
|
|
61
61
|
"aria-live": ariaLive
|
|
62
|
-
}, ariaLabelledBy, ariaDescribedBy, rest), onClick ? /*#__PURE__*/React__default.createElement("button", {
|
|
62
|
+
}, ariaLabelledBy), ariaDescribedBy), rest), onClick ? /*#__PURE__*/React__default.createElement("button", {
|
|
63
63
|
className: "reactist-notification__button",
|
|
64
64
|
onClick: onClick
|
|
65
65
|
}, notificationBody) : notificationBody, onClose ? /*#__PURE__*/React__default.createElement("button", {
|
|
66
66
|
className: "reactist-notification__close-button",
|
|
67
67
|
onClick: onClose,
|
|
68
68
|
"aria-label": closeAltText
|
|
69
|
-
}, customCloseButton
|
|
69
|
+
}, customCloseButton != null ? customCloseButton : /*#__PURE__*/React__default.createElement(CloseIcon, null)) : null);
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
export { Notification };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notification.js","sources":["../../../src/components/notification/notification.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\nimport CloseIcon from '../icons/CloseIcon.svg'\nimport './notification.less'\n\ntype NotificationProps = {\n id: string\n icon?: React.ReactNode\n title?: React.ReactNode\n subtitle?: React.ReactNode\n children?: React.ReactNode\n customCloseButton?: React.ReactNode\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n onClose?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n closeAltText?: string\n className?: string\n /** Indicates that the notification will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */\n 'aria-live'?: 'off' | 'polite' | 'assertive'\n} & Omit<JSX.IntrinsicElements['div'], 'aria-live'>\n\nfunction Notification({\n id,\n icon,\n title,\n subtitle,\n children,\n customCloseButton,\n onClick,\n onClose,\n closeAltText = 'Close',\n className,\n 'aria-live': ariaLive = 'polite',\n ...rest\n}: NotificationProps) {\n const titleId = title ? `${id}-title` : null\n const titleIdAttribute = titleId ? { id: titleId } : null\n const subtitleId = subtitle ? `${id}-subtitle` : null\n const subtitleIdAttribute = subtitleId ? { id: subtitleId } : null\n const contentId = children ? `${id}-content` : null\n const contentIdAttribute = children ? { id: `${id}-content` } : null\n const ariaLabelledBy = contentId\n ? { 'aria-labelledby': contentId }\n : titleId\n ? { 'aria-labelledby': titleId }\n : null\n const ariaDescribedBy = subtitleId && !children ? { 'aria-describedby': subtitleId } : null\n\n const notificationContent = (\n <div className=\"reactist-notification__content\" {...contentIdAttribute}>\n {children ?? (\n <>\n {title ? (\n <h3 className=\"reactist-notification__title\" {...titleIdAttribute}>\n {title}\n </h3>\n ) : null}\n {subtitle ? (\n <p className=\"reactist-notification__subtitle\" {...subtitleIdAttribute}>\n {subtitle}\n </p>\n ) : null}\n </>\n )}\n </div>\n )\n const notificationBody = (\n <div className=\"reactist-notification__icon-content-group\">\n {icon ?? null}\n {notificationContent}\n </div>\n )\n\n return (\n <div\n id={id}\n role=\"alert\"\n className={classNames('reactist-notification', className, {\n 'reactist-notification--with-button': Boolean(onClick),\n 'reactist-notification--with-close-button': Boolean(onClose),\n })}\n aria-live={ariaLive}\n {...ariaLabelledBy}\n {...ariaDescribedBy}\n {...rest}\n >\n {onClick ? (\n <button className=\"reactist-notification__button\" onClick={onClick}>\n {notificationBody}\n </button>\n ) : (\n notificationBody\n )}\n\n {onClose ? (\n <button\n className=\"reactist-notification__close-button\"\n onClick={onClose}\n aria-label={closeAltText}\n >\n {customCloseButton ?? <CloseIcon />}\n </button>\n ) : null}\n </div>\n )\n}\n\nexport { Notification }\n"],"names":["Notification","id","icon","title","subtitle","children","customCloseButton","onClick","onClose","closeAltText","className","ariaLive","rest","titleId","titleIdAttribute","subtitleId","subtitleIdAttribute","contentId","contentIdAttribute","ariaLabelledBy","ariaDescribedBy","notificationContent","React","notificationBody","role","classNames","Boolean","CloseIcon"],"mappings":";;;;;;;AAoBA,SAASA,YAAT;
|
|
1
|
+
{"version":3,"file":"notification.js","sources":["../../../src/components/notification/notification.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\nimport CloseIcon from '../icons/CloseIcon.svg'\nimport './notification.less'\n\ntype NotificationProps = {\n id: string\n icon?: React.ReactNode\n title?: React.ReactNode\n subtitle?: React.ReactNode\n children?: React.ReactNode\n customCloseButton?: React.ReactNode\n onClick?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n onClose?: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void\n closeAltText?: string\n className?: string\n /** Indicates that the notification will be updated, and describes the types of updates the user agents, assistive technologies, and user can expect from the live region. */\n 'aria-live'?: 'off' | 'polite' | 'assertive'\n} & Omit<JSX.IntrinsicElements['div'], 'aria-live'>\n\nfunction Notification({\n id,\n icon,\n title,\n subtitle,\n children,\n customCloseButton,\n onClick,\n onClose,\n closeAltText = 'Close',\n className,\n 'aria-live': ariaLive = 'polite',\n ...rest\n}: NotificationProps) {\n const titleId = title ? `${id}-title` : null\n const titleIdAttribute = titleId ? { id: titleId } : null\n const subtitleId = subtitle ? `${id}-subtitle` : null\n const subtitleIdAttribute = subtitleId ? { id: subtitleId } : null\n const contentId = children ? `${id}-content` : null\n const contentIdAttribute = children ? { id: `${id}-content` } : null\n const ariaLabelledBy = contentId\n ? { 'aria-labelledby': contentId }\n : titleId\n ? { 'aria-labelledby': titleId }\n : null\n const ariaDescribedBy = subtitleId && !children ? { 'aria-describedby': subtitleId } : null\n\n const notificationContent = (\n <div className=\"reactist-notification__content\" {...contentIdAttribute}>\n {children ?? (\n <>\n {title ? (\n <h3 className=\"reactist-notification__title\" {...titleIdAttribute}>\n {title}\n </h3>\n ) : null}\n {subtitle ? (\n <p className=\"reactist-notification__subtitle\" {...subtitleIdAttribute}>\n {subtitle}\n </p>\n ) : null}\n </>\n )}\n </div>\n )\n const notificationBody = (\n <div className=\"reactist-notification__icon-content-group\">\n {icon ?? null}\n {notificationContent}\n </div>\n )\n\n return (\n <div\n id={id}\n role=\"alert\"\n className={classNames('reactist-notification', className, {\n 'reactist-notification--with-button': Boolean(onClick),\n 'reactist-notification--with-close-button': Boolean(onClose),\n })}\n aria-live={ariaLive}\n {...ariaLabelledBy}\n {...ariaDescribedBy}\n {...rest}\n >\n {onClick ? (\n <button className=\"reactist-notification__button\" onClick={onClick}>\n {notificationBody}\n </button>\n ) : (\n notificationBody\n )}\n\n {onClose ? (\n <button\n className=\"reactist-notification__close-button\"\n onClick={onClose}\n aria-label={closeAltText}\n >\n {customCloseButton ?? <CloseIcon />}\n </button>\n ) : null}\n </div>\n )\n}\n\nexport { Notification }\n"],"names":["Notification","id","icon","title","subtitle","children","customCloseButton","onClick","onClose","closeAltText","className","ariaLive","rest","titleId","titleIdAttribute","subtitleId","subtitleIdAttribute","contentId","contentIdAttribute","ariaLabelledBy","ariaDescribedBy","notificationContent","React","notificationBody","role","classNames","Boolean","CloseI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kBA,MAAMmB,gBAAgB,gBAClBD,4BAAA,MAAA;IAAKZ,SAAS,EAAC;GAAf,EACKR,IADL,WACKA,IADL,GACa,IADb,EAEKmB,mBAFL,CADJ;EAOA,oBACIC,4BAAA,MAAA;IACIrB,EAAE,EAAEA,EADR;IAEIuB,IAAI,EAAC,OAFT;IAGId,SAAS,EAAEe,UAAU,CAAC,uBAAD,EAA0Bf,SAA1B,EAAqC;MACtD,sCAAsCgB,OAAO,CAACnB,OAAD,CADS;MAEtD,4CAA4CmB,OAAO,CAAClB,OAAD;KAFlC,CAHzB;iBAOeG;KACPQ,cARR,GASQC,eATR,GAUQR,IAVR,GAYKL,OAAO,gBACJe,4BAAA,SAAA;IAAQZ,SAAS,EAAC;IAAgCH,OAAO,EAAEA;GAA3D,EACKgB,gBADL,CADI,GAKJA,gBAjBR,EAoBKf,OAAO,gBACJc,4BAAA,SAAA;IACIZ,SAAS,EAAC;IACVH,OAAO,EAAEC;kBACGC;GAHhB,EAKKH,iBALL,WAKKA,iBALL,gBAK0BgB,4BAAA,CAACK,SAAD,MAAA,CAL1B,CADI,GAQJ,IA5BR,CADJ;AAgCH;;;;"}
|
|
@@ -1,74 +1,68 @@
|
|
|
1
|
-
import { inheritsLoose as _inheritsLoose } from '../../_virtual/_rollupPluginBabelHelpers.js';
|
|
2
1
|
import React__default from 'react';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import { hasEnoughSpace, calculatePosition } from './positioning-utils.js';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
var documentEl = document.documentElement;
|
|
26
|
-
var node = _this.wrapper;
|
|
27
|
-
var foundParent = false;
|
|
5
|
+
class Popover extends React__default.Component {
|
|
6
|
+
constructor(...args) {
|
|
7
|
+
super(...args);
|
|
8
|
+
this.popover = void 0;
|
|
9
|
+
this.wrapper = void 0;
|
|
10
|
+
|
|
11
|
+
this._updatePopoverPosition = () => {
|
|
12
|
+
const {
|
|
13
|
+
position,
|
|
14
|
+
allowVaguePositioning,
|
|
15
|
+
gapSize
|
|
16
|
+
} = this.props;
|
|
17
|
+
const wrapperRect = this.wrapper.getBoundingClientRect();
|
|
18
|
+
const popoverRect = this.popover.getBoundingClientRect(); // Instead of using the documentElement find the nearest absolutely positioned element
|
|
19
|
+
|
|
20
|
+
const documentEl = document.documentElement;
|
|
21
|
+
let node = this.wrapper;
|
|
22
|
+
let foundParent = false;
|
|
28
23
|
|
|
29
24
|
while (!foundParent) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
var _position = styles.getPropertyValue('position');
|
|
25
|
+
const styles = getComputedStyle(node);
|
|
26
|
+
const position = styles.getPropertyValue('position');
|
|
33
27
|
|
|
34
|
-
if (
|
|
28
|
+
if (position === 'absolute' || node === documentEl || !node.parentElement) {
|
|
35
29
|
foundParent = true;
|
|
36
30
|
} else {
|
|
37
31
|
node = node.parentElement;
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
const nodeRect = node.getBoundingClientRect();
|
|
36
|
+
const windowDimensions = {
|
|
43
37
|
height: nodeRect.height,
|
|
44
38
|
width: nodeRect.width
|
|
45
39
|
};
|
|
46
|
-
|
|
40
|
+
const popoverDimensions = {
|
|
47
41
|
height: popoverRect.height,
|
|
48
42
|
width: popoverRect.width
|
|
49
43
|
};
|
|
50
|
-
|
|
44
|
+
const wrapperDimensions = {
|
|
51
45
|
height: wrapperRect.height,
|
|
52
46
|
width: wrapperRect.width
|
|
53
47
|
};
|
|
54
|
-
|
|
48
|
+
const wrapperPositionRelative = {
|
|
55
49
|
x: wrapperRect.left - nodeRect.left,
|
|
56
50
|
y: wrapperRect.top - nodeRect.top
|
|
57
51
|
};
|
|
58
|
-
|
|
52
|
+
const wrapperPositionAbsolute = {
|
|
59
53
|
x: wrapperRect.left,
|
|
60
54
|
y: wrapperRect.top
|
|
61
55
|
};
|
|
62
|
-
|
|
56
|
+
const positionsToTry = position === 'auto' ? ['top', 'right', 'bottom', 'left', 'top'] : position === 'vertical' ? ['top', 'bottom'] : position === 'horizontal' ? ['left', 'right'] : [position];
|
|
63
57
|
|
|
64
|
-
for (
|
|
65
|
-
|
|
66
|
-
|
|
58
|
+
for (let index = 0; index < positionsToTry.length; index++) {
|
|
59
|
+
const currentPosition = positionsToTry[index];
|
|
60
|
+
const enoughSpaceAtPosition = currentPosition != null ? hasEnoughSpace(windowDimensions, popoverDimensions, wrapperDimensions, wrapperPositionRelative, currentPosition, gapSize) : false;
|
|
67
61
|
|
|
68
62
|
if (enoughSpaceAtPosition || index === positionsToTry.length - 1) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
const popoverPosition = currentPosition != null ? calculatePosition(currentPosition, wrapperDimensions, wrapperPositionAbsolute, popoverDimensions, gapSize) : wrapperPositionAbsolute;
|
|
64
|
+
this.popover.style.top = popoverPosition.y + "px";
|
|
65
|
+
this.popover.style.left = popoverPosition.x + "px";
|
|
72
66
|
/**
|
|
73
67
|
* Correct placement if vague positioning is allowed.
|
|
74
68
|
* When it's not allowed we "cut off" popovers and display them
|
|
@@ -78,17 +72,17 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
78
72
|
if (allowVaguePositioning) {
|
|
79
73
|
// correct horizontally
|
|
80
74
|
if (popoverPosition.x < 0) {
|
|
81
|
-
|
|
75
|
+
this.popover.style.left = 2 * gapSize + "px";
|
|
82
76
|
} // correct vertically
|
|
83
77
|
|
|
84
78
|
|
|
85
79
|
if (popoverPosition.y + popoverDimensions.height > windowDimensions.height) {
|
|
86
|
-
|
|
80
|
+
this.popover.style.top = windowDimensions.height - popoverDimensions.height - 2 * gapSize + "px";
|
|
87
81
|
}
|
|
88
82
|
}
|
|
89
83
|
|
|
90
84
|
if (currentPosition !== position) {
|
|
91
|
-
|
|
85
|
+
this.popover.className = this._getClassNameForPosition(currentPosition);
|
|
92
86
|
}
|
|
93
87
|
|
|
94
88
|
break;
|
|
@@ -96,13 +90,14 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
96
90
|
}
|
|
97
91
|
};
|
|
98
92
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
93
|
+
this._getClassNameForPosition = position => {
|
|
94
|
+
const {
|
|
95
|
+
visible,
|
|
96
|
+
withArrow,
|
|
97
|
+
arrowClassName
|
|
98
|
+
} = this.props;
|
|
99
|
+
const className = classNames('reactist_popover', {
|
|
100
|
+
visible
|
|
106
101
|
});
|
|
107
102
|
|
|
108
103
|
if (visible && withArrow) {
|
|
@@ -117,62 +112,59 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
117
112
|
return className;
|
|
118
113
|
};
|
|
119
114
|
|
|
120
|
-
|
|
121
|
-
|
|
115
|
+
this._updatePopoverRef = popover => {
|
|
116
|
+
this.popover = popover;
|
|
122
117
|
|
|
123
|
-
if (typeof
|
|
124
|
-
|
|
118
|
+
if (typeof this.props.popoverRef === 'function') {
|
|
119
|
+
this.props.popoverRef(popover);
|
|
125
120
|
}
|
|
126
121
|
};
|
|
127
122
|
|
|
128
|
-
|
|
129
|
-
|
|
123
|
+
this._updateWrapperRef = wrapper => {
|
|
124
|
+
this.wrapper = wrapper;
|
|
130
125
|
|
|
131
|
-
if (typeof
|
|
132
|
-
|
|
126
|
+
if (typeof this.props.wrapperRef === 'function') {
|
|
127
|
+
this.props.wrapperRef(wrapper);
|
|
133
128
|
}
|
|
134
129
|
};
|
|
135
|
-
|
|
136
|
-
return _this;
|
|
137
130
|
}
|
|
138
131
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
_proto.componentDidMount = function componentDidMount() {
|
|
132
|
+
componentDidMount() {
|
|
142
133
|
if (this.props.visible) {
|
|
143
134
|
this._updatePopoverPosition();
|
|
144
135
|
}
|
|
145
|
-
}
|
|
136
|
+
}
|
|
146
137
|
|
|
147
|
-
|
|
138
|
+
componentDidUpdate(prevProps) {
|
|
148
139
|
if (this.wrapper && this.props.visible) {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
140
|
+
const positionChanged = prevProps.position !== this.props.position;
|
|
141
|
+
const vaguePositioningChanged = prevProps.allowVaguePositioning !== this.props.allowVaguePositioning;
|
|
142
|
+
const visibilityChanged = prevProps.visible !== this.props.visible;
|
|
143
|
+
const arrowChanged = prevProps.withArrow !== this.props.withArrow;
|
|
144
|
+
const gapSizeChanged = prevProps.gapSize !== this.props.gapSize;
|
|
145
|
+
const contentChanged = prevProps.content !== this.props.content;
|
|
155
146
|
|
|
156
147
|
if (positionChanged || vaguePositioningChanged || visibilityChanged || arrowChanged || gapSizeChanged || contentChanged) {
|
|
157
148
|
this._updatePopoverPosition();
|
|
158
149
|
}
|
|
159
150
|
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
render() {
|
|
154
|
+
const {
|
|
155
|
+
position,
|
|
156
|
+
wrapperClassName,
|
|
157
|
+
popoverClassName,
|
|
158
|
+
onMouseEnter,
|
|
159
|
+
onMouseLeave,
|
|
160
|
+
onClick,
|
|
161
|
+
trigger,
|
|
162
|
+
content
|
|
163
|
+
} = this.props;
|
|
164
|
+
const popoverClass = position ? this._getClassNameForPosition(position) : '';
|
|
165
|
+
const popoverContentClass = classNames('reactist_popover__content', popoverClassName);
|
|
166
|
+
const wrapperClass = classNames('reactist_popover__wrapper', wrapperClassName);
|
|
167
|
+
const triggerElement = React__default.Children.only(trigger);
|
|
176
168
|
|
|
177
169
|
function handleTriggerClick(event) {
|
|
178
170
|
// @ts-expect-error This is temporary while we revisit the Popover interface
|
|
@@ -197,15 +189,17 @@ var Popover = /*#__PURE__*/function (_React$Component) {
|
|
|
197
189
|
}, this.props.visible ? /*#__PURE__*/React__default.createElement("span", {
|
|
198
190
|
className: popoverContentClass
|
|
199
191
|
}, typeof content === 'function' ? content() : content) : null));
|
|
200
|
-
}
|
|
192
|
+
}
|
|
201
193
|
|
|
202
|
-
|
|
203
|
-
}(React__default.Component);
|
|
194
|
+
}
|
|
204
195
|
|
|
196
|
+
Popover.displayName = void 0;
|
|
197
|
+
Popover.defaultProps = void 0;
|
|
205
198
|
Popover.displayName = 'Popover';
|
|
206
199
|
Popover.defaultProps = {
|
|
207
200
|
position: 'auto',
|
|
208
|
-
gapSize: 5
|
|
201
|
+
gapSize: 5 // default size of the arrow (see `tooltip.less`)
|
|
202
|
+
|
|
209
203
|
};
|
|
210
204
|
|
|
211
205
|
export { Popover };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport { hasEnoughSpace, calculatePosition, RelativePosition } from './positioning-utils'\n\nimport './popover.less'\n\n/**\n * Position of the popover. Defaults to `auto`.\n * `auto` tries to position the tooltip to the top,\n * if there's not enough space it tries to position the tooltip clockwise (right, bottom, left).\n * Setting a distinct value like `right` will always position the popover right, regardless of available space.\n * Specifying `horizontal` will only try to position the tooltip left and right in that order.\n * Specifying `vertical` will only try to position the tooltip top and bottom in that order.\n */\ntype Position = 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal' | 'auto'\n\ntype Props = {\n visible?: boolean\n /** ref of the popover in case you need to manipulate it. */\n popoverRef?: React.Ref<HTMLElement>\n /** ref of the wrapper in case you need to manipulate it. */\n wrapperRef?: React.Ref<HTMLElement>\n /** Function to be called when the mouse enters the trigger. */\n onMouseEnter?: React.MouseEventHandler\n /** Function to be called when the mouse leaves the trigger. */\n onMouseLeave?: React.MouseEventHandler\n onClick?: React.MouseEventHandler\n /** Additional css class that is applied to the wrapper element. */\n wrapperClassName?: string\n /** Additional css class that is applied to the popover element. */\n popoverClassName?: string\n /** Additional css class that is applied to style the arrow. Not applied when `withArrow` is false. */\n arrowClassName?: string\n /** Content prop of the popover. */\n content?: (() => React.ReactNode) | React.ReactNode\n trigger?: React.ReactNode\n position: Position\n withArrow?: boolean\n /**\n * Whether vague positioning is allowed. When set to true the popover prefers to be fully visible over being correctly centered.\n */\n allowVaguePositioning?: boolean\n /** Gap between the popover wrapper and the arrow. */\n gapSize: number\n}\n\nclass Popover extends React.Component<Props> {\n public static displayName: string\n public static defaultProps: Props\n\n componentDidMount() {\n if (this.props.visible) {\n this._updatePopoverPosition()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (this.wrapper && this.props.visible) {\n const positionChanged = prevProps.position !== this.props.position\n const vaguePositioningChanged =\n prevProps.allowVaguePositioning !== this.props.allowVaguePositioning\n const visibilityChanged = prevProps.visible !== this.props.visible\n const arrowChanged = prevProps.withArrow !== this.props.withArrow\n const gapSizeChanged = prevProps.gapSize !== this.props.gapSize\n const contentChanged = prevProps.content !== this.props.content\n if (\n positionChanged ||\n vaguePositioningChanged ||\n visibilityChanged ||\n arrowChanged ||\n gapSizeChanged ||\n contentChanged\n ) {\n this._updatePopoverPosition()\n }\n }\n }\n\n popover!: HTMLElement\n wrapper!: HTMLElement\n\n _updatePopoverPosition = () => {\n const { position, allowVaguePositioning, gapSize } = this.props\n const wrapperRect = this.wrapper.getBoundingClientRect()\n const popoverRect = this.popover.getBoundingClientRect()\n\n // Instead of using the documentElement find the nearest absolutely positioned element\n const documentEl = document.documentElement\n let node = this.wrapper\n let foundParent = false\n while (!foundParent) {\n const styles = getComputedStyle(node)\n const position = styles.getPropertyValue('position')\n if (position === 'absolute' || node === documentEl || !node.parentElement) {\n foundParent = true\n } else {\n node = node.parentElement\n }\n }\n const nodeRect = node.getBoundingClientRect()\n const windowDimensions = {\n height: nodeRect.height,\n width: nodeRect.width,\n }\n\n const popoverDimensions = {\n height: popoverRect.height,\n width: popoverRect.width,\n }\n const wrapperDimensions = {\n height: wrapperRect.height,\n width: wrapperRect.width,\n }\n const wrapperPositionRelative = {\n x: wrapperRect.left - nodeRect.left,\n y: wrapperRect.top - nodeRect.top,\n }\n const wrapperPositionAbsolute = {\n x: wrapperRect.left,\n y: wrapperRect.top,\n }\n\n const positionsToTry: RelativePosition[] =\n position === 'auto'\n ? ['top', 'right', 'bottom', 'left', 'top']\n : position === 'vertical'\n ? ['top', 'bottom']\n : position === 'horizontal'\n ? ['left', 'right']\n : [position]\n\n for (let index = 0; index < positionsToTry.length; index++) {\n const currentPosition = positionsToTry[index]\n const enoughSpaceAtPosition = hasEnoughSpace(\n windowDimensions,\n popoverDimensions,\n wrapperDimensions,\n wrapperPositionRelative,\n currentPosition,\n gapSize,\n )\n\n if (enoughSpaceAtPosition || index === positionsToTry.length - 1) {\n const popoverPosition = calculatePosition(\n currentPosition,\n wrapperDimensions,\n wrapperPositionAbsolute,\n popoverDimensions,\n gapSize,\n )\n this.popover.style.top = `${popoverPosition.y}px`\n this.popover.style.left = `${popoverPosition.x}px`\n\n /**\n * Correct placement if vague positioning is allowed.\n * When it's not allowed we \"cut off\" popovers and display them\n * out of the viewport to maintain their centered position.\n */\n if (allowVaguePositioning) {\n // correct horizontally\n if (popoverPosition.x < 0) {\n this.popover.style.left = `${2 * gapSize}px`\n }\n // correct vertically\n if (popoverPosition.y + popoverDimensions.height > windowDimensions.height) {\n this.popover.style.top = `${\n windowDimensions.height - popoverDimensions.height - 2 * gapSize\n }px`\n }\n }\n\n if (currentPosition !== position) {\n this.popover.className = this._getClassNameForPosition(currentPosition)\n }\n break\n }\n }\n }\n\n _getClassNameForPosition = (position: Position) => {\n const { visible, withArrow, arrowClassName } = this.props\n const className = classNames('reactist_popover', { visible })\n\n if (visible && withArrow) {\n return classNames(className, arrowClassName, {\n arrow_top: position === 'bottom',\n arrow_right: position === 'left',\n arrow_bottom: position === 'auto' || position === 'top',\n arrow_left: position === 'right',\n })\n }\n return className\n }\n\n _updatePopoverRef = (popover: HTMLElement) => {\n this.popover = popover\n if (typeof this.props.popoverRef === 'function') {\n this.props.popoverRef(popover)\n }\n }\n\n _updateWrapperRef = (wrapper: HTMLElement) => {\n this.wrapper = wrapper\n if (typeof this.props.wrapperRef === 'function') {\n this.props.wrapperRef(wrapper)\n }\n }\n\n render() {\n const {\n position,\n wrapperClassName,\n popoverClassName,\n onMouseEnter,\n onMouseLeave,\n onClick,\n trigger,\n content,\n } = this.props\n const popoverClass = position ? this._getClassNameForPosition(position) : ''\n const popoverContentClass = classNames('reactist_popover__content', popoverClassName)\n const wrapperClass = classNames('reactist_popover__wrapper', wrapperClassName)\n const triggerElement = React.Children.only<React.ReactElement>(\n trigger as React.ReactElement,\n )\n\n function handleTriggerClick(event: React.SyntheticEvent) {\n // @ts-expect-error This is temporary while we revisit the Popover interface\n if (onClick) onClick(event)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (typeof triggerElement.props.onClick === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n triggerElement.props.onClick(event)\n }\n }\n\n return (\n <span\n className={wrapperClass}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={this._updateWrapperRef}\n >\n {React.cloneElement(triggerElement, { onClick: handleTriggerClick })}\n <span className={popoverClass} ref={this._updatePopoverRef}>\n {this.props.visible ? (\n <span className={popoverContentClass}>\n {typeof content === 'function' ? content() : content}\n </span>\n ) : null}\n </span>\n </span>\n )\n }\n}\nPopover.displayName = 'Popover'\nPopover.defaultProps = {\n position: 'auto',\n gapSize: 5, // default size of the arrow (see `tooltip.less`)\n}\n\nexport { Popover }\n"],"names":["Popover","props","position","allowVaguePositioning","gapSize","wrapperRect","wrapper","getBoundingClientRect","popoverRect","popover","documentEl","document","documentElement","node","foundParent","styles","getComputedStyle","getPropertyValue","parentElement","nodeRect","windowDimensions","height","width","popoverDimensions","wrapperDimensions","wrapperPositionRelative","x","left","y","top","wrapperPositionAbsolute","positionsToTry","index","length","currentPosition","enoughSpaceAtPosition","hasEnoughSpace","popoverPosition","calculatePosition","style","className","_getClassNameForPosition","visible","withArrow","arrowClassName","classNames","arrow_top","arrow_right","arrow_bottom","arrow_left","popoverRef","wrapperRef","componentDidMount","_updatePopoverPosition","componentDidUpdate","prevProps","positionChanged","vaguePositioningChanged","visibilityChanged","arrowChanged","gapSizeChanged","contentChanged","content","render","wrapperClassName","popoverClassName","onMouseEnter","onMouseLeave","onClick","trigger","popoverClass","popoverContentClass","wrapperClass","triggerElement","React","Children","only","handleTriggerClick","event","ref","_updateWrapperRef","cloneElement","_updatePopoverRef","Component","displayName","defaultProps"],"mappings":";;;;;IA+CMA;;;AAAN;;;;;AAmCI,gCAAA,GAAyB;AACrB,wBAAqD,MAAKC,KAA1D;AAAA,UAAQC,QAAR,eAAQA,QAAR;AAAA,UAAkBC,qBAAlB,eAAkBA,qBAAlB;AAAA,UAAyCC,OAAzC,eAAyCA,OAAzC;;AACA,UAAMC,WAAW,GAAG,MAAKC,OAAL,CAAaC,qBAAb,EAApB;;AACA,UAAMC,WAAW,GAAG,MAAKC,OAAL,CAAaF,qBAAb,EAApB;;;AAGA,UAAMG,UAAU,GAAGC,QAAQ,CAACC,eAA5B;AACA,UAAIC,IAAI,GAAG,MAAKP,OAAhB;AACA,UAAIQ,WAAW,GAAG,KAAlB;;AACA,aAAO,CAACA,WAAR,EAAqB;AACjB,YAAMC,MAAM,GAAGC,gBAAgB,CAACH,IAAD,CAA/B;;AACA,YAAMX,SAAQ,GAAGa,MAAM,CAACE,gBAAP,CAAwB,UAAxB,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EAA8BmB,gBAA9B,CAA/B;AACA,QAAMS,cAAc,GAAGC,cAAK,CAACC,QAAN,CAAeC,IAAf,CACnBP,OADmB,CAAvB;;AAIA,aAASQ,kBAAT,CAA4BC,KAA5B;AACI;AACA,UAAIV,OAAJ,EAAaA,OAAO,CAACU,KAAD,CAAP;;AAEb,UAAI,OAAOL,cAAc,CAACxE,KAAf,CAAqBmE,OAA5B,KAAwC,UAA5C,EAAwD;AACpD;AACAK,QAAAA,cAAc,CAACxE,KAAf,CAAqBmE,OAArB,CAA6BU,KAA7B;AACH;AACJ;;AAED,wBACIJ,4BAAA,OAAA;AACIlC,MAAAA,SAAS,EAAEgC;AACXN,MAAAA,YAAY,EAAEA;AACdC,MAAAA,YAAY,EAAEA;AACdY,MAAAA,GAAG,EAAE,KAAKC;KAJd,eAMKN,cAAK,CAACO,YAAN,CAAmBR,cAAnB,EAAmC;AAAEL,MAAAA,OAAO,EAAES;AAAX,KAAnC,CANL,eAOIH,4BAAA,OAAA;AAAMlC,MAAAA,SAAS,EAAE8B;AAAcS,MAAAA,GAAG,EAAE,KAAKG;KAAzC,EACK,KAAKjF,KAAL,CAAWyC,OAAX,gBACGgC,4BAAA,OAAA;AAAMlC,MAAAA,SAAS,EAAE+B;KAAjB,EACK,OAAOT,OAAP,KAAmB,UAAnB,GAAgCA,OAAO,EAAvC,GAA4CA,OADjD,CADH,GAIG,IALR,CAPJ,CADJ;AAiBH;;;EA/MiBY,cAAK,CAACS;;AAiN5BnF,OAAO,CAACoF,WAAR,GAAsB,SAAtB;AACApF,OAAO,CAACqF,YAAR,GAAuB;AACnBnF,EAAAA,QAAQ,EAAE,MADS;AAEnBE,EAAAA,OAAO,EAAE;AAFU,CAAvB;;;;"}
|
|
1
|
+
{"version":3,"file":"popover.js","sources":["../../../src/components/popover/popover.tsx"],"sourcesContent":["import React from 'react'\nimport classNames from 'classnames'\n\nimport { hasEnoughSpace, calculatePosition, RelativePosition } from './positioning-utils'\n\nimport './popover.less'\n\n/**\n * Position of the popover. Defaults to `auto`.\n * `auto` tries to position the tooltip to the top,\n * if there's not enough space it tries to position the tooltip clockwise (right, bottom, left).\n * Setting a distinct value like `right` will always position the popover right, regardless of available space.\n * Specifying `horizontal` will only try to position the tooltip left and right in that order.\n * Specifying `vertical` will only try to position the tooltip top and bottom in that order.\n */\ntype Position = 'left' | 'right' | 'top' | 'bottom' | 'vertical' | 'horizontal' | 'auto'\n\ntype Props = {\n visible?: boolean\n /** ref of the popover in case you need to manipulate it. */\n popoverRef?: React.Ref<HTMLElement>\n /** ref of the wrapper in case you need to manipulate it. */\n wrapperRef?: React.Ref<HTMLElement>\n /** Function to be called when the mouse enters the trigger. */\n onMouseEnter?: React.MouseEventHandler\n /** Function to be called when the mouse leaves the trigger. */\n onMouseLeave?: React.MouseEventHandler\n onClick?: React.MouseEventHandler\n /** Additional css class that is applied to the wrapper element. */\n wrapperClassName?: string\n /** Additional css class that is applied to the popover element. */\n popoverClassName?: string\n /** Additional css class that is applied to style the arrow. Not applied when `withArrow` is false. */\n arrowClassName?: string\n /** Content prop of the popover. */\n content?: (() => React.ReactNode) | React.ReactNode\n trigger?: React.ReactNode\n position: Position\n withArrow?: boolean\n /**\n * Whether vague positioning is allowed. When set to true the popover prefers to be fully visible over being correctly centered.\n */\n allowVaguePositioning?: boolean\n /** Gap between the popover wrapper and the arrow. */\n gapSize: number\n}\n\nclass Popover extends React.Component<Props> {\n public static displayName: string\n public static defaultProps: Props\n\n componentDidMount() {\n if (this.props.visible) {\n this._updatePopoverPosition()\n }\n }\n\n componentDidUpdate(prevProps: Props) {\n if (this.wrapper && this.props.visible) {\n const positionChanged = prevProps.position !== this.props.position\n const vaguePositioningChanged =\n prevProps.allowVaguePositioning !== this.props.allowVaguePositioning\n const visibilityChanged = prevProps.visible !== this.props.visible\n const arrowChanged = prevProps.withArrow !== this.props.withArrow\n const gapSizeChanged = prevProps.gapSize !== this.props.gapSize\n const contentChanged = prevProps.content !== this.props.content\n if (\n positionChanged ||\n vaguePositioningChanged ||\n visibilityChanged ||\n arrowChanged ||\n gapSizeChanged ||\n contentChanged\n ) {\n this._updatePopoverPosition()\n }\n }\n }\n\n popover!: HTMLElement\n wrapper!: HTMLElement\n\n _updatePopoverPosition = () => {\n const { position, allowVaguePositioning, gapSize } = this.props\n const wrapperRect = this.wrapper.getBoundingClientRect()\n const popoverRect = this.popover.getBoundingClientRect()\n\n // Instead of using the documentElement find the nearest absolutely positioned element\n const documentEl = document.documentElement\n let node = this.wrapper\n let foundParent = false\n while (!foundParent) {\n const styles = getComputedStyle(node)\n const position = styles.getPropertyValue('position')\n if (position === 'absolute' || node === documentEl || !node.parentElement) {\n foundParent = true\n } else {\n node = node.parentElement\n }\n }\n const nodeRect = node.getBoundingClientRect()\n const windowDimensions = {\n height: nodeRect.height,\n width: nodeRect.width,\n }\n\n const popoverDimensions = {\n height: popoverRect.height,\n width: popoverRect.width,\n }\n const wrapperDimensions = {\n height: wrapperRect.height,\n width: wrapperRect.width,\n }\n const wrapperPositionRelative = {\n x: wrapperRect.left - nodeRect.left,\n y: wrapperRect.top - nodeRect.top,\n }\n const wrapperPositionAbsolute = {\n x: wrapperRect.left,\n y: wrapperRect.top,\n }\n\n const positionsToTry: RelativePosition[] =\n position === 'auto'\n ? ['top', 'right', 'bottom', 'left', 'top']\n : position === 'vertical'\n ? ['top', 'bottom']\n : position === 'horizontal'\n ? ['left', 'right']\n : [position]\n\n for (let index = 0; index < positionsToTry.length; index++) {\n const currentPosition = positionsToTry[index]\n const enoughSpaceAtPosition =\n currentPosition != null\n ? hasEnoughSpace(\n windowDimensions,\n popoverDimensions,\n wrapperDimensions,\n wrapperPositionRelative,\n currentPosition,\n gapSize,\n )\n : false\n\n if (enoughSpaceAtPosition || index === positionsToTry.length - 1) {\n const popoverPosition =\n currentPosition != null\n ? calculatePosition(\n currentPosition,\n wrapperDimensions,\n wrapperPositionAbsolute,\n popoverDimensions,\n gapSize,\n )\n : wrapperPositionAbsolute\n this.popover.style.top = `${popoverPosition.y}px`\n this.popover.style.left = `${popoverPosition.x}px`\n\n /**\n * Correct placement if vague positioning is allowed.\n * When it's not allowed we \"cut off\" popovers and display them\n * out of the viewport to maintain their centered position.\n */\n if (allowVaguePositioning) {\n // correct horizontally\n if (popoverPosition.x < 0) {\n this.popover.style.left = `${2 * gapSize}px`\n }\n // correct vertically\n if (popoverPosition.y + popoverDimensions.height > windowDimensions.height) {\n this.popover.style.top = `${\n windowDimensions.height - popoverDimensions.height - 2 * gapSize\n }px`\n }\n }\n\n if (currentPosition !== position) {\n this.popover.className = this._getClassNameForPosition(currentPosition)\n }\n break\n }\n }\n }\n\n _getClassNameForPosition = (position: Position | undefined) => {\n const { visible, withArrow, arrowClassName } = this.props\n const className = classNames('reactist_popover', { visible })\n\n if (visible && withArrow) {\n return classNames(className, arrowClassName, {\n arrow_top: position === 'bottom',\n arrow_right: position === 'left',\n arrow_bottom: position === 'auto' || position === 'top',\n arrow_left: position === 'right',\n })\n }\n return className\n }\n\n _updatePopoverRef = (popover: HTMLElement) => {\n this.popover = popover\n if (typeof this.props.popoverRef === 'function') {\n this.props.popoverRef(popover)\n }\n }\n\n _updateWrapperRef = (wrapper: HTMLElement) => {\n this.wrapper = wrapper\n if (typeof this.props.wrapperRef === 'function') {\n this.props.wrapperRef(wrapper)\n }\n }\n\n render() {\n const {\n position,\n wrapperClassName,\n popoverClassName,\n onMouseEnter,\n onMouseLeave,\n onClick,\n trigger,\n content,\n } = this.props\n const popoverClass = position ? this._getClassNameForPosition(position) : ''\n const popoverContentClass = classNames('reactist_popover__content', popoverClassName)\n const wrapperClass = classNames('reactist_popover__wrapper', wrapperClassName)\n const triggerElement = React.Children.only<React.ReactElement>(\n trigger as React.ReactElement,\n )\n\n function handleTriggerClick(event: React.SyntheticEvent) {\n // @ts-expect-error This is temporary while we revisit the Popover interface\n if (onClick) onClick(event)\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n if (typeof triggerElement.props.onClick === 'function') {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call\n triggerElement.props.onClick(event)\n }\n }\n\n return (\n <span\n className={wrapperClass}\n onMouseEnter={onMouseEnter}\n onMouseLeave={onMouseLeave}\n ref={this._updateWrapperRef}\n >\n {React.cloneElement(triggerElement, { onClick: handleTriggerClick })}\n <span className={popoverClass} ref={this._updatePopoverRef}>\n {this.props.visible ? (\n <span className={popoverContentClass}>\n {typeof content === 'function' ? content() : content}\n </span>\n ) : null}\n </span>\n </span>\n )\n }\n}\nPopover.displayName = 'Popover'\nPopover.defaultProps = {\n position: 'auto',\n gapSize: 5, // default size of the arrow (see `tooltip.less`)\n}\n\nexport { Popover }\n"],"names":["Popover","React","Component","popover","wrapper","_updatePopoverPosition","position","allowVaguePositioning","gapSize","props","wrapperRect","getBoundingClientRect","popoverRect","documentEl","document","documentElement","node","foundParent","styles","getComputedStyle","getPropertyValue","parentElement","nodeRect","windowDimensions","height","width","popoverDimensions","wrapperDimensions","wrapperPositionRelative","x","left","y","top","wrapperPositionAbsolute","positionsToTry","index","length","currentPosition","enoughSpaceAtPosition","hasEnoughSpace","popoverPosition","calculatePosition","style","className","_getClassNameForPosition","visible","withArrow","arrowClassName","classNames","arrow_top","arrow_right","arrow_bottom","arrow_left","_updatePopoverRef","popoverRef","_updateWrapperRef","wrapperRef","componentDidMount","componentDidUpdate","prevProps","positionChanged","vaguePositioningChanged","visibilityChanged","arrowChanged","gapSizeChanged","contentChanged","content","render","wrapperClassName","popoverClassName","onMouseEnter","onMouseLeave","onClick","trigger","popoverClass","popoverContentClass","wrapperClass","triggerElement","Children","only","handleTriggerClick","event","ref","cloneElement","displayName","defaultProps"],"mappings":";;;;AA+CA,MAAMA,OAAN,SAAsBC,cAAK,CAACC,SAA5B;;;SAgCIC;SACAC;;SAEAC,yBAAyB;MACrB,MAAM;QAAEC,QAAF;QAAYC,qBAAZ;QAAmCC;UAAY,KAAKC,KAA1D;MACA,MAAMC,WAAW,GAAG,KAAKN,OAAL,CAA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