@neovici/cosmoz-autocomplete 10.0.0 → 10.1.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 +4 -4
- package/dist/autocomplete/util.js +14 -2
- package/dist/listbox/style.css.js +14 -8
- package/package.json +110 -107
package/README.md
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
cosmoz-autocomplete
|
|
2
|
-
==================
|
|
1
|
+
# cosmoz-autocomplete
|
|
3
2
|
|
|
4
3
|
[](https://github.com/Neovici/cosmoz-autocomplete/actions?workflow=Github+CI)
|
|
5
4
|
[](https://depfu.com/github/Neovici/cosmoz-autocomplete?project_id=9639)
|
|
@@ -16,13 +15,14 @@ cosmoz-autocomplete
|
|
|
16
15
|
### Installing
|
|
17
16
|
|
|
18
17
|
Using npm:
|
|
18
|
+
|
|
19
19
|
```bash
|
|
20
20
|
npm install --save @neovici/cosmoz-autocomplete
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
### Usage
|
|
24
24
|
|
|
25
|
-
```
|
|
25
|
+
```javascript
|
|
26
26
|
import { html } from 'lit-html';
|
|
27
|
-
html`<cosmoz-autocomplete .source=${[
|
|
27
|
+
html`<cosmoz-autocomplete .source=${['A', 'B', 'C', 'D']} />`;
|
|
28
28
|
```
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { useCallback } from '@pionjs/pion';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://stackoverflow.com/questions/990904/remove-accents-diacritics-in-a-string-in-javascript
|
|
4
|
+
* @see https://medium.com/nerd-for-tech/basics-of-javascript-string-normalize-method-f3241174c2d0
|
|
5
|
+
* @see https://www.codu.co/articles/remove-accents-from-a-javascript-string-skgp1inb
|
|
6
|
+
*
|
|
7
|
+
* @param {string} str string from which to remove accents
|
|
8
|
+
* @returns {string} string w/o accents
|
|
9
|
+
*/
|
|
10
|
+
const removeAccents = (str) => {
|
|
11
|
+
return str.normalize('NFD').replace(/[\u0300-\u036f]/gu, '');
|
|
12
|
+
};
|
|
2
13
|
export const search = (source, query, textual) => {
|
|
3
14
|
if (!query)
|
|
4
15
|
return source;
|
|
5
|
-
const
|
|
16
|
+
const normalizedQuery = removeAccents(query.toLowerCase());
|
|
6
17
|
const matches = [];
|
|
7
18
|
for (const item of source) {
|
|
8
|
-
const
|
|
19
|
+
const normalizedText = removeAccents(textual(item).toLowerCase());
|
|
20
|
+
const index = normalizedText.indexOf(normalizedQuery);
|
|
9
21
|
if (index < 0) {
|
|
10
22
|
continue;
|
|
11
23
|
}
|
|
@@ -9,12 +9,17 @@ const style = css `
|
|
|
9
9
|
position: fixed;
|
|
10
10
|
z-index: 1000;
|
|
11
11
|
font-family: var(--paper-font-subhead_-_font-family, inherit);
|
|
12
|
-
background:
|
|
13
|
-
|
|
12
|
+
background: var(
|
|
13
|
+
--cosmoz-autocomplete-listbox-bg,
|
|
14
|
+
rgba(255, 255, 255, 0.85)
|
|
15
|
+
);
|
|
16
|
+
min-width: 50px;
|
|
17
|
+
backdrop-filter: blur(16px) saturate(180%);
|
|
18
|
+
-webkit-backdrop-filter: blur(16px) saturate(180%);
|
|
19
|
+
border-radius: 6px;
|
|
14
20
|
box-shadow:
|
|
15
|
-
0
|
|
16
|
-
0
|
|
17
|
-
0 3px 3px -2px rgba(0, 0, 0, 0.4);
|
|
21
|
+
0 4px 24px 0 rgba(0, 0, 0, 0.18),
|
|
22
|
+
0 1.5px 6px 0 rgba(0, 0, 0, 0.1);
|
|
18
23
|
text-transform: var(--cosmoz-autocomplete-listbox-text-transform, initial);
|
|
19
24
|
overflow: hidden;
|
|
20
25
|
}
|
|
@@ -22,7 +27,7 @@ const style = css `
|
|
|
22
27
|
box-sizing: border-box;
|
|
23
28
|
display: block;
|
|
24
29
|
margin: 0;
|
|
25
|
-
border: 0;
|
|
30
|
+
border: 1px solid rgba(200, 200, 200, 0.25);
|
|
26
31
|
}
|
|
27
32
|
:host([popover]) {
|
|
28
33
|
padding: 0;
|
|
@@ -31,10 +36,11 @@ const style = css `
|
|
|
31
36
|
position: relative;
|
|
32
37
|
overflow-y: auto;
|
|
33
38
|
contain: layout paint !important;
|
|
39
|
+
padding-bottom: var(--cosmoz-autocomplete-listbox-padding-bottom, 8px);
|
|
34
40
|
}
|
|
35
41
|
.item {
|
|
36
|
-
font-size:
|
|
37
|
-
padding: 0
|
|
42
|
+
font-size: var(--cosmoz-autocomplete-listbox-font-size, 13px);
|
|
43
|
+
padding: 0 22px;
|
|
38
44
|
box-sizing: border-box;
|
|
39
45
|
width: 100%;
|
|
40
46
|
cursor: pointer;
|
package/package.json
CHANGED
|
@@ -1,109 +1,112 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
2
|
+
"name": "@neovici/cosmoz-autocomplete",
|
|
3
|
+
"version": "10.1.0",
|
|
4
|
+
"description": "A autocomplete input web component",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"lit-html",
|
|
7
|
+
"web-components"
|
|
8
|
+
],
|
|
9
|
+
"homepage": "https://github.com/neovici/cosmoz-autocomplete#readme",
|
|
10
|
+
"bugs": {
|
|
11
|
+
"url": "https://github.com/neovici/cosmoz-autocomplete/issues"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/neovici/cosmoz-autocomplete.git"
|
|
16
|
+
},
|
|
17
|
+
"license": "Apache-2.0",
|
|
18
|
+
"author": "",
|
|
19
|
+
"main": "cosmoz-autocomplete.js",
|
|
20
|
+
"directories": {
|
|
21
|
+
"test": "test"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"lint": "tsc && eslint --cache .",
|
|
25
|
+
"build": "tsc -p tsconfig.build.json",
|
|
26
|
+
"start": "npm run storybook:start",
|
|
27
|
+
"test": "wtr --coverage",
|
|
28
|
+
"test:watch": "wtr --watch",
|
|
29
|
+
"e2e": "playwright test",
|
|
30
|
+
"prepare": "husky",
|
|
31
|
+
"prettier": "prettier --write \"**/*.{js,ts,json,css,md}\"",
|
|
32
|
+
"prettier:check": "prettier --check \"**/*.{js,ts,json,css,md}\"",
|
|
33
|
+
"storybook:start": "storybook dev -p 8000",
|
|
34
|
+
"storybook:build": "storybook build",
|
|
35
|
+
"storybook:deploy": "storybook-to-ghpages",
|
|
36
|
+
"storybook:preview": "npm run storybook:build && http-server ./storybook-static/ --silent"
|
|
37
|
+
},
|
|
38
|
+
"release": {
|
|
39
|
+
"plugins": [
|
|
40
|
+
"@semantic-release/commit-analyzer",
|
|
41
|
+
"@semantic-release/release-notes-generator",
|
|
42
|
+
"@semantic-release/changelog",
|
|
43
|
+
"@semantic-release/github",
|
|
44
|
+
"@semantic-release/npm",
|
|
45
|
+
"@semantic-release/git"
|
|
46
|
+
],
|
|
47
|
+
"branch": "master",
|
|
48
|
+
"preset": "conventionalcommits"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist/"
|
|
55
|
+
],
|
|
56
|
+
"commitlint": {
|
|
57
|
+
"extends": [
|
|
58
|
+
"@commitlint/config-conventional"
|
|
59
|
+
],
|
|
60
|
+
"rules": {
|
|
61
|
+
"body-max-line-length": [
|
|
62
|
+
1,
|
|
63
|
+
"always",
|
|
64
|
+
100
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"exports": {
|
|
69
|
+
".": "./dist/index.js",
|
|
70
|
+
"./autocomplete": "./dist/autocomplete/index.js",
|
|
71
|
+
"./listbox": "./dist/listbox/index.js",
|
|
72
|
+
"./item-renderer": "./dist/listbox/item-renderer.js"
|
|
73
|
+
},
|
|
74
|
+
"dependencies": {
|
|
75
|
+
"@lit-labs/virtualizer": "^2.0.0",
|
|
76
|
+
"@neovici/cosmoz-dropdown": "^5.0.0",
|
|
77
|
+
"@neovici/cosmoz-input": "^5.0.2",
|
|
78
|
+
"@neovici/cosmoz-utils": "^6.0.0",
|
|
79
|
+
"@pionjs/pion": "^2.7.1",
|
|
80
|
+
"lit-html": "^2.0.0 || ^3.0.0"
|
|
81
|
+
},
|
|
82
|
+
"devDependencies": {
|
|
83
|
+
"@commitlint/cli": "^19.0.0",
|
|
84
|
+
"@commitlint/config-conventional": "^19.0.0",
|
|
85
|
+
"@neovici/cfg": "^1.34.0",
|
|
86
|
+
"@open-wc/testing": "^4.0.0",
|
|
87
|
+
"@playwright/test": "^1.43.1",
|
|
88
|
+
"@semantic-release/changelog": "^6.0.0",
|
|
89
|
+
"@semantic-release/git": "^10.0.0",
|
|
90
|
+
"@storybook/addon-essentials": "^7.0.0",
|
|
91
|
+
"@storybook/addon-links": "^7.0.0",
|
|
92
|
+
"@storybook/builder-vite": "7.6.17",
|
|
93
|
+
"@storybook/storybook-deployer": "^2.8.5",
|
|
94
|
+
"@storybook/web-components": "7.6.17",
|
|
95
|
+
"@types/mocha": "^10.0.6",
|
|
96
|
+
"@types/node": "^22.10.2",
|
|
97
|
+
"@web/storybook-builder": "^0.1.9",
|
|
98
|
+
"@web/storybook-framework-web-components": "^0.1.1",
|
|
99
|
+
"esbuild": "^0.24.0",
|
|
100
|
+
"http-server": "^14.1.1",
|
|
101
|
+
"husky": "^9.0.0",
|
|
102
|
+
"prettier": "^3.6.2",
|
|
103
|
+
"rollup-plugin-esbuild": "^6.1.1",
|
|
104
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
105
|
+
"semantic-release": "^24.0.0",
|
|
106
|
+
"sinon": "^19.0.0",
|
|
107
|
+
"storybook": "^7.6.17"
|
|
108
|
+
},
|
|
109
|
+
"overrides": {
|
|
110
|
+
"conventional-changelog-conventionalcommits": ">= 8.0.0"
|
|
111
|
+
}
|
|
109
112
|
}
|