@neovici/cosmoz-autocomplete 3.0.0 → 3.0.3
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/cosmoz-listbox.js +2 -1
- package/lib/autocomplete.css.js +10 -1
- package/lib/autocomplete.js +4 -4
- package/package.json +1 -1
package/cosmoz-listbox.js
CHANGED
package/lib/autocomplete.css.js
CHANGED
|
@@ -21,6 +21,10 @@ export const listboxStyle = css`
|
|
|
21
21
|
border-color: #5881f6;
|
|
22
22
|
background: url("${ svg }") #5881f6 no-repeat 50%;
|
|
23
23
|
}
|
|
24
|
+
|
|
25
|
+
.sizer {
|
|
26
|
+
padding-left: 33px;
|
|
27
|
+
}
|
|
24
28
|
`;
|
|
25
29
|
|
|
26
30
|
export default css`
|
|
@@ -37,7 +41,11 @@ export default css`
|
|
|
37
41
|
display: flex;
|
|
38
42
|
flex-direction: row;
|
|
39
43
|
align-items: center;
|
|
40
|
-
|
|
44
|
+
flex: 0.00001 1 min-content;
|
|
45
|
+
max-width: 285px;
|
|
46
|
+
max-width: 28ch;
|
|
47
|
+
}
|
|
48
|
+
.chip[data-one] {
|
|
41
49
|
position: absolute;
|
|
42
50
|
left: 0;
|
|
43
51
|
top: 1px;
|
|
@@ -46,6 +54,7 @@ export default css`
|
|
|
46
54
|
margin: 0;
|
|
47
55
|
z-index: 2;
|
|
48
56
|
pointer-events: auto;
|
|
57
|
+
max-width: initial;
|
|
49
58
|
}
|
|
50
59
|
.chip-text {
|
|
51
60
|
color: var(--cosmoz-autocomplete-chip-color, #424242);
|
package/lib/autocomplete.js
CHANGED
|
@@ -11,8 +11,8 @@ import style, { listboxStyle } from './autocomplete.css';
|
|
|
11
11
|
|
|
12
12
|
const
|
|
13
13
|
blank = () => nothing,
|
|
14
|
-
renderChip = (text, onClear, disabled) => html`
|
|
15
|
-
<div class="chip" part="chip" slot="suffix" title=${ text }>
|
|
14
|
+
renderChip = (text, onClear, disabled, isOne) => html`
|
|
15
|
+
<div class="chip" part="chip" slot="suffix" title=${ text } ?data-one=${isOne}>
|
|
16
16
|
<span class="chip-text" part="chip-text">${ text }</span>
|
|
17
17
|
${ !disabled && html`
|
|
18
18
|
<span class="chip-clear" part="chip-clear" @click=${ onClear }>
|
|
@@ -25,9 +25,9 @@ const
|
|
|
25
25
|
`,
|
|
26
26
|
renderBadge = len => len > 0 ? html`<div class="badge" slot="suffix" part="badge">${ len }</div>` : nothing,
|
|
27
27
|
renderSelection = (value, isOne, onDeselect, textual, disabled) => {
|
|
28
|
-
if (isOne) {
|
|
28
|
+
if (isOne || value.length === 1) {
|
|
29
29
|
const val = value[0];
|
|
30
|
-
return val ? renderChip(textual(val), () => onDeselect(val), disabled) : nothing;
|
|
30
|
+
return val ? renderChip(textual(val), () => onDeselect(val), disabled, isOne) : nothing;
|
|
31
31
|
}
|
|
32
32
|
return renderBadge(value.length);
|
|
33
33
|
},
|