Skip to content

Commit 152cf03

Browse files
authored
Merge pull request #163 from heroku/ay/3pp-high-sev-deps
Updating packages to address high severity alerts
2 parents dbcc9db + 47b2c2d commit 152cf03

File tree

7 files changed

+3958
-3750
lines changed

7 files changed

+3958
-3750
lines changed

.babelrc

Lines changed: 0 additions & 14 deletions
This file was deleted.

.babelrc.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
{
6+
targets: {
7+
node: 'current',
8+
},
9+
modules: 'commonjs',
10+
},
11+
],
12+
[
13+
'@babel/preset-react',
14+
{
15+
runtime: 'automatic',
16+
},
17+
],
18+
],
19+
env: {
20+
test: {
21+
plugins: ['babel-plugin-require-context-hook'],
22+
},
23+
},
24+
}

package.json

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,68 +10,65 @@
1010
"node": "16.x"
1111
},
1212
"dependencies": {
13+
"@babel/core": "^7.23.0",
14+
"@babel/preset-env": "^7.23.0",
15+
"@babel/preset-react": "^7.22.0",
1316
"@heroku/react-malibu": "^4.1.0",
14-
"@popperjs/core": "^2.11.8",
1517
"@types/jest": "^27.5.2",
1618
"@types/lodash": "^4.17.20",
1719
"@types/react": "^18.0.28",
1820
"@types/react-dom": "^18.0.11",
1921
"@types/react-test-renderer": "^18.0.0",
2022
"@types/react-transition-group": "^4.4.5",
21-
"babel-core": "^6.26.3",
22-
"babel-jest": "^23.6.0",
23-
"babel-loader": "7",
23+
"babel-jest": "^29.7.0",
24+
"babel-loader": "^9.1.0",
2425
"babel-plugin-require-context-hook": "^1.0.0",
25-
"babel-preset-env": "^1.7.0",
26-
"babel-preset-react": "^6.24.1",
27-
"babel-preset-stage-1": "^6.24.1",
2826
"classnames": "^2.3.2",
29-
"copy-webpack-plugin": "^4.6.0",
30-
"css-loader": "^1.0.1",
31-
"d3": "^5.4.0",
27+
"copy-webpack-plugin": "6.4.1",
28+
"css-loader": "^5.2.7",
29+
"d3": "^7.9.0",
3230
"date-fns": "^1.30.1",
3331
"lodash": "^4.17.21",
34-
"mini-css-extract-plugin": "^0.4.4",
35-
"react": "^18.2.0",
36-
"react-dom": "^18.2.0",
37-
"react-hot-loader": "^4.3.1",
32+
"mini-css-extract-plugin": "^1.6.2",
3833
"react-inlinesvg": "^0.8.3",
3934
"react-measure": "^2.0.0",
4035
"react-outside-click-handler": "^1.2.2",
41-
"react-popper": "2.3.0",
42-
"react-select": "^2.1.2",
4336
"react-table": "^6.8.6",
4437
"react-transition-group": "^4.4.5",
4538
"regenerator-runtime": "^0.12.1",
4639
"simple-react-modal": "0.5.1",
47-
"style-loader": "^0.23.1",
48-
"ts-loader": "^8.4.0",
49-
"uglifyjs-webpack-plugin": "^2.0.1"
40+
"style-loader": "3.3.4",
41+
"terser-webpack-plugin": "^4.2.3",
42+
"ts-loader": "^8.4.0"
43+
},
44+
"peerDependencies": {
45+
"react": "^18.2.0",
46+
"react-dom": "^18.2.0"
5047
},
5148
"devDependencies": {
5249
"eslint": "^4.15.0",
5350
"eslint-config-prettier": "^3.3.0",
5451
"eslint-plugin-import": "^2.8.0",
55-
"eslint-plugin-node": "^5.2.1",
52+
"eslint-plugin-node": "^11.1.0",
5653
"eslint-plugin-prettier": "^3.0.0",
5754
"eslint-plugin-promise": "^3.6.0",
5855
"eslint-plugin-react": "^7.5.1",
59-
"file-loader": "^1.1.11",
56+
"file-loader": "^6.2.0",
6057
"husky": "^1.2.0",
6158
"jest": "^27.5.1",
62-
"jest-css-modules-transform": "^2.1.1",
63-
"lint-staged": "^8.1.0",
64-
"np": "^2.19.0",
59+
"jest-css-modules-transform": "4.4.2",
60+
"lint-staged": "^13.3.0",
61+
"np": "7.7.0",
6562
"prettier": "1.15.3",
6663
"react-test-renderer": "^18.2.0",
6764
"ts-jest": "^27.1.5",
6865
"tslint": "^5.9.1",
6966
"tslint-config-prettier": "^1.17.0",
7067
"tslint-react": "^3.4.0",
7168
"typescript": "^4.9.5",
72-
"webpack": "^4.25.1",
73-
"webpack-bundle-analyzer": "^3.0.3",
74-
"webpack-cli": "^3.1.2"
69+
"webpack": "4.47.0",
70+
"webpack-bundle-analyzer": "4.10.2",
71+
"webpack-cli": "4.9.2"
7572
},
7673
"scripts": {
7774
"analyze": "rm stats.json && webpack --profile --json > stats.json && webpack-bundle-analyzer stats.json",
@@ -95,6 +92,11 @@
9592
"transformIgnorePatterns": [
9693
"<rootDir>/node_modules/"
9794
],
95+
"moduleNameMapper": {
96+
"^d3-array$": "<rootDir>/node_modules/d3-array/dist/d3-array.js",
97+
"^d3-scale$": "<rootDir>/node_modules/d3-scale/dist/d3-scale.js",
98+
"^d3-shape$": "<rootDir>/node_modules/d3-shape/dist/d3-shape.js"
99+
},
98100
"setupFiles": [
99101
"<rootDir>/test/test-setup.ts"
100102
],

src/HKDropdown.tsx

Lines changed: 47 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import { Modifier } from '@popperjs/core'
21
import classNames from 'classnames'
32
import * as React from 'react'
43
import OutsideClickHandler from 'react-outside-click-handler'
5-
import { Manager, Popper, Reference } from 'react-popper'
64

75
import { default as HKButton, Type } from './HKButton'
86
import { default as HKIcon } from './HKIcon'
@@ -14,8 +12,6 @@ export enum Align {
1412

1513
interface IDropdownProps {
1614
align?: Align // align dropdown component anchoring button
17-
positionFixed?: boolean
18-
modifiers?: Array<Modifier<any, any>>
1915
children?: JSX.Element | JSX.Element[] | string
2016
className?: string // dropdown button styling
2117
closeOnClick?: boolean // hide dropdown content after onClick in dropdown content
@@ -41,7 +37,6 @@ export default class HKDropdown extends React.Component<
4137
closeOnClick: true,
4238
disabled: false,
4339
name: 'hkdropdown',
44-
positionFixed: false,
4540
small: false,
4641
type: Type.Secondary,
4742
}
@@ -50,6 +45,8 @@ export default class HKDropdown extends React.Component<
5045
showDropdown: false,
5146
}
5247

48+
private dropdownRef = React.createRef<HTMLDivElement>()
49+
5350
public handleDropdown = () => {
5451
this.setState(prevState => ({ showDropdown: !prevState.showDropdown }))
5552
}
@@ -62,21 +59,21 @@ export default class HKDropdown extends React.Component<
6259
public handleContentClick = () =>
6360
this.props.closeOnClick && this.setState({ showDropdown: false })
6461

65-
public handleClickOutside = e => {
62+
public handleClickOutside = (e: Event) => {
6663
// When closing by clicking on the menu button again,
6764
// both this handler and handleDropdown will fire.
6865
// Make sure we noop in that scenario so that the dropdown actually closes.
69-
const path = e.path || (e.composedPath && e.composedPath())
66+
const path = (e as any).path || (e.composedPath && e.composedPath())
7067
if (!path) {
7168
this.setState({
7269
showDropdown: false,
7370
})
7471
return
7572
}
76-
const eventNodes = path.filter(node => {
73+
const eventNodes = path.filter((node: any) => {
7774
return node.nodeType === 1
7875
})
79-
const didClickButton = eventNodes.some(node => {
76+
const didClickButton = eventNodes.some((node: any) => {
8077
return (
8178
node.hasAttribute('data-testid') &&
8279
node.getAttribute('data-testid') === this.testId()
@@ -96,69 +93,59 @@ export default class HKDropdown extends React.Component<
9693
className,
9794
contentClassName,
9895
disabled,
99-
modifiers,
10096
name,
101-
positionFixed,
10297
small,
10398
title,
10499
type,
105100
} = this.props
106101
const { showDropdown } = this.state
107-
const popperPlacement =
108-
align === Align.Right ? 'bottom-end' : 'bottom-start'
102+
103+
const dropdownStyle: React.CSSProperties = {
104+
left: align === Align.Right ? 'auto' : '0',
105+
minWidth: '200px',
106+
position: 'absolute',
107+
right: align === Align.Right ? '0' : 'auto',
108+
top: '100%',
109+
zIndex: 9999,
110+
}
111+
109112
return (
110-
<Manager>
111-
<Reference>
112-
{({ ref }) => (
113-
<div className='relative dib' ref={ref}>
114-
<HKButton
115-
onClick={this.handleDropdown}
116-
data-testid={this.testId()}
117-
className={classNames({ ph1: !title }, className)}
118-
type={type}
119-
small={small}
120-
disabled={disabled}
121-
>
122-
{title}
123-
<HKIcon
124-
name='caret-16'
125-
size={16}
126-
className={classNames({ pl1: title })}
127-
/>
128-
</HKButton>
129-
</div>
130-
)}
131-
</Reference>
113+
<div className='relative dib' ref={this.dropdownRef}>
114+
<HKButton
115+
onClick={this.handleDropdown}
116+
data-testid={this.testId()}
117+
className={classNames({ ph1: !title }, className)}
118+
type={type}
119+
small={small}
120+
disabled={disabled}
121+
>
122+
{title}
123+
<HKIcon
124+
name='caret-16'
125+
size={16}
126+
className={classNames({ pl1: title })}
127+
/>
128+
</HKButton>
132129
{showDropdown && (
133130
<OutsideClickHandler onOutsideClick={this.handleClickOutside}>
134-
<Popper
135-
placement={popperPlacement}
136-
modifiers={modifiers}
137-
positionFixed={positionFixed}
131+
<div
132+
className='z-max'
133+
onClick={this.handleContentClick}
134+
data-testid={`${name}-dropdown-content`}
135+
style={dropdownStyle}
138136
>
139-
{({ ref, style, placement }) => (
140-
<div
141-
className='z-max'
142-
onClick={this.handleContentClick}
143-
data-testid={`${name}-dropdown-content`}
144-
ref={ref}
145-
style={style}
146-
data-placement={placement}
147-
>
148-
<ul
149-
className={classNames(
150-
contentClassName,
151-
'list br1 pl0 pv1 mv1 shadow-outer-2 bg-white'
152-
)}
153-
>
154-
{children}
155-
</ul>
156-
</div>
157-
)}
158-
</Popper>
137+
<ul
138+
className={classNames(
139+
contentClassName,
140+
'list br1 pl0 pv1 mv1 shadow-outer-2 bg-white'
141+
)}
142+
>
143+
{children}
144+
</ul>
145+
</div>
159146
</OutsideClickHandler>
160147
)}
161-
</Manager>
148+
</div>
162149
)
163150
}
164151
}

src/declarations.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ declare module 'd3-shape'
66
declare module 'react-measure'
77
declare module 'simple-react-modal'
88
declare module 'react-outside-click-handler'
9-
declare module 'react-popper'
109
declare module 'react-table'

webpack.config.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const path = require('path')
22
const CopyWebpackPlugin = require('copy-webpack-plugin')
3-
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
3+
const TerserPlugin = require('terser-webpack-plugin')
44
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
55

66
module.exports = {
@@ -17,22 +17,38 @@ module.exports = {
1717
resolve: {
1818
extensions: ['.ts', '.tsx', '.js'],
1919
},
20+
externals: {
21+
react: {
22+
commonjs: 'react',
23+
commonjs2: 'react',
24+
amd: 'react',
25+
root: 'React',
26+
},
27+
'react-dom': {
28+
commonjs: 'react-dom',
29+
commonjs2: 'react-dom',
30+
amd: 'react-dom',
31+
root: 'ReactDOM',
32+
},
33+
},
2034
optimization: {
2135
minimizer: [
22-
new UglifyJsPlugin({
23-
uglifyOptions: {
36+
new TerserPlugin({
37+
terserOptions: {
2438
keep_fnames: true,
2539
},
2640
}),
2741
],
2842
},
2943
plugins: [
30-
new CopyWebpackPlugin([
31-
{
32-
from: path.resolve(__dirname, './src/static'),
33-
to: path.resolve(__dirname, './dist/static'),
34-
},
35-
]),
44+
new CopyWebpackPlugin({
45+
patterns: [
46+
{
47+
from: path.resolve(__dirname, './src/static'),
48+
to: path.resolve(__dirname, './dist/static'),
49+
},
50+
],
51+
}),
3652
new MiniCssExtractPlugin({
3753
filename: '[name].css',
3854
chunkFilename: '[id].css',

0 commit comments

Comments
 (0)