@openedx/paragon 23.22.1 → 23.23.0
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/README.md +25 -54
- package/dist/Alert/index.js +0 -1
- package/dist/Alert/index.js.map +1 -1
- package/dist/Card/BaseCard.d.ts +7 -0
- package/dist/Card/BaseCard.js +0 -21
- package/dist/Card/BaseCard.js.map +1 -1
- package/dist/Chip/ChipIcon.d.ts +7 -18
- package/dist/Chip/ChipIcon.js +2 -17
- package/dist/Chip/ChipIcon.js.map +1 -1
- package/dist/Chip/index.js +6 -2
- package/dist/Chip/index.js.map +1 -1
- package/dist/Modal/ModalDialogHeader.d.ts +3 -0
- package/dist/Modal/ModalDialogHeader.js +0 -13
- package/dist/Modal/ModalDialogHeader.js.map +1 -1
- package/dist/Overlay/index.d.ts +86 -123
- package/dist/Overlay/index.js +25 -123
- package/dist/Overlay/index.js.map +1 -1
- package/dist/Tooltip/index.d.ts +16 -0
- package/dist/Tooltip/index.js +4 -48
- package/dist/Tooltip/index.js.map +1 -1
- package/lib/__tests__/build-scss.test.js +1 -1
- package/lib/__tests__/install-theme.test.js +2 -2
- package/lib/install-theme.js +1 -1
- package/package.json +4 -4
- package/src/Alert/index.tsx +0 -1
- package/src/Card/BaseCard.tsx +7 -21
- package/src/Chip/ChipIcon.tsx +16 -24
- package/src/Chip/index.tsx +8 -4
- package/src/Modal/ModalDialogHeader.tsx +5 -17
- package/src/Overlay/index.tsx +88 -120
- package/src/Tooltip/index.tsx +21 -69
package/src/Card/BaseCard.tsx
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
|
|
5
4
|
import type { ComponentWithAsProp, BsPropsWithAs } from '../utils/types/bootstrap';
|
|
@@ -28,12 +27,19 @@ const textVariants = [
|
|
|
28
27
|
type ColorVariant = typeof colorVariants[number];
|
|
29
28
|
type TextVariant = typeof textVariants[number];
|
|
30
29
|
interface Props extends BsPropsWithAs {
|
|
30
|
+
/** Prefix for component CSS classes. */
|
|
31
31
|
prefix?: string;
|
|
32
|
+
/** Background color of the card. */
|
|
32
33
|
bgColor?: ColorVariant;
|
|
34
|
+
/** Text color of the card. */
|
|
33
35
|
textColor?: ColorVariant | TextVariant;
|
|
36
|
+
/** Border color of the card. */
|
|
34
37
|
borderColor?: ColorVariant;
|
|
38
|
+
/** Determines whether the card should render its children inside a `CardBody` wrapper. */
|
|
35
39
|
hasBody?: boolean;
|
|
40
|
+
/** Additional CSS class names to apply to the card element. */
|
|
36
41
|
className?: string;
|
|
42
|
+
/** The content to render inside the card. */
|
|
37
43
|
children: React.ReactNode;
|
|
38
44
|
}
|
|
39
45
|
type BaseCardType = ComponentWithAsProp<'div', Props>;
|
|
@@ -69,24 +75,4 @@ const BaseCard : BaseCardType = React.forwardRef<HTMLDivElement, Props>(
|
|
|
69
75
|
},
|
|
70
76
|
);
|
|
71
77
|
|
|
72
|
-
/* eslint-disable react/require-default-props */
|
|
73
|
-
BaseCard.propTypes = {
|
|
74
|
-
/** Prefix for component CSS classes. */
|
|
75
|
-
prefix: PropTypes.string,
|
|
76
|
-
/** Background color of the card. */
|
|
77
|
-
bgColor: PropTypes.oneOf(colorVariants),
|
|
78
|
-
/** Text color of the card. */
|
|
79
|
-
textColor: PropTypes.oneOf([...colorVariants, ...textVariants]),
|
|
80
|
-
/** Border color of the card. */
|
|
81
|
-
borderColor: PropTypes.oneOf(colorVariants),
|
|
82
|
-
/** Determines whether the card should render its children inside a `CardBody` wrapper. */
|
|
83
|
-
hasBody: PropTypes.bool,
|
|
84
|
-
/** Set a custom element for this component. */
|
|
85
|
-
as: PropTypes.elementType,
|
|
86
|
-
/** Additional CSS class names to apply to the card element. */
|
|
87
|
-
className: PropTypes.string,
|
|
88
|
-
/** The content to render inside the card. */
|
|
89
|
-
children: PropTypes.node,
|
|
90
|
-
};
|
|
91
|
-
|
|
92
78
|
export default BaseCard;
|
package/src/Chip/ChipIcon.tsx
CHANGED
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
import React, { KeyboardEventHandler, MouseEventHandler } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import Icon from '../Icon';
|
|
4
3
|
import IconButton from '../IconButton';
|
|
5
4
|
import { STYLE_VARIANTS } from './constants';
|
|
6
5
|
|
|
7
6
|
export type ChipIconProps = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
/** Additional CSS class name(s) to append to the base element. */
|
|
8
|
+
className: string;
|
|
9
|
+
/** The icon component to render. */
|
|
10
|
+
src: React.ComponentType;
|
|
11
|
+
/** The visual style variant of the chip icon. */
|
|
12
|
+
variant?: typeof STYLE_VARIANTS[keyof typeof STYLE_VARIANTS];
|
|
13
|
+
/** Whether the icon is in a disabled state. */
|
|
14
|
+
disabled?: boolean;
|
|
12
15
|
} & (
|
|
13
16
|
// Either _both_ onClick and alt are provided, or neither is:
|
|
14
|
-
| {
|
|
15
|
-
|
|
17
|
+
| {
|
|
18
|
+
/** Callback for click and keyboard events on the icon button. */
|
|
19
|
+
onClick: KeyboardEventHandler<HTMLButtonElement> & MouseEventHandler<HTMLButtonElement>;
|
|
20
|
+
/** Accessible label for the icon button. Required when `onClick` is provided. */
|
|
21
|
+
alt: string;
|
|
22
|
+
}
|
|
23
|
+
| { onClick?: undefined; alt?: undefined }
|
|
16
24
|
);
|
|
17
25
|
|
|
18
26
|
function ChipIcon({
|
|
19
|
-
className, src, onClick, alt, variant, disabled,
|
|
27
|
+
className, src, onClick, alt, variant = STYLE_VARIANTS.LIGHT, disabled = false,
|
|
20
28
|
}: ChipIconProps) {
|
|
21
29
|
if (onClick) {
|
|
22
30
|
return (
|
|
@@ -35,20 +43,4 @@ function ChipIcon({
|
|
|
35
43
|
return <Icon src={src} className={className} size="sm" />;
|
|
36
44
|
}
|
|
37
45
|
|
|
38
|
-
ChipIcon.propTypes = {
|
|
39
|
-
className: PropTypes.string.isRequired,
|
|
40
|
-
src: PropTypes.oneOfType([PropTypes.element, PropTypes.func]).isRequired,
|
|
41
|
-
onClick: PropTypes.func,
|
|
42
|
-
alt: PropTypes.string,
|
|
43
|
-
variant: PropTypes.string,
|
|
44
|
-
disabled: PropTypes.bool,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
ChipIcon.defaultProps = {
|
|
48
|
-
onClick: undefined,
|
|
49
|
-
alt: undefined,
|
|
50
|
-
variant: STYLE_VARIANTS.LIGHT,
|
|
51
|
-
disabled: false,
|
|
52
|
-
};
|
|
53
|
-
|
|
54
46
|
export default ChipIcon;
|
package/src/Chip/index.tsx
CHANGED
|
@@ -83,8 +83,10 @@ const Chip = React.forwardRef(({
|
|
|
83
83
|
<ChipIcon
|
|
84
84
|
className={`${CHIP_PGN_CLASS}__icon-before`}
|
|
85
85
|
src={iconBefore}
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
/* The following two props should only be passed if _both_ are defined, but we haven't been checking that nor
|
|
87
|
+
enforcing it at runtime, so doing so now would be a breaking change. Hence the `!` */
|
|
88
|
+
onClick={onIconBeforeClick!}
|
|
89
|
+
alt={iconBeforeAlt!}
|
|
88
90
|
variant={variant}
|
|
89
91
|
disabled={disabled}
|
|
90
92
|
/>
|
|
@@ -101,8 +103,10 @@ const Chip = React.forwardRef(({
|
|
|
101
103
|
<ChipIcon
|
|
102
104
|
className={`${CHIP_PGN_CLASS}__icon-after`}
|
|
103
105
|
src={iconAfter}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
/* The following two props should only be passed if _both_ are defined, but we haven't been checking that nor
|
|
107
|
+
enforcing it at runtime, so doing so now would be a breaking change. Hence the `!` */
|
|
108
|
+
onClick={onIconAfterClick!}
|
|
109
|
+
alt={iconAfterAlt!}
|
|
106
110
|
variant={variant}
|
|
107
111
|
disabled={disabled}
|
|
108
112
|
/>
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import type { ComponentWithAsProp } from '../utils/types/bootstrap';
|
|
5
4
|
|
|
6
5
|
export interface Props {
|
|
6
|
+
/** Specifies the base element. */
|
|
7
7
|
as?: string;
|
|
8
|
+
/** Specifies the contents of the header. */
|
|
8
9
|
children: React.ReactNode;
|
|
10
|
+
/** Specifies class name to append to the base element. */
|
|
9
11
|
className?: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
type HeaderType = ComponentWithAsProp<'div', Props>;
|
|
13
15
|
|
|
14
|
-
const ModalDialogHeader: HeaderType = React.forwardRef
|
|
16
|
+
const ModalDialogHeader: HeaderType = React.forwardRef(({
|
|
15
17
|
as = 'div',
|
|
16
18
|
children,
|
|
17
19
|
...props
|
|
18
|
-
}, ref) => (
|
|
20
|
+
}: Props, ref: React.ForwardedRef<HTMLDivElement>) => (
|
|
19
21
|
React.createElement(
|
|
20
22
|
as,
|
|
21
23
|
{
|
|
@@ -27,18 +29,4 @@ const ModalDialogHeader: HeaderType = React.forwardRef<HTMLDivElement, Props>(({
|
|
|
27
29
|
)
|
|
28
30
|
));
|
|
29
31
|
|
|
30
|
-
ModalDialogHeader.propTypes = {
|
|
31
|
-
/** Specifies the base element */
|
|
32
|
-
as: PropTypes.elementType,
|
|
33
|
-
/** Specifies the contents of the header */
|
|
34
|
-
children: PropTypes.node.isRequired,
|
|
35
|
-
/** Specifies class name to append to the base element */
|
|
36
|
-
className: PropTypes.string,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
ModalDialogHeader.defaultProps = {
|
|
40
|
-
as: 'div',
|
|
41
|
-
className: '',
|
|
42
|
-
};
|
|
43
|
-
|
|
44
32
|
export default ModalDialogHeader;
|
package/src/Overlay/index.tsx
CHANGED
|
@@ -1,169 +1,137 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import BaseOverlay, { type OverlayProps, type Placement } from 'react-bootstrap/Overlay';
|
|
2
|
+
import BaseOverlay, { type OverlayProps, type OverlayChildren, type Placement } from 'react-bootstrap/Overlay';
|
|
3
3
|
import BaseOverlayTrigger, { type OverlayTriggerProps, type OverlayTriggerType } from 'react-bootstrap/OverlayTrigger';
|
|
4
4
|
import Fade from 'react-bootstrap/Fade';
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
6
5
|
|
|
7
|
-
// Note: The only thing this file adds to the base
|
|
6
|
+
// Note: The only thing this file adds to the base components is default prop values.
|
|
8
7
|
// As more Paragon consumers adopt TypeScript, we could consider removing almost all of this code
|
|
9
8
|
// and just re-export the Overlay and OverlayTrigger components from react-bootstrap unmodified.
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
'auto-start',
|
|
13
|
-
'auto',
|
|
14
|
-
'auto-end',
|
|
15
|
-
'top-start',
|
|
16
|
-
'top',
|
|
17
|
-
'top-end',
|
|
18
|
-
'right-start',
|
|
19
|
-
'right',
|
|
20
|
-
'right-end',
|
|
21
|
-
'bottom-end',
|
|
22
|
-
'bottom',
|
|
23
|
-
'bottom-start',
|
|
24
|
-
'left-end',
|
|
25
|
-
'left',
|
|
26
|
-
'left-start',
|
|
27
|
-
];
|
|
28
|
-
|
|
29
|
-
const TRIGGER_VARIANTS: OverlayTriggerType[] = [
|
|
30
|
-
'hover',
|
|
31
|
-
'click',
|
|
32
|
-
'focus',
|
|
33
|
-
];
|
|
34
|
-
|
|
35
|
-
function Overlay(props: OverlayProps) {
|
|
36
|
-
return <BaseOverlay {...props} />;
|
|
37
|
-
}
|
|
38
|
-
function OverlayTrigger(props: OverlayTriggerProps) {
|
|
39
|
-
return (
|
|
40
|
-
<BaseOverlayTrigger {...props}>
|
|
41
|
-
{props.children}
|
|
42
|
-
</BaseOverlayTrigger>
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const triggerType = PropTypes.oneOf(TRIGGER_VARIANTS);
|
|
47
|
-
|
|
48
|
-
Overlay.propTypes = {
|
|
10
|
+
export interface ParagonOverlayProps extends Omit<OverlayProps, 'target'> {
|
|
49
11
|
/** Specifies the content of the `Overlay`. */
|
|
50
|
-
children:
|
|
12
|
+
children: OverlayChildren;
|
|
51
13
|
/**
|
|
52
14
|
* A component instance, DOM node, or function that returns either.
|
|
53
15
|
* The overlay will be positioned in relation to the target.
|
|
54
16
|
*/
|
|
55
|
-
container
|
|
17
|
+
container?: OverlayProps['container'];
|
|
56
18
|
/** Callback fired before the `Overlay` transitions in. */
|
|
57
|
-
onEnter:
|
|
19
|
+
onEnter?: (node: HTMLElement, isAppearing: boolean) => any;
|
|
58
20
|
/** Callback fired after the `Overlay` finishes transitioning in. */
|
|
59
|
-
onEntered:
|
|
21
|
+
onEntered?: (node: HTMLElement, isAppearing: boolean) => any;
|
|
60
22
|
/** Callback fired as the `Overlay` begins to transition in. */
|
|
61
|
-
onEntering:
|
|
62
|
-
/** Callback fired right before the `Overlay` transitions out */
|
|
63
|
-
onExit:
|
|
23
|
+
onEntering?: (node: HTMLElement, isAppearing: boolean) => any;
|
|
24
|
+
/** Callback fired right before the `Overlay` transitions out. */
|
|
25
|
+
onExit?: (node: HTMLElement) => any;
|
|
64
26
|
/** Callback fired after the `Overlay` finishes transitioning out. */
|
|
65
|
-
onExited:
|
|
27
|
+
onExited?: (node: HTMLElement) => any;
|
|
66
28
|
/** Callback fired as the Overlay begins to transition out. */
|
|
67
|
-
onExiting:
|
|
29
|
+
onExiting?: (node: HTMLElement) => any;
|
|
68
30
|
/**
|
|
69
31
|
* A callback invoked by the overlay when it wishes to be hidden.
|
|
70
32
|
* Required if `rootClose` is specified.
|
|
71
33
|
*/
|
|
72
|
-
onHide:
|
|
73
|
-
/**
|
|
74
|
-
|
|
34
|
+
onHide?: (e: Event) => void;
|
|
35
|
+
/**
|
|
36
|
+
* The placement of the `Overlay` in relation to its target.
|
|
37
|
+
*
|
|
38
|
+
* Valid values are: `auto`, `auto-start`, `auto-end`, `top`, `bottom`, `right`, `left`,
|
|
39
|
+
* `top-start`, `top-end`, `bottom-start`, `bottom-end`, `right-start`, `right-end`, `left-start`, `left-end`.
|
|
40
|
+
*/
|
|
41
|
+
placement?: Placement;
|
|
75
42
|
/** A set of popper options and props passed directly to `Popper`. */
|
|
76
|
-
popperConfig
|
|
43
|
+
popperConfig?: OverlayProps['popperConfig'];
|
|
77
44
|
/** Specify whether the overlay should trigger `onHide` when the user clicks outside the overlay. */
|
|
78
|
-
rootClose
|
|
79
|
-
/** Specify event for triggering a
|
|
80
|
-
rootCloseEvent
|
|
45
|
+
rootClose?: boolean;
|
|
46
|
+
/** Specify event for triggering a "root close" toggle. */
|
|
47
|
+
rootCloseEvent?: OverlayProps['rootCloseEvent'];
|
|
81
48
|
/** Set the visibility of the `Overlay`. */
|
|
82
|
-
show
|
|
49
|
+
show?: boolean;
|
|
83
50
|
/**
|
|
84
|
-
* The
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
* Manually toggling show does not wait for delay to change the visibility.
|
|
88
|
-
*
|
|
89
|
-
* Controls `onToggle`.
|
|
51
|
+
* The target element the `Overlay` is positioned in relation to.
|
|
52
|
+
* Note: this is marked optional for backwards compatibility, but it is required for the overlay to work,
|
|
53
|
+
* and the upstream types mark it as required.
|
|
90
54
|
*/
|
|
91
|
-
target
|
|
55
|
+
target?: OverlayProps['target'];
|
|
92
56
|
/**
|
|
93
57
|
* Animate the entering and exiting of the Overlay. `true` will use the `<Fade>` transition,
|
|
94
58
|
* or a custom react-transition-group `<Transition>` component can be provided.
|
|
95
59
|
*/
|
|
96
|
-
transition
|
|
97
|
-
}
|
|
60
|
+
transition?: OverlayProps['transition'];
|
|
61
|
+
}
|
|
98
62
|
|
|
99
|
-
|
|
63
|
+
export interface ParagonOverlayTriggerProps extends OverlayTriggerProps {
|
|
100
64
|
/** Specifies the content of the `OverlayTrigger`. */
|
|
101
|
-
children:
|
|
65
|
+
children: OverlayTriggerProps['children'];
|
|
102
66
|
/** An element or text to overlay next to the target. */
|
|
103
|
-
overlay:
|
|
67
|
+
overlay: OverlayTriggerProps['overlay'];
|
|
104
68
|
/** The initial visibility state of the `Overlay`. */
|
|
105
|
-
defaultShow
|
|
69
|
+
defaultShow?: boolean;
|
|
106
70
|
/** A millisecond delay amount to show and hide the `Overlay` once triggered. */
|
|
107
|
-
delay
|
|
71
|
+
delay?: OverlayTriggerProps['delay'];
|
|
108
72
|
/** The initial flip state of the `Overlay`. */
|
|
109
|
-
flip
|
|
110
|
-
|
|
73
|
+
flip?: boolean;
|
|
74
|
+
/** Callback fired when the visibility of the overlay changes. */
|
|
75
|
+
onHide?: OverlayTriggerProps['onHide'];
|
|
111
76
|
/**
|
|
112
77
|
* A callback that fires when the user triggers a change in tooltip visibility.
|
|
113
78
|
* `onToggle` is called with the desired next show, and generally should be
|
|
114
79
|
* passed back to the `show` prop. `onToggle` fires after the configured `delay`.
|
|
115
|
-
*
|
|
116
|
-
* Controls `show`.
|
|
117
80
|
*/
|
|
118
|
-
onToggle
|
|
119
|
-
/** The placement of the `Overlay` in relation to
|
|
120
|
-
placement
|
|
121
|
-
/** A `Popper.js` config object passed to the
|
|
122
|
-
popperConfig
|
|
81
|
+
onToggle?: OverlayTriggerProps['onToggle'];
|
|
82
|
+
/** The placement of the `Overlay` in relation to its target. */
|
|
83
|
+
placement?: Placement;
|
|
84
|
+
/** A `Popper.js` config object passed to the underlying popper instance. */
|
|
85
|
+
popperConfig?: OverlayTriggerProps['popperConfig'];
|
|
123
86
|
/**
|
|
124
|
-
* The visibility of the `Overlay`. `show` is a controlled prop so should
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* Manually toggling show does not wait for delay to change the visibility.
|
|
128
|
-
*
|
|
129
|
-
* Controls `onToggle`.
|
|
87
|
+
* The visibility of the `Overlay`. `show` is a controlled prop so should be
|
|
88
|
+
* paired with `onToggle` to avoid breaking user interactions.
|
|
130
89
|
*/
|
|
131
|
-
show
|
|
132
|
-
target
|
|
90
|
+
show?: boolean;
|
|
91
|
+
/** The target element the `Overlay` is positioned in relation to. */
|
|
92
|
+
target?: OverlayTriggerProps['target'];
|
|
133
93
|
/** Specify which action or actions trigger `Overlay` visibility. */
|
|
134
|
-
trigger
|
|
135
|
-
}
|
|
94
|
+
trigger?: OverlayTriggerType | OverlayTriggerType[];
|
|
95
|
+
}
|
|
136
96
|
|
|
137
|
-
Overlay
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
}
|
|
97
|
+
function Overlay({
|
|
98
|
+
placement = 'top',
|
|
99
|
+
popperConfig = {},
|
|
100
|
+
rootClose = false,
|
|
101
|
+
show = false,
|
|
102
|
+
transition = Fade,
|
|
103
|
+
...props
|
|
104
|
+
}: ParagonOverlayProps) {
|
|
105
|
+
return (
|
|
106
|
+
<BaseOverlay
|
|
107
|
+
placement={placement}
|
|
108
|
+
popperConfig={popperConfig}
|
|
109
|
+
rootClose={rootClose}
|
|
110
|
+
show={show}
|
|
111
|
+
transition={transition}
|
|
112
|
+
// `target` is currently optional for Paragon consumers, but react-bootstrap types it as required.
|
|
113
|
+
{...props as (typeof props & Pick<OverlayProps, 'target'>)}
|
|
114
|
+
/>
|
|
115
|
+
);
|
|
116
|
+
}
|
|
154
117
|
|
|
155
|
-
OverlayTrigger
|
|
156
|
-
defaultShow
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
}
|
|
118
|
+
function OverlayTrigger({
|
|
119
|
+
defaultShow = false,
|
|
120
|
+
popperConfig = {},
|
|
121
|
+
trigger = ['hover', 'focus'],
|
|
122
|
+
...props
|
|
123
|
+
}: ParagonOverlayTriggerProps) {
|
|
124
|
+
return (
|
|
125
|
+
<BaseOverlayTrigger
|
|
126
|
+
defaultShow={defaultShow}
|
|
127
|
+
popperConfig={popperConfig}
|
|
128
|
+
trigger={trigger}
|
|
129
|
+
{...props}
|
|
130
|
+
>
|
|
131
|
+
{props.children}
|
|
132
|
+
</BaseOverlayTrigger>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
167
135
|
|
|
168
136
|
export { OverlayTrigger };
|
|
169
137
|
export default Overlay;
|
package/src/Tooltip/index.tsx
CHANGED
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
2
|
import classNames from 'classnames';
|
|
4
3
|
import BaseTooltip, { type TooltipProps as BaseTooltipProps } from 'react-bootstrap/Tooltip';
|
|
5
4
|
import { type Placement } from 'react-bootstrap/Overlay';
|
|
6
5
|
import type { ComponentWithAsProp } from '../utils/types/bootstrap';
|
|
7
6
|
|
|
8
7
|
interface TooltipProps extends BaseTooltipProps {
|
|
8
|
+
// NOTE: we have to re-declare many inherited props so that they show up in the auto-generated docs.
|
|
9
|
+
/** An html `id` attribute, necessary for accessibility. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** The visual style variant of the `Tooltip`. Use `'light'` for a light-themed tooltip. */
|
|
9
12
|
variant?: 'light';
|
|
13
|
+
/** Whether the tooltip is currently visible. */
|
|
14
|
+
show?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Sets the direction the Tooltip is positioned towards.
|
|
17
|
+
*
|
|
18
|
+
* This is generally provided by the Overlay component positioning the tooltip.
|
|
19
|
+
*/
|
|
20
|
+
placement?: Placement;
|
|
21
|
+
/** Additional CSS class(es) to put on the tooltip element. */
|
|
22
|
+
className?: string;
|
|
23
|
+
/** A Popper.js config object passed to the the underlying popper instance. */
|
|
24
|
+
popper?: any;
|
|
10
25
|
}
|
|
11
26
|
|
|
12
|
-
const PLACEMENT_VARIANTS: Placement[] = [
|
|
13
|
-
'auto-start',
|
|
14
|
-
'auto',
|
|
15
|
-
'auto-end',
|
|
16
|
-
'top-start',
|
|
17
|
-
'top',
|
|
18
|
-
'top-end',
|
|
19
|
-
'right-start',
|
|
20
|
-
'right',
|
|
21
|
-
'right-end',
|
|
22
|
-
'bottom-end',
|
|
23
|
-
'bottom',
|
|
24
|
-
'bottom-start',
|
|
25
|
-
'left-end',
|
|
26
|
-
'left',
|
|
27
|
-
'left-start',
|
|
28
|
-
];
|
|
29
|
-
|
|
30
27
|
const Tooltip: ComponentWithAsProp<'div', TooltipProps> = React.forwardRef(({
|
|
31
28
|
children,
|
|
32
29
|
variant,
|
|
30
|
+
placement = 'right',
|
|
31
|
+
bsPrefix = 'tooltip',
|
|
33
32
|
...props
|
|
34
|
-
}, ref) => (
|
|
33
|
+
}: TooltipProps, ref: React.ForwardedRef<HTMLDivElement>) => (
|
|
35
34
|
<BaseTooltip
|
|
36
35
|
{...props}
|
|
36
|
+
placement={placement}
|
|
37
|
+
bsPrefix={bsPrefix}
|
|
37
38
|
className={classNames({ 'tooltip-light': variant === 'light' }, props.className)}
|
|
38
39
|
ref={ref}
|
|
39
40
|
>
|
|
@@ -41,53 +42,4 @@ const Tooltip: ComponentWithAsProp<'div', TooltipProps> = React.forwardRef(({
|
|
|
41
42
|
</BaseTooltip>
|
|
42
43
|
));
|
|
43
44
|
|
|
44
|
-
Tooltip.propTypes = {
|
|
45
|
-
...BaseTooltip.propTypes,
|
|
46
|
-
/** An html id attribute, necessary for accessibility. */
|
|
47
|
-
id: PropTypes.string.isRequired,
|
|
48
|
-
/**
|
|
49
|
-
* Sets the direction the `Tooltip` is positioned towards.
|
|
50
|
-
*
|
|
51
|
-
* This is generally provided by the `Overlay` component positioning the tooltip.
|
|
52
|
-
*/
|
|
53
|
-
placement: PropTypes.oneOf(PLACEMENT_VARIANTS),
|
|
54
|
-
/**
|
|
55
|
-
* An `Overlay` injected set of props for positioning the `Tooltip` arrow.
|
|
56
|
-
*
|
|
57
|
-
* This is generally provided by the `Overlay` component positioning the tooltip.
|
|
58
|
-
*/
|
|
59
|
-
arrowProps: PropTypes.shape({
|
|
60
|
-
ref: PropTypes.oneOfType([
|
|
61
|
-
PropTypes.func,
|
|
62
|
-
PropTypes.shape({ current: PropTypes.element }),
|
|
63
|
-
]),
|
|
64
|
-
style: PropTypes.shape({}),
|
|
65
|
-
}),
|
|
66
|
-
/** Whether the `Overlay` is shown. */
|
|
67
|
-
show: PropTypes.bool,
|
|
68
|
-
/** A `Popper.js` config object passed to the the underlying popper instance. */
|
|
69
|
-
popper: PropTypes.shape({}),
|
|
70
|
-
/** Overrides underlying component base CSS class name */
|
|
71
|
-
bsPrefix: PropTypes.string,
|
|
72
|
-
/** Specifies the content of the `Tooltip` */
|
|
73
|
-
children: PropTypes.node,
|
|
74
|
-
/** Specifies class name to append to the base element */
|
|
75
|
-
className: PropTypes.string,
|
|
76
|
-
/** The visual style of the `Tooltip` */
|
|
77
|
-
variant: PropTypes.string,
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
Tooltip.defaultProps = {
|
|
81
|
-
...Tooltip.defaultProps,
|
|
82
|
-
id: undefined,
|
|
83
|
-
placement: 'right',
|
|
84
|
-
arrowProps: undefined,
|
|
85
|
-
show: undefined,
|
|
86
|
-
popper: undefined,
|
|
87
|
-
children: undefined,
|
|
88
|
-
className: undefined,
|
|
89
|
-
variant: undefined,
|
|
90
|
-
bsPrefix: 'tooltip',
|
|
91
|
-
};
|
|
92
|
-
|
|
93
45
|
export default Tooltip;
|