@anmed/mui-selection 0.0.2 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
package/SelectionField.svelte
CHANGED
@@ -7,7 +7,7 @@ export let keyCode = 'value';
|
|
7
7
|
export let keyText = 'text';
|
8
8
|
export let convertText;
|
9
9
|
export let label;
|
10
|
-
export let
|
10
|
+
export let readonly = false;
|
11
11
|
export let required = false;
|
12
12
|
export let error;
|
13
13
|
export let options;
|
@@ -26,7 +26,7 @@ const getDisplayText = (item) => {
|
|
26
26
|
return text;
|
27
27
|
};
|
28
28
|
const onCardItemClick = (item) => {
|
29
|
-
if (!
|
29
|
+
if (!readonly) {
|
30
30
|
value = item;
|
31
31
|
}
|
32
32
|
};
|
@@ -41,7 +41,7 @@ $: {
|
|
41
41
|
}
|
42
42
|
$: above = focused || displayText.toString().length != 0 || isCardSelection;
|
43
43
|
const handlerClick = () => {
|
44
|
-
if (!
|
44
|
+
if (!readonly && !isCardSelection) {
|
45
45
|
dispatcher('action', value);
|
46
46
|
}
|
47
47
|
};
|
@@ -60,9 +60,13 @@ const handlerClick = () => {
|
|
60
60
|
</CommonField>
|
61
61
|
{:else }
|
62
62
|
<CommonField {label} {required} bind:focused {above} {error}>
|
63
|
-
<span class="mui-
|
64
|
-
<div slot="trailing-icon">
|
65
|
-
<
|
63
|
+
<span class="mui-field-text">{displayText}</span>
|
64
|
+
<div slot="trailing-icon" class="mui-field-trailing-icon">
|
65
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
66
|
+
<g id="Frame">
|
67
|
+
<path id="Vector" d="M7.0835 5L12.0835 10L7.0835 15" stroke="#333333" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
68
|
+
</g>
|
69
|
+
</svg>
|
66
70
|
</div>
|
67
71
|
</CommonField>
|
68
72
|
{/if}
|
@@ -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
|
};
|
package/mui-select-field.css
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
@charset "UTF-8";
|
2
1
|
* {
|
3
2
|
margin: 0;
|
4
3
|
padding: 0;
|
@@ -57,17 +56,6 @@ li {
|
|
57
56
|
text-align: center;
|
58
57
|
}
|
59
58
|
|
60
|
-
/*CSS小三角*/
|
61
|
-
span.triangle-down {
|
62
|
-
display: inline-block;
|
63
|
-
width: 0;
|
64
|
-
height: 0;
|
65
|
-
margin: auto;
|
66
|
-
border-left: 5px solid transparent;
|
67
|
-
border-right: 5px solid transparent;
|
68
|
-
border-top: 5px solid #666;
|
69
|
-
}
|
70
|
-
|
71
59
|
.mui-select-field-text {
|
72
60
|
color: var(mui-select-field-text-color, #999);
|
73
61
|
font-size: var(mui-select-field-text-font-size, 16px);
|
@@ -107,6 +95,9 @@ span.triangle-down {
|
|
107
95
|
.card-select-box {
|
108
96
|
display: flex;
|
109
97
|
justify-content: space-around;
|
98
|
+
padding: 0 12px;
|
99
|
+
text-align: center;
|
100
|
+
height: 30px;
|
110
101
|
}
|
111
102
|
.card-select-box .select-item-base, .card-select-box .card-select-item-selected, .card-select-box .card-select-item-normal {
|
112
103
|
width: 100%;
|
package/mui-select-field.scss
CHANGED
@@ -56,17 +56,6 @@ li {
|
|
56
56
|
text-align: center;
|
57
57
|
}
|
58
58
|
|
59
|
-
/*CSS小三角*/
|
60
|
-
span.triangle-down {
|
61
|
-
display: inline-block;
|
62
|
-
width: 0;
|
63
|
-
height: 0;
|
64
|
-
margin: auto;
|
65
|
-
border-left: 5px solid transparent;
|
66
|
-
border-right: 5px solid transparent;
|
67
|
-
border-top: 5px solid #666;
|
68
|
-
}
|
69
|
-
|
70
59
|
.mui-select-field-text {
|
71
60
|
color: var(mui-select-field-text-color, #999);
|
72
61
|
font-size: var(mui-select-field-text-font-size, 16px);;
|
@@ -107,6 +96,9 @@ span.triangle-down {
|
|
107
96
|
.card-select-box {
|
108
97
|
display: flex;
|
109
98
|
justify-content: space-around;
|
99
|
+
padding: 0 12px;
|
100
|
+
text-align: center;
|
101
|
+
height: 30px;
|
110
102
|
|
111
103
|
.select-item-base {
|
112
104
|
width: 100%;
|