@neovici/cosmoz-autocomplete 13.6.0-beta.1 → 13.6.1
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/dist/autocomplete/autocomplete.d.ts +4 -5
- package/dist/autocomplete/autocomplete.js +8 -18
- package/dist/autocomplete/chip.css.js +57 -0
- package/dist/autocomplete/chip.d.ts +2 -2
- package/dist/autocomplete/chip.js +53 -6
- package/dist/autocomplete/index.js +1 -8
- package/dist/autocomplete/styles.css.d.ts +2 -0
- package/dist/autocomplete/styles.css.js +66 -0
- package/dist/autocomplete/use-overflow.js +0 -2
- package/dist/excluding/index.d.ts +0 -1
- package/dist/excluding/index.js +7 -7
- package/dist/excluding/style.css.js +30 -5
- package/dist/listbox/style.css.js +38 -41
- package/package.json +5 -8
- package/dist/autocomplete/style.css.js +0 -91
- /package/dist/autocomplete/{style.css.d.ts → chip.css.d.ts} +0 -0
|
@@ -3,16 +3,15 @@ import '@neovici/cosmoz-input';
|
|
|
3
3
|
import { ItemRenderer } from '../listbox/item-renderer';
|
|
4
4
|
import { ChipRenderer } from './selection';
|
|
5
5
|
import './skeleton-span';
|
|
6
|
-
import style from './
|
|
6
|
+
import style from './styles.css';
|
|
7
7
|
import { Props as Base, RProps } from './use-autocomplete';
|
|
8
8
|
export interface Props<I> extends Base<I> {
|
|
9
|
-
mode?: 'select';
|
|
10
|
-
variant?: 'default' | 'cell' | 'inline';
|
|
11
9
|
invalid?: boolean;
|
|
12
10
|
errorMessage?: string;
|
|
13
|
-
hint?: string;
|
|
14
11
|
label?: string;
|
|
15
12
|
placeholder?: string;
|
|
13
|
+
noLabelFloat?: boolean;
|
|
14
|
+
alwaysFloatLabel?: boolean;
|
|
16
15
|
showSingle?: boolean;
|
|
17
16
|
itemHeight?: number | 'auto';
|
|
18
17
|
itemLimit?: number;
|
|
@@ -25,5 +24,5 @@ export interface Props<I> extends Base<I> {
|
|
|
25
24
|
type AProps<I> = Omit<Props<I>, keyof RProps<I>> & RProps<I> & {
|
|
26
25
|
onInputRef?: (el?: Element) => void;
|
|
27
26
|
};
|
|
28
|
-
declare const autocomplete: <I>(props: AProps<I>) => import("lit-html").TemplateResult<1>, Autocomplete: <I>(props: Props<I>) => import("lit-html").TemplateResult<1>, observedAttributes: readonly ["
|
|
27
|
+
declare const autocomplete: <I>(props: AProps<I>) => import("lit-html").TemplateResult<1>, Autocomplete: <I>(props: Props<I>) => import("lit-html").TemplateResult<1>, observedAttributes: readonly ["disabled", "invalid", "no-label-float", "always-float-label", "text-property", "value-property", "limit", "min", "show-single", "preserve-order", "keep-opened", "keep-query", "default-index", "external-search", "item-height", "item-limit", "wrap", "lazy-open"];
|
|
29
28
|
export { Autocomplete, autocomplete, observedAttributes, style };
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import '@neovici/cosmoz-dropdown/cosmoz-dropdown-next';
|
|
2
|
-
import { chevronDownIcon } from '@neovici/cosmoz-icons/untitled';
|
|
3
2
|
import '@neovici/cosmoz-input';
|
|
4
3
|
import { t } from 'i18next';
|
|
5
4
|
import { html } from 'lit-html';
|
|
6
5
|
import { guard } from 'lit-html/directives/guard.js';
|
|
7
|
-
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
8
6
|
import { live } from 'lit-html/directives/live.js';
|
|
9
7
|
import { until } from 'lit-html/directives/until.js';
|
|
10
8
|
import { when } from 'lit-html/directives/when.js';
|
|
11
9
|
import { listbox } from '../listbox';
|
|
12
10
|
import { selection } from './selection';
|
|
13
11
|
import './skeleton-span';
|
|
14
|
-
import style from './
|
|
12
|
+
import style from './styles.css';
|
|
15
13
|
import { useAutocomplete } from './use-autocomplete';
|
|
16
14
|
import { useOverflow } from './use-overflow';
|
|
17
15
|
const inputParts = ['input', 'control', 'label', 'line', 'error', 'wrap']
|
|
@@ -25,7 +23,7 @@ const shouldShowDropdown = ({ opened, isSingle, showSingle, hasResultsOrQuery, }
|
|
|
25
23
|
return hasResultsOrQuery;
|
|
26
24
|
};
|
|
27
25
|
const autocomplete = (props) => {
|
|
28
|
-
const {
|
|
26
|
+
const { opened, invalid, errorMessage, label, placeholder, disabled, noLabelFloat, alwaysFloatLabel, textual, text, onText, onToggle, onDeselect, value, limit, min, showSingle, items, source$, loading, chipRenderer, } = props, isOne = limit === 1, isSingle = isOne && value?.[0] != null;
|
|
29
27
|
const hasResultsOrQuery = loading || items.length > 0 || (text != null && text.length > 0);
|
|
30
28
|
return html `<cosmoz-dropdown-next
|
|
31
29
|
open-on-focus
|
|
@@ -40,8 +38,8 @@ const autocomplete = (props) => {
|
|
|
40
38
|
part="input"
|
|
41
39
|
.label=${label}
|
|
42
40
|
.placeholder=${isSingle ? undefined : placeholder}
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
?no-label-float=${noLabelFloat}
|
|
42
|
+
?always-float-label=${value?.length > 0 || alwaysFloatLabel}
|
|
45
43
|
?readonly=${isSingle}
|
|
46
44
|
?disabled=${disabled}
|
|
47
45
|
?invalid=${guard([source$, invalid], () => until(source$.then(() => invalid, () => true), invalid))}
|
|
@@ -54,13 +52,7 @@ const autocomplete = (props) => {
|
|
|
54
52
|
?data-single=${isSingle}
|
|
55
53
|
>
|
|
56
54
|
<slot name="prefix" slot="prefix"></slot>
|
|
57
|
-
<slot name="suffix" slot="suffix">
|
|
58
|
-
${when(mode === 'select', () => chevronDownIcon({
|
|
59
|
-
styles: 'margin-right: calc(var(--cz-spacing) * 2);color: var(--cz-color-text-secondary);',
|
|
60
|
-
width: '16',
|
|
61
|
-
height: '16',
|
|
62
|
-
}))}
|
|
63
|
-
</slot>
|
|
55
|
+
<slot name="suffix" slot="suffix"></slot>
|
|
64
56
|
${selection({
|
|
65
57
|
value,
|
|
66
58
|
min,
|
|
@@ -82,7 +74,7 @@ const autocomplete = (props) => {
|
|
|
82
74
|
items,
|
|
83
75
|
multi: !isOne,
|
|
84
76
|
}, when(loading, () => html `<cosmoz-autocomplete-skeleton-span></cosmoz-autocomplete-skeleton-span>`, () => when(text != null && text.length > 0 && items.length === 0, () => html `<slot name="no-result">
|
|
85
|
-
<
|
|
77
|
+
<p class="no-result">${t('No results found')}</p>
|
|
86
78
|
</slot>`))))}
|
|
87
79
|
</cosmoz-dropdown-next>`;
|
|
88
80
|
}, Autocomplete = (props) => {
|
|
@@ -93,11 +85,10 @@ const autocomplete = (props) => {
|
|
|
93
85
|
useOverflow(thru);
|
|
94
86
|
return autocomplete(thru);
|
|
95
87
|
}, observedAttributes = [
|
|
96
|
-
'variant',
|
|
97
88
|
'disabled',
|
|
98
89
|
'invalid',
|
|
99
|
-
'
|
|
100
|
-
'
|
|
90
|
+
'no-label-float',
|
|
91
|
+
'always-float-label',
|
|
101
92
|
'text-property',
|
|
102
93
|
'value-property',
|
|
103
94
|
'limit',
|
|
@@ -112,6 +103,5 @@ const autocomplete = (props) => {
|
|
|
112
103
|
'item-limit',
|
|
113
104
|
'wrap',
|
|
114
105
|
'lazy-open',
|
|
115
|
-
'mode',
|
|
116
106
|
];
|
|
117
107
|
export { Autocomplete, autocomplete, observedAttributes, style };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { tagged as css } from '@neovici/cosmoz-utils';
|
|
2
|
+
export default css `
|
|
3
|
+
:host {
|
|
4
|
+
border-radius: var(--cosmoz-autocomplete-chip-border-radius, 500px);
|
|
5
|
+
background: var(--cosmoz-autocomplete-chip-bg-color, #cbcfdb);
|
|
6
|
+
margin-bottom: 2px;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
flex: 0.0001 1 fit-content;
|
|
10
|
+
max-width: 18ch;
|
|
11
|
+
min-width: 40px;
|
|
12
|
+
padding-inline: 8px;
|
|
13
|
+
gap: 4px;
|
|
14
|
+
cursor: pointer;
|
|
15
|
+
transform: translateY(var(--cosmoz-autocomplete-chip-translate-y, 0));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.content {
|
|
19
|
+
color: var(--cosmoz-autocomplete-chip-color, #424242);
|
|
20
|
+
font-family: var(
|
|
21
|
+
--cosmoz-autocomplete-chip-text-font-family,
|
|
22
|
+
'Inter',
|
|
23
|
+
sans-serif
|
|
24
|
+
);
|
|
25
|
+
font-size: var(--cosmoz-autocomplete-chip-text-font-size, 12px);
|
|
26
|
+
font-weight: var(--cosmoz-autocomplete-chip-text-font-weight, 400);
|
|
27
|
+
line-height: var(--cosmoz-autocomplete-chip-text-line-height, 22px);
|
|
28
|
+
overflow: hidden;
|
|
29
|
+
text-overflow: ellipsis;
|
|
30
|
+
white-space: nowrap;
|
|
31
|
+
flex: auto;
|
|
32
|
+
min-width: 16px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.clear {
|
|
36
|
+
background-color: var(--cosmoz-autocomplete-chip-clear-bg-color, #81899b);
|
|
37
|
+
border-radius: 50%;
|
|
38
|
+
cursor: pointer;
|
|
39
|
+
width: 16px;
|
|
40
|
+
height: 16px;
|
|
41
|
+
margin-right: -4px;
|
|
42
|
+
stroke: var(
|
|
43
|
+
--cosmoz-autocomplete-chip-clear-stroke,
|
|
44
|
+
var(--cosmoz-autocomplete-chip-bg-color, #cbcfdb)
|
|
45
|
+
);
|
|
46
|
+
display: var(--cosmoz-autocomplete-chip-clear-display, block);
|
|
47
|
+
flex: none;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.clear:hover {
|
|
51
|
+
filter: brightness(90%);
|
|
52
|
+
}
|
|
53
|
+
.clear svg {
|
|
54
|
+
display: block;
|
|
55
|
+
transform: translate(3.5px, 3.5px);
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import '@neovici/cosmoz-tag';
|
|
2
1
|
interface Props {
|
|
3
2
|
onClear?: false | (() => void);
|
|
4
3
|
disabled?: boolean;
|
|
5
4
|
}
|
|
5
|
+
export declare const Chip: ({ onClear, disabled }: Props) => import("lit-html").TemplateResult<1>;
|
|
6
6
|
export interface ChipProps<I> extends Props {
|
|
7
7
|
item: I | null;
|
|
8
8
|
slot?: string;
|
|
@@ -10,5 +10,5 @@ export interface ChipProps<I> extends Props {
|
|
|
10
10
|
content: unknown;
|
|
11
11
|
hidden?: boolean;
|
|
12
12
|
}
|
|
13
|
-
export declare const chip: <I>({ content, onClear, disabled,
|
|
13
|
+
export declare const chip: <I>({ content, onClear, disabled, hidden, className, slot, }: ChipProps<I>) => import("lit-html").TemplateResult<1>;
|
|
14
14
|
export {};
|
|
@@ -1,14 +1,61 @@
|
|
|
1
|
-
import '@neovici/cosmoz-
|
|
2
|
-
import { html } from '@pionjs/pion';
|
|
1
|
+
import { sheet } from '@neovici/cosmoz-utils';
|
|
2
|
+
import { component, html } from '@pionjs/pion';
|
|
3
3
|
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
4
|
-
|
|
4
|
+
import { when } from 'lit-html/directives/when.js';
|
|
5
|
+
import styles from './chip.css';
|
|
6
|
+
const clear = html `
|
|
7
|
+
<svg
|
|
8
|
+
width="9"
|
|
9
|
+
height="8"
|
|
10
|
+
viewBox="0 0 9 8"
|
|
11
|
+
fill="none"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
>
|
|
14
|
+
<line
|
|
15
|
+
x1="7.53033"
|
|
16
|
+
y1="0.994808"
|
|
17
|
+
x2="1.16637"
|
|
18
|
+
y2="7.35877"
|
|
19
|
+
stroke-width="1.5"
|
|
20
|
+
/>
|
|
21
|
+
<line
|
|
22
|
+
x1="7.46967"
|
|
23
|
+
y1="7.35882"
|
|
24
|
+
x2="1.10571"
|
|
25
|
+
y2="0.99486"
|
|
26
|
+
stroke-width="1.5"
|
|
27
|
+
/>
|
|
28
|
+
</svg>
|
|
29
|
+
`;
|
|
30
|
+
export const Chip = ({ onClear, disabled }) => html `
|
|
31
|
+
<div
|
|
32
|
+
class="content"
|
|
33
|
+
part="content chip-text"
|
|
34
|
+
@mousedown=${(ev) => ev.preventDefault()}
|
|
35
|
+
>
|
|
36
|
+
<slot></slot>
|
|
37
|
+
</div>
|
|
38
|
+
${when(onClear && !disabled, () => html `<span
|
|
39
|
+
class="clear"
|
|
40
|
+
part="clear chip-clear"
|
|
41
|
+
@mousedown=${(ev) => ev.preventDefault()}
|
|
42
|
+
@click=${onClear}
|
|
43
|
+
>
|
|
44
|
+
${clear}
|
|
45
|
+
</span>`)}
|
|
46
|
+
`;
|
|
47
|
+
customElements.define('cosmoz-autocomplete-chip', component(Chip, {
|
|
48
|
+
observedAttributes: ['disabled'],
|
|
49
|
+
styleSheets: [sheet(styles)],
|
|
50
|
+
}));
|
|
51
|
+
export const chip = ({ content, onClear, disabled, hidden, className = 'chip', slot, }) => html `<cosmoz-autocomplete-chip
|
|
5
52
|
class=${ifDefined(className)}
|
|
6
53
|
slot=${ifDefined(slot)}
|
|
54
|
+
part="chip"
|
|
7
55
|
exportparts="chip-text, chip-clear"
|
|
8
56
|
?disabled=${disabled}
|
|
9
57
|
?hidden=${hidden}
|
|
10
|
-
|
|
11
|
-
@remove=${onClear}
|
|
58
|
+
.onClear=${onClear}
|
|
12
59
|
title=${ifDefined(typeof content === 'string' ? content : undefined)}
|
|
13
|
-
>${content}</cosmoz-
|
|
60
|
+
>${content}</cosmoz-autocomplete-chip
|
|
14
61
|
>`;
|
|
@@ -2,8 +2,7 @@ import { sheet } from '@neovici/cosmoz-utils';
|
|
|
2
2
|
import { component, useCallback, useEffect, useProperty } from '@pionjs/pion';
|
|
3
3
|
import { Autocomplete, observedAttributes, style } from './autocomplete';
|
|
4
4
|
const Standalone = (host) => {
|
|
5
|
-
const { onChange, onText,
|
|
6
|
-
const isSelect = mode === 'select';
|
|
5
|
+
const { onChange, onText, ...props } = host;
|
|
7
6
|
const [value, setValue] = useProperty('value');
|
|
8
7
|
useEffect(() => {
|
|
9
8
|
if (host.onChange == null)
|
|
@@ -13,12 +12,6 @@ const Standalone = (host) => {
|
|
|
13
12
|
}, []);
|
|
14
13
|
return Autocomplete({
|
|
15
14
|
...props,
|
|
16
|
-
...(isSelect && {
|
|
17
|
-
limit: 1,
|
|
18
|
-
min: 1,
|
|
19
|
-
showSingle: true,
|
|
20
|
-
}),
|
|
21
|
-
mode,
|
|
22
15
|
value,
|
|
23
16
|
onChange: useCallback((value, ...args) => {
|
|
24
17
|
setValue(value);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { tagged as css } from '@neovici/cosmoz-utils';
|
|
2
|
+
export default css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
position: relative;
|
|
6
|
+
min-width: 35px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
cosmoz-dropdown-next {
|
|
10
|
+
display: block;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
cosmoz-input::part(control) {
|
|
14
|
+
display: flex;
|
|
15
|
+
gap: 4px;
|
|
16
|
+
min-width: 35px;
|
|
17
|
+
}
|
|
18
|
+
cosmoz-input::part(input) {
|
|
19
|
+
flex: 1 24px;
|
|
20
|
+
min-width: 0;
|
|
21
|
+
}
|
|
22
|
+
cosmoz-input:not([data-one])::part(input):focus {
|
|
23
|
+
flex: 4 0.00001 50px;
|
|
24
|
+
min-width: 20px;
|
|
25
|
+
}
|
|
26
|
+
.badge {
|
|
27
|
+
min-width: initial;
|
|
28
|
+
flex: none;
|
|
29
|
+
text-align: center;
|
|
30
|
+
padding: 0 4px;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
[data-single]::part(input) {
|
|
34
|
+
flex: 0;
|
|
35
|
+
}
|
|
36
|
+
[data-one] .chip {
|
|
37
|
+
max-width: initial;
|
|
38
|
+
flex: 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
[data-one] .badge {
|
|
42
|
+
display: none;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[hidden] {
|
|
46
|
+
display: none;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
:host([wrap]) cosmoz-input::part(control) {
|
|
50
|
+
flex-wrap: wrap;
|
|
51
|
+
}
|
|
52
|
+
:host([wrap]) .chip {
|
|
53
|
+
max-width: 100%;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
slot {
|
|
57
|
+
display: contents !important;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.no-result {
|
|
61
|
+
font-size: var(--cosmoz-autocomplete-listbox-font-size, 13px);
|
|
62
|
+
font-weight: var(--cosmoz-autocomplete-listbox-font-weight, 400);
|
|
63
|
+
padding: 0 22px;
|
|
64
|
+
color: var(--cosmoz-listbox-color, #101010);
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
@@ -5,8 +5,6 @@ import { raf } from './util';
|
|
|
5
5
|
const overflow = (host) => {
|
|
6
6
|
const chips = host.shadowRoot.querySelectorAll('.chip');
|
|
7
7
|
const badge = host.shadowRoot.querySelector('.badge');
|
|
8
|
-
if (!badge)
|
|
9
|
-
return;
|
|
10
8
|
badge.hidden = true;
|
|
11
9
|
for (const chip of chips) {
|
|
12
10
|
chip.hidden = false;
|
package/dist/excluding/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import '@neovici/cosmoz-tag';
|
|
2
1
|
import { component, html, useCallback, useMemo, useProperty, } from '@pionjs/pion';
|
|
2
|
+
import { nothing } from 'lit-html';
|
|
3
3
|
import { ifDefined } from 'lit-html/directives/if-defined.js';
|
|
4
4
|
import '../autocomplete';
|
|
5
5
|
import { Autocomplete, observedAttributes, style, } from '../autocomplete/autocomplete';
|
|
@@ -7,7 +7,7 @@ import excludingStyle from './style.css';
|
|
|
7
7
|
import { useExcludingSelection } from './use-excluding-selection';
|
|
8
8
|
import { unwrap } from './utils';
|
|
9
9
|
const isItemExcluded = (value, item) => value?.some((v) => v.item === item && v.excluded);
|
|
10
|
-
const excludedState = (value, item) => (item && isItemExcluded(value, item) ? '
|
|
10
|
+
const excludedState = (value, item) => (item && isItemExcluded(value, item) ? 'excluded' : nothing);
|
|
11
11
|
const mkItemRenderer = (value) => (item, i, { highlight, select, textual, isSelected }) => {
|
|
12
12
|
const rendered = textual(item);
|
|
13
13
|
return html `<div
|
|
@@ -24,19 +24,19 @@ const mkItemRenderer = (value) => (item, i, { highlight, select, textual, isSele
|
|
|
24
24
|
</div>
|
|
25
25
|
<div class="sizer" virtualizer-sizer>${rendered}</div>`;
|
|
26
26
|
};
|
|
27
|
-
const mkChipRenderer = (value, onClear) => ({ item, content, disabled, hidden, className = 'chip', slot, }) => html `<cosmoz-
|
|
27
|
+
const mkChipRenderer = (value, onClear) => ({ item, content, disabled, hidden, className = 'chip', slot, }) => html `<cosmoz-autocomplete-chip
|
|
28
28
|
class=${ifDefined(className)}
|
|
29
29
|
slot=${ifDefined(slot)}
|
|
30
|
+
part="chip"
|
|
30
31
|
exportparts="chip-text, chip-clear"
|
|
31
|
-
|
|
32
|
+
data-state=${excludedState(value, item)}
|
|
32
33
|
?disabled=${disabled}
|
|
33
34
|
?hidden=${hidden}
|
|
34
|
-
|
|
35
|
-
@remove=${() => onClear(item)}
|
|
35
|
+
.onClear=${() => onClear(item)}
|
|
36
36
|
title=${ifDefined(typeof content === 'string' ? content : undefined)}
|
|
37
37
|
>
|
|
38
38
|
${content}
|
|
39
|
-
</cosmoz-
|
|
39
|
+
</cosmoz-autocomplete-chip>`;
|
|
40
40
|
const AutocompleteExcluding = (props) => {
|
|
41
41
|
const { value, setValue, setExcludingValue } = useExcludingSelection('value');
|
|
42
42
|
const [text, setText] = useProperty('text');
|
|
@@ -5,14 +5,39 @@ const clearSVG =
|
|
|
5
5
|
"d='M2.5 2.5L8.5 8.5M8.5 2.5L2.5 8.5' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E";
|
|
6
6
|
/* eslint-enable quotes */
|
|
7
7
|
const excludingStyle = css `
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
.chip[data-state='excluded'] {
|
|
9
|
+
background: var(--cosmoz-autocomplete-excluded-bg-color, rgb(244, 67, 54));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
cosmoz-autocomplete-chip[data-state='excluded']::part(content) {
|
|
13
|
+
color: var(--cosmoz-autocomplete-excluded-chip-color, #fff);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
cosmoz-autocomplete-chip[data-state='excluded']::part(clear) {
|
|
17
|
+
background-color: var(
|
|
18
|
+
--cosmoz-autocomplete-excluded-chip-clear-bg-color,
|
|
19
|
+
#fff
|
|
20
|
+
);
|
|
21
|
+
stroke: var(
|
|
22
|
+
--cosmoz-autocomplete-excluded-chip-clear-stroke,
|
|
23
|
+
var(--cosmoz-autocomplete-excluded-bg-color, rgb(244, 67, 54))
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
cosmoz-listbox::part(excluded)::before {
|
|
28
|
+
border-color: var(
|
|
29
|
+
--cosmoz-autocomplete-excluded-bg-color,
|
|
30
|
+
rgb(244, 67, 54)
|
|
31
|
+
);
|
|
10
32
|
/* prettier-ignore */
|
|
11
|
-
background: url("${clearSVG}") var(--
|
|
33
|
+
background: url("${clearSVG}") var(--cosmoz-autocomplete-excluded-bg-color, rgb(244, 67, 54)) no-repeat 50%;
|
|
12
34
|
}
|
|
13
35
|
|
|
14
|
-
cosmoz-listbox::part(
|
|
15
|
-
background: var(
|
|
36
|
+
cosmoz-listbox::part(excluded):hover {
|
|
37
|
+
background: var(
|
|
38
|
+
--cosmoz-listbox-excluded-active-color,
|
|
39
|
+
rgba(244, 67, 54, 0.1)
|
|
40
|
+
);
|
|
16
41
|
}
|
|
17
42
|
`;
|
|
18
43
|
export default excludingStyle;
|
|
@@ -8,45 +8,38 @@ const checkSVG =
|
|
|
8
8
|
const style = css `
|
|
9
9
|
:host {
|
|
10
10
|
display: block;
|
|
11
|
-
font-family: var(--
|
|
12
|
-
background: var(
|
|
11
|
+
font-family: var(--paper-font-subhead_-_font-family, inherit);
|
|
12
|
+
background: var(
|
|
13
|
+
--cosmoz-autocomplete-listbox-bg,
|
|
14
|
+
rgba(255, 255, 255, 0.75)
|
|
15
|
+
);
|
|
13
16
|
backdrop-filter: blur(16px) saturate(180%);
|
|
14
17
|
-webkit-backdrop-filter: blur(16px) saturate(180%);
|
|
15
|
-
border-radius:
|
|
16
|
-
box-shadow:
|
|
18
|
+
border-radius: 6px;
|
|
19
|
+
box-shadow:
|
|
20
|
+
0 4px 24px 0 rgba(0, 0, 0, 0.18),
|
|
21
|
+
0 1.5px 6px 0 rgba(0, 0, 0, 0.1);
|
|
22
|
+
border: 1px solid rgba(200, 200, 200, 0.25);
|
|
17
23
|
text-transform: var(--cosmoz-autocomplete-listbox-text-transform, initial);
|
|
18
24
|
overflow: hidden;
|
|
19
|
-
padding-block: var(--cz-spacing);
|
|
20
25
|
}
|
|
21
26
|
.items {
|
|
22
27
|
position: relative;
|
|
23
28
|
overflow-y: auto;
|
|
24
|
-
scrollbar-width: thin;
|
|
25
29
|
contain: layout paint !important;
|
|
26
|
-
padding-inline: calc(var(--cz-spacing) * 1.5);
|
|
27
|
-
}
|
|
28
|
-
:host(:focus-within) {
|
|
29
|
-
outline: none;
|
|
30
|
-
box-shadow: var(--cz-focus-ring);
|
|
31
|
-
}
|
|
32
|
-
.items:focus-visible {
|
|
33
|
-
outline: none;
|
|
34
30
|
}
|
|
35
31
|
.item {
|
|
36
|
-
font-size: var(--
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
font-size: var(--cosmoz-autocomplete-listbox-font-size, 13px);
|
|
33
|
+
font-weight: var(--cosmoz-autocomplete-listbox-font-weight, 400);
|
|
34
|
+
padding: 0 22px;
|
|
39
35
|
box-sizing: border-box;
|
|
40
|
-
|
|
41
|
-
width: calc(100% - var(--cz-spacing) * 3);
|
|
36
|
+
width: 100%;
|
|
42
37
|
cursor: pointer;
|
|
43
38
|
text-overflow: ellipsis;
|
|
44
39
|
white-space: nowrap;
|
|
45
|
-
transition: background 0.
|
|
46
|
-
color: var(--
|
|
40
|
+
transition: background 0.2s;
|
|
41
|
+
color: var(--cosmoz-listbox-color, #101010);
|
|
47
42
|
overflow: hidden;
|
|
48
|
-
padding-inline: calc(var(--cz-spacing) * 2);
|
|
49
|
-
margin-block: 1px;
|
|
50
43
|
}
|
|
51
44
|
|
|
52
45
|
.sizer {
|
|
@@ -57,34 +50,39 @@ const style = css `
|
|
|
57
50
|
z-index: -1;
|
|
58
51
|
height: 0;
|
|
59
52
|
width: auto;
|
|
60
|
-
padding: 0
|
|
53
|
+
padding: 0 20px;
|
|
61
54
|
overflow: hidden;
|
|
62
55
|
max-width: inherit;
|
|
63
|
-
font-size:
|
|
64
|
-
line-height: var(--cz-text-sm-line-height);
|
|
56
|
+
font-size: 14px;
|
|
65
57
|
}
|
|
66
58
|
|
|
67
59
|
:host(:not([multi])) .item[aria-selected] {
|
|
68
|
-
background:
|
|
69
|
-
|
|
70
|
-
|
|
60
|
+
background: var(--cosmoz-listbox-single-selection-color, #dadada);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:host([multi]) .item {
|
|
64
|
+
padding-left: 0;
|
|
71
65
|
}
|
|
72
66
|
|
|
73
67
|
:host([multi]) .item::before {
|
|
74
68
|
content: '';
|
|
75
69
|
font-size: 0;
|
|
76
|
-
padding:
|
|
77
|
-
margin
|
|
78
|
-
background:
|
|
79
|
-
border: 1px solid
|
|
80
|
-
border-radius:
|
|
70
|
+
padding: 7.5px;
|
|
71
|
+
margin: 0 8px;
|
|
72
|
+
background: #fff;
|
|
73
|
+
border: 1px solid #d6d6d5;
|
|
74
|
+
border-radius: 4px;
|
|
81
75
|
vertical-align: top;
|
|
82
76
|
}
|
|
83
77
|
|
|
84
78
|
:host([multi]) .item[aria-selected]::before {
|
|
85
|
-
border-color:
|
|
79
|
+
border-color: #5881f6;
|
|
86
80
|
/* prettier-ignore */
|
|
87
|
-
background: url("${checkSVG}")
|
|
81
|
+
background: url("${checkSVG}") #5881f6 no-repeat 50%;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
:host([multi]) .sizer {
|
|
85
|
+
padding-left: 33px;
|
|
88
86
|
}
|
|
89
87
|
|
|
90
88
|
[virtualizer-sizer]:not(.sizer) {
|
|
@@ -99,12 +97,11 @@ export const styles = ({ index, itemHeight, auto, }) => css `
|
|
|
99
97
|
height: ${itemHeight}px;
|
|
100
98
|
}
|
|
101
99
|
`)}
|
|
100
|
+
|
|
102
101
|
.item[data-index='${index || '0'}'] {
|
|
103
|
-
background:
|
|
104
|
-
|
|
102
|
+
background: var(
|
|
103
|
+
--cosmoz-listbox-active-color,
|
|
104
|
+
var(--cosmoz-selection-color, rgba(58, 145, 226, 0.1))
|
|
105
105
|
);
|
|
106
106
|
}
|
|
107
|
-
.item[data-index='${index || '0'}'][part~='error'] {
|
|
108
|
-
background: var(--cz-color-bg-error);
|
|
109
|
-
}
|
|
110
107
|
`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neovici/cosmoz-autocomplete",
|
|
3
|
-
"version": "13.6.
|
|
3
|
+
"version": "13.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A autocomplete input web component",
|
|
6
6
|
"keywords": [
|
|
@@ -48,6 +48,7 @@
|
|
|
48
48
|
"@semantic-release/npm",
|
|
49
49
|
"@semantic-release/git"
|
|
50
50
|
],
|
|
51
|
+
"branch": "master",
|
|
51
52
|
"preset": "conventionalcommits"
|
|
52
53
|
},
|
|
53
54
|
"publishConfig": {
|
|
@@ -78,14 +79,11 @@
|
|
|
78
79
|
},
|
|
79
80
|
"dependencies": {
|
|
80
81
|
"@lit-labs/virtualizer": "^2.0.0",
|
|
81
|
-
"@neovici/cosmoz-dropdown": "^7.
|
|
82
|
-
"@neovici/cosmoz-
|
|
83
|
-
"@neovici/cosmoz-input": "^6.0.0-beta.1",
|
|
84
|
-
"@neovici/cosmoz-tag": "^1.3.0",
|
|
85
|
-
"@neovici/cosmoz-tokens": "^3.4.0",
|
|
82
|
+
"@neovici/cosmoz-dropdown": "^7.5.0",
|
|
83
|
+
"@neovici/cosmoz-input": "^5.6.0",
|
|
86
84
|
"@neovici/cosmoz-utils": "^6.20.0",
|
|
87
85
|
"@pionjs/pion": "^2.7.1",
|
|
88
|
-
"i18next": "
|
|
86
|
+
"i18next": ">=23.0.0 <27.0.0",
|
|
89
87
|
"lit-html": "^2.0.0 || ^3.0.0"
|
|
90
88
|
},
|
|
91
89
|
"devDependencies": {
|
|
@@ -95,7 +93,6 @@
|
|
|
95
93
|
"@playwright/test": "^1.43.1",
|
|
96
94
|
"@semantic-release/changelog": "^6.0.0",
|
|
97
95
|
"@semantic-release/git": "^10.0.0",
|
|
98
|
-
"@storybook/addon-a11y": "^10.3.4",
|
|
99
96
|
"@storybook/addon-docs": "^10.0.0",
|
|
100
97
|
"@storybook/addon-vitest": "^10.0.0",
|
|
101
98
|
"@storybook/web-components-vite": "^10.0.0",
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { tagged as css } from '@neovici/cosmoz-utils';
|
|
2
|
-
export default css `
|
|
3
|
-
:host {
|
|
4
|
-
display: block;
|
|
5
|
-
position: relative;
|
|
6
|
-
min-width: calc(var(--cz-spacing) * 9);
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
:host([mode='select']) {
|
|
10
|
-
--cosmoz-badge-border-color: transparent;
|
|
11
|
-
--cosmoz-badge-bg-color: transparent;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
cosmoz-dropdown-next {
|
|
15
|
-
display: block;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
:host(:not([variant='inline'])) cosmoz-listbox {
|
|
19
|
-
margin-top: var(--cz-spacing);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
:host([error-message]) cosmoz-listbox,
|
|
23
|
-
:host([hint]) cosmoz-listbox {
|
|
24
|
-
margin-top: calc((var(--cz-spacing) * -5));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
cosmoz-tag {
|
|
28
|
-
align-items: center;
|
|
29
|
-
margin-left: calc(var(--cz-spacing) * 2);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
cosmoz-input::part(control) {
|
|
33
|
-
display: flex;
|
|
34
|
-
min-width: calc(var(--cz-spacing) * 9);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
cosmoz-input[variant='inline']:has(cosmoz-tag[removable])::part(label),
|
|
38
|
-
cosmoz-input[variant='inline'][disabled]:has(cosmoz-tag)::part(label) {
|
|
39
|
-
transform: translate(var(--cz-spacing), -75%) scale(0.85);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
cosmoz-input::part(input) {
|
|
43
|
-
flex: 1 calc(var(--cz-spacing) * 6);
|
|
44
|
-
min-width: 0;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
cosmoz-input:not([data-one])::part(input):focus {
|
|
48
|
-
flex: 4 0.00001 calc(var(--cz-spacing) * 12.5);
|
|
49
|
-
min-width: calc(var(--cz-spacing) * 5);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.badge {
|
|
53
|
-
min-width: initial;
|
|
54
|
-
flex: none;
|
|
55
|
-
text-align: center;
|
|
56
|
-
padding: 0 var(--cz-spacing);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
[data-single]::part(input) {
|
|
60
|
-
flex: 0;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
[data-one] .badge {
|
|
64
|
-
display: none;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
[hidden] {
|
|
68
|
-
display: none;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
:host([wrap]) cosmoz-input::part(control) {
|
|
72
|
-
flex-wrap: wrap;
|
|
73
|
-
padding-right: calc(var(--cz-spacing) * 2);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
:host([wrap]) cosmoz-tag {
|
|
77
|
-
padding-block: calc(var(--cz-spacing) * 1.5);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
slot {
|
|
81
|
-
display: contents !important;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.no-result {
|
|
85
|
-
font-size: var(--cz-text-sm);
|
|
86
|
-
line-height: var(--cz-text-sm-line-height);
|
|
87
|
-
font-weight: var(--cz-font-weight-regular);
|
|
88
|
-
padding: 0 calc(var(--cz-spacing) * 3);
|
|
89
|
-
color: var(--cz-color-text-secondary);
|
|
90
|
-
}
|
|
91
|
-
`;
|
|
File without changes
|