@openedx/paragon 22.6.1 → 22.8.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/dist/Chip/ChipIcon.d.ts +11 -6
- package/dist/Chip/ChipIcon.js +0 -2
- package/dist/Chip/ChipIcon.js.map +1 -1
- package/dist/Chip/constants.d.ts +4 -0
- package/dist/Chip/constants.js +3 -2
- package/dist/Chip/constants.js.map +1 -0
- package/dist/Chip/index.d.ts +2 -1
- package/dist/Chip/index.js +0 -2
- package/dist/Chip/index.js.map +1 -1
- package/dist/ChipCarousel/index.js +0 -2
- package/dist/ChipCarousel/index.js.map +1 -1
- package/dist/Container/index.d.ts +16 -0
- package/dist/Container/index.js +15 -13
- package/dist/Container/index.js.map +1 -1
- package/dist/IconButton/index.d.ts +344 -0
- package/dist/IconButton/index.js +17 -25
- package/dist/IconButton/index.js.map +1 -1
- package/dist/Menu/SelectMenu.js +9 -4
- package/dist/Menu/SelectMenu.js.map +1 -1
- package/dist/Overlay/index.d.ts +128 -0
- package/dist/Overlay/index.js +5 -0
- package/dist/Overlay/index.js.map +1 -1
- package/dist/Tooltip/index.d.ts +7 -0
- package/dist/Tooltip/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +3 -3
- package/package.json +1 -1
- package/src/Chip/{Chip.test.jsx → Chip.test.tsx} +5 -7
- package/src/Chip/ChipIcon.tsx +7 -7
- package/src/Chip/{constants.js → constants.ts} +1 -1
- package/src/Chip/index.tsx +1 -3
- package/src/ChipCarousel/index.tsx +0 -2
- package/src/Container/{Container.test.jsx → Container.test.tsx} +14 -8
- package/src/Container/README.md +4 -0
- package/src/Container/index.tsx +64 -0
- package/src/IconButton/{IconButton.test.jsx → IconButton.test.tsx} +24 -3
- package/src/IconButton/__snapshots__/IconButton.test.tsx.snap +112 -0
- package/src/IconButton/{index.jsx → index.tsx} +62 -22
- package/src/Menu/SelectMenu.jsx +5 -0
- package/src/Menu/SelectMenu.test.jsx +6 -0
- package/src/Menu/select-menu.md +8 -0
- package/src/Overlay/{index.jsx → index.tsx} +10 -6
- package/src/Tooltip/{index.jsx → index.tsx} +9 -3
- package/src/index.d.ts +4 -4
- package/src/index.js +3 -3
- package/src/Container/index.jsx +0 -49
- package/src/IconButton/__snapshots__/IconButton.test.jsx.snap +0 -43
- /package/src/Chip/__snapshots__/{Chip.test.jsx.snap → Chip.test.tsx.snap} +0 -0
- /package/src/Tooltip/{Tooltip.test.jsx → Tooltip.test.tsx} +0 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`<IconButton /> <IconButton.IconButtonWithTooltip> renders with required props 1`] = `
|
|
4
|
+
<button
|
|
5
|
+
aria-label="alternative"
|
|
6
|
+
className="btn-icon btn-icon-primary btn-icon-md"
|
|
7
|
+
onBlur={[Function]}
|
|
8
|
+
onClick={[Function]}
|
|
9
|
+
onFocus={[Function]}
|
|
10
|
+
onMouseOut={[Function]}
|
|
11
|
+
onMouseOver={[Function]}
|
|
12
|
+
type="button"
|
|
13
|
+
>
|
|
14
|
+
<span
|
|
15
|
+
className="btn-icon__icon-container"
|
|
16
|
+
>
|
|
17
|
+
<span
|
|
18
|
+
className="pgn__icon btn-icon__icon"
|
|
19
|
+
>
|
|
20
|
+
<svg
|
|
21
|
+
aria-hidden={true}
|
|
22
|
+
fill="none"
|
|
23
|
+
focusable={false}
|
|
24
|
+
height={24}
|
|
25
|
+
role="img"
|
|
26
|
+
viewBox="0 0 24 24"
|
|
27
|
+
width={24}
|
|
28
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
29
|
+
>
|
|
30
|
+
<path
|
|
31
|
+
d="M11 7h2v2h-2V7Zm0 4h2v6h-2v-6Zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Z"
|
|
32
|
+
fill="currentColor"
|
|
33
|
+
/>
|
|
34
|
+
</svg>
|
|
35
|
+
</span>
|
|
36
|
+
</span>
|
|
37
|
+
</button>
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
exports[`<IconButton /> renders with deprecated props 1`] = `
|
|
41
|
+
<button
|
|
42
|
+
aria-label="alternative"
|
|
43
|
+
className="btn-icon btn-icon-primary btn-icon-md"
|
|
44
|
+
onClick={[Function]}
|
|
45
|
+
type="button"
|
|
46
|
+
>
|
|
47
|
+
<span
|
|
48
|
+
className="btn-icon__icon-container"
|
|
49
|
+
>
|
|
50
|
+
<svg
|
|
51
|
+
aria-hidden="true"
|
|
52
|
+
className="svg-inline--fa fa-InfoOutlineIcon btn-icon__icon"
|
|
53
|
+
data-icon="InfoOutlineIcon"
|
|
54
|
+
data-prefix="pgn"
|
|
55
|
+
focusable="false"
|
|
56
|
+
role="img"
|
|
57
|
+
style={{}}
|
|
58
|
+
viewBox="0 0 function SvgInfoOutline(props) {
|
|
59
|
+
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
60
|
+
width: 24,
|
|
61
|
+
height: 24,
|
|
62
|
+
viewBox: "0 0 24 24",
|
|
63
|
+
fill: "none",
|
|
64
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
65
|
+
}, props), /*#__PURE__*/React.createElement("path", {
|
|
66
|
+
d: "M11 7h2v2h-2V7Zm0 4h2v6h-2v-6Zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Z",
|
|
67
|
+
fill: "currentColor"
|
|
68
|
+
}));
|
|
69
|
+
} undefined"
|
|
70
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
71
|
+
>
|
|
72
|
+
<path
|
|
73
|
+
fill="currentColor"
|
|
74
|
+
style={{}}
|
|
75
|
+
/>
|
|
76
|
+
</svg>
|
|
77
|
+
</span>
|
|
78
|
+
</button>
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
exports[`<IconButton /> renders with required props 1`] = `
|
|
82
|
+
<button
|
|
83
|
+
aria-label="alternative"
|
|
84
|
+
className="btn-icon btn-icon-primary btn-icon-md"
|
|
85
|
+
onClick={[Function]}
|
|
86
|
+
type="button"
|
|
87
|
+
>
|
|
88
|
+
<span
|
|
89
|
+
className="btn-icon__icon-container"
|
|
90
|
+
>
|
|
91
|
+
<span
|
|
92
|
+
className="pgn__icon btn-icon__icon"
|
|
93
|
+
>
|
|
94
|
+
<svg
|
|
95
|
+
aria-hidden={true}
|
|
96
|
+
fill="none"
|
|
97
|
+
focusable={false}
|
|
98
|
+
height={24}
|
|
99
|
+
role="img"
|
|
100
|
+
viewBox="0 0 24 24"
|
|
101
|
+
width={24}
|
|
102
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
103
|
+
>
|
|
104
|
+
<path
|
|
105
|
+
d="M11 7h2v2h-2V7Zm0 4h2v6h-2v-6Zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Z"
|
|
106
|
+
fill="currentColor"
|
|
107
|
+
/>
|
|
108
|
+
</svg>
|
|
109
|
+
</span>
|
|
110
|
+
</span>
|
|
111
|
+
</button>
|
|
112
|
+
`;
|
|
@@ -1,12 +1,46 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
|
|
5
4
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
5
|
+
import { type Placement } from 'react-bootstrap/Overlay';
|
|
6
|
+
|
|
6
7
|
import { OverlayTrigger } from '../Overlay';
|
|
7
8
|
import Tooltip from '../Tooltip';
|
|
9
|
+
import Icon from '../Icon';
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
interface Props extends React.HTMLAttributes<HTMLButtonElement> {
|
|
12
|
+
iconAs?: typeof Icon | typeof FontAwesomeIcon,
|
|
13
|
+
/** Additional CSS class[es] to apply to this button */
|
|
14
|
+
className?: string;
|
|
15
|
+
/** Alt text for your icon. For best practice, avoid using alt text to describe
|
|
16
|
+
* the image in the `IconButton`. Instead, we recommend describing the function
|
|
17
|
+
* of the button. */
|
|
18
|
+
alt: string;
|
|
19
|
+
/** Changes icon styles for dark background */
|
|
20
|
+
invertColors?: boolean;
|
|
21
|
+
/** An icon component to render. Example import of a Paragon icon component:
|
|
22
|
+
* `import { Check } from '@openedx/paragon/icons';`
|
|
23
|
+
* */
|
|
24
|
+
// Note: React.ComponentType is what we want here. React.ElementType would allow some element type strings like "div",
|
|
25
|
+
// but we only want to allow components like 'Add' (a specific icon component function/class)
|
|
26
|
+
src?: React.ComponentType;
|
|
27
|
+
/** Extra class names that will be added to the icon */
|
|
28
|
+
iconClassNames?: string;
|
|
29
|
+
/** Click handler for the button */
|
|
30
|
+
onClick?: React.MouseEventHandler<HTMLButtonElement>;
|
|
31
|
+
/** whether to show the `IconButton` in an active state, whose styling is distinct from default state */
|
|
32
|
+
isActive?: boolean;
|
|
33
|
+
/** @deprecated Using FontAwesome icons is deprecated. Instead, pass iconAs={Icon} src={...} */
|
|
34
|
+
icon?: { prefix?: string; iconName?: string, icon?: any[] },
|
|
35
|
+
/** Type of button (uses Bootstrap options) */
|
|
36
|
+
variant?: 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'light' | 'dark' | 'black' | 'brand';
|
|
37
|
+
/** size of button to render */
|
|
38
|
+
size?: 'sm' | 'md' | 'inline';
|
|
39
|
+
/** no children */
|
|
40
|
+
children?: never;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const IconButton = React.forwardRef<HTMLButtonElement, Props>(({
|
|
10
44
|
className,
|
|
11
45
|
alt,
|
|
12
46
|
invertColors,
|
|
@@ -18,6 +52,7 @@ const IconButton = React.forwardRef(({
|
|
|
18
52
|
variant,
|
|
19
53
|
iconAs,
|
|
20
54
|
isActive,
|
|
55
|
+
children, // unused, just here because we don't want it to be part of 'attrs'
|
|
21
56
|
...attrs
|
|
22
57
|
}, ref) => {
|
|
23
58
|
const invert = invertColors ? 'inverse-' : '';
|
|
@@ -50,7 +85,7 @@ const IconButton = React.forwardRef(({
|
|
|
50
85
|
<span className="btn-icon__icon-container">
|
|
51
86
|
<IconComponent
|
|
52
87
|
className={classNames('btn-icon__icon', iconClassNames)}
|
|
53
|
-
icon={icon}
|
|
88
|
+
icon={icon as any}
|
|
54
89
|
src={src}
|
|
55
90
|
/>
|
|
56
91
|
</span>
|
|
@@ -60,7 +95,7 @@ const IconButton = React.forwardRef(({
|
|
|
60
95
|
|
|
61
96
|
IconButton.defaultProps = {
|
|
62
97
|
iconAs: undefined,
|
|
63
|
-
src:
|
|
98
|
+
src: undefined,
|
|
64
99
|
icon: undefined,
|
|
65
100
|
iconClassNames: undefined,
|
|
66
101
|
className: undefined,
|
|
@@ -69,6 +104,7 @@ IconButton.defaultProps = {
|
|
|
69
104
|
size: 'md',
|
|
70
105
|
onClick: () => {},
|
|
71
106
|
isActive: false,
|
|
107
|
+
children: undefined,
|
|
72
108
|
};
|
|
73
109
|
|
|
74
110
|
IconButton.propTypes = {
|
|
@@ -76,11 +112,11 @@ IconButton.propTypes = {
|
|
|
76
112
|
className: PropTypes.string,
|
|
77
113
|
/** Component that renders the icon, currently defaults to `FontAwesomeIcon`,
|
|
78
114
|
* but is going to be deprecated soon, please use Paragon's icons instead. */
|
|
79
|
-
iconAs: PropTypes.elementType,
|
|
115
|
+
iconAs: PropTypes.elementType as any,
|
|
80
116
|
/** An icon component to render. Example import of a Paragon icon component:
|
|
81
|
-
* `import { Check } from '@openedx/paragon/
|
|
117
|
+
* `import { Check } from '@openedx/paragon/icons';`
|
|
82
118
|
* */
|
|
83
|
-
src: PropTypes.
|
|
119
|
+
src: PropTypes.elementType as any,
|
|
84
120
|
/** Alt text for your icon. For best practice, avoid using alt text to describe
|
|
85
121
|
* the image in the `IconButton`. Instead, we recommend describing the function
|
|
86
122
|
* of the button. */
|
|
@@ -93,7 +129,7 @@ IconButton.propTypes = {
|
|
|
93
129
|
iconName: PropTypes.string,
|
|
94
130
|
// eslint-disable-next-line react/forbid-prop-types
|
|
95
131
|
icon: PropTypes.array,
|
|
96
|
-
}),
|
|
132
|
+
}) as any,
|
|
97
133
|
/** Extra class names that will be added to the icon */
|
|
98
134
|
iconClassNames: PropTypes.string,
|
|
99
135
|
/** Click handler for the button */
|
|
@@ -106,38 +142,40 @@ IconButton.propTypes = {
|
|
|
106
142
|
isActive: PropTypes.bool,
|
|
107
143
|
};
|
|
108
144
|
|
|
145
|
+
interface PropsWithTooltip extends Props {
|
|
146
|
+
/** choose from https://popper.js.org/docs/v2/constructors/#options */
|
|
147
|
+
tooltipPlacement: Placement,
|
|
148
|
+
/** any content to pass to tooltip content area */
|
|
149
|
+
tooltipContent: React.ReactNode,
|
|
150
|
+
}
|
|
151
|
+
|
|
109
152
|
/**
|
|
110
|
-
*
|
|
111
|
-
* @param { object } args Arguments
|
|
112
|
-
* @param { string } args.tooltipPlacement choose from https://popper.js.org/docs/v2/constructors/#options
|
|
113
|
-
* @param { React.Component } args.tooltipContent any content to pass to tooltip content area
|
|
114
|
-
* @returns { IconButton } a button wrapped in overlaytrigger
|
|
153
|
+
* An icon button wrapped in overlaytrigger to display a tooltip.
|
|
115
154
|
*/
|
|
116
155
|
function IconButtonWithTooltip({
|
|
117
|
-
tooltipPlacement, tooltipContent,
|
|
118
|
-
}) {
|
|
119
|
-
const invert = invertColors ? 'inverse-' : '';
|
|
156
|
+
tooltipPlacement, tooltipContent, ...props
|
|
157
|
+
}: PropsWithTooltip) {
|
|
158
|
+
const invert = props.invertColors ? 'inverse-' : '';
|
|
120
159
|
return (
|
|
121
160
|
<OverlayTrigger
|
|
122
161
|
placement={tooltipPlacement}
|
|
123
162
|
overlay={(
|
|
124
163
|
<Tooltip
|
|
125
164
|
id={`iconbutton-tooltip-${tooltipPlacement}`}
|
|
126
|
-
variant={invert ? 'light' :
|
|
165
|
+
variant={invert ? 'light' : undefined}
|
|
127
166
|
>
|
|
128
167
|
{tooltipContent}
|
|
129
168
|
</Tooltip>
|
|
130
169
|
)}
|
|
131
170
|
>
|
|
132
|
-
<IconButton
|
|
171
|
+
<IconButton {...props} />
|
|
133
172
|
</OverlayTrigger>
|
|
134
173
|
);
|
|
135
174
|
}
|
|
136
175
|
|
|
137
176
|
IconButtonWithTooltip.defaultProps = {
|
|
177
|
+
...IconButton.defaultProps,
|
|
138
178
|
tooltipPlacement: 'top',
|
|
139
|
-
variant: 'primary',
|
|
140
|
-
invertColors: false,
|
|
141
179
|
};
|
|
142
180
|
|
|
143
181
|
IconButtonWithTooltip.propTypes = {
|
|
@@ -151,7 +189,9 @@ IconButtonWithTooltip.propTypes = {
|
|
|
151
189
|
invertColors: PropTypes.bool,
|
|
152
190
|
};
|
|
153
191
|
|
|
154
|
-
IconButton.IconButtonWithTooltip = IconButtonWithTooltip;
|
|
192
|
+
(IconButton as any).IconButtonWithTooltip = IconButtonWithTooltip;
|
|
155
193
|
|
|
156
|
-
export default IconButton
|
|
194
|
+
export default IconButton as typeof IconButton & {
|
|
195
|
+
IconButtonWithTooltip: typeof IconButtonWithTooltip,
|
|
196
|
+
};
|
|
157
197
|
export { IconButtonWithTooltip };
|
package/src/Menu/SelectMenu.jsx
CHANGED
|
@@ -15,6 +15,7 @@ function SelectMenu({
|
|
|
15
15
|
children,
|
|
16
16
|
className,
|
|
17
17
|
variant,
|
|
18
|
+
disabled,
|
|
18
19
|
...props
|
|
19
20
|
}) {
|
|
20
21
|
const [triggerTarget, setTriggerTarget] = useState(null);
|
|
@@ -89,6 +90,7 @@ function SelectMenu({
|
|
|
89
90
|
variant={variant}
|
|
90
91
|
iconAfter={ExpandMore}
|
|
91
92
|
onClick={open}
|
|
93
|
+
disabled={disabled}
|
|
92
94
|
>
|
|
93
95
|
{selected !== undefined && children[selected] ? children[selected].props.children : defaultMessage}
|
|
94
96
|
</Button>
|
|
@@ -131,12 +133,15 @@ SelectMenu.propTypes = {
|
|
|
131
133
|
className: PropTypes.string,
|
|
132
134
|
/** Specifies variant to use. */
|
|
133
135
|
variant: PropTypes.string,
|
|
136
|
+
/** Specifies if the `SelectMenu` is disabled. */
|
|
137
|
+
disabled: PropTypes.bool,
|
|
134
138
|
};
|
|
135
139
|
|
|
136
140
|
SelectMenu.defaultProps = {
|
|
137
141
|
defaultMessage: SELECT_MENU_DEFAULT_MESSAGE,
|
|
138
142
|
className: undefined,
|
|
139
143
|
variant: 'outline-primary',
|
|
144
|
+
disabled: false,
|
|
140
145
|
};
|
|
141
146
|
|
|
142
147
|
const SelectMenuWithDeprecatedProp = withDeprecatedProps(SelectMenu, 'SelectMenu', {
|
|
@@ -58,6 +58,12 @@ describe('correct rendering', () => {
|
|
|
58
58
|
const button = screen.getByRole('button');
|
|
59
59
|
expect(button).toHaveClass('btn-brand');
|
|
60
60
|
});
|
|
61
|
+
|
|
62
|
+
it('renders as disabled', () => {
|
|
63
|
+
render(DefaultSelectMenu({ disabled: true }));
|
|
64
|
+
const button = screen.getByRole('button');
|
|
65
|
+
expect(button).toBeDisabled();
|
|
66
|
+
});
|
|
61
67
|
});
|
|
62
68
|
|
|
63
69
|
describe('mouse behavior & keyboard behavior', () => {
|
package/src/Menu/select-menu.md
CHANGED
|
@@ -56,3 +56,11 @@ The ``Modal`` brings focus to the first menu element upon the click of the trigg
|
|
|
56
56
|
<MenuItem>M. Hortens</MenuItem>
|
|
57
57
|
</SelectMenu>
|
|
58
58
|
```
|
|
59
|
+
|
|
60
|
+
## Disabled
|
|
61
|
+
|
|
62
|
+
```jsx live
|
|
63
|
+
<SelectMenu disabled>
|
|
64
|
+
<MenuItem>A Menu Item</MenuItem>
|
|
65
|
+
</SelectMenu>
|
|
66
|
+
```
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import BaseOverlay from 'react-bootstrap/Overlay';
|
|
3
|
-
import BaseOverlayTrigger from 'react-bootstrap/OverlayTrigger';
|
|
2
|
+
import BaseOverlay, { type OverlayProps, type Placement } from 'react-bootstrap/Overlay';
|
|
3
|
+
import BaseOverlayTrigger, { type OverlayTriggerProps, type OverlayTriggerType } from 'react-bootstrap/OverlayTrigger';
|
|
4
4
|
import Fade from 'react-bootstrap/Fade';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
// Note: The only thing this file adds to the base component is propTypes validation.
|
|
8
|
+
// As more Paragon consumers adopt TypeScript, we could consider removing almost all of this code
|
|
9
|
+
// and just re-export the Overlay and OverlayTrigger components from react-bootstrap unmodified.
|
|
10
|
+
|
|
11
|
+
const PLACEMENT_VARIANTS: Placement[] = [
|
|
8
12
|
'auto-start',
|
|
9
13
|
'auto',
|
|
10
14
|
'auto-end',
|
|
@@ -22,16 +26,16 @@ const PLACEMENT_VARIANTS = [
|
|
|
22
26
|
'left-start',
|
|
23
27
|
];
|
|
24
28
|
|
|
25
|
-
const TRIGGER_VARIANTS = [
|
|
29
|
+
const TRIGGER_VARIANTS: OverlayTriggerType[] = [
|
|
26
30
|
'hover',
|
|
27
31
|
'click',
|
|
28
32
|
'focus',
|
|
29
33
|
];
|
|
30
34
|
|
|
31
|
-
function Overlay(props) {
|
|
35
|
+
function Overlay(props: OverlayProps) {
|
|
32
36
|
return <BaseOverlay {...props} />;
|
|
33
37
|
}
|
|
34
|
-
function OverlayTrigger(props) {
|
|
38
|
+
function OverlayTrigger(props: OverlayTriggerProps) {
|
|
35
39
|
return (
|
|
36
40
|
<BaseOverlayTrigger {...props}>
|
|
37
41
|
{props.children}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import classNames from 'classnames';
|
|
4
|
-
import BaseTooltip from 'react-bootstrap/Tooltip';
|
|
4
|
+
import BaseTooltip, { type TooltipProps as BaseTooltipProps } from 'react-bootstrap/Tooltip';
|
|
5
|
+
import { type Placement } from 'react-bootstrap/Overlay';
|
|
6
|
+
import type { ComponentWithAsProp } from '../utils/types/bootstrap';
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
interface TooltipProps extends BaseTooltipProps {
|
|
9
|
+
variant?: 'light';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const PLACEMENT_VARIANTS: Placement[] = [
|
|
7
13
|
'auto-start',
|
|
8
14
|
'auto',
|
|
9
15
|
'auto-end',
|
|
@@ -21,7 +27,7 @@ const PLACEMENT_VARIANTS = [
|
|
|
21
27
|
'left-start',
|
|
22
28
|
];
|
|
23
29
|
|
|
24
|
-
const Tooltip = React.forwardRef(({
|
|
30
|
+
const Tooltip: ComponentWithAsProp<'div', TooltipProps> = React.forwardRef(({
|
|
25
31
|
children,
|
|
26
32
|
variant,
|
|
27
33
|
...props
|
package/src/index.d.ts
CHANGED
|
@@ -8,8 +8,12 @@ export { default as Bubble } from './Bubble';
|
|
|
8
8
|
export { default as Button, ButtonGroup, ButtonToolbar } from './Button';
|
|
9
9
|
export { default as Chip, CHIP_PGN_CLASS } from './Chip';
|
|
10
10
|
export { default as ChipCarousel } from './ChipCarousel';
|
|
11
|
+
export { default as Container, ContainerSize } from './Container';
|
|
11
12
|
export { default as Hyperlink, HYPER_LINK_EXTERNAL_LINK_ALT_TEXT, HYPER_LINK_EXTERNAL_LINK_TITLE } from './Hyperlink';
|
|
12
13
|
export { default as Icon } from './Icon';
|
|
14
|
+
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
15
|
+
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
16
|
+
export { default as Tooltip } from './Tooltip';
|
|
13
17
|
|
|
14
18
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
15
19
|
// Things that don't have types
|
|
@@ -38,7 +42,6 @@ export const
|
|
|
38
42
|
export const CheckBox: any; // from './CheckBox';
|
|
39
43
|
export const CheckBoxGroup: any; // from './CheckBoxGroup';
|
|
40
44
|
export const CloseButton: any; // from './CloseButton';
|
|
41
|
-
export const Container: any; // from './Container';
|
|
42
45
|
export const Layout: any, Col: any, Row: any; // from './Layout';
|
|
43
46
|
export const Collapse: any; // from './Collapse';
|
|
44
47
|
export const Collapsible: any; // from './Collapsible';
|
|
@@ -73,7 +76,6 @@ export const
|
|
|
73
76
|
FormAutosuggestOption: any,
|
|
74
77
|
InputGroup: any;
|
|
75
78
|
// from './Form';
|
|
76
|
-
export const IconButton: any, IconButtonWithTooltip: any; // from './IconButton';
|
|
77
79
|
export const IconButtonToggle: any; // from './IconButtonToggle';
|
|
78
80
|
export const Input: any; // from './Input';
|
|
79
81
|
export const InputSelect: any; // from './InputSelect';
|
|
@@ -106,7 +108,6 @@ export const
|
|
|
106
108
|
NavLink: any;
|
|
107
109
|
// from './Nav';
|
|
108
110
|
export const Navbar: any, NavbarBrand: any, NAVBAR_LABEL: string; // from './Navbar';
|
|
109
|
-
export const Overlay: any, OverlayTrigger: any; // from './Overlay';
|
|
110
111
|
export const PageBanner: any, PAGE_BANNER_DISMISS_ALT_TEXT: string; // from './PageBanner';
|
|
111
112
|
export const
|
|
112
113
|
Pagination: any,
|
|
@@ -145,7 +146,6 @@ export const
|
|
|
145
146
|
// from './Tabs';
|
|
146
147
|
export const TextArea: any; // from './TextArea';
|
|
147
148
|
export const Toast: any, TOAST_CLOSE_LABEL_TEXT: string, TOAST_DELAY: number; // from './Toast';
|
|
148
|
-
export const Tooltip: any; // from './Tooltip';
|
|
149
149
|
export const ValidationFormGroup: any; // from './ValidationFormGroup';
|
|
150
150
|
export const TransitionReplace: any; // from './TransitionReplace';
|
|
151
151
|
export const ValidationMessage: any; // from './ValidationMessage';
|
package/src/index.js
CHANGED
|
@@ -10,6 +10,9 @@ export { default as Chip, CHIP_PGN_CLASS } from './Chip';
|
|
|
10
10
|
export { default as ChipCarousel } from './ChipCarousel';
|
|
11
11
|
export { default as Hyperlink, HYPER_LINK_EXTERNAL_LINK_ALT_TEXT, HYPER_LINK_EXTERNAL_LINK_TITLE } from './Hyperlink';
|
|
12
12
|
export { default as Icon } from './Icon';
|
|
13
|
+
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
14
|
+
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
15
|
+
export { default as Tooltip } from './Tooltip';
|
|
13
16
|
|
|
14
17
|
// // // // // // // // // // // // // // // // // // // // // // // // // // //
|
|
15
18
|
// Things that don't have types
|
|
@@ -73,7 +76,6 @@ export {
|
|
|
73
76
|
FormAutosuggestOption,
|
|
74
77
|
InputGroup,
|
|
75
78
|
} from './Form';
|
|
76
|
-
export { default as IconButton, IconButtonWithTooltip } from './IconButton';
|
|
77
79
|
export { default as IconButtonToggle } from './IconButtonToggle';
|
|
78
80
|
export { default as Input } from './Input';
|
|
79
81
|
export { default as InputSelect } from './InputSelect';
|
|
@@ -106,7 +108,6 @@ export {
|
|
|
106
108
|
NavLink,
|
|
107
109
|
} from './Nav';
|
|
108
110
|
export { default as Navbar, NavbarBrand, NAVBAR_LABEL } from './Navbar';
|
|
109
|
-
export { default as Overlay, OverlayTrigger } from './Overlay';
|
|
110
111
|
export { default as PageBanner, PAGE_BANNER_DISMISS_ALT_TEXT } from './PageBanner';
|
|
111
112
|
export {
|
|
112
113
|
default as Pagination,
|
|
@@ -145,7 +146,6 @@ export {
|
|
|
145
146
|
} from './Tabs';
|
|
146
147
|
export { default as TextArea } from './TextArea';
|
|
147
148
|
export { default as Toast, TOAST_CLOSE_LABEL_TEXT, TOAST_DELAY } from './Toast';
|
|
148
|
-
export { default as Tooltip } from './Tooltip';
|
|
149
149
|
export { default as ValidationFormGroup } from './ValidationFormGroup';
|
|
150
150
|
export { default as TransitionReplace } from './TransitionReplace';
|
|
151
151
|
export { default as ValidationMessage } from './ValidationMessage';
|
package/src/Container/index.jsx
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React, { forwardRef } from 'react';
|
|
2
|
-
import classNames from 'classnames';
|
|
3
|
-
import RBContainer from 'react-bootstrap/Container';
|
|
4
|
-
import PropTypes from 'prop-types';
|
|
5
|
-
|
|
6
|
-
const SIZE_CLASS_NAMES = {
|
|
7
|
-
xs: 'container-mw-xs',
|
|
8
|
-
sm: 'container-mw-sm',
|
|
9
|
-
md: 'container-mw-md',
|
|
10
|
-
lg: 'container-mw-lg',
|
|
11
|
-
xl: 'container-mw-xl',
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const Container = forwardRef(({ size, children, ...props }, ref) => (
|
|
15
|
-
<RBContainer
|
|
16
|
-
{...props}
|
|
17
|
-
ref={ref}
|
|
18
|
-
className={classNames(
|
|
19
|
-
props.className,
|
|
20
|
-
SIZE_CLASS_NAMES[size],
|
|
21
|
-
)}
|
|
22
|
-
>
|
|
23
|
-
{children}
|
|
24
|
-
</RBContainer>
|
|
25
|
-
));
|
|
26
|
-
|
|
27
|
-
Container.propTypes = {
|
|
28
|
-
...RBContainer.propTypes,
|
|
29
|
-
/** Override the base element */
|
|
30
|
-
as: PropTypes.elementType,
|
|
31
|
-
/** Specifies the contents of the container */
|
|
32
|
-
children: PropTypes.node,
|
|
33
|
-
/** Fill all available space at any breakpoint */
|
|
34
|
-
fluid: PropTypes.bool,
|
|
35
|
-
/** Set the maximum width for the container */
|
|
36
|
-
size: PropTypes.oneOf(Object.keys(SIZE_CLASS_NAMES)),
|
|
37
|
-
/** Overrides underlying component base CSS class name */
|
|
38
|
-
bsPrefix: PropTypes.string,
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
Container.defaultProps = {
|
|
42
|
-
as: 'div',
|
|
43
|
-
children: undefined,
|
|
44
|
-
fluid: true,
|
|
45
|
-
size: undefined,
|
|
46
|
-
bsPrefix: 'container',
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default Container;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`<IconButton /> renders with required props 1`] = `
|
|
4
|
-
<button
|
|
5
|
-
aria-label="alternative"
|
|
6
|
-
className="btn-icon btn-icon-primary btn-icon-md"
|
|
7
|
-
onClick={[Function]}
|
|
8
|
-
type="button"
|
|
9
|
-
>
|
|
10
|
-
<span
|
|
11
|
-
className="btn-icon__icon-container"
|
|
12
|
-
>
|
|
13
|
-
<svg
|
|
14
|
-
aria-hidden="true"
|
|
15
|
-
className="svg-inline--fa fa-InfoOutlineIcon btn-icon__icon"
|
|
16
|
-
data-icon="InfoOutlineIcon"
|
|
17
|
-
data-prefix="pgn"
|
|
18
|
-
focusable="false"
|
|
19
|
-
role="img"
|
|
20
|
-
src={null}
|
|
21
|
-
style={{}}
|
|
22
|
-
viewBox="0 0 function SvgInfoOutline(props) {
|
|
23
|
-
return /*#__PURE__*/React.createElement("svg", _extends({
|
|
24
|
-
width: 24,
|
|
25
|
-
height: 24,
|
|
26
|
-
viewBox: "0 0 24 24",
|
|
27
|
-
fill: "none",
|
|
28
|
-
xmlns: "http://www.w3.org/2000/svg"
|
|
29
|
-
}, props), /*#__PURE__*/React.createElement("path", {
|
|
30
|
-
d: "M11 7h2v2h-2V7Zm0 4h2v6h-2v-6Zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2Zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8Z",
|
|
31
|
-
fill: "currentColor"
|
|
32
|
-
}));
|
|
33
|
-
} undefined"
|
|
34
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
35
|
-
>
|
|
36
|
-
<path
|
|
37
|
-
fill="currentColor"
|
|
38
|
-
style={{}}
|
|
39
|
-
/>
|
|
40
|
-
</svg>
|
|
41
|
-
</span>
|
|
42
|
-
</button>
|
|
43
|
-
`;
|
|
File without changes
|
|
File without changes
|