noph-ui 0.18.15 → 0.19.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.
@@ -16,7 +16,9 @@
16
16
  clampMenuWidth = false,
17
17
  children,
18
18
  optionsFilter,
19
- oncomplete = (option) => {
19
+ showPopover = $bindable(),
20
+ hidePopover = $bindable(),
21
+ onoptionselect = (option) => {
20
22
  value = option.label
21
23
  finalPopulated = populated
22
24
  menuElement?.hidePopover()
@@ -28,6 +30,13 @@
28
30
  ...attributes
29
31
  }: AutoCompleteProps = $props()
30
32
 
33
+ showPopover = () => {
34
+ menuElement?.showPopover()
35
+ }
36
+
37
+ hidePopover = () => {
38
+ menuElement?.hidePopover()
39
+ }
31
40
  const uid = $props.id()
32
41
  let defaultOptionsFilter = (option: AutoCompleteOption) => {
33
42
  return !value || option.label.toLocaleLowerCase().includes(value.toLocaleLowerCase())
@@ -43,7 +52,7 @@
43
52
  <Item
44
53
  onclick={(event) => {
45
54
  event.preventDefault()
46
- oncomplete(option)
55
+ onoptionselect(option)
47
56
  element?.focus()
48
57
  }}
49
58
  disabled={option.disabled}
@@ -57,7 +66,7 @@
57
66
  event.preventDefault()
58
67
  }
59
68
  if (event.key === 'Enter') {
60
- oncomplete(option)
69
+ onoptionselect(option)
61
70
  }
62
71
  if (event.key === 'Tab') {
63
72
  finalPopulated = populated
@@ -70,6 +79,8 @@
70
79
  {/snippet}
71
80
 
72
81
  <TextField
82
+ autocomplete="off"
83
+ {...attributes}
73
84
  {variant}
74
85
  type="text"
75
86
  populated={finalPopulated}
@@ -102,7 +113,6 @@
102
113
  bind:reportValidity
103
114
  bind:checkValidity
104
115
  bind:element
105
- {...attributes}
106
116
  >{@render children?.()}
107
117
  </TextField>
108
118
  <Menu
@@ -118,6 +128,11 @@
118
128
  ? 'var(--np-outlined-select-text-field-container-shape)'
119
129
  : 'var(--np-filled-select-text-field-container-shape)'}
120
130
  anchor={element}
131
+ ontoggle={(e) => {
132
+ if (e.newState === 'closed' && !populated && finalPopulated && !value) {
133
+ finalPopulated = false
134
+ }
135
+ }}
121
136
  bind:element={menuElement}
122
137
  >
123
138
  {#if useVirtualList}
@@ -1,4 +1,4 @@
1
1
  import type { AutoCompleteProps } from './types.ts';
2
- declare const AutoComplete: import("svelte").Component<AutoCompleteProps, {}, "element" | "value" | "reportValidity" | "checkValidity" | "focused">;
2
+ declare const AutoComplete: import("svelte").Component<AutoCompleteProps, {}, "element" | "value" | "showPopover" | "hidePopover" | "reportValidity" | "checkValidity" | "focused">;
3
3
  type AutoComplete = ReturnType<typeof AutoComplete>;
4
4
  export default AutoComplete;
@@ -8,6 +8,8 @@ export interface AutoCompleteOption {
8
8
  export interface AutoCompleteProps extends Omit<InputFieldProps, 'clientWidth' | 'clientHeight'> {
9
9
  options: AutoCompleteOption[];
10
10
  optionsFilter?: (option: AutoCompleteOption) => boolean;
11
- oncomplete?: (option: AutoCompleteOption) => void;
11
+ onoptionselect?: (option: AutoCompleteOption) => void;
12
12
  clampMenuWidth?: boolean;
13
+ showPopover?: () => void;
14
+ hidePopover?: () => void;
13
15
  }
@@ -8,7 +8,6 @@
8
8
  element = $bindable(),
9
9
  group = $bindable(),
10
10
  style,
11
- onpointerup,
12
11
  ...attributes
13
12
  }: CheckboxProps = $props()
14
13
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "noph-ui",
3
- "version": "0.18.15",
3
+ "version": "0.19.1",
4
4
  "license": "MIT",
5
5
  "homepage": "https://noph.dev",
6
6
  "repository": {