@anmed/mui-selection 0.0.3 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- package/SelectionField.svelte +20 -7
- package/SelectionField.svelte.d.ts +1 -1
- package/mui-select-field.css +3 -12
- package/mui-select-field.scss +3 -11
- package/package.json +1 -1
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,10 +41,19 @@ $: {
|
|
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
|
};
|
48
|
+
const isItemSelect = (item, value) => {
|
49
|
+
if (item != null && value != null) {
|
50
|
+
if (keyCode != null) {
|
51
|
+
return item[keyCode] == value[keyCode];
|
52
|
+
}
|
53
|
+
return item == value;
|
54
|
+
}
|
55
|
+
return false;
|
56
|
+
};
|
48
57
|
</script>
|
49
58
|
|
50
59
|
<div on:click={handlerClick}>
|
@@ -53,16 +62,20 @@ const handlerClick = () => {
|
|
53
62
|
<CommonField {label} {required} bind:focused {above} {error}>
|
54
63
|
<div class="card-select-box">
|
55
64
|
{#each list as item}
|
56
|
-
<span class="{item
|
65
|
+
<span class="{isItemSelect(item,value)? 'card-select-item-selected' :'card-select-item-normal'}"
|
57
66
|
on:click={()=>onCardItemClick(item)}>{getDisplayText(item)}</span>
|
58
67
|
{/each}
|
59
68
|
</div>
|
60
69
|
</CommonField>
|
61
70
|
{:else }
|
62
71
|
<CommonField {label} {required} bind:focused {above} {error}>
|
63
|
-
<span class="mui-
|
64
|
-
<div slot="trailing-icon">
|
65
|
-
<
|
72
|
+
<span class="mui-field-text">{displayText}</span>
|
73
|
+
<div slot="trailing-icon" class="mui-field-trailing-icon">
|
74
|
+
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
|
75
|
+
<g id="Frame">
|
76
|
+
<path id="Vector" d="M7.0835 5L12.0835 10L7.0835 15" stroke="#333333" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
77
|
+
</g>
|
78
|
+
</svg>
|
66
79
|
</div>
|
67
80
|
</CommonField>
|
68
81
|
{/if}
|
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%;
|