@anmed/mui-selection 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
@@ -4,8 +4,8 @@ export let title;
|
|
4
4
|
export let style;
|
5
5
|
export let list = [];
|
6
6
|
export let value;
|
7
|
-
export let
|
8
|
-
export let
|
7
|
+
export let keyCode = 'value';
|
8
|
+
export let keyText = 'text';
|
9
9
|
export let convertText;
|
10
10
|
export let itemSelect;
|
11
11
|
const dispatch = createEventDispatcher();
|
@@ -14,7 +14,8 @@ const handleItemSelected = (item) => {
|
|
14
14
|
if (itemSelect) {
|
15
15
|
itemSelect(item);
|
16
16
|
}
|
17
|
-
value = item[
|
17
|
+
value = item[keyCode];
|
18
|
+
visible = false;
|
18
19
|
};
|
19
20
|
const getDisplayText = (item) => {
|
20
21
|
let displayText = '';
|
@@ -23,7 +24,7 @@ const getDisplayText = (item) => {
|
|
23
24
|
displayText = convertText(item);
|
24
25
|
}
|
25
26
|
else {
|
26
|
-
displayText = item[
|
27
|
+
displayText = item[keyText];
|
27
28
|
}
|
28
29
|
}
|
29
30
|
else {
|
@@ -40,7 +41,7 @@ const getDisplayText = (item) => {
|
|
40
41
|
<ul class="single-click-selection-ul">
|
41
42
|
{#each list as data}
|
42
43
|
<li on:click={()=>handleItemSelected(data)}
|
43
|
-
class={value === data[
|
44
|
+
class={value === data[keyCode] ? 'single-click-selection-li-selected':'single-click-selection-li-normal'}> {getDisplayText(data)}</li>
|
44
45
|
{/each}
|
45
46
|
</ul>
|
46
47
|
</div>
|
@@ -6,8 +6,8 @@ declare const __propDef: {
|
|
6
6
|
style: any;
|
7
7
|
list?: any[] | undefined;
|
8
8
|
value: any;
|
9
|
-
|
10
|
-
|
9
|
+
keyCode?: string | undefined;
|
10
|
+
keyText?: string | undefined;
|
11
11
|
convertText: (item: any) => string;
|
12
12
|
itemSelect: (item: any) => void;
|
13
13
|
};
|