@neovici/cosmoz-autocomplete 7.4.1 → 7.5.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.
@@ -74,10 +74,11 @@ const autocomplete = (props) => {
74
74
  'no-label-float',
75
75
  'always-float-label',
76
76
  'text-property',
77
+ 'value-property',
77
78
  'limit',
78
79
  'show-single',
79
- 'auto-close',
80
- 'auto-clear',
80
+ 'keep-opened',
81
+ 'keep-query',
81
82
  'hide-empty',
82
83
  'default-index',
83
84
  'item-height',
@@ -9,7 +9,7 @@ export default css `
9
9
  align-items: center;
10
10
  flex: 0.0001 1 fit-content;
11
11
  max-width: 18ch;
12
- min-width: 12px;
12
+ min-width: 40px;
13
13
  padding: 0 4px 0 8px;
14
14
  gap: 4px;
15
15
  }
@@ -21,7 +21,7 @@ export default css `
21
21
  text-overflow: ellipsis;
22
22
  white-space: nowrap;
23
23
  flex: auto;
24
- min-width: 4px;
24
+ min-width: 16px;
25
25
  }
26
26
  .clear {
27
27
  background-color: var(--cosmoz-autocomplete-chip-clear-bg-color, #81899b);
@@ -5,8 +5,8 @@ type Source<I> = (opts: {
5
5
  interface Base<I> {
6
6
  value: I | I[];
7
7
  limit?: number;
8
- autoClose?: boolean;
9
- autoClear?: boolean;
8
+ keepOpened?: boolean;
9
+ keepQuery?: boolean;
10
10
  onText: (text: string) => void;
11
11
  onChange: (value: I[], done?: () => void) => void;
12
12
  onSelect: (value: I, meta: Meta<I>) => void;
@@ -26,7 +26,7 @@ export interface Props<I> extends Base<I> {
26
26
  disabled?: boolean;
27
27
  onFocus?: (focused?: boolean) => void;
28
28
  }
29
- export declare const useAutocomplete: <I>({ value: _value, text, onChange: _onChange, onText: _onText, onSelect, limit, source, textProperty, textual: _textual, valueProperty, external, hideEmpty, autoClose, autoClear, ...thru }: Props<I>) => {
29
+ export declare const useAutocomplete: <I>({ value: _value, text, onChange: _onChange, onText: _onText, onSelect, limit, source, textProperty, textual: _textual, valueProperty, external, hideEmpty, keepOpened, keepQuery, ...thru }: Props<I>) => {
30
30
  active: boolean | undefined;
31
31
  query: string;
32
32
  textual: (i: I) => string;
@@ -6,7 +6,7 @@ import { useMeta } from '@neovici/cosmoz-utils/hooks/use-meta';
6
6
  import { useFocus } from '@neovici/cosmoz-dropdown/use-focus';
7
7
  import { useKeys } from './use-keys';
8
8
  import { search, notify, useNotify, EMPTY$ } from './util';
9
- export const useAutocomplete = ({ value: _value, text, onChange: _onChange, onText: _onText, onSelect, limit, source, textProperty, textual: _textual, valueProperty, external, hideEmpty, autoClose, autoClear, ...thru }) => {
9
+ export const useAutocomplete = ({ value: _value, text, onChange: _onChange, onText: _onText, onSelect, limit, source, textProperty, textual: _textual, valueProperty, external, hideEmpty, keepOpened, keepQuery, ...thru }) => {
10
10
  const textual = useMemo(() => (_textual ?? strProp)(textProperty), [_textual, textProperty]), { active, focused, onFocus, setClosed } = useFocus(thru), empty = !text, query = useMemo(() => text?.trim().toLowerCase(), [text]), host = useHost(), onText = useNotify(host, _onText, 'text'), onChange = useCallback((val) => {
11
11
  _onChange?.(val, () => setClosed(true));
12
12
  notify(host, 'value', val);
@@ -32,8 +32,8 @@ export const useAutocomplete = ({ value: _value, text, onChange: _onChange, onTe
32
32
  onChange,
33
33
  value,
34
34
  limit,
35
- autoClose,
36
- autoClear,
35
+ keepQuery,
36
+ keepOpened,
37
37
  setClosed,
38
38
  onSelect,
39
39
  });
@@ -59,10 +59,10 @@ export const useAutocomplete = ({ value: _value, text, onChange: _onChange, onTe
59
59
  }, [onText, text, setClosed]),
60
60
  onSelect: useCallback((newVal) => {
61
61
  meta.onSelect?.(newVal, meta);
62
- const { onChange, onText, limit, value: val, autoClose, autoClear, setClosed, } = meta;
63
- if (autoClear)
62
+ const { onChange, onText, limit, value: val, keepQuery, keepOpened, setClosed, } = meta;
63
+ if (!keepQuery)
64
64
  onText('');
65
- if (autoClose)
65
+ if (!keepOpened)
66
66
  setClosed(true);
67
67
  const value = array(val);
68
68
  onChange((value.includes(newVal)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neovici/cosmoz-autocomplete",
3
- "version": "7.4.1",
3
+ "version": "7.5.1",
4
4
  "description": "A autocomplete input web component",
5
5
  "keywords": [
6
6
  "lit-html",
@@ -85,6 +85,7 @@
85
85
  "@web/dev-server-storybook": "^0.7.0",
86
86
  "eslint-import-resolver-exports": "^1.0.0-beta.5",
87
87
  "husky": "^8.0.0",
88
+ "rollup-plugin-terser": "^7.0.2",
88
89
  "semantic-release": "^21.0.0",
89
90
  "sinon": "^15.0.0",
90
91
  "typescript": "^5.0.0"