├── .eslintignore
├── .eslintrc.json
├── .github
└── workflows
│ ├── nodejs.yml
│ └── publish.yml
├── .gitignore
├── CODEOWNERS
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── SECURITY.md
├── custom-elements.json
├── examples
└── index.html
├── package-lock.json
├── package.json
├── src
├── filter-input-element-define.ts
├── filter-input-element.ts
└── index.ts
├── test
├── .eslintrc.json
└── test.js
├── tsconfig.json
└── web-test-runner.config.js
/.eslintignore:
--------------------------------------------------------------------------------
1 | dist
2 |
--------------------------------------------------------------------------------
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "plugin:github/browser",
4 | "plugin:github/recommended",
5 | "plugin:github/typescript",
6 | "plugin:custom-elements/recommended"
7 | ],
8 | "rules": {
9 | "custom-elements/tag-name-matches-class": [
10 | "error",
11 | {
12 | "suffix": "Element"
13 | }
14 | ],
15 | "custom-elements/define-tag-after-class-definition": "off",
16 | "custom-elements/no-method-prefixed-with-on": "off",
17 | "custom-elements/expose-class-on-global": "off",
18 | "import/extensions": ["error", "always"],
19 | "import/no-unresolved": "off"
20 | },
21 | "globals": {
22 | "FilterInputElement": "readable"
23 | },
24 | "overrides": [
25 | {
26 | "files": "src/*-define.ts",
27 | "rules": {
28 | "@typescript-eslint/no-namespace": "off"
29 | }
30 | },
31 | {
32 | "files": "test/**/*.js",
33 | "rules": {
34 | "github/unescaped-html-literal": "off",
35 | "github/no-inner-html": "off",
36 | "i18n-text/no-en": "off"
37 | },
38 | "env": {
39 | "mocha": true
40 | }
41 | }
42 | ]
43 | }
44 |
--------------------------------------------------------------------------------
/.github/workflows/nodejs.yml:
--------------------------------------------------------------------------------
1 | name: Node CI
2 |
3 | on:
4 | pull_request:
5 | branches:
6 | - master
7 | jobs:
8 | build:
9 |
10 | runs-on: ubuntu-latest
11 |
12 | steps:
13 | - uses: actions/checkout@v1
14 | - name: Use Node.js 12.x
15 | uses: actions/setup-node@v1
16 | with:
17 | node-version: 12.x
18 | - name: npm install, build, and test
19 | run: |
20 | npm install
21 | npm run build --if-present
22 | npm test
23 | env:
24 | CI: true
25 |
--------------------------------------------------------------------------------
/.github/workflows/publish.yml:
--------------------------------------------------------------------------------
1 | name: Publish
2 |
3 | on:
4 | release:
5 | types: [created]
6 |
7 | jobs:
8 | publish-npm:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - uses: actions/checkout@v3
12 | - uses: actions/setup-node@v3
13 | with:
14 | node-version: 14
15 | registry-url: https://registry.npmjs.org/
16 | cache: npm
17 | - run: npm ci
18 | - run: npm test
19 | - run: npm version ${TAG_NAME} --git-tag-version=false
20 | env:
21 | TAG_NAME: ${{ github.event.release.tag_name }}
22 | - run: npm whoami; npm --ignore-scripts publish
23 | env:
24 | NODE_AUTH_TOKEN: ${{secrets.npm_token}}
25 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | dist
2 | node_modules
3 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @github/primer-reviewers
2 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Contributing
2 |
3 | [fork]: https://github.com/github/filter-input-element/fork
4 | [pr]: https://github.com/github/filter-input-element/compare
5 | [code-of-conduct]: CODE_OF_CONDUCT.md
6 |
7 | Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
8 |
9 | Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
10 |
11 | Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
12 |
13 | ## Submitting a pull request
14 |
15 | 0. [Fork][fork] and clone the repository
16 | 0. Configure and install the dependencies: `script/bootstrap`
17 | 0. Make sure the tests pass on your machine: `rake`
18 | 0. Create a new branch: `git checkout -b my-branch-name`
19 | 0. Make your change, add tests, and make sure the tests still pass
20 | 0. Push to your fork and [submit a pull request][pr]
21 | 0. Pat your self on the back and wait for your pull request to be reviewed and merged.
22 |
23 | Here are a few things you can do that will increase the likelihood of your pull request being accepted:
24 |
25 | - Write tests.
26 | - Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
27 | - Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
28 |
29 | ## Resources
30 |
31 | - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
32 | - [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
33 | - [GitHub Help](https://help.github.com)
34 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing
2 |
3 | [fork]: https://github.com/github/filter-input-element/fork
4 | [pr]: https://github.com/github/filter-input-element/compare
5 | [code-of-conduct]: CODE_OF_CONDUCT.md
6 |
7 | Hi there! We're thrilled that you'd like to contribute to this project. Your help is essential for keeping it great.
8 |
9 | Contributions to this project are [released](https://help.github.com/articles/github-terms-of-service/#6-contributions-under-repository-license) to the public under the [project's open source license](LICENSE).
10 |
11 | Please note that this project is released with a [Contributor Code of Conduct][code-of-conduct]. By participating in this project you agree to abide by its terms.
12 |
13 | ## Submitting a pull request
14 |
15 | 0. [Fork][fork] and clone the repository
16 | 0. Configure and install the dependencies: `script/bootstrap`
17 | 0. Make sure the tests pass on your machine: `rake`
18 | 0. Create a new branch: `git checkout -b my-branch-name`
19 | 0. Make your change, add tests, and make sure the tests still pass
20 | 0. Push to your fork and [submit a pull request][pr]
21 | 0. Pat your self on the back and wait for your pull request to be reviewed and merged.
22 |
23 | Here are a few things you can do that will increase the likelihood of your pull request being accepted:
24 |
25 | - Write tests.
26 | - Keep your change as focused as possible. If there are multiple changes you would like to make that are not dependent upon each other, consider submitting them as separate pull requests.
27 | - Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
28 |
29 | ## Resources
30 |
31 | - [How to Contribute to Open Source](https://opensource.guide/how-to-contribute/)
32 | - [Using Pull Requests](https://help.github.com/articles/about-pull-requests/)
33 | - [GitHub Help](https://help.github.com)
34 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2019 GitHub, Inc.
2 |
3 | Permission is hereby granted, free of charge, to any person obtaining
4 | a copy of this software and associated documentation files (the
5 | "Software"), to deal in the Software without restriction, including
6 | without limitation the rights to use, copy, modify, merge, publish,
7 | distribute, sublicense, and/or sell copies of the Software, and to
8 | permit persons to whom the Software is furnished to do so, subject to
9 | the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be
12 | included in all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # <filter-input> element 
2 |
3 | Display elements in a subtree that match filter input text.
4 |
5 | ## Installation
6 |
7 | ```
8 | $ npm install @github/filter-input-element
9 | ```
10 |
11 | ## Usage
12 |
13 | ```html
14 |
15 |
19 |
20 |
21 |
22 |
Bender
23 |
Hubot
24 |
Wall-E
25 |
BB-8
26 |
R2-D2
27 |
28 |
0 robots found.
29 |
30 | ```
31 |
32 | ## Elements and attributes
33 |
34 | ### Required
35 |
36 | - `filter-input[aria-owns]` should point to the container ID that wraps all `` related elements.
37 | - `filter-input` should have one `input` child element that is used to filter.
38 | - `[id]` should be set on a container that either contains or has `[data-filter-list]` attribute.
39 | - `[data-filter-list]` should be set on the element whose **direct child elements** are to be filtered.
40 |
41 | ### Optional
42 |
43 | #### Specify filter text
44 |
45 | Use `[data-filter-item-text]` to specify an element whose text should be used for filtering. In the following example, the text `(current)` would not be matched.
46 |
47 | ```html
48 |
55 | ```
56 |
57 | #### Blankslate
58 |
59 | Use `[data-filter-empty-state]` to specify an element to be displayed when no results were found. This element must be inside of the container `aria-owns` points to.
60 |
61 | ```html
62 |
69 | ```
70 |
71 | #### Create new item
72 |
73 | Use `[data-filter-new-item]` to include an item to create a new instance when no exact match were found. The element with `[data-filter-new-text]`'s text content will be set to the input value. You can also use `[data-filter-new-value]` to set an input value to the query param.
74 |
75 | ```html
76 |