@neovici/cosmoz-autocomplete 10.4.0 → 10.5.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.
|
@@ -4,17 +4,18 @@ import { mark } from './util';
|
|
|
4
4
|
export const itemRenderer = (render = identity) => (item, i, { highlight, select, textual = identity, query, isSelected, }) => {
|
|
5
5
|
const text = textual(item), content = mark(text, query), rendered = render(content, item, i);
|
|
6
6
|
return html `<div
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
7
|
+
class="item"
|
|
8
|
+
role="option"
|
|
9
|
+
part="option"
|
|
10
|
+
?aria-selected=${isSelected(item)}
|
|
11
|
+
data-index=${i}
|
|
12
|
+
@mouseenter=${() => highlight(i)}
|
|
13
|
+
@click=${() => select(item)}
|
|
14
|
+
@mousedown=${(e) => e.preventDefault()}
|
|
15
|
+
title=${text}
|
|
16
|
+
>
|
|
17
|
+
${rendered}
|
|
18
|
+
</div>
|
|
19
|
+
<div class="sizer" virtualizer-sizer>${rendered}</div>`;
|
|
19
20
|
};
|
|
20
21
|
export default itemRenderer();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { css } from '@pionjs/pion';
|
|
2
2
|
import { when } from 'lit-html/directives/when.js';
|
|
3
3
|
const svg =
|
|
4
4
|
/* eslint-disable quotes */
|
|
@@ -20,12 +20,23 @@ const style = css `
|
|
|
20
20
|
0 1.5px 6px 0 rgba(0, 0, 0, 0.1);
|
|
21
21
|
text-transform: var(--cosmoz-autocomplete-listbox-text-transform, initial);
|
|
22
22
|
overflow: hidden;
|
|
23
|
+
transition:
|
|
24
|
+
opacity 150ms ease-in-out,
|
|
25
|
+
transform 100ms ease-in-out;
|
|
23
26
|
}
|
|
24
27
|
:host(:popover-open) {
|
|
25
28
|
box-sizing: border-box;
|
|
26
29
|
display: block;
|
|
27
30
|
margin: 0;
|
|
28
31
|
border: 1px solid rgba(200, 200, 200, 0.25);
|
|
32
|
+
|
|
33
|
+
opacity: 1;
|
|
34
|
+
transform: translateY(0);
|
|
35
|
+
|
|
36
|
+
@starting-style {
|
|
37
|
+
opacity: 0;
|
|
38
|
+
transform: translateY(-50px);
|
|
39
|
+
}
|
|
29
40
|
}
|
|
30
41
|
:host([popover]) {
|
|
31
42
|
padding: 0;
|
|
@@ -49,6 +60,20 @@ const style = css `
|
|
|
49
60
|
overflow: hidden;
|
|
50
61
|
}
|
|
51
62
|
|
|
63
|
+
.sizer {
|
|
64
|
+
position: relative;
|
|
65
|
+
visibility: hidden;
|
|
66
|
+
opacity: 0;
|
|
67
|
+
pointer-events: none;
|
|
68
|
+
z-index: -1;
|
|
69
|
+
height: 0;
|
|
70
|
+
width: auto;
|
|
71
|
+
padding: 0 20px;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
max-width: inherit;
|
|
74
|
+
font-size: 14px;
|
|
75
|
+
}
|
|
76
|
+
|
|
52
77
|
:host(:not([multi])) .item[aria-selected] {
|
|
53
78
|
background: var(--cosmoz-listbox-single-selection-color, #dadada);
|
|
54
79
|
}
|
|
@@ -71,6 +96,9 @@ const style = css `
|
|
|
71
96
|
/* prettier-ignore */
|
|
72
97
|
background: url("${svg}") #5881f6 no-repeat 50%;
|
|
73
98
|
}
|
|
99
|
+
:host([multi]) .sizer {
|
|
100
|
+
padding-left: 33px;
|
|
101
|
+
}
|
|
74
102
|
.swatch {
|
|
75
103
|
width: 18px;
|
|
76
104
|
height: 18px;
|
|
@@ -79,12 +107,12 @@ const style = css `
|
|
|
79
107
|
vertical-align: middle;
|
|
80
108
|
border-radius: 50%;
|
|
81
109
|
}
|
|
82
|
-
[virtualizer-sizer] {
|
|
110
|
+
[virtualizer-sizer]:not(.sizer) {
|
|
83
111
|
line-height: 1;
|
|
84
112
|
}
|
|
85
113
|
`;
|
|
86
114
|
export default style;
|
|
87
|
-
export const styles = ({ index, itemHeight, auto }) => css `
|
|
115
|
+
export const styles = ({ index, itemHeight, auto, }) => css `
|
|
88
116
|
${when(!auto, () => css `
|
|
89
117
|
.item {
|
|
90
118
|
line-height: ${itemHeight}px;
|