From 4f52adde4dd3e8eb06ebc62858e3c508281e2d5f Mon Sep 17 00:00:00 2001 From: Christopher Krogh <35310373+chriskrogh@users.noreply.github.com> Date: Tue, 14 Nov 2023 02:48:44 -0500 Subject: [PATCH] Allow filtering the list of entrypoints (#624) * filter entrypoints * changelog --- CHANGELOG.md | 3 + client/components/Dropdown.css | 15 +++-- client/components/Dropdown.jsx | 83 ++++++++++++++++++++++++---- client/components/ModulesTreemap.jsx | 9 +-- 4 files changed, 88 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b86d4e54..dd38e914 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ _Note: Gaps between patch versions are faulty, broken or test releases._ ## UNRELEASED +* **Improvement** + * Allows filtering the list of entrypoints ([#624](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/624) by [@chriskrogh](https://github.com/chriskrogh)) + * **Internal** * Make module much slimmer by replacing all `lodash.*` packages ([#612](https://github.com/webpack-contrib/webpack-bundle-analyzer/pull/612)) by [@sukkaw](https://github.com/sukkaw). diff --git a/client/components/Dropdown.css b/client/components/Dropdown.css index 86653a6e..f3b78e8a 100644 --- a/client/components/Dropdown.css +++ b/client/components/Dropdown.css @@ -3,7 +3,13 @@ white-space: nowrap; } -.select { +.label { + font-size: 11px; + font-weight: bold; + margin-bottom: 7px; +} + +.input { border: 1px solid #aaa; border-radius: 4px; display: block; @@ -12,8 +18,7 @@ height: 27px; } -.label { - font-size: 11px; - font-weight: bold; - margin-bottom: 7px; +.option { + padding: 4px 0; + cursor: pointer; } diff --git a/client/components/Dropdown.jsx b/client/components/Dropdown.jsx index a539bb0c..6540a5c9 100644 --- a/client/components/Dropdown.jsx +++ b/client/components/Dropdown.jsx @@ -1,25 +1,88 @@ +import {createRef} from 'preact'; import PureComponent from '../lib/PureComponent'; import s from './Dropdown.css'; + export default class Dropdown extends PureComponent { + input = createRef(); + + state = { + query: '', + showOptions: false + }; + + componentDidMount() { + document.addEventListener('click', this.handleClickOutside, true); + } + + componentWillUnmount() { + document.removeEventListener('click', this.handleClickOutside, true); + } render() { - const {label, defaultOption, onSelectionChange, options} = this.props; + const {label, options} = this.props; + + const filteredOptions = + this.state.query + ? options.filter((option) => + option.toLowerCase().includes(this.state.query.toLowerCase()) + ) + : options; return (