@onsvisual/svelte-components 0.0.34 → 0.0.36
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/@types/inputs/Select/Select.svelte.d.ts +4 -2
- package/dist/@types/js/utils.d.ts +1 -0
- package/dist/@types/layout/Titleblock/Titleblock.svelte.d.ts +2 -0
- package/dist/inputs/Select/Select.svelte +18 -1
- package/dist/js/utils.js +2 -0
- package/dist/layout/Titleblock/Titleblock.svelte +1 -0
- package/package.json +1 -1
|
@@ -13,6 +13,7 @@ export default class Select extends SvelteComponentTyped<{
|
|
|
13
13
|
multiple?: boolean;
|
|
14
14
|
maxSelected?: number;
|
|
15
15
|
clearable?: boolean;
|
|
16
|
+
autoClear?: boolean;
|
|
16
17
|
idKey?: string;
|
|
17
18
|
labelKey?: string;
|
|
18
19
|
colors?: any[];
|
|
@@ -21,10 +22,10 @@ export default class Select extends SvelteComponentTyped<{
|
|
|
21
22
|
floatingConfig?: any;
|
|
22
23
|
}, {
|
|
23
24
|
input: CustomEvent<any>;
|
|
24
|
-
change: CustomEvent<any>;
|
|
25
25
|
focus: CustomEvent<any>;
|
|
26
26
|
blur: CustomEvent<any>;
|
|
27
27
|
clear: CustomEvent<any>;
|
|
28
|
+
change: CustomEvent<any>;
|
|
28
29
|
} & {
|
|
29
30
|
[evt: string]: CustomEvent<any>;
|
|
30
31
|
}, {}> {
|
|
@@ -46,6 +47,7 @@ declare const __propDef: {
|
|
|
46
47
|
multiple?: boolean;
|
|
47
48
|
maxSelected?: number;
|
|
48
49
|
clearable?: boolean;
|
|
50
|
+
autoClear?: boolean;
|
|
49
51
|
idKey?: string;
|
|
50
52
|
labelKey?: string;
|
|
51
53
|
colors?: any[];
|
|
@@ -55,10 +57,10 @@ declare const __propDef: {
|
|
|
55
57
|
};
|
|
56
58
|
events: {
|
|
57
59
|
input: CustomEvent<any>;
|
|
58
|
-
change: CustomEvent<any>;
|
|
59
60
|
focus: CustomEvent<any>;
|
|
60
61
|
blur: CustomEvent<any>;
|
|
61
62
|
clear: CustomEvent<any>;
|
|
63
|
+
change: CustomEvent<any>;
|
|
62
64
|
} & {
|
|
63
65
|
[evt: string]: CustomEvent<any>;
|
|
64
66
|
};
|
|
@@ -13,6 +13,7 @@ export default class Titleblock extends SvelteComponentTyped<{
|
|
|
13
13
|
[evt: string]: CustomEvent<any>;
|
|
14
14
|
}, {
|
|
15
15
|
before: {};
|
|
16
|
+
default: {};
|
|
16
17
|
brand: {};
|
|
17
18
|
after: {};
|
|
18
19
|
}> {
|
|
@@ -36,6 +37,7 @@ declare const __propDef: {
|
|
|
36
37
|
};
|
|
37
38
|
slots: {
|
|
38
39
|
before: {};
|
|
40
|
+
default: {};
|
|
39
41
|
brand: {};
|
|
40
42
|
after: {};
|
|
41
43
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
<script>
|
|
2
|
+
import { createEventDispatcher } from "svelte";
|
|
2
3
|
import SelectInner from "svelte-select";
|
|
4
|
+
import { sleep } from "../../js/utils";
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* Unique id for the element
|
|
@@ -26,6 +28,11 @@
|
|
|
26
28
|
* @type {boolean}
|
|
27
29
|
*/
|
|
28
30
|
export let clearable = true;
|
|
31
|
+
/**
|
|
32
|
+
* Clear value on selection (default for "search" mode)
|
|
33
|
+
* @type {boolean}
|
|
34
|
+
*/
|
|
35
|
+
export let autoClear = mode === "search";
|
|
29
36
|
/**
|
|
30
37
|
* A label to describe the element (expected for accessibility)
|
|
31
38
|
* @type {string}
|
|
@@ -110,6 +117,16 @@
|
|
|
110
117
|
: "No options available";
|
|
111
118
|
|
|
112
119
|
let filterText = "";
|
|
120
|
+
|
|
121
|
+
const dispatch = createEventDispatcher();
|
|
122
|
+
|
|
123
|
+
async function handleChange(e) {
|
|
124
|
+
dispatch("change", e.detail);
|
|
125
|
+
if (autoClear) {
|
|
126
|
+
await sleep(100);
|
|
127
|
+
value = null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
113
130
|
</script>
|
|
114
131
|
|
|
115
132
|
<div class="ons-field" style="{style}">
|
|
@@ -131,8 +148,8 @@
|
|
|
131
148
|
showChevron="{!value}"
|
|
132
149
|
multiple="{multiple}"
|
|
133
150
|
clearable="{clearable}"
|
|
151
|
+
on:change="{handleChange}"
|
|
134
152
|
on:input
|
|
135
|
-
on:change
|
|
136
153
|
on:focus
|
|
137
154
|
on:blur
|
|
138
155
|
on:clear
|
package/dist/js/utils.js
CHANGED